diff options
Diffstat (limited to 'servergreps')
-rwxr-xr-x | servergreps/hercules/packets.py | 6 | ||||
-rwxr-xr-x | servergreps/hercules/src/reporter.py | 29 | ||||
-rwxr-xr-x | servergreps/hercules/src/tables.py | 65 |
3 files changed, 98 insertions, 2 deletions
diff --git a/servergreps/hercules/packets.py b/servergreps/hercules/packets.py index 67f6f75..9290160 100755 --- a/servergreps/hercules/packets.py +++ b/servergreps/hercules/packets.py @@ -14,6 +14,7 @@ from src.ragemu import Ragemu from src.rathena import Rathena from src.reporter import Reporter from src.server import Server +from src.tables import Tables from src.threeceam import Threeceam @@ -49,6 +50,9 @@ idathena.dirName = "idathena" idathena.reportName = "idathena" server2013 = Server() server2014 = Server() +tables = Tables() +tables.dirName = "tables" +tables.reportName = "tables" manaplus = ManaPlus() reporter = Reporter() @@ -68,6 +72,7 @@ idathena.prepareTempFiles("idathena", packetDir, packetVersion) idathena.processPackets("idathena", packetDir, packetVersion) server2013.processPackets("server2013") server2014.processPackets("server2014") +tables.processPackets("tables", packetDir, packetVersion) manaplus.processPackets(packetVersion); reporter.reportManaplus(hercules, manaplus) @@ -79,3 +84,4 @@ reporter.reportHerculesFork(hercules, threeceam, "3CeaM") reporter.reportHerculesFork(hercules, idathena, "idAthena") reporter.reportServer(hercules, server2013) reporter.reportServer(hercules, server2014) +reporter.reportTables(hercules, tables) diff --git a/servergreps/hercules/src/reporter.py b/servergreps/hercules/src/reporter.py index 46257c0..23f5917 100755 --- a/servergreps/hercules/src/reporter.py +++ b/servergreps/hercules/src/reporter.py @@ -241,12 +241,13 @@ class Reporter: w.write("Exists only in " + name + ": " + packet + "\n") for packet in fork.outPacketsSorted: if packet not in hercules.packetsSet: + # incomplete code? if packet in fork.getLenPackets and packet in fork.knownLenPackets and \ packet in hercules.getLenPackets and packet in hercules.knownLenPackets: - w.write("Different packet size for packet {0}: {1} vs {2}\n", + w.write("Different packet size for packet {0}: {1} vs {2}\n".format( packet, hercules.knownLenPackets[packet], - fork.knownLenPackets[packet]) + fork.knownLenPackets[packet])) with open(self.packetDir + "/" + hercules.reportName + "_" + fork.reportName + "_inpackets.txt", "w") as w: for func in hercules.functionToId: packet = hercules.functionToId[func] @@ -307,3 +308,27 @@ class Reporter: w.write("Exists only in Hercules: " + packet + "\n"); if fail == False: w.write("Server include all hercules packets\n") + + + def reportTables(self, hercules, tables): + if len(tables.inPacketsSorted) == 0: + return + with open(self.packetDir + "/" + hercules.reportName + "_" + tables.dirName + "_inpackets.txt", "w") as w: + for packet in tables.inPacketsSorted: + if packet not in hercules.inPacketsSorted: + w.write("Exists only in " + tables.dirName + ": " + packet + "\n") + for packet in tables.inPacketsSorted: + if packet in hercules.inPacketsSorted and packet in tables.inPackets and packet in hercules.knownLenPackets: + if hercules.knownLenPackets[packet] != tables.knownLenPackets[packet]: + w.write("Different packet size for packet {0}: {1} vs {2}\n".format( + packet, + hercules.knownLenPackets[packet], + tables.knownLenPackets[packet])) + with open(self.packetDir + "/" + tables.dirName + "_" + hercules.reportName + "_inpackets.txt", "w") as w: + fail = False + for packet in hercules.inPacketsSorted: + if packet not in tables.inPackets: + fail = True + w.write("Exists only in Hercules: " + packet + "\n"); + if fail == False: + w.write("Table include all hercules packets\n") diff --git a/servergreps/hercules/src/tables.py b/servergreps/hercules/src/tables.py new file mode 100755 index 0000000..ccfa4e0 --- /dev/null +++ b/servergreps/hercules/src/tables.py @@ -0,0 +1,65 @@ +#! /usr/bin/env python2 +# -*- coding: utf8 -*- +# +# Copyright (C) 2015-2016 Evol Online +# Author: Andrei Karas (4144) + +import re +import os + +from src.packetdb import PacketDb +from src.preproc import PreProc +from src.utils import Utils + +filt = re.compile(".+[.](c|h)", re.IGNORECASE) + +class Tables: + inPacketsSorted = [] + inPackets = dict() + knownLenPackets = dict() + + clientpacketre = re.compile( + "^(?P<packet>[0-9a-fA-F]+) (?P<len>[\w-]+)") + + def collectInPackets(self, packetsH): + with open(packetsH, "r") as f: + for line in f: + m = self.clientpacketre.search(line) + if m is not None: + data = m.group("packet").lower() + while len(data) < 4: + data = "0" + data + self.inPackets[data] = \ + (int(m.group("len")), "") + self.knownLenPackets[data] = int(m.group("len")) + + def sortInPackets(self): + for packet in self.inPackets: + self.inPacketsSorted.append(packet) + self.inPacketsSorted.sort() + + + def findVersion(self, srcPath, packetDir): + name = packetDir[:4] + "_" + packetDir[4:6] + "_" + packetDir[6:8] + files = os.listdir(srcPath) + for file1 in files: + if file1[0] == ".": + continue + file2 = os.path.abspath(srcPath + os.path.sep + file1) + if os.path.isdir(file2) and file1.find(name) > 0: + self.collectInPackets(file2 + os.path.sep + "recvpackets.txt") + self.sortInPackets() + return + + def processPackets(self, codeDir, packetDir, packetVersion): +# namedPacketsPath = packetDir + "/src/" + self.dirName + "/packets_struct.h" + srcPath = "../links/" + self.dirName +# packetsDbPath = "../links/" + codeDir + "/db/packet_db.txt" +# 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.findVersion(srcPath, packetDir) +# self.collectCharInPackets(serverCharPackets); +# self.sortOutPackets() |