aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--saga/interface.cpp14
-rw-r--r--saga/objectmap.cpp186
-rw-r--r--saga/objectmap.h40
-rw-r--r--saga/objectmap_mod.h50
-rw-r--r--saga/render.cpp7
-rw-r--r--saga/render.h3
-rw-r--r--saga/saga.cpp17
-rw-r--r--saga/saga.h4
-rw-r--r--saga/scene.cpp16
9 files changed, 154 insertions, 183 deletions
diff --git a/saga/interface.cpp b/saga/interface.cpp
index 8c674b11dc..5ffa526dec 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -30,7 +30,7 @@
#include "actor_mod.h"
#include "console_mod.h"
#include "font_mod.h"
-#include "objectmap_mod.h"
+#include "objectmap.h"
#include "rscfile_mod.h"
#include "script_mod.h"
#include "sprite_mod.h"
@@ -480,7 +480,7 @@ int HandlePlayfieldClick(R_SURFACE *ds, R_POINT *imouse_pt) {
int script_num;
R_POINT iactor_pt;
- hit_object = OBJECTMAP_HitTest(imouse_pt, &object_num);
+ hit_object = _vm->_objectMap->hitTest(imouse_pt, &object_num);
if (hit_object != R_SUCCESS) {
// Player clicked on empty spot - walk here regardless of verb
@@ -489,13 +489,13 @@ int HandlePlayfieldClick(R_SURFACE *ds, R_POINT *imouse_pt) {
return R_SUCCESS;
}
- if (OBJECTMAP_GetFlags(object_num, &object_flags) != R_SUCCESS) {
+ if (_vm->_objectMap->getFlags(object_num, &object_flags) != R_SUCCESS) {
CON_Print("Invalid object number: %d\n", object_num);
return R_FAILURE;
}
if (object_flags & R_OBJECT_NORMAL) {
- if (OBJECTMAP_GetEPNum(object_num, &script_num) == R_SUCCESS) {
+ if (_vm->_objectMap->getEPNum(object_num, &script_num) == R_SUCCESS) {
// Set active verb in script module
_vm->_sdata->putWord(4, 4, I_VerbData[IfModule.active_verb].s_verb);
@@ -524,7 +524,7 @@ int HandlePlayfieldUpdate(R_SURFACE *ds, R_POINT *imouse_pt) {
new_status[0] = 0;
- hit_object = OBJECTMAP_HitTest(imouse_pt, &object_num);
+ hit_object = _vm->_objectMap->hitTest(imouse_pt, &object_num);
if (hit_object != R_SUCCESS) {
// Cursor over nothing - just display current verb
@@ -532,12 +532,12 @@ int HandlePlayfieldUpdate(R_SURFACE *ds, R_POINT *imouse_pt) {
return R_SUCCESS;
}
- if (OBJECTMAP_GetFlags(object_num, &object_flags) != R_SUCCESS) {
+ if (_vm->_objectMap->getFlags(object_num, &object_flags) != R_SUCCESS) {
CON_Print("Invalid object number: %d\n", object_num);
return R_FAILURE;
}
- OBJECTMAP_GetName(object_num, &object_name);
+ _vm->_objectMap->getName(object_num, &object_name);
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 18ce29279b..2ecfea522b 100644
--- a/saga/objectmap.cpp
+++ b/saga/objectmap.cpp
@@ -32,47 +32,39 @@
#include "cvar_mod.h"
#include "console_mod.h"
#include "font_mod.h"
-
-#include "objectmap_mod.h"
#include "objectmap.h"
namespace Saga {
-static R_OBJECTMAP_INFO OMInfo;
+static void CF_object_info(int argc, char *argv[], void *refCon);
-int OBJECTMAP_Register() {
+int ObjectMap::reg() {
CVAR_RegisterFunc(CF_object_info, "object_info", NULL, R_CVAR_NONE, 0, 0, NULL);
return R_SUCCESS;
}
// Initializes the object map module, creates module allocation context
-int OBJECTMAP_Init() {
- debug(0, "OBJECTMAP Module: Initializing...");
-
- OMInfo.initialized = 1;
- return R_SUCCESS;
+ObjectMap::ObjectMap(Gfx *gfx) {
+ debug(0, "ObjectMap Module: Initializing...");
+ _gfx = gfx;
+ _initialized = 1;
}
// Shuts down the object map module, destroys module allocation context
-int OBJECTMAP_Shutdown() {
- if (!OMInfo.initialized) {
- return R_FAILURE;
- }
-
- debug(0, "OBJECTMAP Module: Shutting down...");
+ObjectMap::~ObjectMap() {
+ debug(0, "ObjectMap Module: Shutting down...");
- OBJECTMAP_Free();
- OBJECTMAP_FreeNames();
+ freeMem();
+ freeNames();
- debug(0, "OBJECTMAP Module: Shutdown AOK.");
+ debug(0, "ObjectMap Module: Shutdown AOK.");
- OMInfo.initialized = 0;
- return R_SUCCESS;
+ _initialized = 0;
}
// Loads an object map resource ( objects ( clickareas ( points ) ) )
-int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) {
+int ObjectMap::load(const byte *om_res, size_t om_res_len) {
R_OBJECTMAP_ENTRY *object_map;
R_CLICKAREA *clickarea;
R_POINT *point;
@@ -81,28 +73,28 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) {
MemoryReadStream readS(om_res, om_res_len);
- if (!OMInfo.initialized) {
+ if (!_initialized) {
warning("Error: Object map module not initialized");
return R_FAILURE;
}
- if (OMInfo.objects_loaded) {
- OBJECTMAP_Free();
+ if (_objects_loaded) {
+ freeMem();
}
// Obtain object count N and allocate space for N objects
- OMInfo.n_objects = readS.readUint16LE();
+ _n_objects = readS.readUint16LE();
- OMInfo.object_maps = (R_OBJECTMAP_ENTRY *)malloc(OMInfo.n_objects * sizeof *OMInfo.object_maps);
+ _object_maps = (R_OBJECTMAP_ENTRY *)malloc(_n_objects * sizeof *_object_maps);
- if (OMInfo.object_maps == NULL) {
+ if (_object_maps == NULL) {
warning("Error: Memory allocation failed");
return R_MEM;
}
// Load all N objects
- for (i = 0; i < OMInfo.n_objects; i++) {
- object_map = &OMInfo.object_maps[i];
+ for (i = 0; i < _n_objects; i++) {
+ object_map = &_object_maps[i];
object_map->unknown0 = readS.readByte();
object_map->n_clickareas = readS.readByte();
object_map->flags = readS.readUint16LE();
@@ -133,29 +125,29 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) {
point->x = readS.readSint16LE();
point->y = readS.readSint16LE();
}
- debug(2, "OBJECTMAP_Load(): Read %d points for clickarea %d in object %d.",
+ debug(2, "ObjectMap::load(): Read %d points for clickarea %d in object %d.",
clickarea->n_points, k, object_map->object_num);
}
}
- OMInfo.objects_loaded = 1;
+ _objects_loaded = 1;
return R_SUCCESS;
}
// Frees all storage allocated for the current object map data
-int OBJECTMAP_Free() {
+int ObjectMap::freeMem() {
R_OBJECTMAP_ENTRY *object_map;
R_CLICKAREA *clickarea;
int i, k;
- if (!OMInfo.objects_loaded) {
+ if (!_objects_loaded) {
return R_FAILURE;
}
- for (i = 0; i < OMInfo.n_objects; i++) {
- object_map = &OMInfo.object_maps[i];
+ for (i = 0; i < _n_objects; i++) {
+ object_map = &_object_maps[i];
for (k = 0; k < object_map->n_clickareas; k++) {
clickarea = &object_map->clickareas[k];
free(clickarea->points);
@@ -163,17 +155,17 @@ int OBJECTMAP_Free() {
free(object_map->clickareas);
}
- if (OMInfo.n_objects) {
- free(OMInfo.object_maps);
+ if (_n_objects) {
+ free(_object_maps);
}
- OMInfo.objects_loaded = 0;
+ _objects_loaded = 0;
return R_SUCCESS;
}
// Loads an object name list resource
-int OBJECTMAP_LoadNames(const unsigned char *onl_res, size_t onl_res_len) {
+int ObjectMap::loadNames(const unsigned char *onl_res, size_t onl_res_len) {
int table_len;
int n_names;
size_t name_offset;
@@ -182,46 +174,46 @@ int OBJECTMAP_LoadNames(const unsigned char *onl_res, size_t onl_res_len) {
MemoryReadStream readS(onl_res, onl_res_len);
- if (OMInfo.names_loaded) {
- OBJECTMAP_FreeNames();
+ if (_names_loaded) {
+ freeNames();
}
table_len = readS.readUint16LE();
n_names = table_len / 2 - 2;
- OMInfo.n_names = n_names;
+ _n_names = n_names;
- debug(2, "OBJECTMAP_LoadNames: Loading %d object names.", n_names);
- OMInfo.names = (const char **)malloc(n_names * sizeof *OMInfo.names);
+ debug(2, "ObjectMap::loadNames: Loading %d object names.", n_names);
+ _names = (const char **)malloc(n_names * sizeof *_names);
- if (OMInfo.names == NULL) {
+ if (_names == NULL) {
warning("Error: Memory allocation failed");
return R_MEM;
}
for (i = 0; i < n_names; i++) {
name_offset = readS.readUint16LE();
- OMInfo.names[i] = (const char *)(onl_res + name_offset);
+ _names[i] = (const char *)(onl_res + name_offset);
- debug(3, "Loaded object name string: %s", OMInfo.names[i]);
+ debug(3, "Loaded object name string: %s", _names[i]);
}
- OMInfo.names_loaded = 1;
+ _names_loaded = 1;
return R_SUCCESS;
}
// Frees all storage allocated for the current object name list data
-int OBJECTMAP_FreeNames() {
- if (!OMInfo.names_loaded) {
+int ObjectMap::freeNames() {
+ if (!_names_loaded) {
return R_FAILURE;
}
- if (OMInfo.n_names) {
- free(OMInfo.names);
+ if (_n_names) {
+ free(_names);
}
- OMInfo.names_loaded = 0;
+ _names_loaded = 0;
return R_SUCCESS;
}
@@ -229,34 +221,34 @@ 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 (!OMInfo.names_loaded) {
+int ObjectMap::getName(int object, const char **name) {
+ if (!_names_loaded) {
return R_FAILURE;
}
- if ((object <= 0) || (object > OMInfo.n_names)) {
+ if ((object <= 0) || (object > _n_names)) {
return R_FAILURE;
}
- *name = OMInfo.names[object - 1];
+ *name = _names[object - 1];
return R_SUCCESS;
}
-int OBJECTMAP_GetFlags(int object, uint16 *flags) {
+int ObjectMap::getFlags(int object, uint16 *flags) {
int i;
- if (!OMInfo.names_loaded) {
+ if (!_names_loaded) {
return R_FAILURE;
}
- if ((object <= 0) || (object > OMInfo.n_names)) {
+ if ((object <= 0) || (object > _n_names)) {
return R_FAILURE;
}
- for (i = 0; i < OMInfo.n_objects; i++) {
- if (OMInfo.object_maps[i].object_num == object) {
- *flags = OMInfo.object_maps[i].flags;
+ for (i = 0; i < _n_objects; i++) {
+ if (_object_maps[i].object_num == object) {
+ *flags = _object_maps[i].flags;
return R_SUCCESS;
}
}
@@ -268,22 +260,22 @@ int OBJECTMAP_GetFlags(int object, uint16 *flags) {
// 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) {
+int ObjectMap::getEPNum(int object, int *ep_num) {
int i;
- if (!OMInfo.names_loaded) {
+ if (!_names_loaded) {
return R_FAILURE;
}
- if ((object < 0) || (object > (OMInfo.n_objects + 1))) {
+ if ((object < 0) || (object > (_n_objects + 1))) {
return R_FAILURE;
}
- for (i = 0; i < OMInfo.n_objects; i++) {
+ for (i = 0; i < _n_objects; i++) {
- if (OMInfo.object_maps[i].object_num == object) {
+ if (_object_maps[i].object_num == object) {
- *ep_num = OMInfo.object_maps[i].script_num;
+ *ep_num = _object_maps[i].script_num;
return R_SUCCESS;
}
}
@@ -293,7 +285,7 @@ int OBJECTMAP_GetEPNum(int object, int *ep_num) {
// Uses Gfx::drawLine to display all clickareas for each object in the
// currently loaded object map resource.
-int OBJECTMAP_Draw(R_SURFACE *ds, R_POINT *imouse_pt, int color, int color2) {
+int ObjectMap::draw(R_SURFACE *ds, R_POINT *imouse_pt, int color, int color2) {
R_OBJECTMAP_ENTRY *object_map;
R_CLICKAREA *clickarea;
@@ -308,47 +300,47 @@ int OBJECTMAP_Draw(R_SURFACE *ds, R_POINT *imouse_pt, int color, int color2) {
int pointcount = 0;
int i, k;
- assert(OMInfo.initialized);
+ assert(_initialized);
- if (!OMInfo.objects_loaded) {
+ if (!_objects_loaded) {
return R_FAILURE;
}
if (imouse_pt != NULL) {
- if (OBJECTMAP_HitTest(imouse_pt, &object_num) == R_SUCCESS) {
+ if (hitTest(imouse_pt, &object_num) == R_SUCCESS) {
hit_object = 1;
}
}
- for (i = 0; i < OMInfo.n_objects; i++) {
+ for (i = 0; i < _n_objects; i++) {
draw_color = color;
- if (hit_object && (object_num == OMInfo.object_maps[i].object_num)) {
+ if (hit_object && (object_num == _object_maps[i].object_num)) {
snprintf(txt_buf, sizeof txt_buf, "obj %d: ? %d, f %X",
- OMInfo.object_maps[i].object_num,
- OMInfo.object_maps[i].unknown0,
- OMInfo.object_maps[i].flags);
+ _object_maps[i].object_num,
+ _object_maps[i].unknown0,
+ _object_maps[i].flags);
draw_txt = 1;
draw_color = color2;
}
- object_map = &OMInfo.object_maps[i];
+ object_map = &_object_maps[i];
for (k = 0; k < object_map->n_clickareas; k++) {
clickarea = &object_map->clickareas[k];
pointcount = 0;
if (clickarea->n_points == 2) {
// 2 points represent a box
- _vm->_gfx->drawFrame(ds, &clickarea->points[0], &clickarea->points[1], draw_color);
+ _gfx->drawFrame(ds, &clickarea->points[0], &clickarea->points[1], draw_color);
} else if (clickarea->n_points > 2) {
// Otherwise draw a polyline
- _vm->_gfx->drawPolyLine(ds, clickarea->points, clickarea->n_points, draw_color);
+ _gfx->drawPolyLine(ds, clickarea->points, clickarea->n_points, draw_color);
}
}
}
if (draw_txt) {
FONT_Draw(SMALL_FONT_ID, ds, txt_buf, 0, 2, 2,
- _vm->_gfx->getWhite(), _vm->_gfx->getBlack(), FONT_OUTLINE);
+ _gfx->getWhite(), _gfx->getBlack(), FONT_OUTLINE);
}
return R_SUCCESS;
@@ -379,7 +371,7 @@ static bool MATH_HitTestPoly(R_POINT *points, unsigned int npoints, R_POINT test
return inside_flag;
}
-int OBJECTMAP_HitTest(R_POINT * imouse_pt, int *object_num) {
+int ObjectMap::hitTest(R_POINT * imouse_pt, int *object_num) {
R_POINT imouse;
R_OBJECTMAP_ENTRY *object_map;
R_CLICKAREA *clickarea;
@@ -394,8 +386,8 @@ int OBJECTMAP_HitTest(R_POINT * imouse_pt, int *object_num) {
imouse.y = imouse_pt->y;
// Loop through all scene objects
- for (i = 0; i < OMInfo.n_objects; i++) {
- object_map = &OMInfo.object_maps[i];
+ for (i = 0; i < _n_objects; i++) {
+ object_map = &_object_maps[i];
// Hit-test all clickareas for this object
for (k = 0; k < object_map->n_clickareas; k++) {
@@ -426,28 +418,32 @@ int OBJECTMAP_HitTest(R_POINT * imouse_pt, int *object_num) {
return R_FAILURE;
}
-static void CF_object_info(int argc, char *argv[], void *refCon) {
+void ObjectMap::objectInfo(int argc, char *argv[]) {
int i;
(void)(argc);
(void)(argv);
- if (!OMInfo.initialized) {
+ if (!_initialized) {
return;
}
- CON_Print("%d objects loaded.", OMInfo.n_objects);
+ CON_Print("%d objects loaded.", _n_objects);
- for (i = 0; i < OMInfo.n_objects; i++) {
- CON_Print("%s:", OMInfo.names[i]);
- CON_Print("%d. Unk1: %d, flags: %X, name_i: %d, scr_n: %d, ca_ct: %d", i, OMInfo.object_maps[i].unknown0,
- OMInfo.object_maps[i].flags,
- OMInfo.object_maps[i].object_num,
- OMInfo.object_maps[i].script_num,
- OMInfo.object_maps[i].n_clickareas);
+ for (i = 0; i < _n_objects; i++) {
+ CON_Print("%s:", _names[i]);
+ CON_Print("%d. Unk1: %d, flags: %X, name_i: %d, scr_n: %d, ca_ct: %d", i, _object_maps[i].unknown0,
+ _object_maps[i].flags,
+ _object_maps[i].object_num,
+ _object_maps[i].script_num,
+ _object_maps[i].n_clickareas);
}
return;
}
+static void CF_object_info(int argc, char *argv[], void *refCon) {
+ ((ObjectMap *)refCon)->objectInfo(argc, argv);
+}
+
} // End of namespace Saga
diff --git a/saga/objectmap.h b/saga/objectmap.h
index b24af2c06a..3205809c28 100644
--- a/saga/objectmap.h
+++ b/saga/objectmap.h
@@ -28,6 +28,10 @@
namespace Saga {
+enum R_OBJECT_FLAGS {
+ R_OBJECT_NORMAL = 0x02
+};
+
struct R_CLICKAREA {
int n_points;
R_POINT *points;
@@ -44,19 +48,35 @@ struct R_OBJECTMAP_ENTRY {
R_CLICKAREA *clickareas;
};
-struct R_OBJECTMAP_INFO {
- int initialized;
+class Gfx;
- int objects_loaded;
- int n_objects;
- R_OBJECTMAP_ENTRY *object_maps;
+class ObjectMap{
+public:
+ int reg(void);
+ ObjectMap(Gfx *gfx);
+ ~ObjectMap(void);
+ int load(const byte *om_res, size_t om_res_len);
+ 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);
+ int draw(R_SURFACE *draw_surface, R_POINT *imouse_pt, int color, int color2);
+ int hitTest(R_POINT *imouse_pt, int *object_num);
+ void objectInfo(int argc, char *argv[]);
+private:
+ int _initialized;
- int names_loaded;
- int n_names;
- const char **names;
-};
+ int _objects_loaded;
+ int _n_objects;
+ R_OBJECTMAP_ENTRY *_object_maps;
-static void CF_object_info(int argc, char *argv[], void *refCon);
+ int _names_loaded;
+ int _n_names;
+ const char **_names;
+ Gfx *_gfx;
+};
} // End of namespace Saga
diff --git a/saga/objectmap_mod.h b/saga/objectmap_mod.h
deleted file mode 100644
index cb0d99e87c..0000000000
--- a/saga/objectmap_mod.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2004 The ScummVM project
- *
- * The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Header$
- *
- */
-
-// Object map module public header file
-
-#ifndef SAGA_OBJECTMAP_MOD_H__
-#define SAGA_OBJECTMAP_MOD_H__
-
-namespace Saga {
-
-enum R_OBJECT_FLAGS {
- R_OBJECT_NORMAL = 0x02
-};
-
-int OBJECTMAP_Register();
-int OBJECTMAP_Init();
-int OBJECTMAP_Shutdown();
-int OBJECTMAP_Load(const byte *om_res, size_t om_res_len);
-int OBJECTMAP_Free();
-int OBJECTMAP_LoadNames(const byte *onl_res, size_t onl_res_len);
-int OBJECTMAP_FreeNames();
-int OBJECTMAP_GetName(int object, const char **name);
-int OBJECTMAP_GetFlags(int object, uint16 *flags);
-int OBJECTMAP_GetEPNum(int object, int *ep_num);
-int OBJECTMAP_Draw(R_SURFACE *draw_surface, R_POINT *imouse_pt, int color, int color2);
-int OBJECTMAP_HitTest(R_POINT *imouse_pt, int *object_num);
-
-} // End of namespace Saga
-
-#endif
diff --git a/saga/render.cpp b/saga/render.cpp
index c4c3b6e21a..20f8781087 100644
--- a/saga/render.cpp
+++ b/saga/render.cpp
@@ -36,7 +36,7 @@
#include "text_mod.h"
#include "actionmap.h"
-#include "objectmap_mod.h"
+#include "objectmap.h"
#include "render.h"
#include <common/timer.h>
@@ -49,10 +49,11 @@ int Render::reg(void) {
return R_SUCCESS;
}
-Render::Render(SagaEngine *vm, OSystem *system, Gfx *gfx) {
+Render::Render(SagaEngine *vm, OSystem *system, Gfx *gfx, ObjectMap *omap) {
_vm = vm;
_system = system;
_gfx = gfx;
+ _omap = omap;
_initialized = false;
R_GAME_DISPLAYINFO disp_info;
@@ -136,7 +137,7 @@ int Render::drawScene() {
// Display scene maps, if applicable
if (getFlags() & RF_OBJECTMAP_TEST) {
- OBJECTMAP_Draw(backbuf_surface, &mouse_pt, _gfx->getWhite(), _gfx->getBlack());
+ _omap->draw(backbuf_surface, &mouse_pt, _gfx->getWhite(), _gfx->getBlack());
_vm->_actionMap->draw(backbuf_surface, _gfx->matchColor(R_RGB_RED));
}
diff --git a/saga/render.h b/saga/render.h
index 8bbfb4a4e3..cacf5d0840 100644
--- a/saga/render.h
+++ b/saga/render.h
@@ -52,7 +52,7 @@ struct R_BUFFER_INFO {
class Render {
public:
int reg(void);
- Render(SagaEngine *vm, OSystem *system, Gfx *gfx);
+ Render(SagaEngine *vm, OSystem *system, Gfx *gfx, ObjectMap *omap);
~Render(void);
bool initialized();
int drawScene(void);
@@ -71,6 +71,7 @@ private:
OSystem *_system;
bool _initialized;
Gfx *_gfx;
+ ObjectMap *_omap;
// Module data
R_SURFACE *_backbuf_surface;
diff --git a/saga/saga.cpp b/saga/saga.cpp
index 70795a3652..2d3e46e781 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -53,7 +53,7 @@
#include "sndres.h"
#include "sprite_mod.h"
#include "text_mod.h"
-#include "objectmap_mod.h"
+#include "objectmap.h"
#include "sound.h"
#include "music.h"
#include "game_mod.h"
@@ -117,7 +117,6 @@ void SagaEngine::go() {
CON_Register(); // Register console cvars first
GAME_Register();
- OBJECTMAP_Register();
ACTOR_Register();
SCENE_Register();
@@ -154,7 +153,6 @@ void SagaEngine::go() {
FONT_Init();
SPRITE_Init();
_anim = new Anim(this);
- OBJECTMAP_Init();
_script = new Script();
_sdata = new SData();
INTERFACE_Init(); // requires script module
@@ -190,14 +188,15 @@ void SagaEngine::go() {
GAME_GetDisplayInfo(&disp_info);
_gfx = new Gfx(_system, disp_info.logical_w, disp_info.logical_h);
- _render = new Render(this, _system, _gfx);
+ _isoMap = new IsoMap(_gfx);
+ _actionMap = new ActionMap(this);
+ _objectMap = new ObjectMap(_gfx);
+
+ _render = new Render(this, _system, _gfx, _objectMap);
if (!_render->initialized()) {
return;
}
- _isomap = new IsoMap(_gfx);
- _actionMap = new ActionMap(this);
-
// Initialize system specific sound
_sound = new Sound(this, _mixer, MainData.sound_enabled);
if (!MainData.sound_enabled) {
@@ -208,6 +207,7 @@ void SagaEngine::go() {
_render->reg();
_anim->reg();
_actionMap->reg();
+ _objectMap->reg();
_previousTicks = _system->get_msecs();
@@ -247,7 +247,6 @@ void SagaEngine::shutdown() {
ACTOR_Shutdown();
delete _script;
SPRITE_Shutdown();
- OBJECTMAP_Shutdown();
FONT_Shutdown();
CON_Shutdown();
CVAR_Shutdown();
@@ -255,6 +254,8 @@ void SagaEngine::shutdown() {
delete _render;
delete _actionMap;
+ delete _isoMap;
+ delete _objectMap;
delete _sndRes;
delete _sdata;
// Shutdown system modules */
diff --git a/saga/saga.h b/saga/saga.h
index a4e31b725d..5bb2115da4 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -44,6 +44,7 @@ class Anim;
class Render;
class ActionMap;
class IsoMap;
+class ObjectMap;
class Gfx;
class SData;
class Script;
@@ -95,7 +96,8 @@ public:
Anim *_anim;
Render *_render;
ActionMap *_actionMap;
- IsoMap *_isomap;
+ IsoMap *_isoMap;
+ ObjectMap *_objectMap;
Gfx *_gfx;
SData *_sdata;
Script *_script;
diff --git a/saga/scene.cpp b/saga/scene.cpp
index 8148a8f23f..ec67b2cedd 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -34,7 +34,7 @@
#include "actionmap.h"
#include "isomap.h"
#include "script_mod.h"
-#include "objectmap_mod.h"
+#include "objectmap.h"
#include "palanim_mod.h"
#include "render.h"
#include "rscfile_mod.h"
@@ -611,11 +611,11 @@ int ProcessSceneResources() {
break;
case SAGA_OBJECT_NAME_LIST:
debug(0, "Loading object name list resource...");
- OBJECTMAP_LoadNames(SceneModule.reslist[i].res_data, SceneModule.reslist[i].res_data_len);
+ _vm->_objectMap->loadNames(SceneModule.reslist[i].res_data, SceneModule.reslist[i].res_data_len);
break;
case SAGA_OBJECT_MAP:
debug(0, "Loading object map resource...");
- if (OBJECTMAP_Load(res_data,
+ if (_vm->_objectMap->load(res_data,
res_data_len) != R_SUCCESS) {
warning("Error loading object map resource");
return R_FAILURE;
@@ -636,7 +636,7 @@ int ProcessSceneResources() {
debug(0, "Loading isometric tileset resource.");
- if (_vm->_isomap->loadTileset(res_data, res_data_len) != R_SUCCESS) {
+ if (_vm->_isoMap->loadTileset(res_data, res_data_len) != R_SUCCESS) {
warning("ProcessSceneResources: Error loading isometric tileset resource");
return R_FAILURE;
}
@@ -651,7 +651,7 @@ int ProcessSceneResources() {
debug(0, "Loading isometric metamap resource.");
- if (_vm->_isomap->loadMetamap(res_data, res_data_len) != R_SUCCESS) {
+ if (_vm->_isoMap->loadMetamap(res_data, res_data_len) != R_SUCCESS) {
warning("ProcessSceneResources: Error loading isometric metamap resource");
return R_FAILURE;
}
@@ -666,7 +666,7 @@ int ProcessSceneResources() {
debug(0, "Loading isometric metatileset resource.");
- if (_vm->_isomap->loadMetaTileset(res_data, res_data_len) != R_SUCCESS) {
+ if (_vm->_isoMap->loadMetaTileset(res_data, res_data_len) != R_SUCCESS) {
warning("ProcessSceneResources: Error loading isometric tileset resource");
return R_FAILURE;
}
@@ -736,7 +736,7 @@ int SCENE_Draw(R_SURFACE *dst_s) {
MAX(disp_info.scene_h, SceneModule.bg.h), NULL, &bg_pt);
break;
case R_SCENE_MODE_ISO:
- _vm->_isomap->draw(dst_s);
+ _vm->_isoMap->draw(dst_s);
break;
default:
// Unknown scene mode
@@ -789,7 +789,7 @@ int SCENE_End() {
_vm->_anim->reset();
PALANIM_Free();
- OBJECTMAP_Free();
+ _vm->_objectMap->freeMem();
_vm->_actionMap->freeMap();
ys_dll_destroy(SceneModule.anim_list);