Skip to content

Commit 592121f

Browse files
author
yorickvanpelt
committed
- Update: the generate-doc.bat to use python 2.6 directory and update the epydoc.cfg
- Fix: do not try to reconnect when no password provided - Codechange: add separate functions for unpacking/packing packet headers
1 parent 9de3ed6 commit 592121f

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

generate-doc.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
c:\Python25\Scripts\epydoc.py -v --config web/api/epydoc.cfg
1+
c:\Python26\Scripts\epydoc.py -v --config web/api/epydoc.cfg
22
@pause

ottd-client.py

+1
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ def joinGame(self):
501501
else:
502502
LOG.info("server is password protected, but no pass provided, exiting!")
503503
self.runCond=False
504+
self.reconnectCond = False
504505
elif type == const.NETWORK_COMPANY_PASSWORD:
505506
#if self.password != '':
506507
#salted_password=""*32

ottd_lib.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,12 @@ def packetTest(self):
443443

444444
self.sendMsg_TCP(PACKET_CLIENT_JOIN, payload)
445445

446-
446+
def createPacketHeader(self, command, payload):
447+
return struct.pack(self.header_format, self.header_size + len(payload), command)
448+
def parsePacketHeader(self, header):
449+
return struct.unpack(self.header_format, header[:self.header_size])
447450
def sendMsg(self, type, command, payload = ""):
448-
header = struct.pack(self.header_format, self.header_size + len(payload), command)
451+
header = self.createPacketHeader(command, payload)
449452
return self.sendRaw(header + payload, type)
450453
def sendMsg_TCP(self, *args, **kwargs):
451454
return self.sendMsg(M_TCP, *args, **kwargs)
@@ -464,8 +467,8 @@ def receiveMsg_UDP(self, datapacket = False):
464467
return None
465468
data = self.socket_udp.recv(4096)
466469
#print data
467-
[size, command], osize = unpackFromExt(self.header_format, data, 0)
468-
LOG.debug("received size: %d/%d, command: %d"% (size, osize, command))
470+
size, command = self.parsePacketHeader(data)
471+
LOG.debug("received size: %d, command: %d"% (size, command))
469472
content = data[self.header_size:]
470473
if datapacket:
471474
return DataPacket(size, command, content)
@@ -488,8 +491,8 @@ def receiveMsg_TCP(self, datapacket = False):
488491
if readcounter > 1:
489492
note += "HEADER SEGMENTED INTO %s SEGMENTS!" % readcounter
490493

491-
(size, command) = struct.unpack(self.header_format, data)
492-
if not command in [PACKET_SERVER_FRAME, PACKET_SERVER_SYNC]:
494+
size, command = self.parsePacketHeader(data)
495+
if not command in (PACKET_SERVER_FRAME, PACKET_SERVER_SYNC):
493496
if command in packet_names:
494497
LOG.debug("received size: %d, command: %s (%d)"% (size, packet_names[command], command))
495498
else:

web/api/epydoc.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ url: http://openttd-python.googlecode.com
77
# The list of modules to document. Modules can be named using
88
# dotted names, module filenames, or package directory names.
99
# This option may be repeated.
10-
modules: ottd_lib, ottd_client_event, irc_lib, log, ottd_config, ottd_constants, ottd_grfs, sstruct, struct_zerostrings,webserver, plugins
10+
modules: ottd_lib, ottd_client_event, irc_lib, log, ottd_config, ottd_constants, ottd_grfs, sstruct, struct_zerostrings,webserver, plugins, ottd_savegame, lib.ottdbot
1111

12-
# Write html output to the directory "apidocs"
12+
# Write html output to the directory "web/api"
1313
output: html
1414
target: web/api
1515

0 commit comments

Comments
 (0)