Move lobby data/info to game_initialization, in mp namespace

This commit is contained in:
Celtic Minstrel 2016-11-19 14:41:56 -05:00
parent 17d32e3083
commit 9eb1efadc7
18 changed files with 143 additions and 138 deletions

View file

@ -378,8 +378,8 @@
91A215C91CAD968400927AEA /* new_map.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A9BCB60ECA805A002BE442 /* new_map.cpp */; };
91A215CA1CAD968400927AEA /* resize_map.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A9BCB80ECA805A002BE442 /* resize_map.cpp */; };
91A215CB1CAD968400927AEA /* set_starting_position.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4728DAF145A59CF00F0E1E1 /* set_starting_position.cpp */; };
91A215CC1CAD969200927AEA /* data.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE04711234B1A00154E6C /* data.cpp */; };
91A215CD1CAD969200927AEA /* info.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE04911234B1A00154E6C /* info.cpp */; };
91A215CC1CAD969200927AEA /* lobby_data.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE04711234B1A00154E6C /* lobby_data.cpp */; };
91A215CD1CAD969200927AEA /* lobby_info.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE04911234B1A00154E6C /* lobby_info.cpp */; };
91A215CE1CAD969200927AEA /* lobby.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6EF0FEA9F92006F6FBD /* lobby.cpp */; };
91A215CF1CAD969200927AEA /* player_info.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B59F96EB1034796700A57C1A /* player_info.cpp */; };
91A215D01CAD96D900927AEA /* mp_alerts_options.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EC5C70BE19EEB57400432CF4 /* mp_alerts_options.cpp */; };
@ -951,8 +951,8 @@
B55BE03311234AAB00154E6C /* pathfind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE02E11234AAB00154E6C /* pathfind.cpp */; };
B55BE03A11234AC700154E6C /* gamestate_observer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE03811234AC700154E6C /* gamestate_observer.cpp */; };
B55BE04011234AD700154E6C /* engine_lua.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE03C11234AD700154E6C /* engine_lua.cpp */; };
B55BE04B11234B1A00154E6C /* data.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE04711234B1A00154E6C /* data.cpp */; };
B55BE04C11234B1A00154E6C /* info.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE04911234B1A00154E6C /* info.cpp */; };
B55BE04B11234B1A00154E6C /* lobby_data.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE04711234B1A00154E6C /* lobby_data.cpp */; };
B55BE04C11234B1A00154E6C /* lobby_info.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE04911234B1A00154E6C /* lobby_info.cpp */; };
B55BE05311234B3300154E6C /* tree_view_node.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE04F11234B3300154E6C /* tree_view_node.cpp */; };
B55BE05411234B3300154E6C /* tree_view.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55BE05111234B3300154E6C /* tree_view.cpp */; };
B561F368104B1042001369F5 /* component.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B561F366104B1042001369F5 /* component.cpp */; };
@ -2146,10 +2146,10 @@
B55BE03D11234AD700154E6C /* engine_lua.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = engine_lua.hpp; sourceTree = "<group>"; };
B55BE03E11234AD700154E6C /* property_handler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = property_handler.hpp; sourceTree = "<group>"; };
B55BE03F11234AD700154E6C /* value_translator.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = value_translator.hpp; sourceTree = "<group>"; };
B55BE04711234B1A00154E6C /* data.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = data.cpp; sourceTree = "<group>"; };
B55BE04811234B1A00154E6C /* data.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = data.hpp; sourceTree = "<group>"; };
B55BE04911234B1A00154E6C /* info.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = info.cpp; sourceTree = "<group>"; };
B55BE04A11234B1A00154E6C /* info.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = info.hpp; sourceTree = "<group>"; };
B55BE04711234B1A00154E6C /* lobby_data.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lobby_data.cpp; sourceTree = "<group>"; };
B55BE04811234B1A00154E6C /* lobby_data.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lobby_data.hpp; sourceTree = "<group>"; };
B55BE04911234B1A00154E6C /* lobby_info.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lobby_info.cpp; sourceTree = "<group>"; };
B55BE04A11234B1A00154E6C /* lobby_info.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lobby_info.hpp; sourceTree = "<group>"; };
B55BE04F11234B3300154E6C /* tree_view_node.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tree_view_node.cpp; sourceTree = "<group>"; };
B55BE05011234B3300154E6C /* tree_view_node.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tree_view_node.hpp; sourceTree = "<group>"; };
B55BE05111234B3300154E6C /* tree_view.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tree_view.cpp; sourceTree = "<group>"; };
@ -3590,6 +3590,10 @@
91B621C11B76B44300B00E0F /* depcheck.hpp */,
EC2F60011A048E210018C9D6 /* flg_manager.cpp */,
91B621C21B76B44300B00E0F /* flg_manager.hpp */,
B55BE04711234B1A00154E6C /* lobby_data.cpp */,
B55BE04811234B1A00154E6C /* lobby_data.hpp */,
B55BE04911234B1A00154E6C /* lobby_info.cpp */,
B55BE04A11234B1A00154E6C /* lobby_info.hpp */,
91B621C31B76B44300B00E0F /* lobby_reload_request_exception.hpp */,
EC2F60021A048E210018C9D6 /* mp_game_utils.cpp */,
91B621C41B76B44400B00E0F /* mp_game_utils.hpp */,
@ -4047,10 +4051,6 @@
B55BE04611234B1A00154E6C /* lobby */ = {
isa = PBXGroup;
children = (
B55BE04711234B1A00154E6C /* data.cpp */,
B55BE04811234B1A00154E6C /* data.hpp */,
B55BE04911234B1A00154E6C /* info.cpp */,
B55BE04A11234B1A00154E6C /* info.hpp */,
B54AC6EF0FEA9F92006F6FBD /* lobby.cpp */,
B54AC6F00FEA9F92006F6FBD /* lobby.hpp */,
B59F96EB1034796700A57C1A /* player_info.cpp */,
@ -5039,8 +5039,8 @@
EC67F7F01DB3144A0038337E /* constants.cpp in Sources */,
B52EE89D1213590500CFBDAB /* list.cpp in Sources */,
B5A9BD650ECA805A002BE442 /* listbox.cpp in Sources */,
B55BE04B11234B1A00154E6C /* data.cpp in Sources */,
B55BE04C11234B1A00154E6C /* info.cpp in Sources */,
B55BE04B11234B1A00154E6C /* lobby_data.cpp in Sources */,
B55BE04C11234B1A00154E6C /* lobby_info.cpp in Sources */,
B54AC6F50FEA9F92006F6FBD /* lobby.cpp in Sources */,
B59F96ED1034796700A57C1A /* player_info.cpp in Sources */,
B52EE8D2121359A600CFBDAB /* lobby_preferences.cpp in Sources */,
@ -5821,8 +5821,8 @@
91A215C91CAD968400927AEA /* new_map.cpp in Sources */,
91A215CA1CAD968400927AEA /* resize_map.cpp in Sources */,
91A215CB1CAD968400927AEA /* set_starting_position.cpp in Sources */,
91A215CC1CAD969200927AEA /* data.cpp in Sources */,
91A215CD1CAD969200927AEA /* info.cpp in Sources */,
91A215CC1CAD969200927AEA /* lobby_data.cpp in Sources */,
91A215CD1CAD969200927AEA /* lobby_info.cpp in Sources */,
91A215CE1CAD969200927AEA /* lobby.cpp in Sources */,
91A215CF1CAD969200927AEA /* player_info.cpp in Sources */,
91A215D01CAD96D900927AEA /* mp_alerts_options.cpp in Sources */,

View file

@ -672,6 +672,8 @@ set(wesnoth-main_SRC
config_cache.cpp
game_initialization/configure_engine.cpp
game_initialization/connect_engine.cpp
game_initialization/lobby_data.cpp
game_initialization/lobby_info.cpp
controller_base.cpp
countdown_clock.cpp
game_initialization/create_engine.cpp
@ -785,8 +787,6 @@ set(wesnoth-main_SRC
gui/dialogs/label_settings.cpp
gui/dialogs/language_selection.cpp
gui/dialogs/loadscreen.cpp
gui/dialogs/lobby/data.cpp
gui/dialogs/lobby/info.cpp
gui/dialogs/lobby/lobby.cpp
gui/dialogs/lobby/player_info.cpp
gui/dialogs/logging.cpp

View file

@ -316,6 +316,8 @@ wesnoth_sources = Split("""
game_initialization/create_engine.cpp
game_initialization/depcheck.cpp
game_initialization/flg_manager.cpp
game_initialization/lobby_data.cpp
game_initialization/lobby_info.cpp
game_initialization/mp_game_utils.cpp
game_initialization/multiplayer.cpp
game_initialization/playcampaign.cpp
@ -384,8 +386,6 @@ wesnoth_sources = Split("""
gui/dialogs/label_settings.cpp
gui/dialogs/language_selection.cpp
gui/dialogs/loadscreen.cpp
gui/dialogs/lobby/data.cpp
gui/dialogs/lobby/info.cpp
gui/dialogs/lobby/lobby.cpp
gui/dialogs/lobby/player_info.cpp
gui/dialogs/logging.cpp

View file

@ -12,7 +12,7 @@
See the COPYING file for more details.
*/
#include "gui/dialogs/lobby/data.hpp"
#include "game_initialization/lobby_data.hpp"
#include "config.hpp"
#include "game_preferences.hpp"
@ -42,6 +42,8 @@ static lg::log_domain log_lobby("lobby");
#define LOG_LB LOG_STREAM(info, log_lobby)
#define ERR_LB LOG_STREAM(err, log_lobby)
namespace mp {
chat_message::chat_message(const time_t& timestamp,
const std::string& user,
const std::string& message)
@ -529,3 +531,5 @@ bool game_info::match_string_filter(const std::string& filter) const
|| std::search(s2.begin(), s2.end(), filter.begin(), filter.end(),
chars_equal_insensitive) != s2.end();
}
}

View file

@ -23,6 +23,8 @@
class config;
namespace mp {
/** This class represents a single stored chat message */
struct chat_message
{
@ -203,4 +205,6 @@ struct game_info
bool match_string_filter(const std::string& filter) const;
};
}
#endif

View file

@ -12,7 +12,7 @@
See the COPYING file for more details.
*/
#include "gui/dialogs/lobby/info.hpp"
#include "game_initialization/lobby_info.hpp"
#include "config.hpp"
#include "game_preferences.hpp"
@ -35,6 +35,7 @@ static lg::log_domain log_lobby("lobby");
#define ERR_LB LOG_STREAM(err, log_lobby)
#define SCOPE_LB log_scope2(log_lobby, __func__)
namespace mp {
lobby_info::lobby_info(const config& game_config, const std::vector<std::string>& installed_addons)
: game_config_(game_config)
@ -65,9 +66,8 @@ void lobby_info::delete_games()
delete v.second;
}
}
namespace gui2
{
void do_mp_notify(notify_mode mode, const std::string & sender, const std::string & message)
void do_notify(notify_mode mode, const std::string & sender, const std::string & message)
{
switch (mode) {
case NOTIFY_WHISPER:
@ -94,7 +94,7 @@ void do_mp_notify(notify_mode mode, const std::string & sender, const std::strin
break;
}
}
} // namespace gui2
namespace
{
@ -406,3 +406,5 @@ const std::vector<user_info*>& lobby_info::users_sorted() const
{
return users_sorted_;
}
}

View file

@ -16,9 +16,11 @@
#define INC_LOBBY_INFO
#include "config.hpp"
#include "gui/dialogs/lobby/data.hpp"
#include "game_initialization/lobby_data.hpp"
#include <boost/dynamic_bitset.hpp>
namespace mp {
/**
* This class represents the collective information the client has
* about the players and games on the server
@ -133,9 +135,8 @@ enum notify_mode {
NOTIFY_COUNT
};
namespace gui2
{
void do_mp_notify(notify_mode mode, const std::string & sender, const std::string & message);
inline void do_mp_notify(notify_mode mode) { do_mp_notify(mode, "", ""); }
void do_notify(notify_mode mode, const std::string & sender, const std::string & message);
inline void do_notify(notify_mode mode) { do_notify(mode, "", ""); }
}
#endif

View file

@ -355,7 +355,7 @@ static std::unique_ptr<wesnothd_connection> open_connection(CVideo& video, const
// 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, wesnothd_connection* connection,
lobby_info& li, bool observe, int current_turn = 0)
mp::lobby_info& li, bool observe, int current_turn = 0)
{
DBG_MP << "entering wait mode" << std::endl;
@ -392,10 +392,10 @@ static void enter_wait_mode(CVideo& video, const config& game_config, saved_game
}
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);
mp::lobby_info& li, bool local_players_only = false);
static bool enter_connect_mode(CVideo& video, const config& game_config,
saved_game& state, wesnothd_connection* connection, lobby_info& li,
saved_game& state, wesnothd_connection* connection, mp::lobby_info& li,
bool local_players_only = false)
{
DBG_MP << "entering connect mode" << std::endl;
@ -430,7 +430,7 @@ static bool enter_connect_mode(CVideo& video, const config& game_config,
}
static void enter_create_mode(CVideo& video, const config& game_config,
saved_game& state, wesnothd_connection* connection, lobby_info& li, bool local_players_only)
saved_game& state, wesnothd_connection* connection, mp::lobby_info& li, bool local_players_only)
{
DBG_MP << "entering create mode" << std::endl;
@ -485,7 +485,7 @@ static void enter_lobby_mode(CVideo& video, const config& game_config,
sound::empty_playlist();
sound::stop_music();
}
lobby_info li(game_config, installed_addons);
mp::lobby_info li(game_config, installed_addons);
gui2::dialogs::lobby_main dlg(game_config, li, *connection);
dlg.set_preferences_callback(std::bind(do_preferences_dialog, std::ref(video), std::ref(game_config)));

View file

@ -124,7 +124,7 @@ bool lobby_main::logout_prompt()
return show_prompt(_("Do you really want to log out?"));
}
lobby_main::lobby_main(const config& game_config, lobby_info& info, wesnothd_connection &connection)
lobby_main::lobby_main(const config& game_config, mp::lobby_info& info, wesnothd_connection &connection)
: quit_confirmation(&lobby_main::logout_prompt)
, game_config_(game_config)
, gamelistbox_(nullptr)
@ -260,7 +260,7 @@ void lobby_main::update_gamelist()
int select_row = -1;
for(unsigned i = 0; i < lobby_info_.games().size(); ++i) {
const game_info& game = *lobby_info_.games()[i];
const mp::game_info& game = *lobby_info_.games()[i];
if(game.id == selected_game_id_) {
select_row = i;
@ -296,9 +296,9 @@ void lobby_main::update_gamelist_diff()
std::vector<int> next_gamelist_id_at_row;
for(unsigned i = 0; i < lobby_info_.games().size(); ++i) {
const game_info& game = *lobby_info_.games()[i];
const mp::game_info& game = *lobby_info_.games()[i];
if(game.display_status == game_info::NEW) {
if(game.display_status == mp::game_info::NEW) {
LOG_LB << "Adding game to listbox " << game.id << "\n";
if(list_i != gamelistbox_->get_item_count()) {
@ -339,14 +339,14 @@ void lobby_main::update_gamelist_diff()
return;
}
if(game.display_status == game_info::UPDATED) {
if(game.display_status == mp::game_info::UPDATED) {
LOG_LB << "Modifying game in listbox " << game.id << " (row " << list_i << ")\n";
grid* grid = gamelistbox_->get_row_grid(list_i);
modify_grid_with_data(grid, make_game_row_data(game));
adjust_game_row_contents(game, list_i, grid);
++list_i;
next_gamelist_id_at_row.push_back(game.id);
} else if(game.display_status == game_info::DELETED) {
} else if(game.display_status == mp::game_info::DELETED) {
LOG_LB << "Deleting game from listbox " << game.id << " (row "
<< list_i << ")\n";
gamelistbox_->remove_row(list_i);
@ -398,7 +398,7 @@ void lobby_main::update_gamelist_header()
#endif
}
std::map<std::string, string_map> lobby_main::make_game_row_data(const game_info& game)
std::map<std::string, string_map> lobby_main::make_game_row_data(const mp::game_info& game)
{
std::map<std::string, string_map> data;
@ -449,7 +449,7 @@ std::map<std::string, string_map> lobby_main::make_game_row_data(const game_info
return data;
}
void lobby_main::adjust_game_row_contents(const game_info& game,
void lobby_main::adjust_game_row_contents(const mp::game_info& game,
int idx,
grid* grid)
{
@ -524,7 +524,7 @@ void lobby_main::update_playerlist()
player_list_.sort_by_relation->get_value_bool());
bool lobby = false;
if(room_info* ri = chatbox_->active_window_room()) {
if(mp::room_info* ri = chatbox_->active_window_room()) {
if(ri->name() == "lobby") {
lobby = true;
}
@ -541,7 +541,7 @@ void lobby_main::update_playerlist()
player_list_.other_rooms.tree->clear();
for(auto userptr : lobby_info_.users_sorted()) {
user_info& user = *userptr;
mp::user_info& user = *userptr;
sub_player_list* target_list(nullptr);
std::map<std::string, string_map> data;
@ -550,23 +550,23 @@ void lobby_main::update_playerlist()
std::stringstream icon_ss;
icon_ss << "lobby/status";
switch(user.state) {
case user_info::SEL_ROOM:
case mp::user_info::SEL_ROOM:
icon_ss << "-lobby";
target_list = &player_list_.active_room;
if(lobby) {
target_list = &player_list_.other_rooms;
}
break;
case user_info::LOBBY:
case mp::user_info::LOBBY:
icon_ss << "-lobby";
target_list = &player_list_.other_rooms;
break;
case user_info::SEL_GAME:
case mp::user_info::SEL_GAME:
name = colorize(name, "cyan");
icon_ss << (user.observing ? "-obs" : "-playing");
target_list = &player_list_.active_game;
break;
case user_info::GAME:
case mp::user_info::GAME:
name = colorize(name, "red");
icon_ss << (user.observing ? "-obs" : "-playing");
target_list = &player_list_.other_games;
@ -578,16 +578,16 @@ void lobby_main::update_playerlist()
}
switch(user.relation) {
case user_info::ME:
case mp::user_info::ME:
icon_ss << "-s";
break;
case user_info::NEUTRAL:
case mp::user_info::NEUTRAL:
icon_ss << "-n";
break;
case user_info::FRIEND:
case mp::user_info::FRIEND:
icon_ss << "-f";
break;
case user_info::IGNORED:
case mp::user_info::IGNORED:
icon_ss << "-i";
break;
default:
@ -640,7 +640,7 @@ void lobby_main::update_selected_game()
bool can_join = false, can_observe = false;
if(idx >= 0) {
const game_info& game = *lobby_info_.games()[idx];
const mp::game_info& game = *lobby_info_.games()[idx];
can_observe = game.can_observe();
can_join = game.can_join();
selected_game_id_ = game.id;
@ -866,9 +866,9 @@ void lobby_main::process_gamelist_diff(const config& data)
const int left = data.child_count("remove_child");
if(joined > 0 || left > 0) {
if(left > joined) {
do_notify(NOTIFY_LOBBY_QUIT);
do_notify(mp::NOTIFY_LOBBY_QUIT);
} else {
do_notify(NOTIFY_LOBBY_JOIN);
do_notify(mp::NOTIFY_LOBBY_JOIN);
}
}
}
@ -889,15 +889,15 @@ void lobby_main::join_global_button_callback(window& window)
void lobby_main::join_or_observe(int idx)
{
const game_info& game = *lobby_info_.games()[idx];
const mp::game_info& game = *lobby_info_.games()[idx];
if(do_game_join(idx, !game.can_join())) {
window_->set_retval(game.can_join() ? JOIN : OBSERVE);
}
}
static bool handle_addon_requirements_gui(CVideo& v, const std::vector<game_info::required_addon>& reqs, game_info::ADDON_REQ addon_outcome)
static bool handle_addon_requirements_gui(CVideo& v, const std::vector<mp::game_info::required_addon>& reqs, mp::game_info::ADDON_REQ addon_outcome)
{
if(addon_outcome == game_info::CANNOT_SATISFY) {
if(addon_outcome == mp::game_info::CANNOT_SATISFY) {
std::string e_title = _("Incompatible User-made Content.");
std::string err_msg = _("This game cannot be joined because the host has out-of-date add-ons that are incompatible with your version. You might wish to suggest that the host's add-ons be updated.");
@ -905,15 +905,15 @@ static bool handle_addon_requirements_gui(CVideo& v, const std::vector<game_info
err_msg += _("Details:");
err_msg += "\n";
for(const game_info::required_addon & a : reqs) {
if (a.outcome == game_info::CANNOT_SATISFY) {
for(const mp::game_info::required_addon & a : reqs) {
if (a.outcome == mp::game_info::CANNOT_SATISFY) {
err_msg += "" + a.message + "\n";
}
}
gui2::show_message(v, e_title, err_msg, message::auto_close);
return false;
} else if(addon_outcome == game_info::NEED_DOWNLOAD) {
} else if(addon_outcome == mp::game_info::NEED_DOWNLOAD) {
std::string e_title = _("Missing User-made Content.");
std::string err_msg = _("This game requires one or more user-made addons to be installed or updated in order to join.\nDo you want to try to install them?");
@ -922,8 +922,8 @@ static bool handle_addon_requirements_gui(CVideo& v, const std::vector<game_info
err_msg += "\n";
std::vector<std::string> needs_download;
for(const game_info::required_addon & a : reqs) {
if(a.outcome == game_info::NEED_DOWNLOAD) {
for(const mp::game_info::required_addon & a : reqs) {
if(a.outcome == mp::game_info::NEED_DOWNLOAD) {
err_msg += "" + a.message + "\n";
needs_download.push_back(a.addon_id);
@ -954,7 +954,7 @@ bool lobby_main::do_game_join(int idx, bool observe)
<< idx << ", games size is " << lobby_info_.games().size() << "\n";
return false;
}
const game_info& game = *lobby_info_.games()[idx];
const mp::game_info& game = *lobby_info_.games()[idx];
if(observe) {
if(!game.can_observe()) {
ERR_LB << "Requested observe of a game with observers disabled" << std::endl;
@ -968,7 +968,7 @@ bool lobby_main::do_game_join(int idx, bool observe)
}
// Prompt user to download this game's required addons if its requirements have not been met
if(game.addons_outcome != game_info::SATISFIED) {
if(game.addons_outcome != mp::game_info::SATISFIED) {
if(game.required_addons.empty()) {
gui2::show_error_message(window_->video(), _("Something is wrong with the addon version check database supporting the multiplayer lobby. Please report this at http://bugs.wesnoth.org."));
return false;
@ -1025,26 +1025,26 @@ void lobby_main::game_filter_reload()
lobby_info_.clear_game_filter();
for(const auto& s : utils::split(filter_text_->get_value(), ' ')) {
lobby_info_.add_game_filter([s](const game_info& info)->bool {
lobby_info_.add_game_filter([s](const mp::game_info& info)->bool {
return info.match_string_filter(s);
});
}
// TODO: make changing friend/ignore lists trigger a refresh
if(filter_friends_->get_value()) {
lobby_info_.add_game_filter([](const game_info& info)->bool {
lobby_info_.add_game_filter([](const mp::game_info& info)->bool {
return info.has_friends == true;
});
}
if(filter_ignored_->get_value()) {
lobby_info_.add_game_filter([](const game_info& info)->bool {
lobby_info_.add_game_filter([](const mp::game_info& info)->bool {
return info.has_ignored == false;
});
}
if(filter_slots_->get_value()) {
lobby_info_.add_game_filter([](const game_info& info)->bool {
lobby_info_.add_game_filter([](const mp::game_info& info)->bool {
return info.vacant_slots > 0;
});
}
@ -1082,7 +1082,7 @@ void lobby_main::player_filter_callback(gui2::widget& /*widget*/)
// window_->invalidate_layout();
}
void lobby_main::user_dialog_callback(user_info* info)
void lobby_main::user_dialog_callback(mp::user_info* info)
{
lobby_player_info dlg(*chatbox_, *info, lobby_info_);
@ -1131,7 +1131,7 @@ void lobby_main::skip_replay_changed_callback(window& window)
int lobby_main::get_game_index_from_id(const int game_id) const
{
if(game_info* game = lobby_info_.get_game_by_id(game_id)) {
if(mp::game_info* game = lobby_info_.get_game_by_id(game_id)) {
return std::find(lobby_info_.games().begin(), lobby_info_.games().end(), game) - lobby_info_.games().begin();
}

View file

@ -18,7 +18,7 @@
#include "gui/dialogs/dialog.hpp"
#include "gui/widgets/tree_view.hpp"
#include "chat_events.hpp"
#include "gui/dialogs/lobby/info.hpp"
#include "game_initialization/lobby_info.hpp"
#include "gui/dialogs/multiplayer/plugin_executor.hpp"
#include "game_initialization/multiplayer.hpp"
#include "quit_confirmation.hpp"
@ -73,7 +73,7 @@ struct player_list
class lobby_main : public modal_dialog, public quit_confirmation, private plugin_executor
{
public:
lobby_main(const config& game_config, lobby_info& info, wesnothd_connection &connection);
lobby_main(const config& game_config, mp::lobby_info& info, wesnothd_connection &connection);
~lobby_main();
@ -94,9 +94,9 @@ protected:
void update_gamelist_filter();
std::map<std::string, string_map> make_game_row_data(const game_info& game);
std::map<std::string, string_map> make_game_row_data(const mp::game_info& game);
void adjust_game_row_contents(const game_info& game, int idx, grid* grid);
void adjust_game_row_contents(const mp::game_info& game, int idx, grid* grid);
public:
void update_playerlist();
@ -108,9 +108,6 @@ public:
CREATE
};
void do_notify(notify_mode mode) { do_notify(mode, "", ""); }
void do_notify(notify_mode mode, const std::string & sender, const std::string & message) { do_mp_notify(mode, sender, message); }
protected:
private:
@ -155,7 +152,7 @@ private:
void player_filter_callback(widget& widget);
void user_dialog_callback(user_info* info);
void user_dialog_callback(mp::user_info* info);
void skip_replay_changed_callback(window& window);
@ -183,7 +180,7 @@ private:
window* window_;
lobby_info& lobby_info_;
mp::lobby_info& lobby_info_;
chatbox* chatbox_;

View file

@ -33,8 +33,8 @@ namespace dialogs
REGISTER_DIALOG(lobby_player_info)
lobby_player_info::lobby_player_info(events::chat_handler& chat,
user_info& info,
const lobby_info& li)
mp::user_info& info,
const mp::lobby_info& li)
: chat_(chat)
, info_(info)
, reason_(nullptr)
@ -98,7 +98,7 @@ void lobby_player_info::pre_show(window& window)
find_widget<label>(&window, "player_name", false).set_label(info_.name);
std::stringstream loc;
const game_info* game = lobby_info_.get_game_by_id(info_.game_id);
const mp::game_info* game = lobby_info_.get_game_by_id(info_.game_id);
if(game != nullptr) {
loc << _("In game:") << " " << game->name << " ";
if(info_.observing) {
@ -133,22 +133,22 @@ void lobby_player_info::update_relation()
add_to_ignores_->set_active(false);
remove_from_list_->set_active(false);
switch(info_.relation) {
case user_info::FRIEND:
case mp::user_info::FRIEND:
relation_->set_label(_("On friends list"));
add_to_ignores_->set_active(true);
remove_from_list_->set_active(true);
break;
case user_info::IGNORED:
case mp::user_info::IGNORED:
relation_->set_label(_("On ignores list"));
add_to_friends_->set_active(true);
remove_from_list_->set_active(true);
break;
case user_info::NEUTRAL:
case mp::user_info::NEUTRAL:
relation_->set_label(_("Neither a friend nor ignored"));
add_to_friends_->set_active(true);
add_to_ignores_->set_active(true);
break;
case user_info::ME:
case mp::user_info::ME:
relation_->set_label(_("You"));
break;
default:
@ -159,21 +159,21 @@ void lobby_player_info::update_relation()
void lobby_player_info::add_to_friends_button_callback()
{
preferences::add_acquaintance(info_.name, "friend", "");
info_.relation = user_info::FRIEND;
info_.relation = mp::user_info::FRIEND;
update_relation();
}
void lobby_player_info::add_to_ignores_button_callback()
{
preferences::add_acquaintance(info_.name, "ignore", "");
info_.relation = user_info::IGNORED;
info_.relation = mp::user_info::IGNORED;
update_relation();
}
void lobby_player_info::remove_from_list_button_callback()
{
preferences::remove_acquaintance(info_.name);
info_.relation = user_info::NEUTRAL;
info_.relation = mp::user_info::NEUTRAL;
update_relation();
}

View file

@ -17,7 +17,7 @@
#include "gui/dialogs/dialog.hpp"
#include "chat_events.hpp"
#include "gui/dialogs/lobby/info.hpp"
#include "game_initialization/lobby_info.hpp"
namespace gui2
{
@ -33,8 +33,8 @@ class lobby_player_info : public modal_dialog
{
public:
lobby_player_info(events::chat_handler& chat,
user_info& info,
const lobby_info& li);
mp::user_info& info,
const mp::lobby_info& li);
~lobby_player_info();
@ -73,7 +73,7 @@ private:
events::chat_handler& chat_;
user_info& info_;
mp::user_info& info_;
text_box* reason_;
@ -89,7 +89,7 @@ private:
bool result_open_whisper_;
const lobby_info& lobby_info_;
const mp::lobby_info& lobby_info_;
};
} // namespace dialogs

View file

@ -54,7 +54,7 @@ namespace dialogs
REGISTER_DIALOG(mp_join_game)
mp_join_game::mp_join_game(saved_game& state, lobby_info& lobby_info, wesnothd_connection& connection, const bool first_scenario, const bool observe_game)
mp_join_game::mp_join_game(saved_game& state, mp::lobby_info& lobby_info, wesnothd_connection& connection, const bool first_scenario, const bool observe_game)
: level_()
, state_(state)
, lobby_info_(lobby_info)

View file

@ -16,7 +16,7 @@
#include "ai/configuration.hpp"
#include "gui/dialogs/dialog.hpp"
#include "gui/dialogs/lobby/info.hpp"
#include "game_initialization/lobby_info.hpp"
#include "gui/dialogs/multiplayer/plugin_executor.hpp"
#include "game_initialization/connect_engine.hpp"
@ -37,7 +37,7 @@ namespace dialogs
class mp_join_game : public modal_dialog, private plugin_executor
{
public:
mp_join_game(saved_game& state, lobby_info& lobby_info, wesnothd_connection& connection,
mp_join_game(saved_game& state, mp::lobby_info& lobby_info, wesnothd_connection& connection,
const bool first_scenario = true, const bool observe_game = false);
~mp_join_game();
@ -71,7 +71,7 @@ private:
saved_game& state_;
lobby_info& lobby_info_;
mp::lobby_info& lobby_info_;
wesnothd_connection& wesnothd_connection_;

View file

@ -50,7 +50,7 @@ namespace dialogs
REGISTER_DIALOG(mp_staging)
mp_staging::mp_staging(ng::connect_engine& connect_engine, lobby_info& lobby_info, wesnothd_connection* connection)
mp_staging::mp_staging(ng::connect_engine& connect_engine, mp::lobby_info& lobby_info, wesnothd_connection* connection)
: connect_engine_(connect_engine)
, ai_algorithms_(ai::configuration::get_available_ais())
, lobby_info_(lobby_info)

View file

@ -16,7 +16,7 @@
#include "ai/configuration.hpp"
#include "gui/dialogs/dialog.hpp"
#include "gui/dialogs/lobby/info.hpp"
#include "game_initialization/lobby_info.hpp"
#include "gui/dialogs/multiplayer/plugin_executor.hpp"
#include "game_initialization/connect_engine.hpp"
@ -38,7 +38,7 @@ namespace dialogs
class mp_staging : public modal_dialog, private plugin_executor
{
public:
mp_staging(ng::connect_engine& connect_engine, lobby_info& lobby_info, wesnothd_connection* connection = nullptr);
mp_staging(ng::connect_engine& connect_engine, mp::lobby_info& lobby_info, wesnothd_connection* connection = nullptr);
~mp_staging();
@ -79,7 +79,7 @@ private:
std::vector<ai::description*> ai_algorithms_;
lobby_info& lobby_info_;
mp::lobby_info& lobby_info_;
wesnothd_connection* wesnothd_connection_;

View file

@ -152,7 +152,7 @@ void chatbox::chat_input_keypress_callback(bool& handled, bool& halt, const SDL_
std::string text = chat_input_->get_value();
std::vector<std::string> matches;
for(const auto& ui : lobby_info().users()) {
for(const auto& ui : lobby_info_->users()) {
if(ui.name != preferences::login()) {
matches.push_back(ui.name);
}
@ -265,7 +265,7 @@ void chatbox::add_whisper_sent(const std::string& receiver, const std::string& m
add_active_window_whisper(vgettext("whisper to $receiver", {{"receiver", receiver}}), message, true);
}
lobby_info().get_whisper_log(receiver).add_message(preferences::login(), message);
lobby_info_->get_whisper_log(receiver).add_message(preferences::login(), message);
}
void chatbox::add_whisper_received(const std::string& sender, const std::string& message)
@ -273,22 +273,22 @@ void chatbox::add_whisper_received(const std::string& sender, const std::string&
bool can_go_to_active = !preferences::whisper_friends_only() || preferences::is_friend(sender);
bool can_open_new = preferences::auto_open_whisper_windows() && can_go_to_active;
lobby_info().get_whisper_log(sender).add_message(sender, message);
lobby_info_->get_whisper_log(sender).add_message(sender, message);
if(whisper_window_open(sender, can_open_new)) {
if(whisper_window_active(sender)) {
add_active_window_message(sender, message);
do_notify(NOTIFY_WHISPER, sender, message);
do_notify(mp::NOTIFY_WHISPER, sender, message);
} else {
add_whisper_window_whisper(sender, message);
increment_waiting_whsipers(sender);
do_notify(NOTIFY_WHISPER_OTHER_WINDOW, sender, message);
do_notify(mp::NOTIFY_WHISPER_OTHER_WINDOW, sender, message);
}
} else if(can_go_to_active) {
add_active_window_whisper(sender, message);
do_notify(NOTIFY_WHISPER, sender, message);
do_notify(mp::NOTIFY_WHISPER, sender, message);
} else {
LOG_LB << "Ignoring whisper from " << sender << "\n";
}
@ -304,7 +304,7 @@ void chatbox::add_chat_room_message_sent(const std::string& room,
}
// Do not open room window here. The player should be in the room before sending messages
room_info* ri = lobby_info().get_room(room);
mp::room_info* ri = lobby_info_->get_room(room);
assert(ri);
if(!room_window_active(room)) {
@ -319,30 +319,30 @@ void chatbox::add_chat_room_message_received(const std::string& room,
const std::string& speaker,
const std::string& message)
{
room_info* ri = lobby_info().get_room(room);
mp::room_info* ri = lobby_info_->get_room(room);
if(!ri) {
LOG_LB << "Discarding message to room " << room << " from " << speaker << " (room not open)\n";
return;
}
notify_mode notify_mode = NOTIFY_NONE;
mp::notify_mode notify_mode = mp::NOTIFY_NONE;
ri->log().add_message(speaker, message);
if(room_window_active(room)) {
add_active_window_message(speaker, message);
notify_mode = NOTIFY_MESSAGE;
notify_mode = mp::NOTIFY_MESSAGE;
} else {
add_room_window_message(room, speaker, message);
increment_waiting_messages(room);
notify_mode = NOTIFY_MESSAGE_OTHER_WINDOW;
notify_mode = mp::NOTIFY_MESSAGE_OTHER_WINDOW;
}
if(speaker == "server") {
notify_mode = NOTIFY_SERVER_MESSAGE;
notify_mode = mp::NOTIFY_SERVER_MESSAGE;
} else if (utils::word_match(message, preferences::login())) {
notify_mode = NOTIFY_OWN_NICK;
notify_mode = mp::NOTIFY_OWN_NICK;
} else if (preferences::is_friend(speaker)) {
notify_mode = NOTIFY_FRIEND_MESSAGE;
notify_mode = mp::NOTIFY_FRIEND_MESSAGE;
}
do_notify(notify_mode, speaker, message);
@ -400,7 +400,7 @@ lobby_chat_window* chatbox::search_create_window(const std::string& name,
item["label"] = vgettext("Room <i>“$name”</i> joined", {{"name", name}});
data.emplace("log_text", item);
lobby_info().open_room(name);
lobby_info_->open_room(name);
}
chat_log_container_->add_page(data);
@ -519,9 +519,9 @@ void chatbox::close_window(size_t idx)
}
if(t.whisper) {
lobby_info().get_whisper_log(t.name).clear();
lobby_info_->get_whisper_log(t.name).clear();
} else {
lobby_info().close_room(t.name);
lobby_info_->close_room(t.name);
}
open_windows_.erase(open_windows_.begin() + idx);
@ -560,14 +560,14 @@ void chatbox::add_active_window_message(const std::string& sender,
}
room_info* chatbox::active_window_room()
mp::room_info* chatbox::active_window_room()
{
const lobby_chat_window& t = open_windows_[active_window_];
if(t.whisper) {
return nullptr;
}
return lobby_info().get_room(t.name);
return lobby_info_->get_room(t.name);
}
void chatbox::process_room_join(const ::config& data)
@ -577,7 +577,7 @@ void chatbox::process_room_join(const ::config& data)
DBG_LB << "room join: " << room << " " << player << "\n";
room_info* r = lobby_info().get_room(room);
mp::room_info* r = lobby_info_->get_room(room);
if(r) {
if(player == preferences::login()) {
if(const auto& members = data.child("members")) {
@ -596,8 +596,8 @@ void chatbox::process_room_join(const ::config& data)
} else {
if(player == preferences::login()) {
lobby_chat_window* t = room_window_open(room, true);
lobby_info().open_room(room);
r = lobby_info().get_room(room);
lobby_info_->open_room(room);
r = lobby_info_->get_room(room);
assert(r);
if(const auto& members = data.child("members")) {
r->process_room_members(members);
@ -622,7 +622,7 @@ void chatbox::process_room_part(const ::config& data)
DBG_LB << "Room part: " << room << " " << player << "\n";
if(room_info* r = lobby_info().get_room(room)) {
if(mp::room_info* r = lobby_info_->get_room(room)) {
r->remove_member(player);
/* TODO: add/use preference */
@ -665,7 +665,7 @@ void chatbox::process_room_query_response(const ::config& data)
}
if(const ::config& members = data.child("members")) {
room_info* r = lobby_info().get_room(room);
mp::room_info* r = lobby_info_->get_room(room);
assert(r);
r->process_room_members(members);
if(r == active_window_room()) {

View file

@ -14,8 +14,8 @@
#pragma once
#include "gui/widgets/container.hpp"
#include "gui/dialogs/lobby/data.hpp"
#include "gui/dialogs/lobby/info.hpp"
#include "game_initialization/lobby_data.hpp"
#include "game_initialization/lobby_info.hpp"
#include "chat_events.hpp"
@ -72,7 +72,7 @@ public:
void set_active_window_changed_callback(const std::function<void(void)>& f) { active_window_changed_callback_ = f; }
void set_lobby_info(lobby_info& i) { lobby_info_ = &i; }
void set_lobby_info(mp::lobby_info& i) { lobby_info_ = &i; }
void set_wesnothd_connection(wesnothd_connection& c) { wesnothd_connection_ = &c; }
@ -125,9 +125,9 @@ private:
std::function<void(void)> active_window_changed_callback_;
class lobby_info* lobby_info_;
mp::lobby_info* lobby_info_;
class lobby_info& lobby_info() { return *lobby_info_; }
mp::lobby_info& get_lobby_info() { return *lobby_info_; }
wesnothd_connection* wesnothd_connection_;
@ -215,7 +215,7 @@ public:
* Get the room* corresponding to the currently active window, or nullptr
* if a whisper window is active at the moment
*/
room_info* active_window_room();
mp::room_info* active_window_room();
/**
* Check if a room window for "room" is open, if open_new is true
@ -239,9 +239,6 @@ public:
*/
lobby_chat_window* search_create_window(const std::string& name, const bool whisper, const bool open_new, const bool allow_close);
void do_notify(notify_mode mode) { do_notify(mode, "", ""); }
void do_notify(notify_mode mode, const std::string & sender, const std::string & message) { do_mp_notify(mode, sender, message); }
void close_window_button_callback(lobby_chat_window& chat_window, bool& handled, bool& halt);