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); | ||||
|  | ||||
| 	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); | ||||
| } | ||||
|  | ||||
| @@ -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 | ||||
| 	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); | ||||
| } | ||||
|  | ||||
| @@ -235,7 +251,6 @@ void CHeroClassHandler::afterLoadFinalization() | ||||
|  | ||||
| 	for (CHeroClass * hc : heroClasses) | ||||
| 	{ | ||||
| 		VLC->objtypeh->loadSubObject(hc->identifier, JsonNode(), Obj::HERO, hc->id); | ||||
| 		if (!hc->imageMapMale.empty()) | ||||
| 		{ | ||||
| 			JsonNode templ; | ||||
|   | ||||
| @@ -26,6 +26,11 @@ | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| CIdentifierStorage::CIdentifierStorage(): | ||||
| 	state(LOADING) | ||||
| { | ||||
| } | ||||
|  | ||||
| void CIdentifierStorage::checkIdentifier(std::string & ID) | ||||
| { | ||||
| 	if (boost::algorithm::ends_with(ID, ".")) | ||||
| @@ -81,7 +86,10 @@ void CIdentifierStorage::requestIdentifier(ObjectCallback callback) | ||||
|  | ||||
| 	assert(!callback.localScope.empty()); | ||||
|  | ||||
| 	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) | ||||
| @@ -244,6 +252,7 @@ bool CIdentifierStorage::resolveIdentifier(const ObjectCallback & request) | ||||
|  | ||||
| void CIdentifierStorage::finalize() | ||||
| { | ||||
| 	state = FINALIZING; | ||||
| 	bool errorsFound = false; | ||||
|  | ||||
| 	//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"; | ||||
| 	} | ||||
| 	assert(errorsFound == false); | ||||
| 	state = FINISHED; | ||||
| } | ||||
|  | ||||
| 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" | ||||
| class CIdentifierStorage | ||||
| { | ||||
| 	enum ELoadingState | ||||
| 	{ | ||||
| 		LOADING, | ||||
| 		FINALIZING, | ||||
| 		FINISHED | ||||
| 	}; | ||||
|  | ||||
| 	struct ObjectCallback // entry created on ID request | ||||
| 	{ | ||||
| 		std::string localScope;  /// scope from which this ID was requested | ||||
| @@ -52,6 +59,8 @@ class CIdentifierStorage | ||||
| 	std::multimap<std::string, ObjectData > registeredObjects; | ||||
| 	std::vector<ObjectCallback> scheduledRequests; | ||||
|  | ||||
| 	ELoadingState state; | ||||
|  | ||||
| 	/// Check if identifier can be valid (camelCase, point as separator) | ||||
| 	void checkIdentifier(std::string & ID); | ||||
|  | ||||
| @@ -59,6 +68,7 @@ class CIdentifierStorage | ||||
| 	bool resolveIdentifier(const ObjectCallback & callback); | ||||
| 	std::vector<ObjectData> getPossibleIdentifiers(const ObjectCallback & callback); | ||||
| public: | ||||
| 	CIdentifierStorage(); | ||||
| 	/// request identifier for specific object name. | ||||
| 	/// 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); | ||||
| @@ -82,7 +92,7 @@ public: | ||||
|  | ||||
| 	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() | ||||
| { | ||||
| 	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() | ||||
|   | ||||
| @@ -629,23 +629,22 @@ void CGBonusingObject::initObj() | ||||
| 	}; | ||||
|  | ||||
| 	info.resize(1); | ||||
| 	CVisitInfo & visit = info[0]; | ||||
|  | ||||
| 	switch(ID) | ||||
| 	{ | ||||
| 	case Obj::BUOY: | ||||
| 			blockVisit = true; | ||||
| 		configureMessage(visit, 21, 22, soundBase::MORALE); | ||||
| 		configureBonus(visit, Bonus::MORALE, +1, 94); | ||||
| 		configureMessage(info[0], 21, 22, soundBase::MORALE); | ||||
| 		configureBonus(info[0], Bonus::MORALE, +1, 94); | ||||
| 		break; | ||||
| 	case Obj::SWAN_POND: | ||||
| 		configureMessage(visit, 29, 30, soundBase::LUCK); | ||||
| 		configureBonus(visit, Bonus::LUCK, 2, 67); | ||||
| 		visit.reward.movePercentage = 0; | ||||
| 		configureMessage(info[0], 29, 30, soundBase::LUCK); | ||||
| 		configureBonus(info[0], Bonus::LUCK, 2, 67); | ||||
| 		info[0].reward.movePercentage = 0; | ||||
| 		break; | ||||
| 	case Obj::FAERIE_RING: | ||||
| 		configureMessage(visit, 49, 50, soundBase::LUCK); | ||||
| 		configureBonus(visit, Bonus::LUCK, 2, 71); | ||||
| 		configureMessage(info[0], 49, 50, soundBase::LUCK); | ||||
| 		configureBonus(info[0], Bonus::LUCK, 2, 71); | ||||
| 		break; | ||||
| 	case Obj::FOUNTAIN_OF_FORTUNE: | ||||
| 		selectMode = SELECT_RANDOM; | ||||
| @@ -673,19 +672,19 @@ void CGBonusingObject::initObj() | ||||
| 		break; | ||||
| 	case Obj::MERMAID: | ||||
| 		blockVisit = true; | ||||
| 		configureMessage(visit, 83, 82, soundBase::LUCK); | ||||
| 		configureBonus(visit, Bonus::LUCK, 1, 72); | ||||
| 		configureMessage(info[0], 83, 82, soundBase::LUCK); | ||||
| 		configureBonus(info[0], Bonus::LUCK, 1, 72); | ||||
| 		break; | ||||
| 	case Obj::RALLY_FLAG: | ||||
| 		configureMessage(visit, 111, 110, soundBase::MORALE); | ||||
| 		configureBonus(visit, Bonus::MORALE, 1, 102); | ||||
| 		configureBonus(visit, Bonus::LUCK,   1, 102); | ||||
| 		visit.reward.movePoints = 400; | ||||
| 		configureMessage(info[0], 111, 110, soundBase::MORALE); | ||||
| 		configureBonus(info[0], Bonus::MORALE, 1, 102); | ||||
| 		configureBonus(info[0], Bonus::LUCK,   1, 102); | ||||
| 		info[0].reward.movePoints = 400; | ||||
| 		break; | ||||
| 	case Obj::OASIS: | ||||
| 		configureMessage(visit, 95, 94, soundBase::MORALE); | ||||
| 		configureBonus(visit, Bonus::MORALE, 1, 95); | ||||
| 		visit.reward.movePoints = 800; | ||||
| 		configureMessage(info[0], 95, 94, soundBase::MORALE); | ||||
| 		configureBonus(info[0], Bonus::MORALE, 1, 95); | ||||
| 		info[0].reward.movePoints = 800; | ||||
| 		break; | ||||
| 	case Obj::TEMPLE: | ||||
| 		info[0].limiter.dayOfWeek = 7; | ||||
| @@ -693,24 +692,24 @@ void CGBonusingObject::initObj() | ||||
| 		configureBonus(info[0], Bonus::MORALE, 2, 96); | ||||
| 		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); | ||||
| 		break; | ||||
| 	case Obj::WATERING_HOLE: | ||||
| 		configureMessage(visit, 166, 167, soundBase::MORALE); | ||||
| 		configureBonus(visit, Bonus::MORALE, 1, 100); | ||||
| 		visit.reward.movePoints = 400; | ||||
| 		configureMessage(info[0], 166, 167, soundBase::MORALE); | ||||
| 		configureBonus(info[0], Bonus::MORALE, 1, 100); | ||||
| 		info[0].reward.movePoints = 400; | ||||
| 		break; | ||||
| 	case Obj::FOUNTAIN_OF_YOUTH: | ||||
| 		configureMessage(visit, 57, 58, soundBase::MORALE); | ||||
| 		configureBonus(visit, Bonus::MORALE, 1, 103); | ||||
| 		visit.reward.movePoints = 400; | ||||
| 		configureMessage(info[0], 57, 58, soundBase::MORALE); | ||||
| 		configureBonus(info[0], Bonus::MORALE, 1, 103); | ||||
| 		info[0].reward.movePoints = 400; | ||||
| 		break; | ||||
| 	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); | ||||
| 		visit.reward.movePoints = 600; | ||||
| 		configureBonusDuration(info[0], Bonus::ONE_WEEK, Bonus::LAND_MOVEMENT, 600, 0); | ||||
| 		info[0].reward.movePoints = 600; | ||||
| 		//TODO: upgrade champions to cavaliers | ||||
| /* | ||||
| 		bool someUpgradeDone = false; | ||||
|   | ||||
| @@ -192,7 +192,12 @@ void CDwellingInstanceConstructor::configureObject(CGObjectInstance * object, CR | ||||
| 			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)); | ||||
| 	} | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "../../Global.h" | ||||
| #include "../../lib/GameConstants.h" | ||||
|  | ||||
| /* | ||||
|   | ||||
		Reference in New Issue
	
	Block a user