1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Try to simplify / cleanup code to localize crash

This commit is contained in:
Ivan Savenko
2024-01-20 18:40:03 +02:00
parent 912262e826
commit 8e8d42bfa2
4 changed files with 14 additions and 23 deletions

View File

@@ -1074,14 +1074,14 @@ void CMapLoaderJson::MapObjectLoader::construct()
auto handler = VLC->objtypeh->getHandlerFor( ModScope::scopeMap(), typeName, subtypeName);
auto * appearance = new ObjectTemplate;
auto appearance = std::make_shared<ObjectTemplate>();
appearance->id = Obj(handler->getIndex());
appearance->subid = handler->getSubIndex();
appearance->readJson(configuration["template"], false);
// Will be destroyed soon and replaced with shared template
instance = handler->create(std::shared_ptr<const ObjectTemplate>(appearance));
instance = handler->create(appearance);
instance->id = ObjectInstanceID(static_cast<si32>(owner->map->objects.size()));
instance->instanceName = jsonKey;