Skip to content

Commit

Permalink
Use dtAssertFailSetCustom to control Detour assertion behavior
Browse files Browse the repository at this point in the history
This means that upstream master can now be used directly, as the only
extra commit in our branch was to use DAEMON_ASSERT.
  • Loading branch information
slipher committed Dec 11, 2019
1 parent 11278ed commit a7d235e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/recastnavigation
1 change: 1 addition & 0 deletions src/engine/botlib/bot_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

#include "bot_types.h"

void BotInit();
bool BotSetupNav( const botClass_t *botClass, qhandle_t *navHandle );
void BotShutdownNav();

Expand Down
25 changes: 25 additions & 0 deletions src/engine/botlib/bot_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
===========================================================================
*/

#include "common/Common.h"

#include "DetourAssert.h"

#include "bot_local.h"
#include "nav.h"

Expand All @@ -40,6 +44,27 @@ NavData_t BotNavData[ MAX_NAV_DATA ];
LinearAllocator alloc( 1024 * 1024 * 16 );
FastLZCompressor comp;

// Recast uses NDEBUG to determine whether assertions are enabled.
// Make sure this is in sync with DEBUG_BUILD
#if defined(DEBUG_BUILD) != !defined(NDEBUG)
#error
#endif

#ifdef DEBUG_BUILD
static void FailAssertion(const char* expression, const char* file, int line)
{
DAEMON_ASSERT_CALLSITE_HELPER(
file, "Detour assert", line, , , false, Str::Format("\"%s\" is false", expression));
}
#endif

void BotInit()
{
#ifdef DEBUG_BUILD
dtAssertFailSetCustom(FailAssertion);
#endif
}

void BotSaveOffMeshConnections( NavData_t *nav )
{
char mapname[ MAX_QPATH ];
Expand Down
2 changes: 2 additions & 0 deletions src/engine/server/sv_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Maryland 20850 USA.
#include "CryptoChallenge.h"
#include "common/Defs.h"
#include "qcommon/sys.h"
#include "botlib/bot_api.h"

/*
===============
Expand Down Expand Up @@ -603,6 +604,7 @@ Only called at main exe startup, not for each game
void SV_Init()
{
SV_AddOperatorCommands();
BotInit();

// serverinfo vars
Cvar_Get( "timelimit", "0", CVAR_SERVERINFO );
Expand Down
1 change: 1 addition & 0 deletions srclibs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(DETOURLIST
${LIB_DIR}/recastnavigation/DebugUtils/Source/DebugDraw.cpp
${LIB_DIR}/recastnavigation/Detour/Source/DetourAlloc.cpp
${LIB_DIR}/recastnavigation/Detour/Include/DetourAssert.h
${LIB_DIR}/recastnavigation/Detour/Source/DetourAssert.cpp
${LIB_DIR}/recastnavigation/Detour/Source/DetourCommon.cpp
${LIB_DIR}/recastnavigation/DebugUtils/Source/DetourDebugDraw.cpp
${LIB_DIR}/recastnavigation/Detour/Source/DetourNavMesh.cpp
Expand Down

0 comments on commit a7d235e

Please sign in to comment.