[Scummvm-cvs-logs] CVS: scummvm/scumm scumm.h,1.647,1.648 object.cpp,1.253,1.254 saveload.cpp,1.239,1.240 intern.h,2.529,2.530 resource.cpp,1.339,1.340 resource.h,1.17,1.18 string.cpp,1.304,1.305

Max Horn fingolfin at users.sourceforge.net
Mon Oct 17 08:02:06 CEST 2005


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

Modified Files:
	scumm.h object.cpp saveload.cpp intern.h resource.cpp 
	resource.h string.cpp 
Log Message:
Added ResourceManager::isLocked; made ResourceManager::flags protected; moved some stuff around

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.647
retrieving revision 1.648
diff -u -d -r1.647 -r1.648
--- scumm.h	15 Oct 2005 11:03:32 -0000	1.647
+++ scumm.h	17 Oct 2005 15:00:22 -0000	1.648
@@ -160,6 +160,13 @@
 	DEBUG_SMUSH	=	1 << 10		// Track SMUSH
 };
 
+/**
+ * Internal header for any memory block allocated by the resource manager.
+ *
+ * @todo Hide MemBlkHeader; no code outside the resource manager should
+ * have to use it, ever. Currently script code needs it to detect whether
+ * some scripts have moved (in fetchScriptByte()).
+ */
 struct MemBlkHeader {
 	uint32 size;
 };
@@ -167,38 +174,6 @@
 struct VerbSlot;
 struct ObjectData;
 
-struct V2MouseoverBox {
-	Common::Rect rect;
-	byte color;
-	byte hicolor;
-};
-
-enum ResTypes {
-	rtFirst = 1,
-	rtRoom = 1,
-	rtScript = 2,
-	rtCostume = 3,
-	rtSound = 4,
-	rtInventory = 5,
-	rtCharset = 6,
-	rtString = 7,
-	rtVerb = 8,
-	rtActorName = 9,
-	rtBuffer = 10,
-	rtScaleTable = 11,
-	rtTemp = 12,
-	rtFlObject = 13,
-	rtMatrix = 14,
-	rtBox = 15,
-	rtObjectName = 16,
-	rtRoomScripts = 17,
-	rtRoomImage = 18,
-	rtImage = 19,
-	rtTalkie = 20,
-	rtLast = 20,
-	rtNumTypes = 21
-};
-
 enum {
 	LIGHTMODE_dark			= 0,
 	LIGHTMODE_actor_base	= 1,
@@ -291,11 +266,6 @@
 	WIO_FLOBJECT = 4
 };
 
-struct LangIndexNode {
-	char tag[12+1];
-	int32 offset;
-};
-
 struct AuxBlock {
 	bool visible;
 	Common::Rect r;
@@ -312,12 +282,39 @@
 	int subIndex;
 };
 
+// TODO: Rename InfoStuff to something more descriptive
 struct InfoStuff {
 	uint32 date;
 	uint16 time;
 	uint32 playtime;
 };
 
