File tree 1 file changed +31
-2
lines changed
1 file changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -281,8 +281,38 @@ def removeServer(self, server):
281
281
pass
282
282
283
283
def sort (self ):
284
+ def server_points (server ):
285
+ points = 0
286
+
287
+ # 1 per client
288
+ # Only 1/16 per client with a guest or all-numeric name
289
+ for name in server ["clients_list" ]:
290
+ if name .startswith ("Guest" ) or \
291
+ name .isdigit ():
292
+ points += 1 / 16
293
+ else :
294
+ points += 1
295
+
296
+ # 1 per month of age, limited to 8
297
+ points += min (8 , server ["game_time" ] / (60 * 60 * 24 * 30 ))
298
+
299
+ # -8 for unrealistic max_clients
300
+ if server ["max_clients" ] >= 128 :
301
+ points -= 8
302
+
303
+ # -8 per second of ping
304
+ points -= server ["ping" ] * 8
305
+
306
+ # Up to -8 for less than an hour of uptime (penalty linearly decreasing)
307
+ HOUR_SECS = 60 * 60
308
+ uptime = server ["uptime" ]
309
+ if uptime < HOUR_SECS :
310
+ points -= ((HOUR_SECS - uptime ) / HOUR_SECS ) * 8
311
+
312
+ return points
313
+
284
314
with self .lock :
285
- self .list .sort (key = itemgetter ( "clients" , "start" ) , reverse = True )
315
+ self .list .sort (key = server_points , reverse = True )
286
316
287
317
def purgeOld (self ):
288
318
with self .lock :
@@ -339,7 +369,6 @@ def update(self, server):
339
369
340
370
serverList = ServerList ()
341
371
342
-
343
372
if __name__ == "__main__" :
344
373
app .run (host = app .config ["HOST" ], port = app .config ["PORT" ])
345
374
You can’t perform that action at this time.
0 commit comments