diff options
author | Eugene Sandulenko | 2015-12-14 14:20:22 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:34:05 +0100 |
commit | 167d9c48a3d72c923616f18759b1ab7860e59a7d (patch) | |
tree | 5507f44f83aa56d6f28d098f33035a9c27683d1b /engines/lab | |
parent | 1d027704e0b3f75fa176d64a77f4744dd1ea3ee5 (diff) | |
download | scummvm-rg350-167d9c48a3d72c923616f18759b1ab7860e59a7d.tar.gz scummvm-rg350-167d9c48a3d72c923616f18759b1ab7860e59a7d.tar.bz2 scummvm-rg350-167d9c48a3d72c923616f18759b1ab7860e59a7d.zip |
LAB: Reduced scope of a few more variables
Diffstat (limited to 'engines/lab')
-rw-r--r-- | engines/lab/resource.cpp | 3 | ||||
-rw-r--r-- | engines/lab/savegame.cpp | 9 | ||||
-rw-r--r-- | engines/lab/special.cpp | 16 | ||||
-rw-r--r-- | engines/lab/tilepuzzle.cpp | 37 |
4 files changed, 28 insertions, 37 deletions
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp index cb29bc6407..8b7d26f3ca 100644 --- a/engines/lab/resource.cpp +++ b/engines/lab/resource.cpp @@ -251,7 +251,6 @@ Action *Resource::readAction(Common::File *file) { Action *action = NULL; Action *prev = NULL; Action *head = NULL; - char **messages; do { c = file->readByte(); @@ -268,7 +267,7 @@ Action *Resource::readAction(Common::File *file) { action->_param3 = file->readSint16LE(); if (action->_actionType == SHOWMESSAGES) { - messages = (char **)malloc(action->_param1 * 4); + char **messages = (char **)malloc(action->_param1 * 4); for (int i = 0; i < action->_param1; i++) messages[i] = readString(file); diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp index 99382e95f9..d08dcbc24d 100644 --- a/engines/lab/savegame.cpp +++ b/engines/lab/savegame.cpp @@ -166,7 +166,6 @@ bool LabEngine::saveGame(int slot, Common::String desc) { * Reads the game from disk. */ bool LabEngine::loadGame(int slot) { - uint16 i; Common::String fileName = generateSaveFileName(slot); Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); Common::InSaveFile *file = saveFileManager->openForLoading(fileName); @@ -181,17 +180,17 @@ bool LabEngine::loadGame(int slot) { setQuarters(file->readUint16LE()); // Conditions - for (i = 0; i < _conditions->_lastElement / (8 * 2); i++) + for (uint16 i = 0; i < _conditions->_lastElement / (8 * 2); i++) _conditions->_array[i] = file->readUint16LE(); // Rooms found - for (i = 0; i < _roomsFound->_lastElement / (8 * 2); i++) + for (uint16 i = 0; i < _roomsFound->_lastElement / (8 * 2); i++) _roomsFound->_array[i] = file->readUint16LE(); _tilePuzzle->load(file); // Breadcrumbs - for (i = 0; i < 128; i++) { + for (uint16 i = 0; i < 128; i++) { _breadCrumbs[i]._roomNum = file->readUint16LE(); _breadCrumbs[i]._direction = file->readUint16LE(); } @@ -199,7 +198,7 @@ bool LabEngine::loadGame(int slot) { _droppingCrumbs = (_breadCrumbs[0]._roomNum != 0); _followingCrumbs = false; - for (i = 0; i < 128; i++) { + for (uint16 i = 0; i < 128; i++) { if (_breadCrumbs[i]._roomNum == 0) break; _numCrumbs = i; diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 65a4a9d566..6fc8636037 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -228,7 +228,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { if (wipenum == 0) _journalBackImage->blitBitmap(0, 0, _screenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); else - turnPage((bool)(wipenum == 1)); + turnPage((wipenum == 1)); Button *backButton = _event->getButton(0); Button *forwardButton = _event->getButton(2); @@ -329,7 +329,7 @@ void LabEngine::doJournal() { * Draws the text for the monitor. */ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { - uint16 drawingToPage = 0, yspacing = 0, numlines, fheight; + uint16 drawingToPage = 0, yspacing = 0; int32 charsDrawn = 0L; char *curText = text; @@ -337,12 +337,12 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 if (*text == '%') { text++; - numlines = (*text - '0') * 10; + uint16 numlines = (*text - '0') * 10; text++; numlines += (*text - '0'); text += 2; - fheight = _graphics->textHeight(monitorFont); + uint16 fheight = _graphics->textHeight(monitorFont); x1 = _monitorButton->_width + _utils->vgaScaleX(3); _monitorButtonHeight = _monitorButton->_height + _utils->vgaScaleY(3); @@ -389,7 +389,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 * Processes user input. */ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - const char *test = " ", *startFileName = _monitorTextFilename; + const char *startFileName = _monitorTextFilename; CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10]; uint16 depth = 0; @@ -400,6 +400,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera if (_closeDataPtr == NULL) _closeDataPtr = startClosePtr; + const char *test; if (_closeDataPtr == startClosePtr) test = startFileName; else @@ -433,7 +434,6 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (code == 27))) return; - else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) { if ((mouseX >= _utils->vgaScaleX(259)) && (mouseX <= _utils->vgaScaleX(289))) { @@ -481,8 +481,6 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera * Does what's necessary for the monitor. */ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - char *ntext; - x1 = _utils->vgaScaleX(x1); x2 = _utils->vgaScaleX(x2); y1 = _utils->vgaScaleY(y1); @@ -506,7 +504,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, _monitorButton = new Image(buttonFile, this); delete buttonFile; - ntext = _resource->getText(textfile); + char *ntext = _resource->getText(textfile); _graphics->loadBackPict(background, _highPalette); drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); _event->mouseShow(); diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp index 1e227d3b7e..37cc0318f2 100644 --- a/engines/lab/tilepuzzle.cpp +++ b/engines/lab/tilepuzzle.cpp @@ -89,7 +89,7 @@ TilePuzzle::~TilePuzzle() { for (int i = 0; i < 16; i++) delete _tiles[i]; - for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) { + for (int imgIdx = 0; imgIdx < 10; imgIdx++) { delete _numberImages[imgIdx]; _numberImages[imgIdx] = nullptr; } @@ -253,8 +253,6 @@ void TilePuzzle::doTile(bool showsolution) { * Reads in a backdrop picture. */ void TilePuzzle::showTile(const char *filename, bool showSolution) { - uint16 start = showSolution ? 0 : 1; - _vm->_anim->_doBlack = true; _vm->_anim->_noPalChange = true; _vm->_graphics->readPict(filename, true); @@ -263,7 +261,9 @@ void TilePuzzle::showTile(const char *filename, bool showSolution) { Common::File *tileFile = _vm->_resource->openDataFile(showSolution ? "P:TileSolution" : "P:Tile"); - for (uint16 curBit = start; curBit < 16; curBit++) + int start = showSolution ? 0 : 1; + + for (int curBit = start; curBit < 16; curBit++) _tiles[curBit] = new Image(tileFile, _vm); delete tileFile; @@ -277,7 +277,7 @@ void TilePuzzle::showTile(const char *filename, bool showSolution) { */ void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0; - uint16 last = 0; + int last = 0; if (scrolltype == kScrollLeft) { dX = _vm->_utils->vgaScaleX(5); @@ -306,7 +306,7 @@ void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { byte *buffer = new byte[_tiles[1]->_width * _tiles[1]->_height * 2L]; - for (uint16 i = 0; i < last; i++) { + for (int i = 0; i < last; i++) { _vm->waitTOF(); scrollRaster(dX, dY, x1, y1, x1 + _vm->_utils->vgaScaleX(28) + sx, y1 + _vm->_utils->vgaScaleY(23) + sy, buffer); x1 += dX; @@ -323,15 +323,13 @@ void TilePuzzle::changeCombination(uint16 number) { const int solution[6] = { 0, 4, 0, 8, 7, 2 }; Image display(_vm); - uint16 combnum; - bool unlocked = true; if (_combination[number] < 9) (_combination[number])++; else _combination[number] = 0; - combnum = _combination[number]; + uint16 combnum = _combination[number]; display._imageData = _vm->_graphics->getCurrentDrawingBuffer(); display._width = _vm->_graphics->_screenWidth; @@ -353,7 +351,8 @@ void TilePuzzle::changeCombination(uint16 number) { delete[] buffer; - for (uint16 i = 0; i < 6; i++) + bool unlocked = true; + for (int i = 0; i < 6; i++) unlocked &= (_combination[i] == solution[i]); if (unlocked) @@ -374,7 +373,7 @@ void TilePuzzle::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x * Draws the images of the combination lock to the display bitmap. */ void TilePuzzle::doCombination() { - for (uint16 i = 0; i <= 5; i++) + for (int i = 0; i <= 5; i++) _numberImages[_combination[i]]->drawImage(_vm->_utils->vgaScaleX(COMBINATION_X[i]), _vm->_utils->vgaScaleY(65)); } @@ -402,28 +401,24 @@ void TilePuzzle::showCombination(const char *filename) { } void TilePuzzle::save(Common::OutSaveFile *file) { - uint16 i, j; - // Combination lock and tile stuff - for (i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) file->writeByte(_combination[i]); // Tiles - for (i = 0; i < 4; i++) - for (j = 0; j < 4; j++) + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) file->writeUint16LE(_curTile[i][j]); } void TilePuzzle::load(Common::InSaveFile *file) { - uint16 i, j; - // Combination lock and tile stuff - for (i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) _combination[i] = file->readByte(); // Tiles - for (i = 0; i < 4; i++) - for (j = 0; j < 4; j++) + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) _curTile[i][j] = file->readUint16LE(); } |