summaryrefslogtreecommitdiff
path: root/servergreps
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-03-10 16:06:26 +0300
committerAndrei Karas <akaras@inbox.ru>2015-03-18 14:17:06 +0300
commit4f4519e9dd7d838492e813deeefe75cc414113e6 (patch)
tree93f2134a02d52b67d58d41397bc0e2bb2d345404 /servergreps
parentbadb3c6dc95182c663e15d80d7d95d709cd29480 (diff)
downloadtools-4f4519e9dd7d838492e813deeefe75cc414113e6.tar.gz
tools-4f4519e9dd7d838492e813deeefe75cc414113e6.tar.bz2
tools-4f4519e9dd7d838492e813deeefe75cc414113e6.tar.xz
tools-4f4519e9dd7d838492e813deeefe75cc414113e6.zip
add tool for collecting unimplimented packets in ManaPlus.
Diffstat (limited to 'servergreps')
-rwxr-xr-xservergreps/packets.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/servergreps/packets.py b/servergreps/packets.py
new file mode 100755
index 0000000..9aba513
--- /dev/null
+++ b/servergreps/packets.py
@@ -0,0 +1,67 @@
+#! /usr/bin/env python2.7
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2015 Evol Online
+# Author: Andrei Karas (4144)
+
+import os
+import re
+
+filt = re.compile(".+[.]c", re.IGNORECASE)
+serverpacketre = re.compile("(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)"
+ + "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+)([ ]*)[;]")
+protocolre = re.compile("#define[ ](?P<name>[A-Z0-9_]+)([ ]*)0x(?P<packet>[0-9a-fA-F]+)")
+
+packetsSet = set()
+packets = []
+clientPackets = dict()
+
+def collectServerPackets(parentDir):
+ global itemNamesByName
+ 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):
+ collectServerPackets(file2)
+ elif filt.search(file1):
+ with open(file2, "r") as f:
+ for line in f:
+ m = serverpacketre.findall(line)
+ if len(m) > 0:
+ for str in m:
+ data = str[9]
+ while len(data) < 4:
+ data = "0" + data
+ packetsSet.add(data.lower())
+
+def sortServerPackets():
+ for packet in packetsSet:
+ packets.append(packet)
+ packets.sort()
+
+def collectManaPlusPackets(fileName):
+ with open(fileName, "r") as f:
+ for line in f:
+ m = protocolre.search(line)
+ if m is not None:
+ clientPackets[m.group("packet")] = m.group("name")
+
+def printPackets():
+ for packet in packets:
+ data = packet
+ while data[0] == "0":
+ data = data[1:]
+ if packet in clientPackets:
+ print data + " client name: " + clientPackets[packet]
+ else:
+ print data
+
+srcPath = "../../server-code/src/"
+protocolPath = "../../manaplus/src/net/eathena/protocol.h"
+
+collectServerPackets(srcPath)
+collectManaPlusPackets(protocolPath)
+sortServerPackets()
+printPackets()