Widespread use of ARRAY_SIZE macro.

git-svn-id: https://svn.eduke32.com/eduke32@4385 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2014-03-22 09:25:15 +00:00
parent 057c5c9356
commit ba0c64971c
27 changed files with 78 additions and 78 deletions

View file

@ -434,7 +434,7 @@ int32_t baselayer_init(void)
#endif
};
for (i=0; i<sizeof(cvars_engine)/sizeof(cvars_engine[0]); i++)
for (i=0; i<ARRAY_SIZE(cvars_engine); i++)
{
if (OSD_RegisterCvar(&cvars_engine[i]))
continue;

View file

@ -9730,7 +9730,7 @@ int32_t fillsector(int16_t sectnum, int32_t fillcolor)
if (y1 <= sy && sy < y2)
{
if (fillcnt == sizeof(fillist)/sizeof(fillist[0]))
if (fillcnt == ARRAY_SIZE(fillist))
break;
x1 += scale(sy-y1, x2-x1, y2-y1);
@ -9755,7 +9755,7 @@ int32_t fillsector(int16_t sectnum, int32_t fillcolor)
dax = halfxdim16 + (((dax-pos.x)*zoom)>>14);
if (dax >= lborder)
{
if (fillcnt == sizeof(fillist)/sizeof(fillist[0]))
if (fillcnt == ARRAY_SIZE(fillist))
break;
fillist[fillcnt++] = dax;

View file

@ -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);

View file

@ -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;

View file

@ -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)

View file

@ -780,7 +780,7 @@ void OSD_Init(void)
hash_init(&h_osd);
hash_init(&h_cvars);
for (i=0; i<sizeof(cvars_osd)/sizeof(cvars_osd[0]); i++)
for (i=0; i<ARRAY_SIZE(cvars_osd); i++)
{
if (OSD_RegisterCvar(&cvars_osd[i]))
continue;

View file

@ -5216,7 +5216,7 @@ void polymost_initosdfuncs(void)
#endif
};
for (i=0; i<sizeof(cvars_polymost)/sizeof(cvars_polymost[0]); i++)
for (i=0; i<ARRAY_SIZE(cvars_polymost); i++)
{
// can't do this: editstatus is set after this function
// if (editstatus==0 && !Bstrcmp(cvars_polymost[i].name, "r_preview_mouseaim"))

View file

@ -326,7 +326,7 @@ static void sighandler(int signum)
{
void *addr[32];
int32_t errfd = fileno(stderr);
int32_t n=backtrace(addr, sizeof(addr)/sizeof(addr[0]));
int32_t n=backtrace(addr, ARRAY_SIZE(addr));
backtrace_symbols_fd(addr, n, errfd);
}
// This is useful for attaching the debugger post-mortem. For those pesky
@ -1391,7 +1391,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
x,y,c, ((fs&1) ? "fullscreen" : "windowed"));
do
{
for (i=0; i < (int32_t)(sizeof(attributes)/sizeof(attributes[0])); i++)
for (i=0; i < (int32_t)ARRAY_SIZE(attributes); i++)
{
j = attributes[i].value;
if (!multisamplecheck &&

View file

@ -202,7 +202,7 @@ void win_init(void)
{ "r_togglecomposition","enable/disable toggle of desktop composition when initializing screen modes",(void *) &togglecomp, CVAR_BOOL, 0, 1 },
};
for (i=0; i<sizeof(cvars_win)/sizeof(cvars_win[0]); i++)
for (i=0; i<ARRAY_SIZE(cvars_win); i++)
{
if (OSD_RegisterCvar(&cvars_win[i]))
continue;

View file

@ -288,7 +288,7 @@ static void SignalHandler(int32_t signum)
static void divcommon(int32_t *ap, int32_t *bp)
{
const int32_t p[] = {2,3,5,7,11,13,17,19};
const int32_t N = (int32_t)(sizeof(p)/sizeof(p[0]));
const int32_t N = (int32_t)ARRAY_SIZE(p);
int32_t a=*ap, b=*bp;
while (1)

View file

@ -617,7 +617,7 @@ int32_t map_undoredo(int32_t dir)
#endif
#define M32_NUM_SPRITE_MODES ((signed)(sizeof(SpriteMode)/sizeof(SpriteMode[0])))
#define M32_NUM_SPRITE_MODES (signed)ARRAY_SIZE(SpriteMode)
static const char *SpriteMode[]=
{
"NONE",
@ -650,7 +650,7 @@ static const char *SPRDSPMODE[MAXNOSPRITES]=
"Sprite display: NO EFFECTORS OR ACTORS"
};
#define MAXHELP3D ((signed)(sizeof(Help3d)/sizeof(Help3d[0])))
#define MAXHELP3D (signed)ARRAY_SIZE(Help3d)
static const char *Help3d[]=
{
"Mapster32 3D mode help",
@ -1321,7 +1321,7 @@ const char *SectorEffectorTagText(int32_t lotag)
Bmemset(tempbuf,0,sizeof(tempbuf));
if (lotag>=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 <ascii num> <start tilenum>, 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)

View file

@ -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;

View file

@ -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);

View file

@ -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];

View file

@ -36,14 +36,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <shellapi.h>
#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))

View file

@ -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;

View file

@ -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)
{

View file

@ -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;

View file

@ -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)
{

View file

@ -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;

View file

@ -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

View file

@ -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<j; i++)
if (ratios[i] == pr_customaspect)
@ -3148,7 +3148,7 @@ cheat_for_port_credits2:
dax = 0;
for (day = 0; day < validmodecnt; day++)
{
if (dax == sizeof(vidsets)/sizeof(vidsets[1])) break;
if (dax == ARRAY_SIZE(vidsets)) break;
for (daz = 0; daz < dax; daz++)
if ((validmode[day].bpp|((validmode[day].fs&1)<<16)) == (vidsets[daz]&0x1ffffl)) break;
if (vidsets[daz] != -1) continue;
@ -3161,9 +3161,9 @@ cheat_for_port_credits2:
else
vidsets[dax++] = 0x20000|validmode[day].bpp|((validmode[day].fs&1)<<16);
}
for (dax = 0; dax < (int32_t)(sizeof(vidsets)/sizeof(vidsets[1])) && vidsets[dax] != -1; dax++)
for (dax = 0; dax < (int32_t)ARRAY_SIZE(vidsets) && vidsets[dax] != -1; dax++)
if (vidsets[dax] == (((getrendermode() >= 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<j; i++)
if (rates[i] == ud.config.MixRate)

View file

@ -1567,7 +1567,7 @@ int32_t registerosdcommands(void)
osdcmd_cheatsinfo_stat.cheatnum = -1;
for (i=0; i<sizeof(cvars_game)/sizeof(cvars_game[0]); i++)
for (i=0; i<ARRAY_SIZE(cvars_game); i++)
{
if (OSD_RegisterCvar(&cvars_game[i]))
continue;

View file

@ -1 +1 @@
s_buildRev = "rXXXX";
s_buildRev = "r4381";

View file

@ -973,8 +973,8 @@ static const dataspec_t svgm_secwsp[] =
{ DS_NOCHK, &g_numAnimWalls, sizeof(g_numAnimWalls), 1 },
{ DS_CNT(g_numAnimWalls), &animwall, sizeof(animwall[0]), (intptr_t)&g_numAnimWalls },
{ DS_NOCHK, &g_mirrorCount, sizeof(g_mirrorCount), 1 },
{ DS_NOCHK, &g_mirrorWall[0], sizeof(g_mirrorWall[0]), sizeof(g_mirrorWall)/sizeof(g_mirrorWall[0]) },
{ DS_NOCHK, &g_mirrorSector[0], sizeof(g_mirrorSector[0]), sizeof(g_mirrorSector)/sizeof(g_mirrorSector[0]) },
{ DS_NOCHK, &g_mirrorWall[0], sizeof(g_mirrorWall[0]), ARRAY_SIZE(g_mirrorWall) },
{ DS_NOCHK, &g_mirrorSector[0], sizeof(g_mirrorSector[0]), ARRAY_SIZE(g_mirrorSector) },
// projectiles
{ 0, &SpriteProjectile[0], sizeof(projectile_t), MAXSPRITES },
{ 0, &ProjectileData[0], sizeof(projectile_t), MAXTILES },
@ -1019,8 +1019,8 @@ static const dataspec_t svgm_anmisc[] =
{ 0, &animateptr[0], sizeof(animateptr[0]), MAXANIMATES },
{ DS_SAVEFN|DS_LOADFN , (void *)&sv_postanimateptr, 0, 1 },
{ 0, &g_curViewscreen, sizeof(g_curViewscreen), 1 },
{ 0, &msx[0], sizeof(msx[0]), sizeof(msx)/sizeof(msx[0]) },
{ 0, &msy[0], sizeof(msy[0]), sizeof(msy)/sizeof(msy[0]) },
{ 0, &msx[0], sizeof(msx[0]), ARRAY_SIZE(msx) },
{ 0, &msy[0], sizeof(msy[0]), ARRAY_SIZE(msy) },
{ 0, &g_spriteDeleteQueuePos, sizeof(g_spriteDeleteQueuePos), 1 },
{ DS_NOCHK, &g_spriteDeleteQueueSize, sizeof(g_spriteDeleteQueueSize), 1 },
{ DS_CNT(g_spriteDeleteQueueSize), &SpriteDeletionQueue[0], sizeof(int16_t), (intptr_t)&g_spriteDeleteQueueSize },

View file

@ -238,7 +238,7 @@ fallback:
FILE *fp;
int32_t i;
for (i = (sizeof(s)/sizeof(s[0]))-1; 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);
}

View file

@ -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)