Merge pull request #80 from Olion17/develop21

[Core] Player::TeleportTo() signature change to request undelayed teleport
This commit is contained in:
Antz 2016-02-15 09:41:59 +00:00
commit f70bb75ba0
3 changed files with 33 additions and 37 deletions

View File

@ -1525,7 +1525,7 @@ ChatTagFlags Player::GetChatTag() const
return CHAT_TAG_NONE; return CHAT_TAG_NONE;
} }
bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options /*=0*/, AreaTrigger const* at /*=NULL*/) bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options /*=0*/, bool allowNoDelay /*=false*/)
{ {
if (!MapManager::IsValidMapCoord(mapid, x, y, z, orientation)) if (!MapManager::IsValidMapCoord(mapid, x, y, z, orientation))
{ {
@ -1550,30 +1550,12 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (!InBattleGround() && mEntry->IsBattleGround()) if (!InBattleGround() && mEntry->IsBattleGround())
{ return false; } { return false; }
// Get MapEntrance trigger if teleport to other -nonBG- map
bool assignedAreaTrigger = false;
if (GetMapId() != mapid && !mEntry->IsBattleGround() && !at)
{
at = sObjectMgr.GetMapEntranceTrigger(mapid);
assignedAreaTrigger = true;
}
// Check requirements for teleport // Check requirements for teleport
if (at) if (!IsAlive() && mEntry->IsDungeon()) // rare case of teleporting the player into an instance with no areatrigger participation
{
uint32 miscRequirement = 0;
AreaLockStatus lockStatus = GetAreaTriggerLockStatus(at, miscRequirement);
if (lockStatus != AREA_LOCKSTATUS_OK)
{
SendTransferAbortedByLockStatus(mEntry, lockStatus, miscRequirement);
return false;
}
if (IsDead() && mEntry->IsDungeon()) // rare case of teleporting the player into an instance with no areatrigger participation
{ {
ResurrectPlayer(0.5f); ResurrectPlayer(0.5f);
SpawnCorpseBones(); SpawnCorpseBones();
} }
}
// if we were on a transport, leave // if we were on a transport, leave
if (!(options & TELE_TO_NOT_LEAVE_TRANSPORT) && m_transport) if (!(options & TELE_TO_NOT_LEAVE_TRANSPORT) && m_transport)
@ -1601,6 +1583,8 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// setup delayed teleport flag // setup delayed teleport flag
// if teleport spell is casted in Unit::Update() func // if teleport spell is casted in Unit::Update() func
// then we need to delay it until update process will be finished // then we need to delay it until update process will be finished
if (!allowNoDelay)
{
if (SetDelayedTeleportFlagIfCan()) if (SetDelayedTeleportFlagIfCan())
{ {
SetSemaphoreTeleportNear(true); SetSemaphoreTeleportNear(true);
@ -1609,6 +1593,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
m_teleport_options = options; m_teleport_options = options;
return true; return true;
} }
}
if (!(options & TELE_TO_NOT_UNSUMMON_PET)) if (!(options & TELE_TO_NOT_UNSUMMON_PET))
{ {
@ -1652,6 +1637,8 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// setup delayed teleport flag // setup delayed teleport flag
// if teleport spell is casted in Unit::Update() func // if teleport spell is casted in Unit::Update() func
// then we need to delay it until update process will be finished // then we need to delay it until update process will be finished
if (!allowNoDelay)
{
if (SetDelayedTeleportFlagIfCan()) if (SetDelayedTeleportFlagIfCan())
{ {
SetSemaphoreTeleportFar(true); SetSemaphoreTeleportFar(true);
@ -1660,6 +1647,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
m_teleport_options = options; m_teleport_options = options;
return true; return true;
} }
}
SetSelectionGuid(ObjectGuid()); SetSelectionGuid(ObjectGuid());

View File

@ -908,7 +908,7 @@ class Player : public Unit
void AddToWorld() override; void AddToWorld() override;
void RemoveFromWorld() override; void RemoveFromWorld() override;
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0, AreaTrigger const* at = NULL); bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0, bool allowNoDelay = false);
bool TeleportTo(WorldLocation const& loc, uint32 options = 0) bool TeleportTo(WorldLocation const& loc, uint32 options = 0)
{ {

View File

@ -811,8 +811,16 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
player->SpawnCorpseBones(); player->SpawnCorpseBones();
} }
// teleport player (trigger requirement will be checked on TeleportTo) uint32 miscRequirement = 0;
player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT, at); AreaLockStatus lockStatus = player->GetAreaTriggerLockStatus(at, miscRequirement);
if (lockStatus != AREA_LOCKSTATUS_OK)
{
player->SendTransferAbortedByLockStatus(targetMapEntry, lockStatus, miscRequirement);
return;
}
// teleport player
player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT, true);
} }
void WorldSession::HandleUpdateAccountData(WorldPacket& recv_data) void WorldSession::HandleUpdateAccountData(WorldPacket& recv_data)