[Scummvm-cvs-logs] SF.net SVN: scummvm:[44234] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Sep 21 23:35:43 CEST 2009


Revision: 44234
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44234&view=rev
Author:   fingolfin
Date:     2009-09-21 21:35:43 +0000 (Mon, 21 Sep 2009)

Log Message:
-----------
SCI: Rename Object::flags and pos to _flags and _pos; tweak scriptObjInit0 and scriptObjInit11 to be more similar

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/engine/gc.cpp
    scummvm/trunk/engines/sci/engine/kscripts.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.cpp
    scummvm/trunk/engines/sci/engine/segment.cpp
    scummvm/trunk/engines/sci/engine/segment.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-09-21 20:50:13 UTC (rev 44233)
+++ scummvm/trunk/engines/sci/console.cpp	2009-09-21 21:35:43 UTC (rev 44234)
@@ -563,8 +563,8 @@
 
 	if (!_vm->_gamestate->_executionStack.empty()) {
 		EngineState *s = _vm->_gamestate;	// for PRINT_STK
-		DebugPrintf("pc=%04x:%04x obj=%04x:%04x fp=ST:%04x sp=ST:%04x\n", 
-					PRINT_REG(scriptState.xs->addr.pc), PRINT_REG(scriptState.xs->objp), 
+		DebugPrintf("pc=%04x:%04x obj=%04x:%04x fp=ST:%04x sp=ST:%04x\n",
+					PRINT_REG(scriptState.xs->addr.pc), PRINT_REG(scriptState.xs->objp),
 					PRINT_STK(scriptState.xs->fp), PRINT_STK(scriptState.xs->sp));
 	} else
 		DebugPrintf("<no execution stack: pc,obj,fp omitted>\n");
@@ -897,8 +897,8 @@
 	DebugPrintf("Available classes:\n");
 	for (uint i = 0; i < _vm->_gamestate->segMan->_classtable.size(); i++) {
 		if (_vm->_gamestate->segMan->_classtable[i].reg.segment) {
-			DebugPrintf(" Class 0x%x at %04x:%04x (script 0x%x)\n", i, 
-					PRINT_REG(_vm->_gamestate->segMan->_classtable[i].reg), 
+			DebugPrintf(" Class 0x%x at %04x:%04x (script 0x%x)\n", i,
+					PRINT_REG(_vm->_gamestate->segMan->_classtable[i].reg),
 					_vm->_gamestate->segMan->_classtable[i].script);
 		}
 	}
@@ -1053,7 +1053,7 @@
 	int col = CLIP<int>(atoi(argv[5]), 0, 15);
 
 	gfxop_set_clip_zone(_vm->_gamestate->gfx_state, gfx_rect_fullscreen);
-	gfxop_fill_box(_vm->_gamestate->gfx_state, gfx_rect(atoi(argv[1]), atoi(argv[2]), 
+	gfxop_fill_box(_vm->_gamestate->gfx_state, gfx_rect(atoi(argv[1]), atoi(argv[2]),
 										atoi(argv[3]), atoi(argv[4])), _vm->_gamestate->ega_colors[col]);
 	gfxop_update(_vm->_gamestate->gfx_state);
 
@@ -1303,7 +1303,7 @@
 	_vm->_gamestate->status_bar_foreground = atoi(argv[1]);
 	_vm->_gamestate->status_bar_background = atoi(argv[2]);
 
-	sciw_set_status_bar(_vm->_gamestate, _vm->_gamestate->titlebar_port, _vm->_gamestate->_statusBarText, 
+	sciw_set_status_bar(_vm->_gamestate, _vm->_gamestate->titlebar_port, _vm->_gamestate->_statusBarText,
 							_vm->_gamestate->status_bar_foreground, _vm->_gamestate->status_bar_background);
 	gfxop_update(_vm->_gamestate->gfx_state);
 
@@ -1401,10 +1401,10 @@
 		for (uint i = 0; i < scr->_objects.size(); i++) {
 			DebugPrintf("    ");
 			// Object header
-			Object *obj = _vm->_gamestate->segMan->getObject(scr->_objects[i].pos);
+			Object *obj = _vm->_gamestate->segMan->getObject(scr->_objects[i]._pos);
 			if (obj)
-				DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(scr->_objects[i].pos), 
-							_vm->_gamestate->segMan->getObjectName(scr->_objects[i].pos),
+				DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(scr->_objects[i]._pos),
+							_vm->_gamestate->segMan->getObjectName(scr->_objects[i]._pos),
 							obj->_variables.size(), obj->methods_nr);
 		}
 	}
@@ -1448,10 +1448,10 @@
 				objpos.segment = nr;
 				DebugPrintf("  [%04x] %s; copy of ", i, _vm->_gamestate->segMan->getObjectName(objpos));
 				// Object header
-				Object *obj = _vm->_gamestate->segMan->getObject(ct->_table[i].pos);
+				Object *obj = _vm->_gamestate->segMan->getObject(ct->_table[i]._pos);
 				if (obj)
-					DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(ct->_table[i].pos), 
-								_vm->_gamestate->segMan->getObjectName(ct->_table[i].pos), 
+					DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(ct->_table[i]._pos),
+								_vm->_gamestate->segMan->getObjectName(ct->_table[i]._pos),
 								obj->_variables.size(), obj->methods_nr);
 			}
 	}
