mirror of
https://github.com/vcmi/vcmi.git
synced 2025-12-01 23:12:49 +02:00
Replaced most of accesses to CGObjectInstance::pos with anchorPoint()
This commit is contained in:
@@ -375,7 +375,7 @@ void HeroMovementController::sendMovementRequest(const CGHeroInstance * h, const
|
||||
{
|
||||
updateMovementSound(h, currNode.coord, nextNode.coord, nextNode.action);
|
||||
|
||||
assert(h->pos.z == nextNode.coord.z); // Z should change only if it's movement via teleporter and in this case this code shouldn't be executed at all
|
||||
assert(h->anchorPos().z == nextNode.coord.z); // Z should change only if it's movement via teleporter and in this case this code shouldn't be executed at all
|
||||
|
||||
logGlobal->trace("Requesting hero movement to %s", nextNode.coord.toString());
|
||||
|
||||
|
||||
@@ -81,9 +81,9 @@ void MapAudioPlayer::addObject(const CGObjectInstance * obj)
|
||||
{
|
||||
for(int fy = 0; fy < obj->getHeight(); ++fy)
|
||||
{
|
||||
int3 currTile(obj->pos.x - fx, obj->pos.y - fy, obj->pos.z);
|
||||
int3 currTile(obj->anchorPos().x - fx, obj->anchorPos().y - fy, obj->anchorPos().z);
|
||||
|
||||
if(LOCPLINT->cb->isInTheMap(currTile) && obj->coveringAt(currTile.x, currTile.y))
|
||||
if(LOCPLINT->cb->isInTheMap(currTile) && obj->coveringAt(currTile))
|
||||
objects[currTile.z][currTile.x][currTile.y].push_back(obj->id);
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ void MapAudioPlayer::addObject(const CGObjectInstance * obj)
|
||||
|
||||
for(const auto & tile : tiles)
|
||||
{
|
||||
int3 currTile = obj->pos + tile;
|
||||
int3 currTile = obj->anchorPos() + tile;
|
||||
|
||||
if(LOCPLINT->cb->isInTheMap(currTile))
|
||||
objects[currTile.z][currTile.x][currTile.y].push_back(obj->id);
|
||||
|
||||
@@ -591,8 +591,8 @@ void MapRendererOverlay::renderTile(IMapRendererContext & context, Canvas & targ
|
||||
|
||||
if(context.objectTransparency(objectID, coordinates) > 0 && !context.isActiveHero(object))
|
||||
{
|
||||
visitable |= object->visitableAt(coordinates.x, coordinates.y);
|
||||
blocking |= object->blockingAt(coordinates.x, coordinates.y);
|
||||
visitable |= object->visitableAt(coordinates);
|
||||
blocking |= object->blockingAt(coordinates);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ size_t MapRendererBaseContext::objectGroupIndex(ObjectInstanceID objectID) const
|
||||
Point MapRendererBaseContext::objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const
|
||||
{
|
||||
const CGObjectInstance * object = getObject(objectID);
|
||||
int3 offsetTiles(object->getPosition() - coordinates);
|
||||
int3 offsetTiles(object->anchorPos() - coordinates);
|
||||
return Point(offsetTiles) * Point(32, 32);
|
||||
}
|
||||
|
||||
@@ -498,7 +498,7 @@ size_t MapRendererWorldViewContext::overlayImageIndex(const int3 & coordinates)
|
||||
{
|
||||
const auto * object = getObject(objectID);
|
||||
|
||||
if(!object->visitableAt(coordinates.x, coordinates.y))
|
||||
if(!object->visitableAt(coordinates))
|
||||
continue;
|
||||
|
||||
ObjectPosInfo info(object);
|
||||
|
||||
@@ -49,9 +49,9 @@ void MapRendererContextState::addObject(const CGObjectInstance * obj)
|
||||
{
|
||||
for(int fy = 0; fy < obj->getHeight(); ++fy)
|
||||
{
|
||||
int3 currTile(obj->pos.x - fx, obj->pos.y - fy, obj->pos.z);
|
||||
int3 currTile(obj->anchorPos().x - fx, obj->anchorPos().y - fy, obj->anchorPos().z);
|
||||
|
||||
if(LOCPLINT->cb->isInTheMap(currTile) && obj->coveringAt(currTile.x, currTile.y))
|
||||
if(LOCPLINT->cb->isInTheMap(currTile) && obj->coveringAt(currTile))
|
||||
{
|
||||
auto & container = objects[currTile.z][currTile.x][currTile.y];
|
||||
|
||||
@@ -73,7 +73,7 @@ void MapRendererContextState::addMovingObject(const CGObjectInstance * object, c
|
||||
{
|
||||
for(int y = yFrom; y <= yDest; ++y)
|
||||
{
|
||||
int3 currTile(x, y, object->pos.z);
|
||||
int3 currTile(x, y, object->anchorPos().z);
|
||||
|
||||
if(LOCPLINT->cb->isInTheMap(currTile))
|
||||
{
|
||||
|
||||
@@ -317,7 +317,7 @@ bool MapViewController::isEventVisible(const CGObjectInstance * obj, const Playe
|
||||
if(obj->isVisitable())
|
||||
return context->isVisible(obj->visitablePos());
|
||||
else
|
||||
return context->isVisible(obj->pos);
|
||||
return context->isVisible(obj->anchorPos());
|
||||
}
|
||||
|
||||
bool MapViewController::isEventVisible(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
|
||||
|
||||
@@ -59,7 +59,7 @@ std::string CMapHandler::getTerrainDescr(const int3 & pos, bool rightClick) cons
|
||||
|
||||
for(const auto & object : map->objects)
|
||||
{
|
||||
if(object && object->coveringAt(pos.x, pos.y) && object->pos.z == pos.z && object->isTile2Terrain())
|
||||
if(object && object->coveringAt(pos) && object->isTile2Terrain())
|
||||
{
|
||||
result = object->getObjectName();
|
||||
break;
|
||||
@@ -103,15 +103,15 @@ bool CMapHandler::compareObjectBlitOrder(const CGObjectInstance * a, const CGObj
|
||||
|
||||
for(const auto & aOffset : a->getBlockedOffsets())
|
||||
{
|
||||
int3 testTarget = a->pos + aOffset + int3(0, 1, 0);
|
||||
if(b->blockingAt(testTarget.x, testTarget.y))
|
||||
int3 testTarget = a->anchorPos() + aOffset + int3(0, 1, 0);
|
||||
if(b->blockingAt(testTarget))
|
||||
bBlocksA += 1;
|
||||
}
|
||||
|
||||
for(const auto & bOffset : b->getBlockedOffsets())
|
||||
{
|
||||
int3 testTarget = b->pos + bOffset + int3(0, 1, 0);
|
||||
if(a->blockingAt(testTarget.x, testTarget.y))
|
||||
int3 testTarget = b->anchorPos() + bOffset + int3(0, 1, 0);
|
||||
if(a->blockingAt(testTarget))
|
||||
aBlocksB += 1;
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ bool CMapHandler::compareObjectBlitOrder(const CGObjectInstance * a, const CGObj
|
||||
return aBlocksB < bBlocksA;
|
||||
|
||||
// object that don't have clear priority via tile blocking will appear based on their row
|
||||
if(a->pos.y != b->pos.y)
|
||||
return a->pos.y < b->pos.y;
|
||||
if(a->anchorPos().y != b->anchorPos().y)
|
||||
return a->anchorPos().y < b->anchorPos().y;
|
||||
|
||||
// heroes should appear on top of objects on the same tile
|
||||
if(b->ID==Obj::HERO && a->ID!=Obj::HERO)
|
||||
|
||||
@@ -78,7 +78,7 @@ void CQuestMinimap::addQuestMarks (const QuestInfo * q)
|
||||
|
||||
int3 tile;
|
||||
if (q->obj)
|
||||
tile = q->obj->pos;
|
||||
tile = q->obj->visitablePos();
|
||||
else
|
||||
tile = q->tile;
|
||||
|
||||
@@ -104,7 +104,7 @@ void CQuestMinimap::update()
|
||||
void CQuestMinimap::iconClicked()
|
||||
{
|
||||
if(currentQuest->obj)
|
||||
adventureInt->centerOnTile(currentQuest->obj->pos);
|
||||
adventureInt->centerOnTile(currentQuest->obj->visitablePos());
|
||||
//moveAdvMapSelection();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user