[Scummvm-git-logs] scummvm master -> d37b7918e122769ea6c2ca126f6de23694182563
Strangerke
noreply at scummvm.org
Tue Jan 21 07:38:24 UTC 2025
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
982a747001 GOT: More renaming in shot_movement, shot_pattern and special_tile
d37b7918e1 GOT: Fix several issues reported by Coverity
Commit: 982a747001520afbc471b6da907f2147cbf84c18
https://github.com/scummvm/scummvm/commit/982a747001520afbc471b6da907f2147cbf84c18
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-21T07:09:17+01:00
Commit Message:
GOT: More renaming in shot_movement, shot_pattern and special_tile
Changed paths:
engines/got/game/move.cpp
engines/got/game/move_patterns.cpp
engines/got/game/shot_movement.cpp
engines/got/game/shot_movement.h
engines/got/game/shot_pattern.cpp
engines/got/game/shot_pattern.h
engines/got/game/special_tile.cpp
engines/got/game/special_tile.h
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 09f8d6bd4e7..12ec33728a0 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -340,7 +340,7 @@ void moveActor(Actor *actor) {
if (!actor->_shotCountdown && _G(shot_ok)) {
if (actor->_numShotsAllowed) {
if (actor->_currNumShots < actor->_numShotsAllowed) {
- shot_pattern_func[actor->_shotPattern](actor);
+ shotPatternFunc[actor->_shotPattern](actor);
}
}
}
@@ -355,7 +355,7 @@ void moveActor(Actor *actor) {
int i;
if (actor->_type == 3)
- i = shot_movement_func[actor->_moveType](actor);
+ i = shotMovementFunc[actor->_moveType](actor);
else
i = _movementFunc[actor->_moveType](actor);
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 0d388c64c01..91c42a401e3 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -259,7 +259,7 @@ int checkMove0(const int x, const int y, Actor *actor) {
return 0;
if (icn1 > TILE_SPECIAL) {
- if (!special_tile_thor(y1, x1, icn1))
+ if (!specialTileThor(y1, x1, icn1))
return 0;
icn2 = _G(scrn)._iconGrid[y2][x1];
icn3 = _G(scrn)._iconGrid[y1][x2];
@@ -267,19 +267,19 @@ int checkMove0(const int x, const int y, Actor *actor) {
}
if (icn2 > TILE_SPECIAL) {
- if (!special_tile_thor(y2, x1, icn2))
+ if (!specialTileThor(y2, x1, icn2))
return 0;
icn3 = _G(scrn)._iconGrid[y1][x2];
icn4 = _G(scrn)._iconGrid[y2][x2];
}
if (icn3 > TILE_SPECIAL) {
- if (!special_tile_thor(y1, x2, icn3))
+ if (!specialTileThor(y1, x2, icn3))
return 0;
icn4 = _G(scrn)._iconGrid[y2][x2];
}
- if (icn4 > TILE_SPECIAL && !special_tile_thor(y2, x2, icn4))
+ if (icn4 > TILE_SPECIAL && !specialTileThor(y2, x2, icn4))
return 0;
}
@@ -372,16 +372,16 @@ int checkMove1(const int x, const int y, Actor *actor) {
return 0;
}
- if (icn1 > TILE_SPECIAL && !special_tile(actor, y1, x1, icn1))
+ if (icn1 > TILE_SPECIAL && !specialTile(actor, y1, x1, icn1))
return 0;
- if (icn2 > TILE_SPECIAL && !special_tile(actor, y2, x1, icn2))
+ if (icn2 > TILE_SPECIAL && !specialTile(actor, y2, x1, icn2))
return 0;
- if (icn3 > TILE_SPECIAL && !special_tile(actor, y1, x2, icn3))
+ if (icn3 > TILE_SPECIAL && !specialTile(actor, y1, x2, icn3))
return 0;
- if (icn4 > TILE_SPECIAL && !special_tile(actor, y2, x2, icn4))
+ if (icn4 > TILE_SPECIAL && !specialTile(actor, y2, x2, icn4))
return 0;
x1 = x + 1;
@@ -465,16 +465,16 @@ int checkMove2(const int x, const int y, Actor *actor) {
return 0;
if (icn1 > TILE_SPECIAL)
- if (!special_tile(actor, y1, x1, icn1))
+ if (!specialTile(actor, y1, x1, icn1))
return 0;
if (icn2 > TILE_SPECIAL)
- if (!special_tile(actor, y2, x1, icn2))
+ if (!specialTile(actor, y2, x1, icn2))
return 0;
if (icn3 > TILE_SPECIAL)
- if (!special_tile(actor, y1, x2, icn3))
+ if (!specialTile(actor, y1, x2, icn3))
return 0;
if (icn4 > TILE_SPECIAL)
- if (!special_tile(actor, y2, x2, icn4))
+ if (!specialTile(actor, y2, x2, icn4))
return 0;
x1 = x + 1;
@@ -542,13 +542,13 @@ int checkMove3(const int x, const int y, Actor *actor) {
if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
return 0;
- if (icn1 > TILE_SPECIAL && !special_tile(actor, y1, x1, icn1))
+ if (icn1 > TILE_SPECIAL && !specialTile(actor, y1, x1, icn1))
return 0;
- if (icn2 > TILE_SPECIAL && !special_tile(actor, y2, x1, icn2))
+ if (icn2 > TILE_SPECIAL && !specialTile(actor, y2, x1, icn2))
return 0;
- if (icn3 > TILE_SPECIAL && !special_tile(actor, y1, x2, icn3))
+ if (icn3 > TILE_SPECIAL && !specialTile(actor, y1, x2, icn3))
return 0;
- if (icn4 > TILE_SPECIAL && !special_tile(actor, y2, x2, icn4))
+ if (icn4 > TILE_SPECIAL && !specialTile(actor, y2, x2, icn4))
return 0;
// Check for solid or fly over
@@ -828,13 +828,13 @@ int checkSpecialMove1(const int x, const int y, Actor *actor) {
if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
return 0;
- if (icn1 > TILE_SPECIAL && !special_tile(actor, y1, x1, icn1))
+ if (icn1 > TILE_SPECIAL && !specialTile(actor, y1, x1, icn1))
return 0;
- if (icn2 > TILE_SPECIAL && !special_tile(actor, y2, x1, icn2))
+ if (icn2 > TILE_SPECIAL && !specialTile(actor, y2, x1, icn2))
return 0;
- if (icn3 > TILE_SPECIAL && !special_tile(actor, y1, x2, icn3))
+ if (icn3 > TILE_SPECIAL && !specialTile(actor, y1, x2, icn3))
return 0;
- if (icn4 > TILE_SPECIAL && !special_tile(actor, y2, x2, icn4))
+ if (icn4 > TILE_SPECIAL && !specialTile(actor, y2, x2, icn4))
return 0;
x1 = x;
diff --git a/engines/got/game/shot_movement.cpp b/engines/got/game/shot_movement.cpp
index 2d97a8619ff..f90df5b240c 100644
--- a/engines/got/game/shot_movement.cpp
+++ b/engines/got/game/shot_movement.cpp
@@ -28,220 +28,233 @@
namespace Got {
-int shot_movement_none(Actor *actr);
-int shot_movement_one(Actor *actr);
-int shot_movement_two(Actor *actr);
-int shot_movement_three(Actor *actr);
-int shot_movement_four(Actor *actr);
-int shot_movement_five(Actor *actr);
-int shot_movement_six(Actor *actr);
-int shot_movement_seven(Actor *actr);
-int shot_movement_eight(Actor *actr);
-int shot_movement_nine(Actor *actr);
-int shot_movement_ten(Actor *actr);
-int shot_movement_eleven(Actor *actr);
-int shot_movement_twelve(Actor *actr);
-int shot_movement_thirteen(Actor *actr);
-
-int (*const shot_movement_func[])(Actor *actr) = {
- shot_movement_none,
- shot_movement_one,
- shot_movement_two,
- shot_movement_three,
- shot_movement_four,
- shot_movement_five,
- shot_movement_six,
- shot_movement_seven,
- shot_movement_eight,
- shot_movement_nine,
- shot_movement_ten,
- shot_movement_eleven,
- shot_movement_twelve,
- shot_movement_thirteen};
-
-void next_shot_frame(Actor *actr) {
- if (actr->_directions == 4 && actr->_framesPerDirection == 1) {
- actr->_nextFrame = actr->_lastDir;
- actr->_dir = 0;
+int shotMovementNone(Actor *actor);
+int shotMovementOne(Actor *actor);
+int shotMovementTwo(Actor *actor);
+int shotMovementThree(Actor *actor);
+int shotMovementFour(Actor *actor);
+int shotMovementFive(Actor *actor);
+int shotMovementSix(Actor *actor);
+int shotMovementSeven(Actor *actor);
+int shotMovementEight(Actor *actor);
+int shotMovementNine(Actor *actor);
+int shotMovementTen(Actor *actor);
+int shotMovementEleven(Actor *actor);
+int shotMovementTwelve(Actor *actor);
+int shotMovementThirteen(Actor *actor);
+
+int (*const shotMovementFunc[])(Actor *actor) = {
+ shotMovementNone,
+ shotMovementOne,
+ shotMovementTwo,
+ shotMovementThree,
+ shotMovementFour,
+ shotMovementFive,
+ shotMovementSix,
+ shotMovementSeven,
+ shotMovementEight,
+ shotMovementNine,
+ shotMovementTen,
+ shotMovementEleven,
+ shotMovementTwelve,
+ shotMovementThirteen
+};
+
+void next_shot_frame(Actor *actor) {
+ if (actor->_directions == 4 && actor->_framesPerDirection == 1) {
+ actor->_nextFrame = actor->_lastDir;
+ actor->_dir = 0;
} else {
- const int fcount = actr->_frameCount - 1;
+ const int fcount = actor->_frameCount - 1;
if (fcount <= 0) {
- actr->_nextFrame++;
- if (actr->_nextFrame > 3)
- actr->_nextFrame = 0;
+ actor->_nextFrame++;
+ if (actor->_nextFrame > 3)
+ actor->_nextFrame = 0;
- actr->_frameCount = actr->_frameSpeed;
+ actor->_frameCount = actor->_frameSpeed;
} else
- actr->_frameCount = fcount;
+ actor->_frameCount = fcount;
}
}
// Boss - snake
-int shot_movement_none(Actor *actr) {
- actr->_temp3--;
- if (!actr->_temp3) {
- actorDestroyed(actr);
- if (_G(actor[actr->_creator])._currNumShots)
- _G(actor[actr->_creator])._currNumShots--;
+int shotMovementNone(Actor *actor) {
+ actor->_temp3--;
+ if (!actor->_temp3) {
+ actorDestroyed(actor);
+ if (_G(actor[actor->_creator])._currNumShots)
+ _G(actor[actor->_creator])._currNumShots--;
}
- next_shot_frame(actr);
- if (actr->_directions == 1)
+ next_shot_frame(actor);
+ if (actor->_directions == 1)
return 0;
- return actr->_lastDir;
+ return actor->_lastDir;
}
-int shot_movement_one(Actor *actr) {
+int shotMovementOne(Actor *actor) {
int x1 = 0, y1 = 0;
- int d = actr->_lastDir;
+ const int d = actor->_lastDir;
switch (d) {
case 0:
- x1 = actr->_x;
- y1 = actr->_y - 2;
+ x1 = actor->_x;
+ y1 = actor->_y - 2;
break;
+
case 1:
- x1 = actr->_x;
- y1 = actr->_y + 2;
+ x1 = actor->_x;
+ y1 = actor->_y + 2;
break;
+
case 2:
- x1 = actr->_x - 2;
- y1 = actr->_y;
+ x1 = actor->_x - 2;
+ y1 = actor->_y;
break;
+
case 3:
- x1 = actr->_x + 2;
- y1 = actr->_y;
+ x1 = actor->_x + 2;
+ y1 = actor->_y;
+ break;
+
+ default:
break;
}
- if (!checkMove3(x1, y1, actr)) {
- actorDestroyed(actr);
- if (_G(actor[actr->_creator])._currNumShots)
- _G(actor[actr->_creator])._currNumShots--;
+ if (!checkMove3(x1, y1, actor)) {
+ actorDestroyed(actor);
+ if (_G(actor[actor->_creator])._currNumShots)
+ _G(actor[actor->_creator])._currNumShots--;
} else {
- next_shot_frame(actr);
- actr->_lastDir = d;
+ next_shot_frame(actor);
+ actor->_lastDir = d;
}
- if (actr->_directions == 1)
+ if (actor->_directions == 1)
return 0;
- if (actr->_directions == 4 && actr->_framesPerDirection == 1)
+ if (actor->_directions == 4 && actor->_framesPerDirection == 1)
return 0;
return d;
}
-int shot_movement_two(Actor *actr) {
+int shotMovementTwo(Actor *actor) {
int x1 = 0, y1 = 0;
- int d = actr->_lastDir;
+ const int d = actor->_lastDir;
switch (d) {
case 0:
- x1 = actr->_x;
- y1 = actr->_y - 2;
+ x1 = actor->_x;
+ y1 = actor->_y - 2;
break;
+
case 1:
- x1 = actr->_x;
- y1 = actr->_y + 2;
+ x1 = actor->_x;
+ y1 = actor->_y + 2;
break;
+
case 2:
- x1 = actr->_x - 2;
- y1 = actr->_y;
+ x1 = actor->_x - 2;
+ y1 = actor->_y;
break;
+
case 3:
- x1 = actr->_x + 2;
- y1 = actr->_y;
+ x1 = actor->_x + 2;
+ y1 = actor->_y;
+ break;
+
+ default:
break;
}
- if (!checkMove4(x1, y1, actr)) {
- actorDestroyed(actr);
- if (_G(actor[actr->_creator])._currNumShots)
- _G(actor[actr->_creator])._currNumShots--;
+ if (!checkMove4(x1, y1, actor)) {
+ actorDestroyed(actor);
+ if (_G(actor[actor->_creator])._currNumShots)
+ _G(actor[actor->_creator])._currNumShots--;
} else {
- next_shot_frame(actr);
- actr->_lastDir = d;
+ next_shot_frame(actor);
+ actor->_lastDir = d;
}
- if (actr->_directions == 1)
+ if (actor->_directions == 1)
return 0;
- if (actr->_directions == 4 && actr->_framesPerDirection == 1)
+ if (actor->_directions == 4 && actor->_framesPerDirection == 1)
return 0;
return d;
}
// Serpent fire
-int shot_movement_three(Actor *actr) {
- int d = actr->_lastDir;
+int shotMovementThree(Actor *actor) {
+ const int d = actor->_lastDir;
- actr->_x -= 2;
- actr->_temp3--;
- actr->_temp4--;
+ actor->_x -= 2;
+ actor->_temp3--;
+ actor->_temp4--;
if (overlap(_G(thor_x1) - 1, _G(thor_y1) - 1, _G(thor_x2) + 1, _G(thor_y2) + 1,
- actr->_x, actr->_y, actr->_x + 15, actr->_y + 15)) {
- actr->_moveType = 0;
- actr->_speed = 6;
- thorDamaged(actr);
- actr->_x += 2;
- }
- if (!actr->_temp4) {
- actr->_temp4 = actr->_temp5;
- actr->_speed++;
- if (actr->_speed > 6)
- actr->_moveType = 0;
- }
- if (!actr->_temp3) {
- actorDestroyed(actr);
- if (_G(actor[actr->_creator])._currNumShots)
- _G(actor[actr->_creator])._currNumShots--;
+ actor->_x, actor->_y, actor->_x + 15, actor->_y + 15)) {
+ actor->_moveType = 0;
+ actor->_speed = 6;
+ thorDamaged(actor);
+ actor->_x += 2;
+ }
+ if (!actor->_temp4) {
+ actor->_temp4 = actor->_temp5;
+ actor->_speed++;
+ if (actor->_speed > 6)
+ actor->_moveType = 0;
+ }
+ if (!actor->_temp3) {
+ actorDestroyed(actor);
+ if (_G(actor[actor->_creator])._currNumShots)
+ _G(actor[actor->_creator])._currNumShots--;
} else {
- next_shot_frame(actr);
- actr->_lastDir = d;
+ next_shot_frame(actor);
+ actor->_lastDir = d;
}
- if (actr->_directions == 1)
+ if (actor->_directions == 1)
return 0;
return d;
}
// Wraith balls
-int shot_movement_four(Actor *actr) {
- if (actr->_temp1) {
- actr->_temp1--;
- if (!actr->_temp1) {
- actorDestroyed(actr);
+int shotMovementFour(Actor *actor) {
+ if (actor->_temp1) {
+ actor->_temp1--;
+ if (!actor->_temp1) {
+ actorDestroyed(actor);
_G(apple_drop++);
if (_G(apple_drop) == 4) {
- if (dropObject(actr, 5))
+ if (dropObject(actor, 5))
_G(apple_drop) = 0;
else
_G(apple_drop) = 3;
} else
- dropObject(actr, 3);
+ dropObject(actor, 3);
return 0;
}
}
if (overlap(_G(thor)->_x - 1, _G(thor)->_y - 1, _G(thor_x2) + 1, _G(thor_y2) + 1,
- actr->_x, actr->_y, actr->_x + 15, actr->_y + 15)) {
- thorDamaged(actr);
- actorDestroyed(actr);
+ actor->_x, actor->_y, actor->_x + 15, actor->_y + 15)) {
+ thorDamaged(actor);
+ actorDestroyed(actor);
return 0;
}
- int x1 = actr->_x;
- int y1 = actr->_y;
+ int x1 = actor->_x;
+ int y1 = actor->_y;
int yd = 0;
int xd = 0;
- int d = actr->_lastDir;
+ int d = actor->_lastDir;
if ((x1 > (_G(thor_x1)) + 1))
xd = -2;
else if ((x1 < (_G(thor_x1)) - 1))
xd = 2;
- if (actr->_actorNum == 1) {
+ if (actor->_actorNum == 1) {
if (y1 < (_G(thor_y1) - 6))
yd = 2;
else if (y1 > (_G(thor_y1) - 6))
@@ -254,20 +267,17 @@ int shot_movement_four(Actor *actr) {
}
if (xd && yd) {
- if (xd == -2 && yd == -2)
- d = 2;
- else if (xd == -2 && yd == 2)
+ if (xd == -2 && ABS(yd) == 2)
d = 2;
- else if (xd == 2 && yd == -2)
- d = 3;
- else if (xd == 2 && yd == 2)
+ else if (xd == 2 && ABS(yd) == 2)
d = 3;
+
x1 += xd;
y1 += yd;
- if (checkMove3(x1, y1, actr)) {
- nextFrame(actr);
- actr->_lastDir = d;
- if (actr->_directions == 1)
+ if (checkMove3(x1, y1, actor)) {
+ nextFrame(actor);
+ actor->_lastDir = d;
+ if (actor->_directions == 1)
return 0;
return d;
}
@@ -280,36 +290,36 @@ int shot_movement_four(Actor *actr) {
else if (xd == -2 && yd == 0)
d = 2;
- x1 = actr->_x;
- y1 = actr->_y;
- actr->_toggle ^= 1;
+ x1 = actor->_x;
+ y1 = actor->_y;
+ actor->_toggle ^= 1;
- if (actr->_toggle) {
+ if (actor->_toggle) {
if (xd) {
x1 += xd;
- if (checkMove3(x1, y1, actr)) {
+ if (checkMove3(x1, y1, actor)) {
if (xd > 0)
d = 3;
else
d = 2;
- nextFrame(actr);
- actr->_lastDir = d;
- if (actr->_directions == 1)
+ nextFrame(actor);
+ actor->_lastDir = d;
+ if (actor->_directions == 1)
return 0;
return d;
}
- x1 = actr->_x;
+ x1 = actor->_x;
}
if (yd) {
y1 += yd;
- if (checkMove3(x1, y1, actr)) {
+ if (checkMove3(x1, y1, actor)) {
if (yd > 0)
d = 1;
else
d = 0;
- nextFrame(actr);
- actr->_lastDir = d;
- if (actr->_directions == 1)
+ nextFrame(actor);
+ actor->_lastDir = d;
+ if (actor->_directions == 1)
return 0;
return d;
}
@@ -317,119 +327,117 @@ int shot_movement_four(Actor *actr) {
} else {
if (yd) {
y1 += yd;
- if (checkMove3(x1, y1, actr)) {
+ if (checkMove3(x1, y1, actor)) {
if (yd > 0)
d = 1;
else
d = 0;
- nextFrame(actr);
- actr->_lastDir = d;
- if (actr->_directions == 1)
+ nextFrame(actor);
+ actor->_lastDir = d;
+ if (actor->_directions == 1)
return 0;
return d;
}
- y1 = actr->_y;
+ y1 = actor->_y;
}
if (xd) {
x1 += xd;
- if (checkMove3(x1, y1, actr)) {
+ if (checkMove3(x1, y1, actor)) {
if (xd > 0)
d = 3;
else
d = 2;
- nextFrame(actr);
- actr->_lastDir = d;
- if (actr->_directions == 1)
+ nextFrame(actor);
+ actor->_lastDir = d;
+ if (actor->_directions == 1)
return 0;
return d;
}
}
}
- checkMove3(actr->_x, actr->_y, actr);
- nextFrame(actr);
- actr->_lastDir = d;
- if (actr->_directions == 1)
+ checkMove3(actor->_x, actor->_y, actor);
+ nextFrame(actor);
+ actor->_lastDir = d;
+ if (actor->_directions == 1)
return 0;
return d;
}
// No move, frame cycle
-int shot_movement_five(Actor *actr) {
- next_shot_frame(actr);
- if (actr->_directions == 1)
+int shotMovementFive(Actor *actor) {
+ next_shot_frame(actor);
+ if (actor->_directions == 1)
return 0;
- return actr->_lastDir;
+ return actor->_lastDir;
}
// Wraith spots
-int shot_movement_six(Actor *actr) {
- actr->_temp1--;
- if (!actr->_temp1) {
- actorDestroyed(actr);
- if (_G(actor[actr->_creator])._currNumShots)
- _G(actor[actr->_creator])._currNumShots--;
+int shotMovementSix(Actor *actor) {
+ actor->_temp1--;
+ if (!actor->_temp1) {
+ actorDestroyed(actor);
+ if (_G(actor[actor->_creator])._currNumShots)
+ _G(actor[actor->_creator])._currNumShots--;
} else
- next_shot_frame(actr);
- if (actr->_directions == 1)
+ next_shot_frame(actor);
+ if (actor->_directions == 1)
return 0;
- return actr->_lastDir;
+ return actor->_lastDir;
}
-#define YV actr->_i1
-#define YC actr->_i2
-#define BC actr->_i3
-#define YD actr->_i4
-#define XD actr->_i5
-#define XC actr->_i6
+#define YV actor->_i1
+#define YC actor->_i2
+#define BC actor->_i3
+#define YD actor->_i4
+#define XD actor->_i5
+#define XC actor->_i6
#define IV 100
#define IC 50
// Skull drop
-int shot_movement_seven(Actor *actr) {
- if (actr->_temp3) {
- actr->_temp3--;
+int shotMovementSeven(Actor *actor) {
+ if (actor->_temp3) {
+ actor->_temp3--;
goto done;
}
- if (overlap(actr->_x, actr->_y, actr->_x + actr->_sizeX, actr->_y + actr->_sizeY,
+ if (overlap(actor->_x, actor->_y, actor->_x + actor->_sizeX, actor->_y + actor->_sizeY,
_G(thor)->_x, _G(thor)->_y + 4, _G(thor)->_x + 15, _G(thor)->_y + 15))
- thorDamaged(actr);
+ thorDamaged(actor);
- actr->_temp2++;
- if (actr->_temp2 > 2) {
- if (actr->_temp4)
- actr->_temp4--;
- actr->_temp2 = 0;
+ actor->_temp2++;
+ if (actor->_temp2 > 2) {
+ if (actor->_temp4)
+ actor->_temp4--;
+ actor->_temp2 = 0;
}
- actr->_temp3 = actr->_temp4;
+ actor->_temp3 = actor->_temp4;
- actr->_y += 2;
- if (actr->_y > 160 - 36) {
- actr->_x += (4 - g_events->getRandomNumber(8));
- actr->_moveType = 8;
+ actor->_y += 2;
+ if (actor->_y > 160 - 36) {
+ actor->_x += (4 - g_events->getRandomNumber(8));
+ actor->_moveType = 8;
YV = IV;
YC = 0;
BC = IC;
YD = 0;
XC = 3;
- if (actr->_x < 150)
+ if (actor->_x < 150)
XD = 1;
else
XD = 0;
}
done:
- next_shot_frame(actr);
- if (actr->_directions == 1)
+ next_shot_frame(actor);
+ if (actor->_directions == 1)
return 0;
- return actr->_lastDir;
+ return actor->_lastDir;
}
// Skull bounce
-int shot_movement_eight(Actor *actr) {
- int x, y;
-
- x = actr->_x;
- y = actr->_y;
+int shotMovementEight(Actor *actor) {
+ int x = actor->_x;
+ int y = actor->_y;
XC--;
if (!XC) {
@@ -469,52 +477,52 @@ int shot_movement_eight(Actor *actr) {
if (y > 164)
y = 164;
// 8 311
- if (x < 1 || x > (319 - actr->_sizeX)) {
- if (!actr->_dead)
- if (_G(actor[actr->_creator])._currNumShots)
- _G(actor[actr->_creator])._currNumShots--;
- actorDestroyed(actr);
+ if (x < 1 || x > (319 - actor->_sizeX)) {
+ if (!actor->_dead)
+ if (_G(actor[actor->_creator])._currNumShots)
+ _G(actor[actor->_creator])._currNumShots--;
+ actorDestroyed(actor);
}
- if (overlap(actr->_x, actr->_y, actr->_x + actr->_sizeX, actr->_y + actr->_sizeY,
+ if (overlap(actor->_x, actor->_y, actor->_x + actor->_sizeX, actor->_y + actor->_sizeY,
_G(thor)->_x, _G(thor)->_y + 4, _G(thor)->_x + 15, _G(thor)->_y + 15))
- thorDamaged(actr);
- actr->_x = x;
- actr->_y = y;
+ thorDamaged(actor);
+ actor->_x = x;
+ actor->_y = y;
//done:
- next_shot_frame(actr);
- if (actr->_directions == 1)
+ next_shot_frame(actor);
+ if (actor->_directions == 1)
return 0;
- return actr->_lastDir;
+ return actor->_lastDir;
}
// Skull explode
-int shot_movement_nine(Actor *actr) {
- actr->_nextFrame++;
- if (actr->_nextFrame == 3) {
- _G(actor[actr->_creator])._currNumShots--;
- actorDestroyed(actr);
+int shotMovementNine(Actor *actor) {
+ actor->_nextFrame++;
+ if (actor->_nextFrame == 3) {
+ _G(actor[actor->_creator])._currNumShots--;
+ actorDestroyed(actor);
return 0;
}
- if (actr->_directions == 1)
+ if (actor->_directions == 1)
return 0;
- return actr->_lastDir;
+ return actor->_lastDir;
}
// Skull - stalagtites
-int shot_movement_ten(Actor *actr) {
- int f = 0;
- actr->_y += 2;
+int shotMovementTen(Actor *actor) {
+ bool check = false;
+ actor->_y += 2;
- if (overlap(actr->_x, actr->_y, actr->_x + actr->_sizeX, actr->_y + actr->_sizeY,
+ if (overlap(actor->_x, actor->_y, actor->_x + actor->_sizeX, actor->_y + actor->_sizeY,
_G(thor)->_x, _G(thor)->_y + 4, _G(thor)->_x + 15, _G(thor)->_y + 15)) {
- thorDamaged(actr);
- f = 1;
+ thorDamaged(actor);
+ check = true;
}
- if ((actr->_y > 160) || f) {
- if (_G(actor[actr->_creator])._currNumShots)
- _G(actor[actr->_creator])._currNumShots--;
- actorDestroyed(actr);
+ if (actor->_y > 160 || check) {
+ if (_G(actor[actor->_creator])._currNumShots)
+ _G(actor[actor->_creator])._currNumShots--;
+ actorDestroyed(actor);
}
return 0;
@@ -522,14 +530,14 @@ int shot_movement_ten(Actor *actr) {
#undef YD
#undef XD
-#define YA actr->_i1
-#define XA actr->_i2
-#define YD actr->_i3
-#define XD actr->_i4
-#define DIR actr->_i5
-#define CNT actr->_i6
-
-void calc_angle(int x1, int y1, int x2, int y2, Actor *actr) {
+#define YA actor->_i1
+#define XA actor->_i2
+#define YD actor->_i3
+#define XD actor->_i4
+#define DIR actor->_i5
+#define CNT actor->_i6
+
+void calc_angle(const int x1, const int y1, const int x2, const int y2, Actor *actor) {
if (x1 < x2) {
XA = -2;
XD = x2 - x1;
@@ -560,13 +568,13 @@ void calc_angle(int x1, int y1, int x2, int y2, Actor *actr) {
}
// Angle throw
-int shot_movement_eleven(Actor *actr) {
- int x1 = actr->_x;
- int y1 = actr->_y;
+int shotMovementEleven(Actor *actor) {
+ int x1 = actor->_x;
+ int y1 = actor->_y;
- if (!actr->_temp1) {
- calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
- actr->_temp1 = 1;
+ if (!actor->_temp1) {
+ calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actor);
+ actor->_temp1 = 1;
}
if (DIR) {
@@ -585,26 +593,26 @@ int shot_movement_eleven(Actor *actr) {
}
}
- if (!checkMove3(x1, y1, actr)) {
- if (_G(actor[actr->_creator])._currNumShots)
- _G(actor[actr->_creator])._currNumShots--;
- actorDestroyed(actr);
+ if (!checkMove3(x1, y1, actor)) {
+ if (_G(actor[actor->_creator])._currNumShots)
+ _G(actor[actor->_creator])._currNumShots--;
+ actorDestroyed(actor);
} else
- nextFrame(actr);
+ nextFrame(actor);
- if (actr->_directions == 1)
+ if (actor->_directions == 1)
return 0;
- return actr->_lastDir;
+ return actor->_lastDir;
}
// Angle throw Loki
-int shot_movement_twelve(Actor *actr) {
- int x1 = actr->_x;
- int y1 = actr->_y;
+int shotMovementTwelve(Actor *actor) {
+ int x1 = actor->_x;
+ int y1 = actor->_y;
- if (!actr->_temp5) {
- calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
- actr->_temp5 = 1;
+ if (!actor->_temp5) {
+ calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actor);
+ actor->_temp5 = 1;
}
if (DIR) {
@@ -625,40 +633,40 @@ int shot_movement_twelve(Actor *actr) {
if (x1 < 16 || x1 > 287 || y1 < 16 || y1 > 159) {
calc_angle(g_events->getRandomNumber(319),
- g_events->getRandomNumber(191), x1, y1, actr);
- actr->_moveType = 13;
- actr->_temp4 = 240;
- actr->_nextFrame = 2;
+ g_events->getRandomNumber(191), x1, y1, actor);
+ actor->_moveType = 13;
+ actor->_temp4 = 240;
+ actor->_nextFrame = 2;
} else {
if (overlap(x1 + 2, y1 + 2, x1 + 14, y1 + 14, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
- thorDamaged(actr);
+ thorDamaged(actor);
}
- actr->_x = x1;
- actr->_y = y1;
+ actor->_x = x1;
+ actor->_y = y1;
}
- int fcount = actr->_frameCount - 1;
+ const int fcount = actor->_frameCount - 1;
if (fcount <= 0) {
- actr->_nextFrame++;
- if (actr->_nextFrame > 1)
- actr->_nextFrame = 0;
- actr->_frameCount = actr->_frameSpeed;
+ actor->_nextFrame++;
+ if (actor->_nextFrame > 1)
+ actor->_nextFrame = 0;
+ actor->_frameCount = actor->_frameSpeed;
} else
- actr->_frameCount = fcount;
+ actor->_frameCount = fcount;
- if (actr->_directions == 1)
+ if (actor->_directions == 1)
return 0;
- return actr->_lastDir;
+ return actor->_lastDir;
}
// Angle throw Loki-2
-int shot_movement_thirteen(Actor *actr) {
- int x1 = actr->_x;
- int y1 = actr->_y;
+int shotMovementThirteen(Actor *actor) {
+ int x1 = actor->_x;
+ int y1 = actor->_y;
- if (!actr->_temp5) {
- calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
- actr->_temp5 = 1;
+ if (!actor->_temp5) {
+ calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actor);
+ actor->_temp5 = 1;
}
if (DIR) {
@@ -677,21 +685,21 @@ int shot_movement_thirteen(Actor *actr) {
}
}
- if (actr->_temp4)
- actr->_temp4--;
+ if (actor->_temp4)
+ actor->_temp4--;
- if (!actr->_temp4) {
- if (_G(actor[actr->_creator])._currNumShots)
- _G(actor[actr->_creator])._currNumShots--;
- actorDestroyed(actr);
+ if (!actor->_temp4) {
+ if (_G(actor[actor->_creator])._currNumShots)
+ _G(actor[actor->_creator])._currNumShots--;
+ actorDestroyed(actor);
_G(apple_drop++);
if (_G(apple_drop) > 4) {
- if (dropObject(actr, 5))
+ if (dropObject(actor, 5))
_G(apple_drop) = 0;
else
_G(apple_drop) = 4;
} else
- dropObject(actr, 4);
+ dropObject(actor, 4);
return 0;
}
@@ -702,25 +710,25 @@ int shot_movement_thirteen(Actor *actr) {
YA = 0 - YA;
} else {
if (overlap(x1 + 4, y1 + 4, x1 + 12, y1 + 12, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
- thorDamaged(actr);
+ thorDamaged(actor);
}
- actr->_x = x1;
- actr->_y = y1;
+ actor->_x = x1;
+ actor->_y = y1;
}
- int fcount = actr->_frameCount - 1;
+ const int fcount = actor->_frameCount - 1;
if (fcount <= 0) {
- actr->_nextFrame++;
- if (actr->_nextFrame > 3)
- actr->_nextFrame = 2;
- actr->_frameCount = actr->_frameSpeed;
+ actor->_nextFrame++;
+ if (actor->_nextFrame > 3)
+ actor->_nextFrame = 2;
+ actor->_frameCount = actor->_frameSpeed;
} else
- actr->_frameCount = fcount;
+ actor->_frameCount = fcount;
- if (actr->_directions == 1)
+ if (actor->_directions == 1)
return 0;
- return actr->_lastDir;
+ return actor->_lastDir;
}
} // namespace Got
diff --git a/engines/got/game/shot_movement.h b/engines/got/game/shot_movement.h
index 2211f1d9ffb..b04c3618451 100644
--- a/engines/got/game/shot_movement.h
+++ b/engines/got/game/shot_movement.h
@@ -26,7 +26,7 @@
namespace Got {
-extern int (*const shot_movement_func[]) (Actor *actr);
+extern int (*const shotMovementFunc[]) (Actor *actor);
} // namespace Got
diff --git a/engines/got/game/shot_pattern.cpp b/engines/got/game/shot_pattern.cpp
index 55ea6e4e234..ba43857ba5c 100644
--- a/engines/got/game/shot_pattern.cpp
+++ b/engines/got/game/shot_pattern.cpp
@@ -25,87 +25,93 @@
namespace Got {
-int shot_pattern_none(Actor *actr);
-int shot_pattern_one(Actor *actr);
-int shot_pattern_two(Actor *actr);
-int shot_pattern_three(Actor *actr);
-int shot_pattern_four(Actor *actr);
-int shot_pattern_five(Actor *actr);
-int shot_pattern_six(Actor *actr);
-int shot_pattern_seven(Actor *actr);
-int shot_pattern_eight(Actor *actr);
-
-int (*const shot_pattern_func[])(Actor *actr) = {
- shot_pattern_none,
- shot_pattern_one,
- shot_pattern_two,
- shot_pattern_three,
- shot_pattern_four,
- shot_pattern_five,
- shot_pattern_six,
- shot_pattern_seven,
- shot_pattern_eight,
+int shotPatternNone(Actor *actor);
+int shotPatternOne(Actor *actor);
+int shotPatternTwo(Actor *actor);
+int shotPatternThree(Actor *actor);
+int shotPatternFour(Actor *actor);
+int shotPatternFive(Actor *actor);
+int shotPatternSix(Actor *actor);
+int shotPatternSeven(Actor *actor);
+int shotPatternEight(Actor *actor);
+
+int (*const shotPatternFunc[])(Actor *actor) = {
+ shotPatternNone,
+ shotPatternOne,
+ shotPatternTwo,
+ shotPatternThree,
+ shotPatternFour,
+ shotPatternFive,
+ shotPatternSix,
+ shotPatternSeven,
+ shotPatternEight,
};
// No shooting
-int shot_pattern_none(Actor *actr) {
+int shotPatternNone(Actor *actor) {
return 0;
}
// Uni-directional seek
-int shot_pattern_one(Actor *actr) {
- switch (actr->_lastDir) {
+int shotPatternOne(Actor *actor) {
+ switch (actor->_lastDir) {
case 0:
- if (ABS(_G(thor_x1) - actr->_x) < 8) {
- if (actr->_y > _G(thor_real_y1)) { //r
- if (actorShoots(actr, 0))
+ if (ABS(_G(thor_x1) - actor->_x) < 8) {
+ if (actor->_y > _G(thor_real_y1)) { //r
+ if (actorShoots(actor, 0))
return 1;
}
}
break;
+
case 1:
- if (ABS(_G(thor_x1) - actr->_x) < 8) {
- if (actr->_y < _G(thor_real_y1)) { //r
- if (actorShoots(actr, 1))
+ if (ABS(_G(thor_x1) - actor->_x) < 8) {
+ if (actor->_y < _G(thor_real_y1)) { //r
+ if (actorShoots(actor, 1))
return 1;
}
}
break;
+
case 2:
- if (ABS(_G(thor_real_y1) - actr->_y) < 8) { //r
- if (actr->_x > _G(thor_x1)) {
- if (actorShoots(actr, 2))
+ if (ABS(_G(thor_real_y1) - actor->_y) < 8) { //r
+ if (actor->_x > _G(thor_x1)) {
+ if (actorShoots(actor, 2))
return 1;
}
}
break;
+
case 3:
- if (ABS(_G(thor_real_y1) - actr->_y) < 8) { //r
- if (actr->_x < _G(thor_x1)) {
- if (actorShoots(actr, 3))
+ if (ABS(_G(thor_real_y1) - actor->_y) < 8) { //r
+ if (actor->_x < _G(thor_x1)) {
+ if (actorShoots(actor, 3))
return 1;
}
}
break;
+
+ default:
+ break;
}
return 0;
}
// Omni directional
-int shot_pattern_two(Actor *actr) {
- if (ABS(_G(thor)->_x - actr->_x) < 8) {
- if (_G(thor)->_y > actr->_y)
- actorShoots(actr, 1);
- else if (_G(thor)->_y < actr->_y)
- actorShoots(actr, 0);
+int shotPatternTwo(Actor *actor) {
+ if (ABS(_G(thor)->_x - actor->_x) < 8) {
+ if (_G(thor)->_y > actor->_y)
+ actorShoots(actor, 1);
+ else if (_G(thor)->_y < actor->_y)
+ actorShoots(actor, 0);
else
return 0;
- } else if (ABS(_G(thor)->_y - actr->_y) < 8) {
- if (_G(thor)->_x > actr->_x)
- actorShoots(actr, 3);
- else if (_G(thor)->_x < actr->_x)
- actorShoots(actr, 2);
+ } else if (ABS(_G(thor)->_y - actor->_y) < 8) {
+ if (_G(thor)->_x > actor->_x)
+ actorShoots(actor, 3);
+ else if (_G(thor)->_x < actor->_x)
+ actorShoots(actor, 2);
} else {
return 0;
}
@@ -114,34 +120,34 @@ int shot_pattern_two(Actor *actr) {
}
// Uni directional (backwards)
-int shot_pattern_three(Actor *actr) {
- int ld = actr->_lastDir;
- if (shot_pattern_one(actr)) {
- actr->_lastDir = reverseDirection(actr);
+int shotPatternThree(Actor *actor) {
+ const int oldDir = actor->_lastDir;
+ if (shotPatternOne(actor)) {
+ actor->_lastDir = reverseDirection(actor);
return 1;
}
- actr->_lastDir = reverseDirection(actr);
- shot_pattern_one(actr);
- actr->_lastDir = ld;
+ actor->_lastDir = reverseDirection(actor);
+ shotPatternOne(actor);
+ actor->_lastDir = oldDir;
return 1;
}
// Omni-directional not solid shot
-int shot_pattern_four(Actor *actr) {
- if (ABS(_G(thor)->_x - actr->_x) < 8) {
- if (_G(thor)->_y > actr->_y)
- actorAlwaysShoots(actr, 1);
- else if (_G(thor)->_y < actr->_y)
- actorAlwaysShoots(actr, 0);
+int shotPatternFour(Actor *actor) {
+ if (ABS(_G(thor)->_x - actor->_x) < 8) {
+ if (_G(thor)->_y > actor->_y)
+ actorAlwaysShoots(actor, 1);
+ else if (_G(thor)->_y < actor->_y)
+ actorAlwaysShoots(actor, 0);
else
return 0;
- } else if (ABS(_G(thor)->_y - actr->_y) < 8) {
- if (_G(thor)->_x > actr->_x)
- actorAlwaysShoots(actr, 3);
- else if (_G(thor)->_x < actr->_x)
- actorAlwaysShoots(actr, 2);
+ } else if (ABS(_G(thor)->_y - actor->_y) < 8) {
+ if (_G(thor)->_x > actor->_x)
+ actorAlwaysShoots(actor, 3);
+ else if (_G(thor)->_x < actor->_x)
+ actorAlwaysShoots(actor, 2);
} else {
return 0;
}
@@ -150,19 +156,19 @@ int shot_pattern_four(Actor *actr) {
}
// Boss - snake
-int shot_pattern_five(Actor *actr) {
- if (_G(rand1) < 15 && (actr->_temp1 == 0) && (actr->_temp2 == 0)) {
- actr->_y += 16;
- actr->_numShotsAllowed = 3 + _G(setup)._difficultyLevel;
- actorShoots(actr, 2);
+int shotPatternFive(Actor *actor) {
+ if (_G(rand1) < 15 && (actor->_temp1 == 0) && (actor->_temp2 == 0)) {
+ actor->_y += 16;
+ actor->_numShotsAllowed = 3 + _G(setup)._difficultyLevel;
+ actorShoots(actor, 2);
play_sound(BOSS12, false);
- int num = actr->_shotActor;
- actr->_shotCountdown = 50;
+ const int num = actor->_shotActor;
+ actor->_shotCountdown = 50;
_G(actor[num])._temp3 = 120;
_G(actor[num])._temp4 = 5 + (_G(rand2) % 17);
_G(actor[num])._temp5 = _G(actor[num])._temp4;
- actr->_y -= 16;
+ actor->_y -= 16;
return 1;
}
@@ -170,43 +176,43 @@ int shot_pattern_five(Actor *actr) {
}
// 4 surrounding squares
-int shot_pattern_six(Actor *actr) {
- int pos = ((actr->_x) / 16) + (((actr->_y) / 16) * 20);
+int shotPatternSix(Actor *actor) {
+ const int pos = ((actor->_x) / 16) + (((actor->_y) / 16) * 20);
if (_G(thor_pos) == pos - 20)
- actorShoots(actr, 0);
+ actorShoots(actor, 0);
else if (_G(thor_pos) == pos + 20)
- actorShoots(actr, 1);
+ actorShoots(actor, 1);
else if (_G(thor_pos) == pos - 1)
- actorShoots(actr, 2);
+ actorShoots(actor, 2);
else if (_G(thor_pos) == pos + 1)
- actorShoots(actr, 3);
+ actorShoots(actor, 3);
else
return 0;
- actr->_frameSequence[3] = 3;
- actr->_nextFrame = 3;
+ actor->_frameSequence[3] = 3;
+ actor->_nextFrame = 3;
return 1;
}
// none
-int shot_pattern_seven(Actor *actr) {
+int shotPatternSeven(Actor *actor) {
return 0;
}
// random
-int shot_pattern_eight(Actor *actr) {
- if (!actr->_i2) {
- actr->_i1 = actr->_funcPass;
- actr->_i2 = 1;
+int shotPatternEight(Actor *actor) {
+ if (!actor->_i2) {
+ actor->_i1 = actor->_funcPass;
+ actor->_i2 = 1;
}
- if (actr->_i1) {
- actr->_i1--;
+ if (actor->_i1) {
+ actor->_i1--;
} else if (_G(rand1) < 10) {
- actr->_i1 = actr->_funcPass;
- actr->_i2 = _G(thor_real_y1);
- actorShoots(actr, 0);
+ actor->_i1 = actor->_funcPass;
+ actor->_i2 = _G(thor_real_y1);
+ actorShoots(actor, 0);
return 1;
}
diff --git a/engines/got/game/shot_pattern.h b/engines/got/game/shot_pattern.h
index 91182b867b7..46a1153f763 100644
--- a/engines/got/game/shot_pattern.h
+++ b/engines/got/game/shot_pattern.h
@@ -26,7 +26,7 @@
namespace Got {
-extern int (*const shot_pattern_func[])(Actor *actr);
+extern int (*const shotPatternFunc[])(Actor *actr);
} // namespace Got
diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
index e174d7db124..b19190a70c2 100644
--- a/engines/got/game/special_tile.cpp
+++ b/engines/got/game/special_tile.cpp
@@ -28,22 +28,22 @@
namespace Got {
-int open_door1(int y, int x);
-int cash_door1(int y, int x, int amount);
-void erase_door(int x, int y);
+int openDoor1(int y, int x);
+int cashDoor1(int y, int x, int amount);
+void eraseDoor(int x, int y);
-int special_tile_thor(int x, int y, int icon) {
- int cx, cy, f;
+int specialTileThor(const int x, const int y, const int icon) {
+ int cx, cy;
- f = 0;
+ int f = 0;
switch (icon) {
case 201:
- return open_door1(x, y);
+ return openDoor1(x, y);
case 202:
if (GAME3) {
if (_G(thor_info)._inventory & 64) {
if (_G(thor_info)._object == 4) {
- erase_door(y, x);
+ eraseDoor(y, x);
deleteObject();
return 1;
}
@@ -73,7 +73,9 @@ int special_tile_thor(int x, int y, int icon) {
if (!_G(setup).f19)
_G(slip_flag) = true;
return 1;
- } else if (GAME3) {
+ }
+
+ if (GAME3) {
if (_G(thor)->_x < 4)
_G(end_tile) = true;
return 1;
@@ -96,9 +98,9 @@ int special_tile_thor(int x, int y, int icon) {
return 1;
break;
case 209:
- return cash_door1(x, y, 10);
+ return cashDoor1(x, y, 10);
case 210:
- return cash_door1(x, y, 100);
+ return cashDoor1(x, y, 100);
case 211:
if (GAME1) {
placeTile(y, x, 79);
@@ -113,7 +115,7 @@ int special_tile_thor(int x, int y, int icon) {
Common::fill(_G(scrn)._actorInvis, _G(scrn)._actorInvis + 16, 0);
_G(thunder_flag) = 60;
play_sound(THUNDER, true);
- _G(setup).f22 = 1;
+ _G(setup).f22 = true;
}
} else {
// Game 3
@@ -134,16 +136,16 @@ int special_tile_thor(int x, int y, int icon) {
_G(thor)->_vulnerableCountdown = STAMINA;
play_sound(WOOP, false);
- int nt = _G(scrn)._newLevelLocation[icon - 214];
- int display_page = _G(pge);
- int draw_page = _G(pge) ^ 1;
+ const int nt = _G(scrn)._newLevelLocation[icon - 214];
+ const int displayPage = _G(pge);
+ const int drawPage = _G(pge) ^ 1;
- _G(thor)->_lastX[display_page] = _G(thor)->_x;
- _G(thor)->_lastY[display_page] = _G(thor)->_y;
+ _G(thor)->_lastX[displayPage] = _G(thor)->_x;
+ _G(thor)->_lastY[displayPage] = _G(thor)->_y;
_G(thor)->_x = (nt % 20) * 16;
_G(thor)->_y = ((nt / 20) * 16) - 2;
- _G(thor)->_lastX[draw_page] = _G(thor)->_x;
- _G(thor)->_lastY[draw_page] = _G(thor)->_y;
+ _G(thor)->_lastX[drawPage] = _G(thor)->_x;
+ _G(thor)->_lastY[drawPage] = _G(thor)->_y;
return 0;
}
return 1;
@@ -203,11 +205,14 @@ int special_tile_thor(int x, int y, int icon) {
}
return 1;
+
+ default:
+ break;
}
return 0;
}
-int special_tile(Actor *actr, int x, int y, int icon) {
+int specialTile(Actor *actor, int x, int y, const int icon) {
switch (icon) {
case 201:
case 202:
@@ -231,7 +236,7 @@ int special_tile(Actor *actr, int x, int y, int icon) {
case 225:
case 226:
case 227:
- if (!actr->_flying)
+ if (!actor->_flying)
return 0;
return 1;
default:
@@ -241,42 +246,43 @@ int special_tile(Actor *actr, int x, int y, int icon) {
return 0;
}
-void erase_door(int x, int y) {
+void eraseDoor(int x, int y) {
play_sound(DOOR, false);
_G(scrn)._iconGrid[y][x] = _G(scrn)._backgroundColor;
}
-int open_door1(int y, int x) {
+int openDoor1(int y, int x) {
if (_G(thor_info)._keys > 0) {
- erase_door(x, y);
+ eraseDoor(x, y);
_G(thor_info)._keys--;
return 1;
- } else {
- if (!_G(door_inform)) {
- odinSpeaks(2003, 0);
- _G(door_inform) = true;
- }
+ }
+
+ if (!_G(door_inform)) {
+ odinSpeaks(2003, 0);
+ _G(door_inform) = true;
}
return 0;
}
-int cash_door1(int y, int x, int amount) {
+int cashDoor1(int y, int x, int amount) {
if (_G(thor_info)._jewels >= amount) {
- erase_door(x, y);
+ eraseDoor(x, y);
_G(thor_info)._jewels -= amount;
return 1;
- } else {
- if (amount == 10 && !_G(cash1_inform)) {
- odinSpeaks(2005, 0);
- _G(cash1_inform) = true;
- }
- if (amount == 100 && !_G(cash2_inform)) {
- odinSpeaks(2004, 0);
- _G(cash2_inform) = true;
- }
+ }
+
+ if (amount == 10 && !_G(cash1_inform)) {
+ odinSpeaks(2005, 0);
+ _G(cash1_inform) = true;
+ }
+
+ if (amount == 100 && !_G(cash2_inform)) {
+ odinSpeaks(2004, 0);
+ _G(cash2_inform) = true;
}
return 0;
diff --git a/engines/got/game/special_tile.h b/engines/got/game/special_tile.h
index 339d247c171..362a2eb950b 100644
--- a/engines/got/game/special_tile.h
+++ b/engines/got/game/special_tile.h
@@ -26,8 +26,8 @@
namespace Got {
-extern int special_tile_thor(int x, int y, int icon);
-extern int special_tile(Actor *actr, int x, int y, int icon);
+extern int specialTileThor(int x, int y, int icon);
+extern int specialTile(Actor *actor, int x, int y, int icon);
} // namespace Got
Commit: d37b7918e122769ea6c2ca126f6de23694182563
https://github.com/scummvm/scummvm/commit/d37b7918e122769ea6c2ca126f6de23694182563
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-21T08:36:14+01:00
Commit Message:
GOT: Fix several issues reported by Coverity
Changed paths:
engines/got/game/script.cpp
engines/got/game/script.h
engines/got/views/dialogs/select_item.cpp
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 8be3570c2a3..9eef5562cbc 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -120,9 +120,9 @@ void Scripts::runScript(bool firstTime) {
Common::fill(_gosubStack, _gosubStack + 32, (char *)nullptr);
_gosubPtr = 0;
- Common::fill(_forVar, _forVar + 10, 0);
- Common::fill(_forVal, _forVal + 10, 0);
- Common::fill(_forStack, _forStack + 10, (char *)nullptr);
+ Common::fill(_forVar, _forVar + 11, 0);
+ Common::fill(_forVal, _forVal + 11, 0);
+ Common::fill(_forStack, _forStack + 11, (char *)nullptr);
_forPtr = 0;
int i = readScriptFile();
@@ -154,7 +154,7 @@ void Scripts::scriptLoop() {
}
if (ret > 0) {
- ret = exec_command(ret);
+ ret = execCommand(ret);
if (ret == -100) { // RUN command
if (_buffer)
free(_buffer);
@@ -1109,7 +1109,7 @@ int Scripts::cmd_exec() {
return 0;
}
-int Scripts::exec_command(int num) {
+int Scripts::execCommand(int num) {
char ch;
int ret = 0;
diff --git a/engines/got/game/script.h b/engines/got/game/script.h
index 934b75d61aa..336eb9083a6 100644
--- a/engines/got/game/script.h
+++ b/engines/got/game/script.h
@@ -54,9 +54,9 @@ private:
int _numLabels = 0; // number of labels
char *_gosubStack[32] = {}; // stack for GOSUB return addresses
int _gosubPtr = 0; // GOSUB stack pointer
- char *_forStack[10] = {}; // FOR stack
- long _forVal[10] = {}; // current FOR value
- int8 _forVar[10] = {}; // ending FOR value (target var)
+ char *_forStack[11] = {}; // FOR stack
+ long _forVal[11] = {}; // current FOR value
+ int8 _forVar[11] = {}; // ending FOR value (target var)
int8 _forPtr = 0; // FOR stack pointer
char *_buffPtr = nullptr; // pointer to current command
char *_buffEnd = nullptr; // pointer to end of buffer
@@ -79,7 +79,7 @@ private:
int calcString(int mode);
void getStr();
int getInternalVariable();
- int exec_command(int num);
+ int execCommand(int num);
int getLine(char *src, char *dst);
void scriptEntry() {}
void scriptExit();
diff --git a/engines/got/views/dialogs/select_item.cpp b/engines/got/views/dialogs/select_item.cpp
index aded5d0451a..b5fbddedff5 100644
--- a/engines/got/views/dialogs/select_item.cpp
+++ b/engines/got/views/dialogs/select_item.cpp
@@ -48,7 +48,7 @@ void SelectItem::draw() {
return;
}
- int b = 1;
+ uint b = 1;
for (int l = 0; l < 7; l++, b = b << 1) {
if (_G(thor_info)._inventory & b) {
if (l < 6)
@@ -80,7 +80,7 @@ bool SelectItem::msgFocus(const FocusMessage &msg) {
if (_selectedItem < 1)
_selectedItem = 0;
- int b = 1 << _selectedItem;
+ uint b = 1 << _selectedItem;
for (;;) {
if (_G(thor_info)._inventory & b)
break;
@@ -97,7 +97,7 @@ bool SelectItem::msgFocus(const FocusMessage &msg) {
}
bool SelectItem::msgAction(const ActionMessage &msg) {
- int b;
+ uint b;
if (_G(thor_info)._inventory == 0) {
close();
More information about the Scummvm-git-logs
mailing list