[Scummvm-git-logs] scummvm master -> e453f61d3b6d1130c0222ee5a9730866fd05e20e
bluegr
noreply at scummvm.org
Tue Aug 11 14:00:51 UTC 2026
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
cf657e5a1d GLK: replace ARRAY_SIZE macro with ARRAYSIZE
e453f61d3b ENGINES: use ARRAYSIZE macro where applicable
Commit: cf657e5a1d90f1e5b7ff48949f44b99cc70e7b28
https://github.com/scummvm/scummvm/commit/cf657e5a1d90f1e5b7ff48949f44b99cc70e7b28
Author: Michael Kuerbis (michael_kuerbis at web.de)
Date: 2026-08-11T17:00:45+03:00
Commit Message:
GLK: replace ARRAY_SIZE macro with ARRAYSIZE
Changed paths:
engines/glk/comprehend/draw_surface.cpp
engines/glk/comprehend/game.cpp
engines/glk/comprehend/game_data.cpp
engines/glk/comprehend/game_data.h
diff --git a/engines/glk/comprehend/draw_surface.cpp b/engines/glk/comprehend/draw_surface.cpp
index cf5f3a19d83..15195174c7c 100644
--- a/engines/glk/comprehend/draw_surface.cpp
+++ b/engines/glk/comprehend/draw_surface.cpp
@@ -211,7 +211,7 @@ void Surface::reset() {
}
void Surface::setColorTable(uint index) {
- if (index >= ARRAY_SIZE(COLOR_TABLES)) {
+ if (index >= ARRAYSIZE(COLOR_TABLES)) {
warning("Bad color table %d - using default", index);
_colorTable = DEFAULT_COLOR_TABLE;
}
diff --git a/engines/glk/comprehend/game.cpp b/engines/glk/comprehend/game.cpp
index 73b72379825..da043fc83cf 100644
--- a/engines/glk/comprehend/game.cpp
+++ b/engines/glk/comprehend/game.cpp
@@ -130,11 +130,11 @@ void ComprehendGame::synchronizeSave(Common::Serializer &s) {
s.syncAsUint16LE(_currentRoom);
// Variables
- for (i = 0; i < ARRAY_SIZE(_variables); i++)
+ for (i = 0; i < ARRAYSIZE(_variables); i++)
s.syncAsUint16LE(_variables[i]);
// Flags
- for (i = 0; i < ARRAY_SIZE(_flags); i++)
+ for (i = 0; i < ARRAYSIZE(_flags); i++)
s.syncAsByte(_flags[i]);
// Rooms. Note that index 0 is the player's inventory
@@ -774,7 +774,7 @@ void ComprehendGame::read_sentence(Sentence *sentence) {
sentence->_nr_words++;
- if (sentence->_nr_words >= ARRAY_SIZE(sentence->_words) ||
+ if (sentence->_nr_words >= ARRAYSIZE(sentence->_words) ||
sentence_end)
break;
}
diff --git a/engines/glk/comprehend/game_data.cpp b/engines/glk/comprehend/game_data.cpp
index 69e2b3b3f49..8bef98c7829 100644
--- a/engines/glk/comprehend/game_data.cpp
+++ b/engines/glk/comprehend/game_data.cpp
@@ -494,7 +494,7 @@ void GameData::parse_string_table(FileBuffer *fb, uint start_addr,
void GameData::parse_variables(FileBuffer *fb) {
uint i;
- for (i = 0; i < ARRAY_SIZE(_variables); i++)
+ for (i = 0; i < ARRAYSIZE(_variables); i++)
_variables[i] = fb->readUint16LE();
}
@@ -503,7 +503,7 @@ void GameData::parse_flags(FileBuffer *fb) {
int bit;
uint8 bitmask;
- for (i = 0; i < ARRAY_SIZE(_flags) / 8; i++) {
+ for (i = 0; i < ARRAYSIZE(_flags) / 8; i++) {
bitmask = fb->readByte();
for (bit = 7; bit >= 0; bit--) {
_flags[flag_index] = !!(bitmask & (1 << bit));
diff --git a/engines/glk/comprehend/game_data.h b/engines/glk/comprehend/game_data.h
index 186f7d13b9c..ab2e6761eae 100644
--- a/engines/glk/comprehend/game_data.h
+++ b/engines/glk/comprehend/game_data.h
@@ -31,7 +31,6 @@ namespace Comprehend {
#define MAX_FLAGS 256
#define MAX_VARIABLES 128
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
class ComprehendGame;
Commit: e453f61d3b6d1130c0222ee5a9730866fd05e20e
https://github.com/scummvm/scummvm/commit/e453f61d3b6d1130c0222ee5a9730866fd05e20e
Author: Michael Kuerbis (michael_kuerbis at web.de)
Date: 2026-08-11T17:00:45+03:00
Commit Message:
ENGINES: use ARRAYSIZE macro where applicable
Changed paths:
engines/ags/lib/allegro/unicode.cpp
engines/ags/tests/test_gfx.cpp
engines/chamber/amiga.cpp
engines/eem/ui.cpp
engines/glk/adrift/scnpcs.cpp
engines/glk/agt/os_glk.cpp
engines/glk/comprehend/debugger_dumper.cpp
engines/glk/glk_dispa.cpp
engines/glk/level9/detection.cpp
engines/glk/quest/read_file.cpp
engines/glk/scott/unp64/scanners/scanners.cpp
engines/glk/tads/tads2/built_in.cpp
engines/glk/tads/tads2/character_map.cpp
engines/glk/tads/tads2/output.cpp
engines/glk/tads/tads2/regex.cpp
engines/glk/tads/tads2/runtime_driver.cpp
engines/glk/tads/tads2/tokenizer.cpp
engines/glk/tads/tads2/vocabulary_parser.cpp
engines/glk/zcode/processor_screen.cpp
engines/grim/md5check.cpp
engines/harvester/npc/mcknight_dialogue.cpp
engines/lilliput/script.cpp
engines/pegasus/items/biochips/arthurchip.cpp
engines/petka/petka.cpp
engines/pink/archive.cpp
engines/scumm/insane/rebel1/runlevels.cpp
engines/sherlock/scalpel/scalpel_fixed_text.cpp
engines/sky/compact.cpp
engines/tinsel/dialogs.cpp
engines/ultima/ultima4/map/location.cpp
diff --git a/engines/ags/lib/allegro/unicode.cpp b/engines/ags/lib/allegro/unicode.cpp
index f1dbc508c9d..9ce33faeee4 100644
--- a/engines/ags/lib/allegro/unicode.cpp
+++ b/engines/ags/lib/allegro/unicode.cpp
@@ -67,7 +67,7 @@ static UTYPE_INFO *find_utype(int type) {
if (type == U_CURRENT)
type = _G(utype);
- for (i = 0; i < (int)(sizeof(utypes) / sizeof(UTYPE_INFO)); i++)
+ for (i = 0; i < ARRAYSIZE(utypes); i++)
if (utypes[i].id == type)
return &utypes[i];
diff --git a/engines/ags/tests/test_gfx.cpp b/engines/ags/tests/test_gfx.cpp
index e31fd85fb66..51f3539f02a 100644
--- a/engines/ags/tests/test_gfx.cpp
+++ b/engines/ags/tests/test_gfx.cpp
@@ -62,7 +62,7 @@ void Test_GfxSpeed(bool enableSimd, size_t blenderModeStart, size_t blenderModeE
for (int gfx = 0; gfx < 3; gfx++) {
if (dest == 2 && gfx != 2) continue;
for (size_t mode = blenderModeStart; mode <= blenderModeEnd; mode++) {
- for (int runs = 0; (size_t)runs < sizeof(benchRuns)/sizeof(int); runs++) {
+ for (int runs = 0; (size_t)runs < ARRAYSIZE(benchRuns); runs++) {
uint32 start, end;
_G(_blender_mode) = (AGS3::BlenderMode)blenderModes[mode];
//if (runs == 2) debug("Dest: %d bpp, Gfx: %d bpp, Blender: %s, Stretched: false, Iters: %d\n", bpps[dest], bpps[gfx], modeNames[mode], benchRuns[runs]);
diff --git a/engines/chamber/amiga.cpp b/engines/chamber/amiga.cpp
index 996aee69871..73f98e82ee1 100644
--- a/engines/chamber/amiga.cpp
+++ b/engines/chamber/amiga.cpp
@@ -100,7 +100,7 @@ static AmigaResEnt amiga_res[] = {
{ "ICONE.BIN", &icone_data, 117284, 2752, 116838, 2752 },
{ "LUTIN.BIN", &lutin_data, 120036, 2800, 119594, 2800 },
};
-static const int kAmigaNumRes = sizeof(amiga_res) / sizeof(amiga_res[0]);
+static const int kAmigaNumRes = ARRAYSIZE(amiga_res);
// Copy an exe-embedded text bank into its fixed engine buffer, clamped to the
// buffer size and to the space up to the next bank so we never overrun either.
diff --git a/engines/eem/ui.cpp b/engines/eem/ui.cpp
index db91e860382..97e460009d6 100644
--- a/engines/eem/ui.cpp
+++ b/engines/eem/ui.cpp
@@ -1413,7 +1413,7 @@ int EEMEngine::doShowEnding(uint num, bool firstPage) {
scaleDosRectIfMac(*this, kEndingNextPageRect);
uint pageOffsets[8];
const uint pageOffsetCap =
- (uint)(sizeof(pageOffsets) / sizeof(pageOffsets[0]));
+ (uint)ARRAYSIZE(pageOffsets);
uint validPages = 0;
const bool compactEnding = floppyEnding || (macEnding && !macLooseEnding);
const bool cdEnding = !compactEnding;
@@ -1664,8 +1664,7 @@ void EEMEngine::doShowScrapbook(uint stage) {
uint tierLo = 0, tierHi = 0;
if (stage < 1 || !mysteryTierRange(stage, tierLo, tierHi))
return;
- const int solvedCount =
- (int)(sizeof(_mysteriesSolved) / sizeof(_mysteriesSolved[0]));
+ const int solvedCount = ARRAYSIZE(_mysteriesSolved);
const int lo = (int)tierLo;
const int hi = MIN<int>((int)tierHi + 1, solvedCount);
if (lo >= hi)
diff --git a/engines/glk/adrift/scnpcs.cpp b/engines/glk/adrift/scnpcs.cpp
index a887b863ffd..1bf66c3919a 100644
--- a/engines/glk/adrift/scnpcs.cpp
+++ b/engines/glk/adrift/scnpcs.cpp
@@ -191,9 +191,9 @@ static sc_int npc_random_adjacent_roomgroup_member(sc_gameref_t game, sc_int roo
vt_key[1].string = "EightPointCompass";
eightpointcompass = prop_get_boolean(bundle, "B<-ss", vt_key);
if (eightpointcompass)
- length = sizeof(DIRNAMES_8) / sizeof(DIRNAMES_8[0]) - 1;
+ length = ARRAYSIZE(DIRNAMES_8) - 1;
else
- length = sizeof(DIRNAMES_4) / sizeof(DIRNAMES_4[0]) - 1;
+ length = ARRAYSIZE(DIRNAMES_4) - 1;
/* Poll adjacent rooms. */
vt_key[0].string = "Rooms";
diff --git a/engines/glk/agt/os_glk.cpp b/engines/glk/agt/os_glk.cpp
index a289d3f8a72..2da7594333d 100644
--- a/engines/glk/agt/os_glk.cpp
+++ b/engines/glk/agt/os_glk.cpp
@@ -716,7 +716,7 @@ static void gagt_status_update_extended() {
*/
g_vm->glk_window_move_cursor(g_vm->gagt_status_window, 0, 1);
g_vm->glk_put_string(" Exits: ");
- for (exit = 0; exit < (int)sizeof(exitname) / (int)sizeof(exitname[0]); exit++) {
+ for (exit = 0; exit < ARRAYSIZE(exitname); exit++) {
if (compass_rose & (1 << exit)) {
g_vm->glk_put_string(exitname[exit]);
g_vm->glk_put_char(' ');
diff --git a/engines/glk/comprehend/debugger_dumper.cpp b/engines/glk/comprehend/debugger_dumper.cpp
index e26c02cfbaa..9e619b75fea 100644
--- a/engines/glk/comprehend/debugger_dumper.cpp
+++ b/engines/glk/comprehend/debugger_dumper.cpp
@@ -395,12 +395,12 @@ void DebuggerDumper::dumpState() {
_game->_variables[VAR_INVENTORY_LIMIT]);
print("Flags:\n");
- for (uint i = 0; i < ARRAY_SIZE(_game->_flags); i++)
+ for (uint i = 0; i < ARRAYSIZE(_game->_flags); i++)
print(" [%.2x]: %d\n", i, _game->_flags[i]);
print("\n");
print("Variables:\n");
- for (uint i = 0; i < ARRAY_SIZE(_game->_variables); i++)
+ for (uint i = 0; i < ARRAYSIZE(_game->_variables); i++)
print(" [%.2x]: %5d (0x%.4x)\n",
i, _game->_variables[i],
_game->_variables[i]);
diff --git a/engines/glk/glk_dispa.cpp b/engines/glk/glk_dispa.cpp
index cade5e3a28f..37c4d219583 100644
--- a/engines/glk/glk_dispa.cpp
+++ b/engines/glk/glk_dispa.cpp
@@ -24,11 +24,9 @@
namespace Glk {
-#define NUMCLASSES \
- (sizeof(class_table) / sizeof(gidispatch_intconst_t))
+#define NUMCLASSES ARRAYSIZE(class_table)
-#define NUMINTCONSTANTS \
- (sizeof(intconstant_table) / sizeof(gidispatch_intconst_t))
+#define NUMINTCONSTANTS ARRAYSIZE(intconstant_table)
/**
* The constants in this table must be ordered alphabetically.
diff --git a/engines/glk/level9/detection.cpp b/engines/glk/level9/detection.cpp
index b4489868352..884c4d9f937 100644
--- a/engines/glk/level9/detection.cpp
+++ b/engines/glk/level9/detection.cpp
@@ -249,7 +249,7 @@ long Scanner::ScanV1(byte *startFile, uint32 size) {
}
_l9V1Game = -1;
if (dictVal1 != 0xff || dictVal2 != 0xff) {
- for (i = 0; i < sizeof L9_V1_GAMES / sizeof L9_V1_GAMES[0]; i++) {
+ for (i = 0; i < ARRAYSIZE(L9_V1_GAMES); i++) {
if ((L9_V1_GAMES[i].dictVal1 == dictVal1) && (L9_V1_GAMES[i].dictVal2 == dictVal2)) {
_l9V1Game = i;
if (_dictData)
@@ -541,7 +541,7 @@ gln_game_tableref_t GameDetection::gln_gameid_identify_game() {
/* Handle v1 games */
if (_l9V1Game >= 0) {
- assert((unsigned)_l9V1Game < sizeof (GLN_V1GAME_TABLE) / sizeof (GLN_V1GAME_TABLE[0]));
+ assert((unsigned)_l9V1Game < ARRAYSIZE(GLN_V1GAME_TABLE));
return &GLN_V1GAME_TABLE[_l9V1Game];
}
diff --git a/engines/glk/quest/read_file.cpp b/engines/glk/quest/read_file.cpp
index a75e5ad1588..1608d773369 100644
--- a/engines/glk/quest/read_file.cpp
+++ b/engines/glk/quest/read_file.cpp
@@ -303,8 +303,7 @@ GeasFile::GeasFile(const Common::Array<String> &v, GeasInterface *_gi) : gi(_gi)
reserved_words dir_tag_property("north", "south", "east", "west", "northwest", "northeast", "southeast", "southwest", "up", "down", "out", (char *) nullptr);
//Common::Array <GeasBlock> outv;
- for (uint pass = 0; pass < sizeof(pass_names) / sizeof(*pass_names);
- pass ++) {
+ for (uint pass = 0; pass < ARRAYSIZE(pass_names); pass ++) {
String this_pass = pass_names[pass];
bool recursive = recursive_passes[this_pass];
//bool is_object = object_passes[this_pass];
diff --git a/engines/glk/scott/unp64/scanners/scanners.cpp b/engines/glk/scott/unp64/scanners/scanners.cpp
index 1a880927a5e..e05722f28f6 100644
--- a/engines/glk/scott/unp64/scanners/scanners.cpp
+++ b/engines/glk/scott/unp64/scanners/scanners.cpp
@@ -20,6 +20,7 @@
*/
#include "glk/scott/unp64/unp64.h"
+#include "common/util.h"
namespace Glk {
namespace Scott {
@@ -60,7 +61,7 @@ Scnptr g_scanFunc[] = {
void scanners(UnpStr* unp) {
int x, y;
- y = sizeof(g_scanFunc) / sizeof(*g_scanFunc);
+ y = ARRAYSIZE(g_scanFunc);
for (x = 0; x < y; x++) {
(g_scanFunc[x])(unp);
if (unp->_idFlag)
diff --git a/engines/glk/tads/tads2/built_in.cpp b/engines/glk/tads/tads2/built_in.cpp
index 23104fcf77b..05efb7623b3 100644
--- a/engines/glk/tads/tads2/built_in.cpp
+++ b/engines/glk/tads/tads2/built_in.cpp
@@ -2082,8 +2082,7 @@ static int get_ext_key_name(char *namebuf, int c, int extc)
}
/* if it's in the key name array, use the array entry */
- if (extc >= 1
- && extc <= (int)(sizeof(ext_key_names)/sizeof(ext_key_names[0])))
+ if (extc >= 1 && extc <= ARRAYSIZE(ext_key_names))
{
/* use the array name */
Common::strcpy_s(namebuf, 20, ext_key_names[extc - 1]);
@@ -4256,8 +4255,7 @@ void bifinpdlg(bifcxdef *ctx, int argc)
}
/* if we have exhausted our label array, stop now */
- if (bcnt >= sizeof(labels)/sizeof(labels[0])
- || dst >= lblbuf + sizeof(lblbuf))
+ if (bcnt >= ARRAYSIZE(labels) || dst >= lblbuf + sizeof(lblbuf))
break;
}
}
diff --git a/engines/glk/tads/tads2/character_map.cpp b/engines/glk/tads/tads2/character_map.cpp
index 4a21cff6a04..f1dfe4061e7 100644
--- a/engines/glk/tads/tads2/character_map.cpp
+++ b/engines/glk/tads/tads2/character_map.cpp
@@ -63,11 +63,11 @@ void cmap_init_default(void)
size_t i;
/* initialize the input table */
- for (i = 0 ; i < sizeof(G_cmap_input)/sizeof(G_cmap_input[0]) ; ++i)
+ for (i = 0 ; i < ARRAYSIZE(G_cmap_input); ++i)
G_cmap_input[i] = (unsigned char)i;
/* initialize the output table */
- for (i = 0 ; i < sizeof(G_cmap_output)/sizeof(G_cmap_output[0]) ; ++i)
+ for (i = 0 ; i < ARRAYSIZE(G_cmap_output); ++i)
G_cmap_output[i] = (unsigned char)i;
/* we have a null ID */
diff --git a/engines/glk/tads/tads2/output.cpp b/engines/glk/tads/tads2/output.cpp
index 00293c86d0d..e8e97f7d014 100644
--- a/engines/glk/tads/tads2/output.cpp
+++ b/engines/glk/tads/tads2/output.cpp
@@ -1651,7 +1651,7 @@ static void outchar_html_stream(out_stream_info *stream,
* in an external mapping file
*/
for (ampptr = amp_tbl ;
- ampptr < amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) ; ++ampptr)
+ ampptr < amp_tbl + ARRAYSIZE(amp_tbl); ++ampptr)
{
/* if this is the one, stop looking */
if (ampptr->html_cval == htmlchar)
@@ -1663,8 +1663,7 @@ static void outchar_html_stream(out_stream_info *stream,
* from the external character mapping table file, use the external
* expansion; otherwise, use the default expansion.
*/
- if (ampptr >= amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0])
- || ampptr->expan == nullptr)
+ if (ampptr >= amp_tbl + ARRAYSIZE(amp_tbl) || ampptr->expan == nullptr)
{
char xlat_buf[50];
@@ -2802,13 +2801,13 @@ static char out_parse_entity(char *outbuf, size_t outbuf_size, const char **sp,
/* do a binary search for the name */
lo = 0;
- hi = sizeof(amp_tbl)/sizeof(amp_tbl[0]) - 1;
+ hi = ARRAYSIZE(amp_tbl) - 1;
for (;;)
{
int diff;
/* if we've converged, look no further */
- if (lo > hi || lo >= sizeof(amp_tbl)/sizeof(amp_tbl[0]))
+ if (lo > hi || lo >= ARRAYSIZE(amp_tbl))
{
ampptr = nullptr;
break;
@@ -2961,7 +2960,7 @@ void tio_set_html_expansion(unsigned int html_char_val,
/* find the character value */
for (p = amp_tbl ;
- p < amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) ; ++p)
+ p < amp_tbl + ARRAYSIZE(amp_tbl); ++p)
{
/* if this is the one, store it */
if (p->html_cval == html_char_val)
diff --git a/engines/glk/tads/tads2/regex.cpp b/engines/glk/tads/tads2/regex.cpp
index 589ab29a7fb..63d1df72a59 100644
--- a/engines/glk/tads/tads2/regex.cpp
+++ b/engines/glk/tads/tads2/regex.cpp
@@ -689,8 +689,7 @@ static re_status_t re_compile(re_context *ctx,
* alternate machines onto the group stack, and clear
* everything out for the new group.
*/
- if (group_stack_level
- > sizeof(group_stack)/sizeof(group_stack[0]))
+ if (group_stack_level > ARRAYSIZE(group_stack))
{
/* we cannot proceed - return an error */
return RE_STATUS_GROUP_NESTING_TOO_DEEP;
diff --git a/engines/glk/tads/tads2/runtime_driver.cpp b/engines/glk/tads/tads2/runtime_driver.cpp
index cc0f7973b82..5e4ec8034c5 100644
--- a/engines/glk/tads/tads2/runtime_driver.cpp
+++ b/engines/glk/tads/tads2/runtime_driver.cpp
@@ -688,7 +688,7 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[],
re_init(&bifctx.bifcxregex, ec);
/* add the built-in functions, keywords, etc */
- supbif(&supctx, bif, (int)(sizeof(bif)/sizeof(bif[0])));
+ supbif(&supctx, bif, ARRAYSIZE(bif));
/* set up status line hack */
runistat(&vocctx, &runctx, (tiocxdef *)nullptr);
diff --git a/engines/glk/tads/tads2/tokenizer.cpp b/engines/glk/tads/tads2/tokenizer.cpp
index d1466f73557..7135f460204 100644
--- a/engines/glk/tads/tads2/tokenizer.cpp
+++ b/engines/glk/tads/tads2/tokenizer.cpp
@@ -778,7 +778,7 @@ static int tokgetlin(tokcxdef *ctx, int dopound)
len && t_isspace(*p) ; --len, ++p) ;
/* find and process the directive */
- for (dirp = dir, i = sizeof(dir)/sizeof(dir[0]) ; i ; --i, ++dirp)
+ for (dirp = dir, i = ARRAYSIZE(dir); i ; --i, ++dirp)
{
/* compare this directive; if it wins, call its function */
if (len >= dirp->len && !memcmp(p, dirp->nm, (size_t)dirp->len)
diff --git a/engines/glk/tads/tads2/vocabulary_parser.cpp b/engines/glk/tads/tads2/vocabulary_parser.cpp
index 051bc330aa9..2a125032040 100644
--- a/engines/glk/tads/tads2/vocabulary_parser.cpp
+++ b/engines/glk/tads/tads2/vocabulary_parser.cpp
@@ -1847,7 +1847,7 @@ startover:
Common::sprintf_s(buf, "... %s (", cmd[cur]);
p = buf + strlen(buf);
cnt = 0;
- for (i = 0 ; i < sizeof(type_names)/sizeof(type_names[0]) ; ++i)
+ for (i = 0 ; i < ARRAYSIZE(type_names); ++i)
{
if (t & (1 << i))
{
@@ -3754,8 +3754,7 @@ void voc_parse_dict_lookup(voccxdef *ctx)
curtyp = (int)osrp4(typp+1);
/* search for a type */
- for (mapp = typemap, i = sizeof(typemap)/sizeof(typemap[0]) ;
- i != 0 ; ++mapp, --i)
+ for (mapp = typemap, i = ARRAYSIZE(typemap); i != 0 ; ++mapp, --i)
{
/* if this flag is set, use this type property */
if ((curtyp & mapp->flag) != 0)
diff --git a/engines/glk/zcode/processor_screen.cpp b/engines/glk/zcode/processor_screen.cpp
index 8f0af40aa61..ac53bf95015 100644
--- a/engines/glk/zcode/processor_screen.cpp
+++ b/engines/glk/zcode/processor_screen.cpp
@@ -136,7 +136,7 @@ void Processor::screen_char(zchar c) {
int curx = _wp._upper[X_CURSOR], cury = _wp._upper[Y_CURSOR];
if (cury == 1) {
- if (curx <= (int)((sizeof statusline / sizeof(zchar)) - 1)) {
+ if (curx <= ARRAYSIZE(statusline) - 1) {
statusline[curx - 1] = c;
statusline[curx] = 0;
}
diff --git a/engines/grim/md5check.cpp b/engines/grim/md5check.cpp
index ebad6628ed6..8a713e7a05d 100644
--- a/engines/grim/md5check.cpp
+++ b/engines/grim/md5check.cpp
@@ -430,7 +430,7 @@ void MD5Check::init() {
_initted = true;
_files = new Common::Array<MD5Sum>();
- #define MD5SUM(filename, sums) _files->push_back(MD5Sum(filename, sums, sizeof(sums) / sizeof(const char *)));
+ #define MD5SUM(filename, sums) _files->push_back(MD5Sum(filename, sums, ARRAYSIZE(sums)));
if (g_grim->getGameType() == GType_GRIM) {
if (g_grim->getGameFlags() & ADGF_DEMO) {
diff --git a/engines/harvester/npc/mcknight_dialogue.cpp b/engines/harvester/npc/mcknight_dialogue.cpp
index 920e80308b3..d42befe7ac7 100644
--- a/engines/harvester/npc/mcknight_dialogue.cpp
+++ b/engines/harvester/npc/mcknight_dialogue.cpp
@@ -25,6 +25,8 @@
#include "harvester/npc/dialogue_flags.h"
#include "harvester/npc/dialogue_runtime.h"
+#include "common/util.h"
+
namespace Harvester {
namespace {
@@ -70,7 +72,7 @@ Common::Error McknightDialogueHandler::handleDialogue(DialogueRuntime &runtime,
{ 0x1598, kMcknightNpc, 2 },
{ 0x159d, kPcSpeaker, 0 }
};
- return playSequence(lines, sizeof(lines) / sizeof(lines[0]));
+ return playSequence(lines, ARRAYSIZE(lines));
}
return playMcknightLine(0x15e4);
}
@@ -116,7 +118,7 @@ Common::Error McknightDialogueHandler::handleDialogue(DialogueRuntime &runtime,
{ 0x162b, kPcSpeaker, 4 },
{ 0x1631, kMcknightNpc, 0 }
};
- return playSequence(lines, sizeof(lines) / sizeof(lines[0]));
+ return playSequence(lines, ARRAYSIZE(lines));
}
return playMcknightLine(0x15de);
diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp
index 10aa8b84b3b..cf90b97fc80 100644
--- a/engines/lilliput/script.cpp
+++ b/engines/lilliput/script.cpp
@@ -821,7 +821,7 @@ void LilliputScript::disasmScript(ScriptStream script) {
}
// op code type 1
- assert(val < sizeof(opCodes1) / sizeof(OpCode));
+ assert(val < ARRAYSIZE(opCodes1));
const OpCode *opCode = &opCodes1[val];
const kValueType *opArgType = &opCode->_arg1;
@@ -862,7 +862,7 @@ void LilliputScript::disasmScript(ScriptStream script) {
while (val != 0xFFF7) {
// op code type 2
- assert(val < sizeof(opCodes2) / sizeof(OpCode));
+ assert(val < ARRAYSIZE(opCodes2));
const OpCode *opCode = &opCodes2[val];
const kValueType *opArgType = &opCode->_arg1;
diff --git a/engines/pegasus/items/biochips/arthurchip.cpp b/engines/pegasus/items/biochips/arthurchip.cpp
index 4e4a4ccf73b..2eb07c8e9a6 100644
--- a/engines/pegasus/items/biochips/arthurchip.cpp
+++ b/engines/pegasus/items/biochips/arthurchip.cpp
@@ -224,8 +224,8 @@ void ArthurChip::clickInArthurHotspot(HotSpotID id) {
setItemState(newState);
switch (id) {
case kArthurWisdomSpotID:
- playArthurMovie(kArthurWisdomMovies[g_vm->getRandomNumber((
- sizeof(kArthurWisdomMovies) / sizeof(const char *)) - 1)]);
+ playArthurMovie(kArthurWisdomMovies[g_vm->getRandomNumber(
+ ARRAYSIZE(kArthurWisdomMovies) - 1)]);
break;
case kChattyArthurSpotID:
g_vm->setChattyArthur(!g_vm->isChattyArthur());
diff --git a/engines/petka/petka.cpp b/engines/petka/petka.cpp
index e1d3a58b415..53299643ffe 100644
--- a/engines/petka/petka.cpp
+++ b/engines/petka/petka.cpp
@@ -83,7 +83,7 @@ Common::Error PetkaEngine::run() {
}
const char *const videos[] = {"buka.avi", "skif.avi", "adv.avi"};
- for (uint i = 0; i < sizeof(videos) / sizeof(char *); ++i) {
+ for (uint i = 0; i < ARRAYSIZE(videos); ++i) {
Common::ScopedPtr<Common::File> file(new Common::File);
if (file->open(videos[i])) {
playVideo(file.release());
@@ -209,7 +209,7 @@ void PetkaEngine::loadStores() {
parts.getKey("PathSpeech", section, _speechPath);
Common::String storeName;
- for (uint i = 0; i < sizeof(names) / sizeof(char *); ++i) {
+ for (uint i = 0; i < ARRAYSIZE(names); ++i) {
parts.getKey(names[i], section, storeName);
_fileMgr->openStore(storeName);
}
diff --git a/engines/pink/archive.cpp b/engines/pink/archive.cpp
index bb87d1a0d3b..6e24420545f 100644
--- a/engines/pink/archive.cpp
+++ b/engines/pink/archive.cpp
@@ -287,7 +287,7 @@ static int runtimeClassCmp(const void *key, const void *elem) {
}
uint Archive::findObjectId(const char *name) {
- RuntimeClass *found = (RuntimeClass *)bsearch(name, classMap, sizeof(classMap) / sizeof(RuntimeClass), sizeof(RuntimeClass), runtimeClassCmp);
+ RuntimeClass *found = (RuntimeClass *)bsearch(name, classMap, ARRAYSIZE(classMap), sizeof(RuntimeClass), runtimeClassCmp);
if (!found)
error("Class %s is not in class Map", name);
diff --git a/engines/scumm/insane/rebel1/runlevels.cpp b/engines/scumm/insane/rebel1/runlevels.cpp
index e863db47cd6..a67ae9a8426 100644
--- a/engines/scumm/insane/rebel1/runlevels.cpp
+++ b/engines/scumm/insane/rebel1/runlevels.cpp
@@ -1411,7 +1411,7 @@ void InsaneRebel1::runGame() {
&InsaneRebel1::runLevel14,
&InsaneRebel1::runLevel15
};
- const int numLevels = (int)(sizeof(kLevelRunners) / sizeof(kLevelRunners[0]));
+ const int numLevels = ARRAYSIZE(kLevelRunners);
auto runLevelsFrom = [&](int startLevel, bool resetRunState) {
int firstLevel = CLIP<int>(startLevel, 1, numLevels);
diff --git a/engines/sherlock/scalpel/scalpel_fixed_text.cpp b/engines/sherlock/scalpel/scalpel_fixed_text.cpp
index 800793ddc34..92bd1c7afd6 100644
--- a/engines/sherlock/scalpel/scalpel_fixed_text.cpp
+++ b/engines/sherlock/scalpel/scalpel_fixed_text.cpp
@@ -808,7 +808,7 @@ static const char *const fixedTextZH_ActionUse[] = {
"\xaa\xf9\xb5\x4c\xaa\x6b\xa9\xe2\xb7\xcf" /* "éç¡æ³æ½ç
"; "Doors don't smoke" */
};
-#define FIXEDTEXT_GETCOUNT(_name_) sizeof(_name_) / sizeof(byte *)
+#define FIXEDTEXT_GETCOUNT(_name_) ARRAYSIZE(_name_)
#define FIXEDTEXT_ENTRY(_name_) _name_, FIXEDTEXT_GETCOUNT(_name_)
static const FixedTextActionEntry fixedTextEN_Actions[] = {
diff --git a/engines/sky/compact.cpp b/engines/sky/compact.cpp
index 7e35015a214..5d924d7c5f6 100644
--- a/engines/sky/compact.cpp
+++ b/engines/sky/compact.cpp
@@ -118,9 +118,9 @@ static const uint32 turnTableOffsets[] = {
MK32_A5(TurnTable, turnTableTalk),
};
-#define COMPACT_SIZE (sizeof(compactOffsets)/sizeof(uint32))
-#define MEGASET_SIZE (sizeof(megaSetOffsets)/sizeof(uint32))
-#define TURNTABLE_SIZE (sizeof(turnTableOffsets)/sizeof(uint32))
+#define COMPACT_SIZE (ARRAYSIZE(compactOffsets))
+#define MEGASET_SIZE (ARRAYSIZE(megaSetOffsets))
+#define TURNTABLE_SIZE (ARRAYSIZE(turnTableOffsets))
SkyCompact::SkyCompact() {
_cptFile = new Common::File();
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index 729bb19c41e..ba8402ddbee 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -387,7 +387,7 @@ static CONFBOX t2OptionBox[] = {
};
-static CONFINIT t2ciOption = {6, 4, 144, 60, false, t2OptionBox, sizeof(t2OptionBox) / sizeof(CONFBOX), NO_HEADING};
+static CONFINIT t2ciOption = {6, 4, 144, 60, false, t2OptionBox, ARRAYSIZE(t2OptionBox), NO_HEADING};
static CONFBOX t3OptionBox[] = {
{ARSBUT, OPENLOAD, TM_INDEX, NULL, SS_LOAD_OPTION, T2_OPTX, T2_OPTY, T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0},
@@ -397,7 +397,7 @@ static CONFBOX t3OptionBox[] = {
{ARSBUT, OPENQUIT, TM_INDEX, NULL, SS_QUIT_OPTION, T2_OPTX, T2_OPTY + 4 * (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0}
};
-static CONFINIT t3ciOption = {6, 4, 144, 60, false, t3OptionBox, sizeof(t3OptionBox) / sizeof(CONFBOX), NO_HEADING};
+static CONFINIT t3ciOption = {6, 4, 144, 60, false, t3OptionBox, ARRAYSIZE(t3OptionBox), NO_HEADING};
static CONFINIT* ciOptionLookup[] = {
&t1ciOption,
@@ -471,8 +471,8 @@ static CONFBOX t3LoadBox[] = {
{AATBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}};
static CONFINIT t1ciLoad = {10, 6, 20, 16, true, t1LoadBox, ARRAYSIZE(t1LoadBox), SIX_LOAD_HEADING};
-static CONFINIT t2ciLoad = {10, 6, 40, 16, true, t2LoadBox, sizeof(t2LoadBox) / sizeof(CONFBOX), SS_LOAD_HEADING};
-static CONFINIT t3ciLoad = {10, 6, 40, 16, true, t3LoadBox, sizeof(t3LoadBox) / sizeof(CONFBOX), SS_LOAD_HEADING};
+static CONFINIT t2ciLoad = {10, 6, 40, 16, true, t2LoadBox, ARRAYSIZE(t2LoadBox), SS_LOAD_HEADING};
+static CONFINIT t3ciLoad = {10, 6, 40, 16, true, t3LoadBox, ARRAYSIZE(t3LoadBox), SS_LOAD_HEADING};
static CONFBOX t1SaveBox[NUM_RGROUP_BOXES + 2] = {
{RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY, EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0},
@@ -517,8 +517,8 @@ static CONFBOX t3SaveBox[] = {
{AATBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}};
static CONFINIT t1ciSave = {10, 6, 20, 16, true, t1SaveBox, ARRAYSIZE(t1SaveBox), SIX_SAVE_HEADING};
-static CONFINIT t2ciSave = {10, 6, 40, 16, true, t2SaveBox, sizeof(t2SaveBox) / sizeof(CONFBOX), SS_SAVE_HEADING};
-static CONFINIT t3ciSave = {10, 6, 40, 16, true, t3SaveBox, sizeof(t3SaveBox) / sizeof(CONFBOX), SS_SAVE_HEADING};
+static CONFINIT t2ciSave = {10, 6, 40, 16, true, t2SaveBox, ARRAYSIZE(t2SaveBox), SS_SAVE_HEADING};
+static CONFINIT t3ciSave = {10, 6, 40, 16, true, t3SaveBox, ARRAYSIZE(t3SaveBox), SS_SAVE_HEADING};
static CONFINIT* ciLoadLookup[] = {
&t1ciLoad,
@@ -585,8 +585,8 @@ static CONFINIT t1ciRestart = {6, 2, 72, 53, false, t1RestartBox, ARRAYSIZE(t1Re
static CONFINIT t1ciRestart = {4, 2, 98, 53, false, t1RestartBox, ARRAYSIZE(t1RestartBox), SIX_RESTART_HEADING};
#endif
static CONFINIT t1ciRestartPSX = {8, 2, 46, 53, false, t1RestartBoxPSX, ARRAYSIZE(t1RestartBoxPSX), SIX_RESTART_HEADING};
-static CONFINIT t2ciRestart = {4, 2, 196, 53, false, t2RestartBox, sizeof(t2RestartBox) / sizeof(CONFBOX), SS_RESTART_HEADING};
-static CONFINIT t3ciRestart = {4, 2, 196, 53, false, t3RestartBox, sizeof(t3RestartBox) / sizeof(CONFBOX), SS_RESTART_HEADING};
+static CONFINIT t2ciRestart = {4, 2, 196, 53, false, t2RestartBox, ARRAYSIZE(t2RestartBox), SS_RESTART_HEADING};
+static CONFINIT t3ciRestart = {4, 2, 196, 53, false, t3RestartBox, ARRAYSIZE(t3RestartBox), SS_RESTART_HEADING};
static CONFINIT* ciRestartLookup[] = {
&t1ciRestart,
@@ -626,8 +626,8 @@ static CONFBOX t3SoundBox[] = {
};
static CONFINIT t1ciSound = {10, 5, 20, 16, false, t1SoundBox, ARRAYSIZE(t1SoundBox), NO_HEADING};
-static CONFINIT t2ciSound = {10, 5, 40, 16, false, t2SoundBox, sizeof(t2SoundBox) / sizeof(CONFBOX), SS_SOUND_HEADING};
-static CONFINIT t3ciSound = {10, 5, 40, 16, false, t3SoundBox, sizeof(t3SoundBox) / sizeof(CONFBOX), SS_SOUND_HEADING};
+static CONFINIT t2ciSound = {10, 5, 40, 16, false, t2SoundBox, ARRAYSIZE(t2SoundBox), SS_SOUND_HEADING};
+static CONFINIT t3ciSound = {10, 5, 40, 16, false, t3SoundBox, ARRAYSIZE(t3SoundBox), SS_SOUND_HEADING};
static CONFINIT* ciSoundLookup[] = {
&t1ciSound,
@@ -724,8 +724,8 @@ static CONFBOX t3QuitBox[] = {
{AATBUT, CLOSEWIN, TM_NONE, NULL, 0, 60, 64, BW_T3, BH_T3, NULL, IX3_TICK}};
static CONFINIT t1ciQuit = {4, 2, 98, 53, false, t1QuitBox, ARRAYSIZE(t1QuitBox), SIX_QUIT_HEADING};
-static CONFINIT t2ciQuit = {4, 2, 196, 53, false, t2QuitBox, sizeof(t2QuitBox) / sizeof(CONFBOX), SS_QUIT_HEADING};
-static CONFINIT t3ciQuit = {4, 2, 196, 53, false, t3QuitBox, sizeof(t3QuitBox) / sizeof(CONFBOX), SS_QUIT_HEADING};
+static CONFINIT t2ciQuit = {4, 2, 196, 53, false, t2QuitBox, ARRAYSIZE(t2QuitBox), SS_QUIT_HEADING};
+static CONFINIT t3ciQuit = {4, 2, 196, 53, false, t3QuitBox, ARRAYSIZE(t3QuitBox), SS_QUIT_HEADING};
static CONFINIT* ciQuitLookup[] = {
&t1ciQuit,
@@ -754,7 +754,7 @@ static CONFBOX hopperBox1[] = {
{ARSGBUT, HOPPER2, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1},
{AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}};
-static CONFINIT ciHopper1 = {10, 6, 40, 16, true, hopperBox1, sizeof(hopperBox1) / sizeof(CONFBOX), SS_HOPPER1};
+static CONFINIT ciHopper1 = {10, 6, 40, 16, true, hopperBox1, ARRAYSIZE(hopperBox1), SS_HOPPER1};
static CONFBOX hopperBox2[] = {
{RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0},
@@ -770,7 +770,7 @@ static CONFBOX hopperBox2[] = {
{ARSGBUT, BF_CHANGESCENE, TM_NONE, NULL, 0, 460, 50, BW, BH, NULL, IX2_TICK1},
{AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 200, BW, BH, NULL, IX2_CROSS1}};
-static CONFINIT ciHopper2 = {10, 6, 40, 16, true, hopperBox2, sizeof(hopperBox2) / sizeof(CONFBOX), NO_HEADING};
+static CONFINIT ciHopper2 = {10, 6, 40, 16, true, hopperBox2, ARRAYSIZE(hopperBox2), NO_HEADING};
/***************************************************************************\
|**************************** Top Window *****************************|
diff --git a/engines/ultima/ultima4/map/location.cpp b/engines/ultima/ultima4/map/location.cpp
index 783e99b1109..93b336f4f8b 100644
--- a/engines/ultima/ultima4/map/location.cpp
+++ b/engines/ultima/ultima4/map/location.cpp
@@ -169,7 +169,7 @@ TileId Location::getReplacementTile(MapCoords atCoords, const Tile *forTile) {
Common::HashMap<TileId, int> validMapTileCount;
const static int dirs[][2] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
- const static int dirs_per_step = sizeof(dirs) / sizeof(*dirs);
+ const static int dirs_per_step = ARRAYSIZE(dirs);
int loop_count = 0;
//std::set<MapCoords> searched;
More information about the Scummvm-git-logs
mailing list