diff options
Diffstat (limited to 'src/server/game/Maps/SpawnData.h')
-rw-r--r-- | src/server/game/Maps/SpawnData.h | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/src/server/game/Maps/SpawnData.h b/src/server/game/Maps/SpawnData.h index d1023ffbeb2..1b96a70ecc1 100644 --- a/src/server/game/Maps/SpawnData.h +++ b/src/server/game/Maps/SpawnData.h @@ -22,21 +22,30 @@ #include "Position.h" #include <vector> +class AreaTrigger; +class Creature; +class GameObject; +class Pool; +struct PoolTemplate; + // EnumUtils: DESCRIBE THIS enum SpawnObjectType { SPAWN_TYPE_CREATURE = 0, // TITLE Creature SPAWN_TYPE_GAMEOBJECT = 1, // TITLE Gameobject - - SPAWN_TYPE_MAX // SKIP + SPAWN_TYPE_AREATRIGGER = 2,// TITLE AreaTrigger + NUM_SPAWN_TYPES_WITH_DATA, // SKIP + NUM_SPAWN_TYPES = NUM_SPAWN_TYPES_WITH_DATA // SKIP }; enum SpawnObjectTypeMask { SPAWN_TYPEMASK_CREATURE = (1 << SPAWN_TYPE_CREATURE), SPAWN_TYPEMASK_GAMEOBJECT = (1 << SPAWN_TYPE_GAMEOBJECT), + SPAWN_TYPEMASK_AREATRIGGER = (1 << SPAWN_TYPE_AREATRIGGER), - SPAWN_TYPEMASK_ALL = (1 << SPAWN_TYPE_MAX)-1 + SPAWN_TYPEMASK_WITH_DATA = (1 << NUM_SPAWN_TYPES_WITH_DATA)-1, + SPAWN_TYPEMASK_ALL = (1 << NUM_SPAWN_TYPES)-1 }; enum SpawnGroupFlags @@ -59,24 +68,49 @@ struct SpawnGroupTemplateData SpawnGroupFlags flags; }; -struct SpawnData +namespace Trinity { namespace Impl { + template <typename T> + struct SpawnObjectTypeForImpl { static_assert(!std::is_same<T,T>::value, "This type does not have an associated spawn type!"); }; + template <> struct SpawnObjectTypeForImpl<Creature> { static constexpr SpawnObjectType value = SPAWN_TYPE_CREATURE; }; + template <> struct SpawnObjectTypeForImpl<GameObject> { static constexpr SpawnObjectType value = SPAWN_TYPE_GAMEOBJECT; }; + template <> struct SpawnObjectTypeForImpl<AreaTrigger> { static constexpr SpawnObjectType value = SPAWN_TYPE_AREATRIGGER; }; +}} + +struct SpawnData; +struct SpawnMetadata { + static constexpr bool TypeInMask(SpawnObjectType type, SpawnObjectTypeMask mask) { return ((1 << type) & mask); } + static constexpr bool TypeHasData(SpawnObjectType type) { return (type < NUM_SPAWN_TYPES_WITH_DATA); } + static constexpr bool TypeIsValid(SpawnObjectType type) { return (type < NUM_SPAWN_TYPES); } + template <typename T> + static constexpr SpawnObjectType TypeFor = Trinity::Impl::SpawnObjectTypeForImpl<T>::value; + + SpawnData const* ToSpawnData() const { return TypeHasData(type) ? reinterpret_cast<SpawnData const*>(this) : nullptr; } + SpawnObjectType const type; uint64 spawnId = 0; + uint32 mapId = MAPID_INVALID; + bool dbData = true; + SpawnGroupTemplateData const* spawnGroupData = nullptr; + + protected: + SpawnMetadata(SpawnObjectType t) : type(t) {} +}; + +struct SpawnData : public SpawnMetadata +{ uint32 id = 0; // entry in respective _template table - WorldLocation spawnPoint; + Position spawnPoint; uint8 phaseUseFlags = 0; uint32 phaseId = 0; uint32 phaseGroup = 0; int32 terrainSwapMap = -1; int32 spawntimesecs = 0; std::vector<Difficulty> spawnDifficulties; - SpawnGroupTemplateData const* spawnGroupData = nullptr; uint32 scriptId = 0; - bool dbData = true; protected: - SpawnData(SpawnObjectType t) : type(t) {} + SpawnData(SpawnObjectType t) : SpawnMetadata(t) {} }; enum LinkedRespawnType |