Skip to content

Commit 2303431

Browse files
jonloveslegosFlySniper
authored andcommitted
Undertale: Various Fixes (ArchipelagoMW#2146)
* Changed the pathing code to use os.path.join, instead of adding strings together, also fixed the savepath command using UndertaleContext instead of self.ctx (Credit to Wackerly for finding the self.ctx issue and fix) * Undertale: Fixed a debug function in the game not requiring debug to be enabled. * Undetale: Fixed a logic bug with the location "Letter Quest"
1 parent 6888726 commit 2303431

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

UndertaleClient.py

+20-20
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,40 @@ def _cmd_resync(self):
2929
def _cmd_patch(self):
3030
"""Patch the game."""
3131
if isinstance(self.ctx, UndertaleContext):
32-
os.makedirs(name=os.getcwd() + "\\Undertale", exist_ok=True)
32+
os.makedirs(name=os.path.join(os.getcwd(), "Undertale"), exist_ok=True)
3333
self.ctx.patch_game()
3434
self.output("Patched.")
3535

3636
def _cmd_savepath(self, directory: str):
3737
"""Redirect to proper save data folder. (Use before connecting!)"""
3838
if isinstance(self.ctx, UndertaleContext):
39-
UndertaleContext.save_game_folder = directory
40-
self.output("Changed to the following directory: " + directory)
39+
self.ctx.save_game_folder = directory
40+
self.output("Changed to the following directory: " + self.ctx.save_game_folder)
4141

4242
@mark_raw
4343
def _cmd_auto_patch(self, steaminstall: typing.Optional[str] = None):
4444
"""Patch the game automatically."""
4545
if isinstance(self.ctx, UndertaleContext):
46-
os.makedirs(name=os.getcwd() + "\\Undertale", exist_ok=True)
46+
os.makedirs(name=os.path.join(os.getcwd(), "Undertale"), exist_ok=True)
4747
tempInstall = steaminstall
4848
if not os.path.isfile(os.path.join(tempInstall, "data.win")):
4949
tempInstall = None
5050
if tempInstall is None:
5151
tempInstall = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Undertale"
52-
if not os.path.exists("C:\\Program Files (x86)\\Steam\\steamapps\\common\\Undertale"):
52+
if not os.path.exists(tempInstall):
5353
tempInstall = "C:\\Program Files\\Steam\\steamapps\\common\\Undertale"
5454
elif not os.path.exists(tempInstall):
5555
tempInstall = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Undertale"
56-
if not os.path.exists("C:\\Program Files (x86)\\Steam\\steamapps\\common\\Undertale"):
56+
if not os.path.exists(tempInstall):
5757
tempInstall = "C:\\Program Files\\Steam\\steamapps\\common\\Undertale"
5858
if not os.path.exists(tempInstall) or not os.path.exists(tempInstall) or not os.path.isfile(os.path.join(tempInstall, "data.win")):
5959
self.output("ERROR: Cannot find Undertale. Please rerun the command with the correct folder."
6060
" command. \"/auto_patch (Steam directory)\".")
6161
else:
6262
for file_name in os.listdir(tempInstall):
6363
if file_name != "steam_api.dll":
64-
shutil.copy(tempInstall+"\\"+file_name,
65-
os.getcwd() + "\\Undertale\\" + file_name)
64+
shutil.copy(os.path.join(tempInstall, file_name),
65+
os.path.join(os.getcwd(), "Undertale", file_name))
6666
self.ctx.patch_game()
6767
self.output("Patching successful!")
6868

@@ -111,13 +111,13 @@ def __init__(self, server_address, password):
111111
self.save_game_folder = os.path.expandvars(r"%localappdata%/UNDERTALE")
112112

113113
def patch_game(self):
114-
with open(os.getcwd() + "/Undertale/data.win", "rb") as f:
114+
with open(os.path.join(os.getcwd(), "Undertale", "data.win"), "rb") as f:
115115
patchedFile = bsdiff4.patch(f.read(), undertale.data_path("patch.bsdiff"))
116-
with open(os.getcwd() + "/Undertale/data.win", "wb") as f:
116+
with open(os.path.join(os.getcwd(), "Undertale", "data.win"), "wb") as f:
117117
f.write(patchedFile)
118-
os.makedirs(name=os.getcwd() + "\\Undertale\\" + "Custom Sprites", exist_ok=True)
119-
with open(os.path.expandvars(os.getcwd() + "\\Undertale\\" + "Custom Sprites\\" +
120-
"Which Character.txt"), "w") as f:
118+
os.makedirs(name=os.path.join(os.getcwd(), "Undertale", "Custom Sprites"), exist_ok=True)
119+
with open(os.path.expandvars(os.path.join(os.getcwd(), "Undertale", "Custom Sprites",
120+
"Which Character.txt")), "w") as f:
121121
f.writelines(["// Put the folder name of the sprites you want to play as, make sure it is the only "
122122
"line other than this one.\n", "frisk"])
123123
f.close()
@@ -385,7 +385,7 @@ async def multi_watcher(ctx: UndertaleContext):
385385
for root, dirs, files in os.walk(path):
386386
for file in files:
387387
if "spots.mine" in file and "Online" in ctx.tags:
388-
with open(root + "/" + file, "r") as mine:
388+
with open(os.path.join(root, file), "r") as mine:
389389
this_x = mine.readline()
390390
this_y = mine.readline()
391391
this_room = mine.readline()
@@ -408,7 +408,7 @@ async def game_watcher(ctx: UndertaleContext):
408408
for root, dirs, files in os.walk(path):
409409
for file in files:
410410
if ".item" in file:
411-
os.remove(root+"/"+file)
411+
os.remove(os.path.join(root, file))
412412
sync_msg = [{"cmd": "Sync"}]
413413
if ctx.locations_checked:
414414
sync_msg.append({"cmd": "LocationChecks", "locations": list(ctx.locations_checked)})
@@ -424,25 +424,25 @@ async def game_watcher(ctx: UndertaleContext):
424424
for root, dirs, files in os.walk(path):
425425
for file in files:
426426
if "DontBeMad.mad" in file:
427-
os.remove(root+"/"+file)
427+
os.remove(os.path.join(root, file))
428428
if "DeathLink" in ctx.tags:
429429
await ctx.send_death()
430430
if "scout" == file:
431431
sending = []
432432
try:
433-
with open(root+"/"+file, "r") as f:
433+
with open(os.path.join(root, file), "r") as f:
434434
lines = f.readlines()
435435
for l in lines:
436436
if ctx.server_locations.__contains__(int(l)+12000):
437437
sending = sending + [int(l.rstrip('\n'))+12000]
438438
finally:
439439
await ctx.send_msgs([{"cmd": "LocationScouts", "locations": sending,
440440
"create_as_hint": int(2)}])
441-
os.remove(root+"/"+file)
441+
os.remove(os.path.join(root, file))
442442
if "check.spot" in file:
443443
sending = []
444444
try:
445-
with open(root+"/"+file, "r") as f:
445+
with open(os.path.join(root, file), "r") as f:
446446
lines = f.readlines()
447447
for l in lines:
448448
sending = sending+[(int(l.rstrip('\n')))+12000]
@@ -451,7 +451,7 @@ async def game_watcher(ctx: UndertaleContext):
451451
if "victory" in file and str(ctx.route) in file:
452452
victory = True
453453
if ".playerspot" in file and "Online" not in ctx.tags:
454-
os.remove(root+"/"+file)
454+
os.remove(os.path.join(root, file))
455455
if "victory" in file:
456456
if str(ctx.route) == "all_routes":
457457
if "neutral" in file and ctx.completed_routes["neutral"] != 1:

worlds/undertale/Rules.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def set_rules(multiworld: MultiWorld, player: int):
113113
set_rule(multiworld.get_location("Hush Trade", player),
114114
lambda state: state.can_reach("News Show", "Region", player) and state.has("Hot Dog...?", player, 1))
115115
set_rule(multiworld.get_location("Letter Quest", player),
116-
lambda state: state.can_reach("New Home Exit", "Entrance", player))
116+
lambda state: state.can_reach("New Home Exit", "Entrance", player) and state.has("Undyne Date", player))
117117
if (not _undertale_is_route(multiworld.state, player, 2)) or _undertale_is_route(multiworld.state, player, 3):
118118
set_rule(multiworld.get_location("Nicecream Punch Card", player),
119119
lambda state: state.has("Punch Card", player, 3) and state.can_reach("Waterfall", "Region", player))

worlds/undertale/data/patch.bsdiff

4.13 KB
Binary file not shown.

0 commit comments

Comments
 (0)