[Scummvm-cvs-logs] scummvm master -> c64a69c363093df946d2a8555d3e7264f16441ef

bluegr md5 at scummvm.org
Tue May 15 02:06:42 CEST 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c64a69c363 SCI: Resolve some resource related FIXMEs


Commit: c64a69c363093df946d2a8555d3e7264f16441ef
    https://github.com/scummvm/scummvm/commit/c64a69c363093df946d2a8555d3e7264f16441ef
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2012-05-14T17:05:38-07:00

Commit Message:
SCI: Resolve some resource related FIXMEs

These were introduced in 4f6d42d.
The odd comment dates back to FreeSCI, as far as our history goes, and
seems to be a leftover from an old refactoring during FreeSCI's history

Changed paths:
    engines/sci/resource.cpp
    engines/sci/resource.h



diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 11c3e2b..f8ddf64 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -93,9 +93,7 @@ const char *getSciVersionDesc(SciVersion version) {
 
 //#define SCI_VERBOSE_RESMAN 1
 
-// FIXME: This list is out of sync with the enum in resource.h with
-// its indices.
-static const char *const sci_error_types[] = {
+static const char *const s_errorDescriptions[] = {
 	"No error",
 	"I/O error",
 	"Resource is empty (size 0)",
@@ -103,10 +101,8 @@ static const char *const sci_error_types[] = {
 	"resource.map file not found",
 	"No resource files found",
 	"Unknown compression method",
-	"Decompression failed: Decompression buffer overflow",
 	"Decompression failed: Sanity check failed",
-	"Decompression failed: Resource too big",
-	"SCI version is unsupported"
+	"Decompression failed: Resource too big"
 };
 
 static const char *const s_resourceTypeNames[] = {
@@ -578,7 +574,7 @@ void ResourceSource::loadResource(ResourceManager *resMan, Resource *res) {
 	if (error) {
 		warning("Error %d occurred while reading %s from resource file %s: %s",
 				error, res->_id.toString().c_str(), res->getResourceLocation().c_str(),
-				sci_error_types[error]);
+				s_errorDescriptions[error]);
 		res->unalloc();
 	}
 
@@ -1878,6 +1874,9 @@ int Resource::readResourceInfo(ResVersion volVersion, Common::SeekableReadStream
 	uint32 wCompression, szUnpacked;
 	ResourceType type;
 
+	if (file->size() == 0)
+		return SCI_ERROR_EMPTY_RESOURCE;
+
 	switch (volVersion) {
 	case kResVersionSci0Sci1Early:
 	case kResVersionSci1Middle:
@@ -1922,7 +1921,7 @@ int Resource::readResourceInfo(ResVersion volVersion, Common::SeekableReadStream
 		break;
 #endif
 	default:
-		return SCI_ERROR_INVALID_RESMAP_ENTRY;
+		return SCI_ERROR_RESMAP_INVALID_ENTRY;
 	}
 
 	// check if there were errors while reading
@@ -1963,7 +1962,7 @@ int Resource::readResourceInfo(ResVersion volVersion, Common::SeekableReadStream
 		compression = kCompUnknown;
 	}
 
-	return compression == kCompUnknown ? SCI_ERROR_UNKNOWN_COMPRESSION : 0;
+	return (compression == kCompUnknown) ? SCI_ERROR_UNKNOWN_COMPRESSION : SCI_ERROR_NONE;
 }
 
 int Resource::decompress(ResVersion volVersion, Common::SeekableReadStream *file) {
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index 6c2eb0b..4baf39c 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -54,19 +54,17 @@ enum ResourceStatus {
 	kResStatusLocked /**< Allocated and in use */
 };
 
-// FIXME: This enum is out of sync with its textual descriptions in resource.cpp
-/** Initialization result types */
-enum {
+/** Resource error codes. Should be in sync with s_errorDescriptions */
+enum ResourceErrorCodes {
+	SCI_ERROR_NONE = 0,
 	SCI_ERROR_IO_ERROR = 1,
-	SCI_ERROR_INVALID_RESMAP_ENTRY = 2,	/**< Invalid resource.map entry */
-	SCI_ERROR_RESMAP_NOT_FOUND = 3,
-	SCI_ERROR_NO_RESOURCE_FILES_FOUND = 4,	/**< No resource at all was found */
-	SCI_ERROR_UNKNOWN_COMPRESSION = 5,
-	SCI_ERROR_DECOMPRESSION_ERROR = 6,	/**< sanity checks failed during decompression */
+	SCI_ERROR_EMPTY_RESOURCE = 2,
+	SCI_ERROR_RESMAP_INVALID_ENTRY = 3,	/**< Invalid resource.map entry */
+	SCI_ERROR_RESMAP_NOT_FOUND = 4,
+	SCI_ERROR_NO_RESOURCE_FILES_FOUND = 5,	/**< No resource at all was found */
+	SCI_ERROR_UNKNOWN_COMPRESSION = 6,
+	SCI_ERROR_DECOMPRESSION_ERROR = 7,	/**< sanity checks failed during decompression */
 	SCI_ERROR_RESOURCE_TOO_BIG = 8	/**< Resource size exceeds SCI_MAX_RESOURCE_SIZE */
-
-	// FIXME: This comment makes no sense. Track down in history what it means:
-	/* the first critical error number */
 };
 
 enum {






More information about the Scummvm-git-logs mailing list