diff --git a/AI/VCAI/MapObjectsEvaluator.cpp b/AI/VCAI/MapObjectsEvaluator.cpp index d46323a8a..4568e0ed8 100644 --- a/AI/VCAI/MapObjectsEvaluator.cpp +++ b/AI/VCAI/MapObjectsEvaluator.cpp @@ -2,7 +2,6 @@ #include "MapObjectsEvaluator.h" #include "../../lib/GameConstants.h" #include "../../lib/VCMI_Lib.h" -#include "../../lib/mapObjects/CObjectClassesHandler.h" MapObjectsEvaluator & MapObjectsEvaluator::getInstance() { diff --git a/AI/VCAI/MapObjectsEvaluator.h b/AI/VCAI/MapObjectsEvaluator.h index 4c228f03c..9c9a52ea8 100644 --- a/AI/VCAI/MapObjectsEvaluator.h +++ b/AI/VCAI/MapObjectsEvaluator.h @@ -8,30 +8,7 @@ * */ #pragma once - -struct AiMapObjectID -{ - int primaryID; - int secondaryID; - - AiMapObjectID(int primID, int secID) : primaryID(primID), secondaryID(secID) {}; -}; - -inline bool operator<(const AiMapObjectID& obj1, const AiMapObjectID& obj2) -{ - if(obj1.primaryID != obj2.primaryID) - return obj1.primaryID < obj2.primaryID; - else - return obj1.secondaryID < obj2.secondaryID; -} - -inline bool operator==(const AiMapObjectID& obj1, const AiMapObjectID& obj2) -{ - if(obj1.primaryID == obj2.primaryID) - return obj1.secondaryID == obj2.secondaryID; - - return false; -} +#include "../../lib/mapObjects/CObjectClassesHandler.h" class MapObjectsEvaluator { diff --git a/lib/mapObjects/CObjectClassesHandler.cpp b/lib/mapObjects/CObjectClassesHandler.cpp index 8f43a808f..6fc0d2c8b 100644 --- a/lib/mapObjects/CObjectClassesHandler.cpp +++ b/lib/mapObjects/CObjectClassesHandler.cpp @@ -285,6 +285,11 @@ TObjectTypeHandler CObjectClassesHandler::getHandlerFor(std::string type, std::s throw std::runtime_error("Object type handler not found"); } +TObjectTypeHandler CObjectClassesHandler::getHandlerFor(AiMapObjectID compoundIdentifier) const +{ + return getHandlerFor(compoundIdentifier.primaryID, compoundIdentifier.secondaryID); +} + std::set CObjectClassesHandler::knownObjects() const { std::set ret; diff --git a/lib/mapObjects/CObjectClassesHandler.h b/lib/mapObjects/CObjectClassesHandler.h index c94732f2b..428259d18 100644 --- a/lib/mapObjects/CObjectClassesHandler.h +++ b/lib/mapObjects/CObjectClassesHandler.h @@ -65,6 +65,30 @@ struct DLL_LINKAGE RandomMapInfo } }; +struct DLL_LINKAGE AiMapObjectID +{ + si32 primaryID; + si32 secondaryID; + + AiMapObjectID(si32 primID, si32 secID) : primaryID(primID), secondaryID(secID) {}; + + bool operator<(const AiMapObjectID& other) + { + if(this->primaryID != other.primaryID) + return this->primaryID < other.primaryID; + else + return this->secondaryID < other.secondaryID; + } + + bool operator==(const AiMapObjectID& other) + { + if(this->primaryID == other.primaryID) + return this->secondaryID == other.secondaryID; + + return false; + } +}; + class DLL_LINKAGE IObjectInfo { public: @@ -274,6 +298,7 @@ public: /// returns handler for specified object (ID-based). ObjectHandler keeps ownership TObjectTypeHandler getHandlerFor(si32 type, si32 subtype) const; TObjectTypeHandler getHandlerFor(std::string type, std::string subtype) const; + TObjectTypeHandler getHandlerFor(AiMapObjectID compoundIdentifier) const; std::string getObjectName(si32 type) const; std::string getObjectName(si32 type, si32 subtype) const;