[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.442,2.443 resource.cpp,1.315,1.316 scumm.cpp,1.437,1.438 scumm.h,1.581,1.582

Max Horn fingolfin at users.sourceforge.net
Sun Apr 17 16:00:36 CEST 2005


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

Modified Files:
	intern.h resource.cpp scumm.cpp scumm.h 
Log Message:
Split out some index reading code into a new method readIndexBlock()

Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.442
retrieving revision 2.443
diff -u -d -r2.442 -r2.443
--- intern.h	14 Apr 2005 06:06:57 -0000	2.442
+++ intern.h	17 Apr 2005 22:59:43 -0000	2.443
@@ -679,10 +679,13 @@
 	Win32ResExtractor *_win32ResExtractor;
 	MacResExtractor *_macResExtractor;
 
+	byte *_heV7RoomOffsets;
+
 	int _heSndSoundFreq, _heSndOffset, _heSndChannel, _heSndSoundId, _heSndFlags, _heSBNGId;
 
 public:
 	ScummEngine_v70he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]);
+	~ScummEngine_v70he();
 
 	Wiz _wiz;
 
@@ -693,6 +696,7 @@
 	
 	virtual void readRoomsOffsets();
 	virtual void readGlobalObjects();
+	virtual void readIndexBlock(uint32 blocktype, uint32 itemsize);
 
 	virtual void redrawBGAreas();
 

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.315
retrieving revision 1.316
diff -u -d -r1.315 -r1.316
--- resource.cpp	16 Apr 2005 12:42:09 -0000	1.315
+++ resource.cpp	17 Apr 2005 22:59:43 -0000	1.316
@@ -280,8 +280,6 @@
 void ScummEngine::readIndexFile() {
 	uint32 blocktype, itemsize;
 	int numblock = 0;
-	int i;
-	bool stop = false;
 
 	debugC(DEBUG_GENERAL, "readIndexFile()");
 
@@ -326,141 +324,152 @@
 		_fileHandle->seek(0, SEEK_SET);
 	}
 
