From f3ecdaa6fea27d2e286f4b56057bc197cf886254 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Tue, 5 Aug 2008 19:30:16 +0000 Subject: 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 --- engines/cine/anim.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'engines/cine') 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; -- cgit v1.2.3