Author: mordante
Date: Fri Feb 25 20:56:10 2011
New Revision: 48639

URL: http://svn.gna.org/viewcvs/wesnoth?rev=48639&view=rev
Log:
Try to load a .gz file if opening a file fails.

Modified:
    trunk/changelog
    trunk/src/savegame.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=48639&r1=48638&r2=48639&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Fri Feb 25 20:56:10 2011
@@ -54,6 +54,7 @@
    * Make it impossible to build Wesnoth without the editor.
    * Fixed a replay OOS issue caused by ToD areas defined outside of events
      (bug #17783).
+   * Changed: when loading a file fails to open try with a .gz file.
 
 Version 1.9.4:
  * AI:

Modified: trunk/src/savegame.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.cpp?rev=48639&r1=48638&r2=48639&view=diff
==============================================================================
--- trunk/src/savegame.cpp (original)
+++ trunk/src/savegame.cpp Fri Feb 25 20:56:10 2011
@@ -219,14 +219,26 @@
        std::string modified_name = name;
        replace_space2underbar(modified_name);
 
-       // Try reading the file both with and without underscores
+       // Try reading the file both with and without underscores, if needed 
append .gz as well
        scoped_istream file_stream = istream_file(get_saves_dir() + "/" + 
modified_name);
-       if (file_stream->fail())
+       if (file_stream->fail()) {
                file_stream = istream_file(get_saves_dir() + "/" + name);
+       }
+       if(file_stream->fail() && !is_gzip_file(modified_name)) {
+               file_stream = istream_file(get_saves_dir() + "/" + 
modified_name + ".gz");
+               if (file_stream->fail()) {
+                       file_stream = istream_file(get_saves_dir() + "/" + name 
+ ".gz");
+               }
+               modified_name += ".gz";
+       }
 
        cfg.clear();
        try{
-               if(is_gzip_file(name)) {
+               /*
+                * Test the modified name, since it might use a .gz
+                * file even when not requested.
+                */
+               if(is_gzip_file(modified_name)) {
                        read_gz(cfg, *file_stream);
                } else {
                        read(cfg, *file_stream);


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to