@echo off :: :: %RS_TOOLSBIN%\RockstarTargetManager\_game_common.bat should not be directly modified. :: :: This file gets automatically copied from %RS_CODEBRANCH%\rage\base\tools\ui\RockstarTargetManager\RockstarTargetManager\_game_common.bat :: when a new version of R*TM is released (see %RS_CODEBRANCH%\rage\base\tools\ui\RockstarTargetManager\CopyToTools.bat). :: setlocal enabledelayedexpansion set batch_dir=%~dp0 :: This file is intended to be called by %RS_BUILDBRANCH%\_launch.bat only. if "%called_from%" == "" ( echo %0 should not be called directly. echo Parent batchfile needs to set %%called_from%% exit 1 ) set exename=%called_from% :: If you locally create an exename_transform.bat file, it will be called here. :: The idea is to add a hook to allow the correct name transform if your p4 clientspec has renamed this batchfile. :: For example, the following line in a clientspec :: //depot/gta5/build/dev_ng/game_... //workspace/gta5/build/dev_ng/p4_game_... :: Would add a p4_ prefix to each filename so that it doesn't conflict with locally built executables. :: An exename_transform.bat could then be created to strip the p4_ prefix, :: set exename=%exename:p4_=% if exist exename_transform.bat ( echo.Calling exename_transform.bat call exename_transform.bat echo. %exename% -^> !exename! ) :: Extract the platform and build from exename. :: Expected format is "game_platform_build" (without the double quotes). set application= set platform= set build= for /F "tokens=1,2,* delims=_" %%a in ("%exename%") do ( set application=%%a set platform=%%b set build=%%c ) :: instance_id is used by some targets that can handle multiple simultaneous instances of the game running :: Make sure it's cleared; it will be set up later if applicable (currently in the pc connect script) :: * This will need to be removed if we rely on the var being set externally or earlier in the flow * set instance_id= if "%application%" == "game" ( title Running %platform% %build%... ) else ( title Running %application% %platform% %build%... ) echo. :: POST_KILL_CMD_MSG is used to indicate whether this is a RocketLauncher launch. Set here :: for readability set enablerl=%POST_KILL_CMD_MSG% :: RTM needs to know whether this is a RocketLauncher launch or not. If it is, then :: assuming current directory is in X:\americas\build\{branch}\rocketlauncher , :: extract the rocketlauncher token set RS_RTM_LAUNCH_BRANCH=%cd% pushd .. set RS_RTM_LAUNCH_BRANCH=!RS_RTM_LAUNCH_BRANCH:%cd%\=! popd :: RS_BUILDBRANCH etc are no longer set by tools, so set them here based on current directory so that :: they get passed through as pseudo environment variables to launch the game process through R*TM. :: Note that this can also be relied up by _connect_target_%platform%.bat, so it needs to be set early. if not "%enablerl%" == "" ( pushd .. ) set RS_BUILDBRANCH=%cd% pushd ..\.. set RS_PROJROOT=%cd% popd pushd .. set RS_BRANCH=!RS_BUILDBRANCH:%cd%\=! popd if not "%enablerl%" == "" ( popd ) else ( @REM if this is not a RocketLauncher launch, then force RS_RTM_LAUNCH_BRANCH to be @REM the same as RS_BRANCH for safety set RS_RTM_LAUNCH_BRANCH=!RS_BRANCH! ) :: Scan the command line for any special treatment arguments. :: An arg enclosed in square brackets is treated as the target ip address. :: -skipglobalargs removes the default arguments file. set userSpecifiedCmdline=%* set skipArgsfile= set target_ip= for %%a in (%*) do ( set removeArg=0 set arg=%%a if "!arg:~0,1!" == "[" ( if "!arg:~-1!" == "]" ( set target_ip=!arg:~1,-1! set removeArg=1 ) ) if /i "!arg!" == "-skipglobalargs" ( set skipArgsFile=!arg! set removeArg=1 ) if "!removeArg!" == "1" ( set userSpecifiedCmdline=!userSpecifiedCmdline:%%a=! ) ) :: Bob and future games use global_args.txt as a checked in file, that then recursively references args.txt. :: Legacy GTA V does not use global_args.txt, instead it optionally includes commandline.txt (exclusive) or args.txt, in that order. :: If -skipglobalargs exists, we'll ignore them. :: :: This step is done a little earlier than the rest of autoGeneratedCmdline, since _connect_target_%platform%.bat may :: need access to the response file (for example PC). :: set updatedir=%cd:\=/%/ if "%skipArgsfile%" == "" ( if exist global_args.txt ( set autoGeneratedCmdline=@%updatedir%global_args.txt ) else if exist commandline.txt ( set autoGeneratedCmdline=@%updatedir%commandline.txt ) else if exist args.txt ( set autoGeneratedCmdline=@%updatedir%args.txt ) ) else ( echo Not using commandline text files due to presense of -skipglobalargs. set autoGeneratedCmdline= ) :: Select default target if none was specified, then connect to it. :: Environment variables that are considerred "documented" for this batchfile to access are :: :: autoGeneratedCmdline (though note that this isn't the final version) :: userSpecifiedCmdline :: target_ip (may be empty) :: :: Upon return :: :: target_ip must be set :: call "%batch_dir%\_connect_target_%platform%.bat" if not "%POST_KILL_CMD_MSG%" == "" ( echo %POST_KILL_CMD_MSG% %POST_KILL_CMD% ) :: Build up the autogenerated part of the command line. set rootdir=%updatedir:dlc/titleupdate/=% if not "%updatedir%" == "%rootdir%" ( set updatearg=-update=%updatedir% ) if "%RS_RFS_DISABLE%" == "" ( set rootdircmd=-rootdir=%rootdir% %updatearg% ) else ( set rootdircmd= ) set autoGeneratedCmdline=%autoGeneratedCmdline% %rootdircmd% %updatearg% set /p hostaddr=<"%TEMP%\rfs.dat" set autoGeneratedCmdline=%autoGeneratedCmdline% -localhost %hostaddr% call "%batch_dir%\..\..\script\util\get_config_ports.bat" > nul if not "%PORT_SYSTRAYRFS%" == "" ( set autoGeneratedCmdline=%autoGeneratedCmdline% -rfsport=%PORT_SYSTRAYRFS% ) :: The -argset param allows for a user-defined method of toggling other params (via prefixes) set find_arg=argset set argset= set found_arg_value= 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_message" set found_arg_message=%%b if "%%a" == "found_arg_value" set found_arg_value=%%b ) if not "%found_arg_value%" == "" ( echo -argset=%found_arg_value% specified %found_arg_message% set argset=%found_arg_value% ) :: Add -netlogprefix and potentially also -logfile if not running with R*TM. if not "%RS_RTM_DISABLE%" == "" ( set autoGeneratedCmdline=!autoGeneratedCmdline! -netlogprefix=%target_ip_bare% rem :: Add -logfile to the command line if it isn't already there. rem :: Can't just add to the start of the command line (to allow later commands to override it), since response files are not parsed in order. set find_arg=logfile set found_arg_value= 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" ( set found_arg_value=%%b ) else if "%%a" == "found_arg_message" ( set found_arg_message=%%b ) ) if "!found_arg_value!" == "" ( set autoGeneratedCmdline=!autoGeneratedCmdline! -logfile=console-%target_ip_bare%.log ) else ( echo -logfile=!found_arg_value! specified !found_arg_message!, therefore not adding default -logfile cmd line arg. ) ) :: If -sparsegameheap is in a response file, replicate it on the immediate commandline so it can be parsed early. :: Also convert it from -sparsegameheap to @sparsegameheap set find_arg=sparsegameheap set param_sparsegameheap_found= for /f "usebackq tokens=1,2 delims==" %%a in (`call "%batch_dir%\_scan_cmdline.bat" %autoGeneratedCmdline% %userSpecifiedCmdline%`) do ( if "%%a" == "found_arg_message" ( set param_sparsegameheap_found=%%b ) ) if not "%param_sparsegameheap_found%"=="" ( set autoGeneratedCmdline=@sparsegameheap %autoGeneratedCmdline% ) :: If -extragpumembank is in a response file, replicate it on the immediate commandline so it can be parsed early. set find_arg=extragpumembank set param_extragpumembank= for /f "usebackq tokens=1,2 delims==" %%a in (`call "%batch_dir%\_scan_cmdline.bat" %autoGeneratedCmdline% %userSpecifiedCmdline%`) do ( if "%%a" == "found_arg_value" ( set param_extragpumembank=%%b ) ) if not "%param_extragpumembank%"=="" ( set autoGeneratedCmdline=%autoGeneratedCmdline% -extragpumembank=%param_extragpumembank% ) :: If -enablesharedtex is in a response file, replicate it on the immediate commandline so it can be parsed easily. set find_arg=enablesharedtex set param_enablesharedtex_found= for /f "usebackq tokens=1,2 delims==" %%a in (`call "%batch_dir%\_scan_cmdline.bat" %autoGeneratedCmdline% %userSpecifiedCmdline%`) do ( if "%%a" == "found_arg_message" ( set param_enablesharedtex_found=%%b ) ) if not "%param_enablesharedtex_found%"=="" ( set autoGeneratedCmdline=%autoGeneratedCmdline% -enablesharedtex ) :: If -workspace is in a response file, replicate it on the immediate commandline so it can be parsed easily. set find_arg=workspace set set_workspace= for /f "usebackq tokens=1,2 delims==" %%a in (`call "%batch_dir%\_scan_cmdline.bat" %autoGeneratedCmdline% %userSpecifiedCmdline%`) do ( if "%%a" == "found_arg_message" ( set set_workspace=%%b ) ) if not "%set_workspace%"=="" ( if /i "%platform%"=="prospero" ( set RSG_PS5_WORKSPACE=%USERNAME%_full if /i not "%RS_BRANCH%"=="dev" set RSG_PS5_WORKSPACE=!RSG_PS5_WORKSPACE!_%RS_BRANCH% set autoGeneratedCmdline=%autoGeneratedCmdline% -workspace=!RSG_PS5_WORKSPACE! ) else ( set autoGeneratedCmdline=%autoGeneratedCmdline% -workspace ) ) :: Check if -rag was specified in the command line that will be used to boot the game. :: If it was, then make sure it is running. set find_arg=rag set want_rag=0 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_message" ( set want_rag=1 set found_arg_message=%%b ) ) if "%want_rag%" == "1" ( echo -rag specified %found_arg_message% tasklist | find /i "rag.exe" >nul if errorlevel 1 ( echo Launching RAG start "" /d "%batch_dir%\..\rag" "%batch_dir%\..\rag\rag.exe" ) ) :: Always make sure SysTrayRFS is running. if "%RS_RFS_DISABLE%" == "" ( tasklist | find /i "SysTrayRfs.exe" >nul if errorlevel 1 ( echo Launching SysTrayRFS start "" "%batch_dir%\..\systrayrfs.exe" -trusted -nofocus ) ) :: If R*TM is enabled, ensure it is running. if "%RS_RTM_DISABLE%" == "" ( rem :: Double start here so that R*TM is not directly parented to current cmd, giving it its own lifetime rem :: http://stackoverflow.com/questions/1035213/process-start-and-the-process-tree echo Launching R*TM start "" /d "%batch_dir%" /b cmd /c start "" "Rockstar Target Manager.exe" --gui --retry-start=1 ) else ( echo R*TM disabled, not launching "%batch_dir%\Rockstar Target Manager.exe" --disabletarget=%target_ip% | findstr ^^ ) :: Give all the auxilary programs a little time to launch. ping -w 1000 -n 2 127.0.0.1 >nul call "%batch_dir%\_launch_%platform%.bat" %argsfile% %cmdline% :: Set errorlevel 0 cmd /C exit 0