mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
Move CompoundMapObjectID to separate file
This commit is contained in:
parent
e89649ec1c
commit
9591ce1ab4
@ -13,6 +13,7 @@
|
|||||||
#include "../../lib/VCMI_Lib.h"
|
#include "../../lib/VCMI_Lib.h"
|
||||||
#include "../../lib/CCreatureHandler.h"
|
#include "../../lib/CCreatureHandler.h"
|
||||||
#include "../../lib/CHeroHandler.h"
|
#include "../../lib/CHeroHandler.h"
|
||||||
|
#include "../../lib/mapObjects/CompoundMapObjectID.h"
|
||||||
#include "../../lib/mapObjectConstructors/AObjectTypeHandler.h"
|
#include "../../lib/mapObjectConstructors/AObjectTypeHandler.h"
|
||||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||||
|
@ -502,6 +502,7 @@ set(lib_MAIN_HEADERS
|
|||||||
mapObjects/IObjectInterface.h
|
mapObjects/IObjectInterface.h
|
||||||
mapObjects/MapObjects.h
|
mapObjects/MapObjects.h
|
||||||
mapObjects/MiscObjects.h
|
mapObjects/MiscObjects.h
|
||||||
|
mapObjects/CompoundMapObjectID.h
|
||||||
mapObjects/ObjectTemplate.h
|
mapObjects/ObjectTemplate.h
|
||||||
mapObjects/ObstacleSetHandler.h
|
mapObjects/ObstacleSetHandler.h
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../constants/EntityIdentifiers.h"
|
#include "../mapObjects/CompoundMapObjectID.h"
|
||||||
#include "../IHandlerBase.h"
|
#include "../IHandlerBase.h"
|
||||||
#include "../json/JsonNode.h"
|
#include "../json/JsonNode.h"
|
||||||
|
|
||||||
@ -19,27 +19,6 @@ class AObjectTypeHandler;
|
|||||||
class ObjectTemplate;
|
class ObjectTemplate;
|
||||||
struct SObjectSounds;
|
struct SObjectSounds;
|
||||||
|
|
||||||
struct DLL_LINKAGE CompoundMapObjectID
|
|
||||||
{
|
|
||||||
si32 primaryID;
|
|
||||||
si32 secondaryID;
|
|
||||||
|
|
||||||
CompoundMapObjectID(si32 primID, si32 secID) : primaryID(primID), secondaryID(secID) {};
|
|
||||||
|
|
||||||
bool operator<(const CompoundMapObjectID& other) const
|
|
||||||
{
|
|
||||||
if(this->primaryID != other.primaryID)
|
|
||||||
return this->primaryID < other.primaryID;
|
|
||||||
else
|
|
||||||
return this->secondaryID < other.secondaryID;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const CompoundMapObjectID& other) const
|
|
||||||
{
|
|
||||||
return (this->primaryID == other.primaryID) && (this->secondaryID == other.secondaryID);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class CGObjectInstance;
|
class CGObjectInstance;
|
||||||
|
|
||||||
using TObjectTypeHandler = std::shared_ptr<AObjectTypeHandler>;
|
using TObjectTypeHandler = std::shared_ptr<AObjectTypeHandler>;
|
||||||
|
37
lib/mapObjects/CompoundMapObjectID.h
Normal file
37
lib/mapObjects/CompoundMapObjectID.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* CompoundMapObjectID.h, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../constants/EntityIdentifiers.h"
|
||||||
|
|
||||||
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
struct DLL_LINKAGE CompoundMapObjectID
|
||||||
|
{
|
||||||
|
si32 primaryID;
|
||||||
|
si32 secondaryID;
|
||||||
|
|
||||||
|
CompoundMapObjectID(si32 primID, si32 secID) : primaryID(primID), secondaryID(secID) {};
|
||||||
|
|
||||||
|
bool operator<(const CompoundMapObjectID& other) const
|
||||||
|
{
|
||||||
|
if(this->primaryID != other.primaryID)
|
||||||
|
return this->primaryID < other.primaryID;
|
||||||
|
else
|
||||||
|
return this->secondaryID < other.secondaryID;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const CompoundMapObjectID& other) const
|
||||||
|
{
|
||||||
|
return (this->primaryID == other.primaryID) && (this->secondaryID == other.secondaryID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
VCMI_LIB_NAMESPACE_END
|
@ -508,6 +508,11 @@ bool ObjectTemplate::canBePlacedAt(TerrainId terrainID) const
|
|||||||
return vstd::contains(allowedTerrains, terrainID);
|
return vstd::contains(allowedTerrains, terrainID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompoundMapObjectID ObjectTemplate::getCompoundID() const
|
||||||
|
{
|
||||||
|
return CompoundMapObjectID(id, subid);
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectTemplate::recalculate()
|
void ObjectTemplate::recalculate()
|
||||||
{
|
{
|
||||||
calculateWidth();
|
calculateWidth();
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "../int3.h"
|
#include "../int3.h"
|
||||||
#include "../filesystem/ResourcePath.h"
|
#include "../filesystem/ResourcePath.h"
|
||||||
#include "../serializer/Serializeable.h"
|
#include "../serializer/Serializeable.h"
|
||||||
|
#include "../mapObjects/CompoundMapObjectID.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -47,7 +48,6 @@ public:
|
|||||||
MapObjectID id;
|
MapObjectID id;
|
||||||
MapObjectSubID subid;
|
MapObjectSubID subid;
|
||||||
|
|
||||||
// TODO: get compound id
|
|
||||||
/// print priority, objects with higher priority will be print first, below everything else
|
/// print priority, objects with higher priority will be print first, below everything else
|
||||||
si32 printPriority;
|
si32 printPriority;
|
||||||
/// animation file that should be used to display object
|
/// animation file that should be used to display object
|
||||||
@ -124,6 +124,8 @@ public:
|
|||||||
// Checks if object can be placed on specific terrain
|
// Checks if object can be placed on specific terrain
|
||||||
bool canBePlacedAt(TerrainId terrain) const;
|
bool canBePlacedAt(TerrainId terrain) const;
|
||||||
|
|
||||||
|
CompoundMapObjectID getCompoundID() const;
|
||||||
|
|
||||||
ObjectTemplate();
|
ObjectTemplate();
|
||||||
|
|
||||||
void readTxt(CLegacyConfigParser & parser);
|
void readTxt(CLegacyConfigParser & parser);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../constants/EntityIdentifiers.h"
|
#include "../mapObjects/CompoundMapObjectID.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../mapObjects/ObjectTemplate.h"
|
#include "../mapObjects/ObjectTemplate.h"
|
||||||
#include "../constants/EntityIdentifiers.h"
|
#include "../mapObjects/CompoundMapObjectID.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ class ObjectManager;
|
|||||||
class RmgMap;
|
class RmgMap;
|
||||||
class CMapGenerator;
|
class CMapGenerator;
|
||||||
class ObjectConfig;
|
class ObjectConfig;
|
||||||
struct CompoundMapObjectID;
|
|
||||||
|
|
||||||
class TreasurePlacer: public Modificator
|
class TreasurePlacer: public Modificator
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user