mail[Wesnoth-commits] r37219 - in /trunk/src: gamestatus.cpp gamestatus.hpp playcampaign.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by e0204097 on July 24, 2009 - 16:56:
Author: euschn
Date: Fri Jul 24 16:56:24 2009
New Revision: 37219

URL: http://svn.gna.org/viewcvs/wesnoth?rev=37219&view=rev
Log:
removed the [player] tag from replay_start in savegames. saves with player 
tags in replay_start still work

Modified:
    trunk/src/gamestatus.cpp
    trunk/src/gamestatus.hpp
    trunk/src/playcampaign.cpp

Modified: trunk/src/gamestatus.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.cpp?rev=37219&r1=37218&r2=37219&view=diff
==============================================================================
--- trunk/src/gamestatus.cpp (original)
+++ trunk/src/gamestatus.cpp Fri Jul 24 16:56:24 2009
@@ -164,28 +164,34 @@
                classification_()
                {}
 
-void write_players(game_state& gamestate, config& cfg, const bool merge_side)
+void write_players(game_state& gamestate, config& cfg, const bool 
use_snapshot, const bool merge_side)
 {
        // If there is already a player config available it means we are 
loading
        // from a savegame. Don't do anything then, the information is 
already there
        config::child_itors player_cfg = cfg.child_range("player");
        if (player_cfg.first != player_cfg.second)
                return;
+
+       config *source = NULL;
+       if (use_snapshot) {
+               source = &gamestate.snapshot;
+       } else {
+               source = &gamestate.starting_pos;
+       }
        
        if (merge_side) {
                //merge sides/players from starting pos with the scenario cfg
-               config temp(cfg);
                std::vector<std::string> tags;
                tags.push_back("side");
                tags.push_back("player"); //merge [player] tags for backwards 
compatibility of saves
 
                foreach (const std::string side_tag, tags) {
-                       foreach (config* carryover_side, 
gamestate.starting_pos.get_children(side_tag)) {
+                       foreach (config* carryover_side, 
source->get_children(side_tag)) {
                                config *scenario_side = NULL;
 
-                               if (config& c = temp.find_child("side", 
"save_id", (*carryover_side)["save_id"])) {
+                               if (config& c = cfg.find_child("side", 
"save_id", (*carryover_side)["save_id"])) {
                                        scenario_side = &c;
-                               } else if (config& c = 
temp.find_child("side", "id", (*carryover_side)["save_id"])) {
+                               } else if (config& c = cfg.find_child("side", 
"id", (*carryover_side)["save_id"])) {
                                        scenario_side = &c;
                                }
 
@@ -211,14 +217,13 @@
                                        
(*scenario_side).merge_with(*carryover_side);
                                } else {
                                        //no matching side in the current 
scenario, we add the persistent information in a [player] tag
-                                       temp.add_child("player", 
(*carryover_side));
+                                       cfg.add_child("player", 
(*carryover_side));
                                }
                        }
        }
-       gamestate.starting_pos = temp;
 
        } else {
-               foreach(const config* snapshot_side, 
gamestate.snapshot.get_children("side")) {
+               foreach(const config* snapshot_side, 
source->get_children("side")) {
                        //take all side tags and add them as players 
(assuming they only contain carryover information)
                        cfg.add_child("player", *snapshot_side);
                }

Modified: trunk/src/gamestatus.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.hpp?rev=37219&r1=37218&r2=37219&view=diff
==============================================================================
--- trunk/src/gamestatus.hpp (original)
+++ trunk/src/gamestatus.hpp Fri Jul 24 16:56:24 2009
@@ -152,7 +152,7 @@
 
 std::string generate_game_uuid();
 
-void write_players(game_state& gamestate, config& cfg, const bool merge_side 
= false);
+void write_players(game_state& gamestate, config& cfg, const bool 
use_snapshot=true, const bool merge_side = false);
 
 void extract_summary_from_config(config& cfg_save, config& cfg_summary);
 

Modified: trunk/src/playcampaign.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playcampaign.cpp?rev=37219&r1=37218&r2=37219&view=diff
==============================================================================
--- trunk/src/playcampaign.cpp (original)
+++ trunk/src/playcampaign.cpp Fri Jul 24 16:56:24 2009
@@ -228,7 +228,9 @@
                        if (*scenario) {
                                starting_pos = *scenario;
                                preload_lua_tags(game_config, starting_pos);
-                               write_players(gamestate, starting_pos, true);
+                               config temp(starting_pos);
+                               write_players(gamestate, temp, false, true);
+                               gamestate.starting_pos = temp;
                                scenario = &starting_pos;
                        } else
                                scenario = NULL;
@@ -519,7 +521,7 @@
                                assert(next_cfg != NULL);
                                gamestate.write_snapshot(next_cfg);
                                assert 
(next_cfg.get_children("player").empty());
-                               write_players(gamestate, next_cfg);
+                               write_players(gamestate, next_cfg, true, 
true);
                                network::send_data(cfg, 0, true);
                        }
                }
@@ -570,7 +572,7 @@
                        if (gamestate.classification().campaign_type != 
"multiplayer"){
                                gamestate.starting_pos = *scenario;
                                assert (!gamestate.snapshot.empty());
-                               write_players(gamestate, 
gamestate.starting_pos);
+                               write_players(gamestate, 
gamestate.starting_pos, true, true);
                        }
                }
                gamestate.snapshot = config();




Related Messages


Powered by MHonArc, Updated Fri Jul 24 22:21:19 2009