[Scummvm-cvs-logs] SF.net SVN: scummvm:[33643] scummvm/trunk/engines/cine/anim.cpp

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Tue Aug 5 21:30:19 CEST 2008


Revision: 33643
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33643&view=rev
Author:   buddha_
Date:     2008-08-05 19:30:16 +0000 (Tue, 05 Aug 2008)

Log Message:
-----------
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).

Modified Paths:
--------------
    scummvm/trunk/engines/cine/anim.cpp

Modified: scummvm/trunk/engines/cine/anim.cpp
===================================================================
--- scummvm/trunk/engines/cine/anim.cpp	2008-08-05 18:17:55 UTC (rev 33642)
+++ scummvm/trunk/engines/cine/anim.cpp	2008-08-05 19:30:16 UTC (rev 33643)
@@ -535,10 +535,14 @@
 /*! \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 @@
 /*! \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 @@
 /*! \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 @@
 	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 @@
 /*! \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;
 


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