Author: esr
Date: Wed May 20 07:52:30 2009
New Revision: 35765

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35765&view=rev
Log:
The entire lower layer of save threading, in three lines of code! Tested.
Congrats to YogiHH for making this so easy - I had been planning to wait
a couple of weeks but there's no need.

(Also, a tiny refactoring step using replace_space2underbar that was
clearly intended but missed.)

No actual behavior changes yet; that will take significant
modifications to the load- and save-game dialogs.  This, however, is
*all* the savefile-level infrastructure required.

Modified:
    trunk/src/savegame.cpp

Modified: trunk/src/savegame.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.cpp?rev=35765&r1=35764&r2=35765&view=diff
==============================================================================
--- trunk/src/savegame.cpp (original)
+++ trunk/src/savegame.cpp Wed May 20 07:52:30 2009
@@ -618,6 +618,13 @@
                if (video != NULL && show_confirmation_)
                        gui2::show_message(*video, _("Saved"), _("The game has 
been saved"));
 
+               // The magic moment that does save threading; after each
+               // save, the filename of the saved file becomes the parent
+               // for the next. *Unless* user loads a savegame, in which
+               // case we preserve its parent link by doing nothing.
+               gamestate_.parent = filename_;
+               // FIXME: This transformation probably should be done earlier.
+               replace_space2underbar(gamestate_.parent);
                return true;
        } catch(game::save_game_failed&) {
                if (video != NULL){
@@ -659,6 +666,7 @@
        log_scope("write_game");
 
        out.write_key_val("label", gamestate_.label);
+       out.write_key_val("parent", gamestate_.parent);
        out.write_key_val("history", gamestate_.history);
        out.write_key_val("abbrev", gamestate_.abbrev);
        out.write_key_val("version", game_config::version);
@@ -707,7 +715,7 @@
 void savegame::finish_save_game(const config_writer &out)
 {
        std::string name = gamestate_.label;
-       std::replace(name.begin(),name.end(),' ','_');
+       replace_space2underbar(name);
        std::string fname(get_saves_dir() + "/" + name);
 
        try {


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

Reply via email to