1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Fixed visitation of configurable town buildings by newly recruited heroes

and on building construction
This commit is contained in:
Ivan Savenko
2024-08-12 13:06:32 +00:00
parent abdb23f78f
commit 67132b3e7f
4 changed files with 14 additions and 17 deletions

View File

@@ -476,7 +476,7 @@ void CTownRewardableBuilding::onHeroVisit(const CGHeroInstance *h) const
cb->showBlockingDialog(&sd); cb->showBlockingDialog(&sd);
}; };
if(!town->hasBuilt(bID) || cb->isVisitCoveredByAnotherQuery(town, h)) if(!town->hasBuilt(bID))
return; return;
if(!wasVisitedBefore(h)) if(!wasVisitedBefore(h))

View File

@@ -322,8 +322,9 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const
cb->heroVisitCastle(this, h); cb->heroVisitCastle(this, h);
} }
} }
else if(h->visitablePos() == visitablePos()) else
{ {
assert(h->visitablePos() == this->visitablePos());
bool commander_recover = h->commander && !h->commander->alive; bool commander_recover = h->commander && !h->commander->alive;
if (commander_recover) // rise commander from dead if (commander_recover) // rise commander from dead
{ {
@@ -344,10 +345,6 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const
cb->showInfoDialog(&iw); cb->showInfoDialog(&iw);
} }
} }
else
{
logGlobal->error("%s visits allied town of %s from different pos?", h->getNameTranslated(), getNameTranslated());
}
} }
void CGTownInstance::onHeroLeave(const CGHeroInstance * h) const void CGTownInstance::onHeroLeave(const CGHeroInstance * h) const

View File

@@ -1518,11 +1518,14 @@ void CGameHandler::takeCreatures(ObjectInstanceID objid, const std::vector<CStac
void CGameHandler::heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) void CGameHandler::heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero)
{ {
HeroVisitCastle vc; if (obj->visitingHero != hero && obj->garrisonHero != hero)
vc.hid = hero->id; {
vc.tid = obj->id; HeroVisitCastle vc;
vc.flags |= 1; vc.hid = hero->id;
sendAndApply(&vc); vc.tid = obj->id;
vc.flags |= 1;
sendAndApply(&vc);
}
visitCastleObjects(obj, hero); visitCastleObjects(obj, hero);
giveSpells (obj, hero); giveSpells (obj, hero);
@@ -2487,9 +2490,9 @@ bool CGameHandler::buildStructure(ObjectInstanceID tid, BuildingID requestedID,
changeFogOfWar(t->getSightCenter(), t->getSightRadius(), t->getOwner(), ETileVisibility::REVEALED); changeFogOfWar(t->getSightCenter(), t->getSightRadius(), t->getOwner(), ETileVisibility::REVEALED);
if(t->garrisonHero) //garrison hero first - consistent with original H3 Mana Vortex and Battle Scholar Academy levelup windows order if(t->garrisonHero) //garrison hero first - consistent with original H3 Mana Vortex and Battle Scholar Academy levelup windows order
visitCastleObjects(t, t->garrisonHero); objectVisited(t, t->garrisonHero);
if(t->visitingHero) if(t->visitingHero)
visitCastleObjects(t, t->visitingHero); objectVisited(t, t->visitingHero);
checkVictoryLossConditionsForPlayer(t->tempOwner); checkVictoryLossConditionsForPlayer(t->tempOwner);
return true; return true;

View File

@@ -242,10 +242,7 @@ bool HeroPoolProcessor::hireHero(const ObjectInstanceID & objectID, const HeroTy
gameHandler->giveResource(player, EGameResID::GOLD, -GameConstants::HERO_GOLD_COST); gameHandler->giveResource(player, EGameResID::GOLD, -GameConstants::HERO_GOLD_COST);
if(town) if(town)
{ gameHandler->objectVisited(town, recruitedHero);
gameHandler->visitCastleObjects(town, recruitedHero);
gameHandler->giveSpells(town, recruitedHero);
}
// If new hero has scouting he might reveal more terrain than we saw before // If new hero has scouting he might reveal more terrain than we saw before
gameHandler->changeFogOfWar(recruitedHero->getSightCenter(), recruitedHero->getSightRadius(), player, ETileVisibility::REVEALED); gameHandler->changeFogOfWar(recruitedHero->getSightCenter(), recruitedHero->getSightRadius(), player, ETileVisibility::REVEALED);