Skip to content

Commit 06b6322

Browse files
authored
Removed exe patching from installer. Enabled fatal error if patching fails in loader. (#1580)
1 parent 625e86b commit 06b6322

File tree

8 files changed

+21
-195
lines changed

8 files changed

+21
-195
lines changed

Client/loader/CExePatchedStatus.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ bool ShouldUseExeCopy()
9999
if (RequiresAltTabFix())
100100
strUseCopyReason += " AltTabFix";
101101

102-
if (ShouldForceUseExeCopy())
103-
strUseCopyReason += " ForceUseExeCopy";
104-
105102
// Log reason for using proxy_sa
106103
static SString strUseCopyReasonPrevious;
107104
if (strUseCopyReasonPrevious != strUseCopyReason)
@@ -112,23 +109,6 @@ bool ShouldUseExeCopy()
112109
return !strUseCopyReason.empty();
113110
}
114111

115-
//////////////////////////////////////////////////////////
116-
//
117-
// ShouldForceUseExeCopy
118-
//
119-
// Determine if gta_sa.exe looks unusable (under 10MB)
120-
// AND proxy_sa.exe looks usable (over 10MB)
121-
//
122-
//////////////////////////////////////////////////////////
123-
bool ShouldForceUseExeCopy()
124-
{
125-
SString strGTAPath = GetGTAPath();
126-
if (FileSize(PathJoin(strGTAPath, MTA_GTAEXE_NAME)) < 10 * 1024 * 1024)
127-
if (FileSize(PathJoin(strGTAPath, MTA_HTAEXE_NAME)) > 10 * 1024 * 1024)
128-
return true;
129-
return false;
130-
}
131-
132112
//////////////////////////////////////////////////////////
133113
//
134114
// RequiresAltTabFix
@@ -226,8 +206,6 @@ SString GetExePathFilename(bool bUseExeCopy)
226206
SString strGTAPath = GetGTAPath();
227207
if (!strGTAPath.empty())
228208
{
229-
if (ShouldForceUseExeCopy())
230-
bUseExeCopy = true;
231209
const char* szExeName = bUseExeCopy ? MTA_HTAEXE_NAME : MTA_GTAEXE_NAME;
232210
SString strGTAEXEPath = PathJoin(strGTAPath, szExeName);
233211
return strGTAEXEPath;

Client/loader/CExePatchedStatus.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ SString GetPatchExeAdminReason(bool bUseExeCopy, const SExePatchedStat
4949
uint64 GetExeFileSize(bool bUseExeCopy);
5050
bool CopyExe();
5151
SString GetExePathFilename(bool bUseExeCopy);
52-
bool ShouldForceUseExeCopy();
5352
SString GetUsingExePathFilename();
5453
bool GetPatchRequirementAltModules();
5554
EPatchResult UpdatePatchStatusNvightmare(const SString& strGTAEXEPath, EPatchMode mode);

Client/loader/CInstallManager.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -583,12 +583,8 @@ SString CInstallManager::_ProcessGtaVersionCheck()
583583
AddReportLog(5053, SString("_ProcessGtaVersionCheck: Incorrect file '%s' %d %s", *strPatchBase, (int)FileSize(strPatchBase), *strPatchBaseCurrentMd5));
584584
SString strMessage(_("MTA:SA cannot continue because the following files are incorrect:"));
585585
strMessage += "\n\n" + strPatchBase;
586-
#ifdef TO_DO
587586
BrowseToSolution("gengta_pakfiles", ASK_GO_ONLINE, strMessage);
588587
return "quit";
589-
#else
590-
return "ok";
591-
#endif
592588
}
593589

594590
// Ensure GTA exe is not running
@@ -619,12 +615,8 @@ SString CInstallManager::_ProcessGtaVersionCheck()
619615
SString strMessage(_("MTA:SA cannot continue because the following files are incorrect:"));
620616
strMessage += "\n\n" + strGtaExe;
621617
strMessage += "\n\n" + _("Error") + SString(" %d", result);
622-
#ifdef TO_DO
623618
BrowseToSolution(SString("gengta_error&code=%d", result), ASK_GO_ONLINE, strMessage);
624619
return "quit";
625-
#else
626-
return "ok";
627-
#endif
628620
}
629621
}
630622

Client/loader/Main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#define MTA_GTAEXE_NAME "gta_sa.exe"
1515
#define MTA_HTAEXE_NAME "proxy_sa.exe"
16-
#define MTA_GTASTEAMEXE_NAME "gta-sa.exe"
16+
#define MTA_GTA_KNOWN_FILE_NAME "models\\gta3.img"
1717
#define MTA_GUID "Global\\{4962AF5F-5D82-412D-9CCA-AB8BB9DBD353}"
1818
#define URI_CONNECT 1
1919
#define MTA_EXE_NAME_RELEASE "Multi Theft Auto.exe"

