diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h index 8bb7e6c08..64042761d 100644 --- a/src/server/game/Entities/Corpse/Corpse.h +++ b/src/server/game/Entities/Corpse/Corpse.h @@ -40,8 +40,8 @@ class Corpse : public WorldObject, public GridObject explicit Corpse(CorpseType type = CORPSE_BONES); ~Corpse(); - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; bool Create(uint32 guidlow, Map* map); bool Create(uint32 guidlow, Player* owner); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index defcd642e..f4fc7476e 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -432,11 +432,11 @@ class Creature : public Unit, public GridObject, public MovableMapObje explicit Creature(bool isWorldObject = false); virtual ~Creature(); - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; - void SetObjectScale(float scale); - void SetDisplayId(uint32 modelId); + void SetObjectScale(float scale) override; + void SetDisplayId(uint32 modelId) override; void DisappearAndDie(); @@ -447,7 +447,7 @@ class Creature : public Unit, public GridObject, public MovableMapObje uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } - void Update(uint32 time); // overwrited Unit::Update + void Update(uint32 time) override; // overwrited Unit::Update void GetRespawnPosition(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } @@ -457,8 +457,8 @@ class Creature : public Unit, public GridObject, public MovableMapObje bool IsTrigger() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; } bool IsGuard() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; } bool CanWalk() const { return GetCreatureTemplate()->InhabitType & INHABIT_GROUND; } - bool CanSwim() const { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) || IS_PLAYER_GUID(GetOwnerGUID()); } - bool CanFly() const { return GetCreatureTemplate()->InhabitType & INHABIT_AIR; } + bool CanSwim() const override { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) || IS_PLAYER_GUID(GetOwnerGUID()); } + bool CanFly() const override { return GetCreatureTemplate()->InhabitType & INHABIT_AIR; } void SetReactState(ReactStates st) { m_reactState = st; } ReactStates GetReactState() const { return m_reactState; } @@ -469,11 +469,11 @@ class Creature : public Unit, public GridObject, public MovableMapObje bool isCanInteractWithBattleMaster(Player* player, bool msg) const; bool isCanTrainingAndResetTalentsOf(Player* player) const; bool CanCreatureAttack(Unit const* victim, bool skipDistCheck = false) const; - bool IsImmunedToSpell(SpellInfo const* spellInfo); + bool IsImmunedToSpell(SpellInfo const* spellInfo) override; bool HasMechanicTemplateImmunity(uint32 mask) const; // redefine Unit::IsImmunedToSpell - bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const; + bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override; // redefine Unit::IsImmunedToSpellEffect bool isElite() const { @@ -496,7 +496,7 @@ class Creature : public Unit, public GridObject, public MovableMapObje bool IsImmuneToKnockback() const; bool IsAvoidingAOE() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_AVOID_AOE; } - uint8 getLevelForTarget(WorldObject const* target) const; // overwrite Unit::getLevelForTarget for boss level support + uint8 getLevelForTarget(WorldObject const* target) const override; // overwrite Unit::getLevelForTarget for boss level support bool IsInEvadeMode() const { return HasUnitState(UNIT_STATE_EVADE); } @@ -505,42 +505,42 @@ class Creature : public Unit, public GridObject, public MovableMapObje CreatureAI* AI() const { return (CreatureAI*)i_AI; } - bool SetWalk(bool enable); - bool SetDisableGravity(bool disable, bool packetOnly = false); - bool SetSwim(bool enable); - bool SetCanFly(bool enable, bool packetOnly = false); - bool SetWaterWalking(bool enable, bool packetOnly = false); - bool SetFeatherFall(bool enable, bool packetOnly = false); - bool SetHover(bool enable, bool packetOnly = false); + bool SetWalk(bool enable) override; + bool SetDisableGravity(bool disable, bool packetOnly = false) override; + bool SetSwim(bool enable) override; + bool SetCanFly(bool enable, bool packetOnly = false) override; + bool SetWaterWalking(bool enable, bool packetOnly = false) override; + bool SetFeatherFall(bool enable, bool packetOnly = false) override; + bool SetHover(bool enable, bool packetOnly = false) override; - uint32 GetShieldBlockValue() const + uint32 GetShieldBlockValue() const override { return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20)); } - SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; } + SpellSchoolMask GetMeleeDamageSchoolMask() const override { return m_meleeDamageSchoolMask; } void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); } void _AddCreatureSpellCooldown(uint32 spell_id, uint32 end_time); - virtual void AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false); - virtual bool HasSpellCooldown(uint32 spell_id) const; + virtual void AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false) override; + virtual bool HasSpellCooldown(uint32 spell_id) const override; uint32 GetSpellCooldown(uint32 spell_id) const; - void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); + void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override; bool IsSpellProhibited(SpellSchoolMask idSchoolMask) const; - bool HasSpell(uint32 spellID) const; + bool HasSpell(uint32 spellID) const override; bool UpdateEntry(uint32 entry, const CreatureData* data=NULL, bool changelevel=true ); - bool UpdateStats(Stats stat); - bool UpdateAllStats(); - void UpdateResistances(uint32 school); - void UpdateArmor(); - void UpdateMaxHealth(); - void UpdateMaxPower(Powers power); - void UpdateAttackPowerAndDamage(bool ranged = false); - void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage); + bool UpdateStats(Stats stat) override; + bool UpdateAllStats() override; + void UpdateResistances(uint32 school) override; + void UpdateArmor() override; + void UpdateMaxHealth() override; + void UpdateMaxPower(Powers power) override; + void UpdateAttackPowerAndDamage(bool ranged = false) override; + void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) override; - void SetCanDualWield(bool value); + void SetCanDualWield(bool value) override; int8 GetOriginalEquipmentId() const { return m_originalEquipmentId; } uint8 GetCurrentEquipmentId() { return m_equipmentId; } void SetCurrentEquipmentId(uint8 id) { m_equipmentId = id; } @@ -562,9 +562,9 @@ class Creature : public Unit, public GridObject, public MovableMapObje uint32 GetScriptId() const; // override WorldObject function for proper name localization - std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const; + std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override; - void setDeathState(DeathState s, bool despawn = false); // override virtual Unit::setDeathState + void setDeathState(DeathState s, bool despawn = false) override; // override virtual Unit::setDeathState bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false, true); } bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true, bool gridLoad = false); @@ -635,7 +635,7 @@ class Creature : public Unit, public GridObject, public MovableMapObje time_t GetRespawnTimeEx() const; void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; } void Respawn(bool force = false); - void SaveRespawnTime(); + void SaveRespawnTime() override; uint32 GetRespawnDelay() const { return m_respawnDelay; } void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; } @@ -650,8 +650,8 @@ class Creature : public Unit, public GridObject, public MovableMapObje void SetInCombatWithZone(); - bool hasQuest(uint32 quest_id) const; - bool hasInvolvedQuest(uint32 quest_id) const; + bool hasQuest(uint32 quest_id) const override; + bool hasInvolvedQuest(uint32 quest_id) const override; bool isRegeneratingHealth() { return m_regenHealth; } void SetRegeneratingHealth(bool c) { m_regenHealth = c; } @@ -710,7 +710,7 @@ class Creature : public Unit, public GridObject, public MovableMapObje bool m_isTempWorldObject; //true when possessed // Handling caster facing during spellcast - void SetTarget(uint64 guid); + void SetTarget(uint64 guid) override; void FocusTarget(Spell const* focusSpell, WorldObject const* target); void ReleaseFocus(Spell const* focusSpell); @@ -768,8 +768,8 @@ class Creature : public Unit, public GridObject, public MovableMapObje uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable - bool IsInvisibleDueToDespawn() const; - bool CanAlwaysSee(WorldObject const* obj) const; + bool IsInvisibleDueToDespawn() const override; + bool CanAlwaysSee(WorldObject const* obj) const override; private: void ForcedDespawn(uint32 timeMSToDespawn = 0); diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.h b/src/server/game/Entities/DynamicObject/DynamicObject.h index f48322f80..74dd471a5 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.h +++ b/src/server/game/Entities/DynamicObject/DynamicObject.h @@ -26,13 +26,13 @@ class DynamicObject : public WorldObject, public GridObject, publ DynamicObject(bool isWorldObject); ~DynamicObject(); - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; - void CleanupsBeforeDelete(bool finalCleanup = true); + void CleanupsBeforeDelete(bool finalCleanup = true) override; bool CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type); - void Update(uint32 p_time); + void Update(uint32 p_time) override; void Remove(); void SetDuration(int32 newDuration); int32 GetDuration() const; diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 8a0157270..eae884b61 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -664,14 +664,14 @@ class GameObject : public WorldObject, public GridObject, public Mov explicit GameObject(); ~GameObject(); - void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const; + void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const override; - void AddToWorld(); - void RemoveFromWorld(); - void CleanupsBeforeDelete(bool finalCleanup = true); + void AddToWorld() override; + void RemoveFromWorld() override; + void CleanupsBeforeDelete(bool finalCleanup = true) override; virtual bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0); - void Update(uint32 p_time); + void Update(uint32 p_time) override; GameObjectTemplate const* GetGOInfo() const { return m_goInfo; } GameObjectTemplateAddon const* GetTemplateAddon() const; GameObjectData const* GetGOData() const { return m_goData; } @@ -689,7 +689,7 @@ class GameObject : public WorldObject, public GridObject, public Mov int64 GetPackedWorldRotation() const { return m_packedRotation; } // overwrite WorldObject function for proper name localization - std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const; + std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override; void SaveToDB(); void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); @@ -756,7 +756,7 @@ class GameObject : public WorldObject, public GridObject, public Mov void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); } static void SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid = 0); - void SetPhaseMask(uint32 newPhaseMask, bool update); + void SetPhaseMask(uint32 newPhaseMask, bool update) override; void EnableCollision(bool enable); void Use(Unit* user); @@ -789,7 +789,7 @@ class GameObject : public WorldObject, public GridObject, public Mov uint32 GetUseCount() const { return m_usetimes; } uint32 GetUniqueUseCount() const { return m_unique_users.size(); } - void SaveRespawnTime(); + void SaveRespawnTime() override; Loot loot; @@ -803,8 +803,8 @@ class GameObject : public WorldObject, public GridObject, public Mov void SetLootGenerationTime() { m_lootGenerationTime = time(NULL); } uint32 GetLootGenerationTime() const { return m_lootGenerationTime; } - bool hasQuest(uint32 quest_id) const; - bool hasInvolvedQuest(uint32 quest_id) const; + bool hasQuest(uint32 quest_id) const override; + bool hasInvolvedQuest(uint32 quest_id) const override; bool ActivateToQuest(Player* target) const; void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false, Unit* user = NULL); // 0 = use `gameobject`.`spawntimesecs` @@ -812,11 +812,11 @@ class GameObject : public WorldObject, public GridObject, public Mov void TriggeringLinkedGameObject(uint32 trapEntry, Unit* target); - bool IsNeverVisible() const; - bool IsAlwaysVisibleFor(WorldObject const* seer) const; - bool IsInvisibleDueToDespawn() const; + bool IsNeverVisible() const override; + bool IsAlwaysVisibleFor(WorldObject const* seer) const override; + bool IsInvisibleDueToDespawn() const override; - uint8 getLevelForTarget(WorldObject const* target) const + uint8 getLevelForTarget(WorldObject const* target) const override { if (Unit* owner = GetOwner()) return owner->getLevelForTarget(target); @@ -830,7 +830,7 @@ class GameObject : public WorldObject, public GridObject, public Mov void SendCustomAnim(uint32 anim); bool IsInRange(float x, float y, float z, float radius) const; - void SendMessageToSetInRange(WorldPacket* data, float dist, bool /*self*/, bool includeMargin = false, Player const* skipped_rcvr = NULL); // pussywizard! + void SendMessageToSetInRange(WorldPacket* data, float dist, bool /*self*/, bool includeMargin = false, Player const* skipped_rcvr = NULL) override; // pussywizard! void ModifyHealth(int32 change, Unit* attackerOrHealer = NULL, uint32 spellId = 0); void SetDestructibleBuildingModifyState(bool allow) { m_allowModifyDestructibleBuilding = allow; } @@ -872,10 +872,10 @@ class GameObject : public WorldObject, public GridObject, public Mov MotionTransport* ToMotionTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast(this); else return NULL; } MotionTransport const* ToMotionTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast(this); else return NULL; } - float GetStationaryX() const { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionX(); return GetPositionX(); } - float GetStationaryY() const { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionY(); return GetPositionY(); } - float GetStationaryZ() const { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionZ(); return GetPositionZ(); } - float GetStationaryO() const { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetOrientation(); return GetOrientation(); } + float GetStationaryX() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionX(); return GetPositionX(); } + float GetStationaryY() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionY(); return GetPositionY(); } + float GetStationaryZ() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionZ(); return GetPositionZ(); } + float GetStationaryO() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetOrientation(); return GetOrientation(); } float GetInteractionDistance(); @@ -924,7 +924,7 @@ class GameObject : public WorldObject, public GridObject, public Mov void UpdatePackedRotation(); //! Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size. - bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool /*is3D*/) const + bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool /*is3D*/) const override { //! Following check does check 3d distance dist2compare += obj->GetObjectSize(); diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 4b760a903..ee9d930af 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1450,7 +1450,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const bool canSwim = ToCreature()->CanSwim(); float ground_z = z; float max_z = canSwim - ? GetMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK)) + ? GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK)) : ((ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true))); if (max_z > INVALID_HEIGHT) { @@ -1474,7 +1474,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const if (!ToPlayer()->CanFly()) { float ground_z = z; - float max_z = GetMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK)); + float max_z = GetMap()->GetWaterOrGroundLevel(GetPhaseMask(),x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK)); if (max_z > INVALID_HEIGHT) { if (z > max_z) @@ -2515,7 +2515,7 @@ void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float abs acore::NormalizeMapCoord(y); } -void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const +void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle, float controlZ) const { GetNearPoint2D(x, y, distance2d+searcher_size, absAngle); z = GetPositionZ(); @@ -2529,7 +2529,7 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, return; // return if the point is already in LoS - if (IsWithinLOS(x, y, z)) + if (!controlZ && IsWithinLOS(x, y, z)) return; // remember first point @@ -2543,6 +2543,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, GetNearPoint2D(x, y, distance2d + searcher_size, absAngle + angle); z = GetPositionZ(); UpdateAllowedPositionZ(x, y, z); + if (controlZ && fabsf(GetPositionZ() - z) > controlZ) + continue; + if (IsWithinLOS(x, y, z)) return; } @@ -2553,6 +2556,12 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, z = first_z; } +void WorldObject::GetVoidClosePoint(float& x, float& y, float& z, float size, float distance2d /*= 0*/, float relAngle /*= 0*/, float controlZ /*= 0*/) const +{ + // angle calculated from current orientation + GetNearPoint(nullptr, x, y, z, size, distance2d, GetOrientation() + relAngle, controlZ); +} + bool WorldObject::GetClosePoint(float &x, float &y, float &z, float size, float distance2d, float angle, const WorldObject* forWho, bool force) const { // angle calculated from current orientation diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 165dd0cc3..175e5cd02 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -747,7 +747,8 @@ class WorldObject : public Object, public WorldLocation #endif void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const; - void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const; + void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle, float controlZ = 0) const; + void GetVoidClosePoint(float& x, float& y, float& z, float size, float distance2d = 0, float relAngle = 0, float controlZ = 0) const; bool GetClosePoint(float &x, float &y, float &z, float size, float distance2d = 0, float angle = 0, const WorldObject* forWho = NULL, bool force = false) const; void MovePosition(Position &pos, float dist, float angle); void GetNearPosition(Position &pos, float dist, float angle) @@ -780,6 +781,8 @@ class WorldObject : public Object, public WorldLocation { return (m_valuesCount > UNIT_FIELD_COMBATREACH) ? m_floatValues[UNIT_FIELD_COMBATREACH] : DEFAULT_WORLD_OBJECT_SIZE; } + + virtual float GetCombatReach() const { return 0.0f; } // overridden (only) in Unit void UpdateGroundPositionZ(float x, float y, float &z) const; void UpdateAllowedPositionZ(float x, float y, float &z) const; diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index da5944140..46e42409a 100644 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -47,10 +47,10 @@ class Pet : public Guardian explicit Pet(Player* owner, PetType type = MAX_PET_TYPE); virtual ~Pet(); - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; - void SetDisplayId(uint32 modelId); + void SetDisplayId(uint32 modelId) override; PetType getPetType() const { return m_petType; } void setPetType(PetType type) { m_petType = type; } @@ -65,16 +65,16 @@ class Pet : public Guardian bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask); static SpellCastResult TryLoadFromDB(Player* owner, bool current = false, PetType mandatoryPetType = MAX_PET_TYPE); static bool LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry = 0, uint32 petnumber = 0, bool current = false, AsynchPetSummon* info = NULL); - bool isBeingLoaded() const { return m_loading;} + bool isBeingLoaded() const override { return m_loading;} void SavePetToDB(PetSaveMode mode, bool logout); void Remove(PetSaveMode mode, bool returnreagent = false); static void DeleteFromDB(uint32 guidlow); - void setDeathState(DeathState s, bool despawn = false); // overwrite virtual Creature::setDeathState and Unit::setDeathState - void Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update + void setDeathState(DeathState s, bool despawn = false) override; // overwrite virtual Creature::setDeathState and Unit::setDeathState + void Update(uint32 diff) override; // overwrite virtual Creature::Update and Unit::Update - uint8 GetPetAutoSpellSize() const { return m_autospells.size(); } - uint32 GetPetAutoSpellOnPos(uint8 pos) const + uint8 GetPetAutoSpellSize() const override { return m_autospells.size(); } + uint32 GetPetAutoSpellOnPos(uint8 pos) const override { if (pos >= m_autospells.size()) return 0; @@ -105,7 +105,7 @@ class Pet : public Guardian void ToggleAutocast(SpellInfo const* spellInfo, bool apply); - bool HasSpell(uint32 spell) const; + bool HasSpell(uint32 spell) const override; void LearnPetPassives(); void CastPetAuras(bool current); @@ -178,11 +178,11 @@ class Pet : public Guardian uint8 asynchLoadType; private: - void SaveToDB(uint32, uint8, uint32) // override of Creature::SaveToDB - must not be called + void SaveToDB(uint32, uint8, uint32) override // override of Creature::SaveToDB - must not be called { ABORT(); } - void DeleteFromDB() // override of Creature::DeleteFromDB - must not be called + void DeleteFromDB() override // override of Creature::DeleteFromDB - must not be called { ABORT(); } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 37def0c15..0799a50d5 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1106,12 +1106,12 @@ class Player : public Unit, public GridObject explicit Player(WorldSession* session); ~Player(); - void CleanupsBeforeDelete(bool finalCleanup = true); + void CleanupsBeforeDelete(bool finalCleanup = true) override; - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; - void SetObjectScale(float scale) + void SetObjectScale(float scale) override { Unit::SetObjectScale(scale); SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, scale * DEFAULT_WORLD_OBJECT_SIZE); @@ -1141,14 +1141,14 @@ class Player : public Unit, public GridObject bool Create(uint32 guidlow, CharacterCreateInfo* createInfo); - void Update(uint32 time); + void Update(uint32 time) override; static bool BuildEnumData(PreparedQueryResult result, WorldPacket* data); void SetInWater(bool apply); - bool IsInWater(bool allowAbove = false) const; - bool IsUnderWater() const; + bool IsInWater(bool allowAbove = false) const override; + bool IsUnderWater() const override; bool IsFalling() const; bool IsInAreaTriggerRadius(const AreaTrigger* trigger) const; @@ -1210,7 +1210,7 @@ class Player : public Unit, public GridObject uint32 GetTotalPlayedTime() { return m_Played_time[PLAYED_TIME_TOTAL]; } uint32 GetLevelPlayedTime() { return m_Played_time[PLAYED_TIME_LEVEL]; } - void setDeathState(DeathState s, bool despawn = false); // overwrite Unit::setDeathState + void setDeathState(DeathState s, bool despawn = false) override; // overwrite Unit::setDeathState void SetRestState(uint32 triggerId); void RemoveRestState(); @@ -1235,7 +1235,7 @@ class Player : public Unit, public GridObject /*********************************************************/ void SetVirtualItemSlot(uint8 i, Item* item); - void SetSheath(SheathState sheathed); // overwrite Unit version + void SetSheath(SheathState sheathed) override; // overwrite Unit version uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const; uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = NULL) const; uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = NULL) const; @@ -1549,7 +1549,7 @@ class Player : public Unit, public GridObject /*********************************************************/ bool LoadFromDB(uint32 guid, SQLQueryHolder *holder); - bool isBeingLoaded() const; + bool isBeingLoaded() const override; void Initialize(uint32 guid); static uint32 GetUInt32ValueFromArray(Tokenizer const& data, uint16 index); @@ -1619,7 +1619,7 @@ class Player : public Unit, public GridObject Unit* GetSelectedUnit() const; Player* GetSelectedPlayer() const; - void SetTarget(uint64 /*guid*/) { } /// Used for serverside target changes, does not apply to players + void SetTarget(uint64 /*guid*/) override { } /// Used for serverside target changes, does not apply to players void SetSelection(uint64 guid); uint8 GetComboPoints() const { return m_comboPoints; } @@ -1678,7 +1678,7 @@ class Player : public Unit, public GridObject void PossessSpellInitialize(); void VehicleSpellInitialize(); void SendRemoveControlBar(); - bool HasSpell(uint32 spell) const; + bool HasSpell(uint32 spell) const override; bool HasActiveSpell(uint32 spell) const; // show in spellbook TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const; bool IsSpellFitByClassAndRace(uint32 spell_id) const; @@ -1767,12 +1767,12 @@ class Player : public Unit, public GridObject static uint32 const infinityCooldownDelay = 0x9A7EC800; // used for set "infinity cooldowns" for spells and check, MONTH*IN_MILLISECONDS static uint32 const infinityCooldownDelayCheck = 0x4D3F6400; //MONTH*IN_MILLISECONDS/2; - virtual bool HasSpellCooldown(uint32 spell_id) const + virtual bool HasSpellCooldown(uint32 spell_id) const override { SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); return itr != m_spellCooldowns.end() && itr->second.end > World::GetGameTimeMS(); } - virtual bool HasSpellItemCooldown(uint32 spell_id, uint32 itemid) const + virtual bool HasSpellItemCooldown(uint32 spell_id, uint32 itemid) const override { SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); return itr != m_spellCooldowns.end() && itr->second.end > World::GetGameTimeMS() && itr->second.itemid == itemid; @@ -1783,10 +1783,10 @@ class Player : public Unit, public GridObject return uint32(itr != m_spellCooldowns.end() && itr->second.end > World::GetGameTimeMS() ? itr->second.end - World::GetGameTimeMS() : 0); } void AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false); - virtual void AddSpellCooldown(uint32 spell_id, uint32 itemid, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false); + void AddSpellCooldown(uint32 spell_id, uint32 itemid, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false) override; void ModifySpellCooldown(uint32 spellId, int32 cooldown); void SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId = 0, Spell* spell = NULL, bool setCooldown = true); - void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); + void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override; void RemoveSpellCooldown(uint32 spell_id, bool update = false); void SendClearCooldown(uint32 spell_id, Unit* target); @@ -1845,9 +1845,9 @@ class Player : public Unit, public GridObject void UpdateZone(uint32 newZone, uint32 newArea); void UpdateArea(uint32 newArea); - uint32 GetZoneId(bool forceRecalc = false) const; - uint32 GetAreaId(bool forceRecalc = false) const; - void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, bool forceRecalc = false) const; + uint32 GetZoneId(bool forceRecalc = false) const override; + uint32 GetAreaId(bool forceRecalc = false) const override; + void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, bool forceRecalc = false) const override; void UpdateZoneDependentAuras(uint32 zone_id); // zones void UpdateAreaDependentAuras(uint32 area_id); // subzones @@ -1935,15 +1935,15 @@ class Player : public Unit, public GridObject float GetHealthBonusFromStamina(); float GetManaBonusFromIntellect(); - bool UpdateStats(Stats stat); - bool UpdateAllStats(); + bool UpdateStats(Stats stat) override; + bool UpdateAllStats() override; void ApplySpellPenetrationBonus(int32 amount, bool apply); - void UpdateResistances(uint32 school); - void UpdateArmor(); - void UpdateMaxHealth(); - void UpdateMaxPower(Powers power); + void UpdateResistances(uint32 school) override; + void UpdateArmor() override; + void UpdateMaxHealth() override; + void UpdateMaxPower(Powers power) override; void ApplyFeralAPBonus(int32 amount, bool apply); - void UpdateAttackPowerAndDamage(bool ranged = false); + void UpdateAttackPowerAndDamage(bool ranged = false) override; void UpdateShieldBlockValue(); void ApplySpellPowerBonus(int32 amount, bool apply); void UpdateSpellDamageAndHealingBonus(); @@ -1951,7 +1951,7 @@ class Player : public Unit, public GridObject void UpdateRating(CombatRating cr); void UpdateAllRatings(); - void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage); + void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) override; void UpdateDefenseBonusesMod(); inline void RecalculateRating(CombatRating cr) { ApplyRatingMod(cr, 0, true);} @@ -1993,8 +1993,8 @@ class Player : public Unit, public GridObject WorldSession* GetSession() const { return m_session; } void SetSession(WorldSession* sess) { m_session = sess; } - void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const; - void DestroyForPlayer(Player* target, bool onDeath = false) const; + void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const override; + void DestroyForPlayer(Player* target, bool onDeath = false) const override; void SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend = false, float group_rate=1.0f); // notifiers @@ -2013,14 +2013,14 @@ class Player : public Unit, public GridObject void SendResetInstanceFailed(uint32 reason, uint32 MapId); void SendResetFailedNotify(uint32 mapid); - virtual bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false); + virtual bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false) override; bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } - void UpdateUnderwaterState(Map* m, float x, float y, float z); + void UpdateUnderwaterState(Map* m, float x, float y, float z) override; - void SendMessageToSet(WorldPacket* data, bool self) { SendMessageToSetInRange(data, GetVisibilityRange(), self, true); } // pussywizard! - void SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool includeMargin = false, Player const* skipped_rcvr = NULL); // pussywizard! + void SendMessageToSet(WorldPacket* data, bool self) override { SendMessageToSetInRange(data, GetVisibilityRange(), self, true); } // pussywizard! + void SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool includeMargin = false, Player const* skipped_rcvr = NULL) override; // pussywizard! void SendMessageToSetInRange_OwnTeam(WorldPacket* data, float dist, bool self); // pussywizard! param includeMargin not needed here - void SendMessageToSet(WorldPacket* data, Player const* skipped_rcvr) { SendMessageToSetInRange(data, GetVisibilityRange(), skipped_rcvr != this, true, skipped_rcvr); } // pussywizard! + void SendMessageToSet(WorldPacket* data, Player const* skipped_rcvr) override { SendMessageToSetInRange(data, GetVisibilityRange(), skipped_rcvr != this, true, skipped_rcvr); } // pussywizard! void SendTeleportAckPacket(); @@ -2156,7 +2156,7 @@ class Player : public Unit, public GridObject int32 CalculateCorpseReclaimDelay(bool load = false); void SendCorpseReclaimDelay(uint32 delay); - uint32 GetShieldBlockValue() const; // overwrite Unit version (virtual) + uint32 GetShieldBlockValue() const override; // overwrite Unit version (virtual) bool CanParry() const { return m_canParry; } void SetCanParry(bool value); bool CanBlock() const { return m_canBlock; } @@ -2387,12 +2387,12 @@ class Player : public Unit, public GridObject bool HaveAtClient(WorldObject const* u) const { return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end(); } bool HaveAtClient(uint64 guid) const { return guid == GetGUID() || m_clientGUIDs.find(guid) != m_clientGUIDs.end(); } - bool IsNeverVisible() const; + bool IsNeverVisible() const override; bool IsVisibleGloballyFor(Player const* player) const; void GetInitialVisiblePackets(Unit* target); - void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false); + void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false) override; void UpdateVisibilityForPlayer(bool mapChange = false); void UpdateVisibilityOf(WorldObject* target); void UpdateTriggerVisibility(); @@ -2485,8 +2485,8 @@ class Player : public Unit, public GridObject MapReference &GetMapRef() { return m_mapRef; } // Set map to player and add reference - void SetMap(Map* map); - void ResetMap(); + void SetMap(Map* map) override; + void ResetMap() override; bool isAllowedToLoot(const Creature* creature); @@ -2542,13 +2542,13 @@ class Player : public Unit, public GridObject void AddWhisperWhiteList(uint64 guid) { WhisperList.push_back(guid); } bool IsInWhisperWhiteList(uint64 guid); - bool SetDisableGravity(bool disable, bool packetOnly /* = false */); - bool SetCanFly(bool apply, bool packetOnly = false); - bool SetWaterWalking(bool apply, bool packetOnly = false); - bool SetFeatherFall(bool apply, bool packetOnly = false); - bool SetHover(bool enable, bool packetOnly = false); + bool SetDisableGravity(bool disable, bool packetOnly /* = false */) override; + bool SetCanFly(bool apply, bool packetOnly = false) override; + bool SetWaterWalking(bool apply, bool packetOnly = false) override; + bool SetFeatherFall(bool apply, bool packetOnly = false) override; + bool SetHover(bool enable, bool packetOnly = false) override; - bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); } + bool CanFly() const override { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); } //! Return collision height sent to client float GetCollisionHeight(bool mounted) @@ -2899,9 +2899,9 @@ class Player : public Unit, public GridObject Runes *m_runes; EquipmentSets m_EquipmentSets; - bool CanAlwaysSee(WorldObject const* obj) const; + bool CanAlwaysSee(WorldObject const* obj) const override; - bool IsAlwaysDetectableFor(WorldObject const* seer) const; + bool IsAlwaysDetectableFor(WorldObject const* seer) const override; uint8 m_grantableLevels; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 7e37feb74..519e1e7a0 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -18477,6 +18477,20 @@ bool Unit::IsFalling() const return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR) || movespline->isFalling(); } +bool Unit::CanSwim() const +{ + // Mirror client behavior, if this method returns false then client will not use swimming animation and for players will apply gravity as if there was no water + if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CANNOT_SWIM)) + return false; + if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)) // is player + return true; + if (HasFlag(UNIT_FIELD_FLAGS_2, 0x1000000)) + return false; + if (IsPet() && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT)) + return true; + return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_RENAME | UNIT_FLAG_UNK_15); +} + void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool casting /*= false*/, bool vehicleTeleport /*= false*/, bool withPet /*= false*/, bool removeTransport /*= false*/) { DisableSpline(); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 09bfa2342..dfae9c1e7 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -584,7 +584,7 @@ enum UnitFlags 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_UNK_14 = 0x00004000, // 2.0.8 + 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 @@ -1370,11 +1370,11 @@ class Unit : public WorldObject UnitAI* GetAI() { return i_AI; } void SetAI(UnitAI* newAI) { i_AI = newAI; } - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; void CleanupBeforeRemoveFromMap(bool finalCleanup); - void CleanupsBeforeDelete(bool finalCleanup = true); // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units) + void CleanupsBeforeDelete(bool finalCleanup = true) override; // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units) DiminishingLevels GetDiminishing(DiminishingGroup group); void IncrDiminishing(DiminishingGroup group); @@ -1386,7 +1386,7 @@ class Unit : public WorldObject float GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; float GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; - virtual void Update(uint32 time); + virtual void Update(uint32 time) override; void setAttackTimer(WeaponAttackType type, int32 time) { m_attackTimer[type] = time; } void resetAttackTimer(WeaponAttackType type = BASE_ATTACK); @@ -1395,7 +1395,7 @@ class Unit : public WorldObject bool haveOffhandWeapon() const; bool CanDualWield() const { return m_canDualWield; } virtual void SetCanDualWield(bool value) { m_canDualWield = value; } - float GetCombatReach() const { return m_floatValues[UNIT_FIELD_COMBATREACH]; } + float GetCombatReach() const override { return m_floatValues[UNIT_FIELD_COMBATREACH]; } float GetMeleeReach() const { float reach = m_floatValues[UNIT_FIELD_COMBATREACH]; return reach > MIN_MELEE_REACH ? reach : MIN_MELEE_REACH; } bool IsWithinCombatRange(const Unit* obj, float dist2compare) const; bool IsWithinMeleeRange(const Unit* obj, float dist = MELEE_RANGE) const; @@ -1458,7 +1458,7 @@ class Unit : public WorldObject bool IsVehicle() const { return m_unitTypeMask & UNIT_MASK_VEHICLE; } uint8 getLevel() const { return uint8(GetUInt32Value(UNIT_FIELD_LEVEL)); } - uint8 getLevelForTarget(WorldObject const* /*target*/) const { return getLevel(); } + uint8 getLevelForTarget(WorldObject const* /*target*/) const override { return getLevel(); } void SetLevel(uint8 lvl, bool showLevelChange = true); uint8 getRace(bool original = false) const; void setRace(uint8 race); @@ -2128,8 +2128,8 @@ class Unit : public WorldObject // common function for visibility checks for player/creatures with detection code uint32 GetPhaseByAuras() const; - void SetPhaseMask(uint32 newPhaseMask, bool update);// overwrite WorldObject::SetPhaseMask - void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false); + void SetPhaseMask(uint32 newPhaseMask, bool update) override;// overwrite WorldObject::SetPhaseMask + void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false) override; SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]; uint32 m_lastSanctuaryTime; @@ -2335,7 +2335,7 @@ class Unit : public WorldObject bool IsOnVehicle(const Unit* vehicle) const { return m_vehicle && m_vehicle == vehicle->GetVehicleKit(); } Unit* GetVehicleBase() const; Creature* GetVehicleCreatureBase() const; - uint64 GetTransGUID() const; + uint64 GetTransGUID() const override; /// Returns the transport this unit is on directly (if on vehicle and transport, return vehicle) TransportBase* GetDirectTransport() const; @@ -2354,11 +2354,13 @@ class Unit : public WorldObject void BuildMovementPacket(ByteBuffer *data) const; + virtual bool CanSwim() const; bool isMoving() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_MASK_MOVING); } bool isTurning() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_MASK_TURNING); } - virtual bool CanFly() const = 0; - bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_DISABLE_GRAVITY); } bool IsHovering() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_HOVER); } + bool isSwimming() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_SWIMMING); } + virtual bool CanFly() const = 0; + bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_DISABLE_GRAVITY); } bool IsFalling() const; float GetHoverHeight() const { return IsHovering() ? GetFloatValue(UNIT_FIELD_HOVERHEIGHT) : 0.0f; } @@ -2409,9 +2411,9 @@ class Unit : public WorldObject bool m_last_outdoors_status; bool IsOutdoors() const; - uint32 GetZoneId(bool forceRecalc = false) const; - uint32 GetAreaId(bool forceRecalc = false) const; - void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, bool forceRecalc = false) const; + uint32 GetZoneId(bool forceRecalc = false) const override; + uint32 GetAreaId(bool forceRecalc = false) const override; + void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, bool forceRecalc = false) const override; // cooldowns virtual bool HasSpellCooldown(uint32 /*spell_id*/) const { return false; } @@ -2440,7 +2442,7 @@ class Unit : public WorldObject protected: explicit Unit (bool isWorldObject); - void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const; + void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const override; UnitAI* i_AI, *i_disabledAI; @@ -2515,8 +2517,8 @@ class Unit : public WorldObject // xinef: apply resilience bool m_applyResilience; - bool IsAlwaysVisibleFor(WorldObject const* seer) const; - bool IsAlwaysDetectableFor(WorldObject const* seer) const; + bool IsAlwaysVisibleFor(WorldObject const* seer) const override; + bool IsAlwaysDetectableFor(WorldObject const* seer) const override; bool _instantCast; private: diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 6f039bd1f..71b4bdc78 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -1899,12 +1899,12 @@ GridMap* Map::GetGrid(float x, float y) return GridMaps[gx][gy]; } -float Map::GetWaterOrGroundLevel(float x, float y, float z, float* ground /*= NULL*/, bool /*swim = false*/, float maxSearchDist /*= 50.0f*/) const +float Map::GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float* ground /*= NULL*/, bool /*swim = false*/, float maxSearchDist /*= 50.0f*/) const { if (const_cast(this)->GetGrid(x, y)) { // we need ground level (including grid height version) for proper return water level in point - float ground_z = GetHeight(PHASEMASK_NORMAL, x, y, z, true, maxSearchDist); + float ground_z = GetHeight(phasemask, x, y, z, true, maxSearchDist); if (ground) *ground = ground_z; diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index d516d8c3a..fe67c2a08 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -470,7 +470,7 @@ class Map : public GridRefManager BattlegroundMap* ToBattlegroundMap() { if (IsBattlegroundOrArena()) return reinterpret_cast(this); else return NULL; } const BattlegroundMap* ToBattlegroundMap() const { if (IsBattlegroundOrArena()) return reinterpret_cast(this); return NULL; } - float GetWaterOrGroundLevel(float x, float y, float z, float* ground = NULL, bool swim = false, float maxSearchDist = 50.0f) const; + float GetWaterOrGroundLevel(uint32 phasemask,float x, float y, float z, float* ground = NULL, bool swim = false, float maxSearchDist = 50.0f) const; float GetHeight(uint32 phasemask, float x, float y, float z, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const; bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks) const; void Balance() { _dynamicTree.balance(); } diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp index 4fd224ab5..21b3486c0 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp @@ -62,7 +62,7 @@ void RandomMovementGenerator::_setRandomLocation(Creature* creature) } float ground = INVALID_HEIGHT; - float levelZ = map->GetWaterOrGroundLevel(x, y, z+4.0f, &ground); + float levelZ = map->GetWaterOrGroundLevel(creature->GetPhaseMask(), x, y, z+4.0f, &ground); float newZ = INVALID_HEIGHT; // flying creature diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index 4c76aa74e..f9350ca84 100644 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -346,6 +346,9 @@ void FlightPathMovementGenerator::DoReset(Player* player) bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/) { + if (!player) + return false; + // xinef: map was switched if (_mapSwitch) { diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index d09face2e..e8ba40aad 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -881,7 +881,7 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo* mi) MOVEMENTFLAG_ROOT); //! Cannot hover without SPELL_AURA_HOVER - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_HOVER) && !GetPlayer()->m_mover->HasAuraType(SPELL_AURA_HOVER), // pussywizard: added m_mover + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_HOVER) && !GetPlayer()->HasAuraType(SPELL_AURA_HOVER), MOVEMENTFLAG_HOVER); //! Cannot ascend and descend at the same time @@ -905,11 +905,13 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo* mi) MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_BACKWARD); //! Cannot walk on water without SPELL_AURA_WATER_WALK - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_WATERWALKING) && !GetPlayer()->m_mover->HasAuraType(SPELL_AURA_WATER_WALK), // pussywizard: added m_mover + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_WATERWALKING) && + !GetPlayer()->HasAuraType(SPELL_AURA_WATER_WALK) && + !GetPlayer()->HasAuraType(SPELL_AURA_GHOST), MOVEMENTFLAG_WATERWALKING); //! Cannot feather fall without SPELL_AURA_FEATHER_FALL - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_FALLING_SLOW) && !GetPlayer()->m_mover->HasAuraType(SPELL_AURA_FEATHER_FALL), // pussywizard: added m_mover + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_FALLING_SLOW) && !GetPlayer()->HasAuraType(SPELL_AURA_FEATHER_FALL), MOVEMENTFLAG_FALLING_SLOW); /*! Cannot fly if no fly auras present. Exception is being a GM. @@ -918,23 +920,17 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo* mi) e.g. aerial combat. */ - // pussywizard: remade this condition - bool canFly = GetPlayer()->m_mover->HasAuraType(SPELL_AURA_FLY) || GetPlayer()->m_mover->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || - (GetPlayer()->m_mover->GetTypeId() == TYPEID_UNIT && GetPlayer()->m_mover->ToCreature()->CanFly()) || GetSecurity() > SEC_PLAYER; - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_CAN_FLY) && !canFly, + + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_CAN_FLY) && GetSecurity() == SEC_PLAYER && !GetPlayer()->m_mover->HasAuraType(SPELL_AURA_FLY) && !GetPlayer()->m_mover->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED), MOVEMENTFLAG_FLYING | MOVEMENTFLAG_CAN_FLY); - // pussywizard: added condition for disable gravity - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY) && (GetPlayer()->m_mover->GetTypeId() == TYPEID_PLAYER || !canFly), - MOVEMENTFLAG_DISABLE_GRAVITY); - //! Cannot fly and fall at the same time REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DISABLE_GRAVITY) && mi->HasMovementFlag(MOVEMENTFLAG_FALLING), MOVEMENTFLAG_FALLING); - // Xinef: Spline enabled flag should be never sent by client, its internal movementflag - REMOVE_VIOLATING_FLAGS(!GetPlayer()->m_mover->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_SPLINE_ENABLED), - MOVEMENTFLAG_SPLINE_ENABLED); + + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_SPLINE_ENABLED) && + (!GetPlayer()->movespline->Initialized() || GetPlayer()->movespline->Finalized()), MOVEMENTFLAG_SPLINE_ENABLED); #undef REMOVE_VIOLATING_FLAGS } diff --git a/src/server/scripts/Northrend/zone_sholazar_basin.cpp b/src/server/scripts/Northrend/zone_sholazar_basin.cpp index 34ffe4f71..d5acc3a94 100644 --- a/src/server/scripts/Northrend/zone_sholazar_basin.cpp +++ b/src/server/scripts/Northrend/zone_sholazar_basin.cpp @@ -1273,7 +1273,7 @@ public: Unit::Kill(bird, bird); crunchy->GetMotionMaster()->MovePoint(0, bird->GetPositionX(), bird->GetPositionY(), - bird->GetMap()->GetWaterOrGroundLevel(bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ())); + bird->GetMap()->GetWaterOrGroundLevel(bird->GetPhaseMask(), bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ())); /// @todo Make crunchy perform emote eat when he reaches the bird break;