QVM compilation doesn't have access to <assert.h>, so you can't call assert() from any gamecode. This short patch adds assert() to bg_lib.h, which prints a message something like:
********************
ERROR: src/game/g_main.c:529: Assertion `g_entities[ 63 ].client' failed.
********************
----- Server Shutdown (Server crashed: src/game/g_main.c:529: Assertion `g_entities[ 63 ].client' failed.) -----
==== ShutdownGame ====
by calling:
Com_Error( ERR_DROP, __FILE__ ":" str(__LINE__) ": Assertion `" #x "' failed" );
I'm not really sure if this is appropriate to ioq3 given that baseq3 and most mods have their own VMs, but I thought it might be useful nonetheless.
It's worth noting that this causes inconsistent behaviour for assert() between dynamic libraries and QVMs, but it should do its job on both.
One of the issues with this as a feature is that it isn't optimised out as it should be by NDEBUG, because the build process doesn't differentiate between debug/release builds for the QVMs.
Created attachment 2066[details]
better assert()
I put the attached in Tremulous SVN at r1151, where it has seen very little (yet nonzero) usage.
The version I'm attaching now is simpler and doesn't break when expr contains a percent symbol.
Created attachment 1800 [details] assert()
Created attachment 2066 [details] better assert() I put the attached in Tremulous SVN at r1151, where it has seen very little (yet nonzero) usage. The version I'm attaching now is simpler and doesn't break when expr contains a percent symbol.