Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Telokis committed Oct 1, 2024
1 parent 9df42fd commit 828612b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
5 changes: 3 additions & 2 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: "3.7"
services:
adventureland:
container_name: central-server-al
image: al
build:
context: ./
Expand All @@ -11,6 +12,7 @@ services:
volumes:
- al-db:/appserver/storage/
eu1:
container_name: eu1-al
image: al
build:
context: ./
Expand All @@ -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: ./
Expand Down
47 changes: 47 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<name>",methods=['GET']) #Resort Map Editor
@app.route("/map/<name>/<suffix>",methods=['GET'])
def serve_resort_get(name="",suffix=""):
Expand Down

0 comments on commit 828612b

Please sign in to comment.