update Archipelago
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
"""Friendly reminder that if you want to host this somewhere on the internet, that it's licensed under MIT Berserker66
|
||||
So unless you're Berserker you need to include license information."""
|
||||
|
||||
import os
|
||||
import uuid
|
||||
import base64
|
||||
@@ -38,9 +35,9 @@ app.config["JOB_THRESHOLD"] = 2
|
||||
app.config['SESSION_PERMANENT'] = True
|
||||
|
||||
# waitress uses one thread for I/O, these are for processing of views that then get sent
|
||||
# berserkermulti.world uses gunicorn + nginx; ignoring this option
|
||||
# archipelago.gg uses gunicorn + nginx; ignoring this option
|
||||
app.config["WAITRESS_THREADS"] = 10
|
||||
# a default that just works. berserkermulti.world runs on mariadb
|
||||
# a default that just works. archipelago.gg runs on mariadb
|
||||
app.config["PONY"] = {
|
||||
'provider': 'sqlite',
|
||||
'filename': os.path.abspath('db.db3'),
|
||||
@@ -51,7 +48,6 @@ app.config["CACHE_TYPE"] = "simple"
|
||||
app.config["JSON_AS_ASCII"] = False
|
||||
|
||||
app.autoversion = True
|
||||
app.config["HOSTNAME"] = "berserkermulti.world"
|
||||
|
||||
av = Autoversion(app)
|
||||
cache = Cache(app)
|
||||
|
||||
@@ -8,7 +8,6 @@ import time
|
||||
|
||||
from pony.orm import db_session, select, commit
|
||||
|
||||
from Utils import restricted_loads
|
||||
|
||||
class CommonLocker():
|
||||
"""Uses a file lock to signal that something is already running"""
|
||||
@@ -78,10 +77,10 @@ def handle_generation_failure(result: BaseException):
|
||||
|
||||
|
||||
def launch_generator(pool: multiprocessing.pool.Pool, generation: Generation):
|
||||
options = restricted_loads(generation.options)
|
||||
options = generation.options
|
||||
logging.info(f"Generating {generation.id} for {len(options)} players")
|
||||
|
||||
meta = restricted_loads(generation.meta)
|
||||
meta = generation.meta
|
||||
pool.apply_async(gen_game, (options,),
|
||||
{"race": meta["race"], "sid": generation.id, "owner": generation.owner},
|
||||
handle_generation_success, handle_generation_failure)
|
||||
|
||||
@@ -15,7 +15,7 @@ import zlib
|
||||
from .models import *
|
||||
|
||||
from MultiServer import Context, server, auto_shutdown, ServerCommandProcessor, ClientMessageProcessor
|
||||
from Utils import get_public_ipv4, get_public_ipv6, restricted_loads
|
||||
from Utils import get_public_ipv4, get_public_ipv6, parse_yaml
|
||||
|
||||
|
||||
class CustomClientMessageProcessor(ClientMessageProcessor):
|
||||
@@ -75,7 +75,7 @@ class WebHostContext(Context):
|
||||
else:
|
||||
self.port = get_random_port()
|
||||
|
||||
return self._load(restricted_loads(zlib.decompress(room.seed.multidata)), True)
|
||||
return self._load(self._decompress(room.seed.multidata), True)
|
||||
|
||||
@db_session
|
||||
def init_save(self, enabled: bool = True):
|
||||
|
||||
@@ -155,4 +155,4 @@ def upload_to_db(folder, owner, sid, race:bool):
|
||||
gen.delete()
|
||||
return seed.id
|
||||
else:
|
||||
raise Exception("Multidata required, but not found.")
|
||||
raise Exception("Multidata required (.archipelago), but not found.")
|
||||
|
||||
@@ -51,6 +51,6 @@ class Command(db.Entity):
|
||||
class Generation(db.Entity):
|
||||
id = PrimaryKey(UUID, default=uuid4)
|
||||
owner = Required(UUID)
|
||||
options = Required(bytes, lazy=True) # these didn't work as JSON on mariaDB, so they're getting pickled now
|
||||
meta = Required(bytes, lazy=True) # if state is -1 (error) this will contain an utf-8 encoded error message
|
||||
options = Required(Json, lazy=True)
|
||||
meta = Required(Json, lazy=True)
|
||||
state = Required(int, default=0, index=True)
|
||||
|
||||
@@ -10,7 +10,7 @@ from WebHostLib import app, Seed, Room, Patch
|
||||
|
||||
accepted_zip_contents = {"patches": ".apbp",
|
||||
"spoiler": ".txt",
|
||||
"multidata": "multidata"}
|
||||
"multidata": ".archipelago"}
|
||||
|
||||
banned_zip_contents = (".sfc",)
|
||||
|
||||
@@ -43,7 +43,7 @@ def uploads():
|
||||
patches.add(Patch(data=zfile.open(file, "r").read(), player=player))
|
||||
elif file.filename.endswith(".txt"):
|
||||
spoiler = zfile.open(file, "r").read().decode("utf-8-sig")
|
||||
elif file.filename.endswith("multidata"):
|
||||
elif file.filename.endswith(".archipelago"):
|
||||
try:
|
||||
multidata = json.loads(zlib.decompress(zfile.open(file).read()).decode("utf-8-sig"))
|
||||
except:
|
||||
@@ -80,4 +80,4 @@ def user_content():
|
||||
|
||||
|
||||
def allowed_file(filename):
|
||||
return filename.endswith(('multidata', ".zip"))
|
||||
return filename.endswith(('.archipelago', ".zip"))
|
||||
|
||||
Reference in New Issue
Block a user