1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-02 00:10:22 +02:00

moved contains functions for multimap to Globals.h

This commit is contained in:
Henning Koehler 2017-08-25 18:29:34 +12:00
parent c0740e3623
commit 3cc84e5975
4 changed files with 18 additions and 21 deletions

View File

@ -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-=;

View File

@ -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"

View File

@ -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);

View File

@ -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;