#!/usr/bin/python3 # This consolidates client XMLs import os, shutil, traceback, subprocess, time 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=[] paths=[] 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 def hp(l): global paths if "\n") item_db.append("\n") item_db.append("\n") ## Follow includes instead of saving them if "" in j: save=True continue if "" in j: break hp(j) item_db.append(j) continue ## Save the line hp(l) item_db.append(l) while not "" in item_db[-1]: item_db=item_db[:-1] item_db=item_db[:-1] print("\033[32;1mMoubootaur Legends OK\033[0m") ## Handle copy pastes unify(MOUBOO) ################################################################################ ## 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) ## Follow includes instead of saving them if "" in j: save=True continue if "" in j: break j=fix_id(j, 10000) item_db.append(j) hp(j) continue ## Save the line if not saving: if "" in l: saving=True continue item_db.append(l) hp(l) while not "" in item_db[-1]: item_db=item_db[:-1] item_db=item_db[:-1] print("\033[32;1mLegacy/Evolved OK\033[0m") ## Handle copy pastes unify(EVOLVED) ################################################################################ ## rEvolt has an offset of 20k with open("%s/items.xml" % REVOLT, "r") as f: saving=False for l in f: ## FIXME: RACESPRITE #l=l.replace(" ", "\t") ## Fix ID offset l=fix_id(l, 10000) ## Follow includes instead of saving them if "" in j: save=True continue if "" in j: break j=fix_id(j, 10000) item_db.append(j) hp(j) continue ## Save the line if not saving: if "" in l: saving=True continue item_db.append(l) hp(l) while not "" in item_db[-1]: item_db=item_db[:-1] #item_db=item_db[:-1] print("\033[32;1mrEvolt OK\033[0m") ## Handle copy pastes unify(REVOLT) ################################################################################ ## 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") ## Clean empty dirs time.sleep(1) print("Now deleting empty folders:") time.sleep(4) os.chdir(MYSELF) subprocess.call("""find . -type d -empty -not -iwholename "./.*" -print -delete""", shell=True)