mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
added sufficient debug to diagnose - problem is with lack of original data
This commit is contained in:
parent
d8648288f0
commit
64e2db6a0f
@ -19,6 +19,10 @@
|
||||
"required" : ["basic", "advanced", "expert"],
|
||||
|
||||
"properties": {
|
||||
"index":{
|
||||
"type": "number",
|
||||
"description": "numeric id of skill required only for original skills, prohibited for new skills"
|
||||
},
|
||||
"basic":{
|
||||
"$ref" : "#/definitions/skillBonus"
|
||||
},
|
||||
@ -27,7 +31,7 @@
|
||||
},
|
||||
"expert":{
|
||||
"$ref" : "#/definitions/skillBonus"
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +204,12 @@ void CIdentifierStorage::registerObject(std::string scope, std::string type, std
|
||||
std::string fullID = type + '.' + name;
|
||||
checkIdentifier(fullID);
|
||||
|
||||
registeredObjects.insert(std::make_pair(fullID, data));
|
||||
auto mapping = std::make_pair(fullID, data);
|
||||
if(!registeredObjects.contains(mapping))
|
||||
{
|
||||
CLogger::getLogger(CLoggerDomain("identifier"))->traceStream() << "registered " << fullID << " as " << scope << ":" << identifier;
|
||||
registeredObjects.insert(mapping);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<CIdentifierStorage::ObjectData> CIdentifierStorage::getPossibleIdentifiers(const ObjectCallback & request)
|
||||
@ -393,8 +398,9 @@ bool CContentHandler::ContentTypeHandler::loadMod(std::string modName, bool vali
|
||||
|
||||
continue;
|
||||
}
|
||||
logGlobal->debugStream() << "no original data in loadMod(" << name << "): " << data;
|
||||
}
|
||||
// normal new object or one with index bigger that data size
|
||||
// normal new object or one with index bigger than data size
|
||||
performValidate(data,name);
|
||||
handler->loadObject(modName, name, data);
|
||||
}
|
||||
|
@ -51,6 +51,10 @@ class CIdentifierStorage
|
||||
si32 id;
|
||||
std::string scope; /// scope in which this ID located
|
||||
|
||||
bool operator==(const ObjectData & other) const
|
||||
{
|
||||
return id == other.id && scope == other.scope;
|
||||
}
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
@ -59,7 +63,22 @@ class CIdentifierStorage
|
||||
}
|
||||
};
|
||||
|
||||
std::multimap<std::string, ObjectData > registeredObjects;
|
||||
class ObjectMap: public std::multimap<std::string, ObjectData>
|
||||
{
|
||||
public:
|
||||
bool contains(const value_type & value) const
|
||||
{
|
||||
auto range = equal_range(value.first);
|
||||
for(auto contained = range.first; contained != range.second; contained++)
|
||||
{
|
||||
if(value.second == contained->second)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
ObjectMap registeredObjects;
|
||||
std::vector<ObjectCallback> scheduledRequests;
|
||||
|
||||
ELoadingState state;
|
||||
|
@ -83,7 +83,7 @@ std::vector<JsonNode> CSkillHandler::loadLegacyData(size_t dataSize)
|
||||
|
||||
const std::string CSkillHandler::getTypeName() const
|
||||
{
|
||||
return "secondarySkill";
|
||||
return "skill";
|
||||
}
|
||||
|
||||
CSkill * CSkillHandler::loadFromJson(const JsonNode & json, const std::string & identifier)
|
||||
@ -115,7 +115,7 @@ CSkill * CSkillHandler::loadFromJson(const JsonNode & json, const std::string &
|
||||
skill->addNewBonus(bonus, level);
|
||||
}
|
||||
}
|
||||
CLogger * logger = CLogger::getLogger(CLoggerDomain("skills"));
|
||||
CLogger * logger = CLogger::getLogger(CLoggerDomain(getTypeName()));
|
||||
logger->debugStream() << "loaded secondary skill " << identifier << "(" << (int)skill->id << ")";
|
||||
logger->traceStream() << *skill;
|
||||
|
||||
@ -124,6 +124,10 @@ CSkill * CSkillHandler::loadFromJson(const JsonNode & json, const std::string &
|
||||
|
||||
void CSkillHandler::afterLoadFinalization()
|
||||
{
|
||||
CLogger * logger = CLogger::getLogger(CLoggerDomain(getTypeName()));
|
||||
logger->traceStream() << "skill handler after load: ";
|
||||
for(auto skill : objects)
|
||||
logger->traceStream() << *skill;
|
||||
}
|
||||
|
||||
void CSkillHandler::beforeValidate(JsonNode & object)
|
||||
|
@ -82,12 +82,10 @@ public:
|
||||
auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name));
|
||||
object->id = _ObjectID(index);
|
||||
|
||||
|
||||
assert(objects[index] == nullptr); // ensure that this id was not loaded before
|
||||
objects[index] = object;
|
||||
|
||||
registerObject(scope,type_name, name, object->id);
|
||||
|
||||
}
|
||||
|
||||
ConstTransitivePtr<_Object> operator[] (const _ObjectID id) const
|
||||
|
Loading…
Reference in New Issue
Block a user