mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Merge pull request #1197 from IvanSavenko/hero_positioning_fix
Adjust positions of heroes in towns earlier
This commit is contained in:
commit
34cd856f53
@ -760,6 +760,7 @@ void CGameState::init(const IMapService * mapService, StartInfo * si, bool allow
|
|||||||
initHeroes();
|
initHeroes();
|
||||||
initStartingBonus();
|
initStartingBonus();
|
||||||
initTowns();
|
initTowns();
|
||||||
|
placeHeroesInTowns();
|
||||||
initMapObjects();
|
initMapObjects();
|
||||||
buildBonusSystemTree();
|
buildBonusSystemTree();
|
||||||
initVisitingAndGarrisonedHeroes();
|
initVisitingAndGarrisonedHeroes();
|
||||||
@ -1363,7 +1364,8 @@ void CGameState::placeStartingHeroes()
|
|||||||
{
|
{
|
||||||
if(auto campaignBonus = scenarioOps->campState->getBonusForCurrentMap())
|
if(auto campaignBonus = scenarioOps->campState->getBonusForCurrentMap())
|
||||||
{
|
{
|
||||||
if(campaignBonus->type == CScenarioTravel::STravelBonus::HERO && playerColor == PlayerColor(campaignBonus->info1)) continue;
|
if(campaignBonus->type == CScenarioTravel::STravelBonus::HERO && playerColor == PlayerColor(campaignBonus->info1))
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1861,20 +1863,18 @@ void CGameState::initMapObjects()
|
|||||||
map->calculateGuardingGreaturePositions(); //calculate once again when all the guards are placed and initialized
|
map->calculateGuardingGreaturePositions(); //calculate once again when all the guards are placed and initialized
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameState::initVisitingAndGarrisonedHeroes()
|
void CGameState::placeHeroesInTowns()
|
||||||
{
|
{
|
||||||
for(auto k=players.begin(); k!=players.end(); ++k)
|
for(auto k=players.begin(); k!=players.end(); ++k)
|
||||||
{
|
{
|
||||||
if(k->first==PlayerColor::NEUTRAL)
|
if(k->first==PlayerColor::NEUTRAL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//init visiting and garrisoned heroes
|
|
||||||
for(CGHeroInstance *h : k->second.heroes)
|
for(CGHeroInstance *h : k->second.heroes)
|
||||||
{
|
{
|
||||||
for(CGTownInstance *t : k->second.towns)
|
for(CGTownInstance *t : k->second.towns)
|
||||||
{
|
{
|
||||||
bool heroOnTownBlockableTile = t->blockingAt(h->visitablePos().x, h->visitablePos().y);
|
bool heroOnTownBlockableTile = t->blockingAt(h->visitablePos().x, h->visitablePos().y);
|
||||||
bool heroOnTownVisitableTile = t->visitableAt(h->visitablePos().x, h->visitablePos().y);
|
|
||||||
|
|
||||||
// current hero position is at one of blocking tiles of current town
|
// current hero position is at one of blocking tiles of current town
|
||||||
// assume that this hero should be visiting the town (H3M format quirk) and move hero to correct position
|
// assume that this hero should be visiting the town (H3M format quirk) and move hero to correct position
|
||||||
@ -1889,8 +1889,24 @@ void CGameState::initVisitingAndGarrisonedHeroes()
|
|||||||
|
|
||||||
assert(t->visitableAt(h->visitablePos().x, h->visitablePos().y));
|
assert(t->visitableAt(h->visitablePos().x, h->visitablePos().y));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (heroOnTownBlockableTile || heroOnTownVisitableTile)
|
void CGameState::initVisitingAndGarrisonedHeroes()
|
||||||
|
{
|
||||||
|
for(auto k=players.begin(); k!=players.end(); ++k)
|
||||||
|
{
|
||||||
|
if(k->first==PlayerColor::NEUTRAL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//init visiting and garrisoned heroes
|
||||||
|
for(CGHeroInstance *h : k->second.heroes)
|
||||||
|
{
|
||||||
|
for(CGTownInstance *t : k->second.towns)
|
||||||
|
{
|
||||||
|
if (t->visitableAt(h->visitablePos().x, h->visitablePos().y))
|
||||||
{
|
{
|
||||||
assert(t->visitingHero == nullptr);
|
assert(t->visitingHero == nullptr);
|
||||||
t->setVisitingHero(h);
|
t->setVisitingHero(h);
|
||||||
|
@ -269,6 +269,7 @@ private:
|
|||||||
void placeStartingHero(PlayerColor playerColor, HeroTypeID heroTypeId, int3 townPos);
|
void placeStartingHero(PlayerColor playerColor, HeroTypeID heroTypeId, int3 townPos);
|
||||||
void initStartingResources();
|
void initStartingResources();
|
||||||
void initHeroes();
|
void initHeroes();
|
||||||
|
void placeHeroesInTowns();
|
||||||
void giveCampaignBonusToHero(CGHeroInstance * hero);
|
void giveCampaignBonusToHero(CGHeroInstance * hero);
|
||||||
void initFogOfWar();
|
void initFogOfWar();
|
||||||
void initStartingBonus();
|
void initStartingBonus();
|
||||||
|
Loading…
Reference in New Issue
Block a user