-	while (!stop) {
+	while (true) {
 		blocktype = fileReadDword();
+		itemsize = _fileHandle->readUint32BE();
 
 		if (_fileHandle->ioFailed())
 			break;
-		itemsize = _fileHandle->readUint32BE();
 
 		numblock++;
+		readIndexBlock(blocktype, itemsize);
+	}
 
-		switch (blocktype) {
-		case MKID('DCHR'):
-		case MKID('DIRF'):
-			readResTypeList(rtCharset, MKID('CHAR'), "charset");
-			break;
-		
-		case MKID('DOBJ'):
-			debug(9, "found DOBJ block, reading object table");
-			readGlobalObjects();
-			break;
+//  if (numblock!=9)
+//    error("Not enough blocks read from directory");
 
-		case MKID('RNAM'):
-			// Names of rooms. Maybe we should put them into a table, for use by the debugger?
-			if (_heversion >= 80) {
-				for (int room; (room = _fileHandle->readUint16LE()); ) {
-					char buf[20];
-					i = 0;
-					for (byte s; (s = _fileHandle->readByte()); ) {
-						buf[i++] = s;
-					}
-					buf[i] = 0;
-					debug(5, "Room %d: '%s'", room, buf);
-				}
-			} else {
-				for (int room; (room = _fileHandle->readByte()); ) {
-					char buf[10];
-					_fileHandle->read(buf, 9);
-					buf[9] = 0;
-					for (i = 0; i < 9; i++)
-						buf[i] ^= 0xFF;
-					debug(5, "Room %d: '%s'", room, buf);
-				}
-			}
-			break;
-		
-		case MKID('DLFL'):
-			i = _fileHandle->readUint16LE();
-			_fileHandle->seek(-2, SEEK_CUR);
-			_heV7RoomOffsets = (byte *)calloc(2 + (i * 4), 1);
-			_fileHandle->read(_heV7RoomOffsets, (2 + (i * 4)) );
-			break;
+	closeRoom();
+}
 
-		case MKID('DIRM'):
-			readResTypeList(rtImage, MKID('AWIZ'), "images");
-			break;
-			
-		case MKID('DIRT'):
-			readResTypeList(rtTalkie, MKID('TLKE'), "talkie");
-			break;
+void ScummEngine_v70he::readIndexBlock(uint32 blocktype, uint32 itemsize) {
+	int i;
+	switch (blocktype) {
+	case MKID('DLFL'):
+		i = _fileHandle->readUint16LE();
+		_fileHandle->seek(-2, SEEK_CUR);
+		_heV7RoomOffsets = (byte *)calloc(2 + (i * 4), 1);
+		_fileHandle->read(_heV7RoomOffsets, (2 + (i * 4)) );
+		break;
 
-		case MKID('SVER'):
-			_fileHandle->seek(itemsize - 8, SEEK_CUR);
-			warning("SVER index block not yet handled, skipping");
-			break;
+	case MKID('DISK'):
+		i = _fileHandle->readUint16LE();
+		_heV7DiskOffsets = (byte *)calloc(i, 1);
+		_fileHandle->read(_heV7DiskOffsets, i);
+		break;
 
-		case MKID('DISK'):
-			i = _fileHandle->readUint16LE();
-			_heV7DiskOffsets = (byte *)calloc(i, 1);
-			_fileHandle->read(_heV7DiskOffsets, i);
-			break;
+	default:
+		ScummEngine::readIndexBlock(blocktype, itemsize);
+	}
+}
 
-		case MKID('INIB'):
-			_fileHandle->seek(itemsize - 8, SEEK_CUR);
-			debug(2, "INIB index block not yet handled, skipping");
-			break;
+void ScummEngine::readIndexBlock(uint32 blocktype, uint32 itemsize) {
+	int i;
+	switch (blocktype) {
+	case MKID('DCHR'):
+	case MKID('DIRF'):
+		readResTypeList(rtCharset, MKID('CHAR'), "charset");
+		break;
+	
+	case MKID('DOBJ'):
+		debug(9, "found DOBJ block, reading object table");
+		readGlobalObjects();
+		break;
 
-		case MKID('DIRI'):
-			readResTypeList(rtRoomImage, MKID('RMIM'), "room image");
-			break;
+	case MKID('RNAM'):
+		// Names of rooms. Maybe we should put them into a table, for use by the debugger?
+		if (_heversion >= 80) {
+			for (int room; (room = _fileHandle->readUint16LE()); ) {
+				char buf[20];
+				i = 0;
+				for (byte s; (s = _fileHandle->readByte()); ) {
+					buf[i++] = s;
+				}
+				buf[i] = 0;
+				debug(5, "Room %d: '%s'", room, buf);
+			}
+		} else {
+			for (int room; (room = _fileHandle->readByte()); ) {
+				char buf[10];
+				_fileHandle->read(buf, 9);
+				buf[9] = 0;
+				for (i = 0; i < 9; i++)
+					buf[i] ^= 0xFF;
+				debug(5, "Room %d: '%s'", room, buf);
+			}
+		}
+		break;
+	
+	case MKID('DIRM'):
+		readResTypeList(rtImage, MKID('AWIZ'), "images");
+		break;
+		
+	case MKID('DIRT'):
+		readResTypeList(rtTalkie, MKID('TLKE'), "talkie");
+		break;
 
-		case MKID('ANAM'):		// Used by: The Dig, FT
-			debug(9, "found ANAM block, reading audio names");
-			_numAudioNames = _fileHandle->readUint16LE();
-			_audioNames = (char*)malloc(_numAudioNames * 9);
-			_fileHandle->read(_audioNames, _numAudioNames * 9);
-			break;
+	case MKID('SVER'):
+		_fileHandle->seek(itemsize - 8, SEEK_CUR);
+		warning("SVER index block not yet handled, skipping");
+		break;
 
-		case MKID('DIRR'):
-		case MKID('DROO'):
-			readResTypeList(rtRoom, MKID('ROOM'), "room");
-			break;
+	case MKID('INIB'):
+		_fileHandle->seek(itemsize - 8, SEEK_CUR);
+		debug(2, "INIB index block not yet handled, skipping");
+		break;
 
-		case MKID('DRSC'):
-			readResTypeList(rtRoomScripts, MKID('RMSC'), "room script");
-			break;
+	case MKID('DIRI'):
+		readResTypeList(rtRoomImage, MKID('RMIM'), "room image");
+		break;
 
-		case MKID('DSCR'):
-		case MKID('DIRS'):
-			readResTypeList(rtScript, MKID('SCRP'), "script");
-			break;
+	case MKID('ANAM'):		// Used by: The Dig, FT
+		debug(9, "found ANAM block, reading audio names");
+		_numAudioNames = _fileHandle->readUint16LE();
+		_audioNames = (char*)malloc(_numAudioNames * 9);
+		_fileHandle->read(_audioNames, _numAudioNames * 9);
+		break;
 
-		case MKID('DCOS'):
-		case MKID('DIRC'):
-			readResTypeList(rtCostume, MKID('COST'), "costume");
-			break;
+	case MKID('DIRR'):
+	case MKID('DROO'):
+		readResTypeList(rtRoom, MKID('ROOM'), "room");
+		break;
 
-		case MKID('MAXS'):
-			readMAXS(itemsize);
-			allocateArrays();
-			break;
+	case MKID('DRSC'):
+		readResTypeList(rtRoomScripts, MKID('RMSC'), "room script");
+		break;
 
-		case MKID('DIRN'):
-		case MKID('DSOU'):
-			readResTypeList(rtSound, MKID('SOUN'), "sound");
-			break;
+	case MKID('DSCR'):
+	case MKID('DIRS'):
+		readResTypeList(rtScript, MKID('SCRP'), "script");
+		break;
 
-		case MKID('AARY'):
-			readArrayFromIndexFile();
-			break;
+	case MKID('DCOS'):
+	case MKID('DIRC'):
+		readResTypeList(rtCostume, MKID('COST'), "costume");
+		break;
 
-		case MKID('LECF'):
-			_fileHandle->seek(itemsize - 8, SEEK_CUR);
-			debug(2, "LECF index block not yet handled, skipping");
-			break;
+	case MKID('MAXS'):
+		readMAXS(itemsize);
+		allocateArrays();
+		break;
 
-		default:
-			error("Bad ID %04X('%s') found in index file directory!", blocktype,
-					tag2str(blocktype));
-			return;
-		}
-	}
+	case MKID('DIRN'):
+	case MKID('DSOU'):
+		readResTypeList(rtSound, MKID('SOUN'), "sound");
+		break;
 
-//  if (numblock!=9)
-//    error("Not enough blocks read from directory");
+	case MKID('AARY'):
+		readArrayFromIndexFile();
+		break;
 
-	closeRoom();
+	case MKID('LECF'):
+		_fileHandle->seek(itemsize - 8, SEEK_CUR);
+		debug(2, "LECF index block not yet handled, skipping");
+		break;
+
+	default:
+		error("Bad ID %04X('%s') found in index file directory!", blocktype,
+				tag2str(blocktype));
+	}
 }
 
 void ScummEngine::readArrayFromIndexFile() {

Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.437
retrieving revision 1.438
diff -u -d -r1.437 -r1.438
--- scumm.cpp	17 Apr 2005 22:40:44 -0000	1.437
+++ scumm.cpp	17 Apr 2005 22:59:43 -0000	1.438
@@ -768,7 +768,7 @@
 	_dumpScripts = false;
 	_debugMode = 0;
 	_heV7DiskOffsets = NULL;
-	_heV7RoomOffsets = NULL;
+	_heV7RoomIntOffsets = NULL;
 	_objectOwnerTable = NULL;
 	_objectRoomTable = NULL;
 	_objectStateTable = NULL;
@@ -1194,10 +1194,6 @@
 	free(_palManipIntermediatePal);
 	
 	res.freeResources();
-	if (_heversion >= 70) {
-		free(_heV7RoomIntOffsets);
-		free(_heV7RoomOffsets);
-	}
 
 	free(_objectStateTable);
 	free(_objectRoomTable);
@@ -1259,6 +1255,8 @@
 	 _win32ResExtractor = new Win32ResExtractor(this);
 	 _macResExtractor = new MacResExtractor(this);
 
+	_heV7RoomOffsets = NULL;
+
 	_heSndSoundId = 0;
 	_heSndOffset = 0;
 	_heSndChannel = 0;
@@ -1267,6 +1265,12 @@
 	_heSBNGId = 0;
 }
 
