Core/Global: Cleanup in MovementHandler and some assertions

This commit is contained in:
kaelima
2012-05-23 15:02:54 +02:00
parent 037f37ac65
commit 419d537bc8
4 changed files with 70 additions and 89 deletions
@@ -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_LUMBER_MILL:return LANG_BG_AB_NODE_LUMBER_MILL;
case BG_AB_NODE_GOLD_MINE: return LANG_BG_AB_NODE_GOLD_MINE; case BG_AB_NODE_GOLD_MINE: return LANG_BG_AB_NODE_GOLD_MINE;
default: default:
ASSERT(0); ASSERT(false);
} }
return 0; return 0;
} }
@@ -720,8 +720,13 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source)
DelCreature(BG_SA_MAXNPC + i); DelCreature(BG_SA_MAXNPC + i);
GraveyardStatus[i] = Source->GetTeamId(); GraveyardStatus[i] = Source->GetTeamId();
WorldSafeLocsEntry const* sg = NULL; WorldSafeLocsEntry const* sg = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]);
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)); 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 npc = 0;
uint32 flag = 0; uint32 flag = 0;
@@ -781,7 +786,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source)
SendWarningToAll(LANG_BG_SA_H_GY_SOUTH); SendWarningToAll(LANG_BG_SA_H_GY_SOUTH);
break; break;
default: default:
ASSERT(0); ASSERT(false);
break; break;
}; };
} }
+20 -40
View File
@@ -6247,75 +6247,55 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
switch (guidhigh) switch (guidhigh)
{ {
case HIGHGUID_ITEM: case HIGHGUID_ITEM:
if (_hiItemGuid >= 0xFFFFFFFE)
{ {
sLog->outError("Item guid overflow!! Can't continue, shutting down server. "); ASSERT(_hiItemGuid < 0xFFFFFFFE && "Item guid overflow!");
World::StopNow(ERROR_EXIT_CODE);
}
return _hiItemGuid++; return _hiItemGuid++;
}
case HIGHGUID_UNIT: case HIGHGUID_UNIT:
if (_hiCreatureGuid >= 0x00FFFFFE)
{ {
sLog->outError("Creature guid overflow!! Can't continue, shutting down server. "); ASSERT(_hiCreatureGuid < 0x00FFFFFE && "Creature guid overflow!");
World::StopNow(ERROR_EXIT_CODE);
}
return _hiCreatureGuid++; return _hiCreatureGuid++;
}
case HIGHGUID_PET: case HIGHGUID_PET:
if (_hiPetGuid >= 0x00FFFFFE)
{ {
sLog->outError("Pet guid overflow!! Can't continue, shutting down server. "); ASSERT(_hiPetGuid < 0x00FFFFFE && "Pet guid overflow!");
World::StopNow(ERROR_EXIT_CODE);
}
return _hiPetGuid++; return _hiPetGuid++;
}
case HIGHGUID_VEHICLE: case HIGHGUID_VEHICLE:
if (_hiVehicleGuid >= 0x00FFFFFF)
{ {
sLog->outError("Vehicle guid overflow!! Can't continue, shutting down server. "); ASSERT(_hiVehicleGuid < 0x00FFFFFF && "Vehicle guid overflow!");
World::StopNow(ERROR_EXIT_CODE);
}
return _hiVehicleGuid++; return _hiVehicleGuid++;
}
case HIGHGUID_PLAYER: case HIGHGUID_PLAYER:
if (_hiCharGuid >= 0xFFFFFFFE)
{ {
sLog->outError("Players guid overflow!! Can't continue, shutting down server. "); ASSERT(_hiCharGuid < 0xFFFFFFFE && "Player guid overflow!");
World::StopNow(ERROR_EXIT_CODE);
}
return _hiCharGuid++; return _hiCharGuid++;
}
case HIGHGUID_GAMEOBJECT: case HIGHGUID_GAMEOBJECT:
if (_hiGoGuid >= 0x00FFFFFE)
{ {
sLog->outError("Gameobject guid overflow!! Can't continue, shutting down server. "); ASSERT(_hiGoGuid < 0x00FFFFFE && "Gameobject guid overflow!");
World::StopNow(ERROR_EXIT_CODE);
}
return _hiGoGuid++; return _hiGoGuid++;
}
case HIGHGUID_CORPSE: case HIGHGUID_CORPSE:
if (_hiCorpseGuid >= 0xFFFFFFFE)
{ {
sLog->outError("Corpse guid overflow!! Can't continue, shutting down server. "); ASSERT(_hiCorpseGuid < 0xFFFFFFFE && "Corpse guid overflow!");
World::StopNow(ERROR_EXIT_CODE);
}
return _hiCorpseGuid++; return _hiCorpseGuid++;
}
case HIGHGUID_DYNAMICOBJECT: case HIGHGUID_DYNAMICOBJECT:
if (_hiDoGuid >= 0xFFFFFFFE)
{ {
sLog->outError("DynamicObject guid overflow!! Can't continue, shutting down server. "); ASSERT(_hiDoGuid < 0xFFFFFFFE && "DynamicObject guid overflow!");
World::StopNow(ERROR_EXIT_CODE);
}
return _hiDoGuid++; return _hiDoGuid++;
}
case HIGHGUID_MO_TRANSPORT: case HIGHGUID_MO_TRANSPORT:
if (_hiMoTransGuid >= 0xFFFFFFFE)
{ {
sLog->outError("MO Transport guid overflow!! Can't continue, shutting down server. "); ASSERT(_hiMoTransGuid < 0xFFFFFFFE && "MO Transport guid overflow!");
World::StopNow(ERROR_EXIT_CODE);
}
return _hiMoTransGuid++; return _hiMoTransGuid++;
default:
ASSERT(0);
} }
default:
ASSERT(0); ASSERT(false && "ObjectMgr::GenerateLowGuid - Unknown HIGHGUID type");
return 0; return 0;
} }
}
void ObjectMgr::LoadGameObjectLocales() void ObjectMgr::LoadGameObjectLocales()
{ {
+31 -35
View File
@@ -64,10 +64,9 @@ void WorldSession::HandleMoveWorldportAckOpcode()
GetPlayer()->m_InstanceValid = true; GetPlayer()->m_InstanceValid = true;
Map* oldMap = GetPlayer()->GetMap(); Map* oldMap = GetPlayer()->GetMap();
ASSERT(oldMap);
if (GetPlayer()->IsInWorld()) 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); oldMap->RemovePlayerFromMap(GetPlayer(), false);
} }
@@ -200,8 +199,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data)
sLog->outStaticDebug("Guid " UI64FMTD, guid); sLog->outStaticDebug("Guid " UI64FMTD, guid);
sLog->outStaticDebug("Flags %u, time %u", flags, time/IN_MILLISECONDS); sLog->outStaticDebug("Flags %u, time %u", flags, time/IN_MILLISECONDS);
Unit* mover = _player->m_mover; Player* plMover = _player->m_mover->ToPlayer();
Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;
if (!plMover || !plMover->IsBeingTeleportedNear()) if (!plMover || !plMover->IsBeingTeleportedNear())
return; return;
@@ -240,33 +238,33 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data)
GetPlayer()->ProcessDelayedOperations(); 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; 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 // 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; return;
} }
/* extract packet */ /* extract packet */
uint64 guid; uint64 guid;
recv_data.readPackGUID(guid); recvData.readPackGUID(guid);
MovementInfo movementInfo; MovementInfo movementInfo;
movementInfo.guid = guid; 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 // prevent tampered movement data
if (guid != mover->GetGUID()) if (guid != mover->GetGUID())
@@ -274,7 +272,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
if (!movementInfo.pos.IsPositionValid()) if (!movementInfo.pos.IsPositionValid())
{ {
recv_data.rfinish(); // prevent warnings spam recvData.rfinish(); // prevent warnings spam
return; 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) // (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) 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; return;
} }
if (!Trinity::IsValidMapCoord(movementInfo.pos.GetPositionX() + movementInfo.t_pos.GetPositionX(), movementInfo.pos.GetPositionY() + movementInfo.t_pos.GetPositionY(), 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())) 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; return;
} }
// if we boarded a transport, add us to it // 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 // 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) for (MapManager::TransportSet::const_iterator iter = sMapMgr->m_Transports.begin(); iter != sMapMgr->m_Transports.end(); ++iter)
{ {
if ((*iter)->GetGUID() == movementInfo.t_guid) if ((*iter)->GetGUID() == movementInfo.t_guid)
{ {
plMover->m_transport = (*iter); plrMover->m_transport = (*iter);
(*iter)->AddPassenger(plMover); (*iter)->AddPassenger(plrMover);
break; break;
} }
} }
@@ -318,29 +316,29 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
movementInfo.flags &= ~MOVEMENTFLAG_ONTRANSPORT; 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); plrMover->m_transport->RemovePassenger(plrMover);
plMover->m_transport = NULL; plrMover->m_transport = NULL;
movementInfo.t_pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f); movementInfo.t_pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
movementInfo.t_time = 0; movementInfo.t_time = 0;
movementInfo.t_seat = -1; movementInfo.t_seat = -1;
} }
// fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map). // 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()) if (opcode == MSG_MOVE_FALL_LAND && plrMover && !plrMover->isInFlight())
plMover->HandleFall(movementInfo); 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 // 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 */ /* process position-change */
WorldPacket data(opcode, recv_data.size()); WorldPacket data(opcode, recvData.size());
movementInfo.time = getMSTime(); movementInfo.time = getMSTime();
movementInfo.guid = mover->GetGUID(); movementInfo.guid = mover->GetGUID();
WriteMovementInfo(&data, &movementInfo); WriteMovementInfo(&data, &movementInfo);
@@ -357,27 +355,25 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
mover->UpdatePosition(movementInfo.pos); 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 (movementInfo.pos.GetPositionZ() < -500.0f)
{ {
if (!(plMover->InBattleground() if (!(plrMover->GetBattleground() && plrMover->GetBattleground()->HandlePlayerUnderMap(_player)))
&& plMover->GetBattleground()
&& plMover->GetBattleground()->HandlePlayerUnderMap(_player)))
{ {
// NOTE: this is actually called many times while falling // NOTE: this is actually called many times while falling
// even after the player has been teleported away // even after the player has been teleported away
// TODO: discard movement packets after the player is rooted // 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 // player can be alive if GM/etc
// change the death state to CORPSE to prevent the death timer from // change the death state to CORPSE to prevent the death timer from
// starting in the next player update // starting in the next player update
if (!plMover->isAlive()) if (!plrMover->isAlive())
plMover->KillPlayer(); plrMover->KillPlayer();
} }
} }
} }