Undertale: Doc updates and client bug fixes. (#1996)

This commit is contained in:
Mewlif
2023-07-22 01:38:21 -04:00
committed by GitHub
parent 191dcb505c
commit 889a4f4db9
8 changed files with 53 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
from __future__ import annotations
import os
import sys
import asyncio
import typing
import bsdiff4
@@ -11,7 +12,7 @@ from NetUtils import NetworkItem, ClientStatus
from worlds import undertale
from MultiServer import mark_raw
from CommonClient import CommonContext, server_loop, \
gui_enabled, ClientCommandProcessor, get_base_parser
gui_enabled, ClientCommandProcessor, logger, get_base_parser
from Utils import async_start
@@ -105,6 +106,8 @@ class UndertaleContext(CommonContext):
self.tem_armor = False
self.completed_count = 0
self.completed_routes = {"pacifist": 0, "genocide": 0, "neutral": 0}
# self.save_game_folder: files go in this path to pass data between us and the actual game
self.save_game_folder = os.path.expandvars(r"%localappdata%/UNDERTALE")
def patch_game(self):
with open(os.getcwd() + "/Undertale/data.win", "rb") as f:
@@ -233,9 +236,11 @@ async def process_undertale_cmd(ctx: UndertaleContext, cmd: str, args: dict):
f.close()
filename = f"check.spot"
with open(os.path.join(ctx.save_game_folder, filename), "a") as f:
for ss in ctx.checked_locations:
for ss in set(args["checked_locations"]):
f.write(str(ss-12000)+"\n")
f.close()
message = [{"cmd": "LocationChecks", "locations": [79067]}]
await ctx.send_msgs(message)
elif cmd == "LocationInfo":
for l in args["locations"]:
locationid = l.location
@@ -359,7 +364,7 @@ async def process_undertale_cmd(ctx: UndertaleContext, cmd: str, args: dict):
if "checked_locations" in args:
filename = f"check.spot"
with open(os.path.join(ctx.save_game_folder, filename), "a") as f:
for ss in ctx.checked_locations:
for ss in set(args["checked_locations"]):
f.write(str(ss-12000)+"\n")
f.close()
@@ -430,7 +435,7 @@ async def game_watcher(ctx: UndertaleContext):
lines = f.readlines()
for l in lines:
if ctx.server_locations.__contains__(int(l)+12000):
sending = sending + [int(l)+12000]
sending = sending + [int(l.rstrip('\n'))+12000]
await ctx.send_msgs([{"cmd": "LocationScouts", "locations": sending,
"create_as_hint": int(2)}])
finally:
@@ -441,7 +446,7 @@ async def game_watcher(ctx: UndertaleContext):
with open(root+"/"+file, "r") as f:
lines = f.readlines()
for l in lines:
sending = sending+[(int(l))+12000]
sending = sending+[(int(l.rstrip('\n')))+12000]
message = [{"cmd": "LocationChecks", "locations": sending}]
await ctx.send_msgs(message)
finally: