From b0d8068493a0fd82fc0c2eb75e4119e1dfd1c2c8 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 10 Dec 2024 11:17:26 +0000 Subject: [PATCH] fix "transport artifact" victory condition triggering as victory for human players even when artifact was transported by enemy AI if "standard victory" is also enabled --- lib/gameState/CGameState.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index 7df3c63e9..4b8f99d58 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -1400,8 +1400,10 @@ bool CGameState::checkForVictory(const PlayerColor & player, const EventConditio case EventCondition::TRANSPORT: { const auto * t = getTown(condition.objectID); - return (t->visitingHero && t->visitingHero->getOwner() == player && t->visitingHero->hasArt(condition.objectType.as())) || - (t->garrisonHero && t->garrisonHero->getOwner() == player && t->garrisonHero->hasArt(condition.objectType.as())); + bool garrisonedWon = t->garrisonHero && t->garrisonHero->getOwner() == player && t->garrisonHero->hasArt(condition.objectType.as()); + bool visitingWon = t->visitingHero && t->visitingHero->getOwner() == player && t->visitingHero->hasArt(condition.objectType.as()); + + return garrisonedWon || visitingWon; } case EventCondition::DAYS_PASSED: { @@ -1436,6 +1438,9 @@ PlayerColor CGameState::checkForStandardWin() const TeamID winnerTeam = TeamID::NO_TEAM; for(const auto & elem : players) { + if(elem.second.status == EPlayerStatus::WINNER) + return elem.second.color; + if(elem.second.status == EPlayerStatus::INGAME && elem.first.isValidPlayer()) { if(supposedWinner == PlayerColor::NEUTRAL)