Made more use of mp::send_to_server
This commit is contained in:
parent
8a9265c8fc
commit
508c9406f1
4 changed files with 22 additions and 28 deletions
|
@ -18,6 +18,7 @@
|
|||
#include "ai/configuration.hpp"
|
||||
#include "formula/string_utils.hpp"
|
||||
#include "game_initialization/mp_game_utils.hpp"
|
||||
#include "game_initialization/multiplayer.hpp"
|
||||
#include "game_initialization/playcampaign.hpp"
|
||||
#include "preferences/credentials.hpp"
|
||||
#include "preferences/game.hpp"
|
||||
|
@ -324,7 +325,7 @@ void connect_engine::update_and_send_diff(bool /*update_time_of_day*/)
|
|||
if(!diff.empty()) {
|
||||
config scenario_diff;
|
||||
scenario_diff.add_child("scenario_diff", std::move(diff));
|
||||
send_to_server(scenario_diff);
|
||||
mp::send_to_server(scenario_diff);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,13 +363,6 @@ bool connect_engine::can_start_game() const
|
|||
return false;
|
||||
}
|
||||
|
||||
void connect_engine::send_to_server(const config& cfg) const
|
||||
{
|
||||
if(mp_metadata_) {
|
||||
mp_metadata_->connection.send_data(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
std::multimap<std::string, config> side_engine::get_side_children()
|
||||
{
|
||||
std::multimap<std::string, config> children;
|
||||
|
@ -460,7 +454,7 @@ void connect_engine::start_game()
|
|||
|
||||
// Make other clients not show the results of resolve_random().
|
||||
config lock("stop_updates");
|
||||
send_to_server(lock);
|
||||
mp::send_to_server(lock);
|
||||
|
||||
update_and_send_diff(true);
|
||||
|
||||
|
@ -469,7 +463,7 @@ void connect_engine::start_game()
|
|||
// Build the gamestate object after updating the level.
|
||||
mp::level_to_gamestate(level_, state_);
|
||||
|
||||
send_to_server(config("start_game"));
|
||||
mp::send_to_server(config("start_game"));
|
||||
}
|
||||
|
||||
void connect_engine::start_game_commandline(const commandline_options& cmdline_opts, const game_config_view& game_config)
|
||||
|
@ -570,14 +564,14 @@ void connect_engine::start_game_commandline(const commandline_options& cmdline_o
|
|||
|
||||
// Build the gamestate object after updating the level
|
||||
mp::level_to_gamestate(level_, state_);
|
||||
send_to_server(config("start_game"));
|
||||
mp::send_to_server(config("start_game"));
|
||||
}
|
||||
|
||||
void connect_engine::leave_game()
|
||||
{
|
||||
DBG_MP << "leaving the game" << std::endl;
|
||||
|
||||
send_to_server(config("leave_game"));
|
||||
mp::send_to_server(config("leave_game"));
|
||||
}
|
||||
|
||||
std::pair<bool, bool> connect_engine::process_network_data(const config& data)
|
||||
|
@ -617,7 +611,7 @@ std::pair<bool, bool> connect_engine::process_network_data(const config& data)
|
|||
if(name.empty()) {
|
||||
config response;
|
||||
response["failed"] = true;
|
||||
send_to_server(response);
|
||||
mp::send_to_server(response);
|
||||
|
||||
ERR_CF << "ERROR: No username provided with the side." << std::endl;
|
||||
|
||||
|
@ -632,7 +626,7 @@ std::pair<bool, bool> connect_engine::process_network_data(const config& data)
|
|||
response["failed"] = true;
|
||||
response["message"] = "The nickname '" + name +
|
||||
"' is already in use.";
|
||||
send_to_server(response);
|
||||
mp::send_to_server(response);
|
||||
|
||||
return result;
|
||||
} else {
|
||||
|
@ -640,7 +634,7 @@ std::pair<bool, bool> connect_engine::process_network_data(const config& data)
|
|||
update_side_controller_options();
|
||||
config observer_quit;
|
||||
observer_quit.add_child("observer_quit")["name"] = name;
|
||||
send_to_server(observer_quit);
|
||||
mp::send_to_server(observer_quit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -661,12 +655,12 @@ std::pair<bool, bool> connect_engine::process_network_data(const config& data)
|
|||
if(side_taken >= side_engines_.size()) {
|
||||
config response;
|
||||
response["failed"] = true;
|
||||
send_to_server(response);
|
||||
mp::send_to_server(response);
|
||||
|
||||
config res;
|
||||
config& kick = res.add_child("kick");
|
||||
kick["username"] = data["name"];
|
||||
send_to_server(res);
|
||||
mp::send_to_server(res);
|
||||
|
||||
update_and_send_diff();
|
||||
|
||||
|
@ -693,7 +687,7 @@ std::pair<bool, bool> connect_engine::process_network_data(const config& data)
|
|||
|
||||
config response;
|
||||
response["failed"] = true;
|
||||
send_to_server(response);
|
||||
mp::send_to_server(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,18 +744,18 @@ void connect_engine::send_level_data() const
|
|||
{
|
||||
// Send initial information.
|
||||
if(first_scenario_) {
|
||||
send_to_server(config {
|
||||
mp::send_to_server(config {
|
||||
"create_game", config {
|
||||
"name", params_.name,
|
||||
"password", params_.password,
|
||||
"ignored", preferences::get_ignored_delim(),
|
||||
},
|
||||
});
|
||||
send_to_server(level_);
|
||||
mp::send_to_server(level_);
|
||||
} else {
|
||||
config next_level;
|
||||
next_level.add_child("store_next_scenario", level_);
|
||||
send_to_server(next_level);
|
||||
mp::send_to_server(next_level);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,6 @@ private:
|
|||
std::vector<team_data_pod> team_data_;
|
||||
|
||||
std::set<std::string>& connected_users_rw();
|
||||
void send_to_server(const config& cfg) const;
|
||||
};
|
||||
|
||||
class side_engine
|
||||
|
|
|
@ -852,7 +852,7 @@ void mp_lobby::enter_game(const mp::game_info& game, JOIN_MODE mode)
|
|||
join_data["password"] = password;
|
||||
}
|
||||
|
||||
network_connection_.send_data(response);
|
||||
mp::send_to_server(response);
|
||||
joined_game_id_ = game.id;
|
||||
|
||||
// We're all good. Close lobby and proceed to game!
|
||||
|
@ -889,7 +889,7 @@ void mp_lobby::enter_selected_game(JOIN_MODE mode)
|
|||
|
||||
void mp_lobby::refresh_lobby()
|
||||
{
|
||||
network_connection_.send_data(config("refresh_lobby"));
|
||||
mp::send_to_server(config("refresh_lobby"));
|
||||
}
|
||||
|
||||
void mp_lobby::show_help_callback()
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "game_config.hpp"
|
||||
#include "game_config_manager.hpp"
|
||||
#include "game_initialization/mp_game_utils.hpp"
|
||||
#include "game_initialization/multiplayer.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/core/timer.hpp"
|
||||
|
@ -87,7 +88,7 @@ bool mp_join_game::fetch_game_config()
|
|||
{
|
||||
// Ask for the next scenario data, if applicable
|
||||
if(!first_scenario_) {
|
||||
network_connection_.send_data(config("load_next_scenario"));
|
||||
mp::send_to_server(config("load_next_scenario"));
|
||||
}
|
||||
|
||||
bool has_scenario_and_controllers = false;
|
||||
|
@ -324,7 +325,7 @@ bool mp_join_game::show_flg_select(int side_num, bool first_time)
|
|||
// TODO: the host cannot yet handle this and always uses the first side owned by that player.
|
||||
change["side_num"] = side_num;
|
||||
|
||||
network_connection_.send_data(faction);
|
||||
mp::send_to_server(faction);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -573,9 +574,9 @@ void mp_join_game::post_show(window& window)
|
|||
|
||||
mp::ui_alerts::game_has_begun();
|
||||
} else if(observe_game_) {
|
||||
network_connection_.send_data(config("observer_quit", config { "name", preferences::login() }));
|
||||
mp::send_to_server(config("observer_quit", config { "name", preferences::login() }));
|
||||
} else {
|
||||
network_connection_.send_data(config("leave_game"));
|
||||
mp::send_to_server(config("leave_game"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue