@@ -46,6 +46,7 @@ def run():
4646 parser .add_argument ('--controller-base-uri' , help = 'Base uri of web controller' , type = str )
4747 parser .add_argument ('--control-obs' , dest = 'control_obs' , action = 'store_true' )
4848 parser .add_argument ('--obs-url' , help = 'OBS WebSocket URL in format "ws://:password@hostname:port"' , type = str )
49+ parser .add_argument ('--obs-source-name' , help = 'OBS game source name' , type = str , default = 'Battlefield 2' )
4950 parser .add_argument ('--no-rtl-limit' , dest = 'limit_rtl' , action = 'store_false' )
5051 parser .add_argument ('--debug-log' , dest = 'debug_log' , action = 'store_true' )
5152 parser .add_argument ('--debug-screenshot' , dest = 'debug_screenshot' , action = 'store_true' )
@@ -72,6 +73,7 @@ def run():
7273 controller_base_uri = args .controller_base_uri ,
7374 control_obs = args .control_obs ,
7475 obs_url = args .obs_url ,
76+ obs_source_name = args .obs_source_name ,
7577 resolution = args .game_res ,
7678 debug_screenshot = args .debug_screenshot ,
7779 min_iterations_on_player = args .min_iterations_on_player ,
@@ -128,8 +130,10 @@ def run():
128130 logger .info ('Looking for an existing game instance' )
129131 got_instance , correct_params , * _ = gim .find_instance (config .get_server_mod ())
130132
131- # Schedule restart if no instance was started/found
132- if not got_instance :
133+ if got_instance and config .control_obs ():
134+ logger .debug ('Found existing game window, updating OBS capture window' )
135+ obsc .set_capture_window (config .get_obs_source_name (), constants .BF2_EXE , gim .game_window .title )
136+ elif not got_instance :
133137 logger .info ('Did not find any existing game instance, will launch a new one' )
134138 gis .set_error_restart_required (True )
135139 elif not correct_params :
@@ -342,7 +346,10 @@ def run():
342346 logger .warning (f'Game restart itself with a different mod, updating config' )
343347 config .set_server_mod (running_mod )
344348
345- if not got_instance :
349+ if got_instance and correct_params and config .control_obs ():
350+ logger .debug ('Game instance launched, updating OBS capture window' )
351+ obsc .set_capture_window (config .get_obs_source_name (), constants .BF2_EXE , gim .game_window .title )
352+ elif not got_instance :
346353 logger .error ('Game instance was not launched, retrying' )
347354 continue
348355 elif not correct_params :
0 commit comments