[Scummvm-cvs-logs] CVS: scummvm/saga interface.cpp,1.23,1.24 objectmap.cpp,1.19,1.20 objectmap.h,1.7,1.8 scene.cpp,1.39,1.40 scene.h,1.10,1.11 xref.txt,1.5,1.6

Eugene Sandulenko sev at users.sourceforge.net
Mon Oct 4 19:25:14 CEST 2004


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9344

Modified Files:
	interface.cpp objectmap.cpp objectmap.h scene.cpp scene.h 
	xref.txt 
Log Message:
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.


Index: interface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- interface.cpp	4 Oct 2004 23:09:38 -0000	1.23
+++ interface.cpp	5 Oct 2004 02:16:26 -0000	1.24
@@ -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 @@
 		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 @@
 		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

Index: objectmap.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/objectmap.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- objectmap.cpp	4 Oct 2004 23:09:38 -0000	1.19
+++ objectmap.cpp	5 Oct 2004 02:16:26 -0000	1.20
@@ -39,7 +39,7 @@
 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 @@
 	freeMem();
 	freeNames();
 
-	debug(0, "ObjectMap Module: Shutdown AOK.");
+	debug(0, "ObjectMap Module: Shutdown OK.");
 
 	_initialized = 0;
 }
@@ -97,9 +97,10 @@
 	// 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 @@
 // 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;
-	}
-
-	if ((object < 0) || (object > (_n_objects + 1))) {
-		return R_FAILURE;
-	}
-
-	for (i = 0; i < _n_objects; i++) {
+	assert(_names_loaded);
 
-		if (_object_maps[i].object_num == object) {
+	if ((object < 0) || (object > (_n_objects + 1)))
+		return -1;
 
-			*ep_num = _object_maps[i].script_num;
-			return R_SUCCESS;
-		}
-	}
+	for (i = 0; i < _n_objects; i++)
+		if (_object_maps[i].object_num == object)
+			return _object_maps[i].script_num;
 
-	return R_FAILURE;
+	return -1;
 }
 
 // Uses Gfx::drawLine to display all clickareas for each object in the 
@@ -317,9 +297,9 @@
 	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 @@
 
 	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,

Index: objectmap.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/objectmap.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- objectmap.h	4 Oct 2004 23:09:38 -0000	1.7
+++ objectmap.h	5 Oct 2004 02:16:26 -0000	1.8
@@ -29,6 +29,7 @@
 namespace Saga {
 
 enum R_OBJECT_FLAGS {
+	R_OBJECT_EXIT = 0x01,
 	R_OBJECT_NORMAL = 0x02
 };
 
@@ -38,8 +39,8 @@
 };
 
 struct R_OBJECTMAP_ENTRY {
-	int unknown0;
-	uint16 flags;
+	byte flags;
+	byte defaultVerb;
 
 	int object_num;
 	int script_num;
@@ -59,9 +60,9 @@
 	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[]);

Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- scene.cpp	4 Oct 2004 23:09:38 -0000	1.39
+++ scene.cpp	5 Oct 2004 02:16:26 -0000	1.40
@@ -763,6 +763,12 @@
 			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 @@
 			_vm->_events->queue(&event);
 		} else
 			_vm->_music->stop();
-
+		//break; //HACK to disable faery script
 		if (_desc.sceneScriptNum > 0) {
 			R_SCRIPT_THREAD *_sceneScriptThread;
 

Index: scene.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- scene.h	11 Aug 2004 23:42:02 -0000	1.10
+++ scene.h	5 Oct 2004 02:16:26 -0000	1.11
@@ -82,6 +82,7 @@
 	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 @@
 	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

Index: xref.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/xref.txt,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- xref.txt	22 Aug 2004 18:28:42 -0000	1.5
+++ xref.txt	5 Oct 2004 02:16:26 -0000	1.6
@@ -18,7 +18,7 @@
  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 @@
 
  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()





More information about the Scummvm-git-logs mailing list