aboutsummaryrefslogtreecommitdiff
path: root/engines/hdb/ai-use.cpp
diff options
context:
space:
mode:
authorStrangerke2019-07-22 17:38:57 +0200
committerEugene Sandulenko2019-09-03 17:17:26 +0200
commitbcf910470c0dfef858045cc224ec686e539937b8 (patch)
tree3954c14b3aaf49809e7b5433e571b6a31792d5e2 /engines/hdb/ai-use.cpp
parent04901e7ac9d38ef17191832b370ef25ea5557bef (diff)
downloadscummvm-rg350-bcf910470c0dfef858045cc224ec686e539937b8.tar.gz
scummvm-rg350-bcf910470c0dfef858045cc224ec686e539937b8.tar.bz2
scummvm-rg350-bcf910470c0dfef858045cc224ec686e539937b8.zip
HDB: Fix some CppCheck warnings in ai-player, ai-use, ai-waypoint and gfx
Diffstat (limited to 'engines/hdb/ai-use.cpp')
-rw-r--r--engines/hdb/ai-use.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index 806491fe7b..21c331bb2a 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -89,11 +89,9 @@ bool AI::isOpenDoor(int x, int y) {
}
bool AI::useTarget(int x, int y, int targetX, int targetY, int newTile, int *worked) {
- int tileIndex;
-
// open a locked door?
if (isClosedDoor(targetX, targetY)) {
- tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY);
+ int tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY);
addAnimateTarget(targetX, targetY, tileIndex, tileIndex - 3, ANIM_SLOW, false, true, NULL);
g_hdb->_map->setMapBGTileIndex(x, y, newTile);
@@ -105,7 +103,7 @@ bool AI::useTarget(int x, int y, int targetX, int targetY, int newTile, int *wor
// close an open door?
if (isOpenDoor(targetX, targetY)) {
- tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY);
+ int tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY);
addAnimateTarget(targetX, targetY, tileIndex, tileIndex + 3, ANIM_SLOW, false, true, NULL);
g_hdb->_map->setMapBGTileIndex(x, y, newTile);
@@ -116,7 +114,7 @@ bool AI::useTarget(int x, int y, int targetX, int targetY, int newTile, int *wor
}
// open up a bridge?
- tileIndex = g_hdb->_map->getMapFGTileIndex(targetX, targetY);
+ int tileIndex = g_hdb->_map->getMapFGTileIndex(targetX, targetY);
if (tileIndex == _targetBridgeU ||
tileIndex == _targetBridgeD ||
tileIndex == _targetBridgeL ||
@@ -158,11 +156,9 @@ bool AI::useLockedSwitch(AIEntity *e, int x, int y, int targetX, int targetY, in
return false;
int amount = queryInventoryType(item);
- int worked;
- bool rtn;
-
if (amount) {
- rtn = useTarget(x, y, targetX, targetY, onTile, &worked);
+ int worked;
+ bool rtn = useTarget(x, y, targetX, targetY, onTile, &worked);
if (worked) {
removeInvItemType(item, 1);
if (g_hdb->_map->onScreen(x, y))
@@ -182,12 +178,11 @@ bool AI::useLockedSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY,
if (abs(x - _player->tileX) > 1 || abs(y - _player->tileY) > 1)
return false;
- int worked;
- bool rtn;
if (getInvAmount() == 10)
return false;
- rtn = useTarget(x, y, targetX, targetY, offTile, &worked);
+ int worked;
+ bool rtn = useTarget(x, y, targetX, targetY, offTile, &worked);
if (worked) {
addItemToInventory(item, 1, NULL, NULL, NULL);
if (g_hdb->_map->onScreen(x, y))
@@ -203,11 +198,10 @@ bool AI::useCellHolder(AIEntity *e, int x, int y, int targetX, int targetY) {
return false;
int amount = queryInventoryType(ITEM_CELL);
- int worked;
- bool rtn;
if (amount) {
- rtn = useTarget(x, y, targetX, targetY, _useHolderFull, &worked);
+ int worked;
+ bool rtn = useTarget(x, y, targetX, targetY, _useHolderFull, &worked);
if (worked) {
removeInvItemType(ITEM_CELL, 1);
if (g_hdb->_map->onScreen(x, y))