Skip to content

Commit

Permalink
Reset research pending state even if research facility is destroyed.
Browse files Browse the repository at this point in the history
Destroyed research facilities can no longer permanently hog a research.

Steps to reproduce: Enable debug mode, slow down game speed to 0, destroy facility with Alt+K, start research, speed
  up game to normal speed. Research remained missing even after the facility exploded.

Fixes ticket:3570.
  • Loading branch information
Cyp committed Jun 29, 2012
1 parent 7621581 commit 6a04b6a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/multiplay.cpp
Expand Up @@ -970,6 +970,8 @@ bool recvResearchStatus(NETQUEUE queue)
// psBuilding may be null if finishing
if (bStart) // Starting research
{
ResetPendingResearchStatus(pPlayerRes); // Reset pending state, even if research state is not changed due to the structure being destroyed.

psBuilding = IdToStruct(structRef, player);

// Set that facility to research
Expand All @@ -992,7 +994,6 @@ bool recvResearchStatus(NETQUEUE queue)
MakeResearchStarted(pPlayerRes);
psResFacilty->timeStartHold = 0;
}

}
// Finished/cancelled research
else
Expand Down
1 change: 1 addition & 0 deletions src/researchdef.h
Expand Up @@ -108,6 +108,7 @@ static inline void MakeResearchStarted(PLAYER_RESEARCH *x) { x->Res
/// Pending means not yet synchronised, so only permitted to affect the UI, not the game state.
static inline void MakeResearchCancelledPending(PLAYER_RESEARCH *x) { x->ResearchStatus &= ~RESBITS_PENDING_ONLY; x->ResearchStatus |= CANCELLED_RESEARCH_PENDING; }
static inline void MakeResearchStartedPending(PLAYER_RESEARCH *x) { x->ResearchStatus &= ~RESBITS_PENDING_ONLY; x->ResearchStatus |= STARTED_RESEARCH_PENDING; }
static inline void ResetPendingResearchStatus(PLAYER_RESEARCH *x) { x->ResearchStatus &= ~RESBITS_PENDING_ONLY; }

/// clear all bits in the status except for the possible bit
static inline void ResetResearchStatus(PLAYER_RESEARCH *x) { x->ResearchStatus &= ~RESBITS_PENDING; }
Expand Down

0 comments on commit 6a04b6a

Please sign in to comment.