Core/Spells: Fixed overwriting summon requests

Closes #17049
This commit is contained in:
Incorrect
2016-05-01 12:31:55 +02:00
committed by Shauren
parent 775b03bf6f
commit 1aa30d3cce
8 changed files with 50 additions and 63 deletions
@@ -0,0 +1 @@
DELETE FROM `trinity_string` WHERE `entry`=5007;
+28 -28
View File
@@ -477,21 +477,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;
m_homebindX = 0;
@@ -6374,15 +6364,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)
@@ -23209,13 +23190,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)
@@ -23246,7 +23246,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)
@@ -26352,10 +26352,10 @@ void Player::UpdateCinematicLocation(uint32 /*diff*/)
float xDiff = nextPosition.m_positionX - lastPosition.m_positionX;
float yDiff = nextPosition.m_positionY - lastPosition.m_positionY;
float zDiff = nextPosition.m_positionZ - lastPosition.m_positionZ;
Position interPosition(lastPosition.m_positionX + (xDiff * (float(interDiff)/float(timeDiff))), lastPosition.m_positionY +
Position interPosition(lastPosition.m_positionX + (xDiff * (float(interDiff)/float(timeDiff))), lastPosition.m_positionY +
(yDiff * (float(interDiff) / float(timeDiff))), lastPosition.m_positionZ + (zDiff * (float(interDiff) / float(timeDiff))));
// Advance (at speed) to this position. The remote sight object is used
// Advance (at speed) to this position. The remote sight object is used
// to send update information to player in cinematic
if (m_CinematicObject && interPosition.IsPositionValid())
m_CinematicObject->MonsterMoveWithSpeed(interPosition.m_positionX, interPosition.m_positionY, interPosition.m_positionZ, 200.0f, false, true);
+8 -12
View File
@@ -1050,7 +1050,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
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);
@@ -2077,13 +2078,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
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);
@@ -2516,10 +2512,10 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
// 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;
+7 -7
View File
@@ -884,15 +884,15 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData)
player->SendTransferAborted(entry->MapID, TRANSFER_ABORT_DIFFICULTY, player->GetDifficulty(entry->IsRaid()));
break;
case Map::CANNOT_ENTER_NOT_IN_RAID:
if (MapEntry const* entry = sMapStore.LookupEntry(at->target_mapId))
{
char const* mapName = entry->name[player->GetSession()->GetSessionDbcLocale()];
TC_LOG_DEBUG("maps", "MAP: Player '%s' must be in a raid group to enter instance '%s'", player->GetName().c_str(), mapName);
// probably there must be special opcode, because client has this string constant in GlobalStrings.lua
player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetTrinityString(LANG_INSTANCE_RAID_GROUP_ONLY), mapName);
}
{
WorldPacket data(SMSG_RAID_GROUP_ONLY, 4 + 4);
data << uint32(0);
data << uint32(2); // You must be in a raid group to enter this instance.
player->GetSession()->SendPacket(&data);
TC_LOG_DEBUG("maps", "MAP: Player '%s' must be in a raid group to enter instance map %d", player->GetName().c_str(), at->target_mapId);
reviveAtTrigger = true;
break;
}
case Map::CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE:
{
WorldPacket data(SMSG_CORPSE_NOT_IN_INSTANCE);
+1 -1
View File
@@ -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,
+3
View File
@@ -5324,6 +5324,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())
+1 -14
View File
@@ -4212,20 +4212,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*/)
+1 -1
View File
@@ -796,7 +796,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;
}