From 828612bded76490af42b27e8c9f7d56186957884 Mon Sep 17 00:00:00 2001 From: Telokis <6382729+Telokis@users.noreply.github.com> Date: Wed, 2 Oct 2024 00:07:08 +0200 Subject: [PATCH] WIP --- api.py | 5 +++-- docker-compose.yml | 5 ++++- main.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/api.py b/api.py index d41298d5..8cd70373 100644 --- a/api.py +++ b/api.py @@ -1497,7 +1497,8 @@ def create_server_api(**args): actual_ip=ip=request.remote_addr; server_name="XX" if is_sdk: # The ip we store should be the url the client needs to use - ip = "%s"%(environment.REQUEST_IP_TO_HOSTNAME.get(ip,ip)) + # ip = "%s"%(environment.REQUEST_IP_TO_HOSTNAME.get(ip,ip)) + ip = "localhost" # If we are not running in HTTPS_MODE servers_to_client will use actual_ip instead actual_ip = ip @@ -1534,7 +1535,7 @@ def create_server_api(**args): data={} server=get_by_iid("server|%s%s"%(region,server_name)) if server: - if server.online and msince(server.last_update)<12: return jhtml(self,{"exists":True}); + # if server.online and msince(server.last_update)<12: return jhtml(self,{"exists":True}); data=server.info.data server=Server(key=ndb.Key(Server,"%s%s"%(region,server_name)),info=cGG(players=0,observers=0,total_players=0,lat=lat,lon=lon,pvp=pvp,data=data),name=server_name,region=region,version=to_str(game_version),ip=ip,actual_ip=actual_ip,port=int(port),online=True,gameplay=gameplay) server.info.auth=randomStr(20) diff --git a/docker-compose.yml b/docker-compose.yml index 4a9a23ed..b1432e59 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ version: "3.7" services: adventureland: + container_name: central-server-al image: al build: context: ./ @@ -11,6 +12,7 @@ services: volumes: - al-db:/appserver/storage/ eu1: + container_name: eu1-al image: al build: context: ./ @@ -19,10 +21,11 @@ services: - "8022:8022" volumes: - al-db:/appserver/storage/ - entrypoint: ["/adventureland/docker/game-server-entrypoint.sh", "EU", "V", "8022"] + entrypoint: ["/adventureland/docker/game-server-entrypoint.sh", "EU", "I", "8022"] depends_on: - adventureland us1: + container_name: us1-al image: al build: context: ./ diff --git a/main.py b/main.py index b4b19e85..c5ac4a4d 100644 --- a/main.py +++ b/main.py @@ -219,6 +219,53 @@ def serve_shells(): return whtml(request,"htmls/payments.html",domain=domain,user=user,server=server,extra_shells=extra_shells) + +def dump_all_maps(): + from google.appengine.ext import ndb + import json + from datetime import datetime + from google.appengine.ext.db import GeoPt + import logging + + def custom_json_serializer(obj): + """JSON serializer for objects not serializable by default json code""" + if isinstance(obj, datetime): + return obj.isoformat() + elif isinstance(obj, GeoPt): + return {'lat': obj.lat, 'lon': obj.lon} + elif isinstance(obj, ndb.Key): + return obj.id() # Use the ID of the key + elif isinstance(obj, ndb.Model): + return entity_to_dict(obj) + elif hasattr(obj, '__dict__'): + return {k: custom_json_serializer(v) for k, v in obj.__dict__.items()} + elif hasattr(obj, '__slots__'): + return {slot: custom_json_serializer(getattr(obj, slot)) for slot in obj.__slots__} + else: + logging.warning("Encountered non-serializable type: %s", type(obj)) + return str(obj) + + def entity_to_dict(entity): + result = {} + for k in entity._properties: + try: + result[k] = custom_json_serializer(getattr(entity, k)) + except Exception as e: + logging.error("Error serializing property %s of type %s: %s", + k, type(getattr(entity, k)), str(e)) + result[k] = str(getattr(entity, k)) + return result + + maps = Map.query().fetch() + map_dict = {m.key.id(): entity_to_dict(m) for m in maps} + return json.dumps(map_dict, default=custom_json_serializer) + +@app.route('/dump-all-maps') +def route_dump_all_maps(): + return dump_all_maps() + + + @app.route("/map/",methods=['GET']) #Resort Map Editor @app.route("/map//",methods=['GET']) def serve_resort_get(name="",suffix=""):