mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	added sufficient debug to diagnose - problem is with lack of original data
This commit is contained in:
		| @@ -19,6 +19,10 @@ | |||||||
|         "required" : ["basic", "advanced", "expert"], |         "required" : ["basic", "advanced", "expert"], | ||||||
|  |  | ||||||
|         "properties": { |         "properties": { | ||||||
|  |             "index":{ | ||||||
|  |                 "type": "number", | ||||||
|  |                 "description": "numeric id of skill required only for original skills, prohibited for new skills" | ||||||
|  |             }, | ||||||
|             "basic":{ |             "basic":{ | ||||||
|                 "$ref" : "#/definitions/skillBonus" |                 "$ref" : "#/definitions/skillBonus" | ||||||
|             }, |             }, | ||||||
| @@ -27,7 +31,7 @@ | |||||||
|             }, |             }, | ||||||
|             "expert":{ |             "expert":{ | ||||||
|                 "$ref" : "#/definitions/skillBonus" |                 "$ref" : "#/definitions/skillBonus" | ||||||
|             }, |             } | ||||||
|         } |         } | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -204,7 +204,12 @@ void CIdentifierStorage::registerObject(std::string scope, std::string type, std | |||||||
| 	std::string fullID = type + '.' + name; | 	std::string fullID = type + '.' + name; | ||||||
| 	checkIdentifier(fullID); | 	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) | std::vector<CIdentifierStorage::ObjectData> CIdentifierStorage::getPossibleIdentifiers(const ObjectCallback & request) | ||||||
| @@ -393,8 +398,9 @@ bool CContentHandler::ContentTypeHandler::loadMod(std::string modName, bool vali | |||||||
|  |  | ||||||
| 				continue; | 				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); | 		performValidate(data,name); | ||||||
| 		handler->loadObject(modName, name, data); | 		handler->loadObject(modName, name, data); | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -51,6 +51,10 @@ class CIdentifierStorage | |||||||
| 		si32 id; | 		si32 id; | ||||||
| 		std::string scope; /// scope in which this ID located | 		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) | 		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; | 	std::vector<ObjectCallback> scheduledRequests; | ||||||
|  |  | ||||||
| 	ELoadingState state; | 	ELoadingState state; | ||||||
|   | |||||||
| @@ -83,7 +83,7 @@ std::vector<JsonNode> CSkillHandler::loadLegacyData(size_t dataSize) | |||||||
|  |  | ||||||
| const std::string CSkillHandler::getTypeName() const | const std::string CSkillHandler::getTypeName() const | ||||||
| { | { | ||||||
| 	return "secondarySkill"; | 	return "skill"; | ||||||
| } | } | ||||||
|  |  | ||||||
| CSkill * CSkillHandler::loadFromJson(const JsonNode & json, const std::string & identifier) | 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); |             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->debugStream() << "loaded secondary skill " << identifier << "(" << (int)skill->id << ")"; | ||||||
|     logger->traceStream() << *skill; |     logger->traceStream() << *skill; | ||||||
|  |  | ||||||
| @@ -124,6 +124,10 @@ CSkill * CSkillHandler::loadFromJson(const JsonNode & json, const std::string & | |||||||
|  |  | ||||||
| void CSkillHandler::afterLoadFinalization() | 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) | void CSkillHandler::beforeValidate(JsonNode & object) | ||||||
|   | |||||||
| @@ -82,12 +82,10 @@ public: | |||||||
| 		auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name)); | 		auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name)); | ||||||
| 		object->id = _ObjectID(index); | 		object->id = _ObjectID(index); | ||||||
|  |  | ||||||
|  |  | ||||||
| 		assert(objects[index] == nullptr); // ensure that this id was not loaded before | 		assert(objects[index] == nullptr); // ensure that this id was not loaded before | ||||||
| 		objects[index] = object; | 		objects[index] = object; | ||||||
|  |  | ||||||
| 		registerObject(scope,type_name, name, object->id); | 		registerObject(scope,type_name, name, object->id); | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	ConstTransitivePtr<_Object> operator[] (const _ObjectID id) const | 	ConstTransitivePtr<_Object> operator[] (const _ObjectID id) const | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user