summaryrefslogtreecommitdiff
path: root/servergreps/hercules/src/brathena.py
diff options
context:
space:
mode:
Diffstat (limited to 'servergreps/hercules/src/brathena.py')
-rwxr-xr-xservergreps/hercules/src/brathena.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/servergreps/hercules/src/brathena.py b/servergreps/hercules/src/brathena.py
index b93d18e..8c0e204 100755
--- a/servergreps/hercules/src/brathena.py
+++ b/servergreps/hercules/src/brathena.py
@@ -20,6 +20,8 @@ class Brathena:
inPackets = dict()
functionToId = dict()
loginPacketNameToId = dict()
+ getLenPackets = set()
+ knownLenPackets = dict()
namedPacketre = re.compile(
"((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
@@ -45,6 +47,11 @@ class Brathena:
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:
@@ -145,6 +152,15 @@ class Brathena:
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):
@@ -164,6 +180,12 @@ class Brathena:
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):
@@ -203,5 +225,5 @@ class Brathena:
proc.run("char", "pincode.c");
proc.run("login", "login.c");
proc.run("map", "clif.c");
- proc.defines = "-DPACKETVER=" + packetVersion + " -Dpacket\\(id,size,...\\)=packet\\(id,size,__VA_ARGS__\\)"
+ proc.defines = "-DPACKETVER=" + packetVersion + " -Dpacket\\(...\\)=packet\\(__VA_ARGS__\\)"
proc.run("map", "packets.h");