aboutsummaryrefslogtreecommitdiff
path: root/src/game/MovementHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/MovementHandler.cpp')
-rw-r--r--src/game/MovementHandler.cpp52
1 files changed, 32 insertions, 20 deletions
diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
index 7d7733763cd..f0ff9ec05d7 100644
--- a/src/game/MovementHandler.cpp
+++ b/src/game/MovementHandler.cpp
@@ -66,27 +66,30 @@ void WorldSession::HandleMoveWorldportAckOpcode()
GetPlayer()->SetSemaphoreTeleportFar(false);
+ Map * oldMap = GetPlayer()->GetMap();
// relocate the player to the teleport destination
- GetPlayer()->SetMapId(loc.mapid);
- GetPlayer()->Relocate(loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation);
+ Map * newMap = MapManager::Instance().CreateMap(loc.mapid, GetPlayer(), 0);
+ // 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 (!newMap || !newMap->CanEnter(GetPlayer()))
+ {
+ sLog.outError("Map %d could not be created for player %d, porting player to homebind", loc.mapid, GetPlayer()->GetGUIDLow());
+ GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
+ return;
+ }
+ else
+ GetPlayer()->Relocate(loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation);
- // since the MapId is set before the GetInstance call, the InstanceId must be set to 0
- // to let GetInstance() determine the proper InstanceId based on the player's binds
- GetPlayer()->SetInstanceId(0);
+ GetPlayer()->ResetMap();
+ GetPlayer()->SetMap(newMap);
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()))
{
- sLog.outDebug("WORLD: teleport of player %s (%d) to location %d, %f, %f, %f, %f failed", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation);
- // teleport the player home
- if(!GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()))
- {
- // the player must always be able to teleport home
- sLog.outError("WORLD: failed to teleport player %s (%d) to homebind location %d, %f, %f, %f, %f!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
- assert(false);
- }
+ sLog.outError("WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid);
+ GetPlayer()->ResetMap();
+ GetPlayer()->SetMap(oldMap);
+ GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
return;
}
@@ -156,11 +159,14 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// resummon pet
GetPlayer()->ResummonPetTemporaryUnSummonedIfAny();
+
+ //lets process all delayed operations on successful teleport
+ GetPlayer()->ProcessDelayedOperations();
}
void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data)
{
- CHECK_PACKET_SIZE(recv_data, 8+4);
+ CHECK_PACKET_SIZE(recv_data, 8+4+4);
sLog.outDebug("MSG_MOVE_TELEPORT_ACK");
uint64 guid;
@@ -202,6 +208,9 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data)
// resummon pet
GetPlayer()->ResummonPetTemporaryUnSummonedIfAny();
+
+ //lets process all delayed operations on successful teleport
+ GetPlayer()->ProcessDelayedOperations();
}
void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
@@ -223,7 +232,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
if(recv_data.size() != recv_data.rpos())
{
- sLog.outError("MovementHandler: player %s (guid %d, account %u) sent a packet (opcode %u) that is %u bytes larger than it should be. Kicked as cheater.", _player->GetName(), _player->GetGUIDLow(), _player->GetSession()->GetAccountId(), recv_data.GetOpcode(), recv_data.size() - recv_data.rpos());
+ sLog.outError("MovementHandler: player %s (guid %d, account %u) sent a packet (opcode %u) that is " SIZEFMTD " bytes larger than it should be. Kicked as cheater.", _player->GetName(), _player->GetGUIDLow(), _player->GetSession()->GetAccountId(), recv_data.GetOpcode(), recv_data.size() - recv_data.rpos());
KickPlayer();
return;
}
@@ -294,6 +303,12 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
mover->m_movementInfo = movementInfo;
+ if(mover->m_Vehicle)
+ {
+ mover->SetOrientation(movementInfo.o);
+ return;
+ }
+
if(plMover) // nothing is charmed, or player charmed
{
plMover->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
@@ -332,9 +347,6 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
}
else // creature charmed
{
- uint32 entry = mover->GetEntry();
- if(mover->m_Vehicle)
- return;
mover->GetMap()->CreatureRelocation((Creature*)mover, movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
/*if(mover->canFly())