summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-10 02:32:39 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-10 02:32:39 +0300
commit0c4845fbb0dac4e96e85ae725b00b2aa79116e57 (patch)
tree2e7222046f363a6c710417aa30bc4d543edf7f2e
parent786a270a6bbf68741f21ce69139bc524137fa06f (diff)
downloadtools-0c4845fbb0dac4e96e85ae725b00b2aa79116e57.tar.gz
tools-0c4845fbb0dac4e96e85ae725b00b2aa79116e57.tar.bz2
tools-0c4845fbb0dac4e96e85ae725b00b2aa79116e57.tar.xz
tools-0c4845fbb0dac4e96e85ae725b00b2aa79116e57.zip
servergreps: add support for parsing packets from server (2013 and 2014)
-rwxr-xr-xservergreps/hercules/packets.py7
-rwxr-xr-xservergreps/hercules/src/brathena.py2
-rwxr-xr-xservergreps/hercules/src/hercules.py2
-rwxr-xr-xservergreps/hercules/src/idathena.py2
-rwxr-xr-xservergreps/hercules/src/ragemu.py2
-rwxr-xr-xservergreps/hercules/src/rathena.py2
-rwxr-xr-xservergreps/hercules/src/reporter.py26
-rwxr-xr-xservergreps/hercules/src/server.py57
-rwxr-xr-xservergreps/hercules/src/threeceam.py2
9 files changed, 102 insertions, 0 deletions
diff --git a/servergreps/hercules/packets.py b/servergreps/hercules/packets.py
index 90a987d..f33b5f7 100755
--- a/servergreps/hercules/packets.py
+++ b/servergreps/hercules/packets.py
@@ -13,6 +13,7 @@ from src.manaplus import ManaPlus
from src.ragemu import Ragemu
from src.rathena import Rathena
from src.reporter import Reporter
+from src.server import Server
from src.threeceam import Threeceam
@@ -46,6 +47,8 @@ threeceam.reportName = "3ceam"
idathena = Idathena()
idathena.dirName = "idathena"
idathena.reportName = "idathena"
+server2013 = Server()
+server2014 = Server()
manaplus = ManaPlus()
reporter = Reporter()
@@ -63,6 +66,8 @@ threeceam.prepareTempFiles("3ceam", packetDir, packetVersion)
threeceam.processPackets(packetDir, packetVersion)
idathena.prepareTempFiles("idathena", packetDir, packetVersion)
idathena.processPackets(packetDir, packetVersion)
+server2013.processPackets("server2013")
+server2014.processPackets("server2014")
manaplus.processPackets(packetVersion);
reporter.reportManaplus(hercules, manaplus)
@@ -72,3 +77,5 @@ reporter.reportHerculesFork(hercules, brathena, "brAthena")
reporter.reportHerculesFork(hercules, ragemu, "RagEmu")
reporter.reportThreeceam(hercules, threeceam)
reporter.reportIdathena(hercules, idathena)
+reporter.reportServer(hercules, server2013)
+reporter.reportServer(hercules, server2014)
diff --git a/servergreps/hercules/src/brathena.py b/servergreps/hercules/src/brathena.py
index f9dfb38..efc6b80 100755
--- a/servergreps/hercules/src/brathena.py
+++ b/servergreps/hercules/src/brathena.py
@@ -59,6 +59,8 @@ class Brathena:
def addServerPacket(self, data):
+ if data == "000j":
+ return
if data in self.namedPackets:
for val in self.namedPackets[data]:
if int(val, 16) > 4096:
diff --git a/servergreps/hercules/src/hercules.py b/servergreps/hercules/src/hercules.py
index d069005..f9999b1 100755
--- a/servergreps/hercules/src/hercules.py
+++ b/servergreps/hercules/src/hercules.py
@@ -66,6 +66,8 @@ class Hercules:
def addServerPacket(self, data):
+ if data == "000j":
+ return
if data in self.namedPackets:
for val in self.namedPackets[data]:
if int(val, 16) > 4096:
diff --git a/servergreps/hercules/src/idathena.py b/servergreps/hercules/src/idathena.py
index 298d2ca..96825e6 100755
--- a/servergreps/hercules/src/idathena.py
+++ b/servergreps/hercules/src/idathena.py
@@ -60,6 +60,8 @@ class Idathena:
def addServerPacket(self, data):
+ if data == "000j":
+ return
if data == "cmde":
return
if data in self.namedPackets:
diff --git a/servergreps/hercules/src/ragemu.py b/servergreps/hercules/src/ragemu.py
index 47811a4..020d47c 100755
--- a/servergreps/hercules/src/ragemu.py
+++ b/servergreps/hercules/src/ragemu.py
@@ -59,6 +59,8 @@ class Ragemu:
def addServerPacket(self, data):
+ if data == "000j":
+ return
if data in self.namedPackets:
for val in self.namedPackets[data]:
if int(val, 16) > 4096:
diff --git a/servergreps/hercules/src/rathena.py b/servergreps/hercules/src/rathena.py
index 1a0718b..c6019a4 100755
--- a/servergreps/hercules/src/rathena.py
+++ b/servergreps/hercules/src/rathena.py
@@ -60,6 +60,8 @@ class Rathena:
def addServerPacket(self, data):
+ if data == "000j":
+ return
if data == "cmde":
return
if data in self.namedPackets:
diff --git a/servergreps/hercules/src/reporter.py b/servergreps/hercules/src/reporter.py
index a073975..af05a65 100755
--- a/servergreps/hercules/src/reporter.py
+++ b/servergreps/hercules/src/reporter.py
@@ -254,3 +254,29 @@ class Reporter:
for packet in idathena.outPacketsSorted:
if packet not in hercules.packetsSet:
w.write("Exists only in idAthena: " + packet + "\n")
+
+ def reportServer(self, hercules, server):
+ with open(self.packetDir + "/" + hercules.reportName + "_" + server.dirName + "_outpackets.txt", "w") as w:
+ for packet in server.outPacketsSorted:
+ if packet not in hercules.outPacketsSorted:
+ w.write("Exists only in " + server.dirName + ": " + packet + "\n")
+ with open(self.packetDir + "/" + hercules.reportName + "_" + server.dirName + "_inpackets.txt", "w") as w:
+ for packet in server.inPacketsSorted:
+ if packet not in hercules.inPacketsSorted:
+ w.write("Exists only in " + server.dirName + ": " + packet + "\n")
+ with open(self.packetDir + "/" + server.dirName + "_" + hercules.reportName + "_outpackets.txt", "w") as w:
+ fail = False
+ for packet in hercules.outPacketsSorted:
+ if packet not in server.outPackets:
+ fail = True
+ w.write("Exists only in Hercules: " + packet + "\n");
+ if fail == False:
+ w.write("Server include all hercules packets\n")
+ with open(self.packetDir + "/" + server.dirName + "_" + hercules.reportName + "_inpackets.txt", "w") as w:
+ fail = False
+ for packet in hercules.inPacketsSorted:
+ if packet not in server.inPackets:
+ fail = True
+ w.write("Exists only in Hercules: " + packet + "\n");
+ if fail == False:
+ w.write("Server include all hercules packets\n")
diff --git a/servergreps/hercules/src/server.py b/servergreps/hercules/src/server.py
new file mode 100755
index 0000000..c70d411
--- /dev/null
+++ b/servergreps/hercules/src/server.py
@@ -0,0 +1,57 @@
+#! /usr/bin/env python2
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2015-2016 Evol Online
+# Author: Andrei Karas (4144)
+
+import os
+import re
+
+class Server:
+ packetre = re.compile(
+ "([ ]*)HEADER_(?P<type>[A-Z][A-Z])_(?P<name>[A-Z0-9_]+)([ ]*)=" +
+ "([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
+
+ def __init__(self):
+ self.outPackets = set()
+ self.inPackets = set()
+ self.outPacketsSorted = []
+ self.inPacketsSorted = []
+ self.idToName = dict()
+
+ def collectPackets(self):
+ with open("../links/" + self.dirName + "/packets.txt", "r") as f:
+ for line in f:
+ m = self.packetre.search(line)
+ if m is not None:
+ data = m.group("packet").lower()
+ packetType = m.group("type")
+ partName = m.group("name")
+ if len(data) > 2 and data[:2] == "0x":
+ data = data[2:]
+ while len(data) < 4:
+ data = "0" + data
+ if packetType in ("CA", "CH", "CZ"):
+ self.inPackets.add(data)
+ if packetType in ("AC", "HC", "ZC"):
+ self.outPackets.add(data)
+ self.idToName[data] = "HEADER_{0}_{1}".format(packetType, partName)
+
+
+ def sortOutPackets(self):
+ for packet in self.outPackets:
+ self.outPacketsSorted.append(packet)
+ self.outPacketsSorted.sort()
+
+
+ def sortInPackets(self):
+ for packet in self.inPackets:
+ self.inPacketsSorted.append(packet)
+ self.inPacketsSorted.sort()
+
+
+ def processPackets(self, dirName):
+ self.dirName = dirName
+ self.collectPackets()
+ self.sortInPackets()
+ self.sortOutPackets()
diff --git a/servergreps/hercules/src/threeceam.py b/servergreps/hercules/src/threeceam.py
index 3639f47..bf45ed4 100755
--- a/servergreps/hercules/src/threeceam.py
+++ b/servergreps/hercules/src/threeceam.py
@@ -61,6 +61,8 @@ class Threeceam:
def addServerPacket(self, data):
+ if data == "000j":
+ return
if data == "cmde" or data == "packet" or data == "PacketType" or data == "packet_type" or data == "packet_num":
return
if data in self.namedPackets: