[10432] Rename ASSERT -> MANGOS_ASSERT and related fixes

ASSERT hard use in predictable way because diff. 3rd party libs code
redefine it inf different ways and hard make sure that used in end
of mangos define version. This is real detected problem make some
expected assert checks ignored and so bugs not detected as expected from code.

In addition made related changes:
* Common.h header expected to be first include in any src/game/header except most simple cases.
* Related FILE.h header expected to be first include in FILE.cpp
* Fixed some absent includes and type forwards for safe build without PCH enabled.
* Avoid using MANGOS_ASSERT in src/framework code
This commit is contained in:
VladimirMangos 2010-09-02 04:18:55 +04:00
parent 32e3e252fb
commit acd0716297
77 changed files with 309 additions and 260 deletions

View file

@ -16,13 +16,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Common.h"
#include "Object.h"
#include "SharedDefines.h"
#include "WorldPacket.h"
#include "Opcodes.h"
#include "Log.h"
#include "World.h"
#include "Object.h"
#include "Creature.h"
#include "Player.h"
#include "Vehicle.h"
@ -82,13 +81,13 @@ Object::~Object( )
{
///- Do NOT call RemoveFromWorld here, if the object is a player it will crash
sLog.outError("Object::~Object (GUID: %u TypeId: %u) deleted but still in world!!", GetGUIDLow(), GetTypeId());
ASSERT(false);
MANGOS_ASSERT(false);
}
if(m_objectUpdated)
{
sLog.outError("Object::~Object (GUID: %u TypeId: %u) deleted but still have updated status!!", GetGUIDLow(), GetTypeId());
ASSERT(false);
MANGOS_ASSERT(false);
}
if(m_uint32Values)
@ -237,7 +236,7 @@ void Object::BuildOutOfRangeUpdateBlock(UpdateData * data) const
void Object::DestroyForPlayer( Player *target, bool anim ) const
{
ASSERT(target);
MANGOS_ASSERT(target);
WorldPacket data(SMSG_DESTROY_OBJECT, 8);
data << GetObjectGuid();
@ -305,7 +304,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
if(player->IsTaxiFlying())
{
ASSERT(player->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE);
MANGOS_ASSERT(player->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE);
player->m_movementInfo.AddMovementFlag(MOVEFLAG_FORWARD);
player->m_movementInfo.AddMovementFlag(MOVEFLAG_SPLINE_ENABLED);
}
@ -346,7 +345,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
return;
}
ASSERT(player->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE);
MANGOS_ASSERT(player->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE);
FlightPathMovementGenerator *fmg = (FlightPathMovementGenerator*)(player->GetMotionMaster()->top());
@ -583,7 +582,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
}
}
ASSERT(updateMask && updateMask->GetCount() == m_valuesCount);
MANGOS_ASSERT(updateMask && updateMask->GetCount() == m_valuesCount);
*data << (uint8)updateMask->GetBlockCount();
data->append( updateMask->GetMask(), updateMask->GetLength() );
@ -782,7 +781,7 @@ void Object::_SetCreateBits(UpdateMask *updateMask, Player* /*target*/) const
void Object::SetInt32Value( uint16 index, int32 value )
{
ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
if(m_int32Values[ index ] != value)
{
@ -801,7 +800,7 @@ void Object::SetInt32Value( uint16 index, int32 value )
void Object::SetUInt32Value( uint16 index, uint32 value )
{
ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
if(m_uint32Values[ index ] != value)
{
@ -820,7 +819,7 @@ void Object::SetUInt32Value( uint16 index, uint32 value )
void Object::SetUInt64Value( uint16 index, const uint64 &value )
{
ASSERT( index + 1 < m_valuesCount || PrintIndexError( index, true ) );
MANGOS_ASSERT( index + 1 < m_valuesCount || PrintIndexError( index, true ) );
if(*((uint64*)&(m_uint32Values[ index ])) != value)
{
m_uint32Values[ index ] = *((uint32*)&value);
@ -839,7 +838,7 @@ void Object::SetUInt64Value( uint16 index, const uint64 &value )
void Object::SetFloatValue( uint16 index, float value )
{
ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
if(m_floatValues[ index ] != value)
{
@ -858,7 +857,7 @@ void Object::SetFloatValue( uint16 index, float value )
void Object::SetByteValue( uint16 index, uint8 offset, uint8 value )
{
ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
if(offset > 4)
{
@ -884,7 +883,7 @@ void Object::SetByteValue( uint16 index, uint8 offset, uint8 value )
void Object::SetUInt16Value( uint16 index, uint8 offset, uint16 value )
{
ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
if(offset > 2)
{
@ -958,7 +957,7 @@ void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply)
void Object::SetFlag( uint16 index, uint32 newFlag )
{
ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
uint32 oldval = m_uint32Values[ index ];
uint32 newval = oldval | newFlag;
@ -979,7 +978,7 @@ void Object::SetFlag( uint16 index, uint32 newFlag )
void Object::RemoveFlag( uint16 index, uint32 oldFlag )
{
ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
uint32 oldval = m_uint32Values[ index ];
uint32 newval = oldval & ~oldFlag;
@ -1000,7 +999,7 @@ void Object::RemoveFlag( uint16 index, uint32 oldFlag )
void Object::SetByteFlag( uint16 index, uint8 offset, uint8 newFlag )
{
ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
if(offset > 4)
{
@ -1025,7 +1024,7 @@ void Object::SetByteFlag( uint16 index, uint8 offset, uint8 newFlag )
void Object::RemoveByteFlag( uint16 index, uint8 offset, uint8 oldFlag )
{
ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );
if(offset > 4)
{
@ -1063,7 +1062,7 @@ void Object::BuildUpdateDataForPlayer(Player* pl, UpdateDataMapType& update_play
if (iter == update_players.end())
{
std::pair<UpdateDataMapType::iterator, bool> p = update_players.insert( UpdateDataMapType::value_type(pl, UpdateData()) );
ASSERT(p.second);
MANGOS_ASSERT(p.second);
iter = p.first;
}
@ -1073,19 +1072,19 @@ void Object::BuildUpdateDataForPlayer(Player* pl, UpdateDataMapType& update_play
void Object::AddToClientUpdateList()
{
sLog.outError("Unexpected call of Object::AddToClientUpdateList for object (TypeId: %u Update fields: %u)",GetTypeId(), m_valuesCount);
ASSERT(false);
MANGOS_ASSERT(false);
}
void Object::RemoveFromClientUpdateList()
{
sLog.outError("Unexpected call of Object::RemoveFromClientUpdateList for object (TypeId: %u Update fields: %u)",GetTypeId(), m_valuesCount);
ASSERT(false);
MANGOS_ASSERT(false);
}
void Object::BuildUpdateData( UpdateDataMapType& /*update_players */)
{
sLog.outError("Unexpected call of Object::BuildUpdateData for object (TypeId: %u Update fields: %u)",GetTypeId(), m_valuesCount);
ASSERT(false);
MANGOS_ASSERT(false);
}
WorldObject::WorldObject()
@ -1610,7 +1609,7 @@ void WorldObject::SendGameObjectCustomAnim(uint64 guid)
void WorldObject::SetMap(Map * map)
{
ASSERT(map);
MANGOS_ASSERT(map);
m_currMap = map;
//lets save current map's Id/instanceId
m_mapId = map->GetId();
@ -1619,7 +1618,7 @@ void WorldObject::SetMap(Map * map)
Map const* WorldObject::GetBaseMap() const
{
ASSERT(m_currMap);
MANGOS_ASSERT(m_currMap);
return m_currMap->GetParent();
}