From cd9acb7d05295b34196b92b1cb52520c72faadf1 Mon Sep 17 00:00:00 2001 From: Aokromes Date: Tue, 19 Jul 2016 17:15:06 +0200 Subject: [PATCH] Core/Spells: Fixed overwriting summon requests --- src/server/game/Entities/Player/Player.cpp | 49 +++++++++++----------- src/server/game/Entities/Player/Player.h | 20 ++++----- src/server/game/Miscellaneous/Language.h | 2 +- src/server/game/Spells/Spell.cpp | 3 ++ src/server/game/Spells/SpellEffects.cpp | 15 +------ src/server/scripts/Commands/cs_misc.cpp | 2 +- 6 files changed, 39 insertions(+), 52 deletions(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index ad515c0319..a1c0f2496d 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -471,20 +471,11 @@ Player::Player(WorldSession* session): Unit(true) // Player summoning m_summon_expire = 0; - m_summon_mapid = 0; - m_summon_x = 0.0f; - m_summon_y = 0.0f; - m_summon_z = 0.0f; m_mover = this; m_movedPlayer = this; m_seer = this; - m_recallMap = 0; - m_recallX = 0; - m_recallY = 0; - m_recallZ = 0; - m_recallO = 0; m_homebindMapId = 0; m_homebindAreaId = 0; @@ -6316,15 +6307,6 @@ bool Player::UpdatePosition(float x, float y, float z, float orientation, bool t return true; } -void Player::SaveRecallPosition() -{ - m_recallMap = GetMapId(); - m_recallX = GetPositionX(); - m_recallY = GetPositionY(); - m_recallZ = GetPositionZ(); - m_recallO = GetOrientation(); -} - void Player::SendMessageToSetInRange(WorldPacket* data, float dist, bool self) { if (self) @@ -23787,13 +23769,32 @@ void Player::UpdateForQuestWorldObjects() GetSession()->SendPacket(&packet); } -void Player::SetSummonPoint(uint32 mapid, float x, float y, float z) +bool Player::HasSummonPending() const { + return m_summon_expire >= time(nullptr); +} + +void Player::SendSummonRequestFrom(Unit* summoner) +{ + if (!summoner) + return; + + // Player already has active summon request + if (HasSummonPending()) + return; + + // Evil Twin (ignore player summon, but hide this for summoner) + if (HasAura(23445)) + return; + m_summon_expire = time(nullptr) + MAX_PLAYER_SUMMON_DELAY; - m_summon_mapid = mapid; - m_summon_x = x; - m_summon_y = y; - m_summon_z = z; + m_summon_location.WorldRelocate(*summoner); + + WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); + data << uint64(summoner->GetGUID()); // summoner guid + data << uint32(summoner->GetZoneId()); // summoner zone + data << uint32(MAX_PLAYER_SUMMON_DELAY*IN_MILLISECONDS); // auto decline after msecs + GetSession()->SendPacket(&data); } void Player::SummonIfPossible(bool agree) @@ -23824,7 +23825,7 @@ void Player::SummonIfPossible(bool agree) UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS, 1); - TeleportTo(m_summon_mapid, m_summon_x, m_summon_y, m_summon_z, GetOrientation()); + TeleportTo(m_summon_location); } void Player::RemoveItemDurations(Item* item) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 0729c00c79..04ae760fb2 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1230,7 +1230,8 @@ class Player : public Unit, public GridObject bool TeleportTo(WorldLocation const &loc, uint32 options = 0); bool TeleportToBGEntryPoint(); - void SetSummonPoint(uint32 mapid, float x, float y, float z); + bool HasSummonPending() const; + void SendSummonRequestFrom(Unit* summoner); void SummonIfPossible(bool agree); bool Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo); @@ -2304,13 +2305,8 @@ class Player : public Unit, public GridObject uint32 GetSaveTimer() const { return m_nextSave; } void SetSaveTimer(uint32 timer) { m_nextSave = timer; } - // Recall position - uint32 m_recallMap; - float m_recallX; - float m_recallY; - float m_recallZ; - float m_recallO; - void SaveRecallPosition(); + void SaveRecallPosition() { m_recall_location.WorldRelocate(*this); } + void Recall() { TeleportTo(m_recall_location); } void SetHomebind(WorldLocation const& loc, uint32 areaId); @@ -2771,10 +2767,10 @@ class Player : public Unit, public GridObject // Player summoning time_t m_summon_expire; - uint32 m_summon_mapid; - float m_summon_x; - float m_summon_y; - float m_summon_z; + WorldLocation m_summon_location; + + // Recall position + WorldLocation m_recall_location; DeclinedName *m_declinedname; Runes *m_runes; diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index d2641cd82e..bcb925b9dc 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -1063,7 +1063,7 @@ enum TrinityStrings LANG_COMMAND_NO_FROZEN_PLAYERS = 5004, LANG_COMMAND_LIST_FREEZE = 5005, LANG_COMMAND_PERMA_FROZEN_PLAYER = 5006, - LANG_INSTANCE_RAID_GROUP_ONLY = 5007, + // = 5007, unused LANG_INSTANCE_CLOSED = 5008, LANG_COMMAND_PLAYED_TO_ALL = 5009, LANG_NPCINFO_LINKGUID = 5010, diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 4582590b77..8b66651b1f 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5395,6 +5395,9 @@ SpellCastResult Spell::CheckCast(bool strict) if (!target || m_caster->ToPlayer() == target || (!target->IsInSameRaidWith(m_caster->ToPlayer()) && m_spellInfo->Id != 48955)) // refer-a-friend spell return SPELL_FAILED_BAD_TARGETS; + if (target->HasSummonPending()) + return SPELL_FAILED_SUMMON_PENDING; + // check if our map is dungeon MapEntry const* map = sMapStore.LookupEntry(m_caster->GetMapId()); if (map->IsDungeon()) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index cd5215f9ea..c1cc6986d1 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -3925,20 +3925,7 @@ void Spell::EffectSummonPlayer(SpellEffIndex /*effIndex*/) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - // Evil Twin (ignore player summon, but hide this for summoner) - if (unitTarget->HasAura(23445)) - return; - - float x, y, z; - m_caster->GetPosition(x, y, z); - - unitTarget->ToPlayer()->SetSummonPoint(m_caster->GetMapId(), x, y, z); - - WorldPacket data(SMSG_SUMMON_REQUEST, 8+4+4); - data << uint64(m_caster->GetGUID()); // summoner guid - data << uint32(m_caster->GetZoneId()); // summoner zone - data << uint32(MAX_PLAYER_SUMMON_DELAY*IN_MILLISECONDS); // auto decline after msecs - unitTarget->ToPlayer()->GetSession()->SendPacket(&data); + unitTarget->ToPlayer()->SendSummonRequestFrom(m_caster); } void Spell::EffectActivateObject(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 15bb9d424c..49e65346a0 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -811,7 +811,7 @@ public: target->CleanupAfterTaxiFlight(); } - target->TeleportTo(target->m_recallMap, target->m_recallX, target->m_recallY, target->m_recallZ, target->m_recallO); + target->Recall(); return true; }