Skip to content

Commit

Permalink
mp: Reset authentication flag after disconnecting
Browse files Browse the repository at this point in the history
Otherwise it's possible to join once as moderator so that the MP mod
options are enabled, disconnect, reconnect again as non-moderator, and
still see the MP mod options enabled.

Yay for ugly hacks.
  • Loading branch information
irydacea committed Jun 2, 2015
1 parent e4af763 commit d105aa8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/game_initialization/multiplayer.cpp
Expand Up @@ -913,6 +913,8 @@ void start_client(game_display& disp, const config& game_config,
// even if the user changes the contents of the addon directory in the meantime.

DBG_MP << "starting client" << std::endl;

preferences::admin_authentication_reset r;
const network::manager net_manager(1,1);

gamechat.clear_history();
Expand Down
5 changes: 5 additions & 0 deletions src/game_preferences.cpp
Expand Up @@ -194,6 +194,11 @@ void parse_admin_authentication(const std::string& sender, const std::string& me
}
}

admin_authentication_reset::~admin_authentication_reset()
{
authenticated = false;
}

static void load_acquaintances() {
if(!acquaintances_initialized) {
acquaintances.clear();
Expand Down
11 changes: 11 additions & 0 deletions src/game_preferences.hpp
Expand Up @@ -42,6 +42,17 @@ class acquaintance;
bool is_authenticated();
void parse_admin_authentication(const std::string& sender, const std::string& message);

/**
* Used to reset is_authenticated flag after disconnecting.
*
* @todo FIXME: is_authenticated shouldn't be a preferences function. Also,
* the name is misleading.
*/
struct admin_authentication_reset
{
~admin_authentication_reset();
};

bool parse_should_show_lobby_join(const std::string& sender, const std::string& message);
int lobby_joins();
void _set_lobby_joins(int show);
Expand Down

0 comments on commit d105aa8

Please sign in to comment.