Client/loader/MainFunctions.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -631,14 +631,6 @@ void ValidateGTAPath()
631631
_E("CL13"));
632632
return ExitProcess(EXIT_ERROR);
633633
}
634-
else if (iResult == GAME_PATH_STEAM)
635-
{
636-
DisplayErrorMessageBox(_("It appears you have a Steam version of GTA:SA, which is currently incompatible with MTASA. You are now being redirected to "
637-
"a page where you can find information to resolve this issue."),
638-
_E("CL14"));
639-
BrowseToSolution("downgrade-steam");
640-
return ExitProcess(EXIT_ERROR);
641-
}
642634

643635
const SString strGTAPath = GetGTAPath();
644636
const SString strMTASAPath = GetMTASAPath();

Client/loader/Utils.cpp

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -789,40 +789,21 @@ ePathResult GetGamePath(SString& strOutResult, bool bFindIfMissing)
789789
return GAME_PATH_UNICODE_CHARS;
790790
}
791791

792-
// Then step through looking for an existing file
793-
bool bFoundSteamExe = false;
794-
SString strRegPath;
792+
// Then step through looking for a known existing file
795793
for (uint i = 0; i < pathList.size(); i++)
796794
{
797795
if (pathList[i].empty())
798796
continue;
799797

800-
if (FileExists(PathJoin(pathList[i], MTA_GTAEXE_NAME)))
798+
if (FileExists(PathJoin(pathList[i], MTA_GTA_KNOWN_FILE_NAME)))
801799
{
802-
strRegPath = pathList[i];
803-
break;
804-
}
805-
if (FileExists(PathJoin(pathList[i], MTA_GTASTEAMEXE_NAME)))
806-
{
807-
bFoundSteamExe = true;
800+
strOutResult = pathList[i];
801+
// Update registry.
802+
SetCommonRegistryValue("", "GTA:SA Path", strOutResult);
803+
return GAME_PATH_OK;
808804
}
809805
}
810806

811-
// Found an exe?
812-
if (!strRegPath.empty())
813-
{
814-
strOutResult = strRegPath;
815-
// Update registry.
816-
SetCommonRegistryValue("", "GTA:SA Path", strOutResult);
817-
return GAME_PATH_OK;
818-
}
819-
820-
// Found a steam exe?
821-
if (bFoundSteamExe)
822-
{
823-
return GAME_PATH_STEAM;
824-
}
825-
826807
// Try to find?
827808
if (!bFindIfMissing)
828809
return GAME_PATH_MISSING;
@@ -852,19 +833,13 @@ ePathResult GetGamePath(SString& strOutResult, bool bFindIfMissing)
852833
}
853834

