[Scummvm-git-logs] scummvm master -> 636bfaadc9a504e333346c6e4b224a9ef4bbf09a

Strangerke noreply at scummvm.org
Fri Jan 24 05:12:03 UTC 2025


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

Summary:
636bfaadc9 GOT: Remove several useless variables in var.h, fix "bugprone-branch-clone" warnings


Commit: 636bfaadc9a504e333346c6e4b224a9ef4bbf09a
    https://github.com/scummvm/scummvm/commit/636bfaadc9a504e333346c6e4b224a9ef4bbf09a
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-24T06:11:27+01:00

Commit Message:
GOT: Remove several useless variables in var.h, fix "bugprone-branch-clone" warnings

Changed paths:
    engines/got/game/back.cpp
    engines/got/game/boss2.cpp
    engines/got/game/boss3.cpp
    engines/got/game/object.cpp
    engines/got/game/script.cpp
    engines/got/vars.h
    engines/got/views/game_content.cpp


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index ad42dfbaadf..91b48ab998d 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -253,13 +253,8 @@ void killEnemies(const int iy, const int ix) {
 			x2 = (_G(actor[i])._x + _G(actor[i])._sizeX);
 			y2 = _G(actor[i])._y + _G(actor[i])._sizeY - 1;
 
-			if (pointWithin(x1, y1, ix, iy, ix + 15, iy + 15))
-				actorDestroyed(&_G(actor[i]));
-			else if (pointWithin(x2, y1, ix, iy, ix + 15, iy + 15))
-				actorDestroyed(&_G(actor[i]));
-			else if (pointWithin(x1, y2, ix, iy, ix + 15, iy + 15))
-				actorDestroyed(&_G(actor[i]));
-			else if (pointWithin(x2, y2, ix, iy, ix + 15, iy + 15))
+			if (pointWithin(x1, y1, ix, iy, ix + 15, iy + 15) || pointWithin(x2, y1, ix, iy, ix + 15, iy + 15)
+				|| pointWithin(x1, y2, ix, iy, ix + 15, iy + 15) || pointWithin(x2, y2, ix, iy, ix + 15, iy + 15))
 				actorDestroyed(&_G(actor[i]));
 		}
 	}
