summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/am_map.c14
-rw-r--r--src/d_iwad.c15
-rw-r--r--src/d_main.c2
-rw-r--r--src/deh_cheat.c2
-rw-r--r--src/deh_main.c10
-rw-r--r--src/deh_misc.c4
-rw-r--r--src/doomtype.h2
-rw-r--r--src/f_finale.c2
-rw-r--r--src/i_pcsound.c6
-rw-r--r--src/i_sdlmusic.c2
-rw-r--r--src/i_sdlsound.c2
-rw-r--r--src/m_misc.c4
-rw-r--r--src/wi_stuff.c6
13 files changed, 32 insertions, 39 deletions
diff --git a/src/am_map.c b/src/am_map.c
index 11f77c1e..347d592f 100644
--- a/src/am_map.c
+++ b/src/am_map.c
@@ -171,7 +171,6 @@ mline_t player_arrow[] = {
{ { -R+3*R/8, 0 }, { -R+R/8, -R/4 } }
};
#undef R
-#define NUMPLYRLINES (sizeof(player_arrow)/sizeof(mline_t))
#define R ((8*PLAYERRADIUS)/7)
mline_t cheat_player_arrow[] = {
@@ -193,7 +192,6 @@ mline_t cheat_player_arrow[] = {
{ { R/6+R/32, -R/7-R/32 }, { R/6+R/10, -R/7 } }
};
#undef R
-#define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t))
#define R (FRACUNIT)
mline_t triangle_guy[] = {
@@ -202,7 +200,6 @@ mline_t triangle_guy[] = {
{ { 0, R }, { -.867*R, -.5*R } }
};
#undef R
-#define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t))
#define R (FRACUNIT)
mline_t thintriangle_guy[] = {
@@ -211,7 +208,6 @@ mline_t thintriangle_guy[] = {
{ { -.5*R, .7*R }, { -.5*R, -.7*R } }
};
#undef R
-#define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t))
@@ -800,7 +796,7 @@ void AM_updateLightLev(void)
if (amclock>nexttic)
{
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<<FRACBITS, t->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; i<sizeof(uninstall_values) / sizeof(*uninstall_values); ++i)
+ for (i=0; i<arrlen(uninstall_values); ++i)
{
char *val;
char *path;
@@ -237,8 +237,7 @@ static void CheckCollectorsEdition(void)
return;
}
- for (i=0; i<sizeof(collectors_edition_subdirs)
- / sizeof(*collectors_edition_subdirs); ++i)
+ for (i=0; i<arrlen(collectors_edition_subdirs); ++i)
{
subpath = malloc(strlen(install_path)
+ strlen(collectors_edition_subdirs[i])
@@ -273,7 +272,7 @@ static char *SearchDirectoryForIWAD(char *dir)
{
size_t i;
- for (i=0; i<sizeof(iwads) / sizeof(*iwads); ++i)
+ for (i=0; i<arrlen(iwads); ++i)
{
char *filename;
char *iwadname;
@@ -312,7 +311,7 @@ static void IdentifyIWADByName(char *name)
gamemission = none;
- for (i=0; i<sizeof(iwads) / sizeof(*iwads); ++i)
+ for (i=0; i<arrlen(iwads); ++i)
{
char *iwadname;
@@ -592,7 +591,7 @@ void D_SetSaveGameDir(void)
// This ensures that doom1.wad and doom.wad saves are stored
// in the same place.
- for (i=0; i<sizeof(iwads) / sizeof(*iwads); ++i)
+ for (i=0; i<arrlen(iwads); ++i)
{
if (gamemission == iwads[i].mission)
{
@@ -653,7 +652,7 @@ static char *GetGameName(char *gamename)
size_t i;
char *deh_sub;
- for (i=0; i<sizeof(banners) / sizeof(*banners); ++i)
+ for (i=0; i<arrlen(banners); ++i)
{
// Has the banner been replaced?
@@ -801,7 +800,7 @@ void D_FindInstalledIWADs(void)
result = 0;
- for (i=0; i<sizeof(iwads) / sizeof(*iwads); ++i)
+ for (i=0; i<arrlen(iwads); ++i)
{
if (D_FindWADByName(iwads[i].name) != NULL)
{
diff --git a/src/d_main.c b/src/d_main.c
index 6981b884..ca459022 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -631,7 +631,7 @@ void PrintDehackedBanners(void)
{
size_t i;
- for (i=0; i<sizeof(copyright_banners) / sizeof(char *); ++i)
+ for (i=0; i<arrlen(copyright_banners); ++i)
{
char *deh_s;
diff --git a/src/deh_cheat.c b/src/deh_cheat.c
index 6536ca3d..28f32572 100644
--- a/src/deh_cheat.c
+++ b/src/deh_cheat.c
@@ -64,7 +64,7 @@ static deh_cheat_t *FindCheatByName(char *name)
{
size_t i;
- for (i=0; i<sizeof(allcheats) / sizeof(*allcheats); ++i)
+ for (i=0; i<arrlen(allcheats); ++i)
{
if (!strcasecmp(allcheats[i].name, name))
return &allcheats[i];
diff --git a/src/deh_main.c b/src/deh_main.c
index ab205248..7d86e4b2 100644
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -77,8 +77,6 @@ static deh_section_t *section_types[] =
&deh_section_weapon,
};
-static int num_section_types = sizeof(section_types) / sizeof(*section_types);
-
void DEH_Checksum(md5_digest_t digest)
{
md5_context_t md5_context;
@@ -86,7 +84,7 @@ void DEH_Checksum(md5_digest_t digest)
MD5_Init(&md5_context);
- for (i=0; i<num_section_types; ++i)
+ for (i=0; i<arrlen(section_types); ++i)
{
if (section_types[i]->md5_hash != NULL)
{
@@ -103,7 +101,7 @@ static void InitialiseSections(void)
{
int i;
- for (i=0; i<num_section_types; ++i)
+ for (i=0; i<arrlen(section_types); ++i)
{
if (section_types[i]->init != NULL)
{
@@ -118,7 +116,7 @@ static deh_section_t *GetSectionByName(char *name)
{
int i;
- for (i=0; i<num_section_types; ++i)
+ for (i=0; i<arrlen(section_types); ++i)
{
if (!strcasecmp(section_types[i]->name, name))
{
@@ -218,7 +216,7 @@ static boolean CheckSignatures(deh_context_t *context)
// Check all signatures to see if one matches
- for (i=0; i<sizeof(deh_signatures) / sizeof(*deh_signatures); ++i)
+ for (i=0; i<arrlen(deh_signatures); ++i)
{
if (!strcmp(deh_signatures[i], line))
{
diff --git a/src/deh_misc.c b/src/deh_misc.c
index 8f65afae..ea99fb12 100644
--- a/src/deh_misc.c
+++ b/src/deh_misc.c
@@ -206,7 +206,7 @@ static void DEH_MiscParseLine(deh_context_t *context, char *line, void *tag)
return;
}
- for (i=0; i<sizeof(misc_settings) / sizeof(*misc_settings); ++i)
+ for (i=0; i<arrlen(misc_settings); ++i)
{
if (!strcasecmp(variable_name, misc_settings[i].deh_name))
{
@@ -222,7 +222,7 @@ static void DEH_MiscMD5Sum(md5_context_t *context)
{
unsigned int i;
- for (i=0; i<sizeof(misc_settings) / sizeof(*misc_settings); ++i)
+ for (i=0; i<arrlen(misc_settings); ++i)
{
MD5_UpdateInt32(context, *misc_settings[i].value);
}
diff --git a/src/doomtype.h b/src/doomtype.h
index 5b2faf38..2c9680b3 100644
--- a/src/doomtype.h
+++ b/src/doomtype.h
@@ -71,5 +71,7 @@ typedef uint8_t byte;
#endif
+#define arrlen(array) (sizeof(array) / sizeof(*array))
+
#endif
diff --git a/src/f_finale.c b/src/f_finale.c
index c81649dd..7674f09f 100644
--- a/src/f_finale.c
+++ b/src/f_finale.c
@@ -132,7 +132,7 @@ void F_StartFinale (void)
// Find the right screen and set the text and background
- for (i=0; i<sizeof(textscreens) / sizeof(textscreen_t); ++i)
+ for (i=0; i<arrlen(textscreens); ++i)
{
textscreen_t *screen = &textscreens[i];
diff --git a/src/i_pcsound.c b/src/i_pcsound.c
index 08ba92e9..19d23cfb 100644
--- a/src/i_pcsound.c
+++ b/src/i_pcsound.c
@@ -60,8 +60,6 @@ static float frequencies[] = {
2157.64, 2217.80, 2285.78, 2353.41, 2420.24, 2490.98, 2565.97, 2639.77,
};
-#define NUM_FREQUENCIES (sizeof(frequencies) / sizeof(*frequencies))
-
static void PCSCallbackFunc(int *duration, int *freq)
{
int tone;
@@ -84,7 +82,7 @@ static void PCSCallbackFunc(int *duration, int *freq)
// for a full discussion of this.
// Check we don't overflow the frequency table.
- if (tone < (int)NUM_FREQUENCIES)
+ if (tone < arrlen(frequencies))
{
*freq = (int) frequencies[tone];
}
@@ -286,7 +284,7 @@ static snddevice_t sound_pcsound_devices[] =
sound_module_t sound_pcsound_module =
{
sound_pcsound_devices,
- sizeof(sound_pcsound_devices) / sizeof(*sound_pcsound_devices),
+ arrlen(sound_pcsound_devices),
I_PCS_InitSound,
I_PCS_ShutdownSound,
I_PCS_GetSfxLumpNum,
diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c
index 4ece1555..28c8f60f 100644
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -337,7 +337,7 @@ static snddevice_t music_sdl_devices[] =
music_module_t music_sdl_module =
{
music_sdl_devices,
- sizeof(music_sdl_devices) / sizeof(*music_sdl_devices),
+ arrlen(music_sdl_devices),
I_SDL_InitMusic,
I_SDL_ShutdownMusic,
I_SDL_SetMusicVolume,
diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c
index 920e74d2..8e10a932 100644
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -434,7 +434,7 @@ static snddevice_t sound_sdl_devices[] =
sound_module_t sound_sdl_module =
{
sound_sdl_devices,
- sizeof(sound_sdl_devices) / sizeof(*sound_sdl_devices),
+ arrlen(sound_sdl_devices),
I_SDL_InitSound,
I_SDL_ShutdownSound,
I_SDL_GetSfxLumpNum,
diff --git a/src/m_misc.c b/src/m_misc.c
index 92510734..451d9b31 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -401,7 +401,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,
};
@@ -444,7 +444,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/src/wi_stuff.c b/src/wi_stuff.c
index 21809f45..c6e5c359 100644
--- a/src/wi_stuff.c
+++ b/src/wi_stuff.c
@@ -270,9 +270,9 @@ static anim_t epsd2animinfo[] =
static int NUMANIMS[NUMEPISODES] =
{
- sizeof(epsd0animinfo)/sizeof(anim_t),
- sizeof(epsd1animinfo)/sizeof(anim_t),
- sizeof(epsd2animinfo)/sizeof(anim_t)
+ arrlen(epsd0animinfo),
+ arrlen(epsd1animinfo),
+ arrlen(epsd2animinfo),
};
static anim_t *anims[NUMEPISODES] =