aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorArnaud Boutonné2010-10-22 20:45:00 +0000
committerArnaud Boutonné2010-10-22 20:45:00 +0000
commit4a0ba817e58c5a1c7d17af5a79f91570dd98ca16 (patch)
tree9cd068b31f3cb26e73a0b016de7701a651e76183 /engines
parent031e0167e4979fcb9f5bef3fde273605d3dc8eb9 (diff)
downloadscummvm-rg350-4a0ba817e58c5a1c7d17af5a79f91570dd98ca16.tar.gz
scummvm-rg350-4a0ba817e58c5a1c7d17af5a79f91570dd98ca16.tar.bz2
scummvm-rg350-4a0ba817e58c5a1c7d17af5a79f91570dd98ca16.zip
HUGO: Move findObjectSpace() to ObjectHandler class
svn-id: r53705
Diffstat (limited to 'engines')
-rw-r--r--engines/hugo/hugo.cpp43
-rw-r--r--engines/hugo/hugo.h3
-rw-r--r--engines/hugo/mouse.cpp4
-rw-r--r--engines/hugo/object.cpp43
-rw-r--r--engines/hugo/object.h6
5 files changed, 49 insertions, 50 deletions
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index e59ee9a61c..cd7d8ac2fc 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -1737,49 +1737,6 @@ void HugoEngine::processMaze() {
}
}
-// Find a clear space around supplied object that hero can walk to
-bool HugoEngine::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) {
- debugC(1, kDebugEngine, "findObjectSpace(obj, %d, %d)", *destx, *desty);
-
- seq_t *curImage = obj->currImagePtr;
- int16 y = obj->y + curImage->y2 - 1;
-
- bool foundFl = true;
- // Try left rear corner
- for (int16 x = *destx = obj->x + curImage->x1; x < *destx + HERO_MAX_WIDTH; x++) {
- if (BOUND(x, y))
- foundFl = false;
- }
-
- if (!foundFl) { // Try right rear corner
- foundFl = true;
- for (int16 x = *destx = obj->x + curImage->x2 - HERO_MAX_WIDTH + 1; x <= obj->x + (int16)curImage->x2; x++) {
- if (BOUND(x, y))
- foundFl = false;
- }
- }
-
- if (!foundFl) { // Try left front corner
- foundFl = true;
- y += 2;
- for (int16 x = *destx = obj->x + curImage->x1; x < *destx + HERO_MAX_WIDTH; x++) {
- if (BOUND(x, y))
- foundFl = false;
- }
- }
-
- if (!foundFl) { // Try right rear corner
- foundFl = true;
- for (int16 x = *destx = obj->x + curImage->x2 - HERO_MAX_WIDTH + 1; x <= obj->x + (int16)curImage->x2; x++) {
- if (BOUND(x, y))
- foundFl = false;
- }
- }
-
- *desty = y;
- return foundFl;
-}
-
// Search background command list for this screen for supplied object.
// Return first associated verb (not "look") or 0 if none found.
char *HugoEngine::useBG(char *name) {
diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h
index 633f1829ab..f398fdbb9d 100644
--- a/engines/hugo/hugo.h
+++ b/engines/hugo/hugo.h
@@ -38,7 +38,6 @@
#define EDGE 10 // Closest object can get to edge of screen
#define EDGE2 (EDGE * 2) // Push object further back on edge collision
#define SHIFT 8 // Place hero this far inside bounding box
-#define BOUND(X, Y) ((_boundary[Y * XBYTES + X / 8] & (0x80 >> X % 8)) != 0) // Boundary bit set
namespace Common {
class RandomSource;
@@ -191,8 +190,6 @@ public:
return _mouseY;
}
- bool findObjectSpace(object_t *obj, int16 *destx, int16 *desty);
-
void boundaryCollision(object_t *obj);
void clearBoundary(int x1, int x2, int y);
void endGame();
diff --git a/engines/hugo/mouse.cpp b/engines/hugo/mouse.cpp
index 247b859793..9fc8a33373 100644
--- a/engines/hugo/mouse.cpp
+++ b/engines/hugo/mouse.cpp
@@ -118,7 +118,7 @@ void MouseHandler::processRightClick(int16 objId, int16 cx, int16 cy) {
int16 x, y;
switch (obj->viewx) { // Where to walk to
case -1: // Walk to object position
- if (_vm->findObjectSpace(obj, &x, &y))
+ if (_vm->_object->findObjectSpace(obj, &x, &y))
foundFl = _vm->_route->startRoute(GO_GET, objId, x, y);
if (!foundFl) // Can't get there, try to use from here
_vm->_object->useObject(objId);
@@ -201,7 +201,7 @@ void MouseHandler::processLeftClick(int16 objId, int16 cx, int16 cy) {
bool foundFl = false; // TRUE if route found to object
switch (obj->viewx) { // Clicked over viewport object
case -1: // Walk to object position
- if (_vm->findObjectSpace(obj, &x, &y))
+ if (_vm->_object->findObjectSpace(obj, &x, &y))
foundFl = _vm->_route->startRoute(GO_LOOK, objId, x, y);
if (!foundFl) // Can't get there, immediate description
_vm->_object->lookObject(obj);
diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp
index f2b4d08644..e594e6918f 100644
--- a/engines/hugo/object.cpp
+++ b/engines/hugo/object.cpp
@@ -590,6 +590,49 @@ void ObjectHandler::showTakeables() {
}
}
+// Find a clear space around supplied object that hero can walk to
+bool ObjectHandler::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) {
+ debugC(1, kDebugEngine, "findObjectSpace(obj, %d, %d)", *destx, *desty);
+
+ seq_t *curImage = obj->currImagePtr;
+ int16 y = obj->y + curImage->y2 - 1;
+
+ bool foundFl = true;
+ // Try left rear corner
+ for (int16 x = *destx = obj->x + curImage->x1; x < *destx + HERO_MAX_WIDTH; x++) {
+ if (BOUND(x, y))
+ foundFl = false;
+ }
+
+ if (!foundFl) { // Try right rear corner
+ foundFl = true;
+ for (int16 x = *destx = obj->x + curImage->x2 - HERO_MAX_WIDTH + 1; x <= obj->x + (int16)curImage->x2; x++) {
+ if (BOUND(x, y))
+ foundFl = false;
+ }
+ }
+
+ if (!foundFl) { // Try left front corner
+ foundFl = true;
+ y += 2;
+ for (int16 x = *destx = obj->x + curImage->x1; x < *destx + HERO_MAX_WIDTH; x++) {
+ if (BOUND(x, y))
+ foundFl = false;
+ }
+ }
+
+ if (!foundFl) { // Try right rear corner
+ foundFl = true;
+ for (int16 x = *destx = obj->x + curImage->x2 - HERO_MAX_WIDTH + 1; x <= obj->x + (int16)curImage->x2; x++) {
+ if (BOUND(x, y))
+ foundFl = false;
+ }
+ }
+
+ *desty = y;
+ return foundFl;
+}
+
void ObjectHandler::loadObject(Common::File &in) {
// TODO: For Hugo3, if not in story mode, set _objects[2].state to 3
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
diff --git a/engines/hugo/object.h b/engines/hugo/object.h
index b270b3dd75..0f7f4e9e10 100644
--- a/engines/hugo/object.h
+++ b/engines/hugo/object.h
@@ -36,6 +36,7 @@
#include "common/file.h"
#define MAXOBJECTS 128 // Used in Update_images()
+#define BOUND(X, Y) ((_vm->getBoundaryOverlay()[Y * XBYTES + X / 8] & (0x80 >> X % 8)) != 0) // Boundary bit set
namespace Hugo {
@@ -46,13 +47,14 @@ public:
object_t *_objects;
- bool isCarrying(uint16 wordIndex);
+ bool isCarrying(uint16 wordIndex);
+ bool findObjectSpace(object_t *obj, int16 *destx, int16 *desty);
int16 findObject(uint16 x, uint16 y);
- void lookObject(object_t *obj);
void freeObjects();
void loadObject(Common::File &in);
+ void lookObject(object_t *obj);
void moveObjects();
void restoreSeq(object_t *obj);
void saveSeq(object_t *obj);