Update GAMEUPDATE

This commit is contained in:
DazedAnon 2024-06-05 10:38:43 -05:00
parent 3a0b54b453
commit db052deef9

View file

@ -1,9 +1,36 @@
@echo off
setlocal enabledelayedexpansion
setlocal EnableExtensions EnableDelayedExpansion
echo Checking for pwsh...
set _my_shell=pwsh
REM Check if pwsh.exe exists
where /q !_my_shell!
if !errorlevel! neq 0 (
echo pwsh not found. Falling back to powershell...
REM If pwsh is not found, set to powershell
set _my_shell=powershell
REM Check if powershell.exe exists
echo Checking for powershell...
where /q !_my_shell!
if !errorlevel! neq 0 (
echo.Error: Powershell not found!
pause
exit /B 1
) else (
echo powershell found.
)
) else (
echo pwsh found.
)
echo Using !_my_shell! for script execution.
REM Check if patch-config.txt exists
if not exist patch-config.txt (
echo "Config file (patch-config.txt) not found! Assuming no patching needed."
pause
exit /b
)
@ -16,7 +43,7 @@ for /f "tokens=1,2 delims==" %%a in (patch-config.txt) do (
REM Get the latest hash
echo "Getting latest commit SHA hash"
powershell -Command "(Invoke-WebRequest -Uri 'https://api.github.com/repos/%username%/%repo%/branches/%branch%').Content | ConvertFrom-Json | Select-Object -ExpandProperty commit | Select-Object -ExpandProperty sha" > latest_patch_sha.txt
!_my_shell! -Command "(Invoke-WebRequest -Uri 'https://api.github.com/repos/%username%/%repo%/branches/%branch%').Content | ConvertFrom-Json | Select-Object -ExpandProperty commit | Select-Object -ExpandProperty sha" > latest_patch_sha.txt
REM Read the latest SHA from the file
set /p latest_patch_sha=<latest_patch_sha.txt
@ -47,16 +74,17 @@ REM Delete latest_patch_sha.txt
del latest_patch_sha.txt
endlocal
pause
exit /b
:download_extract
REM Download zip file
echo "Downloading latest patch..."
powershell -Command "Invoke-WebRequest -Uri 'https://codeload.github.com/%username%/%repo%/zip/refs/heads/%branch%' -OutFile 'repo.zip'"
!_my_shell! -Command "Invoke-WebRequest -Uri 'https://codeload.github.com/%username%/%repo%/zip/refs/heads/%branch%' -OutFile 'repo.zip'"
REM Extract contents, overwriting conflicts
echo "Extracting..."
powershell -Command "Expand-Archive -Path '.\repo.zip' -DestinationPath '.' -Force"
!_my_shell! -Command "Expand-Archive -Path '.\repo.zip' -DestinationPath '.' -Force"
echo "Applying patch..."
xcopy /s /e /y "%repo%-%branch%\*" "."
@ -69,4 +97,5 @@ del latest_patch_sha.txt
REM Store latest SHA for next check
echo %latest_patch_sha% > previous_patch_sha.txt
endlocal
pause
exit /b