Fix merge conflict. Very minor difference.
This commit is contained in:
@@ -76,7 +76,7 @@ class WebHostContext(Context):
|
||||
else:
|
||||
self.port = get_random_port()
|
||||
|
||||
return self._load(self._decompress(room.seed.multidata), True)
|
||||
return self._load(self.decompress(room.seed.multidata), True)
|
||||
|
||||
@db_session
|
||||
def init_save(self, enabled: bool = True):
|
||||
|
||||
@@ -37,8 +37,6 @@ def create():
|
||||
}
|
||||
|
||||
for game_name, world in AutoWorldRegister.world_types.items():
|
||||
if (world.hidden):
|
||||
continue
|
||||
|
||||
all_options = {**world.options, **Options.per_game_common_options}
|
||||
res = Template(open(os.path.join("WebHostLib", "templates", "options.yaml")).read()).render(
|
||||
@@ -99,13 +97,14 @@ def create():
|
||||
os.makedirs(os.path.join(target_folder, 'player-settings'), exist_ok=True)
|
||||
|
||||
with open(os.path.join(target_folder, 'player-settings', game_name + ".json"), "w") as f:
|
||||
f.write(json.dumps(player_settings, indent=2, separators=(',', ': ')))
|
||||
json.dump(player_settings, f, indent=2, separators=(',', ': '))
|
||||
|
||||
weighted_settings["baseOptions"]["game"][game_name] = 0
|
||||
weighted_settings["games"][game_name] = {}
|
||||
weighted_settings["games"][game_name]["gameSettings"] = game_options
|
||||
weighted_settings["games"][game_name]["gameItems"] = tuple(world.item_name_to_id.keys())
|
||||
weighted_settings["games"][game_name]["gameLocations"] = tuple(world.location_name_to_id.keys())
|
||||
if not world.hidden:
|
||||
weighted_settings["baseOptions"]["game"][game_name] = 0
|
||||
weighted_settings["games"][game_name] = {}
|
||||
weighted_settings["games"][game_name]["gameSettings"] = game_options
|
||||
weighted_settings["games"][game_name]["gameItems"] = tuple(world.item_names)
|
||||
weighted_settings["games"][game_name]["gameLocations"] = tuple(world.location_names)
|
||||
|
||||
with open(os.path.join(target_folder, 'weighted-settings.json'), "w") as f:
|
||||
f.write(json.dumps(weighted_settings, indent=2, separators=(',', ': ')))
|
||||
json.dump(weighted_settings, f, indent=2, separators=(',', ': '))
|
||||
|
||||
@@ -252,7 +252,7 @@ def get_static_room_data(room: Room):
|
||||
result = _multidata_cache.get(room.seed.id, None)
|
||||
if result:
|
||||
return result
|
||||
multidata = Context._decompress(room.seed.multidata)
|
||||
multidata = Context.decompress(room.seed.multidata)
|
||||
# in > 100 players this can take a bit of time and is the main reason for the cache
|
||||
locations: Dict[int, Dict[int, Tuple[int, int]]] = multidata['locations']
|
||||
names: Dict[int, Dict[int, str]] = multidata["names"]
|
||||
|
||||
@@ -67,7 +67,7 @@ def upload_zip_to_db(zfile: zipfile.ZipFile, owner=None, meta={"race": False}, s
|
||||
multidata = None
|
||||
|
||||
if multidata:
|
||||
decompressed_multidata = MultiServer.Context._decompress(multidata)
|
||||
decompressed_multidata = MultiServer.Context.decompress(multidata)
|
||||
player_names = {slot.player_name for slot in slots}
|
||||
leftover_names = [(name, index) for index, name in
|
||||
enumerate((name for name in decompressed_multidata["names"][0]), start=1)]
|
||||
@@ -100,7 +100,7 @@ def uploads():
|
||||
if file.filename == '':
|
||||
flash('No selected file')
|
||||
elif file and allowed_file(file.filename):
|
||||
if file.filename.endswith(".zip"):
|
||||
if zipfile.is_zipfile(file.filename):
|
||||
with zipfile.ZipFile(file, 'r') as zfile:
|
||||
res = upload_zip_to_db(zfile)
|
||||
if type(res) == str:
|
||||
@@ -108,12 +108,12 @@ def uploads():
|
||||
elif res:
|
||||
return redirect(url_for("view_seed", seed=res.id))
|
||||
else:
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
multidata = file.read()
|
||||
MultiServer.Context._decompress(multidata)
|
||||
MultiServer.Context.decompress(multidata)
|
||||
except:
|
||||
flash("Could not load multidata. File may be corrupted or incompatible.")
|
||||
raise
|
||||
else:
|
||||
seed = Seed(multidata=multidata, owner=session["_id"])
|
||||
flush() # place into DB and generate ids
|
||||
|
||||
Reference in New Issue
Block a user