aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2015-12-12 16:33:01 +0200
committerWillem Jan Palenstijn2015-12-23 21:34:00 +0100
commit46a25b93abc8b44cc2c1e44f7ba73f86de64399b (patch)
tree83931205cca34660366a3327b709558bf159809d
parent8f5c91ee07b65f977ec556e22a5ddf8a916f776d (diff)
downloadscummvm-rg350-46a25b93abc8b44cc2c1e44f7ba73f86de64399b.tar.gz
scummvm-rg350-46a25b93abc8b44cc2c1e44f7ba73f86de64399b.tar.bz2
scummvm-rg350-46a25b93abc8b44cc2c1e44f7ba73f86de64399b.zip
LAB: Rewrite some code using switch statements
-rw-r--r--engines/lab/engine.cpp89
1 files changed, 54 insertions, 35 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index b80910e091..c9e1348115 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -280,8 +280,8 @@ void LabEngine::interfaceOn() {
* If the user hits the "Use" gadget; things that can get used on themselves.
*/
bool LabEngine::doUse(uint16 curInv) {
- if (curInv == MAPNUM) {
- // LAB: Labyrinth specific
+ switch (curInv) {
+ case MAPNUM:
drawStaticMessage(kTextUseMap);
interfaceOff();
_anim->stopDiff();
@@ -291,8 +291,8 @@ bool LabEngine::doUse(uint16 curInv) {
_graphics->setPalette(initcolors, 8);
_graphics->drawMessage(nullptr);
_graphics->drawPanel();
- } else if (curInv == JOURNALNUM) {
- // LAB: Labyrinth specific
+ return true;
+ case JOURNALNUM:
drawStaticMessage(kTextUseJournal);
interfaceOff();
_anim->stopDiff();
@@ -301,14 +301,15 @@ bool LabEngine::doUse(uint16 curInv) {
doJournal();
_graphics->drawPanel();
_graphics->drawMessage(nullptr);
- } else if (curInv == LAMPNUM) {
- // LAB: Labyrinth specific
+ return true;
+ case LAMPNUM:
interfaceOff();
if (_conditions->in(LAMPON)) {
drawStaticMessage(kTextTurnLampOff);
_conditions->exclElement(LAMPON);
- } else {
+ }
+ else {
drawStaticMessage(kTextTurnLampOn);
_conditions->inclElement(LAMPON);
}
@@ -320,29 +321,29 @@ bool LabEngine::doUse(uint16 curInv) {
_anim->_doBlack = false;
_nextFileName = getInvName(curInv);
- } else if (curInv == BELTNUM) {
- // LAB: Labyrinth specific
+ return true;
+ case BELTNUM:
if (!_conditions->in(BELTGLOW))
_conditions->inclElement(BELTGLOW);
_anim->_doBlack = false;
_nextFileName = getInvName(curInv);
- } else if (curInv == WHISKEYNUM) {
- // LAB: Labyrinth specific
+ return true;
+ case WHISKEYNUM:
_conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUseWhiskey);
- } else if (curInv == PITHHELMETNUM) {
- // LAB: Labyrinth specific
+ return true;
+ case PITHHELMETNUM:
_conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUsePith);
- } else if (curInv == HELMETNUM) {
- // LAB: Labyrinth specific
+ return true;
+ case HELMETNUM:
_conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUseHelmet);
- } else
+ return true;
+ default:
return false;
-
- return true;
+ }
}
/**
@@ -458,14 +459,20 @@ void LabEngine::mainGameLoop() {
_curFileName = _nextFileName;
if (_closeDataPtr) {
- if ((_closeDataPtr->_closeUpType == SPECIALLOCK) && _mainDisplay)
- _tilePuzzle->showCombination(_curFileName);
- else if (((_closeDataPtr->_closeUpType == SPECIALBRICK) ||
- (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE)) &&
- _mainDisplay)
- _tilePuzzle->showTile(_curFileName, (bool)(_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
- else
+ switch (_closeDataPtr->_closeUpType) {
+ case SPECIALLOCK:
+ if (_mainDisplay)
+ _tilePuzzle->showCombination(_curFileName);
+ break;
+ case SPECIALBRICK:
+ case SPECIALBRICKNOMOUSE:
+ if (_mainDisplay)
+ _tilePuzzle->showTile(_curFileName, (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
+ break;
+ default:
_graphics->readPict(_curFileName, false);
+ break;
+ }
} else
_graphics->readPict(_curFileName, false);
@@ -503,12 +510,19 @@ void LabEngine::mainGameLoop() {
if (result != 0) {
uint16 code = 0;
- if (result == VKEY_UPARROW)
+ switch (result) {
+ case VKEY_UPARROW:
code = 7;
- else if (result == VKEY_LTARROW)
+ break;
+ case VKEY_LTARROW:
code = 6;
- else if (result == VKEY_RTARROW)
+ break;
+ case VKEY_RTARROW:
code = 8;
+ break;
+ default:
+ break;
+ }
gotMessage = true;
mayShowCrumbIndicator();
@@ -776,8 +790,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
}
} else if (_droppingCrumbs && oldRoomNum != _roomNum) {
// If in surreal maze, turn off DroppingCrumbs.
- // Note: These numbers were generated by parsing the
- // "Maps" file, which is why they are hard-coded. Bleh!
if (_roomNum >= 245 && _roomNum <= 280) {
_followingCrumbs = false;
_droppingCrumbs = false;
@@ -940,12 +952,19 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
doit = false;
if (_closeDataPtr) {
- if ((_closeDataPtr->_closeUpType == SPECIALLOCK) && _mainDisplay)
- _tilePuzzle->mouseCombination(curPos);
- else if ((_closeDataPtr->_closeUpType == SPECIALBRICK) && _mainDisplay)
- _tilePuzzle->mouseTile(curPos);
- else
+ switch (_closeDataPtr->_closeUpType) {
+ case SPECIALLOCK:
+ if (_mainDisplay)
+ _tilePuzzle->mouseCombination(curPos);
+ break;
+ case SPECIALBRICK:
+ if (_mainDisplay)
+ _tilePuzzle->mouseTile(curPos);
+ break;
+ default:
doit = true;
+ break;
+ }
} else
doit = true;