summaryrefslogtreecommitdiff
path: root/servergreps/hercules/src
diff options
context:
space:
mode:
Diffstat (limited to 'servergreps/hercules/src')
-rw-r--r--servergreps/hercules/src/__init__.py0
-rwxr-xr-xservergreps/hercules/src/brathena.py180
-rwxr-xr-xservergreps/hercules/src/hercules.py199
-rwxr-xr-xservergreps/hercules/src/idathena.py183
-rwxr-xr-xservergreps/hercules/src/manaplus.py97
-rwxr-xr-xservergreps/hercules/src/packetdb.py279
-rwxr-xr-xservergreps/hercules/src/peek.py109
-rwxr-xr-xservergreps/hercules/src/preproc.py24
-rwxr-xr-xservergreps/hercules/src/ragemu.py194
-rwxr-xr-xservergreps/hercules/src/rathena.py183
-rwxr-xr-xservergreps/hercules/src/reporter.py384
-rwxr-xr-xservergreps/hercules/src/server.py56
-rwxr-xr-xservergreps/hercules/src/tables.py61
-rwxr-xr-xservergreps/hercules/src/threeceam.py184
-rwxr-xr-xservergreps/hercules/src/utils.py129
15 files changed, 0 insertions, 2262 deletions
diff --git a/servergreps/hercules/src/__init__.py b/servergreps/hercules/src/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/servergreps/hercules/src/__init__.py
+++ /dev/null
diff --git a/servergreps/hercules/src/brathena.py b/servergreps/hercules/src/brathena.py
deleted file mode 100755
index d0a62f8..0000000
--- a/servergreps/hercules/src/brathena.py
+++ /dev/null
@@ -1,180 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import os
-import re
-
-from src.preproc import PreProc
-from src.utils import Utils
-
-filt = re.compile(".+[.](c|h)", re.IGNORECASE)
-
-class Brathena:
- namedPackets = dict()
- packetsSet = set()
- outPacketsSorted = []
- inPacketsSorted = []
- inPackets = dict()
- functionToId = dict()
- loginPacketNameToId = dict()
- getLenPackets = set()
- knownLenPackets = dict()
-
- namedPacketre = re.compile(
- "((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<value>[0-9a-fA-F]+)")
- outPacketLoginre = re.compile(
- "([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
- serverpacketLoginOutre = re.compile("packet_id([ ]*)=([ ]*)(?P<name>[\w_]+);")
- clientpacketre = re.compile(
- "(\t*)packet[(]0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+)" +
- ",(?P<function>[0-9a-zA-Z_>-]+)(,|[)])")
- 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:
- for line in f:
- m = self.namedPacketre.search(line)
- if m is not None:
- if m.group("name") not in self.namedPackets:
- self.namedPackets[m.group("name")] = []
- data = m.group("value").lower()
- while len(data) < 4:
- data = "0" + data
- self.namedPackets[m.group("name")].append(data)
-
-
- def addServerPacket(self, data):
- if data == "000j":
- return
- if data in self.namedPackets:
- for val in self.namedPackets[data]:
- if int(val, 16) > 4096:
- return
- self.packetsSet.add(val)
- else:
- if len(data) > 2 and data[:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- try:
- if int(data, 16) > 4096:
- return
- except:
- pass
- self.packetsSet.add(data.lower())
-
-
- def collectOutPackets(self, parentDir):
- files = os.listdir(parentDir)
- for file1 in files:
- if file1[0] == ".":
- continue
- file2 = os.path.abspath(parentDir + os.path.sep + file1)
- if not os.path.isfile(file2):
- if file2.find("/src/evol") <= 0:
- self.collectOutPackets(file2)
- elif filt.search(file1):
- with open(file2, "r") as f:
- for line in f:
- Utils.getOutPackets(line, self)
- m = self.serverpacketLoginOutre.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] in self.loginPacketNameToId:
- data = str[2]
- data = self.loginPacketNameToId[data]
- self.addServerPacket(data)
- m = self.outPacketLoginre.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[4]
- while len(data) < 4:
- data = "0" + data
- self.loginPacketNameToId["PACKET_ID_" + str[1]] = 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:
- self.outPacketsSorted.append(packet)
- self.outPacketsSorted.sort()
-
-
- 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")), 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"))
-
-
- def collectCharInPackets(self, charFilePackets):
- for packets in Utils.enumCasePackets(charFilePackets, "int char_parse_char(int fd)"):
- self.inPackets[packets[1]] = (0, packets[0])
- self.functionToId[packets[0]] = packets[1]
-
-
- def sortInPackets(self):
- for packet in self.inPackets:
- self.inPacketsSorted.append(packet)
- self.inPacketsSorted.sort()
-
-
- def processPackets(self, packetDir, packetVersion):
- namedPacketsPath = packetDir + "/src/" + self.dirName + "/packets_struct.h"
- srcPath = packetDir + "/src/" + self.dirName
- serverInPacketsHPath = packetDir + "/src/" + self.dirName + "/packets.h"
- serverCharPackets = packetDir + "/src/" + self.dirName + "/char.c"
- self.collectNamedPackets(namedPacketsPath)
- self.collectOutPackets(srcPath)
- self.collectInPackets(serverInPacketsHPath)
- self.collectCharInPackets(serverCharPackets);
- self.sortInPackets()
- self.sortOutPackets()
-
-
- def prepareTempFiles(self, codeDir, packetDir, packetVersion):
- proc = PreProc()
- proc.init(packetDir + "/src/" + self.dirName)
- proc.defines = "-DPACKETVER=" + packetVersion + " -DCOMMON_SOCKET_H -DWFIFOW\\(fd,pos\\)=WFIFOW\\(fd,pos\\) -DWBUFW\\(p,pos\\)=WBUFW\\(p,pos\\)"
- proc.includes = "-I../links/" + codeDir + "/src -I../links/" + codeDir + "/3rdparty"
- proc.inDir = "../links/" + codeDir + "/src/"
- proc.outDir = packetDir + "/src/" + self.dirName + "/"
- proc.run("map", "packets_struct.h");
- proc.run("char", "char.c");
- proc.run("char", "pincode.c");
- proc.run("login", "login.c");
- proc.run("map", "clif.c");
- proc.defines = "-DPACKETVER=" + packetVersion + " -Dpacket\\(...\\)=packet\\(__VA_ARGS__\\)"
- proc.run("map", "packets.h");
diff --git a/servergreps/hercules/src/hercules.py b/servergreps/hercules/src/hercules.py
deleted file mode 100755
index cfa98b8..0000000
--- a/servergreps/hercules/src/hercules.py
+++ /dev/null
@@ -1,199 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import os
-import re
-
-from src.preproc import PreProc
-from src.utils import Utils
-
-filt = re.compile(".+[.](c|h)", re.IGNORECASE)
-
-class Hercules:
- namedPackets = dict()
- packetsSet = set()
- outPacketsSorted = []
- inPacketsSorted = []
- inPackets = dict()
- inMapPacketsSorted = []
- inMapPackets = dict()
- functionToId = dict()
- loginPacketNameToId = dict()
- getLenPackets = set()
- knownLenPackets = dict()
-
- namedPacketre = re.compile(
- "((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<value>[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_>-]+)(,|[)])")
- 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-]+)" +
- "[)]")
- outPacketLoginre = re.compile(
- "([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
- serverpacketLoginOutre = re.compile("packet_id([ ]*)=([ ]*)(?P<name>[\w_]+);")
-
- def collectNamedPackets(self, fileName):
- with open(fileName, "r") as f:
- for line in f:
- m = self.namedPacketre.search(line)
- if m is not None:
- if m.group("name") not in self.namedPackets:
- self.namedPackets[m.group("name")] = []
- data = m.group("value").lower()
- while len(data) < 4:
- data = "0" + data
- self.namedPackets[m.group("name")].append(data)
-
-
- def addServerPacket(self, data):
- if data == "000j":
- return
- if data in self.namedPackets:
- for val in self.namedPackets[data]:
- if int(val, 16) > 4096:
- return
- self.packetsSet.add(val)
- else:
- if len(data) > 2 and data[:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- try:
- if int(data, 16) > 4096:
- return
- except:
- pass
- self.packetsSet.add(data.lower())
-
-
- def collectOutPackets(self, parentDir):
- files = os.listdir(parentDir)
- for file1 in files:
- if file1[0] == ".":
- continue
- file2 = os.path.abspath(parentDir + os.path.sep + file1)
- if not os.path.isfile(file2):
- if file2.find("/src/evol") <= 0:
- self.collectOutPackets(file2)
- elif filt.search(file1):
- with open(file2, "r") as f:
- for line in f:
- Utils.getOutPackets(line, self)
- m = self.serverpacketLoginOutre.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] in self.loginPacketNameToId:
- data = str[2]
- data = self.loginPacketNameToId[data]
- self.addServerPacket(data)
- m = self.outPacketLoginre.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[4]
- while len(data) < 4:
- data = "0" + data
- self.loginPacketNameToId["PACKET_ID_" + str[1]] = 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:
- self.outPacketsSorted.append(packet)
- self.outPacketsSorted.sort()
-
-
- def collectInPackets(self, packetsH, lclifPackets):
- 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")), m.group("function"))
- self.inMapPackets[data] = self.inPackets[data]
- 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)
- if m is not None:
- name = "PACKET_ID_CA_" + m.group("name")
- if name not in self.loginPacketNameToId:
- print "Wrong login packet name: " + name
- continue
- data = self.loginPacketNameToId[name]
- self.inPackets[data] = (0, m.group("function"))
- self.functionToId[m.group("function")] = data
-
-
- def collectCharInPackets(self, charFilePackets):
- for packets in Utils.enumCasePackets(charFilePackets, "int char_parse_char(int fd)"):
- self.inPackets[packets[1]] = (0, packets[0])
- self.functionToId[packets[0]] = packets[1]
-
-
- def sortInPackets(self):
- for packet in self.inPackets:
- self.inPacketsSorted.append(packet)
- self.inPacketsSorted.sort()
- for packet in self.inMapPackets:
- self.inMapPacketsSorted.append(packet)
- self.inMapPacketsSorted.sort()
-
-
- def processPackets(self, packetDir, packetVersion):
- namedPacketsPath = packetDir + "/src/" + self.dirName + "/packets_struct.h"
- srcPath = packetDir + "/src/" + self.dirName
- 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.collectInPackets(serverInPacketsHPath, serverLoginInPackets)
- self.collectCharInPackets(serverCharPackets);
- self.sortInPackets()
- self.sortOutPackets()
-
-
- def prepareTempFiles(self, codeDir, packetDir, packetVersion):
- proc = PreProc()
- proc.init(packetDir + "/src/" + self.dirName)
- proc.defines = "-DPACKETVER=" + packetVersion + " -DCOMMON_SOCKET_H -DWFIFOW\\(fd,pos\\)=WFIFOW\\(fd,pos\\) -DWBUFW\\(p,pos\\)=WBUFW\\(p,pos\\)"
- proc.includes = "-I../links/" + codeDir + "/src -I../links/" + codeDir + "/3rdparty"
- proc.inDir = "../links/" + codeDir + "/src/"
- proc.outDir = packetDir + "/src/" + self.dirName + "/"
- proc.run("map", "packets_struct.h");
- proc.run("char", "char.c");
- proc.run("char", "pincode.c");
- proc.run("login", "login.c");
- proc.run("map", "clif.c");
- proc.run("login", "lclif.p.h");
- proc.run("login", "lclif.c");
- proc.defines = "-DPACKETVER=" + packetVersion + " -Dpacket\\(...\\)=packet\\(__VA_ARGS__\\)"
- proc.run("map", "packets.h");
diff --git a/servergreps/hercules/src/idathena.py b/servergreps/hercules/src/idathena.py
deleted file mode 100755
index 80fb944..0000000
--- a/servergreps/hercules/src/idathena.py
+++ /dev/null
@@ -1,183 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import os
-import re
-
-from src.packetdb import PacketDb
-from src.preproc import PreProc
-from src.utils import Utils
-
-filt = re.compile(".+[.](c|h)", re.IGNORECASE)
-
-class Idathena:
- namedPackets = dict()
- packetsSet = set()
- outPacketsSorted = []
- inPacketsSorted = []
- inPackets = dict()
- functionToId = dict()
- loginPacketNameToId = dict()
- getLenPackets = set()
- knownLenPackets = dict()
-
- namedPacketre = re.compile(
- "((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<value>[0-9a-fA-F]+)")
- outPacketLoginre = re.compile(
- "([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
- serverpacketLoginOutre = re.compile("packet_id([ ]*)=([ ]*)(?P<name>[\w_]+);")
- clientpacketre = re.compile(
- "(\t*)packet[(]0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+)" +
- ",(?P<function>[0-9a-zA-Z_>-]+)(,|[)])")
- lclifPacketre = re.compile(
- "([ ]*)[{][ ]PACKET_ID_CA_(?P<name>[A-Z0-9_]+),([^,]+)," +
- "([ ]*)[&](?P<function>[0-9a-zA-Z_>-]+)([ ]*)[}],")
- packetLenre = re.compile(
- "packet_db[\\[]0[\\]][\\[]0x(?P<packet>[0-9a-fA-F]+)[\\]].len")
-
- def collectNamedPackets(self, fileName):
- with open(fileName, "r") as f:
- for line in f:
- m = self.namedPacketre.search(line)
- if m is not None:
- if m.group("name") not in self.namedPackets:
- self.namedPackets[m.group("name")] = []
- data = m.group("value").lower()
- while len(data) < 4:
- data = "0" + data
- self.namedPackets[m.group("name")].append(data)
-
-
- def addServerPacket(self, data):
- if data == "000j":
- return
- if data == "cmde":
- return
- if data in self.namedPackets:
- for val in self.namedPackets[data]:
- if int(val, 16) > 4096:
- return
- self.packetsSet.add(val)
- else:
- if len(data) > 2 and data[:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- try:
- if int(data, 16) > 4096:
- return
- except:
- pass
- self.packetsSet.add(data.lower())
-
-
- def collectOutPackets(self, parentDir):
- files = os.listdir(parentDir)
- for file1 in files:
- if file1[0] == ".":
- continue
- file2 = os.path.abspath(parentDir + os.path.sep + file1)
- if not os.path.isfile(file2):
- if file2.find("/src/evol") <= 0:
- self.collectOutPackets(file2)
- elif filt.search(file1):
- with open(file2, "r") as f:
- for line in f:
- Utils.getOutPackets(line, self)
- m = self.outPacketLoginre.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[4]
- while len(data) < 4:
- data = "0" + data
- self.loginPacketNameToId["PACKET_ID_" + str[1]] = data
- m = self.serverpacketLoginOutre.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] in self.loginPacketNameToId:
- 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:
- self.outPacketsSorted.append(packet)
- self.outPacketsSorted.sort()
-
-
- def collectInPackets(self, packetsH, lclifPackets):
- 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")), m.group("function"))
- self.functionToId[m.group("function")] = data
- with open(lclifPackets, "r") as f:
- for line in f:
- m = self.lclifPacketre.search(line)
- if m is not None:
- name = "PACKET_ID_CA_" + m.group("name")
- if name not in self.loginPacketNameToId:
- print "Wrong login packet name: " + name
- continue
- data = self.loginPacketNameToId[name]
- self.inPackets[data] = (0, m.group("function"))
- self.functionToId[m.group("function")] = data
-
-
- def collectCharInPackets(self, charFilePackets):
- for packets in Utils.enumCasePackets(charFilePackets, "int char_parse_char(int fd)"):
- self.inPackets[packets[1]] = (0, packets[0])
- self.functionToId[packets[0]] = packets[1]
-
-
- def sortInPackets(self):
- for packet in self.inPackets:
- self.inPacketsSorted.append(packet)
- self.inPacketsSorted.sort()
-
-
- def processPackets(self, codeDir, packetDir, packetVersion):
-# namedPacketsPath = packetDir + "/src/" + self.dirName + "/packets_struct.h"
- srcPath = packetDir + "/src/" + 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)
- PacketDb.getInPackets(packetsDbPath, packetVersion, self)
-# self.collectCharInPackets(serverCharPackets);
- self.sortInPackets()
- self.sortOutPackets()
-
-
- def prepareTempFiles(self, codeDir, packetDir, packetVersion):
- proc = PreProc()
- proc.init(packetDir + "/src/" + self.dirName)
- proc.defines = "-DPACKETVER=" + packetVersion + " -D_SOCKET_H_ -DWFIFOW\\(fd,pos\\)=WFIFOW\\(fd,pos\\) -DWBUFW\\(p,pos\\)=WBUFW\\(p,pos\\)"
- proc.includes = "-I../links/" + codeDir + "/src -I../links/" + codeDir + "/3rdparty"
- proc.inDir = "../links/" + codeDir + "/src/"
- proc.outDir = packetDir + "/src/" + self.dirName + "/"
- proc.run("char", "char.c");
- proc.run("login", "login.c");
- proc.run("map", "clif.c");
diff --git a/servergreps/hercules/src/manaplus.py b/servergreps/hercules/src/manaplus.py
deleted file mode 100755
index 5a52e1b..0000000
--- a/servergreps/hercules/src/manaplus.py
+++ /dev/null
@@ -1,97 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import os
-import re
-
-class ManaPlus:
- inPackets = dict()
- outPackets = dict()
- sizes = dict()
- manaplusUsedPacketsSet = set()
- outMsgNameToId = dict()
- 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]+)," +
- "([ ]*)(?P<len>[\w-]+),([ ]*)(?P<function>[0-9a-zA-Z_>-]+)[)];")
- packetOutNametre = re.compile("(?P<name>(S|C)MSG_[A-Z0-9_]+)")
-
- def collectInPackets(self, fileName, packetVersion):
- version = 0
- with open(fileName, "r") as f:
- for line in f:
- m = self.protocolinverre.search(line)
- if m is not None:
- version = int(m.group("ver"))
- continue
- # skip bigger versions than requested
- if version > packetVersion:
- continue
- m = self.protocolinre.search(line)
- if m is not None:
- packet = int(m.group("packet"), 16)
- if packet > 0xb00 or packet == 0:
- continue
- self.inPackets[m.group("packet").lower()] = \
- (m.group("name"), int(m.group("len")), "nullptr")
- self.sizes[m.group("packet").lower()] = int(m.group("len"))
-
-
- def collectOutPackets(self, fileName, packetVersion):
- version = 0
- with open(fileName, "r") as f:
- for line in f:
- m = self.protocolinverre.search(line)
- if m is not None:
- version = int(m.group("ver"))
- continue
- # skip bigger versions than requested
- if version > packetVersion:
- continue
- m = self.protocoloutre.search(line)
- if m is not None:
- packet = int(m.group("packet"), 16)
- if packet > 0xb00 or packet == 0:
- continue
- self.inPackets[m.group("packet").lower()] = \
- (m.group("name"), int(m.group("len")), m.group("function"))
- self.outPackets[m.group("packet").lower()] = \
- (m.group("name"), int(m.group("len")), m.group("function"))
- self.outMsgNameToId[m.group("name").strip()] = \
- m.group("packet").lower()
- # print "{0} = {1}".format(
- # m.group("name").strip(), m.group("packet").lower())
-
-
- def processCppFiles(self, parentDir):
- files = os.listdir(parentDir)
- for file1 in files:
- if file1[0] == ".":
- continue
- file2 = os.path.abspath(parentDir + os.path.sep + file1)
- if not os.path.isfile(file2):
- self.processCppFiles(file2)
- elif file1[-4:] == ".cpp":
- self.collectManaPlusUsedPackets(file2)
-
-
- def collectManaPlusUsedPackets(self, fileName):
- with open(fileName, "r") as f:
- for line in f:
- m = self.packetOutNametre.search(line)
- if m is not None:
- self.manaplusUsedPacketsSet.add(m.group("name"))
-
- def processPackets(self, packetVersion):
- manaplusPath = "../../../manaplus/src/"
- protocolPath = manaplusPath + "net/eathena/packets"
- eathenaPath = manaplusPath + "net/eathena/"
- self.collectInPackets(protocolPath + "in.inc", int(packetVersion))
- self.collectOutPackets(protocolPath + "out.inc", int(packetVersion))
- self.processCppFiles(eathenaPath)
diff --git a/servergreps/hercules/src/packetdb.py b/servergreps/hercules/src/packetdb.py
deleted file mode 100755
index e50f51a..0000000
--- a/servergreps/hercules/src/packetdb.py
+++ /dev/null
@@ -1,279 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import re
-
-class PacketDb:
- packetVersionRe = re.compile("^//(?P<v1>[\d][\d][\d][\d])-(?P<v2>[\d][\d])-(?P<v3>[\d][\d])")
- clientpacketre = re.compile(
- "^0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+)" +
- ",(?P<function>[0-9a-zA-Z_]+),")
- serverpacketre = re.compile(
- "^0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+)")
-
- nameMap = {
-#3CeAm
- 'guildinvite': 'clif->pGuildInvite',
- 'createparty': 'clif->pCreateParty',
- 'ticksend': 'clif->pTickSend',
- 'viewplayerequip': 'clif->pViewPlayerEquip',
- 'hommovetomaster': 'clif->pHomMoveToMaster',
- 'wisexin': 'clif->pPMIgnore',
- 'storagepassword': 'clif->pStoragePassword',
- 'npccloseclicked': 'clif->pNpcCloseClicked',
- 'guildrequestinfo': 'clif->pGuildRequestInfo',
- 'hommenu': 'clif->pHomMenu',
- 'createchatroom': 'clif->pCreateChatRoom',
- 'partychangeleader': 'clif->pPartyChangeLeader',
- 'tradecancel': 'clif->pTradeCancel',
- 'wanttoconnection': 'clif->pWantToConnection',
- 'lesseffect': 'clif->pLessEffect',
- 'gmhide': 'clif->pGMHide',
- 'purchasereq2': 'clif->pPurchaseReq2',
- 'stopattack': 'clif->pStopAttack',
- 'walktoxy': 'clif->pWalkToXY',
- 'npcclicked': 'clif->pNpcClicked',
- 'bookingcanceljoinparty': 'clif->pDull',
- 'recall2': 'clif->pGMRecall2',
- 'changedir': 'clif->pChangeDir',
- 'guildleave': 'clif->pGuildLeave',
- 'searchstoreinfo': 'clif->pSearchStoreInfo',
- 'bookingsearchreq': 'clif->pPartyBookingSearchReq',
- 'partyinvite': 'clif->pPartyInvite',
- 'auctionclose': 'clif->pAuction_close',
- 'repairitem': 'clif->pRepairItem',
- 'bookingignorereq': 'clif->pDull',
- 'searchstoreinfonextpage': 'clif->pSearchStoreInfoNextPage',
- 'solvecharname': 'clif->pSolveCharName',
- 'guildreplyalliance': 'clif->pGuildReplyAlliance',
- 'weaponrefine': 'clif->pWeaponRefine',
- 'maildelete': 'clif->pMail_delete',
- 'useskilltoid': 'clif->pUseSkillToId',
- 'cashshopbuy': 'clif->pcashshop_buy',
- 'traderequest': 'clif->pTradeRequest',
- 'restart': 'clif->pRestart',
- 'gmreqnochat': 'clif->pGMReqNoChat',
- 'movefromkafra': 'clif->pMoveFromKafra',
- 'replypartyinvite2': 'clif->pReplyPartyInvite2',
- 'changechatowner': 'clif->pChangeChatOwner',
- 'guildbreak': 'clif->pGuildBreak',
- 'producemix': 'clif->pProduceMix',
- 'auctionregister': 'clif->pAuction_register',
- 'auctioncancel': 'clif->pAuction_cancel',
- 'remove': 'clif->pGMShift', # probably error
- 'summon': 'clif->pGMRecall', # probably error
- 'openvending': 'clif->pOpenVending',
- 'leaveparty': 'clif->pLeaveParty',
- 'cashshopclose': 'clif->pCashShopClose',
- 'guildchangenotice': 'clif->pGuildChangeNotice',
- 'chatroomstatuschange': 'clif->pChatRoomStatusChange',
- 'auctionsearch': 'clif->pAuction_search',
- 'tradeack': 'clif->pTradeAck',
- 'useitem': 'clif->pUseItem',
- 'sndoridori': 'clif->pNoviceDoriDori',
- 'guildreplyinvite': 'clif->pGuildReplyInvite',
- 'selectarrow': 'clif->pSelectArrow',
- 'feelsaveok': 'clif->pFeelSaveOk',
- 'taekwon': 'clif->pTaekwon',
- 'battlechat': 'clif->pBattleChat',
- 'guilddelalliance': 'clif->pGuildDelAlliance',
- 'cashshopreqtab': 'clif->pCashShopReqTab',
- 'partyinvite2': 'clif->pPartyInvite2',
- 'hommoveto': 'clif->pHomMoveTo',
- 'useskilltoposmoreinfo': 'clif->pUseSkillToPosMoreInfo',
- 'getcharnamerequest': 'clif->pGetCharNameRequest',
- 'closesearchstoreinfo': 'clif->pCloseSearchStoreInfo',
- 'localbroadcast': 'clif->pLocalBroadcast',
- 'closekafra': 'clif->pCloseKafra',
- 'putitemtocart': 'clif->pPutItemToCart',
- 'actionrequest': 'clif->pActionRequest',
- 'cashshopschedule': 'clif->pCashShopSchedule',
- 'auctioncancelreg': 'clif->pAuction_cancelreg',
- 'rc': 'clif->pGMRc',
- 'guildexpulsion': 'clif->pGuildExpulsion',
- 'partymessage': 'clif->pPartyMessage',
- 'equiptickbox': 'clif->pEquipTick',
- 'guildchangememberposition': 'clif->pGuildChangeMemberPosition',
- 'adoptreply': 'clif->pAdopt_reply',
- 'mailwinopen': 'clif->pMail_winopen',
- 'hotkey': 'clif->pHotkey',
- 'searchstoreinfolistitemclick': 'clif->pSearchStoreInfoListItemClick',
- 'npcselllistsend': 'clif->pNpcSellListSend',
- 'dropitem': 'clif->pDropItem',
- 'takeitem': 'clif->pTakeItem',
- 'npcselectmenu': 'clif->pNpcSelectMenu',
- 'changehomunculusname': 'clif->pChangeHomunculusName',
- 'shift': 'clif->pGMShift',
- 'friendslistadd': 'clif->pFriendsListAdd',
- 'sendemotion': 'clif->pSendEmotion',
- 'progressbar': 'clif->pProgressbar',
- 'bookingdelreq': 'clif->pPartyBookingDeleteReq',
- 'howmanyconnections': 'clif->pHowManyConnections',
- 'changemaptype': 'clif->pGMChangeMapType',
- 'blacksmith': 'clif->pBlacksmith',
- 'npcbuylistsend': 'clif->pNpcBuyListSend',
- 'gmreqaccname': 'clif->pGMReqAccountName',
- 'emotion': 'clif->pEmotion',
- 'skillselectmenu': 'clif->pSkillSelectMenu',
- 'reqtradebuyingstore': 'clif->pReqTradeBuyingStore',
- 'pvpinfo': 'clif->pPVPInfo',
- 'wisexlist': 'clif->pPMIgnoreList',
- 'chataddmember': 'clif->pChatAddMember',
- 'remove2': 'clif->pGMRemove2',
- 'requestmemo': 'clif->pRequestMemo',
- 'wis': 'clif->pWisMessage',
- 'petmenu': 'clif->pPetMenu',
- 'rankingpk': 'clif->pRankingPk',
- 'mailgetattach': 'clif->pMail_getattach',
- 'tradeadditem': 'clif->pTradeAddItem',
- 'useskillmap': 'clif->pUseSkillMap',
- 'auctionbuysell': 'clif->pAuction_buysell',
- 'autorevive': 'clif->pAutoRevive',
- 'movetokafrafromcart': 'clif->pMoveToKafraFromCart',
- 'cashshopopen': 'clif->pCashShopOpen',
- 'queststate': 'clif->pquestStateAck',
- 'loadendack': 'clif->pLoadEndAck',
- 'unequipitem': 'clif->pUnequipItem',
- 'replypartyinvite': 'clif->pReplyPartyInvite',
- 'guildrequestemblem': 'clif->pGuildRequestEmblem',
- 'globalmessage': 'clif->pGlobalMessage',
- 'reqclickbuyingstore': 'clif->pReqClickBuyingStore',
- 'bookingsummonmember': 'clif->pDull',
- 'friendslistreply': 'clif->pFriendsListReply',
- 'npcstringinput': 'clif->pNpcStringInput',
- 'closevending': 'clif->pCloseVending',
- 'skillup': 'clif->pSkillUp',
- 'broadcast': 'clif->pBroadcast',
- 'guildcheckmaster': 'clif->pGuildCheckMaster',
- 'guildchangeemblem': 'clif->pGuildChangeEmblem',
- 'itemmonster': 'clif->pGM_Monster_Item',
- 'vendinglistreq': 'clif->pVendingListReq',
- 'guildrequestalliance': 'clif->pGuildRequestAlliance',
- 'bookingupdatereq': 'clif->pPartyBookingUpdateReq',
- 'removeoption': 'clif->pRemoveOption',
- 'recall': 'clif->pGMRecall',
- 'changepetname': 'clif->pChangePetName',
- 'chatleave': 'clif->pChatLeave',
- 'snexplosionspirits': 'clif->pNoviceExplosionSpirits',
- 'mailread': 'clif->pMail_read',
- 'mermenu': 'clif->pmercenary_action',
- 'alchemist': 'clif->pAlchemist',
- 'partychangeoption': 'clif->pPartyChangeOption',
- 'tradeok': 'clif->pTradeOk',
- 'kickfromchat': 'clif->pKickFromChat',
- 'reqopenbuyingstore': 'clif->pReqOpenBuyingStore',
- 'moveitem': 'clif->pMoveItem',
- 'homattack': 'clif->pHomAttack',
- 'ranking': 'clif->pRankingPk',
- 'changecart': 'clif->pChangeCart',
- 'reqclosebuyingstore': 'clif->pReqCloseBuyingStore',
- 'removepartymember': 'clif->pRemovePartyMember',
- 'catchpet': 'clif->pCatchPet',
- 'selectegg': 'clif->pSelectEgg',
- 'partybookingregisterreq': 'clif->pPartyBookingRegisterReq',
- 'mailsend': 'clif->pMail_send',
- 'itemlistwindowselected': 'clif->pItemListWindowSelected',
- 'mailrefresh': 'clif->pMail_refreshinbox',
- 'mapmove': 'clif->pMapMove',
- 'check': 'clif->pCheck',
- 'useskilltoposinfo': 'clif->pUseSkillToPosMoreInfo',
- 'adoptrequest': 'clif->pAdopt_request',
- 'npcamountinput': 'clif->pNpcAmountInput',
- 'battlegroundreg': 'clif->pBGQueueRegister',
- 'wisall': 'clif->pPMIgnoreAll',
- 'npcnextclicked': 'clif->pNpcNextClicked',
- 'resetchar': 'clif->pResetChar',
- 'npcbuysellselected': 'clif->pNpcBuySellSelected',
- 'killall': 'clif->pGMKickAll',
- 'mailsetattach': 'clif->pMail_setattach',
- 'insertcard': 'clif->pInsertCard',
- 'purchasereq': 'clif->pPurchaseReq',
- 'auctionbid': 'clif->pAuction_bid',
- 'gmkick': 'clif->pGMKick',
- 'auctionsetitem': 'clif->pAuction_setitem',
- 'createparty2': 'clif->pCreateParty2',
- 'statusup': 'clif->pStatusUp',
- 'usecard': 'clif->pUseCard',
- 'guildmessage': 'clif->pGuildMessage',
- 'itemidentify': 'clif->pItemIdentify',
- 'bookingjoinpartyreq': 'clif->pDull',
- 'equipitem': 'clif->pEquipItem',
- 'useskilltopos': 'clif->pUseSkillToPos',
- 'autospell': 'clif->pAutoSpell',
- 'cooking': 'clif->pCooking',
- 'bookingregreq': 'clif->pPartyBookingRegisterReq',
- 'movefromkafratocart': 'clif->pMoveFromKafraToCart',
- 'mailreturn': 'clif->pMail_return',
- 'tradecommit': 'clif->pTradeCommit',
- 'quitgame': 'clif->pQuitGame',
- 'movetokafra': 'clif->pMoveToKafra',
- 'friendslistremove': 'clif->pFriendsListRemove',
- 'getitemfromcart': 'clif->pGetItemFromCart',
- 'guildopposition': 'clif->pGuildOpposition',
- 'createguild': 'clif->pCreateGuild',
- 'guildchangepositioninfo': 'clif->pGuildChangePositionInfo',
- 'selectcart': 'clif->pSelectCart',
-
-#rathena
- 'partytick': 'clif->pPartyTick',
- 'clientversion': 'in packet',
- 'gmfullstrip': 'clif->pGMFullStrip',
- 'guildinvite2': 'clif->pGuildInvite2',
- 'mergeitem_req': 'clif->ackmergeitems',
- 'mergeitem_cancel': 'clif->cancelmergeitem',
- 'booking_playcancel': 'in packet',
- 'cashshopitemlist': 'clif->pCashShopSchedule',
- 'reqworldinfo': 'reqworldinfo',
- 'ranklist': 'clif->pRanklist',
- 'bankdeposit': 'clif->pBankDeposit',
- 'bankwithdrawal': 'clif->pBankWithdraw',
- 'bankcheck': 'clif->pBankCheck',
- 'bankopen': 'clif->pBankOpen',
- 'bankclose': 'clif->pBankClose',
- 'dull': 'clif->pDull',
- 'npcshopclosed': 'clif->pNPCShopClosed',
- 'npcmarketpurchase': 'clif->pNPCMarketPurchase',
- 'npcmarketclosed': 'clif->pNPCMarketClosed',
- 'hotkeyrowshift': 'clif->pHotkeyRowShift',
- 'rouletteopen': 'clif->pRouletteOpen',
- 'rouletteinfo': 'clif->pRouletteInfo',
- 'rouletteclose': 'clif->pRouletteClose',
- 'roulettegenerate': 'clif->pRouletteGenerate',
- 'rouletterecvitem': 'clif->pRouletteRecvItem'
- }
-
- @staticmethod
- def getInPackets(dbName, packetVersion, server):
- with open(dbName, "r") as f:
- version = "00000000"
- for line in f:
- m = PacketDb.packetVersionRe.search(line)
- if m is not None:
- version = m.group("v1") + m.group("v2") + m.group("v3")
- if version > packetVersion:
- continue
- m = PacketDb.clientpacketre.search(line)
- if m is not None:
- data = m.group("packet").lower()
- while len(data) < 4:
- data = "0" + data
- func = m.group("function")
- if func not in PacketDb.nameMap:
- if func.find("_") < 0:
- print "Cant find name for functions " + func
- else:
- func = PacketDb.nameMap[func]
- if func.find("_") < 0 and func != "in packet":
- server.functionToId[func] = data
- server.inPackets[data] = \
- (int(m.group("len")), func)
- #print "{0}, {1}, {2}".format(m.group("packet"), m.group("len"), func)
- m = PacketDb.serverpacketre.search(line)
- if m is not None:
- data = m.group("packet").lower()
- while len(data) < 4:
- data = "0" + data
- server.knownLenPackets[data] = int(m.group("len"))
diff --git a/servergreps/hercules/src/peek.py b/servergreps/hercules/src/peek.py
deleted file mode 100755
index d4410c7..0000000
--- a/servergreps/hercules/src/peek.py
+++ /dev/null
@@ -1,109 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import configparser
-import os
-
-class Peek:
- inPacketsSorted = []
- inPackets = dict()
- knownLenPackets = dict()
-
-# staticMap = {
-# }
-
- 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/preproc.py b/servergreps/hercules/src/preproc.py
deleted file mode 100755
index 4f3b458..0000000
--- a/servergreps/hercules/src/preproc.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import os
-import shutil
-
-class PreProc:
- def init(self, tmpDir):
- if os.path.exists(tmpDir):
- shutil.rmtree(tmpDir)
- os.makedirs(tmpDir)
-
-
- def run(self, subDir, outFile):
- os.system(
- "cpp {defines} {includes} {subDir}/{inFile} {outFile}".format(
- defines = self.defines,
- includes = self.includes,
- subDir = self.inDir + subDir,
- inFile = outFile,
- outFile = self.outDir + outFile))
diff --git a/servergreps/hercules/src/ragemu.py b/servergreps/hercules/src/ragemu.py
deleted file mode 100755
index a06dc5f..0000000
--- a/servergreps/hercules/src/ragemu.py
+++ /dev/null
@@ -1,194 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import os
-import re
-
-from src.preproc import PreProc
-from src.utils import Utils
-
-filt = re.compile(".+[.](c|h)", re.IGNORECASE)
-
-class Ragemu:
- namedPackets = dict()
- packetsSet = set()
- outPacketsSorted = []
- inPacketsSorted = []
- inPackets = dict()
- functionToId = dict()
- loginPacketNameToId = dict()
- getLenPackets = set()
- knownLenPackets = dict()
-
- namedPacketre = re.compile(
- "((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<value>[0-9a-fA-F]+)")
- outPacketLoginre = re.compile(
- "([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
- serverpacketLoginOutre = re.compile("packet_id([ ]*)=([ ]*)(?P<name>[\w_]+);")
- clientpacketre = re.compile(
- "(\t*)packet[(]0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+)" +
- ",(?P<function>[0-9a-zA-Z_>-]+)(,|[)])")
- 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:
- for line in f:
- m = self.namedPacketre.search(line)
- if m is not None:
- if m.group("name") not in self.namedPackets:
- self.namedPackets[m.group("name")] = []
- data = m.group("value").lower()
- while len(data) < 4:
- data = "0" + data
- self.namedPackets[m.group("name")].append(data)
-
-
- def addServerPacket(self, data):
- if data == "000j":
- return
- if data in self.namedPackets:
- for val in self.namedPackets[data]:
- if int(val, 16) > 4096:
- return
- self.packetsSet.add(val)
- else:
- if len(data) > 2 and data[:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- try:
- if int(data, 16) > 4096:
- return
- except:
- pass
- self.packetsSet.add(data.lower())
-
-
- def collectOutPackets(self, parentDir):
- files = os.listdir(parentDir)
- for file1 in files:
- if file1[0] == ".":
- continue
- file2 = os.path.abspath(parentDir + os.path.sep + file1)
- if not os.path.isfile(file2):
- if file2.find("/src/evol") <= 0:
- self.collectOutPackets(file2)
- elif filt.search(file1):
- with open(file2, "r") as f:
- for line in f:
- Utils.getOutPackets(line, self)
- m = self.outPacketLoginre.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[4]
- while len(data) < 4:
- data = "0" + data
- self.loginPacketNameToId["PACKET_ID_" + str[1]] = data
- m = self.serverpacketLoginOutre.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] in self.loginPacketNameToId:
- 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:
- self.outPacketsSorted.append(packet)
- self.outPacketsSorted.sort()
-
-
- def collectInPackets(self, packetsH, lclifPackets):
- 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")), 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)
- if m is not None:
- name = "PACKET_ID_CA_" + m.group("name")
- if name not in self.loginPacketNameToId:
- print "Wrong login packet name: " + name
- continue
- data = self.loginPacketNameToId[name]
- self.inPackets[data] = (0, m.group("function"))
- self.functionToId[m.group("function")] = data
-
-
- def collectCharInPackets(self, charFilePackets):
- for packets in Utils.enumCasePackets(charFilePackets, "int char_parse_char(int fd)"):
- self.inPackets[packets[1]] = (0, packets[0])
- self.functionToId[packets[0]] = packets[1]
-
-
- def sortInPackets(self):
- for packet in self.inPackets:
- self.inPacketsSorted.append(packet)
- self.inPacketsSorted.sort()
-
-
- def processPackets(self, packetDir, packetVersion):
- namedPacketsPath = packetDir + "/src/" + self.dirName + "/packets_struct.h"
- srcPath = packetDir + "/src/" + self.dirName
- 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.collectInPackets(serverInPacketsHPath, serverLoginInPackets)
- self.collectCharInPackets(serverCharPackets);
- self.sortInPackets()
- self.sortOutPackets()
-
-
- def prepareTempFiles(self, codeDir, packetDir, packetVersion):
- proc = PreProc()
- proc.init(packetDir + "/src/" + self.dirName)
- proc.defines = "-DPACKETVER=" + packetVersion + " -DCOMMON_SOCKET_H -DWFIFOW\\(fd,pos\\)=WFIFOW\\(fd,pos\\) -DWBUFW\\(p,pos\\)=WBUFW\\(p,pos\\)"
- proc.includes = "-I../links/" + codeDir + "/src -I../links/" + codeDir + "/3rdparty"
- proc.inDir = "../links/" + codeDir + "/src/"
- proc.outDir = packetDir + "/src/" + self.dirName + "/"
- proc.run("map", "packets_struct.h");
- proc.run("char", "char.c");
- proc.run("char", "pincode.c");
- proc.run("login", "login.c");
- proc.run("map", "clif.c");
- proc.run("login", "lclif.p.h");
- proc.run("login", "lclif.c");
- proc.defines = "-DPACKETVER=" + packetVersion + " -Dpacket\\(...\\)=packet\\(__VA_ARGS__\\)"
- proc.run("map", "packets.h");
diff --git a/servergreps/hercules/src/rathena.py b/servergreps/hercules/src/rathena.py
deleted file mode 100755
index 596edf0..0000000
--- a/servergreps/hercules/src/rathena.py
+++ /dev/null
@@ -1,183 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import os
-import re
-
-from src.packetdb import PacketDb
-from src.preproc import PreProc
-from src.utils import Utils
-
-filt = re.compile(".+[.](c|h)", re.IGNORECASE)
-
-class Rathena:
- namedPackets = dict()
- packetsSet = set()
- outPacketsSorted = []
- inPacketsSorted = []
- inPackets = dict()
- functionToId = dict()
- loginPacketNameToId = dict()
- getLenPackets = set()
- knownLenPackets = dict()
-
- namedPacketre = re.compile(
- "((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<value>[0-9a-fA-F]+)")
- outPacketLoginre = re.compile(
- "([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
- serverpacketLoginOutre = re.compile("packet_id([ ]*)=([ ]*)(?P<name>[\w_]+);")
- clientpacketre = re.compile(
- "(\t*)packet[(]0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+)" +
- ",(?P<function>[0-9a-zA-Z_>-]+)(,|[)])")
- lclifPacketre = re.compile(
- "([ ]*)[{][ ]PACKET_ID_CA_(?P<name>[A-Z0-9_]+),([^,]+)," +
- "([ ]*)[&](?P<function>[0-9a-zA-Z_>-]+)([ ]*)[}],")
- packetLenre = re.compile(
- "packet_db[\\[]0[\\]][\\[]0x(?P<packet>[0-9a-fA-F]+)[\\]].len")
-
- def collectNamedPackets(self, fileName):
- with open(fileName, "r") as f:
- for line in f:
- m = self.namedPacketre.search(line)
- if m is not None:
- if m.group("name") not in self.namedPackets:
- self.namedPackets[m.group("name")] = []
- data = m.group("value").lower()
- while len(data) < 4:
- data = "0" + data
- self.namedPackets[m.group("name")].append(data)
-
-
- def addServerPacket(self, data):
- if data == "000j":
- return
- if data == "cmde":
- return
- if data in self.namedPackets:
- for val in self.namedPackets[data]:
- if int(val, 16) > 4096:
- return
- self.packetsSet.add(val)
- else:
- if len(data) > 2 and data[:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- try:
- if int(data, 16) > 4096:
- return
- except:
- pass
- self.packetsSet.add(data.lower())
-
-
- def collectOutPackets(self, parentDir):
- files = os.listdir(parentDir)
- for file1 in files:
- if file1[0] == ".":
- continue
- file2 = os.path.abspath(parentDir + os.path.sep + file1)
- if not os.path.isfile(file2):
- if file2.find("/src/evol") <= 0:
- self.collectOutPackets(file2)
- elif filt.search(file1):
- with open(file2, "r") as f:
- for line in f:
- Utils.getOutPackets(line, self)
- m = self.outPacketLoginre.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[4]
- while len(data) < 4:
- data = "0" + data
- self.loginPacketNameToId["PACKET_ID_" + str[1]] = data
- m = self.serverpacketLoginOutre.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] in self.loginPacketNameToId:
- 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:
- self.outPacketsSorted.append(packet)
- self.outPacketsSorted.sort()
-
-
- def collectInPackets(self, packetsH, lclifPackets):
- 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")), m.group("function"))
- self.functionToId[m.group("function")] = data
- with open(lclifPackets, "r") as f:
- for line in f:
- m = self.lclifPacketre.search(line)
- if m is not None:
- name = "PACKET_ID_CA_" + m.group("name")
- if name not in self.loginPacketNameToId:
- print "Wrong login packet name: " + name
- continue
- data = self.loginPacketNameToId[name]
- self.inPackets[data] = (0, m.group("function"))
- self.functionToId[m.group("function")] = data
-
-
- def collectCharInPackets(self, charFilePackets):
- for packets in Utils.enumCasePackets(charFilePackets, "int char_parse_char(int fd)"):
- self.inPackets[packets[1]] = (0, packets[0])
- self.functionToId[packets[0]] = packets[1]
-
-
- def sortInPackets(self):
- for packet in self.inPackets:
- self.inPacketsSorted.append(packet)
- self.inPacketsSorted.sort()
-
-
- def processPackets(self, codeDir, packetDir, packetVersion):
-# namedPacketsPath = packetDir + "/src/" + self.dirName + "/packets_struct.h"
- srcPath = packetDir + "/src/" + 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_clif.c"
-# self.collectNamedPackets(namedPacketsPath)
- self.collectOutPackets(srcPath)
- PacketDb.getInPackets(packetsDbPath, packetVersion, self)
-# self.collectCharInPackets(serverCharPackets);
- self.sortInPackets()
- self.sortOutPackets()
-
-
- def prepareTempFiles(self, codeDir, packetDir, packetVersion):
- proc = PreProc()
- proc.init(packetDir + "/src/" + self.dirName)
- proc.defines = "-DPACKETVER=" + packetVersion + " -D_SOCKET_H_ -DWFIFOW\\(fd,pos\\)=WFIFOW\\(fd,pos\\) -DWBUFW\\(p,pos\\)=WBUFW\\(p,pos\\)"
- proc.includes = "-I../links/" + codeDir + "/src -I../links/" + codeDir + "/3rdparty"
- proc.inDir = "../links/" + codeDir + "/src/"
- proc.outDir = packetDir + "/src/" + self.dirName + "/"
- proc.run("char", "char_clif.c");
- proc.run("login", "loginclif.c");
- proc.run("map", "clif.c");
diff --git a/servergreps/hercules/src/reporter.py b/servergreps/hercules/src/reporter.py
deleted file mode 100755
index ea1c6b7..0000000
--- a/servergreps/hercules/src/reporter.py
+++ /dev/null
@@ -1,384 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-class Reporter:
- def reportManaplus(self, hercules, manaplus):
- with open(self.packetDir + "/" + hercules.reportName + "_outpackets.txt", "w") as w:
- for packet in hercules.outPacketsSorted:
- data = packet
- while data[0] == "0":
- data = data[1:]
- if packet in manaplus.inPackets:
- clientName = manaplus.inPackets[packet][0]
- # if clientName not in manaplus.manaplusUsedPacketsSet and clientName.find("_OUTDATED") <= 0:
- # w.write("UNIMPLIMENTED ")
- w.write(data + " client name: " + clientName)
- else:
- w.write(data)
- w.write("\n")
-
- funcDict = dict()
- for packet in hercules.inPacketsSorted:
- data = packet
- while data[0] == "0":
- data = data[1:]
- if packet in hercules.inPackets:
- funcDict[hercules.inPackets[packet][1]] = packet
-
- with open(self.packetDir + "/client_uselesspackets.txt", "w") as w:
- for packet in manaplus.outPackets:
- if packet not in hercules.inPackets:
- w.write("Useless packet {0}.\n".format(packet))
-
- # manaplusFunc = set()
- rev = []
-
- with open(self.packetDir + "/client_packets.txt", "w") as w:
- for packet in manaplus.outPackets:
- clientName = manaplus.outPackets[packet][0]
- if clientName not in manaplus.manaplusUsedPacketsSet and clientName.find("_OUTDATED") <= 0:
- w.write("PSESENT BUT UNIMPLIMENTED {0}\n".format(clientName))
-
- # for packet in manaplus.outPackets:
- # if packet in hercules.inPackets:
- # manaplusFunc.add(hercules.inPackets[packet][1])
- # for func in funcDict:
- # if func not in manaplusFunc:
- # packet = funcDict[func]
- # rev.append("{0:4} {1:>4} {2}".format(packet, hercules.inPackets[packet][0], hercules.inPackets[packet][1]))
-
- clientSet = set()
- for packet in hercules.inPackets:
- clientSet.add(hercules.inPackets[packet][1])
- for packet in manaplus.outPackets:
- if packet in hercules.inPackets and hercules.inPackets[packet][1] in clientSet:
- if manaplus.outPackets[packet][2] == hercules.inPackets[packet][1]:
- clientSet.remove(hercules.inPackets[packet][1])
- else:
- if manaplus.outPackets[packet][2] in clientSet:
- clientSet.remove(manaplus.outPackets[packet][2])
-
- allPackets = set()
- for packet in hercules.inPackets:
- allPackets.add(packet)
- for packet in manaplus.outPackets:
- allPackets.add(packet)
-
- for packet in clientSet:
- rev.append("{0:4} {1:33} {2}".format("?", "UNIMPLIMENTED", packet))
-
- for packet in allPackets:
- if packet not in manaplus.outPackets:
- continue
- data = "{0:4} {1:33} ".format(packet, manaplus.outPackets[packet][0])
- if packet in hercules.inPackets:
- if manaplus.outPackets[packet][2] == hercules.inPackets[packet][1]:
- data = data + hercules.inPackets[packet][1]
- rev.append(data)
- else:
- data = data + "?"
- rev.append(data)
-
- rev.sort()
-
- for data in rev:
- w.write(data)
- w.write("\n")
-
- rev = []
- with open(self.packetDir + "/client_wrongoutpacketsizes.txt", "w") as w:
- for name in manaplus.outMsgNameToId:
- packet = manaplus.outMsgNameToId[name]
- # for packet in manaplus.outPackets:
- if packet in hercules.inPackets and manaplus.outPackets[packet][1] != hercules.inPackets[packet][0]:
- packet1 = manaplus.outPackets[packet]
- packet2 = hercules.inPackets[packet]
- if packet2[0] != 0:
- rev.append("{0:4} {1:33} {2:35} {3:4} vs {4:4}".format(
- packet,
- packet1[0],
- packet2[1],
- packet1[1],
- packet2[0]))
- rev.sort()
-
- for data in rev:
- w.write(data)
- w.write("\n")
-
- rev = []
- with open(self.packetDir + "/client_badpackets.txt", "w") as w:
- for name in manaplus.outMsgNameToId:
- packet = manaplus.outMsgNameToId[name]
- # for packet in manaplus.outPackets:
- if packet in hercules.inPackets:
- packet1 = manaplus.outPackets[packet]
- packet2 = hercules.inPackets[packet]
- if packet1[2] in hercules.functionToId:
- data = hercules.functionToId[packet1[2]]
- data2 = hercules.functionToId[packet2[1]]
- if data2 == packet:
- if packet1[2] != packet2[1]:
- rev.append("{0:4} {1:33} client: {2:35} server: {3:35} Change id to {4}".format(packet,
- packet1[0],
- packet1[2],
- packet2[1],
- data))
- else:
- # here hidden or previous packet
- pass
- else:
- data = "unknown"
- if packet1[2] != packet2[1]:
- rev.append("{0:4} {1:33} client: {2:35} server: {3:35} Change id to {4}".format(packet,
- packet1[0],
- packet1[2],
- packet2[1],
- data))
-
- rev.sort()
-
- for data in rev:
- w.write(data)
- w.write("\n")
-
- rev = []
- with open(self.packetDir + "/client_preferredpackets.txt", "w") as w:
- with open(self.packetDir + "/client_badpackets.txt", "a+") as w2:
- for name in manaplus.outMsgNameToId:
- packet = manaplus.outMsgNameToId[name]
- if packet in hercules.inPackets:
- packet1 = manaplus.outPackets[packet]
- packet2 = hercules.inPackets[packet]
- if packet1[0] != name:
- # skip if same id used for other packet already
- #print("{0}, {1}, {2}, {3}".format(name, packet, packet1, packet2))
- w2.write("{0:4} {1:33} hidden by {2}\n".format(packet,
- name,
- packet1[2]))
- continue
- if packet1[2] in hercules.functionToId:
- data = hercules.functionToId[packet1[2]]
- if packet1[2] == packet2[1] and hercules.functionToId[packet1[2]] != packet:
- rev.append("{0:4} -> {1:4} {2:33} {3}".format(packet,
- data,
- packet1[0],
- packet1[2]))
- else:
- data = "unknown"
- if packet1[2] == packet2[1] and hercules.functionToId[packet1[2]] != packet:
- rev.append("{0:4} -> {1:4} {2:33} {3}".format(packet,
- data,
- packet1[0],
- packet1[2]))
- rev.sort()
- for data in rev:
- w.write(data)
- w.write("\n")
-
- with open(self.packetDir + "/client_wronginpacketsizes.txt", "w") as w:
- for packet in hercules.getLenPackets:
- if packet in manaplus.sizes:
- if hercules.knownLenPackets[packet] != manaplus.sizes[packet]:
- w.write("{0:4} client={1:4} vs server={2:4}\n".format(
- packet,
- manaplus.sizes[packet],
- hercules.knownLenPackets[packet]))
- else:
- if packet in hercules.knownLenPackets:
- w.write("{0:4} client=missing vs server={1:4}\n".format(
- packet,
- hercules.knownLenPackets[packet]))
- else:
- w.write("{0:4} client=missing vs server=missing\n".format(
- packet))
-
- 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))
- 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):
- with open(self.packetDir + "/" + hercules.reportName + "_" + rathena.reportName + "_outpackets.txt", "w") as w:
- for packet in rathena.outPacketsSorted:
- if packet not in hercules.packetsSet:
- w.write("Exists only in rAthena: " + packet + "\n")
-
-
- def reportHerculesFork(self, hercules, fork, name):
- with open(self.packetDir + "/" + hercules.reportName + "_" + fork.reportName + "_outpackets.txt", "w") as w:
- for packet in fork.outPacketsSorted:
- if packet not in hercules.packetsSet:
- if packet in fork.getLenPackets and packet not in fork.knownLenPackets:
- w.write("Exists only in " + name + ", but missing packet size: " + packet + "\n")
- else:
- 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".format(
- packet,
- hercules.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]
- if packet in hercules.inPackets:
- if func not in fork.functionToId:
- continue
- forkPacket = fork.functionToId[func]
- if packet != forkPacket and func != "clif->pDull":
- w.write("Wrong preffered packet for function {0}: {1} vs {2}\n".format(
- func,
- packet,
- forkPacket))
- for packet in fork.inPacketsSorted:
- if packet not in hercules.inPackets:
- w.write("Exists only in " + name + ": " + packet + " " + fork.inPackets[packet][1] + "\n")
- for packet in fork.inPacketsSorted:
- if packet in hercules.inPackets:
- herculesFunction = hercules.inPackets[packet][1]
- herculesLen = hercules.inPackets[packet][0]
- forkFunction = fork.inPackets[packet][1]
- forkLen = fork.inPackets[packet][0]
- if herculesFunction != forkFunction:
- if hercules.functionToId[herculesFunction] == packet or fork.functionToId[forkFunction] == packet:
- w.write("Wrong function name for packet {0}: {1} vs {2}\n".format(
- packet,
- herculesFunction,
- forkFunction))
- elif herculesLen != forkLen:
- w.write("Different packet size for packet {0} {1}: {2} vs {3}\n".format(
- packet,
- herculesFunction,
- herculesLen,
- forkLen))
-
-
- 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")
-
-
- 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 and packet not in hercules.outPacketsSorted:
- 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")
- with open(self.packetDir + "/" + tables.dirName + "_" + hercules.reportName + "_outpackets.txt", "w") as w:
- fail = False
- for packet in hercules.outPacketsSorted:
- if packet not in tables.inPackets:
- fail = True
- 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.inMapPacketsSorted:
- if packet in peek.inPackets:
- peekFunction = peek.inPackets[packet][1]
- if peekFunction != "":
- herculesFunction = hercules.inMapPackets[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")
diff --git a/servergreps/hercules/src/server.py b/servergreps/hercules/src/server.py
deleted file mode 100755
index 614feb5..0000000
--- a/servergreps/hercules/src/server.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-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/tables.py b/servergreps/hercules/src/tables.py
deleted file mode 100755
index 4f265a2..0000000
--- a/servergreps/hercules/src/tables.py
+++ /dev/null
@@ -1,61 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import re
-import os
-
-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()
diff --git a/servergreps/hercules/src/threeceam.py b/servergreps/hercules/src/threeceam.py
deleted file mode 100755
index 322233b..0000000
--- a/servergreps/hercules/src/threeceam.py
+++ /dev/null
@@ -1,184 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import os
-import re
-
-from src.packetdb import PacketDb
-from src.preproc import PreProc
-from src.utils import Utils
-
-filt = re.compile(".+[.](c|h)", re.IGNORECASE)
-
-class Threeceam:
- namedPackets = dict()
- packetsSet = set()
- outPacketsSorted = []
- inPacketsSorted = []
- inPackets = dict()
- functionToId = dict()
- loginPacketNameToId = dict()
- getLenPackets = set()
- knownLenPackets = dict()
-
- namedPacketre = re.compile(
- "((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<value>[0-9a-fA-F]+)")
- outPacketLoginre = re.compile(
- "([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
- serverpacketLoginOutre = re.compile("packet_id([ ]*)=([ ]*)(?P<name>[\w_]+);")
- clientpacketre = re.compile(
- "(\t*)packet[(]0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+)" +
- ",(?P<function>[0-9a-zA-Z_>-]+)(,|[)])")
- lclifPacketre = re.compile(
- "([ ]*)[{][ ]PACKET_ID_CA_(?P<name>[A-Z0-9_]+),([^,]+)," +
- "([ ]*)[&](?P<function>[0-9a-zA-Z_>-]+)([ ]*)[}],")
- packetLenre = re.compile(
- "packet_db[\\[]0[\\]][\\[]0x(?P<packet>[0-9a-fA-F]+)[\\]].len")
-
- def collectNamedPackets(self, fileName):
- with open(fileName, "r") as f:
- for line in f:
- m = self.namedPacketre.search(line)
- if m is not None:
- if m.group("name") not in self.namedPackets:
- self.namedPackets[m.group("name")] = []
- data = m.group("value").lower()
- while len(data) < 4:
- data = "0" + data
- self.namedPackets[m.group("name")].append(data)
-
-
- 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:
- for val in self.namedPackets[data]:
- if int(val, 16) > 4096:
- return
- self.packetsSet.add(val)
- else:
- if len(data) > 2 and data[:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- try:
- if int(data, 16) > 4096:
- return
- except:
- pass
- self.packetsSet.add(data.lower())
-
-
- def collectOutPackets(self, parentDir):
- files = os.listdir(parentDir)
- for file1 in files:
- if file1[0] == ".":
- continue
- file2 = os.path.abspath(parentDir + os.path.sep + file1)
- if not os.path.isfile(file2):
- if file2.find("/src/evol") <= 0:
- self.collectOutPackets(file2)
- elif filt.search(file1):
- with open(file2, "r") as f:
- for line in f:
- Utils.getOutPackets(line, self)
- m = self.outPacketLoginre.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[4]
- while len(data) < 4:
- data = "0" + data
- self.loginPacketNameToId["PACKET_ID_" + str[1]] = data
- m = self.serverpacketLoginOutre.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] in self.loginPacketNameToId:
- 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:
- self.outPacketsSorted.append(packet)
- self.outPacketsSorted.sort()
-
-
- def collectInPackets(self, packetsH, lclifPackets):
- 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")), m.group("function"))
- self.functionToId[m.group("function")] = data
- with open(lclifPackets, "r") as f:
- for line in f:
- m = self.lclifPacketre.search(line)
- if m is not None:
- name = "PACKET_ID_CA_" + m.group("name")
- if name not in self.loginPacketNameToId:
- print "Wrong login packet name: " + name
- continue
- data = self.loginPacketNameToId[name]
- self.inPackets[data] = (0, m.group("function"))
- self.functionToId[m.group("function")] = data
-
-
- def collectCharInPackets(self, charFilePackets):
- for packets in Utils.enumCasePackets(charFilePackets, "int char_parse_char(int fd)"):
- self.inPackets[packets[1]] = (0, packets[0])
- self.functionToId[packets[0]] = packets[1]
-
-
- def sortInPackets(self):
- for packet in self.inPackets:
- self.inPacketsSorted.append(packet)
- self.inPacketsSorted.sort()
-
-
- def processPackets(self, codeDir, packetDir, packetVersion):
-# namedPacketsPath = packetDir + "/src/" + self.dirName + "/packets_struct.h"
- srcPath = packetDir + "/src/" + 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)
- PacketDb.getInPackets(packetsDbPath, packetVersion, self)
-# self.collectCharInPackets(serverCharPackets);
- self.sortInPackets()
- self.sortOutPackets()
-
-
- def prepareTempFiles(self, codeDir, packetDir, packetVersion):
- proc = PreProc()
- proc.init(packetDir + "/src/" + self.dirName)
- proc.defines = "-DPACKETVER=" + packetVersion + " -D_SOCKET_H_ -DWFIFOW\\(fd,pos\\)=WFIFOW\\(fd,pos\\) -DWBUFW\\(p,pos\\)=WBUFW\\(p,pos\\)"
- proc.includes = "-I../links/" + codeDir + "/src -I../links/" + codeDir + "/3rdparty"
- proc.inDir = "../links/" + codeDir + "/src/"
- proc.outDir = packetDir + "/src/" + self.dirName + "/"
- proc.run("char", "char.c");
- proc.run("char_sql", "char.c");
- proc.run("login", "login.c");
- proc.run("map", "clif.c");
diff --git a/servergreps/hercules/src/utils.py b/servergreps/hercules/src/utils.py
deleted file mode 100755
index f502b67..0000000
--- a/servergreps/hercules/src/utils.py
+++ /dev/null
@@ -1,129 +0,0 @@
-#! /usr/bin/env python2
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2015-2016 Evol Online
-# Author: Andrei Karas (4144)
-
-import re
-
-class Utils:
- casere = re.compile("^case 0x(?P<packet>[0-9a-fA-F]+)[:]")
- charParseFunctionre = re.compile(
- "(?P<function>chr->[0-9a-zA-Z_>-]+)([(]|[ ][(])");
- ourPacketre = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+)([ ]*)[;]")
- ourPacketre2 = re.compile("PacketType([ ]*)=([ ]*)(?P<name>[\w_]+);")
- ourPacketre3 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
- ourPacketre4 = re.compile(" cmd([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+)(;|,)")
- ourPacketre5 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(count[*]p_len)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
- ourPacketre6 = re.compile("int cmde([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre7 = re.compile(" (packet|packet_num|PacketType|packet_type|header)([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre8 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)([a-zA-Z]+)[?]0x(?P<packet1>[0-9a-fA-F]+)([ ]*)[:]([ ]*)0x(?P<packet2>[0-9a-fA-F]+)([ ]*)[;]")
-
- @staticmethod
- def enumCasePackets(fileName, startCode):
- startCode = startCode + "\n"
- endCode = "}\n"
- breakCode = "break;"
- with open(fileName, "r") as f:
- for line in f:
- if line == startCode:
- packets = []
- for line in f:
- line = line.strip()
- m = Utils.casere.search(line)
- if m is not None:
- data = m.group("packet").lower()
- while len(data) < 4:
- data = "0" + data
- if int(data, 16) < 4096:
- packets.append(data)
- if line == breakCode:
- packets = []
- if line == endCode:
- break
- if len(packets) > 0:
- m = Utils.charParseFunctionre.search(line)
- if m is not None:
- func = m.group("function")
- if len(packets) > 1:
- for packet in packets:
- fname = func + "_" + str(packet)
- yield (fname, packet)
- else:
- yield (func, packets[0])
- break
-
-
- @staticmethod
- def getOutPackets(line, server):
- m = Utils.ourPacketre4.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[2]
- while len(data) < 4:
- data = "0" + data
- server.addServerPacket(data)
- m = Utils.ourPacketre5.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[9]
- while len(data) < 4:
- data = "0" + data
- server.addServerPacket(data)
- m = Utils.ourPacketre.findall(line)
- if len(m) == 0:
- m = Utils.ourPacketre3.findall(line)
- if len(m) > 0:
- for str in m:
- if str[9] == "0":
- continue
- data = str[9]
- if data == "cmd":
- continue
- while len(data) < 4:
- data = "0" + data
- server.addServerPacket(data)
- m = Utils.ourPacketre2.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] == "0":
- continue
- data = str[2]
- if len(data) > 2 and data[0:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- server.addServerPacket(data)
- m = Utils.ourPacketre6.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[2]
- while len(data) < 4:
- data = "0" + data
- server.addServerPacket(data)
- m = Utils.ourPacketre7.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[3]
- while len(data) < 4:
- data = "0" + data
- server.addServerPacket(data)
- m = Utils.ourPacketre8.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[10]
- while len(data) < 4:
- data = "0" + data
- server.addServerPacket(data)
- data = str[13]
- while len(data) < 4:
- data = "0" + data
- server.addServerPacket(data)