diff --git a/Phobos.vcxproj b/Phobos.vcxproj index 8240b6cc6f..7cd780d98d 100644 --- a/Phobos.vcxproj +++ b/Phobos.vcxproj @@ -153,6 +153,7 @@ + diff --git a/src/Misc/Hooks.SkirmishColors.cpp b/src/Misc/Hooks.SkirmishColors.cpp new file mode 100644 index 0000000000..7ca77bd4ab --- /dev/null +++ b/src/Misc/Hooks.SkirmishColors.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +DEFINE_HOOK(0x69A317, GetLinkedColor_SkirmishUnlimitedColors, 0x0) +{ + GET_STACK(int, index, 0x4); + + if (index == -2) + index = ColorScheme::FindIndex("LightGrey", 53); + else + index = index * 2 + 1; + + R->EAX(index); + + return 0x69A325; +} diff --git a/src/Phobos.INI.cpp b/src/Phobos.INI.cpp index 8b16bb0274..b504863125 100644 --- a/src/Phobos.INI.cpp +++ b/src/Phobos.INI.cpp @@ -176,20 +176,9 @@ DEFINE_HOOK(0x5FACDF, OptionsClass_LoadSettings_LoadPhobosSettings, 0x5) BlittersFix::Apply(); Phobos::Config::SkirmishUnlimitedColors = pINI_RULESMD->ReadBool(GameStrings::General, "SkirmishUnlimitedColors", false); + // Disable Ares hook at this address so that our logic can run. if (Phobos::Config::SkirmishUnlimitedColors) - { - // Game_GetLinkedColor converts vanilla dropdown color index into color scheme index ([Colors] from rules) - // What we want to do is to restore vanilla from Ares hook, and immediately return arg - // So if spawner feeds us a number, it will be used to look up color scheme directly - Patch::Apply_RAW(0x69A310, - { - 0x8B, 0x44, 0x24, 0x04, // mov eax, [esp+4] - 0xD1, 0xE0, // shl eax, 1 - 0x40, // inc eax - 0xC2, 0x04, 0x00 // retn 4 - } - ); - } + Patch::Apply_RAW(0x69A310, { 0x8B, 0x44, 0x24, 0x04, 0xD1, 0xE0, 0x40 }); Phobos::Config::SaveVariablesOnScenarioEnd = pINI_RULESMD->ReadBool(GameStrings::General, "SaveVariablesOnScenarioEnd", false);