[Scummvm-git-logs] scummvm master -> 51e80e442b5aa0f74ce4692dced4493e34fa65d3

bluegr noreply at scummvm.org
Sun Feb 15 20:39:26 UTC 2026


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
51e80e442b JANITORIAL: ULTIMA: use ARRAYSIZE macro


Commit: 51e80e442b5aa0f74ce4692dced4493e34fa65d3
    https://github.com/scummvm/scummvm/commit/51e80e442b5aa0f74ce4692dced4493e34fa65d3
Author: Michael Kuerbis (michael_kuerbis at web.de)
Date: 2026-02-15T22:39:23+02:00

Commit Message:
JANITORIAL: ULTIMA: use ARRAYSIZE macro

Changed paths:
    engines/ultima/nuvie/script/script_actor.cpp
    engines/ultima/ultima4/game/creature.cpp
    engines/ultima/ultima4/game/death.cpp
    engines/ultima/ultima4/game/game.cpp
    engines/ultima/ultima4/game/spell.cpp
    engines/ultima/ultima4/game/weapon.cpp
    engines/ultima/ultima4/map/tileset.cpp
    engines/ultima/ultima8/games/game_info.cpp


diff --git a/engines/ultima/nuvie/script/script_actor.cpp b/engines/ultima/nuvie/script/script_actor.cpp
index 209b99602bf..95243724ed5 100644
--- a/engines/ultima/nuvie/script/script_actor.cpp
+++ b/engines/ultima/nuvie/script/script_actor.cpp
@@ -651,7 +651,7 @@ static int nscript_actor_set(lua_State *L) {
 
 	key = lua_tostring(L, 2);
 
-	int idx = str_bsearch(actor_set_vars, sizeof(actor_set_vars) / sizeof(actor_set_vars[0]), (const char *)key);
+	int idx = str_bsearch(actor_set_vars, ARRAYSIZE(actor_set_vars), (const char *)key);
 	if (idx == -1)
 		return 0;
 
@@ -830,7 +830,7 @@ static int nscript_actor_get(lua_State *L) {
 
 	key = lua_tostring(L, 2);
 
-	int idx = str_bsearch(actor_get_vars, sizeof(actor_get_vars) / sizeof(actor_get_vars[0]), key);
+	int idx = str_bsearch(actor_get_vars, ARRAYSIZE(actor_get_vars), key);
 	if (idx == -1)
 		return 0;
 
diff --git a/engines/ultima/ultima4/game/creature.cpp b/engines/ultima/ultima4/game/creature.cpp
index 80f9f7f8972..d200aa6f5e2 100644
--- a/engines/ultima/ultima4/game/creature.cpp
+++ b/engines/ultima/ultima4/game/creature.cpp
@@ -183,42 +183,42 @@ void Creature::load(const ConfigElement &conf) {
 	_leavesTile = conf.getBool("leavestile");
 
 	/* get effects that this creature is immune to */
-	for (idx = 0; idx < sizeof(effects) / sizeof(effects[0]); idx++) {
+	for (idx = 0; idx < ARRAYSIZE(effects); idx++) {
 		if (conf.getString("resists") == effects[idx].name) {
 			_resists = effects[idx].effect;
 		}
 	}
 
 	/* Load creature attributes */
-	for (idx = 0; idx < sizeof(booleanAttributes) / sizeof(booleanAttributes[0]); idx++) {
+	for (idx = 0; idx < ARRAYSIZE(booleanAttributes); idx++) {
 		if (conf.getBool(booleanAttributes[idx].name)) {
 			_mAttr = static_cast<CreatureAttrib>(_mAttr | booleanAttributes[idx].mask);
 		}
 	}
 
 	/* Load boolean attributes that affect movement */
-	for (idx = 0; idx < sizeof(movementBoolean) / sizeof(movementBoolean[0]); idx++) {
+	for (idx = 0; idx < ARRAYSIZE(movementBoolean); idx++) {
 		if (conf.getBool(movementBoolean[idx].name)) {
 			_movementAttr = static_cast<CreatureMovementAttrib>(_movementAttr | movementBoolean[idx].mask);
 		}
 	}
 
 	/* steals="" */
-	for (idx = 0; idx < sizeof(steals) / sizeof(steals[0]); idx++) {
+	for (idx = 0; idx < ARRAYSIZE(steals); idx++) {
 		if (conf.getString("steals") == steals[idx].name) {
 			_mAttr = static_cast<CreatureAttrib>(_mAttr | steals[idx].mask);
 		}
 	}
 
 	/* casts="" */
-	for (idx = 0; idx < sizeof(casts) / sizeof(casts[0]); idx++) {
+	for (idx = 0; idx < ARRAYSIZE(casts); idx++) {
 		if (conf.getString("casts") == casts[idx].name) {
 			_mAttr = static_cast<CreatureAttrib>(_mAttr | casts[idx].mask);
 		}
 	}
 
 	/* movement="" */
-	for (idx = 0; idx < sizeof(movement) / sizeof(movement[0]); idx++) {
+	for (idx = 0; idx < ARRAYSIZE(movement); idx++) {
 		if (conf.getString("movement") == movement[idx].name) {
 			_movementAttr = static_cast<CreatureMovementAttrib>(_movementAttr | movement[idx].mask);
 		}
diff --git a/engines/ultima/ultima4/game/death.cpp b/engines/ultima/ultima4/game/death.cpp
index aeac682067f..ada474ae5c5 100644
--- a/engines/ultima/ultima4/game/death.cpp
+++ b/engines/ultima/ultima4/game/death.cpp
@@ -62,7 +62,7 @@ const struct {
 	{ 5, "\nLord British says: I have pulled thy spirit and some possessions from the void.  Be more careful in the future!\n\n\020" }
 };
 
-#define N_MSGS (sizeof(DEATH_MSGS) / sizeof(DEATH_MSGS[0]))
+#define N_MSGS ARRAYSIZE(DEATH_MSGS)
 
 Death::Death() : timerCount(0), timerMsg(0), deathSequenceRunning(false) {
 	g_death = this;
diff --git a/engines/ultima/ultima4/game/game.cpp b/engines/ultima/ultima4/game/game.cpp
index 35b26524c8e..8b9dd11593f 100644
--- a/engines/ultima/ultima4/game/game.cpp
+++ b/engines/ultima/ultima4/game/game.cpp
@@ -744,7 +744,7 @@ void mixReagentsSuper() {
 		{ "Paws", {3, 4, 2, 8, 6, 7} },
 		{ "SkaraBr", {2, 4, 9, 6, 4, 8} },
 	};
-	const int shopcount = sizeof(shops) / sizeof(shops[0]);
+	const int shopcount = ARRAYSIZE(shops);
 
 	int oldlocation = g_context->_location->_viewMode;
 	g_context->_location->_viewMode = VIEW_MIXTURES;
diff --git a/engines/ultima/ultima4/game/spell.cpp b/engines/ultima/ultima4/game/spell.cpp
index 6736afc677e..3b0b0adb88a 100644
--- a/engines/ultima/ultima4/game/spell.cpp
+++ b/engines/ultima/ultima4/game/spell.cpp
@@ -232,7 +232,7 @@ Common::String Spells::spellGetErrorMessage(uint spell, SpellCastError error) {
 	}
 
 	/* find the message that we're looking for and return it! */
-	for (i = 0; i < sizeof(SPELL_ERROR_MSGS) / sizeof(SPELL_ERROR_MSGS[0]); i++) {
+	for (i = 0; i < ARRAYSIZE(SPELL_ERROR_MSGS); i++) {
 		if (err == SPELL_ERROR_MSGS[i].err)
 			return Common::String(SPELL_ERROR_MSGS[i].msg);
 	}
diff --git a/engines/ultima/ultima4/game/weapon.cpp b/engines/ultima/ultima4/game/weapon.cpp
index c2860428d9e..2dbb54aee10 100644
--- a/engines/ultima/ultima4/game/weapon.cpp
+++ b/engines/ultima/ultima4/game/weapon.cpp
@@ -117,7 +117,7 @@ Weapon::Weapon(WeaponType weaponType, const ConfigElement &conf)
 	_range = atoi(range.c_str());
 
 	/* Load weapon attributes */
-	for (unsigned at = 0; at < sizeof(booleanAttributes) / sizeof(booleanAttributes[0]); at++) {
+	for (unsigned at = 0; at < ARRAYSIZE(booleanAttributes); at++) {
 		if (conf.getBool(booleanAttributes[at].name)) {
 			_flags |= booleanAttributes[at].flag;
 		}
diff --git a/engines/ultima/ultima4/map/tileset.cpp b/engines/ultima/ultima4/map/tileset.cpp
index eea5964e2cb..6cdd7bd2846 100644
--- a/engines/ultima/ultima4/map/tileset.cpp
+++ b/engines/ultima/ultima4/map/tileset.cpp
@@ -199,12 +199,12 @@ bool TileRule::initFromConf(const ConfigElement &conf) {
 	_walkOffDirs = MASK_DIR_ALL;
 	_name = conf.getString("name");
 
-	for (i = 0; i < sizeof(booleanAttributes) / sizeof(booleanAttributes[0]); i++) {
+	for (i = 0; i < ARRAYSIZE(booleanAttributes); i++) {
 		if (conf.getBool(booleanAttributes[i].name))
 			_mask |= booleanAttributes[i].mask;
 	}
 
-	for (i = 0; i < sizeof(movementBooleanAttr) / sizeof(movementBooleanAttr[0]); i++) {
+	for (i = 0; i < ARRAYSIZE(movementBooleanAttr); i++) {
 		if (conf.getBool(movementBooleanAttr[i]._name))
 			_movementMask |= movementBooleanAttr[i]._mask;
 	}
diff --git a/engines/ultima/ultima8/games/game_info.cpp b/engines/ultima/ultima8/games/game_info.cpp
index 3af0565778b..15ccc571939 100644
--- a/engines/ultima/ultima8/games/game_info.cpp
+++ b/engines/ultima/ultima8/games/game_info.cpp
@@ -70,7 +70,7 @@ char GameInfo::getLanguageFileLetter() const {
 	switch (_type) {
 	case GAME_U8: {
 		unsigned int l = static_cast<unsigned int>(_language);
-		assert(l < (sizeof(gamelangs) / sizeof(gamelangs[0])) - 1);
+		assert(l < ARRAYSIZE(gamelangs) - 1);
 
 		return gamelangs[l].letter;
 	}
@@ -86,7 +86,7 @@ char GameInfo::getLanguageUsecodeLetter() const {
 	switch (_type) {
 	case GAME_U8: {
 		unsigned int l = static_cast<unsigned int>(_language);
-		assert(l < (sizeof(gamelangs) / sizeof(gamelangs[0])) - 1);
+		assert(l < ARRAYSIZE(gamelangs) - 1);
 
 		return gamelangs[l].usecodeletter;
 	}
@@ -100,14 +100,14 @@ char GameInfo::getLanguageUsecodeLetter() const {
 
 Common::String GameInfo::getLanguage() const {
 	unsigned int l = static_cast<unsigned int>(_language);
-	assert(l < (sizeof(gamelangs) / sizeof(gamelangs[0])) - 1);
+	assert(l < ARRAYSIZE(gamelangs) - 1);
 
 	return gamelangs[l].name;
 }
 
 Common::String GameInfo::getGameTitle() const {
 	unsigned int t = static_cast<unsigned int>(_type);
-	assert(t < (sizeof(gametypes) / sizeof(gametypes[0])) - 1);
+	assert(t < ARRAYSIZE(gametypes) - 1);
 
 	return gametypes[t].longname;
 }
@@ -164,9 +164,9 @@ bool GameInfo::match(GameInfo &other, bool ignoreMD5) const {
 
 void GameInfo::save(Common::WriteStream *ws) {
 	unsigned int l = static_cast<unsigned int>(_language);
-	assert(l < (sizeof(gamelangs) / sizeof(gamelangs[0])) - 1);
+	assert(l < ARRAYSIZE(gamelangs) - 1);
 	unsigned int t = static_cast<unsigned int>(_type);
-	assert(t < (sizeof(gametypes) / sizeof(gametypes[0])) - 1);
+	assert(t < ARRAYSIZE(gametypes) - 1);
 
 	Common::String game = gametypes[t].shortname;
 	Common::String lang = gamelangs[l].name;




More information about the Scummvm-git-logs mailing list