aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2015-05-07 19:21:55 +0200
committerStrangerke2015-05-07 19:21:55 +0200
commita0661c8d5a970791a6fac3e304fe975e8e61b5f9 (patch)
tree8effba11f029ea3782bc5ed1a976d3ea7e594eb6
parentf6b6b4c7289d128d5784d809baf1b20ba42aae03 (diff)
downloadscummvm-rg350-a0661c8d5a970791a6fac3e304fe975e8e61b5f9.tar.gz
scummvm-rg350-a0661c8d5a970791a6fac3e304fe975e8e61b5f9.tar.bz2
scummvm-rg350-a0661c8d5a970791a6fac3e304fe975e8e61b5f9.zip
SHERLOCK: Reduce some more variable scopes
-rw-r--r--engines/sherlock/objects.cpp2
-rw-r--r--engines/sherlock/scalpel/darts.cpp5
-rw-r--r--engines/sherlock/settings.cpp3
-rw-r--r--engines/sherlock/user_interface.cpp25
4 files changed, 14 insertions, 21 deletions
diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp
index f22bedfc44..8a7ae49e34 100644
--- a/engines/sherlock/objects.cpp
+++ b/engines/sherlock/objects.cpp
@@ -989,7 +989,6 @@ int Object::pickUpObject(const char *const messages[]) {
UserInterface &ui = *_vm->_ui;
int pickup = _pickup & 0x7f;
bool printed = false;
- bool takeFlag = true;
int numObjects = 0;
if (pickup == 99) {
@@ -1014,6 +1013,7 @@ int Object::pickUpObject(const char *const messages[]) {
ui._menuCounter = 30;
} else {
// Pick it up
+ bool takeFlag = true;
if ((_pickup & 0x80) == 0) {
// Play an animation
if (pickup > 80) {
diff --git a/engines/sherlock/scalpel/darts.cpp b/engines/sherlock/scalpel/darts.cpp
index 476a3071c5..4b48a1dacf 100644
--- a/engines/sherlock/scalpel/darts.cpp
+++ b/engines/sherlock/scalpel/darts.cpp
@@ -69,7 +69,6 @@ Darts::Darts(ScalpelEngine *vm) : _vm(vm) {
void Darts::playDarts() {
Events &events = *_vm->_events;
Screen &screen = *_vm->_screen;
- int score, roundStartScore;
int playerNumber = 0;
int lastDart;
@@ -82,6 +81,7 @@ void Darts::playDarts() {
bool done = false;
do {
+ int score, roundStartScore;
roundStartScore = score = playerNumber == 0 ? _dartScore1 : _dartScore2;
// Show player details
@@ -502,7 +502,6 @@ int Darts::dartScore(const Common::Point &pt) {
*/
Common::Point Darts::getComputerDartDest(int playerNum) {
Common::Point target;
- int aim;
int score = playerNum == 0 ? _dartScore1 : _dartScore2;
if (score > 50) {
@@ -515,7 +514,7 @@ Common::Point Darts::getComputerDartDest(int playerNum) {
target.y += _vm->getRandomNumber(21) - 10;
}
} else {
- aim = score;
+ int aim = score;
bool done;
Common::Point pt;
diff --git a/engines/sherlock/settings.cpp b/engines/sherlock/settings.cpp
index 1673eca389..e19aefd9c5 100644
--- a/engines/sherlock/settings.cpp
+++ b/engines/sherlock/settings.cpp
@@ -224,7 +224,6 @@ void Settings::show(SherlockEngine *vm) {
Sound &sound = *vm->_sound;
Talk &talk = *vm->_talk;
UserInterface &ui = *vm->_ui;
- int found;
bool updateConfig = false;
Settings settings(vm);
@@ -234,7 +233,7 @@ void Settings::show(SherlockEngine *vm) {
if (ui._menuCounter)
ui.whileMenuCounter();
- found = -1;
+ int found = -1;
ui._key = -1;
scene.doBgAnim();
diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp
index d40e1cced1..a134b95196 100644
--- a/engines/sherlock/user_interface.cpp
+++ b/engines/sherlock/user_interface.cpp
@@ -531,13 +531,12 @@ void UserInterface::examine() {
Scene &scene = *_vm->_scene;
Talk &talk = *_vm->_talk;
Common::Point pt = events.mousePos();
- int canimSpeed;
if (pt.y < (CONTROLS_Y + 9)) {
Object &obj = scene._bgShapes[_bgFound];
if (obj._lookcAnim != 0) {
- canimSpeed = ((obj._lookcAnim & 0xe0) >> 5) + 1;
+ int canimSpeed = ((obj._lookcAnim & 0xe0) >> 5) + 1;
scene._cAnimFramePause = obj._lookFrames;
_cAnimStr = obj._examine;
_cNum = (obj._lookcAnim & 0x1f) - 1;
@@ -587,7 +586,6 @@ void UserInterface::lookScreen(const Common::Point &pt) {
Common::Point mousePos = events.mousePos();
int temp;
Common::String tempStr;
- int x, width;
// Don't display anything for right button command
if ((events._rightPressed || events._rightPressed) && !events._pressed)
@@ -612,7 +610,7 @@ void UserInterface::lookScreen(const Common::Point &pt) {
if ((_menuMode == INV_MODE || _menuMode == USE_MODE || _menuMode == GIVE_MODE) &&
(inv._invMode == 2 || inv._invMode == 3)) {
int width1 = 0, width2 = 0;
-
+ int x, width;
if (inv._invMode == 2) {
// Using an object
x = width = screen.stringWidth("Use ");
@@ -743,9 +741,9 @@ void UserInterface::doEnvControl() {
events.clearKeyboard();
// Check for a filename entry being highlighted
- int found1 = 0;
if ((events._pressed || events._released) && mousePos.y > (CONTROLS_Y + 10))
{
+ int found1 = 0;
for (_selector = 0; (_selector < 5) && !found1; ++_selector)
if (mousePos.y > (CONTROLS_Y + 11 + _selector * 10) && mousePos.y < (CONTROLS_Y + 21 + _selector * 10))
found1 = 1;
@@ -1540,7 +1538,6 @@ void UserInterface::doTalkControl() {
Sound &sound = *_vm->_sound;
Talk &talk = *_vm->_talk;
Common::Point mousePos = events.mousePos();
- int select;
_key = _oldKey = -1;
_keyboardInput = false;
@@ -1728,7 +1725,7 @@ void UserInterface::doTalkControl() {
talk.loadTalkFile(linkFilename);
// Find the first new statement
- select = _selector = _oldSelector = -1;
+ int select = _selector = _oldSelector = -1;
for (uint idx = 0; idx < talk._statements.size() && select == -1; ++idx) {
if (!talk._statements[idx]._talkMap)
select = talk._talkIndex = idx;
@@ -1795,7 +1792,6 @@ void UserInterface::journalControl() {
Journal &journal = *_vm->_journal;
Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
- int found;
bool doneFlag = false;
// Draw the journal screen
@@ -1803,7 +1799,7 @@ void UserInterface::journalControl() {
// Handle journal events
do {
- found = _key = -1;
+ _key = -1;
events.setButtonState();
// Handle keypresses
@@ -1846,12 +1842,11 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) {
Inventory &inv = *_vm->_inventory;
Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk;
- int savedSelector;
if (str.hasPrefix("_")) {
_lookScriptFlag = true;
events.setCursor(MAGNIFY);
- savedSelector = _selector;
+ int savedSelector = _selector;
talk.talkTo(str.c_str() + 1);
_lookScriptFlag = false;
@@ -2255,11 +2250,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[]
Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk;
- bool printed = false;
- bool doCAnim = true;
- int cAnimNum;
Common::Point pt(-1, -1);
- int dir = -1;
if (objNum >= 1000)
// Ignore actions done on characters
@@ -2277,12 +2268,14 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[]
} else {
Object &obj = scene._bgShapes[objNum];
+ int cAnimNum;
if (action._cAnimNum == 0)
// Really a 10
cAnimNum = 9;
else
cAnimNum = action._cAnimNum - 1;
+ int dir = -1;
if (action._cAnimNum != 99) {
CAnim &anim = scene._cAnim[cAnimNum];
@@ -2303,6 +2296,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[]
// Has a value, so do action
// Show wait cursor whilst walking to object and doing action
events.setCursor(WAIT);
+ bool printed = false;
for (int nameIdx = 0; nameIdx < 4; ++nameIdx) {
if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2
@@ -2314,6 +2308,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[]
}
}
+ bool doCAnim = true;
for (int nameIdx = 0; nameIdx < 4; ++nameIdx) {
if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2) {
char ch = toupper(action._names[nameIdx][1]);