aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2004-10-05 02:16:26 +0000
committerEugene Sandulenko2004-10-05 02:16:26 +0000
commitf1ffeaf3ecebbbb1806645d70b3b745d9da4b7ea (patch)
treec6c9c5a84ead2ac4d07161f55fd397b7aeae6301
parent53d807ab169572a9991c18cc1373b585a8ec44d8 (diff)
downloadscummvm-rg350-f1ffeaf3ecebbbb1806645d70b3b745d9da4b7ea.tar.gz
scummvm-rg350-f1ffeaf3ecebbbb1806645d70b3b745d9da4b7ea.tar.bz2
scummvm-rg350-f1ffeaf3ecebbbb1806645d70b3b745d9da4b7ea.zip
o Convert some objectMap methods to more C++-like.
o Add stubs for unhandled scene resources in first scene o Fix object map entry structure o Fix bug with objject_info() debug command All this was done in attempt to make room exits work until I realized that they are different hit zone list which is activate at end of walk sequence. svn-id: r15416
-rw-r--r--saga/interface.cpp15
-rw-r--r--saga/objectmap.cpp71
-rw-r--r--saga/objectmap.h11
-rw-r--r--saga/scene.cpp8
-rw-r--r--saga/scene.h4
-rw-r--r--saga/xref.txt7
6 files changed, 52 insertions, 64 deletions
diff --git a/saga/interface.cpp b/saga/interface.cpp
index 72d38dc5fa..8ad46fa0a5 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -32,6 +32,7 @@
#include "saga/font.h"
#include "saga/objectmap.h"
#include "saga/rscfile_mod.h"
+#include "saga/scene.h"
#include "saga/script.h"
#include "saga/sprite.h"
@@ -492,13 +493,10 @@ int Interface::handlePlayfieldClick(R_SURFACE *ds, Point *imouse_pt) {
return R_SUCCESS;
}
- if (_vm->_objectMap->getFlags(object_num, &object_flags) != R_SUCCESS) {
- _vm->_console->print("Invalid object number: %d\n", object_num);
- return R_FAILURE;
- }
+ object_flags = _vm->_objectMap->getFlags(object_num);
if (object_flags & R_OBJECT_NORMAL) {
- if (_vm->_objectMap->getEPNum(object_num, &script_num) == R_SUCCESS) {
+ if ((script_num = _vm->_objectMap->getEPNum(object_num)) != -1) {
// Set active verb in script module
_vm->_sdata->putWord(4, 4, I_VerbData[_activeVerb].s_verb);
@@ -535,12 +533,9 @@ int Interface::handlePlayfieldUpdate(R_SURFACE *ds, Point *imouse_pt) {
return R_SUCCESS;
}
- if (_vm->_objectMap->getFlags(object_num, &object_flags) != R_SUCCESS) {
- _vm->_console->print("Invalid object number: %d\n", object_num);
- return R_FAILURE;
- }
+ object_flags = _vm->_objectMap->getFlags(object_num);
- _vm->_objectMap->getName(object_num, &object_name);
+ object_name = _vm->_objectMap->getName(object_num);
if (object_flags & R_OBJECT_NORMAL) {
// Normal scene object - display as subject of verb
diff --git a/saga/objectmap.cpp b/saga/objectmap.cpp
index 1880e24c0a..7b9ebaee2c 100644
--- a/saga/objectmap.cpp
+++ b/saga/objectmap.cpp
@@ -39,7 +39,7 @@ namespace Saga {
static void CF_object_info(int argc, char *argv[], void *refCon);
int ObjectMap::reg() {
- CVAR_RegisterFunc(CF_object_info, "object_info", NULL, R_CVAR_NONE, 0, 0, NULL);
+ CVAR_RegisterFunc(CF_object_info, "object_info", NULL, R_CVAR_NONE, 0, 0, this);
return R_SUCCESS;
}
@@ -60,7 +60,7 @@ ObjectMap::~ObjectMap() {
freeMem();
freeNames();
- debug(0, "ObjectMap Module: Shutdown AOK.");
+ debug(0, "ObjectMap Module: Shutdown OK.");
_initialized = 0;
}
@@ -97,9 +97,10 @@ int ObjectMap::load(const byte *om_res, size_t om_res_len) {
// Load all N objects
for (i = 0; i < _n_objects; i++) {
object_map = &_object_maps[i];
- object_map->unknown0 = readS.readByte();
+ object_map->flags = readS.readByte();
object_map->n_clickareas = readS.readByte();
- object_map->flags = readS.readUint16LE();
+ object_map->defaultVerb = readS.readByte();
+ readS.readByte();
object_map->object_num = readS.readUint16LE();
object_map->script_num = readS.readUint16LE();
object_map->clickareas = (R_CLICKAREA *)malloc(object_map->n_clickareas * sizeof *(object_map->clickareas));
@@ -223,66 +224,45 @@ int ObjectMap::freeNames() {
// name list resource, the funciton sets '*name' to the descriptive string
// corresponding to 'object' and returns R_SUCCESS. Otherwise it returns
// R_FAILURE.
-int ObjectMap::getName(int object, const char **name) {
- if (!_names_loaded) {
- return R_FAILURE;
- }
-
- if ((object <= 0) || (object > _n_names)) {
- return R_FAILURE;
- }
-
- *name = _names[object - 1];
+const char *ObjectMap::getName(int object) {
+ assert(_names_loaded);
+ assert((object > 0) && (object <= _n_names));
- return R_SUCCESS;
+ return _names[object - 1];
}
-int ObjectMap::getFlags(int object, uint16 *flags) {
+const uint16 ObjectMap::getFlags(int object) {
int i;
- if (!_names_loaded) {
- return R_FAILURE;
- }
-
- if ((object <= 0) || (object > _n_names)) {
- return R_FAILURE;
- }
+ assert(_names_loaded);
+ assert((object > 0) && (object <= _n_names));
for (i = 0; i < _n_objects; i++) {
if (_object_maps[i].object_num == object) {
- *flags = _object_maps[i].flags;
- return R_SUCCESS;
+ return _object_maps[i].flags;
}
}
- return R_FAILURE;
+ return 0;
}
// If 'object' is a valid object number in the currently loaded object
// name list resource, the funciton sets '*ep_num' to the entrypoint number
// corresponding to 'object' and returns R_SUCCESS. Otherwise, it returns
// R_FAILURE.
-int ObjectMap::getEPNum(int object, int *ep_num) {
+const int ObjectMap::getEPNum(int object) {
int i;
- if (!_names_loaded) {
- return R_FAILURE;
- }
+ assert(_names_loaded);
- if ((object < 0) || (object > (_n_objects + 1))) {
- return R_FAILURE;
- }
+ if ((object < 0) || (object > (_n_objects + 1)))
+ return -1;
- for (i = 0; i < _n_objects; i++) {
+ for (i = 0; i < _n_objects; i++)
+ if (_object_maps[i].object_num == object)
+ return _object_maps[i].script_num;
- if (_object_maps[i].object_num == object) {
-
- *ep_num = _object_maps[i].script_num;
- return R_SUCCESS;
- }
- }
-
- return R_FAILURE;
+ return -1;
}
// Uses Gfx::drawLine to display all clickareas for each object in the
@@ -317,9 +297,9 @@ int ObjectMap::draw(R_SURFACE *ds, Point *imouse_pt, int color, int color2) {
for (i = 0; i < _n_objects; i++) {
draw_color = color;
if (hit_object && (object_num == _object_maps[i].object_num)) {
- snprintf(txt_buf, sizeof txt_buf, "obj %d: ? %d, f %X",
+ snprintf(txt_buf, sizeof txt_buf, "obj %d: v %d, f %X",
_object_maps[i].object_num,
- _object_maps[i].unknown0,
+ _object_maps[i].defaultVerb,
_object_maps[i].flags);
draw_txt = 1;
draw_color = color2;
@@ -434,7 +414,8 @@ void ObjectMap::objectInfo(int argc, char *argv[]) {
for (i = 0; i < _n_objects; i++) {
_vm->_console->print("%s:", _names[i]);
- _vm->_console->print("%d. Unk1: %d, flags: %X, name_i: %d, scr_n: %d, ca_ct: %d", i, _object_maps[i].unknown0,
+ _vm->_console->print("%d. verb: %d, flags: %X, name_i: %d, scr_n: %d, ca_ct: %d", i,
+ _object_maps[i].defaultVerb,
_object_maps[i].flags,
_object_maps[i].object_num,
_object_maps[i].script_num,
diff --git a/saga/objectmap.h b/saga/objectmap.h
index 3a5b31823d..47350825f1 100644
--- a/saga/objectmap.h
+++ b/saga/objectmap.h
@@ -29,6 +29,7 @@
namespace Saga {
enum R_OBJECT_FLAGS {
+ R_OBJECT_EXIT = 0x01,
R_OBJECT_NORMAL = 0x02
};
@@ -38,8 +39,8 @@ struct R_CLICKAREA {
};
struct R_OBJECTMAP_ENTRY {
- int unknown0;
- uint16 flags;
+ byte flags;
+ byte defaultVerb;
int object_num;
int script_num;
@@ -59,9 +60,9 @@ public:
int freeMem(void);
int loadNames(const byte *onl_res, size_t onl_res_len);
int freeNames();
- int getName(int object, const char **name);
- int getFlags(int object, uint16 *flags);
- int getEPNum(int object, int *ep_num);
+ const char *getName(int object);
+ const uint16 getFlags(int object);
+ const int getEPNum(int object);
int draw(R_SURFACE *draw_surface, Point *imouse_pt, int color, int color2);
int hitTest(Point *imouse_pt, int *object_num);
void objectInfo(int argc, char *argv[]);
diff --git a/saga/scene.cpp b/saga/scene.cpp
index 8250f18cb0..72227eecf3 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -763,6 +763,12 @@ int Scene::processSceneResources() {
debug(0, "Loading palette animation resource.");
_vm->_palanim->loadPalAnim(_resList[i].res_data, _resList[i].res_data_len);
break;
+ case SAGA_ENTRY:
+ warning("Scene::ProcessSceneResources(): Loading scene entries is not implemented");
+ break;
+ case SAGA_FACES:
+ warning("Scene::ProcessSceneResources(): Loading scene faces is not implemented");
+ break;
default:
warning("Scene::ProcessSceneResources(): Encountered unknown resource type: %d", _resList[i].res_type);
break;
@@ -972,7 +978,7 @@ int Scene::defaultScene(int param, R_SCENE_INFO *scene_info) {
_vm->_events->queue(&event);
} else
_vm->_music->stop();
-
+ //break; //HACK to disable faery script
if (_desc.sceneScriptNum > 0) {
R_SCRIPT_THREAD *_sceneScriptThread;
diff --git a/saga/scene.h b/saga/scene.h
index 0112f6e6a5..e787722c2d 100644
--- a/saga/scene.h
+++ b/saga/scene.h
@@ -82,6 +82,7 @@ enum SAGA_RESOURCE_TYPES {
SAGA_ISO_TILESET = 8,
SAGA_ISO_METAMAP = 9,
SAGA_ISO_METATILESET = 10,
+ SAGA_ENTRY = 12,
SAGA_ANIM_1 = 14,
SAGA_ANIM_2,
SAGA_ANIM_3,
@@ -89,7 +90,8 @@ enum SAGA_RESOURCE_TYPES {
SAGA_ANIM_5,
SAGA_ANIM_6,
SAGA_ANIM_7,
- SAGA_PAL_ANIM = 23
+ SAGA_PAL_ANIM = 23,
+ SAGA_FACES = 24
};
#define SAGA_RESLIST_ENTRY_LEN 4
diff --git a/saga/xref.txt b/saga/xref.txt
index b11dc732db..4668e3a067 100644
--- a/saga/xref.txt
+++ b/saga/xref.txt
@@ -18,7 +18,7 @@ Sceneres.h
LOADREQ_TILE_MAP SAGA_ISO_METAMAP
LOADREQ_TILE_PLATFORMS SAGA_ISO_METATILESET
LOADREQ_TILE_METATILES
- LOADREQ_ENTRY
+ LOADREQ_ENTRY SAGA_ENTRY
LOADREQ_FRAMELIST
LOADREQ_ANIM_0 SAGA_ANIM_1
@@ -32,9 +32,12 @@ Sceneres.h
LOADREQ_TILE_MULTI
LOADREQ_CYCLES SAGA_PAL_ANIM
- LOADREQ_FACES
+ LOADREQ_FACES SAGA_FACES
LOADREQ_PALETTE
+ HZONE_EXIT R_OBJECT_EXIT
+ HZONEF_AUTOWALK R_OBJECT_NORMAL
+
Scene.c
=======
ResToImage() _vm->decodeBGImage()