[Scummvm-git-logs] scummvm master -> c55ee04199520511191af92dfefc4a6485b156c1
Strangerke
noreply at scummvm.org
Tue Jan 14 07:31:11 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:
c55ee04199 GOT: Fix various CppCheck issues
Commit: c55ee04199520511191af92dfefc4a6485b156c1
https://github.com/scummvm/scummvm/commit/c55ee04199520511191af92dfefc4a6485b156c1
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-14T08:31:02+01:00
Commit Message:
GOT: Fix various CppCheck issues
Changed paths:
engines/got/game/boss3.cpp
engines/got/game/script.cpp
engines/got/game/shot_movement.cpp
engines/got/game/shot_pattern.cpp
engines/got/views/credits.cpp
engines/got/views/dialogs/select_item.h
engines/got/views/game_content.cpp
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index a6c2cd7bf10..edfeeda2ee3 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -214,6 +214,8 @@ done1:
// Boss - Loki-1
int boss3_movement(ACTOR *actr) {
int x1, y1, ox, oy;
+ int fcount;
+
if (actr->temp2)
actr->temp2--;
@@ -354,13 +356,14 @@ int boss3_movement(ACTOR *actr) {
actr->y = oy + 2;
break;
}
- actr->frame_count--;
- if (actr->frame_count <= 0) {
+ fcount = actr->frame_count - 1;
+ if (fcount) {
actr->next++;
if (actr->next > 2)
actr->next = 0;
actr->frame_count = 30;
- }
+ } else
+ actr->frame_count = fcount;
skip_move:
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 5d8dab5d315..f5a56d57b26 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -356,8 +356,6 @@ int Scripts::calc_value() {
}
int Scripts::get_next_val() {
- char tmpstr[25];
-
char ch = *_buffPtr;
if (ch == 0 || ch == ':')
return 0;
@@ -370,11 +368,12 @@ int Scripts::get_next_val() {
return 1;
}
- int t = 0;
if (strchr("0123456789-", ch)) {
- tmpstr[0] = ch;
- t++;
+ char tmpstr[25];
+ int t = 0;
+ tmpstr[t] = ch;
_buffPtr++;
+ t++;
while (strchr("0123456789", *_buffPtr) && *_buffPtr != 0) {
tmpstr[t] = *_buffPtr;
_buffPtr++;
@@ -786,7 +785,6 @@ int Scripts::cmd_say(int mode, int type) {
int Scripts::cmd_ask() {
int v = 0;
- uint p;
char title[41], opt[41];
Common::StringArray opts;
@@ -818,7 +816,6 @@ int Scripts::cmd_ask() {
return 5;
_buffPtr++;
- p = _lValue;
} else {
return 5;
}
@@ -833,9 +830,6 @@ int Scripts::cmd_ask() {
return 3;
}
- if (p > opts.size())
- p = 0;
-
// Pause the script execution, and open up an ask window.
// Execution of the script will resume after a selection.
pause();
diff --git a/engines/got/game/shot_movement.cpp b/engines/got/game/shot_movement.cpp
index 50484463fbc..30483690fbe 100644
--- a/engines/got/game/shot_movement.cpp
+++ b/engines/got/game/shot_movement.cpp
@@ -64,15 +64,16 @@ void next_shot_frame(ACTOR *actr) {
actr->next = actr->last_dir;
actr->dir = 0;
} else {
- actr->frame_count--;
+ const int fcount = actr->frame_count - 1;
- if (actr->frame_count <= 0) {
+ if (fcount <= 0) {
actr->next++;
if (actr->next > 3)
actr->next = 0;
actr->frame_count = actr->frame_speed;
- }
+ } else
+ actr->frame_count = fcount;
}
}
@@ -313,7 +314,6 @@ int shot_movement_four(ACTOR *actr) {
return d;
}
}
- y1 = actr->y;
} else {
if (yd) {
y1 += yd;
@@ -636,13 +636,16 @@ int shot_movement_twelve(ACTOR *actr) {
actr->x = x1;
actr->y = y1;
}
- actr->frame_count--;
- if (actr->frame_count <= 0) {
+
+ int fcount = actr->frame_count - 1;
+ if (fcount <= 0) {
actr->next++;
if (actr->next > 1)
actr->next = 0;
actr->frame_count = actr->frame_speed;
- }
+ } else
+ actr->frame_count = fcount;
+
if (actr->directions == 1)
return 0;
return actr->last_dir;
@@ -673,8 +676,10 @@ int shot_movement_thirteen(ACTOR *actr) {
CNT -= XD;
}
}
+
if (actr->temp4)
actr->temp4--;
+
if (!actr->temp4) {
if (_G(actor[actr->creator]).num_shots)
_G(actor[actr->creator]).num_shots--;
@@ -689,6 +694,7 @@ int shot_movement_thirteen(ACTOR *actr) {
_drop_obj(actr, 4);
return 0;
}
+
if (x1 < 16 || x1 > 287 || y1 < 16 || y1 > 159) {
if (x1 < 16 || x1 > 287)
XA = 0 - XA;
@@ -701,15 +707,19 @@ int shot_movement_thirteen(ACTOR *actr) {
actr->x = x1;
actr->y = y1;
}
- actr->frame_count--;
- if (actr->frame_count <= 0) {
+
+ int fcount = actr->frame_count - 1;
+ if (fcount <= 0) {
actr->next++;
if (actr->next > 3)
actr->next = 2;
actr->frame_count = actr->frame_speed;
- }
+ } else
+ actr->frame_count = fcount;
+
if (actr->directions == 1)
return 0;
+
return actr->last_dir;
}
diff --git a/engines/got/game/shot_pattern.cpp b/engines/got/game/shot_pattern.cpp
index a185cae7be0..9ab3d93a7d5 100644
--- a/engines/got/game/shot_pattern.cpp
+++ b/engines/got/game/shot_pattern.cpp
@@ -204,9 +204,8 @@ int shot_pattern_eight(ACTOR *actr) {
if (actr->i1) {
actr->i1--;
} else if (_G(rand1) < 10) {
- actr->i1 = _G(thor_x1);
- actr->i2 = _G(thor_real_y1);
actr->i1 = actr->func_pass;
+ actr->i2 = _G(thor_real_y1);
actor_shoots(actr, 0);
return 1;
}
diff --git a/engines/got/views/credits.cpp b/engines/got/views/credits.cpp
index a088c3f4831..6457e7e67a0 100644
--- a/engines/got/views/credits.cpp
+++ b/engines/got/views/credits.cpp
@@ -76,14 +76,12 @@ void Credits::drawCredit(GfxSurface &s, int gfxNum1, int gfxNum2, int x, int y)
const Gfx::GraphicChunk &lookup = _G(gfx[gfxNum2]);
const byte *lines = data._data;
const byte *lineData = data._data + 2 * data._height;
- byte *dest;
- byte count;
assert(x >= 0 && (x + data._width) <= 320);
assert(y >= 0 && (y + data._height) <= 200);
for (int yCtr = 0; yCtr < data._height; ++yCtr) {
- dest = (byte *)s.getBasePtr(x, y + yCtr);
+ byte *dest = (byte *)s.getBasePtr(x, y + yCtr);
uint16 lineParts = READ_LE_UINT16(lines);
lines += 2;
@@ -92,7 +90,7 @@ void Credits::drawCredit(GfxSurface &s, int gfxNum1, int gfxNum2, int x, int y)
continue;
for (; lineParts > 0; --lineParts) {
- count = *lineData++;
+ byte count = *lineData++;
if (count & 0x80) {
// Shade a range of pixels using lookup table
diff --git a/engines/got/views/dialogs/select_item.h b/engines/got/views/dialogs/select_item.h
index 4994ec2f8c3..cf851465904 100644
--- a/engines/got/views/dialogs/select_item.h
+++ b/engines/got/views/dialogs/select_item.h
@@ -30,7 +30,7 @@ namespace Dialogs {
class SelectItem : public Dialog {
private:
- int _selectedItem;
+ int _selectedItem = -1;
void selectItem();
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index c88c979a98c..c837a2f7f50 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -385,9 +385,8 @@ void GameContent::updateActors() {
}
void GameContent::checkForBossDead() {
- int loop;
-
if (_G(boss_dead)) {
+ int loop;
for (loop = 3; loop < 7; loop++) {
if (_G(actor[loop]).used)
break;
@@ -668,18 +667,17 @@ void GameContent::drawLightning(GfxSurface &s) {
}
void GameContent::lightningCountdownDone() {
- int x, y, i, ax, ay;
_G(gameMode) = MODE_NORMAL;
- x = _G(thor)->x + 7;
- y = _G(thor)->y + 7;
+ int x = _G(thor)->x + 7;
+ int y = _G(thor)->y + 7;
- for (i = 3; i < MAX_ACTORS; i++) {
+ for (int i = 3; i < MAX_ACTORS; i++) {
if (!_G(actor[i]).used)
continue;
- ax = _G(actor[i]).x + (_G(actor[i]).size_x / 2);
- ay = _G(actor[i]).y + (_G(actor[i]).size_y / 2);
+ int ax = _G(actor[i]).x + (_G(actor[i]).size_x / 2);
+ int ay = _G(actor[i]).y + (_G(actor[i]).size_y / 2);
if ((ABS(ax - x) < 30) && (ABS(ay - y) < 30)) {
_G(actor[i]).magic_hit = 1;
More information about the Scummvm-git-logs
mailing list