diff --git a/patch.go b/patch.go index 9f2c033..c38bdd3 100644 --- a/patch.go +++ b/patch.go @@ -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 @@ -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 @@ -178,8 +174,6 @@ func applyPatch(test bool, originalFileName, OS string) error { } } status = true - - break } } } diff --git a/test_hoi4_patch_test.go b/test_hoi4_patch_test.go index 7a7c20c..ce5f07c 100644 --- a/test_hoi4_patch_test.go +++ b/test_hoi4_patch_test.go @@ -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") + +}