bugfix(energy): Don't apply power production bonus for disabled power plants on save game load#2509
Conversation
… plants on save game load
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Source/Common/RTS/Energy.cpp | Adds a DEBUG_ASSERTCRASH to addPowerBonus to enforce the invariant that disabled objects must not receive a power bonus; no logic change in release builds. |
| Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp | loadPostProcess now checks obj->isDisabled() before adding the overcharge power bonus on save-game reload, fixing the reported bug. |
| Generals/Code/GameEngine/Source/GameLogic/Object/Upgrade/PowerPlantUpgrade.cpp | loadPostProcess now checks obj->isDisabled() before adding the upgrade power bonus on save-game reload, fixing the reported bug. |
| GeneralsMD/Code/GameEngine/Source/Common/RTS/Energy.cpp | Mirror of Generals Energy.cpp change — identical DEBUG_ASSERTCRASH added to addPowerBonus for the Zero Hour build. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp | Mirror of Generals OverchargeBehavior.cpp change — isDisabled() check added in loadPostProcess for Zero Hour build. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/PowerPlantUpgrade.cpp | Mirror of Generals PowerPlantUpgrade.cpp change — isDisabled() check added in loadPostProcess for Zero Hour build. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Save Game Load] --> B[loadPostProcess called]
B --> C{isAlreadyUpgraded / m_overchargeActive?}
C -- No --> D[Skip — no bonus to restore]
C -- Yes --> E{getControllingPlayer != null?}
E -- No --> F[Skip — no player]
E -- Yes --> G{obj->isDisabled?}
G -- Yes --> H[Skip — BUG FIXED: disabled plant gets no bonus]
G -- No --> I[player->addPowerBonus]
I --> J[Energy::addPowerBonus]
J --> K[DEBUG_ASSERTCRASH: !isDisabled]
K --> L[addProduction + sanity check]
Reviews (2): Last reviewed commit: "Replicated in Generals." | Re-trigger Greptile
|
Replicated in Generals. |
When loading a save game with disabled power plants, players still get the power production bonus from those plants if they're either overcharged or upgraded. That's because the power production is increased without a check if the plant is disabled. This PR fixes that.
TODO: