@echo off
REM ============================================================
REM  Crushbone Patcher (Windows) - double-click to update client
REM  Place this file IN your EverQuest folder (next to eqgame.exe).
REM  It downloads the current updater and patches this folder.
REM ============================================================
setlocal
title Crushbone Patcher

REM This .bat's own folder = the game folder (no path guessing).
set "GAMEDIR=%~dp0"
if "%GAMEDIR:~-1%"=="\" set "GAMEDIR=%GAMEDIR:~0,-1%"

if not exist "%GAMEDIR%\eqgame.exe" (
  echo.
  echo [X] eqgame.exe not found in:
  echo     %GAMEDIR%
  echo.
  echo Put Crushbone-Patcher.bat inside your EverQuest folder
  echo (the one that contains eqgame.exe^), then run it again.
  echo.
  pause
  exit /b 1
)

echo.
echo  Crushbone Patcher
echo  Game folder: %GAMEDIR%
echo.
echo  Close EverQuest before continuing.
echo  Patching will start in 3 seconds...
timeout /t 3 /nobreak >nul

REM Run the official updater against this folder. -ExecutionPolicy Bypass is
REM scoped to this single invocation; TLS1.2 forced for older boxes.
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
  "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; ^
   $u='https://patch.crushbone.live/patch/updaters/crushbone-update.ps1'; ^
   $f=Join-Path $env:TEMP 'crushbone-update.ps1'; ^
   try { Invoke-WebRequest -Uri $u -OutFile $f -UseBasicParsing } catch { Write-Host '[X] Could not download updater:' $_.Exception.Message -ForegroundColor Red; exit 1 }; ^
   & $f '%GAMEDIR%'"

set "RC=%ERRORLEVEL%"
echo.
if "%RC%"=="0" (
  echo  Done. You can close this window and launch EverQuest.
) else (
  echo  Finished with code %RC%. If files failed, close EverQuest and re-run.
)
echo.
pause
endlocal
