[10839] At far teleport fail retunr player to source point instead homebind.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
maly32167 2010-12-08 06:47:39 +03:00 committed by VladimirMangos
parent e95aee27e0
commit 1fef606dd8
2 changed files with 24 additions and 12 deletions

View file

@ -44,14 +44,19 @@ void WorldSession::HandleMoveWorldportAckOpcode()
if(!GetPlayer()->IsBeingTeleportedFar())
return;
// get start teleport coordinates (will used later in fail case)
WorldLocation old_loc;
GetPlayer()->GetPosition(old_loc);
// get the teleport destination
WorldLocation &loc = GetPlayer()->GetTeleportDest();
// possible errors in the coordinate validity check
if(!MapManager::IsValidMapCoord(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation))
// possible errors in the coordinate validity check (only cheating case possible)
if (!MapManager::IsValidMapCoord(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation))
{
sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: player %s (%d) was teleported far to a not valid location. (map:%u, x:%f, y:%f, "
"z:%f) We port him to his homebind instead..", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to a not valid location "
"(map:%u, x:%f, y:%f, z:%f) We port him to his homebind instead..",
GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
// stop teleportation else we would try this again and again in LogoutPlayer...
GetPlayer()->SetSemaphoreTeleportFar(false);
// and teleport the player to a valid place
@ -64,7 +69,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
InstanceTemplate const* mInstance = ObjectMgr::GetInstanceTemplate(loc.mapid);
// reset instance validity, except if going to an instance inside an instance
if(GetPlayer()->m_InstanceValid == false && !mInstance)
if (GetPlayer()->m_InstanceValid == false && !mInstance)
GetPlayer()->m_InstanceValid = true;
GetPlayer()->SetSemaphoreTeleportFar(false);
@ -76,15 +81,22 @@ void WorldSession::HandleMoveWorldportAckOpcode()
GetPlayer()->SendInitialPacketsBeforeAddToMap();
// the CanEnter checks are done in TeleporTo but conditions may change
// while the player is in transit, for example the map may get full
if(!GetPlayer()->GetMap()->Add(GetPlayer()))
if (!GetPlayer()->GetMap()->Add(GetPlayer()))
{
//if player wasn't added to map, reset his map pointer!
// if player wasn't added to map, reset his map pointer!
GetPlayer()->ResetMap();
sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: player %s (%d) was teleported far but couldn't be added to map. (map:%u, x:%f, y:%f, "
"z:%f) We port him to his homebind instead..", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
// teleport the player home
GetPlayer()->TeleportToHomebind();
DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far but couldn't be added to map "
" (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..",
GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
// Teleport to previous place, if cannot be ported back TP to homebind place
if (!GetPlayer()->TeleportTo(old_loc))
{
DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s cannot be ported to his previous place, teleporting him to his homebind place...",
GetPlayer()->GetGuidStr().c_str());
GetPlayer()->TeleportToHomebind();
}
return;
}