From 6a912c128d12a80d3a7bba494de36ab4f25ea257 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sun, 14 Nov 2021 22:37:27 +0100 Subject: [PATCH] Setup: use GetSNESMD5OfFile (by Black Sliver) --- inno_setup_310.iss | 42 +++++++++++++++++++++++++++--------------- inno_setup_38.iss | 42 +++++++++++++++++++++++++++--------------- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/inno_setup_310.iss b/inno_setup_310.iss index 1da72694..23fa7fc4 100644 --- a/inno_setup_310.iss +++ b/inno_setup_310.iss @@ -48,20 +48,20 @@ Name: "playing"; Description: "Installation for playing purposes" Name: "custom"; Description: "Custom installation"; Flags: iscustom [Components] -Name: "core"; Description: "Core Files"; Types: full hosting playing custom; Flags: fixed -Name: "generator"; Description: "Generator"; Types: full hosting -Name: "generator/sm"; Description: "Super Metroid ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 3145728 -Name: "generator/soe"; Description: "Secret of Evermore ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 3145728 -Name: "generator/lttp"; Description: "A Link to the Past ROM Setup and Enemizer"; Types: full hosting; ExtraDiskSpaceRequired: 5191680 -Name: "generator/oot"; Description: "Ocarina of Time ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 100663296 -Name: "server"; Description: "Server"; Types: full hosting -Name: "client"; Description: "Clients"; Types: full playing -Name: "client/sni"; Description: "SNI Client"; Types: full playing -Name: "client/sni/lttp"; Description: "SNI Client - A Link to the Past Patch Setup"; Types: full playing -Name: "client/sni/sm"; Description: "SNI Client - Super Metroid Patch Setup"; Types: full playing -Name: "client/factorio"; Description: "Factorio"; Types: full playing +Name: "core"; Description: "Core Files"; Types: full hosting playing custom; Flags: fixed +Name: "generator"; Description: "Generator"; Types: full hosting +Name: "generator/sm"; Description: "Super Metroid ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 3145728; Flags: disablenouninstallwarning +Name: "generator/soe"; Description: "Secret of Evermore ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 3145728; Flags: disablenouninstallwarning +Name: "generator/lttp"; Description: "A Link to the Past ROM Setup and Enemizer"; Types: full hosting; ExtraDiskSpaceRequired: 5191680 +Name: "generator/oot"; Description: "Ocarina of Time ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 100663296; Flags: disablenouninstallwarning +Name: "server"; Description: "Server"; Types: full hosting +Name: "client"; Description: "Clients"; Types: full playing +Name: "client/sni"; Description: "SNI Client"; Types: full playing +Name: "client/sni/lttp"; Description: "SNI Client - A Link to the Past Patch Setup"; Types: full playing; Flags: disablenouninstallwarning +Name: "client/sni/sm"; Description: "SNI Client - Super Metroid Patch Setup"; Types: full playing; Flags: disablenouninstallwarning +Name: "client/factorio"; Description: "Factorio"; Types: full playing Name: "client/minecraft"; Description: "Minecraft"; Types: full playing; ExtraDiskSpaceRequired: 226894278 -Name: "client/text"; Description: "Text, to !command and chat"; Types: full playing +Name: "client/text"; Description: "Text, to !command and chat"; Types: full playing [Dirs] NAME: "{app}"; Flags: setntfscompression; Permissions: everyone-modify users-modify authusers-modify; @@ -134,7 +134,6 @@ Root: HKCR; Subkey: "{#MyAppName}multidata\DefaultIcon"; ValueData: "{ap Root: HKCR; Subkey: "{#MyAppName}multidata\shell\open\command"; ValueData: """{app}\ArchipelagoServer.exe"" ""%1"""; ValueType: string; ValueName: ""; Components: server - [Code] const SHCONTCH_NOPROGRESSBOX = 4; @@ -219,6 +218,19 @@ var OoTROMFilePage: TInputFileWizardPage; var MinecraftDownloadPage: TDownloadWizardPage; +function GetSNESMD5OfFile(const rom: string): string; +var data: AnsiString; +begin + if LoadStringFromFile(rom, data) then + begin + if Length(data) mod 1024 = 512 then + begin + data := copy(data, 513, Length(data)-512); + end; + Result := GetMD5OfString(data); + end; +end; + function CheckRom(name: string; hash: string): string; var rom: string; begin @@ -228,7 +240,7 @@ begin begin log('existing ROM found'); log(IntToStr(CompareStr(GetMD5OfFile(rom), hash))); - if CompareStr(GetMD5OfFile(rom), hash) = 0 then + if CompareStr(GetSNESMD5OfFile(rom), hash) = 0 then begin log('existing ROM verified'); Result := rom; diff --git a/inno_setup_38.iss b/inno_setup_38.iss index f9387c1a..c036c1cd 100644 --- a/inno_setup_38.iss +++ b/inno_setup_38.iss @@ -48,20 +48,20 @@ Name: "playing"; Description: "Installation for playing purposes" Name: "custom"; Description: "Custom installation"; Flags: iscustom [Components] -Name: "core"; Description: "Core Files"; Types: full hosting playing custom; Flags: fixed -Name: "generator"; Description: "Generator"; Types: full hosting -Name: "generator/sm"; Description: "Super Metroid ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 3145728 -Name: "generator/soe"; Description: "Secret of Evermore ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 3145728 -Name: "generator/lttp"; Description: "A Link to the Past ROM Setup and Enemizer"; Types: full hosting; ExtraDiskSpaceRequired: 5191680 -Name: "generator/oot"; Description: "Ocarina of Time ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 100663296 -Name: "server"; Description: "Server"; Types: full hosting -Name: "client"; Description: "Clients"; Types: full playing -Name: "client/sni"; Description: "SNI Client"; Types: full playing -Name: "client/sni/lttp"; Description: "SNI Client - A Link to the Past Patch Setup"; Types: full playing -Name: "client/sni/sm"; Description: "SNI Client - Super Metroid Patch Setup"; Types: full playing -Name: "client/factorio"; Description: "Factorio"; Types: full playing +Name: "core"; Description: "Core Files"; Types: full hosting playing custom; Flags: fixed +Name: "generator"; Description: "Generator"; Types: full hosting +Name: "generator/sm"; Description: "Super Metroid ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 3145728; Flags: disablenouninstallwarning +Name: "generator/soe"; Description: "Secret of Evermore ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 3145728; Flags: disablenouninstallwarning +Name: "generator/lttp"; Description: "A Link to the Past ROM Setup and Enemizer"; Types: full hosting; ExtraDiskSpaceRequired: 5191680 +Name: "generator/oot"; Description: "Ocarina of Time ROM Setup"; Types: full hosting; ExtraDiskSpaceRequired: 100663296; Flags: disablenouninstallwarning +Name: "server"; Description: "Server"; Types: full hosting +Name: "client"; Description: "Clients"; Types: full playing +Name: "client/sni"; Description: "SNI Client"; Types: full playing +Name: "client/sni/lttp"; Description: "SNI Client - A Link to the Past Patch Setup"; Types: full playing; Flags: disablenouninstallwarning +Name: "client/sni/sm"; Description: "SNI Client - Super Metroid Patch Setup"; Types: full playing; Flags: disablenouninstallwarning +Name: "client/factorio"; Description: "Factorio"; Types: full playing Name: "client/minecraft"; Description: "Minecraft"; Types: full playing; ExtraDiskSpaceRequired: 226894278 -Name: "client/text"; Description: "Text, to !command and chat"; Types: full playing +Name: "client/text"; Description: "Text, to !command and chat"; Types: full playing [Dirs] NAME: "{app}"; Flags: setntfscompression; Permissions: everyone-modify users-modify authusers-modify; @@ -134,7 +134,6 @@ Root: HKCR; Subkey: "{#MyAppName}multidata\DefaultIcon"; ValueData: "{ap Root: HKCR; Subkey: "{#MyAppName}multidata\shell\open\command"; ValueData: """{app}\ArchipelagoServer.exe"" ""%1"""; ValueType: string; ValueName: ""; Components: server - [Code] const SHCONTCH_NOPROGRESSBOX = 4; @@ -219,6 +218,19 @@ var OoTROMFilePage: TInputFileWizardPage; var MinecraftDownloadPage: TDownloadWizardPage; +function GetSNESMD5OfFile(const rom: string): string; +var data: AnsiString; +begin + if LoadStringFromFile(rom, data) then + begin + if Length(data) mod 1024 = 512 then + begin + data := copy(data, 513, Length(data)-512); + end; + Result := GetMD5OfString(data); + end; +end; + function CheckRom(name: string; hash: string): string; var rom: string; begin @@ -228,7 +240,7 @@ begin begin log('existing ROM found'); log(IntToStr(CompareStr(GetMD5OfFile(rom), hash))); - if CompareStr(GetMD5OfFile(rom), hash) = 0 then + if CompareStr(GetSNESMD5OfFile(rom), hash) = 0 then begin log('existing ROM verified'); Result := rom;