@@ -2901,7 +2901,7 @@
 
 				if (mobj->getType() == SEG_TYPE_SCRIPT) {
 					obj = &(*(Script *)mobj)._objects[idx];
-					objpos.offset = obj->pos.offset;
+					objpos.offset = obj->_pos.offset;
 				} else if (mobj->getType() == SEG_TYPE_CLONES) {
 					obj = &((*(CloneTable *)mobj)._table[idx]);
 					objpos.offset = idx;

Modified: scummvm/trunk/engines/sci/engine/gc.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/gc.cpp	2009-09-21 20:50:13 UTC (rev 44233)
+++ scummvm/trunk/engines/sci/engine/gc.cpp	2009-09-21 21:35:43 UTC (rev 44234)
@@ -120,7 +120,7 @@
 
 				// All objects (may be classes, may be indirectly reachable)
 				for (uint obj_nr = 0; obj_nr < script->_objects.size(); obj_nr++) {
-					wm.push(script->_objects[obj_nr].pos);
+					wm.push(script->_objects[obj_nr]._pos);
 				}
 			}
 		}

Modified: scummvm/trunk/engines/sci/engine/kscripts.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kscripts.cpp	2009-09-21 20:50:13 UTC (rev 44233)
+++ scummvm/trunk/engines/sci/engine/kscripts.cpp	2009-09-21 21:35:43 UTC (rev 44234)
@@ -123,15 +123,15 @@
 	}
 
 	*clone_obj = *parent_obj;
-	clone_obj->flags = 0;
+	clone_obj->_flags = 0;
 
 	// Mark as clone
 	clone_obj->setInfoSelector(make_reg(0, SCRIPT_INFO_CLONE));
-	clone_obj->setSpeciesSelector(clone_obj->pos);
+	clone_obj->setSpeciesSelector(clone_obj->_pos);
 	if (parent_obj->isClass())
-		clone_obj->setSuperClassSelector(parent_obj->pos);
-	s->segMan->getScript(parent_obj->pos.segment)->incrementLockers();
-	s->segMan->getScript(clone_obj->pos.segment)->incrementLockers();
+		clone_obj->setSuperClassSelector(parent_obj->_pos);
+	s->segMan->getScript(parent_obj->_pos.segment)->incrementLockers();
+	s->segMan->getScript(clone_obj->_pos.segment)->incrementLockers();
 
 	return clone_addr;
 }
@@ -169,7 +169,7 @@
 	}
 #endif
 
