mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Fix incorrect templates for mines in HoTA
This commit is contained in:
committed by
Andrii Danylchenko
parent
238dabe060
commit
8c481dff46
@@ -105,20 +105,26 @@ void Object::Instance::setPositionRaw(const int3 & position)
|
||||
dObject.pos = dPosition + dParent.getPosition();
|
||||
}
|
||||
|
||||
void Object::Instance::setTemplate(const TerrainId & terrain)
|
||||
void Object::Instance::setAnyTemplate()
|
||||
{
|
||||
if(dObject.appearance->id == Obj::NO_OBJ)
|
||||
auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates();
|
||||
if(templates.empty())
|
||||
throw rmgException(boost::to_string(boost::format("Did not find any graphics for object (%d,%d)") % dObject.ID % dObject.subID));
|
||||
|
||||
dObject.appearance = templates.front();
|
||||
dAccessibleAreaCache.clear();
|
||||
setPosition(getPosition(false));
|
||||
}
|
||||
|
||||
void Object::Instance::setTemplate(TerrainId terrain)
|
||||
{
|
||||
auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates(terrain);
|
||||
if (templates.empty())
|
||||
{
|
||||
auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates(terrain);
|
||||
auto terrainName = VLC->terrainTypeHandler->terrains()[terrain].name;
|
||||
if (templates.empty())
|
||||
{
|
||||
throw rmgException(boost::to_string(boost::format("Did not find graphics for object (%d,%d) at %s") %
|
||||
dObject.ID % dObject.subID % terrainName));
|
||||
}
|
||||
|
||||
dObject.appearance = templates.front();
|
||||
throw rmgException(boost::to_string(boost::format("Did not find graphics for object (%d,%d) at %s") % dObject.ID % dObject.subID % terrainName));
|
||||
}
|
||||
dObject.appearance = templates.front();
|
||||
dAccessibleAreaCache.clear();
|
||||
setPosition(getPosition(false));
|
||||
}
|
||||
@@ -283,6 +289,21 @@ void Object::Instance::finalize(RmgMap & map)
|
||||
if(!map.isOnMap(getPosition(true)))
|
||||
throw rmgException(boost::to_string(boost::format("Position of object %d at %s is outside the map") % dObject.id % getPosition(true).toString()));
|
||||
|
||||
//If no specific template was defined for this object, select any matching
|
||||
if (!dObject.appearance)
|
||||
{
|
||||
auto terrainType = map.map().getTile(getPosition(true)).terType;
|
||||
auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates(terrainType->id);
|
||||
if (templates.empty())
|
||||
{
|
||||
throw rmgException(boost::to_string(boost::format("Did not find graphics for object (%d,%d) at %s (terrain %d)") % dObject.ID % dObject.subID % getPosition(true).toString() % terrainType));
|
||||
}
|
||||
else
|
||||
{
|
||||
setTemplate(terrainType->id);
|
||||
}
|
||||
}
|
||||
|
||||
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()));
|
||||
|
||||
@@ -292,17 +313,6 @@ void Object::Instance::finalize(RmgMap & map)
|
||||
throw rmgException(boost::to_string(boost::format("Tile %s of object %d at %s is outside the map") % tile.toString() % dObject.id % dObject.pos.toString()));
|
||||
}
|
||||
|
||||
if (dObject.appearance->id == Obj::NO_OBJ)
|
||||
{
|
||||
auto terrainType = map.map().getTile(getPosition(true)).terType;
|
||||
auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates(terrainType->id);
|
||||
if (templates.empty())
|
||||
throw rmgException(boost::to_string(boost::format("Did not find graphics for object (%d,%d) at %s (terrain %d)") %
|
||||
dObject.ID % dObject.subID % getPosition(true).toString() % terrainType->name));
|
||||
|
||||
setTemplate(terrainType->id);
|
||||
}
|
||||
|
||||
for(auto & tile : getBlockedArea().getTilesVector())
|
||||
{
|
||||
map.setOccupied(tile, ETileType::ETileType::USED);
|
||||
|
||||
Reference in New Issue
Block a user