SHERLOCK: Reduce the scope of some variables

This commit is contained in:
Strangerke 2015-05-07 18:21:25 +02:00
parent 97bec43799
commit 4884762e04
5 changed files with 14 additions and 18 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;