@@ -233,10 +233,6 @@ def processCommand(self, event):
233
233
elif command == 'unloadirc' and not self .irc is None :
234
234
self .stopIRC ()
235
235
Broadcast ("unloaded IRC" , parentclient = self )
236
- elif command == 'startwebserver' :
237
- self .startWebserver ()
238
- elif command == 'stopwebserver' :
239
- self .stopWebserver ()
240
236
elif command == 'reconnect' :
241
237
payload = packExt ('z' , "%s (reconnecting)" % config .get ("openttd" , "quitmessage" ))
242
238
Broadcast ("Reconnecting to server" , parentclient = self , parent = event )
@@ -272,16 +268,6 @@ def processCommand(self, event):
272
268
if commandstring in self .commands :
273
269
self .commands [commandstring ](event , command )
274
270
275
- def startWebserver (self ):
276
- if not config .getboolean ("webserver" , "enable" ) or not self .webserver is None :
277
- return
278
- from webserver import myWebServer
279
- LOG .debug ("starting webserver ..." )
280
- port = config .getint ("webserver" , "port" )
281
- self .webserver = myWebServer (self , port )
282
- self .webserver .start ()
283
- Broadcast ("webserver started on port %d" % port , parentclient = self )
284
-
285
271
def startIRC (self ):
286
272
from irc_lib import IRCBotThread
287
273
self .irc = IRCBotThread (self .irc_channel , config .get ("irc" , "nickname" ), self .irc_server , self , self .irc_server_port )
@@ -301,13 +287,6 @@ def quit(self):
301
287
self .reconnectCond = False
302
288
self .sendMsg_TCP (const .PACKET_CLIENT_QUIT , payload )
303
289
304
- def stopWebserver (self ):
305
- if self .webserver :
306
- LOG .debug ("stopping webserver ..." )
307
- self .webserver .stop ()
308
- self .webserver = None
309
- Broadcast ("webserver stopped" , parentclient = self )
310
-
311
290
def on_irc_pubmsg (self , c , e ):
312
291
if not e .source () is None and e .source ().find ('!' ) != - 1 :
313
292
IRCPublicChat (e .arguments ()[0 ], e .source ().split ('!' )[0 ], parentclient = self , parentircevent = e )
@@ -399,57 +378,6 @@ def handlePacket(self, command, content):
399
378
self .doCallback ("on_server_newmap" )
400
379
self .runCond = False
401
380
402
- def updateStats (self ):
403
- available = True
404
- try :
405
- import pickle
406
- except ImportError :
407
- available = False
408
- if not available :
409
- LOG .error ("error while loading pickle module, stats saving disabled!" )
410
- return
411
-
412
- LOG .debug ("updating stats..." )
413
- tstart = time .time ()
414
-
415
- fn = config .get ("stats" , "cachefilename" )
416
- obj = []
417
- firstSave = False
418
- try :
419
- f = open (fn , 'rb' )
420
- obj = pickle .load (f )
421
- f .close ()
422
- except IOError :
423
- firstSave = True
424
-
425
- value = [
426
- self .getGameInfo (encode_grfs = True , short = not firstSave ),
427
- self .getCompanyInfo ().companies ,
428
- tstart
429
- ]
430
-
431
- obj .append (value )
432
-
433
- try :
434
- f = open (fn , 'wb' )
435
- #if you use python < 2.3 use this line:
436
- #pickle.dump(obj, f)
437
- pickle .dump (obj , f , 1 )
438
- f .close ()
439
- except IOError :
440
- LOG .error ("error while saving stats cache file!" )
441
-
442
- tdiff = time .time () - tstart
443
- fs = float (os .path .getsize (fn )) / float (1024 )
444
- LOG .debug ("stats updated in %0.5f seconds. File is %.2fKB big (%d lines)" % (tdiff , fs , len (obj )))
445
-
446
- def clearStats (self ):
447
- fn = config .get ("stats" , "cachefilename" )
448
- try :
449
- os .remove (fn )
450
- LOG .debug ("stats cleared" )
451
- except :
452
- pass
453
381
def findPlayerByNick (self , nick ):
454
382
for client in self .playerlist :
455
383
if self .playerlist [client ]['name' ] == nick :
@@ -581,17 +509,8 @@ def joinGame(self):
581
509
# auto start IRC
582
510
if config .getboolean ("irc" , "autojoin" ):
583
511
self .startIRC ()
584
- if config .getboolean ("webserver" , "autostart" ):
585
- self .startWebserver ()
586
512
587
513
ignoremsgs = []
588
- companyrefresh_interval = 120 #every two minutes
589
- companyrefresh_last = 0
590
-
591
-
592
- doStats = config .getboolean ("stats" , "enable" )
593
- if doStats :
594
- self .clearStats ()
595
514
596
515
while self .runCond :
597
516
size , command , content = self .receiveMsg_TCP ()
@@ -611,10 +530,6 @@ def joinGame(self):
611
530
self .sendMsg_TCP (const .PACKET_CLIENT_ACK , payload )
612
531
frameCounter = 0
613
532
614
- if doStats and time .time () - companyrefresh_last > companyrefresh_interval :
615
- self .updateStats ()
616
- companyrefresh_last = time .time ()
617
-
618
533
if command == const .PACKET_SERVER_COMMAND :
619
534
[player , command2 , p1 , p2 , tile , text , callback , frame , my_cmd ], size = unpackFromExt ('BIIIIzBIB' , content )
620
535
0 commit comments