mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-25 21:38:59 +02:00
fix visiting objects other than town
This commit is contained in:
parent
b0b3b9bb84
commit
37f621abbd
@ -4194,6 +4194,19 @@ const CGHeroInstance * CGameHandler::getVisitingHero(const CGObjectInstance *obj
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const CGObjectInstance * CGameHandler::getVisitingObject(const CGHeroInstance *hero)
|
||||
{
|
||||
assert(hero);
|
||||
|
||||
for(const auto & query : queries->allQueries())
|
||||
{
|
||||
auto visit = std::dynamic_pointer_cast<const CObjectVisitQuery>(query);
|
||||
if (visit && visit->visitingHero == hero)
|
||||
return visit->visitedObject;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CGameHandler::isVisitCoveredByAnotherQuery(const CGObjectInstance *obj, const CGHeroInstance *hero)
|
||||
{
|
||||
assert(obj);
|
||||
|
@ -154,6 +154,7 @@ public:
|
||||
|
||||
/// Returns hero that is currently visiting this object, or nullptr if no visit is active
|
||||
const CGHeroInstance * getVisitingHero(const CGObjectInstance *obj);
|
||||
const CGObjectInstance * getVisitingObject(const CGHeroInstance *hero);
|
||||
bool isVisitCoveredByAnotherQuery(const CGObjectInstance *obj, const CGHeroInstance *hero) override;
|
||||
void setObjPropertyValue(ObjectInstanceID objid, ObjProperty prop, int32_t value) override;
|
||||
void setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, ObjPropertyID identifier) override;
|
||||
|
@ -98,9 +98,12 @@ void CBattleDialogQuery::onRemoval(PlayerColor color)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(result && bi->getDefendedTown())
|
||||
bi->getDefendedTown()->battleFinished(bi->getSideHero(BattleSide::ATTACKER), *result);
|
||||
|
||||
auto hero = bi->getSideHero(BattleSide::ATTACKER);
|
||||
auto visitingObj = bi->getDefendedTown() ? bi->getDefendedTown() : gh->getVisitingObject(hero);
|
||||
|
||||
gh->battles->endBattleConfirm(bi->getBattleID());
|
||||
|
||||
if(visitingObj)
|
||||
visitingObj->battleFinished(hero, *result);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user