bugfix(energy): Don't increase power production for disabled power plants on save game load#2508
bugfix(energy): Don't increase power production for disabled power plants on save game load#2508Caball009 wants to merge 2 commits intoTheSuperHackers:mainfrom
Conversation
…ants on save game load Moved code.
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp | Moves setOrRestoreTeam call from before to after m_disabledMask and m_disabledTillFrame are xfer'd, ensuring isDisabled() returns the correct value when power production is evaluated on save load. |
Sequence Diagram
sequenceDiagram
participant X as Object::xfer (XFER_LOAD)
participant S as Object::setOrRestoreTeam
participant P as Player::becomingTeamMember
participant A as Object::friend_adjustPowerForPlayer
Note over X: xfer status bits (m_status, m_scriptStatus, m_privateStatus)
Note over X: xfer geometry / vision / shroud data
Note over X: ✅ xfer m_disabledMask (NEW ORDER)
Note over X: ✅ xfer m_disabledTillFrame (NEW ORDER)
X->>S: setOrRestoreTeam(team, restoring=true)
S->>P: becomingTeamMember(this, yes=true)
P->>A: friend_adjustPowerForPlayer(incoming=true)
Note over A: isDisabled() now correctly reads<br/>the already-loaded m_disabledMask
alt isDisabled() == true && energyProduction > 0
A-->>P: return early (no power added ✅)
else not disabled
A-->>P: objectEnteringInfluence(this)
end
Reviews (1): Last reviewed commit: "Updated comment." | Re-trigger Greptile
| // disabled till frame | ||
| xfer->xferUser( m_disabledTillFrame, sizeof( UnsignedInt ) * DISABLED_COUNT ); | ||
|
|
||
| // OK, now that we have xferred our status bits and disabled data, it's safe to set the team... |
There was a problem hiding this comment.
Can it perhaps be moved into Object::loadPostProcess or would that be too late then?
There was a problem hiding this comment.
Not sure. The most immediate issue I see is that the teamID would need to be accessible in Object::loadPostProcess.
When loading a save game with disabled power plants, players still get the power production from those plants. That's because the power production is increased before the
Objectdisabled flags are xfer'd. The following code is supposed to prevent the increase in power production, but the disabled flag would have to be xfer'd before this is called. This PR fixes that.GeneralsGameCode/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
Lines 3829 to 3835 in 920c4e6
Callstack:
TODO: