aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Hesse2010-10-30 17:24:52 +0000
committerSven Hesse2010-10-30 17:24:52 +0000
commit31dd8026dce37df32785443b6ee1b535873b4b29 (patch)
tree9cdfc807186c8a4ef306b6cf4d4094d295111741
parent724a702fdfb5cd635706403829f8770bb3a3de8d (diff)
downloadscummvm-rg350-31dd8026dce37df32785443b6ee1b535873b4b29.tar.gz
scummvm-rg350-31dd8026dce37df32785443b6ee1b535873b4b29.tar.bz2
scummvm-rg350-31dd8026dce37df32785443b6ee1b535873b4b29.zip
GOB: Minor map cleanup
- Move enum Direction out of class Map - Convert kLeft et al into a proper enum RelativeDirection svn-id: r53946
-rw-r--r--engines/gob/goblin_v1.cpp18
-rw-r--r--engines/gob/goblin_v2.cpp20
-rw-r--r--engines/gob/goblin_v4.cpp72
-rw-r--r--engines/gob/map.cpp43
-rw-r--r--engines/gob/map.h37
5 files changed, 98 insertions, 92 deletions
diff --git a/engines/gob/goblin_v1.cpp b/engines/gob/goblin_v1.cpp
index ec3d724624..a11134b05c 100644
--- a/engines/gob/goblin_v1.cpp
+++ b/engines/gob/goblin_v1.cpp
@@ -176,7 +176,7 @@ void Goblin_v1::movePathFind(Mult::Mult_Object *obj,
nextAct = (int16) _vm->_map->getDirection(_vm->_map->_curGoblinX,
_vm->_map->_curGoblinY, _vm->_map->_destX, _vm->_map->_destY);
- if (nextAct == Map::kDirNone)
+ if (nextAct == kDirNone)
_pathExistence = 0;
} else if (_pathExistence == 3) {
_vm->_map->_curGoblinX = _gobPositions[_currentGoblin].x;
@@ -238,11 +238,11 @@ void Goblin_v1::movePathFind(Mult::Mult_Object *obj,
nextAct = 0x4DC8;
switch (nextAct) {
- case Map::kDirW:
+ case kDirW:
gobDesc->nextState = rotateState(gobDesc->curLookDir, 0);
break;
- case Map::kDirE:
+ case kDirE:
gobDesc->nextState = rotateState(gobDesc->curLookDir, 4);
break;
@@ -254,7 +254,7 @@ void Goblin_v1::movePathFind(Mult::Mult_Object *obj,
gobDesc->nextState = 23;
break;
- case Map::kDirN:
+ case kDirN:
if ((_vm->_map->getPass(_vm->_map->_curGoblinX, _vm->_map->_curGoblinY - 1) == 6) &&
(_currentGoblin != 1)) {
_pathExistence = 0;
@@ -275,7 +275,7 @@ void Goblin_v1::movePathFind(Mult::Mult_Object *obj,
gobDesc->nextState = rotateState(gobDesc->curLookDir, 2);
break;
- case Map::kDirS:
+ case kDirS:
if ((_vm->_map->getPass(_vm->_map->_curGoblinX, _vm->_map->_curGoblinY + 1) == 6) &&
(_currentGoblin != 1)) {
_pathExistence = 0;
@@ -296,7 +296,7 @@ void Goblin_v1::movePathFind(Mult::Mult_Object *obj,
gobDesc->nextState = rotateState(gobDesc->curLookDir, 6);
break;
- case Map::kDirSE:
+ case kDirSE:
if ((_vm->_map->getPass(_vm->_map->_curGoblinX + 1, _vm->_map->_curGoblinY + 1) == 6) &&
(_currentGoblin != 1)) {
_pathExistence = 0;
@@ -310,7 +310,7 @@ void Goblin_v1::movePathFind(Mult::Mult_Object *obj,
gobDesc->nextState = rotateState(gobDesc->curLookDir, 4);
break;
- case Map::kDirSW:
+ case kDirSW:
if ((_vm->_map->getPass(_vm->_map->_curGoblinX - 1, _vm->_map->_curGoblinY + 1) == 6) &&
(_currentGoblin != 1)) {
_pathExistence = 0;
@@ -324,7 +324,7 @@ void Goblin_v1::movePathFind(Mult::Mult_Object *obj,
gobDesc->nextState = rotateState(gobDesc->curLookDir, 0);
break;
- case Map::kDirNW:
+ case kDirNW:
if ((_vm->_map->getPass(_vm->_map->_curGoblinX - 1, _vm->_map->_curGoblinY - 1) == 6) &&
(_currentGoblin != 1)) {
_pathExistence = 0;
@@ -338,7 +338,7 @@ void Goblin_v1::movePathFind(Mult::Mult_Object *obj,
gobDesc->nextState = rotateState(gobDesc->curLookDir, 0);
break;
- case Map::kDirNE:
+ case kDirNE:
if ((_vm->_map->getPass(_vm->_map->_curGoblinX + 1, _vm->_map->_curGoblinY - 1) == 6) &&
(_currentGoblin != 1)) {
_pathExistence = 0;
diff --git a/engines/gob/goblin_v2.cpp b/engines/gob/goblin_v2.cpp
index 0ea3003e96..c2fc4ad166 100644
--- a/engines/gob/goblin_v2.cpp
+++ b/engines/gob/goblin_v2.cpp
@@ -142,12 +142,12 @@ void Goblin_v2::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
animData->destY = gobDestY;
animData->order = gobY;
- Map::Direction dir = Map::kDirNone;
+ Direction dir = kDirNone;
if (animData->pathExistence == 1) {
dir = _vm->_map->getDirection(gobX, gobY, destX, destY);
- if (dir == Map::kDirNone)
+ if (dir == kDirNone)
animData->pathExistence = 0;
if ((gobX == gobDestX) && (gobY == gobDestY))
animData->pathExistence = 4;
@@ -218,7 +218,7 @@ void Goblin_v2::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
obj->gobDestY = gobDestY;
switch (dir) {
- case Map::kDirNW:
+ case kDirNW:
animData->nextState = 1;
if (_vm->_map->_screenWidth == 640) {
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
@@ -228,7 +228,7 @@ void Goblin_v2::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
}
break;
- case Map::kDirN:
+ case kDirN:
animData->nextState =
(animData->curLookDir == 2) ? 2 : rotateState(animData->curLookDir, 2);
if (_vm->_map->_screenWidth == 640) {
@@ -248,7 +248,7 @@ void Goblin_v2::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
}
break;
- case Map::kDirNE:
+ case kDirNE:
animData->nextState = 3;
if (_vm->_map->_screenWidth == 640) {
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
@@ -258,15 +258,15 @@ void Goblin_v2::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
}
break;
- case Map::kDirW:
+ case kDirW:
animData->nextState = rotateState(animData->curLookDir, 0);
break;
- case Map::kDirE:
+ case kDirE:
animData->nextState = rotateState(animData->curLookDir, 4);
break;
- case Map::kDirSW:
+ case kDirSW:
animData->nextState = 7;
if (_vm->_map->_screenWidth == 640) {
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
@@ -276,7 +276,7 @@ void Goblin_v2::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
}
break;
- case Map::kDirS:
+ case kDirS:
animData->nextState =
(animData->curLookDir == 6) ? 6 : rotateState(animData->curLookDir, 6);
if (_vm->_map->_screenWidth == 640) {
@@ -287,7 +287,7 @@ void Goblin_v2::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
}
break;
- case Map::kDirSE:
+ case kDirSE:
animData->nextState = 5;
if (_vm->_map->_screenWidth == 640) {
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
diff --git a/engines/gob/goblin_v4.cpp b/engines/gob/goblin_v4.cpp
index 25c52cef35..7758170332 100644
--- a/engines/gob/goblin_v4.cpp
+++ b/engines/gob/goblin_v4.cpp
@@ -125,18 +125,18 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
if (_vm->_map->_widthByte == 4) {
switch (dir) {
- case Map::kDirNW:
- animData->nextState = turnState(animData->state, Map::kDirNW);
+ case kDirNW:
+ animData->nextState = turnState(animData->state, kDirNW);
if ((_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) &&
(animData->nextState == 1))
animData->nextState = 40;
if (_vm->_map->getPass(obj->goblinX - 1, obj->goblinY - 2) != 10)
- animData->nextState = turnState(animData->state, Map::kDirNW);
+ animData->nextState = turnState(animData->state, kDirNW);
break;
- case Map::kDirN:
+ case kDirN:
animData->nextState =
- (animData->curLookDir == 2) ? 2 : turnState(animData->state, Map::kDirN);
+ (animData->curLookDir == 2) ? 2 : turnState(animData->state, kDirN);
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) {
if (_vm->_map->getPass(obj->goblinX - 1, obj->goblinY - 2) != 10) {
if (_vm->_map->getPass(obj->goblinX + 1, obj->goblinY - 2) == 10)
@@ -154,35 +154,35 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
animData->nextState = 26;
break;
- case Map::kDirNE:
- animData->nextState = turnState(animData->state, Map::kDirNE);
+ case kDirNE:
+ animData->nextState = turnState(animData->state, kDirNE);
if ((_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) &&
(animData->nextState == 3))
animData->nextState = 42;
if (_vm->_map->getPass(obj->goblinX + 1, obj->goblinY - 2) != 10)
- animData->nextState = turnState(animData->state, Map::kDirNE);
+ animData->nextState = turnState(animData->state, kDirNE);
break;
- case Map::kDirW:
- animData->nextState = turnState(animData->state, Map::kDirW);
+ case kDirW:
+ animData->nextState = turnState(animData->state, kDirW);
break;
- case Map::kDirE:
- animData->nextState = turnState(animData->state, Map::kDirE);
+ case kDirE:
+ animData->nextState = turnState(animData->state, kDirE);
break;
- case Map::kDirSW:
- animData->nextState = turnState(animData->state, Map::kDirSW);
+ case kDirSW:
+ animData->nextState = turnState(animData->state, kDirSW);
if ((_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) &&
(animData->nextState == 7))
animData->nextState = 41;
if (_vm->_map->getPass(obj->goblinX - 1, obj->goblinY) != 10)
- animData->nextState = turnState(animData->state, Map::kDirSW);
+ animData->nextState = turnState(animData->state, kDirSW);
break;
- case Map::kDirS:
+ case kDirS:
animData->nextState =
- (animData->curLookDir == 6) ? 6 : turnState(animData->state, Map::kDirS);
+ (animData->curLookDir == 6) ? 6 : turnState(animData->state, kDirS);
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) {
if (_vm->_map->getPass(obj->goblinX - 1, obj->goblinY + 2) != 10) {
if (_vm->_map->getPass(obj->goblinX + 1, obj->goblinY + 2) == 10)
@@ -201,13 +201,13 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
animData->nextState = 27;
break;
- case Map::kDirSE:
- animData->nextState = turnState(animData->state, Map::kDirSE);
+ case kDirSE:
+ animData->nextState = turnState(animData->state, kDirSE);
if ((_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) &&
(animData->nextState == 5))
animData->nextState = 43;
if (_vm->_map->getPass(obj->goblinX + 1, obj->goblinY) != 10)
- animData->nextState = turnState(animData->state, Map::kDirSE);
+ animData->nextState = turnState(animData->state, kDirSE);
break;
default:
@@ -260,7 +260,7 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
}
} else {
switch (dir) {
- case Map::kDirNW:
+ case kDirNW:
animData->nextState = 1;
if (_vm->_map->_screenWidth == 640) {
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
@@ -270,7 +270,7 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
}
break;
- case Map::kDirN:
+ case kDirN:
animData->nextState =
(animData->curLookDir == 2) ? 2 : rotateState(animData->curLookDir, 2);
if (_vm->_map->_screenWidth == 640) {
@@ -289,7 +289,7 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
}
break;
- case Map::kDirNE:
+ case kDirNE:
animData->nextState = 3;
if (_vm->_map->_screenWidth == 640) {
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
@@ -299,15 +299,15 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
}
break;
- case Map::kDirW:
+ case kDirW:
animData->nextState = rotateState(animData->curLookDir, 0);
break;
- case Map::kDirE:
+ case kDirE:
animData->nextState = rotateState(animData->curLookDir, 4);
break;
- case Map::kDirSW:
+ case kDirSW:
animData->nextState = 7;
if (_vm->_map->_screenWidth == 640) {
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
@@ -317,7 +317,7 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
}
break;
- case Map::kDirS:
+ case kDirS:
animData->nextState =
(animData->curLookDir == 6) ? 6 : rotateState(animData->curLookDir, 6);
if (_vm->_map->_screenWidth == 640) {
@@ -328,7 +328,7 @@ void Goblin_v4::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16
}
break;
- case Map::kDirSE:
+ case kDirSE:
animData->nextState = 5;
if (_vm->_map->_screenWidth == 640) {
if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
@@ -589,35 +589,35 @@ int16 Goblin_v4::turnState(int16 state, uint16 dir) {
}
switch (dir) {
- case Map::kDirNW:
+ case kDirNW:
cx = 1;
break;
- case Map::kDirN:
+ case kDirN:
cx = 2;
break;
- case Map::kDirNE:
+ case kDirNE:
cx = 3;
break;
- case Map::kDirW:
+ case kDirW:
cx = 0;
break;
- case Map::kDirE:
+ case kDirE:
cx = 4;
break;
- case Map::kDirSW:
+ case kDirSW:
cx = 7;
break;
- case Map::kDirS:
+ case kDirS:
cx = 6;
break;
- case Map::kDirSE:
+ case kDirSE:
cx = 5;
break;
}
diff --git a/engines/gob/map.cpp b/engines/gob/map.cpp
index 4fc642572c..03708298d7 100644
--- a/engines/gob/map.cpp
+++ b/engines/gob/map.cpp
@@ -83,14 +83,7 @@ void Map::placeItem(int16 x, int16 y, int16 id) {
setItem(x, y, (getItem(x, y) & 0x00FF) | (id << 8));
}
-enum {
- kLeft = (1 << 0),
- kUp = (1 << 1),
- kRight = (1 << 2),
- kDown = (1 << 3)
-};
-
-Map::Direction Map::getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
+Direction Map::getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
if ((x0 == x1) && (y0 == y1))
// Already at the destination
return kDirNone;
@@ -99,36 +92,36 @@ Map::Direction Map::getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
// Destination out of range
return kDirNone;
- int16 dir = 0;
+ RelativeDirection relDir = kRelDirNone;
// Find the direct direction we want to move
if (y1 > y0)
- dir |= kDown;
+ relDir = kRelDirDown;
else if (y1 < y0)
- dir |= kUp;
+ relDir = kRelDirUp;
if (x1 > x0)
- dir |= kRight;
+ relDir = (RelativeDirection)(relDir | kRelDirRight);
else if (x1 < x0)
- dir |= kLeft;
+ relDir = (RelativeDirection)(relDir | kRelDirLeft);
// Are we on ladders and can continue the ladder in the wanted direction?
- if ((getPass(x0, y0) == 3) && (dir & kUp ) && (getPass(x0, y0 - 1) != 0))
+ if ((getPass(x0, y0) == 3) && (relDir & kRelDirUp ) && (getPass(x0, y0 - 1) != 0))
return kDirN;
- if ((getPass(x0, y0) == 3) && (dir & kDown) && (getPass(x0, y0 + 1) != 0))
+ if ((getPass(x0, y0) == 3) && (relDir & kRelDirDown) && (getPass(x0, y0 + 1) != 0))
return kDirS;
- if ((getPass(x0, y0) == 6) && (dir & kUp ) && (getPass(x0, y0 - 1) != 0))
+ if ((getPass(x0, y0) == 6) && (relDir & kRelDirUp ) && (getPass(x0, y0 - 1) != 0))
return kDirN;
- if ((getPass(x0, y0) == 6) && (dir & kDown) && (getPass(x0, y0 + 1) != 0))
+ if ((getPass(x0, y0) == 6) && (relDir & kRelDirDown) && (getPass(x0, y0 + 1) != 0))
return kDirS;
// Want to go left
- if (dir == kLeft) {
+ if (relDir == kRelDirLeft) {
if (getPass(x0 - 1, y0) != 0)
// Can go west
return kDirW;
@@ -138,7 +131,7 @@ Map::Direction Map::getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
}
// Want to go left
- if (dir == kRight) {
+ if (relDir == kRelDirRight) {
if (getPass(x0 + 1, y0) != 0)
// Can go east
return kDirE;
@@ -149,7 +142,7 @@ Map::Direction Map::getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
// Want to go up
- if (dir == kUp) {
+ if (relDir == kRelDirUp) {
if (getPass(x0 , y0 - 1) != 0)
// Can go north
return kDirN;
@@ -167,7 +160,7 @@ Map::Direction Map::getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
}
// Want to go down
- if (dir == kDown) {
+ if (relDir == kRelDirDown) {
if (getPass(x0 , y0 + 1) != 0)
// Can go south
return kDirS;
@@ -186,7 +179,7 @@ Map::Direction Map::getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
// Want to go up and right
- if (dir == (kRight | kUp)) {
+ if (relDir == kRelDirRightUp) {
if (getPass(x0 + 1, y0 - 1) != 0)
// Can go north-east
return kDirNE;
@@ -204,7 +197,7 @@ Map::Direction Map::getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
}
// Want to go down and right
- if (dir == (kRight | kDown)) {
+ if (relDir == kRelDirRightDown) {
if (getPass(x0 + 1, y0 + 1) != 0)
// Can go south-east
return kDirSE;
@@ -222,7 +215,7 @@ Map::Direction Map::getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
}
// Want to go up and left
- if (dir == (kLeft | kUp)) {
+ if (relDir == kRelDirLeftUp) {
if (getPass(x0 - 1, y0 - 1) != 0)
// Can go north-west
return kDirNW;
@@ -240,7 +233,7 @@ Map::Direction Map::getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
}
// Want to go left and down
- if (dir == (kLeft | kDown)) {
+ if (relDir == kRelDirLeftDown) {
if (getPass(x0 - 1, y0 + 1) != 0)
// Can go south-west
return kDirSW;
diff --git a/engines/gob/map.h b/engines/gob/map.h
index c268fbaca5..a38826d1d0 100644
--- a/engines/gob/map.h
+++ b/engines/gob/map.h
@@ -30,22 +30,35 @@
namespace Gob {
+enum RelativeDirection {
+ kRelDirNone = 0 ,
+
+ kRelDirLeft = (1 << 0),
+ kRelDirUp = (1 << 1),
+ kRelDirRight = (1 << 2),
+ kRelDirDown = (1 << 3),
+
+ kRelDirLeftUp = kRelDirLeft | kRelDirUp,
+ kRelDirLeftDown = kRelDirLeft | kRelDirDown,
+ kRelDirRightUp = kRelDirRight | kRelDirUp,
+ kRelDirRightDown = kRelDirRight | kRelDirDown
+};
+
// The same numeric values are also used for the arrow keys.
+enum Direction {
+ kDirNone = 0x0000,
+ kDirNW = 0x4700,
+ kDirN = 0x4800,
+ kDirNE = 0x4900,
+ kDirW = 0x4B00,
+ kDirE = 0x4D00,
+ kDirSW = 0x4F00,
+ kDirS = 0x5000,
+ kDirSE = 0x5100
+};
class Map {
public:
- enum Direction {
- kDirNone = 0x0000,
- kDirNW = 0x4700,
- kDirN = 0x4800,
- kDirNE = 0x4900,
- kDirW = 0x4B00,
- kDirE = 0x4D00,
- kDirSW = 0x4F00,
- kDirS = 0x5000,
- kDirSE = 0x5100
- };
-
#include "common/pack-start.h" // START STRUCT PACKING
struct Point {