+enum ResTypes {
+	rtFirst = 1,
+	rtRoom = 1,
+	rtScript = 2,
+	rtCostume = 3,
+	rtSound = 4,
+	rtInventory = 5,
+	rtCharset = 6,
+	rtString = 7,
+	rtVerb = 8,
+	rtActorName = 9,
+	rtBuffer = 10,
+	rtScaleTable = 11,
+	rtTemp = 12,
+	rtFlObject = 13,
+	rtMatrix = 14,
+	rtBox = 15,
+	rtObjectName = 16,
+	rtRoomScripts = 17,
+	rtRoomImage = 18,
+	rtImage = 19,
+	rtTalkie = 20,
+	rtLast = 20,
+	rtNumTypes = 21
+};
+
 class ResourceManager {
 	friend class ScummDebugger;
 	friend class ScummEngine;
@@ -330,7 +327,9 @@
 	uint32 tags[rtNumTypes];
 	const char *name[rtNumTypes];
 	byte **address[rtNumTypes];
+protected:
 	byte *flags[rtNumTypes];
+public:
 	byte *roomno[rtNumTypes];
 	uint32 *roomoffs[rtNumTypes];
 	uint32 *globsize[rtNumTypes];
@@ -347,17 +346,20 @@
 
 	void freeResources();
 
-	bool validateResource(const char *str, int type, int index) const;
 	bool isResourceLoaded(int type, int index) const;
 
 	void lock(int type, int i);
 	void unlock(int type, int i);
+	bool isLocked(int type, int i) const;
 
 	void setResourceCounter(int type, int index, byte flag);
 	void increaseResourceCounter();
 
 	void resourceStats();
 	void expireResources(uint32 size);
+
+protected:
+	bool validateResource(const char *str, int type, int index) const;
 };
 
 class ScummEngine : public Engine {

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.253
retrieving revision 1.254
diff -u -d -r1.253 -r1.254
--- object.cpp	14 Oct 2005 08:39:27 -0000	1.253
+++ object.cpp	17 Oct 2005 15:00:23 -0000	1.254
@@ -518,7 +518,7 @@
 				_objs[i].obj_nr = 0;
 			} else {
 				// Nuke all unlocked flObjects
-				if (!(res.flags[rtFlObject][_objs[i].fl_object_index] & RF_LOCK)) {
+				if (!res.isLocked(rtFlObject, _objs[i].fl_object_index)) {
 					res.nukeResource(rtFlObject, _objs[i].fl_object_index);
 					_objs[i].obj_nr = 0;
 					_objs[i].fl_object_index = 0;
@@ -1739,8 +1739,8 @@
 
 	// Lock room/roomScripts for the given room. They contains the OBCD/OBIM
 	// data, and a call to createResource might expire them, hence we lock them.
-	isRoomLocked = ((res.flags[rtRoom][room] & RF_LOCK) != 0);
-	isRoomScriptsLocked = ((res.flags[rtRoomScripts][room] & RF_LOCK) != 0);
+	isRoomLocked = res.isLocked(rtRoom, room);
+	isRoomScriptsLocked = res.isLocked(rtRoomScripts, room);
 	if (!isRoomLocked)
 		res.lock(rtRoom, room);
 	if (_version == 8 && !isRoomScriptsLocked)

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.239
retrieving revision 1.240
diff -u -d -r1.239 -r1.240
--- saveload.cpp	14 Oct 2005 19:51:56 -0000	1.239
+++ saveload.cpp	17 Oct 2005 15:00:23 -0000	1.240
@@ -238,7 +238,6 @@
 		if (i != rtTemp && i != rtBuffer && (i != rtSound || _saveSound || !compat))
 			for (j = 0; j < res.num[i]; j++) {
 				res.nukeResource(i, j);
-				res.flags[i][j] = 0;
 			}
 
 	initScummVars();
@@ -1135,7 +1134,7 @@
 	if (s->isSaving()) {
 		for (i = rtFirst; i <= rtLast; i++)
 			for (j = 1; j < res.num[i]; j++) {
-				if (res.flags[i][j] & RF_LOCK) {
+				if (res.isLocked(i, j)) {
 					s->saveByte(i);
 					s->saveUint16(j);
 				}
@@ -1144,7 +1143,7 @@
 	} else {
 		while ((i = s->loadByte()) != 0xFF) {
 			j = s->loadUint16();
-			res.flags[i][j] |= RF_LOCK;
+			res.lock(i, j);
 		}
 	}
 

Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.529
retrieving revision 2.530
diff -u -d -r2.529 -r2.530
--- intern.h	2 Oct 2005 13:21:49 -0000	2.529
+++ intern.h	17 Oct 2005 15:00:23 -0000	2.530
@@ -254,6 +254,12 @@
 
 	const OpcodeEntryV2 *_opcodesV2;
 
+	struct V2MouseoverBox {
+		Common::Rect rect;
+		byte color;
+		byte hicolor;
+	};
+
 	V2MouseoverBox _mouseOverBoxesV2[7];
 	int8 _mouseOverBoxV2;
 
@@ -1319,6 +1325,11 @@
 	ScummEngine_v7(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16], int substResFileNameIndex);
 	~ScummEngine_v7();
 
+	struct LangIndexNode {
+		char tag[12+1];
+		int32 offset;
+	};
+	
 	bool _existLanguageFile;
 	char *_languageBuffer;
 	LangIndexNode *_languageIndex;

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.339
retrieving revision 1.340
diff -u -d -r1.339 -r1.340
--- resource.cpp	15 Oct 2005 00:47:23 -0000	1.339
+++ resource.cpp	17 Oct 2005 15:00:23 -0000	1.340
@@ -37,6 +37,14 @@
 
 namespace Scumm {
 
+enum {
+	RF_LOCK = 0x80,
+	RF_USAGE = 0x7F,
+	RF_USAGE_MAX = RF_USAGE
+};
+
+
+
 extern const char *resTypeFromId(int id);
 
 static uint16 newTag2Old(uint32 newTag);
@@ -877,7 +885,8 @@
 
 	assert(idx >= 0 && idx < num[type]);
 
-	if ((ptr = address[type][idx]) != NULL) {
+	ptr = address[type][idx];
+	if (ptr != NULL) {
 		debugC(DEBUG_RESOURCE, "nukeResource(%s,%d)", resTypeFromId(type), idx);
 		address[type][idx] = 0;
 		flags[type][idx] = 0;
@@ -923,6 +932,12 @@
 	flags[type][i] &= ~RF_LOCK;
 }
 
+bool ResourceManager::isLocked(int type, int i) const {
+	if (!validateResource("Unlocking", type, i))
+		return false;
+	return (flags[type][i] & RF_LOCK) != 0;
+}
+
 bool ScummEngine::isResourceInUse(int type, int i) const {
 	if (!res.validateResource("isResourceInUse", type, i))
 		return false;

Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- resource.h	30 Jul 2005 21:11:27 -0000	1.17
+++ resource.h	17 Oct 2005 15:00:23 -0000	1.18
@@ -30,13 +30,6 @@
 	OF_STATE_SHL = 4
 };
 
-enum {
-	RF_LOCK = 0x80,
-	RF_USAGE = 0x7F,
-	RF_USAGE_MAX = RF_USAGE
-};
-
-
 class ResourceIterator {
 	uint32 _size;
 	uint32 _pos;

Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.304
retrieving revision 1.305
diff -u -d -r1.304 -r1.305
--- string.cpp	15 Oct 2005 11:03:32 -0000	1.304
+++ string.cpp	17 Oct 2005 15:00:23 -0000	1.305
@@ -860,8 +860,8 @@
 
 #ifndef DISABLE_SCUMM_7_8
 int indexCompare(const void *p1, const void *p2) {
-	const LangIndexNode *i1 = (const LangIndexNode *) p1;
-	const LangIndexNode *i2 = (const LangIndexNode *) p2;
+	const ScummEngine_v7::LangIndexNode *i1 = (const ScummEngine_v7::LangIndexNode *) p1;
+	const ScummEngine_v7::LangIndexNode *i2 = (const ScummEngine_v7::LangIndexNode *) p2;
 
 	return strcmp(i1->tag, i2->tag);
 }





More information about the Scummvm-git-logs mailing list