mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	vcmi: remove ALL_CREATURES propagator
Now unneded, because it handled by GLOBAL_EFFECT with CREATURE_LEVEL_LIMITER (when range set to UINT_MIN and UINT_MAX).
This commit is contained in:
		| @@ -571,8 +571,8 @@ void CTownHandler::loadSpecialBuildingBonuses(const JsonNode & source, BonusList | ||||
| 		{ | ||||
| 			auto * limPtr = dynamic_cast<CreatureFactionLimiter *>(bonus->limiter.get()); | ||||
|  | ||||
| 			if(limPtr != nullptr && limPtr->faction == static_cast<TFaction>(-1)) | ||||
| 			limPtr->faction = building->town->faction->getIndex(); | ||||
| 			if(limPtr != nullptr && limPtr->faction == FactionID::ANY) | ||||
| 			limPtr->faction = building->town->faction->getId(); | ||||
| 		} | ||||
| 		//JsonUtils::parseBuildingBonus produces UNKNOWN type propagator instead of empty. | ||||
| 		if(bonus->propagator != nullptr | ||||
|   | ||||
| @@ -187,6 +187,7 @@ std::string PlayerColor::getStrCap(bool L10n) const | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| const FactionID FactionID::NONE = FactionID(-2); | ||||
| const FactionID FactionID::ANY = FactionID(-1); | ||||
| const FactionID FactionID::CASTLE = FactionID(0); | ||||
| const FactionID FactionID::RAMPART = FactionID(1); | ||||
| @@ -205,7 +206,7 @@ si32 FactionID::decode(const std::string & identifier) | ||||
| 	if(rawId) | ||||
| 		return rawId.get(); | ||||
| 	else | ||||
| 		return -1; | ||||
| 		return FactionID::ANY; | ||||
| } | ||||
|  | ||||
| std::string FactionID::encode(const si32 index) | ||||
|   | ||||
| @@ -442,6 +442,7 @@ class FactionID : public BaseForID<FactionID, int32_t> | ||||
| { | ||||
| 	INSTID_LIKE_CLASS_COMMON(FactionID, si32) | ||||
|  | ||||
| 	DLL_LINKAGE static const FactionID NONE; | ||||
| 	DLL_LINKAGE static const FactionID ANY; | ||||
| 	DLL_LINKAGE static const FactionID CASTLE; | ||||
| 	DLL_LINKAGE static const FactionID RAMPART; | ||||
|   | ||||
| @@ -88,8 +88,7 @@ const std::map<std::string, TPropagatorPtr> bonusPropagatorMap = | ||||
| 	{"PLAYER_PROPAGATOR", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::PLAYER)}, | ||||
| 	{"HERO", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::HERO)}, | ||||
| 	{"TEAM_PROPAGATOR", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::TEAM)}, //untested | ||||
| 	{"GLOBAL_EFFECT", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::GLOBAL_EFFECTS)}, | ||||
| 	{"ALL_CREATURES", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::ALL_CREATURES)} | ||||
| 	{"GLOBAL_EFFECT", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::GLOBAL_EFFECTS)} | ||||
| }; //untested | ||||
|  | ||||
| const std::map<std::string, TUpdaterPtr> bonusUpdaterMap = | ||||
| @@ -2368,20 +2367,15 @@ JsonNode CreatureTerrainLimiter::toJsonNode() const | ||||
| 	return root; | ||||
| } | ||||
|  | ||||
| CreatureFactionLimiter::CreatureFactionLimiter(TFaction creatureFaction) | ||||
| CreatureFactionLimiter::CreatureFactionLimiter(FactionID creatureFaction) | ||||
| 	: faction(creatureFaction) | ||||
| { | ||||
| } | ||||
|  | ||||
| CreatureFactionLimiter::CreatureFactionLimiter(): | ||||
| 	faction(static_cast<TFaction>(-1)) | ||||
| { | ||||
| } | ||||
|  | ||||
| ILimiter::EDecision CreatureFactionLimiter::limit(const BonusLimitationContext &context) const | ||||
| { | ||||
| 	const CCreature *c = retrieveCreature(&context.node); | ||||
| 	auto accept = c && c->getFactionIndex() == faction; | ||||
| 	auto accept = c && (c->getFactionIndex() == faction || faction == FactionID::ANY); | ||||
| 	return accept ? ILimiter::EDecision::ACCEPT : ILimiter::EDecision::DISCARD; //drop bonus for non-creatures or non-native residents | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1130,9 +1130,8 @@ public: | ||||
| class DLL_LINKAGE CreatureFactionLimiter : public ILimiter //applies only to creatures of given faction | ||||
| { | ||||
| public: | ||||
| 	TFaction faction; | ||||
| 	CreatureFactionLimiter(); | ||||
| 	CreatureFactionLimiter(TFaction faction); | ||||
| 	FactionID faction; | ||||
| 	CreatureFactionLimiter(FactionID faction = FactionID::ANY); | ||||
|  | ||||
| 	EDecision limit(const BonusLimitationContext &context) const override; | ||||
| 	std::string toString() const override; | ||||
|   | ||||
| @@ -754,7 +754,7 @@ std::shared_ptr<ILimiter> JsonUtils::parseLimiter(const JsonNode & limiter) | ||||
| 				std::shared_ptr<CreatureFactionLimiter> factionLimiter = std::make_shared<CreatureFactionLimiter>(); | ||||
| 				VLC->modh->identifiers.requestIdentifier("faction", parameters[0], [=](si32 faction) | ||||
| 				{ | ||||
| 					factionLimiter->faction = faction; | ||||
| 					factionLimiter->faction = FactionID(faction); | ||||
| 				}); | ||||
| 				return factionLimiter; | ||||
| 			} | ||||
| @@ -1002,7 +1002,17 @@ bool JsonUtils::parseBonus(const JsonNode &ability, Bonus *b) | ||||
|  | ||||
| 	value = &ability["propagator"]; | ||||
| 	if (!value->isNull()) | ||||
| 		b->propagator = parseByMap(bonusPropagatorMap, value, "propagator type "); | ||||
| 	{ | ||||
| 		//ALL_CREATURES old propagator compatibility | ||||
| 		if(value->String() == "ALL_CREATURES")  | ||||
| 		{ | ||||
| 			logMod->warn("ALL_CREATURES propagator is deprecated. Use GLOBAL_EFFECT propagator with CREATURES_ONLY limiter"); | ||||
| 			b->addLimiter(std::make_shared<CreatureLevelLimiter>()); | ||||
| 			b->propagator = bonusPropagatorMap.at("GLOBAL_EFFECT"); | ||||
| 		} | ||||
| 		else | ||||
| 			b->propagator = parseByMap(bonusPropagatorMap, value, "propagator type "); | ||||
| 	} | ||||
|  | ||||
| 	value = &ability["updater"]; | ||||
| 	if(!value->isNull()) | ||||
|   | ||||
| @@ -1232,12 +1232,7 @@ void CGTownInstance::recreateBuildingsBonuses() | ||||
| 			continue; | ||||
|  | ||||
| 		for(auto & bonus : building->buildingBonuses) | ||||
| 		{ | ||||
| 			if(bonus->propagator != nullptr && bonus->propagator->getPropagatorType() == ALL_CREATURES) | ||||
| 				VLC->creh->addBonusForAllCreatures(bonus); | ||||
| 			else | ||||
| 				addNewBonus(bonus); | ||||
| 		} | ||||
| 			addNewBonus(bonus); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user