summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-10-06 20:10:38 +0300
committerAndrei Karas <akaras@inbox.ru>2016-10-06 20:10:38 +0300
commite5b71c4bb75dbcdb3fe2bc6352121fb76c3822dd (patch)
tree18f0c4910b15eb4a5afbce3809d469f719d03fda
parent9832601852decb717907201fdcf809ae77fb1e8f (diff)
downloadevol-tools-e5b71c4bb75dbcdb3fe2bc6352121fb76c3822dd.tar.gz
evol-tools-e5b71c4bb75dbcdb3fe2bc6352121fb76c3822dd.tar.bz2
evol-tools-e5b71c4bb75dbcdb3fe2bc6352121fb76c3822dd.tar.xz
evol-tools-e5b71c4bb75dbcdb3fe2bc6352121fb76c3822dd.zip
servergreps: add support for get packets from Peek logs.
-rwxr-xr-xservergreps/hercules/packets.py6
-rwxr-xr-xservergreps/hercules/src/peek.py107
-rwxr-xr-xservergreps/hercules/src/reporter.py42
3 files changed, 155 insertions, 0 deletions
diff --git a/servergreps/hercules/packets.py b/servergreps/hercules/packets.py
index 9290160..39b8d3e 100755
--- a/servergreps/hercules/packets.py
+++ b/servergreps/hercules/packets.py
@@ -10,6 +10,7 @@ from src.brathena import Brathena
from src.hercules import Hercules
from src.idathena import Idathena
from src.manaplus import ManaPlus
+from src.peek import Peek
from src.ragemu import Ragemu
from src.rathena import Rathena
from src.reporter import Reporter
@@ -53,6 +54,9 @@ server2014 = Server()
tables = Tables()
tables.dirName = "tables"
tables.reportName = "tables"
+peek = Peek()
+peek.dirName = "peek";
+peek.reportName = "peek"
manaplus = ManaPlus()
reporter = Reporter()
@@ -73,6 +77,7 @@ idathena.processPackets("idathena", packetDir, packetVersion)
server2013.processPackets("server2013")
server2014.processPackets("server2014")
tables.processPackets("tables", packetDir, packetVersion)
+peek.processPackets("peek", packetDir, packetVersion)
manaplus.processPackets(packetVersion);
reporter.reportManaplus(hercules, manaplus)
@@ -85,3 +90,4 @@ reporter.reportHerculesFork(hercules, idathena, "idAthena")
reporter.reportServer(hercules, server2013)
reporter.reportServer(hercules, server2014)
reporter.reportTables(hercules, tables)
+reporter.reportPeek(hercules, peek)
diff --git a/servergreps/hercules/src/peek.py b/servergreps/hercules/src/peek.py
new file mode 100755
index 0000000..3012987
--- /dev/null
+++ b/servergreps/hercules/src/peek.py
@@ -0,0 +1,107 @@
+#! /usr/bin/env python2
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2015-2016 Evol Online
+# Author: Andrei Karas (4144)
+
+import configparser
+import re
+import os
+
+class Peek:
+ inPacketsSorted = []
+ inPackets = dict()
+ knownLenPackets = dict()
+
+ shuffleMap = {
+ '0': 'clif->pActionRequest',
+ '1': 'clif->pUseSkillToId',
+ '2': 'clif->pWalkToXY',
+ '3': 'clif->pTickSend',
+ '4': 'clif->pChangeDir',
+ '5': 'clif->pTakeItem',
+ '6': 'clif->pDropItem',
+ '7': 'clif->pMoveToKafra',
+ '8': 'clif->pMoveFromKafra',
+ '9': 'clif->pUseSkillToPos',
+ '10': 'clif->pUseSkillToPosMoreInfo',
+ '11': 'clif->pGetCharNameRequest',
+ '12': 'clif->pSolveCharName',
+ '13': 'clif->pSearchStoreInfoListItemClick',
+ '14': 'clif->pSearchStoreInfoNextPage',
+ '15': 'clif->pSearchStoreInfo',
+ '16': 'clif->pReqTradeBuyingStore',
+ '17': 'clif->pReqClickBuyingStore',
+ '18': 'clif->pReqCloseBuyingStore',
+ '19': 'clif->pReqOpenBuyingStore',
+ '20': 'clif->pPartyBookingRegisterReq',
+ '21': 'clif->pDull // CZ_JOIN_BATTLE_FIELD', # CZ_JOIN_BATTLE_FIELD
+ '22': 'clif->pItemListWindowSelected',
+ '23': 'clif->pWantToConnection',
+ '24': 'clif->pPartyInvite2',
+ '25': 'clif->pDull // CZ_GANGSI_RANK', # CZ_GANGSI_RANK
+ '26': 'clif->pFriendsListAdd',
+ '27': 'clif->pHomMenu',
+ '28': 'clif->pStoragePassword'
+ }
+
+ def collectInPackets(self, packetsH):
+ config = configparser.ConfigParser()
+ config.read(packetsH)
+ cfg = config["Packet_Lengths"]
+ for key in cfg:
+ data = key[2:].lower()
+ while len(data) < 4:
+ data = "0" + data
+ self.inPackets[data] = \
+ (int(cfg[key]), "")
+ self.knownLenPackets[data] = int(cfg[key])
+ cfg = config["Shuffle_Packets"]
+ for key in cfg:
+ data = key[2:].lower()
+ while len(data) < 4:
+ data = "0" + data
+ shuffle = cfg[key]
+ if shuffle in self.shuffleMap:
+ packet = self.inPackets[data]
+ self.inPackets[data] = (packet[0], self.shuffleMap[shuffle])
+ else:
+ print "Not found shuffle code {0}".format(shuffle)
+
+ 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:
+ srcPath = file2
+ files = os.listdir(srcPath)
+ for file1 in files:
+ if file1[0] == ".":
+ continue
+ file2 = os.path.abspath(srcPath + os.path.sep + file1)
+ if os.path.isfile(file2):
+ self.collectInPackets(file2)
+ 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()
diff --git a/servergreps/hercules/src/reporter.py b/servergreps/hercules/src/reporter.py
index ddaec38..fb287ce 100755
--- a/servergreps/hercules/src/reporter.py
+++ b/servergreps/hercules/src/reporter.py
@@ -340,3 +340,45 @@ class Reporter:
w.write("Exists only in Hercules: " + packet + "\n");
if fail == False:
w.write("Server include all hercules packets\n")
+
+
+ def reportPeek(self, hercules, peek):
+ if len(peek.inPacketsSorted) == 0:
+ return
+ with open(self.packetDir + "/" + hercules.reportName + "_" + peek.dirName + "_inpackets.txt", "w") as w:
+ for packet in peek.inPacketsSorted:
+ if packet not in hercules.inPacketsSorted and packet not in hercules.outPacketsSorted:
+ w.write("Exists only in " + peek.dirName + ": " + packet + "\n")
+ for packet in peek.inPacketsSorted:
+ if packet in hercules.inPacketsSorted and packet in peek.inPackets and packet in hercules.knownLenPackets:
+ if hercules.knownLenPackets[packet] != peek.knownLenPackets[packet]:
+ w.write("Different packet size for packet {0}: {1} vs {2}\n".format(
+ packet,
+ hercules.knownLenPackets[packet],
+ peek.knownLenPackets[packet]))
+ with open(self.packetDir + "/" + peek.dirName + "_" + hercules.reportName + "_inpackets.txt", "w") as w:
+ fail = False
+ for packet in hercules.inPacketsSorted:
+ if packet not in peek.inPackets:
+ fail = True
+ w.write("Exists only in Hercules: " + packet + "\n");
+ if fail == False:
+ w.write("Table include all hercules packets\n")
+ for packet in hercules.inPacketsSorted:
+ if packet in peek.inPackets:
+ peekFunction = peek.inPackets[packet][1]
+ if peekFunction != "":
+ herculesFunction = hercules.inPackets[packet][1]
+ if peekFunction != herculesFunction:
+ w.write("Wrong function name for packet {0}: {1} vs {2}\n".format(
+ packet,
+ peekFunction,
+ herculesFunction))
+ with open(self.packetDir + "/" + peek.dirName + "_" + hercules.reportName + "_outpackets.txt", "w") as w:
+ fail = False
+ for packet in hercules.outPacketsSorted:
+ if packet not in peek.inPackets:
+ fail = True
+ w.write("Exists only in Hercules: " + packet + "\n");
+ if fail == False:
+ w.write("Server include all hercules packets\n")