summaryrefslogtreecommitdiff
path: root/servergreps
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-16 19:25:42 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-16 19:25:42 +0300
commit5d512ce82c9dcb4047634c08227917c26cf761c2 (patch)
treec0737892930e039eaafb60240e04c9067d388987 /servergreps
parent2583f9ca16232d74720753b5d214431b526b28df (diff)
downloadevol-tools-5d512ce82c9dcb4047634c08227917c26cf761c2.tar.gz
evol-tools-5d512ce82c9dcb4047634c08227917c26cf761c2.tar.bz2
evol-tools-5d512ce82c9dcb4047634c08227917c26cf761c2.tar.xz
evol-tools-5d512ce82c9dcb4047634c08227917c26cf761c2.zip
servergreps: add support for parsing hercules char server in packets.
Diffstat (limited to 'servergreps')
-rwxr-xr-xservergreps/hercules/src/hercules.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/servergreps/hercules/src/hercules.py b/servergreps/hercules/src/hercules.py
index e08e559..cb5c3d3 100755
--- a/servergreps/hercules/src/hercules.py
+++ b/servergreps/hercules/src/hercules.py
@@ -51,6 +51,9 @@ class Hercules:
clientpacketLenre = re.compile(
"(\t*)packet[(]0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+)" +
"[)]")
+ casere = re.compile("^case 0x(?P<packet>[0-9a-fA-F]+)[:]")
+ charParseFunctionre = re.compile(
+ "(?P<function>chr->[0-9a-zA-Z_>-]+)([(]|[ ][(])");
def collectNamedPackets(self, fileName):
with open(fileName, "r") as f:
@@ -197,6 +200,41 @@ class Hercules:
self.functionToId[m.group("function")] = data
+ def collectCharInPackets(self, charFilePackets):
+ startCode = "int char_parse_char(int fd)\n"
+ endCode = "}\n"
+ breakCode = "break;"
+ with open(charFilePackets, "r") as f:
+ for line in f:
+ if line == startCode:
+ packets = []
+ for line in f:
+ line = line.strip()
+ m = self.casere.search(line)
+ if m is not None:
+ data = m.group("packet").lower()
+ while len(data) < 4:
+ data = "0" + data
+ if int(data, 16) < 4096:
+ packets.append(data)
+ if line == breakCode:
+ packets = []
+ if line == endCode:
+ break
+ if len(packets) > 0:
+ m = self.charParseFunctionre.search(line)
+ if m is not None:
+ func = m.group("function")
+ if len(packets) > 1:
+ for packet in packets:
+ fname = func + "_" + str(packet)
+ self.inPackets[packet] = (0, fname)
+ self.functionToId[fname] = packet
+ else:
+ self.inPackets[packets[0]] = (0, func)
+ self.functionToId[func] = packets[0]
+ break
+
def sortInPackets(self):
for packet in self.inPackets:
self.inPacketsSorted.append(packet)
@@ -208,9 +246,11 @@ class Hercules:
srcPath = packetDir + "/src/" + self.dirName
serverInPacketsHPath = packetDir + "/src/" + self.dirName + "/packets.h"
serverLoginInPackets = packetDir + "/src/" + self.dirName + "/lclif.c"
+ serverCharPackets = packetDir + "/src/" + self.dirName + "/char.c"
self.collectNamedPackets(namedPacketsPath)
self.collectOutPackets(srcPath)
self.collectInPackets(serverInPacketsHPath, serverLoginInPackets)
+ self.collectCharInPackets(serverCharPackets);
self.sortInPackets()
self.sortOutPackets()