mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Better solution for rmg crash fix
This commit is contained in:
parent
44d3629028
commit
aa02d5787a
@ -138,6 +138,9 @@ void Object::Instance::setTemplate(TerrainId terrain, CRandomGenerator & rng)
|
||||
|
||||
void Object::Instance::clear()
|
||||
{
|
||||
if (onCleared)
|
||||
onCleared(&dObject);
|
||||
|
||||
delete &dObject;
|
||||
dBlockedAreaCache.clear();
|
||||
dAccessibleAreaCache.clear();
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
void finalize(RmgMap & map, CRandomGenerator &); //cache invalidation
|
||||
void clear();
|
||||
|
||||
std::function<void(CGObjectInstance *)> onCleared;
|
||||
private:
|
||||
mutable Area dBlockedAreaCache;
|
||||
int3 dPosition;
|
||||
|
@ -672,7 +672,6 @@ rmg::Object TreasurePlacer::constructTreasurePile(const std::vector<ObjectInfo*>
|
||||
}
|
||||
|
||||
auto * object = oi->generateObject();
|
||||
|
||||
if(oi->templates.empty())
|
||||
{
|
||||
logGlobal->warn("Deleting randomized object with no templates: %s", object->getObjectName());
|
||||
@ -701,6 +700,7 @@ rmg::Object TreasurePlacer::constructTreasurePile(const std::vector<ObjectInfo*>
|
||||
}
|
||||
|
||||
auto & instance = rmgObject.addInstance(*object);
|
||||
instance.onCleared = oi->destroyObject;
|
||||
|
||||
do
|
||||
{
|
||||
@ -837,7 +837,6 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
|
||||
{
|
||||
for (auto* oi : treasurePile)
|
||||
{
|
||||
//oi->destroyObject();
|
||||
oi->maxPerZone++;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user