Core/Transports: Localized transport objects within each map

Transports no longer move between maps, each map gets a separate copy of the transport object and players are moved between them when transferring to another map
This means they can no longer be globally looked up in HashMapHolder
This commit is contained in:
Shauren authored and Ovahlord committed 2022-06-19 18:11:20 +02:00
1 parent acb599823e
commit 786131a162
13 files changed
+207 -186

No files matched your search

@@ -77,6 +77,10 @@ void WorldSession::HandleMoveWorldportAck()
Map* oldMap = GetPlayer()->GetMap();
Map* newMap = sMapMgr->CreateMap(loc.GetMapId(), GetPlayer());
MovementInfo::TransportInfo transportInfo = GetPlayer()->m_movementInfo.transport;
if (TransportBase* transport = GetPlayer()->GetTransport())
transport->RemovePassenger(GetPlayer());
if (GetPlayer()->IsInWorld())
{
TC_LOG_ERROR("network", "%s %s is still in world when teleported from map %s (%u) to new map %s (%u)", GetPlayer()->GetGUID().ToString().c_str(), GetPlayer()->GetName().c_str(), oldMap->GetMapName(), oldMap->GetId(), newMap ? newMap->GetMapName() : "Unknown", loc.GetMapId());
@@ -102,6 +106,14 @@ void WorldSession::HandleMoveWorldportAck()
GetPlayer()->SetMap(newMap);
GetPlayer()->SendInitialPacketsBeforeAddToMap();
// move player between transport copies on each map
if (Transport* newTransport = newMap->GetTransport(transportInfo.guid))
{
GetPlayer()->m_movementInfo.transport = transportInfo;
newTransport->AddPassenger(GetPlayer());
}
if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer()))
{
TC_LOG_ERROR("network", "WORLD: failed to teleport player %s (%d) to map %d (%s) because of unknown reason!",