mail[Wesnoth-commits] r40144 - in /trunk/src: game_preferences.cpp game_preferences_display.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by guillaume . melquiond on December 06, 2009 - 14:36:
Author: silene
Date: Sun Dec  6 14:36:09 2009
New Revision: 40144

URL: http://svn.gna.org/viewcvs/wesnoth?rev=40144&view=rev
Log:
Simplified code a bit.

Modified:
    trunk/src/game_preferences.cpp
    trunk/src/game_preferences_display.cpp

Modified: trunk/src/game_preferences.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_preferences.cpp?rev=40144&r1=40143&r2=40144&view=diff
==============================================================================
--- trunk/src/game_preferences.cpp (original)
+++ trunk/src/game_preferences.cpp Sun Dec  6 14:36:09 2009
@@ -241,25 +241,26 @@
        return std::find(completed.begin(), completed.end(), campaign_id) != 
completed.end();
 }
 
-bool parse_should_show_lobby_join(const std::string& sender, const 
std::string& message) {
+bool parse_should_show_lobby_join(const std::string &sender, const 
std::string &message)
+{
        // If it's actually not a lobby join message return true (show it).
-       if (sender != "server" || message.find("has logged into the lobby") 
== std::string::npos) return true;
-       if (lobby_joins() == SHOW_NONE) return false;
-       if (lobby_joins() == SHOW_ALL) return true;
-       const std::string::const_iterator i =
-                       std::find(message.begin(), message.end(), ' ');
-       const std::string joiner(message.begin(), i);
-       if (lobby_joins() == SHOW_FRIENDS && is_friend(joiner)) return true;
-       return false;
+       if (sender != "server") return true;
+       std::string::size_type pos = message.find(" has logged into the 
lobby");
+       if (pos == std::string::npos) return true;
+       int lj = lobby_joins();
+       if (lj == SHOW_NONE) return false;
+       if (lj == SHOW_ALL) return true;
+       return is_friend(message.substr(0, pos));
 }
 
 int lobby_joins()
 {
-    if(preferences::get("lobby_joins") == "friends") {
+       std::string pref = preferences::get("lobby_joins");
+       if (pref == "friends") {
                return SHOW_FRIENDS;
-       } else if(preferences::get("lobby_joins") == "all") {
+       } else if (pref == "all") {
                return SHOW_ALL;
-       } else if(preferences::get("lobby_joins") == "none") {
+       } else if (pref == "none") {
                return SHOW_NONE;
        } else {
                return SHOW_FRIENDS;

Modified: trunk/src/game_preferences_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_preferences_display.cpp?rev=40144&r1=40143&r2=40144&view=diff
==============================================================================
--- trunk/src/game_preferences_display.cpp (original)
+++ trunk/src/game_preferences_display.cpp Sun Dec  6 14:36:09 2009
@@ -357,11 +357,12 @@
        remember_pw_button_.set_check(remember_password());
        remember_pw_button_.set_help_string(_("Uncheck to delete the saved 
password (on exit)."));
 
-       show_lobby_joins_button1_.set_check(lobby_joins() == SHOW_NONE);
+       int lj = lobby_joins();
+       show_lobby_joins_button1_.set_check(lj == SHOW_NONE);
        show_lobby_joins_button1_.set_help_string(_("Do not show messages 
about players joining the multiplayer lobby"));
-       show_lobby_joins_button2_.set_check(lobby_joins() == SHOW_FRIENDS);
+       show_lobby_joins_button2_.set_check(lj == SHOW_FRIENDS);
        show_lobby_joins_button2_.set_help_string(_("Show messages about your 
friends joining the multiplayer lobby"));
-       show_lobby_joins_button3_.set_check(lobby_joins() == SHOW_ALL);
+       show_lobby_joins_button3_.set_check(lj == SHOW_ALL);
        show_lobby_joins_button3_.set_help_string(_("Show messages about all 
players joining the multiplayer lobby"));
 
        mp_server_search_button_.set_help_string(_("Find and set path to MP 
server to host LAN games."));




Related Messages


Powered by MHonArc, Updated Sun Dec 06 15:00:07 2009