mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Bugfixing. Game seems to be working without major bugs.
This commit is contained in:
		| @@ -202,6 +202,14 @@ void CHeroClassHandler::loadObject(std::string scope, std::string name, const Js | |||||||
|  |  | ||||||
| 	heroClasses.push_back(object); | 	heroClasses.push_back(object); | ||||||
|  |  | ||||||
|  | 	VLC->modh->identifiers.requestIdentifier(scope, "object", "hero", [=](si32 index) | ||||||
|  | 	{ | ||||||
|  | 		JsonNode classConf; | ||||||
|  | 		classConf["heroClass"].String() = name; | ||||||
|  | 		classConf.setMeta(scope); | ||||||
|  | 		VLC->objtypeh->loadSubObject(name, classConf, index, object->id); | ||||||
|  | 	}); | ||||||
|  |  | ||||||
| 	VLC->modh->identifiers.registerObject(scope, "heroClass", name, object->id); | 	VLC->modh->identifiers.registerObject(scope, "heroClass", name, object->id); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -213,6 +221,14 @@ void CHeroClassHandler::loadObject(std::string scope, std::string name, const Js | |||||||
| 	assert(heroClasses[index] == nullptr); // ensure that this id was not loaded before | 	assert(heroClasses[index] == nullptr); // ensure that this id was not loaded before | ||||||
| 	heroClasses[index] = object; | 	heroClasses[index] = object; | ||||||
|  |  | ||||||
|  | 	VLC->modh->identifiers.requestIdentifier(scope, "object", "hero", [=](si32 index) | ||||||
|  | 	{ | ||||||
|  | 		JsonNode classConf; | ||||||
|  | 		classConf["heroClass"].String() = name; | ||||||
|  | 		classConf.setMeta(scope); | ||||||
|  | 		VLC->objtypeh->loadSubObject(name, classConf, index, object->id); | ||||||
|  | 	}); | ||||||
|  |  | ||||||
| 	VLC->modh->identifiers.registerObject(scope, "heroClass", name, object->id); | 	VLC->modh->identifiers.registerObject(scope, "heroClass", name, object->id); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -235,7 +251,6 @@ void CHeroClassHandler::afterLoadFinalization() | |||||||
|  |  | ||||||
| 	for (CHeroClass * hc : heroClasses) | 	for (CHeroClass * hc : heroClasses) | ||||||
| 	{ | 	{ | ||||||
| 		VLC->objtypeh->loadSubObject(hc->identifier, JsonNode(), Obj::HERO, hc->id); |  | ||||||
| 		if (!hc->imageMapMale.empty()) | 		if (!hc->imageMapMale.empty()) | ||||||
| 		{ | 		{ | ||||||
| 			JsonNode templ; | 			JsonNode templ; | ||||||
|   | |||||||
| @@ -26,6 +26,11 @@ | |||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  | CIdentifierStorage::CIdentifierStorage(): | ||||||
|  | 	state(LOADING) | ||||||
|  | { | ||||||
|  | } | ||||||
|  |  | ||||||
| void CIdentifierStorage::checkIdentifier(std::string & ID) | void CIdentifierStorage::checkIdentifier(std::string & ID) | ||||||
| { | { | ||||||
| 	if (boost::algorithm::ends_with(ID, ".")) | 	if (boost::algorithm::ends_with(ID, ".")) | ||||||
| @@ -81,7 +86,10 @@ void CIdentifierStorage::requestIdentifier(ObjectCallback callback) | |||||||
|  |  | ||||||
| 	assert(!callback.localScope.empty()); | 	assert(!callback.localScope.empty()); | ||||||
|  |  | ||||||
| 	scheduledRequests.push_back(callback); | 	if (state != FINISHED) // enqueue request if loading is still in progress | ||||||
|  | 		scheduledRequests.push_back(callback); | ||||||
|  | 	else // execute immediately for "late" requests | ||||||
|  | 		resolveIdentifier(callback); | ||||||
| } | } | ||||||
|  |  | ||||||
| void CIdentifierStorage::requestIdentifier(std::string scope, std::string type, std::string name, const std::function<void(si32)> & callback) | void CIdentifierStorage::requestIdentifier(std::string scope, std::string type, std::string name, const std::function<void(si32)> & callback) | ||||||
| @@ -244,6 +252,7 @@ bool CIdentifierStorage::resolveIdentifier(const ObjectCallback & request) | |||||||
|  |  | ||||||
| void CIdentifierStorage::finalize() | void CIdentifierStorage::finalize() | ||||||
| { | { | ||||||
|  | 	state = FINALIZING; | ||||||
| 	bool errorsFound = false; | 	bool errorsFound = false; | ||||||
|  |  | ||||||
| 	//Note: we may receive new requests during resolution phase -> end may change -> range for can't be used | 	//Note: we may receive new requests during resolution phase -> end may change -> range for can't be used | ||||||
| @@ -261,6 +270,7 @@ void CIdentifierStorage::finalize() | |||||||
| 		logGlobal->errorStream() << "All known identifiers were dumped into log file"; | 		logGlobal->errorStream() << "All known identifiers were dumped into log file"; | ||||||
| 	} | 	} | ||||||
| 	assert(errorsFound == false); | 	assert(errorsFound == false); | ||||||
|  | 	state = FINISHED; | ||||||
| } | } | ||||||
|  |  | ||||||
| CContentHandler::ContentTypeHandler::ContentTypeHandler(IHandlerBase * handler, std::string objectName): | CContentHandler::ContentTypeHandler::ContentTypeHandler(IHandlerBase * handler, std::string objectName): | ||||||
|   | |||||||
| @@ -25,6 +25,13 @@ class IHandlerBase; | |||||||
| /// if possible, objects ID's should be in format <type>.<name>, camelCase e.g. "creature.grandElf" | /// if possible, objects ID's should be in format <type>.<name>, camelCase e.g. "creature.grandElf" | ||||||
| class CIdentifierStorage | class CIdentifierStorage | ||||||
| { | { | ||||||
|  | 	enum ELoadingState | ||||||
|  | 	{ | ||||||
|  | 		LOADING, | ||||||
|  | 		FINALIZING, | ||||||
|  | 		FINISHED | ||||||
|  | 	}; | ||||||
|  |  | ||||||
| 	struct ObjectCallback // entry created on ID request | 	struct ObjectCallback // entry created on ID request | ||||||
| 	{ | 	{ | ||||||
| 		std::string localScope;  /// scope from which this ID was requested | 		std::string localScope;  /// scope from which this ID was requested | ||||||
| @@ -52,6 +59,8 @@ class CIdentifierStorage | |||||||
| 	std::multimap<std::string, ObjectData > registeredObjects; | 	std::multimap<std::string, ObjectData > registeredObjects; | ||||||
| 	std::vector<ObjectCallback> scheduledRequests; | 	std::vector<ObjectCallback> scheduledRequests; | ||||||
|  |  | ||||||
|  | 	ELoadingState state; | ||||||
|  |  | ||||||
| 	/// Check if identifier can be valid (camelCase, point as separator) | 	/// Check if identifier can be valid (camelCase, point as separator) | ||||||
| 	void checkIdentifier(std::string & ID); | 	void checkIdentifier(std::string & ID); | ||||||
|  |  | ||||||
| @@ -59,6 +68,7 @@ class CIdentifierStorage | |||||||
| 	bool resolveIdentifier(const ObjectCallback & callback); | 	bool resolveIdentifier(const ObjectCallback & callback); | ||||||
| 	std::vector<ObjectData> getPossibleIdentifiers(const ObjectCallback & callback); | 	std::vector<ObjectData> getPossibleIdentifiers(const ObjectCallback & callback); | ||||||
| public: | public: | ||||||
|  | 	CIdentifierStorage(); | ||||||
| 	/// request identifier for specific object name. | 	/// request identifier for specific object name. | ||||||
| 	/// Function callback will be called during ID resolution phase of loading | 	/// Function callback will be called during ID resolution phase of loading | ||||||
| 	void requestIdentifier(std::string scope, std::string type, std::string name, const std::function<void(si32)> & callback); | 	void requestIdentifier(std::string scope, std::string type, std::string name, const std::function<void(si32)> & callback); | ||||||
| @@ -82,7 +92,7 @@ public: | |||||||
|  |  | ||||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | 	template <typename Handler> void serialize(Handler &h, const int version) | ||||||
| 	{ | 	{ | ||||||
| 		h & registeredObjects; | 		h & registeredObjects & state; | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -773,26 +773,6 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod | |||||||
| void CTownHandler::afterLoadFinalization() | void CTownHandler::afterLoadFinalization() | ||||||
| { | { | ||||||
| 	initializeRequirements(); | 	initializeRequirements(); | ||||||
| 	for (CFaction * fact : factions) |  | ||||||
| 	{ |  | ||||||
| 		// MODS COMPATIBILITY FOR 0.96 |  | ||||||
| 		if (fact->town) |  | ||||||
| 		{ |  | ||||||
| 			assert(fact->town->dwellings.size() == fact->town->dwellingNames.size()); |  | ||||||
| 			for (size_t i=0; i<fact->town->dwellings.size(); i++) |  | ||||||
| 			{ |  | ||||||
| 				//both unupgraded and upgraded get same dwelling |  | ||||||
| 				for (auto cre : fact->town->creatures[i]) |  | ||||||
| 				{ |  | ||||||
| 					JsonNode templ; |  | ||||||
| 					templ["animation"].String() = fact->town->dwellings[i]; |  | ||||||
|  |  | ||||||
| 					VLC->objtypeh->loadSubObject("", JsonNode(), Obj::CREATURE_GENERATOR1, 100 + cre); |  | ||||||
| 					VLC->objtypeh->getHandlerFor(Obj::CREATURE_GENERATOR1, 100 + cre)->addTemplate(templ); |  | ||||||
| 				 } |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void CTownHandler::initializeRequirements() | void CTownHandler::initializeRequirements() | ||||||
|   | |||||||
| @@ -629,23 +629,22 @@ void CGBonusingObject::initObj() | |||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	info.resize(1); | 	info.resize(1); | ||||||
| 	CVisitInfo & visit = info[0]; |  | ||||||
|  |  | ||||||
| 	switch(ID) | 	switch(ID) | ||||||
| 	{ | 	{ | ||||||
| 	case Obj::BUOY: | 	case Obj::BUOY: | ||||||
| 			blockVisit = true; | 			blockVisit = true; | ||||||
| 		configureMessage(visit, 21, 22, soundBase::MORALE); | 		configureMessage(info[0], 21, 22, soundBase::MORALE); | ||||||
| 		configureBonus(visit, Bonus::MORALE, +1, 94); | 		configureBonus(info[0], Bonus::MORALE, +1, 94); | ||||||
| 		break; | 		break; | ||||||
| 	case Obj::SWAN_POND: | 	case Obj::SWAN_POND: | ||||||
| 		configureMessage(visit, 29, 30, soundBase::LUCK); | 		configureMessage(info[0], 29, 30, soundBase::LUCK); | ||||||
| 		configureBonus(visit, Bonus::LUCK, 2, 67); | 		configureBonus(info[0], Bonus::LUCK, 2, 67); | ||||||
| 		visit.reward.movePercentage = 0; | 		info[0].reward.movePercentage = 0; | ||||||
| 		break; | 		break; | ||||||
| 	case Obj::FAERIE_RING: | 	case Obj::FAERIE_RING: | ||||||
| 		configureMessage(visit, 49, 50, soundBase::LUCK); | 		configureMessage(info[0], 49, 50, soundBase::LUCK); | ||||||
| 		configureBonus(visit, Bonus::LUCK, 2, 71); | 		configureBonus(info[0], Bonus::LUCK, 2, 71); | ||||||
| 		break; | 		break; | ||||||
| 	case Obj::FOUNTAIN_OF_FORTUNE: | 	case Obj::FOUNTAIN_OF_FORTUNE: | ||||||
| 		selectMode = SELECT_RANDOM; | 		selectMode = SELECT_RANDOM; | ||||||
| @@ -673,19 +672,19 @@ void CGBonusingObject::initObj() | |||||||
| 		break; | 		break; | ||||||
| 	case Obj::MERMAID: | 	case Obj::MERMAID: | ||||||
| 		blockVisit = true; | 		blockVisit = true; | ||||||
| 		configureMessage(visit, 83, 82, soundBase::LUCK); | 		configureMessage(info[0], 83, 82, soundBase::LUCK); | ||||||
| 		configureBonus(visit, Bonus::LUCK, 1, 72); | 		configureBonus(info[0], Bonus::LUCK, 1, 72); | ||||||
| 		break; | 		break; | ||||||
| 	case Obj::RALLY_FLAG: | 	case Obj::RALLY_FLAG: | ||||||
| 		configureMessage(visit, 111, 110, soundBase::MORALE); | 		configureMessage(info[0], 111, 110, soundBase::MORALE); | ||||||
| 		configureBonus(visit, Bonus::MORALE, 1, 102); | 		configureBonus(info[0], Bonus::MORALE, 1, 102); | ||||||
| 		configureBonus(visit, Bonus::LUCK,   1, 102); | 		configureBonus(info[0], Bonus::LUCK,   1, 102); | ||||||
| 		visit.reward.movePoints = 400; | 		info[0].reward.movePoints = 400; | ||||||
| 		break; | 		break; | ||||||
| 	case Obj::OASIS: | 	case Obj::OASIS: | ||||||
| 		configureMessage(visit, 95, 94, soundBase::MORALE); | 		configureMessage(info[0], 95, 94, soundBase::MORALE); | ||||||
| 		configureBonus(visit, Bonus::MORALE, 1, 95); | 		configureBonus(info[0], Bonus::MORALE, 1, 95); | ||||||
| 		visit.reward.movePoints = 800; | 		info[0].reward.movePoints = 800; | ||||||
| 		break; | 		break; | ||||||
| 	case Obj::TEMPLE: | 	case Obj::TEMPLE: | ||||||
| 		info[0].limiter.dayOfWeek = 7; | 		info[0].limiter.dayOfWeek = 7; | ||||||
| @@ -693,24 +692,24 @@ void CGBonusingObject::initObj() | |||||||
| 		configureBonus(info[0], Bonus::MORALE, 2, 96); | 		configureBonus(info[0], Bonus::MORALE, 2, 96); | ||||||
| 		configureBonus(info[1], Bonus::MORALE, 1, 97); | 		configureBonus(info[1], Bonus::MORALE, 1, 97); | ||||||
|  |  | ||||||
| 		configureMessage(visit, 140, 141, soundBase::temple); | 		configureMessage(info[0], 140, 141, soundBase::temple); | ||||||
| 		configureMessage(info[1], 140, 141, soundBase::temple); | 		configureMessage(info[1], 140, 141, soundBase::temple); | ||||||
| 		break; | 		break; | ||||||
| 	case Obj::WATERING_HOLE: | 	case Obj::WATERING_HOLE: | ||||||
| 		configureMessage(visit, 166, 167, soundBase::MORALE); | 		configureMessage(info[0], 166, 167, soundBase::MORALE); | ||||||
| 		configureBonus(visit, Bonus::MORALE, 1, 100); | 		configureBonus(info[0], Bonus::MORALE, 1, 100); | ||||||
| 		visit.reward.movePoints = 400; | 		info[0].reward.movePoints = 400; | ||||||
| 		break; | 		break; | ||||||
| 	case Obj::FOUNTAIN_OF_YOUTH: | 	case Obj::FOUNTAIN_OF_YOUTH: | ||||||
| 		configureMessage(visit, 57, 58, soundBase::MORALE); | 		configureMessage(info[0], 57, 58, soundBase::MORALE); | ||||||
| 		configureBonus(visit, Bonus::MORALE, 1, 103); | 		configureBonus(info[0], Bonus::MORALE, 1, 103); | ||||||
| 		visit.reward.movePoints = 400; | 		info[0].reward.movePoints = 400; | ||||||
| 		break; | 		break; | ||||||
| 	case Obj::STABLES: | 	case Obj::STABLES: | ||||||
| 		configureMessage(visit, 137, 136, soundBase::STORE); | 		configureMessage(info[0], 137, 136, soundBase::STORE); | ||||||
|  |  | ||||||
| 		configureBonusDuration(visit, Bonus::ONE_WEEK, Bonus::LAND_MOVEMENT, 600, 0); | 		configureBonusDuration(info[0], Bonus::ONE_WEEK, Bonus::LAND_MOVEMENT, 600, 0); | ||||||
| 		visit.reward.movePoints = 600; | 		info[0].reward.movePoints = 600; | ||||||
| 		//TODO: upgrade champions to cavaliers | 		//TODO: upgrade champions to cavaliers | ||||||
| /* | /* | ||||||
| 		bool someUpgradeDone = false; | 		bool someUpgradeDone = false; | ||||||
|   | |||||||
| @@ -192,7 +192,12 @@ void CDwellingInstanceConstructor::configureObject(CGObjectInstance * object, CR | |||||||
| 			dwelling->creatures.back().second.push_back(cre->idNumber); | 			dwelling->creatures.back().second.push_back(cre->idNumber); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for (auto & stack : loadCreatures(guards, rng)) | 	if (guards.getType() == JsonNode::DATA_BOOL) | ||||||
|  | 	{ | ||||||
|  | 		const CCreature * crea = availableCreatures.at(0).at(0); | ||||||
|  | 		dwelling->putStack(SlotID(0), new CStackInstance(crea->idNumber, crea->growth * 3 )); | ||||||
|  | 	} | ||||||
|  | 	else for (auto & stack : loadCreatures(guards, rng)) | ||||||
| 	{ | 	{ | ||||||
| 		dwelling->putStack(SlotID(dwelling->stacksCount()), new CStackInstance(stack.type->idNumber, stack.count)); | 		dwelling->putStack(SlotID(dwelling->stacksCount()), new CStackInstance(stack.type->idNumber, stack.count)); | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -1,6 +1,5 @@ | |||||||
| #pragma once | #pragma once | ||||||
|  |  | ||||||
| #include "../../Global.h" |  | ||||||
| #include "../../lib/GameConstants.h" | #include "../../lib/GameConstants.h" | ||||||
|  |  | ||||||
| /* | /* | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user