use nullptr

master
Daniel Kolesa 2020-07-30 03:15:44 +02:00
parent dc27d1296d
commit d68b813f44
61 changed files with 907 additions and 912 deletions

View File

@ -39,7 +39,7 @@ static void setuptqaa(int w, int h)
if(!tqaatex[i]) glGenTextures(1, &tqaatex[i]);
if(!tqaafbo[i]) glGenFramebuffers_(1, &tqaafbo[i]);
glBindFramebuffer_(GL_FRAMEBUFFER, tqaafbo[i]);
createtexture(tqaatex[i], w, h, NULL, 3, 1, GL_RGBA8, GL_TEXTURE_RECTANGLE);
createtexture(tqaatex[i], w, h, nullptr, 3, 1, GL_RGBA8, GL_TEXTURE_RECTANGLE);
glFramebufferTexture2D_(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, tqaatex[i], 0);
bindgdepth();
if(glCheckFramebufferStatus_(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
@ -129,12 +129,12 @@ static void dotqaa(GLuint outfbo = 0)
static GLuint fxaafbo = 0, fxaatex = 0;
static int fxaatype = -1;
static Shader *fxaashader = NULL;
static Shader *fxaashader = nullptr;
static void clearfxaashaders()
{
fxaatype = -1;
fxaashader = NULL;
fxaashader = nullptr;
}
static void cleanupfxaa()
@ -168,7 +168,7 @@ static void setupfxaa(int w, int h)
if(!fxaatex) glGenTextures(1, &fxaatex);
if(!fxaafbo) glGenFramebuffers_(1, &fxaafbo);
glBindFramebuffer_(GL_FRAMEBUFFER, fxaafbo);
createtexture(fxaatex, w, h, NULL, 3, 1, tqaa || (!fxaagreenluma && !intel_texalpha_bug) ? GL_RGBA8 : GL_RGB, GL_TEXTURE_RECTANGLE);
createtexture(fxaatex, w, h, nullptr, 3, 1, tqaa || (!fxaagreenluma && !intel_texalpha_bug) ? GL_RGBA8 : GL_RGB, GL_TEXTURE_RECTANGLE);
glFramebufferTexture2D_(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, fxaatex, 0);
bindgdepth();
if(glCheckFramebufferStatus_(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
@ -196,7 +196,7 @@ static GLuint smaaareatex = 0, smaasearchtex = 0, smaafbo[4] = { 0, 0, 0, 0 }, s
static int smaasubsampleorder = -1;
static int smaatype = -1;
static Shader *smaalumaedgeshader = NULL, *smaacoloredgeshader = NULL, *smaablendweightshader = NULL, *smaaneighborhoodshader = NULL;
static Shader *smaalumaedgeshader = nullptr, *smaacoloredgeshader = nullptr, *smaablendweightshader = nullptr, *smaaneighborhoodshader = nullptr;
VAR(smaat2x, 1, 0, 0);
VAR(smaas2x, 1, 0, 0);
@ -205,10 +205,10 @@ VAR(smaa4x, 1, 0, 0);
static void clearsmaashaders()
{
smaatype = -1;
smaalumaedgeshader = NULL;
smaacoloredgeshader = NULL;
smaablendweightshader = NULL;
smaaneighborhoodshader = NULL;
smaalumaedgeshader = nullptr;
smaacoloredgeshader = nullptr;
smaablendweightshader = nullptr;
smaaneighborhoodshader = nullptr;
}
static void cleanupsmaa()
@ -258,7 +258,7 @@ static void loadsmaashaders(bool split = false)
if(smaalumaedgeshader && smaacoloredgeshader && smaablendweightshader && smaaneighborhoodshader) return;
generateshader(NULL, "smaashaders %d \"%s\"", smaaquality, opts);
generateshader(nullptr, "smaashaders %d \"%s\"", smaaquality, opts);
smaalumaedgeshader = lookupshaderbyname(lumaedgename);
if(!smaalumaedgeshader) smaalumaedgeshader = nullshader;
smaacoloredgeshader = lookupshaderbyname(coloredgename);
@ -549,12 +549,12 @@ static void setupsmaa(int w, int h)
case 1: format = hasTRG ? GL_RG8 : GL_RGBA8; break;
case 2: case 3: format = GL_RGBA8; break;
}
createtexture(smaatex[i], w, h, NULL, 3, 1, format, GL_TEXTURE_RECTANGLE);
createtexture(smaatex[i], w, h, nullptr, 3, 1, format, GL_TEXTURE_RECTANGLE);
glFramebufferTexture2D_(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, smaatex[i], 0);
if(!i && split)
{
if(!smaatex[4]) glGenTextures(1, &smaatex[4]);
createtexture(smaatex[4], w, h, NULL, 3, 1, format, GL_TEXTURE_RECTANGLE);
createtexture(smaatex[4], w, h, nullptr, 3, 1, format, GL_TEXTURE_RECTANGLE);
glFramebufferTexture2D_(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_RECTANGLE, smaatex[4], 0);
static const GLenum drawbufs[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
glDrawBuffers_(2, drawbufs);

View File

@ -116,13 +116,13 @@ struct animmodel : model
int cullface;
shaderparamskey *key;
skin() : owner(0), tex(notexture), decal(NULL), masks(notexture), envmap(NULL), normalmap(NULL), shader(NULL), rsmshader(NULL), cullface(1), key(NULL) {}
skin() : owner(0), tex(notexture), decal(nullptr), masks(notexture), envmap(nullptr), normalmap(nullptr), shader(nullptr), rsmshader(nullptr), cullface(1), key(nullptr) {}
bool masked() const { return masks != notexture; }
bool envmapped() const { return envmapmax>0; }
bool bumpmapped() const { return normalmap != NULL; }
bool bumpmapped() const { return normalmap != nullptr; }
bool alphatested() const { return alphatest > 0 && tex->type&Texture::ALPHA; }
bool decaled() const { return decal != NULL; }
bool decaled() const { return decal != nullptr; }
void setkey()
{
@ -161,7 +161,7 @@ struct animmodel : model
{
#define DOMODELSHADER(name, body) \
do { \
static Shader *name##shader = NULL; \
static Shader *name##shader = nullptr; \
if(!name##shader) name##shader = useshaderbyname(#name); \
body; \
} while(0)
@ -202,7 +202,7 @@ struct animmodel : model
void cleanup()
{
if(shader && shader->standard) shader = NULL;
if(shader && shader->standard) shader = nullptr;
}
void preloadBIH()
@ -300,7 +300,7 @@ struct animmodel : model
char *name;
bool cancollide, canrender, noclip;
mesh() : group(NULL), name(NULL), cancollide(true), canrender(true), noclip(false)
mesh() : group(nullptr), name(nullptr), cancollide(true), canrender(true), noclip(false)
{
}
@ -506,7 +506,7 @@ struct animmodel : model
char *name;
vector<mesh *> meshes;
meshgroup() : next(NULL), shared(0), name(NULL)
meshgroup() : next(nullptr), shared(0), name(nullptr)
{
}
@ -627,7 +627,7 @@ struct animmodel : model
vec *pos;
matrix4 matrix;
linkedpart() : p(NULL), tag(-1), anim(-1), basetime(0), translate(0, 0, 0), pos(NULL) {}
linkedpart() : p(nullptr), tag(-1), anim(-1), basetime(0), translate(0, 0, 0), pos(nullptr) {}
};
struct part
@ -641,9 +641,9 @@ struct animmodel : model
int numanimparts;
float pitchscale, pitchoffset, pitchmin, pitchmax;
part(animmodel *model, int index = 0) : model(model), index(index), meshes(NULL), numanimparts(1), pitchscale(1), pitchoffset(0), pitchmin(0), pitchmax(0)
part(animmodel *model, int index = 0) : model(model), index(index), meshes(nullptr), numanimparts(1), pitchscale(1), pitchoffset(0), pitchmin(0), pitchmax(0)
{
loopk(MAXANIMPARTS) anims[k] = NULL;
loopk(MAXANIMPARTS) anims[k] = nullptr;
}
virtual ~part()
{
@ -703,7 +703,7 @@ struct animmodel : model
}
}
bool link(part *p, const char *tag, const vec &translate = vec(0, 0, 0), int anim = -1, int basetime = 0, vec *pos = NULL)
bool link(part *p, const char *tag, const vec &translate = vec(0, 0, 0), int anim = -1, int basetime = 0, vec *pos = nullptr)
{
int i = meshes ? meshes->findtag(tag) : -1;
if(i<0)
@ -785,7 +785,7 @@ struct animmodel : model
}
else
{
animspec *spec = NULL;
animspec *spec = nullptr;
if(anims[animpart])
{
vector<animspec> &primary = anims[animpart][anim&ANIM_INDEX];
@ -1222,7 +1222,7 @@ struct animmodel : model
animmodel *m = (animmodel *)a[i].m;
if(!m)
{
if(a[i].pos) link(NULL, a[i].tag, vec(0, 0, 0), 0, 0, a[i].pos);
if(a[i].pos) link(nullptr, a[i].tag, vec(0, 0, 0), 0, 0, a[i].pos);
continue;
}
part *p = m->parts[0];
@ -1266,7 +1266,7 @@ struct animmodel : model
animmodel *m = (animmodel *)a[i].m;
if(!m)
{
if(a[i].pos) unlink(NULL);
if(a[i].pos) unlink(nullptr);
continue;
}
part *p = m->parts[0];
@ -1444,7 +1444,7 @@ struct animmodel : model
return bih;
}
bool link(part *p, const char *tag, const vec &translate = vec(0, 0, 0), int anim = -1, int basetime = 0, vec *pos = NULL)
bool link(part *p, const char *tag, const vec &translate = vec(0, 0, 0), int anim = -1, int basetime = 0, vec *pos = nullptr)
{
if(parts.empty()) return false;
return parts[0]->link(p, tag, translate, anim, basetime, pos);
@ -1631,7 +1631,7 @@ struct animmodel : model
enabletc = enabletangents = enablebones = enabledepthoffset = false;
enablecullface = true;
lastvbuf = lasttcbuf = lastxbuf = lastbbuf = lastebuf = lastenvmaptex = closestenvmaptex = 0;
lasttex = lastdecal = lastmasks = lastnormalmap = NULL;
lasttex = lastdecal = lastmasks = lastnormalmap = nullptr;
shaderparamskey::invalidate();
}
@ -1685,7 +1685,7 @@ float animmodel::sizescale = 1;
vec4 animmodel::colorscale(1, 1, 1, 1);
GLuint animmodel::lastvbuf = 0, animmodel::lasttcbuf = 0, animmodel::lastxbuf = 0, animmodel::lastbbuf = 0, animmodel::lastebuf = 0,
animmodel::lastenvmaptex = 0, animmodel::closestenvmaptex = 0;
Texture *animmodel::lasttex = NULL, *animmodel::lastdecal = NULL, *animmodel::lastmasks = NULL, *animmodel::lastnormalmap = NULL;
Texture *animmodel::lasttex = nullptr, *animmodel::lastdecal = nullptr, *animmodel::lastmasks = nullptr, *animmodel::lastnormalmap = nullptr;
int animmodel::matrixpos = 0;
matrix4 animmodel::matrixstack[64];
@ -1720,7 +1720,7 @@ template<class MDL, class BASE> struct modelloader : BASE
void endload()
{
loading = NULL;
loading = nullptr;
}
bool loadconfig()
@ -1735,7 +1735,7 @@ template<class MDL, class BASE> struct modelloader : BASE
}
};
template<class MDL, class BASE> MDL *modelloader<MDL, BASE>::loading = NULL;
template<class MDL, class BASE> MDL *modelloader<MDL, BASE>::loading = nullptr;
template<class MDL, class BASE> string modelloader<MDL, BASE>::dir = {'\0'}; // crashes clang if "" is used here
template<class MDL, class MESH> struct modelcommands

View File

@ -236,7 +236,7 @@ void BIH::build(mesh &m, ushort *indices, int numindices, const ivec &vmin, cons
}
BIH::BIH(vector<mesh> &buildmeshes)
: meshes(NULL), nummeshes(0), nodes(NULL), numnodes(0), tribbs(NULL), numtris(0), bbmin(1e16f, 1e16f, 1e16f), bbmax(-1e16f, -1e16f, -1e16f), center(0, 0, 0), radius(0), entradius(0)
: meshes(nullptr), nummeshes(0), nodes(nullptr), numnodes(0), tribbs(nullptr), numtris(0), bbmin(1e16f, 1e16f, 1e16f), bbmax(-1e16f, -1e16f, -1e16f), center(0, 0, 0), radius(0), entradius(0)
{
if(buildmeshes.empty()) return;
loopv(buildmeshes) numtris += buildmeshes[i].numtris;

View File

@ -57,7 +57,7 @@ struct BIH
int flags;
vec bbmin, bbmax;
mesh() : numnodes(0), numtris(0), tex(NULL), flags(0) {}
mesh() : numnodes(0), numtris(0), tex(nullptr), flags(0) {}
vec getpos(int i) const { return *(const vec *)(pos + i*posstride); }
vec2 gettc(int i) const { return *(const vec2 *)(tc + i*tcstride); }

View File

@ -135,7 +135,7 @@ struct BlendMapCache
BlendMapCache *newblendmapcache() { return new BlendMapCache; }
void freeblendmapcache(BlendMapCache *&cache) { delete cache; cache = NULL; }
void freeblendmapcache(BlendMapCache *&cache) { delete cache; cache = nullptr; }
bool setblendmaporigin(BlendMapCache *cache, const ivec &o, int size)
{
@ -648,7 +648,7 @@ struct BlendTexture
GLenum format;
bool valid;
BlendTexture() : x(0), y(0), size(0), data(NULL), tex(0), format(GL_FALSE), valid(false)
BlendTexture() : x(0), y(0), size(0), data(nullptr), tex(0), format(GL_FALSE), valid(false)
{}
~BlendTexture()
@ -666,7 +666,7 @@ struct BlendTexture
if(data) delete[] data;
data = new uchar[size*size];
format = hasTRG ? GL_RED : GL_LUMINANCE;
createtexture(tex, size, size, NULL, 3, 1, hasTRG ? GL_R8 : GL_LUMINANCE8);
createtexture(tex, size, size, nullptr, 3, 1, hasTRG ? GL_R8 : GL_LUMINANCE8);
valid = false;
return true;
}
@ -674,7 +674,7 @@ struct BlendTexture
void cleanup()
{
if(tex) { glDeleteTextures(1, &tex); tex = 0; }
if(data) { delete[] data; data = NULL; }
if(data) { delete[] data; data = nullptr; }
size = 0;
valid = false;
}
@ -830,7 +830,7 @@ static void updateblendtextures(uchar &type, BlendMapNode &node, int bmx, int bm
ty2 = (min(bmy+bmsize, uy+uh) + (0x1000>>BM_SCALE)-1)&~((0x1000>>BM_SCALE)-1);
for(int ty = ty1; ty < ty2; ty += 0x1000>>BM_SCALE) for(int tx = tx1; tx < tx2; tx += 0x1000>>BM_SCALE)
{
BlendTexture *bt = NULL;
BlendTexture *bt = nullptr;
loopv(blendtexs) if(blendtexs[i].contains(tx<<BM_SCALE, ty<<BM_SCALE)) { bt = &blendtexs[i]; break; }
if(!bt)
{

View File

@ -10,7 +10,7 @@
hashnameset<ident> idents; // contains ALL vars/commands/aliases
vector<ident *> identmap;
ident *dummyident = NULL;
ident *dummyident = nullptr;
int identflags = 0;
@ -112,7 +112,7 @@ static inline void cleancode(ident &id)
{
id.code[0] -= 0x100;
if(int(id.code[0]) < 0x100) delete[] id.code;
id.code = NULL;
id.code = nullptr;
}
}
@ -173,7 +173,7 @@ void clearoverrides()
}
static bool initedidents = false;
static vector<ident> *identinits = NULL;
static vector<ident> *identinits = nullptr;
static inline ident *addident(const ident &id)
{
@ -181,7 +181,7 @@ static inline ident *addident(const ident &id)
{
if(!identinits) identinits = new vector<ident>;
identinits->add(id);
return NULL;
return nullptr;
}
ident &def = idents.access(id.name, id);
def.index = identmap.length();
@ -206,7 +206,7 @@ static bool initidents()
}
UNUSED static bool forceinitidents = initidents();
static const char *sourcefile = NULL, *sourcestr = NULL;
static const char *sourcefile = nullptr, *sourcestr = nullptr;
static const char *debugline(const char *p, const char *fmt)
{
@ -237,7 +237,7 @@ static struct identlink
identlink *next;
int usedargs;
identstack *argstack;
} noalias = { NULL, NULL, (1<<MAXARGS)-1, NULL }, *aliasstack = &noalias;
} noalias = { nullptr, nullptr, (1<<MAXARGS)-1, nullptr }, *aliasstack = &noalias;
VAR(dbgalias, 0, 4, 1000);
@ -463,7 +463,7 @@ ident *readident(const char *name)
{
ident *id = idents.access(name);
if(id && id->index < MAXARGS && !(aliasstack->usedargs&(1<<id->index)))
return NULL;
return nullptr;
return id;
}
@ -579,7 +579,7 @@ struct defvar : identval
char *name;
uint *onchange;
defvar() : name(NULL), onchange(NULL) {}
defvar() : name(nullptr), onchange(nullptr) {}
~defvar()
{
@ -603,18 +603,18 @@ hashnameset<defvar> defvars;
name = newstring(name); \
defvar &def = defvars[name]; \
def.name = name; \
def.onchange = onchange[0] ? compilecode(onchange) : NULL; \
def.onchange = onchange[0] ? compilecode(onchange) : nullptr; \
body; \
});
#define DEFIVAR(cmdname, flags) \
DEFVAR(cmdname, "siiis", (char *name, int *min, int *cur, int *max, char *onchange), \
def.i = variable(name, *min, *cur, *max, &def.i, def.onchange ? defvar::changed : NULL, flags))
def.i = variable(name, *min, *cur, *max, &def.i, def.onchange ? defvar::changed : nullptr, flags))
#define DEFFVAR(cmdname, flags) \
DEFVAR(cmdname, "sfffs", (char *name, float *min, float *cur, float *max, char *onchange), \
def.f = fvariable(name, *min, *cur, *max, &def.f, def.onchange ? defvar::changed : NULL, flags))
def.f = fvariable(name, *min, *cur, *max, &def.f, def.onchange ? defvar::changed : nullptr, flags))
#define DEFSVAR(cmdname, flags) \
DEFVAR(cmdname, "sss", (char *name, char *cur, char *onchange), \
def.s = svariable(name, cur, &def.s, def.onchange ? defvar::changed : NULL, flags))
def.s = svariable(name, cur, &def.s, def.onchange ? defvar::changed : nullptr, flags))
DEFIVAR(defvar, 0);
DEFIVAR(defvarp, IDF_PERSIST);
@ -698,7 +698,7 @@ ICOMMAND(getvarmax, "s", (char *s), intret(getvarmax(s)));
ICOMMAND(getfvarmin, "s", (char *s), floatret(getfvarmin(s)));
ICOMMAND(getfvarmax, "s", (char *s), floatret(getfvarmax(s)));
bool identexists(const char *name) { return idents.access(name)!=NULL; }
bool identexists(const char *name) { return idents.access(name)!=nullptr; }
ICOMMAND(identexists, "s", (char *s), intret(identexists(s) ? 1 : 0));
ident *getident(const char *name) { return idents.access(name); }
@ -869,7 +869,7 @@ int unescapestring(char *dst, const char *src, const char *end)
return dst - start;
}
static char *conc(vector<char> &buf, tagval *v, int n, bool space, const char *prefix = NULL, int prefixlen = 0)
static char *conc(vector<char> &buf, tagval *v, int n, bool space, const char *prefix = nullptr, int prefixlen = 0)
{
if(prefix)
{
@ -952,7 +952,7 @@ overflow:
static inline char *conc(tagval *v, int n, bool space)
{
return conc(v, n, space, NULL, 0);
return conc(v, n, space, nullptr, 0);
}
static inline char *conc(tagval *v, int n, bool space, const char *prefix)
@ -1031,7 +1031,7 @@ static inline char *cutword(const char *&p)
{
const char *word = p;
p = parseword(p);
return p!=word ? newstring(word, p-word) : NULL;
return p!=word ? newstring(word, p-word) : nullptr;
}
#define retcode(type, defaultret) ((type) >= VAL_ANY ? ((type) == VAL_CSTR ? RET_STR : (defaultret)) : (type) << CODE_RET)
@ -1203,7 +1203,7 @@ static inline bool getbool(const tagval &v)
}
}
static inline void compileval(vector<uint> &code, int wordtype, const stringslice &word = stringslice(NULL, 0))
static inline void compileval(vector<uint> &code, int wordtype, const stringslice &word = stringslice(nullptr, 0))
{
switch(wordtype)
{
@ -1220,7 +1220,7 @@ static inline void compileval(vector<uint> &code, int wordtype, const stringslic
}
}
static stringslice unusedword(NULL, 0);
static stringslice unusedword(nullptr, 0);
static bool compilearg(vector<uint> &code, const char *&p, int wordtype, int prevargs = MAXRESULTS, stringslice &word = unusedword);
static void compilelookup(vector<uint> &code, const char *&p, int ltype, int prevargs = MAXRESULTS)
@ -1298,7 +1298,7 @@ static void compilelookup(vector<uint> &code, const char *&p, int ltype, int pre
for(const char *fmt = id->args; *fmt; fmt++) switch(*fmt)
{
case 'S': compilestr(code); numargs++; break;
case 's': compilestr(code, NULL, 0, true); numargs++; break;
case 's': compilestr(code, nullptr, 0, true); numargs++; break;
case 'i': compileint(code); numargs++; break;
case 'b': compileint(code, INT_MIN); numargs++; break;
case 'f': compilefloat(code); numargs++; break;
@ -1536,7 +1536,7 @@ done:
case VAL_CODE: if(!concs && p-1 <= start) compileblock(code); else code.add(CODE_COMPILE); break;
case VAL_IDENT: if(!concs && p-1 <= start) compileident(code); else code.add(CODE_IDENTU); break;
case VAL_CSTR: case VAL_CANY:
if(!concs && p-1 <= start) compilestr(code, NULL, 0, true);
if(!concs && p-1 <= start) compilestr(code, nullptr, 0, true);
break;
case VAL_STR: case VAL_NULL: case VAL_ANY: case VAL_WORD:
if(!concs && p-1 <= start) compilestr(code);
@ -1674,7 +1674,7 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
for(;;)
{
skipcomments(p);
idname.str = NULL;
idname.str = nullptr;
bool more = compilearg(code, p, VAL_WORD, prevargs, idname);
if(!more) goto endstatement;
skipcomments(p);
@ -1760,7 +1760,7 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
if(!more)
{
if(rep) break;
compilestr(code, NULL, 0, *fmt=='s');
compilestr(code, nullptr, 0, *fmt=='s');
fakeargs++;
}
else if(!fmt[1])
@ -2906,7 +2906,7 @@ char *executestr(const uint *code)
{
tagval result;
runcode(code, result);
if(result.type == VAL_NULL) return NULL;
if(result.type == VAL_NULL) return nullptr;
forcestr(result);
return result.s;
}
@ -2915,7 +2915,7 @@ char *executestr(const char *p)
{
tagval result;
executeret(p, result);
if(result.type == VAL_NULL) return NULL;
if(result.type == VAL_NULL) return nullptr;
forcestr(result);
return result.s;
}
@ -2924,7 +2924,7 @@ char *executestr(ident *id, tagval *args, int numargs, bool lookup)
{
tagval result;
executeret(id, args, numargs, lookup, result);
if(result.type == VAL_NULL) return NULL;
if(result.type == VAL_NULL) return nullptr;
forcestr(result);
return result.s;
}
@ -2932,7 +2932,7 @@ char *executestr(ident *id, tagval *args, int numargs, bool lookup)
char *execidentstr(const char *name, bool lookup)
{
ident *id = idents.access(name);
return id ? executestr(id, NULL, 0, lookup) : NULL;
return id ? executestr(id, nullptr, 0, lookup) : nullptr;
}
int execute(const uint *code)
@ -2969,7 +2969,7 @@ int execute(ident *id, tagval *args, int numargs, bool lookup)
int execident(const char *name, int noid, bool lookup)
{
ident *id = idents.access(name);
return id ? execute(id, NULL, 0, lookup) : noid;
return id ? execute(id, nullptr, 0, lookup) : noid;
}
float executefloat(const uint *code)
@ -3002,7 +3002,7 @@ float executefloat(ident *id, tagval *args, int numargs, bool lookup)
float execidentfloat(const char *name, float noid, bool lookup)
{
ident *id = idents.access(name);
return id ? executefloat(id, NULL, 0, lookup) : noid;
return id ? executefloat(id, nullptr, 0, lookup) : noid;
}
bool executebool(const uint *code)
@ -3035,14 +3035,14 @@ bool executebool(ident *id, tagval *args, int numargs, bool lookup)
bool execidentbool(const char *name, bool noid, bool lookup)
{
ident *id = idents.access(name);
return id ? executebool(id, NULL, 0, lookup) : noid;
return id ? executebool(id, nullptr, 0, lookup) : noid;
}
bool execfile(const char *cfgfile, bool msg)
{
string s;
copystring(s, cfgfile);
char *buf = loadfile(path(s), NULL);
char *buf = loadfile(path(s), nullptr);
if(!buf)
{
if(msg) conoutf(CON_ERROR, "could not read \"%s\"", cfgfile);
@ -3420,7 +3420,7 @@ void format(tagval *args, int numargs)
}
COMMAND(format, "V");
static const char *liststart = NULL, *listend = NULL, *listquotestart = NULL, *listquoteend = NULL;
static const char *liststart = nullptr, *listend = nullptr, *listquotestart = nullptr, *listquoteend = nullptr;
static inline void skiplist(const char *&p)
{
@ -3823,7 +3823,7 @@ ICOMMAND(loopfiles, "rsse", (ident *id, char *dir, char *ext, uint *body),
if(id->type!=ID_ALIAS) return;
identstack stack;
vector<char *> files;
listfiles(dir, ext[0] ? ext : NULL, files);
listfiles(dir, ext[0] ? ext : nullptr, files);
files.sort();
files.uniquedeletearrays();
loopv(files)
@ -3911,7 +3911,7 @@ void sortlist(char *list, ident *x, ident *y, uint *body, uint *unique)
for(int i = 1; i < items.length(); i++)
{
sortitem &item = items[i];
if(f(items[i-1], item)) item.quotestart = NULL;
if(f(items[i-1], item)) item.quotestart = nullptr;
else { totalunique += item.quotelength(); numunique++; }
}
}
@ -3927,7 +3927,7 @@ void sortlist(char *list, ident *x, ident *y, uint *body, uint *unique)
loopj(i)
{
sortitem &prev = items[j];
if(prev.quotestart && f(item, prev)) { item.quotestart = NULL; break; }
if(prev.quotestart && f(item, prev)) { item.quotestart = nullptr; break; }
}
if(item.quotestart) { totalunique += item.quotelength(); numunique++; }
}
@ -3959,7 +3959,7 @@ void sortlist(char *list, ident *x, ident *y, uint *body, uint *unique)
commandret->setstr(sorted);
}
COMMAND(sortlist, "srree");
ICOMMAND(uniquelist, "srre", (char *list, ident *x, ident *y, uint *body), sortlist(list, x, y, NULL, body));
ICOMMAND(uniquelist, "srre", (char *list, ident *x, ident *y, uint *body), sortlist(list, x, y, nullptr, body));
#define MATHCMD(name, fmt, type, op, initval, unaryop) \
ICOMMANDS(name, #fmt "1V", (tagval *args, int numargs), \
@ -4282,7 +4282,7 @@ void checksleep(int millis)
if(millis - s.millis >= s.delay)
{
char *cmd = s.command; // execute might create more sleep commands
s.command = NULL;
s.command = nullptr;
int oldflags = identflags;
identflags = s.flags;
execute(cmd);

View File

@ -8,7 +8,7 @@ extern hashnameset<ident> idents;
extern int identflags;
void clearoverrides();
void writecfg(const char *name = NULL);
void writecfg(const char *name = nullptr);
void checksleep(int millis);
void clearsleep(bool clearoverrides = true);

View File

@ -19,7 +19,7 @@ static reversequeue<cline, MAXCONLINES> conlines;
static int commandmillis = -1;
static string commandbuf;
static char *commandaction = NULL, *commandprompt = NULL;
static char *commandaction = nullptr, *commandprompt = nullptr;
enum { CF_COMPLETE = 1<<0, CF_EXECUTE = 1<<1 };
static int commandflags = 0, commandpos = -1;
@ -187,7 +187,7 @@ struct keym
char *actions[NUMACTIONS];
bool pressed;
keym() : code(-1), name(NULL), pressed(false) { loopi(NUMACTIONS) actions[i] = newstring(""); }
keym() : code(-1), name(nullptr), pressed(false) { loopi(NUMACTIONS) actions[i] = newstring(""); }
~keym() { DELETEA(name); loopi(NUMACTIONS) DELETEA(actions[i]); }
void clear(int type);
@ -207,14 +207,14 @@ static void keymap(int *code, char *key)
COMMAND(keymap, "is");
static keym *keypressed = NULL;
static char *keyaction = NULL;
static keym *keypressed = nullptr;
static char *keyaction = nullptr;
#if 0
static const char *getkeyname(int code)
{
keym *km = keyms.access(code);
return km ? km->name : NULL;
return km ? km->name : nullptr;
}
#endif
@ -239,7 +239,7 @@ static keym *findbind(char *key)
{
if(!strcasecmp(km.name, key)) return &km;
});
return NULL;
return nullptr;
}
static void getbind(char *key, int type)
@ -287,7 +287,7 @@ ICOMMAND(clearspecbinds, "", (), enumerate(keyms, keym, km, km.clear(keym::ACTIO
ICOMMAND(cleareditbinds, "", (), enumerate(keyms, keym, km, km.clear(keym::ACTION_EDITING)));
ICOMMAND(clearallbinds, "", (), enumerate(keyms, keym, km, km.clear()));
static void inputcommand(char *init, char *action = NULL, char *prompt = NULL, char *flags = NULL) // turns input to the command line on or off
static void inputcommand(char *init, char *action = nullptr, char *prompt = nullptr, char *flags = nullptr) // turns input to the command line on or off
{
commandmillis = init ? totalmillis : -1;
textinput(commandmillis >= 0, TI_CONSOLE);
@ -328,7 +328,7 @@ struct hline
char *buf, *action, *prompt;
int flags;
hline() : buf(NULL), action(NULL), prompt(NULL), flags(0) {}
hline() : buf(nullptr), action(nullptr), prompt(nullptr), flags(0) {}
~hline()
{
DELETEA(buf);
@ -350,8 +350,8 @@ struct hline
bool shouldsave()
{
return strcmp(commandbuf, buf) ||
(commandaction ? !action || strcmp(commandaction, action) : action!=NULL) ||
(commandprompt ? !prompt || strcmp(commandprompt, prompt) : prompt!=NULL) ||
(commandaction ? !action || strcmp(commandaction, action) : action!=nullptr) ||
(commandprompt ? !prompt || strcmp(commandprompt, prompt) : prompt!=nullptr) ||
commandflags != flags;
}
@ -407,7 +407,7 @@ static vector<releaseaction> releaseactions;
const char *addreleaseaction(char *s)
{
if(!keypressed) { delete[] s; return NULL; }
if(!keypressed) { delete[] s; return nullptr; }
releaseaction &ra = releaseactions.add();
ra.key = keypressed;
ra.action = s;
@ -417,7 +417,7 @@ const char *addreleaseaction(char *s)
tagval *addreleaseaction(ident *id, int numargs)
{
if(!keypressed || numargs > 3) return NULL;
if(!keypressed || numargs > 3) return nullptr;
releaseaction &ra = releaseactions.add();
ra.key = keypressed;
ra.id = id;
@ -444,7 +444,7 @@ static void execbind(keym &k, bool isdown)
if(!isdown) execute(ra.action);
delete[] ra.action;
}
else execute(isdown ? NULL : ra.id, ra.args, ra.numargs);
else execute(isdown ? nullptr : ra.id, ra.args, ra.numargs);
releaseactions.remove(i--);
}
}
@ -460,7 +460,7 @@ static void execbind(keym &k, bool isdown)
keyaction = action;
keypressed = &k;
execute(keyaction);
keypressed = NULL;
keypressed = nullptr;
if(keyaction!=action) delete[] keyaction;
}
k.pressed = isdown;
@ -556,7 +556,7 @@ static bool consolekey(int code, bool isdown)
case SDLK_TAB:
if(commandflags&CF_COMPLETE)
{
complete(commandbuf, sizeof(commandbuf), commandflags&CF_EXECUTE ? "/" : NULL);
complete(commandbuf, sizeof(commandbuf), commandflags&CF_EXECUTE ? "/" : nullptr);
if(commandpos>=0 && commandpos>=(int)strlen(commandbuf)) commandpos = -1;
}
break;
@ -570,7 +570,7 @@ static bool consolekey(int code, bool isdown)
{
if(code==SDLK_RETURN || code==SDLK_KP_ENTER)
{
hline *h = NULL;
hline *h = nullptr;
if(commandbuf[0])
{
if(history.empty() || history.last()->shouldsave())
@ -585,13 +585,13 @@ static bool consolekey(int code, bool isdown)
else h = history.last();
}
histpos = history.length();
inputcommand(NULL);
inputcommand(nullptr);
if(h) h->run();
}
else if(code==SDLK_ESCAPE)
{
histpos = history.length();
inputcommand(NULL);
inputcommand(nullptr);
}
}
@ -670,7 +670,7 @@ struct filesval
vector<char *> files;
int millis;
filesval(int type, const char *dir, const char *ext) : type(type), dir(newstring(dir)), ext(ext && ext[0] ? newstring(ext) : NULL), millis(-1) {}
filesval(int type, const char *dir, const char *ext) : type(type), dir(newstring(dir)), ext(ext && ext[0] ? newstring(ext) : nullptr), millis(-1) {}
~filesval() { DELETEA(dir); DELETEA(ext); files.deletearrays(); }
void update()
@ -698,7 +698,7 @@ static hashtable<fileskey, filesval *> completefiles;
static hashtable<char *, filesval *> completions;
static int completesize = 0;
static char *lastcomplete = NULL;
static char *lastcomplete = nullptr;
static void resetcomplete() { completesize = 0; }
@ -712,7 +712,7 @@ static void addcomplete(char *command, int type, char *dir, char *ext)
if(!dir[0])
{
filesval **hasfiles = completions.access(command);
if(hasfiles) *hasfiles = NULL;
if(hasfiles) *hasfiles = nullptr;
return;
}
if(type==FILES_DIR)
@ -723,7 +723,7 @@ static void addcomplete(char *command, int type, char *dir, char *ext)
if(ext)
{
if(strchr(ext, '*')) ext[0] = '\0';
if(!ext[0]) ext = NULL;
if(!ext[0]) ext = nullptr;
}
}
fileskey key(type, dir, ext);
@ -747,7 +747,7 @@ static void addfilecomplete(char *command, char *dir, char *ext)
static void addlistcomplete(char *command, char *list)
{
addcomplete(command, FILES_LIST, list, NULL);
addcomplete(command, FILES_LIST, list, nullptr);
}
COMMANDN(complete, addfilecomplete, "sss");
@ -764,14 +764,14 @@ static void complete(char *s, int maxlen, const char *cmdprefix)
if(!s[cmdlen]) return;
if(!completesize) { completesize = (int)strlen(&s[cmdlen]); DELETEA(lastcomplete); }
filesval *f = NULL;
filesval *f = nullptr;
if(completesize)
{
char *end = strchr(&s[cmdlen], ' ');
if(end) f = completions.find(stringslice(&s[cmdlen], end), NULL);
if(end) f = completions.find(stringslice(&s[cmdlen], end), nullptr);
}
const char *nextcomplete = NULL;
const char *nextcomplete = nullptr;
if(f) // complete using filenames
{
int commandsize = strchr(&s[cmdlen], ' ')+1-s;

View File

@ -94,7 +94,7 @@ static void cleardynlights()
void removetrackeddynlights(physent *owner)
{
loopvrev(dynlights) if(owner ? dynlights[i].owner == owner : dynlights[i].owner != NULL) dynlights.remove(i);
loopvrev(dynlights) if(owner ? dynlights[i].owner == owner : dynlights[i].owner != nullptr) dynlights.remove(i);
}
void updatedynlights()

View File

@ -14,7 +14,7 @@ enum
void adddynlight(const vec &o, float radius, const vec &color, int fade = 0, int peak = 0, int flags = 0, float initradius = 0, const vec &initcolor = vec(0, 0, 0), physent *owner = NULL, const vec &dir = vec(0, 0, 0), int spot = 0);
void dynlightreaching(const vec &target, vec &color, vec &dir, bool hud = false);
void removetrackeddynlights(physent *owner = NULL);
void removetrackeddynlights(physent *owner = nullptr);
void updatedynlights();
int finddynlights();

View File

@ -38,7 +38,7 @@ struct extentity : entity // part of the entity that doesn
int flags;
extentity *attached;
extentity() : flags(0), attached(NULL) {}
extentity() : flags(0), attached(nullptr) {}
bool spawned() const { return (flags&EF_SPAWNED) != 0; }
void setspawned(bool val) { if(val) flags |= EF_SPAWNED; else flags &= ~EF_SPAWNED; }
@ -162,7 +162,7 @@ struct animinterpinfo // used for animation blending of animated characters
int lastswitch;
void *lastmodel;
animinterpinfo() : lastswitch(-1), lastmodel(NULL) {}
animinterpinfo() : lastswitch(-1), lastmodel(nullptr) {}
void reset() { lastswitch = -1; }
};
@ -181,7 +181,7 @@ struct dynent : physent // animated characters, or chara
occludequery *query;
int lastrendered;
dynent() : ragdoll(NULL), query(NULL), lastrendered(0)
dynent() : ragdoll(nullptr), query(nullptr), lastrendered(0)
{
reset();
}

View File

@ -7,8 +7,8 @@ namespace sphere
{
vec pos;
ushort s, t;
} *verts = NULL;
GLushort *indices = NULL;
} *verts = nullptr;
GLushort *indices = nullptr;
int numverts = 0, numindices = 0;
GLuint vbuf = 0, ebuf = 0;

View File

@ -211,7 +211,7 @@ static void gengrassquads(vtxarray *va)
s.grasstex = textureload(s.grass, 2);
}
grassgroup *group = NULL;
grassgroup *group = nullptr;
loopi(NUMGRASSWEDGES)
{
grasswedge &w = grasswedges[i];
@ -250,12 +250,12 @@ void generategrass()
gle::bindvbo(grassvbo);
int size = grassverts.length()*sizeof(grassvert);
grassvbosize = max(grassvbosize, size);
glBufferData_(GL_ARRAY_BUFFER, grassvbosize, size == grassvbosize ? grassverts.getbuf() : NULL, GL_STREAM_DRAW);
glBufferData_(GL_ARRAY_BUFFER, grassvbosize, size == grassvbosize ? grassverts.getbuf() : nullptr, GL_STREAM_DRAW);
if(size != grassvbosize) glBufferSubData_(GL_ARRAY_BUFFER, 0, size, grassverts.getbuf());
gle::clearvbo();
}
static Shader *grassshader = NULL;
static Shader *grassshader = nullptr;
static Shader *loadgrassshader()
{
@ -276,7 +276,7 @@ void loadgrassshaders()
static void cleargrassshaders()
{
grassshader = NULL;
grassshader = nullptr;
}
void rendergrass()

View File

@ -283,7 +283,7 @@ void skelbih::build(skelmodel::skelmeshgroup *m, ushort *indices, int numindices
}
skelbih::skelbih(skelmodel::skelmeshgroup *m, int numtris, tri *tris)
: nodes(NULL), numnodes(0), tris(tris), bbmin(1e16f, 1e16f, 1e16f), bbmax(-1e16f, -1e16f, -1e16f)
: nodes(nullptr), numnodes(0), tris(tris), bbmin(1e16f, 1e16f, 1e16f), bbmax(-1e16f, -1e16f, -1e16f)
{
loopi(numtris)
{
@ -323,10 +323,10 @@ struct skelhitzone
skelbih *bih;
};
skelhitzone() : numparents(0), numchildren(0), parents(NULL), children(NULL), center(0, 0, 0), animcenter(0, 0, 0), radius(0), visited(-1)
skelhitzone() : numparents(0), numchildren(0), parents(nullptr), children(nullptr), center(0, 0, 0), animcenter(0, 0, 0), radius(0), visited(-1)
{
blend = -1;
bih = NULL;
bih = nullptr;
}
~skelhitzone()
@ -561,7 +561,7 @@ struct skelhitdata
int numblends;
skelmodel::blendcacheentry blendcache;
skelhitdata() : numzones(0), rootzones(0), visited(0), zones(NULL), links(NULL), tris(NULL), numblends(0) {}
skelhitdata() : numzones(0), rootzones(0), visited(0), zones(nullptr), links(nullptr), tris(nullptr), numblends(0) {}
~skelhitdata()
{
DELETEA(zones);
@ -666,7 +666,7 @@ void skelhitdata::build(skelmodel::skelmeshgroup *g, const uchar *ids)
skelzonebounds *bounds = new skelzonebounds[g->skel->numbones];
numblends = g->blendcombos.length();
loopv(g->blendcombos) if(!g->blendcombos[i].weights[1]) { numblends = i; break; }
blendcache.bdata = numblends > 0 ? new dualquat[numblends] : NULL;
blendcache.bdata = numblends > 0 ? new dualquat[numblends] : nullptr;
loopi(min(g->meshes.length(), 0x100))
{
skelmodel::skelmesh *m = (skelmodel::skelmesh *)g->meshes[i];
@ -783,7 +783,7 @@ void skelhitdata::build(skelmodel::skelmeshgroup *g, const uchar *ids)
}
numzones = info.length();
zones = new skelhitzone[numzones];
links = numlinks ? new skelhitzone *[numlinks] : NULL;
links = numlinks ? new skelhitzone *[numlinks] : nullptr;
tris = new skelhitzone::tri[numtris];
skelhitzone **curlink = links;
skelhitzone::tri *curtris = tris;

View File

@ -115,8 +115,8 @@ struct iqm : skelloader<iqm>
lilswap((uint *)&buf[hdr.ofs_joints], hdr.num_joints*sizeof(iqmjoint)/sizeof(uint));
const char *str = hdr.ofs_text ? (char *)&buf[hdr.ofs_text] : "";
float *vpos = NULL, *vnorm = NULL, *vtan = NULL, *vtc = NULL;
uchar *vindex = NULL, *vweight = NULL;
float *vpos = nullptr, *vnorm = nullptr, *vtan = nullptr, *vtc = nullptr;
uchar *vindex = nullptr, *vweight = nullptr;
iqmvertexarray *vas = (iqmvertexarray *)&buf[hdr.ofs_vertexarrays];
loopi(hdr.num_vertexarrays)
{
@ -187,10 +187,10 @@ struct iqm : skelloader<iqm>
}
int fv = im.first_vertex;
float *mpos = vpos + 3*fv,
*mnorm = vnorm ? vnorm + 3*fv : NULL,
*mtan = vtan ? vtan + 4*fv : NULL,
*mtc = vtc ? vtc + 2*fv : NULL;
uchar *mindex = vindex ? vindex + 4*fv : NULL, *mweight = vweight ? vweight + 4*fv : NULL;
*mnorm = vnorm ? vnorm + 3*fv : nullptr,
*mtan = vtan ? vtan + 4*fv : nullptr,
*mtc = vtc ? vtc + 2*fv : nullptr;
uchar *mindex = vindex ? vindex + 4*fv : nullptr, *mweight = vweight ? vweight + 4*fv : nullptr;
loopj(im.num_vertexes)
{
vert &v = m->verts[j];
@ -325,7 +325,7 @@ struct iqm : skelloader<iqm>
stream *f = openfile(filename, "rb");
if(!f) return false;
uchar *buf = NULL;
uchar *buf = nullptr;
iqmheader hdr;
if(f->read(&hdr, sizeof(hdr)) != sizeof(hdr) || memcmp(hdr.magic, "INTERQUAKEMODEL", sizeof(hdr.magic))) goto error;
lilswap(&hdr.version, (sizeof(hdr) - sizeof(hdr.magic))/sizeof(uint));

View File

@ -156,7 +156,7 @@ struct flarerenderer : partrenderer
}
//square per round hole - use addflare(..) instead
particle *addpart(const vec &o, const vec &d, int fade, int color, float size, int gravity = 0) { return NULL; }
particle *addpart(const vec &o, const vec &d, int fade, int color, float size, int gravity = 0) { return nullptr; }
};
static flarerenderer flares("<grey>media/particle/lensflares.png", 64);

View File

@ -392,7 +392,7 @@ static void calcsurfaces(cube &c, const ivec &co, int size, int usefacemask, int
}