[Wesnoth-cvs-commits] wesnoth/src image.cpp (February 08, 2005 - 22:04)

 

CVSROOT:	/cvsroot/wesnoth
Module name:	wesnoth
Branch: 	
Changes by:	Guillaume Melquiond <silene@xxxxxxxxxxxxxxxx>	05/02/08 20:24:50

Modified files:
	src            : image.cpp 

Log message:
	Enhance the image loader so that an image not found is correctly reported as an error (but perhaps it should only be a warning).

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/image.cpp.diff?tr1=1.72&tr2=1.73&r1=text&r2=text

Patches:
Index: wesnoth/src/image.cpp
diff -u wesnoth/src/image.cpp:1.72 wesnoth/src/image.cpp:1.73
--- wesnoth/src/image.cpp:1.72	Sat Jan  8 21:18:27 2005
+++ wesnoth/src/image.cpp	Tue Feb  8 20:24:49 2005
@@ -202,24 +202,22 @@
 
 surface locator::load_image_file() const
 {
-#ifdef USE_ZIPIOS
-	std::string s = read_file("images/" + val_.filename_);
-	if (s.empty())
-		return surface(NULL);
+	surface res;
 
-	SDL_RWops* ops = SDL_RWFromMem((void*)s.c_str(), s.size());
-	const surface res(IMG_Load_RW(ops, 0));
-	SDL_FreeRW(ops);
+#ifdef USE_ZIPIOS
+	std::string const &s = read_file("images/" + val_.filename_);
+	if (!s.empty()) {
+		SDL_RWops* ops = SDL_RWFromMem((void*)s.c_str(), s.size());
+		res = IMG_Load_RW(ops, 0);
+		SDL_FreeRW(ops);
+	}
 #else
-	const std::string& location = get_binary_file_location("images", val_.filename_);
-	if(location.empty())
-		return surface(NULL);
-
-	const surface res(IMG_Load(location.c_str()));
+	std::string const &location = get_binary_file_location("images", val_.filename_);
+	if (!location.empty())
+		res = IMG_Load(location.c_str());
 #endif
-	if(res == NULL) {
+	if (res.null())
 		ERR_DP << "could not open image '" << val_.filename_ << "'\n";
-	}
 
 	return res;
 }



You are on the gna.org mail server.

Generated by mhonarc, Tue Sep 20 16:46:57 2005