Files
2025-09-29 00:52:08 +02:00

57 lines
2.4 KiB
Batchfile
Executable File

::
:: %RS_TOOLSBIN%\RockstarTargetManager\_connect_target_win64.bat should not be directly modified.
::
:: This file gets automatically copied from %RS_CODEBRANCH%\rage\base\tools\ui\RockstarTargetManager\RockstarTargetManager\_connect_target_win64.bat
:: when a new version of R*TM is released (see %RS_CODEBRANCH%\rage\base\tools\ui\RockstarTargetManager\CopyToTools.bat).
::
if not exist "%exename%.exe" (
echo Can't find PC executable [%exename%.exe]
exit 1
)
:: Check if -processinstance=* was specified in the command line (or in a response file) that will be used to boot the game.
:: If it was, then we allow multiple instances of the game to be running. If not, then kill any previous instances.
::
:: At the same time, we also extract the instance id, since it is required to determine the R*TM TTY port number.
:: Annoyingly, cmd for is splitting the command line args up as separate tokens by treating = as a delimiter, not just
:: whitespace. Because of that, we need next_is_instance_id to keep track of when the instance id is expected.
::
set instance_id=1
set find_arg=processinstance
set found_arg_message=
for /f "usebackq tokens=1,2 delims==" %%a in (`call "%batch_dir%\_scan_cmdline.bat" %autoGeneratedCmdline% %userSpecifiedCmdline%`) do (
if "%%a" == "found_arg_value" (
if "%%b" == "" (
if "%application%" == "game" (
echo Killing old instances of the game
call "%batch_dir%\_kill_x64_game.bat"
)
) else (
set instance_id=%%b
)
) else if "%%a" == "found_arg_message" (
set found_arg_message=%%b
)
)
if /i "%instance_id%"=="auto" (
set instance_id=1
for /f "usebackq delims=," %%a in (`tasklist /fi "imagename eq game_*" /fo csv /nh`) do (
set tasklistout=%%a
if "!tasklistout::=!"=="!tasklistout!" set /a instance_id=!instance_id!+1
)
echo -processinstance=auto specified %found_arg_message%, so setting this instance ID to !instance_id!
) else (
if %instance_id% leq 0 (
echo Invalid -processinstance=%instance_id% specified %found_arg_message%, process instance numbers must start from 1.
exit 1
) else if "x%found_arg_message%" neq "x" (
echo -processinstance=%instance_id% specified %found_arg_message%, therefore not automatically killing all old instances of the game.
)
)
set /a instance_id_sub_1=%instance_id%-1
set /p target_ip_bare=<"%TEMP%\rfs.dat"
set target_ip=%target_ip_bare%_%instance_id_sub_1%