aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2012-05-15 03:05:08 +0300
committerFilippos Karapetis2012-05-15 03:05:38 +0300
commitc64a69c363093df946d2a8555d3e7264f16441ef (patch)
tree5c45a9b5185e43a9ac84e61689d078f263159818 /engines
parentec7dfedc9f275133523b82a08bc62f5c5dbc4d80 (diff)
downloadscummvm-rg350-c64a69c363093df946d2a8555d3e7264f16441ef.tar.gz
scummvm-rg350-c64a69c363093df946d2a8555d3e7264f16441ef.tar.bz2
scummvm-rg350-c64a69c363093df946d2a8555d3e7264f16441ef.zip
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
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/resource.cpp17
-rw-r--r--engines/sci/resource.h20
2 files changed, 17 insertions, 20 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 11c3e2bab5..f8ddf64551 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 6c2eb0b025..4baf39c67f 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 {