diff --git a/src/dialogs.cpp b/src/dialogs.cpp index 279e03f357d8..d63df4e1b7a3 100644 --- a/src/dialogs.cpp +++ b/src/dialogs.cpp @@ -719,7 +719,15 @@ void save_preview_pane::draw_contents() std::string map_data = summary["map_data"]; if(map_data.empty()) { + LOG_DP << "When parsing save summary " << ((*info_)[index_]).name() << std::endl + << "Did not find a map_data field. Looking in game config for a child [" << summary["campaign_type"] << "] with id " << summary["scenario"] << std::endl; + assert(game_config_ && "ran into a null game config pointer inside a game preview pane"); const config &scenario = game_config_->find_child(summary["campaign_type"], "id", summary["scenario"]); + + if (!scenario) { + LOG_DP << "Did not find a matching scenario." << std::endl; + } + if (scenario && !scenario.find_child("side", "shroud", "yes")) { map_data = scenario["map_data"].str(); if (map_data.empty() && scenario.has_attribute("map")) { @@ -765,6 +773,8 @@ void save_preview_pane::draw_contents() ypos = std::max(ypos,map_rect.y + map_rect.h + save_preview_border); sdl_blit(map_surf,NULL,screen,&map_rect); + } else { + LOG_DP << "Never found a map for savefile " << (*info_)[index_].name() << std::endl; } char time_buf[256] = {0}; diff --git a/src/game_controller.cpp b/src/game_controller.cpp index 54f1c63f10a4..2efee951bb05 100644 --- a/src/game_controller.cpp +++ b/src/game_controller.cpp @@ -447,6 +447,15 @@ bool game_controller::is_loading() const bool game_controller::load_game() { + assert(resources::config_manager); + + if (state_.classification().campaign_type.size() == 0) { + state_ = game_state(); + state_.classification().campaign_type = "scenario"; + } + + DBG_GENERAL << "Current campaign type: " << state_.classification().campaign_type << std::endl; + savegame::loadgame load(disp(), resources::config_manager->game_config(), state_); diff --git a/src/gamestatus.cpp b/src/gamestatus.cpp index 1c81f32e8471..67122a0e7629 100644 --- a/src/gamestatus.cpp +++ b/src/gamestatus.cpp @@ -1167,12 +1167,16 @@ void extract_summary_from_config(config& cfg_save, config& cfg_summary) if(!shrouded) { if(has_snapshot) { - if (!cfg_snapshot.find_child("side", "shroud", "yes")) { - cfg_summary.add_child("map", cfg_snapshot.child_or_empty("map")); + if (!cfg_snapshot.find_child("side", "shroud", "yes") && cfg_snapshot.has_attribute("map_data")) { + cfg_summary["map_data"] = cfg_snapshot["map_data"].str(); + } else { + ERR_NG << "Not saving map because there is shroud" << std::endl; } } else if(has_replay) { - if (!cfg_replay_start.find_child("side","shroud","yes")) { - cfg_summary.add_child("map", cfg_replay_start.child_or_empty("map")); + if (!cfg_replay_start.find_child("side","shroud","yes") && cfg_replay_start.has_attribute("map_data")) { + cfg_summary["map_data"] = cfg_replay_start["map_data"]; + } else { + ERR_NG << "Not saving map because there is shroud" << std::endl; } } } diff --git a/src/savegame.cpp b/src/savegame.cpp index 8503d6dafcf5..acc825b24fd4 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -707,7 +707,7 @@ void loadgame::fill_mplevel_config(config& level){ // is empty the starting position contains the wanted info. const config& start_data = !gamestate_.snapshot.empty() ? gamestate_.snapshot : gamestate_.replay_start(); - level.add_child("map", start_data.child_or_empty("map")); + level["map_data"], start_data["map_data"]; level["id"] = start_data["id"]; level["name"] = start_data["name"]; level["completion"] = start_data["completion"];