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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Jun 15 14:18:57 CEST 2010


Revision: 49833
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49833&view=rev
Author:   fingolfin
Date:     2010-06-15 12:18:57 +0000 (Tue, 15 Jun 2010)

Log Message:
-----------
SCI: Move several methods from ResourceManager to Resource

Modified Paths:
--------------
    scummvm/trunk/engines/sci/resource.cpp
    scummvm/trunk/engines/sci/resource.h
    scummvm/trunk/engines/sci/resource_audio.cpp

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2010-06-15 12:18:31 UTC (rev 49832)
+++ scummvm/trunk/engines/sci/resource.cpp	2010-06-15 12:18:57 UTC (rev 49833)
@@ -234,7 +234,9 @@
 
 // Resource manager constructors and operations
 
-bool ResourceManager::loadPatch(Resource *res, Common::SeekableReadStream *file) {
+bool Resource::loadPatch(Common::SeekableReadStream *file) {
+	Resource *res = this;
+
 	// We assume that the resource type matches res->type
 	//  We also assume that the current file position is right at the actual data (behind resourceid/headersize byte)
 
@@ -262,17 +264,17 @@
 	return true;
 }
 
-bool ResourceManager::loadFromPatchFile(Resource *res) {
+bool Resource::loadFromPatchFile() {
 	Common::File file;
-	const Common::String &filename = res->_source->getLocationName();
+	const Common::String &filename = _source->getLocationName();
 	if (file.open(filename) == false) {
 		warning("Failed to open patch file %s", filename.c_str());
-		res->unalloc();
+		unalloc();
 		return false;
 	}
 	// Skip resourceid and header size byte
 	file.seek(2, SEEK_SET);
-	return loadPatch(res, &file);
+	return loadPatch(&file);
 }
 
 Common::SeekableReadStream *ResourceManager::getVolumeFile(ResourceSource *source) {
@@ -321,8 +323,7 @@
 
 
 void PatchResourceSource::loadResource(Resource *res) {
-	ResourceManager *resMan = g_sci->getResMan();
-	bool result = resMan->loadFromPatchFile(res);
+	bool result = res->loadFromPatchFile();
 	if (!result) {
 		// TODO: We used to fallback to the "default" code here if loadFromPatchFile
 		// failed, but I am not sure whether that is really appropriate.
@@ -360,19 +361,17 @@
 }
 
 void WaveResourceSource::loadResource(Resource *res) {
-	ResourceManager *resMan = g_sci->getResMan();
 	Common::SeekableReadStream *fileStream = getVolumeFile(res);
 	if (!fileStream)
 		return;
 
 	fileStream->seek(res->_fileOffset, SEEK_SET);
-	resMan->loadFromWaveFile(res, fileStream);
+	res->loadFromWaveFile(fileStream);
 	if (_resourceFile)
 		delete fileStream;
 }
 
 void AudioVolumeResourceSource::loadResource(Resource *res) {
-	ResourceManager *resMan = g_sci->getResMan();
 	Common::SeekableReadStream *fileStream = getVolumeFile(res);
 	if (!fileStream)
 		return;
@@ -410,7 +409,7 @@
 		case kResourceTypeAudio:
 		case kResourceTypeAudio36:
 			// Directly read the stream, compressed audio wont have resource type id and header size for SCI1.1
-			resMan->loadFromAudioVolumeSCI1(res, fileStream);
+			res->loadFromAudioVolumeSCI1(fileStream);
 			if (_resourceFile)
 				delete fileStream;
 			return;
@@ -422,9 +421,9 @@
 		fileStream->seek(res->_fileOffset, SEEK_SET);
 	}
 	if (getSciVersion() < SCI_VERSION_1_1)
-		resMan->loadFromAudioVolumeSCI1(res, fileStream);
+		res->loadFromAudioVolumeSCI1(fileStream);
 	else
-		resMan->loadFromAudioVolumeSCI11(res, fileStream);
+		res->loadFromAudioVolumeSCI11(fileStream);
 
 	if (_resourceFile)
 		delete fileStream;

Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h	2010-06-15 12:18:31 UTC (rev 49832)
+++ scummvm/trunk/engines/sci/resource.h	2010-06-15 12:18:57 UTC (rev 49833)
@@ -192,6 +192,12 @@
 	void writeToStream(Common::WriteStream *stream) const;
 	uint32 getAudioCompressionType() const;
 
+	bool loadPatch(Common::SeekableReadStream *file);
+	bool loadFromPatchFile();
+	bool loadFromWaveFile(Common::SeekableReadStream *file);
+	bool loadFromAudioVolumeSCI1(Common::SeekableReadStream *file);
+	bool loadFromAudioVolumeSCI11(Common::SeekableReadStream *file);
+
 protected:
 	int32 _fileOffset; /**< Offset in file */
 	ResourceStatus _status;
@@ -386,11 +392,6 @@
 
 	Common::SeekableReadStream *getVolumeFile(ResourceSource *source);
 	void loadResource(Resource *res);
-	bool loadPatch(Resource *res, Common::SeekableReadStream *file);
-	bool loadFromPatchFile(Resource *res);
-	bool loadFromWaveFile(Resource *res, Common::SeekableReadStream *file);
-	bool loadFromAudioVolumeSCI1(Resource *res, Common::SeekableReadStream *file);
-	bool loadFromAudioVolumeSCI11(Resource *res, Common::SeekableReadStream *file);
 	void freeOldResources();
 	int decompress(Resource *res, Common::SeekableReadStream *file);
 	int readResourceInfo(Resource *res, Common::SeekableReadStream *file, uint32 &szPacked, ResourceCompression &compression);

Modified: scummvm/trunk/engines/sci/resource_audio.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource_audio.cpp	2010-06-15 12:18:31 UTC (rev 49832)
+++ scummvm/trunk/engines/sci/resource_audio.cpp	2010-06-15 12:18:57 UTC (rev 49833)
@@ -76,7 +76,9 @@
 		delete fileStream;
 }
 
-bool ResourceManager::loadFromWaveFile(Resource *res, Common::SeekableReadStream *file) {
+bool Resource::loadFromWaveFile(Common::SeekableReadStream *file) {
+	Resource *res = this;
+
 	res->data = new byte[res->size];
 
 	uint32 really_read = file->read(res->data, res->size);
@@ -87,14 +89,16 @@
 	return true;
 }
 
-bool ResourceManager::loadFromAudioVolumeSCI11(Resource *res, Common::SeekableReadStream *file) {
+bool Resource::loadFromAudioVolumeSCI11(Common::SeekableReadStream *file) {
+	Resource *res = this;
+
 	// Check for WAVE files here
 	uint32 riffTag = file->readUint32BE();
 	if (riffTag == MKID_BE('RIFF')) {
 		res->_headerSize = 0;
 		res->size = file->readUint32LE();
 		file->seek(-8, SEEK_CUR);
-		return loadFromWaveFile(res, file);
+		return loadFromWaveFile(file);
 	}
 	file->seek(-4, SEEK_CUR);
 
@@ -122,10 +126,12 @@
 		file->seek(-11, SEEK_CUR);
 	}
 
-	return loadPatch(res, file);
+	return loadPatch(file);
 }
 
-bool ResourceManager::loadFromAudioVolumeSCI1(Resource *res, Common::SeekableReadStream *file) {
+bool Resource::loadFromAudioVolumeSCI1(Common::SeekableReadStream *file) {
+	Resource *res = this;
+
 	res->data = new byte[res->size];
 
 	if (res->data == NULL) {


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