Author: esr
Date: Wed May 20 12:03:09 2009
New Revision: 35770

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35770&view=rev
Log:
Simplify parent assignment still further, and compute the inverse relationship 
in the initializatoopn of the load_game dialog (it's not used yet).

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

Modified: trunk/src/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/dialogs.cpp?rev=35770&r1=35769&r2=35770&view=diff
==============================================================================
--- trunk/src/dialogs.cpp (original)
+++ trunk/src/dialogs.cpp Wed May 20 12:03:09 2009
@@ -568,8 +568,11 @@
 
        std::vector<config*> summaries;
        std::vector<save_info>::const_iterator i;
+       //FIXME: parent_to_child is not used yet
+       std::map<std::string,std::string> parent_to_child;
        for(i = games.begin(); i != games.end(); ++i) {
                config& cfg = save_index::save_summary(i->name);
+               parent_to_child[cfg["parent"]] = i->name;
                summaries.push_back(&cfg);
        }
 

Modified: trunk/src/savegame.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.cpp?rev=35770&r1=35769&r2=35770&view=diff
==============================================================================
--- trunk/src/savegame.cpp (original)
+++ trunk/src/savegame.cpp Wed May 20 12:03:09 2009
@@ -602,7 +602,7 @@
 
 bool savegame::save_game(CVideo* video, const std::string& filename)
 {
-  static std::string parent, grandparent;
+       static std::string parent, grandparent;
 
        try {
                Uint32 start, end;
@@ -610,8 +610,6 @@
 
                if (filename_ == "")
                        filename_ = filename;
-
-               bool overwriting = (filename_ == parent);
 
                before_save();
 
@@ -619,22 +617,19 @@
                // each save, the filename of the save file becomes
                // the parent for the next. *Unless* the parent file
                // has the same name as the savefile, in which case we
-               // restore the grandparent name. When user loads a
-               // savegame, we load its correct parent link along with it.
-               LOG_SAVE << "While saving '" << filename_ << "', parent is '" 
<< gamestate_.parent << "' and grandparent is '" << grandparent << "'\n";
-
-               if (overwriting) {
+               // use the grandparent name. When user loads a savegame,
+               // we load its correct parent link along with it.
+               if (filename_ == parent) {
                        gamestate_.parent = grandparent;
                } else {
                        gamestate_.parent = parent;
                }
-               LOG_SAVE << "Setting file parent to " << gamestate_.parent << 
"\n";
+               LOG_SAVE << "Setting parent of '" << filename_<< "' to " << 
gamestate_.parent << "\n";
 
                write_game_to_disk(filename_);
 
                grandparent = parent;
                parent = filename_;
-               LOG_SAVE << "Setting parent to '" << parent << "' and 
grandparent to '" << grandparent << "'\n";
 
                end = SDL_GetTicks();
                LOG_SAVE << "Milliseconds to save " << filename_ << ": " << end 
- start << "\n";
@@ -771,6 +766,7 @@
        out["snapshot"] = has_snapshot ? "yes" : "no";
 
        out["label"] = gamestate_.label;
+       out["parent"] = gamestate_.parent;
        out["campaign"] = gamestate_.campaign;
        out["campaign_type"] = gamestate_.campaign_type;
        out["scenario"] = gamestate_.scenario;


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

Reply via email to