1
1
import asyncio
2
2
import logging
3
+ import tempfile
3
4
import traceback
4
5
import typing
5
6
from collections .abc import Callable
@@ -481,9 +482,20 @@ def on_package(self, cmd: str, args: dict):
481
482
logger .error (tb )
482
483
return
483
484
else :
484
- # TODO consider allowing worlds that self-attest to not need an options file for UT
485
- self .log_to_tab (f"Player's Yaml not in tracker's list. Known players: { list (self .launch_multiworld .world_name_lookup .keys ())} " , False )
486
- return
485
+ if getattr (AutoWorld .AutoWorldRegister .world_types [self .game ], "ut_can_gen_without_yaml" , False ):
486
+ with tempfile .TemporaryDirectory () as tempdir :
487
+ self .write_empty_yaml (self .game , slot_name , tempdir )
488
+ self .run_generator (None , tempdir )
489
+ self .player_id = 1
490
+ if callable (getattr (self .multiworld .worlds [self .player_id ], "interpret_slot_data" , None )):
491
+ temp = self .multiworld .worlds [self .player_id ].interpret_slot_data (args ["slot_data" ])
492
+ if temp :
493
+ self .re_gen_passthrough = {self .game : temp }
494
+
495
+ self .run_generator (args ["slot_data" ], tempdir )
496
+ else :
497
+ self .log_to_tab (f"Player's Yaml not in tracker's list. Known players: { list (self .launch_multiworld .world_name_lookup .keys ())} " , False )
498
+ return
487
499
488
500
if self .ui is not None and getattr (self .multiworld .worlds [self .player_id ], "tracker_world" , None ):
489
501
self .tracker_world = UTMapTabData (** self .multiworld .worlds [self .player_id ].tracker_world )
@@ -499,6 +511,13 @@ def on_package(self, cmd: str, args: dict):
499
511
elif cmd == 'RoomUpdate' :
500
512
updateTracker (self )
501
513
514
+ def write_empty_yaml (self , game , player_name , tempdir ):
515
+ path = os .path .join (tempdir , f'{ game } _{ player_name } .yaml' )
516
+ with open (path , 'w' ) as f :
517
+ f .write ('name: ' + player_name + '\n ' )
518
+ f .write ('game: ' + game + '\n ' )
519
+ f .write (game + ': {}\n ' )
520
+
502
521
async def disconnect (self , allow_autoreconnect : bool = False ):
503
522
if "Tracker" in self .tags :
504
523
self .game = ""
@@ -528,7 +547,7 @@ def _set_host_settings(self):
528
547
return tracker_settings ['player_files_path' ], report_type , tracker_settings [
529
548
'hide_excluded_locations' ]
530
549
531
- def run_generator (self , slot_data : Optional [Dict ] = None ):
550
+ def run_generator (self , slot_data : Optional [Dict ] = None , override_yaml_path : Optional [ str ] = None ):
532
551
def move_slots (args : "Namespace" , slot_name : str ):
533
552
"""
534
553
helper function to copy all the proper option values into slot 1,
@@ -547,7 +566,9 @@ def move_slots(args: "Namespace", slot_name: str):
547
566
# strip command line args, they won't be useful from the client anyway
548
567
sys .argv = sys .argv [:1 ]
549
568
args = mystery_argparse ()
550
- if yaml_path :
569
+ if override_yaml_path :
570
+ args .player_files_path = override_yaml_path
571
+ elif yaml_path :
551
572
args .player_files_path = yaml_path
552
573
args .skip_output = True
553
574
0 commit comments