mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 19:10:07 +00:00
Merge pull request #177 from gfgtdf/remove_diffic
remove "difficulty_" and "random_mode_" from game_data and carryover (we already have them in the classification)
This commit is contained in:
commit
ebbf813e03
@ -250,7 +250,7 @@ bool ai_default_recruitment_stage::recruit_usage(const std::string& usage)
|
||||
//FIXME: This message should be suppressed when WML author
|
||||
//chooses the default recruitment pattern.
|
||||
const std::string warning = "At difficulty level " +
|
||||
resources::gamedata->difficulty() + ", trying to recruit a:" +
|
||||
resources::state_of_game->classification().difficulty + ", trying to recruit a:" +
|
||||
usage + " but no unit of that type (usage=) is"
|
||||
" available. Check the recruit and [ai]"
|
||||
" recruitment_pattern keys for team '" +
|
||||
|
@ -361,7 +361,7 @@ bool recruitment_phase::recruit_usage(const std::string& usage)
|
||||
//FIXME: This message should be suppressed when WML author
|
||||
//chooses the default recruitment pattern.
|
||||
const std::string warning = "At difficulty level " +
|
||||
resources::gamedata->difficulty() + ", trying to recruit a:" +
|
||||
resources::state_of_game->classification().difficulty + ", trying to recruit a:" +
|
||||
usage + " but no unit of that type (usage=) is"
|
||||
" available. Check the recruit and [ai]"
|
||||
" recruitment_pattern keys for team '" +
|
||||
|
@ -193,8 +193,6 @@ carryover_info::carryover_info(const config& cfg)
|
||||
, variables_(cfg.child_or_empty("variables"))
|
||||
, rng_(cfg)
|
||||
, wml_menu_items_()
|
||||
, difficulty_(cfg["difficulty"].empty() ? DEFAULT_DIFFICULTY : cfg["difficulty"].str())
|
||||
, random_mode_(cfg["random_mode"].str())
|
||||
, next_scenario_(cfg["next_scenario"])
|
||||
{
|
||||
end_level_.read(cfg.child_or_empty("end_level_data"));
|
||||
@ -262,8 +260,6 @@ void carryover_info::transfer_from(game_data& gamedata){
|
||||
variables_ = gamedata.get_variables();
|
||||
wml_menu_items_ = gamedata.get_wml_menu_items();
|
||||
rng_ = gamedata.rng();
|
||||
difficulty_ = gamedata.difficulty();
|
||||
random_mode_ = gamedata.random_mode();
|
||||
next_scenario_ = gamedata.next_scenario();
|
||||
}
|
||||
|
||||
@ -283,13 +279,6 @@ void carryover_info::transfer_to(config& level){
|
||||
wml_menu_items_.to_config(level);
|
||||
}
|
||||
|
||||
if(level["difficulty"].empty()){
|
||||
level["difficulty"] = difficulty_;
|
||||
}
|
||||
if(level["random_mode"].empty()){
|
||||
level["random_mode"] = random_mode_;
|
||||
}
|
||||
difficulty_ = "";
|
||||
next_scenario_ = "";
|
||||
|
||||
}
|
||||
@ -298,8 +287,6 @@ const config carryover_info::to_config()
|
||||
{
|
||||
config cfg;
|
||||
|
||||
cfg["difficulty"] = difficulty_;
|
||||
cfg["random_mode"] = random_mode_;
|
||||
cfg["next_scenario"] = next_scenario_;
|
||||
|
||||
BOOST_FOREACH(carryover& c, carryover_sides_){
|
||||
@ -624,8 +611,6 @@ game_data::game_data()
|
||||
, temporaries_()
|
||||
, phase_(INITIAL)
|
||||
, can_end_turn_(true)
|
||||
, difficulty_(DEFAULT_DIFFICULTY)
|
||||
, random_mode_("")
|
||||
, scenario_()
|
||||
, next_scenario_()
|
||||
{}
|
||||
@ -639,8 +624,6 @@ game_data::game_data(const config& level)
|
||||
, temporaries_()
|
||||
, phase_(INITIAL)
|
||||
, can_end_turn_(level["can_end_turn"].to_bool(true))
|
||||
, difficulty_(level["difficulty"].empty() ? DEFAULT_DIFFICULTY : level["difficulty"].str())
|
||||
, random_mode_(level["random_mode"].str())
|
||||
, scenario_(level["id"])
|
||||
, next_scenario_(level["next_scenario"])
|
||||
{
|
||||
@ -657,8 +640,6 @@ game_data::game_data(const game_data& data)
|
||||
, temporaries_()
|
||||
, phase_(data.phase_)
|
||||
, can_end_turn_(data.can_end_turn_)
|
||||
, difficulty_(data.difficulty_)
|
||||
, random_mode_(data.random_mode_)
|
||||
, scenario_(data.scenario_)
|
||||
, next_scenario_(data.next_scenario_)
|
||||
{}
|
||||
@ -723,8 +704,6 @@ void game_data::clear_variable(const std::string& varname)
|
||||
}
|
||||
|
||||
void game_data::write_snapshot(config& cfg){
|
||||
cfg["difficulty"] = difficulty_;
|
||||
cfg["random_mode"] = random_mode_;
|
||||
cfg["scenario"] = scenario_;
|
||||
cfg["next_scenario"] = next_scenario_;
|
||||
|
||||
@ -739,8 +718,6 @@ void game_data::write_snapshot(config& cfg){
|
||||
}
|
||||
|
||||
void game_data::write_config(config_writer& out){
|
||||
out.write_key_val("difficulty", difficulty_);
|
||||
out.write_key_val("random_mode", random_mode_);
|
||||
out.write_key_val("scenario", scenario_);
|
||||
out.write_key_val("next_scenario", next_scenario_);
|
||||
|
||||
@ -823,7 +800,7 @@ game_classification::game_classification(const config& cfg):
|
||||
end_credits(cfg["end_credits"].to_bool(true)),
|
||||
end_text(cfg["end_text"]),
|
||||
end_text_duration(cfg["end_text_duration"]),
|
||||
difficulty(cfg["difficulty"]),
|
||||
difficulty(cfg["difficulty"].empty() ? DEFAULT_DIFFICULTY : cfg["difficulty"].str()),
|
||||
random_mode(cfg["random_mode"])
|
||||
{}
|
||||
|
||||
@ -1092,13 +1069,14 @@ void extract_summary_from_config(config& cfg_save, config& cfg_summary)
|
||||
|
||||
if(cfg_save.has_child("carryover_sides_start")){
|
||||
cfg_summary["scenario"] = cfg_save.child("carryover_sides_start")["next_scenario"];
|
||||
cfg_summary["difficulty"] = cfg_save.child("carryover_sides_start")["difficulty"];
|
||||
cfg_summary["random_mode"] = cfg_save.child("carryover_sides_start")["random_mode"];
|
||||
} else {
|
||||
cfg_summary["scenario"] = cfg_save["scenario"];
|
||||
cfg_summary["difficulty"] = cfg_save["difficulty"];
|
||||
cfg_summary["random_mode"] = cfg_save["random_mode"];
|
||||
}
|
||||
|
||||
cfg_summary["difficulty"] = cfg_save["difficulty"];
|
||||
cfg_summary["random_mode"] = cfg_save["random_mode"];
|
||||
|
||||
|
||||
cfg_summary["campaign"] = cfg_save["campaign"];
|
||||
cfg_summary["version"] = cfg_save["version"];
|
||||
cfg_summary["corrupt"] = "";
|
||||
|
@ -101,8 +101,6 @@ public:
|
||||
, variables_()
|
||||
, rng_()
|
||||
, wml_menu_items_()
|
||||
, difficulty_(DEFAULT_DIFFICULTY)
|
||||
, random_mode_("")
|
||||
, next_scenario_()
|
||||
{}
|
||||
// Turns config from a loaded savegame into carryover_info
|
||||
@ -131,8 +129,6 @@ public:
|
||||
|
||||
const end_level_data& get_end_level() const;
|
||||
|
||||
const std::string& difficulty() const { return difficulty_; }
|
||||
const std::string& random_mode() const { return random_mode_; }
|
||||
const std::string& next_scenario() const { return next_scenario_; }
|
||||
|
||||
const config to_config();
|
||||
@ -142,8 +138,6 @@ private:
|
||||
config variables_;
|
||||
rand_rng::simple_rng rng_;
|
||||
game_events::wmi_container wml_menu_items_;
|
||||
std::string difficulty_; /**< The difficulty level the game is being played on. */
|
||||
std::string random_mode_; /**< whether we generate a new randomseed for each user action. */
|
||||
std::string next_scenario_; /**< the scenario coming next (for campaigns) */
|
||||
};
|
||||
|
||||
@ -203,8 +197,6 @@ public:
|
||||
void write_snapshot(config& cfg);
|
||||
void write_config(config_writer& out);
|
||||
|
||||
const std::string& difficulty() const { return difficulty_; }
|
||||
const std::string& random_mode() const { return random_mode_; }
|
||||
const std::string& next_scenario() const { return next_scenario_; }
|
||||
void set_next_scenario(const std::string& next_scenario) { next_scenario_ = next_scenario; }
|
||||
|
||||
@ -219,8 +211,6 @@ private:
|
||||
friend struct variable_info;
|
||||
PHASE phase_;
|
||||
bool can_end_turn_;
|
||||
std::string difficulty_; /**< The difficulty level the game is being played on. */
|
||||
std::string random_mode_;
|
||||
std::string scenario_; /**< the scenario being played */
|
||||
std::string next_scenario_; /**< the scenario coming next (for campaigns) */
|
||||
};
|
||||
|
@ -585,7 +585,7 @@ void play_controller::fire_start(bool execute){
|
||||
} else {
|
||||
it_is_a_new_turn_ = false;
|
||||
}
|
||||
if((gamedata_.random_mode() != "" || gamestate_.classification().random_mode != "") && (network::nconnections() != 0))
|
||||
if( gamestate_.classification().random_mode != "" && (network::nconnections() != 0))
|
||||
{
|
||||
std::string mes = _("MP game uses an alternative random mode, if you don't know what this message means, then most likeley someone is cheating or someone reloaded a corrupt game.");
|
||||
resources::screen->add_chat_message(
|
||||
|
@ -574,21 +574,22 @@ void loadgame::load_game(
|
||||
}
|
||||
|
||||
if (!difficulty_.empty()){
|
||||
if ( config & carryover = load_config_.child("carryover_sides_start") )
|
||||
carryover["difficulty"] = difficulty_;
|
||||
load_config_["difficulty"] = difficulty_;
|
||||
}
|
||||
|
||||
gamestate_.classification().campaign_define = load_config_["campaign_define"].str();
|
||||
gamestate_.classification().campaign_type = lexical_cast_default<game_classification::CAMPAIGN_TYPE> (load_config_["campaign_type"].str(), game_classification::SCENARIO);
|
||||
gamestate_.classification().campaign_xtra_defines = utils::split(load_config_["campaign_extra_defines"]);
|
||||
gamestate_.classification().version = load_config_["version"].str();
|
||||
gamestate_.classification().difficulty = load_config_["difficulty"].str();
|
||||
/*
|
||||
if (config & carryover_sides_start = load_config_.child("carryover_sides_start")) {
|
||||
std::string load_config_difficulty = carryover_sides_start["difficulty"];
|
||||
gamestate_.classification().difficulty = load_config_difficulty;
|
||||
} else {
|
||||
gamestate_.classification().difficulty = difficulty_;
|
||||
}
|
||||
|
||||
*/
|
||||
check_version_compatibility();
|
||||
|
||||
}
|
||||
|
@ -105,11 +105,14 @@ public:
|
||||
const std::string & filename() const { return filename_; }
|
||||
|
||||
std::string get_difficulty() const
|
||||
{ if ( const config & carryover = load_config_.child("carryover_sides_start") )
|
||||
{ return load_config_["difficulty"].empty() ? DEFAULT_DIFFICULTY : load_config_["difficulty"].str(); }
|
||||
/*
|
||||
{ if ( const config & carryover = load_config_.child("carryover_sides_start") )
|
||||
return carryover["difficulty"];
|
||||
else
|
||||
return DEFAULT_DIFFICULTY; }
|
||||
|
||||
return DEFAULT_DIFFICULTY;
|
||||
}
|
||||
*/
|
||||
private:
|
||||
/** Display the load-game dialog. */
|
||||
void show_dialog(bool show_replay, bool cancel_orders);
|
||||
|
@ -210,14 +210,7 @@ void synced_context::pull_remote_user_input()
|
||||
|
||||
boost::shared_ptr<random_new::rng> synced_context::get_rng_for_action()
|
||||
{
|
||||
/*
|
||||
i copied the code for "deterministic_mode" from the code for "difficulty".
|
||||
i don't know why we have this information twice, i just did it because we have the information for difficulty twice too.
|
||||
*/
|
||||
const std::string& v1 = resources::gamedata->random_mode();
|
||||
const std::string& v2 = resources::state_of_game->classification().random_mode;
|
||||
assert(v1==v2);
|
||||
const std::string& mode= v1; // = resources ... gamestate ... get_random_mode()
|
||||
const std::string& mode = resources::state_of_game->classification().random_mode;
|
||||
if(mode == "deterministic")
|
||||
{
|
||||
return boost::shared_ptr<random_new::rng>(new random_new::rng_deterministic(resources::gamedata->rng()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user