mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
Fixes for handling of oversized map dwellings
- Marked large version of H3 Unicorn's Glade as not usable for random dwelling replacement - Shifted oversized dwellings - that have at most 2x2 as blocked tile, but have non-blocked tile column will now be placed correctly - This fixes incorrect random dwelling replacement of the only oversized H3 dwelling - Portal of Glory - Game will now detect & report invalid dwelling templates from mods - Updated docs to clarify dwellings format
This commit is contained in:
@@ -121,7 +121,7 @@ const std::set<int3> & CGObjectInstance::getBlockedOffsets() const
|
||||
void CGObjectInstance::setType(MapObjectID newID, MapObjectSubID newSubID)
|
||||
{
|
||||
auto position = visitablePos();
|
||||
auto oldOffset = getVisitableOffset();
|
||||
auto oldOffset = appearance->getCornerOffset();
|
||||
auto &tile = cb->gameState().getMap().getTile(position);
|
||||
|
||||
//recalculate blockvis tiles - new appearance might have different blockmap than before
|
||||
@@ -144,11 +144,12 @@ void CGObjectInstance::setType(MapObjectID newID, MapObjectSubID newSubID)
|
||||
// instead, appearance update & pos adjustment occurs in GiveHero::applyGs
|
||||
needToAdjustOffset |= this->ID == Obj::PRISON && newID == Obj::HERO;
|
||||
needToAdjustOffset |= newID == Obj::MONSTER;
|
||||
needToAdjustOffset |= newID == Obj::CREATURE_GENERATOR1 || newID == Obj::CREATURE_GENERATOR2 || newID == Obj::CREATURE_GENERATOR3 || newID == Obj::CREATURE_GENERATOR4;
|
||||
|
||||
if(needToAdjustOffset)
|
||||
{
|
||||
// adjust position since object visitable offset might have changed
|
||||
auto newOffset = getVisitableOffset();
|
||||
auto newOffset = appearance->getCornerOffset();
|
||||
pos = pos - oldOffset + newOffset;
|
||||
}
|
||||
|
||||
|
||||
@@ -500,6 +500,23 @@ void ObjectTemplate::calculateVisitableOffset()
|
||||
visitableOffset = int3(0, 0, 0);
|
||||
}
|
||||
|
||||
int3 ObjectTemplate::getCornerOffset() const
|
||||
{
|
||||
assert(isVisitable());
|
||||
|
||||
int3 ret = visitableOffset;
|
||||
for (const auto & tile : blockedOffsets)
|
||||
{
|
||||
ret = {
|
||||
std::min(-tile.x, ret.x),
|
||||
std::min(-tile.y, ret.y),
|
||||
ret.z
|
||||
};
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ObjectTemplate::canBePlacedAt(TerrainId terrainID) const
|
||||
{
|
||||
if (anyLandTerrain)
|
||||
|
||||
@@ -124,6 +124,11 @@ public:
|
||||
// Checks if object can be placed on specific terrain
|
||||
bool canBePlacedAt(TerrainId terrain) const;
|
||||
|
||||
/// Returns number of completely empty rows & columns in template
|
||||
/// Such as shifted wandering monster def's from hota, or Portal of Glory dwelling from H3
|
||||
/// object must be visitable
|
||||
int3 getCornerOffset() const;
|
||||
|
||||
CompoundMapObjectID getCompoundID() const;
|
||||
|
||||
ObjectTemplate();
|
||||
|
||||
Reference in New Issue
Block a user