summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2019-03-17 15:30:43 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2019-03-25 09:33:18 +0200
commit662d78b9a5bebdb98dc178ebd1f8e3384793c104 (patch)
treeea02633b41bd08957d3490d40553d389b1e78a36 /tools
Initial commitHEADmaster
Diffstat (limited to 'tools')
-rw-r--r--tools/find-client-packets.bash31
-rw-r--r--tools/vbatch2c.py36
2 files changed, 67 insertions, 0 deletions
diff --git a/tools/find-client-packets.bash b/tools/find-client-packets.bash
new file mode 100644
index 0000000..34882c8
--- /dev/null
+++ b/tools/find-client-packets.bash
@@ -0,0 +1,31 @@
+#!/bin/bash
+# Crawl soulworker for packet ids
+
+base=0x401200
+grep -obUaP '(send_)?(eSUB_)?CMD_.*?\x00' "$@" | while IFS=':' read -r off name; do
+ name="${name/*CMD/PACKET}"
+ name="$(awk '{print $1}' <<<"$name")"
+ off=$(rax2 -e "$off+$base")
+ off=${off//0x/}
+ while [[ "${#off}" -lt 8 ]]; do off="0$off"; done
+ rafind2 -nx "68$off" "$@" | while read -r off; do
+ off=$(rax2 "$off")
+ head -c $off "$@" | LC_ALL=C tac -rs $'.' | grep -obUaP -m1 '.\x6a.\x6a' | while IFS=':' read -r off2 nul; do
+ lo=$(xxd -s $((off-off2-3)) -l 1 -g 1 -ps "$@")
+ hi=$(xxd -s $((off-off2-1)) -l 1 -g 1 -ps "$@")
+ if [[ "$lo$hi" == '0001' ]] || [[ "$lo$hi" == '0000' ]]; then
+ break
+ fi
+ [[ "$name" == "PACKET_SHOP_CASH_GIFT" ]] && lo=25
+ [[ "$name" == "PACKET_ITEM_RESTORE" ]] && lo=22
+ [[ "$name" == "PACKET_ITEM_UNSEAL" ]] && lo=24
+ [[ "$name" == "PACKET_ITEM_USE_EFFECT" ]] && lo=26
+ [[ "$name" == "PACKET_ITEM_APPEARANCE_EQUIP" ]] && lo=52
+ [[ "$name" == "PACKET_LEAGUE_DELEGATE" ]] && lo=0a
+ [[ "$name" == "PACKET_HELPER_SUPPORT_INFO" ]] && lo=05
+ printf "%s = 0x%s%s,\n" "$name" "$lo" "$hi"
+ break
+ done
+ break
+ done
+done
diff --git a/tools/vbatch2c.py b/tools/vbatch2c.py
new file mode 100644
index 0000000..fdfbf92
--- /dev/null
+++ b/tools/vbatch2c.py
@@ -0,0 +1,36 @@
+import sys, os, operator, xml.etree.ElementTree
+
+zones = []
+d = os.fsencode(sys.argv[1])
+for f in os.listdir(d):
+ fname = os.fsdecode(f)
+ if not fname.endswith('.vbatch'):
+ continue
+
+ e = xml.etree.ElementTree.parse(fname).getroot()
+ s = e.find('Batchs').find('VStartEventBox')
+ if s:
+ name = os.path.splitext(fname)[0]
+ name = name if name.endswith('TUTORIAL') or name.endswith('GOLDENCITADEL') or name.endswith('STEELGRAVE') else name.split('_', 1)[-1]
+ zone = {
+ 'id': s.find('m_ID').get('value')[0:5],
+ 'name': name,
+ 'tl': s.find('m_vPosTopLeft').get('value'),
+ 'br': s.find('m_vPosBottomRight').get('value')
+ }
+ zones.append(zone)
+
+zones = sorted(zones, key=operator.itemgetter('name'))
+
+print('#pragma once\n')
+
+print('''static const struct {
+ float box[2][3];
+ const char *name;
+ uint32_t id;
+} ZONES[] = {''')
+
+for z in zones:
+ print(' {{ .id = {}, .name = "{}", .box = {{ {{ {} }}, {{ {} }} }} }},'.format(z['id'], z['name'], z['tl'], z['br']))
+
+print('};\n')