mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
parent
86e1ae928e
commit
abe88ea890
@ -468,6 +468,12 @@ static int getDir(int3 src, int3 dst)
|
||||
void TryMoveHero::applyGs( CGameState *gs )
|
||||
{
|
||||
CGHeroInstance *h = gs->getHero(id);
|
||||
if (!h)
|
||||
{
|
||||
logGlobal->errorStream() << "Attempt ot move unavailable hero " << id;
|
||||
return;
|
||||
}
|
||||
|
||||
h->movement = movePoints;
|
||||
|
||||
if((result == SUCCESS || result == BLOCKING_VISIT || result == EMBARK || result == DISEMBARK) && start != end)
|
||||
|
@ -4772,42 +4772,41 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
|
||||
else
|
||||
{
|
||||
//player lost -> all his objects become unflagged (neutral)
|
||||
auto hlp = p->heroes;
|
||||
for (auto i = hlp.cbegin(); i != hlp.cend(); i++) //eliminate heroes
|
||||
removeObject(*i);
|
||||
for (auto h : p->heroes) //eliminate heroes
|
||||
if (h.get())
|
||||
removeObject(h);
|
||||
|
||||
for (auto i = gs->map->objects.cbegin(); i != gs->map->objects.cend(); i++) //unflag objs
|
||||
for (auto obj : gs->map->objects) //unflag objs
|
||||
{
|
||||
if(*i && (*i)->tempOwner == player)
|
||||
setOwner(*i,PlayerColor::NEUTRAL);
|
||||
if(obj.get() && obj->tempOwner == player)
|
||||
setOwner(obj, PlayerColor::NEUTRAL);
|
||||
}
|
||||
|
||||
//eliminating one player may cause victory of another:
|
||||
std::set<PlayerColor> playerColors;
|
||||
for(int i = 0; i < PlayerColor::PLAYER_LIMIT_I; ++i)
|
||||
for (auto p : gs->players) //FIXME: players may have different colors, iterate by over players and not integers
|
||||
{
|
||||
if(player.getNum() != i) playerColors.insert(PlayerColor(i));
|
||||
if (p.first != player)
|
||||
playerColors.insert(p.first);
|
||||
}
|
||||
|
||||
//notify all players
|
||||
for (auto i = gs->players.cbegin(); i!=gs->players.cend(); i++)
|
||||
for (auto pc : playerColors)
|
||||
{
|
||||
if(i->first != player && gs->getPlayer(i->first)->status == EPlayerStatus::INGAME)
|
||||
if (gs->getPlayer(pc)->status == EPlayerStatus::INGAME)
|
||||
{
|
||||
InfoWindow iw;
|
||||
getVictoryLossMessage(player, victoryLossCheckResult.invert(), iw);
|
||||
iw.player = i->first;
|
||||
iw.player = pc;
|
||||
sendAndApply(&iw);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkVictoryLossConditions(playerColors);
|
||||
}
|
||||
|
||||
auto playerInfo = gs->getPlayer(gs->currentPlayer, false);
|
||||
// If we are called before the actual game start, there might be no current player
|
||||
if(playerInfo && playerInfo->status != EPlayerStatus::INGAME)
|
||||
if (playerInfo && playerInfo->status != EPlayerStatus::INGAME)
|
||||
{
|
||||
// If player making turn has lost his turn must be over as well
|
||||
states.setFlag(gs->currentPlayer, &PlayerStatus::makingTurn, false);
|
||||
|
Loading…
Reference in New Issue
Block a user