mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Show error message on load if mod has broken creature instead of
crashing on creature window screen
This commit is contained in:
		| @@ -646,10 +646,15 @@ CCreature * CCreatureHandler::loadFromJson(const std::string & scope, const Json | ||||
| 			registerObject(scope, type_name, extraName.String(), cre->getIndex()); | ||||
| 	} | ||||
|  | ||||
| 	if (!cre->special && | ||||
| 		!CResourceHandler::get()->existsResource(cre->animDefName) && | ||||
| 		!CResourceHandler::get()->existsResource(cre->animDefName.addPrefix("SPRITES/"))) | ||||
| 		throw ModLoadingException(scope, "creature " + cre->getJsonKey() + " has no combat animation but is not marked as special!" ); | ||||
|  | ||||
| 	JsonNode advMapFile = node["graphics"]["map"]; | ||||
| 	JsonNode advMapMask = node["graphics"]["mapMask"]; | ||||
|  | ||||
| 	VLC->identifiers()->requestIdentifier(scope, "object", "monster", [cre, scope, advMapFile, advMapMask](si32 index) | ||||
| 	VLC->identifiers()->requestIdentifier(scope, "object", "monster", [cre, scope, advMapFile, advMapMask](si32 monsterIndex) | ||||
| 	{ | ||||
| 		JsonNode conf; | ||||
| 		conf.setModScope(scope); | ||||
| @@ -672,7 +677,7 @@ CCreature * CCreatureHandler::loadFromJson(const std::string & scope, const Json | ||||
| 		if (VLC->objtypeh->getHandlerFor(Obj::MONSTER, cre->getId().num)->getTemplates().empty()) | ||||
| 		{ | ||||
| 			if (!cre->special) | ||||
| 				throw DataLoadingException("Mod " + scope + " is corrupted! Please disable or reinstall this mod. Reason: creature " + cre->getJsonKey() + " has no adventure map animation but is not marked as special!" ); | ||||
| 				throw ModLoadingException(scope, "creature " + cre->getJsonKey() + " has no adventure map animation but is not marked as special!" ); | ||||
|  | ||||
| 			VLC->objtypeh->removeSubObject(Obj::MONSTER, cre->getId().num); | ||||
| 		} | ||||
| @@ -737,7 +742,6 @@ void CCreatureHandler::loadCrExpMod() | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| void CCreatureHandler::loadCrExpBon(CBonusSystemNode & globalEffects) | ||||
| { | ||||
| 	if (VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE)) 	//reading default stack experience bonuses | ||||
|   | ||||
| @@ -14,3 +14,11 @@ class DLL_LINKAGE DataLoadingException: public std::runtime_error | ||||
| public: | ||||
|     using std::runtime_error::runtime_error; | ||||
| }; | ||||
|  | ||||
| class DLL_LINKAGE ModLoadingException: public DataLoadingException | ||||
| { | ||||
| public: | ||||
| 	ModLoadingException(const std::string & modName, const std::string & reason) | ||||
| 		: DataLoadingException("Mod " + modName + " is corrupted! Please disable or reinstall this mod. Reason: " + reason) | ||||
| 	{} | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user