From 8114309e893aec60232cec4bc09329099c820efa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Sep 2020 21:24:48 +0200 Subject: [PATCH] - compat.h cleanup. * use static_assert directly. Raze is C++17, no need for that macro shit. * removed CONSTEXPR - I seriously fail to see the use here, many of the functions marked as CONSTEXPR cannot possibly even be constant evaluated so the declaration makes no sense. Removed most of these and replaced the valid ones with the official constexpr keyword. * got rid of EDUKE_PREDICT_FALSE - this makes zero sense in script parsing code, at best it will save a few microseconds. Clean code wins. * replaced Blrintf with xs_CRoundToInt. Shitty name is shitty name, even if derived from POSIX. * replaced Bstr*casecmp with str*icmp. As these get defined in the CMake project based on actual compiler checks they are preferable here. * removed lots of other stuff that is not needed with a minimum compiler requirement of C++17. --- source/blood/src/barf.cpp | 6 +- source/blood/src/inifile.cpp | 2 +- source/blood/src/nnexts.cpp | 7 +- source/blood/src/view.cpp | 2 +- source/build/include/build.h | 19 +--- source/build/include/compat.h | 116 ++------------------ source/build/include/polymost.h | 4 +- source/build/include/pragmas.h | 22 ++-- source/build/src/animvpx.cpp | 2 +- source/build/src/defs.cpp | 188 ++++++++++++++------------------ source/build/src/engine.cpp | 18 +-- source/build/src/mdsprite.cpp | 4 +- source/build/src/mhk.cpp | 2 +- source/build/src/polymost.cpp | 6 +- source/build/src/scriptfile.cpp | 8 +- source/build/src/voxmodel.cpp | 8 +- source/core/gamecontrol.h | 5 - source/core/searchpaths.cpp | 4 +- source/exhumed/src/input.cpp | 2 +- source/exhumed/src/view.cpp | 2 +- source/sw/src/draw.cpp | 4 +- source/sw/src/saveable.h | 2 +- source/sw/src/scrip2.cpp | 2 +- 23 files changed, 151 insertions(+), 284 deletions(-) diff --git a/source/blood/src/barf.cpp b/source/blood/src/barf.cpp index da4dc6d58..039514dea 100644 --- a/source/blood/src/barf.cpp +++ b/source/blood/src/barf.cpp @@ -118,7 +118,7 @@ const int kTagCount = sizeof(tags) / sizeof(tag_t); int qsort_compar(const void *a, const void *b) { - return Bstrcasecmp((const char*)a, (const char*)b); + return stricmp((const char*)a, (const char*)b); } void SortTags() @@ -452,7 +452,7 @@ uint8_t RFS::GetNextTag() } // eax = strnicmp(tags[i]._value, scriptBuffer, ebp); - eax = Bstrncasecmp(scriptBuffer, tags[i]._value, ebp); + eax = strnicmp(scriptBuffer, tags[i]._value, ebp); //if (eax >= 0) { if (eax == 0) { @@ -685,7 +685,7 @@ void ParseScript(int lumpnum) // check if this was defined via command prompt arguments for (int i = 0; i < nCmdDefines; i++) { - if (Bstrcasecmp(gCmdDefines[i]._text, char256_1) == 0) { // string is equivalent + if (stricmp(gCmdDefines[i]._text, char256_1) == 0) { // string is equivalent bGotDefine = true; break; } diff --git a/source/blood/src/inifile.cpp b/source/blood/src/inifile.cpp index 51eec9879..dfcf59857 100644 --- a/source/blood/src/inifile.cpp +++ b/source/blood/src/inifile.cpp @@ -208,7 +208,7 @@ bool IniFile::FindSection(const char *section) curNode = curNode->next; if (curNode == &head) return false; - } while(Bstrcasecmp(curNode->name, buffer) != 0); + } while(stricmp(curNode->name, buffer) != 0); } return true; } diff --git a/source/blood/src/nnexts.cpp b/source/blood/src/nnexts.cpp index 9b2f62c1e..4349e9bab 100644 --- a/source/blood/src/nnexts.cpp +++ b/source/blood/src/nnexts.cpp @@ -1484,9 +1484,10 @@ void trPlayerCtrlSetScreenEffect(XSPRITE* pXSource, PLAYER* pPlayer) { void trPlayerCtrlSetLookAngle(XSPRITE* pXSource, PLAYER* pPlayer) { - CONSTEXPR int upAngle = 289; CONSTEXPR int downAngle = -347; - CONSTEXPR double lookStepUp = 4.0 * upAngle / 60.0; - CONSTEXPR double lookStepDown = -4.0 * downAngle / 60.0; + const int upAngle = 289; + const int downAngle = -347; + const double lookStepUp = 4.0 * upAngle / 60.0; + const double lookStepDown = -4.0 * downAngle / 60.0; int look = pXSource->data2 << 5; if (look > 0) pPlayer->q16look = min(mulscale8(FloatToFixed(lookStepUp), look), FloatToFixed(upAngle)); diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index d250867c1..8e1e906d0 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -647,7 +647,7 @@ void viewDrawScreen(bool sceneonly) int viewingRange = viewingrange; videoSetCorrectedAspect(); - int v1 = Blrintf(double(viewingrange) * tan(r_fov * (PI / 360.))); + int v1 = xs_CRoundToInt(double(viewingrange) * tan(r_fov * (PI / 360.))); renderSetAspect(v1, yxaspect); int cX = gView->pSprite->x; diff --git a/source/build/include/build.h b/source/build/include/build.h index bc3484fcc..f12cc3a1d 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -435,17 +435,6 @@ EXTERN int16_t headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; -static CONSTEXPR const int32_t pow2long[32] = -{ - 1, 2, 4, 8, - 16, 32, 64, 128, - 256, 512, 1024, 2048, - 4096, 8192, 16384, 32768, - 65536, 131072, 262144, 524288, - 1048576, 2097152, 4194304, 8388608, - 16777216, 33554432, 67108864, 134217728, - 268435456, 536870912, 1073741824, 2147483647 -}; //These variables are for auto-mapping with the draw2dscreen function. //When you load a new board, these bits are all set to 0 - since @@ -736,7 +725,7 @@ static FORCE_INLINE fixed_t getq16angle(int32_t xvect, int32_t yvect) return IntToFixed(getangle(xvect, yvect)); } -static FORCE_INLINE CONSTEXPR uint32_t uhypsq(int32_t const dx, int32_t const dy) +static FORCE_INLINE constexpr uint32_t uhypsq(int32_t const dx, int32_t const dy) { return (uint32_t)dx*dx + (uint32_t)dy*dy; } @@ -808,12 +797,12 @@ static FORCE_INLINE int32_t getcorrectflorzofslope(int16_t sectnum, int32_t dax, // Is a red wall in a safe fashion, i.e. only if consistency invariant // ".nextsector >= 0 iff .nextwall >= 0" holds. -static FORCE_INLINE CONSTEXPR int32_t redwallp(uwallptr_t wal) +static FORCE_INLINE int32_t redwallp(uwallptr_t wal) { return (wal->nextwall >= 0 && wal->nextsector >= 0); } -static FORCE_INLINE CONSTEXPR int32_t E_SpriteIsValid(const int32_t i) +static FORCE_INLINE int32_t E_SpriteIsValid(const int32_t i) { return ((unsigned)i < MAXSPRITES && sprite[i].statnum != MAXSTATUS); } @@ -1007,7 +996,7 @@ extern int skiptile; static vec2_t const zerovec = { 0, 0 }; -static FORCE_INLINE CONSTEXPR int inside_p(int32_t const x, int32_t const y, int const sectnum) { return (sectnum >= 0 && inside(x, y, sectnum) == 1); } +static FORCE_INLINE int inside_p(int32_t const x, int32_t const y, int const sectnum) { return (sectnum >= 0 && inside(x, y, sectnum) == 1); } #define SET_AND_RETURN(Lval, Rval) \ do \ diff --git a/source/build/include/compat.h b/source/build/include/compat.h index 715ef0fd4..d6bce63cb 100644 --- a/source/build/include/compat.h +++ b/source/build/include/compat.h @@ -102,15 +102,6 @@ # define ATTRIBUTE(attrlist) #endif -#if EDUKE32_GCC_PREREQ(4,0) -# define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) -#else -# define WARN_UNUSED_RESULT -#endif - -#if defined _MSC_VER && _MSC_VER < 1800 -# define inline __inline -#endif #ifndef MAY_ALIAS # ifdef _MSC_VER @@ -132,14 +123,6 @@ # endif #endif - -#if 0 && defined(__OPTIMIZE__) && (defined __GNUC__ || __has_builtin(__builtin_expect)) -#define EDUKE32_PREDICT_FALSE(x) __builtin_expect(!!(x),0) -#else -#define EDUKE32_PREDICT_FALSE(x) (x) -#endif - - #if EDUKE32_GCC_PREREQ(2,0) || defined _MSC_VER # define EDUKE32_FUNCTION __FUNCTION__ #elif CSTD >= 1999 || CXXSTD >= 2011 @@ -148,56 +131,6 @@ # define EDUKE32_FUNCTION "???" #endif -#ifdef _MSC_VER -# define EDUKE32_PRETTY_FUNCTION __FUNCSIG__ -#elif EDUKE32_GCC_PREREQ(2,0) -# define EDUKE32_PRETTY_FUNCTION __PRETTY_FUNCTION__ -#else -# define EDUKE32_PRETTY_FUNCTION EDUKE32_FUNCTION -#endif - -#ifdef __COUNTER__ -# define EDUKE32_UNIQUE_SRC_ID __COUNTER__ -#else -# define EDUKE32_UNIQUE_SRC_ID __LINE__ -#endif - -#if CXXSTD >= 2017 -# define EDUKE32_STATIC_ASSERT(cond) static_assert(cond) -#elif CXXSTD >= 2011 || CSTD >= 2011 || EDUKE32_MSVC_CXX_PREREQ(1600) -# define EDUKE32_STATIC_ASSERT(cond) static_assert(cond, "") -#else -/* C99 / C++03 static assertions based on source found in LuaJIT's src/lj_def.h. */ -# define EDUKE32_ASSERT_NAME2(name, line) name ## line -# define EDUKE32_ASSERT_NAME(line) EDUKE32_ASSERT_NAME2(eduke32_assert_, line) -# define EDUKE32_STATIC_ASSERT(cond) \ - extern void EDUKE32_ASSERT_NAME(EDUKE32_UNIQUE_SRC_ID)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) -#endif - -#ifndef FP_OFF -# define FP_OFF(__p) ((uintptr_t)(__p)) -#endif - - -#if defined __cplusplus && (__cplusplus >= 201103L || __has_feature(cxx_constexpr) || EDUKE32_MSVC_PREREQ(1900)) -# define HAVE_CONSTEXPR -# define CONSTEXPR constexpr -#else -# define CONSTEXPR -#endif - -#if CXXSTD >= 2011 || EDUKE32_MSVC_PREREQ(1700) -# define FINAL final -#else -# define FINAL -#endif - -#if CXXSTD >= 2014 -# define CONSTEXPR_CXX14 CONSTEXPR -#else -# define CONSTEXPR_CXX14 -#endif - #if CXXSTD >= 2011 # if __has_cpp_attribute(fallthrough) # define fallthrough__ [[fallthrough]] @@ -328,27 +261,6 @@ typedef ssize_t bssize_t; ////////// Standard library wrappers ////////// -#if defined(_MSC_VER) -# define Bstrcasecmp _stricmp -# define Bstrncasecmp _strnicmp -#elif defined(__QNX__) -# define Bstrcasecmp stricmp -# define Bstrncasecmp strnicmp -#else -# define Bstrcasecmp strcasecmp -# define Bstrncasecmp strncasecmp -#endif - -static inline int32_t atoi_safe(const char *str) { return (int32_t)strtoll(str, NULL, 10); } - -#define Batoi(x) atoi_safe(x) -#define Batol(str) (strtol(str, NULL, 10)) - -static inline int Blrintf(const double x) -{ - return xs_CRoundToInt(x); -} - #if defined(__arm__) # define Bsqrtf __builtin_sqrtf #else @@ -409,7 +321,7 @@ typedef struct { }; } vec3f_t; -EDUKE32_STATIC_ASSERT(sizeof(vec3f_t) == sizeof(float) * 3); +static_assert(sizeof(vec3f_t) == sizeof(float) * 3); typedef struct { union { double x; double d; }; @@ -417,7 +329,7 @@ typedef struct { union { double z; double v; }; } vec3d_t; -EDUKE32_STATIC_ASSERT(sizeof(vec3d_t) == sizeof(double) * 3); +static_assert(sizeof(vec3d_t) == sizeof(double) * 3); ////////// Language tricks that depend on size_t ////////// @@ -443,38 +355,32 @@ inline int32_t B_LITTLE16(int16_t val) { return LittleShort(val); } inline uint32_t B_LITTLE16(uint16_t val) { return LittleShort(val); } static FORCE_INLINE void B_BUF32(void * const buf, uint32_t const x) { *(uint32_t *) buf = x; } -static FORCE_INLINE CONSTEXPR uint32_t B_UNBUF32(void const * const buf) { return *(uint32_t const *) buf; } -static FORCE_INLINE CONSTEXPR uint16_t B_UNBUF16(void const * const buf) { return *(uint16_t const *) buf; } +static FORCE_INLINE uint32_t B_UNBUF32(void const * const buf) { return *(uint32_t const *) buf; } +static FORCE_INLINE uint16_t B_UNBUF16(void const * const buf) { return *(uint16_t const *) buf; } ////////// Abstract data operations ////////// -#define ABSTRACT_DECL static FORCE_INLINE WARN_UNUSED_RESULT CONSTEXPR - -template ABSTRACT_DECL T clamp(T in, X min, Y max) { return in <= (T) min ? (T) min : (in >= (T) max ? (T) max : in); } -template ABSTRACT_DECL T clamp2(T in, X min, Y max) { return in >= (T) max ? (T) max : (in <= (T) min ? (T) min : in); } +template constexpr T clamp(T in, X min, Y max) { return in <= (T) min ? (T) min : (in >= (T) max ? (T) max : in); } +template constexpr T clamp2(T in, X min, Y max) { return in >= (T) max ? (T) max : (in <= (T) min ? (T) min : in); } using std::min; using std::max; ////////// Bitfield manipulation ////////// -#if 0 -// Behold the probably most useless (de)optimization I ever discovered. -// Replacing a simple bit shift with a memory access through a global pointer is surely going to improve matters... >( -// Constexpr means shit here if the index is not a constant! -static CONSTEXPR const char pow2char[8] = {1,2,4,8,16,32,64,128u}; -#else +// This once was a static array, requiring a memory acces where a shift would suffice. // Revert the above to a real bit shift through some C++ operator magic. That saves me from reverting all the code that uses this construct. +// Note: Only occurs 25 times in the code, should be removed for good. static struct { constexpr uint8_t operator[](int index) const { return 1 << index; }; } pow2char; -#endif + static FORCE_INLINE void bitmap_set(uint8_t *const ptr, int const n) { ptr[n>>3] |= pow2char[n&7]; } static FORCE_INLINE void bitmap_clear(uint8_t *const ptr, int const n) { ptr[n>>3] &= ~pow2char[n&7]; } -static FORCE_INLINE CONSTEXPR char bitmap_test(uint8_t const *const ptr, int const n) { return ptr[n>>3] & pow2char[n&7]; } +static FORCE_INLINE char bitmap_test(uint8_t const *const ptr, int const n) { return ptr[n>>3] & pow2char[n&7]; } ////////// Utility functions ////////// @@ -543,6 +449,4 @@ inline FVector3 GetSoundPos(const vec3_t *pos) # define FALSE 0 #endif -#define WITHKPLIB - #endif // compat_h_ diff --git a/source/build/include/polymost.h b/source/build/include/polymost.h index 3aa103004..a0598ae62 100644 --- a/source/build/include/polymost.h +++ b/source/build/include/polymost.h @@ -64,7 +64,7 @@ static FORCE_INLINE int32_t fogshade(int32_t const shade, int32_t const pal) return (globalflags & GLOBAL_NO_GL_FOGSHADE) ? 0 : shade; } -static FORCE_INLINE int check_nonpow2(int32_t const x) +static constexpr inline int check_nonpow2(int32_t const x) { return (x > 1 && (x&(x-1))); } @@ -102,7 +102,7 @@ enum { }; #define DAMETH_NARROW_MASKPROPS(dameth) (((dameth)&(~DAMETH_TRANS1))|(((dameth)&DAMETH_TRANS1)>>1)) -EDUKE32_STATIC_ASSERT(DAMETH_NARROW_MASKPROPS(DAMETH_MASKPROPS) == DAMETH_MASK); +static_assert(DAMETH_NARROW_MASKPROPS(DAMETH_MASKPROPS) == DAMETH_MASK); extern float fcosglobalang, fsinglobalang; extern float fxdim, fydim, fydimen, fviewingrange; diff --git a/source/build/include/pragmas.h b/source/build/include/pragmas.h index 709e1e445..528bd74e8 100644 --- a/source/build/include/pragmas.h +++ b/source/build/include/pragmas.h @@ -55,21 +55,21 @@ static inline int32_t scale(int32_t eax, int32_t edx, int32_t ecx) // #define EDUKE32_SCALER_PRAGMA(a) \ - static FORCE_INLINE CONSTEXPR int32_t mulscale##a(int32_t eax, int32_t edx) { return dw((qw(eax) * edx) >> by(a)); } \ - static FORCE_INLINE CONSTEXPR double fmulscale##a(double eax, double edx) { return (eax * edx) / (double)(qw(1) << a); } \ - static FORCE_INLINE CONSTEXPR int32_t dmulscale##a(int32_t eax, int32_t edx, int32_t esi, int32_t edi) \ + static FORCE_INLINE int32_t mulscale##a(int32_t eax, int32_t edx) { return dw((qw(eax) * edx) >> by(a)); } \ + static FORCE_INLINE double fmulscale##a(double eax, double edx) { return (eax * edx) / (double)(qw(1) << a); } \ + static FORCE_INLINE int32_t dmulscale##a(int32_t eax, int32_t edx, int32_t esi, int32_t edi) \ { \ return dw(((qw(eax) * edx) + (qw(esi) * edi)) >> by(a)); \ } \ - static FORCE_INLINE CONSTEXPR double fdmulscale##a(double eax, double edx, double esi, double edi) \ + static FORCE_INLINE double fdmulscale##a(double eax, double edx, double esi, double edi) \ { \ return ((eax * edx) + (esi * edi)) / (double)(qw(1) << a); \ } \ - static FORCE_INLINE CONSTEXPR int32_t tmulscale##a(int32_t eax, int32_t edx, int32_t ebx, int32_t ecx, int32_t esi, int32_t edi) \ + static FORCE_INLINE int32_t tmulscale##a(int32_t eax, int32_t edx, int32_t ebx, int32_t ecx, int32_t esi, int32_t edi) \ { \ return dw(((qw(eax) * edx) + (qw(ebx) * ecx) + (qw(esi) * edi)) >> by(a)); \ } \ - static FORCE_INLINE CONSTEXPR double ftmulscale##a(double eax, double edx, double ebx, double ecx, double esi, double edi) \ + static FORCE_INLINE double ftmulscale##a(double eax, double edx, double ebx, double ecx, double esi, double edi) \ { \ return ((eax * edx) + (ebx * ecx) + (esi * edi)) / (double)(qw(1) << a); \ } @@ -103,17 +103,17 @@ static FORCE_INLINE void swapchar2(void *a, void *b, int32_t s) #endif #define klabs(x) abs(x) -static FORCE_INLINE CONSTEXPR int ksgn(int32_t a) { return (a > 0) - (a < 0); } +static inline constexpr int ksgn(int32_t a) { return (a > 0) - (a < 0); } inline int sgn(int32_t a) { return (a > 0) - (a < 0); } -static FORCE_INLINE CONSTEXPR int32_t mulscale(int32_t eax, int32_t edx, int32_t ecx) { return dw((qw(eax) * edx) >> by(ecx)); } -static FORCE_INLINE CONSTEXPR double fmulscale(double eax, double edx, int32_t ecx) { return (eax * edx) / (double)(qw(1) << ecx); } -static FORCE_INLINE CONSTEXPR int32_t dmulscale(int32_t eax, int32_t edx, int32_t esi, int32_t edi, int32_t ecx) +static inline int32_t mulscale(int32_t eax, int32_t edx, int32_t ecx) { return dw((qw(eax) * edx) >> by(ecx)); } +static inline double fmulscale(double eax, double edx, int32_t ecx) { return (eax * edx) / (double)(qw(1) << ecx); } +static inline int32_t dmulscale(int32_t eax, int32_t edx, int32_t esi, int32_t edi, int32_t ecx) { return dw(((qw(eax) * edx) + (qw(esi) * edi)) >> by(ecx)); } -static FORCE_INLINE CONSTEXPR double fdmulscale(double eax, double edx, double esi, double edi, int32_t ecx) +static inline double fdmulscale(double eax, double edx, double esi, double edi, int32_t ecx) { return ((eax * edx) + (esi * edi)) / (double)(qw(1) << ecx); } diff --git a/source/build/src/animvpx.cpp b/source/build/src/animvpx.cpp index b953221e8..3320d1dd4 100644 --- a/source/build/src/animvpx.cpp +++ b/source/build/src/animvpx.cpp @@ -31,7 +31,7 @@ const char *animvpx_read_ivf_header_errmsg[] = { "invalid framerate numerator or denominator after correction, must not be 0", }; -EDUKE32_STATIC_ASSERT(sizeof(animvpx_ivf_header_t) == 32); +static_assert(sizeof(animvpx_ivf_header_t) == 32); int32_t animvpx_read_ivf_header(FileReader & inhandle, animvpx_ivf_header_t *hdr) { diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index cc39e3205..70804aa53 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -207,7 +207,7 @@ static void defsparser_include(const char *fn, const scriptfile *script, const c scriptfile *included; included = scriptfile_fromfile(fn); - if (EDUKE32_PREDICT_FALSE(!included)) + if (!included) { if (!cmdtokptr) Printf("Warning: Failed including %s as module\n", fn); @@ -231,14 +231,14 @@ static void defsparser_include(const char *fn, const scriptfile *script, const c static int32_t check_tile_range(const char *defcmd, int32_t *tilebeg, int32_t *tileend, const scriptfile *script, const char *cmdtokptr) { - if (EDUKE32_PREDICT_FALSE(*tileend < *tilebeg)) + if (*tileend < *tilebeg) { Printf("Warning: %s: backwards tile range on line %s:%d\n", defcmd, script->filename, scriptfile_getlinum(script,cmdtokptr)); swaplong(tilebeg, tileend); } - if (EDUKE32_PREDICT_FALSE((unsigned)*tilebeg >= MAXUSERTILES || (unsigned)*tileend >= MAXUSERTILES)) + if ((unsigned)*tilebeg >= MAXUSERTILES || (unsigned)*tileend >= MAXUSERTILES) { Printf("Error: %s: Invalid tile range on line %s:%d\n", defcmd, script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -251,7 +251,7 @@ static int32_t check_tile_range(const char *defcmd, int32_t *tilebeg, int32_t *t static int32_t check_tile(const char *defcmd, int32_t tile, const scriptfile *script, const char *cmdtokptr) { - if (EDUKE32_PREDICT_FALSE((unsigned)tile >= MAXUSERTILES)) + if ((unsigned)tile >= MAXUSERTILES) { Printf("Error: %s: Invalid tile number on line %s:%d\n", defcmd, script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -391,7 +391,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getstring(script,&name)) break; if (scriptfile_getsymbol(script,&number)) break; - if (EDUKE32_PREDICT_FALSE(scriptfile_addsymbolvalue(name,number) < 0)) + if (scriptfile_addsymbolvalue(name,number) < 0) Printf("Warning: Symbol %s was NOT redefined to %d on line %s:%d\n", name,number,script->filename,scriptfile_getlinum(script,cmdtokptr)); break; @@ -590,7 +590,7 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE(!fn)) + if (!fn) { Printf("Error: missing 'file name' for artfile definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -615,7 +615,7 @@ static int32_t defsparser(scriptfile *script) break; spd = clamp(spd, 0, 15); - if (EDUKE32_PREDICT_FALSE(type&~3)) + if (type&~3) { Printf("Error: animtilerange: animation type must be 0, 1, 2 or 3 on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -626,7 +626,7 @@ static int32_t defsparser(scriptfile *script) if (type == 3 && tile1 > tile2) // PICANM_ANIMTYPE_BACK num = -num; - if (EDUKE32_PREDICT_FALSE((unsigned)num > 255)) + if ((unsigned)num > 255) { Printf("Error: animtilerange: tile difference can be at most 255 on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -776,7 +776,7 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE((unsigned)tile >= MAXUSERTILES)) + if ((unsigned)tile >= MAXUSERTILES) { Printf("Error: missing or invalid 'tile number' for texture definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,texturetokptr)); @@ -832,7 +832,7 @@ static int32_t defsparser(scriptfile *script) if (haveextra) picanm[tile].extra = extra; - if (EDUKE32_PREDICT_FALSE(flags == 0 && !havexoffset && !haveyoffset && !haveextra)) + if (flags == 0 && !havexoffset && !haveyoffset && !haveextra) Printf("\nError: missing 'file name' for tilefromtexture definition near line %s:%d", script->filename, scriptfile_getlinum(script,texturetokptr)); break; @@ -928,7 +928,7 @@ static int32_t defsparser(scriptfile *script) havetile = 1; } - if (EDUKE32_PREDICT_FALSE((unsigned)temppal >= MAXPALOOKUPS-RESERVEDPALS)) + if ((unsigned)temppal >= MAXPALOOKUPS-RESERVEDPALS) { Printf("Error: copytile 'palette number' out of range (max=%d)\n", MAXPALOOKUPS-RESERVEDPALS-1); @@ -1069,7 +1069,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getnumber(script,&shadeoffs)) break; lastmodelid = md_loadmodel(modelfn); - if (EDUKE32_PREDICT_FALSE(lastmodelid < 0)) + if (lastmodelid < 0) { Printf("Warning: Failed loading MD2/MD3 model \"%s\"\n", modelfn); break; @@ -1096,7 +1096,7 @@ static int32_t defsparser(scriptfile *script) if (check_tile_range("definemodelframe", &ftilenume, <ilenume, script, cmdtokptr)) break; - if (EDUKE32_PREDICT_FALSE(lastmodelid < 0)) + if (lastmodelid < 0) { #ifdef USE_OPENGL Printf("Warning: Ignoring frame definition.\n"); @@ -1139,7 +1139,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getdouble(script,&dfps)) break; //animation frame rate if (scriptfile_getnumber(script,&flags)) break; - if (EDUKE32_PREDICT_FALSE(lastmodelid < 0)) + if (lastmodelid < 0) { #ifdef USE_OPENGL Printf("Warning: Ignoring animation definition.\n"); @@ -1227,19 +1227,19 @@ static int32_t defsparser(scriptfile *script) { char *fn; - if (EDUKE32_PREDICT_FALSE(scriptfile_getstring(script,&fn))) + if (scriptfile_getstring(script,&fn)) break; //voxel filename while (nextvoxid < MAXVOXELS && (voxreserve[nextvoxid>>3]&(1<<(nextvoxid&7)))) nextvoxid++; - if (EDUKE32_PREDICT_FALSE(nextvoxid == MAXVOXELS)) + if (nextvoxid == MAXVOXELS) { Printf("Maximum number of voxels (%d) already defined.\n", MAXVOXELS); break; } - if (EDUKE32_PREDICT_FALSE(qloadkvx(nextvoxid, fn))) + if (qloadkvx(nextvoxid, fn)) { Printf("Failure loading voxel file \"%s\"\n",fn); break; @@ -1258,7 +1258,7 @@ static int32_t defsparser(scriptfile *script) if (check_tile_range("definevoxeltiles", &ftilenume, <ilenume, script, cmdtokptr)) break; - if (EDUKE32_PREDICT_FALSE(lastvoxid < 0)) + if (lastvoxid < 0) { Printf("Warning: Ignoring voxel tiles definition.\n"); break; @@ -1305,7 +1305,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&modelend)) break; #ifdef USE_OPENGL lastmodelid = md_loadmodel(modelfn); - if (EDUKE32_PREDICT_FALSE(lastmodelid < 0)) + if (lastmodelid < 0) { Printf("Warning: Failed loading MD2/MD3 model \"%s\"\n", modelfn); script->textptr = modelend+1; @@ -1376,7 +1376,7 @@ static int32_t defsparser(scriptfile *script) break; } - if (EDUKE32_PREDICT_FALSE(lastmodelid < 0)) + if (lastmodelid < 0) { #ifdef USE_OPENGL Printf("Warning: ignoring frame definition on line %s:%d.\n", @@ -1451,19 +1451,16 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE(!startframe)) Printf("Error: missing 'start frame' for anim definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,animtokptr)), happy = 0; - if (EDUKE32_PREDICT_FALSE(!endframe)) Printf("Error: missing 'end frame' for anim definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,animtokptr)), happy = 0; + if (!startframe) Printf("Error: missing 'start frame' for anim definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,animtokptr)), happy = 0; + if (!endframe) Printf("Error: missing 'end frame' for anim definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,animtokptr)), happy = 0; model_ok &= happy; - if (EDUKE32_PREDICT_FALSE(!happy)) break; + if (!happy) break; - if (EDUKE32_PREDICT_FALSE(lastmodelid < 0)) + if (lastmodelid < 0) { -#ifdef USE_OPENGL Printf("Warning: Ignoring animation definition.\n"); -#endif break; } -#ifdef USE_OPENGL switch (md_defineanimation(lastmodelid, startframe, endframe, (int32_t)(dfps*(65536.0*.001)), flags)) { case 0: @@ -1486,7 +1483,6 @@ static int32_t defsparser(scriptfile *script) model_ok = 0; break; } -#endif } break; case T_SKIN: case T_DETAIL: case T_GLOW: case T_SPECULAR: case T_NORMAL: @@ -1495,9 +1491,7 @@ static int32_t defsparser(scriptfile *script) char *skinend, *skinfn = 0; int32_t palnum = 0, surfnum = 0; double param = 1.0, specpower = 1.0, specfactor = 1.0; -#ifdef USE_OPENGL int32_t flags = 0; -#endif static const tokenlist modelskintokens[] = { @@ -1536,7 +1530,7 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE(!skinfn)) + if (!skinfn) { Printf("Error: missing 'skin filename' for skin definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,skintokptr)); model_ok = 0; @@ -1651,20 +1645,17 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE(check_tile_range("hud", &ftilenume, <ilenume, script, hudtokptr))) + if (check_tile_range("hud", &ftilenume, <ilenume, script, hudtokptr)) { model_ok = 0; break; } - if (EDUKE32_PREDICT_FALSE(lastmodelid < 0)) + if (lastmodelid < 0) { -#ifdef USE_OPENGL Printf("Warning: Ignoring frame definition.\n"); -#endif break; } -#ifdef USE_OPENGL for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) { vec3f_t const add = { (float)xadd, (float)yadd, (float)zadd }; @@ -1688,13 +1679,12 @@ static int32_t defsparser(scriptfile *script) model_ok &= happy; } -#endif } break; } } - if (EDUKE32_PREDICT_FALSE(!model_ok)) + if (!model_ok) { if (lastmodelid >= 0) { @@ -1726,19 +1716,19 @@ static int32_t defsparser(scriptfile *script) { "rotate", T_ROTATE }, }; - if (EDUKE32_PREDICT_FALSE(scriptfile_getstring(script,&fn))) + if (scriptfile_getstring(script,&fn)) break; //voxel filename while (nextvoxid < MAXVOXELS && (voxreserve[nextvoxid>>3]&(1<<(nextvoxid&7)))) nextvoxid++; - if (EDUKE32_PREDICT_FALSE(nextvoxid == MAXVOXELS)) + if (nextvoxid == MAXVOXELS) { Printf("Maximum number of voxels (%d) already defined.\n", MAXVOXELS); break; } - if (EDUKE32_PREDICT_FALSE(qloadkvx(nextvoxid, fn))) + if (qloadkvx(nextvoxid, fn)) { Printf("Failure loading voxel file \"%s\"\n",fn); break; @@ -1845,10 +1835,10 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE(tile < 0)) Printf("Error: skybox: missing 'tile number' near line %s:%d\n", script->filename, scriptfile_getlinum(script,skyboxtokptr)), happy=0; + if (tile < 0) Printf("Error: skybox: missing 'tile number' near line %s:%d\n", script->filename, scriptfile_getlinum(script,skyboxtokptr)), happy=0; for (i=0; i<6; i++) { - if (EDUKE32_PREDICT_FALSE(!fn[i])) Printf("Error: skybox: missing '%s filename' near line %s:%d\n", skyfaces[i], script->filename, scriptfile_getlinum(script,skyboxtokptr)), happy = 0; + if (!fn[i]) Printf("Error: skybox: missing '%s filename' near line %s:%d\n", skyfaces[i], script->filename, scriptfile_getlinum(script,skyboxtokptr)), happy = 0; // FIXME? if (fileSystem.FileExists(fn[i])) happy = 0; @@ -1884,21 +1874,21 @@ static int32_t defsparser(scriptfile *script) scriptfile_getstring(script,&fn); break; } } - if (EDUKE32_PREDICT_FALSE((unsigned)basepal >= MAXBASEPALS)) + if ((unsigned)basepal >= MAXBASEPALS) { Printf("Error: missing or invalid 'base palette number' for highpalookup definition " "near line %s:%d\n", script->filename, scriptfile_getlinum(script,highpaltokptr)); break; } - if (EDUKE32_PREDICT_FALSE((unsigned)pal >= MAXPALOOKUPS - RESERVEDPALS)) + if ((unsigned)pal >= MAXPALOOKUPS - RESERVEDPALS) { Printf("Error: missing or invalid 'palette number' for highpalookup definition near " "line %s:%d\n", script->filename, scriptfile_getlinum(script,highpaltokptr)); break; } - if (EDUKE32_PREDICT_FALSE(!fn)) + if (!fn) { Printf("Error: missing 'file name' for highpalookup definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,highpaltokptr)); @@ -1952,7 +1942,7 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE(pal < 0)) + if (pal < 0) { Printf("Error: tint: missing 'palette number' near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); @@ -2035,25 +2025,25 @@ static int32_t defsparser(scriptfile *script) sprintf(msgend, "for palookup definition near line %s:%d", script->filename, scriptfile_getlinum(script,starttokptr)); - if (EDUKE32_PREDICT_FALSE((havepal & HAVE_PAL)==0)) + if ((havepal & HAVE_PAL)==0) { Printf("Error: missing 'palette number' %s\n", msgend); break; } - else if (EDUKE32_PREDICT_FALSE(pal==0 || (unsigned)pal >= MAXPALOOKUPS-RESERVEDPALS)) + else if (pal==0 || (unsigned)pal >= MAXPALOOKUPS-RESERVEDPALS) { Printf("Error: 'palette number' out of range (1 .. %d) %s\n", MAXPALOOKUPS-RESERVEDPALS-1, msgend); break; } - if (EDUKE32_PREDICT_FALSE(havepal & HAVEPAL_ERROR)) + if (havepal & HAVEPAL_ERROR) { // will also disallow multiple remappals or remapselfs Printf("Error: must have exactly one of either 'remappal' or 'remapself' %s\n", msgend); break; } - else if (EDUKE32_PREDICT_FALSE((havepal & HAVE_REMAPPAL) + else if ((havepal & HAVE_REMAPPAL && (unsigned)remappal >= MAXPALOOKUPS-RESERVEDPALS)) { Printf("Error: 'remap palette number' out of range (max=%d) %s\n", @@ -2144,21 +2134,21 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE((unsigned)tile >= MAXUSERTILES)) break; // message is printed later - if (EDUKE32_PREDICT_FALSE((unsigned)pal >= MAXPALOOKUPS - RESERVEDPALS)) + if ((unsigned)tile >= MAXUSERTILES) break; // message is printed later + if ((unsigned)pal >= MAXPALOOKUPS - RESERVEDPALS) { Printf("Error: missing or invalid 'palette number' for texture definition near " "line %s:%d\n", script->filename, scriptfile_getlinum(script,paltokptr)); break; } - if (EDUKE32_PREDICT_FALSE(!fn)) + if (!fn) { Printf("Error: missing 'file name' for texture definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,paltokptr)); break; } - if (EDUKE32_PREDICT_FALSE(!fileSystem.FileExists(fn))) + if (!fileSystem.FileExists(fn)) { Printf("Error: %s not found in replacement for tile %d\n", fn, tile); break; @@ -2196,7 +2186,7 @@ static int32_t defsparser(scriptfile *script) { "artquality", T_ARTQUALITY }, }; - if (EDUKE32_PREDICT_FALSE(scriptfile_getbraces(script,&detailend))) break; + if (scriptfile_getbraces(script,&detailend)) break; while (script->textptr < detailend) { switch (getatoken(script,texturetokens_pal,ARRAY_SIZE(texturetokens_pal))) @@ -2216,15 +2206,15 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE((unsigned)tile >= MAXUSERTILES)) break; // message is printed later - if (EDUKE32_PREDICT_FALSE(!fn)) + if ((unsigned)tile >= MAXUSERTILES) break; // message is printed later + if (!fn) { Printf("Error: missing 'file name' for texture definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,detailtokptr)); break; } - if (EDUKE32_PREDICT_FALSE(fileSystem.FileExists(fn))) + if (fileSystem.FileExists(fn)) break; switch (token) @@ -2251,7 +2241,7 @@ static int32_t defsparser(scriptfile *script) break; } } - if (EDUKE32_PREDICT_FALSE((unsigned)tile >= MAXUSERTILES)) + if ((unsigned)tile >= MAXUSERTILES) { Printf("Error: missing or invalid 'tile number' for texture definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,texturetokptr)); @@ -2265,7 +2255,7 @@ static int32_t defsparser(scriptfile *script) { int32_t r0,r1; - if (EDUKE32_PREDICT_FALSE(scriptfile_getsymbol(script,&r0))) break; + if (scriptfile_getsymbol(script,&r0)) break; if (tokn == T_UNDEFMODELRANGE) { if (scriptfile_getsymbol(script,&r1)) break; @@ -2280,21 +2270,15 @@ static int32_t defsparser(scriptfile *script) if (check_tile("undefmodel", r0, script, cmdtokptr)) break; } -#ifdef USE_OPENGL for (; r0 <= r1; r0++) md_undefinetile(r0); -#endif } break; case T_UNDEFMODELOF: { int32_t r0; -#if defined USE_OPENGL && 0 - int32_t mid; -#endif - - if (EDUKE32_PREDICT_FALSE(scriptfile_getsymbol(script,&r0))) break; + if (scriptfile_getsymbol(script,&r0)) break; if (check_tile("undefmodelof", r0, script, cmdtokptr)) break; @@ -2316,19 +2300,19 @@ static int32_t defsparser(scriptfile *script) case T_UNDEFTEXTURERANGE: { int32_t r0,r1; - if (EDUKE32_PREDICT_FALSE(scriptfile_getsymbol(script,&r0))) break; + if (scriptfile_getsymbol(script,&r0)) break; if (tokn == T_UNDEFTEXTURERANGE) { - if (EDUKE32_PREDICT_FALSE(scriptfile_getsymbol(script,&r1))) break; + if (scriptfile_getsymbol(script,&r1)) break; - if (EDUKE32_PREDICT_FALSE(check_tile_range("undeftexturerange", &r0, &r1, script, cmdtokptr))) + if (check_tile_range("undeftexturerange", &r0, &r1, script, cmdtokptr)) break; } else { r1 = r0; - if (EDUKE32_PREDICT_FALSE(check_tile("undeftexture", r0, script, cmdtokptr))) + if (check_tile("undeftexture", r0, script, cmdtokptr)) break; } for (; r0 <= r1; r0++) tileRemoveReplacement(r0); @@ -2342,8 +2326,8 @@ static int32_t defsparser(scriptfile *script) static const tokenlist dummytokens[] = { { "id", T_ID }, }; - if (EDUKE32_PREDICT_FALSE(scriptfile_getstring(script, &dummy))) break; - if (EDUKE32_PREDICT_FALSE(scriptfile_getbraces(script,&dummy))) break; + if (scriptfile_getstring(script, &dummy)) break; + if (scriptfile_getbraces(script,&dummy)) break; while (script->textptr < dummy) { // XXX? @@ -2357,8 +2341,8 @@ static int32_t defsparser(scriptfile *script) { int32_t b,e, i; - if (EDUKE32_PREDICT_FALSE(scriptfile_getsymbol(script,&b))) break; - if (EDUKE32_PREDICT_FALSE(scriptfile_getsymbol(script,&e))) break; + if (scriptfile_getsymbol(script,&b)) break; + if (scriptfile_getsymbol(script,&e))break; b = max(b, 0); e = min(e, MAXUSERTILES-1); @@ -2379,7 +2363,7 @@ static int32_t defsparser(scriptfile *script) { "file", T_FILE }, }; - if (EDUKE32_PREDICT_FALSE(scriptfile_getbraces(script,&dummy))) break; + if (scriptfile_getbraces(script,&dummy)) break; while (script->textptr < dummy) { switch (getatoken(script,sound_musictokens,ARRAY_SIZE(sound_musictokens))) @@ -2408,7 +2392,7 @@ static int32_t defsparser(scriptfile *script) }; int32_t previous_usermaphacks = num_usermaphacks; - if (EDUKE32_PREDICT_FALSE(scriptfile_getbraces(script,&mapinfoend))) break; + if (scriptfile_getbraces(script,&mapinfoend)) break; while (script->textptr < mapinfoend) { switch (getatoken(script,mapinfotokens,ARRAY_SIZE(mapinfotokens))) @@ -2578,7 +2562,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&blockend)) break; - if (EDUKE32_PREDICT_FALSE((unsigned)id >= MAXBASEPALS)) + if ((unsigned)id >= MAXBASEPALS) { Printf("Error: basepalette: Invalid basepal number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -2636,21 +2620,21 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE(fn == NULL)) + if (fn == NULL) { Printf("Error: basepalette: No filename provided on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } - if (EDUKE32_PREDICT_FALSE(offset < 0)) + if (offset < 0) { Printf("Error: basepalette: Invalid file offset on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } - if (EDUKE32_PREDICT_FALSE((unsigned)shiftleft >= 8)) + if ((unsigned)shiftleft >= 8) { Printf("Error: basepalette: Invalid left shift provided on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -2695,7 +2679,7 @@ static int32_t defsparser(scriptfile *script) int32_t source; scriptfile_getsymbol(script,&source); - if (EDUKE32_PREDICT_FALSE((unsigned)source >= MAXBASEPALS || source == id)) + if ((unsigned)source >= MAXBASEPALS || source == id) { Printf("Error: basepalette: Invalid source basepal number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -2757,7 +2741,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&blockend)) break; - if (EDUKE32_PREDICT_FALSE((unsigned)id >= MAXPALOOKUPS)) + if ((unsigned)id >= MAXPALOOKUPS) { Printf("Error: palookup: Invalid pal number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -2815,14 +2799,14 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE(fn == NULL)) + if (fn == NULL) { Printf("Error: palookup: No filename provided on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } - if (EDUKE32_PREDICT_FALSE(offset < 0)) + if (offset < 0) { Printf("Error: palookup: Invalid file offset on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -2860,7 +2844,7 @@ static int32_t defsparser(scriptfile *script) } else { - if (EDUKE32_PREDICT_FALSE(!(paletteloaded & PALETTE_SHADE))) + if (!(paletteloaded & PALETTE_SHADE)) { Printf("Error: palookup: Shade tables not loaded on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -2876,14 +2860,14 @@ static int32_t defsparser(scriptfile *script) int32_t source; scriptfile_getsymbol(script,&source); - if (EDUKE32_PREDICT_FALSE((unsigned)source >= MAXPALOOKUPS || source == id)) + if ((unsigned)source >= MAXPALOOKUPS || source == id) { Printf("Error: palookup: Invalid source pal number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } - if (EDUKE32_PREDICT_FALSE(source == 0 && !(paletteloaded & PALETTE_SHADE))) + if (source == 0 && !(paletteloaded & PALETTE_SHADE)) { Printf("Error: palookup: Shade tables not loaded on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -2930,7 +2914,7 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE(!(paletteloaded & PALETTE_SHADE))) + if (!(paletteloaded & PALETTE_SHADE)) { Printf("Error: palookup: Shade tables not loaded on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -2984,14 +2968,14 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE((unsigned)remappal >= MAXPALOOKUPS)) + if ((unsigned)remappal >= MAXPALOOKUPS) { Printf("Error: palookup: Invalid remappal on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } - if (EDUKE32_PREDICT_FALSE(!(paletteloaded & PALETTE_SHADE))) + if (!(paletteloaded & PALETTE_SHADE)) { Printf("Error: palookup: Shade tables not loaded on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -3049,7 +3033,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&blockend)) break; - if (EDUKE32_PREDICT_FALSE((unsigned)id >= MAXBLENDTABS)) + if ((unsigned)id >= MAXBLENDTABS) { Printf("Error: blendtable: Invalid blendtable number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -3100,14 +3084,14 @@ static int32_t defsparser(scriptfile *script) } } - if (EDUKE32_PREDICT_FALSE(fn == NULL)) + if (fn == NULL) { Printf("Error: blendtable: No filename provided on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } - if (EDUKE32_PREDICT_FALSE(offset < 0)) + if (offset < 0) { Printf("Error: blendtable: Invalid file offset on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -3145,7 +3129,7 @@ static int32_t defsparser(scriptfile *script) int32_t source; scriptfile_getsymbol(script,&source); - if (EDUKE32_PREDICT_FALSE((unsigned)source >= MAXBLENDTABS || source == id)) + if ((unsigned)source >= MAXBLENDTABS || source == id) { Printf("Error: blendtable: Invalid source blendtable number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -3154,9 +3138,7 @@ static int32_t defsparser(scriptfile *script) didLoadTransluc = 1; -#ifdef USE_OPENGL glblend[id] = glblend[source]; -#endif break; } case T_UNDEF: @@ -3165,9 +3147,7 @@ static int32_t defsparser(scriptfile *script) if (id == 0) paletteloaded &= ~PALETTE_TRANSLUC; -#ifdef USE_OPENGL glblend[id] = defaultglblend; -#endif break; } case T_GLBLEND: @@ -3184,10 +3164,8 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&glblendblockend)) break; -#ifdef USE_OPENGL glblend_t * const glb = glblend + id; *glb = nullglblend; -#endif while (script->textptr < glblendblockend) { @@ -3338,7 +3316,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getsymbol(script,&id1)) break; - if (EDUKE32_PREDICT_FALSE(id0 > id1 || (unsigned)id0 >= MAXBASEPALS || (unsigned)id1 >= MAXBASEPALS)) + if (id0 > id1 || (unsigned)id0 >= MAXBASEPALS || (unsigned)id1 >= MAXBASEPALS) { Printf("Error: undefbasepaletterange: Invalid range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -3361,7 +3339,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getsymbol(script,&id1)) break; - if (EDUKE32_PREDICT_FALSE(id0 > id1 || (unsigned)id0 >= MAXPALOOKUPS || (unsigned)id1 >= MAXPALOOKUPS)) + if (id0 > id1 || (unsigned)id0 >= MAXPALOOKUPS || (unsigned)id1 >= MAXPALOOKUPS) { Printf("Error: undefpalookuprange: Invalid range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -3384,7 +3362,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getsymbol(script,&id1)) break; - if (EDUKE32_PREDICT_FALSE(id0 > id1 || (unsigned)id0 >= MAXBLENDTABS || (unsigned)id1 >= MAXBLENDTABS)) + if (id0 > id1 || (unsigned)id0 >= MAXBLENDTABS || (unsigned)id1 >= MAXBLENDTABS) { Printf("Error: undefblendtablerange: Invalid range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 73fa0b39e..b72c555ac 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -350,7 +350,7 @@ int16_t pointhighlight=-1, linehighlight=-1, highlightcnt=0; int32_t halfxdim16, midydim16; -EDUKE32_STATIC_ASSERT(MAXWALLSB < INT16_MAX); +static_assert(MAXWALLSB < INT16_MAX); int16_t numscans, numbunches; static int16_t numhits; @@ -2115,7 +2115,7 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang) ox = widthBits(globalpicnum); oy = heightBits(globalpicnum); - if (pow2long[ox] != xspan) + if ((1 << ox) != xspan) { ox++; globalx1 = mulscale(globalx1,xspan,ox); @@ -3385,7 +3385,7 @@ int32_t lastwall(int16_t point) * NOTE: The redundant bound checks are expected to be optimized away in the * inlined code. */ -static FORCE_INLINE CONSTEXPR int inside_exclude_p(int32_t const x, int32_t const y, int const sectnum, const uint8_t *excludesectbitmap) +static inline int inside_exclude_p(int32_t const x, int32_t const y, int const sectnum, const uint8_t *excludesectbitmap) { return (sectnum>=0 && !bitmap_test(excludesectbitmap, sectnum) && inside_p(x, y, sectnum)); } @@ -3872,12 +3872,12 @@ static int32_t sectorofwall_internal(int16_t wallNum) int32_t sectorofwall(int16_t wallNum) { - if (EDUKE32_PREDICT_FALSE((unsigned)wallNum >= (unsigned)numwalls)) - return -1; - - native_t const w = wall[wallNum].nextwall; - - return ((unsigned)w < MAXWALLS) ? wall[w].nextsector : sectorofwall_internal(wallNum); + if ((unsigned)wallNum < (unsigned)numwalls) + { + native_t const w = wall[wallNum].nextwall; + return ((unsigned)w < MAXWALLS) ? wall[w].nextsector : sectorofwall_internal(wallNum); + } + return -1; } diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index f870153ed..8afbe75a8 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -216,7 +216,7 @@ int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume, tile2model[tilenume].modelid = modelid; tile2model[tilenume].framenum = i; tile2model[tilenume].skinnum = skinnum; - tile2model[tilenume].smoothduration = Blrintf((float)UINT16_MAX * smoothduration); + tile2model[tilenume].smoothduration = xs_CRoundToInt((float)UINT16_MAX * smoothduration); return i; } @@ -596,7 +596,7 @@ static void updateanimation(md2model_t *m, tspriteptr_t tspr, uint8_t lpal) goto prep_return; } - fps = smooth->mdsmooth ? Blrintf((1.0f / ((float)tile2model[tile].smoothduration * (1.f / (float)UINT16_MAX))) * 66.f) + fps = smooth->mdsmooth ? xs_CRoundToInt((1.0f / ((float)tile2model[tile].smoothduration * (1.f / (float)UINT16_MAX))) * 66.f) : anim ? anim->fpssc : 1; i = (mdtims - sprext->mdanimtims) * ((fps * 120) / 120); diff --git a/source/build/src/mhk.cpp b/source/build/src/mhk.cpp index 2ae88bbb9..732f5729b 100644 --- a/source/build/src/mhk.cpp +++ b/source/build/src/mhk.cpp @@ -129,7 +129,7 @@ int32_t engineLoadMHK(const char *filename) { tok = scriptfile_gettoken(script); if (!tok) break; - for (i=0; legaltokens[i].text; i++) if (!Bstrcasecmp(tok, legaltokens[i].text)) break; + for (i=0; legaltokens[i].text; i++) if (!stricmp(tok, legaltokens[i].text)) break; cmdtokptr = script->ltextptr; if (!filename && legaltokens[i].tokenid != T_LIGHT) continue; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 5198d3e9b..bb6633fb1 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -3028,7 +3028,7 @@ void polymost_drawsprite(int32_t snum) { auto const tspr = tspriteptr[snum]; - if (EDUKE32_PREDICT_FALSE(bad_tspr(tspr))) + if (bad_tspr(tspr)) return; usectorptr_t sec; @@ -3500,7 +3500,7 @@ void polymost_drawsprite(int32_t snum) if (pos.z < globalposz) // if floor sprite is above you, reverse order of points { - EDUKE32_STATIC_ASSERT(sizeof(uint64_t) == sizeof(vec2f_t)); + static_assert(sizeof(uint64_t) == sizeof(vec2f_t)); swap64bit(&pxy[0], &pxy[1]); swap64bit(&pxy[2], &pxy[3]); @@ -3632,7 +3632,7 @@ _drawsprite_return: ; } -EDUKE32_STATIC_ASSERT((int)RS_YFLIP == (int)HUDFLAG_FLIPPED); +static_assert((int)RS_YFLIP == (int)HUDFLAG_FLIPPED); void polymost_initosdfuncs(void) { diff --git a/source/build/src/scriptfile.cpp b/source/build/src/scriptfile.cpp index 48af3576b..0db34e132 100644 --- a/source/build/src/scriptfile.cpp +++ b/source/build/src/scriptfile.cpp @@ -381,7 +381,7 @@ int32_t scriptfile_getsymbolvalue(char const *name, int32_t *val) uint64_t x; sscanf(name + 2, "%" PRIx64 "", &x); - if (EDUKE32_PREDICT_FALSE(x > UINT32_MAX)) + if (x > UINT32_MAX) Printf("warning: number 0x%" PRIx64 " truncated to 32 bits.\n", x); *val = x; @@ -393,7 +393,7 @@ int32_t scriptfile_getsymbolvalue(char const *name, int32_t *val) if (!symbtab) return 0; while (scanner - symbtab < symbtablength) { - if (!Bstrcasecmp(name, scanner)) + if (!stricmp(name, scanner)) { *val = B_UNBUF32(scanner + strlen(scanner) + 1); return 1; @@ -415,7 +415,7 @@ int32_t scriptfile_addsymbolvalue(char const *name, int32_t val) char *scanner = symbtab; while (scanner - symbtab < symbtablength) { - if (!Bstrcasecmp(name, scanner)) + if (!stricmp(name, scanner)) { B_BUF32(scanner + strlen(scanner) + 1, val); return 1; @@ -451,7 +451,7 @@ int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens) for (i=ntokens-1; i>=0; i--) { - if (!Bstrcasecmp(tok, tl[i].text)) + if (!stricmp(tok, tl[i].text)) return tl[i].tokenid; } return T_ERROR; diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 3c9b41f05..b5471a60e 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -867,10 +867,10 @@ voxmodel_t *voxload(const char *filnam) if (i < 0) return NULL; - if (!Bstrcasecmp(&filnam[i], ".vox")) { ret = loadvox(filnam); is8bit = 1; } - else if (!Bstrcasecmp(&filnam[i], ".kvx")) { ret = loadkvx(filnam); is8bit = 1; } - else if (!Bstrcasecmp(&filnam[i], ".kv6")) { ret = loadkv6(filnam); is8bit = 0; } - //else if (!Bstrcasecmp(&filnam[i],".vxl")) { ret = loadvxl(filnam); is8bit = 0; } + if (!stricmp(&filnam[i], ".vox")) { ret = loadvox(filnam); is8bit = 1; } + else if (!stricmp(&filnam[i], ".kvx")) { ret = loadkvx(filnam); is8bit = 1; } + else if (!stricmp(&filnam[i], ".kv6")) { ret = loadkv6(filnam); is8bit = 0; } + //else if (!stricmp(&filnam[i],".vxl")) { ret = loadvxl(filnam); is8bit = 0; } else return NULL; voxmodel_t *const vm = (ret >= 0) ? vox2poly() : NULL; diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 1472be452..ca53cc2db 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -82,11 +82,6 @@ struct UserConfig bool nologo = false; int setupstate = -1; - int netPort = 0; // g_netPort = Batoi(argv[i + 1]); - int netServerMode = -1; // g_networkMode = NET_SERVER; g_noSetup = g_noLogo = TRUE; - FString netServerAddress; // Net_Connect(argv[i + 1]); g_noSetup = g_noLogo = TRUE; - FString netPassword; // Bstrncpyz(g_netPassword, argv[i + 1], sizeof(g_netPassword)); - void ProcessOptions(); }; diff --git a/source/core/searchpaths.cpp b/source/core/searchpaths.cpp index 45e37d276..9cc739cca 100644 --- a/source/core/searchpaths.cpp +++ b/source/core/searchpaths.cpp @@ -957,7 +957,7 @@ bool AddINIFile(const char* pzFile, bool bForce = false) Bstrncpy(pINIIter->zName, pzFile, BMAX_PATH); for (int i = 0; i < countof(gINIDescription); i++) { - if (!Bstrncasecmp(pINIIter->zName, gINIDescription[i].pzFilename, BMAX_PATH)) + if (!strnicmp(pINIIter->zName, gINIDescription[i].pzFilename, BMAX_PATH)) { pINIIter->pDescription = &gINIDescription[i]; break; @@ -985,7 +985,7 @@ void ScanINIFiles(void) pINISelected = pINIChain; for (auto pIter = pINIChain; pIter; pIter = pIter->pNext) { - if (!Bstrncasecmp(BloodIniFile, pIter->zName, BMAX_PATH)) + if (!strnicmp(BloodIniFile, pIter->zName, BMAX_PATH)) { pINISelected = pIter; break; diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index bd221d719..9faac17cb 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -263,7 +263,7 @@ void PlayerInterruptKeys(bool after) // so we convert horiz to 1024 angle units float const horizAngle = clamp(atan2f(PlayerList[nLocalPlayer].q16horiz - IntToFixed(92), IntToFixed(128)) * (512.f / fPI) + FixedToFloat(tempinput.q16horz), -255.f, 255.f); - auto newq16horiz = IntToFixed(92) + Blrintf(IntToFixed(128) * tanf(horizAngle * (fPI / 512.f))); + auto newq16horiz = IntToFixed(92) + xs_CRoundToInt(IntToFixed(128) * tanf(horizAngle * (fPI / 512.f))); if (PlayerList[nLocalPlayer].q16horiz != newq16horiz) { bLockPan = true; diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index e0ec496b6..01c21b877 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -356,7 +356,7 @@ void DrawView(double smoothRatio, bool sceneonly) static uint8_t sectorCeilingPal[MAXSECTORS]; static uint8_t wallPal[MAXWALLS]; int const viewingRange = viewingrange; - int const vr = Blrintf(65536.f * tanf(r_fov * (fPI / 360.f))); + int const vr = xs_CRoundToInt(65536.f * tanf(r_fov * (fPI / 360.f))); videoSetCorrectedAspect(); diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 07c869e89..52ccfacf8 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -804,7 +804,7 @@ analyzesprites(int viewx, int viewy, int viewz, SWBOOL mirror) if (OverlapDraw && FAF_ConnectArea(tsp->sectnum) && tsp->owner >= 0) { - EDUKE32_STATIC_ASSERT(sizeof(uspritetype) == sizeof(tspritetype)); // see TSPRITE_SIZE + static_assert(sizeof(uspritetype) == sizeof(tspritetype)); // see TSPRITE_SIZE ConnectCopySprite((uspriteptr_t)tsp); } @@ -1787,7 +1787,7 @@ drawscreen(PLAYERp pp, double smoothratio) videoSetCorrectedAspect(); - renderSetAspect(Blrintf(float(viewingrange)* tanf(r_fov* (fPI / 360.f))), yxaspect); + renderSetAspect(xs_CRoundToInt(double(viewingrange)* tan(r_fov* (PI / 360.))), yxaspect); OverlapDraw = TRUE; DrawOverlapRoom(tx, ty, tz, tq16ang, tq16horiz, tsectnum); OverlapDraw = FALSE; diff --git a/source/sw/src/saveable.h b/source/sw/src/saveable.h index 0a288d058..97992360a 100644 --- a/source/sw/src/saveable.h +++ b/source/sw/src/saveable.h @@ -44,7 +44,7 @@ typedef struct } saveable_module; template -static FORCE_INLINE constexpr enable_if_t::value, size_t> SAVE_SIZEOF(T const & obj) noexcept +constexpr enable_if_t::value, size_t> SAVE_SIZEOF(T const & obj) noexcept { return sizeof(obj); } diff --git a/source/sw/src/scrip2.cpp b/source/sw/src/scrip2.cpp index 8ea9aa3e6..5fc3dcd96 100644 --- a/source/sw/src/scrip2.cpp +++ b/source/sw/src/scrip2.cpp @@ -419,7 +419,7 @@ static int cm_transtok(const char *tok, const struct _tokset *set, const unsigne for (i=0; i