@@ -269,7 +264,8 @@ void killEnemies(const int iy, const int ix) {
 	x2 = x1 + 13;
 	y2 = y1 + 5;
 
-	if (pointWithin(x1, y1, ix, iy, ix + 15, iy + 15) || pointWithin(x2, y1, ix, iy, ix + 15, iy + 15) || pointWithin(x1, y2, ix, iy, ix + 15, iy + 15) || pointWithin(x2, y2, ix, iy, ix + 15, iy + 15)) {
+	if (pointWithin(x1, y1, ix, iy, ix + 15, iy + 15) || pointWithin(x2, y1, ix, iy, ix + 15, iy + 15)
+		|| pointWithin(x1, y2, ix, iy, ix + 15, iy + 15) || pointWithin(x2, y2, ix, iy, ix + 15, iy + 15)) {
 		if (!_G(cheats)._freezeHealth) {
 			_G(thor)->_health = 0;
 			g_events->send(GameMessage("THOR_DIES"));
@@ -280,9 +276,9 @@ void killEnemies(const int iy, const int ix) {
 void removeObjects(const int y, const int x) {
 	const int p = (y * 20) + x;
 
-	if (_G(object_map[p]) > 0) {
-		_G(object_map[p]) = 0;
-		_G(object_index[p]) = 0;
+	if (_G(objectMap[p]) > 0) {
+		_G(objectMap[p]) = 0;
+		_G(objectIndex[p]) = 0;
 	}
 }
 
diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 523bc1dd88b..bc26e334d9a 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -213,7 +213,6 @@ void boss2SetupLevel() {
 	_G(boss_active) = true;
 	musicPause();
 	playSound(BOSS11, true);
-	_G(timerCounter) = 0;
 
 	dropFlag = false;
 	Common::fill(su, su + 18, 0);
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index 908a1e44999..a7669b440ff 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -476,7 +476,6 @@ void boss3SetupLevel() {
 	_G(boss_active) = true;
 	musicPause();
 	playSound(BOSS11, true);
-	_G(timerCounter) = 0;
 
 	g_events->send("Game", GameMessage("PAUSE", 40));
 
@@ -564,7 +563,6 @@ void endingScreen() {
 		_G(actor[i])._moveType = 1;
 	
 	musicPlay(6, true);
-	_G(timerCounter) = 0;
 
 	memset(expf, 0, 4 * 8);
 	_G(endgame) = 1;
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 8d75f41de1d..016c21366c2 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -34,20 +34,20 @@ void notEnoughMagic();
 void cannotCarryMore();
 
 void showObjects() {
-	Common::fill(_G(object_map), _G(object_map) + TILES_COUNT, 0);
-	Common::fill(_G(object_index), _G(object_index) + TILES_COUNT, 0);
+	Common::fill(_G(objectMap), _G(objectMap) + TILES_COUNT, 0);
+	Common::fill(_G(objectIndex), _G(objectIndex) + TILES_COUNT, 0);
 
 	for (int i = 0; i < OBJECTS_COUNT; i++) {
 		if (_G(scrn)._staticObject[i]) {
 			const int p = _G(scrn)._staticX[i] + (_G(scrn)._staticY[i] * TILES_X);
-			_G(object_index[p]) = i;
-			_G(object_map[p]) = _G(scrn)._staticObject[i];
+			_G(objectIndex[p]) = i;
+			_G(objectMap[p]) = _G(scrn)._staticObject[i];
 		}
 	}
 }
 
 void pickUpObject(int p) {
-	switch (_G(object_map[p])) {
+	switch (_G(objectMap[p])) {
 	case 1: // Red jewel
 		if (_G(thor_info)._jewels >= 999) {
 			cannotCarryMore();
@@ -119,7 +119,7 @@ void pickUpObject(int p) {
 	case 24:
 	case 25:
 	case 26:
-		if (_G(object_map[p]) == 13 && HERMIT_HAS_DOLL)
+		if (_G(objectMap[p]) == 13 && HERMIT_HAS_DOLL)
 			return;
 		_G(thor)->_numMoves = 1;
 		_G(hammer)->_numMoves = 2;
@@ -128,9 +128,9 @@ void pickUpObject(int p) {
 		_G(tornado_used) = false;
 		_G(thor_info)._inventory |= 64;
 		_G(thor_info)._selectedItem = 7;
-		_G(thor_info)._object = _G(object_map[p]) - 11;
+		_G(thor_info)._object = _G(objectMap[p]) - 11;
 		_G(thor_info)._objectName = OBJECT_NAMES[_G(thor_info)._object - 1];
-		odinSpeaks((_G(object_map[p]) - 12) + 501, _G(object_map[p]) - 1);
+		odinSpeaks((_G(objectMap[p]) - 12) + 501, _G(objectMap[p]) - 1);
 		break;
 	case 27:
 	case 28:
@@ -146,10 +146,10 @@ void pickUpObject(int p) {
 		_G(hammer)->_numMoves = 2;
 		_G(thor)->_numMoves = 1;
 		_G(actor[2])._active = false;
-		const int s = 1 << (_G(object_map[p]) - 27);
+		const int s = 1 << (_G(objectMap[p]) - 27);
 		_G(thor_info)._inventory |= s;
-		odinSpeaks((_G(object_map[p]) - 27) + 516, _G(object_map[p]) - 1);
-		_G(thor_info)._selectedItem = _G(object_map[p]) - 26;
+		odinSpeaks((_G(objectMap[p]) - 27) + 516, _G(objectMap[p]) - 1);
+		_G(thor_info)._selectedItem = _G(objectMap[p]) - 26;
 		addMagic(150);
 		fillScore(5);
 		}
@@ -158,21 +158,15 @@ void pickUpObject(int p) {
 	default:
 		break;
 	}
-	const int x = p % 20;
-	const int y = p / 20;
-
-	_G(ox) = x * 16;
-	_G(oy) = y * 16;
-	_G(of) = 1;
 
 	playSound(YAH, false);
-	_G(object_map[p]) = 0;
+	_G(objectMap[p]) = 0;
 
 	// Reset so it doesn't reappear on reentry to screen
-	if (_G(object_index[p]) < 30)
-		_G(scrn)._staticObject[_G(object_index[p])] = 0;
+	if (_G(objectIndex[p]) < 30)
+		_G(scrn)._staticObject[_G(objectIndex[p])] = 0;
 	
-	_G(object_index[p]) = 0;
+	_G(objectIndex[p]) = 0;
 }
 
 void dropRandomObject(Actor *actor) {
@@ -202,9 +196,9 @@ void dropRandomObject(Actor *actor) {
 
 bool dropObject(Actor *actor, const int objId) {
 	const int p = (actor->_x + (actor->_sizeX / 2)) / 16 + (((actor->_y + (actor->_sizeY / 2)) / 16) * 20);
-	if (!_G(object_map[p]) && _G(scrn)._iconGrid[p / 20][p % 20] >= 140) { //nothing there and solid
-		_G(object_map[p]) = objId;
-		_G(object_index[p]) = 27 + actor->_actorNum; //actor is 3-15
+	if (!_G(objectMap[p]) && _G(scrn)._iconGrid[p / 20][p % 20] >= 140) { //nothing there and solid
+		_G(objectMap[p]) = objId;
+		_G(objectIndex[p]) = 27 + actor->_actorNum; //actor is 3-15
 
 		return true;
 	}
@@ -262,13 +256,11 @@ bool useThunder(int flag) {
 bool useBoots(int flag) {
 	if (flag) {
 		if (_G(thor_info)._magic > 0) {
-			if (_G(thor)->_numMoves == 1) {
-				_G(magicCounter) = 0;
-				addMagic(-1);
-			} else if (_G(magicCounter) > 8) {
+			if (_G(thor)->_numMoves == 1 || _G(magicCounter) > 8) {
 				_G(magicCounter) = 0;
 				addMagic(-1);
 			}
+			
 			_G(thor)->_numMoves = 2;
 			_G(hammer)->_numMoves = 3;
 			return true;
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 2ae125d7e9d..2733ba9d9f5 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -563,12 +563,15 @@ int Scripts::readScriptFile() {
 			else if (ch == 13 || ch == 10) { // Check for CR
 				tmpBuffer[p] = 0;
 				break;
-			} else if ((ch == 39 || ch == 96) && !quoteFlag) {
+			}
+
+			if ((ch == 39 || ch == 96) && !quoteFlag) {
 				tmpBuffer[p] = 0;
 				break;
 			}
 			if (!quoteFlag)
 				ch = toupper(ch);
+			
 			if (quoteFlag || ch > 32) {
 				tmpBuffer[p++] = ch;
 			}
@@ -1071,13 +1074,13 @@ void Scripts::scr_func3() {
 
 	if ((g_events->getRandomNumber(99)) < 25 ||
 		(_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)) {
-		if (!_G(object_map[p]) && _G(scrn)._iconGrid[y][x] >= 140) { // nothing there and solid
+		if (!_G(objectMap[p]) && _G(scrn)._iconGrid[y][x] >= 140) { // nothing there and solid
 			int o = g_events->getRandomNumber(1, 5);
 			if (_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)
 				o = 20;
 
-			_G(object_map[p]) = o;
-			_G(object_index[p]) = 31; // actor is 3-15
+			_G(objectMap[p]) = o;
+			_G(objectIndex[p]) = 31; // actor is 3-15
 		}
 	}
 }
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 843d77514cd..7dd3d0ba9bf 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -134,14 +134,10 @@ public:
 	int _thorRealY1 = 0;
 	int _thorPos = 0;
 
-	uint _timerCounter = 0; // unused?
-	uint _vbl_cnt = 0; // unused?
 	uint _magicCounter = 0;
-	uint _extra_cnt = 0; // unused?
 
-	int _ox = 0, _oy = 0, _of = 0;
-	byte _object_map[TILES_COUNT] = {};
-	byte _object_index[TILES_COUNT] = {};
+	byte _objectMap[TILES_COUNT] = {};
+	byte _objectIndex[TILES_COUNT] = {};
 	int8 _thor_icon1 = 0, _thor_icon2 = 0, _thor_icon3 = 0, _thor_icon4 = 0;
 	int8 _levelMusic = 0;
 	int8 _music_current = -1;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index ee457dca6de..7d95abd1c39 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -240,7 +240,7 @@ void GameContent::drawObjects(GfxSurface &s) {
 		for (int x = 0; x < TILES_X; ++x) {
 			int p = (y * TILES_X) + x;
 
-			byte currObjId = _G(object_map[p]);
+			byte currObjId = _G(objectMap[p]);
 			if (currObjId) {
 				s.simpleBlitFrom(_G(objects[currObjId - 1]), Common::Point(x * TILE_SIZE, y * TILE_SIZE));
 			}
@@ -347,7 +347,7 @@ void GameContent::checkSwitchFlag() {
 
 void GameContent::checkForItem() {
 	int thor_pos = _G(thor)->getPos();
-	if (_G(object_map[thor_pos]))
+	if (_G(objectMap[thor_pos]))
 		pickUpObject(thor_pos);
 }
 




More information about the Scummvm-git-logs mailing list