1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

Fix subObject identification

This commit is contained in:
AlexVinS
2015-11-16 17:38:42 +03:00
parent b56b7017ba
commit 3f79d001c1
4 changed files with 24 additions and 6 deletions

View File

@ -154,11 +154,14 @@ void CObjectClassesHandler::loadObjectEntry(const std::string & identifier, cons
logGlobal->errorStream() << "Handler with name " << obj->handlerName << " was not found!";
return;
}
std::string convertedId = VLC->modh->normalizeIdentifier(entry.meta, "core", identifier);
si32 id = selectNextID(entry["index"], obj->subObjects, 1000);
auto handler = handlerConstructors.at(obj->handlerName)();
handler->setType(obj->id, id);
handler->setTypeName(obj->identifier, identifier);
handler->setTypeName(obj->identifier, convertedId);
if (customNames.count(obj->id) && customNames.at(obj->id).size() > id)
handler->init(entry, customNames.at(obj->id).at(id));
@ -175,10 +178,10 @@ void CObjectClassesHandler::loadObjectEntry(const std::string & identifier, cons
legacyTemplates.erase(range.first, range.second);
}
logGlobal->debugStream() << "Loaded object " << obj->identifier << "(" << obj->id << ")" << ":" << identifier << "(" << id << ")" ;
logGlobal->debugStream() << "Loaded object " << obj->identifier << "(" << obj->id << ")" << ":" << convertedId << "(" << id << ")" ;
assert(!obj->subObjects.count(id)); // DO NOT override
obj->subObjects[id] = handler;
obj->subIds[identifier] = id;//todo: scope
obj->subIds[convertedId] = id;
}
CObjectClassesHandler::ObjectContainter * CObjectClassesHandler::loadFromJson(const JsonNode & json, const std::string & name)