diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-09-08 23:33:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-09-08 23:33:26 +0300 |
commit | f3ead21cd12066a5d7cdc02cfd0c88f0b5ca97bd (patch) | |
tree | a9d0ffcdba16d8ddeb06fb49dedaf6c54ede01c5 | |
parent | f9e6037c7759139338f54cf3234f171e669da35f (diff) | |
download | evol-tools-f3ead21cd12066a5d7cdc02cfd0c88f0b5ca97bd.tar.gz evol-tools-f3ead21cd12066a5d7cdc02cfd0c88f0b5ca97bd.tar.bz2 evol-tools-f3ead21cd12066a5d7cdc02cfd0c88f0b5ca97bd.tar.xz evol-tools-f3ead21cd12066a5d7cdc02cfd0c88f0b5ca97bd.zip |
servergreps: check hercules requested packet sizes and known packet sizes.
-rwxr-xr-x | servergreps/hercules/src/hercules.py | 25 | ||||
-rwxr-xr-x | servergreps/hercules/src/reporter.py | 44 |
2 files changed, 47 insertions, 22 deletions
diff --git a/servergreps/hercules/src/hercules.py b/servergreps/hercules/src/hercules.py index fdee363..7c1b230 100755 --- a/servergreps/hercules/src/hercules.py +++ b/servergreps/hercules/src/hercules.py @@ -19,6 +19,8 @@ class Hercules: inPackets = dict() functionToId = dict() loginPacketNameToId = dict() + getLenPackets = set() + knownLenPackets = dict() namedPacketre = re.compile( "((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" + @@ -41,6 +43,11 @@ class Hercules: lclifPacketre = re.compile( "([ ]*)[{][ ]PACKET_ID_CA_(?P<name>[A-Z0-9_]+),([^,]+)," + "([ ]*)[&](?P<function>[0-9a-zA-Z_>-]+)([ ]*)[}],") + packetLenre = re.compile( + "packet_db[\\[]0x(?P<packet>[0-9a-fA-F]+)[\\]].len") + clientpacketLenre = re.compile( + "(\t*)packet[(]0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+)" + + "[)]") def collectNamedPackets(self, fileName): with open(fileName, "r") as f: @@ -128,7 +135,15 @@ class Hercules: data = str[2] data = self.loginPacketNameToId[data] self.addServerPacket(data) - + m = self.packetLenre.findall(line) + if len(m) > 0: + for str in m: + data = str.lower() + if len(data) > 2 and data[0:2] == "0x": + data = data[2:] + while len(data) < 4: + data = "0" + data + self.getLenPackets.add(data) def sortOutPackets(self): for packet in self.packetsSet: @@ -147,6 +162,12 @@ class Hercules: self.inPackets[data] = \ (int(m.group("len")), m.group("function")) self.functionToId[m.group("function")] = data + m = self.clientpacketLenre.search(line) + if m is not None: + data = m.group("packet").lower() + while len(data) < 4: + data = "0" + data + self.knownLenPackets[data] = int(m.group("len")) with open(lclifPackets, "r") as f: for line in f: m = self.lclifPacketre.search(line) @@ -192,5 +213,5 @@ class Hercules: proc.run("map", "clif.c"); proc.run("login", "lclif.p.h"); proc.run("login", "lclif.c"); - proc.defines = "-DPACKETVER=" + packetVersion + " -Dpacket\\(id,size,...\\)=packet\\(id,size,__VA_ARGS__\\)" + proc.defines = "-DPACKETVER=" + packetVersion + " -Dpacket\\(...\\)=packet\\(__VA_ARGS__\\)" proc.run("map", "packets.h"); diff --git a/servergreps/hercules/src/reporter.py b/servergreps/hercules/src/reporter.py index 18caa5a..1bfc116 100755 --- a/servergreps/hercules/src/reporter.py +++ b/servergreps/hercules/src/reporter.py @@ -182,26 +182,30 @@ class Reporter: def reportHercules(self, hercules): with open(self.packetDir + "/" + hercules.reportName + "_issues.txt", "w") as w: - for name in hercules.functionToId: - packet = hercules.functionToId[name] - if name != hercules.inPackets[packet][1]: - found = False - oldId = "" - for packet in hercules.inPackets: - if name == hercules.inPackets[packet][1]: - found = True - if oldId == "": - oldId = str(packet) - else: - oldId = oldId + "," + str(packet) - - if found is False: - w.write("Server code error: function {0} hidden in server code\n".format( - name)) - else: - w.write("Server code warning: function {0} hidden in server code but can be used older packets definition {1}\n".format( - name, - oldId)) + for name in hercules.functionToId: + packet = hercules.functionToId[name] + if name != hercules.inPackets[packet][1]: + found = False + oldId = "" + for packet in hercules.inPackets: + if name == hercules.inPackets[packet][1]: + found = True + if oldId == "": + oldId = str(packet) + else: + oldId = oldId + "," + str(packet) + if found is False: + w.write("Server code error: function {0} hidden in server code\n".format( + name)) + else: + w.write("Server code warning: function {0} hidden in server code but can be used older packets definition {1}\n".format( + name, + oldId)) + with open(self.packetDir + "/" + hercules.reportName + "_missing_sizes.txt", "w") as w: + for packet in hercules.getLenPackets: + if packet not in hercules.knownLenPackets: + w.write("Missing length for packet {0}\n".format( + packet)) def reportRathena(self, hercules, rathena): |