Core/Global: Cleanup in MovementHandler and some assertions
This commit is contained in:
@@ -290,7 +290,7 @@ int32 BattlegroundAB::_GetNodeNameId(uint8 node)
|
||||
case BG_AB_NODE_LUMBER_MILL:return LANG_BG_AB_NODE_LUMBER_MILL;
|
||||
case BG_AB_NODE_GOLD_MINE: return LANG_BG_AB_NODE_GOLD_MINE;
|
||||
default:
|
||||
ASSERT(0);
|
||||
ASSERT(false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -720,8 +720,13 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source)
|
||||
|
||||
DelCreature(BG_SA_MAXNPC + i);
|
||||
GraveyardStatus[i] = Source->GetTeamId();
|
||||
WorldSafeLocsEntry const* sg = NULL;
|
||||
sg = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]);
|
||||
WorldSafeLocsEntry const* sg = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]);
|
||||
if (!sg)
|
||||
{
|
||||
sLog->outError("BattlegroundSA::CaptureGraveyard: non-existant GY entry: %u", BG_SA_GYEntries[i]);
|
||||
return;
|
||||
}
|
||||
|
||||
AddSpiritGuide(i + BG_SA_MAXNPC, sg->x, sg->y, sg->z, BG_SA_GYOrientation[i], (GraveyardStatus[i] == TEAM_ALLIANCE? ALLIANCE : HORDE));
|
||||
uint32 npc = 0;
|
||||
uint32 flag = 0;
|
||||
@@ -781,7 +786,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source)
|
||||
SendWarningToAll(LANG_BG_SA_H_GY_SOUTH);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
ASSERT(false);
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6247,74 +6247,54 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
|
||||
switch (guidhigh)
|
||||
{
|
||||
case HIGHGUID_ITEM:
|
||||
if (_hiItemGuid >= 0xFFFFFFFE)
|
||||
{
|
||||
sLog->outError("Item guid overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
{
|
||||
ASSERT(_hiItemGuid < 0xFFFFFFFE && "Item guid overflow!");
|
||||
return _hiItemGuid++;
|
||||
}
|
||||
case HIGHGUID_UNIT:
|
||||
if (_hiCreatureGuid >= 0x00FFFFFE)
|
||||
{
|
||||
sLog->outError("Creature guid overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
{
|
||||
ASSERT(_hiCreatureGuid < 0x00FFFFFE && "Creature guid overflow!");
|
||||
return _hiCreatureGuid++;
|
||||
}
|
||||
case HIGHGUID_PET:
|
||||
if (_hiPetGuid >= 0x00FFFFFE)
|
||||
{
|
||||
sLog->outError("Pet guid overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
{
|
||||
ASSERT(_hiPetGuid < 0x00FFFFFE && "Pet guid overflow!");
|
||||
return _hiPetGuid++;
|
||||
}
|
||||
case HIGHGUID_VEHICLE:
|
||||
if (_hiVehicleGuid >= 0x00FFFFFF)
|
||||
{
|
||||
sLog->outError("Vehicle guid overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
{
|
||||
ASSERT(_hiVehicleGuid < 0x00FFFFFF && "Vehicle guid overflow!");
|
||||
return _hiVehicleGuid++;
|
||||
}
|
||||
case HIGHGUID_PLAYER:
|
||||
if (_hiCharGuid >= 0xFFFFFFFE)
|
||||
{
|
||||
sLog->outError("Players guid overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
{
|
||||
ASSERT(_hiCharGuid < 0xFFFFFFFE && "Player guid overflow!");
|
||||
return _hiCharGuid++;
|
||||
}
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
if (_hiGoGuid >= 0x00FFFFFE)
|
||||
{
|
||||
sLog->outError("Gameobject guid overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
{
|
||||
ASSERT(_hiGoGuid < 0x00FFFFFE && "Gameobject guid overflow!");
|
||||
return _hiGoGuid++;
|
||||
}
|
||||
case HIGHGUID_CORPSE:
|
||||
if (_hiCorpseGuid >= 0xFFFFFFFE)
|
||||
{
|
||||
sLog->outError("Corpse guid overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
{
|
||||
ASSERT(_hiCorpseGuid < 0xFFFFFFFE && "Corpse guid overflow!");
|
||||
return _hiCorpseGuid++;
|
||||
}
|
||||
case HIGHGUID_DYNAMICOBJECT:
|
||||
if (_hiDoGuid >= 0xFFFFFFFE)
|
||||
{
|
||||
sLog->outError("DynamicObject guid overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
{
|
||||
ASSERT(_hiDoGuid < 0xFFFFFFFE && "DynamicObject guid overflow!");
|
||||
return _hiDoGuid++;
|
||||
}
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
if (_hiMoTransGuid >= 0xFFFFFFFE)
|
||||
{
|
||||
sLog->outError("MO Transport guid overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
{
|
||||
ASSERT(_hiMoTransGuid < 0xFFFFFFFE && "MO Transport guid overflow!");
|
||||
return _hiMoTransGuid++;
|
||||
}
|
||||
default:
|
||||
ASSERT(0);
|
||||
ASSERT(false && "ObjectMgr::GenerateLowGuid - Unknown HIGHGUID type");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGameObjectLocales()
|
||||
|
||||
@@ -64,10 +64,9 @@ void WorldSession::HandleMoveWorldportAckOpcode()
|
||||
GetPlayer()->m_InstanceValid = true;
|
||||
|
||||
Map* oldMap = GetPlayer()->GetMap();
|
||||
ASSERT(oldMap);
|
||||
if (GetPlayer()->IsInWorld())
|
||||
{
|
||||
sLog->outCrash("Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName(), oldMap->GetId(), loc.GetMapId());
|
||||
sLog->outError("Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName(), oldMap->GetId(), loc.GetMapId());
|
||||
oldMap->RemovePlayerFromMap(GetPlayer(), false);
|
||||
}
|
||||
|
||||
@@ -200,8 +199,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data)
|
||||
sLog->outStaticDebug("Guid " UI64FMTD, guid);
|
||||
sLog->outStaticDebug("Flags %u, time %u", flags, time/IN_MILLISECONDS);
|
||||
|
||||
Unit* mover = _player->m_mover;
|
||||
Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;
|
||||
Player* plMover = _player->m_mover->ToPlayer();
|
||||
|
||||
if (!plMover || !plMover->IsBeingTeleportedNear())
|
||||
return;
|
||||
@@ -240,33 +238,33 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data)
|
||||
GetPlayer()->ProcessDelayedOperations();
|
||||
}
|
||||
|
||||
void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
|
||||
void WorldSession::HandleMovementOpcodes(WorldPacket & recvData)
|
||||
{
|
||||
uint16 opcode = recv_data.GetOpcode();
|
||||
uint16 opcode = recvData.GetOpcode();
|
||||
|
||||
Unit* mover = _player->m_mover;
|
||||
|
||||
ASSERT(mover != NULL); // there must always be a mover
|
||||
ASSERT(mover != NULL); // there must always be a mover
|
||||
|
||||
Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;
|
||||
Player* plrMover = mover->ToPlayer();
|
||||
|
||||
// ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
|
||||
if (plMover && plMover->IsBeingTeleported())
|
||||
if (plrMover && plrMover->IsBeingTeleported())
|
||||
{
|
||||
recv_data.rfinish(); // prevent warnings spam
|
||||
recvData.rfinish(); // prevent warnings spam
|
||||
return;
|
||||
}
|
||||
|
||||
/* extract packet */
|
||||
uint64 guid;
|
||||
|
||||
recv_data.readPackGUID(guid);
|
||||
recvData.readPackGUID(guid);
|
||||
|
||||
MovementInfo movementInfo;
|
||||
movementInfo.guid = guid;
|
||||
ReadMovementInfo(recv_data, &movementInfo);
|
||||
ReadMovementInfo(recvData, &movementInfo);
|
||||
|
||||
recv_data.rfinish(); // prevent warnings spam
|
||||
recvData.rfinish(); // prevent warnings spam
|
||||
|
||||
// prevent tampered movement data
|
||||
if (guid != mover->GetGUID())
|
||||
@@ -274,7 +272,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
|
||||
|
||||
if (!movementInfo.pos.IsPositionValid())
|
||||
{
|
||||
recv_data.rfinish(); // prevent warnings spam
|
||||
recvData.rfinish(); // prevent warnings spam
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -285,27 +283,27 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
|
||||
// (also received at zeppelin leave by some reason with t_* as absolute in continent coordinates, can be safely skipped)
|
||||
if (movementInfo.t_pos.GetPositionX() > 50 || movementInfo.t_pos.GetPositionY() > 50 || movementInfo.t_pos.GetPositionZ() > 50)
|
||||
{
|
||||
recv_data.rfinish(); // prevent warnings spam
|
||||
recvData.rfinish(); // prevent warnings spam
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Trinity::IsValidMapCoord(movementInfo.pos.GetPositionX() + movementInfo.t_pos.GetPositionX(), movementInfo.pos.GetPositionY() + movementInfo.t_pos.GetPositionY(),
|
||||
movementInfo.pos.GetPositionZ() + movementInfo.t_pos.GetPositionZ(), movementInfo.pos.GetOrientation() + movementInfo.t_pos.GetOrientation()))
|
||||
{
|
||||
recv_data.rfinish(); // prevent warnings spam
|
||||
recvData.rfinish(); // prevent warnings spam
|
||||
return;
|
||||
}
|
||||
|
||||
// if we boarded a transport, add us to it
|
||||
if (plMover && !plMover->GetTransport())
|
||||
if (plrMover && !plrMover->GetTransport())
|
||||
{
|
||||
// elevators also cause the client to send MOVEMENTFLAG_ONTRANSPORT - just dismount if the guid can be found in the transport list
|
||||
for (MapManager::TransportSet::const_iterator iter = sMapMgr->m_Transports.begin(); iter != sMapMgr->m_Transports.end(); ++iter)
|
||||
{
|
||||
if ((*iter)->GetGUID() == movementInfo.t_guid)
|
||||
{
|
||||
plMover->m_transport = (*iter);
|
||||
(*iter)->AddPassenger(plMover);
|
||||
plrMover->m_transport = (*iter);
|
||||
(*iter)->AddPassenger(plrMover);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -318,29 +316,29 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
|
||||
movementInfo.flags &= ~MOVEMENTFLAG_ONTRANSPORT;
|
||||
}
|
||||
}
|
||||
else if (plMover && plMover->GetTransport()) // if we were on a transport, leave
|
||||
else if (plrMover && plrMover->GetTransport()) // if we were on a transport, leave
|
||||
{
|
||||
plMover->m_transport->RemovePassenger(plMover);
|
||||
plMover->m_transport = NULL;
|
||||
plrMover->m_transport->RemovePassenger(plrMover);
|
||||
plrMover->m_transport = NULL;
|
||||
movementInfo.t_pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
movementInfo.t_time = 0;
|
||||
movementInfo.t_seat = -1;
|
||||
}
|
||||
|
||||
// fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
|
||||
if (opcode == MSG_MOVE_FALL_LAND && plMover && !plMover->isInFlight())
|
||||
plMover->HandleFall(movementInfo);
|
||||
if (opcode == MSG_MOVE_FALL_LAND && plrMover && !plrMover->isInFlight())
|
||||
plrMover->HandleFall(movementInfo);
|
||||
|
||||
if (plMover && ((movementInfo.flags & MOVEMENTFLAG_SWIMMING) != 0) != plMover->IsInWater())
|
||||
if (plrMover && ((movementInfo.flags & MOVEMENTFLAG_SWIMMING) != 0) != plrMover->IsInWater())
|
||||
{
|
||||
// now client not include swimming flag in case jumping under water
|
||||
plMover->SetInWater(!plMover->IsInWater() || plMover->GetBaseMap()->IsUnderWater(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(), movementInfo.pos.GetPositionZ()));
|
||||
plrMover->SetInWater(!plrMover->IsInWater() || plrMover->GetBaseMap()->IsUnderWater(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(), movementInfo.pos.GetPositionZ()));
|
||||
}
|
||||
|
||||
/*----------------------*/
|
||||
|
||||
/* process position-change */
|
||||
WorldPacket data(opcode, recv_data.size());
|
||||
WorldPacket data(opcode, recvData.size());
|
||||
movementInfo.time = getMSTime();
|
||||
movementInfo.guid = mover->GetGUID();
|
||||
WriteMovementInfo(&data, &movementInfo);
|
||||
@@ -357,27 +355,25 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
|
||||
|
||||
mover->UpdatePosition(movementInfo.pos);
|
||||
|
||||
if (plMover) // nothing is charmed, or player charmed
|
||||
if (plrMover) // nothing is charmed, or player charmed
|
||||
{
|
||||
plMover->UpdateFallInformationIfNeed(movementInfo, opcode);
|
||||
plrMover->UpdateFallInformationIfNeed(movementInfo, opcode);
|
||||
|
||||
if (movementInfo.pos.GetPositionZ() < -500.0f)
|
||||
{
|
||||
if (!(plMover->InBattleground()
|
||||
&& plMover->GetBattleground()
|
||||
&& plMover->GetBattleground()->HandlePlayerUnderMap(_player)))
|
||||
if (!(plrMover->GetBattleground() && plrMover->GetBattleground()->HandlePlayerUnderMap(_player)))
|
||||
{
|
||||
// NOTE: this is actually called many times while falling
|
||||
// even after the player has been teleported away
|
||||
// TODO: discard movement packets after the player is rooted
|
||||
if (plMover->isAlive())
|
||||
if (plrMover->isAlive())
|
||||
{
|
||||
plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, GetPlayer()->GetMaxHealth());
|
||||
plrMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, GetPlayer()->GetMaxHealth());
|
||||
// player can be alive if GM/etc
|
||||
// change the death state to CORPSE to prevent the death timer from
|
||||
// starting in the next player update
|
||||
if (!plMover->isAlive())
|
||||
plMover->KillPlayer();
|
||||
if (!plrMover->isAlive())
|
||||
plrMover->KillPlayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user