wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src filesystem.cpp image.cpp


From: Yann Dirson
Subject: [Wesnoth-cvs-commits] wesnoth/src filesystem.cpp image.cpp
Date: Fri, 07 Jan 2005 19:44:25 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Yann Dirson <address@hidden>    05/01/08 00:13:30

Modified files:
        src            : filesystem.cpp image.cpp 

Log message:
        allow reading images from zip files

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/filesystem.cpp.diff?tr1=1.52&tr2=1.53&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/image.cpp.diff?tr1=1.69&tr2=1.70&r1=text&r2=text

Patches:
Index: wesnoth/src/filesystem.cpp
diff -u wesnoth/src/filesystem.cpp:1.52 wesnoth/src/filesystem.cpp:1.53
--- wesnoth/src/filesystem.cpp:1.52     Wed Jan  5 23:25:33 2005
+++ wesnoth/src/filesystem.cpp  Sat Jan  8 00:13:30 2005
@@ -1,4 +1,4 @@
-/* $Id: filesystem.cpp,v 1.52 2005/01/05 23:25:33 ydirson Exp $ */
+/* $Id: filesystem.cpp,v 1.53 2005/01/08 00:13:30 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -573,6 +573,10 @@
 
 bool file_exists(const std::string& name)
 {
+#ifdef USE_ZIPIOS
+       if (the_collection.getEntry(name))
+               return true;
+#endif
        std::ifstream file(name.c_str());
        if (file.rdstate() != 0)
                return false;
Index: wesnoth/src/image.cpp
diff -u wesnoth/src/image.cpp:1.69 wesnoth/src/image.cpp:1.70
--- wesnoth/src/image.cpp:1.69  Fri Dec 31 21:01:37 2004
+++ wesnoth/src/image.cpp       Sat Jan  8 00:13:30 2005
@@ -201,6 +201,21 @@
 
 surface locator::load_image_file() const
 {
+#ifdef USE_ZIPIOS
+       std::string s = read_file("images/" + val_.filename_);
+       if (s.empty()) {
+               return surface(NULL);
+       } else {
+               SDL_RWops* ops = SDL_RWFromMem((void*)s.c_str(), s.size());
+               const surface res(IMG_Load_RW(ops, 0));
+               if(res == NULL) {
+                       ERR_DP << "could not open image '" << val_.filename_ << 
"'\n";
+               }
+               SDL_FreeRW(ops);
+
+               return res;
+       }
+#else
        const std::string& location = get_binary_file_location("images", 
val_.filename_);
 
        if(location.empty()) {
@@ -213,6 +228,7 @@
 
                return res;
        }
+#endif
 }
 
 surface locator::load_image_sub_file() const
@@ -622,10 +638,14 @@
        if(image_existance_map.find(i_locator) != image_existance_map.end())
                return image_existance_map[i_locator];
 
+#ifdef USE_ZIPIOS
+       if(file_exists("images/" + i_locator.get_filename()))
+               ret = true;
+#else
        if(get_binary_file_location("images",i_locator.get_filename()).empty() 
== false) {
                ret = true;
        }
-
+#endif
        image_existance_map[i_locator] = ret;
 
        return ret;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]