[11922] Add ASSERT helper function to print entry and guid info

Use this in first cases: GetAngle and in PathFinder::BuildPolyPath

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
Schmoozerd 2012-02-07 17:24:24 +01:00
parent b03443c425
commit 49bd484a41
6 changed files with 23 additions and 11 deletions

View file

@ -942,6 +942,9 @@ void GameObject::SwitchDoorOrButton(bool activate, bool alternative /* = false *
void GameObject::Use(Unit* user)
{
// user must be provided
MANGOS_ASSERT(user || PrintEntryError("GameObject::Use (without user)"));
// by default spell caster is user
Unit* spellCaster = user;
uint32 spellId = 0;

View file

@ -3214,11 +3214,9 @@ uint32 Map::GenerateLocalLowGuid(HighGuid guidhigh)
case HIGHGUID_VEHICLE:
return m_VehicleGuids.Generate();
default:
MANGOS_ASSERT(0);
MANGOS_ASSERT(false);
return 0;
}
MANGOS_ASSERT(0);
return 0;
}
/**

View file

@ -883,6 +883,15 @@ bool Object::PrintIndexError(uint32 index, bool set) const
return false;
}
bool Object::PrintEntryError(char const* descr) const
{
sLog.outError("Object Type %u, Entry %u (lowguid %u) with invalid call for %s", GetTypeId(), GetEntry(), GetObjectGuid().GetCounter(), descr);
// always false for continue assert fail
return false;
}
void Object::BuildUpdateDataForPlayer(Player* pl, UpdateDataMapType& update_players)
{
UpdateDataMapType::iterator iter = update_players.find(pl);
@ -1190,7 +1199,7 @@ float WorldObject::GetAngle(const WorldObject* obj) const
if (!obj)
return 0.0f;
MANGOS_ASSERT(obj != this);
MANGOS_ASSERT(obj != this || PrintEntryError("GetAngle (for self)"));
return GetAngle(obj->GetPositionX(), obj->GetPositionY());
}

View file

@ -359,7 +359,6 @@ class MANGOS_DLL_SPEC Object
virtual bool HasInvolvedQuest(uint32 /* quest_id */) const { return false; }
protected:
Object ( );
void _InitValues();
@ -396,10 +395,13 @@ class MANGOS_DLL_SPEC Object
PackedGuid m_PackGUID;
// for output helpfull error messages from ASSERTs
bool PrintIndexError(uint32 index, bool set) const;
Object(const Object&); // prevent generation copy constructor
Object& operator=(Object const&); // prevent generation assigment operator
public:
// for output helpfull error messages from ASSERTs
bool PrintIndexError(uint32 index, bool set) const;
bool PrintEntryError(char const* descr) const;
};
struct WorldObjectChangeAccumulator;

View file

@ -259,8 +259,8 @@ void PathFinder::BuildPolyPath(const Vector3 &startPos, const Vector3 &endPos)
{
for (pathStartIndex = 0; pathStartIndex < m_polyLength; ++pathStartIndex)
{
// here to carch few bugs
MANGOS_ASSERT(m_pathPolyRefs[pathStartIndex] != INVALID_POLYREF);
// here to catch few bugs
MANGOS_ASSERT(m_pathPolyRefs[pathStartIndex] != INVALID_POLYREF || m_sourceUnit->PrintEntryError("PathFinder::BuildPolyPath"));
if (m_pathPolyRefs[pathStartIndex] == startPoly)
{

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11921"
#define REVISION_NR "11922"
#endif // __REVISION_NR_H__