From cfdd70355cc500f8d1e068b33234cbac772b7a3f Mon Sep 17 00:00:00 2001 From: Michal Brzozowski Date: Fri, 24 May 2024 14:02:01 +0200 Subject: [PATCH] Fix duplicate conquered villain messages when killing fighters after a duel --- collective.cpp | 2 +- creature.cpp | 4 ++++ creature.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/collective.cpp b/collective.cpp index 67b421af4..2c87ef1ae 100644 --- a/collective.cpp +++ b/collective.cpp @@ -747,7 +747,7 @@ const optional& Collective::getAlarmInfo() const { } bool Collective::needsToBeKilledToConquer(const Creature* c) const { - return hasTrait(c, MinionTrait::FIGHTER) || hasTrait(c, MinionTrait::LEADER); + return (hasTrait(c, MinionTrait::FIGHTER) && !c->wasDuel()) || hasTrait(c, MinionTrait::LEADER); } bool Collective::creatureConsideredPlayer(Creature* c) const { diff --git a/creature.cpp b/creature.cpp index 96ba91578..bf709e3b6 100644 --- a/creature.cpp +++ b/creature.cpp @@ -1703,6 +1703,10 @@ void Creature::removePrivateEnemy(const Creature* c) { privateEnemies.erase(c); } +bool Creature::wasDuel() const { + return !!duelInfo; +} + void Creature::setDuel(TribeId enemyTribe, Creature* opponent, GlobalTime timeout) { duelInfo = DuelInfo{enemyTribe, opponent ? opponent->getUniqueId() : Creature::Id{}, timeout}; if (steed) diff --git a/creature.h b/creature.h index 78c3ad681..a678456a2 100644 --- a/creature.h +++ b/creature.h @@ -343,6 +343,7 @@ class Creature : public Renderable, public UniqueEntity, public OwnedO bool canBeCaptured() const; void removePrivateEnemy(const Creature*); void setDuel(TribeId enemyTribe, Creature* opponent, GlobalTime timeout); + bool wasDuel() const; const vector& getAutomatonParts() const; bool isAutomaton() const; void addAutomatonPart(AutomatonPart);