From d39aa3e3f4b5b87e6bfb5b2f9d5bd7b7a42f1376 Mon Sep 17 00:00:00 2001 From: wish Date: Tue, 1 Aug 2023 20:27:03 +1000 Subject: [PATCH] add script & branch to port Events to new format --- GenerateEventSchema.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 GenerateEventSchema.py diff --git a/GenerateEventSchema.py b/GenerateEventSchema.py new file mode 100644 index 000000000..61c40dc70 --- /dev/null +++ b/GenerateEventSchema.py @@ -0,0 +1,20 @@ +import os + +d = 'bin/_events' +out = 'begin;insert into event_quests(max_players, quest_type, quest_id, mark)values' +for y, _, x in os.walk(d): + for z in x: + f = os.path.join(y, z) + if os.stat(f).st_size < 352: + continue + with open(f, 'rb') as p: + p.seek(9, 0) + max_players = int.from_bytes(p.read(1), 'big') + quest_type = int.from_bytes(p.read(1), 'big') + p.seek(14, 0) + mark = int.from_bytes(p.read(4), 'big') + p.seek(68, 0) + quest_id = int.from_bytes(p.read(2), 'big') + out += f'({max_players},{quest_type},{quest_id},{mark}),' +with open('PortedEventQuests.sql', 'w') as f: + f.write(out[:-1]+';end')