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,29 +1550,11 @@ 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; ResurrectPlayer(0.5f);
AreaLockStatus lockStatus = GetAreaTriggerLockStatus(at, miscRequirement); SpawnCorpseBones();
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);
SpawnCorpseBones();
}
} }
// if we were on a transport, leave // if we were on a transport, leave
@ -1601,13 +1583,16 @@ 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 (SetDelayedTeleportFlagIfCan()) if (!allowNoDelay)
{ {
SetSemaphoreTeleportNear(true); if (SetDelayedTeleportFlagIfCan())
// lets save teleport destination for player {
m_teleport_dest = WorldLocation(mapid, x, y, z, orientation); SetSemaphoreTeleportNear(true);
m_teleport_options = options; // lets save teleport destination for player
return true; m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
m_teleport_options = options;
return true;
}
} }
if (!(options & TELE_TO_NOT_UNSUMMON_PET)) if (!(options & TELE_TO_NOT_UNSUMMON_PET))
@ -1652,13 +1637,16 @@ 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 (SetDelayedTeleportFlagIfCan()) if (!allowNoDelay)
{ {
SetSemaphoreTeleportFar(true); if (SetDelayedTeleportFlagIfCan())
// lets save teleport destination for player {
m_teleport_dest = WorldLocation(mapid, x, y, z, orientation); SetSemaphoreTeleportFar(true);
m_teleport_options = options; // lets save teleport destination for player
return true; m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
m_teleport_options = options;
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)