Display mp::wait (temporary dummy) in between mp::scenarios.

The screen is displayed only if '--campaign-screens' command line
option was specified. The same now goes for mp::connect screen for the
game's host.

Server has been modified to not immediately start the game after
'store_next_scenario', but to wait for explicit 'start_game'.

Minor changes to parameter passing inside multiplayer.?pp have been
made as well.
This commit is contained in:
Andrius Silinskas 2013-08-08 12:00:01 +01:00
parent d94b36d58a
commit f7fa3c59b5
17 changed files with 222 additions and 121 deletions

View file

@ -68,6 +68,7 @@ commandline_options::commandline_options ( int argc, char** argv ) :
load(),
logdomains(),
multiplayer(false),
campaign_screens(false),
multiplayer_ai_config(),
multiplayer_algorithm(),
multiplayer_controller(),
@ -188,6 +189,7 @@ commandline_options::commandline_options ( int argc, char** argv ) :
po::options_description multiplayer_opts("Multiplayer options");
multiplayer_opts.add_options()
("multiplayer,m", "Starts a multiplayer game. There are additional options that can be used as explained below:")
("campaign-screens", "Shows multiplayer screens in between campaign's scenarios for additional game configuration. Experimental function.")
("ai-config", po::value<std::vector<std::string> >()->composing(), "selects a configuration file to load for this side. <arg> should have format side:value")
("algorithm", po::value<std::vector<std::string> >()->composing(), "selects a non-standard algorithm to be used by the AI controller for this side. <arg> should have format side:value")
("controller", po::value<std::vector<std::string> >()->composing(), "selects the controller for this side. <arg> should have format side:value")
@ -309,6 +311,8 @@ commandline_options::commandline_options ( int argc, char** argv ) :
max_fps = vm["max-fps"].as<int>();
if (vm.count("multiplayer"))
multiplayer = true;
if (vm.count("campaign-screens"))
campaign_screens = true;
if (vm.count("new-storyscreens"))
new_storyscreens = true;
if (vm.count("new-widgets"))

View file

@ -83,6 +83,8 @@ public:
boost::optional<std::string> logdomains;
/// True if --multiplayer was given on the command line. Goes directly into multiplayer mode.
bool multiplayer;
/// True if --campaign-screens was given on the command line. Additional game options in between campaign's scenarios.
bool campaign_screens;
/// Non-empty if --ai-config was given on the command line. Vector of pairs (side number, value). Dependent on --multiplayer.
boost::optional<std::vector<boost::tuple<unsigned int, std::string> > > multiplayer_ai_config;
/// Non-empty if --algorithm was given on the command line. Vector of pairs (side number, value). Dependent on --multiplayer.

View file

@ -60,7 +60,7 @@ namespace game_config
std::string wesnoth_program_dir;
bool debug = false, debug_lua = false, editor = false,
ignore_replay_errors = false, mp_debug = false, exit_at_end = false,
no_delay = false, disable_autosave = false;
no_delay = false, disable_autosave = false, campaign_screens = false;
int cache_compression_level = 6;

View file

@ -53,7 +53,7 @@ namespace game_config
extern const int gold_carryover_percentage;
extern bool debug, debug_lua, editor, ignore_replay_errors, mp_debug,
exit_at_end, no_delay, disable_autosave;
exit_at_end, no_delay, disable_autosave, campaign_screens;
extern int cache_compression_level;

View file

@ -129,6 +129,9 @@ game_controller::game_controller(const commandline_options& cmdline_opts, const
std::cerr << "selected scenario id: [" << jump_to_campaign_.scenario_id_ << "]\n";
}
}
if (cmdline_opts_.campaign_screens) {
game_config::campaign_screens = true;
}
if (cmdline_opts_.clock)
gui2::show_debug_clock_button = true;
if (cmdline_opts_.debug) {
@ -845,13 +848,8 @@ bool game_controller::play_multiplayer()
cursor::set(cursor::NORMAL);
if(res == 3) {
config game_data;
const mp::controller cntr = mp::CNTR_LOCAL;
mp::start_local_game(disp(),
resources::config_manager->game_config(), cntr);
resources::config_manager->game_config());
} else if((res >= 0 && res <= 2) || res == 4) {
std::string host;
if(res == 0) {
@ -917,11 +915,8 @@ bool game_controller::play_multiplayer_commandline()
events::discard_input(); // prevent the "keylogger" effect
cursor::set(cursor::NORMAL);
config game_data;
const mp::controller cntr = mp::CNTR_LOCAL;
mp::start_local_game_commandline(disp(),
resources::config_manager->game_config(), cntr, cmdline_opts_);
resources::config_manager->game_config(), cmdline_opts_);
return false;
}