+ScummEngine_v70he::~ScummEngine_v70he() {
+	free(_heV7DiskOffsets);
+	free(_heV7RoomIntOffsets);
+	free(_heV7RoomOffsets);
+}
+
 #pragma mark -
 #pragma mark --- Initialization ---
 #pragma mark -

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.581
retrieving revision 1.582
diff -u -d -r1.581 -r1.582
--- scumm.h	17 Apr 2005 22:40:44 -0000	1.581
+++ scumm.h	17 Apr 2005 22:59:43 -0000	1.582
@@ -682,7 +682,6 @@
 	Common::String _targetName;	// This is the game the user calls it, so use for saving
 	byte _resourceMapper[128];
 	byte *_heV7DiskOffsets;
-	byte *_heV7RoomOffsets;
 	uint32 *_heV7RoomIntOffsets;
 	const byte *_resourceLastSearchBuf; // FIXME: need to put it to savefile?
 	uint32 _resourceLastSearchSize;    // FIXME: need to put it to savefile?
@@ -725,6 +724,7 @@
 	virtual void readMAXS(int blockSize) = 0;
 	virtual void readGlobalObjects();
 	virtual void readIndexFile();
+	virtual void readIndexBlock(uint32 block, uint32 itemsize);
 	virtual void loadCharset(int i);
 	void nukeCharset(int i);
 





More information about the Scummvm-git-logs mailing list