Core/Transports: Fixed crashes happening when passenger is removed from transport during teleport
Closes #11067
This commit is contained in:
1 parent
f8b1b264d1
commit
b6db622b52
4 files changed
+25
-38
No files matched your search
@@ -105,7 +105,11 @@ void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
|
||||
RemoveFromOwner();
|
||||
|
||||
if (GetTransport() && !ToTransport())
|
||||
{
|
||||
GetTransport()->RemovePassenger(this);
|
||||
SetTransport(NULL);
|
||||
m_movementInfo.transport.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void GameObject::RemoveFromOwner()
|
||||
|
||||
@@ -923,9 +923,6 @@ void Player::CleanupsBeforeDelete(bool finalCleanup)
|
||||
|
||||
Unit::CleanupsBeforeDelete(finalCleanup);
|
||||
|
||||
if (m_transport)
|
||||
m_transport->RemovePassenger(this);
|
||||
|
||||
// clean up player-instance binds, may unload some instance saves
|
||||
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
|
||||
for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr)
|
||||
@@ -2297,10 +2294,13 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
|
||||
if (m_transport)
|
||||
{
|
||||
final_x += m_movementInfo.transport.pos.GetPositionX();
|
||||
final_y += m_movementInfo.transport.pos.GetPositionY();
|
||||
final_z += m_movementInfo.transport.pos.GetPositionZ();
|
||||
final_o += m_movementInfo.transport.pos.GetOrientation();
|
||||
float tx, ty, tz, to;
|
||||
m_movementInfo.transport.pos.GetPosition(tx, ty, tz, to);
|
||||
|
||||
final_x = x + tx * std::cos(orientation) - ty * std::sin(orientation);
|
||||
final_y = y + ty * std::cos(orientation) + tx * std::sin(orientation);
|
||||
final_z = z + tz;
|
||||
final_o = Position::NormalizeOrientation(orientation + m_movementInfo.transport.pos.GetOrientation());
|
||||
}
|
||||
|
||||
m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o);
|
||||
|
||||
@@ -450,40 +450,19 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
|
||||
}
|
||||
}
|
||||
|
||||
// Teleport passengers after everyone on destination map are sent create packet
|
||||
// but before transport itself is registered there and begins updating
|
||||
for (std::set<WorldObject*>::iterator itr = _staticPassengers.begin(); itr != _staticPassengers.end(); ++itr)
|
||||
for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end();)
|
||||
{
|
||||
switch ((*itr)->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
(*itr)->ToCreature()->FarTeleportTo(newMap, x, y, z, (*itr)->GetOrientation());
|
||||
break;
|
||||
case TYPEID_GAMEOBJECT:
|
||||
{
|
||||
GameObject* go = (*itr)->ToGameObject();
|
||||
go->GetMap()->RemoveFromMap(go, false);
|
||||
Relocate(x, y, z, go->GetOrientation());
|
||||
SetMap(newMap);
|
||||
newMap->AddToMap(go);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
WorldObject* obj = (*itr++);
|
||||
|
||||
for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr)
|
||||
{
|
||||
switch ((*itr)->GetTypeId())
|
||||
switch (obj->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
if (!IS_PLAYER_GUID((*itr)->ToUnit()->GetOwnerGUID())) // pets should be teleported with player
|
||||
(*itr)->ToCreature()->FarTeleportTo(newMap, x, y, z, (*itr)->GetOrientation());
|
||||
if (!IS_PLAYER_GUID(obj->ToUnit()->GetOwnerGUID())) // pets should be teleported with player
|
||||
obj->ToCreature()->FarTeleportTo(newMap, x, y, z, obj->GetOrientation());
|
||||
break;
|
||||
case TYPEID_GAMEOBJECT:
|
||||
{
|
||||
GameObject* go = (*itr)->ToGameObject();
|
||||
GameObject* go = obj->ToGameObject();
|
||||
go->GetMap()->RemoveFromMap(go, false);
|
||||
Relocate(x, y, z, go->GetOrientation());
|
||||
SetMap(newMap);
|
||||
@@ -491,7 +470,8 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
|
||||
break;
|
||||
}
|
||||
case TYPEID_PLAYER:
|
||||
(*itr)->ToPlayer()->TeleportTo(newMapid, x, y, z, (*itr)->GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
|
||||
if (!obj->ToPlayer()->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT))
|
||||
_passengers.erase(obj);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -13499,9 +13499,12 @@ void Unit::CleanupsBeforeDelete(bool finalCleanup)
|
||||
{
|
||||
CleanupBeforeRemoveFromMap(finalCleanup);
|
||||
|
||||
if (Creature* thisCreature = ToCreature())
|
||||
if (GetTransport())
|
||||
GetTransport()->RemovePassenger(thisCreature);
|
||||
if (GetTransport())
|
||||
{
|
||||
GetTransport()->RemovePassenger(this);
|
||||
SetTransport(NULL);
|
||||
m_movementInfo.transport.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::UpdateCharmAI()
|
||||
|
||||
Reference in new issue
Block a user