diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-04-03 18:42:27 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-04-03 18:42:27 +0300 |
commit | 06c188389431ae1157a169f480e9d699503b9de1 (patch) | |
tree | 0d5ab3e2b80e639880136576e4dda7043c56dd43 /servergreps/hercules/packets.py | |
parent | c45c79aa1e2e287c606c9f3f553b65b5b7b635e0 (diff) | |
download | evol-tools-06c188389431ae1157a169f480e9d699503b9de1.tar.gz evol-tools-06c188389431ae1157a169f480e9d699503b9de1.tar.bz2 evol-tools-06c188389431ae1157a169f480e9d699503b9de1.tar.xz evol-tools-06c188389431ae1157a169f480e9d699503b9de1.zip |
servergreps: fix parsing packets in server code. Disable parsing evol plugin.
Diffstat (limited to 'servergreps/hercules/packets.py')
-rwxr-xr-x | servergreps/hercules/packets.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/servergreps/hercules/packets.py b/servergreps/hercules/packets.py index 4d1747e..5eaac9a 100755 --- a/servergreps/hercules/packets.py +++ b/servergreps/hercules/packets.py @@ -11,12 +11,12 @@ import sys filt = re.compile(".+[.]c", re.IGNORECASE) serverpacketre = re.compile("(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" + "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+)([ ]*)[;]") -serverpacketre2 = re.compile("[.]PacketType([ ]*)=([ ]*)(?P<name>[\w]+);") +#serverpacketre2 = re.compile("([.]|[-][>])PacketType([ ]*)=([ ]*)(?P<name>[\w]+);") +serverpacketre2 = re.compile("PacketType([ ]*)=([ ]*)(?P<name>[\w_]+);") serverpacketre3 = re.compile("(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" + "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]") -# need remove SMSG_ -#protocolinre = re.compile("packet[(](?P<name>[A-Z0-9_]+),([ ]*)0x(?P<packet>[0-9a-fA-F]+)[)];") protocolinre = re.compile("packet[(](?P<name>[A-Z0-9_]+),([ ]*)0x(?P<packet>[0-9a-fA-F]+),([ ]*)(?P<len>[\w-]+),([ ]*)") +protocolinverre = re.compile("^// (?P<ver>[0-9]+)$") protocoloutre = re.compile("packet[(](?P<name>CMSG_[A-Z0-9_]+),([ ]*)0x(?P<packet>[0-9a-fA-F]+)[)];") clientpacketre = re.compile("(\t*)packet[(]0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+),(?P<function>[0-9a-zA-Z_>-]+)(,|[)])") packetNameClientre = re.compile("(?P<name>(S|C)MSG_[A-Z0-9_]+)") @@ -47,7 +47,8 @@ def collectServerPackets(parentDir): continue file2 = os.path.abspath(parentDir + os.path.sep + file1) if not os.path.isfile(file2): - collectServerPackets(file2) + if file2.find("/src/evol") <= 0: + collectServerPackets(file2) elif filt.search(file1): with open(file2, "r") as f: for line in f: @@ -85,9 +86,17 @@ def sortClientPackets(): clientpacketsSorted.append(packet) clientpacketsSorted.sort() -def collectManaPlusInPackets(fileName): +def collectManaPlusInPackets(fileName, packetVersion): + version = 0 with open(fileName, "r") as f: for line in f: + m = protocolinverre.search(line) + if m is not None: + version = int(m.group("ver")) + continue + # skip bigger versions than requested + if version > packetVersion: + continue m = protocolinre.search(line) if m is not None: clientPacketsManaPlus[m.group("packet").lower()] = m.group("name") @@ -235,18 +244,19 @@ def showHelp(): if len(sys.argv) != 2: showHelp() +packetVersion = sys.argv[1] srcPath = "../../../server-code/src/" -namedPacketsPath = sys.argv[1] + "/packets_struct.h" +namedPacketsPath = packetVersion + "/packets_struct.h" manaplusPath = "../../../manaplus/src/" protocolPath = manaplusPath + "net/eathena/packets" -clientPacketsPath = sys.argv[1] + "/packets.h" +clientPacketsPath = packetVersion + "/packets.h" packetsPath = manaplusPath + "net/eathena/packetsin.inc" eathenaPath = manaplusPath + "net/eathena/" collectNamedPackets(namedPacketsPath); collectServerPackets(srcPath) collectClientPackets(clientPacketsPath) -collectManaPlusInPackets(protocolPath + "in.inc") +collectManaPlusInPackets(protocolPath + "in.inc", int(packetVersion)) collectManaPlusOutPackets(protocolPath + "out.inc") #collectManaPlusSizes(packetsPath); processManaPlusCppFiles(eathenaPath); |