use standard assert()

and define NDEBUG for all buildtypes that are not debug, to
disable it by default
master
Daniel Kolesa 2020-07-30 03:48:18 +02:00
rodzic 5f3ceea7bf
commit 5b7e1e6dd2
9 zmienionych plików z 31 dodań i 20 usunięć

Wyświetl plik

@ -2,6 +2,8 @@
#include "main.hh"
#include <cassert>
#include <shared/command.hh>
#include <shared/glemu.hh>
#include <shared/igame.hh>
@ -1236,7 +1238,7 @@ int main(int argc, char **argv)
renderedframe = inbetweenframes = true;
}
ASSERT(0);
assert(false);
return EXIT_FAILURE;
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)

Wyświetl plik

@ -9,6 +9,8 @@
#include "movie.hh"
#include <cassert>
#include <shared/command.hh>
#include "console.hh" /* conoutf */
@ -96,13 +98,13 @@ struct aviwriter
void endchunk()
{
ASSERT(chunkdepth >= 0);
assert(chunkdepth >= 0);
--chunkdepth;
}
void endlistchunk()
{
ASSERT(chunkdepth >= 0);
assert(chunkdepth >= 0);
int size = int(totalsize - chunkoffsets[chunkdepth]);
f->seek(-4 - size, SEEK_CUR);
f->putlil(size);

Wyświetl plik

@ -409,7 +409,7 @@ namespace mpr
// Determine whether origin is on + or - side of plane (v1,v0,v2)
n.cross(v0, v1, v2);
ASSERT( !n.iszero() );
assert( !n.iszero() );
// If the origin is on the - side of the plane, reverse the direction of the plane
if(n.dot(v0) > 0)
{
@ -471,7 +471,7 @@ namespace mpr
// Can this happen??? Can it be handled more cleanly?
if(n.iszero())
{
ASSERT(0);
assert(false);
return true;
}

Wyświetl plik

@ -2,6 +2,8 @@
#include "octa.hh"
#include <cassert>
#include <shared/command.hh>
#include <shared/igame.hh>
@ -879,7 +881,7 @@ static inline int clipfacevec(const ivec2 &o, const ivec2 &dir, int cx, int cy,
r += clipfacevecy(o, dir, cx, cy, size, rvecs[r]);
r += clipfacevecy(o, dir, cx+size, cy, size, rvecs[r]);
ASSERT(r <= 2);
assert(r <= 2);
return r;
}
@ -915,7 +917,7 @@ static inline int clipfacevecs(const ivec2 *o, int numo, int cx, int cy, int siz
}
ivec2 corner[4] = {ivec2(cx, cy), ivec2(cx+size, cy), ivec2(cx+size, cy+size), ivec2(cx, cy+size)};
loopi(4) if(insideface(&corner[i], 1, o, numo)) rvecs[r++] = corner[i];
ASSERT(r <= 8);
assert(r <= 8);
return r;
}

Wyświetl plik

@ -2,6 +2,8 @@
#include "octarender.hh"
#include <cassert>
#include <shared/command.hh>
#include <shared/glemu.hh>
#include <shared/igame.hh>
@ -1497,7 +1499,7 @@ static octaentities *entstack[32];
static void setva(cube &c, const ivec &co, int size, int csi)
{
ASSERT(size <= 0x1000);
assert(size <= 0x1000);
int vamergeoffset[MAXMERGELEVEL+1];
loopi(MAXMERGELEVEL+1) vamergeoffset[i] = vamerges[i].length();

Wyświetl plik

@ -5,6 +5,8 @@
#include "physics.hh"
#include <cassert>
#include <shared/command.hh>
#include <shared/igame.hh>

Wyświetl plik

@ -1,5 +1,7 @@
#include "water.hh"
#include <cassert>
#include <shared/command.hh>
#include <shared/glemu.hh>
@ -307,8 +309,8 @@ static void rendervertwater(int subdiv, int xo, int yo, int z, int size, int mat
wsize = size;
whscale = 59.0f/(23.0f*wsize*wsize)/(2*M_PI);
ASSERT((wx1 & (subdiv - 1)) == 0);
ASSERT((wy1 & (subdiv - 1)) == 0);
assert((wx1 & (subdiv - 1)) == 0);
assert((wy1 & (subdiv - 1)) == 0);
switch(mat)
{

Wyświetl plik

@ -1,5 +1,9 @@
add_global_arguments('-D_FILE_OFFSET_BITS=64', language: 'cpp')
if get_option('buildtype') != 'debug'
add_global_arguments('-DNDEBUG', language: 'cpp')
endif
octacore_includes = [
include_directories('.', 'shared', 'engine', 'game')
]

Wyświetl plik

@ -7,6 +7,7 @@
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <new>
@ -20,12 +21,6 @@ typedef unsigned long ulong;
typedef signed long long int llong;
typedef unsigned long long int ullong;
#ifdef _DEBUG
#define ASSERT(c) assert(c)
#else
#define ASSERT(c) if(c) {}
#endif
#if defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1400)
#define RESTRICT __restrict
#else
@ -604,13 +599,13 @@ template <class T> struct vector
int capacity() const { return alen; }
int length() const { return ulen; }
T &operator[](int i) { ASSERT(i>=0 && i<ulen); return buf[i]; }
const T &operator[](int i) const { ASSERT(i >= 0 && i<ulen); return buf[i]; }
T &operator[](int i) { assert(i>=0 && i<ulen); return buf[i]; }
const T &operator[](int i) const { assert(i >= 0 && i<ulen); return buf[i]; }
T *disown() { T *r = buf; buf = nullptr; alen = ulen = 0; return r; }
void shrink(int i) { ASSERT(i<=ulen); if(isclass<T>::no) ulen = i; else while(ulen>i) drop(); }
void setsize(int i) { ASSERT(i<=ulen); ulen = i; }
void shrink(int i) { assert(i<=ulen); if(isclass<T>::no) ulen = i; else while(ulen>i) drop(); }
void setsize(int i) { assert(i<=ulen); ulen = i; }
void deletecontents(int n = 0) { while(ulen > n) delete pop(); }
void deletearrays(int n = 0) { while(ulen > n) delete[] pop(); }