mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Merge pull request #2360 from vcmi/fix_incorrect_guard_cherrypick
Fix incorrect guard position This is quite essential to generate HoTA map without crashes
This commit is contained in:
@@ -344,6 +344,16 @@ void Object::Instance::finalize(RmgMap & map)
|
|||||||
setTemplate(terrainType->getId());
|
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()))
|
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()));
|
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()));
|
||||||
|
@@ -334,7 +334,17 @@ void ConnectionsPlacer::selfSideIndirectConnection(const rmg::ZoneConnection & c
|
|||||||
if(dist < minDist || otherDist < minDist)
|
if(dist < minDist || otherDist < minDist)
|
||||||
return -1.f;
|
return -1.f;
|
||||||
|
|
||||||
|
//This could fail is accessibleArea is below the map
|
||||||
rmg::Area toPlace(rmgGate1.getArea() + rmgGate1.getAccessibleArea());
|
rmg::Area toPlace(rmgGate1.getArea() + rmgGate1.getAccessibleArea());
|
||||||
|
auto inTheMap = toPlace.getTilesVector();
|
||||||
|
toPlace.clear();
|
||||||
|
for (const int3& tile : inTheMap)
|
||||||
|
{
|
||||||
|
if (map.isOnMap(tile))
|
||||||
|
{
|
||||||
|
toPlace.add(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
toPlace.translate(-zShift);
|
toPlace.translate(-zShift);
|
||||||
|
|
||||||
path2 = managerOther.placeAndConnectObject(toPlace, rmgGate2, minDist, guarded2, true, ObjectManager::OptimizeType::NONE);
|
path2 = managerOther.placeAndConnectObject(toPlace, rmgGate2, minDist, guarded2, true, ObjectManager::OptimizeType::NONE);
|
||||||
|
@@ -606,8 +606,6 @@ bool ObjectManager::addGuard(rmg::Object & object, si32 strength, bool zoneGuard
|
|||||||
auto & instance = object.addInstance(*guard);
|
auto & instance = object.addInstance(*guard);
|
||||||
instance.setPosition(guardPos - object.getPosition());
|
instance.setPosition(guardPos - object.getPosition());
|
||||||
instance.setAnyTemplate(); //terrain is irrelevant for monsters, but monsters need some template now
|
instance.setAnyTemplate(); //terrain is irrelevant for monsters, but monsters need some template now
|
||||||
//Make up for extra offset in HotA creature templates
|
|
||||||
instance.setPosition(instance.getPosition() + instance.object().getVisitableOffset());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user