aboutsummaryrefslogtreecommitdiff
path: root/engines/cine
diff options
context:
space:
mode:
authorKari Salminen2008-08-05 19:30:16 +0000
committerKari Salminen2008-08-05 19:30:16 +0000
commitf3ecdaa6fea27d2e286f4b56057bc197cf886254 (patch)
tree3d62c08f150745d5a3d45d8a16f2e760c6294330 /engines/cine
parent941706664161b7009db465a0049f25cc282aea10 (diff)
downloadscummvm-rg350-f3ecdaa6fea27d2e286f4b56057bc197cf886254.tar.gz
scummvm-rg350-f3ecdaa6fea27d2e286f4b56057bc197cf886254.tar.bz2
scummvm-rg350-f3ecdaa6fea27d2e286f4b56057bc197cf886254.zip
Made rest of resource loading functions used in loadResource return -1 on error.
This fixed a crash in Operation Stealth when walking out of the airport (Some file couldn't be opened and the game crashed because of that. Now it doesn't crash but handles the missing file gracefully). svn-id: r33643
Diffstat (limited to 'engines/cine')
-rw-r--r--engines/cine/anim.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp
index 28c2ee3ac8..1036078fb3 100644
--- a/engines/cine/anim.cpp
+++ b/engines/cine/anim.cpp
@@ -535,10 +535,14 @@ int loadSpl(const char *resourceName, int16 idx) {
/*! \brief Load 1bpp mask
* \param resourceName Mask filename
* \param idx Target index in animDataTable (-1 if any empty space will do)
- * \return The number of the animDataTable entry after the loaded mask
+ * \return The number of the animDataTable entry after the loaded mask (-1 if error)
*/
int loadMsk(const char *resourceName, int16 idx) {
int16 foundFileIdx = findFileInBundle(resourceName);
+ if (foundFileIdx < 0) {
+ return -1;
+ }
+
int entry = 0;
byte *dataPtr = readBundleFile(foundFileIdx);
byte *ptr;
@@ -562,10 +566,14 @@ int loadMsk(const char *resourceName, int16 idx) {
/*! \brief Load animation
* \param resourceName Animation filename
* \param idx Target index in animDataTable (-1 if any empty space will do)
- * \return The number of the animDataTable entry after the loaded animation
+ * \return The number of the animDataTable entry after the loaded animation (-1 if error)
*/
int loadAni(const char *resourceName, int16 idx) {
int16 foundFileIdx = findFileInBundle(resourceName);
+ if (foundFileIdx < 0) {
+ return -1;
+ }
+
int entry = 0;
byte *dataPtr = readBundleFile(foundFileIdx);
byte *ptr;
@@ -651,7 +659,7 @@ void convert8BBP2(byte *dest, byte *source, int16 width, int16 height) {
/*! \brief Load image set
* \param resourceName Image set filename
* \param idx Target index in animDataTable (-1 if any empty space will do)
- * \return The number of the animDataTable entry after the loaded image set
+ * \return The number of the animDataTable entry after the loaded image set (-1 if error)
*/
int loadSet(const char *resourceName, int16 idx) {
AnimHeader2Struct header2;
@@ -661,6 +669,10 @@ int loadSet(const char *resourceName, int16 idx) {
byte *ptr, *startOfDataPtr, *dataPtr, *origDataPtr;
int type;
+ if (foundFileIdx < 0) {
+ return -1;
+ }
+
origDataPtr = dataPtr = readBundleFile(foundFileIdx);
assert(!memcmp(dataPtr, "SET", 3));
ptr = dataPtr + 4;
@@ -708,10 +720,14 @@ int loadSet(const char *resourceName, int16 idx) {
/*! \brief Load SEQ data into animDataTable
* \param resourceName SEQ data filename
* \param idx Target index in animDataTable (-1 if any empty space will do)
- * \return The number of the animDataTable entry after the loaded SEQ data
+ * \return The number of the animDataTable entry after the loaded SEQ data (-1 if error)
*/
int loadSeq(const char *resourceName, int16 idx) {
int16 foundFileIdx = findFileInBundle(resourceName);
+ if (foundFileIdx < 0) {
+ return -1;
+ }
+
byte *dataPtr = readBundleFile(foundFileIdx);
int entry = idx < 0 ? emptyAnimSpace() : idx;