[Scummvm-git-logs] scummvm master -> 14e6b23c4d0338958b00f7a9700450776a448ea3

kelmer44 noreply at scummvm.org
Fri Oct 3 06:33:48 UTC 2025


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:
14e6b23c4d TOT: Rework redundant conditions. PVS-Studio: V560


Commit: 14e6b23c4d0338958b00f7a9700450776a448ea3
    https://github.com/scummvm/scummvm/commit/14e6b23c4d0338958b00f7a9700450776a448ea3
Author: kelmer (kelmer at gmail.com)
Date: 2025-10-03T08:33:34+02:00

Commit Message:
TOT: Rework redundant conditions. PVS-Studio: V560

Changed paths:
    engines/tot/cutscenes.cpp
    engines/tot/debug.cpp
    engines/tot/dialog.cpp
    engines/tot/engine.cpp
    engines/tot/tot.cpp


diff --git a/engines/tot/cutscenes.cpp b/engines/tot/cutscenes.cpp
index 978eb7c4ea9..bb409cf0629 100644
--- a/engines/tot/cutscenes.cpp
+++ b/engines/tot/cutscenes.cpp
@@ -294,13 +294,13 @@ void TotEngine::credits() {
 	if (keyPressed() || shouldExit)
 		goto Lexit;
 	removeTitle(background2);
-	if (keyPressed() || shouldExit)
+	if (keyPressed())
 		goto Lexit;
 	_graphics->putImg(0, 0, background2);
-	if (keyPressed() || shouldExit)
+	if (keyPressed())
 		goto Lexit;
 	_graphics->copyFromScreen(background);
-	if (keyPressed() || shouldExit)
+	if (keyPressed())
 		goto Lexit;
 	scrollCredit(59904, 8004, pal2, background, shouldExit, 10, false, true);
 	if (keyPressed() || shouldExit)
@@ -324,13 +324,13 @@ void TotEngine::credits() {
 	if (keyPressed() || shouldExit)
 		goto Lexit;
 	removeTitle(background2);
-	if (keyPressed() || shouldExit)
+	if (keyPressed())
 		goto Lexit;
 	_graphics->putImg(0, 0, background2);
-	if (keyPressed() || shouldExit)
+	if (keyPressed())
 		goto Lexit;
 	_graphics->copyFromScreen(background);
-	if (keyPressed() || shouldExit)
+	if (keyPressed())
 		goto Lexit;
 	scrollCredit(121308, 8004, pal2, background, shouldExit, 80, false, true);
 Lexit:
diff --git a/engines/tot/debug.cpp b/engines/tot/debug.cpp
index deb54f1a735..ba46c7f9cfa 100644
--- a/engines/tot/debug.cpp
+++ b/engines/tot/debug.cpp
@@ -37,9 +37,7 @@ void drawMouseGrid(RoomFileRegister *screen) {
 				for (int j2 = 0; j2 < kYGridCount; j2++) {
 					int absPixel = startY + j2;
 					int offsetX = (absPixel % 2 == 0) ? 1 : 0;
-					if (offsetX < startX + kXGridCount && color != 0) {
-						*(byte *)g_engine->_screen->getBasePtr(startX + i2 + offsetX, startY + j2) = 255 - color;
-					}
+					*(byte *)g_engine->_screen->getBasePtr(startX + i2 + offsetX, startY + j2) = 255 - color;
 				}
 			}
 
@@ -61,9 +59,7 @@ void drawScreenGrid(RoomFileRegister *screen) {
 				for (int j2 = 0; j2 < kYGridCount; j2++) {
 					int absPixel = startY + j2;
 					int offsetX = (absPixel % 2 == 0) ? 1 : 0;
-					if (offsetX < startX + kXGridCount && color != 0) {
-						*(byte *)g_engine->_screen->getBasePtr(startX + i2 + offsetX, startY + j2) = 255 - color;
-					}
+					*(byte *)g_engine->_screen->getBasePtr(startX + i2 + offsetX, startY + j2) = 255 - color;
 				}
 			}
 		}
diff --git a/engines/tot/dialog.cpp b/engines/tot/dialog.cpp
index 48b81931730..7d65d4038f9 100644
--- a/engines/tot/dialog.cpp
+++ b/engines/tot/dialog.cpp
@@ -364,17 +364,17 @@ void showDialogOptions(
 				selectedConv = 0;
 			else {
 				if (g_engine->_mouse->mouseClickX <= 280) {
-					if (g_engine->_mouse->mouseClickY >= 143 && g_engine->_mouse->mouseClickY <= 155) {
+					if (g_engine->_mouse->mouseClickY <= 155) {
 						selectedConv = firstChat;
-					} else if (g_engine->_mouse->mouseClickY >= 156 && g_engine->_mouse->mouseClickY <= 166) {
+					} else if (g_engine->_mouse->mouseClickY <= 166) {
 						selectedConv = firstChat + 1;
-					} else if (g_engine->_mouse->mouseClickY >= 167 && g_engine->_mouse->mouseClickY <= 177) {
+					} else if (g_engine->_mouse->mouseClickY <= 177) {
 						selectedConv = firstChat + 2;
-					} else if (g_engine->_mouse->mouseClickY >= 178 && g_engine->_mouse->mouseClickY <= 186) {
+					} else if (g_engine->_mouse->mouseClickY <= 186) {
 						selectedConv = firstChat + 3;
 					}
-				} else if (g_engine->_mouse->mouseClickX >= 281 && g_engine->_mouse->mouseClickX <= 319) {
-					if (g_engine->_mouse->mouseClickY >= 143 && g_engine->_mouse->mouseClickY <= 165) {
+				} else if (g_engine->_mouse->mouseClickX <= 319) {
+					if (g_engine->_mouse->mouseClickY <= 165) {
 						if (firstChat > 1) {
 							selectedConv = 0;
 							firstChat -= 1;
diff --git a/engines/tot/engine.cpp b/engines/tot/engine.cpp
index 2cf8ef3ae72..9cac9bb1b62 100644
--- a/engines/tot/engine.cpp
+++ b/engines/tot/engine.cpp
@@ -98,10 +98,10 @@ void TotEngine::runaroundRed() {
 			if (secTrajIndex <= 8) {
 				_secondaryAnimation.dir = 2;
 				_secondaryAnimation.depth = 1;
-			} else if (secTrajIndex >= 9 && secTrajIndex <= 33) {
+			} else if (secTrajIndex <= 33) {
 				_secondaryAnimation.dir = 2;
 				_secondaryAnimation.depth = 14;
-			} else if (secTrajIndex >= 34 && secTrajIndex <= 63) {
+			} else if (secTrajIndex <= 63) {
 				_secondaryAnimation.dir = 1;
 				_secondaryAnimation.depth = 14;
 			} else {
@@ -4318,7 +4318,7 @@ void TotEngine::clearAnimation() {
 		_curSecondaryAnimationFrame = nullptr;
 		for (int j = 0; j < _secondaryAnimDirCount; j++) {
 			for (int i = 0; i < _secondaryAnimationFrameCount; i++) {
-				if (_secondaryAnimation.bitmap[j][i] != nullptr && _secondaryAnimation.bitmap[j][i] != _curSecondaryAnimationFrame) {
+				if (_secondaryAnimation.bitmap[j][i] != nullptr) {
 					free(_secondaryAnimation.bitmap[j][i]);
 				}
 				_secondaryAnimation.bitmap[j][i] = nullptr;
@@ -4678,7 +4678,7 @@ void TotEngine::checkMouseGrid() {
 		}
 		_oldActionCode = 253;
 		_oldInventoryObjectName = "";
-	} else if (_mouse->mouseY >= 132 && _mouse->mouseY <= 165) {
+	} else if (_mouse->mouseY <= 165) {
 		if (_actionCode != _oldActionCode) {
 			bar(0, 140, 319, 149, 0);
 			Common::String actionLine;
@@ -4715,7 +4715,7 @@ void TotEngine::checkMouseGrid() {
 			_oldGridX = 0;
 			_oldGridY = 0;
 		}
-	} else if (_mouse->mouseY >= 166 && _mouse->mouseY <= 199) {
+	} else if (_mouse->mouseY <= 199) {
 		if (_mouse->mouseX >= 26 && _mouse->mouseX <= 65) {
 			invObject = _inventory[_inventoryPosition].objectName;
 		} else if (_mouse->mouseX >= 70 && _mouse->mouseX <= 108) {
@@ -5063,8 +5063,8 @@ void TotEngine::copyProtection() {
 		int correctedMouseY = _mouse->mouseClickY + 7;
 
 		if ((correctedMouseX > 59 && correctedMouseX < 180) && (correctedMouseY > 28 && correctedMouseY < 119)) {
-			if (correctedMouseY >= 29 && correctedMouseY <= 58) {
-				if (correctedMouseX >= 60 && correctedMouseX <= 89) {
+			if (correctedMouseY <= 58) {
+				if (correctedMouseX <= 89) {
 					if (cursorPos < 50) {
 						_sound->beep(200, beepDelay);
 						buttonPress(60, 29, 89, 58, true);
@@ -5075,7 +5075,7 @@ void TotEngine::copyProtection() {
 					} else {
 						_sound->beep(70, 250);
 					}
-				} else if (correctedMouseX >= 90 && correctedMouseX <= 119) {
+				} else if (correctedMouseX <= 119) {
 					if (cursorPos < 50) {
 						_sound->beep(250, beepDelay);
 						buttonPress(90, 29, 119, 58, true);
@@ -5086,7 +5086,7 @@ void TotEngine::copyProtection() {
 					} else {
 						_sound->beep(70, 250);
 					}
-				} else if (correctedMouseX >= 120 && correctedMouseX <= 149) {
+				} else if (correctedMouseX <= 149) {
 					if (cursorPos < 50) {
 						_sound->beep(300, beepDelay);
 						buttonPress(120, 29, 149, 58, true);
@@ -5097,7 +5097,7 @@ void TotEngine::copyProtection() {
 					} else {
 						_sound->beep(70, 250);
 					}
-				} else if (correctedMouseX >= 150 && correctedMouseX <= 179) {
+				} else {
 					if (cursorPos < 50) {
 						_sound->beep(350, beepDelay);
 						buttonPress(150, 29, 179, 58, true);
@@ -5109,8 +5109,8 @@ void TotEngine::copyProtection() {
 						_sound->beep(70, 250);
 					}
 				}
-			} else if (correctedMouseY >= 59 && correctedMouseY <= 88) {
-				if (correctedMouseX >= 60 && correctedMouseX <= 89) {
+			} else if (correctedMouseY <= 88) {
+				if (correctedMouseX <= 89) {
 					if (cursorPos < 50) {
 						_sound->beep(400, beepDelay);
 						buttonPress(60, 59, 89, 88, true);
@@ -5121,7 +5121,7 @@ void TotEngine::copyProtection() {
 					} else {
 						_sound->beep(70, 250);
 					}
-				} else if (correctedMouseX >= 90 && correctedMouseX <= 119) {
+				} else if (correctedMouseX <= 119) {
 					if (cursorPos < 50) {
 						_sound->beep(450, beepDelay);
 						buttonPress(90, 59, 119, 88, true);
@@ -5132,7 +5132,7 @@ void TotEngine::copyProtection() {
 					} else {
 						_sound->beep(70, 250);
 					}
-				} else if (correctedMouseX >= 120 && correctedMouseX <= 149) {
+				} else if (correctedMouseX <= 149) {
 					if (cursorPos < 50) {
 						_sound->beep(500, beepDelay);
 						buttonPress(120, 59, 149, 88, true);
@@ -5143,7 +5143,7 @@ void TotEngine::copyProtection() {
 					} else {
 						_sound->beep(70, 250);
 					}
-				} else if (correctedMouseX >= 150 && correctedMouseX <= 179) {
+				} else {
 					if (cursorPos < 50) {
 						_sound->beep(550, beepDelay);
 						buttonPress(150, 59, 179, 88, true);
@@ -5155,8 +5155,8 @@ void TotEngine::copyProtection() {
 						_sound->beep(70, 250);
 					}
 				}
-			} else if (correctedMouseY >= 89 && correctedMouseY <= 118) {
-				if (correctedMouseX >= 60 && correctedMouseX <= 89) {
+			} else {
+				if (correctedMouseX <= 89) {
 					if (cursorPos < 50) {
 						_sound->beep(600, beepDelay);
 						buttonPress(60, 89, 89, 118, true);
@@ -5167,7 +5167,7 @@ void TotEngine::copyProtection() {
 					} else {
 						_sound->beep(70, 250);
 					}
-				} else if (correctedMouseX >= 90 && correctedMouseX <= 119) {
+				} else if (correctedMouseX <= 119) {
 					if (cursorPos < 50) {
 						_sound->beep(650, beepDelay);
 						buttonPress(90, 89, 119, 118, true);
@@ -5178,7 +5178,7 @@ void TotEngine::copyProtection() {
 					} else {
 						_sound->beep(70, 250);
 					}
-				} else if (correctedMouseX >= 120 && correctedMouseX <= 149) {
+				} else if (correctedMouseX <= 149) {
 					if (cursorPos > 0) {
 						_sound->beep(700, beepDelay);
 						buttonPress(120, 89, 149, 118, true);
@@ -5189,7 +5189,7 @@ void TotEngine::copyProtection() {
 					} else {
 						_sound->beep(70, 250);
 					}
-				} else if (correctedMouseX >= 150 && correctedMouseX <= 179) {
+				} else {
 					if (cursorPos > 39) {
 						_sound->beep(750, beepDelay);
 						buttonPress(150, 89, 179, 118, true);
diff --git a/engines/tot/tot.cpp b/engines/tot/tot.cpp
index 54bacf7925a..5f89b84236c 100644
--- a/engines/tot/tot.cpp
+++ b/engines/tot/tot.cpp
@@ -400,7 +400,7 @@ void TotEngine::processEvents(bool &escapePressed) {
 }
 
 int TotEngine::startGame() {
-	if(shouldQuit()) {
+	if (shouldQuit()) {
 		return 0;
 	}
 	_sound->fadeOutMusic();
@@ -1262,7 +1262,7 @@ void TotEngine::mainMenu(bool fade) {
 					_startNewGame = false;
 					validOption = true;
 					_continueGame = true;
-				} else if (x > 173 && y < 288) {
+				} else if (x > 173 && x < 288) {
 					exitToDOS();
 				}
 			}




More information about the Scummvm-git-logs mailing list