Rename twesnothd_connection -> wesnothd_connection
This commit is contained in:
parent
173c4aecf3
commit
e555ff9f43
30 changed files with 152 additions and 152 deletions
|
@ -350,14 +350,14 @@ bool connect_engine::can_start_game() const
|
|||
void connect_engine::send_to_server(const config& cfg) const
|
||||
{
|
||||
if (campaign_info_) {
|
||||
campaign_info_->wesnothd_connection.send_data(cfg);
|
||||
campaign_info_->connection.send_data(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
bool connect_engine::receive_from_server(config& dst) const
|
||||
{
|
||||
if (campaign_info_) {
|
||||
return campaign_info_->wesnothd_connection.receive_data(dst);
|
||||
return campaign_info_->connection.receive_data(dst);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
|
|
@ -111,7 +111,7 @@ void run_lobby_loop(CVideo& video, mp::ui& ui)
|
|||
}
|
||||
|
||||
|
||||
static std::unique_ptr<twesnothd_connection> open_connection(CVideo& video, const std::string& original_host)
|
||||
static std::unique_ptr<wesnothd_connection> open_connection(CVideo& video, const std::string& original_host)
|
||||
{
|
||||
DBG_MP << "opening connection" << std::endl;
|
||||
std::string h = original_host;
|
||||
|
@ -126,7 +126,7 @@ static std::unique_ptr<twesnothd_connection> open_connection(CVideo& video, cons
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
std::unique_ptr<twesnothd_connection> sock;
|
||||
std::unique_ptr<wesnothd_connection> sock;
|
||||
|
||||
const int colon_index = h.find_first_of(":");
|
||||
std::string host;
|
||||
|
@ -407,7 +407,7 @@ static std::unique_ptr<twesnothd_connection> open_connection(CVideo& video, cons
|
|||
// The functions enter_(screen)_mode are simple functions that take care of
|
||||
// creating the dialogs, then, according to the dialog result, of calling other
|
||||
// of those screen functions.
|
||||
static void enter_wait_mode(CVideo& video, const config& game_config, saved_game& state, twesnothd_connection* wesnothd_connection,
|
||||
static void enter_wait_mode(CVideo& video, const config& game_config, saved_game& state, wesnothd_connection* connection,
|
||||
lobby_info& li, bool observe, int current_turn = 0)
|
||||
{
|
||||
DBG_MP << "entering wait mode" << std::endl;
|
||||
|
@ -417,7 +417,7 @@ static void enter_wait_mode(CVideo& video, const config& game_config, saved_game
|
|||
gamelist.clear();
|
||||
statistics::fresh_stats();
|
||||
std::unique_ptr<mp_campaign_info> campaign_info;
|
||||
campaign_info.reset(new mp_campaign_info(*wesnothd_connection));
|
||||
campaign_info.reset(new mp_campaign_info(*connection));
|
||||
campaign_info->is_host = false;
|
||||
if(preferences::skip_mp_replay() || preferences::blindfold_replay()) {
|
||||
campaign_info->skip_replay_until_turn = current_turn;
|
||||
|
@ -427,7 +427,7 @@ static void enter_wait_mode(CVideo& video, const config& game_config, saved_game
|
|||
{
|
||||
if(preferences::new_lobby()) {
|
||||
|
||||
gui2::tmp_join_game dlg(state, li, *wesnothd_connection, true, observe);
|
||||
gui2::tmp_join_game dlg(state, li, *connection, true, observe);
|
||||
|
||||
if(!dlg.fetch_game_config(video)) {
|
||||
return;
|
||||
|
@ -441,14 +441,14 @@ static void enter_wait_mode(CVideo& video, const config& game_config, saved_game
|
|||
controller.play_game();
|
||||
}
|
||||
|
||||
if(wesnothd_connection) {
|
||||
wesnothd_connection->send_data(config("leave_game"));
|
||||
if(connection) {
|
||||
connection->send_data(config("leave_game"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mp::wait ui(video, wesnothd_connection, game_config, state, gamechat, gamelist);
|
||||
mp::wait ui(video, connection, game_config, state, gamechat, gamelist);
|
||||
|
||||
ui.join_game(observe);
|
||||
|
||||
|
@ -474,14 +474,14 @@ static void enter_wait_mode(CVideo& video, const config& game_config, saved_game
|
|||
default:
|
||||
break;
|
||||
}
|
||||
wesnothd_connection->send_data(config("leave_game"));
|
||||
connection->send_data(config("leave_game"));
|
||||
}
|
||||
|
||||
static void enter_create_mode(CVideo& video, const config& game_config, saved_game& state, twesnothd_connection* wesnothd_connection,
|
||||
static void enter_create_mode(CVideo& video, const config& game_config, saved_game& state, wesnothd_connection* connection,
|
||||
lobby_info& li, bool local_players_only = false);
|
||||
|
||||
static bool enter_connect_mode(CVideo& video, const config& game_config,
|
||||
saved_game& state, twesnothd_connection* wesnothd_connection, lobby_info& li,
|
||||
saved_game& state, wesnothd_connection* connection, lobby_info& li,
|
||||
bool local_players_only = false)
|
||||
{
|
||||
DBG_MP << "entering connect mode" << std::endl;
|
||||
|
@ -492,8 +492,8 @@ static bool enter_connect_mode(CVideo& video, const config& game_config,
|
|||
statistics::fresh_stats();
|
||||
std::unique_ptr<mp_campaign_info> campaign_info;
|
||||
if(!local_players_only) {
|
||||
assert(wesnothd_connection);
|
||||
campaign_info.reset(new mp_campaign_info(*wesnothd_connection));
|
||||
assert(connection);
|
||||
campaign_info.reset(new mp_campaign_info(*connection));
|
||||
campaign_info->connected_players.insert(preferences::login());
|
||||
campaign_info->is_host = true;
|
||||
}
|
||||
|
@ -502,7 +502,7 @@ static bool enter_connect_mode(CVideo& video, const config& game_config,
|
|||
ng::connect_engine_ptr connect_engine(new ng::connect_engine(state, true, campaign_info.get()));
|
||||
|
||||
if(preferences::new_lobby()) {
|
||||
gui2::tmp_staging dlg(*connect_engine, li, wesnothd_connection);
|
||||
gui2::tmp_staging dlg(*connect_engine, li, connection);
|
||||
dlg.show(video);
|
||||
|
||||
if(dlg.get_retval() == gui2::twindow::OK) {
|
||||
|
@ -511,14 +511,14 @@ static bool enter_connect_mode(CVideo& video, const config& game_config,
|
|||
controller.play_game();
|
||||
}
|
||||
|
||||
if(wesnothd_connection) {
|
||||
wesnothd_connection->send_data(config("leave_game"));
|
||||
if(connection) {
|
||||
connection->send_data(config("leave_game"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
mp::connect ui(video, wesnothd_connection, state.mp_settings().name, game_config, gamechat, gamelist,
|
||||
mp::connect ui(video, connection, state.mp_settings().name, game_config, gamechat, gamelist,
|
||||
*connect_engine);
|
||||
run_lobby_loop(video, ui);
|
||||
|
||||
|
@ -536,22 +536,22 @@ static bool enter_connect_mode(CVideo& video, const config& game_config,
|
|||
campaign_controller controller(video, state, game_config, game_config_manager::get()->terrain_types());
|
||||
controller.set_mp_info(campaign_info.get());
|
||||
controller.play_game();
|
||||
if (wesnothd_connection) {
|
||||
wesnothd_connection->send_data(config("leave_game"));
|
||||
if (connection) {
|
||||
connection->send_data(config("leave_game"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case mp::ui::CREATE:
|
||||
enter_create_mode(video, game_config, state, wesnothd_connection, li, local_players_only);
|
||||
if (wesnothd_connection) {
|
||||
wesnothd_connection->send_data(config("leave_game"));
|
||||
enter_create_mode(video, game_config, state, connection, li, local_players_only);
|
||||
if (connection) {
|
||||
connection->send_data(config("leave_game"));
|
||||
}
|
||||
break;
|
||||
case mp::ui::QUIT:
|
||||
default:
|
||||
if (wesnothd_connection) {
|
||||
wesnothd_connection->send_data(config("refresh_lobby"));
|
||||
wesnothd_connection->send_data(config("leave_game"));
|
||||
if (connection) {
|
||||
connection->send_data(config("refresh_lobby"));
|
||||
connection->send_data(config("leave_game"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -559,11 +559,11 @@ static bool enter_connect_mode(CVideo& video, const config& game_config,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool enter_configure_mode(CVideo& video, const config& game_config, saved_game& state, twesnothd_connection* wesnothd_connection, lobby_info& li,
|
||||
static bool enter_configure_mode(CVideo& video, const config& game_config, saved_game& state, wesnothd_connection* connection, lobby_info& li,
|
||||
bool local_players_only = false);
|
||||
|
||||
static void enter_create_mode(CVideo& video, const config& game_config,
|
||||
saved_game& state, twesnothd_connection* wesnothd_connection, lobby_info& li, bool local_players_only)
|
||||
saved_game& state, wesnothd_connection* connection, lobby_info& li, bool local_players_only)
|
||||
{
|
||||
DBG_MP << "entering create mode" << std::endl;
|
||||
|
||||
|
@ -578,9 +578,9 @@ static void enter_create_mode(CVideo& video, const config& game_config,
|
|||
dlg.show(video);
|
||||
|
||||
if(dlg.get_retval() != gui2::twindow::CANCEL) {
|
||||
enter_connect_mode(video, game_config, state, wesnothd_connection, li, local_players_only);
|
||||
} else if(wesnothd_connection) {
|
||||
wesnothd_connection->send_data(config("refresh_lobby"));
|
||||
enter_connect_mode(video, game_config, state, connection, li, local_players_only);
|
||||
} else if(connection) {
|
||||
connection->send_data(config("refresh_lobby"));
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -593,7 +593,7 @@ static void enter_create_mode(CVideo& video, const config& game_config,
|
|||
mp::ui::result res;
|
||||
|
||||
{
|
||||
mp::create ui(video, wesnothd_connection, game_config, state, gamechat, gamelist);
|
||||
mp::create ui(video, connection, game_config, state, gamechat, gamelist);
|
||||
run_lobby_loop(video, ui);
|
||||
res = ui.get_result();
|
||||
ui.get_parameters();
|
||||
|
@ -601,16 +601,16 @@ static void enter_create_mode(CVideo& video, const config& game_config,
|
|||
|
||||
switch (res) {
|
||||
case mp::ui::CREATE:
|
||||
configure_canceled = !enter_configure_mode(video, game_config, state, wesnothd_connection, li, local_players_only);
|
||||
configure_canceled = !enter_configure_mode(video, game_config, state, connection, li, local_players_only);
|
||||
break;
|
||||
case mp::ui::LOAD_GAME:
|
||||
connect_canceled = !enter_connect_mode(video, game_config, state, wesnothd_connection, li, local_players_only);
|
||||
connect_canceled = !enter_connect_mode(video, game_config, state, connection, li, local_players_only);
|
||||
break;
|
||||
case mp::ui::QUIT:
|
||||
default:
|
||||
//update lobby content
|
||||
if (wesnothd_connection) {
|
||||
wesnothd_connection->send_data(config("refresh_lobby"));
|
||||
if (connection) {
|
||||
connection->send_data(config("refresh_lobby"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ static void enter_create_mode(CVideo& video, const config& game_config,
|
|||
}
|
||||
|
||||
static bool enter_configure_mode(CVideo& video, const config& game_config,
|
||||
saved_game& state, twesnothd_connection* wesnothd_connection, lobby_info& li, bool local_players_only)
|
||||
saved_game& state, wesnothd_connection* connection, lobby_info& li, bool local_players_only)
|
||||
{
|
||||
DBG_MP << "entering configure mode" << std::endl;
|
||||
|
||||
|
@ -631,7 +631,7 @@ static bool enter_configure_mode(CVideo& video, const config& game_config,
|
|||
|
||||
{
|
||||
if (state.get_starting_pos().child("side")) {
|
||||
mp::configure ui(video, wesnothd_connection, game_config, gamechat, gamelist, state,
|
||||
mp::configure ui(video, connection, game_config, gamechat, gamelist, state,
|
||||
local_players_only);
|
||||
run_lobby_loop(video, ui);
|
||||
res = ui.get_result();
|
||||
|
@ -644,13 +644,13 @@ static bool enter_configure_mode(CVideo& video, const config& game_config,
|
|||
|
||||
switch (res) {
|
||||
case mp::ui::CREATE:
|
||||
connect_canceled = !enter_connect_mode(video, game_config, state, wesnothd_connection, li, local_players_only);
|
||||
connect_canceled = !enter_connect_mode(video, game_config, state, connection, li, local_players_only);
|
||||
break;
|
||||
case mp::ui::QUIT:
|
||||
default:
|
||||
//update lobby content
|
||||
if (wesnothd_connection) {
|
||||
wesnothd_connection->send_data(config("refresh_lobby"));
|
||||
if (connection) {
|
||||
connection->send_data(config("refresh_lobby"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -680,9 +680,9 @@ static void do_preferences_dialog(CVideo& video, const config& game_config)
|
|||
}
|
||||
|
||||
static void enter_lobby_mode(CVideo& video, const config& game_config,
|
||||
saved_game& state, twesnothd_connection* wesnothd_connection, const std::vector<std::string> & installed_addons)
|
||||
saved_game& state, wesnothd_connection* connection, const std::vector<std::string> & installed_addons)
|
||||
{
|
||||
assert(wesnothd_connection);
|
||||
assert(connection);
|
||||
DBG_MP << "entering lobby mode" << std::endl;
|
||||
|
||||
mp::ui::result res;
|
||||
|
@ -710,7 +710,7 @@ static void enter_lobby_mode(CVideo& video, const config& game_config,
|
|||
sdl::fill_rect(video.getSurface(), nullptr, color);
|
||||
|
||||
if(preferences::new_lobby()) {
|
||||
gui2::tlobby_main dlg(game_config, li, *wesnothd_connection);
|
||||
gui2::tlobby_main dlg(game_config, li, *connection);
|
||||
dlg.set_preferences_callback(
|
||||
std::bind(do_preferences_dialog,
|
||||
std::ref(video), std::ref(game_config)));
|
||||
|
@ -730,7 +730,7 @@ static void enter_lobby_mode(CVideo& video, const config& game_config,
|
|||
res = mp::ui::QUIT;
|
||||
}
|
||||
} else {
|
||||
mp::lobby ui(video, wesnothd_connection, game_config, gamechat, gamelist, installed_addons);
|
||||
mp::lobby ui(video, connection, game_config, gamechat, gamelist, installed_addons);
|
||||
run_lobby_loop(video, ui);
|
||||
res = ui.get_result();
|
||||
current_turn = ui.current_turn;
|
||||
|
@ -740,23 +740,23 @@ static void enter_lobby_mode(CVideo& video, const config& game_config,
|
|||
case mp::ui::JOIN:
|
||||
case mp::ui::OBSERVE:
|
||||
try {
|
||||
enter_wait_mode(video, game_config, state, wesnothd_connection, li, res == mp::ui::OBSERVE, current_turn);
|
||||
enter_wait_mode(video, game_config, state, connection, li, res == mp::ui::OBSERVE, current_turn);
|
||||
} catch(config::error& error) {
|
||||
if(!error.message.empty()) {
|
||||
gui2::show_error_message(video, error.message);
|
||||
}
|
||||
//update lobby content
|
||||
wesnothd_connection->send_data(config("refresh_lobby"));
|
||||
connection->send_data(config("refresh_lobby"));
|
||||
}
|
||||
break;
|
||||
case mp::ui::CREATE:
|
||||
try {
|
||||
enter_create_mode(video, game_config, state, wesnothd_connection, li, false);
|
||||
enter_create_mode(video, game_config, state, connection, li, false);
|
||||
} catch(config::error& error) {
|
||||
if (!error.message.empty())
|
||||
gui2::show_error_message(video, error.message);
|
||||
//update lobby content
|
||||
wesnothd_connection->send_data(config("refresh_lobby"));
|
||||
connection->send_data(config("refresh_lobby"));
|
||||
}
|
||||
break;
|
||||
case mp::ui::QUIT:
|
||||
|
@ -765,7 +765,7 @@ static void enter_lobby_mode(CVideo& video, const config& game_config,
|
|||
{
|
||||
do_preferences_dialog(video, game_config);
|
||||
//update lobby content
|
||||
wesnothd_connection->send_data(config("refresh_lobby"));
|
||||
connection->send_data(config("refresh_lobby"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -904,13 +904,13 @@ void start_client(CVideo& video, const config& game_config,
|
|||
|
||||
gamechat.clear_history();
|
||||
gamelist.clear();
|
||||
std::unique_ptr<twesnothd_connection> wesnothd_connection = open_connection(video, host);
|
||||
if(wesnothd_connection) {
|
||||
std::unique_ptr<wesnothd_connection> connection = open_connection(video, host);
|
||||
if(connection) {
|
||||
bool re_enter;
|
||||
do {
|
||||
re_enter = false;
|
||||
try {
|
||||
enter_lobby_mode(video, *game_config_ptr, state, wesnothd_connection.get(), installed_addons);
|
||||
enter_lobby_mode(video, *game_config_ptr, state, connection.get(), installed_addons);
|
||||
} catch (lobby_reload_request_exception &) {
|
||||
re_enter = true;
|
||||
game_config_manager * gcm = game_config_manager::get();
|
||||
|
@ -921,19 +921,19 @@ void start_client(CVideo& video, const config& game_config,
|
|||
installed_addons = ::installed_addons(); // Refersh the installed add-on list for this session.
|
||||
|
||||
gamelist.clear(); //needed to make sure we update which games we have content for
|
||||
wesnothd_connection->send_data(config("refresh_lobby"));
|
||||
connection->send_data(config("refresh_lobby"));
|
||||
}
|
||||
} while (re_enter);
|
||||
}
|
||||
}
|
||||
|
||||
mp::ui::result goto_mp_connect(CVideo& video, ng::connect_engine& engine,
|
||||
const config& game_config, twesnothd_connection* wesnothd_connection, const std::string& game_name)
|
||||
const config& game_config, wesnothd_connection* connection, const std::string& game_name)
|
||||
{
|
||||
mp::ui::result res;
|
||||
|
||||
{
|
||||
mp::connect ui(video, wesnothd_connection, game_name, game_config, gamechat, gamelist,
|
||||
mp::connect ui(video, connection, game_name, game_config, gamechat, gamelist,
|
||||
engine);
|
||||
run_lobby_loop(video, ui);
|
||||
|
||||
|
@ -946,12 +946,12 @@ mp::ui::result goto_mp_connect(CVideo& video, ng::connect_engine& engine,
|
|||
return res;
|
||||
}
|
||||
|
||||
mp::ui::result goto_mp_wait(CVideo& video, saved_game& state, const config& game_config, twesnothd_connection* wesnothd_connection, bool observe)
|
||||
mp::ui::result goto_mp_wait(CVideo& video, saved_game& state, const config& game_config, wesnothd_connection* connection, bool observe)
|
||||
{
|
||||
mp::ui::result res;
|
||||
|
||||
{
|
||||
mp::wait ui(video, wesnothd_connection, game_config, state, gamechat, gamelist, false);
|
||||
mp::wait ui(video, connection, game_config, state, gamechat, gamelist, false);
|
||||
|
||||
ui.join_game(observe);
|
||||
run_lobby_loop(video, ui);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
class config;
|
||||
class CVideo;
|
||||
class twesnothd_connection;
|
||||
class wesnothd_connection;
|
||||
namespace mp {
|
||||
|
||||
// max. length of a player name
|
||||
|
@ -64,13 +64,13 @@ void start_client(CVideo& video, const config& game_config,
|
|||
* changes made.
|
||||
*/
|
||||
mp::ui::result goto_mp_connect(CVideo& video, ng::connect_engine& engine,
|
||||
const config& game_config, twesnothd_connection* wesnothd_connection, const std::string& game_name);
|
||||
const config& game_config, wesnothd_connection* connection, const std::string& game_name);
|
||||
|
||||
/**
|
||||
* Opens mp::wait screen and sets game state according to the
|
||||
* changes made.
|
||||
*/
|
||||
mp::ui::result goto_mp_wait(CVideo& video, saved_game& state, const config& game_config, twesnothd_connection* wesnothd_connection, bool observe);
|
||||
mp::ui::result goto_mp_wait(CVideo& video, saved_game& state, const config& game_config, wesnothd_connection* connection, bool observe);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -63,8 +63,8 @@ configure::nolock_settings::nolock_settings(CVideo& video)
|
|||
{
|
||||
|
||||
}
|
||||
configure::configure(CVideo& video, twesnothd_connection* wesnothd_connection, const config &cfg, chat& c, config& gamelist, saved_game& game, bool local_players_only) :
|
||||
ui(video, wesnothd_connection, _("Configure Game"), cfg, c, gamelist),
|
||||
configure::configure(CVideo& video, wesnothd_connection* connection, const config &cfg, chat& c, config& gamelist, saved_game& game, bool local_players_only) :
|
||||
ui(video, connection, _("Configure Game"), cfg, c, gamelist),
|
||||
|
||||
local_players_only_(local_players_only),
|
||||
tooltip_manager_(video),
|
||||
|
|
|
@ -33,7 +33,7 @@ class configure : public mp::ui
|
|||
public:
|
||||
///gives the user the option to adjust the passed saved_game
|
||||
///Call get_parameters to finalize;
|
||||
configure(CVideo& v, twesnothd_connection* wesnothd_connection, const config& game_config, chat& c, config& gamelist, saved_game& game, bool local_players_only);
|
||||
configure(CVideo& v, wesnothd_connection* connection, const config& game_config, chat& c, config& gamelist, saved_game& game, bool local_players_only);
|
||||
~configure();
|
||||
|
||||
void get_parameters();
|
||||
|
|
|
@ -364,10 +364,10 @@ void connect::side::update_controller_ui()
|
|||
}
|
||||
}
|
||||
|
||||
connect::connect(CVideo& v, twesnothd_connection* wesnothd_connection, const std::string& game_name,
|
||||
connect::connect(CVideo& v, wesnothd_connection* connection, const std::string& game_name,
|
||||
const config& game_config, chat& c, config& gamelist,
|
||||
ng::connect_engine& engine) :
|
||||
mp::ui(v, wesnothd_connection, _("Game Lobby: ") + game_name, game_config, c, gamelist),
|
||||
mp::ui(v, connection, _("Game Lobby: ") + game_name, game_config, c, gamelist),
|
||||
ai_algorithms_(),
|
||||
sides_(),
|
||||
engine_(engine),
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
|
||||
typedef std::vector<side> side_list;
|
||||
|
||||
connect(CVideo& v, twesnothd_connection* wesnothd_connection, const std::string& game_name,
|
||||
connect(CVideo& v, wesnothd_connection* connection, const std::string& game_name,
|
||||
const config& game_config, chat& c, config& gamelist,
|
||||
ng::connect_engine& engine);
|
||||
~connect();
|
||||
|
|
|
@ -84,8 +84,8 @@ static config find_helper(const ng::create_engine * eng_ptr, const config & cfg)
|
|||
return config_of("index", eng.find_level_by_id(str))("type", eng.find_level_type_by_id(str));
|
||||
}
|
||||
|
||||
create::create(CVideo& video, twesnothd_connection* wesnothd_connection, const config& cfg, saved_game& state, chat& c, config& gamelist) :
|
||||
ui(video, wesnothd_connection, _("Create Game"), cfg, c, gamelist),
|
||||
create::create(CVideo& video, wesnothd_connection* connection, const config& cfg, saved_game& state, chat& c, config& gamelist) :
|
||||
ui(video, connection, _("Create Game"), cfg, c, gamelist),
|
||||
tooltip_manager_(video),
|
||||
era_selection_(-1),
|
||||
mod_selection_(-1),
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace mp {
|
|||
class create : public mp::ui
|
||||
{
|
||||
public:
|
||||
create(CVideo& v, twesnothd_connection* wesnothd_connection, const config& game_config, saved_game& state,
|
||||
create(CVideo& v, wesnothd_connection* connection, const config& game_config, saved_game& state,
|
||||
chat& c, config& gamelist);
|
||||
~create();
|
||||
|
||||
|
|
|
@ -1025,8 +1025,8 @@ bool lobby::lobby_sorter::less(int column, const gui::menu::item& row1, const gu
|
|||
return basic_sorter::less(column,row1,row2);
|
||||
}
|
||||
|
||||
lobby::lobby(CVideo& v, twesnothd_connection* wesnothd_connection, const config& cfg, chat& c, config& gamelist, const std::vector<std::string> & installed_addons) :
|
||||
mp::ui(v, wesnothd_connection, _("Game Lobby"), cfg, c, gamelist),
|
||||
lobby::lobby(CVideo& v, wesnothd_connection* connection, const config& cfg, chat& c, config& gamelist, const std::vector<std::string> & installed_addons) :
|
||||
mp::ui(v, connection, _("Game Lobby"), cfg, c, gamelist),
|
||||
|
||||
current_turn(0),
|
||||
game_vacant_slots_(),
|
||||
|
|
|
@ -189,7 +189,7 @@ private:
|
|||
class lobby : public ui
|
||||
{
|
||||
public:
|
||||
lobby(CVideo& v, twesnothd_connection* wesnothd_connection, const config& cfg, chat& c, config& gamelist, const std::vector<std::string> & installed_addons);
|
||||
lobby(CVideo& v, wesnothd_connection* connection, const config& cfg, chat& c, config& gamelist, const std::vector<std::string> & installed_addons);
|
||||
|
||||
virtual void process_event();
|
||||
|
||||
|
|
|
@ -182,10 +182,10 @@ SDL_Color chat::color_message(const msg& message) {
|
|||
return c;
|
||||
}
|
||||
|
||||
ui::ui(CVideo& video, twesnothd_connection* wesnothd_connection, const std::string& title, const config& cfg, chat& c, config& gamelist) :
|
||||
ui::ui(CVideo& video, wesnothd_connection* connection, const std::string& title, const config& cfg, chat& c, config& gamelist) :
|
||||
gui::widget(video),
|
||||
video_(video),
|
||||
wesnothd_connection_(wesnothd_connection),
|
||||
wesnothd_connection_(connection),
|
||||
initialized_(false),
|
||||
gamelist_initialized_(false),
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class game_display;
|
|||
class config;
|
||||
class plugins_context;
|
||||
|
||||
class twesnothd_connection;
|
||||
class wesnothd_connection;
|
||||
namespace mp {
|
||||
|
||||
std::string get_color_string(int id);
|
||||
|
@ -78,7 +78,7 @@ public:
|
|||
enum result { CONTINUE, JOIN, OBSERVE, CREATE, LOAD_GAME, PREFERENCES,
|
||||
PLAY, QUIT };
|
||||
|
||||
ui(CVideo& v, twesnothd_connection* wesnothd_connection, const std::string& title,
|
||||
ui(CVideo& v, wesnothd_connection* connection, const std::string& title,
|
||||
const config& cfg, chat& c, config& gamelist);
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ protected:
|
|||
SDL_Rect client_area() const;
|
||||
|
||||
CVideo& video_;
|
||||
twesnothd_connection* wesnothd_connection_;
|
||||
wesnothd_connection* wesnothd_connection_;
|
||||
CVideo& video() { return video_; }
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,9 +56,9 @@ static lg::log_domain log_mp("mp/main");
|
|||
|
||||
namespace mp {
|
||||
|
||||
wait::wait(CVideo& v, twesnothd_connection* wesnothd_connection, const config& cfg, saved_game& state,
|
||||
wait::wait(CVideo& v, wesnothd_connection* connection, const config& cfg, saved_game& state,
|
||||
mp::chat& c, config& gamelist, const bool first_scenario) :
|
||||
ui(v, wesnothd_connection, _("Game Lobby"), cfg, c, gamelist),
|
||||
ui(v, connection, _("Game Lobby"), cfg, c, gamelist),
|
||||
cancel_button_(video(), first_scenario ? _("Cancel") : _("Quit")),
|
||||
start_label_(video(), _("Waiting for game to start..."), font::SIZE_SMALL, font::LOBBY_COLOR),
|
||||
game_menu_(video(), std::vector<std::string>(), false, -1, -1, nullptr, &gui::menu::bluebg_style),
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace mp {
|
|||
class wait : public ui
|
||||
{
|
||||
public:
|
||||
wait(CVideo& v, twesnothd_connection* wesnothd_connection, const config& cfg, saved_game& state, chat& c,
|
||||
wait(CVideo& v, wesnothd_connection* connection, const config& cfg, saved_game& state, chat& c,
|
||||
config& gamelist, const bool first_scenario = true);
|
||||
~wait();
|
||||
virtual void process_event();
|
||||
|
|
|
@ -353,7 +353,7 @@ LEVEL_RESULT campaign_controller::play_game()
|
|||
if (mp_info_ && !mp_info_->is_host) {
|
||||
// Opens mp::connect dialog to get a new gamestate.
|
||||
mp::ui::result wait_res = mp::goto_mp_wait(video_, state_,
|
||||
game_config_, &mp_info_->wesnothd_connection, res == LEVEL_RESULT::OBSERVER_END);
|
||||
game_config_, &mp_info_->connection, res == LEVEL_RESULT::OBSERVER_END);
|
||||
if (wait_res == mp::ui::QUIT) {
|
||||
return LEVEL_RESULT::QUIT;
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ LEVEL_RESULT campaign_controller::play_game()
|
|||
if (!connect_engine->can_start_game() || (game_config::debug && game_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER)) {
|
||||
// Opens mp::connect dialog to allow users to make an adjustments for scenario.
|
||||
mp::ui::result connect_res = mp::goto_mp_connect(video_,
|
||||
*connect_engine, game_config_, mp_info_ ? &mp_info_->wesnothd_connection : nullptr, state_.mp_settings().name);
|
||||
*connect_engine, game_config_, mp_info_ ? &mp_info_->connection : nullptr, state_.mp_settings().name);
|
||||
if (connect_res == mp::ui::QUIT) {
|
||||
return LEVEL_RESULT::QUIT;
|
||||
}
|
||||
|
|
|
@ -34,15 +34,15 @@ typedef std::shared_ptr<terrain_type_data> tdata_cache;
|
|||
|
||||
class config;
|
||||
|
||||
class twesnothd_connection;
|
||||
class wesnothd_connection;
|
||||
struct mp_campaign_info
|
||||
{
|
||||
mp_campaign_info(twesnothd_connection& wdc)
|
||||
mp_campaign_info(wesnothd_connection& wdc)
|
||||
: connected_players()
|
||||
, is_host()
|
||||
, skip_replay_until_turn(0)
|
||||
, skip_replay_blindfolded(false)
|
||||
, wesnothd_connection(wdc)
|
||||
, connection(wdc)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ struct mp_campaign_info
|
|||
bool is_host;
|
||||
int skip_replay_until_turn;
|
||||
bool skip_replay_blindfolded;
|
||||
twesnothd_connection& wesnothd_connection;
|
||||
wesnothd_connection& connection;
|
||||
};
|
||||
|
||||
class campaign_controller
|
||||
|
|
|
@ -122,7 +122,7 @@ bool tlobby_main::logout_prompt()
|
|||
return show_prompt(_("Do you really want to log out?"));
|
||||
}
|
||||
|
||||
tlobby_main::tlobby_main(const config& game_config, lobby_info& info, twesnothd_connection &wesnothd_connection)
|
||||
tlobby_main::tlobby_main(const config& game_config, lobby_info& info, wesnothd_connection &connection)
|
||||
: quit_confirmation(&tlobby_main::logout_prompt)
|
||||
, game_config_(game_config)
|
||||
, gamelistbox_(nullptr)
|
||||
|
@ -140,7 +140,7 @@ tlobby_main::tlobby_main(const config& game_config, lobby_info& info, twesnothd_
|
|||
, gamelist_dirty_(false)
|
||||
, last_gamelist_update_(0)
|
||||
, gamelist_diff_update_(true)
|
||||
, wesnothd_connection_(wesnothd_connection)
|
||||
, wesnothd_connection_(connection)
|
||||
, lobby_update_timer_(0)
|
||||
, gamelist_id_at_row_()
|
||||
, delay_playerlist_update_(false)
|
||||
|
|
|
@ -28,7 +28,7 @@ class display;
|
|||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#endif
|
||||
class twesnothd_connection;
|
||||
class wesnothd_connection;
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
|
@ -70,7 +70,7 @@ struct tplayer_list
|
|||
class tlobby_main : public tdialog, public quit_confirmation, private plugin_executor
|
||||
{
|
||||
public:
|
||||
tlobby_main(const config& game_config, lobby_info& info, twesnothd_connection &wesnothd_connection);
|
||||
tlobby_main(const config& game_config, lobby_info& info, wesnothd_connection &connection);
|
||||
|
||||
~tlobby_main();
|
||||
|
||||
|
@ -208,7 +208,7 @@ private:
|
|||
|
||||
bool gamelist_diff_update_;
|
||||
|
||||
twesnothd_connection &wesnothd_connection_;
|
||||
wesnothd_connection &wesnothd_connection_;
|
||||
|
||||
/** Timer for updating the lobby. */
|
||||
size_t lobby_update_timer_;
|
||||
|
|
|
@ -52,11 +52,11 @@ namespace gui2
|
|||
|
||||
REGISTER_DIALOG(mp_join_game)
|
||||
|
||||
tmp_join_game::tmp_join_game(saved_game& state, lobby_info& lobby_info, twesnothd_connection& wesnothd_connection, const bool first_scenario, const bool observe_game)
|
||||
tmp_join_game::tmp_join_game(saved_game& state, lobby_info& lobby_info, wesnothd_connection& connection, const bool first_scenario, const bool observe_game)
|
||||
: level_()
|
||||
, state_(state)
|
||||
, lobby_info_(lobby_info)
|
||||
, wesnothd_connection_(wesnothd_connection)
|
||||
, wesnothd_connection_(connection)
|
||||
, update_timer_(0)
|
||||
, first_scenario_(first_scenario)
|
||||
, observe_game_(observe_game)
|
||||
|
|
|
@ -34,7 +34,7 @@ class ttree_view_node;
|
|||
class tmp_join_game : public tdialog, private plugin_executor
|
||||
{
|
||||
public:
|
||||
tmp_join_game(saved_game& state, lobby_info& lobby_info, twesnothd_connection& wesnothd_connection,
|
||||
tmp_join_game(saved_game& state, lobby_info& lobby_info, wesnothd_connection& connection,
|
||||
const bool first_scenario = true, const bool observe_game = false);
|
||||
|
||||
~tmp_join_game();
|
||||
|
@ -70,7 +70,7 @@ private:
|
|||
|
||||
lobby_info& lobby_info_;
|
||||
|
||||
twesnothd_connection& wesnothd_connection_;
|
||||
wesnothd_connection& wesnothd_connection_;
|
||||
|
||||
size_t update_timer_;
|
||||
|
||||
|
|
|
@ -48,11 +48,11 @@ namespace gui2
|
|||
|
||||
REGISTER_DIALOG(mp_staging)
|
||||
|
||||
tmp_staging::tmp_staging(ng::connect_engine& connect_engine, lobby_info& lobby_info, twesnothd_connection* wesnothd_connection)
|
||||
tmp_staging::tmp_staging(ng::connect_engine& connect_engine, lobby_info& lobby_info, wesnothd_connection* connection)
|
||||
: connect_engine_(connect_engine)
|
||||
, ai_algorithms_(ai::configuration::get_available_ais())
|
||||
, lobby_info_(lobby_info)
|
||||
, wesnothd_connection_(wesnothd_connection)
|
||||
, wesnothd_connection_(connection)
|
||||
, update_timer_(0)
|
||||
, state_changed_(false)
|
||||
, team_tree_map_()
|
||||
|
|
|
@ -35,7 +35,7 @@ class ttree_view_node;
|
|||
class tmp_staging : public tdialog, private plugin_executor
|
||||
{
|
||||
public:
|
||||
tmp_staging(ng::connect_engine& connect_engine, lobby_info& lobby_info, twesnothd_connection* wesnothd_connection = nullptr);
|
||||
tmp_staging(ng::connect_engine& connect_engine, lobby_info& lobby_info, wesnothd_connection* connection = nullptr);
|
||||
|
||||
~tmp_staging();
|
||||
|
||||
|
@ -78,7 +78,7 @@ private:
|
|||
|
||||
lobby_info& lobby_info_;
|
||||
|
||||
twesnothd_connection* wesnothd_connection_;
|
||||
wesnothd_connection* wesnothd_connection_;
|
||||
|
||||
size_t update_timer_;
|
||||
|
||||
|
|
|
@ -118,36 +118,36 @@ void tnetwork_transmission::wesnothd_dialog(CVideo& video, gui2::tnetwork_transm
|
|||
|
||||
struct read_wesnothd_connection_data : public gui2::tnetwork_transmission::connection_data
|
||||
{
|
||||
read_wesnothd_connection_data(twesnothd_connection& conn) : conn_(conn) {}
|
||||
read_wesnothd_connection_data(wesnothd_connection& conn) : conn_(conn) {}
|
||||
size_t total() override { return conn_.bytes_to_read(); }
|
||||
virtual size_t current() override { return conn_.bytes_read(); }
|
||||
virtual bool finished() override { return conn_.has_data_received(); }
|
||||
virtual void cancel() override { }
|
||||
virtual void poll() override { conn_.poll(); }
|
||||
twesnothd_connection& conn_;
|
||||
wesnothd_connection& conn_;
|
||||
};
|
||||
|
||||
bool tnetwork_transmission::wesnothd_receive_dialog(CVideo& video, const std::string& msg, config& cfg, twesnothd_connection& wesnothd_connection)
|
||||
bool tnetwork_transmission::wesnothd_receive_dialog(CVideo& video, const std::string& msg, config& cfg, wesnothd_connection& connection)
|
||||
{
|
||||
assert(!msg.empty());
|
||||
read_wesnothd_connection_data gui_data(wesnothd_connection);
|
||||
read_wesnothd_connection_data gui_data(connection);
|
||||
wesnothd_dialog(video, gui_data, msg);
|
||||
return wesnothd_connection.receive_data(cfg);
|
||||
return connection.receive_data(cfg);
|
||||
}
|
||||
|
||||
struct connect_wesnothd_connection_data : public gui2::tnetwork_transmission::connection_data
|
||||
{
|
||||
connect_wesnothd_connection_data(twesnothd_connection& conn) : conn_(conn) {}
|
||||
connect_wesnothd_connection_data(wesnothd_connection& conn) : conn_(conn) {}
|
||||
virtual bool finished() override { return conn_.handshake_finished(); }
|
||||
virtual void cancel() override { }
|
||||
virtual void poll() override { conn_.poll(); }
|
||||
twesnothd_connection& conn_;
|
||||
wesnothd_connection& conn_;
|
||||
};
|
||||
|
||||
std::unique_ptr<twesnothd_connection> tnetwork_transmission::wesnothd_connect_dialog(CVideo& video, const std::string& msg, const std::string& hostname, int port)
|
||||
std::unique_ptr<wesnothd_connection> tnetwork_transmission::wesnothd_connect_dialog(CVideo& video, const std::string& msg, const std::string& hostname, int port)
|
||||
{
|
||||
assert(!msg.empty());
|
||||
std::unique_ptr<twesnothd_connection> res(new twesnothd_connection(hostname, std::to_string(port)));
|
||||
std::unique_ptr<wesnothd_connection> res(new wesnothd_connection(hostname, std::to_string(port)));
|
||||
connect_wesnothd_connection_data gui_data(*res);
|
||||
wesnothd_dialog(video, gui_data, msg);
|
||||
return res;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <boost/optional.hpp>
|
||||
#include "events.hpp"
|
||||
|
||||
class twesnothd_connection;
|
||||
class wesnothd_connection;
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ namespace gui2
|
|||
class tnetwork_transmission : public tdialog
|
||||
{
|
||||
public:
|
||||
//A wrapper of either a twesnothd_connection or a network_asio::connection
|
||||
//A wrapper of either a wesnothd_connection or a network_asio::connection
|
||||
class connection_data
|
||||
{
|
||||
public:
|
||||
|
@ -48,8 +48,8 @@ public:
|
|||
virtual ~connection_data() {}
|
||||
};
|
||||
|
||||
static bool wesnothd_receive_dialog(CVideo& video, const std::string& msg, config& cfg, twesnothd_connection& wesnothd_connection);
|
||||
static std::unique_ptr<twesnothd_connection> wesnothd_connect_dialog(CVideo& video, const std::string& msg, const std::string& hostname, int port);
|
||||
static bool wesnothd_receive_dialog(CVideo& video, const std::string& msg, config& cfg, wesnothd_connection& connection);
|
||||
static std::unique_ptr<wesnothd_connection> wesnothd_connect_dialog(CVideo& video, const std::string& msg, const std::string& hostname, int port);
|
||||
|
||||
private:
|
||||
static void wesnothd_dialog(CVideo& video, gui2::tnetwork_transmission::connection_data& conn, const std::string& msg);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <string>
|
||||
|
||||
class config;
|
||||
class twesnothd_connection;
|
||||
class wesnothd_connection;
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
|
||||
void set_lobby_info(lobby_info& i) { lobby_info_ = &i; }
|
||||
|
||||
void set_wesnothd_connection(twesnothd_connection& c) { wesnothd_connection_ = &c; }
|
||||
void set_wesnothd_connection(wesnothd_connection& c) { wesnothd_connection_ = &c; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -129,7 +129,7 @@ private:
|
|||
|
||||
class lobby_info& lobby_info() { return *lobby_info_; }
|
||||
|
||||
twesnothd_connection* wesnothd_connection_;
|
||||
wesnothd_connection* wesnothd_connection_;
|
||||
|
||||
/** See @ref tcontrol::get_control_type. */
|
||||
virtual const std::string& get_control_type() const override;
|
||||
|
|
|
@ -281,7 +281,7 @@ void playmp_controller::wait_for_upload()
|
|||
while(true) {
|
||||
try {
|
||||
const bool res = gui2::tnetwork_transmission::wesnothd_receive_dialog(
|
||||
gui_->video(), "next scenario", cfg, mp_info_->wesnothd_connection);
|
||||
gui_->video(), "next scenario", cfg, mp_info_->connection);
|
||||
|
||||
if(res) {
|
||||
if (turn_data_.process_network_data_from_reader() == turn_info::PROCESS_END_LINGER) {
|
||||
|
@ -483,13 +483,13 @@ bool playmp_controller::is_networked_mp() const
|
|||
void playmp_controller::send_to_wesnothd(const config& cfg, const std::string&) const
|
||||
{
|
||||
if (mp_info_ != nullptr) {
|
||||
mp_info_->wesnothd_connection.send_data(cfg);
|
||||
mp_info_->connection.send_data(cfg);
|
||||
}
|
||||
}
|
||||
bool playmp_controller::recieve_from_wesnothd(config& cfg) const
|
||||
{
|
||||
if (mp_info_ != nullptr) {
|
||||
return mp_info_->wesnothd_connection.receive_data(cfg);
|
||||
return mp_info_->connection.receive_data(cfg);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
|
|
@ -766,9 +766,9 @@ struct twrapper<gui2::tgamestate_inspector>
|
|||
|
||||
struct twesnothd_connection_init
|
||||
{
|
||||
twesnothd_connection_init(twesnothd_connection& conn)
|
||||
twesnothd_connection_init(wesnothd_connection& conn)
|
||||
{
|
||||
//Swallow the 'cannot connect' execption so that the wesnothd_connection object doesn't throw while we test the dialog.
|
||||
//Swallow the 'cannot connect' execption so that the connection object doesn't throw while we test the dialog.
|
||||
try
|
||||
{
|
||||
while (true) {
|
||||
|
@ -786,16 +786,16 @@ template<>
|
|||
struct twrapper<gui2::tlobby_main>
|
||||
{
|
||||
config game_config;
|
||||
twesnothd_connection wesnothd_connection;
|
||||
wesnothd_connection connection;
|
||||
twesnothd_connection_init wesnothd_connection_init;
|
||||
std::vector<std::string> installed_addons;
|
||||
lobby_info li;
|
||||
twrapper() : wesnothd_connection("", ""), wesnothd_connection_init(wesnothd_connection), li(game_config, installed_addons)
|
||||
twrapper() : connection("", ""), wesnothd_connection_init(connection), li(game_config, installed_addons)
|
||||
{
|
||||
}
|
||||
gui2::tlobby_main* create()
|
||||
{
|
||||
return new gui2::tlobby_main(game_config, li, wesnothd_connection);
|
||||
return new gui2::tlobby_main(game_config, li, connection);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -812,13 +812,13 @@ struct twrapper<gui2::tlobby_player_info>
|
|||
{
|
||||
config c;
|
||||
fake_chat_handler ch;
|
||||
twesnothd_connection wesnothd_connection;
|
||||
wesnothd_connection connection;
|
||||
twesnothd_connection_init wesnothd_connection_init;
|
||||
user_info ui;
|
||||
std::vector<std::string> installed_addons;
|
||||
lobby_info li;
|
||||
twrapper()
|
||||
: wesnothd_connection("", ""), wesnothd_connection_init(wesnothd_connection)
|
||||
: connection("", ""), wesnothd_connection_init(connection)
|
||||
, ui(c), li(c, installed_addons)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ static lg::log_domain log_network("network");
|
|||
using boost::system::system_error;
|
||||
using boost::system::error_code;
|
||||
|
||||
twesnothd_connection::twesnothd_connection(const std::string& host, const std::string& service)
|
||||
wesnothd_connection::wesnothd_connection(const std::string& host, const std::string& service)
|
||||
: io_service_()
|
||||
, resolver_(io_service_)
|
||||
, socket_(io_service_)
|
||||
|
@ -45,12 +45,12 @@ twesnothd_connection::twesnothd_connection(const std::string& host, const std::s
|
|||
{
|
||||
resolver_.async_resolve(
|
||||
boost::asio::ip::tcp::resolver::query(host, service),
|
||||
std::bind(&twesnothd_connection::handle_resolve, this, _1, _2)
|
||||
std::bind(&wesnothd_connection::handle_resolve, this, _1, _2)
|
||||
);
|
||||
LOG_NW << "Resolving hostname: " << host << '\n';
|
||||
}
|
||||
|
||||
void twesnothd_connection::handle_resolve(const error_code& ec, resolver::iterator iterator)
|
||||
void wesnothd_connection::handle_resolve(const error_code& ec, resolver::iterator iterator)
|
||||
{
|
||||
if (ec) {
|
||||
throw system_error(ec);
|
||||
|
@ -58,15 +58,15 @@ void twesnothd_connection::handle_resolve(const error_code& ec, resolver::iterat
|
|||
connect(iterator);
|
||||
}
|
||||
|
||||
void twesnothd_connection::connect(resolver::iterator iterator)
|
||||
void wesnothd_connection::connect(resolver::iterator iterator)
|
||||
{
|
||||
socket_.async_connect(*iterator, std::bind(
|
||||
&twesnothd_connection::handle_connect, this, _1, iterator)
|
||||
&wesnothd_connection::handle_connect, this, _1, iterator)
|
||||
);
|
||||
LOG_NW << "Connecting to " << iterator->endpoint().address() << '\n';
|
||||
}
|
||||
|
||||
void twesnothd_connection::handle_connect(
|
||||
void wesnothd_connection::handle_connect(
|
||||
const boost::system::error_code& ec,
|
||||
resolver::iterator iterator
|
||||
)
|
||||
|
@ -89,7 +89,7 @@ void twesnothd_connection::handle_connect(
|
|||
}
|
||||
}
|
||||
|
||||
void twesnothd_connection::handshake()
|
||||
void wesnothd_connection::handshake()
|
||||
{
|
||||
static const uint32_t handshake = 0;
|
||||
boost::asio::async_write(socket_,
|
||||
|
@ -98,11 +98,11 @@ void twesnothd_connection::handshake()
|
|||
);
|
||||
boost::asio::async_read(socket_,
|
||||
boost::asio::buffer(&handshake_response_.binary, 4),
|
||||
std::bind(&twesnothd_connection::handle_handshake, this, _1)
|
||||
std::bind(&wesnothd_connection::handle_handshake, this, _1)
|
||||
);
|
||||
}
|
||||
|
||||
void twesnothd_connection::handle_handshake(const error_code& ec)
|
||||
void wesnothd_connection::handle_handshake(const error_code& ec)
|
||||
{
|
||||
if (ec) {
|
||||
throw system_error(ec);
|
||||
|
@ -111,7 +111,7 @@ void twesnothd_connection::handle_handshake(const error_code& ec)
|
|||
recv();
|
||||
}
|
||||
|
||||
void twesnothd_connection::send_data(const configr_of& request)
|
||||
void wesnothd_connection::send_data(const configr_of& request)
|
||||
{
|
||||
poll();
|
||||
send_queue_.emplace_back();
|
||||
|
@ -123,7 +123,7 @@ void twesnothd_connection::send_data(const configr_of& request)
|
|||
}
|
||||
}
|
||||
|
||||
void twesnothd_connection::cancel()
|
||||
void wesnothd_connection::cancel()
|
||||
{
|
||||
if(socket_.is_open()) {
|
||||
boost::system::error_code ec;
|
||||
|
@ -134,7 +134,7 @@ void twesnothd_connection::cancel()
|
|||
}
|
||||
}
|
||||
|
||||
std::size_t twesnothd_connection::is_write_complete(const boost::system::error_code& ec, size_t bytes_transferred)
|
||||
std::size_t wesnothd_connection::is_write_complete(const boost::system::error_code& ec, size_t bytes_transferred)
|
||||
{
|
||||
if(ec)
|
||||
throw system_error(ec);
|
||||
|
@ -142,7 +142,7 @@ std::size_t twesnothd_connection::is_write_complete(const boost::system::error_c
|
|||
return bytes_to_write_ - bytes_transferred;
|
||||
}
|
||||
|
||||
void twesnothd_connection::handle_write(
|
||||
void wesnothd_connection::handle_write(
|
||||
const boost::system::error_code& ec,
|
||||
std::size_t bytes_transferred
|
||||
)
|
||||
|
@ -157,7 +157,7 @@ void twesnothd_connection::handle_write(
|
|||
}
|
||||
}
|
||||
|
||||
std::size_t twesnothd_connection::is_read_complete(
|
||||
std::size_t wesnothd_connection::is_read_complete(
|
||||
const boost::system::error_code& ec,
|
||||
std::size_t bytes_transferred
|
||||
)
|
||||
|
@ -182,7 +182,7 @@ std::size_t twesnothd_connection::is_read_complete(
|
|||
}
|
||||
}
|
||||
|
||||
void twesnothd_connection::handle_read(
|
||||
void wesnothd_connection::handle_read(
|
||||
const boost::system::error_code& ec,
|
||||
std::size_t bytes_transferred
|
||||
)
|
||||
|
@ -199,7 +199,7 @@ void twesnothd_connection::handle_read(
|
|||
recv();
|
||||
}
|
||||
|
||||
void twesnothd_connection::send()
|
||||
void wesnothd_connection::send()
|
||||
{
|
||||
auto& buf = send_queue_.front();
|
||||
size_t buf_size = buf.size();
|
||||
|
@ -211,20 +211,20 @@ void twesnothd_connection::send()
|
|||
std::deque<boost::asio::const_buffer> bufs(gzipped_data.begin(), gzipped_data.end());
|
||||
bufs.push_front(boost::asio::buffer(reinterpret_cast<const char*>(&payload_size_), 4));
|
||||
boost::asio::async_write(socket_, bufs,
|
||||
std::bind(&twesnothd_connection::is_write_complete, this, _1, _2),
|
||||
std::bind(&twesnothd_connection::handle_write, this, _1, _2)
|
||||
std::bind(&wesnothd_connection::is_write_complete, this, _1, _2),
|
||||
std::bind(&wesnothd_connection::handle_write, this, _1, _2)
|
||||
);
|
||||
}
|
||||
|
||||
void twesnothd_connection::recv()
|
||||
void wesnothd_connection::recv()
|
||||
{
|
||||
boost::asio::async_read(socket_, read_buf_,
|
||||
std::bind(&twesnothd_connection::is_read_complete, this, _1, _2),
|
||||
std::bind(&twesnothd_connection::handle_read, this, _1, _2)
|
||||
std::bind(&wesnothd_connection::is_read_complete, this, _1, _2),
|
||||
std::bind(&wesnothd_connection::handle_read, this, _1, _2)
|
||||
);
|
||||
}
|
||||
|
||||
std::size_t twesnothd_connection::poll()
|
||||
std::size_t wesnothd_connection::poll()
|
||||
{
|
||||
try {
|
||||
return io_service_.poll();
|
||||
|
@ -238,7 +238,7 @@ std::size_t twesnothd_connection::poll()
|
|||
throw error(err.code());
|
||||
}
|
||||
}
|
||||
bool twesnothd_connection::receive_data(config& result)
|
||||
bool wesnothd_connection::receive_data(config& result)
|
||||
{
|
||||
poll();
|
||||
if (recv_queue_.empty()) {
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
class config;
|
||||
|
||||
/** A class that represents a TCP/IP connection to the wesnothd server. */
|
||||
class twesnothd_connection : boost::noncopyable
|
||||
class wesnothd_connection : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
using error = wesnothd_connection_error;
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
* @param host Name of the host to connect to
|
||||
* @param service Service identifier such as "80" or "http"
|
||||
*/
|
||||
twesnothd_connection(const std::string& host, const std::string& service);
|
||||
wesnothd_connection(const std::string& host, const std::string& service);
|
||||
|
||||
void send_data(const configr_of& request);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue