@ECHO OFF
SET LOG=step0004.log
SET GDF=..\GameDataFolder
SET DG=..\GameDataFolder\level0_Final
ECHO LOG FILE FOR XDELTA3 PATCHES> %LOG%
ECHO ONCCstriker_dream_lab>> %LOG%
xdelta3.exe -dfs %DG%\ONCCstriker_easy_1.oni x3deltas\ONCCstriker_dream_lab.oni %DG%\ONCCstriker_dream_lab.oni>> %LOG% 2>&1
ECHO ONCCCop_generic>> %LOG%
xdelta3.exe -dfs %DG%\ONCCTCTF_lite_1.oni x3deltas\ONCCCop_generic.oni %DG%\ONCCCop_generic.oni>> %LOG% 2>&1
ECHO ONCCninjabot2>> %LOG%
xdelta3.exe -dfs %DG%\ONCCninjabot.oni x3deltas\ONCCninjabot2.oni %DG%\ONCCninjabot2.oni>> %LOG% 2>&1

ECHO TRMAninjabot2>> %LOG%
xdelta3.exe -dfs %DG%\TRMAninjabot_tx.oni x3deltas\TRMAninjabot2.oni %DG%\TRMAninjabot2.oni>> %LOG% 2>&1
ECHO TXMPninjabot2 (uncompressed)>> %LOG%
xdelta3.exe -dfs %DG%\TXMPNINJA_EASY%%2Fpractise.oni x3deltas\TXMPninjabot2.oni %DG%\TXMPninjabot2.oni>> %LOG% 2>&1
ECHO TXMPninjabot2 (compressed)>> %LOG%
xdelta3.exe -dfs %DG%\TXMPNINJA_EASY%%2Fpractise.oni x3deltas\TXMPninjabot2dxt.oni %DG%\TXMPninjabot2.oni>> %LOG% 2>&1

ECHO ONWCw10_sni>> %LOG%
xdelta3.exe -dfs %DG%\ONWCw9_scr.oni x3deltas\ONWCw10_sni.oni %DG%\ONWCw10_sni.oni>> %LOG% 2>&1
ECHO TXMPw10_sni_tex>> %LOG%
xdelta3.exe -dfs %DG%\TXMPw9_scr_tex.oni x3deltas\TXMPw10_sni_tex.oni %DG%\TXMPw10_sni_tex.oni>> %LOG% 2>&1
ECHO BINA3RAPw9_scr_e01b>> %LOG%
xdelta3.exe -dfs %DG%\BINA3RAPw9_scr_e01.oni x3deltas\BINA3RAPw9_scr_e01b.oni %DG%\BINA3RAPw9_scr_e01b.oni>> %LOG% 2>&1
ECHO BINA3RAPw9_scr_e02b>> %LOG%
xdelta3.exe -dfs %DG%\BINA3RAPw9_scr_e02.oni x3deltas\BINA3RAPw9_scr_e02b.oni %DG%\BINA3RAPw9_scr_e02b.oni>> %LOG% 2>&1
ECHO BINA3RAPw9_scr_x03a>> %LOG%
xdelta3.exe -dfs %DG%\BINA3RAPw9_scr_x03.oni x3deltas\BINA3RAPw9_scr_x03a.oni %DG%\BINA3RAPw9_scr_x03a.oni>> %LOG% 2>&1

