|
@@ -111,18 +111,18 @@ void Object::Instance::setPositionRaw(const int3 & position)
|
|
|
dObject.pos = dPosition + dParent.getPosition();
|
|
|
}
|
|
|
|
|
|
-void Object::Instance::setAnyTemplate()
|
|
|
+void Object::Instance::setAnyTemplate(CRandomGenerator & rng)
|
|
|
{
|
|
|
auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates();
|
|
|
if(templates.empty())
|
|
|
throw rmgException(boost::str(boost::format("Did not find any graphics for object (%d,%d)") % dObject.ID % dObject.subID));
|
|
|
|
|
|
- dObject.appearance = templates.front();
|
|
|
+ dObject.appearance = *RandomGeneratorUtil::nextItem(templates, rng);
|
|
|
dAccessibleAreaCache.clear();
|
|
|
setPosition(getPosition(false));
|
|
|
}
|
|
|
|
|
|
-void Object::Instance::setTemplate(TerrainId terrain)
|
|
|
+void Object::Instance::setTemplate(TerrainId terrain, CRandomGenerator & rng)
|
|
|
{
|
|
|
auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates(terrain);
|
|
|
if (templates.empty())
|
|
@@ -130,7 +130,8 @@ void Object::Instance::setTemplate(TerrainId terrain)
|
|
|
auto terrainName = VLC->terrainTypeHandler->getById(terrain)->getNameTranslated();
|
|
|
throw rmgException(boost::str(boost::format("Did not find graphics for object (%d,%d) at %s") % dObject.ID % dObject.subID % terrainName));
|
|
|
}
|
|
|
- dObject.appearance = templates.front();
|
|
|
+
|
|
|
+ dObject.appearance = *RandomGeneratorUtil::nextItem(templates, rng);
|
|
|
dAccessibleAreaCache.clear();
|
|
|
setPosition(getPosition(false));
|
|
|
}
|
|
@@ -280,10 +281,10 @@ void Object::setPosition(const int3 & position)
|
|
|
i.setPositionRaw(i.getPosition());
|
|
|
}
|
|
|
|
|
|
-void Object::setTemplate(const TerrainId & terrain)
|
|
|
+void Object::setTemplate(const TerrainId & terrain, CRandomGenerator & rng)
|
|
|
{
|
|
|
for(auto& i : dInstances)
|
|
|
- i.setTemplate(terrain);
|
|
|
+ i.setTemplate(terrain, rng);
|
|
|
}
|
|
|
|
|
|
const Area & Object::getArea() const
|
|
@@ -325,7 +326,7 @@ void rmg::Object::setGuardedIfMonster(const Instance& object)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void Object::Instance::finalize(RmgMap & map)
|
|
|
+void Object::Instance::finalize(RmgMap & map, CRandomGenerator & rng)
|
|
|
{
|
|
|
if(!map.isOnMap(getPosition(true)))
|
|
|
throw rmgException(boost::str(boost::format("Position of object %d at %s is outside the map") % dObject.id % getPosition(true).toString()));
|
|
@@ -341,7 +342,7 @@ void Object::Instance::finalize(RmgMap & map)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- setTemplate(terrainType->getId());
|
|
|
+ setTemplate(terrainType->getId(), rng);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -362,14 +363,14 @@ void Object::Instance::finalize(RmgMap & map)
|
|
|
map.getMapProxy()->insertObject(&dObject);
|
|
|
}
|
|
|
|
|
|
-void Object::finalize(RmgMap & map)
|
|
|
+void Object::finalize(RmgMap & map, CRandomGenerator & rng)
|
|
|
{
|
|
|
if(dInstances.empty())
|
|
|
throw rmgException("Cannot finalize object without instances");
|
|
|
|
|
|
for(auto & dInstance : dInstances)
|
|
|
{
|
|
|
- dInstance.finalize(map);
|
|
|
+ dInstance.finalize(map, rng);
|
|
|
}
|
|
|
}
|
|
|
|