[Scummvm-cvs-logs] SF.net SVN: scummvm:[53705] scummvm/trunk/engines/hugo
strangerke at users.sourceforge.net
strangerke at users.sourceforge.net
Fri Oct 22 22:45:01 CEST 2010
Revision: 53705
http://scummvm.svn.sourceforge.net/scummvm/?rev=53705&view=rev
Author: strangerke
Date: 2010-10-22 20:45:00 +0000 (Fri, 22 Oct 2010)
Log Message:
-----------
HUGO: Move findObjectSpace() to ObjectHandler class
Modified Paths:
--------------
scummvm/trunk/engines/hugo/hugo.cpp
scummvm/trunk/engines/hugo/hugo.h
scummvm/trunk/engines/hugo/mouse.cpp
scummvm/trunk/engines/hugo/object.cpp
scummvm/trunk/engines/hugo/object.h
Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp 2010-10-22 19:28:12 UTC (rev 53704)
+++ scummvm/trunk/engines/hugo/hugo.cpp 2010-10-22 20:45:00 UTC (rev 53705)
@@ -1737,49 +1737,6 @@
}
}
-// 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) {
Modified: scummvm/trunk/engines/hugo/hugo.h
===================================================================
--- scummvm/trunk/engines/hugo/hugo.h 2010-10-22 19:28:12 UTC (rev 53704)
+++ scummvm/trunk/engines/hugo/hugo.h 2010-10-22 20:45:00 UTC (rev 53705)
@@ -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 @@
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();
Modified: scummvm/trunk/engines/hugo/mouse.cpp
===================================================================
--- scummvm/trunk/engines/hugo/mouse.cpp 2010-10-22 19:28:12 UTC (rev 53704)
+++ scummvm/trunk/engines/hugo/mouse.cpp 2010-10-22 20:45:00 UTC (rev 53705)
@@ -118,7 +118,7 @@
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 @@
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);
Modified: scummvm/trunk/engines/hugo/object.cpp
===================================================================
--- scummvm/trunk/engines/hugo/object.cpp 2010-10-22 19:28:12 UTC (rev 53704)
+++ scummvm/trunk/engines/hugo/object.cpp 2010-10-22 20:45:00 UTC (rev 53705)
@@ -590,6 +590,49 @@
}
}
+// 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++) {
Modified: scummvm/trunk/engines/hugo/object.h
===================================================================
--- scummvm/trunk/engines/hugo/object.h 2010-10-22 19:28:12 UTC (rev 53704)
+++ scummvm/trunk/engines/hugo/object.h 2010-10-22 20:45:00 UTC (rev 53705)
@@ -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 @@
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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list