ECHO ONWCw12_ba2>> %LOG%
xdelta3.exe -dfs %DG%\ONWCw11_ba1.oni x3deltas\ONWCw12_ba2.oni %DG%\ONWCw12_ba2.oni>> %LOG% 2>&1
ECHO TXMPw12_ba2_tex>> %LOG%
xdelta3.exe -dfs %DG%\TXMPw11_ba1_tex.oni x3deltas\TXMPw12_ba2_tex.oni %DG%\TXMPw12_ba2_tex.oni>> %LOG% 2>&1
ECHO ONWCw13_muro>> %LOG%
xdelta3.exe -dfs %DG%\ONWCw4_psm.oni x3deltas\ONWCw13_muro.oni %DG%\ONWCw13_muro.oni>> %LOG% 2>&1
ECHO TXMPw13_muro_tex>> %LOG%
xdelta3.exe -dfs %DG%\TXMPw4_psm_tex.oni x3deltas\TXMPw13_muro_tex.oni %DG%\TXMPw13_muro_tex.oni>> %LOG% 2>&1
ECHO ONWCw14_sbg2>> %LOG%
xdelta3.exe -dfs %DG%\ONWCw5_sbg.oni x3deltas\ONWCw14_sbg2.oni %DG%\ONWCw14_sbg2.oni>> %LOG% 2>&1
ECHO TXMPw14_sbg2_tex>> %LOG%
xdelta3.exe -dfs %DG%\TXMPw5_sbg_tex.oni x3deltas\TXMPw14_sbg2_tex.oni %DG%\TXMPw14_sbg2_tex.oni>> %LOG% 2>&1

FOR %%P IN (TRAM) DO (
FOR %%R IN (COMGUY ELITE KONOKO NINJA STRIKE TANKER THUG) DO (
FOR %%S IN (run_lt run_rt) DO (
IF NOT EXIST backup\level0_Final\%%P%%R%%S.oni XCOPY %DG%\%%P%%R%%S.oni backup\level0_Final\
)))
ECHO TRAMKONOKOrun_lt>> %LOG%
xdelta3.exe -dfs %DG%\TRAMKONSPRrun_lt.oni x3deltas\TRAMKONOKOrun_lt.oni %DG%\TRAMKONOKOrun_lt.oni>> %LOG% 2>&1
ECHO TRAMKONOKOrun_rt>> %LOG%
xdelta3.exe -dfs %DG%\TRAMKONSPRrun_rt.oni x3deltas\TRAMKONOKOrun_rt.oni %DG%\TRAMKONOKOrun_rt.oni>> %LOG% 2>&1
ECHO TRAMNINJArun_lt>> %LOG%
xdelta3.exe -dfs %DG%\TRAMNINSPRrun_lt.oni x3deltas\TRAMNINJArun_lt.oni %DG%\TRAMNINJArun_lt.oni>> %LOG% 2>&1
ECHO TRAMNINJArun_rt>> %LOG%
xdelta3.exe -dfs %DG%\TRAMNINSPRrun_rt.oni x3deltas\TRAMNINJArun_rt.oni %DG%\TRAMNINJArun_rt.oni>> %LOG% 2>&1
FOR %%P IN (TRAM) DO (
FOR %%R IN (COMGUY ELITE STRIKE TANKER THUG) DO (
FOR %%S IN (run_lt run_rt) DO (
ECHO %%P%%R%%S>> %LOG%
xdelta3.exe -dfs %DG%\TRAMSTRSPR%%S.oni x3deltas\TRAMSTRIKE%%S.oni %DG%\%%P%%R%%S.oni>> %LOG% 2>&1
)))

FOR %%L IN (0 1 2 3 4 6 8 9 10 11 12 13 14 18 19) DO (
    CD x3deltas\inplace
    FOR %%D IN (level%%L_Final) DO (
        IF EXIST %%D (
            CD %%D
            FOR %%F IN (*.oni) DO (
                CD ..\..\..
                IF EXIST %GDF%\%%D\%%F (
                    ECHO In-place patching: %%D\%%F>> %LOG%
                    IF NOT EXIST backup\%%D\%%F XCOPY %GDF%\%%D\%%F backup\%%D\
                    xdelta3.exe -dfs backup\%%D\%%F x3deltas\inplace\%%D\%%F %GDF%\%%D\%%F>> %LOG% 2>&1
                )
                CD x3deltas\inplace\%%D
            )
            CD ..
        )
    )
    CD ..\..
)
