goto :eof
:parsetask
call set "activetask=%activetask%"
%activetask%
goto :eof
:functionparser
set function=%1
set function=%function:"=%
for /f "tokens=1,* delims=." %%a in ("func%function%") do set function=%%a&&call call set "functiontask=%%%%a%%"&&if [%%b]==[] (set triggervalue=DEFAULTFUNC) else (set "triggervalue=%%b")
set function=%function:func=%
if not defined functiontask goto :eof
%functiontask% %triggervalue%
goto :eof
:echostatus
echo %time:~0,5%-^> %~1
if ["%~2"]==[""] goto :eof
echo %date:* =%	%time:~0,5%-^>%~1>>%~2
goto :eof
:senddirectcmd
if not %testing%==0 echo %time:~0,5%    -^>Send Direct CMD %~1 
pushd %cfgfolder%
for /f "tokens=* delims=" %%a in ('%sed% -n 1p srctools\temp\%cfgin%') do echo %~1;%%a>srctools\temp\%cfgin%
popd
goto :eof
:resetdirectcmd
if not %testing%==0 echo %time:~0,5%    -^>Reset Direct CFG %~1
pushd %cfgfolder%
for /f "tokens=* delims=" %%a in ('%sed% -n s/%~1.//gp srctools\temp\%cfgin%') do echo %%a>srctools\temp\%cfgin%
popd
goto :eof
:sendcmd
set /a cfginputcount+=1
call set sendcmd=%~1
::if not "%2"=="" (set cfginputtemp=srct-%2) else (
set cfginputtemp=srctools\temp\srctcfg-incoming%cfginputcount%
::if not %testing%==0 echo %time:~0,5%    -^>Send CMD %sendcmd% to CFG #%cfginputcount%
pushd %cfgfolder%
call echo "echo executed srctcfg-incoming%cfginputcount%.cfg;%~1"|%sed% s/^\"//g;s/\"$//g>srctools\temp\srctcfg-incoming%cfginputcount%.cfg
for /f "tokens=* delims=" %%a in ('%sed% -n 1p srctools\temp\%cfgin%') do echo exec srctools\temp\srctcfg-incoming%cfginputcount%.cfg;%%a>srctools\temp\%cfgin%
popd
goto :eof
:resetcfg
::if not %testing%==0 echo %time:~0,5%    -^>Reset CFG #%~1
pushd %cfgfolder%
del /q srctools\temp\srctcfg-incoming%~1 >nul 2>&1
for /f "tokens=* delims=" %%a in ('%sed% -n s/exec" "srctools\\temp\\srctcfg-incoming%~1.//gp srctools\temp\%cfgin%') do echo %%a>srctools\temp\%cfgin%
popd
goto :eof
:newround
if not "%usergamename%"=="noneattributed" call set tempusergamename="%%usergamename%%"&&call :sendcmd "setinfo name %%%%tempusergamename%%%%"
if "%autorecord%"=="yes" start /b %demorecord%
if defined usercfg_hascfg call :sendcmd "exec srctools\temp\srctcfg-userconnect.cfg"
goto :eof

:gamestarted
goto :eof

::----------------------------------------------------------------------
::---------------------- Non Console Log Tasks -------------------------
::----------------------------------------------------------------------
:processaddon
::if not %testing%==0 echo %time:~0,5%    -^>In %0
call %1
if not defined dontdeleteaddon del /q %~1
set dontdeleteaddon=
if not defined addontask goto :eof
%addontask%
set addontask=
goto :eof

:terminalcmd
set terminal_input=
set terminal_input_temp=
set terminal_input_temp=%~1
for /f "tokens=* delims=" %%a in ("%~1") do call call set "terminal_input=%%%%a%%"
if not defined terminal_input echo Unknown Command: %terminal_input_temp:terminal_=%&&start /b %terminal%&&goto :eof
%terminal_input% %2
start /b %terminal%
goto :eof

:terminal_help
echo -------------------------- Console Commands --------------------------
echo.
for /f "tokens=1,* delims==" %%a in ('set terminal_help_') do call :terminal_help_list "%%a" "%%b"
echo ______________________________________________________________________
goto :eof

:terminal_help_list
set "terminal_cmd=%~1                                                    "
set "terminal_cmd=%terminal_cmd:terminal_help_=%"
set "terminal_cmd=%terminal_cmd:~0,14%"
echo %terminal_cmd% - %~2
goto :eof

:launchterminal
for /f "tokens=* delims=" %%a in (core\parameters\terminalcmd.txt) do call set "%%a"
if exist core\status\terminalcmd.txt for /f "tokens=* delims=" %%a in (core\status\terminalcmd.txt) do call set "%%a"
for /f "tokens=* delims=" %%a in (core\parameters\terminalhelp.txt) do call set "%%a"
if exist core\status\terminalcmd.txt for /f "tokens=* delims=" %%a in (core\status\terminalhelp.txt) do call set "%%a"
start /b core\modules\misc\terminal.bat
goto :eof

:hl2closed
if not %testing%==0 echo %time:~0,5%    -^>HL2.EXE ENDED
set addontask=
for %%a in (core\status\addontask-close-*.bat) do call :processaddon %%a
if defined addontask %addontask% else
if not %testing%==0 echo Shutdown Procedure
call %shutdown%
if %testing%==0 if not "%multimode%"=="0" call %launchcounter% shutdown
set addontask=
for %%a in (core\status\addontask-shutdown-*.bat) do call :processaddon %%a
if defined addontask %addontask% else
goto :eof