Merge branch 'master' of git://github.com/wesnoth/wesnoth
This commit is contained in:
commit
f446245ff5
31 changed files with 301 additions and 267 deletions
|
@ -740,6 +740,7 @@ set(wesnoth-main_SRC
|
|||
formula_string_utils.cpp
|
||||
formula_tokenizer.cpp
|
||||
game_board.cpp
|
||||
game_classification.cpp
|
||||
game_config_manager.cpp
|
||||
game_controller.cpp
|
||||
game_display.cpp
|
||||
|
|
|
@ -273,6 +273,7 @@ wesnoth_sources = Split("""
|
|||
formula_string_utils.cpp
|
||||
formula_tokenizer.cpp
|
||||
game_board.cpp
|
||||
game_classification.cpp
|
||||
game_config_manager.cpp
|
||||
game_controller.cpp
|
||||
game_display.cpp
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "../manager.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../lua/lua_object.hpp"
|
||||
#include "../../gamestatus.hpp"
|
||||
#include "../../resources.hpp"
|
||||
#include "../../scripting/lua.hpp"
|
||||
#include "../../terrain_filter.hpp"
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "../../dialogs.hpp"
|
||||
#include "../../game_board.hpp"
|
||||
#include "../../game_events/pump.hpp"
|
||||
#include "../../gamestatus.hpp"
|
||||
#include "../../game_classification.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../../mouse_handler_base.hpp"
|
||||
#include "../../resources.hpp"
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "../../attack_prediction.hpp"
|
||||
#include "../../filesystem.hpp"
|
||||
#include "../../game_display.hpp"
|
||||
#include "../../gamestatus.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../../map.hpp"
|
||||
#include "../../pathfind/pathfind.hpp"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "../composite/rca.hpp"
|
||||
#include "../composite/stage.hpp"
|
||||
#include "../../game_board.hpp"
|
||||
#include "../../game_classification.hpp"
|
||||
#include "../../gamestatus.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../../map.hpp"
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "../composite/rca.hpp"
|
||||
#include "../composite/stage.hpp"
|
||||
#include "../../game_board.hpp"
|
||||
#include "../../gamestatus.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../../map.hpp"
|
||||
#include "../../resources.hpp"
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
#define EDITOR_MAP_CONTEXT_HPP_INCLUDED
|
||||
|
||||
#include "editor_map.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "game_classification.hpp"
|
||||
#include "map_label.hpp"
|
||||
#include "mp_game_settings.hpp"
|
||||
#include "sound_music_track.hpp"
|
||||
#include "tod_manager.hpp"
|
||||
#include "unit_map.hpp"
|
||||
|
|
101
src/game_classification.cpp
Normal file
101
src/game_classification.cpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
Copyright (C) 2003 - 2014 by David White <dave@whitevine.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "global.hpp"
|
||||
#include "game_classification.hpp"
|
||||
#include "util.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
#include "log.hpp"
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define ERR_NG LOG_STREAM(err, log_engine)
|
||||
#define WRN_NG LOG_STREAM(warn, log_engine)
|
||||
#define LOG_NG LOG_STREAM(info, log_engine)
|
||||
#define DBG_NG LOG_STREAM(debug, log_engine)
|
||||
|
||||
/// The default difficulty setting for campaigns.
|
||||
const std::string DEFAULT_DIFFICULTY("NORMAL");
|
||||
|
||||
game_classification::game_classification():
|
||||
savegame_config(),
|
||||
label(),
|
||||
version(),
|
||||
campaign_type(),
|
||||
campaign_define(),
|
||||
campaign_xtra_defines(),
|
||||
campaign(),
|
||||
abbrev(),
|
||||
completion(),
|
||||
end_credits(true),
|
||||
end_text(),
|
||||
end_text_duration(),
|
||||
difficulty(DEFAULT_DIFFICULTY),
|
||||
random_mode("")
|
||||
{}
|
||||
|
||||
game_classification::game_classification(const config& cfg):
|
||||
savegame_config(),
|
||||
label(cfg["label"]),
|
||||
version(cfg["version"]),
|
||||
campaign_type(lexical_cast_default<game_classification::CAMPAIGN_TYPE> (cfg["campaign_type"].str(), game_classification::SCENARIO)),
|
||||
campaign_define(cfg["campaign_define"]),
|
||||
campaign_xtra_defines(utils::split(cfg["campaign_extra_defines"])),
|
||||
campaign(cfg["campaign"]),
|
||||
abbrev(cfg["abbrev"]),
|
||||
completion(cfg["completion"]),
|
||||
end_credits(cfg["end_credits"].to_bool(true)),
|
||||
end_text(cfg["end_text"]),
|
||||
end_text_duration(cfg["end_text_duration"]),
|
||||
difficulty(cfg["difficulty"].empty() ? DEFAULT_DIFFICULTY : cfg["difficulty"].str()),
|
||||
random_mode(cfg["random_mode"])
|
||||
{}
|
||||
|
||||
game_classification::game_classification(const game_classification& gc):
|
||||
savegame_config(),
|
||||
label(gc.label),
|
||||
version(gc.version),
|
||||
campaign_type(gc.campaign_type),
|
||||
campaign_define(gc.campaign_define),
|
||||
campaign_xtra_defines(gc.campaign_xtra_defines),
|
||||
campaign(gc.campaign),
|
||||
abbrev(gc.abbrev),
|
||||
completion(gc.completion),
|
||||
end_credits(gc.end_credits),
|
||||
end_text(gc.end_text),
|
||||
end_text_duration(gc.end_text_duration),
|
||||
difficulty(gc.difficulty),
|
||||
random_mode(gc.random_mode)
|
||||
{
|
||||
}
|
||||
|
||||
config game_classification::to_config() const
|
||||
{
|
||||
config cfg;
|
||||
|
||||
cfg["label"] = label;
|
||||
cfg["version"] = game_config::version;
|
||||
cfg["campaign_type"] = lexical_cast<std::string> (campaign_type);
|
||||
cfg["campaign_define"] = campaign_define;
|
||||
cfg["campaign_extra_defines"] = utils::join(campaign_xtra_defines);
|
||||
cfg["campaign"] = campaign;
|
||||
cfg["abbrev"] = abbrev;
|
||||
cfg["completion"] = completion;
|
||||
cfg["end_credits"] = end_credits;
|
||||
cfg["end_text"] = end_text;
|
||||
cfg["end_text_duration"] = str_cast<unsigned int>(end_text_duration);
|
||||
cfg["difficulty"] = difficulty;
|
||||
cfg["random_mode"] = random_mode;
|
||||
|
||||
return cfg;
|
||||
}
|
61
src/game_classification.hpp
Normal file
61
src/game_classification.hpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
Copyright (C) 2003 - 2014 by David White <dave@whitevine.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GAME_CLASSIFICATION_HPP_INCLUDED
|
||||
#define GAME_CLASSIFICATION_HPP_INCLUDED
|
||||
|
||||
#include "config.hpp"
|
||||
#include "make_enum.hpp"
|
||||
#include "savegame_config.hpp"
|
||||
|
||||
/// The default difficulty setting for campaigns.
|
||||
extern const std::string DEFAULT_DIFFICULTY;
|
||||
|
||||
//meta information of the game
|
||||
class game_classification : public savegame::savegame_config
|
||||
{
|
||||
public:
|
||||
game_classification();
|
||||
explicit game_classification(const config& cfg);
|
||||
game_classification(const game_classification& gc);
|
||||
|
||||
config to_config() const;
|
||||
|
||||
std::string label; /**< Name of the game (e.g. name of save file). */
|
||||
std::string version; /**< Version game was created with. */
|
||||
MAKE_ENUM (CAMPAIGN_TYPE, /**< Type of the game - campaign, multiplayer etc. */
|
||||
(SCENARIO, "scenario")
|
||||
(MULTIPLAYER, "multiplayer")
|
||||
(TEST, "test")
|
||||
(TUTORIAL, "tutorial")
|
||||
)
|
||||
CAMPAIGN_TYPE campaign_type;
|
||||
std::string campaign_define; /**< If there is a define the campaign uses to customize data */
|
||||
std::vector<std::string> campaign_xtra_defines; /**< more customization of data */
|
||||
|
||||
std::string campaign; /**< the campaign being played */
|
||||
|
||||
std::string abbrev; /**< the campaign abbreviation */
|
||||
// std::string scenario; /**< the scenario being played */
|
||||
// std::string next_scenario; /**< the scenario coming next (for campaigns) */
|
||||
std::string completion; /**< running. victory, or defeat */
|
||||
bool end_credits; /**< whether to show the standard credits at the end */
|
||||
std::string end_text; /**< end-of-campaign text */
|
||||
unsigned int end_text_duration; /**< for how long the end-of-campaign text is shown */
|
||||
std::string difficulty; /**< The difficulty level the game is being played on. */
|
||||
std::string random_mode;
|
||||
};
|
||||
MAKE_ENUM_STREAM_OPS2(game_classification, CAMPAIGN_TYPE)
|
||||
|
||||
#endif
|
|
@ -19,6 +19,7 @@
|
|||
#include "cursor.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "game_classification.hpp"
|
||||
#include "gui/dialogs/wml_error.hpp"
|
||||
#include "hotkey/hotkey_item.hpp"
|
||||
#include "hotkey/hotkey_command.hpp"
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
#include "commandline_options.hpp"
|
||||
#include "config_cache.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "game_display.hpp"
|
||||
#include "filesystem.hpp"
|
||||
|
||||
class config;
|
||||
class game_classification;
|
||||
|
||||
class game_config_manager
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "../dialogs.hpp"
|
||||
#include "../fake_unit.hpp"
|
||||
#include "../fake_unit_manager.hpp"
|
||||
#include "../game_classification.hpp"
|
||||
#include "../game_display.hpp"
|
||||
#include "../game_preferences.hpp"
|
||||
#include "../gettext.hpp"
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "game_board.hpp"
|
||||
#include "game_display.hpp"
|
||||
#include "game_preferences.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "log.hpp"
|
||||
#include "map.hpp"
|
||||
|
|
|
@ -523,197 +523,3 @@ game_data* game_data::operator=(const game_data* info)
|
|||
}
|
||||
return this ;
|
||||
}
|
||||
|
||||
game_classification::game_classification():
|
||||
savegame_config(),
|
||||
label(),
|
||||
version(),
|
||||
campaign_type(),
|
||||
campaign_define(),
|
||||
campaign_xtra_defines(),
|
||||
campaign(),
|
||||
abbrev(),
|
||||
completion(),
|
||||
end_credits(true),
|
||||
end_text(),
|
||||
end_text_duration(),
|
||||
difficulty(DEFAULT_DIFFICULTY),
|
||||
random_mode("")
|
||||
{}
|
||||
|
||||
game_classification::game_classification(const config& cfg):
|
||||
savegame_config(),
|
||||
label(cfg["label"]),
|
||||
version(cfg["version"]),
|
||||
campaign_type(lexical_cast_default<game_classification::CAMPAIGN_TYPE> (cfg["campaign_type"].str(), game_classification::SCENARIO)),
|
||||
campaign_define(cfg["campaign_define"]),
|
||||
campaign_xtra_defines(utils::split(cfg["campaign_extra_defines"])),
|
||||
campaign(cfg["campaign"]),
|
||||
abbrev(cfg["abbrev"]),
|
||||
completion(cfg["completion"]),
|
||||
end_credits(cfg["end_credits"].to_bool(true)),
|
||||
end_text(cfg["end_text"]),
|
||||
end_text_duration(cfg["end_text_duration"]),
|
||||
difficulty(cfg["difficulty"].empty() ? DEFAULT_DIFFICULTY : cfg["difficulty"].str()),
|
||||
random_mode(cfg["random_mode"])
|
||||
{}
|
||||
|
||||
game_classification::game_classification(const game_classification& gc):
|
||||
savegame_config(),
|
||||
label(gc.label),
|
||||
version(gc.version),
|
||||
campaign_type(gc.campaign_type),
|
||||
campaign_define(gc.campaign_define),
|
||||
campaign_xtra_defines(gc.campaign_xtra_defines),
|
||||
campaign(gc.campaign),
|
||||
abbrev(gc.abbrev),
|
||||
completion(gc.completion),
|
||||
end_credits(gc.end_credits),
|
||||
end_text(gc.end_text),
|
||||
end_text_duration(gc.end_text_duration),
|
||||
difficulty(gc.difficulty),
|
||||
random_mode(gc.random_mode)
|
||||
{
|
||||
}
|
||||
|
||||
config game_classification::to_config() const
|
||||
{
|
||||
config cfg;
|
||||
|
||||
cfg["label"] = label;
|
||||
cfg["version"] = game_config::version;
|
||||
cfg["campaign_type"] = lexical_cast<std::string> (campaign_type);
|
||||
cfg["campaign_define"] = campaign_define;
|
||||
cfg["campaign_extra_defines"] = utils::join(campaign_xtra_defines);
|
||||
cfg["campaign"] = campaign;
|
||||
cfg["abbrev"] = abbrev;
|
||||
cfg["completion"] = completion;
|
||||
cfg["end_credits"] = end_credits;
|
||||
cfg["end_text"] = end_text;
|
||||
cfg["end_text_duration"] = str_cast<unsigned int>(end_text_duration);
|
||||
cfg["difficulty"] = difficulty;
|
||||
cfg["random_mode"] = random_mode;
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
void convert_old_saves(config& cfg){
|
||||
if(!cfg.has_child("snapshot")){
|
||||
return;
|
||||
}
|
||||
|
||||
const config& snapshot = cfg.child("snapshot");
|
||||
const config& replay_start = cfg.child("replay_start");
|
||||
const config& replay = cfg.child("replay");
|
||||
|
||||
if(!cfg.has_child("carryover_sides") && !cfg.has_child("carryover_sides_start")){
|
||||
config carryover;
|
||||
//copy rng and menu items from toplevel to new carryover_sides
|
||||
carryover["random_seed"] = cfg["random_seed"];
|
||||
carryover["random_calls"] = cfg["random_calls"];
|
||||
BOOST_FOREACH(const config& menu_item, cfg.child_range("menu_item")){
|
||||
carryover.add_child("menu_item", menu_item);
|
||||
}
|
||||
carryover["difficulty"] = cfg["difficulty"];
|
||||
carryover["random_mode"] = cfg["random_mode"];
|
||||
//the scenario to be played is always stored as next_scenario in carryover_sides_start
|
||||
carryover["next_scenario"] = cfg["scenario"];
|
||||
|
||||
config carryover_start = carryover;
|
||||
|
||||
//copy sides from either snapshot or replay_start to new carryover_sides
|
||||
if(!snapshot.empty()){
|
||||
BOOST_FOREACH(const config& side, snapshot.child_range("side")){
|
||||
carryover.add_child("side", side);
|
||||
}
|
||||
//for compatibility with old savegames that use player instead of side
|
||||
BOOST_FOREACH(const config& side, snapshot.child_range("player")){
|
||||
carryover.add_child("side", side);
|
||||
}
|
||||
//save the sides from replay_start in carryover_sides_start
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("side")){
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
//for compatibility with old savegames that use player instead of side
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("player")){
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
} else if (!replay_start.empty()){
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("side")){
|
||||
carryover.add_child("side", side);
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
//for compatibility with old savegames that use player instead of side
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("player")){
|
||||
carryover.add_child("side", side);
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
}
|
||||
|
||||
//get variables according to old hierarchy and copy them to new carryover_sides
|
||||
if(!snapshot.empty()){
|
||||
if(const config& variables = snapshot.child("variables")){
|
||||
carryover.add_child("variables", variables);
|
||||
carryover_start.add_child("variables", replay_start.child_or_empty("variables"));
|
||||
} else if (const config& variables = cfg.child("variables")){
|
||||
carryover.add_child("variables", variables);
|
||||
carryover_start.add_child("variables", variables);
|
||||
}
|
||||
} else if (!replay_start.empty()){
|
||||
if(const config& variables = replay_start.child("variables")){
|
||||
carryover.add_child("variables", variables);
|
||||
carryover_start.add_child("variables", variables);
|
||||
}
|
||||
} else {
|
||||
carryover.add_child("variables", cfg.child("variables"));
|
||||
carryover_start.add_child("variables", cfg.child("variables"));
|
||||
}
|
||||
|
||||
cfg.add_child("carryover_sides", carryover);
|
||||
cfg.add_child("carryover_sides_start", carryover_start);
|
||||
}
|
||||
|
||||
//if replay and snapshot are empty we've got a start of scenario save and don't want replay_start either
|
||||
if(replay.empty() && snapshot.empty()){
|
||||
LOG_RG<<"removing replay_start \n";
|
||||
cfg.remove_child("replay_start", 0);
|
||||
}
|
||||
|
||||
//remove empty replay or snapshot so type of save can be detected more easily
|
||||
if(replay.empty()){
|
||||
LOG_RG<<"removing replay \n";
|
||||
cfg.remove_child("replay", 0);
|
||||
}
|
||||
|
||||
if(snapshot.empty()){
|
||||
LOG_RG<<"removing snapshot \n";
|
||||
cfg.remove_child("snapshot", 0);
|
||||
}
|
||||
//?-1.11.? end
|
||||
//1.12-1.13 begin
|
||||
|
||||
if(config& carryover_sides_start = cfg.child("carryover_sides_start"))
|
||||
{
|
||||
if(!carryover_sides_start.has_attribute("next_underlying_unit_id"))
|
||||
{
|
||||
carryover_sides_start["next_underlying_unit_id"] = cfg["next_underlying_unit_id"];
|
||||
}
|
||||
}
|
||||
|
||||
if(config& snapshot = cfg.child("snapshot"))
|
||||
{
|
||||
//make [end_level] -> [end_level_data] since its alo called [end_level_data] in the carryover.
|
||||
if(config& end_level = cfg.child("end_level") )
|
||||
{
|
||||
snapshot.add_child("end_level_data", end_level);
|
||||
snapshot.remove_child("end_level",0);
|
||||
}
|
||||
if(cfg.has_child("carryover_sides_start"))
|
||||
{
|
||||
cfg.remove_child("carryover_sides_start", 0);
|
||||
}
|
||||
}
|
||||
|
||||
//1.12-1.13 end
|
||||
LOG_RG<<"cfg after conversion "<<cfg<<"\n";
|
||||
}
|
||||
|
|
|
@ -20,9 +20,7 @@
|
|||
#include "config.hpp"
|
||||
#include "game_end_exceptions.hpp"
|
||||
#include "game_events/wmi_container.hpp"
|
||||
#include "make_enum.hpp"
|
||||
#include "map_location.hpp"
|
||||
#include "mp_game_settings.hpp"
|
||||
#include "simple_rng.hpp"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
@ -35,24 +33,13 @@ class t_string;
|
|||
class team;
|
||||
class unit_map;
|
||||
|
||||
// Defined later in this header:
|
||||
class game_data;
|
||||
|
||||
void convert_old_saves(config& cfg);
|
||||
|
||||
namespace t_translation {
|
||||
struct t_match;
|
||||
}
|
||||
|
||||
extern int sdfasf;
|
||||
class team_builder;
|
||||
typedef boost::shared_ptr<team_builder> team_builder_ptr;
|
||||
|
||||
|
||||
/// The default difficulty setting for campaigns.
|
||||
extern const std::string DEFAULT_DIFFICULTY;
|
||||
|
||||
|
||||
|
||||
class game_data : public variable_set {
|
||||
public:
|
||||
game_data();
|
||||
|
@ -127,40 +114,4 @@ private:
|
|||
std::string next_scenario_; /**< the scenario coming next (for campaigns) */
|
||||
};
|
||||
|
||||
//meta information of the game
|
||||
class game_classification : public savegame::savegame_config
|
||||
{
|
||||
public:
|
||||
game_classification();
|
||||
explicit game_classification(const config& cfg);
|
||||
game_classification(const game_classification& gc);
|
||||
|
||||
config to_config() const;
|
||||
|
||||
std::string label; /**< Name of the game (e.g. name of save file). */
|
||||
std::string version; /**< Version game was created with. */
|
||||
MAKE_ENUM (CAMPAIGN_TYPE, /**< Type of the game - campaign, multiplayer etc. */
|
||||
(SCENARIO, "scenario")
|
||||
(MULTIPLAYER, "multiplayer")
|
||||
(TEST, "test")
|
||||
(TUTORIAL, "tutorial")
|
||||
)
|
||||
CAMPAIGN_TYPE campaign_type;
|
||||
std::string campaign_define; /**< If there is a define the campaign uses to customize data */
|
||||
std::vector<std::string> campaign_xtra_defines; /**< more customization of data */
|
||||
|
||||
std::string campaign; /**< the campaign being played */
|
||||
|
||||
std::string abbrev; /**< the campaign abbreviation */
|
||||
// std::string scenario; /**< the scenario being played */
|
||||
// std::string next_scenario; /**< the scenario coming next (for campaigns) */
|
||||
std::string completion; /**< running. victory, or defeat */
|
||||
bool end_credits; /**< whether to show the standard credits at the end */
|
||||
std::string end_text; /**< end-of-campaign text */
|
||||
unsigned int end_text_duration; /**< for how long the end-of-campaign text is shown */
|
||||
std::string difficulty; /**< The difficulty level the game is being played on. */
|
||||
std::string random_mode;
|
||||
};
|
||||
MAKE_ENUM_STREAM_OPS2(game_classification, CAMPAIGN_TYPE)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include "../../clipboard.hpp"
|
||||
#include "../../game_preferences.hpp"
|
||||
#include "../../gamestatus.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../../resources.hpp"
|
||||
#include "../../team.hpp"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "gettext.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "game_preferences.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "game_classification.hpp"
|
||||
#include "gui/auxiliary/log.hpp"
|
||||
#include "gui/dialogs/field.hpp"
|
||||
#include "gui/dialogs/game_delete.hpp"
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#define MULTIPLAYER_CONNECT_H_INCLUDED
|
||||
|
||||
#include "commandline_options.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "multiplayer_connect_engine.hpp"
|
||||
#include "multiplayer_ui.hpp"
|
||||
#include "widgets/combo_drag.hpp"
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "global.hpp"
|
||||
|
||||
#include "construct_dialog.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "game_display.hpp"
|
||||
#include "game_preferences.hpp"
|
||||
#include "gettext.hpp"
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#define MULTIPLAYER_WAIT_HPP_INCLUDED
|
||||
|
||||
#include "flg_manager.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "multiplayer_ui.hpp"
|
||||
#include "show_dialog.hpp"
|
||||
#include "widgets/combo.hpp"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define REPLAY_CONTROLLER_H_INCLUDED
|
||||
|
||||
#include "game_end_exceptions.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "saved_game.hpp"
|
||||
#include "play_controller.hpp"
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "serialization/binary_or_text.hpp"
|
||||
#include "serialization/parser.hpp"
|
||||
|
||||
#include "gamestatus.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "config.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
#ifndef SAVE_INDEX_H_INCLUDED
|
||||
#define SAVE_INDEX_H_INCLUDED
|
||||
|
||||
//#include "filesystem.hpp"
|
||||
//#include "gamestatus.hpp"
|
||||
//#include "tod_manager.hpp"
|
||||
//#include "show_dialog.hpp"
|
||||
#include "config.hpp"
|
||||
#include "serialization/compression.hpp"
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
*/
|
||||
|
||||
#include "saved_game.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "carryover.hpp"
|
||||
#include "cursor.hpp"
|
||||
#include "log.hpp"
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#define SAVED_GAME_HPP_INCLUDED
|
||||
|
||||
#include "config.hpp"
|
||||
#include "gamestatus.hpp" //game_classification
|
||||
#include "game_classification.hpp"
|
||||
#include "mp_game_settings.hpp"
|
||||
class config_writer;
|
||||
|
||||
|
||||
|
|
121
src/savegame.cpp
121
src/savegame.cpp
|
@ -743,5 +743,126 @@ void ingame_savegame::write_game(config_writer &out) {
|
|||
out.write_child("replay", gamestate().replay_data);
|
||||
}
|
||||
|
||||
void convert_old_saves(config& cfg){
|
||||
if(!cfg.has_child("snapshot")){
|
||||
return;
|
||||
}
|
||||
|
||||
const config& snapshot = cfg.child("snapshot");
|
||||
const config& replay_start = cfg.child("replay_start");
|
||||
const config& replay = cfg.child("replay");
|
||||
|
||||
if(!cfg.has_child("carryover_sides") && !cfg.has_child("carryover_sides_start")){
|
||||
config carryover;
|
||||
//copy rng and menu items from toplevel to new carryover_sides
|
||||
carryover["random_seed"] = cfg["random_seed"];
|
||||
carryover["random_calls"] = cfg["random_calls"];
|
||||
BOOST_FOREACH(const config& menu_item, cfg.child_range("menu_item")){
|
||||
carryover.add_child("menu_item", menu_item);
|
||||
}
|
||||
carryover["difficulty"] = cfg["difficulty"];
|
||||
carryover["random_mode"] = cfg["random_mode"];
|
||||
//the scenario to be played is always stored as next_scenario in carryover_sides_start
|
||||
carryover["next_scenario"] = cfg["scenario"];
|
||||
|
||||
config carryover_start = carryover;
|
||||
|
||||
//copy sides from either snapshot or replay_start to new carryover_sides
|
||||
if(!snapshot.empty()){
|
||||
BOOST_FOREACH(const config& side, snapshot.child_range("side")){
|
||||
carryover.add_child("side", side);
|
||||
}
|
||||
//for compatibility with old savegames that use player instead of side
|
||||
BOOST_FOREACH(const config& side, snapshot.child_range("player")){
|
||||
carryover.add_child("side", side);
|
||||
}
|
||||
//save the sides from replay_start in carryover_sides_start
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("side")){
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
//for compatibility with old savegames that use player instead of side
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("player")){
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
} else if (!replay_start.empty()){
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("side")){
|
||||
carryover.add_child("side", side);
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
//for compatibility with old savegames that use player instead of side
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("player")){
|
||||
carryover.add_child("side", side);
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
}
|
||||
|
||||
//get variables according to old hierarchy and copy them to new carryover_sides
|
||||
if(!snapshot.empty()){
|
||||
if(const config& variables = snapshot.child("variables")){
|
||||
carryover.add_child("variables", variables);
|
||||
carryover_start.add_child("variables", replay_start.child_or_empty("variables"));
|
||||
} else if (const config& variables = cfg.child("variables")){
|
||||
carryover.add_child("variables", variables);
|
||||
carryover_start.add_child("variables", variables);
|
||||
}
|
||||
} else if (!replay_start.empty()){
|
||||
if(const config& variables = replay_start.child("variables")){
|
||||
carryover.add_child("variables", variables);
|
||||
carryover_start.add_child("variables", variables);
|
||||
}
|
||||
} else {
|
||||
carryover.add_child("variables", cfg.child("variables"));
|
||||
carryover_start.add_child("variables", cfg.child("variables"));
|
||||
}
|
||||
|
||||
cfg.add_child("carryover_sides", carryover);
|
||||
cfg.add_child("carryover_sides_start", carryover_start);
|
||||
}
|
||||
|
||||
//if replay and snapshot are empty we've got a start of scenario save and don't want replay_start either
|
||||
if(replay.empty() && snapshot.empty()){
|
||||
LOG_RG<<"removing replay_start \n";
|
||||
cfg.remove_child("replay_start", 0);
|
||||
}
|
||||
|
||||
//remove empty replay or snapshot so type of save can be detected more easily
|
||||
if(replay.empty()){
|
||||
LOG_RG<<"removing replay \n";
|
||||
cfg.remove_child("replay", 0);
|
||||
}
|
||||
|
||||
if(snapshot.empty()){
|
||||
LOG_RG<<"removing snapshot \n";
|
||||
cfg.remove_child("snapshot", 0);
|
||||
}
|
||||
//?-1.11.? end
|
||||
//1.12-1.13 begin
|
||||
|
||||
if(config& carryover_sides_start = cfg.child("carryover_sides_start"))
|
||||
{
|
||||
if(!carryover_sides_start.has_attribute("next_underlying_unit_id"))
|
||||
{
|
||||
carryover_sides_start["next_underlying_unit_id"] = cfg["next_underlying_unit_id"];
|
||||
}
|
||||
}
|
||||
|
||||
if(config& snapshot = cfg.child("snapshot"))
|
||||
{
|
||||
//make [end_level] -> [end_level_data] since its alo called [end_level_data] in the carryover.
|
||||
if(config& end_level = cfg.child("end_level") )
|
||||
{
|
||||
snapshot.add_child("end_level_data", end_level);
|
||||
snapshot.remove_child("end_level",0);
|
||||
}
|
||||
if(cfg.has_child("carryover_sides_start"))
|
||||
{
|
||||
cfg.remove_child("carryover_sides_start", 0);
|
||||
}
|
||||
}
|
||||
|
||||
//1.12-1.13 end
|
||||
LOG_RG<<"cfg after conversion "<<cfg<<"\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define SAVEGAME_H_INCLUDED
|
||||
|
||||
#include "filesystem.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "saved_game.hpp"
|
||||
#include "show_dialog.hpp"
|
||||
#include "serialization/compression.hpp"
|
||||
|
@ -28,7 +27,8 @@ struct load_game_cancelled_exception {};
|
|||
struct illegal_filename_exception {};
|
||||
|
||||
namespace savegame {
|
||||
|
||||
/** converts saves from older versions of wesnoth*/
|
||||
void convert_old_saves(config& cfg);
|
||||
/** Returns true if there is already a savegame with that name. */
|
||||
bool save_game_exists(const std::string& name, compression::format compressed);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "ai/testing/stage_rca.hpp"
|
||||
#include "attack_prediction.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "game_classification.hpp"
|
||||
#include "game_display.hpp"
|
||||
#include "game_events/conditional_wml.hpp"
|
||||
#include "game_events/pump.hpp"
|
||||
|
@ -51,6 +52,7 @@
|
|||
#include "lua_jailbreak_exception.hpp"
|
||||
#include "map.hpp"
|
||||
#include "map_label.hpp"
|
||||
#include "mp_game_settings.hpp"
|
||||
#include "pathfind/pathfind.hpp"
|
||||
#include "pathfind/teleport.hpp"
|
||||
#include "play_controller.hpp"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "global.hpp"
|
||||
#include "config.hpp"
|
||||
#include "config_assign.hpp"
|
||||
#include "game_classification.hpp"
|
||||
#include "replay.hpp"
|
||||
#include "random_new.hpp"
|
||||
#include "random_new_synced.hpp"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* Manage unit-abilities, like heal, cure, and weapon_specials.
|
||||
*/
|
||||
|
||||
#include "gamestatus.hpp"
|
||||
#include "log.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "terrain_filter.hpp"
|
||||
|
|
Loading…
Add table
Reference in a new issue