1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Possibly fixed #1583 and other issues concerning players capturing towns.

This commit is contained in:
DjWarmonger 2015-10-24 18:03:00 +02:00
parent 3c4f7ec126
commit 61692ba168

View File

@ -1937,13 +1937,20 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, PlayerColor owner)
std::set<PlayerColor> playerColors = {owner, oldOwner};
checkVictoryLossConditions(playerColors);
if(owner < PlayerColor::PLAYER_LIMIT && dynamic_cast<const CGTownInstance *>(obj)) //town captured
if(dynamic_cast<const CGTownInstance *>(obj)) //town captured
{
if (owner < PlayerColor::PLAYER_LIMIT) //new owner is real player
{
const CGTownInstance * town = dynamic_cast<const CGTownInstance *>(obj);
if (town->hasBuilt(BuildingID::PORTAL_OF_SUMMON, ETownType::DUNGEON))
setPortalDwelling(town, true, false);
if (!gs->getPlayer(owner)->towns.size())//player lost last town
gs->getPlayer(owner)->daysWithoutCastle = boost::none; // reset counter
}
if (oldOwner < PlayerColor::PLAYER_LIMIT) //old owner is real player
{
if (gs->getPlayer(oldOwner)->towns.empty())//previous player lost last last town
{
InfoWindow iw;
iw.player = oldOwner;
@ -1951,6 +1958,7 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, PlayerColor owner)
sendAndApply(&iw);
}
}
}
const PlayerState * p = gs->getPlayer(owner);