diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index b20700de4..a5cceb139 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -434,7 +434,7 @@ int32_t baselayer_init(void) #endif }; - for (i=0; i>14); if (dax >= lborder) { - if (fillcnt == sizeof(fillist)/sizeof(fillist[0])) + if (fillcnt == ARRAY_SIZE(fillist)) break; fillist[fillcnt++] = dax; diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index 1386badf8..f6b5a58cd 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -278,7 +278,7 @@ static int32_t defsparser(scriptfile *script) } #endif if (quitevent) return 0; - tokn = getatoken(script,basetokens,sizeof(basetokens)/sizeof(tokenlist)); + tokn = getatoken(script,basetokens,ARRAY_SIZE(basetokens)); cmdtokptr = script->ltextptr; switch (tokn) { @@ -567,7 +567,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&textureend)) break; while (script->textptr < textureend) { - int32_t token = getatoken(script,tilefromtexturetokens,sizeof(tilefromtexturetokens)/sizeof(tokenlist)); + int32_t token = getatoken(script,tilefromtexturetokens,ARRAY_SIZE(tilefromtexturetokens)); switch (token) { case T_FILE: @@ -969,7 +969,7 @@ static int32_t defsparser(scriptfile *script) #endif while (script->textptr < modelend) { - int32_t token = getatoken(script,modeltokens,sizeof(modeltokens)/sizeof(tokenlist)); + int32_t token = getatoken(script,modeltokens,ARRAY_SIZE(modeltokens)); switch (token) { //case T_ERROR: initprintf("Error on line %s:%d in model tokens\n", script->filename,script->linenum); break; @@ -1008,7 +1008,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&frameend)) break; while (script->textptr < frameend) { - switch (getatoken(script,modelframetokens,sizeof(modelframetokens)/sizeof(tokenlist))) + switch (getatoken(script,modelframetokens,ARRAY_SIZE(modelframetokens))) { case T_PAL: scriptfile_getnumber(script,&pal); break; @@ -1085,7 +1085,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&animend)) break; while (script->textptr < animend) { - switch (getatoken(script,modelanimtokens,sizeof(modelanimtokens)/sizeof(tokenlist))) + switch (getatoken(script,modelanimtokens,ARRAY_SIZE(modelanimtokens))) { case T_FRAME0: scriptfile_getstring(script,&startframe); break; @@ -1159,7 +1159,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&skinend)) break; while (script->textptr < skinend) { - switch (getatoken(script,modelskintokens,sizeof(modelskintokens)/sizeof(tokenlist))) + switch (getatoken(script,modelskintokens,ARRAY_SIZE(modelskintokens))) { case T_PAL: scriptfile_getsymbol(script,&palnum); break; @@ -1262,7 +1262,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&frameend)) break; while (script->textptr < frameend) { - switch (getatoken(script,modelhudtokens,sizeof(modelhudtokens)/sizeof(tokenlist))) + switch (getatoken(script,modelhudtokens,ARRAY_SIZE(modelhudtokens))) { case T_TILE: scriptfile_getsymbol(script,&ftilenume); ltilenume = ftilenume; break; @@ -1399,7 +1399,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&modelend)) break; while (script->textptr < modelend) { - switch (getatoken(script,voxeltokens,sizeof(voxeltokens)/sizeof(tokenlist))) + switch (getatoken(script,voxeltokens,ARRAY_SIZE(voxeltokens))) { //case T_ERROR: initprintf("Error on line %s:%d in voxel tokens\n", script->filename,linenum); break; case T_TILE: @@ -1463,7 +1463,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&modelend)) break; while (script->textptr < modelend) { - switch (getatoken(script,skyboxtokens,sizeof(skyboxtokens)/sizeof(tokenlist))) + switch (getatoken(script,skyboxtokens,ARRAY_SIZE(skyboxtokens))) { //case T_ERROR: initprintf("Error on line %s:%d in skybox tokens\n",script->filename,linenum); break; case T_TILE: @@ -1520,7 +1520,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&highpalend)) break; while (script->textptr < highpalend) { - switch (getatoken(script,highpaltokens,sizeof(highpaltokens)/sizeof(tokenlist))) + switch (getatoken(script,highpaltokens,ARRAY_SIZE(highpaltokens))) { case T_BASEPAL: scriptfile_getsymbol(script,&basepal); break; @@ -1614,7 +1614,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&tintend)) break; while (script->textptr < tintend) { - switch (getatoken(script,tinttokens,sizeof(tinttokens)/sizeof(tokenlist))) + switch (getatoken(script,tinttokens,ARRAY_SIZE(tinttokens))) { case T_PAL: scriptfile_getsymbol(script,&pal); break; @@ -1661,7 +1661,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&endtextptr)) break; while (script->textptr < endtextptr) { - switch (getatoken(script, palookuptokens, sizeof(palookuptokens)/sizeof(tokenlist))) + switch (getatoken(script, palookuptokens, ARRAY_SIZE(palookuptokens))) { case T_PAL: scriptfile_getsymbol(script, &pal); @@ -1750,7 +1750,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&textureend)) break; while (script->textptr < textureend) { - token = getatoken(script,texturetokens,sizeof(texturetokens)/sizeof(tokenlist)); + token = getatoken(script,texturetokens,ARRAY_SIZE(texturetokens)); switch (token) { case T_PAL: @@ -1780,7 +1780,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&palend)) break; while (script->textptr < palend) { - switch (getatoken(script,texturetokens_pal,sizeof(texturetokens_pal)/sizeof(tokenlist))) + switch (getatoken(script,texturetokens_pal,ARRAY_SIZE(texturetokens_pal))) { case T_FILE: scriptfile_getstring(script,&fn); break; @@ -1867,7 +1867,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&detailend)) break; while (script->textptr < detailend) { - switch (getatoken(script,texturetokens_pal,sizeof(texturetokens_pal)/sizeof(tokenlist))) + switch (getatoken(script,texturetokens_pal,ARRAY_SIZE(texturetokens_pal))) { case T_FILE: scriptfile_getstring(script,&fn); break; @@ -2075,7 +2075,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&dummy)) break; while (script->textptr < dummy) { - switch (getatoken(script,sound_musictokens,sizeof(sound_musictokens)/sizeof(tokenlist))) + switch (getatoken(script,sound_musictokens,ARRAY_SIZE(sound_musictokens))) { case T_ID: scriptfile_getstring(script,&dummy2); @@ -2102,7 +2102,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getbraces(script,&dummy)) break; while (script->textptr < dummy) { - switch (getatoken(script,mapinfotokens,sizeof(mapinfotokens)/sizeof(tokenlist))) + switch (getatoken(script,mapinfotokens,ARRAY_SIZE(mapinfotokens))) { case T_MAPFILE: scriptfile_getstring(script,&dummy2); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 6bdf4c7df..807484260 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -7833,7 +7833,7 @@ static void dosetaspect(void) { j = (x&65535); k = (x>>16); x += xinc; - if (k < 0 || k >= (int32_t)(sizeof(radarang)/sizeof(radarang[0]))-1) + if (k < 0 || k >= (int32_t)ARRAY_SIZE(radarang)-1) { no_radarang2 = 1; #ifdef DEBUGGINGAIDS @@ -7848,7 +7848,7 @@ static void dosetaspect(void) radarang2[i] = (int16_t)((radarang[k]+j)>>6); } - for (i=1; i<(int32_t)(sizeof(distrecip)/sizeof(distrecip[0])); i++) + for (i=1; i<(int32_t)ARRAY_SIZE(distrecip); i++) distrecip[i] = divscale20(xdimen,i); nytooclose = xdimen*2100; @@ -8718,7 +8718,7 @@ int32_t preinitengine(void) // Bprintf("FIXME: Allocating additional space beyond wall[] for editor bugs.\n"); } - for (i=0; i<(signed)(sizeof(dynarray)/sizeof(dynarray[0])); i++) + for (i=0; i<(signed)ARRAY_SIZE(dynarray); i++) size += dynarray[i].size; if ((blockptr = Bcalloc(1, size)) == NULL) @@ -8726,7 +8726,7 @@ int32_t preinitengine(void) size = 0; - for (i=0; i<(signed)(sizeof(dynarray)/sizeof(dynarray[0])); i++) + for (i=0; i<(signed)ARRAY_SIZE(dynarray); i++) { *dynarray[i].ptr = (int8_t *)blockptr + size; size += dynarray[i].size; diff --git a/polymer/eduke32/build/src/kplib.c b/polymer/eduke32/build/src/kplib.c index 0a8f1c0bb..b39c607d3 100644 --- a/polymer/eduke32/build/src/kplib.c +++ b/polymer/eduke32/build/src/kplib.c @@ -2652,7 +2652,7 @@ static int32_t kzcalchash(const char *st) if (ch == '/') ch = '\\'; hashind = (ch - hashind*3); } - return(hashind%(sizeof(kzhashead)/sizeof(kzhashead[0]))); + return(hashind%ARRAY_SIZE(kzhashead)); } static int32_t kzcheckhash(const char *filnam, char **zipnam, int32_t *fileoffs, int32_t *fileleng, char *iscomp) diff --git a/polymer/eduke32/build/src/osd.c b/polymer/eduke32/build/src/osd.c index c4a28b689..63dc6cb85 100644 --- a/polymer/eduke32/build/src/osd.c +++ b/polymer/eduke32/build/src/osd.c @@ -780,7 +780,7 @@ void OSD_Init(void) hash_init(&h_osd); hash_init(&h_cvars); - for (i=0; i=0 && lotag<(int32_t)(sizeof(tags)/sizeof(tags[0]))) + if (lotag>=0 && lotag<(int32_t)ARRAY_SIZE(tags)) Bsprintf(tempbuf, "%d: %s", lotag, tags[lotag]); else switch (lotag) @@ -4100,7 +4100,7 @@ restart: k = (mousex || mousey || mouseb); if (!k) - for (i=0; i<(signed)(sizeof(keystatus)/sizeof(keystatus[0])); i++) + for (i=0; i<(signed)ARRAY_SIZE(keystatus); i++) if (keystatus[i]) { k = 1; @@ -9682,7 +9682,7 @@ static int32_t parsegroupfiles(scriptfile *script) while (1) { - tokn = getatoken(script,grptokens,sizeof(grptokens)/sizeof(tokenlist)); + tokn = getatoken(script,grptokens,ARRAY_SIZE(grptokens)); cmdtokptr = script->ltextptr; switch (tokn) { @@ -9771,7 +9771,7 @@ int32_t parsetilegroups(scriptfile *script) while (1) { - tokn = getatoken(script,tgtokens,sizeof(tgtokens)/sizeof(tokenlist)); + tokn = getatoken(script,tgtokens,ARRAY_SIZE(tgtokens)); cmdtokptr = script->ltextptr; switch (tokn) { @@ -9841,7 +9841,7 @@ int32_t parsetilegroups(scriptfile *script) { "colors", T_COLORS }, }; - int32_t token = getatoken(script,tgtokens2,sizeof(tgtokens2)/sizeof(tokenlist)); + int32_t token = getatoken(script,tgtokens2,ARRAY_SIZE(tgtokens2)); switch (token) { case T_TILE: @@ -9938,7 +9938,7 @@ int32_t parsetilegroups(scriptfile *script) { "offseta", T_OFFSETA }, }; - int32_t token = getatoken(script,alphtokens2,sizeof(alphtokens2)/sizeof(tokenlist)); + int32_t token = getatoken(script,alphtokens2,ARRAY_SIZE(alphtokens2)); switch (token) { case T_MAP: // map , e.g. map 46 3002 @@ -10145,7 +10145,7 @@ static int32_t parseconsounds(scriptfile *script) while (1) { - tokn = getatoken(script,cstokens,sizeof(cstokens)/sizeof(tokenlist)); + tokn = getatoken(script,cstokens,ARRAY_SIZE(cstokens)); cmdtokptr = script->ltextptr; switch (tokn) { @@ -11323,7 +11323,7 @@ void ExtCheckKeys(void) int32_t i; // check keys so that e.g. bulk deletions won't produce // as much revisions as deleted sprites - for (i=sizeof(keystatus)/sizeof(keystatus[0])-1; i>=0; i--) + for (i=ARRAY_SIZE(keystatus)-1; i>=0; i--) if (keystatus[i]) break; if (i==-1) diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 2f148db7d..660d32580 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -156,7 +156,7 @@ void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN]) CONTROL_ClearAllBinds(); - for (i=0; i < (int32_t)(sizeof(keydefaults)/sizeof(keydefaults[0])); i+=3) + for (i=0; i < (int32_t)ARRAY_SIZE(keydefaults); i+=3) { f = CONFIG_FunctionNameToNum(keyptr[i+0]); if (f == -1) continue; @@ -342,7 +342,7 @@ void CONFIG_MapKey(int32_t which, kb_scancode key1, kb_scancode oldkey1, kb_scan if (which == gamefunc_Show_Console) OSD_CaptureKey(key1); - for (k = 0; (unsigned)k < (sizeof(ii) / sizeof(ii[0])); k++) + for (k = 0; (unsigned)k < ARRAY_SIZE(ii); k++) { if (ii[k] == 0xff || !ii[k]) continue; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index ecb495bfd..712841cca 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -9307,7 +9307,7 @@ static int32_t parsedefinitions_game(scriptfile *script, int32_t preload) while (1) { - tokn = getatoken(script,tokens,sizeof(tokens)/sizeof(tokenlist)); + tokn = getatoken(script,tokens,ARRAY_SIZE(tokens)); cmdtokptr = script->ltextptr; switch (tokn) { @@ -9366,7 +9366,7 @@ static int32_t parsedefinitions_game(scriptfile *script, int32_t preload) if (scriptfile_getbraces(script,&musicend)) break; while (script->textptr < musicend) { - switch (getatoken(script,sound_musictokens,sizeof(sound_musictokens)/sizeof(tokenlist))) + switch (getatoken(script,sound_musictokens,ARRAY_SIZE(sound_musictokens))) { case T_ID: scriptfile_getstring(script,&ID); @@ -9547,7 +9547,7 @@ static int32_t parsedefinitions_game(scriptfile *script, int32_t preload) if (scriptfile_getbraces(script,&musicend)) break; while (script->textptr < musicend) { - switch (getatoken(script,sound_musictokens,sizeof(sound_musictokens)/sizeof(tokenlist))) + switch (getatoken(script,sound_musictokens,ARRAY_SIZE(sound_musictokens))) { case T_ID: scriptfile_getsymbol(script,&num); diff --git a/polymer/eduke32/source/game.h b/polymer/eduke32/source/game.h index 8aa78351d..5ad78f4bb 100644 --- a/polymer/eduke32/source/game.h +++ b/polymer/eduke32/source/game.h @@ -384,7 +384,7 @@ static inline int32_t G_GetTeamPalette(int32_t team) { int8_t pal[] = { 3, 10, 11, 12 }; - if ((unsigned)team >= (sizeof(pal)/sizeof(pal[0]))) + if ((unsigned)team >= ARRAY_SIZE(pal)) return 0; return pal[team]; diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index fc02b0c10..7b5af6676 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -36,14 +36,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #endif -#define NUMKEYWORDS (int32_t)(sizeof(keyw)/sizeof(keyw[0])) +#define NUMKEYWORDS (int32_t)ARRAY_SIZE(keyw) int32_t g_scriptVersion = 13; // 13 = 1.3D-style CON files, 14 = 1.4/1.5 style CON files uint32_t g_scriptDateVersion = 99999999; // YYYYMMDD #if !defined LUNATIC static uint32_t g_scriptLastKeyword; // = NUMKEYWORDS-1; -#define NUMKEYWDATES (int32_t)(sizeof(g_keywdate)/sizeof(g_keywdate[0])) +#define NUMKEYWDATES (int32_t)ARRAY_SIZE(g_keywdate) // { keyw, date } means that at the date, all keywords up to keyw inclusive are available static struct { uint32_t keyw; uint32_t date; } g_keywdate[] = { @@ -2448,14 +2448,14 @@ void C_InitQuotes(void) "^02%s^02 bled out", }; - g_numObituaries = (sizeof(PlayerObituaries)/sizeof(PlayerObituaries[0])); + g_numObituaries = ARRAY_SIZE(PlayerObituaries); for (i=g_numObituaries-1; i>=0; i--) { if (C_AllocQuote(i+OBITQUOTEINDEX)) Bstrcpy(ScriptQuotes[i+OBITQUOTEINDEX],PlayerObituaries[i]); } - g_numSelfObituaries = (sizeof(PlayerSelfObituaries)/sizeof(PlayerSelfObituaries[0])); + g_numSelfObituaries = ARRAY_SIZE(PlayerObituaries); for (i=g_numSelfObituaries-1; i>=0; i--) { if (C_AllocQuote(i+SUICIDEQUOTEINDEX)) diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index cca295be3..dfcc49b64 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define LABEL_ISSTRING 2 #define MAXCHEATLEN 20 -#define NUMCHEATCODES (int32_t)(sizeof(CheatStrings)/sizeof(CheatStrings[0])) +#define NUMCHEATCODES (int32_t)ARRAY_SIZE(CheatStrings) extern hashtable_t h_gamefuncs; diff --git a/polymer/eduke32/source/grpscan.c b/polymer/eduke32/source/grpscan.c index a40b02db3..c31f6b302 100644 --- a/polymer/eduke32/source/grpscan.c +++ b/polymer/eduke32/source/grpscan.c @@ -93,7 +93,7 @@ static void LoadList(const char * filename) { "grpinfo", T_GRPINFO }, }; - int32_t token = getatoken(script,profiletokens,sizeof(profiletokens)/sizeof(tokenlist)); + int32_t token = getatoken(script,profiletokens,ARRAY_SIZE(profiletokens)); switch (token) { case T_GRPINFO: @@ -117,7 +117,7 @@ static void LoadList(const char * filename) while (script->textptr < grpend) { - int32_t token = getatoken(script,grpinfotokens,sizeof(grpinfotokens)/sizeof(tokenlist)); + int32_t token = getatoken(script,grpinfotokens,ARRAY_SIZE(grpinfotokens)); switch (token) { diff --git a/polymer/eduke32/source/jmact/keyboard.c b/polymer/eduke32/source/jmact/keyboard.c index 31b49faa5..53e395857 100644 --- a/polymer/eduke32/source/jmact/keyboard.c +++ b/polymer/eduke32/source/jmact/keyboard.c @@ -161,7 +161,7 @@ const char *KB_ScanCodeToString(kb_scancode scancode) { uint32_t s; - for (s=0; s < (sizeof(sctokeylut)/sizeof(sctokeylut[0])); s++) + for (s=0; s < ARRAY_SIZE(sctokeylut); s++) if (sctokeylut[s].sc == scancode) return sctokeylut[s].key; return ""; @@ -171,7 +171,7 @@ kb_scancode KB_StringToScanCode(const char * string) { uint32_t s; - for (s=0; s < (sizeof(sctokeylut)/sizeof(sctokeylut[0])); s++) + for (s=0; s < ARRAY_SIZE(sctokeylut); s++) if (!Bstrcasecmp(sctokeylut[s].key, string)) return sctokeylut[s].sc; return 0; diff --git a/polymer/eduke32/source/m32def.c b/polymer/eduke32/source/m32def.c index 303475634..5268469ba 100644 --- a/polymer/eduke32/source/m32def.c +++ b/polymer/eduke32/source/m32def.c @@ -131,8 +131,8 @@ static const char *C_GetLabelType(int32_t type) return strdup(x); } -#define NUMKEYWORDS (int32_t)(sizeof(keyw)/sizeof(keyw[0])) -#define NUMALTKEYWORDS (int32_t)(sizeof(altkeyw)/sizeof(altkeyw[0])) +#define NUMKEYWORDS (int32_t)ARRAY_SIZE(keyw) +#define NUMALTKEYWORDS (int32_t)ARRAY_SIZE(altkeyw) const tokenmap_t altkeyw[] = { @@ -3677,7 +3677,7 @@ void C_CompilationInfo(void) initprintf(" %d/%d quotes, %d/%d quote redefinitions\n", k,MAXQUOTES, g_numQuoteRedefinitions,MAXQUOTES); } -EDUKE32_STATIC_ASSERT((sizeof(keyw)/sizeof(keyw[0]))-1 == CON_END); +EDUKE32_STATIC_ASSERT(ARRAY_SIZE(keyw)-1 == CON_END); void C_Compile(const char *filenameortext, int32_t isfilename) { diff --git a/polymer/eduke32/source/m32exec.c b/polymer/eduke32/source/m32exec.c index ba8161fdb..51a6ae805 100644 --- a/polymer/eduke32/source/m32exec.c +++ b/polymer/eduke32/source/m32exec.c @@ -1471,7 +1471,7 @@ badindex: insptr++; { int32_t key=Gv_GetVarX(*insptr); - if (key<0 || key >= (int32_t)(sizeof(keystatus)/sizeof(keystatus[0]))) + if (key<0 || key >= (int32_t)ARRAY_SIZE(keystatus)) { M32_ERROR("Invalid key %d!", key); continue; diff --git a/polymer/eduke32/source/mapster32.h b/polymer/eduke32/source/mapster32.h index df889d468..5bc2fda34 100644 --- a/polymer/eduke32/source/mapster32.h +++ b/polymer/eduke32/source/mapster32.h @@ -111,7 +111,7 @@ static const int32_t ZoomToThumbSize[] = FUCKING_GOOD_EYESIGHT, 32, 64, 128, 192, 256, 384, 512 }; -#define NUM_ZOOMS (sizeof(ZoomToThumbSize)/sizeof(ZoomToThumbSize[0])) +#define NUM_ZOOMS ARRAY_SIZE(ZoomToThumbSize) #define INITIAL_ZOOM 2 typedef struct diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 6967cc62f..35c2e8376 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -594,7 +594,7 @@ void G_CheckPlayerColor(int32_t *color, int32_t prev_color) { int32_t i, disallowed[] = { 1, 2, 3, 4, 5, 6, 7, 8, 17, 18, 19, 20, 22 }; - for (i=0; i<(signed)(sizeof(disallowed)/sizeof(disallowed[0])); i++) + for (i=0; i<(signed)ARRAY_SIZE(disallowed); i++) { while (*color == disallowed[i]) { @@ -2552,7 +2552,7 @@ cheat_for_port_credits2: { double ratios[] = { 0.0, 1.33, 1.66, 1.78, 1.85, 2.35 }; - int32_t j = (sizeof(ratios)/sizeof(ratios[0])); + int32_t j = ARRAY_SIZE(ratios); for (i = 0; i= REND_POLYMOST)<<17)|(fullscreen<<16)|bpp)) break; - if (dax < (int32_t)(sizeof(vidsets)/sizeof(vidsets[1]))) newvidset = dax; + if (dax < (int32_t)ARRAY_SIZE(vidsets)) newvidset = dax; curvidset = newvidset; M_ChangeMenu(MENU_VIDEOSETUP); @@ -3256,7 +3256,7 @@ cheat_for_port_credits2: while (vidsets[0] != -1) { newvidset++; - if (newvidset == sizeof(vidsets)/sizeof(vidsets[0]) || vidsets[newvidset] == -1) + if (newvidset == ARRAY_SIZE(vidsets) || vidsets[newvidset] == -1) { newvidset = -1; continue; @@ -3320,7 +3320,7 @@ cheat_for_port_credits2: { newvidset++; if (newvidset == lastvidset) break; - if (newvidset == sizeof(vidsets)/sizeof(vidsets[0]) || vidsets[newvidset] == -1) + if (newvidset == ARRAY_SIZE(vidsets) || vidsets[newvidset] == -1) { newvidset = -1; continue; @@ -4603,7 +4603,7 @@ cheat_for_port_credits2: case 4: { int32_t rates[] = { 22050, 24000, 32000, 44100, 48000 }; - int32_t j = (sizeof(rates)/sizeof(rates[0])); + int32_t j = ARRAY_SIZE(rates); for (i = 0; i=0; i--) + for (i = ARRAY_SIZE(s)-1; i>=0; i--) { fp = Bfopen(s[i], "r"); if (fp == NULL) @@ -246,7 +246,7 @@ fallback: if (i == 0) { initprintf("Error: couldn't open any of the following files:\n"); - for (i = (sizeof(s)/sizeof(s[0]))-1; i>=0; i--) + for (i = ARRAY_SIZE(s)-1; i>=0; i--) initprintf("%s\n",s[i]); return(MUSIC_Error); } diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 0372bddfa..dd25ff1f9 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -188,7 +188,7 @@ void S_MenuSound(void) SELECT_WEAPON, }; - S_PlaySound(menusnds[SoundNum++ % (sizeof(menusnds)/sizeof(menusnds[0]))]); + S_PlaySound(menusnds[SoundNum++ % ARRAY_SIZE(menusnds)]); } int32_t S_PlayMusic(const char *fn, const int32_t sel)