From 3106bcac0ab8e9f9cb88568e8a36d334b6937bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hinrichs?= Date: Tue, 10 Apr 2007 18:30:47 +0000 Subject: [PATCH] Fixes bug #8889 (recall list woes on loading) and possibly fixes bug #8886 (empty recall list) --- src/config_adapter.cpp | 10 +++++++++- src/config_adapter.hpp | 2 +- src/play_controller.cpp | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/config_adapter.cpp b/src/config_adapter.cpp index 6408619a0b0..e76e637aa4d 100644 --- a/src/config_adapter.cpp +++ b/src/config_adapter.cpp @@ -42,7 +42,7 @@ std::string get_unique_saveid(const config& cfg, std::set& seen_sav return save_id; } -void get_player_info(const config& cfg, game_state& gamestate, std::string save_id, std::vector& teams, const config& level, const game_data& gameinfo, gamemap& map, unit_map& units, gamestatus& game_status){ +void get_player_info(const config& cfg, game_state& gamestate, std::string save_id, std::vector& teams, const config& level, const game_data& gameinfo, gamemap& map, unit_map& units, gamestatus& game_status, bool snapshot){ player_info *player = NULL; if(cfg["controller"] == "human" || @@ -143,6 +143,14 @@ void get_player_info(const config& cfg, game_state& gamestate, std::string save_ //if there are additional starting units on this side const config::child_list& starting_units = cfg.get_children("unit"); + //available_units has been filled by loading the [player]-section already. However, we need + //to get the information from the snapshot so we start from scratch here. This is rather a + //quick hack, originating from keeping changes as minimal as possible for 1.2. Moving [player] + //into [replay_start] should be the correct way to go. + if (player && snapshot){ + player->available_units.clear(); + } + //backwards compatibility code for 1.2/1.2.1 if ( (starting_units.begin() != starting_units.end()) && player && (gamestate.version < "1.2.2") ){ player->available_units.clear(); } diff --git a/src/config_adapter.hpp b/src/config_adapter.hpp index b797923f9bd..b2fe299c3ca 100644 --- a/src/config_adapter.hpp +++ b/src/config_adapter.hpp @@ -32,7 +32,7 @@ class unit_map; std::string get_unique_saveid(const config& cfg, std::set& seen_save_ids); int get_first_human_team(const config::child_list::const_iterator& cfg, const config::child_list& unit_cfg); -void get_player_info(const config& cfg, game_state& gamestate, std::string save_id, std::vector& teams, const config& level, const game_data& gameinfo, gamemap& map, unit_map& units, gamestatus& game_status); +void get_player_info(const config& cfg, game_state& gamestate, std::string save_id, std::vector& teams, const config& level, const game_data& gameinfo, gamemap& map, unit_map& units, gamestatus& game_status, bool snapshot); const config* get_theme(const config& game_config, std::string theme_name); #endif diff --git a/src/play_controller.cpp b/src/play_controller.cpp index 25f2be660b4..b9c514134e3 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -69,6 +69,7 @@ void play_controller::init(CVideo& video){ recorder.set_skip(false); const config::child_list& unit_cfg = level_.get_children("side"); + bool snapshot = level_["snapshot"] == "yes"; if(level_["modify_placing"] == "true") { LOG_NG << "modifying placing...\n"; @@ -86,7 +87,7 @@ void play_controller::init(CVideo& video){ if (first_human_team_ == -1){ first_human_team_ = get_first_human_team(ui, unit_cfg); } - get_player_info(**ui, gamestate_, save_id, teams_, level_, gameinfo_, map_, units_, status_); + get_player_info(**ui, gamestate_, save_id, teams_, level_, gameinfo_, map_, units_, status_, snapshot); } preferences::encounter_recruitable_units(teams_);