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

Switch ObjectTemplate to shared_ptr<const> (#870)

This commit is contained in:
DjWarmonger
2022-09-11 15:12:35 +02:00
committed by Andrii Danylchenko
parent cedc9a92ed
commit 3d2dc2335b
34 changed files with 384 additions and 222 deletions

View File

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