Skip to content

Commit 1ba3dfb

Browse files
committed
Enforce active turn for first warring human
Who knows if this will have bad side-effects, but it seems to work in the lobby. Test plan: Load up my bad save game and check that India's turn is active in the lobby. It does. Hopefully we can make it through India's turn and then through every other warring players turns too. Fingers crossed on that. Also, I tried to reproduce the bad save game in a two player game. Unfortunately (?), this game seems to load fine. I can load this working save with the patch applied, and have verified that it doesn't break anything.
1 parent 6501d23 commit 1ba3dfb

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

CvGameCoreDLL_Expansion2/CvPlayer.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22194,6 +22194,50 @@ void CvPlayer::Read(FDataStream& kStream)
2219422194
//m_pDiplomacyRequests->Read(kStream);
2219522195
}
2219622196

22197+
/**
22198+
* Warring sequential humans deadlock fix
22199+
*
22200+
* Upon loading an autosave, all human players at war were loaded into the
22201+
* game with inactive turns, making it impossible for them to end the turn.
22202+
*
22203+
* The following hack detects and fixes that problem by forcing the first
22204+
* human player in sequential turn mode to be active.
22205+
*
22206+
* Hopefully this has no side effects but it's impossible for me to know.
22207+
*/
22208+
if(GC.getGame().isOption(GAMEOPTION_DYNAMIC_TURNS) && isHuman()) {
22209+
NET_MESSAGE_DEBUG_OSTR_ALWAYS("read() for human player " << getName());
22210+
NET_MESSAGE_DEBUG_OSTR_ALWAYS("m_bTurnActive is " << m_bTurnActive);
22211+
NET_MESSAGE_DEBUG_OSTR_ALWAYS("m_bAutoMoves is " << m_bAutoMoves);
22212+
NET_MESSAGE_DEBUG_OSTR_ALWAYS("m_bProcessedAutoMoves is " << m_bProcessedAutoMoves);
22213+
NET_MESSAGE_DEBUG_OSTR_ALWAYS("m_bDynamicTurnsSimultMode is " << m_bDynamicTurnsSimultMode);
22214+
22215+
if (!m_bDynamicTurnsSimultMode) {
22216+
// this human is in sequential turns mode,
22217+
// so make sure there is an active human in the game
22218+
static bool s_bVerified1stSeqentialHumanIsActive = false;
22219+
if (!s_bVerified1stSeqentialHumanIsActive) {
22220+
s_bVerified1stSeqentialHumanIsActive = true;
22221+
22222+
if (m_bTurnActive) {
22223+
NET_MESSAGE_DEBUG_OSTR_ALWAYS(
22224+
"first sequential human was already active");
22225+
} else {
22226+
NET_MESSAGE_DEBUG_OSTR_ALWAYS(
22227+
"hacktivating unexpectedly inactive player :(");
22228+
22229+
// force the player to be active
22230+
m_bTurnActive = true;
22231+
22232+
// also turn off automoves - without this, the turn
22233+
// becomes inactive before the player can do anything
22234+
m_bAutoMoves = false;
22235+
m_bProcessedAutoMoves = false;
22236+
}
22237+
}
22238+
}
22239+
}
22240+
2219722241
if(m_bTurnActive)
2219822242
GC.getGame().changeNumGameTurnActive(1, std::string("setTurnActive() [loading save game] for player ") + getName());
2219922243

0 commit comments

Comments
 (0)