Skip to content

Commit

Permalink
Linux hoi4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
IlliaYalovoi committed Aug 18, 2023
1 parent f2ccac2 commit a340b3e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
10 changes: 2 additions & 8 deletions patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func applyPatch(test bool, originalFileName, OS string) error {
// HOI4
hexExistsHOI4Windows := []string{"48", "8D", "0D", "77", "B6", "C9", "01", "E8", "CA", "86", "B3", "01", "85", "C0", "0F", "94", "C3", "E8", "90"}
hexWantedHOI4Windows := []string{"48", "8D", "0D", "77", "B6", "C9", "01", "E8", "CA", "86", "B3", "01", "31", "C0", "0F", "94", "C3", "E8", "90"}
hexExistsHOI4Linux := []string{}
hexWantedHOI4Linux := []string{}
hexExistsHOI4Linux := []string{"E8", "20", "70", "F8", "FE", "41", "89", "C7", "31", "DB", "85", "C0", "0F", "94", "C3", "E8", "51", "87", "B8", "FF"}
hexWantedHOI4Linux := []string{"E8", "20", "70", "F8", "FE", "41", "89", "C7", "31", "DB", "31", "C0", "0F", "94", "C3", "E8", "51", "87", "B8", "FF"}

if strings.Contains(originalFileName, "eu4") {
hexExistsWindows = hexExistsEU4Windows
Expand All @@ -86,10 +86,6 @@ func applyPatch(test bool, originalFileName, OS string) error {
hexExistsDarwin = hexExistsEU4Darwin
hexWantedDarwin = hexWantedEU4Darwin
} else if strings.Contains(originalFileName, "hoi4") {
if OS == "linux" {

return errors.New("patching linux version of Hearts of Iron IV is not currently supported")
}

hexExistsWindows = hexExistsHOI4Windows
hexWantedWindows = hexWantedHOI4Windows
Expand Down Expand Up @@ -178,8 +174,6 @@ func applyPatch(test bool, originalFileName, OS string) error {
}
}
status = true

break
}
}
}
Expand Down
42 changes: 21 additions & 21 deletions test_hoi4_patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ func TestApplyPatchHOI4Windows(t *testing.T) {
os.Remove("./test_files/hoi4/hoi4.exe")
}

// func TestApplyPatchHOILinux(t *testing.T) {
// err := backupFile("./test_files/hoi4/hoi4_original", "./test_files/hoi4/hoi4_test")

// if err != nil {
// t.Error(err)
// }
// err = applyPatch(true, "./test_files/hoi4/hoi4_test", "linux")
// if err != nil {
// t.Error(err)
// }

// if !compareExes("./test_files/hoi4/hoi4_patched", "./test_files/hoi4/hoi4_test") {
// if err != nil {
// t.Error("Executables doesnt match")
// }
// }
// os.Remove("./test_files/hoi4/hoi4_test")
// os.Remove("./test_files/hoi4/hoi4_test_backup")
// os.Remove("./test_files/hoi4/hoi4")

// }
func TestApplyPatchHOILinux(t *testing.T) {
err := backupFile("./test_files/hoi4/hoi4_original", "./test_files/hoi4/hoi4_test")

if err != nil {
t.Error(err)
}
err = applyPatch(true, "./test_files/hoi4/hoi4_test", "linux")
if err != nil {
t.Error(err)
}

if !compareExes("./test_files/hoi4/hoi4_patched", "./test_files/hoi4/hoi4_test") {
if err != nil {
t.Error("Executables doesnt match")
}
}
os.Remove("./test_files/hoi4/hoi4_test")
os.Remove("./test_files/hoi4/hoi4_test_backup")
os.Remove("./test_files/hoi4/hoi4")

}

0 comments on commit a340b3e

Please sign in to comment.