854835
// Check browse result
855-
if (!FileExists(PathJoin(strOutResult, MTA_GTAEXE_NAME)))
836+
if (!FileExists(PathJoin(strOutResult, MTA_GTA_KNOWN_FILE_NAME)))
856837
{
857-
if (FileExists(PathJoin(strOutResult, MTA_GTASTEAMEXE_NAME)))
858-
return GAME_PATH_STEAM;
859-
860838
// If browse didn't help, try another method
861839
strOutResult = DoUserAssistedSearch();
862840

863-
if (!FileExists(PathJoin(strOutResult, MTA_GTAEXE_NAME)))
841+
if (!FileExists(PathJoin(strOutResult, MTA_GTA_KNOWN_FILE_NAME)))
864842
{
865-
if (FileExists(PathJoin(strOutResult, MTA_GTASTEAMEXE_NAME)))
866-
return GAME_PATH_STEAM;
867-
868843
// If still not found, give up
869844
return GAME_PATH_MISSING;
870845
}

Client/loader/Utils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ extern HINSTANCE g_hInstance;
1313

1414
enum ePathResult
1515
{
16-
GAME_PATH_STEAM,
1716
GAME_PATH_UNICODE_CHARS,
1817
GAME_PATH_MISSING,
1918
GAME_PATH_OK,

Shared/installer/nightly.nsi

Lines changed: 12 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -576,79 +576,16 @@ SectionGroup /e "$(INST_SEC_CLIENT)" SECGCLIENT
576576
Call RemoveVirtualStore
577577
${EndIf}
578578
${EndIf}
579-
#############################################################
580-
581-
# Handle "Grand Theft Auto San Andreas.exe" being present instead of gta_sa.exe
582-
IfFileExists "$GTA_DIR\gta_sa.exe" noCopyReq
583-
IfFileExists "$GTA_DIR\Grand Theft Auto San Andreas.exe" 0 noCopyReq
584-
CopyFiles "$GTA_DIR\Grand Theft Auto San Andreas.exe" "$GTA_DIR\gta_sa.exe"
585-
noCopyReq:
586579

587580
#############################################################
588-
# Patch our San Andreas .exe if it is required
589-
nsArray::SetList array "gta_sa.exe" "gta-sa.exe" "testapp.exe" /end
590-
${ForEachIn} array $0 $1
591-
IfFileExists $GTA_DIR\$1 0 TryNextExe
592-
${GetSize} "$GTA_DIR" "/M=$1 /S=0M /G=0" $0 $3 $4
593-
StrCmp "$0" "0" TryNextExe
594-
!insertmacro GetMD5 $GTA_DIR\$1 $ExeMD5
595-
DetailPrint "$1 successfully detected ($ExeMD5)"
596-
${LogText} "GetMD5 $GTA_DIR\$1 $ExeMD5"
597-
${Switch} $ExeMD5
598-
${Case} "bf25c28e9f6c13bd2d9e28f151899373" #US 2.00
599-
${Case} "7fd5f9436bd66af716ac584ff32eb483" #US 1.01
600-
${Case} "d84326ba0e0ace89f87288ffe7504da4" #EU 3.00 Steam Mac
601-
${Case} "4e99d762f44b1d5e7652dfa7e73d6b6f" #EU 2.00
602-
${Case} "2ac4b81b3e85c8d0f9846591df9597d3" #EU 1.01
603-
${Case} "d0ad36071f0e9bead7bddea4fbda583f" #EU 1.01 GamersGate
604-
${Case} "25405921d1c47747fd01fd0bfe0a05ae" #EU 1.01 DEViANCE
605-
${Case} "a2929a61e4d63dd3c15749b2b7ed74ae" #?? 1.01
606-
${Case} "9effcaf66b59b9f8fb8dff920b3f6e63" #DE 2.00
607-
${Case} "fa490564cd9811978085a7a8f8ed7b2a" #DE 1.01
608-
${Case} "49dd417760484a18017805df46b308b8" #DE 1.00
609-
${Case} "185f0970f5913d0912a89789af175ffe" #?? ?.?? 4,496,063 bytes
610-
${Case} "0fd315d1af41e26e536a78b4d4556488" #EU 3.00 Steam 2007-12-04 11:50:50 5697536
611-
${Case} "2ed36a3cee7b77da86a343838e3516b6" #EU 3.01 Steam (2014 Nov update) 2014-10-14 21:58:05 5971456
612-
${Case} "5bfd4dd83989a8264de4b8e771f237fd" #EU 3.02 Steam (2014 Dec update) 2014-12-01 20:43:21 5971456
613-
${Case} "d9cb35c898d3298ca904a63e10ee18d7" #DE 3.02 Steam (2014 Dec update) 2016-08-11 20:57:22 5971456
614-
${Case} "c29d96e0c063cd4568d977bcf273215f" #?? ?.?? 5,719,552 bytes
615-
# Copy to gta_sa.exe.bak and patch to gta_sa.exe
616-
CopyFiles "$GTA_DIR\$1" "$GTA_DIR\gta_sa.exe.bak"
617-
StrCpy $PATCH_TARGET "$GTA_DIR\gta_sa.exe"
618-
Call InstallPatch
619-
${If} $PatchInstalled == "1"
620-
Goto CompletePatchProc
621-
${EndIf}
622-
Goto TryNextExe
623-
${Break}
624-
625-
${Case} "6687a315558935b3fc80cdbff04437a4" #?? ?.?? 5,685,688 bytes (RS Launcher 2019-08-29)
626-
# Don't patch if proxy_sa is already present (and is over 10MB)
627-
${GetSize} "$GTA_DIR" "/M=proxy_sa.exe /S=0M /G=0" $0 $3 $4
628-
${If} $0 > 10
629-
Goto CompletePatchProc
630-
${EndIf}
631-
# Copy to gta_sa.exe.bak and patch to proxy_sa.exe
632-
CopyFiles "$GTA_DIR\$1" "$GTA_DIR\gta_sa.exe.bak"
633-
StrCpy $PATCH_TARGET "$GTA_DIR\proxy_sa.exe"
634-
Call InstallPatch
635-
${If} $PatchInstalled == "1"
636-
Goto CompletePatchProc
637-
${EndIf}
638-
Goto TryNextExe
639-
${Break}
640-
${Default}
641-
${If} $1 == "gta_sa.exe"
642-
Goto CompletePatchProc #This gta_sa.exe doesn't need patching, let's continue
643-
${EndIf}
644-
${Break}
645-
${EndSwitch}
646-
TryNextExe:
647-
${Next}
648-
649-
NoExeFound:
581+
# Issue warning if GTA path looks incorrect
582+
Push $GTA_DIR
583+
Call IsGtaDirectory
584+
Pop $0
585+
${If} $0 != "gta"
650586
MessageBox MB_ICONSTOP "$(MSGBOX_INVALID_GTASA)"
651-
CompletePatchProc:
587+
${EndIf}
588+
#############################################################
652589

653590
#############################################################
654591
# Fix missing or incorrect VS2013 redist files
@@ -1184,45 +1121,6 @@ Function SkipDirectoryPage
11841121
FunctionEnd
11851122

11861123

1187-
;====================================================================================
1188-
; Patcher related functions
1189-
;====================================================================================
1190-
Var PATCHFILE
1191-
1192-
LangString MSGBOX_PATCH_FAIL1 ${LANG_ENGLISH} "Unable to download the patch file for your version of Grand Theft Auto: San Andreas"
1193-
LangString MSGBOX_PATCH_FAIL2 ${LANG_ENGLISH} "Unable to install the patch file for your version of Grand Theft Auto: San Andreas"
1194-
Function InstallPatch
1195-
${LogText} "+Function begin - InstallPatch"
1196-
DetailPrint "Incompatible version of San Andreas detected. Patching executable..."
1197-
StrCpy $PATCHFILE "$TEMP\$ExeMD5.GTASAPatch"
1198-
NSISdl::download "http://mirror.multitheftauto.com/gdata/$ExeMD5.GTASAPatch" $PATCHFILE
1199-
Pop $0
1200-
${If} $0 != "success"
1201-
DetailPrint "* Download of patch file failed:"
1202-
DetailPrint "* $0"
1203-
DetailPrint "* Installation continuing anyway"
1204-
MessageBox MB_ICONSTOP "$(MSGBOX_PATCH_FAIL1)"
1205-
StrCpy $PatchInstalled "0"
1206-
${Else}
1207-
DetailPrint "Patch download successful. Installing patch..."
1208-
vpatch::vpatchfile "$PATCHFILE" "$GTA_DIR\gta_sa.exe.bak" $PATCH_TARGET
1209-
Pop $R0
1210-
${If} $R0 == "OK"
1211-
StrCpy $PatchInstalled "1"
1212-
${ElseIf} $R0 == "OK, new version already installed"
1213-
StrCpy $PatchInstalled "1"
1214-
${Else}
1215-
StrCpy $PatchInstalled "0"
1216-
DetailPrint "* Some error occured installing the patch for Grand Theft Auto: San Andreas:"
1217-
DetailPrint "* $R0"
1218-
DetailPrint "* It is required in order to run Multi Theft Auto : San Andreas"
1219-
DetailPrint "* Installation continuing anyway"
1220-
MessageBox MB_ICONSTOP MSGBOX_PATCH_FAIL2
1221-
${EndIf}
1222-
${EndIf}
1223-
${LogText} "-Function end - InstallPatch"
1224-
FunctionEnd
1225-
12261124
;====================================================================================
12271125
; UAC related functions
12281126
;====================================================================================
@@ -1891,8 +1789,8 @@ Function "GTADirectoryLeaveProc"
18911789
Abort
18921790
hasdir:
18931791

1894-
; data subdirectory should exist
1895-
IfFileExists "$GTA_DIR\data\*.*" cont
1792+
; models\gta3.img should exist
1793+
IfFileExists "$GTA_DIR\models\gta3.img" cont
18961794
MessageBox MB_OKCANCEL|MB_ICONQUESTION|MB_TOPMOST|MB_SETFOREGROUND \
18971795
"$(INST_GTA_ERROR2)" \
18981796
IDOK cont1
@@ -1916,17 +1814,10 @@ Function IsGtaDirectory
19161814
Pop $0
19171815
StrCpy $1 "gta"
19181816

1919-
; gta_sa.exe or gta-sa.exe should exist
1920-
IfFileExists "$0\gta_sa.exe" cont1
1921-
IfFileExists "$0\gta-sa.exe" cont1
1922-
IfFileExists "$0\Grand Theft Auto San Andreas.exe" cont1
1923-
StrCpy $1 ""
1924-
cont1:
1925-
1926-
; data subdirectory should exist
1927-
IfFileExists "$0\data\*.*" cont2
1817+
; models\gta3.img should exist
1818+
${IfNot} ${FileExists} "$0\models\gta3.img"
19281819
StrCpy $1 ""
1929-
cont2:
1820+
${EndIf}
19301821

19311822
Push $1
19321823
FunctionEnd

0 commit comments

Comments
 (0)