revert PR 98

This commit removes the "carryover_wml" feature which was added
just before 1.12 was branched off.

I added this feature at a time when I didn't have as good an
understanding as I do now of the networked mp code, I now believe
that it was poorly concieved and should not be implemented this
way if at all. There are better ways to achieve what was meant to
be achieved here, we are better off to remove it as it currently
exists.
This commit is contained in:
Chris Beck 2014-07-09 22:06:33 -04:00
parent 81390b1b6c
commit 61bca90f6f
4 changed files with 4 additions and 71 deletions

View file

@ -33,8 +33,6 @@ end_level_data::end_level_data()
, carryover_percentage(game_config::gold_carryover_percentage)
, carryover_add(false)
, transient()
, next_scenario_settings()
, next_scenario_append()
{
}
@ -45,13 +43,6 @@ void end_level_data::write(config& cfg) const
cfg["bonus"] = gold_bonus;
cfg["carryover_percentage"] = carryover_percentage;
cfg["carryover_add"] = carryover_add;
if (!next_scenario_settings.empty()) {
cfg.add_child("next_scenario_settings", next_scenario_settings);
}
if (!next_scenario_append.empty()) {
cfg.add_child("next_scenario_append", next_scenario_append);
}
}
void end_level_data::read(const config& cfg)
@ -61,13 +52,4 @@ void end_level_data::read(const config& cfg)
gold_bonus = cfg["bonus"].to_bool(true);
carryover_percentage = cfg["carryover_percentage"].to_int(game_config::gold_carryover_percentage);
carryover_add = cfg["carryover_add"].to_bool(false);
const config & next_scenario_settings_cfg = cfg.child_or_empty("next_scenario_settings");
if (!next_scenario_settings_cfg.empty()) {
next_scenario_settings = next_scenario_settings_cfg;
}
const config & next_scenario_append_cfg = cfg.child_or_empty("next_scenario_append");
if (!next_scenario_append_cfg.empty()) {
next_scenario_append = next_scenario_append_cfg;
}
}

View file

@ -26,7 +26,7 @@
#include <string>
#include "config.hpp"
class config;
enum LEVEL_RESULT {
NONE,
@ -108,9 +108,6 @@ struct end_level_data
bool carryover_add; /**< Add or replace next scenario's minimum starting gold. */
transient_end_level transient;
config next_scenario_settings;
config next_scenario_append;
void write(config& cfg) const;
void read(const config& cfg);

View file

@ -727,15 +727,6 @@ WML_HANDLER_FUNCTION(endlevel, /*event_info*/, cfg)
std::string next_scenario = cfg["next_scenario"];
if (!next_scenario.empty()) {
resources::gamedata->set_next_scenario(next_scenario);
const config next_scenario_settings_cfg = cfg.get_parsed_config().child_or_empty("next_scenario_settings");
if (!next_scenario_settings_cfg.empty()) {
data.next_scenario_settings = next_scenario_settings_cfg;
}
const config next_scenario_append_cfg = cfg.get_parsed_config().child_or_empty("next_scenario_append");
if (!next_scenario_append_cfg.empty()) {
data.next_scenario_append = next_scenario_append_cfg;
}
}
std::string end_of_campaign_text = cfg["end_text"];

View file

@ -70,33 +70,6 @@ static void team_init(config& level, game_state& gamestate){
}
}
static void do_carryover_WML(config & level, game_state& gamestate){
if(gamestate.snapshot.child_or_empty("variables")["turn_number"].to_int(-1)<1){
carryover_info sides(gamestate.carryover_sides_start);
end_level_data end_level_ = sides.get_end_level();
if(!end_level_.next_scenario_settings.empty()) {
level.merge_with(end_level_.next_scenario_settings);
}
if(!end_level_.next_scenario_append.empty())
{
level.append_children(end_level_.next_scenario_append);
}
}
}
static void clear_carryover_WML (game_state & gamestate) {
if (gamestate.carryover_sides.has_child("end_level_data")) {
config & eld = gamestate.carryover_sides.child("end_level_data");
eld.clear_children("next_scenario_settings");
eld.clear_children("next_scenario_append");
}
}
static void store_carryover(game_state& gamestate, playsingle_controller& playcontroller, display& disp, const end_level_data& end_level){
bool has_next_scenario = !resources::gamedata->next_scenario().empty() &&
resources::gamedata->next_scenario() != "null";
@ -262,9 +235,8 @@ static LEVEL_RESULT playsingle_scenario(const config& game_config,
int num_turns = (*level)["turns"].to_int(-1);
config init_level = *level;
do_carryover_WML(init_level, state_of_game);
team_init(init_level, state_of_game);
clear_carryover_WML(state_of_game);
LOG_NG << "creating objects... " << (SDL_GetTicks() - ticks) << "\n";
playsingle_controller playcontroller(init_level, state_of_game, ticks, num_turns, game_config, disp.video(), skip_replay);
@ -312,9 +284,8 @@ static LEVEL_RESULT playmp_scenario(const config& game_config,
int num_turns = (*level)["turns"].to_int(-1);
config init_level = *level;
do_carryover_WML(init_level, state_of_game);
team_init(init_level, state_of_game);
clear_carryover_WML(state_of_game);
playmp_controller playcontroller(init_level, state_of_game, ticks, num_turns,
game_config, disp.video(), skip_replay, blindfold_replay, io_type == IO_SERVER);
@ -604,14 +575,6 @@ LEVEL_RESULT play_game(game_display& disp, game_state& gamestate,
// mp::connect_engine.
team_init(starting_pos, gamestate);
//We don't merge WML until start of next scenario, but if we want to allow user to disable MP ui in transition,
//then we have to move "allow_new_game" attribute over now.
bool allow_new_game_flag = (*scenario)["allow_new_game"].to_bool(true);
if (gamestate.carryover_sides_start.child_or_empty("end_level_data").child_or_empty("next_scenario_settings").has_attribute("allow_new_game")) {
allow_new_game_flag = gamestate.carryover_sides_start.child_or_empty("end_level_data").child("next_scenario_settings")["allow_new_game"].to_bool();
}
params.scenario_data = *scenario;
params.scenario_data["next_underlying_unit_id"] = n_unit::id_manager::instance().get_save_id();
params.mp_scenario = (*scenario)["id"].str();
@ -625,7 +588,7 @@ LEVEL_RESULT play_game(game_display& disp, game_state& gamestate,
connect_engine(new mp::connect_engine(disp, gamestate,
params, !network_game, false));
if (allow_new_game_flag || (game_config::debug && network::nconnections() == 0)) {
if ((*scenario)["allow_new_game"].to_bool(true) || (game_config::debug && network::nconnections() == 0)) {
// Opens mp::connect dialog to allow users to
// make an adjustments for scenario.
// TODO: Fix this so that it works when network::nconnections() > 0 as well.