Skip to content

Commit

Permalink
[11922] Add ASSERT helper function to print entry and guid info
Browse files Browse the repository at this point in the history
Use this in first cases: GetAngle and in PathFinder::BuildPolyPath

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
  • Loading branch information
Schmoozerd committed Feb 7, 2012
1 parent d6fe15f commit dfa3d9a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/game/GameObject.cpp
Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions src/game/Map.cpp
Expand Up @@ -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;
}

/**
Expand Down
11 changes: 10 additions & 1 deletion src/game/Object.cpp
Expand Up @@ -883,6 +883,15 @@ bool Object::PrintIndexError(uint32 index, bool set) const
return false;
}

bool Object::PrintEntryError(char const* descr) const

This comment has been minimized.

Copy link
@michalpolko

michalpolko Feb 7, 2012

Contributor

"The procedure entry point blah blah blah" error when server starts, win32 building with VC90 project.

This comment has been minimized.

Copy link
@Schmoozerd

Schmoozerd Feb 7, 2012

Author Contributor

extra tested on VC90 Win32 Release
No problems for me!

Forgotten recompile of mangosscript.dll and an outdated script dll present?

This comment has been minimized.

Copy link
@michalpolko

michalpolko Feb 7, 2012

Contributor

Ah, yes, sorry for bothering ;/

This comment has been minimized.

Copy link
@Schmoozerd

Schmoozerd Feb 7, 2012

Author Contributor

np at all

{
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);
Expand Down Expand Up @@ -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());
}
Expand Down
8 changes: 5 additions & 3 deletions src/game/Object.h
Expand Up @@ -359,7 +359,6 @@ class MANGOS_DLL_SPEC Object
virtual bool HasInvolvedQuest(uint32 /* quest_id */) const { return false; }

protected:

Object ( );

void _InitValues();
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/game/PathFinder.cpp
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11921"
#define REVISION_NR "11922"
#endif // __REVISION_NR_H__

0 comments on commit dfa3d9a

Please sign in to comment.