@echo off
setlocal enableextensions enabledelayedexpansion

if not exist %TEMP%\UT4Cook\%1 mkdir %TEMP%\UT4Cook\%1

echo.
echo Start cooking %1
set time_start=%time%
set base_dir=%~dp0
echo     Start Time: %time_start%

for /f "tokens=2 delims==" %%i in ('wmic os get LocalDateTime /value') do set datetime_=%%i
set datetime=%datetime_:~0,14%

pushd %base_dir%..\..\..\Engine\Build\BatchFiles
call RunUAT.bat makeUTDLC -DLCName=%1 -platform=Win64 -version=3525360 >%TEMP%\UT4Cook\%1\build.log
popd

if %ERRORLEVEL% EQU 0 (
	echo     End Time:   %time%
	echo Finished cooking %1
	echo.

	if not exist %USERPROFILE%\Documents\UnrealTournament\Saved\Paks\MyContent mkdir %USERPROFILE%\Documents\UnrealTournament\Saved\Paks\MyContent
	copy /Y %base_dir%..\..\..\UnrealTournament\Saved\StagedBuilds\%1\WindowsNoEditor\UnrealTournament\Content\Paks\%1-WindowsNoEditor.pak /B %USERPROFILE%\Documents\UnrealTournament\Saved\Paks\MyContent >NUL

	endlocal
	exit /B %ERRORLEVEL%
) else (
	echo     End Time:   %time%
	echo Failed cooking %1
	echo.

	copy /Y %TEMP%\UT4Cook\%1\build.log %TEMP%\UT4Cook\%1\build_failed_%datetime%.log >NUL
	echo See %TEMP%\UT4Cook\%1\build_failed_%datetime%.log for more information.
	echo.

	endlocal
	exit /B %ERRORLEVEL%
)
