From 09a43565940be30b233fa8730e65d531a454a03b Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 21 Jul 2025 06:06:50 +0200 Subject: [PATCH] Cleaned 95% of -Wall -Wextra... --- src/Makefile | 4 +- src/engine/3dgui.cpp | 2 + src/engine/command.cpp | 211 +++++++++++++++++++----------------- src/engine/grass.cpp | 26 ++--- src/engine/md3.h | 2 +- src/engine/octaedit.cpp | 4 +- src/engine/octarender.cpp | 10 +- src/engine/rendergl.cpp | 2 +- src/engine/renderva.cpp | 4 +- src/engine/texture.cpp | 220 ++++++++++++++++++++------------------ src/engine/world.cpp | 71 ++++++------ src/engine/worldio.cpp | 2 +- src/fpsgame/ai.cpp | 3 +- src/fpsgame/entities.cpp | 30 ++++-- src/fpsgame/game.h | 10 +- src/fpsgame/server.cpp | 3 +- src/shared/tools.cpp | 10 +- 17 files changed, 328 insertions(+), 286 deletions(-) diff --git a/src/Makefile b/src/Makefile index 978de06..c4450f3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,5 @@ -CXXFLAGS= -O3 -g -fomit-frame-pointer -ffast-math -override CXXFLAGS+= -Wall -fsigned-char -fno-exceptions -fno-rtti -Wno-unused-parameter +CXXFLAGS= -O3 -fomit-frame-pointer -ffast-math +override CXXFLAGS+= -Wall -Wextra -fsigned-char -fno-exceptions -fno-rtti -Wno-unused-parameter PLATFORM= $(shell uname -s | tr '[:lower:]' '[:upper:]') PLATFORM_PREFIX= native diff --git a/src/engine/3dgui.cpp b/src/engine/3dgui.cpp index 68d5428..cc9d61b 100644 --- a/src/engine/3dgui.cpp +++ b/src/engine/3dgui.cpp @@ -1243,8 +1243,10 @@ bool g3d_key(int code, bool isdown) if(isdown) fieldmode = FIELDABORT; return true; case SDLK_RETURN: + [[fallthrough]]; case SDLK_TAB: if(e->maxy != 1) break; + [[fallthrough]]; case SDLK_KP_ENTER: if(isdown) fieldmode = FIELDCOMMIT; //signal field commit (handled when drawing field) return true; diff --git a/src/engine/command.cpp b/src/engine/command.cpp index 74efff2..0029e4d 100644 --- a/src/engine/command.cpp +++ b/src/engine/command.cpp @@ -73,7 +73,9 @@ static inline const char *forcestr(tagval &v) { case VAL_FLOAT: s = floatstr(v.f); break; case VAL_INT: s = intstr(v.i); break; - case VAL_STR: case VAL_MACRO: return v.s; + case VAL_STR: + [[fallthrough]]; + case VAL_MACRO: return v.s; } freearg(v); v.setstr(newstring(s)); @@ -101,12 +103,12 @@ static inline ident *forceident(tagval &v) v.setident(id); return id; } - case VAL_STR: - { - ident *id = newident(v.s, IDF_UNKNOWN); - delete[] v.s; - v.setident(id); - return id; + case VAL_STR: + { + ident *id = newident(v.s, IDF_UNKNOWN); + delete[] v.s; + v.setident(id); + return id; } } freearg(v); @@ -143,11 +145,11 @@ tagval noret = nullval, *commandret = &noret; void clear_command() { - enumerate(idents, ident, i, + enumerate(idents, ident, i, { - if(i.type==ID_ALIAS) - { - DELETEA(i.name); + if(i.type==ID_ALIAS) + { + DELETEA(i.name); i.forcenull(); DELETEA(i.code); } @@ -160,7 +162,7 @@ void clearoverride(ident &i) switch(i.type) { case ID_ALIAS: - if(i.valtype==VAL_STR) + if(i.valtype==VAL_STR) { if(!i.val.s[0]) break; delete[] i.val.s; @@ -216,7 +218,7 @@ static bool initidents() newident(argname, IDF_ARG); } dummyident = newident("//dummy", IDF_UNKNOWN); - if(identinits) + if(identinits) { loopv(*identinits) addident((*identinits)[i]); DELETEP(identinits); @@ -305,7 +307,7 @@ static void debugcodeline(const char *p, const char *fmt, ...) } ICOMMAND(nodebug, "e", (uint *body), { nodebug++; executeret(body, *commandret); nodebug--; }); - + void addident(ident *id) { addident(*id); @@ -319,7 +321,7 @@ static inline void pusharg(ident &id, const tagval &v, identstack &stack) id.stack = &stack; id.setval(v); cleancode(id); -} +} static inline void poparg(ident &id) { @@ -344,7 +346,7 @@ ICOMMAND(push, "rte", (ident *id, tagval *v, uint *code), static inline void pushalias(ident &id, identstack &stack) { - if(id.type == ID_ALIAS && id.index >= MAXARGS) + if(id.type == ID_ALIAS && id.index >= MAXARGS) { pusharg(id, nullval, stack); id.flags &= ~IDF_UNKNOWN; @@ -374,7 +376,7 @@ ident *newident(const char *name, int flags) ident *id = idents.access(name); if(!id) { - if(checknumber(name)) + if(checknumber(name)) { debugcode("number %s is not a valid identifier name", name); return dummyident; @@ -402,7 +404,7 @@ ident *readident(const char *name) return NULL; return id; } - + void resetvar(char *name) { ident *id = idents.access(name); @@ -439,9 +441,9 @@ static inline void setalias(ident &id, tagval &v) static void setalias(const char *name, tagval &v) { ident *id = idents.access(name); - if(id) + if(id) { - if(id->type == ID_ALIAS) + if(id->type == ID_ALIAS) { if(id->index < MAXARGS) setarg(*id, v); else setalias(*id, v); } @@ -451,7 +453,7 @@ static void setalias(const char *name, tagval &v) freearg(v); } } - else if(checknumber(name)) + else if(checknumber(name)) { debugcode("cannot alias number %s", name); freearg(v); @@ -463,7 +465,7 @@ static void setalias(const char *name, tagval &v) } void alias(const char *name, const char *str) -{ +{ tagval v; v.setstr(newstring(str)); setalias(name, v); @@ -886,7 +888,7 @@ static inline char *cutstring(const char *&p, int &len) { p++; const char *end = parsestring(p); - char *s = newstring(end - p); + char *s = newstring(end - p); len = unescapestring(s, p, end); s[len] = '\0'; p = end; @@ -980,7 +982,7 @@ static inline void compileident(vector &code, ident *id) { code.add((id->index < MAXARGS ? CODE_IDENTARG : CODE_IDENT)|(id->index<<8)); } - + static inline void compileident(vector &code, const char *word = NULL) { compileident(code, word ? newident(word, IDF_UNKNOWN) : dummyident); @@ -1020,7 +1022,7 @@ static inline void compileval(vector &code, int wordtype, char *word, int case VAL_ANY: compilestr(code, word, wordlen); break; case VAL_FLOAT: compilefloat(code, word); break; case VAL_INT: compileint(code, word); break; - case VAL_CODE: + case VAL_CODE: { int start = code.length(); code.add(CODE_BLOCK); @@ -1074,7 +1076,7 @@ static void compilelookup(vector &code, const char *&p, int ltype) for(const char *fmt = id->args; *fmt; fmt++) switch(*fmt) { case 's': compilestr(code, NULL, 0, true); numargs++; break; - case 'i': compileint(code); numargs++; break; + case 'i': compileint(code); numargs++; break; case 'b': compileint(code, INT_MIN); numargs++; break; case 'f': compilefloat(code); numargs++; break; case 't': compilenull(code); numargs++; break; @@ -1087,7 +1089,7 @@ static void compilelookup(vector &code, const char *&p, int ltype) #endif case 'C': comtype = CODE_COMC; numargs = 1; goto endfmt; case 'V': comtype = CODE_COMV; numargs = 2; goto endfmt; - case '1': case '2': case '3': case '4': break; + case '1': case '2': case '3': case '4': break; } endfmt: code.add(comtype|(ltype < VAL_ANY ? ltype<index<<8)); @@ -1120,7 +1122,7 @@ invalid: static bool compileblockstr(vector &code, const char *str, const char *end, bool macro) { int start = code.length(); - code.add(macro ? CODE_MACRO : CODE_VAL|RET_STR); + code.add(macro ? CODE_MACRO : CODE_VAL|RET_STR); char *buf = (char *)code.reserve((end-str)/sizeof(uint)+1).buf; int len = 0; while(str < end) @@ -1155,8 +1157,10 @@ static bool compileblockstr(vector &code, const char *str, const char *end else buf[len++] = *str++; break; case '@': + [[fallthrough]]; case ']': if(str < end) { buf[len++] = *str++; break; } + [[fallthrough]]; case '\0': goto done; } } @@ -1234,10 +1238,10 @@ static void compileblock(vector &code, const char *&p, int wordtype) break; case '[': brak++; break; case ']': brak--; break; - case '@': + case '@': { const char *esc = p; - while(*p == '@') p++; + while(*p == '@') p++; int level = p - (esc - 1); if(brak > level) continue; else if(brak < level) debugcodeline(line, "too many @s"); @@ -1256,7 +1260,7 @@ static void compileblock(vector &code, const char *&p, int wordtype) } } done: - if(p-1 > start) + if(p-1 > start) { if(!concs) switch(wordtype) { @@ -1281,7 +1285,7 @@ done: } compileblockstr(code, start, p-1, concs > 0); if(concs > 1) concs++; - } + } if(concs) { code.add(CODE_CONCM|(wordtype < VAL_ANY ? wordtype< &code, const char *&p, int wordtype, char *&word, int &wordlen) { skipcomments(p); @@ -1321,7 +1325,7 @@ static bool compileword(vector &code, const char *&p, int wordtype, char * case VAL_CODE: code.add(CODE_COMPILE); break; case VAL_IDENT: code.add(CODE_IDENTU); break; } - return true; + return true; case '[': p++; compileblock(code, p, wordtype); @@ -1337,7 +1341,7 @@ static inline bool compilearg(vector &code, const char *&p, int wordtype) int wordlen = 0; bool more = compileword(code, p, wordtype, word, wordlen); if(!more) return false; - if(word) + if(word) { compileval(code, wordtype, word, wordlen); delete[] word; @@ -1359,13 +1363,24 @@ static void compilestatements(vector &code, const char *&p, int rettype, i bool more = compileword(code, p, VAL_ANY, idname, idlen); if(!more) goto endstatement; skipcomments(p); - if(p[0] == '=') switch(p[1]) - { - case '/': + if(p[0] == '=') switch(p[1]) + { + case '/': if(p[2] != '/') break; - case ';': case ' ': case '\t': case '\r': case '\n': case '\0': + [[fallthrough]]; + case ';': + [[fallthrough]]; + case ' ': + [[fallthrough]]; + case '\t': + [[fallthrough]]; + case '\r': + [[fallthrough]]; + case '\n': + [[fallthrough]]; + case '\0': p++; - if(idname) + if(idname) { id = newident(idname, IDF_UNKNOWN); if(id) switch(id->type) @@ -1408,13 +1423,13 @@ static void compilestatements(vector &code, const char *&p, int rettype, i else { id = idents.access(idname); - if(!id) + if(!id) { if(!checknumber(idname)) { compilestr(code, idname, idlen); delete[] idname; goto noid; } char *end = idname; int val = int(strtoul(idname, &end, 0)); if(*end) compilestr(code, idname, idlen); - else compileint(code, val); + else compileint(code, val); code.add(CODE_RESULT); } else switch(id->type) @@ -1429,9 +1444,9 @@ static void compilestatements(vector &code, const char *&p, int rettype, i bool rep = false; for(const char *fmt = id->args; *fmt; fmt++) switch(*fmt) { - case 's': + case 's': if(more) more = compilearg(code, p, VAL_STR); - if(!more) + if(!more) { if(rep) break; compilestr(code, NULL, 0, true); @@ -1447,7 +1462,7 @@ static void compilestatements(vector &code, const char *&p, int rettype, i break; case 'i': if(more) more = compilearg(code, p, VAL_INT); if(!more) { if(rep) break; compileint(code); fakeargs++; } numargs++; break; case 'b': if(more) more = compilearg(code, p, VAL_INT); if(!more) { if(rep) break; compileint(code, INT_MIN); fakeargs++; } numargs++; break; - case 'f': if(more) more = compilearg(code, p, VAL_FLOAT); if(!more) { if(rep) break; compilefloat(code); fakeargs++; } numargs++; break; + case 'f': if(more) more = compilearg(code, p, VAL_FLOAT); if(!more) { if(rep) break; compilefloat(code); fakeargs++; } numargs++; break; case 't': if(more) more = compilearg(code, p, VAL_ANY); if(!more) { if(rep) break; compilenull(code); fakeargs++; } numargs++; break; case 'e': if(more) more = compilearg(code, p, VAL_CODE); if(!more) { if(rep) break; compileblock(code); fakeargs++; } numargs++; break; case 'r': if(more) more = compilearg(code, p, VAL_IDENT); if(!more) { if(rep) break; compileident(code); fakeargs++; } numargs++; break; @@ -1489,7 +1504,7 @@ static void compilestatements(vector &code, const char *&p, int rettype, i break; case ID_SVAR: if(!(more = compilearg(code, p, VAL_STR))) code.add(CODE_PRINT|(id->index<<8)); - else + else { int numconc = 0; while(numconc+1 < MAXARGS && (more = compilearg(code, p, VAL_ANY))) numconc++; @@ -1497,12 +1512,12 @@ static void compilestatements(vector &code, const char *&p, int rettype, i code.add(CODE_SVAR1|(id->index<<8)); } break; - } + } endcommand: delete[] idname; } endstatement: - if(more) while(compilearg(code, p, VAL_ANY)) code.add(CODE_POP); + if(more) while(compilearg(code, p, VAL_ANY)) code.add(CODE_POP); p += strcspn(p, ")];/\n\0"); int c = *p++; switch(c) @@ -1515,7 +1530,7 @@ static void compilestatements(vector &code, const char *&p, int rettype, i case ')': case ']': if(c == brak) return; - debugcodeline(line, "unexpected \"%c\"", c); + debugcodeline(line, "unexpected \"%c\"", c); break; case '/': @@ -1568,7 +1583,7 @@ void freecode(uint *code) { if(!code) return; switch(*code&CODE_OP_MASK) - { + { case CODE_START: *code -= 0x100; if(int(*code) < 0x100) delete[] code; @@ -1756,7 +1771,7 @@ cleanup: #define MAXRUNDEPTH 255 static int rundepth = 0; - + static const uint *runcode(const uint *code, tagval &result) { result.setnull(); @@ -1779,11 +1794,11 @@ static const uint *runcode(const uint *code, tagval &result) case CODE_POP: freearg(args[--numargs]); - continue; - case CODE_ENTER: - code = runcode(code, args[numargs++]); continue; - case CODE_EXIT|RET_NULL: case CODE_EXIT|RET_STR: case CODE_EXIT|RET_INT: case CODE_EXIT|RET_FLOAT: + case CODE_ENTER: + code = runcode(code, args[numargs++]); + continue; + case CODE_EXIT|RET_NULL: case CODE_EXIT|RET_STR: case CODE_EXIT|RET_INT: case CODE_EXIT|RET_FLOAT: forcearg(result, op&CODE_RET_MASK); goto exit; case CODE_PRINT: @@ -1798,7 +1813,7 @@ static const uint *runcode(const uint *code, tagval &result) loopi(numargs) popalias(*args[i].id); goto exit; } - + case CODE_MACRO: { uint len = op>>8; @@ -1873,19 +1888,19 @@ static const uint *runcode(const uint *code, tagval &result) { pusharg(*id, nullval, aliasstack->argstack[id->index]); aliasstack->usedargs |= 1<index; - } + } args[numargs++].setident(id); continue; } case CODE_IDENTU: { tagval &arg = args[numargs-1]; - ident *id = arg.type == VAL_STR || arg.type == VAL_MACRO ? newident(arg.s, IDF_UNKNOWN) : dummyident; + ident *id = arg.type == VAL_STR || arg.type == VAL_MACRO ? newident(arg.s, IDF_UNKNOWN) : dummyident; if(id->index < MAXARGS && !(aliasstack->usedargs&(1<index))) { pusharg(*id, nullval, aliasstack->argstack[id->index]); aliasstack->usedargs |= 1<index; - } + } freearg(arg); arg.setident(id); continue; @@ -1925,7 +1940,7 @@ static const uint *runcode(const uint *code, tagval &result) nval; \ continue; \ } - LOOKUPU(arg.setstr(newstring(id->getstr())), + LOOKUPU(arg.setstr(newstring(id->getstr())), arg.setstr(newstring(*id->storage.s)), arg.setstr(newstring(intstr(*id->storage.i))), arg.setstr(newstring(floatstr(*id->storage.f))), @@ -1993,14 +2008,14 @@ static const uint *runcode(const uint *code, tagval &result) case CODE_FVAR|RET_STR: args[numargs++].setstr(newstring(floatstr(*identmap[op>>8]->storage.f))); continue; case CODE_FVAR|RET_INT: args[numargs++].setint(int(*identmap[op>>8]->storage.f)); continue; case CODE_FVAR1: setfvarchecked(identmap[op>>8], args[0].f); numargs = 0; continue; - + case CODE_COM|RET_NULL: case CODE_COM|RET_STR: case CODE_COM|RET_FLOAT: case CODE_COM|RET_INT: id = identmap[op>>8]; #ifndef STANDALONE callcom: #endif forcenull(result); - CALLCOM(numargs) + CALLCOM(numargs) forceresult: freeargs(args, numargs, 0); forcearg(result, op&CODE_RET_MASK); @@ -2016,7 +2031,7 @@ static const uint *runcode(const uint *code, tagval &result) id = identmap[op>>8]; forcenull(result); ((comfunv)id->fun)(args, numargs); - goto forceresult; + goto forceresult; case CODE_COMC|RET_NULL: case CODE_COMC|RET_STR: case CODE_COMC|RET_FLOAT: case CODE_COMC|RET_INT: id = identmap[op>>8]; forcenull(result); @@ -2115,7 +2130,7 @@ static const uint *runcode(const uint *code, tagval &result) debugcode("unknown command: %s", args[0].s); forcenull(result); goto forceresult; - } + } forcenull(result); switch(id->type) { @@ -2132,7 +2147,7 @@ static const uint *runcode(const uint *code, tagval &result) loopj(numargs-1) pushalias(*forceident(args[j+1]), locals[j]); code = runcode(code, result); loopj(numargs-1) popalias(*args[j+1].id); - goto exit; + goto exit; } case ID_VAR: if(numargs <= 1) printvar(id); else setvarchecked(id, &args[1], numargs-1); @@ -2142,7 +2157,7 @@ static const uint *runcode(const uint *code, tagval &result) goto forceresult; case ID_SVAR: if(numargs <= 1) printvar(id); else setsvarchecked(id, forcestr(args[1])); - goto forceresult; + goto forceresult; case ID_ALIAS: if(id->index < MAXARGS && !(aliasstack->usedargs&(1<index))) goto forceresult; if(id->valtype==VAL_NULL) goto noid; @@ -2159,10 +2174,10 @@ exit: --rundepth; return code; } - + void executeret(const uint *code, tagval &result) { - runcode(code, result); + runcode(code, result); } void executeret(const char *p, tagval &result) @@ -2238,7 +2253,7 @@ char *executestr(const char *p) char *executestr(ident *id, tagval *args, int numargs, bool lookup) { - tagval result; + tagval result; executeret(id, args, numargs, lookup, result); if(result.type == VAL_NULL) return NULL; forcestr(result); @@ -2292,7 +2307,7 @@ static inline bool getbool(const char *s) { switch(s[0]) { - case '+': case '-': + case '+': case '-': switch(s[1]) { case '0': break; @@ -2468,8 +2483,10 @@ void writecfg(const char *name) case VAL_STR: if(!id.val.s[0]) break; if(!validateblock(id.val.s)) { f->printf("%s = %s\n", escapeid(id), escapestring(id.val.s)); break; } + [[fallthrough]]; case VAL_FLOAT: - case VAL_INT: + [[fallthrough]]; + case VAL_INT: f->printf("%s = [%s]\n", escapeid(id), id.getstr()); break; } } @@ -2487,7 +2504,7 @@ void changedvars() enumerate(idents, ident, id, if(id.flags&IDF_OVERRIDDEN) ids.add(&id)); ids.sortname(); loopv(ids) printvar(ids[i]); -} +} COMMAND(changedvars, ""); // below the commands that implement a small imperative language. thanks to the semantics of @@ -2637,15 +2654,15 @@ ICOMMAND(loopconcatword, "rie", (ident *id, int *n, uint *body), }); void concat(tagval *v, int n) -{ +{ commandret->setstr(conc(v, n, true)); } COMMAND(concat, "V"); void concatword(tagval *v, int n) -{ +{ commandret->setstr(conc(v, n, false)); -} +} COMMAND(concatword, "V"); void append(ident *id, tagval *v, bool space) @@ -2749,7 +2766,7 @@ static bool parselist(const char *&s, const char *&start = liststart, const char case '(': case '[': if(c == braktype) brak++; break; case ')': if(braktype == '(' && --brak <= 0) goto endblock; break; case ']': if(braktype == '[' && --brak <= 0) goto endblock; break; - } + } } endblock: end = s-1; @@ -2762,7 +2779,7 @@ static bool parselist(const char *&s, const char *&start = liststart, const char if(*s == ';') s++; return true; } - + void explodelist(const char *s, vector &elems, int limit) { const char *start, *end; @@ -2793,7 +2810,7 @@ void at(tagval *args, int numargs) { const char *list = start; int pos = args[i].getint(); - for(; pos > 0; pos--) if(!parselist(list)) break; + for(; pos > 0; pos--) if(!parselist(list)) break; if(pos > 0 || !parselist(list, start, end)) start = end = ""; } commandret->setstr(newstring(start, end-start)); @@ -2839,7 +2856,7 @@ void sublist(const char *s, int *skip, int *count, int *numargs) if(len < 0) { if(offset > 0) skiplist(s); commandret->setstr(newstring(s)); return; } const char *list = s, *start, *end, *qstart, *qend = s; if(len > 0 && parselist(s, start, end, list, qend)) while(--len > 0 && parselist(s, start, end, qstart, qend)); - commandret->setstr(newstring(list, qend - list)); + commandret->setstr(newstring(list, qend - list)); } COMMAND(sublist, "siiN"); @@ -2984,7 +3001,7 @@ void prettylist(const char *s, const char *conj) } p.add(' '); } - } + } p.add('\0'); result(p.getbuf()); } @@ -3002,7 +3019,7 @@ int listincludes(const char *list, const char *needle, int needlelen) return -1; } ICOMMAND(indexof, "ss", (char *list, char *elem), intret(listincludes(list, elem, strlen(elem)))); - + char *listdel(const char *s, const char *del) { vector p; @@ -3058,17 +3075,17 @@ ICOMMAND(loopfiles, "rsse", (ident *id, char *dir, char *ext, uint *body), bool redundant = false; loopj(i) if(!strcmp(files[j], file)) { redundant = true; break; } if(redundant) delete[] files.removeunordered(i); - } + } loopv(files) { char *file = files[i]; - if(i) + if(i) { if(id->valtype == VAL_STR) delete[] id->val.s; else id->valtype = VAL_STR; id->val.s = file; } - else + else { tagval t; t.setstr(file); @@ -3081,7 +3098,7 @@ ICOMMAND(loopfiles, "rsse", (ident *id, char *dir, char *ext, uint *body), }); void findfile_(char *name) -{ +{ string fname; copystring(fname, name); path(fname); @@ -3098,7 +3115,7 @@ struct sortitem { const char *str, *quotestart, *quoteend; }; - + struct sortfun { ident *x, *y; @@ -3115,7 +3132,7 @@ struct sortfun return executebool(body); } }; - + void sortlist(char *list, ident *x, ident *y, uint *body) { if(x == y || x->type != ID_ALIAS || y->type != ID_ALIAS) return; @@ -3130,7 +3147,7 @@ void sortlist(char *list, ident *x, ident *y, uint *body) sortitem item = { ¯os[start - list], quotestart, quoteend }; items.add(item); total += int(quoteend - quotestart); - } + } identstack xstack, ystack; pusharg(*x, nullval, xstack); x->flags &= ~IDF_UNKNOWN; @@ -3141,7 +3158,7 @@ void sortlist(char *list, ident *x, ident *y, uint *body) poparg(*x); poparg(*y); - + char *sorted = macros; int sortedlen = total + max(items.length() - 1, 0); if(macrolen < sortedlen) @@ -3160,7 +3177,7 @@ void sortlist(char *list, ident *x, ident *y, uint *body) offset += len; } sorted[offset] = '\0'; - + commandret->setstr(sorted); } COMMAND(sortlist, "srre"); @@ -3196,8 +3213,8 @@ ICOMMAND(>>, "ii", (int *a, int *b), intret(*a >> clamp(*b, 0, 31))); ICOMMAND(&&, "e1V", (tagval *args, int numargs), { if(!numargs) intret(1); - else loopi(numargs) - { + else loopi(numargs) + { if(i) freearg(*commandret); executeret(args[i].code, *commandret); if(!getbool(*commandret)) break; @@ -3207,7 +3224,7 @@ ICOMMAND(||, "e1V", (tagval *args, int numargs), { if(!numargs) intret(0); else loopi(numargs) - { + { if(i) freearg(*commandret); executeret(args[i].code, *commandret); if(getbool(*commandret)) break; @@ -3342,7 +3359,7 @@ ICOMMAND(strlen, "s", (char *s), intret(strlen(s))); ICOMMAND(strcode, "si", (char *s, int *i), intret(*i > 0 ? (memchr(s, 0, *i) ? 0 : uchar(s[*i])) : uchar(s[0]))); ICOMMAND(codestr, "i", (int *i), { char *s = newstring(1); s[0] = char(*i); s[1] = '\0'; stringret(s); }); ICOMMAND(struni, "si", (char *s, int *i), intret(*i > 0 ? (memchr(s, 0, *i) ? 0 : cube2uni(s[*i])) : cube2uni(s[0]))); -ICOMMAND(unistr, "i", (int *i), { char *s = newstring(1); s[0] = uni2cube(*i); s[1] = '\0'; stringret(s); }); +ICOMMAND(unistr, "i", (int *i), { char *s = newstring(1); s[0] = uni2cube(*i); s[1] = '\0'; stringret(s); }); int naturalsort(const char *a, const char *b) { diff --git a/src/engine/grass.cpp b/src/engine/grass.cpp index f91b6dc..58d9ee5 100644 --- a/src/engine/grass.cpp +++ b/src/engine/grass.cpp @@ -91,7 +91,7 @@ static void gengrassquads(grassgroup *&group, const grasswedge &w, const grasstr int minstep = max(int(ceil(tmin/grassstep)) - tstep, 1), maxstep = int(floor(min(tmax, t + grassdist)/grassstep)) - tstep, numsteps = maxstep - minstep + 1; - + float texscale = (grassscale*tex->ys)/float(grassheight*tex->xs), animscale = grassheight*texscale; vec tc; tc.cross(g.surface, w.dir).mul(texscale); @@ -140,7 +140,7 @@ static void gengrassquads(grassgroup *&group, const grasswedge &w, const grasstr float prevdist = rightdist; if(++rightv >= &g.v[g.numv]) rightv = g.v; rightdist = rightv->dot(w.dir); - if(dist <= rightdist) + if(dist <= rightdist) { prev = rightv; prevdist = rightdist; @@ -158,7 +158,7 @@ static void gengrassquads(grassgroup *&group, const grasswedge &w, const grasstr { if(w.bound1.dist(p2) >= grassmargin) continue; p1.add(vec(across).mul(leftb - grassmargin)); - } + } if(rightb > grassmargin) { if(w.bound2.dist(p1) >= grassmargin) continue; @@ -172,15 +172,15 @@ static void gengrassquads(grassgroup *&group, const grasswedge &w, const grasstr group->tex = tex->id; extern bool brightengeom; extern int fullbright; - int lmid = brightengeom && (g.lmid < LMID_RESERVED || (fullbright && editmode)) ? LMID_BRIGHT : g.lmid; + int lmid = brightengeom && (g.lmid < LMID_RESERVED || (fullbright && editmode)) ? (int) LMID_BRIGHT : (int) g.lmid; group->lmtex = lightmaptexs.inrange(lmid) ? lightmaptexs[lmid].id : notexture->id; group->offset = grassverts.length()/4; group->numquads = 0; if(lastgrassanim!=lastmillis) animategrass(); } - + group->numquads++; - + float tcoffset = grassoffsets[offset%NUMGRASSOFFSETS], animoffset = animscale*grassanimoffsets[offset%NUMGRASSOFFSETS], tc1 = tc.dot(p1) + tcoffset, tc2 = tc.dot(p2) + tcoffset, @@ -199,13 +199,13 @@ static void gengrassquads(grassgroup *&group, const grasswedge &w, const grasstr gv.bounds = w.vertbounds; \ modify; \ } - + GRASSVERT(2, 0, { gv.pos.z += height; gv.tc.x += animoffset; }); GRASSVERT(1, 0, { gv.pos.z += height; gv.tc.x += animoffset; }); GRASSVERT(1, 1, ); GRASSVERT(2, 1, ); } -} +} static void gengrassquads(vtxarray *va) { @@ -215,9 +215,9 @@ static void gengrassquads(vtxarray *va) if(isfoggedsphere(g.radius, g.center)) continue; float dist = g.center.dist(camera1->o); if(dist - g.radius > grassdist) continue; - + Slot &s = *lookupvslot(g.texture, false).slot; - if(!s.grasstex) + if(!s.grasstex) { if(!s.autograss) continue; s.grasstex = textureload(s.autograss, 2); @@ -226,7 +226,7 @@ static void gengrassquads(vtxarray *va) grassgroup *group = NULL; loopi(NUMGRASSWEDGES) { - grasswedge &w = grasswedges[i]; + grasswedge &w = grasswedges[i]; if(w.bound1.dist(g.center) > g.radius + grassmargin || w.bound2.dist(g.center) > g.radius + grassmargin) continue; gengrassquads(group, w, g, s.grasstex); } @@ -290,7 +290,7 @@ void rendergrass() SETSHADER(grass); LOCALPARAMF(grassmargin, grassmargin, grassmargin ? grassmarginfade / grassmargin : 0.0f, grassmargin ? grassmarginfade : 1.0f); - + gle::bindvbo(grassvbo); const grassvert *ptr = 0; @@ -349,7 +349,7 @@ void rendergrass() } void cleanupgrass() -{ +{ if(grassvbo) { glDeleteBuffers_(1, &grassvbo); grassvbo = 0; } grassvbosize = 0; } diff --git a/src/engine/md3.h b/src/engine/md3.h index 7e098bb..2ae5986 100644 --- a/src/engine/md3.h +++ b/src/engine/md3.h @@ -108,7 +108,7 @@ struct md3 : vertloader f->seek(mesh_offset + mheader.ofs_vertices, SEEK_SET); loopj(numframes*m.numverts) { - md3vertex v = { 0 }; + md3vertex v = { {0}, 0 }; f->read(&v, sizeof(md3vertex)); // read the vertices lilswap(v.vertex, 4); diff --git a/src/engine/octaedit.cpp b/src/engine/octaedit.cpp index 3092221..af69db9 100644 --- a/src/engine/octaedit.cpp +++ b/src/engine/octaedit.cpp @@ -1987,7 +1987,7 @@ void mpeditface(int dir, int mode, selinfo &sel, bool local) solidfaces(c); cube &o = blockcube(x, y, 1, sel, -sel.grid); loopi(6) - c.texture[i] = o.children ? DEFAULT_GEOM : o.texture[i]; + c.texture[i] = o.children ? (int) DEFAULT_GEOM : (int) o.texture[i]; } else emptyfaces(c); @@ -2714,7 +2714,7 @@ void mpeditmat(int matid, int filter, selinfo &sel, bool local) if(filter >= 0) { filtermat = filter&0xFFFF; - filtermask = filtermat&(MATF_VOLUME|MATF_INDEX) ? MATF_VOLUME|MATF_INDEX : (filtermat&MATF_CLIP ? MATF_CLIP : filtermat); + filtermask = filtermat&(MATF_VOLUME|MATF_INDEX) ? (int) MATF_VOLUME|MATF_INDEX : (filtermat&MATF_CLIP ? (int) MATF_CLIP : (int) filtermat); filtergeom = filter&~0xFFFF; } if(matid < 0) diff --git a/src/engine/octarender.cpp b/src/engine/octarender.cpp index ec410de..53547a7 100644 --- a/src/engine/octarender.cpp +++ b/src/engine/octarender.cpp @@ -246,7 +246,7 @@ struct vacollect : verthash int type = lmtex.type&LM_TYPE; if(k.layer==LAYER_BLEND) type += 2; else if(k.alpha) type += 4 + 2*(k.alpha-1); - lastlmid[type] = lmtex.unlitx>=0 ? k.lmid : LMID_AMBIENT; + lastlmid[type] = lmtex.unlitx>=0 ? (int) k.lmid : (int) LMID_AMBIENT; if(firstlmid[type]==LMID_AMBIENT && lastlmid[type]!=LMID_AMBIENT) { firstlit[type] = i; @@ -1073,8 +1073,8 @@ void gencubeverts(cube &c, const ivec &co, int size, int csi) VSlot &vslot = lookupvslot(c.texture[i], true), *layer = vslot.layer && !(c.material&MAT_ALPHA) ? &lookupvslot(vslot.layer, true) : NULL; - ushort envmap = vslot.slot->shader->type&SHADER_ENVMAP ? (vslot.slot->texmask&(1<slot->shader->type&SHADER_ENVMAP ? (layer->slot->texmask&(1<shader->type&SHADER_ENVMAP ? (int) (vslot.slot->texmask&(1<slot->shader->type&SHADER_ENVMAP ? (int) (layer->slot->texmask&(1<= 0 && tjoints[tj].edge < i*(MAXFACEVERTS+1)) tj = tjoints[tj].next; int hastj = tj >= 0 && tjoints[tj].edge < (i+1)*(MAXFACEVERTS+1) ? tj : -1; int grassy = vslot.slot->autograss && i!=O_BOTTOM ? (vis!=3 || convex ? 1 : 2) : 0; @@ -1360,8 +1360,8 @@ int genmergedfaces(cube &c, const ivec &co, int size, int minlevel = -1) VSlot &vslot = lookupvslot(mf.tex, true), *layer = vslot.layer && !(c.material&MAT_ALPHA) ? &lookupvslot(vslot.layer, true) : NULL; if(vslot.slot->shader->type&SHADER_ENVMAP) - mf.envmap = vslot.slot->texmask&(1<slot->shader->type&SHADER_ENVMAP ? (layer->slot->texmask&(1<texmask&(1<slot->shader->type&SHADER_ENVMAP ? (int) (layer->slot->texmask&(1< &vas, bool resetocclude = false) loopv(vas) { vtxarray &v = *vas[i]; - int prevvfc = resetocclude ? VFC_NOT_VISIBLE : v.curvfc; + int prevvfc = resetocclude ? (int) VFC_NOT_VISIBLE : (int) v.curvfc; v.curvfc = isvisiblecube(v.o, v.size); if(v.curvfc!=VFC_NOT_VISIBLE) { @@ -1059,7 +1059,7 @@ static void changebatchtmus(renderstate &cur, int pass, geombatch &b) bool changed = false; extern bool brightengeom; extern int fullbright; - int lmid = brightengeom && (b.es.lmid < LMID_RESERVED || (fullbright && editmode)) ? LMID_BRIGHT : b.es.lmid; + int lmid = brightengeom && (b.es.lmid < LMID_RESERVED || (fullbright && editmode)) ? (int) LMID_BRIGHT : (int) b.es.lmid; if(cur.textures[1]!=lightmaptexs[lmid].id) { glActiveTexture_(GL_TEXTURE1); diff --git a/src/engine/texture.cpp b/src/engine/texture.cpp index 964d39d..5abc850 100644 --- a/src/engine/texture.cpp +++ b/src/engine/texture.cpp @@ -229,9 +229,9 @@ static void reorients3tc(GLenum format, int blocksize, int w, int h, uchar *src, if(normals) { ushort ncolor1 = color1, ncolor2 = color2; - if(flipx) - { - ncolor1 = (ncolor1 & ~0xF800) | (0xF800 - (ncolor1 & 0xF800)); + if(flipx) + { + ncolor1 = (ncolor1 & ~0xF800) | (0xF800 - (ncolor1 & 0xF800)); ncolor2 = (ncolor2 & ~0xF800) | (0xF800 - (ncolor2 & 0xF800)); } if(flipy) @@ -403,8 +403,11 @@ void texreorient(ImageData &s, bool flipx, bool flipy, bool swapxy, int type = T switch(s.compressed) { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + [[fallthrough]]; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + [[fallthrough]]; case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + [[fallthrough]]; case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { uchar *dst = d.data, *src = s.data; @@ -417,8 +420,11 @@ void texreorient(ImageData &s, bool flipx, bool flipy, bool swapxy, int type = T break; } case GL_COMPRESSED_RED_RGTC1: + [[fallthrough]]; case GL_COMPRESSED_RG_RGTC2: + [[fallthrough]]; case GL_COMPRESSED_LUMINANCE_LATC1_EXT: + [[fallthrough]]; case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: { uchar *dst = d.data, *src = s.data; @@ -509,7 +515,7 @@ void texcolormask(ImageData &s, const vec &color1, const vec &color2) ); s.replace(d); } - + void texdup(ImageData &s, int srcchan, int dstchan) { if(srcchan==dstchan || max(srcchan, dstchan) >= s.bpp) return; @@ -525,9 +531,13 @@ void texmix(ImageData &s, int c1, int c2, int c3, int c4) switch(numchans) { case 4: dst[3] = src[c4]; + [[fallthrough]]; case 3: dst[2] = src[c3]; + [[fallthrough]]; case 2: dst[1] = src[c2]; - case 1: dst[0] = src[c1]; + [[fallthrough]]; + case 1: dst[0] = src[c1]; break; + default: break; } ); s.replace(d); @@ -544,7 +554,7 @@ void texgrey(ImageData &s) dst[1] = src[3]; ); } - else + else { readwritetex(d, s, dst[0] = src[0]); } @@ -555,12 +565,12 @@ void texpremul(ImageData &s) { switch(s.bpp) { - case 2: - writetex(s, + case 2: + writetex(s, dst[0] = uchar((uint(dst[0])*uint(dst[1]))/255); - ); + ); break; - case 4: + case 4: writetex(s, uint alpha = dst[3]; dst[0] = uchar((uint(dst[0])*alpha)/255); @@ -587,7 +597,7 @@ void texagrad(ImageData &s, float x2, float y2, float x1, float y1) miny = (0 - y1) / (y2 - y1); maxy = (1 - y1) / (y2 - y1); } - float dx = (maxx - minx)/max(s.w-1, 1), + float dx = (maxx - minx)/max(s.w-1, 1), dy = (maxy - miny)/max(s.h-1, 1), cury = miny; for(uchar *dstrow = s.data + s.bpp - 1, *endrow = dstrow + s.h*s.pitch; dstrow < endrow; dstrow += s.pitch) @@ -740,9 +750,9 @@ VARFP(gpumipmap, 0, 0, 1, cleanupmipmaps()); void uploadtexture(int tnum, GLenum target, GLenum internal, int tw, int th, GLenum format, GLenum type, void *pixels, int pw, int ph, int pitch, bool mipmap) { int bpp = formatsize(format), row = 0, rowalign = 0; - if(!pitch) pitch = pw*bpp; + if(!pitch) pitch = pw*bpp; uchar *buf = NULL; - if(pw!=tw || ph!=th) + if(pw!=tw || ph!=th) { buf = new uchar[tw*th*bpp]; scaletexture((uchar *)pixels, pw, ph, bpp, pitch, buf, tw, th); @@ -855,7 +865,7 @@ const GLint *swizzlemask(GLenum format) } return NULL; } - + void setuptexparameters(int tnum, void *pixels, int clamp, int filter, GLenum format, GLenum target, bool swizzle) { glBindTexture(target, tnum); @@ -983,19 +993,19 @@ void createtexture(int tnum, int w, int h, void *pixels, int clamp, int filter, if(!ph) ph = h; int tw = w, th = h; bool mipmap = filter > 1 && pixels; - if(resize && pixels) + if(resize && pixels) { resizetexture(w, h, mipmap, false, target, 0, tw, th); if(mipmap) component = compressedformat(component, tw, th); } - uploadtexture(tnum, subtarget, component, tw, th, format, type, pixels, pw, ph, pitch, mipmap); + uploadtexture(tnum, subtarget, component, tw, th, format, type, pixels, pw, ph, pitch, mipmap); } void createcompressedtexture(int tnum, int w, int h, uchar *data, int align, int blocksize, int levels, int clamp, int filter, GLenum format, GLenum subtarget, bool swizzle = false) { GLenum target = textarget(subtarget); if(filter >= 0 && clamp >= 0) setuptexparameters(tnum, data, clamp, filter, format, target); - uploadcompressedtexture(target, subtarget, format, w, h, data, align, blocksize, levels, filter > 1); + uploadcompressedtexture(target, subtarget, format, w, h, data, align, blocksize, levels, filter > 1); } hashnameset textures; @@ -1035,7 +1045,7 @@ int texalign(const void *data, int w, int bpp) if(stride&2) return 2; return 4; } - + static Texture *newtexture(Texture *t, const char *rname, ImageData &s, int clamp = 0, bool mipit = true, bool canreduce = false, bool transient = false, int compress = 0) { if(!t) @@ -1065,13 +1075,13 @@ static Texture *newtexture(Texture *t, const char *rname, ImageData &s, int clam t->bpp = formatsize(format); t->type |= Texture::COMPRESSED; } - else + else { format = texformat(s.bpp, swizzle); t->bpp = s.bpp; if(swizzle && hasTRG && !hasTSW && swizzlemask(format)) { - swizzleimage(s); + swizzleimage(s); format = texformat(s.bpp, swizzle); t->bpp = s.bpp; } @@ -1092,7 +1102,7 @@ static Texture *newtexture(Texture *t, const char *rname, ImageData &s, int clam levels--; if(t->w > 1) t->w /= 2; if(t->h > 1) t->h /= 2; - } + } int sizelimit = mipit && maxtexsize ? min(maxtexsize, hwtexsize) : hwtexsize; while(t->w > sizelimit || t->h > sizelimit) { @@ -1141,7 +1151,7 @@ SDL_Surface *creatergbsurface(SDL_Surface *os) SDL_Surface *creatergbasurface(SDL_Surface *os) { SDL_Surface *ns = SDL_CreateRGBSurface(SDL_SWSURFACE, os->w, os->h, 32, RGBAMASKS); - if(ns) + if(ns) { SDL_SetSurfaceBlendMode(os, SDL_BLENDMODE_NONE); SDL_BlitSurface(os, NULL, ns, NULL); @@ -1166,9 +1176,9 @@ SDL_Surface *fixsurfaceformat(SDL_Surface *s) { if(!s) return NULL; if(!s->pixels || min(s->w, s->h) <= 0 || s->format->BytesPerPixel <= 0) - { - SDL_FreeSurface(s); - return NULL; + { + SDL_FreeSurface(s); + return NULL; } static const uint rgbmasks[] = { RGBMASKS }, rgbamasks[] = { RGBAMASKS }; switch(s->format->BytesPerPixel) @@ -1177,7 +1187,7 @@ SDL_Surface *fixsurfaceformat(SDL_Surface *s) if(!checkgrayscale(s)) return SDL_GetColorKey(s, NULL) >= 0 ? creatergbasurface(s) : creatergbsurface(s); break; case 3: - if(s->format->Rmask != rgbmasks[0] || s->format->Gmask != rgbmasks[1] || s->format->Bmask != rgbmasks[2]) + if(s->format->Rmask != rgbmasks[0] || s->format->Gmask != rgbmasks[1] || s->format->Bmask != rgbmasks[2]) return creatergbsurface(s); break; case 4: @@ -1201,7 +1211,7 @@ void texflip(ImageData &s) s.replace(d); } -void texnormal(ImageData &s, int emphasis) +void texnormal(ImageData &s, int emphasis) { ImageData d(s.w, s.h, 3); uchar *src = s.data, *dst = d.data; @@ -1282,7 +1292,7 @@ static void blurtexture(int w, int h, uchar *dst, const uchar *src, int margin) dst[1] = uchar(v.y*mag + 127.5f); dst[2] = uchar(v.z*mag + 127.5f); } - else + else { dst[0] = dr>>8; dst[1] = dg>>8; @@ -1315,7 +1325,7 @@ void blurnormals(int n, int w, int h, bvec *dst, const bvec *src, int margin) case 2: blurtexture<2, 3, true>(w, h, dst->v, src->v, margin); break; } } - + void texblur(ImageData &s, int n, int r) { if(s.bpp < 3) return; @@ -1349,7 +1359,7 @@ SDL_Surface *loadsurface(const char *name) if(z) { SDL_RWops *rw = z->rwops(); - if(rw) + if(rw) { char *ext = (char *)strrchr(name, '.'); if(ext) ++ext; @@ -1361,7 +1371,7 @@ SDL_Surface *loadsurface(const char *name) if(!s) s = IMG_Load(findfile(name, "rb")); return fixsurfaceformat(s); } - + static vec parsevec(const char *arg) { vec v(0, 0, 0); @@ -1386,7 +1396,7 @@ static bool texturedata(ImageData &d, const char *tname, Slot::Tex *tex = NULL, if(!tname) { if(!tex) return false; - if(tex->name[0]=='<') + if(tex->name[0]=='<') { cmds = tex->name; file = strrchr(tex->name, '>'); @@ -1394,12 +1404,12 @@ static bool texturedata(ImageData &d, const char *tname, Slot::Tex *tex = NULL, file++; } else file = tex->name; - + static string pname; formatstring(pname, "packages/%s", file); file = path(pname); } - else if(tname[0]=='<') + else if(tname[0]=='<') { cmds = tname; file = strrchr(tname, '>'); @@ -1448,7 +1458,7 @@ static bool texturedata(ImageData &d, const char *tname, Slot::Tex *tex = NULL, } if(d.data && !d.compressed && !dds && compress) *compress = scaledds; } - + if(!d.data) { SDL_Surface *s = NULL; @@ -1476,10 +1486,10 @@ static bool texturedata(ImageData &d, const char *tname, Slot::Tex *tex = NULL, { PARSETEXCOMMANDS(cmds); if(d.compressed) goto compressed; - if(matchstring(cmd, len, "mad")) texmad(d, parsevec(arg[0]), parsevec(arg[1])); + if(matchstring(cmd, len, "mad")) texmad(d, parsevec(arg[0]), parsevec(arg[1])); else if(matchstring(cmd, len, "colorify")) texcolorify(d, parsevec(arg[0]), parsevec(arg[1])); else if(matchstring(cmd, len, "colormask")) texcolormask(d, parsevec(arg[0]), *arg[1] ? parsevec(arg[1]) : vec(1, 1, 1)); - else if(matchstring(cmd, len, "normal")) + else if(matchstring(cmd, len, "normal")) { int emphasis = atoi(arg[0]); texnormal(d, emphasis > 0 ? emphasis : 3); @@ -1497,8 +1507,8 @@ static bool texturedata(ImageData &d, const char *tname, Slot::Tex *tex = NULL, } else if(matchstring(cmd, len, "premul")) texpremul(d); else if(matchstring(cmd, len, "agrad")) texagrad(d, atof(arg[0]), atof(arg[1]), atof(arg[2]), atof(arg[3])); - else if(matchstring(cmd, len, "compress") || matchstring(cmd, len, "dds")) - { + else if(matchstring(cmd, len, "compress") || matchstring(cmd, len, "dds")) + { int scale = atoi(arg[0]); if(scale <= 0) scale = scaledds; if(compress) *compress = scale; @@ -1582,7 +1592,7 @@ void texturereset(int *n) if(!(identflags&IDF_OVERRIDDEN) && !game::allowedittoggle()) return; resetslotshader(); int limit = clamp(*n, 0, slots.length()); - for(int i = limit; i < slots.length(); i++) + for(int i = limit; i < slots.length(); i++) { Slot *s = slots[i]; for(VSlot *vs = s->variants; vs; vs = vs->next) vs->slot = &dummyslot; @@ -1709,7 +1719,7 @@ int compactvslots() { VSlot &ds = *vslots[lastdiscard++]; if(!ds.changed && ds.index < 0) ds.index = compactedvslots++; - } + } vs.index = compactedvslots++; } } @@ -1723,10 +1733,10 @@ int compactvslots() VSlot &vs = *vslots[i]; if(vs.index >= 0 && vs.layer && vslots.inrange(vs.layer)) vs.layer = vslots[vs.layer]->index; } - loopv(vslots) + loopv(vslots) { - while(vslots[i]->index >= 0 && vslots[i]->index != i) - swap(vslots[i], vslots[vslots[i]->index]); + while(vslots[i]->index >= 0 && vslots[i]->index != i) + swap(vslots[i], vslots[vslots[i]->index]); } for(int i = compactedvslots; i < vslots.length(); i++) delete vslots[i]; vslots.setsize(compactedvslots); @@ -1763,7 +1773,7 @@ static void propagatevslot(VSlot &dst, const VSlot &src, int diff, bool edit = f { if(diff & (1<>1, tex); @@ -2176,7 +2186,7 @@ void texlayer(int *layer, char *name, int *mode, float *scale) if(slots.empty()) return; Slot &s = *slots.last(); s.variants->layer = *layer < 0 ? max(slots.length()-1+*layer, 0) : *layer; - s.layermaskname = name[0] ? newstring(path(makerelpath("packages", name))) : NULL; + s.layermaskname = name[0] ? newstring(path(makerelpath("packages", name))) : NULL; s.layermaskmode = *mode; s.layermaskscale = *scale <= 0 ? 1 : *scale; propagatevslot(s.variants, 1< &key, Slot &slot, Slot::Tex &t, bool combined = static void texcombine(Slot &s, int index, Slot::Tex &t, bool forceload = false) { - vector key; + vector key; addname(key, s, t); int texmask = 0; if(!forceload) switch(t.type) @@ -2383,7 +2393,7 @@ void linkslotshaders() { loopv(slots) if(slots[i]->loaded) linkslotshader(*slots[i]); loopv(vslots) if(vslots[i]->linked) linkvslotshader(*vslots[i]); - loopi((MATF_VOLUME|MATF_INDEX)+1) if(materialslots[i].loaded) + loopi((MATF_VOLUME|MATF_INDEX)+1) if(materialslots[i].loaded) { linkslotshader(materialslots[i]); linkvslotshader(materialslots[i]); @@ -2409,17 +2419,17 @@ Texture *loadthumbnail(Slot &slot) addname(name, slot, slot.sts[0], false, prefix); } int glow = -1; - if(slot.texmask&(1<= 0) + if(slot.texmask&(1<= 0) { - defformatstring(prefix, "", vslot.glowcolor.x, vslot.glowcolor.y, vslot.glowcolor.z); + defformatstring(prefix, "", vslot.glowcolor.x, vslot.glowcolor.y, vslot.glowcolor.z); addname(name, slot, slot.sts[glow], true, prefix); } } VSlot *layer = vslot.layer ? &lookupvslot(vslot.layer, false) : NULL; - if(layer) + if(layer) { if(layer->colorscale == vec(1, 1, 1)) addname(name, *layer->slot, layer->slot->sts[0], true, ""); else @@ -2453,12 +2463,12 @@ Texture *loadthumbnail(Slot &slot) if(layer->colorscale != vec(1, 1, 1)) texmad(l, layer->colorscale, vec(0, 0, 0)); if(l.w != s.w/2 || l.h != s.h/2) scaleimage(l, s.w/2, s.h/2); forcergbimage(s); - forcergbimage(l); + forcergbimage(l); uchar *dstrow = &s.data[s.pitch*l.h + s.bpp*l.w], *srcrow = l.data; - loop(y, l.h) + loop(y, l.h) { for(uchar *dst = dstrow, *src = srcrow, *end = &srcrow[l.w*l.bpp]; src < end; dst += s.bpp, src += l.bpp) - loopk(3) dst[k] = src[k]; + loopk(3) dst[k] = src[k]; dstrow += s.pitch; srcrow += l.pitch; } @@ -2478,7 +2488,7 @@ void loadlayermasks() loopv(slots) { Slot &slot = *slots[i]; - if(slot.loaded && slot.layermaskname && !slot.layermask) + if(slot.loaded && slot.layermaskname && !slot.layermask) { slot.layermask = new ImageData; texturedata(*slot.layermask, slot.layermaskname); @@ -2535,7 +2545,7 @@ Texture *cubemaploadwildcard(Texture *t, const char *name, bool mipit, bool msg, { copystring(tname, name); t = textures.access(path(tname)); - if(t) + if(t) { if(!transient && t->type&Texture::TRANSIENT) t->type &= ~Texture::TRANSIENT; return t; @@ -2584,7 +2594,7 @@ Texture *cubemaploadwildcard(Texture *t, const char *name, bool mipit, bool msg, t->bpp = formatsize(format); t->type |= Texture::COMPRESSED; } - else + else { format = texformat(surface[0].bpp, true); t->bpp = surface[0].bpp; @@ -2674,7 +2684,7 @@ struct envmap { if(tex) { glDeleteTextures(1, &tex); tex = 0; } } -}; +}; static vector envmaps; static Texture *skyenvmap = NULL; @@ -2761,7 +2771,7 @@ void initenvmaps() envmap &em = envmaps.add(); em.radius = ent.attr1 ? clamp(int(ent.attr1), 0, 10000) : envmapradius; em.size = ent.attr2 ? clamp(int(ent.attr2), 4, 9) : 0; - em.blur = ent.attr3 ? clamp(int(ent.attr3), 1, 2) : 0; + em.blur = ent.attr3 ? clamp(int(ent.attr3), 1, 2) : 0; em.o = ent.o; } } @@ -2845,7 +2855,7 @@ void cleanuptexture(Texture *t) { DELETEA(t->alphamask); if(t->id) { glDeleteTextures(1, &t->id); t->id = 0; } - if(t->type&Texture::TRANSIENT) textures.remove(t->name); + if(t->type&Texture::TRANSIENT) textures.remove(t->name); } void cleanuptextures() @@ -2881,7 +2891,7 @@ bool reloadtexture(Texture &tex) case Texture::CUBEMAP: if(!cubemaploadwildcard(&tex, NULL, tex.mipmap, true)) return false; break; - } + } return true; } @@ -2906,7 +2916,7 @@ COMMAND(reloadtex, "s"); void reloadtextures() { int reloaded = 0; - enumerate(textures, Texture, tex, + enumerate(textures, Texture, tex, { loadprogress = float(++reloaded)/textures.numelems; reloadtexture(tex); @@ -2916,31 +2926,31 @@ void reloadtextures() enum { - DDSD_CAPS = 0x00000001, + DDSD_CAPS = 0x00000001, DDSD_HEIGHT = 0x00000002, - DDSD_WIDTH = 0x00000004, - DDSD_PITCH = 0x00000008, - DDSD_PIXELFORMAT = 0x00001000, - DDSD_MIPMAPCOUNT = 0x00020000, - DDSD_LINEARSIZE = 0x00080000, - DDSD_BACKBUFFERCOUNT = 0x00800000, - DDPF_ALPHAPIXELS = 0x00000001, - DDPF_FOURCC = 0x00000004, - DDPF_INDEXED = 0x00000020, + DDSD_WIDTH = 0x00000004, + DDSD_PITCH = 0x00000008, + DDSD_PIXELFORMAT = 0x00001000, + DDSD_MIPMAPCOUNT = 0x00020000, + DDSD_LINEARSIZE = 0x00080000, + DDSD_BACKBUFFERCOUNT = 0x00800000, + DDPF_ALPHAPIXELS = 0x00000001, + DDPF_FOURCC = 0x00000004, + DDPF_INDEXED = 0x00000020, DDPF_ALPHA = 0x00000002, - DDPF_RGB = 0x00000040, + DDPF_RGB = 0x00000040, DDPF_COMPRESSED = 0x00000080, DDPF_LUMINANCE = 0x00020000, - DDSCAPS_COMPLEX = 0x00000008, - DDSCAPS_TEXTURE = 0x00001000, - DDSCAPS_MIPMAP = 0x00400000, - DDSCAPS2_CUBEMAP = 0x00000200, - DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400, - DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800, - DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000, - DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000, - DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000, - DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000, + DDSCAPS_COMPLEX = 0x00000008, + DDSCAPS_TEXTURE = 0x00001000, + DDSCAPS_MIPMAP = 0x00400000, + DDSCAPS2_CUBEMAP = 0x00000200, + DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400, + DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800, + DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000, + DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000, + DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000, + DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000, DDSCAPS2_VOLUME = 0x00200000, FOURCC_DXT1 = 0x31545844, FOURCC_DXT2 = 0x32545844, @@ -2965,16 +2975,16 @@ struct DDPIXELFORMAT struct DDSCAPS2 { uint dwCaps, dwCaps2, dwCaps3, dwCaps4; }; struct DDSURFACEDESC2 { - uint dwSize, dwFlags, dwHeight, dwWidth; + uint dwSize, dwFlags, dwHeight, dwWidth; union { int lPitch; uint dwLinearSize; }; - uint dwBackBufferCount; + uint dwBackBufferCount; union { uint dwMipMapCount, dwRefreshRate, dwSrcVBHandle; }; - uint dwAlphaBitDepth, dwReserved, lpSurface; + uint dwAlphaBitDepth, dwReserved, lpSurface; union { DDCOLORKEY ddckCKDestOverlay; uint dwEmptyFaceColor; }; - DDCOLORKEY ddckCKDestBlt, ddckCKSrcOverlay, ddckCKSrcBlt; + DDCOLORKEY ddckCKDestBlt, ddckCKSrcOverlay, ddckCKSrcBlt; union { DDPIXELFORMAT ddpfPixelFormat; uint dwFVF; }; - DDSCAPS2 ddsCaps; - uint dwTextureStage; + DDSCAPS2 ddsCaps; + uint dwTextureStage; }; #define DECODEDDS(name, dbpp, initblock, writeval, nextval) \ @@ -3160,9 +3170,9 @@ bool loaddds(const char *filename, ImageData &image, int force) int bpp = 0; switch(format) { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: bpp = 8; break; - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: bpp = 16; break; case GL_COMPRESSED_LUMINANCE_LATC1_EXT: case GL_COMPRESSED_RED_RGTC1: bpp = 8; break; @@ -3211,7 +3221,7 @@ void gendds(char *infile, char *outfile) if(t==notexture) { conoutf(CON_ERROR, "failed loading %s", infile); return; } glBindTexture(GL_TEXTURE_2D, t->id); - GLint compressed = 0, format = 0, width = 0, height = 0; + GLint compressed = 0, format = 0, width = 0, height = 0; glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &compressed); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &format); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); @@ -3243,9 +3253,9 @@ void gendds(char *infile, char *outfile) else concatstring(buf, ".dds"); outfile = buf; } - + stream *f = openfile(path(outfile, true), "wb"); - if(!f) { conoutf(CON_ERROR, "failed writing to %s", outfile); return; } + if(!f) { conoutf(CON_ERROR, "failed writing to %s", outfile); return; } int csize = 0; for(int lw = width, lh = height, level = 0;;) @@ -3269,7 +3279,7 @@ void gendds(char *infile, char *outfile) d.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); d.ddpfPixelFormat.dwFlags = DDPF_FOURCC | (alphaformat(uncompressedformat(format)) ? DDPF_ALPHAPIXELS : 0); d.ddpfPixelFormat.dwFourCC = fourcc; - + uchar *data = new uchar[csize], *dst = data; for(int lw = width, lh = height;;) { @@ -3288,7 +3298,7 @@ void gendds(char *infile, char *outfile) f->write(&d, sizeof(d)); f->write(data, csize); delete f; - + delete[] data; conoutf("wrote DDS file %s", outfile); diff --git a/src/engine/world.cpp b/src/engine/world.cpp index fcf64c2..a2e1766 100644 --- a/src/engine/world.cpp +++ b/src/engine/world.cpp @@ -42,6 +42,7 @@ bool getentboundingbox(const extentity &e, ivec &o, ivec &r) break; } } + [[fallthrough]]; // invisible mapmodels use entselradius default: o = ivec(vec(e.o).sub(entselradius)); @@ -86,6 +87,7 @@ void modifyoctaentity(int flags, int id, extentity &e, cube *c, const ivec &cor, break; } // invisible mapmodel + [[fallthrough]]; default: oe.other.add(id); break; @@ -122,12 +124,13 @@ void modifyoctaentity(int flags, int id, extentity &e, cube *c, const ivec &cor, oe.bbmax.min(ivec(oe.o).add(oe.size)); break; } + [[fallthrough]]; // invisible mapmodel default: oe.other.removeobj(id); break; } - if(oe.mapmodels.empty() && oe.other.empty()) + if(oe.mapmodels.empty() && oe.other.empty()) freeoctaentities(c[i]); } if(c[i].ext && c[i].ext->ents) c[i].ext->ents->query = NULL; @@ -151,7 +154,7 @@ static bool modifyoctaent(int flags, int id, extentity &e) ivec o, r; if(!getentboundingbox(e, o, r)) return false; - if(!insideworld(e.o)) + if(!insideworld(e.o)) { int idx = outsideents.find(id); if(flags&MODOE_ADD) @@ -221,7 +224,7 @@ static inline void findents(cube *c, const ivec &o, int size, const ivec &bo, co loopoctabox(o, size, bo, br) { if(c[i].ext && c[i].ext->ents) findents(*c[i].ext->ents, low, high, notspawned, pos, invradius, found); - if(c[i].children && size > octaentsize) + if(c[i].children && size > octaentsize) { ivec co(i, o, size); findents(c[i].children, co, size>>1, bo, br, low, high, notspawned, pos, invradius, found); @@ -365,8 +368,8 @@ void attachentity(extentity &e) if(a->attached) continue; switch(e.type) { - case ET_SPOTLIGHT: - if(a->type!=ET_LIGHT) continue; + case ET_SPOTLIGHT: + if(a->type!=ET_LIGHT) continue; break; default: @@ -476,30 +479,30 @@ void entrotate(int *cw) ); } -void entselectionbox(const entity &e, vec &eo, vec &es) +void entselectionbox(const entity &e, vec &eo, vec &es) { model *m = NULL; const char *mname = entities::entmodel(e); if(mname && (m = loadmodel(mname))) - { + { m->collisionbox(eo, es); if(es.x > es.y) es.y = es.x; else es.x = es.y; // square es.z = (es.z + eo.z + 1 + entselradius)/2; // enclose ent radius box and model box eo.x += e.o.x; eo.y += e.o.y; eo.z = e.o.z - entselradius + es.z; - } + } else if(e.type == ET_MAPMODEL && (m = loadmapmodel(e.attr2))) { mmcollisionbox(e, m, eo, es); es.max(entselradius); eo.add(e.o); - } + } else { es = vec(entselradius); eo = e.o; - } + } eo.sub(es); es.mul(2); } @@ -524,19 +527,19 @@ void entdrag(const vec &ray) int d = dimension(entorient), dc= dimcoord(entorient); - entfocus(entgroup.last(), + entfocus(entgroup.last(), entselectionbox(e, eo, es); if(!editmoveplane(e.o, ray, d, eo[d] + (dc ? es[d] : 0), handle, v, entmoving==1)) - return; + return; ivec g(v); int z = g[d]&(~(sel.grid-1)); g.add(sel.grid/2).mask(~(sel.grid-1)); g[d] = z; - + r = (entselsnap ? g[R[d]] : v[R[d]]) - e.o[R[d]]; - c = (entselsnap ? g[C[d]] : v[C[d]]) - e.o[C[d]]; + c = (entselsnap ? g[C[d]] : v[C[d]]) - e.o[C[d]]; ); if(entmoving==1) makeundoent(); @@ -641,7 +644,7 @@ void renderentradius(extentity &e, bool color) vec dir = vec(e.o).sub(e.attached->o).normalize(); float angle = clamp(int(e.attr1), 1, 89); renderentattachment(e); - renderentcone(*e.attached, dir, radius, angle); + renderentcone(*e.attached, dir, radius, angle); } break; @@ -670,7 +673,7 @@ void renderentradius(extentity &e, bool color) } default: - if(e.type>=ET_GAMESPECIFIC) + if(e.type>=ET_GAMESPECIFIC) { if(color) gle::colorf(0, 1, 1); entities::entradius(e, color); @@ -703,7 +706,7 @@ static void renderentbox(const vec &eo, vec es) } void renderentselection(const vec &o, const vec &ray, bool entmoving) -{ +{ if(noentedit()) return; vec eo, es; @@ -728,8 +731,8 @@ void renderentselection(const vec &o, const vec &ray, bool entmoving) { vec a, b; gle::colorub(20, 20, 20); - (a = eo).x = eo.x - fmod(eo.x, worldsize); (b = es).x = a.x + worldsize; boxs3D(a, b, 1); - (a = eo).y = eo.y - fmod(eo.y, worldsize); (b = es).y = a.x + worldsize; boxs3D(a, b, 1); + (a = eo).x = eo.x - fmod(eo.x, worldsize); (b = es).x = a.x + worldsize; boxs3D(a, b, 1); + (a = eo).y = eo.y - fmod(eo.y, worldsize); (b = es).y = a.x + worldsize; boxs3D(a, b, 1); (a = eo).z = eo.z - fmod(eo.z, worldsize); (b = es).z = a.x + worldsize; boxs3D(a, b, 1); } gle::colorub(150,0,0); @@ -807,11 +810,11 @@ void entpush(int *dir) if(noentedit()) return; int d = dimension(entorient); int s = dimcoord(entorient) ? -*dir : *dir; - if(entmoving) + if(entmoving) { groupeditpure(e.o[d] += float(s*sel.grid)); // editdrag supplies the undo } - else + else groupedit(e.o[d] += float(s*sel.grid)); if(entitysurf==1) { @@ -821,7 +824,7 @@ void entpush(int *dir) } VAR(entautoviewdist, 0, 25, 100); -void entautoview(int *dir) +void entautoview(int *dir) { if(!haveselent()) return; static int s = 0; @@ -993,7 +996,7 @@ void entcopy() if(noentedit()) return; entcopygrid = sel.grid; entcopybuf.shrink(0); - loopv(entgroup) + loopv(entgroup) entfocus(entgroup[i], entcopybuf.add(e).o.sub(vec(sel.o))); } @@ -1043,9 +1046,9 @@ void printent(extentity &e, char *buf, int len) switch(e.type) { case ET_PARTICLES: - if(printparticles(e, buf, len)) return; + if(printparticles(e, buf, len)) return; break; - + default: if(e.type >= ET_GAMESPECIFIC && entities::printent(e, buf, len)) return; break; @@ -1086,9 +1089,9 @@ void enttype(char *type, int *numargs) { if(*numargs >= 1) { - int typeidx = findtype(type); + int typeidx = findtype(type); if(typeidx != ET_EMPTY) groupedit(e.type = typeidx); - } + } else entfocus(efocus, { result(entities::entname(e.type)); @@ -1109,7 +1112,7 @@ void entattr(int *attr, int *val, int *numargs) case 3: e.attr4 = *val; break; case 4: e.attr5 = *val; break; } - ); + ); } else entfocus(efocus, { @@ -1131,7 +1134,7 @@ int findentity(int type, int index, int attr1, int attr2) { const vector &ents = entities::getents(); if(index > ents.length()) index = ents.length(); - else for(int i = index; i16 ? 16 : scale), true, false); setvar("mapsize", 1< &ents = entities::getents(); loopv(ents) ents[i]->o.sub(vec(offset)); shrinkblendmap(octant); - + allchanged(); conoutf("shrunk map to size %d", worldscale); diff --git a/src/engine/worldio.cpp b/src/engine/worldio.cpp index ee936f0..591af3c 100644 --- a/src/engine/worldio.cpp +++ b/src/engine/worldio.cpp @@ -525,7 +525,7 @@ void loadc(stream *f, cube &c, const ivec &co, int size, bool &failed) if(mapversion < 27) { static const ushort matconv[] = { MAT_AIR, MAT_WATER, MAT_CLIP, MAT_GLASS|MAT_CLIP, MAT_NOCLIP, MAT_LAVA|MAT_DEATH, MAT_GAMECLIP, MAT_DEATH }; - c.material = size_t(mat) < sizeof(matconv)/sizeof(matconv[0]) ? matconv[mat] : MAT_AIR; + c.material = size_t(mat) < sizeof(matconv)/sizeof(matconv[0]) ? (int) matconv[mat] : (int) MAT_AIR; } else c.material = convertoldmaterial(mat); } diff --git a/src/fpsgame/ai.cpp b/src/fpsgame/ai.cpp index 50f0549..a4d3c33 100644 --- a/src/fpsgame/ai.cpp +++ b/src/fpsgame/ai.cpp @@ -877,10 +877,9 @@ namespace ai switch(wpspot(d, d->ai->route[n], true)) { case 2: d->ai->clear(false); + [[fallthrough]]; case 1: return true; // not close enough to pop it yet - case 0: - default: break; } } diff --git a/src/fpsgame/entities.cpp b/src/fpsgame/entities.cpp index 3403c2e..63d35d0 100644 --- a/src/fpsgame/entities.cpp +++ b/src/fpsgame/entities.cpp @@ -77,30 +77,30 @@ namespace entities switch(i) { case I_SHELLS: - + [[fallthrough]]; case I_BULLETS: - + [[fallthrough]]; case I_ROCKETS: - + [[fallthrough]]; case I_ROUNDS: - + [[fallthrough]]; case I_GRENADES: - + [[fallthrough]]; case I_CARTRIDGES: if(m_noammo) continue; break; case I_HEALTH: - + [[fallthrough]]; case I_BOOST: - + [[fallthrough]]; case I_TINYHEALTH: - + [[fallthrough]]; case I_TINYARMOUR: - + [[fallthrough]]; case I_GREENARMOUR: - + [[fallthrough]]; case I_YELLOWARMOUR: - + [[fallthrough]]; case I_QUAD: if(m_noitems) continue; break; @@ -116,6 +116,7 @@ namespace entities { case TELEPORT: if(e.attr2 > 0) preloadmodel(mapmodelname(e.attr2)); + [[fallthrough]]; case JUMPPAD: if(e.attr4 > 0) preloadmapsound(e.attr4); @@ -394,6 +395,13 @@ namespace entities { switch(e.type) { + case TELEDEST: + { + vec dir; + vecfromyawpitch(e.attr1, 0, 1, 0, dir); + renderentarrow(e, dir, 4); + break; + } case TELEPORT: loopv(ents) if(ents[i]->type == TELEDEST && e.attr1==ents[i]->attr2) { diff --git a/src/fpsgame/game.h b/src/fpsgame/game.h index df0eeb5..3ab0447 100644 --- a/src/fpsgame/game.h +++ b/src/fpsgame/game.h @@ -313,9 +313,9 @@ struct fpsstate case I_HEALTH: return healthroundTripTime + peer->roundTripTimeVariance : ENET_PEER_DEFAULT_ROUND_TRIP_TIME); + return PUSHMILLIS + ((peer) ? (int) (peer->roundTripTime + peer->roundTripTimeVariance) : (int) ENET_PEER_DEFAULT_ROUND_TRIP_TIME); } bool checkpushed(int millis, int range) @@ -535,6 +535,7 @@ namespace server case '!': mode++; if(mode[0] != '?') break; + [[fallthrough]]; case '?': mode++; loopk(NUMGAMEMODES) if(searchmodename(gamemodes[k].name, mode)) diff --git a/src/shared/tools.cpp b/src/shared/tools.cpp index ca82e8f..0ae7559 100644 --- a/src/shared/tools.cpp +++ b/src/shared/tools.cpp @@ -17,9 +17,11 @@ void *operator new[](size_t size) } void operator delete(void *p) { if(p) free(p); } - void operator delete[](void *p) { if(p) free(p); } +void operator delete(void *p, size_t n) { (void) n; if(p) free(p); } +void operator delete[](void *p, size_t n) { (void) n; if(p) free(p); } + void *operator new(size_t size, bool err) { void *p = malloc(size); @@ -36,9 +38,9 @@ void *operator new[](size_t size, bool err) ////////////////////////// rnd numbers //////////////////////////////////////// -#define N (624) -#define M (397) -#define K (0x9908B0DFU) +#define N (624) +#define M (397) +#define K (0x9908B0DFU) static uint state[N]; static int next = N; -- 2.39.5