diff options
| author | Shauren <shauren.trinity@gmail.com> | 2017-05-18 23:52:58 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2017-05-18 23:53:25 +0200 |
| commit | c5d3dd90bea3889ef5fcd33c9ef0d59d7c544f8a (patch) | |
| tree | aa7fde6f924fc39da54908bd6eeeb0be422e5fc3 /src/server/game/Entities | |
| parent | 74456703146194de72424ec98c4ea76402077be6 (diff) | |
Core/Game: Include cleanup
* Mostly aimed at removing Log/DatabaseEnv includes from other headers
* Fix most packet headers including other packet headers - moved common structures such as ItemInstance to their own files
* Moved SAI function definitions to source files (massive or requiring many different dependencies)
Diffstat (limited to 'src/server/game/Entities')
36 files changed, 674 insertions, 669 deletions
diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index aa8a6249cf5..91adaa4ca34 100644 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -18,11 +18,12 @@ #include "Common.h" #include "Corpse.h" +#include "DatabaseEnv.h" #include "Log.h" +#include "ObjectAccessor.h" #include "Player.h" #include "UpdateData.h" -#include "ObjectAccessor.h" -#include "DatabaseEnv.h" +#include "World.h" Corpse::Corpse(CorpseType type) : WorldObject(type != CORPSE_BONES), m_type(type) { diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h index 2ce17d8cc82..fa6e0e34ae0 100644 --- a/src/server/game/Entities/Corpse/Corpse.h +++ b/src/server/game/Entities/Corpse/Corpse.h @@ -20,9 +20,9 @@ #define TRINITYCORE_CORPSE_H #include "Object.h" -#include "DatabaseEnv.h" +#include "DatabaseEnvFwd.h" #include "GridDefines.h" -#include "LootMgr.h" +#include "Loot.h" enum CorpseType { diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 827ffbffd28..2ebc31a291e 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -23,8 +23,8 @@ #include "Duration.h" #include "Unit.h" #include "ItemTemplate.h" -#include "LootMgr.h" -#include "DatabaseEnv.h" +#include "Loot.h" +#include "DatabaseEnvFwd.h" #include "MapObject.h" #include <list> @@ -489,17 +489,6 @@ struct CreatureLocale std::vector<std::string> TitleAlt; }; -struct GossipMenuItemsLocale -{ - std::vector<std::string> OptionText; - std::vector<std::string> BoxText; -}; - -struct PointOfInterestLocale -{ - std::vector<std::string> Name; -}; - struct EquipmentItem { uint32 ItemId = 0; @@ -569,19 +558,6 @@ enum InhabitTypeValues INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR | INHABIT_ROOT }; -// Enums used by StringTextData::Type (CreatureEventAI) -enum ChatType -{ - CHAT_TYPE_SAY = 0, - CHAT_TYPE_YELL = 1, - CHAT_TYPE_TEXT_EMOTE = 2, - CHAT_TYPE_BOSS_EMOTE = 3, - CHAT_TYPE_WHISPER = 4, - CHAT_TYPE_BOSS_WHISPER = 5, - CHAT_TYPE_ZONE_YELL = 6, - CHAT_TYPE_END = 255 -}; - #pragma pack(pop) // `creature_addon` table diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index 860a7a20c4e..e92506f3a9a 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -16,11 +16,12 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Creature.h" #include "CreatureGroups.h" -#include "ObjectMgr.h" - +#include "Creature.h" #include "CreatureAI.h" +#include "DatabaseEnv.h" +#include "Log.h" +#include "ObjectMgr.h" #define MAX_DESYNC 5.0f diff --git a/src/server/game/Entities/Creature/CreatureGroups.h b/src/server/game/Entities/Creature/CreatureGroups.h index 1bfe3f70a92..c4746f181c6 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.h +++ b/src/server/game/Entities/Creature/CreatureGroups.h @@ -20,11 +20,13 @@ #define _FORMATIONS_H #include "Define.h" +#include "ObjectGuid.h" #include <unordered_map> #include <map> class Creature; class CreatureGroup; +class Unit; struct FormationInfo { diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index 2c2d7699706..26b0509f13f 100644 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -16,13 +16,14 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "QuestDef.h" #include "GossipDef.h" -#include "ObjectMgr.h" -#include "WorldSession.h" #include "Formulas.h" -#include "QuestPackets.h" +#include "Log.h" #include "NPCPackets.h" +#include "ObjectMgr.h" +#include "QuestDef.h" +#include "QuestPackets.h" +#include "WorldSession.h" GossipMenu::GossipMenu() { diff --git a/src/server/game/Entities/Creature/GossipDef.h b/src/server/game/Entities/Creature/GossipDef.h index dbc9884b3d7..222443188fa 100644 --- a/src/server/game/Entities/Creature/GossipDef.h +++ b/src/server/game/Entities/Creature/GossipDef.h @@ -23,6 +23,7 @@ #include "ObjectGuid.h" #include "QuestDef.h" #include "NPCHandler.h" +#include <map> class WorldSession; diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.cpp b/src/server/game/Entities/DynamicObject/DynamicObject.cpp index bd2ce99c264..3a2708e80fe 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.cpp +++ b/src/server/game/Entities/DynamicObject/DynamicObject.cpp @@ -17,14 +17,13 @@ */ #include "Common.h" -#include "Opcodes.h" -#include "World.h" -#include "ObjectAccessor.h" -#include "DatabaseEnv.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" +#include "Log.h" +#include "ObjectAccessor.h" #include "ScriptMgr.h" #include "Transport.h" +#include "World.h" DynamicObject::DynamicObject(bool isWorldObject) : WorldObject(isWorldObject), _aura(NULL), _removedAura(NULL), _caster(NULL), _duration(0), _spellXSpellVisualId(0), _isViewpoint(false) diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index dc749949fe9..9ecc85478b2 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -16,25 +16,29 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "GameObjectAI.h" +#include "GameObject.h" +#include "ArtifactPackets.h" #include "Battleground.h" #include "CellImpl.h" #include "CreatureAISelector.h" +#include "DatabaseEnv.h" +#include "GameObjectAI.h" #include "GameObjectModel.h" #include "GameObjectPackets.h" #include "GridNotifiersImpl.h" #include "Group.h" #include "GroupMgr.h" -#include "ArtifactPackets.h" +#include "Log.h" +#include "LootMgr.h" #include "MiscPackets.h" #include "ObjectMgr.h" #include "OutdoorPvPMgr.h" #include "PoolMgr.h" #include "ScriptMgr.h" #include "SpellMgr.h" +#include "Transport.h" #include "UpdateFieldFlags.h" #include "World.h" -#include "Transport.h" GameObject::GameObject() : WorldObject(false), MapObject(), m_model(nullptr), m_goValue(), m_AI(nullptr), _animKitId(0) diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 3a24e704ad3..e5951dec833 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -23,8 +23,8 @@ #include "SharedDefines.h" #include "Unit.h" #include "Object.h" -#include "LootMgr.h" -#include "DatabaseEnv.h" +#include "Loot.h" +#include "DatabaseEnvFwd.h" #include "MapObject.h" #include <G3D/Quat.h> diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 6c97161ba3a..fd671d7386b 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -16,25 +16,27 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Common.h" #include "Item.h" -#include "ObjectMgr.h" -#include "WorldPacket.h" +#include "ArtifactPackets.h" +#include "CollectionMgr.h" +#include "Common.h" +#include "ConditionMgr.h" #include "DatabaseEnv.h" +#include "GameTables.h" #include "ItemEnchantmentMgr.h" -#include "SpellMgr.h" -#include "SpellInfo.h" -#include "ScriptMgr.h" -#include "ConditionMgr.h" -#include "Player.h" -#include "Opcodes.h" -#include "WorldSession.h" #include "ItemPackets.h" +#include "Log.h" +#include "LootMgr.h" +#include "ObjectMgr.h" +#include "Opcodes.h" +#include "Player.h" +#include "ScriptMgr.h" +#include "SpellInfo.h" +#include "SpellMgr.h" #include "TradeData.h" -#include "GameTables.h" -#include "CollectionMgr.h" -#include "ArtifactPackets.h" #include "UpdateData.h" +#include "WorldPacket.h" +#include "WorldSession.h" void AddItemsSetItem(Player* player, Item* item) { @@ -898,31 +900,6 @@ uint32 Item::GetSkill() return proto->GetSkill(); } -ItemRandomEnchantmentId Item::GenerateItemRandomPropertyId(uint32 item_id) -{ - ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_id); - if (!itemProto) - return{}; - - // item must have one from this field values not null if it can have random enchantments - if (!itemProto->GetRandomProperty() && !itemProto->GetRandomSuffix()) - return{}; - - // item can have not null only one from field values - if (itemProto->GetRandomProperty() && itemProto->GetRandomSuffix()) - { - TC_LOG_ERROR("sql.sql", "Item template %u have RandomProperty == %u and RandomSuffix == %u, but must have one from field =0", itemProto->GetId(), itemProto->GetRandomProperty(), itemProto->GetRandomSuffix()); - return{}; - } - - // RandomProperty case - if (itemProto->GetRandomProperty()) - return GetItemEnchantMod(itemProto->GetRandomProperty(), ItemRandomEnchantmentType::Property); - // RandomSuffix case - else - return GetItemEnchantMod(itemProto->GetRandomSuffix(), ItemRandomEnchantmentType::Suffix); -} - void Item::SetItemRandomProperties(ItemRandomEnchantmentId const& randomPropId) { if (!randomPropId.Id) diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index bd78aaf1e06..91b55982f56 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -21,10 +21,11 @@ #include "Common.h" #include "Object.h" -#include "LootMgr.h" +#include "Loot.h" #include "ItemEnchantmentMgr.h" #include "ItemTemplate.h" -#include "DatabaseEnv.h" +#include "DatabaseEnvFwd.h" +#include <unordered_set> class SpellInfo; class Bag; @@ -404,7 +405,6 @@ class TC_GAME_API Item : public Object uint32 GetItemSuffixFactor() const { return GetUInt32Value(ITEM_FIELD_PROPERTY_SEED); } void SetItemRandomProperties(ItemRandomEnchantmentId const& randomPropId); void UpdateItemSuffixFactor(); - static ItemRandomEnchantmentId GenerateItemRandomPropertyId(uint32 item_id); ItemRandomEnchantmentId GetItemRandomEnchantmentId() const { return m_randomEnchantment; } void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster = ObjectGuid::Empty); void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner); diff --git a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp index a9bef8e415f..92e6bd8097d 100644 --- a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp +++ b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp @@ -19,10 +19,13 @@ #include "ItemEnchantmentMgr.h" #include "Containers.h" #include "DatabaseEnv.h" +#include "DB2Stores.h" +#include "ItemTemplate.h" #include "Log.h" #include "ObjectMgr.h" -#include "Util.h" #include "Random.h" +#include "Timer.h" +#include "Util.h" #include <list> #include <vector> @@ -158,6 +161,31 @@ ItemRandomEnchantmentId GetItemEnchantMod(int32 entry, ItemRandomEnchantmentType return{ selectedItr->type, selectedItr->ench }; } +ItemRandomEnchantmentId GenerateItemRandomPropertyId(uint32 item_id) +{ + ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_id); + if (!itemProto) + return{}; + + // item must have one from this field values not null if it can have random enchantments + if (!itemProto->GetRandomProperty() && !itemProto->GetRandomSuffix()) + return{}; + + // item can have not null only one from field values + if (itemProto->GetRandomProperty() && itemProto->GetRandomSuffix()) + { + TC_LOG_ERROR("sql.sql", "Item template %u have RandomProperty == %u and RandomSuffix == %u, but must have one from field =0", itemProto->GetId(), itemProto->GetRandomProperty(), itemProto->GetRandomSuffix()); + return{}; + } + + // RandomProperty case + if (itemProto->GetRandomProperty()) + return GetItemEnchantMod(itemProto->GetRandomProperty(), ItemRandomEnchantmentType::Property); + // RandomSuffix case + else + return GetItemEnchantMod(itemProto->GetRandomSuffix(), ItemRandomEnchantmentType::Suffix); +} + uint32 GenerateEnchSuffixFactor(uint32 item_id) { ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_id); diff --git a/src/server/game/Entities/Item/ItemEnchantmentMgr.h b/src/server/game/Entities/Item/ItemEnchantmentMgr.h index e2f0785ccd4..24b4b2284ac 100644 --- a/src/server/game/Entities/Item/ItemEnchantmentMgr.h +++ b/src/server/game/Entities/Item/ItemEnchantmentMgr.h @@ -38,7 +38,7 @@ struct ItemRandomEnchantmentId }; TC_GAME_API void LoadRandomEnchantmentsTable(); -TC_GAME_API ItemRandomEnchantmentId GetItemEnchantMod(int32 entry, ItemRandomEnchantmentType type); +TC_GAME_API ItemRandomEnchantmentId GenerateItemRandomPropertyId(uint32 item_id); TC_GAME_API uint32 GenerateEnchSuffixFactor(uint32 item_id); TC_GAME_API uint32 GetRandomPropertyPoints(uint32 itemLevel, uint32 quality, uint32 inventoryType, uint32 subclass); diff --git a/src/server/game/Entities/Item/ItemTemplate.h b/src/server/game/Entities/Item/ItemTemplate.h index 71cb552f752..c40cb3791db 100644 --- a/src/server/game/Entities/Item/ItemTemplate.h +++ b/src/server/game/Entities/Item/ItemTemplate.h @@ -19,9 +19,12 @@ #ifndef _ITEMPROTOTYPE_H #define _ITEMPROTOTYPE_H +#include "Common.h" #include "DB2Structure.h" #include "SharedDefines.h" #include <bitset> +#include <unordered_map> +#include <vector> enum ItemModType { diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index c59ae332c9e..a97451b1c05 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -127,7 +127,6 @@ void Object::_Create(ObjectGuid const& guid) SetGuidValue(OBJECT_FIELD_GUID, guid); SetUInt16Value(OBJECT_FIELD_TYPE, 0, m_objectType); - m_PackGUID.Set(guid); } std::string Object::_ConcatFields(uint16 startIndex, uint16 size) const @@ -239,7 +238,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c ByteBuffer buf(0x400); buf << uint8(updateType); - buf << GetPackGUID(); + buf << GetGUID(); buf << uint8(m_objectTypeId); BuildMovementUpdate(&buf, flags); @@ -267,7 +266,7 @@ void Object::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) c ByteBuffer buf(500); buf << uint8(UPDATETYPE_VALUES); - buf << GetPackGUID(); + buf << GetGUID(); BuildValuesUpdate(UPDATETYPE_VALUES, &buf, target); BuildDynamicValuesUpdate(UPDATETYPE_VALUES, &buf, target); @@ -385,7 +384,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint32 flags) const bool HasFall = HasFallDirection || unit->m_movementInfo.jump.fallTime != 0; bool HasSpline = unit->IsSplineEnabled(); - *data << GetPackGUID(); // MoverGUID + *data << GetGUID(); // MoverGUID *data << uint32(unit->m_movementInfo.time); // MoveTime *data << float(unit->GetPositionX()); diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index bc332f74ce9..3030364ed2f 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -25,6 +25,7 @@ #include "ObjectGuid.h" #include "Position.h" #include "SharedDefines.h" + #include "UpdateFields.h" #include <list> #include <set> @@ -170,7 +171,6 @@ class TC_GAME_API Object virtual void RemoveFromWorld(); ObjectGuid const& GetGUID() const { return GetGuidValue(OBJECT_FIELD_GUID); } - PackedGuid const& GetPackGUID() const { return m_PackGUID; } uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); } void SetEntry(uint32 entry) { SetUInt32Value(OBJECT_FIELD_ENTRY, entry); } @@ -373,8 +373,6 @@ class TC_GAME_API Object private: bool m_inWorld; - PackedGuid m_PackGUID; - // for output helpfull error messages from asserts bool PrintIndexError(uint32 index, bool set) const; Object(Object const& right) = delete; diff --git a/src/server/game/Entities/Object/ObjectGuid.cpp b/src/server/game/Entities/Object/ObjectGuid.cpp index a353a8a2afd..a3a1b235c3b 100644 --- a/src/server/game/Entities/Object/ObjectGuid.cpp +++ b/src/server/game/Entities/Object/ObjectGuid.cpp @@ -17,9 +17,11 @@ */ #include "ObjectGuid.h" +#include "ByteBuffer.h" #include "Errors.h" #include "Hash.h" #include "Log.h" +#include "Realm.h" #include "World.h" #include <sstream> #include <iomanip> @@ -148,10 +150,16 @@ void ObjectGuid::SetRawValue(std::vector<uint8> const& guid) memcpy(this, guid.data(), sizeof(*this)); } -void PackedGuid::Set(ObjectGuid const& guid) +uint8& ObjectGuid::operator[](uint32 index) { - _packedGuid.clear(); - _packedGuid << guid; + ASSERT(index < sizeof(uint64) * 2); + return ((uint8*)&_low)[index]; +} + +uint8 const& ObjectGuid::operator[](uint32 index) const +{ + ASSERT(index < sizeof(uint64) * 2); + return ((uint8 const*)&_low)[index]; } ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid) @@ -184,12 +192,6 @@ ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid) return buf; } -ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid) -{ - buf.append(guid._packedGuid); - return buf; -} - std::ostream& operator<<(std::ostream& stream, ObjectGuid const& guid) { std::ostringstream tmp; diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h index bcb029b2deb..131f911f77d 100644 --- a/src/server/game/Entities/Object/ObjectGuid.h +++ b/src/server/game/Entities/Object/ObjectGuid.h @@ -19,14 +19,14 @@ #ifndef ObjectGuid_h__ #define ObjectGuid_h__ -#include "ByteBuffer.h" +#include "Define.h" #include <deque> #include <functional> #include <list> #include <set> #include <type_traits> -#include <unordered_set> #include <vector> +#include <unordered_set> enum TypeID { @@ -199,8 +199,7 @@ struct ObjectGuidTraits<HighGuid::Transport> static bool const MapSpecific = true; }; -class ObjectGuid; -class PackedGuid; +class ByteBuffer; #pragma pack(push, 1) @@ -248,19 +247,8 @@ class TC_GAME_API ObjectGuid LowType GetMaxCounter() const { return GetMaxCounter(GetHigh()); } - // deprecated - uint8& operator[](uint32 index) - { - //ASSERT(index < sizeof(uint64) * 2); - return ((uint8*)&_low)[index]; - } - - // deprecated - uint8 const& operator[](uint32 index) const - { - //ASSERT(index < sizeof(uint64) * 2); - return ((uint8 const*)&_low)[index]; - } + uint8& operator[](uint32 index); + uint8 const& operator[](uint32 index) const; bool IsEmpty() const { return _low == 0 && _high == 0; } bool IsCreature() const { return GetHigh() == HighGuid::Creature; } @@ -360,25 +348,6 @@ typedef std::deque<ObjectGuid> GuidDeque; typedef std::vector<ObjectGuid> GuidVector; typedef std::unordered_set<ObjectGuid> GuidUnorderedSet; -// maximum buffer size for packed guid is 18 bytes -#define PACKED_GUID_MIN_BUFFER_SIZE 18 - -class TC_GAME_API PackedGuid -{ - friend TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid); - - public: - explicit PackedGuid() : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid << uint16(0); } - explicit PackedGuid(ObjectGuid const& guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { Set(guid); } - - void Set(ObjectGuid const& guid); - - size_t size() const { return _packedGuid.size(); } - - private: - ByteBuffer _packedGuid; -}; - class TC_GAME_API ObjectGuidGeneratorBase { public: @@ -410,8 +379,6 @@ public: TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid); TC_GAME_API ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid); -TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid); - TC_GAME_API std::ostream& operator<<(std::ostream& stream, ObjectGuid const& guid); namespace std diff --git a/src/server/game/Entities/Object/Position.cpp b/src/server/game/Entities/Object/Position.cpp index 63120fff443..74ead0a6f8e 100644 --- a/src/server/game/Entities/Object/Position.cpp +++ b/src/server/game/Entities/Object/Position.cpp @@ -21,6 +21,7 @@ #include "Random.h" #include <G3D/g3dmath.h> +#include <sstream> bool Position::operator==(Position const &a) { @@ -43,6 +44,26 @@ bool Position::IsPositionValid() const return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation); } +float Position::GetExactDist2d(const float x, const float y) const +{ + return std::sqrt(GetExactDist2dSq(x, y)); +} + +float Position::GetExactDist2d(Position const* pos) const +{ + return std::sqrt(GetExactDist2dSq(pos)); +} + +float Position::GetExactDist(float x, float y, float z) const +{ + return std::sqrt(GetExactDistSq(x, y, z)); +} + +float Position::GetExactDist(Position const* pos) const +{ + return std::sqrt(GetExactDistSq(pos)); +} + void Position::GetPositionOffsetTo(const Position & endPos, Position & retOffset) const { float dx = endPos.GetPositionX() - GetPositionX(); @@ -165,6 +186,20 @@ std::string Position::ToString() const return sstr.str(); } +float Position::NormalizeOrientation(float o) +{ + // fmod only supports positive numbers. Thus we have + // to emulate negative numbers + if (o < 0) + { + float mod = o *-1; + mod = std::fmod(mod, 2.0f * static_cast<float>(M_PI)); + mod = -mod + 2.0f * static_cast<float>(M_PI); + return mod; + } + return std::fmod(o, 2.0f * static_cast<float>(M_PI)); +} + ByteBuffer& operator<<(ByteBuffer& buf, Position::ConstStreamer<Position::XY> const& streamer) { buf << streamer.Pos->GetPositionX(); diff --git a/src/server/game/Entities/Object/Position.h b/src/server/game/Entities/Object/Position.h index 381f970a014..f045eb93824 100644 --- a/src/server/game/Entities/Object/Position.h +++ b/src/server/game/Entities/Object/Position.h @@ -18,7 +18,8 @@ #ifndef Trinity_game_Position_h__ #define Trinity_game_Position_h__ -#include "Common.h" +#include "Define.h" +#include <string> #include <cmath> class ByteBuffer; @@ -136,10 +137,7 @@ public: float dx = m_positionX - x; float dy = m_positionY - y; return dx*dx + dy*dy; } - float GetExactDist2d(const float x, const float y) const - { - return std::sqrt(GetExactDist2dSq(x, y)); - } + float GetExactDist2d(const float x, const float y) const; float GetExactDist2dSq(Position const& pos) const { @@ -156,20 +154,14 @@ public: float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; return dx*dx + dy*dy; } - float GetExactDist2d(Position const* pos) const - { - return std::sqrt(GetExactDist2dSq(pos)); - } + float GetExactDist2d(Position const* pos) const; float GetExactDistSq(float x, float y, float z) const { float dz = m_positionZ - z; return GetExactDist2dSq(x, y) + dz*dz; } - float GetExactDist(float x, float y, float z) const - { - return std::sqrt(GetExactDistSq(x, y, z)); - } + float GetExactDist(float x, float y, float z) const; float GetExactDistSq(Position const& pos) const { @@ -186,10 +178,7 @@ public: float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; float dz = m_positionZ - pos->m_positionZ; return dx*dx + dy*dy + dz*dz; } - float GetExactDist(Position const* pos) const - { - return std::sqrt(GetExactDistSq(pos)); - } + float GetExactDist(Position const* pos) const; void GetPositionOffsetTo(Position const & endPos, Position & retOffset) const; Position GetPositionWithOffset(Position const& offset) const; @@ -234,19 +223,7 @@ public: std::string ToString() const; // modulos a radian orientation to the range of 0..2PI - static float NormalizeOrientation(float o) - { - // fmod only supports positive numbers. Thus we have - // to emulate negative numbers - if (o < 0) - { - float mod = o *-1; - mod = std::fmod(mod, 2.0f * static_cast<float>(M_PI)); - mod = -mod + 2.0f * static_cast<float>(M_PI); - return mod; - } - return std::fmod(o, 2.0f * static_cast<float>(M_PI)); - } + static float NormalizeOrientation(float o); }; #define MAPID_INVALID 0xFFFFFFFF diff --git a/src/server/game/Entities/Object/Updates/UpdateData.cpp b/src/server/game/Entities/Object/Updates/UpdateData.cpp index 7a59f1cf236..1358d7a8568 100644 --- a/src/server/game/Entities/Object/Updates/UpdateData.cpp +++ b/src/server/game/Entities/Object/Updates/UpdateData.cpp @@ -16,11 +16,9 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Common.h" -#include "ByteBuffer.h" +#include "UpdateData.h" #include "Errors.h" #include "WorldPacket.h" -#include "UpdateData.h" #include "Opcodes.h" UpdateData::UpdateData(uint32 map) : m_map(map), m_blockCount(0) { } diff --git a/src/server/game/Entities/Object/Updates/UpdateData.h b/src/server/game/Entities/Object/Updates/UpdateData.h index 7e7d86590d9..ca3bdcd4cce 100644 --- a/src/server/game/Entities/Object/Updates/UpdateData.h +++ b/src/server/game/Entities/Object/Updates/UpdateData.h @@ -19,6 +19,7 @@ #ifndef __UPDATEDATA_H #define __UPDATEDATA_H +#include "Define.h" #include "ByteBuffer.h" #include "ObjectGuid.h" #include <set> diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 304d7a1bbad..63ca784c2ff 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -16,22 +16,23 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "Pet.h" #include "Common.h" #include "DatabaseEnv.h" +#include "Group.h" #include "Log.h" -#include "WorldPacket.h" -#include "SpellPackets.h" #include "ObjectMgr.h" -#include "SpellMgr.h" -#include "Pet.h" +#include "Opcodes.h" #include "PetPackets.h" -#include "SpellAuras.h" #include "SpellAuraEffects.h" +#include "SpellAuras.h" #include "SpellHistory.h" +#include "SpellMgr.h" +#include "SpellPackets.h" #include "Unit.h" #include "Util.h" -#include "Group.h" -#include "Opcodes.h" +#include "World.h" +#include "WorldPacket.h" #include "WorldSession.h" #define PET_XP_FACTOR 0.05f diff --git a/src/server/game/Entities/Player/CUFProfile.h b/src/server/game/Entities/Player/CUFProfile.h new file mode 100644 index 00000000000..c1ac073f611 --- /dev/null +++ b/src/server/game/Entities/Player/CUFProfile.h @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef CUFProfile_h__ +#define CUFProfile_h__ + +#include "Define.h" +#include <bitset> +#include <string> + +/// Maximum number of CompactUnitFrames profiles +#define MAX_CUF_PROFILES 5 + +/// Bit index used in the many bool options of CompactUnitFrames +enum CUFBoolOptions +{ + CUF_KEEP_GROUPS_TOGETHER, + CUF_DISPLAY_PETS, + CUF_DISPLAY_MAIN_TANK_AND_ASSIST, + CUF_DISPLAY_HEAL_PREDICTION, + CUF_DISPLAY_AGGRO_HIGHLIGHT, + CUF_DISPLAY_ONLY_DISPELLABLE_DEBUFFS, + CUF_DISPLAY_POWER_BAR, + CUF_DISPLAY_BORDER, + CUF_USE_CLASS_COLORS, + CUF_DISPLAY_HORIZONTAL_GROUPS, + CUF_DISPLAY_NON_BOSS_DEBUFFS, + CUF_DYNAMIC_POSITION, + CUF_LOCKED, + CUF_SHOWN, + CUF_AUTO_ACTIVATE_2_PLAYERS, + CUF_AUTO_ACTIVATE_3_PLAYERS, + CUF_AUTO_ACTIVATE_5_PLAYERS, + CUF_AUTO_ACTIVATE_10_PLAYERS, + CUF_AUTO_ACTIVATE_15_PLAYERS, + CUF_AUTO_ACTIVATE_25_PLAYERS, + CUF_AUTO_ACTIVATE_40_PLAYERS, + CUF_AUTO_ACTIVATE_SPEC_1, + CUF_AUTO_ACTIVATE_SPEC_2, + CUF_AUTO_ACTIVATE_SPEC_3, + CUF_AUTO_ACTIVATE_SPEC_4, + CUF_AUTO_ACTIVATE_PVP, + CUF_AUTO_ACTIVATE_PVE, + + CUF_BOOL_OPTIONS_COUNT, +}; + +/// Represents a CompactUnitFrame profile +struct CUFProfile +{ + CUFProfile() : ProfileName(), BoolOptions() // might want to change default value for options + { + FrameHeight = 0; + FrameWidth = 0; + SortBy = 0; + HealthText = 0; + TopPoint = 0; + BottomPoint = 0; + LeftPoint = 0; + TopOffset = 0; + BottomOffset = 0; + LeftOffset = 0; + } + + CUFProfile(std::string const& name, uint16 frameHeight, uint16 frameWidth, uint8 sortBy, uint8 healthText, uint32 boolOptions, + uint8 topPoint, uint8 bottomPoint, uint8 leftPoint, uint16 topOffset, uint16 bottomOffset, uint16 leftOffset) + : ProfileName(name), BoolOptions(int(boolOptions)) + { + FrameHeight = frameHeight; + FrameWidth = frameWidth; + SortBy = sortBy; + HealthText = healthText; + TopPoint = topPoint; + BottomPoint = bottomPoint; + LeftPoint = leftPoint; + TopOffset = topOffset; + BottomOffset = bottomOffset; + LeftOffset = leftOffset; + } + + std::string ProfileName; + uint16 FrameHeight; + uint16 FrameWidth; + uint8 SortBy; + uint8 HealthText; + + // LeftAlign, TopAlight, BottomAlign + uint8 TopPoint; + uint8 BottomPoint; + uint8 LeftPoint; + + // LeftOffset, TopOffset and BottomOffset + uint16 TopOffset; + uint16 BottomOffset; + uint16 LeftOffset; + + std::bitset<CUF_BOOL_OPTIONS_COUNT> BoolOptions; + + // More fields can be added to BoolOptions without changing DB schema (up to 32, currently 27) +}; + +#endif // CUFProfile_h__ diff --git a/src/server/game/Entities/Player/CollectionMgr.cpp b/src/server/game/Entities/Player/CollectionMgr.cpp index a4c8c179cf3..f52408f1c4b 100644 --- a/src/server/game/Entities/Player/CollectionMgr.cpp +++ b/src/server/game/Entities/Player/CollectionMgr.cpp @@ -16,10 +16,17 @@ */ #include "CollectionMgr.h" +#include "DatabaseEnv.h" +#include "DB2Stores.h" +#include "Item.h" +#include "Log.h" #include "MiscPackets.h" #include "ObjectMgr.h" #include "Player.h" +#include "Timer.h" #include "TransmogrificationPackets.h" +#include "WorldSession.h" +#include <boost/dynamic_bitset.hpp> namespace { @@ -63,7 +70,11 @@ void CollectionMgr::LoadMountDefinitions() TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " mount definitions in %u ms", FactionSpecificMounts.size(), GetMSTimeDiffToNow(oldMSTime)); } -CollectionMgr::CollectionMgr(WorldSession* owner) : _owner(owner), _appearances() +CollectionMgr::CollectionMgr(WorldSession* owner) : _owner(owner), _appearances(Trinity::make_unique<boost::dynamic_bitset<uint32>>()) +{ +} + +CollectionMgr::~CollectionMgr() { } @@ -438,7 +449,7 @@ private: void CollectionMgr::LoadItemAppearances() { - boost::to_block_range(_appearances, DynamicBitsetBlockOutputIterator([this](uint32 blockValue) + boost::to_block_range(*_appearances, DynamicBitsetBlockOutputIterator([this](uint32 blockValue) { _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_TRANSMOG, blockValue); })); @@ -463,7 +474,7 @@ void CollectionMgr::LoadAccountItemAppearances(PreparedQueryResult knownAppearan } while (knownAppearances->NextRow()); - _appearances.init_from_block_range(blocks.begin(), blocks.end()); + _appearances->init_from_block_range(blocks.begin(), blocks.end()); } if (favoriteAppearances) @@ -489,17 +500,17 @@ void CollectionMgr::LoadAccountItemAppearances(PreparedQueryResult knownAppearan { ItemModifiedAppearanceEntry const* hiddenAppearance = sDB2Manager.GetItemModifiedAppearance(hiddenItem, 0); ASSERT(hiddenAppearance); - if (_appearances.size() <= hiddenAppearance->ID) - _appearances.resize(hiddenAppearance->ID + 1); + if (_appearances->size() <= hiddenAppearance->ID) + _appearances->resize(hiddenAppearance->ID + 1); - _appearances.set(hiddenAppearance->ID); + _appearances->set(hiddenAppearance->ID); } } void CollectionMgr::SaveAccountItemAppearances(SQLTransaction& trans) { uint16 blockIndex = 0; - boost::to_block_range(_appearances, DynamicBitsetBlockOutputIterator([this, &blockIndex, trans](uint32 blockValue) + boost::to_block_range(*_appearances, DynamicBitsetBlockOutputIterator([this, &blockIndex, trans](uint32 blockValue) { if (blockValue) // this table is only appended/bits are set (never cleared) so don't save empty blocks { @@ -657,7 +668,7 @@ bool CollectionMgr::CanAddAppearance(ItemModifiedAppearanceEntry const* itemModi if (!(itemTemplate->GetFlags2() & ITEM_FLAG2_IGNORE_QUALITY_FOR_ITEM_VISUAL_SOURCE) || !(itemTemplate->GetFlags3() & ITEM_FLAG3_ACTS_AS_TRANSMOG_HIDDEN_VISUAL_OPTION)) return false; - if (itemModifiedAppearance->ID < _appearances.size() && _appearances.test(itemModifiedAppearance->ID)) + if (itemModifiedAppearance->ID < _appearances->size() && _appearances->test(itemModifiedAppearance->ID)) return false; return true; @@ -665,16 +676,16 @@ bool CollectionMgr::CanAddAppearance(ItemModifiedAppearanceEntry const* itemModi void CollectionMgr::AddItemAppearance(ItemModifiedAppearanceEntry const* itemModifiedAppearance) { - if (_appearances.size() <= itemModifiedAppearance->ID) + if (_appearances->size() <= itemModifiedAppearance->ID) { - std::size_t numBlocks = _appearances.num_blocks(); - _appearances.resize(itemModifiedAppearance->ID + 1); - numBlocks = _appearances.num_blocks() - numBlocks; + std::size_t numBlocks = _appearances->num_blocks(); + _appearances->resize(itemModifiedAppearance->ID + 1); + numBlocks = _appearances->num_blocks() - numBlocks; while (numBlocks--) _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_TRANSMOG, 0); } - _appearances.set(itemModifiedAppearance->ID); + _appearances->set(itemModifiedAppearance->ID); uint32 blockIndex = itemModifiedAppearance->ID / 32; uint32 bitIndex = itemModifiedAppearance->ID % 32; uint32 currentMask = _owner->GetPlayer()->GetDynamicValue(PLAYER_DYNAMIC_FIELD_TRANSMOG, blockIndex); @@ -716,7 +727,7 @@ void CollectionMgr::RemoveTemporaryAppearance(Item* item) std::pair<bool, bool> CollectionMgr::HasItemAppearance(uint32 itemModifiedAppearanceId) const { - if (itemModifiedAppearanceId < _appearances.size() && _appearances.test(itemModifiedAppearanceId)) + if (itemModifiedAppearanceId < _appearances->size() && _appearances->test(itemModifiedAppearanceId)) return{ true, false }; if (_temporaryAppearances.find(itemModifiedAppearanceId) != _temporaryAppearances.end()) diff --git a/src/server/game/Entities/Player/CollectionMgr.h b/src/server/game/Entities/Player/CollectionMgr.h index 5b96396f5e6..5150ea3963a 100644 --- a/src/server/game/Entities/Player/CollectionMgr.h +++ b/src/server/game/Entities/Player/CollectionMgr.h @@ -18,9 +18,16 @@ #ifndef CollectionMgr_h__ #define CollectionMgr_h__ -#include "WorldSession.h" -#include <boost/dynamic_bitset.hpp> - +#include "Define.h" +#include "DatabaseEnvFwd.h" +#include "ObjectGuid.h" +#include <boost/dynamic_bitset_fwd.hpp> +#include <map> +#include <unordered_map> +#include <unordered_set> + +class Item; +class WorldSession; struct ItemModifiedAppearanceEntry; enum HeirloomPlayerFlags @@ -62,6 +69,7 @@ class TC_GAME_API CollectionMgr { public: explicit CollectionMgr(WorldSession* owner); + ~CollectionMgr(); static void LoadMountDefinitions(); @@ -132,7 +140,7 @@ private: ToyBoxContainer _toys; HeirloomContainer _heirlooms; MountContainer _mounts; - boost::dynamic_bitset<uint32> _appearances; + std::unique_ptr<boost::dynamic_bitset<uint32>> _appearances; std::unordered_map<uint32, std::unordered_set<ObjectGuid>> _temporaryAppearances; std::unordered_map<uint32, FavoriteAppearanceState> _favoriteAppearances; }; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index ef23b8b4495..443c1aefc82 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -28,6 +28,7 @@ #include "BattlefieldWG.h" #include "Battleground.h" #include "BattlegroundMgr.h" +#include "BattlegroundPackets.h" #include "BattlegroundScore.h" #include "BattlePetMgr.h" #include "CellImpl.h" @@ -68,6 +69,7 @@ #include "LFGMgr.h" #include "Language.h" #include "Log.h" +#include "LootMgr.h" #include "LootPackets.h" #include "MailPackets.h" #include "MapManager.h" @@ -83,6 +85,7 @@ #include "QueryHolder.h" #include "QuestDef.h" #include "QuestPackets.h" +#include "Realm.h" #include "ReputationMgr.h" #include "Scenario.h" #include "SkillDiscovery.h" @@ -724,7 +727,7 @@ bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount) InventoryResult msg = CanStoreNewItem(INVENTORY_SLOT_BAG_0, NULL_SLOT, sDest, titem_id, titem_amount); if (msg == EQUIP_ERR_OK) { - StoreNewItem(sDest, titem_id, true, Item::GenerateItemRandomPropertyId(titem_id)); + StoreNewItem(sDest, titem_id, true, GenerateItemRandomPropertyId(titem_id)); return true; // stored } @@ -15073,7 +15076,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, ItemPosCountVec dest; if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, reward, quest->RewardChoiceItemCount[i]) == EQUIP_ERR_OK) { - Item* item = StoreNewItem(dest, reward, true, Item::GenerateItemRandomPropertyId(reward)); + Item* item = StoreNewItem(dest, reward, true, GenerateItemRandomPropertyId(reward)); SendNewItem(item, quest->RewardChoiceItemCount[i], true, false); } } @@ -15097,7 +15100,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, ItemPosCountVec dest; if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, questPackageItem->ItemID, questPackageItem->ItemCount) == EQUIP_ERR_OK) { - Item* item = StoreNewItem(dest, questPackageItem->ItemID, true, Item::GenerateItemRandomPropertyId(questPackageItem->ItemID)); + Item* item = StoreNewItem(dest, questPackageItem->ItemID, true, GenerateItemRandomPropertyId(questPackageItem->ItemID)); SendNewItem(item, questPackageItem->ItemCount, true, false); } } @@ -15116,7 +15119,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, ItemPosCountVec dest; if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, questPackageItem->ItemID, questPackageItem->ItemCount) == EQUIP_ERR_OK) { - Item* item = StoreNewItem(dest, questPackageItem->ItemID, true, Item::GenerateItemRandomPropertyId(questPackageItem->ItemID)); + Item* item = StoreNewItem(dest, questPackageItem->ItemID, true, GenerateItemRandomPropertyId(questPackageItem->ItemID)); SendNewItem(item, questPackageItem->ItemCount, true, false); } } @@ -15133,7 +15136,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, ItemPosCountVec dest; if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, quest->RewardItemCount[i]) == EQUIP_ERR_OK) { - Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); + Item* item = StoreNewItem(dest, itemId, true, GenerateItemRandomPropertyId(itemId)); SendNewItem(item, quest->RewardItemCount[i], true, false); } else if (quest->IsDFQuest()) @@ -22124,7 +22127,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c } Item* it = bStore ? - StoreNewItem(vDest, item, true, Item::GenerateItemRandomPropertyId(item), {}, 0, {}, false) : + StoreNewItem(vDest, item, true, GenerateItemRandomPropertyId(item), {}, 0, {}, false) : EquipNewItem(uiDest, item, true); if (it) { @@ -26615,7 +26618,7 @@ bool Player::AddItem(uint32 itemId, uint32 count) return false; } - Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); + Item* item = StoreNewItem(dest, itemId, true, GenerateItemRandomPropertyId(itemId)); if (item) SendNewItem(item, count, true, false); else diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index f6f7e75ca99..6dcb1f99900 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -22,7 +22,7 @@ #include "DB2Stores.h" #include "GroupReference.h" #include "MapReference.h" - +#include "CUFProfile.h" #include "Item.h" #include "PetDefines.h" #include "QuestDef.h" @@ -34,7 +34,9 @@ #include "TradeData.h" #include "CinematicMgr.h" #include "SceneMgr.h" +#include <queue> +struct AccessRequirement; struct CreatureTemplate; struct Mail; struct ItemExtendedCostEntry; @@ -202,97 +204,6 @@ typedef std::unordered_map<uint32, PlayerSpell*> PlayerSpellMap; typedef std::list<SpellModifier*> SpellModList; typedef std::unordered_map<uint32, PlayerCurrency> PlayerCurrenciesMap; -/// Maximum number of CompactUnitFrames profiles -#define MAX_CUF_PROFILES 5 - -/// Bit index used in the many bool options of CompactUnitFrames -enum CUFBoolOptions -{ - CUF_KEEP_GROUPS_TOGETHER, - CUF_DISPLAY_PETS, - CUF_DISPLAY_MAIN_TANK_AND_ASSIST, - CUF_DISPLAY_HEAL_PREDICTION, - CUF_DISPLAY_AGGRO_HIGHLIGHT, - CUF_DISPLAY_ONLY_DISPELLABLE_DEBUFFS, - CUF_DISPLAY_POWER_BAR, - CUF_DISPLAY_BORDER, - CUF_USE_CLASS_COLORS, - CUF_DISPLAY_HORIZONTAL_GROUPS, - CUF_DISPLAY_NON_BOSS_DEBUFFS, - CUF_DYNAMIC_POSITION, - CUF_LOCKED, - CUF_SHOWN, - CUF_AUTO_ACTIVATE_2_PLAYERS, - CUF_AUTO_ACTIVATE_3_PLAYERS, - CUF_AUTO_ACTIVATE_5_PLAYERS, - CUF_AUTO_ACTIVATE_10_PLAYERS, - CUF_AUTO_ACTIVATE_15_PLAYERS, - CUF_AUTO_ACTIVATE_25_PLAYERS, - CUF_AUTO_ACTIVATE_40_PLAYERS, - CUF_AUTO_ACTIVATE_SPEC_1, - CUF_AUTO_ACTIVATE_SPEC_2, - CUF_AUTO_ACTIVATE_SPEC_3, - CUF_AUTO_ACTIVATE_SPEC_4, - CUF_AUTO_ACTIVATE_PVP, - CUF_AUTO_ACTIVATE_PVE, - - CUF_BOOL_OPTIONS_COUNT, -}; - -/// Represents a CompactUnitFrame profile -struct CUFProfile -{ - CUFProfile() : ProfileName(), BoolOptions() // might want to change default value for options - { - FrameHeight = 0; - FrameWidth = 0; - SortBy = 0; - HealthText = 0; - TopPoint = 0; - BottomPoint = 0; - LeftPoint = 0; - TopOffset = 0; - BottomOffset = 0; - LeftOffset = 0; - } - - CUFProfile(const std::string& name, uint16 frameHeight, uint16 frameWidth, uint8 sortBy, uint8 healthText, uint32 boolOptions, - uint8 topPoint, uint8 bottomPoint, uint8 leftPoint, uint16 topOffset, uint16 bottomOffset, uint16 leftOffset) - : ProfileName(name), BoolOptions(int(boolOptions)) - { - FrameHeight = frameHeight; - FrameWidth = frameWidth; - SortBy = sortBy; - HealthText = healthText; - TopPoint = topPoint; - BottomPoint = bottomPoint; - LeftPoint = leftPoint; - TopOffset = topOffset; - BottomOffset = bottomOffset; - LeftOffset = leftOffset; - } - - std::string ProfileName; - uint16 FrameHeight; - uint16 FrameWidth; - uint8 SortBy; - uint8 HealthText; - - // LeftAlign, TopAlight, BottomAlign - uint8 TopPoint; - uint8 BottomPoint; - uint8 LeftPoint; - - // LeftOffset, TopOffset and BottomOffset - uint16 TopOffset; - uint16 BottomOffset; - uint16 LeftOffset; - - std::bitset<CUF_BOOL_OPTIONS_COUNT> BoolOptions; - - // More fields can be added to BoolOptions without changing DB schema (up to 32, currently 27) -}; - typedef std::unordered_map<uint32 /*instanceId*/, time_t/*releaseTime*/> InstanceTimeMap; enum TrainerSpellState @@ -364,61 +275,6 @@ struct ActionButton typedef std::map<uint8, ActionButton> ActionButtonList; -struct PlayerCreateInfoItem -{ - PlayerCreateInfoItem(uint32 id, uint32 amount) : item_id(id), item_amount(amount) { } - - uint32 item_id; - uint32 item_amount; -}; - -typedef std::list<PlayerCreateInfoItem> PlayerCreateInfoItems; - -struct PlayerLevelInfo -{ - PlayerLevelInfo() { for (uint8 i=0; i < MAX_STATS; ++i) stats[i] = 0; } - - uint16 stats[MAX_STATS]; -}; - -typedef std::list<uint32> PlayerCreateInfoSpells; - -struct PlayerCreateInfoAction -{ - PlayerCreateInfoAction() : button(0), type(0), action(0) { } - PlayerCreateInfoAction(uint8 _button, uint32 _action, uint8 _type) : button(_button), type(_type), action(_action) { } - - uint8 button; - uint8 type; - uint32 action; -}; - -typedef std::list<PlayerCreateInfoAction> PlayerCreateInfoActions; - -typedef std::list<SkillRaceClassInfoEntry const*> PlayerCreateInfoSkills; - -struct PlayerInfo -{ - // existence checked by displayId != 0 - PlayerInfo() : mapId(0), areaId(0), positionX(0.0f), positionY(0.0f), positionZ(0.0f), orientation(0.0f), displayId_m(0), displayId_f(0), levelInfo(nullptr) { } - - uint32 mapId; - uint32 areaId; - float positionX; - float positionY; - float positionZ; - float orientation; - uint16 displayId_m; - uint16 displayId_f; - PlayerCreateInfoItems item; - PlayerCreateInfoSpells customSpells; - PlayerCreateInfoSpells castSpells; - PlayerCreateInfoActions action; - PlayerCreateInfoSkills skills; - - PlayerLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1 -}; - struct PvPInfo { PvPInfo() : IsHostile(false), IsInHostileArea(false), IsInNoPvPArea(false), IsInFFAPvPArea(false), EndTimer(0) { } @@ -1047,18 +903,6 @@ struct InstancePlayerBind InstancePlayerBind() : save(NULL), perm(false), extendState(EXTEND_STATE_NORMAL) { } }; -struct AccessRequirement -{ - uint8 levelMin; - uint8 levelMax; - uint32 item; - uint32 item2; - uint32 quest_A; - uint32 quest_H; - uint32 achievement; - std::string questFailedText; -}; - enum CharDeleteMethod { CHAR_DELETE_REMOVE = 0, // Completely remove from the database diff --git a/src/server/game/Entities/Player/PlayerTaxi.cpp b/src/server/game/Entities/Player/PlayerTaxi.cpp index 478b2dbc89d..f3ebb891062 100644 --- a/src/server/game/Entities/Player/PlayerTaxi.cpp +++ b/src/server/game/Entities/Player/PlayerTaxi.cpp @@ -1,8 +1,26 @@ +/* + * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #include "Player.h" #include "TaxiPackets.h" #include "ObjectMgr.h" #include <limits> #include <math.h> +#include <sstream> void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level) { diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index cf28735b1dc..2ee30f7d6ff 100644 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -18,11 +18,12 @@ #include "SocialMgr.h" #include "DatabaseEnv.h" +#include "ObjectAccessor.h" #include "Player.h" +#include "RBAC.h" #include "SocialPackets.h" #include "World.h" #include "WorldSession.h" -#include "ObjectAccessor.h" uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag) { diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h index 2a59844b89b..68fd95411bf 100644 --- a/src/server/game/Entities/Player/SocialMgr.h +++ b/src/server/game/Entities/Player/SocialMgr.h @@ -19,9 +19,10 @@ #ifndef __TRINITY_SOCIALMGR_H #define __TRINITY_SOCIALMGR_H -#include "DatabaseEnv.h" +#include "DatabaseEnvFwd.h" #include "Common.h" #include "ObjectGuid.h" +#include <map> class Player; class WorldPacket; diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index f7461a5355e..672903f8dea 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -16,19 +16,20 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Common.h" #include "Transport.h" +#include "Cell.h" +#include "CellImpl.h" +#include "Common.h" +#include "GameObjectAI.h" +#include "Log.h" #include "MapManager.h" #include "ObjectMgr.h" +#include "Player.h" #include "ScriptMgr.h" -#include "GameObjectAI.h" #include "Spline.h" -#include "Vehicle.h" -#include "Player.h" -#include "Cell.h" -#include "CellImpl.h" #include "Totem.h" #include "UpdateData.h" +#include "Vehicle.h" #include <G3D/Vector3.h> Transport::Transport() : GameObject(), diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 6259225b2f9..70811186cee 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -21,6 +21,7 @@ #include "Battlefield.h" #include "BattlefieldMgr.h" #include "Battleground.h" +#include "BattlegroundPackets.h" #include "BattlegroundScore.h" #include "CellImpl.h" #include "ChatTextBuilder.h" @@ -35,6 +36,7 @@ #include "InstanceSaveMgr.h" #include "InstanceScript.h" #include "Log.h" +#include "LootMgr.h" #include "MoveSpline.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index e05d2020a31..6ca7b8d9bf4 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -19,6 +19,7 @@ #ifndef __UNIT_H #define __UNIT_H +#include "UnitDefines.h" #include "EventProcessor.h" #include "FollowerReference.h" #include "FollowerRefManager.h" @@ -202,69 +203,6 @@ enum SpellFacingFlags SPELL_FACING_FLAG_INFRONT = 0x0001 }; -#define BASE_MINDAMAGE 1.0f -#define BASE_MAXDAMAGE 2.0f -#define BASE_ATTACK_TIME 2000 - -// byte value (UNIT_FIELD_BYTES_1, 0) -enum UnitStandStateType -{ - UNIT_STAND_STATE_STAND = 0, - UNIT_STAND_STATE_SIT = 1, - UNIT_STAND_STATE_SIT_CHAIR = 2, - UNIT_STAND_STATE_SLEEP = 3, - UNIT_STAND_STATE_SIT_LOW_CHAIR = 4, - UNIT_STAND_STATE_SIT_MEDIUM_CHAIR = 5, - UNIT_STAND_STATE_SIT_HIGH_CHAIR = 6, - UNIT_STAND_STATE_DEAD = 7, - UNIT_STAND_STATE_KNEEL = 8, - UNIT_STAND_STATE_SUBMERGED = 9 -}; - -// byte flag value (UNIT_FIELD_BYTES_1, 2) -enum UnitStandFlags -{ - UNIT_STAND_FLAGS_UNK1 = 0x01, - UNIT_STAND_FLAGS_CREEP = 0x02, - UNIT_STAND_FLAGS_UNTRACKABLE = 0x04, - UNIT_STAND_FLAGS_UNK4 = 0x08, - UNIT_STAND_FLAGS_UNK5 = 0x10, - UNIT_STAND_FLAGS_ALL = 0xFF -}; - -enum UnitBytes0Offsets -{ - UNIT_BYTES_0_OFFSET_RACE = 0, - UNIT_BYTES_0_OFFSET_CLASS = 1, - UNIT_BYTES_0_OFFSET_PLAYER_CLASS = 2, - UNIT_BYTES_0_OFFSET_GENDER = 3 -}; - -enum UnitBytes1Offsets -{ - UNIT_BYTES_1_OFFSET_STAND_STATE = 0, - UNIT_BYTES_1_OFFSET_PET_TALENTS = 1, // unused - UNIT_BYTES_1_OFFSET_VIS_FLAG = 2, - UNIT_BYTES_1_OFFSET_ANIM_TIER = 3 -}; - -enum UnitBytes2Offsets -{ - UNIT_BYTES_2_OFFSET_SHEATH_STATE = 0, - UNIT_BYTES_2_OFFSET_PVP_FLAG = 1, - UNIT_BYTES_2_OFFSET_PET_FLAGS = 2, - UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM = 3 -}; - -// byte flags value (UNIT_FIELD_BYTES_1, 3) -enum UnitBytes1_Flags -{ - UNIT_BYTE1_FLAG_ALWAYS_STAND = 0x01, - UNIT_BYTE1_FLAG_HOVER = 0x02, - UNIT_BYTE1_FLAG_UNK_3 = 0x04, - UNIT_BYTE1_FLAG_ALL = 0xFF -}; - // high byte (3 from 0..3) of UNIT_FIELD_BYTES_2 enum ShapeshiftForm { @@ -304,36 +242,6 @@ enum ShapeshiftForm FORM_GLADIATOR_STANCE = 33 }; -// low byte (0 from 0..3) of UNIT_FIELD_BYTES_2 -enum SheathState : uint8 -{ - SHEATH_STATE_UNARMED = 0, // non prepared weapon - SHEATH_STATE_MELEE = 1, // prepared melee weapon - SHEATH_STATE_RANGED = 2 // prepared ranged weapon -}; - -#define MAX_SHEATH_STATE 3 - -// byte (1 from 0..3) of UNIT_FIELD_BYTES_2 -enum UnitPVPStateFlags -{ - UNIT_BYTE2_FLAG_PVP = 0x01, - UNIT_BYTE2_FLAG_UNK1 = 0x02, - UNIT_BYTE2_FLAG_FFA_PVP = 0x04, - UNIT_BYTE2_FLAG_SANCTUARY = 0x08, - UNIT_BYTE2_FLAG_UNK4 = 0x10, - UNIT_BYTE2_FLAG_UNK5 = 0x20, - UNIT_BYTE2_FLAG_UNK6 = 0x40, - UNIT_BYTE2_FLAG_UNK7 = 0x80 -}; - -// byte (2 from 0..3) of UNIT_FIELD_BYTES_2 -enum UnitRename -{ - UNIT_CAN_BE_RENAMED = 0x01, - UNIT_CAN_BE_ABANDONED = 0x02 -}; - #define MAX_SPELL_CHARM 4 #define MAX_SPELL_VEHICLE 6 #define MAX_SPELL_POSSESS 8 @@ -689,200 +597,6 @@ enum DamageEffectType SELF_DAMAGE = 5 }; -// Value masks for UNIT_FIELD_FLAGS -enum UnitFlags : uint32 -{ - UNIT_FLAG_SERVER_CONTROLLED = 0x00000001, // set only when unit movement is controlled by server - by SPLINE/MONSTER_MOVE packets, together with UNIT_FLAG_STUNNED; only set to units controlled by client; client function CGUnit_C::IsClientControlled returns false when set for owner - UNIT_FLAG_NON_ATTACKABLE = 0x00000002, // not attackable - UNIT_FLAG_REMOVE_CLIENT_CONTROL = 0x00000004, // This is a legacy flag used to disable movement player's movement while controlling other units, SMSG_CLIENT_CONTROL replaces this functionality clientside now. CONFUSED and FLEEING flags have the same effect on client movement asDISABLE_MOVE_CONTROL in addition to preventing spell casts/autoattack (they all allow climbing steeper hills and emotes while moving) - UNIT_FLAG_PVP_ATTACKABLE = 0x00000008, // allow apply pvp rules to attackable state in addition to faction dependent state - UNIT_FLAG_RENAME = 0x00000010, - UNIT_FLAG_PREPARATION = 0x00000020, // don't take reagents for spells with SPELL_ATTR5_NO_REAGENT_WHILE_PREP - UNIT_FLAG_UNK_6 = 0x00000040, - UNIT_FLAG_NOT_ATTACKABLE_1 = 0x00000080, // ?? (UNIT_FLAG_PVP_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1) is NON_PVP_ATTACKABLE - UNIT_FLAG_IMMUNE_TO_PC = 0x00000100, // disables combat/assistance with PlayerCharacters (PC) - see Unit::_IsValidAttackTarget, Unit::_IsValidAssistTarget - UNIT_FLAG_IMMUNE_TO_NPC = 0x00000200, // disables combat/assistance with NonPlayerCharacters (NPC) - see Unit::_IsValidAttackTarget, Unit::_IsValidAssistTarget - UNIT_FLAG_LOOTING = 0x00000400, // loot animation - UNIT_FLAG_PET_IN_COMBAT = 0x00000800, // in combat?, 2.0.8 - UNIT_FLAG_PVP = 0x00001000, // changed in 3.0.3 - UNIT_FLAG_SILENCED = 0x00002000, // silenced, 2.1.1 - UNIT_FLAG_CANNOT_SWIM = 0x00004000, // 2.0.8 - UNIT_FLAG_UNK_15 = 0x00008000, - UNIT_FLAG_UNK_16 = 0x00010000, - UNIT_FLAG_PACIFIED = 0x00020000, // 3.0.3 ok - UNIT_FLAG_STUNNED = 0x00040000, // 3.0.3 ok - UNIT_FLAG_IN_COMBAT = 0x00080000, - UNIT_FLAG_TAXI_FLIGHT = 0x00100000, // disable casting at client side spell not allowed by taxi flight (mounted?), probably used with 0x4 flag - UNIT_FLAG_DISARMED = 0x00200000, // 3.0.3, disable melee spells casting..., "Required melee weapon" added to melee spells tooltip. - UNIT_FLAG_CONFUSED = 0x00400000, - UNIT_FLAG_FLEEING = 0x00800000, - UNIT_FLAG_PLAYER_CONTROLLED = 0x01000000, // used in spell Eyes of the Beast for pet... let attack by controlled creature - UNIT_FLAG_NOT_SELECTABLE = 0x02000000, - UNIT_FLAG_SKINNABLE = 0x04000000, - UNIT_FLAG_MOUNT = 0x08000000, - UNIT_FLAG_UNK_28 = 0x10000000, - UNIT_FLAG_UNK_29 = 0x20000000, // used in Feing Death spell - UNIT_FLAG_SHEATHE = 0x40000000, - UNIT_FLAG_UNK_31 = 0x80000000, - MAX_UNIT_FLAGS = 33 -}; - -// Value masks for UNIT_FIELD_FLAGS_2 -enum UnitFlags2 -{ - UNIT_FLAG2_FEIGN_DEATH = 0x00000001, - UNIT_FLAG2_UNK1 = 0x00000002, // Hide unit model (show only player equip) - UNIT_FLAG2_IGNORE_REPUTATION = 0x00000004, - UNIT_FLAG2_COMPREHEND_LANG = 0x00000008, - UNIT_FLAG2_MIRROR_IMAGE = 0x00000010, - UNIT_FLAG2_INSTANTLY_APPEAR_MODEL = 0x00000020, // Unit model instantly appears when summoned (does not fade in) - UNIT_FLAG2_FORCE_MOVEMENT = 0x00000040, - UNIT_FLAG2_DISARM_OFFHAND = 0x00000080, - UNIT_FLAG2_DISABLE_PRED_STATS = 0x00000100, // Player has disabled predicted stats (Used by raid frames) - UNIT_FLAG2_DISARM_RANGED = 0x00000400, // this does not disable ranged weapon display (maybe additional flag needed?) - UNIT_FLAG2_REGENERATE_POWER = 0x00000800, - UNIT_FLAG2_RESTRICT_PARTY_INTERACTION = 0x00001000, // Restrict interaction to party or raid - UNIT_FLAG2_PREVENT_SPELL_CLICK = 0x00002000, // Prevent spellclick - UNIT_FLAG2_ALLOW_ENEMY_INTERACT = 0x00004000, - UNIT_FLAG2_DISABLE_TURN = 0x00008000, - UNIT_FLAG2_UNK2 = 0x00010000, - UNIT_FLAG2_PLAY_DEATH_ANIM = 0x00020000, // Plays special death animation upon death - UNIT_FLAG2_ALLOW_CHEAT_SPELLS = 0x00040000, // Allows casting spells with AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL - UNIT_FLAG2_NO_ACTIONS = 0x00800000 -}; - -/// Non Player Character flags -enum NPCFlags : uint64 -{ - UNIT_NPC_FLAG_NONE = 0x0000000000, - UNIT_NPC_FLAG_GOSSIP = 0x0000000001, // 100% - UNIT_NPC_FLAG_QUESTGIVER = 0x0000000002, // 100% - UNIT_NPC_FLAG_UNK1 = 0x0000000004, - UNIT_NPC_FLAG_UNK2 = 0x0000000008, - UNIT_NPC_FLAG_TRAINER = 0x0000000010, // 100% - UNIT_NPC_FLAG_TRAINER_CLASS = 0x0000000020, // 100% - UNIT_NPC_FLAG_TRAINER_PROFESSION = 0x0000000040, // 100% - UNIT_NPC_FLAG_VENDOR = 0x0000000080, // 100% - UNIT_NPC_FLAG_VENDOR_AMMO = 0x0000000100, // 100%, general goods vendor - UNIT_NPC_FLAG_VENDOR_FOOD = 0x0000000200, // 100% - UNIT_NPC_FLAG_VENDOR_POISON = 0x0000000400, // guessed - UNIT_NPC_FLAG_VENDOR_REAGENT = 0x0000000800, // 100% - UNIT_NPC_FLAG_REPAIR = 0x0000001000, // 100% - UNIT_NPC_FLAG_FLIGHTMASTER = 0x0000002000, // 100% - UNIT_NPC_FLAG_SPIRITHEALER = 0x0000004000, // guessed - UNIT_NPC_FLAG_SPIRITGUIDE = 0x0000008000, // guessed - UNIT_NPC_FLAG_INNKEEPER = 0x0000010000, // 100% - UNIT_NPC_FLAG_BANKER = 0x0000020000, // 100% - UNIT_NPC_FLAG_PETITIONER = 0x0000040000, // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions - UNIT_NPC_FLAG_TABARDDESIGNER = 0x0000080000, // 100% - UNIT_NPC_FLAG_BATTLEMASTER = 0x0000100000, // 100% - UNIT_NPC_FLAG_AUCTIONEER = 0x0000200000, // 100% - UNIT_NPC_FLAG_STABLEMASTER = 0x0000400000, // 100% - UNIT_NPC_FLAG_GUILD_BANKER = 0x0000800000, // cause client to send 997 opcode - UNIT_NPC_FLAG_SPELLCLICK = 0x0001000000, // cause client to send 1015 opcode (spell click) - UNIT_NPC_FLAG_PLAYER_VEHICLE = 0x0002000000, // players with mounts that have vehicle data should have it set - UNIT_NPC_FLAG_MAILBOX = 0x0004000000, // mailbox - UNIT_NPC_FLAG_ARTIFACT_POWER_RESPEC = 0x0008000000, // artifact powers reset - UNIT_NPC_FLAG_TRANSMOGRIFIER = 0x0010000000, // transmogrification - UNIT_NPC_FLAG_VAULTKEEPER = 0x0020000000, // void storage - UNIT_NPC_FLAG_BLACK_MARKET = 0x0080000000, // black market - UNIT_NPC_FLAG_ITEM_UPGRADE_MASTER = 0x0100000000, - UNIT_NPC_FLAG_GARRISON_ARCHITECT = 0x0200000000, - UNIT_NPC_FLAG_STEERING = 0x0400000000, - UNIT_NPC_FLAG_SHIPMENT_CRAFTER = 0x1000000000, - UNIT_NPC_FLAG_GARRISON_MISSION_NPC = 0x2000000000, - UNIT_NPC_FLAG_TRADESKILL_NPC = 0x4000000000, - UNIT_NPC_FLAG_BLACK_MARKET_VIEW = 0x8000000000 -}; - -enum MovementFlags -{ - MOVEMENTFLAG_NONE = 0x00000000, - MOVEMENTFLAG_FORWARD = 0x00000001, - MOVEMENTFLAG_BACKWARD = 0x00000002, - MOVEMENTFLAG_STRAFE_LEFT = 0x00000004, - MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008, - MOVEMENTFLAG_LEFT = 0x00000010, - MOVEMENTFLAG_RIGHT = 0x00000020, - MOVEMENTFLAG_PITCH_UP = 0x00000040, - MOVEMENTFLAG_PITCH_DOWN = 0x00000080, - MOVEMENTFLAG_WALKING = 0x00000100, // Walking - MOVEMENTFLAG_DISABLE_GRAVITY = 0x00000200, // Former MOVEMENTFLAG_LEVITATING. This is used when walking is not possible. - MOVEMENTFLAG_ROOT = 0x00000400, // Must not be set along with MOVEMENTFLAG_MASK_MOVING - MOVEMENTFLAG_FALLING = 0x00000800, // damage dealt on that type of falling - MOVEMENTFLAG_FALLING_FAR = 0x00001000, - MOVEMENTFLAG_PENDING_STOP = 0x00002000, - MOVEMENTFLAG_PENDING_STRAFE_STOP = 0x00004000, - MOVEMENTFLAG_PENDING_FORWARD = 0x00008000, - MOVEMENTFLAG_PENDING_BACKWARD = 0x00010000, - MOVEMENTFLAG_PENDING_STRAFE_LEFT = 0x00020000, - MOVEMENTFLAG_PENDING_STRAFE_RIGHT = 0x00040000, - MOVEMENTFLAG_PENDING_ROOT = 0x00080000, - MOVEMENTFLAG_SWIMMING = 0x00100000, // appears with fly flag also - MOVEMENTFLAG_ASCENDING = 0x00200000, // press "space" when flying - MOVEMENTFLAG_DESCENDING = 0x00400000, - MOVEMENTFLAG_CAN_FLY = 0x00800000, // Appears when unit can fly AND also walk - MOVEMENTFLAG_FLYING = 0x01000000, // unit is actually flying. pretty sure this is only used for players. creatures use disable_gravity - MOVEMENTFLAG_SPLINE_ELEVATION = 0x02000000, // used for flight paths - MOVEMENTFLAG_WATERWALKING = 0x04000000, // prevent unit from falling through water - MOVEMENTFLAG_FALLING_SLOW = 0x08000000, // active rogue safe fall spell (passive) - MOVEMENTFLAG_HOVER = 0x10000000, // hover, cannot jump - MOVEMENTFLAG_DISABLE_COLLISION = 0x20000000, - - MOVEMENTFLAG_MASK_MOVING = - MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_BACKWARD | MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT | - MOVEMENTFLAG_FALLING | MOVEMENTFLAG_ASCENDING | MOVEMENTFLAG_DESCENDING, - - MOVEMENTFLAG_MASK_TURNING = - MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT | MOVEMENTFLAG_PITCH_UP | MOVEMENTFLAG_PITCH_DOWN, - - MOVEMENTFLAG_MASK_MOVING_FLY = - MOVEMENTFLAG_FLYING | MOVEMENTFLAG_ASCENDING | MOVEMENTFLAG_DESCENDING, - - // Movement flags allowed for creature in CreateObject - we need to keep all other enabled serverside - // to properly calculate all movement - MOVEMENTFLAG_MASK_CREATURE_ALLOWED = - MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_ROOT | MOVEMENTFLAG_SWIMMING | - MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_WATERWALKING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_HOVER | MOVEMENTFLAG_DISABLE_COLLISION, - - /// @todo if needed: add more flags to this masks that are exclusive to players - MOVEMENTFLAG_MASK_PLAYER_ONLY = - MOVEMENTFLAG_FLYING, - - /// Movement flags that have change status opcodes associated for players - MOVEMENTFLAG_MASK_HAS_PLAYER_STATUS_OPCODE = MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_ROOT | - MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_WATERWALKING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_HOVER | MOVEMENTFLAG_DISABLE_COLLISION -}; - -enum MovementFlags2 -{ - MOVEMENTFLAG2_NONE = 0x00000000, - MOVEMENTFLAG2_NO_STRAFE = 0x00000001, - MOVEMENTFLAG2_NO_JUMPING = 0x00000002, - MOVEMENTFLAG2_FULL_SPEED_TURNING = 0x00000004, - MOVEMENTFLAG2_FULL_SPEED_PITCHING = 0x00000008, - MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING = 0x00000010, - MOVEMENTFLAG2_IS_VEHICLE_EXIT_VOLUNTARY = 0x00000020, - MOVEMENTFLAG2_JUMP_SPLINE_IN_AIR = 0x00000040, - MOVEMENTFLAG2_ANIM_TIER_IN_TRANS = 0x00000080, - MOVEMENTFLAG2_WATERWALKING_FULL_PITCH = 0x00000100, // will always waterwalk, even if facing the camera directly down - MOVEMENTFLAG2_VEHICLE_PASSENGER_IS_TRANSITION_ALLOWED = 0x00000200, - MOVEMENTFLAG2_CAN_SWIM_TO_FLY_TRANS = 0x00000400, - MOVEMENTFLAG2_UNK11 = 0x00000800, // terrain normal calculation is disabled if this flag is not present, client automatically handles setting this flag - MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING = 0x00001000, - MOVEMENTFLAG2_UNK13 = 0x00002000, // set automatically by the client for aura 373 - MOVEMENTFLAG2_IGNORE_MOVEMENT_FORCES = 0x00004000, - MOVEMENTFLAG2_UNK15 = 0x00008000, - MOVEMENTFLAG2_CAN_DOUBLE_JUMP = 0x00010000, - MOVEMENTFLAG2_DOUBLE_JUMP = 0x00020000, - // these flags cannot be sent (18 bits in packet) - MOVEMENTFLAG2_UNK18 = 0x00040000, - MOVEMENTFLAG2_UNK19 = 0x00080000, - MOVEMENTFLAG2_INTERPOLATED_MOVEMENT = 0x00100000, - MOVEMENTFLAG2_INTERPOLATED_TURNING = 0x00200000, - MOVEMENTFLAG2_INTERPOLATED_PITCHING = 0x00400000 -}; - enum UnitTypeMask { UNIT_MASK_NONE = 0x00000000, @@ -1134,13 +848,6 @@ struct RedirectThreatInfo } }; -#define MAX_DECLINED_NAME_CASES 5 - -struct DeclinedName -{ - std::string name[MAX_DECLINED_NAME_CASES]; -}; - enum CurrentSpellTypes { CURRENT_MELEE_SPELL = 0, diff --git a/src/server/game/Entities/Unit/UnitDefines.h b/src/server/game/Entities/Unit/UnitDefines.h new file mode 100644 index 00000000000..03bff121ebf --- /dev/null +++ b/src/server/game/Entities/Unit/UnitDefines.h @@ -0,0 +1,322 @@ +/* + * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef UnitDefines_h__ +#define UnitDefines_h__ + +#include "Define.h" +#include <string> + +#define DEFAULT_COMBAT_REACH 1.5f +#define MIN_MELEE_REACH 2.0f +#define NOMINAL_MELEE_RANGE 5.0f +#define MELEE_RANGE (NOMINAL_MELEE_RANGE - MIN_MELEE_REACH * 2) //center to center for players +#define BASE_MINDAMAGE 1.0f +#define BASE_MAXDAMAGE 2.0f +#define BASE_ATTACK_TIME 2000 + +// byte value (UNIT_FIELD_BYTES_1, 0) +enum UnitStandStateType : uint8 +{ + UNIT_STAND_STATE_STAND = 0, + UNIT_STAND_STATE_SIT = 1, + UNIT_STAND_STATE_SIT_CHAIR = 2, + UNIT_STAND_STATE_SLEEP = 3, + UNIT_STAND_STATE_SIT_LOW_CHAIR = 4, + UNIT_STAND_STATE_SIT_MEDIUM_CHAIR = 5, + UNIT_STAND_STATE_SIT_HIGH_CHAIR = 6, + UNIT_STAND_STATE_DEAD = 7, + UNIT_STAND_STATE_KNEEL = 8, + UNIT_STAND_STATE_SUBMERGED = 9 +}; + +// byte flag value (UNIT_FIELD_BYTES_1, 2) +enum UnitStandFlags : uint8 +{ + UNIT_STAND_FLAGS_UNK1 = 0x01, + UNIT_STAND_FLAGS_CREEP = 0x02, + UNIT_STAND_FLAGS_UNTRACKABLE = 0x04, + UNIT_STAND_FLAGS_UNK4 = 0x08, + UNIT_STAND_FLAGS_UNK5 = 0x10, + UNIT_STAND_FLAGS_ALL = 0xFF +}; + +enum UnitBytes0Offsets : uint8 +{ + UNIT_BYTES_0_OFFSET_RACE = 0, + UNIT_BYTES_0_OFFSET_CLASS = 1, + UNIT_BYTES_0_OFFSET_PLAYER_CLASS = 2, + UNIT_BYTES_0_OFFSET_GENDER = 3 +}; + +enum UnitBytes1Offsets : uint8 +{ + UNIT_BYTES_1_OFFSET_STAND_STATE = 0, + UNIT_BYTES_1_OFFSET_PET_TALENTS = 1, // unused + UNIT_BYTES_1_OFFSET_VIS_FLAG = 2, + UNIT_BYTES_1_OFFSET_ANIM_TIER = 3 +}; + +enum UnitBytes2Offsets : uint8 +{ + UNIT_BYTES_2_OFFSET_SHEATH_STATE = 0, + UNIT_BYTES_2_OFFSET_PVP_FLAG = 1, + UNIT_BYTES_2_OFFSET_PET_FLAGS = 2, + UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM = 3 +}; + +// byte flags value (UNIT_FIELD_BYTES_1, 3) +enum UnitBytes1_Flags : uint8 +{ + UNIT_BYTE1_FLAG_ALWAYS_STAND = 0x01, + UNIT_BYTE1_FLAG_HOVER = 0x02, + UNIT_BYTE1_FLAG_UNK_3 = 0x04, + UNIT_BYTE1_FLAG_ALL = 0xFF +}; + +// low byte (0 from 0..3) of UNIT_FIELD_BYTES_2 +enum SheathState : uint8 +{ + SHEATH_STATE_UNARMED = 0, // non prepared weapon + SHEATH_STATE_MELEE = 1, // prepared melee weapon + SHEATH_STATE_RANGED = 2 // prepared ranged weapon +}; + +#define MAX_SHEATH_STATE 3 + +// byte (1 from 0..3) of UNIT_FIELD_BYTES_2 +enum UnitPVPStateFlags : uint8 +{ + UNIT_BYTE2_FLAG_PVP = 0x01, + UNIT_BYTE2_FLAG_UNK1 = 0x02, + UNIT_BYTE2_FLAG_FFA_PVP = 0x04, + UNIT_BYTE2_FLAG_SANCTUARY = 0x08, + UNIT_BYTE2_FLAG_UNK4 = 0x10, + UNIT_BYTE2_FLAG_UNK5 = 0x20, + UNIT_BYTE2_FLAG_UNK6 = 0x40, + UNIT_BYTE2_FLAG_UNK7 = 0x80 +}; + +// byte (2 from 0..3) of UNIT_FIELD_BYTES_2 +enum UnitRename : uint8 +{ + UNIT_CAN_BE_RENAMED = 0x01, + UNIT_CAN_BE_ABANDONED = 0x02 +}; + +// Value masks for UNIT_FIELD_FLAGS +enum UnitFlags : uint32 +{ + UNIT_FLAG_SERVER_CONTROLLED = 0x00000001, // set only when unit movement is controlled by server - by SPLINE/MONSTER_MOVE packets, together with UNIT_FLAG_STUNNED; only set to units controlled by client; client function CGUnit_C::IsClientControlled returns false when set for owner + UNIT_FLAG_NON_ATTACKABLE = 0x00000002, // not attackable + UNIT_FLAG_REMOVE_CLIENT_CONTROL = 0x00000004, // This is a legacy flag used to disable movement player's movement while controlling other units, SMSG_CLIENT_CONTROL replaces this functionality clientside now. CONFUSED and FLEEING flags have the same effect on client movement asDISABLE_MOVE_CONTROL in addition to preventing spell casts/autoattack (they all allow climbing steeper hills and emotes while moving) + UNIT_FLAG_PVP_ATTACKABLE = 0x00000008, // allow apply pvp rules to attackable state in addition to faction dependent state + UNIT_FLAG_RENAME = 0x00000010, + UNIT_FLAG_PREPARATION = 0x00000020, // don't take reagents for spells with SPELL_ATTR5_NO_REAGENT_WHILE_PREP + UNIT_FLAG_UNK_6 = 0x00000040, + UNIT_FLAG_NOT_ATTACKABLE_1 = 0x00000080, // ?? (UNIT_FLAG_PVP_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1) is NON_PVP_ATTACKABLE + UNIT_FLAG_IMMUNE_TO_PC = 0x00000100, // disables combat/assistance with PlayerCharacters (PC) - see Unit::_IsValidAttackTarget, Unit::_IsValidAssistTarget + UNIT_FLAG_IMMUNE_TO_NPC = 0x00000200, // disables combat/assistance with NonPlayerCharacters (NPC) - see Unit::_IsValidAttackTarget, Unit::_IsValidAssistTarget + UNIT_FLAG_LOOTING = 0x00000400, // loot animation + UNIT_FLAG_PET_IN_COMBAT = 0x00000800, // in combat?, 2.0.8 + UNIT_FLAG_PVP = 0x00001000, // changed in 3.0.3 + UNIT_FLAG_SILENCED = 0x00002000, // silenced, 2.1.1 + UNIT_FLAG_CANNOT_SWIM = 0x00004000, // 2.0.8 + UNIT_FLAG_UNK_15 = 0x00008000, + UNIT_FLAG_UNK_16 = 0x00010000, + UNIT_FLAG_PACIFIED = 0x00020000, // 3.0.3 ok + UNIT_FLAG_STUNNED = 0x00040000, // 3.0.3 ok + UNIT_FLAG_IN_COMBAT = 0x00080000, + UNIT_FLAG_TAXI_FLIGHT = 0x00100000, // disable casting at client side spell not allowed by taxi flight (mounted?), probably used with 0x4 flag + UNIT_FLAG_DISARMED = 0x00200000, // 3.0.3, disable melee spells casting..., "Required melee weapon" added to melee spells tooltip. + UNIT_FLAG_CONFUSED = 0x00400000, + UNIT_FLAG_FLEEING = 0x00800000, + UNIT_FLAG_PLAYER_CONTROLLED = 0x01000000, // used in spell Eyes of the Beast for pet... let attack by controlled creature + UNIT_FLAG_NOT_SELECTABLE = 0x02000000, + UNIT_FLAG_SKINNABLE = 0x04000000, + UNIT_FLAG_MOUNT = 0x08000000, + UNIT_FLAG_UNK_28 = 0x10000000, + UNIT_FLAG_UNK_29 = 0x20000000, // used in Feing Death spell + UNIT_FLAG_SHEATHE = 0x40000000, + UNIT_FLAG_UNK_31 = 0x80000000, + MAX_UNIT_FLAGS = 33 +}; + +// Value masks for UNIT_FIELD_FLAGS_2 +enum UnitFlags2 : uint32 +{ + UNIT_FLAG2_FEIGN_DEATH = 0x00000001, + UNIT_FLAG2_UNK1 = 0x00000002, // Hide unit model (show only player equip) + UNIT_FLAG2_IGNORE_REPUTATION = 0x00000004, + UNIT_FLAG2_COMPREHEND_LANG = 0x00000008, + UNIT_FLAG2_MIRROR_IMAGE = 0x00000010, + UNIT_FLAG2_INSTANTLY_APPEAR_MODEL = 0x00000020, // Unit model instantly appears when summoned (does not fade in) + UNIT_FLAG2_FORCE_MOVEMENT = 0x00000040, + UNIT_FLAG2_DISARM_OFFHAND = 0x00000080, + UNIT_FLAG2_DISABLE_PRED_STATS = 0x00000100, // Player has disabled predicted stats (Used by raid frames) + UNIT_FLAG2_DISARM_RANGED = 0x00000400, // this does not disable ranged weapon display (maybe additional flag needed?) + UNIT_FLAG2_REGENERATE_POWER = 0x00000800, + UNIT_FLAG2_RESTRICT_PARTY_INTERACTION = 0x00001000, // Restrict interaction to party or raid + UNIT_FLAG2_PREVENT_SPELL_CLICK = 0x00002000, // Prevent spellclick + UNIT_FLAG2_ALLOW_ENEMY_INTERACT = 0x00004000, + UNIT_FLAG2_DISABLE_TURN = 0x00008000, + UNIT_FLAG2_UNK2 = 0x00010000, + UNIT_FLAG2_PLAY_DEATH_ANIM = 0x00020000, // Plays special death animation upon death + UNIT_FLAG2_ALLOW_CHEAT_SPELLS = 0x00040000, // Allows casting spells with AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL + UNIT_FLAG2_NO_ACTIONS = 0x00800000 +}; + +/// Non Player Character flags +enum NPCFlags : uint64 +{ + UNIT_NPC_FLAG_NONE = 0x0000000000, + UNIT_NPC_FLAG_GOSSIP = 0x0000000001, // 100% + UNIT_NPC_FLAG_QUESTGIVER = 0x0000000002, // 100% + UNIT_NPC_FLAG_UNK1 = 0x0000000004, + UNIT_NPC_FLAG_UNK2 = 0x0000000008, + UNIT_NPC_FLAG_TRAINER = 0x0000000010, // 100% + UNIT_NPC_FLAG_TRAINER_CLASS = 0x0000000020, // 100% + UNIT_NPC_FLAG_TRAINER_PROFESSION = 0x0000000040, // 100% + UNIT_NPC_FLAG_VENDOR = 0x0000000080, // 100% + UNIT_NPC_FLAG_VENDOR_AMMO = 0x0000000100, // 100%, general goods vendor + UNIT_NPC_FLAG_VENDOR_FOOD = 0x0000000200, // 100% + UNIT_NPC_FLAG_VENDOR_POISON = 0x0000000400, // guessed + UNIT_NPC_FLAG_VENDOR_REAGENT = 0x0000000800, // 100% + UNIT_NPC_FLAG_REPAIR = 0x0000001000, // 100% + UNIT_NPC_FLAG_FLIGHTMASTER = 0x0000002000, // 100% + UNIT_NPC_FLAG_SPIRITHEALER = 0x0000004000, // guessed + UNIT_NPC_FLAG_SPIRITGUIDE = 0x0000008000, // guessed + UNIT_NPC_FLAG_INNKEEPER = 0x0000010000, // 100% + UNIT_NPC_FLAG_BANKER = 0x0000020000, // 100% + UNIT_NPC_FLAG_PETITIONER = 0x0000040000, // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions + UNIT_NPC_FLAG_TABARDDESIGNER = 0x0000080000, // 100% + UNIT_NPC_FLAG_BATTLEMASTER = 0x0000100000, // 100% + UNIT_NPC_FLAG_AUCTIONEER = 0x0000200000, // 100% + UNIT_NPC_FLAG_STABLEMASTER = 0x0000400000, // 100% + UNIT_NPC_FLAG_GUILD_BANKER = 0x0000800000, // cause client to send 997 opcode + UNIT_NPC_FLAG_SPELLCLICK = 0x0001000000, // cause client to send 1015 opcode (spell click) + UNIT_NPC_FLAG_PLAYER_VEHICLE = 0x0002000000, // players with mounts that have vehicle data should have it set + UNIT_NPC_FLAG_MAILBOX = 0x0004000000, // mailbox + UNIT_NPC_FLAG_ARTIFACT_POWER_RESPEC = 0x0008000000, // artifact powers reset + UNIT_NPC_FLAG_TRANSMOGRIFIER = 0x0010000000, // transmogrification + UNIT_NPC_FLAG_VAULTKEEPER = 0x0020000000, // void storage + UNIT_NPC_FLAG_BLACK_MARKET = 0x0080000000, // black market + UNIT_NPC_FLAG_ITEM_UPGRADE_MASTER = 0x0100000000, + UNIT_NPC_FLAG_GARRISON_ARCHITECT = 0x0200000000, + UNIT_NPC_FLAG_STEERING = 0x0400000000, + UNIT_NPC_FLAG_SHIPMENT_CRAFTER = 0x1000000000, + UNIT_NPC_FLAG_GARRISON_MISSION_NPC = 0x2000000000, + UNIT_NPC_FLAG_TRADESKILL_NPC = 0x4000000000, + UNIT_NPC_FLAG_BLACK_MARKET_VIEW = 0x8000000000 +}; + +enum MovementFlags : uint32 +{ + MOVEMENTFLAG_NONE = 0x00000000, + MOVEMENTFLAG_FORWARD = 0x00000001, + MOVEMENTFLAG_BACKWARD = 0x00000002, + MOVEMENTFLAG_STRAFE_LEFT = 0x00000004, + MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008, + MOVEMENTFLAG_LEFT = 0x00000010, + MOVEMENTFLAG_RIGHT = 0x00000020, + MOVEMENTFLAG_PITCH_UP = 0x00000040, + MOVEMENTFLAG_PITCH_DOWN = 0x00000080, + MOVEMENTFLAG_WALKING = 0x00000100, // Walking + MOVEMENTFLAG_DISABLE_GRAVITY = 0x00000200, // Former MOVEMENTFLAG_LEVITATING. This is used when walking is not possible. + MOVEMENTFLAG_ROOT = 0x00000400, // Must not be set along with MOVEMENTFLAG_MASK_MOVING + MOVEMENTFLAG_FALLING = 0x00000800, // damage dealt on that type of falling + MOVEMENTFLAG_FALLING_FAR = 0x00001000, + MOVEMENTFLAG_PENDING_STOP = 0x00002000, + MOVEMENTFLAG_PENDING_STRAFE_STOP = 0x00004000, + MOVEMENTFLAG_PENDING_FORWARD = 0x00008000, + MOVEMENTFLAG_PENDING_BACKWARD = 0x00010000, + MOVEMENTFLAG_PENDING_STRAFE_LEFT = 0x00020000, + MOVEMENTFLAG_PENDING_STRAFE_RIGHT = 0x00040000, + MOVEMENTFLAG_PENDING_ROOT = 0x00080000, + MOVEMENTFLAG_SWIMMING = 0x00100000, // appears with fly flag also + MOVEMENTFLAG_ASCENDING = 0x00200000, // press "space" when flying + MOVEMENTFLAG_DESCENDING = 0x00400000, + MOVEMENTFLAG_CAN_FLY = 0x00800000, // Appears when unit can fly AND also walk + MOVEMENTFLAG_FLYING = 0x01000000, // unit is actually flying. pretty sure this is only used for players. creatures use disable_gravity + MOVEMENTFLAG_SPLINE_ELEVATION = 0x02000000, // used for flight paths + MOVEMENTFLAG_WATERWALKING = 0x04000000, // prevent unit from falling through water + MOVEMENTFLAG_FALLING_SLOW = 0x08000000, // active rogue safe fall spell (passive) + MOVEMENTFLAG_HOVER = 0x10000000, // hover, cannot jump + MOVEMENTFLAG_DISABLE_COLLISION = 0x20000000, + + MOVEMENTFLAG_MASK_MOVING = + MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_BACKWARD | MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT | + MOVEMENTFLAG_FALLING | MOVEMENTFLAG_ASCENDING | MOVEMENTFLAG_DESCENDING, + + MOVEMENTFLAG_MASK_TURNING = + MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT | MOVEMENTFLAG_PITCH_UP | MOVEMENTFLAG_PITCH_DOWN, + + MOVEMENTFLAG_MASK_MOVING_FLY = + MOVEMENTFLAG_FLYING | MOVEMENTFLAG_ASCENDING | MOVEMENTFLAG_DESCENDING, + + // Movement flags allowed for creature in CreateObject - we need to keep all other enabled serverside + // to properly calculate all movement + MOVEMENTFLAG_MASK_CREATURE_ALLOWED = + MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_ROOT | MOVEMENTFLAG_SWIMMING | + MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_WATERWALKING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_HOVER | MOVEMENTFLAG_DISABLE_COLLISION, + + /// @todo if needed: add more flags to this masks that are exclusive to players + MOVEMENTFLAG_MASK_PLAYER_ONLY = + MOVEMENTFLAG_FLYING, + + /// Movement flags that have change status opcodes associated for players + MOVEMENTFLAG_MASK_HAS_PLAYER_STATUS_OPCODE = MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_ROOT | + MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_WATERWALKING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_HOVER | MOVEMENTFLAG_DISABLE_COLLISION +}; + +enum MovementFlags2 : uint32 +{ + MOVEMENTFLAG2_NONE = 0x00000000, + MOVEMENTFLAG2_NO_STRAFE = 0x00000001, + MOVEMENTFLAG2_NO_JUMPING = 0x00000002, + MOVEMENTFLAG2_FULL_SPEED_TURNING = 0x00000004, + MOVEMENTFLAG2_FULL_SPEED_PITCHING = 0x00000008, + MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING = 0x00000010, + MOVEMENTFLAG2_IS_VEHICLE_EXIT_VOLUNTARY = 0x00000020, + MOVEMENTFLAG2_JUMP_SPLINE_IN_AIR = 0x00000040, + MOVEMENTFLAG2_ANIM_TIER_IN_TRANS = 0x00000080, + MOVEMENTFLAG2_WATERWALKING_FULL_PITCH = 0x00000100, // will always waterwalk, even if facing the camera directly down + MOVEMENTFLAG2_VEHICLE_PASSENGER_IS_TRANSITION_ALLOWED = 0x00000200, + MOVEMENTFLAG2_CAN_SWIM_TO_FLY_TRANS = 0x00000400, + MOVEMENTFLAG2_UNK11 = 0x00000800, // terrain normal calculation is disabled if this flag is not present, client automatically handles setting this flag + MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING = 0x00001000, + MOVEMENTFLAG2_UNK13 = 0x00002000, // set automatically by the client for aura 373 + MOVEMENTFLAG2_IGNORE_MOVEMENT_FORCES = 0x00004000, + MOVEMENTFLAG2_UNK15 = 0x00008000, + MOVEMENTFLAG2_CAN_DOUBLE_JUMP = 0x00010000, + MOVEMENTFLAG2_DOUBLE_JUMP = 0x00020000, + // these flags cannot be sent (18 bits in packet) + MOVEMENTFLAG2_UNK18 = 0x00040000, + MOVEMENTFLAG2_UNK19 = 0x00080000, + MOVEMENTFLAG2_INTERPOLATED_MOVEMENT = 0x00100000, + MOVEMENTFLAG2_INTERPOLATED_TURNING = 0x00200000, + MOVEMENTFLAG2_INTERPOLATED_PITCHING = 0x00400000 +}; + +#define MAX_DECLINED_NAME_CASES 5 + +struct DeclinedName +{ + std::string name[MAX_DECLINED_NAME_CASES]; +}; + +#endif // UnitDefines_h__ |
