@echo off
setlocal

set "ROOT=%~dp0"
set "CLIENT_DIR=%ROOT%Client_Base"
set "CLIENT_JAR=%CLIENT_DIR%\Open_RSC_Client.jar"
set "JAVA_BIN=%ROOT%java\bin\java.exe"

if not exist "%CLIENT_JAR%" (
  echo GegeScape client jar is missing:
  echo %CLIENT_JAR%
  echo.
  pause
  exit /b 1
)

if exist "%JAVA_BIN%" goto run

where java >nul 2>nul
if errorlevel 1 (
  echo Java was not found.
  echo This bundle should include java\bin\java.exe.
  echo Please re-download the Windows client zip.
  echo.
  pause
  exit /b 1
)

set "JAVA_BIN=java"

:run
cd /d "%CLIENT_DIR%"
"%JAVA_BIN%" -Xms312m -Dsun.java2d.opengl=true -cp "%CLIENT_JAR%" orsc.OpenRSC
if errorlevel 1 (
  echo.
  echo GegeScape client exited with an error.
  pause
)

