Skip to content

Instantly share code, notes, and snippets.

@mmtrt
Last active March 9, 2022 14:27
Show Gist options
  • Save mmtrt/0fdce3f4e252a2755b4fe097e5c92483 to your computer and use it in GitHub Desktop.
Save mmtrt/0fdce3f4e252a2755b4fe097e5c92483 to your computer and use it in GitHub Desktop.
@ECHO OFF
@SETLOCAL EnableDelayedExpansion
set LF=^& ECHO.
CD INI
for /F "delims=" %%G in ('findstr /n "=Maps" MPMaps.ini') do set "lastoccur=%%G"
set lastnum=%lastoccur:~4,3%
set lastmap=%lastoccur:~7,100%
set lastmapap=%lastoccur:~4,100%
set /a mpn1=%lastnum%+1
set /a mpn2=%lastnum%+2
set /a mpn3=%lastnum%+3
set /a mpn4=%lastnum%+4
set /a mpn5=%lastnum%+5
set /a mpn6=%lastnum%+6
set /a mpn7=%lastnum%+7
set /a mpn8=%lastnum%+8
set /a mpn9=%lastnum%+9
Rem | Configuration
Set "FileToEdit=MPMaps.ini"
Set "LineToFind=%lastmapap%"
Set "LineToPutAfter=%mpn1%=Maps\Custom\2_tour_of_egypt_gold%LF%%mpn2%=Maps\Custom\3_scortched_earth_v1%LF%%mpn3%=Maps\Custom\6_tour_of_egypt_gold%LF%%mpn4%=Maps\Custom\6_tour_of_egypt_gold_ed%LF%%mpn5%=Maps\Custom\6_tour_of_egypt_gold_nc%LF%%mpn6%=Maps\Custom\6_tour_of_egypt_gold_v1%LF%%mpn7%=Maps\Custom\8_tour_of_egypt_gold_nc%LF%%mpn8%=Maps\Custom\8_tour_of_egypt_gold_nc_v2%LF%%mpn9%=Maps\Custom\8_tour_of_egypt_gold_v1"
Rem | Check If "FileToEdit" Exists
IF NOT EXIST "%FileToEdit%" (
ECHO File "%FileToEdit%" Not Found!
PAUSE
GOTO :EOF
)
Rem | Check If "FileToEdit" Is Already Modified
FIND /I /C "8_tour_of_egypt_gold_v1" %FileToEdit% >NUL
IF %ERRORLEVEL% EQU 1 GOTO StartFunction
ECHO.
ECHO "%FileToEdit%" file is already patched.
ECHO.
PAUSE
GOTO :EOF
:StartFunction
Rem | Export SearchString
ECHO !LineToFind!>LineToFind.txt
Rem | Add Text Under %LineToFind%
(
FOR /f "delims=" %%i IN (LineToFind.txt) DO (
SET AddAfter=%%i
FOR /f "delims=" %%n IN ('findstr /n "^" %FileToEdit%') DO (
SET line=%%n
SET line=!line:*:=!
ECHO(!line!
IF "!line!"=="!AddAfter!" ECHO(%LineToPutAfter%
)
)
)>>%FileToEdit%.TEMP
( ECHO.
ECHO.[Maps\Custom\2_tour_of_egypt_gold]
ECHO.Description=[2] Tour of Egypt Gold
ECHO.Author=mmtrt
ECHO.GameModes=Battle,Free For All,Unholy Alliance,Meat Grinder,SFJ
ECHO.Waypoint0=93044
ECHO.Waypoint1=45090
ECHO.MinPlayers=1
ECHO.MaxPlayers=2
ECHO.EnforceMaxPlayers=True
ECHO.Size=0,0,69,69
ECHO.LocalSize=2,4,65,63
ECHO.PreviewSize=0,0,106,61
ECHO.
ECHO.[Maps\Custom\3_scortched_earth_v1]
ECHO.Description=[3] Scortched Earth v1
ECHO.Author=Blkwaltz3, mmtrt
ECHO.GameModes=Battle,Free For All,Naval War,Unholy Alliance,Meat Grinder,SFJ
ECHO.Waypoint0=142081
ECHO.Waypoint1=87136
ECHO.Waypoint2=163157
ECHO.MinPlayers=1
ECHO.MaxPlayers=3
ECHO.EnforceMaxPlayers=True
ECHO.Size=0,0,121,134
ECHO.LocalSize=2,4,117,128
ECHO.
ECHO.[Maps\Custom\6_tour_of_egypt_gold]
ECHO.Description=[6] Tour of Egypt Gold
ECHO.Author=mmtrt
ECHO.GameModes=Battle,Free For All,Team Alliance,Unholy Alliance,Meat Grinder,SFJ
ECHO.Waypoint0=72022
ECHO.Waypoint1=93043
ECHO.Waypoint2=113063
ECHO.Waypoint3=24070
ECHO.Waypoint4=45091
ECHO.Waypoint5=65111
ECHO.MinPlayers=1
ECHO.MaxPlayers=6
ECHO.EnforceMaxPlayers=True
ECHO.Size=0,0,69,69
ECHO.LocalSize=2,4,65,63
ECHO.PreviewSize=0,0,138,69
ECHO.TeamStartMapping0=A,A,A,B,B,B
ECHO.TeamStartMapping0Name=Left vs Right
ECHO.
ECHO.[Maps\Custom\6_tour_of_egypt_gold_ed]
ECHO.Description=[6] Tour of Egypt Gold Ed
ECHO.Author=mmtrt
ECHO.GameModes=Battle,Free For All,Team Alliance,Unholy Alliance,Meat Grinder,SFJ
ECHO.Waypoint0=72022
ECHO.Waypoint1=93043
ECHO.Waypoint2=113063
ECHO.Waypoint3=24070
ECHO.Waypoint4=45091
ECHO.Waypoint5=65111
ECHO.MinPlayers=1
ECHO.MaxPlayers=6
ECHO.EnforceMaxPlayers=True
ECHO.Size=0,0,69,69
ECHO.LocalSize=2,4,65,63
ECHO.PreviewSize=0,0,138,69
ECHO.TeamStartMapping0=A,A,A,B,B,B
ECHO.TeamStartMapping0Name=Left vs Right
ECHO.
ECHO.[Maps\Custom\6_tour_of_egypt_gold_nc]
ECHO.Description=[6] Tour of Egypt Gold NC
ECHO.Author=mmtrt
ECHO.GameModes=Battle,Free For All,Team Alliance,Unholy Alliance,Meat Grinder,SFJ
ECHO.Waypoint0=72022
ECHO.Waypoint1=93043
ECHO.Waypoint2=113063
ECHO.Waypoint3=24070
ECHO.Waypoint4=45091
ECHO.Waypoint5=65111
ECHO.MinPlayers=1
ECHO.MaxPlayers=6
ECHO.EnforceMaxPlayers=True
ECHO.Size=0,0,69,69
ECHO.LocalSize=2,4,65,63
ECHO.PreviewSize=0,0,106,61
ECHO.TeamStartMapping0=A,A,A,B,B,B
ECHO.TeamStartMapping0Name=Left vs Right
ECHO.
ECHO.[Maps\Custom\6_tour_of_egypt_gold_v1]
ECHO.Description=[6] Tour of Egypt Gold V1
ECHO.Author=mmtrt
ECHO.GameModes=Battle,Free For All,Team Alliance,Unholy Alliance,Meat Grinder,SFJ
ECHO.Waypoint0=72022
ECHO.Waypoint1=93043
ECHO.Waypoint2=113063
ECHO.Waypoint3=24070
ECHO.Waypoint4=45091
ECHO.Waypoint5=65111
ECHO.MinPlayers=1
ECHO.MaxPlayers=6
ECHO.EnforceMaxPlayers=True
ECHO.Size=0,0,69,69
ECHO.LocalSize=2,4,65,63
ECHO.PreviewSize=0,0,106,61
ECHO.TeamStartMapping0=A,A,A,B,B,B
ECHO.TeamStartMapping0Name=Left vs Right
ECHO.
ECHO.[Maps\Custom\8_tour_of_egypt_gold_nc]
ECHO.Description=[8] Tour of Egypt Gold NC
ECHO.Author=mmtrt
ECHO.GameModes=Battle,Free For All,Team Alliance,Unholy Alliance,Meat Grinder,SFJ
ECHO.Waypoint0=72022
ECHO.Waypoint1=93043
ECHO.Waypoint2=113063
ECHO.Waypoint3=24070
ECHO.Waypoint4=45091
ECHO.Waypoint5=65111
ECHO.Waypoint6=88059
ECHO.Waypoint7=63087
ECHO.MinPlayers=1
ECHO.MaxPlayers=8
ECHO.EnforceMaxPlayers=True
ECHO.Size=0,0,69,69
ECHO.LocalSize=2,4,65,63
ECHO.PreviewSize=0,0,106,61
ECHO.TeamStartMapping0=A,A,A,A,B,B,B,B
ECHO.TeamStartMapping0Name=Left vs Right
ECHO.
ECHO.[Maps\Custom\8_tour_of_egypt_gold_nc_v2]
ECHO.Description=[8] Tour of Egypt Gold NC V2
ECHO.Author=mmtrt
ECHO.GameModes=Battle,Free For All,Team Alliance,Unholy Alliance,Meat Grinder,SFJ
ECHO.Waypoint0=107031
ECHO.Waypoint1=138062
ECHO.Waypoint2=170093
ECHO.Waypoint3=161112
ECHO.Waypoint4=27104
ECHO.Waypoint5=62139
ECHO.Waypoint6=90168
ECHO.Waypoint7=113167
ECHO.MinPlayers=1
ECHO.MaxPlayers=8
ECHO.EnforceMaxPlayers=True
ECHO.Size=0,0,100,100
ECHO.LocalSize=2,4,96,94
ECHO.PreviewSize=0,0,200,100
ECHO.TeamStartMapping0=A,A,A,A,B,B,B,B
ECHO.TeamStartMapping0Name=Left vs Right
ECHO.
ECHO.[Maps\Custom\8_tour_of_egypt_gold_v1]
ECHO.Description=[8] Tour of Egypt Gold V1
ECHO.Author=mmtrt
ECHO.GameModes=Battle,Free For All,Team Alliance,Unholy Alliance,Meat Grinder,SFJ
ECHO.Waypoint0=72022
ECHO.Waypoint1=93043
ECHO.Waypoint2=113063
ECHO.Waypoint3=24070
ECHO.Waypoint4=45091
ECHO.Waypoint5=65111
ECHO.Waypoint6=88059
ECHO.Waypoint7=63087
ECHO.MinPlayers=1
ECHO.MaxPlayers=8
ECHO.EnforceMaxPlayers=True
ECHO.Size=0,0,69,69
ECHO.LocalSize=2,4,65,63
ECHO.PreviewSize=0,0,106,61
ECHO.TeamStartMapping0=A,A,A,A,B,B,B,B
ECHO.TeamStartMapping0Name=Left vs Right
)>>%FileToEdit%.TEMP
Rem | Backup Original File, Restore New
REN %FileToEdit% %FileToEdit%.bak-%time:~0,2%%time:~3,2%%time:~6,2%_%date:~-10,2%%date:~-7,2%%date:~-4,4%
REN %FileToEdit%.TEMP %FileToEdit%
Rem | Remove LineToFind.txt
DEL LineToFind.txt
GOTO :EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment