diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index a24f97dcd3..abf987d743 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -172,7 +172,6 @@ Player::Player(WorldSession* session): Unit(true) m_comboPoints = 0; m_foodEmoteTimerCount = 0; - m_previousLiquidStatus = GetLiquidStatus(); m_weaponChangeTimer = 0; m_zoneUpdateId = uint32(-1); @@ -5450,7 +5449,11 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal) LearnSkillRewardedSpells(id, newVal); // if skill value is going up, update enchantments after setting the new value if (newVal > currVal) + { UpdateSkillEnchantments(id, currVal, newVal); + if (id == SKILL_RIDING) + UpdateMountCapability(); + } UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id); UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id); @@ -5861,14 +5864,6 @@ bool Player::UpdatePosition(float x, float y, float z, float orientation, bool t } CheckAreaExploreAndOutdoor(); - - // Update mount capabilities - if (m_previousLiquidStatus != GetLiquidStatus()) - { - UpdateMountCapabilities(); - m_previousLiquidStatus = GetLiquidStatus(); - } - return true; } @@ -6996,6 +6991,8 @@ void Player::UpdateArea(uint32 newArea) SetRestFlag(REST_FLAG_IN_FACTION_AREA); else RemoveRestFlag(REST_FLAG_IN_FACTION_AREA); + + UpdateMountCapability(); } void Player::UpdateZone(uint32 newZone, uint32 newArea) @@ -18469,33 +18466,6 @@ void Player::AddToPlayerPetDataStore(PlayerPetData* playerPetData) PlayerPetDataStore.push_back(playerPetData); } -void Player::UpdateMountCapabilities() -{ - if (HasAuraType(SPELL_AURA_MOUNTED)) - { - for (AuraEffect* aurEff : GetAuraEffectsByType(SPELL_AURA_MOUNTED)) - { - MountCapabilityEntry const* capability = GetMountCapability(uint32(aurEff->GetMiscValueB())); - if (!capability) - { - // No mount capabilitiy found, remove aura - if (Aura* aura = aurEff->GetBase()) - aura->Remove(); - continue; - } - - if (capability->ID != uint32(aurEff->GetAmount())) - { - if (MountCapabilityEntry const* oldMountCapability = sMountCapabilityStore.LookupEntry(aurEff->GetAmount())) - RemoveAurasDueToSpell(oldMountCapability->ModSpellAuraID, aurEff->GetCasterGUID()); - - CastSpell(this, capability->ModSpellAuraID, true); - aurEff->SetAmount(capability->ID); - } - } - } -} - void Player::_LoadQuestStatus(PreparedQueryResult result) { uint16 slot = 0; @@ -25878,7 +25848,10 @@ bool Player::SetDisableGravity(bool disable, bool /*packetOnly = false*/, bool / if (disable == IsGravityDisabled()) return false; - MovementPacketSender::SendMovementFlagChangeToMover(this, MOVEMENTFLAG_DISABLE_GRAVITY, disable); + if (IsMovedByClient() && IsInWorld()) + MovementPacketSender::SendMovementFlagChangeToMover(this, MOVEMENTFLAG_DISABLE_GRAVITY, disable); + else if (IsMovedByClient() && !IsInWorld()) // (1) + Unit::SetDisableGravity(disable, false, false); return true; } @@ -25888,7 +25861,10 @@ bool Player::SetCanFly(bool enable, bool /*packetOnly = false*/) if (enable == HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY)) return false; - MovementPacketSender::SendMovementFlagChangeToMover(this, MOVEMENTFLAG_CAN_FLY, enable); + if (IsMovedByClient() && IsInWorld()) + MovementPacketSender::SendMovementFlagChangeToMover(this, MOVEMENTFLAG_CAN_FLY, enable); + else if (IsMovedByClient() && !IsInWorld()) // (1) + Unit::SetCanFly(enable); return true; } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 2c0687a595..85681e3e87 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -2384,9 +2384,6 @@ class TC_GAME_API Player : public Unit, public GridObject void DeleteFromPlayerPetDataStore(uint32 petNumber); void AddToPlayerPetDataStore(PlayerPetData* playerPetData); - // Mount Capabilites - void UpdateMountCapabilities(); - uint32 GetTransportSpawnID() const { return _transportSpawnID; } void SetTransportSpawnID(uint32 spawnId) { _transportSpawnID = spawnId; } @@ -2395,7 +2392,6 @@ class TC_GAME_API Player : public Unit, public GridObject GuidList WhisperList; uint32 m_foodEmoteTimerCount; uint32 m_contestedPvPTimer; - ZLiquidStatus m_previousLiquidStatus; /*********************************************************/ /*** BATTLEGROUND SYSTEM ***/ diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 8143ab2c3c..700428c365 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3219,7 +3219,7 @@ void Unit::ProcessPositionDataChanged(PositionFullTerrainStatus const& data) void Unit::ProcessTerrainStatusUpdate(ZLiquidStatus status, Optional const& liquidData) { - if (IsFlying() || (!IsControlledByPlayer())) + if (!IsControlledByPlayer()) return; // remove appropriate auras if we are swimming/not swimming respectively @@ -3243,6 +3243,9 @@ void Unit::ProcessTerrainStatusUpdate(ZLiquidStatus status, Optional if (curLiquid && curLiquid->SpellID && (!player || !player->IsGameMaster())) CastSpell(this, curLiquid->SpellID, true); + + // mount capability depends on liquid state change + UpdateMountCapability(); } } void Unit::DeMorph() @@ -8290,7 +8293,7 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const uint32 areaId = GetAreaId(); uint32 ridingSkill = 5000; uint32 mountFlags = 0; - bool isUnderwater = false; + bool isSubmerged = false; bool isInWater = false; if (GetTypeId() == TYPEID_PLAYER) @@ -8305,7 +8308,7 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const mountFlags = areaTable->MountFlags; ZLiquidStatus liquidStatus = GetLiquidStatus(); - isUnderwater = (liquidStatus & LIQUID_MAP_UNDER_WATER) != 0; + isSubmerged = (liquidStatus & LIQUID_MAP_UNDER_WATER) != 0 || HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING); isInWater = (liquidStatus & LIQUID_MAP_IN_WATER) != 0; for (uint32 i = MAX_MOUNT_CAPABILITIES; i > 0; --i) @@ -8329,16 +8332,24 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const continue; } - // Do not allow underwater restricted capabilities when not underwater - if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_UNDERWATER) && isUnderwater) - continue; - // Do not allow water surface restricted capabilities when not on water surface - if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_FLOAT) && isInWater) - continue; - - // Do not allow liquid restricted mounts on ground or in air - if (!(mountCapability->Flags & (MOUNT_CAPABILITY_FLAG_GROUND | MOUNT_CAPABILITY_FLAG_FLYING)) && !isUnderwater && !isInWater) + if (!isSubmerged) + { + if (!isInWater) + { + // player is completely out of water + if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_GROUND)) + continue; + } + else if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_UNDERWATER)) + continue; + } + else if (isInWater) + { + if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_UNDERWATER)) + continue; + } + else if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_FLOAT)) continue; if (mountCapability->ReqMapID != -1 && @@ -8361,6 +8372,20 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const return nullptr; } +void Unit::UpdateMountCapability() +{ + AuraEffectList mounts = GetAuraEffectsByType(SPELL_AURA_MOUNTED); + for (AuraEffect* aurEff : mounts) + { + aurEff->RecalculateAmount(); + if (!aurEff->GetAmount()) + aurEff->GetBase()->Remove(); + else if (MountCapabilityEntry const* capability = sMountCapabilityStore.LookupEntry(aurEff->GetAmount())) // aura may get removed by interrupt flag, reapply + if (!HasAura(capability->ModSpellAuraID)) + CastSpell(this, capability->ModSpellAuraID, aurEff); + } +} + bool Unit::IsServiceProvider() const { return HasFlag(UNIT_NPC_FLAGS, @@ -14259,10 +14284,12 @@ bool Unit::SetCanFly(bool enable, bool packetOnly) player->SendMovementSetCanTransitionBetweenSwimAndFly(enable); } - if (enable) - Movement::PacketSender(this, SMSG_SPLINE_MOVE_SET_FLYING, SMSG_MOVE_SET_CAN_FLY).Send(); - else - Movement::PacketSender(this, SMSG_SPLINE_MOVE_UNSET_FLYING, SMSG_MOVE_UNSET_CAN_FLY).Send(); + if (IsCreature()) + { + WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_FLYING : SMSG_SPLINE_MOVE_UNSET_FLYING); + WriteMovementInfo(data); + SendMessageToSet(&data, false); + } return true; } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 8b60513162..e7340b61b5 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1023,6 +1023,7 @@ class TC_GAME_API Unit : public WorldObject void Mount(uint32 mount, uint32 vehicleId = 0, uint32 creatureEntry = 0); void Dismount(); MountCapabilityEntry const* GetMountCapability(uint32 mountType) const; + void UpdateMountCapability(); void SendDurabilityLoss(Player* receiver, uint32 percent); void PlayOneShotAnimKitId(uint16 animKitId); diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 436ea45bf7..534f9d45ca 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -959,7 +959,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder const& holder) pCurrChar->UpdatePositionData(); pCurrChar->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Login); - pCurrChar->UpdateMountCapabilities(); pCurrChar->SendInitialPacketsAfterAddToMap(); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ONLINE); diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index 0046d27c67..8e30304e68 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -145,7 +145,6 @@ void WorldSession::HandleMoveWorldportAck() } } - GetPlayer()->UpdateMountCapabilities(); GetPlayer()->SendInitialPacketsAfterAddToMap(); // flight fast teleport case @@ -698,7 +697,7 @@ void WorldSession::HandleMoveSetCanTransitionBetweenSwinAndFlyAck(WorldPacket& r void WorldSession::HandleMoveGravityDisableAck(WorldPacket& recvData) { - TC_LOG_DEBUG("network", GetOpcodeNameForLogging(static_cast(recvData.GetOpcode())).c_str()); + TC_LOG_DEBUG("network", "received %s", GetOpcodeNameForLogging(static_cast(recvData.GetOpcode())).c_str()); MovementInfo movementInfo; GetPlayer()->ReadMovementInfo(recvData, &movementInfo); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 70750e3718..4ad8825e08 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -2705,61 +2705,65 @@ void AuraEffect::HandleAuraModSkill(AuraApplication const* aurApp, uint8 mode, b void AuraEffect::HandleAuraMounted(AuraApplication const* aurApp, uint8 mode, bool apply) const { - if (!(mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK)) + if (!(mode & AURA_EFFECT_HANDLE_CHANGE_AMOUNT_SEND_FOR_CLIENT_MASK)) return; Unit* target = aurApp->GetTarget(); if (apply) { - uint32 creatureEntry = GetMiscValue(); - uint32 displayId = 0; - uint32 vehicleId = 0; - - // Festive Holiday Mount - if (target->HasAura(62061)) + if (mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK) { - if (GetBase()->HasEffectType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED)) - creatureEntry = 24906; - else - creatureEntry = 15665; + uint32 creatureEntry = GetMiscValue(); + uint32 displayId = 0; + uint32 vehicleId = 0; + + // Festive Holiday Mount + if (target->HasAura(62061)) + { + if (GetBase()->HasEffectType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED)) + creatureEntry = 24906; + else + creatureEntry = 15665; + } + + if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creatureEntry)) + { + displayId = ObjectMgr::ChooseDisplayId(creatureInfo); + sObjectMgr->GetCreatureModelRandomGender(&displayId); + + vehicleId = creatureInfo->VehicleId; + + //some spell has one aura of mount and one of vehicle + for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) + if (GetSpellInfo()->Effects[i].Effect == SPELL_EFFECT_SUMMON + && GetSpellInfo()->Effects[i].MiscValue == GetMiscValue()) + displayId = 0; + } + + target->Mount(displayId, vehicleId, creatureEntry); } - if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creatureEntry)) - { - displayId = ObjectMgr::ChooseDisplayId(creatureInfo); - sObjectMgr->GetCreatureModelRandomGender(&displayId); - - vehicleId = creatureInfo->VehicleId; - - //some spell has one aura of mount and one of vehicle - for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (GetSpellInfo()->Effects[i].Effect == SPELL_EFFECT_SUMMON - && GetSpellInfo()->Effects[i].MiscValue == GetMiscValue()) - displayId = 0; - } - - target->Mount(displayId, vehicleId, creatureEntry); - // cast speed aura - if (mode & AURA_EFFECT_HANDLE_REAL) + if (mode & AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK) if (MountCapabilityEntry const* mountCapability = sMountCapabilityStore.LookupEntry(GetAmount())) target->CastSpell(target, mountCapability->ModSpellAuraID, true); } else { - target->Dismount(); + if (mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK) + target->Dismount(); + //some mounts like Headless Horseman's Mount or broom stick are skill based spell // need to remove ALL arura related to mounts, this will stop client crash with broom stick // and never endless flying after using Headless Horseman's Mount if (mode & AURA_EFFECT_HANDLE_REAL) - { target->RemoveAurasByType(SPELL_AURA_MOUNTED); + if (mode & AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK) // remove speed aura if (MountCapabilityEntry const* mountCapability = sMountCapabilityStore.LookupEntry(GetAmount())) target->RemoveAurasDueToSpell(mountCapability->ModSpellAuraID, target->GetGUID()); - } } }