Skip to content

Commit

Permalink
add addon version checking and reporting to multiplayer lobby
Browse files Browse the repository at this point in the history
This also includes a refactor of the "set_game_items" function,
which was quite large and difficult to understand at a glance.
The refactor splits most of the work among 5 or 6 helper functions.

We also add some reporting of add-on status to the name, just as
with the (Unknown Era) string.

We also give the mp lobby a reference, at construction time, to
the list of currently installed add-ons, which will have the same
lifespan as the game_config reference which it is passed. This
ensures that this list is not changing based on add-on directory
contents, unless the lobby gets rebuilt. This is for the sanity
of the lobby, but it also makes testing easier.
  • Loading branch information
cbeck88 committed Mar 15, 2015
1 parent 5e81768 commit 6ffb9df
Show file tree
Hide file tree
Showing 4 changed files with 487 additions and 258 deletions.
15 changes: 11 additions & 4 deletions src/game_initialization/multiplayer.cpp
Expand Up @@ -13,6 +13,7 @@
*/
#include "multiplayer.hpp"

#include "addon/manager.hpp" // for get_installed_addons
#include "dialogs.hpp"
#include "formula_string_utils.hpp"
#include "game_preferences.hpp"
Expand Down Expand Up @@ -647,7 +648,7 @@ static void do_preferences_dialog(game_display& disp, const config& game_config)
}

static void enter_lobby_mode(game_display& disp, const config& game_config,
saved_game& state)
saved_game& state, const std::vector<std::string> & installed_addons)
{
DBG_MP << "entering lobby mode" << std::endl;

Expand Down Expand Up @@ -696,7 +697,7 @@ static void enter_lobby_mode(game_display& disp, const config& game_config,
res = mp::ui::QUIT;
}
} else {
mp::lobby ui(disp, game_config, gamechat, gamelist);
mp::lobby ui(disp, game_config, gamechat, gamelist, installed_addons);
run_lobby_loop(disp, ui);
res = ui.get_result();
}
Expand Down Expand Up @@ -906,6 +907,10 @@ void start_client(game_display& disp, const config& game_config,
saved_game& state, const std::string& host)
{
const config * game_config_ptr = &game_config;
std::vector<std::string> installed_addons = ::installed_addons();
// This function does not refer to an addon database, it calls filesystem functions.
// For the sanity of the mp lobby, this list should be fixed for the entire lobby session,
// even if the user changes the contents of the addon directory in the meantime.

DBG_MP << "starting client" << std::endl;
const network::manager net_manager(1,1);
Expand All @@ -920,14 +925,16 @@ void start_client(game_display& disp, const config& game_config,
do {
re_enter = false;
try {
enter_lobby_mode(disp, *game_config_ptr, state);
enter_lobby_mode(disp, *game_config_ptr, state, installed_addons);
} catch (lobby_reload_request_exception & ex) {
re_enter = true;
game_config_manager * gcm = game_config_manager::get();
gcm->reload_changed_game_config();
gcm->load_game_config_for_game(state.classification()); // NOTE: Using reload_changed_game_config doesn't seem to work here
gcm->load_game_config_for_game(state.classification()); // NOTE: Using reload_changed_game_config only doesn't seem to work here
game_config_ptr = &gcm->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
network::send_data(config("refresh_lobby"), 0);
}
Expand Down

0 comments on commit 6ffb9df

Please sign in to comment.