@@ -30,11 +30,13 @@ cheat.moderators = anticheatsettings.moderators;
30
30
anticheatdb = {}; -- data about detected cheaters
31
31
32
32
cheat .suspect = " " ;
33
- cheat .players = {};
33
+ cheat .players = {}; -- temporary cheat detection db
34
34
cheat .message = " " ;
35
35
cheat .debuglist = {}; -- [name]=true -- who gets to see debug msgs
36
36
37
- cheat .scan_timer = 0
37
+ cheat .scan_timer = 0 ; -- global scan of players
38
+ cheat .stat_timer = 0 ; -- used to collect stats
39
+
38
40
cheat .nodelist = {};
39
41
cheat .watcher = {}; -- list of watchers
40
42
@@ -96,8 +98,32 @@ minetest.register_globalstep(function(dtime)
96
98
97
99
cheat .scan_timer = cheat .scan_timer + dtime
98
100
101
+
99
102
-- GENERAL SCAN OF ALL PLAYERS
100
103
if cheat .scan_timer > cheat .timestep then
104
+
105
+
106
+ cheat .stat_timer = cheat .stat_timer + cheat .timestep ;
107
+ -- dig xp stats every 2 minutes
108
+ if boneworld and cheat .stat_timer > 120 then
109
+ cheat .stat_timer = 0 ;
110
+ local players = minetest .get_connected_players ();
111
+ for _ ,player in pairs (players ) do
112
+ local pname = player :get_player_name ();
113
+ if cheat .players [pname ].stats .state == 1 then -- only if dig xp loaded to prevent anomalous stats
114
+ local deltadig = cheat .players [pname ].stats .digxp ;
115
+ cheat .players [pname ].stats .digxp = boneworld .digxp [pname ];
116
+ deltadig = boneworld .digxp [pname ]- deltadig ;
117
+ cheat .players [pname ].stats .deltadig = deltadig ;
118
+
119
+ if deltadig > cheat .players [pname ].stats .maxdeltadig then
120
+ cheat .players [pname ].stats .maxdeltadig = deltadig ;
121
+ end
122
+ end
123
+ end
124
+ end
125
+
126
+
101
127
cheat .timestep = CHEAT_TIMESTEP + (2 * math.random ()- 1 )* 2 ; -- randomize step so its unpredictable
102
128
cheat .scan_timer = 0 ;
103
129
-- local t = minetest.get_gametime();
@@ -168,25 +194,45 @@ minetest.after(0,
168
194
169
195
170
196
197
+ -- DISABLED: lot of false positives
171
198
-- collects misc stats on players
172
199
173
- minetest .register_on_cheat (
174
- function (player , c )
175
- local name = player :get_player_name (); if name == nil then return end
176
- local stats = cheat .players [name ].stats ;
177
- if not stats [c .type ] then stats [c .type ] = 0 end
178
- stats [c .type ]= stats [c .type ]+ 1 ;
179
- end
180
- )
200
+ -- minetest.register_on_cheat(
201
+ -- function(player, c)
202
+ -- local name = player:get_player_name(); if name == nil then return end
203
+ -- local stats = cheat.players[name].stats;
204
+ -- if not stats[c.type] then stats[c.type] = 0 end
205
+ -- stats[c.type]=stats[c.type]+1;
206
+ -- end
207
+ -- )
181
208
182
209
183
210
184
211
local watchers = {}; -- for each player a list of watchers
185
212
minetest .register_on_joinplayer (function (player ) -- init stuff on player join
186
213
local name = player :get_player_name (); if name == nil then return end
187
214
local pos = player :getpos ();
188
- cheat .players [name ]= {count = 0 ,cheatpos = pos , clearpos = pos , lastpos = pos , cheattype = 0 }; -- type 0: none, 1 noclip, 2 fly
189
- cheat .players [name ].stats = {}; -- various statistics about player
215
+
216
+ if cheat .players [name ] == nil then
217
+ cheat .players [name ]= {count = 0 ,cheatpos = pos , clearpos = pos , lastpos = pos , cheattype = 0 }; -- type 0: none, 1 noclip, 2 fly
218
+ end
219
+
220
+ if cheat .players [name ] and cheat .players [name ].stats == nil then
221
+ cheat .players [name ].stats = {maxdeltadig = 0 ,deltadig = 0 ,digxp = 0 , state = 0 }; -- various statistics about player: max dig xp increase in 2 minutes, current dig xp increase
222
+
223
+ minetest .after (5 , -- load digxp after boneworld loads it
224
+ function ()
225
+ if boneworld and boneworld .xp then
226
+ cheat .players [name ].stats .digxp = boneworld .digxp [name ] or 0 ;
227
+ cheat .players [name ].stats .state = 1 ;
228
+ end
229
+ end
230
+ )
231
+
232
+ end
233
+ -- state 0 = stats not loaded yet
234
+
235
+
190
236
watchers [name ] = {}; -- for spectator mod
191
237
192
238
local ip = tostring (minetest .get_player_ip (name ));
@@ -271,7 +317,12 @@ minetest.register_chatcommand("crep", { -- see cheat report
271
317
local players = minetest .get_connected_players ();
272
318
for _ ,player in pairs (players ) do
273
319
local pname = player :get_player_name ();
274
- text = text .. " name " .. pname .. " " .. string.gsub (dump (cheat .players [pname ].stats ), " \n " , " " ) .. " \n " ;
320
+ local ip = tostring (minetest .get_player_ip (pname ));
321
+
322
+
323
+ text = text .. " \n name " .. pname .. " , digxp " .. cheat .players [pname ].stats .digxp ..
324
+ " , deltadigxp(2min) " .. cheat .players [pname ].stats .deltadig .. " , maxdeltadigxp " .. cheat .players [pname ].stats .maxdeltadig ; -- .. " ".. string.gsub(dump(cheat.players[pname].stats), "\n", " ");
325
+ if anticheatdb [ip ] then text = text .. " (DETECTED) ip " .. ip .. " , name " .. anticheatdb [ip ].name end
275
326
end
276
327
if text ~= " " then
277
328
local form = " size [10,8] textarea[0,0;10.5,9.;creport;CHEAT STATISTICS;" .. text .. " ]"
@@ -410,6 +461,9 @@ minetest.register_chatcommand("watch", {
410
461
break ;
411
462
end
412
463
end
464
+
465
+ local ip = tostring (minetest .get_player_ip (pname ));
466
+ if anticheatdb [ip ] then canwatch = true end -- can watch since this ip was detected before
413
467
414
468
415
469
if canwatch or cheat .players [param ].count > 0 or param == cheat .suspect or privs .kick then
0 commit comments