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

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10838" #define REVISION_NR "10839"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__