aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2015-12-07 10:08:01 +0200
committerWillem Jan Palenstijn2015-12-23 21:33:53 +0100
commit9cc30c3c6d6edb616bb76d15b46391bacf3e2052 (patch)
tree85ef97d877a6c1cdf1e7ecc20a7fde2e0fe44697
parent87201cfed25e2b145d55c5d77fe0988d32444395 (diff)
downloadscummvm-rg350-9cc30c3c6d6edb616bb76d15b46391bacf3e2052.tar.gz
scummvm-rg350-9cc30c3c6d6edb616bb76d15b46391bacf3e2052.tar.bz2
scummvm-rg350-9cc30c3c6d6edb616bb76d15b46391bacf3e2052.zip
LAB: Clean up processArrow()
-rw-r--r--engines/lab/engine.cpp5
-rw-r--r--engines/lab/parsefun.h2
-rw-r--r--engines/lab/processroom.cpp53
3 files changed, 30 insertions, 30 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index ce89225560..726a10365f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -720,8 +720,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
oldDirection = _direction;
- NewDir = _direction;
- processArrow(&NewDir, gadgetId - 6);
+ NewDir = processArrow(_direction, gadgetId - 6);
doTurn(_direction, NewDir, &_cptr);
_anim->_doBlack = true;
_direction = NewDir;
@@ -737,7 +736,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_anim->_doBlack = true;
} else {
_anim->_doBlack = true;
- processArrow(&_direction, gadgetId - 6);
+ _direction = processArrow(_direction, gadgetId - 6);
if (oldRoomNum != _roomNum) {
drawStaticMessage(kTextGoForward);
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index 7f8895176b..c45727d907 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -45,7 +45,7 @@ bool parse(const char *inputFile);
ViewData *getViewData(uint16 roomNum, uint16 direction);
char *getPictName(CloseDataPtr *lcptr);
void drawDirection(CloseDataPtr lcptr);
-bool processArrow(uint16 *direction, uint16 arrow);
+uint16 processArrow(uint16 curDirection, uint16 arrow);
void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords = false);
bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *lcptr);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index d467c21cb5..1487888b27 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -188,44 +188,45 @@ void LabEngine::drawDirection(CloseDataPtr lcptr) {
/*****************************************************************************/
/* process a arrow gadget movement. */
/*****************************************************************************/
-bool processArrow(uint16 *direction, uint16 arrow) {
- if (arrow == 1) { /* Forward */
+uint16 processArrow(uint16 curDirection, uint16 arrow) {
+ if (arrow == 1) { // Forward
uint16 room = 1;
- if (*direction == NORTH)
+ if (curDirection == NORTH)
room = g_lab->_rooms[g_lab->_roomNum]._northDoor;
- else if (*direction == SOUTH)
+ else if (curDirection == SOUTH)
room = g_lab->_rooms[g_lab->_roomNum]._southDoor;
- else if (*direction == EAST)
+ else if (curDirection == EAST)
room = g_lab->_rooms[g_lab->_roomNum]._eastDoor;
- else if (*direction == WEST)
+ else if (curDirection == WEST)
room = g_lab->_rooms[g_lab->_roomNum]._westDoor;
- if (room == 0)
- return false;
- else
+ if (room != 0)
g_lab->_roomNum = room;
- } else if (arrow == 0) { /* Left */
- if (*direction == NORTH)
- *direction = WEST;
- else if (*direction == WEST)
- *direction = SOUTH;
- else if (*direction == SOUTH)
- *direction = EAST;
+
+ return curDirection;
+ } else if (arrow == 0) { // Left
+ if (curDirection == NORTH)
+ return WEST;
+ else if (curDirection == WEST)
+ return SOUTH;
+ else if (curDirection == SOUTH)
+ return EAST;
else
- *direction = NORTH;
- } else if (arrow == 2) { /* Right */
- if (*direction == NORTH)
- *direction = EAST;
- else if (*direction == EAST)
- *direction = SOUTH;
- else if (*direction == SOUTH)
- *direction = WEST;
+ return NORTH;
+ } else if (arrow == 2) { // Right
+ if (curDirection == NORTH)
+ return EAST;
+ else if (curDirection == EAST)
+ return SOUTH;
+ else if (curDirection == SOUTH)
+ return WEST;
else
- *direction = NORTH;
+ return NORTH;
}
- return true;
+ // Should never reach here!
+ return curDirection;
}
/*****************************************************************************/