mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Removed CGHeroInstance::getPosition pseudo-override
Now access to hero visible position is always done via visitablePos
This commit is contained in:
parent
2855606a88
commit
908e6892f3
@ -107,7 +107,7 @@ boost::optional<AIPathNode *> AINodeStorage::getOrCreateNode(const int3 & pos, c
|
|||||||
|
|
||||||
std::vector<CGPathNode *> AINodeStorage::getInitialNodes()
|
std::vector<CGPathNode *> AINodeStorage::getInitialNodes()
|
||||||
{
|
{
|
||||||
auto hpos = hero->getPosition(false);
|
auto hpos = hero->visitablePos();
|
||||||
auto initialNode =
|
auto initialNode =
|
||||||
getOrCreateNode(hpos, hero->boat ? EPathfindingLayer::SAIL : EPathfindingLayer::LAND, NORMAL_CHAIN)
|
getOrCreateNode(hpos, hero->boat ? EPathfindingLayer::SAIL : EPathfindingLayer::LAND, NORMAL_CHAIN)
|
||||||
.get();
|
.get();
|
||||||
@ -211,7 +211,7 @@ std::vector<CGPathNode *> AINodeStorage::calculateTeleportations(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hero->getPosition(false) == source.coord)
|
if(hero->visitablePos() == source.coord)
|
||||||
{
|
{
|
||||||
calculateTownPortalTeleportations(source, neighbours);
|
calculateTownPortalTeleportations(source, neighbours);
|
||||||
}
|
}
|
||||||
|
@ -2008,7 +2008,7 @@ CGPath * CPlayerInterface::getAndVerifyPath(const CGHeroInstance * h)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(h->getPosition(false) == path.startPos());
|
assert(h->visitablePos() == path.startPos());
|
||||||
//update the hero path in case of something has changed on map
|
//update the hero path in case of something has changed on map
|
||||||
if (LOCPLINT->cb->getPathsInfo(h)->getPath(path, path.endPos()))
|
if (LOCPLINT->cb->getPathsInfo(h)->getPath(path, path.endPos()))
|
||||||
return &path;
|
return &path;
|
||||||
@ -2112,7 +2112,7 @@ void CPlayerInterface::acceptTurn()
|
|||||||
void CPlayerInterface::tryDiggging(const CGHeroInstance * h)
|
void CPlayerInterface::tryDiggging(const CGHeroInstance * h)
|
||||||
{
|
{
|
||||||
int msgToShow = -1;
|
int msgToShow = -1;
|
||||||
const bool isBlocked = CGI->mh->hasObjectHole(h->getPosition(false)); // Don't dig in the pit.
|
const bool isBlocked = CGI->mh->hasObjectHole(h->visitablePos()); // Don't dig in the pit.
|
||||||
|
|
||||||
const auto diggingStatus = isBlocked
|
const auto diggingStatus = isBlocked
|
||||||
? EDiggingStatus::TILE_OCCUPIED
|
? EDiggingStatus::TILE_OCCUPIED
|
||||||
|
@ -486,7 +486,7 @@ void CMinimapInstance::showAll(SDL_Surface * to)
|
|||||||
std::vector <const CGHeroInstance *> heroes = LOCPLINT->cb->getHeroesInfo(false); //TODO: do we really need separate function for drawing heroes?
|
std::vector <const CGHeroInstance *> heroes = LOCPLINT->cb->getHeroesInfo(false); //TODO: do we really need separate function for drawing heroes?
|
||||||
for(auto & hero : heroes)
|
for(auto & hero : heroes)
|
||||||
{
|
{
|
||||||
int3 position = hero->getPosition(false);
|
int3 position = hero->visitablePos();
|
||||||
if(position.z == level)
|
if(position.z == level)
|
||||||
{
|
{
|
||||||
const SDL_Color & color = graphics->playerColors[hero->getOwner().getNum()];
|
const SDL_Color & color = graphics->playerColors[hero->getOwner().getNum()];
|
||||||
|
@ -1363,7 +1363,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|||||||
|
|
||||||
CGPath &path = LOCPLINT->paths[h];
|
CGPath &path = LOCPLINT->paths[h];
|
||||||
terrain.currentPath = &path;
|
terrain.currentPath = &path;
|
||||||
int3 dst = h->getPosition(false) + dir;
|
int3 dst = h->visitablePos() + dir;
|
||||||
if(dst != verifyPos(dst) || !LOCPLINT->cb->getPathsInfo(h)->getPath(path, dst))
|
if(dst != verifyPos(dst) || !LOCPLINT->cb->getPathsInfo(h)->getPath(path, dst))
|
||||||
{
|
{
|
||||||
terrain.currentPath = nullptr;
|
terrain.currentPath = nullptr;
|
||||||
|
@ -294,7 +294,7 @@ bool CGameInfoCallback::getHeroInfo(const CGObjectInstance * hero, InfoAboutHero
|
|||||||
if(gs->curB && gs->curB->playerHasAccessToHeroInfo(*player, h)) //if it's battle we can get enemy hero full data
|
if(gs->curB && gs->curB->playerHasAccessToHeroInfo(*player, h)) //if it's battle we can get enemy hero full data
|
||||||
infoLevel = InfoAboutHero::EInfoLevel::INBATTLE;
|
infoLevel = InfoAboutHero::EInfoLevel::INBATTLE;
|
||||||
else
|
else
|
||||||
ERROR_RET_VAL_IF(!isVisible(h->getPosition(false)), "That hero is not visible!", false);
|
ERROR_RET_VAL_IF(!isVisible(h->visitablePos()), "That hero is not visible!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (infoLevel == InfoAboutHero::EInfoLevel::BASIC) && nullptr != selectedObject)
|
if( (infoLevel == InfoAboutHero::EInfoLevel::BASIC) && nullptr != selectedObject)
|
||||||
@ -734,7 +734,7 @@ std::vector < const CGHeroInstance *> CPlayerSpecificInfoCallback::getHeroesInfo
|
|||||||
{
|
{
|
||||||
// !player || // - why would we even get access to hero not owned by any player?
|
// !player || // - why would we even get access to hero not owned by any player?
|
||||||
if((hero->tempOwner == *player) ||
|
if((hero->tempOwner == *player) ||
|
||||||
(isVisible(hero->getPosition(false), player) && !onlyOur) )
|
(isVisible(hero->visitablePos(), player) && !onlyOur) )
|
||||||
{
|
{
|
||||||
ret.push_back(hero);
|
ret.push_back(hero);
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ NodeStorage::NodeStorage(CPathsInfo & pathsInfo, const CGHeroInstance * hero)
|
|||||||
:out(pathsInfo)
|
:out(pathsInfo)
|
||||||
{
|
{
|
||||||
out.hero = hero;
|
out.hero = hero;
|
||||||
out.hpos = hero->getPosition(false);
|
out.hpos = hero->visitablePos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeStorage::resetTile(
|
void NodeStorage::resetTile(
|
||||||
|
@ -141,18 +141,6 @@ BattleField CGHeroInstance::getBattlefield() const
|
|||||||
return BattleField::NONE;
|
return BattleField::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int3 CGHeroInstance::getPosition(bool h3m) const //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
|
|
||||||
{
|
|
||||||
if (h3m)
|
|
||||||
{
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return convertPosition(pos,false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ui8 CGHeroInstance::getSecSkillLevel(SecondarySkill skill) const
|
ui8 CGHeroInstance::getSecSkillLevel(SecondarySkill skill) const
|
||||||
{
|
{
|
||||||
for(auto & elem : secSkills)
|
for(auto & elem : secSkills)
|
||||||
@ -1121,7 +1109,7 @@ EDiggingStatus CGHeroInstance::diggingStatus() const
|
|||||||
if((int)movement < maxMovePoints(true))
|
if((int)movement < maxMovePoints(true))
|
||||||
return EDiggingStatus::LACK_OF_MOVEMENT;
|
return EDiggingStatus::LACK_OF_MOVEMENT;
|
||||||
|
|
||||||
return cb->getTile(getPosition(false))->getDiggingStatus();
|
return cb->getTile(visitablePos())->getDiggingStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArtBearer::ArtBearer CGHeroInstance::bearerType() const
|
ArtBearer::ArtBearer CGHeroInstance::bearerType() const
|
||||||
@ -1375,7 +1363,7 @@ bool CGHeroInstance::hasVisions(const CGObjectInstance * target, const int subty
|
|||||||
if (visionsMultiplier > 0)
|
if (visionsMultiplier > 0)
|
||||||
vstd::amax(visionsRange, 3); //minimum range is 3 tiles, but only if VISIONS bonus present
|
vstd::amax(visionsRange, 3); //minimum range is 3 tiles, but only if VISIONS bonus present
|
||||||
|
|
||||||
const int distance = static_cast<int>(target->pos.dist2d(getPosition(false)));
|
const int distance = static_cast<int>(target->pos.dist2d(visitablePos()));
|
||||||
|
|
||||||
//logGlobal->debug(boost::to_string(boost::format("Visions: dist %d, mult %d, range %d") % distance % visionsMultiplier % visionsRange));
|
//logGlobal->debug(boost::to_string(boost::format("Visions: dist %d, mult %d, range %d") % distance % visionsMultiplier % visionsRange));
|
||||||
|
|
||||||
|
@ -46,8 +46,6 @@ class DLL_LINKAGE CGHeroInstance : public CArmedInstance, public IBoatGenerator,
|
|||||||
friend class CCampaignState;
|
friend class CCampaignState;
|
||||||
friend class CMapLoaderH3M;
|
friend class CMapLoaderH3M;
|
||||||
|
|
||||||
using CArmedInstance::getPosition; //FIXME: recheck: overloaded-virtual
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::set<SpellID> spells; //known spells (spell IDs)
|
std::set<SpellID> spells; //known spells (spell IDs)
|
||||||
|
|
||||||
@ -161,7 +159,6 @@ public:
|
|||||||
ui32 getTileCost(const TerrainTile &dest, const TerrainTile &from, const TurnInfo * ti) const; //move cost - applying pathfinding skill, road and terrain modifiers. NOT includes diagonal move penalty, last move levelling
|
ui32 getTileCost(const TerrainTile &dest, const TerrainTile &from, const TurnInfo * ti) const; //move cost - applying pathfinding skill, road and terrain modifiers. NOT includes diagonal move penalty, last move levelling
|
||||||
TerrainId getNativeTerrain() const;
|
TerrainId getNativeTerrain() const;
|
||||||
ui32 getLowestCreatureSpeed() const;
|
ui32 getLowestCreatureSpeed() const;
|
||||||
int3 getPosition(bool h3m = false) const; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
|
|
||||||
si32 manaRegain() const; //how many points of mana can hero regain "naturally" in one day
|
si32 manaRegain() const; //how many points of mana can hero regain "naturally" in one day
|
||||||
si32 getManaNewTurn() const; //calculate how much mana this hero is going to have the next day
|
si32 getManaNewTurn() const; //calculate how much mana this hero is going to have the next day
|
||||||
int getCurrentLuck(int stack=-1, bool town=false) const;
|
int getCurrentLuck(int stack=-1, bool town=false) const;
|
||||||
|
@ -1920,7 +1920,7 @@ void CGMagi::onHeroVisit(const CGHeroInstance * h) const
|
|||||||
|
|
||||||
cb->sendAndApply(&cv);
|
cb->sendAndApply(&cv);
|
||||||
}
|
}
|
||||||
cv.pos = h->getPosition(false);
|
cv.pos = h->visitablePos();
|
||||||
cv.focusTime = 0;
|
cv.focusTime = 0;
|
||||||
cb->sendAndApply(&cv);
|
cb->sendAndApply(&cv);
|
||||||
}
|
}
|
||||||
|
@ -1931,7 +1931,7 @@ void CGameHandler::newTurn()
|
|||||||
hth.id = h->id;
|
hth.id = h->id;
|
||||||
auto ti = make_unique<TurnInfo>(h, 1);
|
auto ti = make_unique<TurnInfo>(h, 1);
|
||||||
// TODO: this code executed when bonuses of previous day not yet updated (this happen in NewTurn::applyGs). See issue 2356
|
// TODO: this code executed when bonuses of previous day not yet updated (this happen in NewTurn::applyGs). See issue 2356
|
||||||
hth.move = h->maxMovePointsCached(gs->map->getTile(h->getPosition(false)).terType->isLand(), ti.get());
|
hth.move = h->maxMovePointsCached(gs->map->getTile(h->visitablePos()).terType->isLand(), ti.get());
|
||||||
hth.mana = h->getManaNewTurn();
|
hth.mana = h->getManaNewTurn();
|
||||||
|
|
||||||
n.heroes.insert(hth);
|
n.heroes.insert(hth);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user