aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2015-12-14 10:28:12 +0100
committerWillem Jan Palenstijn2015-12-23 21:34:04 +0100
commitcbf4c876e52300cf1a8d54a166ceed3bebeb3016 (patch)
tree373d444b2bbf99f457dffe51e64972e8a1c78011 /engines
parent1120958dac976fcd6634e4001af17fabbf6fd1b5 (diff)
downloadscummvm-rg350-cbf4c876e52300cf1a8d54a166ceed3bebeb3016.tar.gz
scummvm-rg350-cbf4c876e52300cf1a8d54a166ceed3bebeb3016.tar.bz2
scummvm-rg350-cbf4c876e52300cf1a8d54a166ceed3bebeb3016.zip
LAB: Turned another if chain into switch
Diffstat (limited to 'engines')
-rw-r--r--engines/lab/engine.cpp187
1 files changed, 101 insertions, 86 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f101c74b47..51b20a7705 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -709,7 +709,14 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
_graphics->screenUpdate();
}
} else if ((msgClass == BUTTONUP) && !_alternate) {
- if (buttonId <= 5) {
+ uint16 newDir;
+
+ switch (buttonId) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
if ((actionMode == 4) && (buttonId == 4) && _closeDataPtr) {
doMainView(&_closeDataPtr);
@@ -717,26 +724,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
wrkClosePtr = nullptr;
_closeDataPtr = nullptr;
mayShowCrumbIndicator();
- } else if (buttonId == 5) {
- eatMessages();
-
- _alternate = true;
- _anim->_doBlack = true;
- _graphics->_doNotDrawMessage = false;
- // Sets the correct button list
- interfaceOn();
- _mainDisplay = false;
-
- if (lastInv && _conditions->in(lastInv)) {
- curInv = lastInv;
- _nextFileName = getInvName(curInv);
- } else
- decIncInv(&curInv, false);
-
- _graphics->drawPanel();
- drawRoomMessage(curInv, _closeDataPtr);
-
- mayShowCrumbIndicator();
} else {
uint16 oldActionMode = actionMode;
actionMode = buttonId;
@@ -747,95 +734,123 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
perFlipButton(actionMode);
drawStaticMessage(kTextTakeWhat + buttonId);
}
- } else if (buttonId == 9) {
+ break;
+ case 5:
+ eatMessages();
+
+ _alternate = true;
+ _anim->_doBlack = true;
+ _graphics->_doNotDrawMessage = false;
+ // Sets the correct button list
+ interfaceOn();
+ _mainDisplay = false;
+
+ if (lastInv && _conditions->in(lastInv)) {
+ curInv = lastInv;
+ _nextFileName = getInvName(curInv);
+ } else
+ decIncInv(&curInv, false);
+
+ _graphics->drawPanel();
+ drawRoomMessage(curInv, _closeDataPtr);
+
+ mayShowCrumbIndicator();
+ break;
+
+ case 9:
doUse(kItemMap);
mayShowCrumbIndicator();
- } else if (buttonId >= 6) {
+ break;
+
+ case 6:
+ case 8:
// Arrow Buttons
_closeDataPtr = nullptr;
wrkClosePtr = nullptr;
+ if (buttonId == 6)
+ drawStaticMessage(kTextTurnLeft);
+ else
+ drawStaticMessage(kTextTurnRight);
- if ((buttonId == 6) || (buttonId == 8)) {
- if (buttonId == 6)
- drawStaticMessage(kTextTurnLeft);
- else
- drawStaticMessage(kTextTurnRight);
+ _curFileName = " ";
- _curFileName = " ";
+ oldDirection = _direction;
- oldDirection = _direction;
+ newDir = processArrow(_direction, buttonId - 6);
+ doTurn(_direction, newDir, &_closeDataPtr);
+ _anim->_doBlack = true;
+ _direction = newDir;
+ forceDraw = true;
- uint16 newDir = processArrow(_direction, buttonId - 6);
- doTurn(_direction, newDir, &_closeDataPtr);
- _anim->_doBlack = true;
- _direction = newDir;
- forceDraw = true;
+ mayShowCrumbIndicator();
+ break;
- mayShowCrumbIndicator();
- } else if (buttonId == 7) {
- uint16 oldRoomNum = _roomNum;
+ case 7:
+ _closeDataPtr = nullptr;
+ wrkClosePtr = nullptr;
+ uint16 oldRoomNum = _roomNum;
- if (doGoForward(&_closeDataPtr)) {
- if (oldRoomNum == _roomNum)
- _anim->_doBlack = true;
+ if (doGoForward(&_closeDataPtr)) {
+ if (oldRoomNum == _roomNum)
+ _anim->_doBlack = true;
+ } else {
+ _anim->_doBlack = true;
+ _direction = processArrow(_direction, buttonId - 6);
+
+ if (oldRoomNum != _roomNum) {
+ drawStaticMessage(kTextGoForward);
+ // Potentially entered a new room
+ _roomsFound->inclElement(_roomNum);
+ _curFileName = " ";
+ forceDraw = true;
} else {
_anim->_doBlack = true;
- _direction = processArrow(_direction, buttonId - 6);
-
- if (oldRoomNum != _roomNum) {
- drawStaticMessage(kTextGoForward);
- // Potentially entered a new room
- _roomsFound->inclElement(_roomNum);
- _curFileName = " ";
- forceDraw = true;
- } else {
- _anim->_doBlack = true;
- drawStaticMessage(kTextNoPath);
- }
+ drawStaticMessage(kTextNoPath);
}
+ }
- if (_followingCrumbs) {
- if (_isCrumbTurning) {
- if (_direction == oldDirection) {
- _followingCrumbs = false;
- }
- } else {
- if (_roomNum == oldRoomNum) { // didn't get there?
- _followingCrumbs = false;
- }
+ if (_followingCrumbs) {
+ if (_isCrumbTurning) {
+ if (_direction == oldDirection) {
+ _followingCrumbs = false;
}
- } else if (_droppingCrumbs && oldRoomNum != _roomNum) {
- // If in surreal maze, turn off DroppingCrumbs.
- if (_roomNum >= 245 && _roomNum <= 280) {
+ } else {
+ if (_roomNum == oldRoomNum) { // didn't get there?
_followingCrumbs = false;
- _droppingCrumbs = false;
- _numCrumbs = 0;
- _breadCrumbs[0]._roomNum = 0;
- } else {
- bool intersect = false;
- for (int idx = 0; idx < _numCrumbs; idx++) {
- if (_breadCrumbs[idx]._roomNum == _roomNum) {
- _numCrumbs = idx + 1;
- _breadCrumbs[_numCrumbs]._roomNum = 0;
- intersect = true;
- }
+ }
+ }
+ } else if (_droppingCrumbs && oldRoomNum != _roomNum) {
+ // If in surreal maze, turn off DroppingCrumbs.
+ if (_roomNum >= 245 && _roomNum <= 280) {
+ _followingCrumbs = false;
+ _droppingCrumbs = false;
+ _numCrumbs = 0;
+ _breadCrumbs[0]._roomNum = 0;
+ } else {
+ bool intersect = false;
+ for (int idx = 0; idx < _numCrumbs; idx++) {
+ if (_breadCrumbs[idx]._roomNum == _roomNum) {
+ _numCrumbs = idx + 1;
+ _breadCrumbs[_numCrumbs]._roomNum = 0;
+ intersect = true;
}
+ }
- if (!intersect) {
- if (_numCrumbs == MAX_CRUMBS) {
- _numCrumbs = MAX_CRUMBS - 1;
- memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]);
- }
-
- _breadCrumbs[_numCrumbs]._roomNum = _roomNum;
- _breadCrumbs[_numCrumbs++]._direction = _direction;
+ if (!intersect) {
+ if (_numCrumbs == MAX_CRUMBS) {
+ _numCrumbs = MAX_CRUMBS - 1;
+ memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]);
}
+
+ _breadCrumbs[_numCrumbs]._roomNum = _roomNum;
+ _breadCrumbs[_numCrumbs++]._direction = _direction;
}
}
-
- mayShowCrumbIndicator();
}
+
+ mayShowCrumbIndicator();
+ break;
}
_graphics->screenUpdate();
} else if ((msgClass == BUTTONUP) && _alternate) {