-	victim_obj->flags |= OBJECT_FLAG_FREED;
+	victim_obj->_flags |= OBJECT_FLAG_FREED;
 
 	_k_view_list_mark_free(s, victim_addr); // Free on view list, if neccessary
 

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-09-21 20:50:13 UTC (rev 44233)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-09-21 21:35:43 UTC (rev 44234)
@@ -319,8 +319,8 @@
 
 template <>
 void syncWithSerializer(Common::Serializer &s, Object &obj) {
-	s.syncAsSint32LE(obj.flags);
-	sync_reg_t(s, obj.pos);
+	s.syncAsSint32LE(obj._flags);
+	sync_reg_t(s, obj._pos);
 	s.syncAsSint32LE(obj.variable_names_nr);
 	s.syncAsSint32LE(obj.methods_nr);
 
@@ -580,7 +580,7 @@
 				scr->_codeBlocks.clear();
 
 				for (j = 0; j < scr->_objects.size(); j++) {
-					byte *data = scr->_buf + scr->_objects[j].pos.offset;
+					byte *data = scr->_buf + scr->_objects[j]._pos.offset;
 					scr->_objects[j].base = scr->_buf;
 					scr->_objects[j].base_obj = data;
 				}
@@ -600,7 +600,7 @@
 				Script *scr = (Script *)mobj;
 
 				for (j = 0; j < scr->_objects.size(); j++) {
-					byte *data = scr->_buf + scr->_objects[j].pos.offset;
+					byte *data = scr->_buf + scr->_objects[j]._pos.offset;
 
 					if (s->resMan->sciVersion() >= SCI_VERSION_1_1) {
 						uint16 *funct_area = (uint16 *) (scr->_buf + READ_LE_UINT16( data + 6 ));

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-09-21 20:50:13 UTC (rev 44233)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-09-21 21:35:43 UTC (rev 44234)
@@ -189,7 +189,7 @@
 	Object *obj = getObject(pos);
 	if (obj == NULL)
 		return false;
-	if (obj->flags & OBJECT_FLAG_FREED)
+	if (obj->_flags & OBJECT_FLAG_FREED)
 		return false;
 	Script *scr = getScriptIfLoaded(pos.segment);
 	return !(scr && scr->_markedAsDeleted);
@@ -324,7 +324,7 @@
 }
 
 int Script::relocateObject(Object *obj, SegmentId segment, int location) {
-	return relocateBlock(obj->_variables, obj->pos.offset, segment, location);
+	return relocateBlock(obj->_variables, obj->_pos.offset, segment, location);
 }
 
 void Script::scriptAddCodeBlock(reg_t location) {
@@ -368,7 +368,7 @@
 				else
 					printf("- No locals\n");
 				for (k = 0; k < _objects.size(); k++)
-					printf("- obj#%d at %04x w/ %d vars\n", k, _objects[k].pos.offset, _objects[k]._variables.size());
+					printf("- obj#%d at %04x w/ %d vars\n", k, _objects[k]._pos.offset, _objects[k]._variables.size());
 				// SQ3 script 71 has broken relocation entries.
 				printf("Trying to continue anyway...\n");
 			}
@@ -405,7 +405,7 @@
 				else
 					printf("- No locals\n");
 				for (k = 0; k < _objects.size(); k++)
-					printf("- obj#%d at %04x w/ %d vars\n", k, _objects[k].pos.offset, _objects[k]._variables.size());
+					printf("- obj#%d at %04x w/ %d vars\n", k, _objects[k]._pos.offset, _objects[k]._variables.size());
 				error("Breakpoint in %s, line %d", __FILE__, __LINE__);
 			}
 		}
