bugfix: Battle plans are now transferred to the new owner on capture#2257
bugfix: Battle plans are now transferred to the new owner on capture#2257Stubbjax wants to merge 1 commit intoTheSuperHackers:mainfrom
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Source/Common/RTS/Player.cpp | Fixed bonus removal bug by creating separate invertedBonus copy instead of modifying original bonus in-place |
| GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp | Fixed bonus removal bug (identical fix to Generals version) |
| Generals/Code/GameEngine/Source/GameLogic/Object/Update/BattlePlanUpdate.cpp | Implemented onCapture to transfer battle plans from old to new owner; wrapped in !RETAIL_COMPATIBLE_CRC guard |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/BattlePlanUpdate.cpp | Implemented onCapture (identical to Generals version) |
Sequence Diagram
sequenceDiagram
participant Team
participant Object as Strategy Center
participant BattlePlanUpdate
participant OldOwner as Old Player
participant NewOwner as New Player
Team->>Object: onCapture(oldOwner, newOwner)
Note over Object: Object ownership already changed
Object->>Object: Update AI state, score, etc.
loop For each behavior module
Object->>BattlePlanUpdate: onCapture(oldOwner, newOwner)
alt m_planAffectingArmy != PLANSTATUS_NONE
BattlePlanUpdate->>OldOwner: changeBattlePlan(plan, -1, bonuses)
Note over OldOwner: Remove plan from old owner<br/>Decrement counter<br/>If counter reaches 0, remove bonuses
OldOwner->>OldOwner: applyBattlePlanBonusesForPlayerObjects(invertedBonus)
Note over OldOwner: Apply inverted bonuses to undo effects
BattlePlanUpdate->>NewOwner: changeBattlePlan(plan, 1, bonuses)
Note over NewOwner: Add plan to new owner<br/>Increment counter<br/>If counter reaches 1, add bonuses
NewOwner->>NewOwner: applyBattlePlanBonusesForPlayerObjects(bonus)
Note over NewOwner: Apply bonuses to all qualifying units
end
end
Object->>Object: handlePartitionCellMaintenance()
Generals/Code/GameEngine/Source/GameLogic/Object/Update/BattlePlanUpdate.cpp
Outdated
Show resolved
Hide resolved
3c994e9 to
434df18
Compare
| //------------------------------------------------------------------------------------------------- | ||
| void BattlePlanUpdate::onCapture(Player* oldOwner, Player* newOwner) | ||
| { | ||
| #if !RETAIL_COMPATIBLE_CRC | ||
| // TheSuperHackers @bugfix Stubbjax 04/11/2025 Transfer battle plan bonuses on capture. | ||
| oldOwner->changeBattlePlan(m_planAffectingArmy, -1, m_bonuses); | ||
| newOwner->changeBattlePlan(m_planAffectingArmy, 1, m_bonuses); | ||
| #endif |
There was a problem hiding this comment.
calling changeBattlePlan with PLANSTATUS_NONE will do nothing (no bonuses applied/removed), so capturing a Strategy Center with no active plan is safe but will call changeBattlePlan unnecessarily
| //------------------------------------------------------------------------------------------------- | |
| void BattlePlanUpdate::onCapture(Player* oldOwner, Player* newOwner) | |
| { | |
| #if !RETAIL_COMPATIBLE_CRC | |
| // TheSuperHackers @bugfix Stubbjax 04/11/2025 Transfer battle plan bonuses on capture. | |
| oldOwner->changeBattlePlan(m_planAffectingArmy, -1, m_bonuses); | |
| newOwner->changeBattlePlan(m_planAffectingArmy, 1, m_bonuses); | |
| #endif | |
| void BattlePlanUpdate::onCapture(Player* oldOwner, Player* newOwner) | |
| { | |
| #if !RETAIL_COMPATIBLE_CRC | |
| // TheSuperHackers @bugfix Stubbjax 04/11/2025 Transfer battle plan bonuses on capture. | |
| if (m_planAffectingArmy != PLANSTATUS_NONE) | |
| { | |
| oldOwner->changeBattlePlan(m_planAffectingArmy, -1, m_bonuses); | |
| newOwner->changeBattlePlan(m_planAffectingArmy, 1, m_bonuses); | |
| } | |
| #endif | |
| } |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: Generals/Code/GameEngine/Source/GameLogic/Object/Update/BattlePlanUpdate.cpp
Line: 256:263
Comment:
calling `changeBattlePlan` with `PLANSTATUS_NONE` will do nothing (no bonuses applied/removed), so capturing a Strategy Center with no active plan is safe but will call `changeBattlePlan` unnecessarily
```suggestion
void BattlePlanUpdate::onCapture(Player* oldOwner, Player* newOwner)
{
#if !RETAIL_COMPATIBLE_CRC
// TheSuperHackers @bugfix Stubbjax 04/11/2025 Transfer battle plan bonuses on capture.
if (m_planAffectingArmy != PLANSTATUS_NONE)
{
oldOwner->changeBattlePlan(m_planAffectingArmy, -1, m_bonuses);
newOwner->changeBattlePlan(m_planAffectingArmy, 1, m_bonuses);
}
#endif
}
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| //------------------------------------------------------------------------------------------------- | ||
| void BattlePlanUpdate::onCapture(Player* oldOwner, Player* newOwner) | ||
| { | ||
| #if !RETAIL_COMPATIBLE_CRC | ||
| // TheSuperHackers @bugfix Stubbjax 04/11/2025 Transfer battle plan bonuses on capture. | ||
| oldOwner->changeBattlePlan(m_planAffectingArmy, -1, m_bonuses); | ||
| newOwner->changeBattlePlan(m_planAffectingArmy, 1, m_bonuses); | ||
| #endif |
There was a problem hiding this comment.
calling changeBattlePlan with PLANSTATUS_NONE will do nothing (no bonuses applied/removed), so capturing a Strategy Center with no active plan is safe but will call changeBattlePlan unnecessarily
| //------------------------------------------------------------------------------------------------- | |
| void BattlePlanUpdate::onCapture(Player* oldOwner, Player* newOwner) | |
| { | |
| #if !RETAIL_COMPATIBLE_CRC | |
| // TheSuperHackers @bugfix Stubbjax 04/11/2025 Transfer battle plan bonuses on capture. | |
| oldOwner->changeBattlePlan(m_planAffectingArmy, -1, m_bonuses); | |
| newOwner->changeBattlePlan(m_planAffectingArmy, 1, m_bonuses); | |
| #endif | |
| void BattlePlanUpdate::onCapture(Player* oldOwner, Player* newOwner) | |
| { | |
| #if !RETAIL_COMPATIBLE_CRC | |
| // TheSuperHackers @bugfix Stubbjax 04/11/2025 Transfer battle plan bonuses on capture. | |
| if (m_planAffectingArmy != PLANSTATUS_NONE) | |
| { | |
| oldOwner->changeBattlePlan(m_planAffectingArmy, -1, m_bonuses); | |
| newOwner->changeBattlePlan(m_planAffectingArmy, 1, m_bonuses); | |
| } | |
| #endif | |
| } |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/BattlePlanUpdate.cpp
Line: 256:263
Comment:
calling `changeBattlePlan` with `PLANSTATUS_NONE` will do nothing (no bonuses applied/removed), so capturing a Strategy Center with no active plan is safe but will call `changeBattlePlan` unnecessarily
```suggestion
void BattlePlanUpdate::onCapture(Player* oldOwner, Player* newOwner)
{
#if !RETAIL_COMPATIBLE_CRC
// TheSuperHackers @bugfix Stubbjax 04/11/2025 Transfer battle plan bonuses on capture.
if (m_planAffectingArmy != PLANSTATUS_NONE)
{
oldOwner->changeBattlePlan(m_planAffectingArmy, -1, m_bonuses);
newOwner->changeBattlePlan(m_planAffectingArmy, 1, m_bonuses);
}
#endif
}
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
Closes #2211
This change fixes an issue where battle plans are not transferred from the old owner to the new owner when a Strategy Center is captured. In addition, bonuses in effect upon surrender in team games are also now transferred to the new owner, if applicable.
In retail, capturing a Strategy Center leaves any existing bonus intact for the opponent, while giving the capturing player no bonus.