@@ -29,40 +29,40 @@ def _cmd_resync(self):
29
29
def _cmd_patch (self ):
30
30
"""Patch the game."""
31
31
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 )
33
33
self .ctx .patch_game ()
34
34
self .output ("Patched." )
35
35
36
36
def _cmd_savepath (self , directory : str ):
37
37
"""Redirect to proper save data folder. (Use before connecting!)"""
38
38
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 )
41
41
42
42
@mark_raw
43
43
def _cmd_auto_patch (self , steaminstall : typing .Optional [str ] = None ):
44
44
"""Patch the game automatically."""
45
45
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 )
47
47
tempInstall = steaminstall
48
48
if not os .path .isfile (os .path .join (tempInstall , "data.win" )):
49
49
tempInstall = None
50
50
if tempInstall is None :
51
51
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 ):
53
53
tempInstall = "C:\\ Program Files\\ Steam\\ steamapps\\ common\\ Undertale"
54
54
elif not os .path .exists (tempInstall ):
55
55
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 ):
57
57
tempInstall = "C:\\ Program Files\\ Steam\\ steamapps\\ common\\ Undertale"
58
58
if not os .path .exists (tempInstall ) or not os .path .exists (tempInstall ) or not os .path .isfile (os .path .join (tempInstall , "data.win" )):
59
59
self .output ("ERROR: Cannot find Undertale. Please rerun the command with the correct folder."
60
60
" command. \" /auto_patch (Steam directory)\" ." )
61
61
else :
62
62
for file_name in os .listdir (tempInstall ):
63
63
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 ) )
66
66
self .ctx .patch_game ()
67
67
self .output ("Patching successful!" )
68
68
@@ -111,13 +111,13 @@ def __init__(self, server_address, password):
111
111
self .save_game_folder = os .path .expandvars (r"%localappdata%/UNDERTALE" )
112
112
113
113
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 :
115
115
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 :
117
117
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 :
121
121
f .writelines (["// Put the folder name of the sprites you want to play as, make sure it is the only "
122
122
"line other than this one.\n " , "frisk" ])
123
123
f .close ()
@@ -385,7 +385,7 @@ async def multi_watcher(ctx: UndertaleContext):
385
385
for root , dirs , files in os .walk (path ):
386
386
for file in files :
387
387
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 :
389
389
this_x = mine .readline ()
390
390
this_y = mine .readline ()
391
391
this_room = mine .readline ()
@@ -408,7 +408,7 @@ async def game_watcher(ctx: UndertaleContext):
408
408
for root , dirs , files in os .walk (path ):
409
409
for file in files :
410
410
if ".item" in file :
411
- os .remove (root + "/" + file )
411
+ os .remove (os . path . join ( root , file ) )
412
412
sync_msg = [{"cmd" : "Sync" }]
413
413
if ctx .locations_checked :
414
414
sync_msg .append ({"cmd" : "LocationChecks" , "locations" : list (ctx .locations_checked )})
@@ -424,25 +424,25 @@ async def game_watcher(ctx: UndertaleContext):
424
424
for root , dirs , files in os .walk (path ):
425
425
for file in files :
426
426
if "DontBeMad.mad" in file :
427
- os .remove (root + "/" + file )
427
+ os .remove (os . path . join ( root , file ) )
428
428
if "DeathLink" in ctx .tags :
429
429
await ctx .send_death ()
430
430
if "scout" == file :
431
431
sending = []
432
432
try :
433
- with open (root + "/" + file , "r" ) as f :
433
+ with open (os . path . join ( root , file ) , "r" ) as f :
434
434
lines = f .readlines ()
435
435
for l in lines :
436
436
if ctx .server_locations .__contains__ (int (l )+ 12000 ):
437
437
sending = sending + [int (l .rstrip ('\n ' ))+ 12000 ]
438
438
finally :
439
439
await ctx .send_msgs ([{"cmd" : "LocationScouts" , "locations" : sending ,
440
440
"create_as_hint" : int (2 )}])
441
- os .remove (root + "/" + file )
441
+ os .remove (os . path . join ( root , file ) )
442
442
if "check.spot" in file :
443
443
sending = []
444
444
try :
445
- with open (root + "/" + file , "r" ) as f :
445
+ with open (os . path . join ( root , file ) , "r" ) as f :
446
446
lines = f .readlines ()
447
447
for l in lines :
448
448
sending = sending + [(int (l .rstrip ('\n ' )))+ 12000 ]
@@ -451,7 +451,7 @@ async def game_watcher(ctx: UndertaleContext):
451
451
if "victory" in file and str (ctx .route ) in file :
452
452
victory = True
453
453
if ".playerspot" in file and "Online" not in ctx .tags :
454
- os .remove (root + "/" + file )
454
+ os .remove (os . path . join ( root , file ) )
455
455
if "victory" in file :
456
456
if str (ctx .route ) == "all_routes" :
457
457
if "neutral" in file and ctx .completed_routes ["neutral" ] != 1 :
0 commit comments