@@ -459,44 +459,44 @@
 
 Object *Script::scriptObjInit0(reg_t obj_pos) {
 	Object *obj;
-	uint base = obj_pos.offset - SCRIPT_OBJECT_MAGIC_OFFSET;
 
-	VERIFY(base < _bufSize, "Attempt to initialize object beyond end of script\n");
+	obj_pos.offset -= SCRIPT_OBJECT_MAGIC_OFFSET;
+	VERIFY(obj_pos.offset < _bufSize, "Attempt to initialize object beyond end of script\n");
 
-	obj = allocateObject(base);
+	obj = allocateObject(obj_pos.offset);
 
-	VERIFY(base + SCRIPT_FUNCTAREAPTR_OFFSET  < _bufSize, "Function area pointer stored beyond end of script\n");
+	VERIFY(obj_pos.offset + SCRIPT_FUNCTAREAPTR_OFFSET < (int)_bufSize, "Function area pointer stored beyond end of script\n");
 
 	{
-		byte *data = (byte *)(_buf + base);
-		int funct_area = READ_LE_UINT16(data + SCRIPT_FUNCTAREAPTR_OFFSET);
+		byte *data = (byte *)(_buf + obj_pos.offset);
+		uint16 *funct_area = (uint16 *)(data + READ_LE_UINT16(data + SCRIPT_FUNCTAREAPTR_OFFSET));
 		int variables_nr;
 		int functions_nr;
 		int is_class;
-		int i;
 
-		obj->flags = 0;
-		obj->pos = make_reg(obj_pos.segment, base);
+		obj->_flags = 0;
+		obj->_pos = obj_pos;
 
-		VERIFY(base + funct_area < _bufSize, "Function area pointer references beyond end of script");
+		VERIFY((byte *)funct_area < _buf + _bufSize, "Function area pointer references beyond end of script");
 
 		variables_nr = READ_LE_UINT16(data + SCRIPT_SELECTORCTR_OFFSET);
-		functions_nr = READ_LE_UINT16(data + funct_area - 2);
+		functions_nr = READ_LE_UINT16(funct_area - 1);
 		is_class = READ_LE_UINT16(data + SCRIPT_INFO_OFFSET) & SCRIPT_INFO_CLASS;
 
-		VERIFY(base + funct_area + functions_nr * 2
+		obj->base_method = funct_area;
+		obj->base_vars = NULL;
+
+		VERIFY((byte *)funct_area + functions_nr * 2
 		       // add again for classes, since those also store selectors
-		       + (is_class ? functions_nr * 2 : 0) < _bufSize, "Function area extends beyond end of script");
+		       + (is_class ? functions_nr * 2 : 0) < _buf + _bufSize, "Function area extends beyond end of script");
 
 		obj->_variables.resize(variables_nr);
 
 		obj->methods_nr = functions_nr;
 		obj->base = _buf;
 		obj->base_obj = data;
-		obj->base_method = (uint16 *)(data + funct_area);
-		obj->base_vars = NULL;
 
-		for (i = 0; i < variables_nr; i++)
+		for (int i = 0; i < variables_nr; i++)
 			obj->_variables[i] = make_reg(0, READ_LE_UINT16(data + (i * 2)));
 	}
 
@@ -505,27 +505,25 @@
 
 Object *Script::scriptObjInit11(reg_t obj_pos) {
 	Object *obj;
-	uint base = obj_pos.offset;
 
-	VERIFY(base < _bufSize, "Attempt to initialize object beyond end of script\n");
+	VERIFY(obj_pos.offset < _bufSize, "Attempt to initialize object beyond end of script\n");
 
-	obj = allocateObject(base);
+	obj = allocateObject(obj_pos.offset);
 
-	VERIFY(base + SCRIPT_FUNCTAREAPTR_OFFSET < _bufSize, "Function area pointer stored beyond end of script\n");
+	VERIFY(obj_pos.offset + SCRIPT_FUNCTAREAPTR_OFFSET < (int)_bufSize, "Function area pointer stored beyond end of script\n");
 
 	{
-		byte *data = (byte *)(_buf + base);
+		byte *data = (byte *)(_buf + obj_pos.offset);
 		uint16 *funct_area = (uint16 *)(_buf + READ_LE_UINT16(data + 6));
 		uint16 *prop_area = (uint16 *)(_buf + READ_LE_UINT16(data + 4));
 		int variables_nr;
 		int functions_nr;
 		int is_class;
-		int i;
 
-		obj->flags = 0;
-		obj->pos = obj_pos;
+		obj->_flags = 0;
+		obj->_pos = obj_pos;
 
-		VERIFY((byte *) funct_area < _buf + _bufSize, "Function area pointer references beyond end of script");
+		VERIFY((byte *)funct_area < _buf + _bufSize, "Function area pointer references beyond end of script");
 
 		variables_nr = READ_LE_UINT16(data + 2);
 		functions_nr = READ_LE_UINT16(funct_area);
@@ -534,7 +532,7 @@
 		obj->base_method = funct_area;
 		obj->base_vars = prop_area;
 
-		VERIFY(((byte *) funct_area + functions_nr) < _buf + _bufSize, "Function area extends beyond end of script");
+		VERIFY(((byte *)funct_area + functions_nr) < _buf + _bufSize, "Function area extends beyond end of script");
 
 		obj->variable_names_nr = variables_nr;
 		obj->_variables.resize(variables_nr);
@@ -543,7 +541,7 @@
 		obj->base = _buf;
 		obj->base_obj = data;
 
-		for (i = 0; i < variables_nr; i++)
+		for (int i = 0; i < variables_nr; i++)
 			obj->_variables[i] = make_reg(0, READ_LE_UINT16(data + (i * 2)));
 	}
 

Modified: scummvm/trunk/engines/sci/engine/segment.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.cpp	2009-09-21 20:50:13 UTC (rev 44233)
+++ scummvm/trunk/engines/sci/engine/segment.cpp	2009-09-21 21:35:43 UTC (rev 44234)
@@ -362,7 +362,7 @@
 		(*note)(param, clone->_variables[i]);
 
 	// Note that this also includes the 'base' object, which is part of the script and therefore also emits the locals.
-	(*note)(param, clone->pos);
+	(*note)(param, clone->_pos);
 	//debugC(2, kDebugLevelGC, "[GC] Reporting clone-pos %04x:%04x\n", PRINT_REG(clone->pos));
 }
 
@@ -374,7 +374,7 @@
 
 	victim_obj = &(_table[addr.offset]);
 
-	if (!(victim_obj->flags & OBJECT_FLAG_FREED))
+	if (!(victim_obj->_flags & OBJECT_FLAG_FREED))
 		warning("[GC] Clone %04x:%04x not reachable and not freed (freeing now)", PRINT_REG(addr));
 #ifdef GC_DEBUG_VERBOSE
 	else

Modified: scummvm/trunk/engines/sci/engine/segment.h
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.h	2009-09-21 20:50:13 UTC (rev 44233)
+++ scummvm/trunk/engines/sci/engine/segment.h	2009-09-21 21:35:43 UTC (rev 44234)
@@ -185,8 +185,8 @@
 
 // TODO: convert to class, perhaps?
 struct Object {
-	int flags;
-	reg_t pos; /**< Object offset within its script; for clones, this is their base */
+	int _flags;
+	reg_t _pos; /**< Object offset within its script; for clones, this is their base */
 	int variable_names_nr; /**< Number of variable names, may be less than variables_nr */
 	int methods_nr;
 	byte *base; /**< Points to a buffer all relative references (code, strings) point to */
@@ -249,7 +249,7 @@
 
 	reg_t getFunction(uint16 i) {
 		uint16 offset = (getSciVersion() < SCI_VERSION_1_1) ? methods_nr + 1 + i : i * 2 + 2;
-		return make_reg(pos.segment, READ_LE_UINT16((byte *) (base_method + offset)));
+		return make_reg(_pos.segment, READ_LE_UINT16((byte *) (base_method + offset)));
 	}
 
 	bool isClass() {


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