@Echo off
Echo UT99 StrikeForce 1.84 client FIX patch 2 - This fix patches your StrikeForce.ini with Server Browser Fix (v1.2 by Jovi), Direct3D9 renderer (v1.3 by Chris Dohnal) and OpenAL Audio (v2.4.7 UT by Smirftsch. Restores 3D-surround sound)
pause
Echo Please wait !

IF EXIST "StrikeForce.ini" (

	echo Patch executed on %date% at %time% >> UT99_StrikeForce_1.84_client_FIX_patch2.log
	
	IF NOT EXIST "StrikeForce-backup-patch2.ini" (
		copy StrikeForce.ini StrikeForce-backup-patch2.ini
		echo Backup copy of StrikeForce.ini made: StrikeForce-backup-patch2.ini
	)
		
	powershell -Command "(gc StrikeForce.ini) | where-object {$_ -like '*EavyServerBrowser.EavyServerBrowser,GameType=sfdm*'}" > testi.txt
	powershell -Command "if((Get-Item testi.txt).length -gt 0kb) { (gc StrikeForce.ini) -replace 'EavyServerBrowser.EavyServerBrowser,GameType=sfdm', 'SFBrowser.SFBrowserSubsetFact,SupersetTag=UBrowserAll,GameType=SFDM,bCompatibleServersOnly=True' | Out-File fix1.txt -Encoding:ASCII }"
	del testi.txt
	IF EXIST "fix1.txt" (
		copy /b /y fix1.txt StrikeForce.ini
		del fix1.txt
		echo Fix 1 succesfully patched. >>UT99_StrikeForce_1.84_client_FIX_patch2.log
	)

	powershell -Command "(gc StrikeForce.ini) | where-object {$_ -like '*EavyServerBrowser.EavyServerBrowser,GameType=SFEscape*'}" > testi.txt
	powershell -Command "if((Get-Item testi.txt).length -gt 0kb) { (gc StrikeForce.ini) -replace 'EavyServerBrowser.EavyServerBrowser,GameType=SFEscape', 'SFBrowser.SFBrowserSubsetFact,SupersetTag=UBrowserAll,GameType=SFEscape,bCompatibleServersOnly=True' | Out-File fix2.txt -Encoding:ASCII }"
	del testi.txt
	IF EXIST "fix2.txt" (
		copy /b /y fix2.txt StrikeForce.ini
		del fix2.txt
		echo Fix 2 succesfully patched. >>UT99_StrikeForce_1.84_client_FIX_patch2.log
	)

	powershell -Command "(gc StrikeForce.ini) | where-object {$_ -like '*EavyServerBrowser.EavyServerBrowser,GameType=SFHostageRescue*'}" > testi.txt
	powershell -Command "if((Get-Item testi.txt).length -gt 0kb) { (gc StrikeForce.ini) -replace 'EavyServerBrowser.EavyServerBrowser,GameType=SFHostageRescue', 'SFBrowser.SFBrowserSubsetFact,SupersetTag=UBrowserAll,GameType=SFHostageRescue,bCompatibleServersOnly=True' | Out-File fix3.txt -Encoding:ASCII }"
	del testi.txt
	IF EXIST "fix3.txt" (
		copy /b /y fix3.txt StrikeForce.ini
		del fix3.txt
		echo Fix 3 succesfully patched. >>UT99_StrikeForce_1.84_client_FIX_patch2.log
	)

	powershell -Command "(gc StrikeForce.ini) | where-object {$_ -like '*EavyServerBrowser.EavyServerBrowser,GameType=sfteamdm*'}" > testi.txt
	powershell -Command "if((Get-Item testi.txt).length -gt 0kb) { (gc StrikeForce.ini) -replace 'EavyServerBrowser.EavyServerBrowser,GameType=sfteamdm', 'SFBrowser.SFBrowserSubsetFact,SupersetTag=UBrowserAll,GameType=SFTeamDM,bCompatibleServersOnly=True' | Out-File fix4.txt -Encoding:ASCII }"
	del testi.txt
	IF EXIST "fix4.txt" (
		copy /b /y fix4.txt StrikeForce.ini
		del fix4.txt
		echo Fix 4 succesfully patched. >>UT99_StrikeForce_1.84_client_FIX_patch2.log
	)

	powershell -Command "(gc StrikeForce.ini) | where-object {$_ -like '*unreal.epicgames.com*'}" > testi.txt
	powershell -Command "if((Get-Item testi.txt).length -gt 0kb) { (gc StrikeForce.ini) -replace 'unreal.epicgames.com', 'utmaster.epicgames.com' | Out-File fix5.txt -Encoding:ASCII }"
	del testi.txt
	IF EXIST "fix5.txt" (
		copy /b /y fix5.txt StrikeForce.ini
		del fix5.txt
		echo Fix 5 succesfully patched. >>UT99_StrikeForce_1.84_client_FIX_patch2.log
	)

	powershell -Command "(gc StrikeForce.ini) | where-object {$_ -like '*master0.gamespy.com*'}" > testi.txt
	powershell -Command "if((Get-Item testi.txt).length -gt 0kb) { (gc StrikeForce.ini) -replace 'master0.gamespy.com', 'master.oldunreal.com' | Out-File fix6.txt -Encoding:ASCII }"
	del testi.txt
	IF EXIST "fix6.txt" (
		copy /b /y fix6.txt StrikeForce.ini
		del fix6.txt
		echo Fix 6 succesfully patched. >>UT99_StrikeForce_1.84_client_FIX_patch2.log
	)

	powershell -Command "(gc StrikeForce.ini) | where-object {$_ -like '*bKeepMasterServer=False*'}" > testi.txt
	powershell -Command "if((Get-Item testi.txt).length -gt 0kb) { (gc StrikeForce.ini) -replace 'bKeepMasterServer=False', 'bKeepMasterServer=True' | Out-File fix7.txt -Encoding:ASCII }"
	del testi.txt
	IF EXIST "fix7.txt" (
		copy /b /y fix7.txt StrikeForce.ini
		del fix7.txt
		echo Fix 7 succesfully patched. >>UT99_StrikeForce_1.84_client_FIX_patch2.log
	)

	powershell -Command "(gc StrikeForce.ini) | where-object {$_ -like '*bFallbackFactories=True*'}" > testi.txt
	powershell -Command "if((Get-Item testi.txt).length -gt 0kb) { (gc StrikeForce.ini) -replace 'bFallbackFactories=True', 'bFallbackFactories=False' | Out-File fix8.txt -Encoding:ASCII }"
	del testi.txt
	IF EXIST "fix8.txt" (
		copy /b /y fix8.txt StrikeForce.ini
		del fix8.txt
		echo Fix 8 succesfully patched. >>UT99_StrikeForce_1.84_client_FIX_patch2.log
	)
	
	IF EXIST "SF_ini-fixes" (
		copy /b /y StrikeForce.ini+SF_ini-fixes StrikeForce.ini
		echo Fix 9 succesfully patched. >>UT99_StrikeForce_1.84_client_FIX_patch2.log
	)
	
	echo Patch job finished. >> UT99_StrikeForce_1.84_client_FIX_patch2.log
	Echo Done.
	pause
) ELSE (
		Echo I wasn't able to find StrikeForce.ini. Please unzip all files of this patch to UnrealTournament\System folder and run this UT99_StrikeForce_1.84_client_FIX_patch2.cmd there !
		pause
)
