[11015] Prevent crash at player far teleport landing to nonexisten battleground instance.

Teleport back in like case or to homebind in bad case.
This commit is contained in:
VladimirMangos 2011-01-16 00:28:10 +03:00
parent 3de0f99f59
commit 0c19c2c6a2
4 changed files with 39 additions and 9 deletions

View file

@ -66,6 +66,32 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// get the destination map entry, not the current one, this will fix homebind and reset greeting
MapEntry const* mEntry = sMapStore.LookupEntry(loc.mapid);
Map* map = NULL;
// prevent crash at attempt landing to not existed battleground instance
if(mEntry->IsBattleGroundOrArena())
{
if (GetPlayer()->GetBattleGroundId())
map = sMapMgr.FindMap(loc.mapid, GetPlayer()->GetBattleGroundId());
if (!map)
{
DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to nonexisten battleground instance "
" (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;
}
}
InstanceTemplate const* mInstance = ObjectMgr::GetInstanceTemplate(loc.mapid);
// reset instance validity, except if going to an instance inside an instance
@ -75,7 +101,10 @@ void WorldSession::HandleMoveWorldportAckOpcode()
GetPlayer()->SetSemaphoreTeleportFar(false);
// relocate the player to the teleport destination
GetPlayer()->SetMap(sMapMgr.CreateMap(loc.mapid, GetPlayer()));
if (!map)
map = sMapMgr.CreateMap(loc.mapid, GetPlayer());
GetPlayer()->SetMap(map);
GetPlayer()->Relocate(loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation);
GetPlayer()->SendInitialPacketsBeforeAddToMap();