From 3fa024dbdcea14739a04d89aa6ca2e3522392e6c Mon Sep 17 00:00:00 2001 From: Stubbjax Date: Thu, 5 Feb 2026 01:46:32 +1100 Subject: [PATCH 1/3] bugfix: Multiple battle plans are now always applied correctly --- Generals/Code/GameEngine/Source/Common/RTS/Player.cpp | 10 ++++++++++ .../Code/GameEngine/Source/Common/RTS/Player.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp b/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp index 25596036b7b..e1b872bcdef 100644 --- a/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp +++ b/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp @@ -3152,7 +3152,17 @@ void Player::applyBattlePlanBonusesForPlayerObjects( const BattlePlanBonusesData } DUMPBATTLEPLANBONUSES(m_battlePlanBonuses, this, nullptr); +#if RETAIL_COMPATIBLE_CRC iterateObjects( localApplyBattlePlanBonusesToObject, const_cast(bonus) ); +#else + // TheSuperHackers @bugfix Stubbjax 05/02/2026 Apply all bonuses the player has rather than just the most recent. + BattlePlanBonuses* newBonus = newInstance(BattlePlanBonuses); + *newBonus = *m_battlePlanBonuses; + newBonus->m_armorScalar = bonus->m_armorScalar; + + iterateObjects(localApplyBattlePlanBonusesToObject, (void*)newBonus); + deleteInstance(newBonus); +#endif } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp index f7a676be93b..417068eb5a6 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp @@ -3643,7 +3643,17 @@ void Player::applyBattlePlanBonusesForPlayerObjects( const BattlePlanBonusesData } DUMPBATTLEPLANBONUSES(m_battlePlanBonuses, this, nullptr); +#if RETAIL_COMPATIBLE_CRC iterateObjects( localApplyBattlePlanBonusesToObject, const_cast(bonus) ); +#else + // TheSuperHackers @bugfix Stubbjax 05/02/2026 Apply all bonuses the player has rather than just the most recent. + BattlePlanBonuses* newBonus = newInstance(BattlePlanBonuses); + *newBonus = *m_battlePlanBonuses; + newBonus->m_armorScalar = bonus->m_armorScalar; + + iterateObjects(localApplyBattlePlanBonusesToObject, (void*)newBonus); + deleteInstance(newBonus); +#endif } From 66493271e75dada493ff842d187cae0b654ae353 Mon Sep 17 00:00:00 2001 From: Stubbjax Date: Wed, 4 Mar 2026 11:50:18 +1100 Subject: [PATCH 2/3] refactor: Use new allocation method --- Generals/Code/GameEngine/Source/Common/RTS/Player.cpp | 9 ++++----- GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp b/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp index e1b872bcdef..8cb100d79b5 100644 --- a/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp +++ b/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp @@ -3156,12 +3156,11 @@ void Player::applyBattlePlanBonusesForPlayerObjects( const BattlePlanBonusesData iterateObjects( localApplyBattlePlanBonusesToObject, const_cast(bonus) ); #else // TheSuperHackers @bugfix Stubbjax 05/02/2026 Apply all bonuses the player has rather than just the most recent. - BattlePlanBonuses* newBonus = newInstance(BattlePlanBonuses); - *newBonus = *m_battlePlanBonuses; - newBonus->m_armorScalar = bonus->m_armorScalar; + BattlePlanBonusesData newBonus = *m_battlePlanBonuses; + newBonus.m_armorScalar = bonus->m_armorScalar; + newBonus.m_sightRangeScalar = bonus->m_sightRangeScalar; - iterateObjects(localApplyBattlePlanBonusesToObject, (void*)newBonus); - deleteInstance(newBonus); + iterateObjects(localApplyBattlePlanBonusesToObject, (void*)&newBonus); #endif } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp index 417068eb5a6..416ce5b3487 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp @@ -3647,12 +3647,11 @@ void Player::applyBattlePlanBonusesForPlayerObjects( const BattlePlanBonusesData iterateObjects( localApplyBattlePlanBonusesToObject, const_cast(bonus) ); #else // TheSuperHackers @bugfix Stubbjax 05/02/2026 Apply all bonuses the player has rather than just the most recent. - BattlePlanBonuses* newBonus = newInstance(BattlePlanBonuses); - *newBonus = *m_battlePlanBonuses; - newBonus->m_armorScalar = bonus->m_armorScalar; + BattlePlanBonusesData newBonus = *m_battlePlanBonuses; + newBonus.m_armorScalar = bonus->m_armorScalar; + newBonus.m_sightRangeScalar = bonus->m_sightRangeScalar; - iterateObjects(localApplyBattlePlanBonusesToObject, (void*)newBonus); - deleteInstance(newBonus); + iterateObjects(localApplyBattlePlanBonusesToObject, (void*)&newBonus); #endif } From 23f8710aa0acf58d38c0995d2b685b45a1a1548d Mon Sep 17 00:00:00 2001 From: Stubbjax Date: Thu, 5 Mar 2026 10:30:25 +1100 Subject: [PATCH 3/3] tweak: Remove implicit cast --- Generals/Code/GameEngine/Source/Common/RTS/Player.cpp | 2 +- GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp b/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp index 8cb100d79b5..bed9c8895aa 100644 --- a/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp +++ b/Generals/Code/GameEngine/Source/Common/RTS/Player.cpp @@ -3160,7 +3160,7 @@ void Player::applyBattlePlanBonusesForPlayerObjects( const BattlePlanBonusesData newBonus.m_armorScalar = bonus->m_armorScalar; newBonus.m_sightRangeScalar = bonus->m_sightRangeScalar; - iterateObjects(localApplyBattlePlanBonusesToObject, (void*)&newBonus); + iterateObjects(localApplyBattlePlanBonusesToObject, &newBonus); #endif } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp index 416ce5b3487..fff38be87e8 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp @@ -3651,7 +3651,7 @@ void Player::applyBattlePlanBonusesForPlayerObjects( const BattlePlanBonusesData newBonus.m_armorScalar = bonus->m_armorScalar; newBonus.m_sightRangeScalar = bonus->m_sightRangeScalar; - iterateObjects(localApplyBattlePlanBonusesToObject, (void*)&newBonus); + iterateObjects(localApplyBattlePlanBonusesToObject, &newBonus); #endif }