diff options
-rwxr-xr-x | merge-client.py | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/merge-client.py b/merge-client.py index 45cf149..10c8083 100755 --- a/merge-client.py +++ b/merge-client.py @@ -25,20 +25,41 @@ def fix_id(l, offset): l="\"".join(tmp) return l -def hp(l): +def hp(l, WHERE): global paths if "<include" in l: return if ".png" in l or ".ogg" in l or ".xml" in l: tmpi=l.split("\"") + if len(tmpi) == 1: + tmpi=l.split("sprite") for e in tmpi: + e=e.replace(">", "").replace("<", "") + if e.endswith("/"): + e=e[:-1] if e.endswith(".png"): paths.append(e) elif e.endswith(".ogg"): paths.append(e) elif e.endswith(".xml"): - ## TODO: We must also open the XML and extract paths from it paths.append(e) + + ## We must also open the XML and extract paths from it + + pt="NO PATH FOUND" + if os.path.exists("%s/%s" % (WHERE, e)): + pt = "%s/%s" % (WHERE, e) + elif os.path.exists("%s/graphics/sprites/%s" % (WHERE, e)): + pt = "%s/graphics/sprites/%s" % (WHERE, e) + elif os.path.exists("%s/graphics/%s" % (WHERE, e)): + pt = "%s/graphics/%s" % (WHERE, e) + + with open(pt, 'r') as j: + for k in j: + i=k.split("\"") + for n in i: + if n.endswith(".png"): + paths.append(n) return def unify(YESELF): @@ -119,12 +140,12 @@ with open("%s/items.xml" % MOUBOO, "r") as f: continue if "</items>" in j: break - hp(j) + hp(j, MOUBOO) item_db.append(j) continue ## Save the line - hp(l) + hp(l, MOUBOO) item_db.append(l) while not "</items>" in item_db[-1]: item_db=item_db[:-1] @@ -161,7 +182,7 @@ with open("%s/items.xml" % EVOLVED, "r") as f: break j=fix_id(j, 10000) item_db.append(j) - hp(j) + hp(j, EVOLVED) continue ## Save the line @@ -170,7 +191,7 @@ with open("%s/items.xml" % EVOLVED, "r") as f: saving=True continue item_db.append(l) - hp(l) + hp(l, EVOLVED) while not "</items>" in item_db[-1]: item_db=item_db[:-1] item_db=item_db[:-1] @@ -207,7 +228,7 @@ with open("%s/items.xml" % REVOLT, "r") as f: break j=fix_id(j, 10000) item_db.append(j) - hp(j) + hp(j, REVOLT) continue ## Save the line @@ -216,7 +237,7 @@ with open("%s/items.xml" % REVOLT, "r") as f: saving=True continue item_db.append(l) - hp(l) + hp(l, REVOLT) while not "</items>" in item_db[-1]: item_db=item_db[:-1] #item_db=item_db[:-1] |