mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-17 00:07:41 +02:00
PlayerState::daysWithoutCastle: change in netpacks only. Fix issue 2462
Moving code from CGameHandler to NetPacksLib without changes.
This commit is contained in:
@ -1093,6 +1093,25 @@ DLL_LINKAGE void NewTurn::applyGs( CGameState *gs )
|
|||||||
|
|
||||||
if(gs->getDate(Date::DAY_OF_WEEK) == 1)
|
if(gs->getDate(Date::DAY_OF_WEEK) == 1)
|
||||||
gs->updateRumor();
|
gs->updateRumor();
|
||||||
|
|
||||||
|
//count days without town for all players, regardless of their turn order
|
||||||
|
for (auto &p : gs->players)
|
||||||
|
{
|
||||||
|
PlayerState & playerState = p.second;
|
||||||
|
if (playerState.status == EPlayerStatus::INGAME)
|
||||||
|
{
|
||||||
|
if (playerState.towns.empty())
|
||||||
|
{
|
||||||
|
if (playerState.daysWithoutCastle)
|
||||||
|
++(*playerState.daysWithoutCastle);
|
||||||
|
else playerState.daysWithoutCastle = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playerState.daysWithoutCastle = boost::none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_LINKAGE void SetObjectProperty::applyGs( CGameState *gs )
|
DLL_LINKAGE void SetObjectProperty::applyGs( CGameState *gs )
|
||||||
@ -1113,7 +1132,14 @@ DLL_LINKAGE void SetObjectProperty::applyGs( CGameState *gs )
|
|||||||
if(t->tempOwner < PlayerColor::PLAYER_LIMIT)
|
if(t->tempOwner < PlayerColor::PLAYER_LIMIT)
|
||||||
gs->getPlayer(t->tempOwner)->towns -= t;
|
gs->getPlayer(t->tempOwner)->towns -= t;
|
||||||
if(val < PlayerColor::PLAYER_LIMIT_I)
|
if(val < PlayerColor::PLAYER_LIMIT_I)
|
||||||
gs->getPlayer(PlayerColor(val))->towns.push_back(t);
|
{
|
||||||
|
PlayerState * p = gs->getPlayer(PlayerColor(val));
|
||||||
|
p->towns.push_back(t);
|
||||||
|
|
||||||
|
//reset counter before NewTurn to avoid no town message if game loaded at turn when one already captured
|
||||||
|
if(p->daysWithoutCastle)
|
||||||
|
p->daysWithoutCastle = boost::none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CBonusSystemNode *nodeToMove = cai->whatShouldBeAttached();
|
CBonusSystemNode *nodeToMove = cai->whatShouldBeAttached();
|
||||||
|
@ -1716,25 +1716,6 @@ void CGameHandler::newTurn()
|
|||||||
elem->newTurn();
|
elem->newTurn();
|
||||||
}
|
}
|
||||||
|
|
||||||
//count days without town for all players, regardless of their turn order
|
|
||||||
for (auto &p : gs->players)
|
|
||||||
{
|
|
||||||
PlayerState & playerState = p.second;
|
|
||||||
if (playerState.status == EPlayerStatus::INGAME)
|
|
||||||
{
|
|
||||||
if (playerState.towns.empty())
|
|
||||||
{
|
|
||||||
if (playerState.daysWithoutCastle)
|
|
||||||
++(*playerState.daysWithoutCastle);
|
|
||||||
else playerState.daysWithoutCastle = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
playerState.daysWithoutCastle = boost::none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronizeArtifactHandlerLists(); //new day events may have changed them. TODO better of managing that
|
synchronizeArtifactHandlerLists(); //new day events may have changed them. TODO better of managing that
|
||||||
}
|
}
|
||||||
void CGameHandler::run(bool resume)
|
void CGameHandler::run(bool resume)
|
||||||
@ -2183,8 +2164,6 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, PlayerColor owner)
|
|||||||
const CGTownInstance * town = dynamic_cast<const CGTownInstance *>(obj);
|
const CGTownInstance * town = dynamic_cast<const CGTownInstance *>(obj);
|
||||||
if (town->hasBuilt(BuildingID::PORTAL_OF_SUMMON, ETownType::DUNGEON))
|
if (town->hasBuilt(BuildingID::PORTAL_OF_SUMMON, ETownType::DUNGEON))
|
||||||
setPortalDwelling(town, true, false);
|
setPortalDwelling(town, true, false);
|
||||||
|
|
||||||
gs->getPlayer(owner)->daysWithoutCastle = boost::none; // reset counter
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldOwner < PlayerColor::PLAYER_LIMIT) //old owner is real player
|
if (oldOwner < PlayerColor::PLAYER_LIMIT) //old owner is real player
|
||||||
|
Reference in New Issue
Block a user