summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2022-10-24 10:06:10 -0300
committerJesusaves <cpntb1@ymail.com>2022-10-24 10:06:10 -0300
commit58b34f91d7013c3cc3652aa1dff3ce1c8d7260b0 (patch)
treeb3c3753bc313ab802dfbf08c2a99b50bf21866c2
parentd3c5180d9ebaceb35be9f7622c805368629dcf6a (diff)
downloadtools-58b34f91d7013c3cc3652aa1dff3ce1c8d7260b0.tar.gz
tools-58b34f91d7013c3cc3652aa1dff3ce1c8d7260b0.tar.bz2
tools-58b34f91d7013c3cc3652aa1dff3ce1c8d7260b0.tar.xz
tools-58b34f91d7013c3cc3652aa1dff3ce1c8d7260b0.zip
Initial version of clientdata merger
-rwxr-xr-xmerge-client.py115
1 files changed, 115 insertions, 0 deletions
diff --git a/merge-client.py b/merge-client.py
new file mode 100755
index 0000000..988fc40
--- /dev/null
+++ b/merge-client.py
@@ -0,0 +1,115 @@
+#!/usr/bin/python3
+# This consolidates client XMLs
+import os, traceback
+
+MYSELF="clientdata/"
+EVOLVED="../pre-renewal/client-data/"
+MOUBOO="../client-data/"
+REVOLT="../evol/client-data/"
+
+# items.xml and their sprites in graphics/
+# Remember to regenerate weapons.xml after merging
+
+os.chdir("..")
+item_db=[]
+
+def fix_id(l, offset):
+ if "id=" in l:
+ tmp=l.split("\"")
+ try:
+ if (int(tmp[1]) > 0):
+ tmp[1]=str(int(tmp[1]) + offset)
+ except:
+ traceback.print_exc()
+ l="\"".join(tmp)
+ return l
+
+## Moubootaur Legends is a raw copy
+with open("%s/items.xml" % MOUBOO, "r") as f:
+ for l in f:
+ ## FIXME: RACESPRITE
+ #l=l.replace(" ", "\t")
+ ## Add headers
+ if "Authors:" in l:
+ item_db.append("<!-- This file is generated automatically. -->\n")
+ item_db.append("<!-- Please do not edit it directly. -->\n")
+ item_db.append("<!-- ************************************************************************ -->\n")
+ ## TODO: Follow includes instead of saving them
+ if "<include" in l:
+ tmp=l.split("\"")
+ if not "name" in tmp[0]:
+ print("\033[31mIllegal include: %s" % l)
+ continue
+ with open("%s/%s" % (MOUBOO, tmp[1]), "r") as k:
+ save=False
+ for j in k:
+ if not save:
+ if "<items>" in j:
+ save=True
+ continue
+ if "</items>" in j:
+ break
+ item_db.append(j)
+ continue
+
+ ## Save the line
+ item_db.append(l)
+ while not "</items>" in item_db[-1]:
+ item_db=item_db[:-1]
+item_db=item_db[:-1]
+print("\033[32;1mMoubootaur Legends OK\033[0m")
+
+
+
+
+## Legacy/Evolved has an offset of 10k
+with open("%s/items.xml" % EVOLVED, "r") as f:
+ saving=False
+ for l in f:
+ ## FIXME: RACESPRITE
+ #l=l.replace(" ", "\t")
+ ## Fix ID offset
+ l=fix_id(l, 10000)
+ ## TODO: Follow includes instead of saving them
+ if "<include" in l:
+ tmp=l.split("\"")
+ if not "name" in tmp[0]:
+ print("\033[31mIllegal include: %s" % l)
+ continue
+ with open("%s/%s" % (EVOLVED, tmp[1]), "r") as k:
+ save=False
+ for j in k:
+ if not save:
+ if "<items>" in j:
+ save=True
+ continue
+ if "</items>" in j:
+ break
+ j=fix_id(j, 10000)
+ item_db.append(j)
+ continue
+
+ ## Save the line
+ if not saving:
+ if "<items>" in l:
+ saving=True
+ continue
+ item_db.append(l)
+ while not "</items>" in item_db[-1]:
+ item_db=item_db[:-1]
+#item_db=item_db[:-1]
+print("\033[32;1mLegacy/Evolved OK\033[0m")
+
+
+
+
+
+## Save the final item database
+with open(MYSELF+"items.xml", "w") as f:
+ for l in item_db:
+ f.write(l)
+
+print("\033[33;1mSaved! Databases merged!\033[0m")
+
+## TODO: Sync files
+