diff options
author | Strangerke | 2015-05-07 18:21:25 +0200 |
---|---|---|
committer | Strangerke | 2015-05-07 18:21:25 +0200 |
commit | 4884762e0471e358bc6416d8baf97e0685b1aa3c (patch) | |
tree | 445696b8202967b5ee455b0fef9c709b067cba4e /engines/sherlock | |
parent | 97bec43799aa85b9ef49e4e26016de95dd054e71 (diff) | |
download | scummvm-rg350-4884762e0471e358bc6416d8baf97e0685b1aa3c.tar.gz scummvm-rg350-4884762e0471e358bc6416d8baf97e0685b1aa3c.tar.bz2 scummvm-rg350-4884762e0471e358bc6416d8baf97e0685b1aa3c.zip |
SHERLOCK: Reduce the scope of some variables
Diffstat (limited to 'engines/sherlock')
-rw-r--r-- | engines/sherlock/animation.cpp | 3 | ||||
-rw-r--r-- | engines/sherlock/journal.cpp | 17 | ||||
-rw-r--r-- | engines/sherlock/map.cpp | 5 | ||||
-rw-r--r-- | engines/sherlock/objects.cpp | 5 | ||||
-rw-r--r-- | engines/sherlock/people.cpp | 2 |
5 files changed, 14 insertions, 18 deletions
diff --git a/engines/sherlock/animation.cpp b/engines/sherlock/animation.cpp index b1ec6590b1..62e6e4bebf 100644 --- a/engines/sherlock/animation.cpp +++ b/engines/sherlock/animation.cpp @@ -109,12 +109,11 @@ bool Animation::play(const Common::String &filename, int minDelay, int fade, } int frameNumber = 0; - int imageFrame; Common::Point pt; bool skipped = false; while (!_vm->shouldQuit()) { // Get the next sprite to display - imageFrame = stream->readSint16LE(); + int imageFrame = stream->readSint16LE(); if (imageFrame == -2) { // End of animation reached diff --git a/engines/sherlock/journal.cpp b/engines/sherlock/journal.cpp index 25b0bb5451..dfff6e9bb7 100644 --- a/engines/sherlock/journal.cpp +++ b/engines/sherlock/journal.cpp @@ -96,7 +96,6 @@ void Journal::record(int converseNum, int statementNum, bool replyOnly) { */ void Journal::loadJournalLocations() { Resources &res = *_vm->_res; - char c; _directory.clear(); @@ -123,6 +122,7 @@ void Journal::loadJournalLocations() { _locations.clear(); while (loc->pos() < loc->size()) { Common::String line; + char c; while ((c = loc->readByte()) != 0) line += c; @@ -564,9 +564,7 @@ bool Journal::doJournal(int direction, int howFar) { int lineNum = 0; int maxLines; int savedIndex; - int savedSub; int temp; - bool inc; const char *matchP; int width; @@ -663,7 +661,7 @@ bool Journal::doJournal(int direction, int howFar) { lineNum = 0; savedIndex = _index; - savedSub = _sub; + int savedSub = _sub; // Move a single page ahead do { @@ -725,7 +723,7 @@ bool Journal::doJournal(int direction, int howFar) { lineNum = 0; do { - inc = true; + bool inc = true; // If there wasn't any line to print at the top of the page, we won't need to // increment the y position @@ -955,9 +953,9 @@ bool Journal::handleEvents(int key) { screen.buttonPrint(Common::Point(JOURNAL_POINTS[5][2], JOURNAL_BUTTONS_Y + 11), COMMAND_FOREGROUND, true, "Search"); bool notFound = false; - int dir; do { + int dir; if ((dir = getFindName(notFound)) != 0) { int savedIndex = _index; int savedSub = _sub; @@ -1016,6 +1014,8 @@ bool Journal::handleEvents(int key) { * Show the search submenu */ int Journal::getFindName(bool printError) { + enum Button { BTN_NONE, BTN_EXIT, BTN_BACKWARD, BTN_FORWARD }; + Events &events = *_vm->_events; Screen &screen = *_vm->_screen; Talk &talk = *_vm->_talk; @@ -1023,8 +1023,6 @@ int Journal::getFindName(bool printError) { int yp = 174; bool flag = false; Common::String name; - enum Button { BTN_NONE, BTN_EXIT, BTN_BACKWARD, BTN_FORWARD }; - Button found = BTN_NONE; int done = 0; byte color; @@ -1062,7 +1060,6 @@ int Journal::getFindName(bool printError) { for (int idx = 0; idx < 40 && !_vm->shouldQuit() && !events.kbHit() && !events._released; ++idx) { events.pollEvents(); events.setButtonState(); - events.wait(2); } @@ -1082,7 +1079,7 @@ int Journal::getFindName(bool printError) { do { events._released = false; - found = BTN_NONE; + Button found = BTN_NONE; while (!_vm->shouldQuit() && !events.kbHit() && !events._released) { found = BTN_NONE; diff --git a/engines/sherlock/map.cpp b/engines/sherlock/map.cpp index f572e3771a..4f04312ba7 100644 --- a/engines/sherlock/map.cpp +++ b/engines/sherlock/map.cpp @@ -95,10 +95,10 @@ void Map::loadSequences(int count, const byte *seq) { void Map::loadData() { // Load the list of location names Common::SeekableReadStream *txtStream = _vm->_res->load("chess.txt"); - char c; while (txtStream->pos() < txtStream->size()) { Common::String line; + char c; while ((c = txtStream->readByte()) != '\0') line += c; @@ -442,7 +442,6 @@ void Map::updateMap(bool flushScreen) { */ void Map::walkTheStreets() { People &people = *_vm->_people; - bool reversePath = false; Common::Array<Common::Point> tempPath; // Get indexes into the path lists for the start and destination scenes @@ -463,6 +462,8 @@ void Map::walkTheStreets() { if (_charPoint == 51 || _oldCharPoint == 51) { people.setWalking(); } else { + bool reversePath = false; + // Check for moving the path backwards or forwards if (path[0] == 255) { reversePath = true; diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp index 6f4795de7e..f22bedfc44 100644 --- a/engines/sherlock/objects.cpp +++ b/engines/sherlock/objects.cpp @@ -835,15 +835,13 @@ int Object::checkNameForCodes(const Common::String &name, const char *const mess Talk &talk = *_vm->_talk; UserInterface &ui = *_vm->_ui; bool printed = false; - char ch; - const char *p; scene.toggleObject(name); if (name.hasPrefix("*")) { // A code was found printed = true; - ch = (name == "*") ? 0 : toupper(name[1]); + char ch = (name == "*") ? 0 : toupper(name[1]); switch (ch) { case 'C': @@ -880,6 +878,7 @@ int Object::checkNameForCodes(const Common::String &name, const char *const mess map._overPos.y = map[scene._goToScene].y * 100 + 900; } + const char *p; if ((p = strchr(name.c_str(), ',')) != nullptr) { ++p; diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp index 9c264b4754..84194059e1 100644 --- a/engines/sherlock/people.cpp +++ b/engines/sherlock/people.cpp @@ -287,7 +287,6 @@ void People::setWalking() { Scene &scene = *_vm->_scene; int oldDirection, oldFrame; Common::Point speed, delta; - int temp; // Flag that player has now walked in the scene scene._walkedInScene = true; @@ -311,6 +310,7 @@ void People::setWalking() { // Since we want the player to be centered on the destination they // clicked, but characters draw positions start at their left, move // the destination half the character width to draw him centered + int temp; if (_walkDest.x >= (temp = _player._imageFrame->_frame.w / 2)) _walkDest.x -= temp; |