[Scummvm-git-logs] scummvm master -> a926741308f9657f6a2952033cec9e5ee8c67bb7

Strangerke noreply at scummvm.org
Sat Jul 29 07:06:35 UTC 2023


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:
a926741308 AVALANCHE: Fix some more issues reported by pvs-studio


Commit: a926741308f9657f6a2952033cec9e5ee8c67bb7
    https://github.com/scummvm/scummvm/commit/a926741308f9657f6a2952033cec9e5ee8c67bb7
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2023-07-29T08:06:27+01:00

Commit Message:
AVALANCHE: Fix some more issues reported by pvs-studio

Changed paths:
    engines/avalanche/animation.cpp
    engines/avalanche/help.cpp
    engines/avalanche/highscore.cpp
    engines/avalanche/nim.cpp
    engines/avalanche/parser.cpp


diff --git a/engines/avalanche/animation.cpp b/engines/avalanche/animation.cpp
index 4eb1475301d..6eb9ce0b0a4 100644
--- a/engines/avalanche/animation.cpp
+++ b/engines/avalanche/animation.cpp
@@ -79,6 +79,8 @@ AnimationType::AnimationType(Animation *anim) {
 	_fgBubbleCol = kColorWhite;
 	_bgBubbleCol = kColorBlack;
 	_id = 177;
+	_oldX[0] = _oldX[1] = 0;
+	_oldY[0] = _oldY[1] = 0;
 }
 
 /**
diff --git a/engines/avalanche/help.cpp b/engines/avalanche/help.cpp
index 5ce91a73e0c..991ff3c16e9 100644
--- a/engines/avalanche/help.cpp
+++ b/engines/avalanche/help.cpp
@@ -167,7 +167,7 @@ bool Help::handleMouse(const Common::Event &event) {
 	mousePos.x = event.mouse.x;
 	mousePos.y = event.mouse.y / 2;
 
-	int index = -1;
+	int index;
 
 	if (event.type == Common::EVENT_LBUTTONUP) { // Clicked *somewhere*...
 		_holdLeft = false;
@@ -178,6 +178,7 @@ bool Help::handleMouse(const Common::Event &event) {
 			index = ((mousePos.y - 13) / 27) - 1;
 	} else { // LBUTTONDOWN or MOUSEMOVE
 		int highlightIs = 0;
+		index = -1;
 
 		// Decide which button we are hovering the cursor over:
 		if ((mousePos.x > 470) && (mousePos.x <= 550) && (((mousePos.y - 13) % 27) <= 20)) { // No click, so highlight.
@@ -208,12 +209,11 @@ bool Help::handleMouse(const Common::Event &event) {
 	if ((index >= 0) && (_buttons[index]._trigger != Common::KEYCODE_INVALID)) {
 		if (_buttons[index]._trigger == Common::KEYCODE_ESCAPE)
 			return true;
-		else {
-			_vm->fadeOut();
-			switchPage(_buttons[index]._whither);
-			_vm->fadeIn();
-			return false;
-		}
+
+		_vm->fadeOut();
+		switchPage(_buttons[index]._whither);
+		_vm->fadeIn();
+		return false;
 	}
 
 	return false;
diff --git a/engines/avalanche/highscore.cpp b/engines/avalanche/highscore.cpp
index 0a034d76019..11ff3a4f304 100644
--- a/engines/avalanche/highscore.cpp
+++ b/engines/avalanche/highscore.cpp
@@ -34,6 +34,12 @@ namespace Avalanche {
 
 HighScore::HighScore(AvalancheEngine *vm) {
 	_vm = vm;
+
+	for (int i = 0; i < 12; ++i) {
+		_data[i]._name = "";
+		_data[i]._rank = "";
+		_data[i]._score = 0;
+	}
 }
 
 void HighScore::displayHighScores() {
diff --git a/engines/avalanche/nim.cpp b/engines/avalanche/nim.cpp
index 88de3ce3e70..6f96aa54f51 100644
--- a/engines/avalanche/nim.cpp
+++ b/engines/avalanche/nim.cpp
@@ -280,6 +280,7 @@ bool Nim::checkInput() {
 					if (_number > 1)
 						_number--;
 					return false;
+				case Common::KEYCODE_END:
 				case Common::KEYCODE_1:
 					_number = 1;
 					return false;
@@ -308,9 +309,6 @@ bool Nim::checkInput() {
 				case Common::KEYCODE_HOME:
 					_number = _stones[_row];
 					return false;
-				case Common::KEYCODE_END:
-					_number = 1;
-					return false;
 				case Common::KEYCODE_UP:
 					_row--;
 					if (_row < 0)
diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp
index e855c901bb1..7d15862d0be 100644
--- a/engines/avalanche/parser.cpp
+++ b/engines/avalanche/parser.cpp
@@ -54,6 +54,9 @@ Parser::Parser(AvalancheEngine *vm) {
 	_alcoholLevel = 0;
 
 	_boughtOnion = false;
+
+	for (int i = 0; i < kParserWordsNum; ++i)
+		_vocabulary[i].init(1, "");
 }
 
 void Parser::init() {
@@ -829,11 +832,7 @@ void Parser::parse() {
 		// Check Accis's own table (words[]) for "global" commands.
 		if (notfound) {
 			byte answer = wordNum(thisword);
-			if (answer == kPardon) {
-				notfound = true;
-				_thats = _thats + kPardon;
-			} else
-				_thats = _thats + answer;
+			_thats = _thats + answer;
 			n++;
 		}
 
@@ -1098,7 +1097,8 @@ void Parser::examine() {
 			else if ((50 <= _thing) && (_thing <= 100)) {
 				// Also _thing
 				int id = _thing - 50;
-				assert(id < 31);
+				if (id >= 31)
+					error("Parser::Examine - Unexpected _thing value %d (>80)", _thing);
 				openBox(true);
 				_vm->_dialogs->displayText(*_vm->_also[id][1]);
 				openBox(false);




More information about the Scummvm-git-logs mailing list