1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
This commit is contained in:
Dydzio 2018-07-22 19:53:06 +02:00
parent 21c1f47a78
commit 1a78ea15bb
2 changed files with 4 additions and 6 deletions

View File

@ -12,7 +12,7 @@ MapObjectsEvaluator & MapObjectsEvaluator::getInstance()
return *(singletonInstance.get());
}
MapObjectsEvaluator::MapObjectsEvaluator() : objectDatabase(std::map<CompoundMapObjectID, int>())
MapObjectsEvaluator::MapObjectsEvaluator()
{
for(auto primaryID : VLC->objtypeh->knownObjects())
{
@ -21,9 +21,7 @@ MapObjectsEvaluator::MapObjectsEvaluator() : objectDatabase(std::map<CompoundMap
auto handler = VLC->objtypeh->getHandlerFor(primaryID, secondaryID);
if(!handler->isStaticObject() && handler->getRMGInfo().value)
{
CompoundMapObjectID newObjectType = CompoundMapObjectID(primaryID, secondaryID);
std::pair<CompoundMapObjectID, int> newObject = { newObjectType, handler->getRMGInfo().value };
objectDatabase.insert(newObject);
objectDatabase[CompoundMapObjectID(primaryID, secondaryID)] = handler->getRMGInfo().value;
}
}
}
@ -46,7 +44,7 @@ void MapObjectsEvaluator::addObjectData(int primaryID, int secondaryID, int valu
objectDatabase.insert_or_assign(internalIdentifier, value);
}
void MapObjectsEvaluator::removeObjectData(int primaryID, int secondaryID, int value)
void MapObjectsEvaluator::removeObjectData(int primaryID, int secondaryID)
{
CompoundMapObjectID internalIdentifier = CompoundMapObjectID(primaryID, secondaryID);
vstd::erase_if_present(objectDatabase, internalIdentifier);

View File

@ -20,6 +20,6 @@ public:
static MapObjectsEvaluator & getInstance();
boost::optional<int> getObjectValue(int primaryID, int secondaryID) const;
void addObjectData(int primaryID, int secondaryID, int value);
void removeObjectData(int primaryID, int secondaryID, int value);
void removeObjectData(int primaryID, int secondaryID);
};