1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Fix hota offset + 2 possible crashes

This commit is contained in:
Tomasz Zieliński
2023-08-11 07:45:24 +02:00
parent f5926c4023
commit 0252d0f986
2 changed files with 44 additions and 15 deletions

View File

@ -344,16 +344,6 @@ void Object::Instance::finalize(RmgMap & map)
setTemplate(terrainType->getId());
}
}
if (dObject.ID == Obj::MONSTER)
{
//Make up for extra offset in HotA creature templates
auto visitableOffset = dObject.getVisitableOffset();
auto fixedPos = getPosition(true) + visitableOffset;
vstd::abetween(fixedPos.x, visitableOffset.x, map.width() - 1);
vstd::abetween(fixedPos.y, visitableOffset.y, map.height() - 1);
int3 parentPos = getPosition(true) - getPosition(false);
setPosition(fixedPos - parentPos);
}
if (dObject.isVisitable() && !map.isOnMap(dObject.visitablePos()))
throw rmgException(boost::to_string(boost::format("Visitable tile %s of object %d at %s is outside the map") % dObject.visitablePos().toString() % dObject.id % dObject.pos.toString()));