From d105aa86c4f199b132b6027e26129a72281fe928 Mon Sep 17 00:00:00 2001 From: "Ignacio R. Morelle" Date: Mon, 1 Jun 2015 23:39:27 -0300 Subject: [PATCH] mp: Reset authentication flag after disconnecting 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. --- src/game_initialization/multiplayer.cpp | 2 ++ src/game_preferences.cpp | 5 +++++ src/game_preferences.hpp | 11 +++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/game_initialization/multiplayer.cpp b/src/game_initialization/multiplayer.cpp index 3ae778bb8938..82b271ae18f7 100644 --- a/src/game_initialization/multiplayer.cpp +++ b/src/game_initialization/multiplayer.cpp @@ -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(); diff --git a/src/game_preferences.cpp b/src/game_preferences.cpp index 99a72cfa7cfc..e66505700811 100644 --- a/src/game_preferences.cpp +++ b/src/game_preferences.cpp @@ -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(); diff --git a/src/game_preferences.hpp b/src/game_preferences.hpp index 375e6313bdeb..b52e781a2e1a 100644 --- a/src/game_preferences.hpp +++ b/src/game_preferences.hpp @@ -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);