From 69c5b01e127c5f2c63469ea04fcb51fc6dd0ee37 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 9 Aug 2016 22:58:23 +0200 Subject: DM: Refactor f155_getStairsExitDirection --- engines/dm/dungeonman.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 8816ed7d71..0da7ccd310 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1568,19 +1568,22 @@ void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList } int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) { - int16 L0256_i_SquareType; - bool L0257_B_NorthSouthOrientedStairs; + bool northSouthOrientedStairs = !getFlag(f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient); - - if (L0257_B_NorthSouthOrientedStairs = !getFlag(f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient)) { + if (northSouthOrientedStairs) { mapX = mapX + _vm->_dirIntoStepCountEast[kDirEast]; mapY = mapY + _vm->_dirIntoStepCountNorth[kDirEast]; } else { mapX = mapX + _vm->_dirIntoStepCountEast[kDirNorth]; mapY = mapY + _vm->_dirIntoStepCountNorth[kDirNorth]; } - return ((((L0256_i_SquareType = Square(f151_getSquare(mapX, mapY)).getType()) == k0_ElementTypeWall) || (L0256_i_SquareType == k3_ElementTypeStairs)) << 1) + L0257_B_NorthSouthOrientedStairs; + int16 squareType = Square(f151_getSquare(mapX, mapY)).getType(); + + int16 retval = ((squareType == k0_ElementTypeWall) || (squareType == k3_ElementTypeStairs)) ? 1 : 0; + retval <<= 1; + retval += (northSouthOrientedStairs ? 1 : 0); + return retval; } Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) { -- cgit v1.2.3