mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-29 21:56:54 +02:00
Possibly fixed #1583 and other issues concerning players capturing towns.
This commit is contained in:
parent
3c4f7ec126
commit
61692ba168
@ -1937,18 +1937,26 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, PlayerColor owner)
|
|||||||
std::set<PlayerColor> playerColors = {owner, oldOwner};
|
std::set<PlayerColor> playerColors = {owner, oldOwner};
|
||||||
checkVictoryLossConditions(playerColors);
|
checkVictoryLossConditions(playerColors);
|
||||||
|
|
||||||
if(owner < PlayerColor::PLAYER_LIMIT && dynamic_cast<const CGTownInstance *>(obj)) //town captured
|
if(dynamic_cast<const CGTownInstance *>(obj)) //town captured
|
||||||
{
|
{
|
||||||
const CGTownInstance * town = dynamic_cast<const CGTownInstance *>(obj);
|
if (owner < PlayerColor::PLAYER_LIMIT) //new owner is real player
|
||||||
if (town->hasBuilt(BuildingID::PORTAL_OF_SUMMON, ETownType::DUNGEON))
|
|
||||||
setPortalDwelling(town, true, false);
|
|
||||||
|
|
||||||
if (!gs->getPlayer(owner)->towns.size())//player lost last town
|
|
||||||
{
|
{
|
||||||
InfoWindow iw;
|
const CGTownInstance * town = dynamic_cast<const CGTownInstance *>(obj);
|
||||||
iw.player = oldOwner;
|
if (town->hasBuilt(BuildingID::PORTAL_OF_SUMMON, ETownType::DUNGEON))
|
||||||
iw.text.addTxt(MetaString::GENERAL_TXT, 6); //%s, you have lost your last town. If you do not conquer another town in the next week, you will be eliminated.
|
setPortalDwelling(town, true, false);
|
||||||
sendAndApply(&iw);
|
|
||||||
|
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;
|
||||||
|
iw.text.addTxt (MetaString::GENERAL_TXT, 6); //%s, you have lost your last town. If you do not conquer another town in the next week, you will be eliminated.
|
||||||
|
sendAndApply(&iw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user