Adjust patch to support srpg.
This commit is contained in:
parent
0edf458709
commit
68dd8a639b
2 changed files with 165 additions and 0 deletions
|
|
@ -68,6 +68,57 @@ for /f "usebackq tokens=1,2 delims==" %%a in ("%CONFIG_FILE%") do (
|
|||
if "%%a"=="branch" set "branch=%%b"
|
||||
)
|
||||
|
||||
REM --------------------------------------------------------
|
||||
REM PRE-SETUP: Ensure SRPG data and patch structure exists
|
||||
REM Run Steps 1 and 2 BEFORE pulling repo patch to avoid overwriting updates
|
||||
REM 1) Unpack once if data folder doesn't exist (and data.dts does)
|
||||
REM 2) Create Patch once if patch folder doesn't exist
|
||||
REM --------------------------------------------------------
|
||||
set "UNPACKER=%ROOT_DIR%\SRPG_Unpacker.exe"
|
||||
if exist "%ROOT_DIR%\data.dts" (
|
||||
if exist "%UNPACKER%" (
|
||||
echo [Pre-Setup] Running SRPG_Unpacker preparation steps...
|
||||
|
||||
REM Step 1: Unpack (once)
|
||||
if not exist "%ROOT_DIR%\data\" (
|
||||
if exist "%ROOT_DIR%\data.dts" (
|
||||
echo [Pre-Setup] Step 1: Unpacking data.dts -> data
|
||||
pushd "%ROOT_DIR%"
|
||||
"%UNPACKER%" -o "data" "data.dts"
|
||||
if !errorlevel! neq 0 (
|
||||
echo [Pre-Setup] ERROR: Unpack failed. Continuing.
|
||||
)
|
||||
popd
|
||||
) else (
|
||||
echo [Pre-Setup] Step 1: Skipping unpack (no data folder and no data.dts found).
|
||||
)
|
||||
) else (
|
||||
echo [Pre-Setup] Step 1: data folder exists; skipping unpack.
|
||||
)
|
||||
|
||||
REM Step 2: Create Patch (once)
|
||||
if not exist "%ROOT_DIR%\patch\" (
|
||||
if exist "%ROOT_DIR%\data\project.dat" (
|
||||
echo [Pre-Setup] Step 2: Creating patch from data\project.dat
|
||||
pushd "%ROOT_DIR%"
|
||||
"%UNPACKER%" ".\data\project.dat" -c
|
||||
if !errorlevel! neq 0 (
|
||||
echo [Pre-Setup] ERROR: Create Patch failed. Continuing.
|
||||
)
|
||||
popd
|
||||
) else (
|
||||
echo [Pre-Setup] Step 2: Skipping create patch (data\project.dat not found).
|
||||
)
|
||||
) else (
|
||||
echo [Pre-Setup] Step 2: patch folder exists; skipping create.
|
||||
)
|
||||
) else (
|
||||
echo [Pre-Setup] SRPG_Unpacker.exe not found in root; skipping pre-setup steps.
|
||||
)
|
||||
) else (
|
||||
echo [Pre-Setup] data.dts not found; skipping pre-setup SRPG steps.
|
||||
)
|
||||
|
||||
REM Get the latest hash
|
||||
echo "Getting latest commit SHA hash"
|
||||
!_my_shell! -Command "(Invoke-RestMethod -Uri 'https://gitgud.io/api/v4/projects/%username%%%2F%repo%/repository/branches/%branch%').commit.id" > "%ROOT_DIR%\latest_patch_sha.txt"
|
||||
|
|
@ -136,6 +187,47 @@ if !errorlevel! neq 0 (
|
|||
pause
|
||||
exit /b
|
||||
)
|
||||
REM --------------------------------------------------------
|
||||
REM POST-APPLY: Run Steps 3 and 4 after patch files are merged
|
||||
REM 3) Apply Patch to data\project.dat
|
||||
REM 4) Pack data back into data.dts
|
||||
REM --------------------------------------------------------
|
||||
set "UNPACKER=%ROOT_DIR%\SRPG_Unpacker.exe"
|
||||
if exist "%ROOT_DIR%\data.dts" (
|
||||
if exist "%UNPACKER%" (
|
||||
echo Running SRPG_Unpacker apply/pack steps...
|
||||
|
||||
REM Step 3: Apply Patch
|
||||
if exist "%ROOT_DIR%\data\project.dat" (
|
||||
echo Step 3: Applying patch to data\project.dat
|
||||
pushd "%ROOT_DIR%"
|
||||
"%UNPACKER%" ".\data\project.dat" -a
|
||||
if !errorlevel! neq 0 (
|
||||
echo ERROR: Apply Patch failed.
|
||||
)
|
||||
popd
|
||||
) else (
|
||||
echo ERROR: data\project.dat not found; cannot apply patch.
|
||||
)
|
||||
|
||||
REM Step 4: Pack
|
||||
if exist "%ROOT_DIR%\data\" (
|
||||
echo Step 4: Packing data -> data.dts
|
||||
pushd "%ROOT_DIR%"
|
||||
"%UNPACKER%" -o "data.dts" "data"
|
||||
if !errorlevel! neq 0 (
|
||||
echo WARNING: Pack failed.
|
||||
)
|
||||
popd
|
||||
) else (
|
||||
echo Step 4: Skipping pack (data folder not found).
|
||||
)
|
||||
) else (
|
||||
echo SRPG_Unpacker.exe not found in root; skipping SRPG patch steps.
|
||||
)
|
||||
) else (
|
||||
echo data.dts not found; skipping SRPG patch steps.
|
||||
)
|
||||
REM Clean up
|
||||
echo "Cleaning up..."
|
||||
del "%ROOT_DIR%\repo.zip"
|
||||
|
|
|
|||
|
|
@ -38,6 +38,47 @@ echo "Config file path: $CONFIG_FILE"
|
|||
echo "Getting latest commit SHA hash"
|
||||
latest_patch_sha=$(curl -s "https://gitgud.io/api/v4/projects/$username%2F$repo/repository/branches/$branch" | jq -r '.commit.id')
|
||||
|
||||
# --------------------------------------------------------
|
||||
# PRE-SETUP: Ensure SRPG data and patch structure exists
|
||||
# Run Steps 1 and 2 BEFORE pulling repo patch to avoid overwriting updates
|
||||
# 1) Unpack once if data folder doesn't exist (and data.dts does)
|
||||
# 2) Create Patch once if patch folder doesn't exist
|
||||
# --------------------------------------------------------
|
||||
UNPACKER="$ROOT_DIR/SRPG_Unpacker.exe"
|
||||
if [ -f "$ROOT_DIR/data.dts" ]; then
|
||||
if [ -f "$UNPACKER" ]; then
|
||||
echo "[Pre-Setup] Running SRPG_Unpacker preparation steps..."
|
||||
|
||||
# Step 1: Unpack (once)
|
||||
if [ ! -d "$ROOT_DIR/data" ]; then
|
||||
if [ -f "$ROOT_DIR/data.dts" ]; then
|
||||
echo "[Pre-Setup] Step 1: Unpacking data.dts -> data"
|
||||
( cd "$ROOT_DIR" && "$UNPACKER" -o data data.dts ) || echo "[Pre-Setup] ERROR: Unpack failed."
|
||||
else
|
||||
echo "[Pre-Setup] Step 1: Skipping unpack (no data folder and no data.dts found)."
|
||||
fi
|
||||
else
|
||||
echo "[Pre-Setup] Step 1: data folder exists; skipping unpack."
|
||||
fi
|
||||
|
||||
# Step 2: Create Patch (once)
|
||||
if [ ! -d "$ROOT_DIR/patch" ]; then
|
||||
if [ -f "$ROOT_DIR/data/project.dat" ]; then
|
||||
echo "[Pre-Setup] Step 2: Creating patch from data/project.dat"
|
||||
( cd "$ROOT_DIR" && "$UNPACKER" ./data/project.dat -c ) || echo "[Pre-Setup] ERROR: Create Patch failed."
|
||||
else
|
||||
echo "[Pre-Setup] Step 2: Skipping create patch (data/project.dat not found)."
|
||||
fi
|
||||
else
|
||||
echo "[Pre-Setup] Step 2: patch folder exists; skipping create."
|
||||
fi
|
||||
else
|
||||
echo "[Pre-Setup] SRPG_Unpacker.exe not found in root; skipping pre-setup steps."
|
||||
fi
|
||||
else
|
||||
echo "[Pre-Setup] data.dts not found; skipping pre-setup SRPG steps."
|
||||
fi
|
||||
|
||||
download_extract() {
|
||||
# Download zip file into root
|
||||
echo "Downloading latest patch..."
|
||||
|
|
@ -75,6 +116,38 @@ download_extract() {
|
|||
|
||||
# Store latest SHA for next check in gameupdate
|
||||
echo "$latest_patch_sha" > "$SCRIPT_DIR/previous_patch_sha.txt"
|
||||
|
||||
# --------------------------------------------------------
|
||||
# POST-APPLY: Run Steps 3 and 4 after patch files are merged
|
||||
# 3) Apply Patch to data/project.dat
|
||||
# 4) Pack data back into data.dts
|
||||
# --------------------------------------------------------
|
||||
UNPACKER="$ROOT_DIR/SRPG_Unpacker.exe"
|
||||
if [ -f "$ROOT_DIR/data.dts" ]; then
|
||||
if [ -f "$UNPACKER" ]; then
|
||||
echo "Running SRPG_Unpacker apply/pack steps..."
|
||||
|
||||
# Step 3: Apply Patch
|
||||
if [ -f "$ROOT_DIR/data/project.dat" ]; then
|
||||
echo "Step 3: Applying patch to data/project.dat"
|
||||
( cd "$ROOT_DIR" && "$UNPACKER" ./data/project.dat -a ) || echo "ERROR: Apply Patch failed."
|
||||
else
|
||||
echo "ERROR: data/project.dat not found; cannot apply patch."
|
||||
fi
|
||||
|
||||
# Step 4: Pack
|
||||
if [ -d "$ROOT_DIR/data" ]; then
|
||||
echo "Step 4: Packing data -> data.dts"
|
||||
( cd "$ROOT_DIR" && "$UNPACKER" -o data.dts data ) || echo "WARNING: Pack failed."
|
||||
else
|
||||
echo "Step 4: Skipping pack (data folder not found)."
|
||||
fi
|
||||
else
|
||||
echo "SRPG_Unpacker.exe not found in root; skipping SRPG patch steps."
|
||||
fi
|
||||
else
|
||||
echo "data.dts not found; skipping SRPG patch steps."
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if previous_patch_sha.txt exists in gameupdate
|
||||
|
|
|
|||
Loading…
Reference in a new issue