From ed6191430b27a5447ef2675f2cfe19d8f0b88333 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 21 Jun 2007 11:33:46 +0000 Subject: Add arrlen() macro as a clearer way of doing sizeof(array) / sizeof(*array) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 922 --- setup/configfile.c | 5 +++-- setup/keyboard.c | 3 ++- setup/mouse.c | 3 ++- setup/multiplayer.c | 5 +++-- src/am_map.c | 14 +++++--------- src/d_iwad.c | 15 +++++++-------- src/d_main.c | 2 +- src/deh_cheat.c | 2 +- src/deh_main.c | 10 ++++------ src/deh_misc.c | 4 ++-- src/doomtype.h | 2 ++ src/f_finale.c | 2 +- src/i_pcsound.c | 6 ++---- src/i_sdlmusic.c | 2 +- src/i_sdlsound.c | 2 +- src/m_misc.c | 4 ++-- src/wi_stuff.c | 6 +++--- 17 files changed, 42 insertions(+), 45 deletions(-) diff --git a/setup/configfile.c b/setup/configfile.c index d9b17af2..984df6b2 100644 --- a/setup/configfile.c +++ b/setup/configfile.c @@ -44,6 +44,7 @@ #include "doomfeatures.h" #include "doomkeys.h" +#include "doomtype.h" #include "d_englsh.h" #include "m_argv.h" @@ -243,7 +244,7 @@ static default_t doom_defaults_list[] = static default_collection_t doom_defaults = { doom_defaults_list, - sizeof(doom_defaults_list) / sizeof(*doom_defaults_list), + arrlen(doom_defaults_list), NULL, }; @@ -282,7 +283,7 @@ static default_t extra_defaults_list[] = static default_collection_t extra_defaults = { extra_defaults_list, - sizeof(extra_defaults_list) / sizeof(*extra_defaults_list), + arrlen(extra_defaults_list), NULL, }; diff --git a/setup/keyboard.c b/setup/keyboard.c index e558840a..3a7ccb8f 100644 --- a/setup/keyboard.c +++ b/setup/keyboard.c @@ -19,6 +19,7 @@ // 02111-1307, USA. // #include "textscreen.h" +#include "doomtype.h" #include "execute.h" #include "txt_keyinput.h" @@ -72,7 +73,7 @@ static void KeySetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable)) TXT_CAST_ARG(int, variable); unsigned int i; - for (i=0; i #include "textscreen.h" +#include "doomtype.h" #include "execute.h" #include "txt_mouseinput.h" @@ -64,7 +65,7 @@ static void MouseSetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable)) // Check if the same mouse button is used for a different action // If so, set the other action(s) to -1 (unset) - for (i=0; inexttic) { lightlev = litelevels[litelevelscnt++]; - if (litelevelscnt == sizeof(litelevels)/sizeof(int)) litelevelscnt = 0; + if (litelevelscnt == arrlen(litelevels)) litelevelscnt = 0; nexttic = amclock + 6 - (amclock % 6); } @@ -1262,11 +1258,11 @@ void AM_drawPlayers(void) { if (cheating) AM_drawLineCharacter - (cheat_player_arrow, NUMCHEATPLYRLINES, 0, + (cheat_player_arrow, arrlen(cheat_player_arrow), 0, plr->mo->angle, WHITE, plr->mo->x, plr->mo->y); else AM_drawLineCharacter - (player_arrow, NUMPLYRLINES, 0, plr->mo->angle, + (player_arrow, arrlen(player_arrow), 0, plr->mo->angle, WHITE, plr->mo->x, plr->mo->y); return; } @@ -1288,7 +1284,7 @@ void AM_drawPlayers(void) color = their_colors[their_color]; AM_drawLineCharacter - (player_arrow, NUMPLYRLINES, 0, p->mo->angle, + (player_arrow, arrlen(player_arrow), 0, p->mo->angle, color, p->mo->x, p->mo->y); } @@ -1308,7 +1304,7 @@ AM_drawThings while (t) { AM_drawLineCharacter - (thintriangle_guy, NUMTHINTRIANGLEGUYLINES, + (thintriangle_guy, arrlen(thintriangle_guy), 16<angle, colors+lightlev, t->x, t->y); t = t->snext; } diff --git a/src/d_iwad.c b/src/d_iwad.c index 895b5afb..320ee835 100644 --- a/src/d_iwad.c +++ b/src/d_iwad.c @@ -194,7 +194,7 @@ static void CheckUninstallStrings(void) { unsigned int i; - for (i=0; imd5_hash != NULL) { @@ -103,7 +101,7 @@ static void InitialiseSections(void) { int i; - for (i=0; iinit != NULL) { @@ -118,7 +116,7 @@ static deh_section_t *GetSectionByName(char *name) { int i; - for (i=0; iname, name)) { @@ -218,7 +216,7 @@ static boolean CheckSignatures(deh_context_t *context) // Check all signatures to see if one matches - for (i=0; i