diff options
| author | Shauren <shauren.trinity@gmail.com> | 2017-05-21 23:18:43 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2017-05-21 23:18:43 +0200 |
| commit | 3d7c2ef88f2ca3293a1df0411ad49e3eb5a96079 (patch) | |
| tree | d9a92cf30fcf560d837e2b3b0a212a6834534f46 /src/server/game/Entities | |
| parent | 3cb8f532dae1062c5f5bcda1b980463da99fe547 (diff) | |
Core/Game: Include cleanup, part 4 - packets and largest headers (after preprocessing, except player/objectmgr)
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/AreaTrigger/AreaTrigger.cpp | 1 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 8 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 23 | ||||
| -rw-r--r-- | src/server/game/Entities/Item/Item.h | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/MovementInfo.h | 111 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/Object.h | 134 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/ObjectDefines.h | 68 | ||||
| -rw-r--r-- | src/server/game/Entities/Pet/Pet.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/EquipementSet.h | 67 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 23 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.h | 50 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 33 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 54 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/UnitDefines.h | 30 |
14 files changed, 307 insertions, 299 deletions
diff --git a/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp b/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp index bfe8018af08..555a3aa581f 100644 --- a/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp +++ b/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp @@ -34,6 +34,7 @@ #include "Transport.h" #include "Unit.h" #include "UpdateData.h" +#include <G3D/AABox.h> AreaTrigger::AreaTrigger() : WorldObject(false), MapObject(), _duration(0), _totalDuration(0), _timeSinceCreated(0), _previousCheckOrientation(std::numeric_limits<float>::infinity()), diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 9c8985e63c3..f3b40225078 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1957,8 +1957,8 @@ SpellInfo const* Creature::reachWithSpellAttack(Unit* victim) if (bcontinue) continue; - std::vector<SpellInfo::CostData> costs = spellInfo->CalcPowerCost(this, SpellSchoolMask(spellInfo->SchoolMask)); - auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; }); + std::vector<SpellPowerCost> costs = spellInfo->CalcPowerCost(this, SpellSchoolMask(spellInfo->SchoolMask)); + auto m = std::find_if(costs.begin(), costs.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_MANA; }); if (m != costs.end()) if (m->Amount > GetPower(POWER_MANA)) continue; @@ -2005,8 +2005,8 @@ SpellInfo const* Creature::reachWithSpellCure(Unit* victim) if (bcontinue) continue; - std::vector<SpellInfo::CostData> costs = spellInfo->CalcPowerCost(this, SpellSchoolMask(spellInfo->SchoolMask)); - auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; }); + std::vector<SpellPowerCost> costs = spellInfo->CalcPowerCost(this, SpellSchoolMask(spellInfo->SchoolMask)); + auto m = std::find_if(costs.begin(), costs.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_MANA; }); if (m != costs.end()) if (m->Amount > GetPower(POWER_MANA)) continue; diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index e5951dec833..64c0ed1711c 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -21,7 +21,6 @@ #include "Common.h" #include "SharedDefines.h" -#include "Unit.h" #include "Object.h" #include "Loot.h" #include "DatabaseEnvFwd.h" @@ -31,6 +30,7 @@ class GameObjectAI; class Group; class Transport; +enum TriggerCastFlags : uint32; // from `gameobject_template` struct GameObjectTemplate @@ -881,19 +881,6 @@ struct GameObjectAddon typedef std::unordered_map<ObjectGuid::LowType, GameObjectAddon> GameObjectAddonContainer; -// client side GO show states -enum GOState -{ - GO_STATE_ACTIVE = 0, // show in world as used and not reset (closed door open) - GO_STATE_READY = 1, // show in world as ready (closed door close) - GO_STATE_ACTIVE_ALTERNATIVE = 2, // show in world as used in alt way and not reset (closed door open by cannon fire) - GO_STATE_TRANSPORT_ACTIVE = 24, - GO_STATE_TRANSPORT_STOPPED = 25 -}; - -#define MAX_GO_STATE 3 -#define MAX_GO_STATE_TRANSPORT_STOP_FRAMES 9 - // from `gameobject` struct GameObjectData { @@ -1095,13 +1082,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> bool IsAlwaysVisibleFor(WorldObject const* seer) const override; bool IsInvisibleDueToDespawn() const override; - uint8 getLevelForTarget(WorldObject const* target) const override - { - if (Unit* owner = GetOwner()) - return owner->getLevelForTarget(target); - - return 1; - } + uint8 getLevelForTarget(WorldObject const* target) const override; GameObject* LookupFishingHoleAround(float range); diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index 78759928c54..76e1ef5258b 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -45,7 +45,7 @@ struct ItemSetEffect std::unordered_set<ItemSetSpellEntry const*> SetBonuses; }; -enum InventoryResult +enum InventoryResult : uint8 { EQUIP_ERR_OK = 0, EQUIP_ERR_CANT_EQUIP_LEVEL_I = 1, // You must reach level %d to use that item. diff --git a/src/server/game/Entities/Object/MovementInfo.h b/src/server/game/Entities/Object/MovementInfo.h new file mode 100644 index 00000000000..9d95cf7ce97 --- /dev/null +++ b/src/server/game/Entities/Object/MovementInfo.h @@ -0,0 +1,111 @@ +/* + * 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 MovementInfo_h__ +#define MovementInfo_h__ + +#include "ObjectGuid.h" +#include "Position.h" + +struct MovementInfo +{ + // common + ObjectGuid guid; + uint32 flags; + uint32 flags2; + Position pos; + uint32 time; + + // transport + struct TransportInfo + { + void Reset() + { + guid.Clear(); + pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f); + seat = -1; + time = 0; + prevTime = 0; + vehicleId = 0; + } + + ObjectGuid guid; + Position pos; + int8 seat; + uint32 time; + uint32 prevTime; + uint32 vehicleId; + } transport; + + // swimming/flying + float pitch; + + // jumping + struct JumpInfo + { + void Reset() + { + fallTime = 0; + zspeed = sinAngle = cosAngle = xyspeed = 0.0f; + } + + uint32 fallTime; + + float zspeed, sinAngle, cosAngle, xyspeed; + + } jump; + + // spline + float splineElevation; + + MovementInfo() : + flags(0), flags2(0), time(0), pitch(0.0f), splineElevation(0.0f) + { + pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f); + transport.Reset(); + jump.Reset(); + } + + uint32 GetMovementFlags() const { return flags; } + void SetMovementFlags(uint32 flag) { flags = flag; } + void AddMovementFlag(uint32 flag) { flags |= flag; } + void RemoveMovementFlag(uint32 flag) { flags &= ~flag; } + bool HasMovementFlag(uint32 flag) const { return (flags & flag) != 0; } + + uint32 GetExtraMovementFlags() const { return flags2; } + void SetExtraMovementFlags(uint32 flag) { flags2 = flag; } + void AddExtraMovementFlag(uint32 flag) { flags2 |= flag; } + void RemoveExtraMovementFlag(uint32 flag) { flags2 &= ~flag; } + bool HasExtraMovementFlag(uint32 flag) const { return (flags2 & flag) != 0; } + + uint32 GetFallTime() const { return jump.fallTime; } + void SetFallTime(uint32 fallTime) { jump.fallTime = fallTime; } + + void ResetTransport() + { + transport.Reset(); + } + + void ResetJump() + { + jump.Reset(); + } + + void OutDebug(); +}; + +#endif // MovementInfo_h__ diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index fbe3aadaa05..c5a34ab4a55 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -22,6 +22,8 @@ #include "Common.h" #include "GridReference.h" #include "GridRefManager.h" +#include "MovementInfo.h" +#include "ObjectDefines.h" #include "ObjectGuid.h" #include "Position.h" #include "SharedDefines.h" @@ -31,51 +33,6 @@ #include <set> #include <unordered_map> -#define CONTACT_DISTANCE 0.5f -#define INTERACTION_DISTANCE 5.0f -#define ATTACK_DISTANCE 5.0f -#define INSPECT_DISTANCE 28.0f -#define TRADE_DISTANCE 11.11f -#define MAX_VISIBILITY_DISTANCE SIZE_OF_GRIDS // max distance for visible objects -#define SIGHT_RANGE_UNIT 50.0f -#define DEFAULT_VISIBILITY_DISTANCE 90.0f // default visible distance, 90 yards on continents -#define DEFAULT_VISIBILITY_INSTANCE 170.0f // default visible distance in instances, 170 yards -#define DEFAULT_VISIBILITY_BGARENAS 533.0f // default visible distance in BG/Arenas, roughly 533 yards - -#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // player size, also currently used (correctly?) for any non Unit world objects -#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 DEFAULT_PHASE 169 - -enum TempSummonType -{ - TEMPSUMMON_TIMED_OR_DEAD_DESPAWN = 1, // despawns after a specified time OR when the creature disappears - TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN = 2, // despawns after a specified time OR when the creature dies - TEMPSUMMON_TIMED_DESPAWN = 3, // despawns after a specified time - TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT = 4, // despawns after a specified time after the creature is out of combat - TEMPSUMMON_CORPSE_DESPAWN = 5, // despawns instantly after death - TEMPSUMMON_CORPSE_TIMED_DESPAWN = 6, // despawns after a specified time after death - TEMPSUMMON_DEAD_DESPAWN = 7, // despawns when the creature disappears - TEMPSUMMON_MANUAL_DESPAWN = 8 // despawns when UnSummon() is called -}; - -enum PhaseMasks -{ - PHASEMASK_NORMAL = 0x00000001, - PHASEMASK_ANYWHERE = 0xFFFFFFFF -}; - -enum NotifyFlags -{ - NOTIFY_NONE = 0x00, - NOTIFY_AI_RELOCATION = 0x01, - NOTIFY_VISIBILITY_CHANGED = 0x02, - NOTIFY_ALL = 0xFF -}; - class AreaTrigger; class Conversation; class Corpse; @@ -379,93 +336,6 @@ class TC_GAME_API Object Object& operator=(Object const& right) = delete; }; -struct MovementInfo -{ - // common - ObjectGuid guid; - uint32 flags; - uint32 flags2; - Position pos; - uint32 time; - - // transport - struct TransportInfo - { - void Reset() - { - guid.Clear(); - pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f); - seat = -1; - time = 0; - prevTime = 0; - vehicleId = 0; - } - - ObjectGuid guid; - Position pos; - int8 seat; - uint32 time; - uint32 prevTime; - uint32 vehicleId; - } transport; - - // swimming/flying - float pitch; - - // jumping - struct JumpInfo - { - void Reset() - { - fallTime = 0; - zspeed = sinAngle = cosAngle = xyspeed = 0.0f; - } - - uint32 fallTime; - - float zspeed, sinAngle, cosAngle, xyspeed; - - } jump; - - // spline - float splineElevation; - - MovementInfo() : - flags(0), flags2(0), time(0), pitch(0.0f), splineElevation(0.0f) - { - pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f); - transport.Reset(); - jump.Reset(); - } - - uint32 GetMovementFlags() const { return flags; } - void SetMovementFlags(uint32 flag) { flags = flag; } - void AddMovementFlag(uint32 flag) { flags |= flag; } - void RemoveMovementFlag(uint32 flag) { flags &= ~flag; } - bool HasMovementFlag(uint32 flag) const { return (flags & flag) != 0; } - - uint32 GetExtraMovementFlags() const { return flags2; } - void SetExtraMovementFlags(uint32 flag) { flags2 = flag; } - void AddExtraMovementFlag(uint32 flag) { flags2 |= flag; } - void RemoveExtraMovementFlag(uint32 flag) { flags2 &= ~flag; } - bool HasExtraMovementFlag(uint32 flag) const { return (flags2 & flag) != 0; } - - uint32 GetFallTime() const { return jump.fallTime; } - void SetFallTime(uint32 fallTime) { jump.fallTime = fallTime; } - - void ResetTransport() - { - transport.Reset(); - } - - void ResetJump() - { - jump.Reset(); - } - - void OutDebug(); -}; - template<class T> class GridObject { diff --git a/src/server/game/Entities/Object/ObjectDefines.h b/src/server/game/Entities/Object/ObjectDefines.h index dfe2a7c6ec5..1c2b785218d 100644 --- a/src/server/game/Entities/Object/ObjectDefines.h +++ b/src/server/game/Entities/Object/ObjectDefines.h @@ -21,46 +21,82 @@ #include "Define.h" -// used for creating values for respawn for example -inline uint64 MAKE_PAIR64(uint32 l, uint32 h); -inline uint32 PAIR64_HIPART(uint64 x); -inline uint32 PAIR64_LOPART(uint64 x); -inline uint16 MAKE_PAIR16(uint8 l, uint8 h); -inline uint32 MAKE_PAIR32(uint16 l, uint16 h); -inline uint16 PAIR32_HIPART(uint32 x); -inline uint16 PAIR32_LOPART(uint32 x); - -uint64 MAKE_PAIR64(uint32 l, uint32 h) +#define CONTACT_DISTANCE 0.5f +#define INTERACTION_DISTANCE 5.0f +#define ATTACK_DISTANCE 5.0f +#define INSPECT_DISTANCE 28.0f +#define TRADE_DISTANCE 11.11f +#define MAX_VISIBILITY_DISTANCE SIZE_OF_GRIDS // max distance for visible objects +#define SIGHT_RANGE_UNIT 50.0f +#define DEFAULT_VISIBILITY_DISTANCE 90.0f // default visible distance, 90 yards on continents +#define DEFAULT_VISIBILITY_INSTANCE 170.0f // default visible distance in instances, 170 yards +#define DEFAULT_VISIBILITY_BGARENAS 533.0f // default visible distance in BG/Arenas, roughly 533 yards + +#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // player size, also currently used (correctly?) for any non Unit world objects +#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 DEFAULT_PHASE 169 + +enum TempSummonType +{ + TEMPSUMMON_TIMED_OR_DEAD_DESPAWN = 1, // despawns after a specified time OR when the creature disappears + TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN = 2, // despawns after a specified time OR when the creature dies + TEMPSUMMON_TIMED_DESPAWN = 3, // despawns after a specified time + TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT = 4, // despawns after a specified time after the creature is out of combat + TEMPSUMMON_CORPSE_DESPAWN = 5, // despawns instantly after death + TEMPSUMMON_CORPSE_TIMED_DESPAWN = 6, // despawns after a specified time after death + TEMPSUMMON_DEAD_DESPAWN = 7, // despawns when the creature disappears + TEMPSUMMON_MANUAL_DESPAWN = 8 // despawns when UnSummon() is called +}; + +enum PhaseMasks +{ + PHASEMASK_NORMAL = 0x00000001, + PHASEMASK_ANYWHERE = 0xFFFFFFFF +}; + +enum NotifyFlags +{ + NOTIFY_NONE = 0x00, + NOTIFY_AI_RELOCATION = 0x01, + NOTIFY_VISIBILITY_CHANGED = 0x02, + NOTIFY_ALL = 0xFF +}; + +inline uint64 MAKE_PAIR64(uint32 l, uint32 h) { return uint64(l | (uint64(h) << 32)); } -uint32 PAIR64_HIPART(uint64 x) +inline uint32 PAIR64_HIPART(uint64 x) { return (uint32)((x >> 32) & UI64LIT(0x00000000FFFFFFFF)); } -uint32 PAIR64_LOPART(uint64 x) +inline uint32 PAIR64_LOPART(uint64 x) { return (uint32)(x & UI64LIT(0x00000000FFFFFFFF)); } -uint16 MAKE_PAIR16(uint8 l, uint8 h) +inline uint16 MAKE_PAIR16(uint8 l, uint8 h) { return uint16(l | (uint16(h) << 8)); } -uint32 MAKE_PAIR32(uint16 l, uint16 h) +inline uint32 MAKE_PAIR32(uint16 l, uint16 h) { return uint32(l | (uint32(h) << 16)); } -uint16 PAIR32_HIPART(uint32 x) +inline uint16 PAIR32_HIPART(uint32 x) { return (uint16)((x >> 16) & 0x0000FFFF); } -uint16 PAIR32_LOPART(uint32 x) +inline uint16 PAIR32_LOPART(uint32 x) { return (uint16)(x & 0x0000FFFF); } diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 63ca784c2ff..2209282223a 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -24,6 +24,8 @@ #include "ObjectMgr.h" #include "Opcodes.h" #include "PetPackets.h" +#include "Player.h" +#include "Spell.h" #include "SpellAuraEffects.h" #include "SpellAuras.h" #include "SpellHistory.h" diff --git a/src/server/game/Entities/Player/EquipementSet.h b/src/server/game/Entities/Player/EquipementSet.h new file mode 100644 index 00000000000..3ac891db523 --- /dev/null +++ b/src/server/game/Entities/Player/EquipementSet.h @@ -0,0 +1,67 @@ +/* + * 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 EquipementSet_h__ +#define EquipementSet_h__ + +#include "Define.h" +#include "ObjectGuid.h" +#include <array> +#include <map> + +enum EquipmentSetUpdateState +{ + EQUIPMENT_SET_UNCHANGED = 0, + EQUIPMENT_SET_CHANGED = 1, + EQUIPMENT_SET_NEW = 2, + EQUIPMENT_SET_DELETED = 3 +}; + +#define EQUIPEMENT_SET_SLOTS 19 + +struct EquipmentSetInfo +{ + enum EquipmentSetType : int32 + { + EQUIPMENT = 0, + TRANSMOG = 1 + }; + + /// Data sent in EquipmentSet related packets + struct EquipmentSetData + { + EquipmentSetType Type = EQUIPMENT; + uint64 Guid = 0; ///< Set Identifier + uint32 SetID = 0; ///< Index + uint32 IgnoreMask = 0; ///< Mask of EquipmentSlot + int32 AssignedSpecIndex = -1; ///< Index of character specialization that this set is automatically equipped for + std::string SetName; + std::string SetIcon; + std::array<ObjectGuid, EQUIPEMENT_SET_SLOTS> Pieces; + std::array<int32, EQUIPEMENT_SET_SLOTS> Appearances; ///< ItemModifiedAppearanceID + std::array<int32, 2> Enchants; ///< SpellItemEnchantmentID + } Data; + + /// Server-side data + EquipmentSetUpdateState State = EQUIPMENT_SET_NEW; +}; + +#define MAX_EQUIPMENT_SET_INDEX 20 // client limit + +typedef std::map<uint64, EquipmentSetInfo> EquipmentSetContainer; + +#endif // EquipementSet_h__ diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 443c1aefc82..21553d8ec07 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -5784,14 +5784,9 @@ void Player::SendActionButtons(uint32 state) const { WorldPackets::Spells::UpdateActionButtons packet; - for (uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button) - { - ActionButtonList::const_iterator itr = m_actionButtons.find(button); - if (itr != m_actionButtons.end() && itr->second.uState != ACTIONBUTTON_DELETED) - packet.ActionButtons[button] = uint64(itr->second.packedData); - else - packet.ActionButtons[button] = 0; - } + for (auto itr = m_actionButtons.begin(); itr != m_actionButtons.end(); ++itr) + if (itr->second.uState != ACTIONBUTTON_DELETED && itr->first < packet.ActionButtons.size()) + packet.ActionButtons[itr->first] = itr->second.packedData; packet.Reason = state; @@ -20785,26 +20780,22 @@ void Player::SetUInt32ValueInArray(Tokenizer& Tokenizer, uint16 index, uint32 va void Player::SendAttackSwingDeadTarget() const { - WorldPackets::Combat::AttackSwingError packet(ATTACKSWINGERR_DEADTARGET); - GetSession()->SendPacket(packet.Write()); + GetSession()->SendPacket(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::DeadTarget).Write()); } void Player::SendAttackSwingCantAttack() const { - WorldPackets::Combat::AttackSwingError packet(ATTACKSWINGERR_CANT_ATTACK); - GetSession()->SendPacket(packet.Write()); + GetSession()->SendPacket(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::CantAttack).Write()); } void Player::SendAttackSwingNotInRange() const { - WorldPackets::Combat::AttackSwingError packet(ATTACKSWINGERR_NOTINRANGE); - GetSession()->SendPacket(packet.Write()); + GetSession()->SendPacket(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::NotInRange).Write()); } void Player::SendAttackSwingBadFacingAttack() const { - WorldPackets::Combat::AttackSwingError packet(ATTACKSWINGERR_BADFACING); - GetSession()->SendPacket(packet.Write()); + GetSession()->SendPacket(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::BadFacing).Write()); } void Player::SendAttackSwingCancelAttack() const diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 6dcb1f99900..7d9a8d915f5 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -23,6 +23,7 @@ #include "GroupReference.h" #include "MapReference.h" #include "CUFProfile.h" +#include "EquipementSet.h" #include "Item.h" #include "PetDefines.h" #include "QuestDef.h" @@ -419,8 +420,6 @@ enum PlayerBytes2Offsets PLAYER_BYTES_2_OFFSET_FACIAL_STYLE = 3, }; -#define PLAYER_CUSTOM_DISPLAY_SIZE 3 - enum PlayerBytes3Offsets { PLAYER_BYTES_3_OFFSET_PARTY_TYPE = 0, @@ -576,14 +575,6 @@ struct SkillStatusData typedef std::unordered_map<uint32, SkillStatusData> SkillStatusMap; -enum AttackSwingErr -{ - ATTACKSWINGERR_CANT_ATTACK = 0, - ATTACKSWINGERR_BADFACING = 1, - ATTACKSWINGERR_NOTINRANGE = 2, - ATTACKSWINGERR_DEADTARGET = 3 -}; - class Quest; class Spell; class Item; @@ -671,45 +662,6 @@ enum ChildEquipmentSlots CHILD_EQUIPMENT_SLOT_END = 187, }; -enum EquipmentSetUpdateState -{ - EQUIPMENT_SET_UNCHANGED = 0, - EQUIPMENT_SET_CHANGED = 1, - EQUIPMENT_SET_NEW = 2, - EQUIPMENT_SET_DELETED = 3 -}; - -struct EquipmentSetInfo -{ - enum EquipmentSetType : int32 - { - EQUIPMENT = 0, - TRANSMOG = 1 - }; - - /// Data sent in EquipmentSet related packets - struct EquipmentSetData - { - EquipmentSetType Type = EQUIPMENT; - uint64 Guid = 0; ///< Set Identifier - uint32 SetID = 0; ///< Index - uint32 IgnoreMask = 0; ///< Mask of EquipmentSlot - int32 AssignedSpecIndex = -1; ///< Index of character specialization that this set is automatically equipped for - std::string SetName; - std::string SetIcon; - std::array<ObjectGuid, EQUIPMENT_SLOT_END> Pieces; - std::array<int32, EQUIPMENT_SLOT_END> Appearances; ///< ItemModifiedAppearanceID - std::array<int32, 2> Enchants; ///< SpellItemEnchantmentID - } Data; - - /// Server-side data - EquipmentSetUpdateState State = EQUIPMENT_SET_NEW; -}; - -#define MAX_EQUIPMENT_SET_INDEX 20 // client limit - -typedef std::map<uint64, EquipmentSetInfo> EquipmentSetContainer; - struct ItemPosCount { ItemPosCount(uint16 _pos, uint32 _count) : pos(_pos), count(_count) { } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 70811186cee..e3d0519bfa7 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -17,19 +17,22 @@ */ #include "Unit.h" -#include "Common.h" #include "Battlefield.h" #include "BattlefieldMgr.h" #include "Battleground.h" #include "BattlegroundPackets.h" #include "BattlegroundScore.h" #include "CellImpl.h" +#include "ChatPackets.h" #include "ChatTextBuilder.h" +#include "CombatLogPackets.h" +#include "CombatPackets.h" +#include "Common.h" #include "ConditionMgr.h" +#include "Creature.h" #include "CreatureAI.h" #include "CreatureAIImpl.h" #include "CreatureGroups.h" -#include "Creature.h" #include "Formulas.h" #include "GridNotifiersImpl.h" #include "Group.h" @@ -37,41 +40,39 @@ #include "InstanceScript.h" #include "Log.h" #include "LootMgr.h" +#include "LootPackets.h" +#include "MiscPackets.h" +#include "MovementPackets.h" #include "MoveSpline.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Opcodes.h" #include "OutdoorPvP.h" +#include "PartyPackets.h" #include "PassiveAI.h" -#include "PetAI.h" #include "Pet.h" +#include "PetAI.h" #include "Player.h" #include "PlayerAI.h" #include "QuestDef.h" #include "ReputationMgr.h" +#include "Spell.h" #include "SpellAuraEffects.h" #include "SpellAuras.h" -#include "Spell.h" -#include "SpellInfo.h" #include "SpellHistory.h" +#include "SpellInfo.h" #include "SpellMgr.h" +#include "SpellPackets.h" #include "TemporarySummon.h" -#include "Transport.h" #include "Totem.h" +#include "Transport.h" #include "UpdateFieldFlags.h" #include "Util.h" #include "Vehicle.h" +#include "VehiclePackets.h" #include "World.h" #include "WorldPacket.h" #include "WorldSession.h" -#include "ChatPackets.h" -#include "MiscPackets.h" -#include "MovementPackets.h" -#include "CombatPackets.h" -#include "CombatLogPackets.h" -#include "VehiclePackets.h" -#include "LootPackets.h" -#include "PartyPackets.h" #include <cmath> float baseMoveSpeed[MAX_MOVE_TYPE] = @@ -10630,8 +10631,8 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u // Skip melee hits and spells ws wrong school or zero cost if (procSpell && (triggeredByAura->GetMiscValue() & procSpell->SchoolMask)) // School check { - std::vector<SpellInfo::CostData> costs = procSpell->CalcPowerCost(this, procSpell->GetSchoolMask()); - auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Amount > 0; }); + std::vector<SpellPowerCost> costs = procSpell->CalcPowerCost(this, procSpell->GetSchoolMask()); + auto m = std::find_if(costs.begin(), costs.end(), [](SpellPowerCost const& cost) { return cost.Amount > 0; }); if (m != costs.end()) takeCharges = true; } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 6ca7b8d9bf4..a6dbb3f6e94 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -130,7 +130,7 @@ enum SpellModOp #define MAX_SPELLMOD 39 -enum SpellValueMod +enum SpellValueMod : uint8 { SPELLVALUE_BASE_POINT0, SPELLVALUE_BASE_POINT1, @@ -263,36 +263,6 @@ enum VictimState VICTIMSTATE_DEFLECTS = 8 }; -enum HitInfo -{ - HITINFO_NORMALSWING = 0x00000000, - HITINFO_UNK1 = 0x00000001, // req correct packet structure - HITINFO_AFFECTS_VICTIM = 0x00000002, - HITINFO_OFFHAND = 0x00000004, - HITINFO_UNK2 = 0x00000008, - HITINFO_MISS = 0x00000010, - HITINFO_FULL_ABSORB = 0x00000020, - HITINFO_PARTIAL_ABSORB = 0x00000040, - HITINFO_FULL_RESIST = 0x00000080, - HITINFO_PARTIAL_RESIST = 0x00000100, - HITINFO_CRITICALHIT = 0x00000200, // critical hit - HITINFO_UNK10 = 0x00000400, - HITINFO_UNK11 = 0x00000800, - HITINFO_UNK12 = 0x00001000, - HITINFO_BLOCK = 0x00002000, // blocked damage - HITINFO_UNK14 = 0x00004000, // set only if meleespellid is present// no world text when victim is hit for 0 dmg(HideWorldTextForNoDamage?) - HITINFO_UNK15 = 0x00008000, // player victim?// something related to blod sprut visual (BloodSpurtInBack?) - HITINFO_GLANCING = 0x00010000, - HITINFO_CRUSHING = 0x00020000, - HITINFO_NO_ANIMATION = 0x00040000, - HITINFO_UNK19 = 0x00080000, - HITINFO_UNK20 = 0x00100000, - HITINFO_SWINGNOHITSOUND = 0x00200000, // unused? - HITINFO_UNK22 = 0x00400000, - HITINFO_RAGE_GAIN = 0x00800000, - HITINFO_FAKE_DAMAGE = 0x01000000 // enables damage animation even if no damage done, set only if no damage -}; - //i would like to remove this: (it is defined in item.h enum InventorySlot { @@ -367,17 +337,7 @@ enum WeaponDamageRange MAXDAMAGE }; -enum AuraRemoveMode -{ - AURA_REMOVE_NONE = 0, - AURA_REMOVE_BY_DEFAULT = 1, // scripted remove, remove by stack with aura with different ids and sc aura remove - AURA_REMOVE_BY_CANCEL, - AURA_REMOVE_BY_ENEMY_SPELL, // dispel and absorb aura destroy - AURA_REMOVE_BY_EXPIRE, // aura duration has ended - AURA_REMOVE_BY_DEATH -}; - -enum TriggerCastFlags +enum TriggerCastFlags : uint32 { TRIGGERED_NONE = 0x00000000, //! Not triggered TRIGGERED_IGNORE_GCD = 0x00000001, //! Will ignore GCD @@ -587,7 +547,7 @@ enum CombatRating #define MAX_COMBAT_RATING 32 -enum DamageEffectType +enum DamageEffectType : uint8 { DIRECT_DAMAGE = 0, // used for normal weapon damage (not for class abilities or spells) SPELL_DIRECT_DAMAGE = 1, // spell/class abilities damage @@ -848,7 +808,7 @@ struct RedirectThreatInfo } }; -enum CurrentSpellTypes +enum CurrentSpellTypes : uint8 { CURRENT_MELEE_SPELL = 0, CURRENT_GENERIC_SPELL = 1, @@ -2210,4 +2170,10 @@ namespace Trinity bool const _ascending; }; } + +inline void SetUnitCurrentCastSpell(Unit* unit, Spell* spell) +{ + unit->SetCurrentCastSpell(spell); +} + #endif diff --git a/src/server/game/Entities/Unit/UnitDefines.h b/src/server/game/Entities/Unit/UnitDefines.h index 6b853057751..35490f33bb0 100644 --- a/src/server/game/Entities/Unit/UnitDefines.h +++ b/src/server/game/Entities/Unit/UnitDefines.h @@ -320,6 +320,36 @@ enum MovementFlags2 : uint32 MOVEMENTFLAG2_INTERPOLATED_PITCHING = 0x00400000 }; +enum HitInfo +{ + HITINFO_NORMALSWING = 0x00000000, + HITINFO_UNK1 = 0x00000001, // req correct packet structure + HITINFO_AFFECTS_VICTIM = 0x00000002, + HITINFO_OFFHAND = 0x00000004, + HITINFO_UNK2 = 0x00000008, + HITINFO_MISS = 0x00000010, + HITINFO_FULL_ABSORB = 0x00000020, + HITINFO_PARTIAL_ABSORB = 0x00000040, + HITINFO_FULL_RESIST = 0x00000080, + HITINFO_PARTIAL_RESIST = 0x00000100, + HITINFO_CRITICALHIT = 0x00000200, // critical hit + HITINFO_UNK10 = 0x00000400, + HITINFO_UNK11 = 0x00000800, + HITINFO_UNK12 = 0x00001000, + HITINFO_BLOCK = 0x00002000, // blocked damage + HITINFO_UNK14 = 0x00004000, // set only if meleespellid is present// no world text when victim is hit for 0 dmg(HideWorldTextForNoDamage?) + HITINFO_UNK15 = 0x00008000, // player victim?// something related to blod sprut visual (BloodSpurtInBack?) + HITINFO_GLANCING = 0x00010000, + HITINFO_CRUSHING = 0x00020000, + HITINFO_NO_ANIMATION = 0x00040000, + HITINFO_UNK19 = 0x00080000, + HITINFO_UNK20 = 0x00100000, + HITINFO_SWINGNOHITSOUND = 0x00200000, // unused? + HITINFO_UNK22 = 0x00400000, + HITINFO_RAGE_GAIN = 0x00800000, + HITINFO_FAKE_DAMAGE = 0x01000000 // enables damage animation even if no damage done, set only if no damage +}; + #define MAX_DECLINED_NAME_CASES 5 struct DeclinedName |
