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()
|
void Object::Instance::clear()
|
||||||
{
|
{
|
||||||
|
if (onCleared)
|
||||||
|
onCleared(&dObject);
|
||||||
|
|
||||||
delete &dObject;
|
delete &dObject;
|
||||||
dBlockedAreaCache.clear();
|
dBlockedAreaCache.clear();
|
||||||
dAccessibleAreaCache.clear();
|
dAccessibleAreaCache.clear();
|
||||||
|
@ -51,6 +51,7 @@ public:
|
|||||||
void finalize(RmgMap & map, CRandomGenerator &); //cache invalidation
|
void finalize(RmgMap & map, CRandomGenerator &); //cache invalidation
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
std::function<void(CGObjectInstance *)> onCleared;
|
||||||
private:
|
private:
|
||||||
mutable Area dBlockedAreaCache;
|
mutable Area dBlockedAreaCache;
|
||||||
int3 dPosition;
|
int3 dPosition;
|
||||||
|
@ -672,7 +672,6 @@ rmg::Object TreasurePlacer::constructTreasurePile(const std::vector<ObjectInfo*>
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto * object = oi->generateObject();
|
auto * object = oi->generateObject();
|
||||||
|
|
||||||
if(oi->templates.empty())
|
if(oi->templates.empty())
|
||||||
{
|
{
|
||||||
logGlobal->warn("Deleting randomized object with no templates: %s", object->getObjectName());
|
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);
|
auto & instance = rmgObject.addInstance(*object);
|
||||||
|
instance.onCleared = oi->destroyObject;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -837,7 +837,6 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
|
|||||||
{
|
{
|
||||||
for (auto* oi : treasurePile)
|
for (auto* oi : treasurePile)
|
||||||
{
|
{
|
||||||
//oi->destroyObject();
|
|
||||||
oi->maxPerZone++;
|
oi->maxPerZone++;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user