mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Move object ID struct to lib
This commit is contained in:
parent
08a66abdcc
commit
2c1d91e2ff
@ -2,7 +2,6 @@
|
|||||||
#include "MapObjectsEvaluator.h"
|
#include "MapObjectsEvaluator.h"
|
||||||
#include "../../lib/GameConstants.h"
|
#include "../../lib/GameConstants.h"
|
||||||
#include "../../lib/VCMI_Lib.h"
|
#include "../../lib/VCMI_Lib.h"
|
||||||
#include "../../lib/mapObjects/CObjectClassesHandler.h"
|
|
||||||
|
|
||||||
MapObjectsEvaluator & MapObjectsEvaluator::getInstance()
|
MapObjectsEvaluator & MapObjectsEvaluator::getInstance()
|
||||||
{
|
{
|
||||||
|
@ -8,30 +8,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "../../lib/mapObjects/CObjectClassesHandler.h"
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MapObjectsEvaluator
|
class MapObjectsEvaluator
|
||||||
{
|
{
|
||||||
|
@ -285,6 +285,11 @@ TObjectTypeHandler CObjectClassesHandler::getHandlerFor(std::string type, std::s
|
|||||||
throw std::runtime_error("Object type handler not found");
|
throw std::runtime_error("Object type handler not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TObjectTypeHandler CObjectClassesHandler::getHandlerFor(AiMapObjectID compoundIdentifier) const
|
||||||
|
{
|
||||||
|
return getHandlerFor(compoundIdentifier.primaryID, compoundIdentifier.secondaryID);
|
||||||
|
}
|
||||||
|
|
||||||
std::set<si32> CObjectClassesHandler::knownObjects() const
|
std::set<si32> CObjectClassesHandler::knownObjects() const
|
||||||
{
|
{
|
||||||
std::set<si32> ret;
|
std::set<si32> ret;
|
||||||
|
@ -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
|
class DLL_LINKAGE IObjectInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -274,6 +298,7 @@ public:
|
|||||||
/// returns handler for specified object (ID-based). ObjectHandler keeps ownership
|
/// returns handler for specified object (ID-based). ObjectHandler keeps ownership
|
||||||
TObjectTypeHandler getHandlerFor(si32 type, si32 subtype) const;
|
TObjectTypeHandler getHandlerFor(si32 type, si32 subtype) const;
|
||||||
TObjectTypeHandler getHandlerFor(std::string type, std::string 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) const;
|
||||||
std::string getObjectName(si32 type, si32 subtype) const;
|
std::string getObjectName(si32 type, si32 subtype) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user