mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	moved contains functions for multimap to Globals.h
This commit is contained in:
		
							
								
								
									
										12
									
								
								Global.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								Global.h
									
									
									
									
									
								
							| @@ -676,6 +676,18 @@ namespace vstd | ||||
| 		return v3; | ||||
| 	} | ||||
|  | ||||
| 	template <typename Key, typename V> | ||||
| 	bool containsMapping(const std::multimap<Key,V> & map, const std::pair<const Key,V> & mapping) | ||||
| 	{ | ||||
| 		auto range = map.equal_range(mapping.first); | ||||
| 		for(auto contained = range.first; contained != range.second; contained++) | ||||
| 		{ | ||||
| 			if(mapping.second == contained->second) | ||||
| 				return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	using boost::math::round; | ||||
| } | ||||
| using vstd::operator-=; | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
|             "description" : "Hero generates 250 gold each day.", | ||||
|             "effects" : [ | ||||
|                 { | ||||
|                     "subtype" : 13, | ||||
|                     "subtype" : "skill.estates", | ||||
|                     "type" : "SECONDARY_SKILL_PREMY", | ||||
|                     "val" : 250, | ||||
|                     "valueType" : "BASE_NUMBER" | ||||
| @@ -15,7 +15,7 @@ | ||||
|             "description" : "Hero generates 500 gold each day.", | ||||
|             "effects" : [ | ||||
|                 { | ||||
|                     "subtype" : 13, | ||||
|                     "subtype" : "skill.estates", | ||||
|                     "type" : "SECONDARY_SKILL_PREMY", | ||||
|                     "val" : 500, | ||||
|                     "valueType" : "BASE_NUMBER" | ||||
| @@ -26,7 +26,7 @@ | ||||
|             "description" : "Hero generates 1000 gold each day.", | ||||
|             "effects" : [ | ||||
|                 { | ||||
|                     "subtype" : 13, | ||||
|                     "subtype" : "skill.estates", | ||||
|                     "type" : "SECONDARY_SKILL_PREMY", | ||||
|                     "val" : 1000, | ||||
|                     "valueType" : "BASE_NUMBER" | ||||
|   | ||||
| @@ -204,8 +204,8 @@ void CIdentifierStorage::registerObject(std::string scope, std::string type, std | ||||
| 	std::string fullID = type + '.' + name; | ||||
| 	checkIdentifier(fullID); | ||||
|  | ||||
| 	auto mapping = std::make_pair(fullID, data); | ||||
| 	if(!registeredObjects.contains(mapping)) | ||||
| 	std::pair<const std::string, ObjectData> mapping = std::make_pair(fullID, data); | ||||
| 	if(!vstd::containsMapping(registeredObjects, mapping)) | ||||
| 	{ | ||||
| 		CLogger::getLogger(CLoggerDomain("identifier"))->traceStream() << "registered " << fullID << " as " << scope << ":" << identifier; | ||||
| 		registeredObjects.insert(mapping); | ||||
|   | ||||
| @@ -63,22 +63,7 @@ class CIdentifierStorage | ||||
| 		} | ||||
| 	}; | ||||
|  | ||||
| 	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::multimap<std::string, ObjectData> registeredObjects; | ||||
| 	std::vector<ObjectCallback> scheduledRequests; | ||||
|  | ||||
| 	ELoadingState state; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user