View file

@ -460,7 +460,7 @@ static void enter_wait_mode(game_display& disp, const config& game_config, mp::c
switch (res) {
case mp::ui::PLAY:
play_game(disp, state, game_config, IO_CLIENT,
preferences::skip_mp_replay() && observe, false);
preferences::skip_mp_replay() && observe, true);
recorder.clear();
break;
@ -470,11 +470,12 @@ static void enter_wait_mode(game_display& disp, const config& game_config, mp::c
}
}
static void enter_create_mode(game_display& disp, const config& game_config, mp::chat& chat, config& gamelist, mp::controller default_controller, bool local_players_only = false);
static void enter_create_mode(game_display& disp, const config& game_config,
mp::chat& chat, config& gamelist, bool local_players_only = false);
static bool enter_connect_mode(game_display& disp, const config& game_config,
mp::chat& chat, config& gamelist, const mp_game_settings& params,
mp::controller default_controller, bool local_players_only = false)
bool local_players_only = false)
{
DBG_MP << "entering connect mode" << std::endl;
@ -487,7 +488,8 @@ static bool enter_connect_mode(game_display& disp, const config& game_config,
statistics::fresh_stats();
{
mp::connect ui(disp, game_config, chat, gamelist, params, default_controller, local_players_only);
mp::connect ui(disp, game_config, chat, gamelist, params,
local_players_only, true);
run_lobby_loop(disp, ui);
res = ui.get_result();
@ -503,12 +505,13 @@ static bool enter_connect_mode(game_display& disp, const config& game_config,
switch (res) {
case mp::ui::PLAY:
play_game(disp, state, game_config, IO_SERVER, false,
default_controller == mp::CNTR_LOCAL);
!local_players_only);
recorder.clear();
break;
case mp::ui::CREATE:
enter_create_mode(disp, game_config, chat, gamelist, default_controller, local_players_only);
enter_create_mode(disp, game_config, chat, gamelist,
local_players_only);
break;
case mp::ui::QUIT:
default:
@ -521,9 +524,10 @@ static bool enter_connect_mode(game_display& disp, const config& game_config,
static bool enter_configure_mode(game_display& disp, const config& game_config,
mp::chat& chat, config& gamelist, const mp_game_settings& params,
mp::controller default_controller, bool local_players_only = false);
bool local_players_only = false);
static void enter_create_mode(game_display& disp, const config& game_config, mp::chat& chat, config& gamelist, mp::controller default_controller, bool local_players_only)
static void enter_create_mode(game_display& disp, const config& game_config,
mp::chat& chat, config& gamelist, bool local_players_only)
{
DBG_MP << "entering create mode" << std::endl;
@ -556,13 +560,11 @@ static void enter_create_mode(game_display& disp, const config& game_config, mp:
switch (res) {
case mp::ui::CREATE:
configure_canceled = !enter_configure_mode(disp, game_config,
chat, gamelist, new_params, default_controller,
local_players_only);
chat, gamelist, new_params, local_players_only);
break;
case mp::ui::LOAD_GAME:
connect_canceled = !enter_connect_mode(disp, game_config, chat,
gamelist, new_params, default_controller,
local_players_only);
gamelist, new_params, local_players_only);
break;
case mp::ui::QUIT:
default:
@ -576,7 +578,7 @@ static void enter_create_mode(game_display& disp, const config& game_config, mp:
static bool enter_configure_mode(game_display& disp, const config& game_config,
mp::chat& chat, config& gamelist, const mp_game_settings& params,
mp::controller default_controller, bool local_players_only)
bool local_players_only)
{
DBG_MP << "entering configure mode" << std::endl;
@ -598,7 +600,7 @@ static bool enter_configure_mode(game_display& disp, const config& game_config,
switch (res) {
case mp::ui::CREATE:
connect_canceled = !enter_connect_mode(disp, game_config, chat,
gamelist, new_params, default_controller, local_players_only);
gamelist, new_params, local_players_only);
break;
case mp::ui::QUIT:
default:
@ -712,7 +714,7 @@ static void enter_lobby_mode(game_display& disp, const config& game_config, mp::
break;
case mp::ui::CREATE:
try {
enter_create_mode(disp, game_config, chat, gamelist, mp::CNTR_NETWORK);
enter_create_mode(disp, game_config, chat, gamelist, false);
} catch(config::error& error) {
if (!error.message.empty())
gui2::show_error_message(disp.video(), error.message);
@ -737,8 +739,7 @@ static void enter_lobby_mode(game_display& disp, const config& game_config, mp::
namespace mp {
void start_local_game(game_display& disp, const config& game_config,
mp::controller default_controller)
void start_local_game(game_display& disp, const config& game_config)
{
DBG_MP << "starting local game" << std::endl;
const rand_rng::set_random_generator generator_setter(&recorder);
@ -746,11 +747,11 @@ void start_local_game(game_display& disp, const config& game_config,
config gamelist;
playmp_controller::set_replay_last_turn(0);
preferences::set_message_private(false);
enter_create_mode(disp, game_config, chat, gamelist, default_controller, true);
enter_create_mode(disp, game_config, chat, gamelist, true);
}
void start_local_game_commandline(game_display& disp, const config& game_config,
mp::controller default_controller, const commandline_options& cmdline_opts)
const commandline_options& cmdline_opts)
{
DBG_MP << "starting local MP game from commandline" << std::endl;
@ -859,7 +860,8 @@ void start_local_game_commandline(game_display& disp, const config& game_config,
statistics::fresh_stats();
{
mp::connect ui(disp, game_config, chat, gamelist, parameters, default_controller, true);
mp::connect ui(disp, game_config, chat, gamelist, parameters, true,
true);
// Update the parameters to reflect game start conditions
ui.start_game_commandline(cmdline_opts);
@ -870,8 +872,7 @@ void start_local_game_commandline(game_display& disp, const config& game_config,
if (cmdline_opts.multiplayer_label) label = *cmdline_opts.multiplayer_label;
recorder.add_log_data("ai_log","ai_label",label);
play_game(disp, state, game_config, IO_SERVER, false,
default_controller == CNTR_LOCAL);
play_game(disp, state, game_config, IO_SERVER, false, false);
recorder.clear();
}
@ -901,19 +902,17 @@ void start_client(game_display& disp, const config& game_config,
}
game_state goto_mp_connect(game_display& disp, const config& game_config,
const mp_game_settings& params)
const mp_game_settings& params, bool network_game)
{
mp::ui::result res;
game_state state;
const network::manager net_manager(1,1);
network_game_manager m;
mp::chat chat;
config gamelist;
{
mp::connect ui(disp, game_config, chat, gamelist, params, CNTR_LOCAL,
true);
mp::connect ui(disp, game_config, chat, gamelist, params, !network_game,
false);
run_lobby_loop(disp, ui);
res = ui.get_result();
@ -934,5 +933,37 @@ game_state goto_mp_connect(game_display& disp, const config& game_config,
return state;
}
game_state goto_mp_wait(game_display& disp, const config& game_config)
{
mp::ui::result res;
game_state state;
mp::chat chat;
config gamelist;
{
mp::wait ui(disp, game_config, chat, gamelist, false);
ui.join_game(false);
run_lobby_loop(disp, ui);
res = ui.get_result();
if (res == mp::ui::PLAY) {
ui.start_game();
state = ui.get_state();
}
}
switch (res) {
case mp::ui::PLAY:
case mp::ui::CREATE:
case mp::ui::QUIT:
default:
break;
}
return state;
}
} // end namespace mp

View file

@ -34,10 +34,8 @@ const size_t max_login_size = 20;
*
* @param disp The global display
* @param game_config The global, top-level WML configuration for the game
* @param default_controller The default controller type
*/
void start_local_game(game_display& disp, const config& game_config,
mp::controller default_controller);
void start_local_game(game_display& disp, const config& game_config);
/** Starts a multiplayer game in single-user mode.
*
@ -45,7 +43,7 @@ void start_local_game(game_display& disp, const config& game_config,
* cmdline_opts The commandline options
*/
void start_local_game_commandline(game_display& disp, const config& game_config,
mp::controller default_controller, const commandline_options& cmdline_opts);
const commandline_options& cmdline_opts);
/** Starts a multiplayer game in client mode.
*
@ -57,7 +55,9 @@ void start_client(game_display& disp, const config& game_config,
const std::string& host);
game_state goto_mp_connect(game_display& disp, const config& game_config,
const mp_game_settings& params);
const mp_game_settings& params, bool network_game);
game_state goto_mp_wait(game_display& disp, const config& game_config);
}
#endif

View file

@ -165,7 +165,7 @@ void connect::side::process_event()
const int cntr_last =
(engine_->save_id().empty() ? CNTR_LAST-1 : CNTR_LAST) -
(parent_->local_only_ ? 1 : 0);
(parent_->engine_.local_players_only() ? 1 : 0);
if (combo_controller_->selected() == cntr_last) {
update_controller_ui();
} else if (combo_controller_->selected() < cntr_last) {
@ -173,7 +173,7 @@ void connect::side::process_event()
// is not allowed for combo_controller_.
engine_->
set_mp_controller(mp::controller(combo_controller_->selected() +
(parent_->local_only_ ? 1 : 0)));
(parent_->engine_.local_players_only() ? 1 : 0)));
engine_->set_player_id("");
engine_->set_ready_for_start(false);
changed_ = true;
@ -442,7 +442,7 @@ void connect::side::update_controller_ui()
{
if (engine_->player_id().empty()) {
combo_controller_->set_selected(
engine_->mp_controller() - (parent_->local_only_ ? 1 : 0));
engine_->mp_controller() - (parent_->engine_.local_players_only() ? 1 : 0));
} else {
connected_user_list::iterator player =
parent_->engine_.find_player_by_id(engine_->player_id());
@ -452,9 +452,9 @@ void connect::side::update_controller_ui()
combo_controller_->set_selected(
CNTR_LAST + no_reserve + 1 +
(player - parent_->engine_.users().begin()) -
(parent_->local_only_ ? 1 : 0));
(parent_->engine_.local_players_only() ? 1 : 0));
} else {
assert(parent_->local_only_ != true);
assert(parent_->engine_.local_players_only() != true);
combo_controller_->set_selected(CNTR_NETWORK);
}
}
@ -479,16 +479,15 @@ std::string connect::side::get_RC_suffix(
connect::connect(game_display& disp, const config& game_config,
chat& c, config& gamelist, const mp_game_settings& params,
mp::controller default_controller, bool local_players_only) :
bool local_players_only, bool first_scenario) :
mp::ui(disp, _("Game Lobby: ") + params.name, game_config, c, gamelist),
local_only_(local_players_only),
params_(params),
player_types_(),
player_teams_(),
player_colors_(),
ai_algorithms_(),
sides_(),
engine_(disp, default_controller, params),
engine_(disp, params, local_players_only, first_scenario),
waiting_label_(video(), "", font::SIZE_SMALL, font::LOBBY_COLOR),
type_title_label_(video(), _("Player/Type"), font::SIZE_SMALL,
font::LOBBY_COLOR),
@ -529,14 +528,16 @@ connect::connect(game_display& disp, const config& game_config,
_("The scenario is invalid because it has no sides."));
}
// Send Initial information
config response;
config& create_game = response.add_child("create_game");
create_game["name"] = params.name;
if (params.password.empty() == false) {
response["password"] = params.password;
if (first_scenario) {
// Send Initial information
config response;
config& create_game = response.add_child("create_game");
create_game["name"] = params.name;
if (params.password.empty() == false) {
response["password"] = params.password;
}
network::send_data(response, 0);
}
network::send_data(response, 0);
update_user_combos();
@ -550,7 +551,13 @@ connect::connect(game_display& disp, const config& game_config,
update_playerlist_state(true);
// If we are connected, send data to the connected host.
network::send_data(engine_.level(), 0);
if (first_scenario) {
network::send_data(engine_.level(), 0);
} else {
config next_level;
next_level.add_child("store_next_scenario", engine_.level());
network::send_data(next_level, 0);
}
}
connect::~connect()
@ -744,7 +751,7 @@ bool connect::accept_connections()
void connect::lists_init()
{
// Options.
if (!local_only_) {
if (!engine_.local_players_only()) {
player_types_.push_back(_("Network Player"));
}
player_types_.push_back(_("Local Player"));

View file

@ -100,7 +100,7 @@ public:
connect(game_display& disp, const config& game_config, chat& c,
config& gamelist, const mp_game_settings& params,
mp::controller default_controller, bool local_players_only = false);
bool local_players_only, bool first_scenario);
~connect();
// Returns the game state, which contains all information about the current
@ -134,8 +134,6 @@ private:
void update_playerlist_state(bool silent = true);
void update_user_combos();
bool local_only_;
const mp_game_settings params_;
// Lists used for combos.

View file

@ -63,12 +63,14 @@ const std::string attributes_to_trim[] = {
namespace mp {
connect_engine::connect_engine(game_display& disp, controller mp_controller,
const mp_game_settings& params) :
connect_engine::connect_engine(game_display& disp,
const mp_game_settings& params, const bool local_players_only,
const bool first_scenario) :
level_(),
state_(),
params_(params),
mp_controller_(mp_controller),
local_players_only_(local_players_only),
first_scenario_(first_scenario),
side_engines_(),
era_factions_(),
team_names_(),
@ -605,8 +607,8 @@ int connect_engine::process_network_error(network::error& error)
if (user->connection == error.socket) {
int side_index = find_player_side_index_by_id(user->name);
if (side_index != -1) {
side_engines_[side_index]->reset(mp_controller_);
side_engines_[side_index]->
reset((local_players_only_) ? CNTR_LOCAL : CNTR_NETWORK);
res = side_index + 1;
} else {
res = 0;
@ -633,7 +635,14 @@ int connect_engine::process_network_error(network::error& error)
void connect_engine::process_network_connection(const network::connection sock)
{
network::send_data(config("join_game"), 0);
network::send_data(level_, sock);
// If we are connected, send data to the connected host.
if (first_scenario_) {
network::send_data(level_, sock);
} else {
config next_level;
next_level.add_child("store_next_scenario", level_);
network::send_data(next_level, sock);
}
}
connected_user_list::iterator
@ -701,7 +710,8 @@ side_engine::side_engine(const config& cfg, connect_engine& parent_engine,
cfg_["controller"] = "ai";
}
if (allow_player_ && !parent_.params_.saved_game) {
mp_controller_ = parent_.mp_controller_;
mp_controller_ = (parent_.local_players_only_) ? CNTR_LOCAL :
CNTR_NETWORK;
} else {
size_t i = CNTR_NETWORK;
if (!allow_player_) {
@ -932,7 +942,7 @@ bool side_engine::ready_for_start() const
// The host and the AI are always ready.
if ((mp_controller_ == mp::CNTR_COMPUTER) ||
(mp_controller_ == mp::CNTR_EMPTY) ||
(mp_controller_== mp::CNTR_LOCAL)) {
(mp_controller_ == mp::CNTR_LOCAL)) {
return true;
}

View file

@ -45,8 +45,8 @@ typedef boost::tuple<bool, bool, bool, std::vector<int> > network_res_tuple;
class connect_engine
{
public:
connect_engine(game_display& disp, controller mp_controller,
const mp_game_settings& params);
connect_engine(game_display& disp, const mp_game_settings& params,
const bool local_players_only, const bool first_scenario);
~connect_engine();
config* current_config();
@ -87,8 +87,8 @@ public:
const config& level() const { return level_; }
const game_state& state() const { return state_; }
bool local_players_only() const { return local_players_only_; }
connected_user_list& users() { return users_; }
controller mp_controller() const { return mp_controller_; }
std::vector<std::string>& team_names() { return team_names_; }
std::vector<std::string>& user_team_names() { return user_team_names_; }
@ -109,7 +109,9 @@ private:
game_state state_;
const mp_game_settings& params_;
controller mp_controller_;
const bool local_players_only_;
const bool first_scenario_;
std::vector<side_engine_ptr> side_engines_;
std::vector<const config*> era_factions_;

View file

@ -175,13 +175,14 @@ handler_vector wait::leader_preview_pane::handler_members() {
wait::wait(game_display& disp, const config& cfg,
mp::chat& c, config& gamelist) :
mp::chat& c, config& gamelist, const bool first_scenario) :
ui(disp, _("Game Lobby"), cfg, c, gamelist),
cancel_button_(disp.video(), _("Cancel")),
start_label_(disp.video(), _("Waiting for game to start..."), font::SIZE_SMALL, font::LOBBY_COLOR),
game_menu_(disp.video(), std::vector<std::string>(), false, -1, -1, NULL, &gui::menu::bluebg_style),
level_(),
state_(),
first_scenario_(first_scenario),
stop_updates_(false)
{
game_menu_.set_numeric_keypress_selection(false);
@ -199,18 +200,12 @@ void wait::join_game(bool observe)
//if we have got valid side data
//the first condition is to make sure that we don't have another
//WML message with a side-tag in it
while (!level_.has_attribute("version") || !level_.child("side")) {
network::connection data_res = dialogs::network_receive_dialog(disp(),
_("Getting game data..."), level_);
if (!data_res) {
set_result(QUIT);
return;
}
check_response(data_res, level_);
if(level_.child("leave_game")) {
set_result(QUIT);
return;
}
if (!download_level_data()) {
set_result(QUIT);
return;
} else if (!first_scenario_) {
config cfg = level_.child("next_scenario");
level_ = cfg;
}
// Add the map name to the title.
@ -424,8 +419,12 @@ void wait::process_network_data(const config& data, const network::connection so
/** @todo We should catch config::error and then leave the game. */
level_.apply_diff(c);
generate_menu();
} else if(data.child("side")) {
level_ = data;
} else if(data.child("side") || data.child("next_scenario")) {
if (first_scenario_) {
level_ = data;
} else {
level_ = data.child("next_scenario");
}
LOG_NW << "got some sides. Current number of sides = "
<< level_.child_count("side") << ','
<< data.child_count("side") << '\n';
@ -552,5 +551,37 @@ void wait::generate_menu()
}
}
bool wait::download_level_data()
{
if (!first_scenario_) {
// Ask for the next scenario data.
network::send_data(config("load_next_scenario"), 0);
}
while (!has_level_data()) {
network::connection data_res = dialogs::network_receive_dialog(
disp(), _("Getting game data..."), level_);
if (!data_res) {
return false;
}
check_response(data_res, level_);
if (level_.child("leave_game")) {
return false;
}
}
return true;
}
bool wait::has_level_data()
{
if (first_scenario_) {
return level_.has_attribute("version") && level_.child("side");
} else {
return level_.child("next_scenario");
}
}
} // namespace mp

View file

@ -27,7 +27,8 @@ namespace mp {
class wait : public ui
{
public:
wait(game_display& disp, const config& cfg, chat& c, config& gamelist);
wait(game_display& disp, const config& cfg, chat& c, config& gamelist,
const bool first_scenario = true);
virtual void process_event();
void join_game(bool observe);
@ -68,6 +69,9 @@ private:
void generate_menu();
bool download_level_data();
bool has_level_data();
gui::button cancel_button_;
gui::label start_label_;
gui::menu game_menu_;
@ -77,6 +81,7 @@ private:
config level_;
game_state state_;
const bool first_scenario_;
bool stop_updates_;
};

View file

@ -352,7 +352,7 @@ static LEVEL_RESULT playmp_scenario(const config& game_config,
LEVEL_RESULT play_game(game_display& disp, game_state& gamestate,
const config& game_config, io_type_t io_type, bool skip_replay,
bool local_mp_game)
bool network_game)
{
std::string type = gamestate.classification().campaign_type;
if(type.empty())
@ -577,29 +577,47 @@ LEVEL_RESULT play_game(game_display& disp, game_state& gamestate,
return res;
}
// Ask for the next scenario data.
network::send_data(config("load_next_scenario"), 0);
config cfg;
std::string msg = _("Downloading next scenario...");
do {
cfg.clear();
network::connection data_res = dialogs::network_receive_dialog(disp,
msg, cfg);
if(!data_res) {
gamestate.snapshot = config();
return QUIT;
}
} while (!cfg.child("next_scenario"));
if (game_config::campaign_screens) {
config old_carryover_sides_start =
gamestate.carryover_sides_start;
gamestate.mp_settings().scenario_data = *scenario;
if (const config &c = cfg.child("next_scenario")) {
starting_pos = c;
// Opens mp::connect dialog to get a new gamestate.
// Old carryover data is preserved.
gamestate = mp::goto_mp_wait(disp, game_config);
gamestate.carryover_sides_start.merge_with(
old_carryover_sides_start);
starting_pos.merge_with(gamestate.replay_start());
scenario = &starting_pos;
gamestate = game_state(starting_pos);
//retain carryover_sides_start, as the config from the server doesn't contain it
gamestate.carryover_sides_start = sides.to_config();
} else {
gamestate.snapshot = config();
return QUIT;
// Ask for the next scenario data.
network::send_data(config("load_next_scenario"), 0);
config cfg;
std::string msg = _("Downloading next scenario...");
do {
cfg.clear();
network::connection data_res = dialogs::network_receive_dialog(disp,
msg, cfg);
if(!data_res) {
gamestate.snapshot = config();
return QUIT;
}
} while (!cfg.child("next_scenario"));
if (const config &c = cfg.child("next_scenario")) {
starting_pos = c;
scenario = &starting_pos;
gamestate = game_state(starting_pos);
//retain carryover_sides_start, as the config from the server doesn't contain it
gamestate.carryover_sides_start = sides.to_config();
} else {
gamestate.snapshot = config();
return QUIT;
}
}
} else {
scenario = &game_config.find_child(type, "id", gamestate.carryover_sides_start["next_scenario"]);
@ -612,14 +630,15 @@ LEVEL_RESULT play_game(game_display& disp, game_state& gamestate,
}
if(io_type == IO_SERVER && scenario != NULL) {
if (local_mp_game && game_config::debug) {
if (game_config::campaign_screens) {
config old_carryover_sides_start =
gamestate.carryover_sides_start;
gamestate.mp_settings().scenario_data = *scenario;
// Opens mp::connect dialog to get a new gamestate.
// Old carryover data is preserved.
gamestate = mp::goto_mp_connect(disp, game_config, gamestate.mp_settings());
gamestate = mp::goto_mp_connect(disp, game_config,
gamestate.mp_settings(), network_game);
gamestate.carryover_sides_start.merge_with(
old_carryover_sides_start);
@ -672,6 +691,7 @@ LEVEL_RESULT play_game(game_display& disp, game_state& gamestate,
// Send next scenario data.
network::send_data(mp::next_level_config(*scenario, gamestate),
0);
network::send_data(config("start_game"), 0);
}
}

View file

@ -35,8 +35,7 @@ LEVEL_RESULT play_game(game_display& disp, game_state& state,
const config& game_config,
io_type_t io_type=IO_NONE,
bool skip_replay = false,
bool local_mp_game = true);
bool network_game = false);
void play_replay(display& disp, game_state& state,
const config& game_config, CVideo& video);

View file

@ -2521,7 +2521,6 @@ void server::process_data_game(const network::connection sock,
// Send the update of the game description to the lobby.
update_game_in_lobby(g);
g->start_game(pl);
return;
// If a player advances to the next scenario of a mp campaign. (deprecated)
///@deprecated r22619 a player advances to the next scenario of a mp campaign (notify_next_scenario)

View file

@ -31,8 +31,7 @@ class test_mp_connect : public mp::connect {
public:
test_mp_connect(game_display& disp, const config& game_config,
mp::chat& c, config& gamelist, const mp_game_settings& params) :
mp::connect(disp, game_config, c, gamelist, params, mp::CNTR_LOCAL,
true)
mp::connect(disp, game_config, c, gamelist, params, true, true)
{}
mp::connect_engine& engine() { return mp::connect::engine(); }
@ -41,9 +40,8 @@ public:
class test_mp_connect_engine : public mp::connect_engine {
public:
test_mp_connect_engine(game_display& disp, mp::controller mp_controller,
const mp_game_settings& params) :
mp::connect_engine(disp, mp_controller, params)
test_mp_connect_engine(game_display& disp, const mp_game_settings& params) :
mp::connect_engine(disp, params, true, true)
{}
std::vector<mp::side_engine_ptr>& side_engines()
@ -101,7 +99,7 @@ struct mp_connect_fixture {
static test_mp_connect_engine* create_test_mp_connect_engine()
{
test_mp_connect_engine* mp_connect_engine =
new test_mp_connect_engine(*disp, mp::CNTR_LOCAL, params);
new test_mp_connect_engine(*disp, params);
// There must be at least one team.
mp_connect_engine->team_names().push_back("1");