WebHost: Add game listing for all players on room info page.

This commit is contained in:
Hussein Farran
2021-12-22 20:15:56 -05:00
committed by Fabian Dill
parent 1f4ddc295a
commit 3508cf21c7
4 changed files with 76 additions and 17 deletions

View File

@@ -62,12 +62,19 @@ def upload_zip_to_db(zfile: zipfile.ZipFile, owner=None, meta={"race": False}, s
elif file.filename.endswith(".archipelago"):
try:
multidata = zfile.open(file).read()
MultiServer.Context._decompress(multidata)
except:
flash("Could not load multidata. File may be corrupted or incompatible.")
multidata = None
if multidata:
decompressed_multidata = MultiServer.Context._decompress(multidata)
leftover_names = [(name, decompressed_multidata["names"][0].index(name) + 1) for name in
decompressed_multidata["names"][0] if name not in [slot.player_name for slot in slots]]
newslots = [(Slot(data=None, player_name=name, player_id=slot, game=decompressed_multidata["games"][slot]))
for name, slot in leftover_names]
for slot in newslots:
slots.add(slot)
flush() # commit slots
seed = Seed(multidata=multidata, spoiler=spoiler, slots=slots, owner=owner, meta=json.dumps(meta),
id=sid if sid else uuid.uuid4())