@echo off
REM ============================================================
REM  HELLHOUSE play launcher (installed shortcut target).
REM  Arg %1 = server address (the installer bakes in LAN or NET).
REM  Fetches the current season wad as _current.wad so the client
REM  always matches the rotating server, then connects. Runs from
REM  the install folder (%~dp0). Same logic as the portable pack.
REM ============================================================
setlocal
set "HERE=%~dp0"
set "EXE=%HERE%zandronum.exe"
set "IWAD=%HERE%doom2.wad"
set "MOD=%HERE%brutalv21.50.0.pk3"
set "CUR=%HERE%_current.wad"
set "SERVER=%~1"
if "%SERVER%"=="" set "SERVER=94.72.111.66:10666"
set "WADURL=https://rigzhouse.co.uk/doom/wads/_current.wad"

if not exist "%IWAD%" (
  echo HELLHOUSE needs your own doom2.wad in:
  echo   %HERE%
  echo Copy it there, then run HELLHOUSE again.
  pause & exit /b 1
)
echo Fetching the current season from the house...
powershell -NoProfile -Command "try{Invoke-WebRequest -UseBasicParsing '%WADURL%' -OutFile '%CUR%';exit 0}catch{exit 1}"
start "" "%EXE%" -iwad "%IWAD%" -file "%MOD%" -file "%CUR%" -connect %SERVER%
endlocal
