Skip to content

Commit

Permalink
fix -Wwarn-zero-as-nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
Morel Bérenger authored and illwieckz committed Jun 18, 2024
1 parent 3985f5b commit ee3d3a4
Show file tree
Hide file tree
Showing 55 changed files with 551 additions and 529 deletions.
6 changes: 3 additions & 3 deletions DebugUtils/Source/DebugDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "DebugDraw.h"
#include "DetourMath.h"
#include "DetourNavMesh.h"

#include "DetourModernCpp.h"

duDebugDraw::~duDebugDraw()
{
Expand Down Expand Up @@ -525,8 +525,8 @@ void duAppendCross(struct duDebugDraw* dd, const float x, const float y, const f
}

duDisplayList::duDisplayList(int cap) :
m_pos(0),
m_color(0),
m_pos(DT_NULL),
m_color(DT_NULL),
m_size(0),
m_cap(0),
m_prim(DU_DRAW_LINES),
Expand Down
8 changes: 4 additions & 4 deletions DebugUtils/Source/DetourDebugDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ void duDebugDrawNavMesh(duDebugDraw* dd, const dtNavMesh& mesh, unsigned char fl
{
const dtMeshTile* tile = mesh.getTile(i);
if (!tile->header) continue;
drawMeshTile(dd, mesh, 0, tile, flags);
drawMeshTile(dd, mesh, DT_NULL, tile, flags);
}
}

void duDebugDrawNavMeshWithClosedList(struct duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery& query, unsigned char flags)
{
if (!dd) return;

const dtNavMeshQuery* q = (flags & DU_DRAWNAVMESH_CLOSEDLIST) ? &query : 0;
const dtNavMeshQuery* q = (flags & DU_DRAWNAVMESH_CLOSEDLIST) ? &query : DT_NULL;

for (int i = 0; i < mesh.getMaxTiles(); ++i)
{
Expand Down Expand Up @@ -440,8 +440,8 @@ void duDebugDrawNavMeshPoly(duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef re
{
if (!dd) return;

const dtMeshTile* tile = 0;
const dtPoly* poly = 0;
const dtMeshTile* tile = DT_NULL;
const dtPoly* poly = DT_NULL;
if (dtStatusFailed(mesh.getTileAndPolyByRef(ref, &tile, &poly)))
return;

Expand Down
3 changes: 2 additions & 1 deletion DebugUtils/Source/RecastDebugDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "DebugDraw.h"
#include "RecastDebugDraw.h"
#include "Recast.h"
#include "DetourModernCpp.h"

void duDebugDrawTriMesh(duDebugDraw* dd, const float* verts, int /*nverts*/,
const int* tris, const float* normals, int ntris,
Expand Down Expand Up @@ -675,7 +676,7 @@ static const rcContour* findContourFromSet(const rcContourSet& cset, unsigned sh
if (cset.conts[i].reg == reg)
return &cset.conts[i];
}
return 0;
return DT_NULL;
}

void duDebugDrawRegionConnections(duDebugDraw* dd, const rcContourSet& cset, const float alpha)
Expand Down
2 changes: 1 addition & 1 deletion Detour/Include/DetourAssert.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dtAssertFailFunc* dtAssertFailGetCustom();
# define dtAssert(expression) \
{ \
dtAssertFailFunc* failFunc = dtAssertFailGetCustom(); \
if(failFunc == NULL) { assert(expression); } \
if(failFunc == DT_NULL) { assert(expression); } \
else if(!(expression)) { (*failFunc)(#expression, __FILE__, __LINE__); } \
}

Expand Down
6 changes: 2 additions & 4 deletions Detour/Include/DetourModernCpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
#include "DetourAssert.h"

#if __cplusplus and __cplusplus >= 201103L
#ifdef NULL
#undef NULL
#endif
#define NULL nullptr
#define DT_NULL nullptr
#define DT_OVERRIDE override
#else
#include <stddef.h>
#define DT_NULL NULL
#define DT_OVERRIDE
#endif

Expand Down
14 changes: 7 additions & 7 deletions Detour/Include/DetourNavMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
#ifndef DETOURNAVMESH_H
#define DETOURNAVMESH_H

#ifdef DT_POLYREF64
// TODO: figure out a multiplatform version of uint64_t
// - maybe: https://code.google.com/p/msinttypes/
// - or: http://www.azillionmonkeys.com/qed/pstdint.h
#include <stdint.h>
#endif

#include "DetourAlloc.h"
#include "DetourStatus.h"

Expand All @@ -27,13 +34,6 @@
// Note: tiles build using 32bit refs are not compatible with 64bit refs!
//#define DT_POLYREF64 1

#ifdef DT_POLYREF64
// TODO: figure out a multiplatform version of uint64_t
// - maybe: https://code.google.com/p/msinttypes/
// - or: http://www.azillionmonkeys.com/qed/pstdint.h
#include <stdint.h>
#endif

// Note: If you want to use 64-bit refs, change the types of both dtPolyRef & dtTileRef.
// It is also recommended that you change dtHashRef() to a proper 64-bit hash.

Expand Down
6 changes: 3 additions & 3 deletions Detour/Include/DetourNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

#include <stdint.h>

#include "DetourModernCpp.h"
#include "DetourNavMesh.h"
#include "DetourModernCpp.h"

enum dtNodeFlags
{
Expand Down Expand Up @@ -70,13 +70,13 @@ class dtNodePool

inline dtNode* getNodeAtIdx(unsigned int idx)
{
if (!idx) return 0;
if (!idx) return DT_NULL;
return &m_nodes[idx - 1];
}

inline const dtNode* getNodeAtIdx(unsigned int idx) const
{
if (!idx) return 0;
if (!idx) return DT_NULL;
return &m_nodes[idx - 1];
}

Expand Down
4 changes: 2 additions & 2 deletions Detour/Source/DetourAssert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
// 3. This notice may not be removed or altered from any source distribution.
//

#include "DetourModernCpp.h"
#include "DetourAssert.h"
#include "DetourModernCpp.h"

#ifndef RC_DISABLE_ASSERTS

static dtAssertFailFunc* sAssertFailFunc = 0;
static dtAssertFailFunc* sAssertFailFunc = DT_NULL;

void dtAssertFailSetCustom(dtAssertFailFunc *assertFailFunc)
{
Expand Down
Loading

0 comments on commit ee3d3a4

Please sign in to comment.