AVALANCHE: Fix some more issues reported by pvs-studio

This commit is contained in:
Strangerke 2023-07-29 08:06:27 +01:00
parent 0b809f4339
commit a926741308
5 changed files with 22 additions and 16 deletions

View File

@ -79,6 +79,8 @@ AnimationType::AnimationType(Animation *anim) {
_fgBubbleCol = kColorWhite;
_bgBubbleCol = kColorBlack;
_id = 177;
_oldX[0] = _oldX[1] = 0;
_oldY[0] = _oldY[1] = 0;
}
/**

View File

@ -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;

View File

@ -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() {

View File

@ -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)

View File

@ -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);