@@cd /d %~dp0
@echo off
title Login Server Console

:start
@@DEL __wait__ 2>NUL
echo Starting L2J Login Server.
echo.

@@move UPDATE\l2jlogin.jar . 2>NUL
@@call L2LogRotate.bat
SET JAVA=java -Xms128m -Xmx128m -cp ./../libs/*;l2jlogin.jar com.l2jserver.loginserver.L2LoginServer
@@cmd /v:on /c "%JAVA% 2>&1 & echo exit /b !ERRORLEVEL! > __errorlevel.bat" |tee log/stdout.log
@@call __errorlevel.bat

if ERRORLEVEL 2 goto restart
if ERRORLEVEL 1 goto error
goto end

:restart
echo.
echo Admin Restarted Login Server.
echo.
goto start

:error
echo.
echo Login Server terminated abnormally!
echo.

:end
@@IF EXIST __wait__ waitServer.bat %0
echo.
echo Login Server Terminated.
echo.
@@IF "%~0" == "%cd%\%~nx0" @PAUSE