client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
authorsheepluva
Sun, 09 Sep 2012 20:11:07 +0200
changeset 7683 993337e5021f
parent 7682 f6bfbe829008
child 7684 db140521d102
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
QTfrontend/net/newnetclient.cpp
QTfrontend/net/newnetclient.h
--- a/QTfrontend/net/newnetclient.cpp	Sun Sep 09 19:57:13 2012 +0400
+++ b/QTfrontend/net/newnetclient.cpp	Sun Sep 09 20:11:07 2012 +0200
@@ -357,6 +357,7 @@
 
         QString flags = lst[1];
         bool setFlag = flags[0] == '+';
+        const QStringList nicks = lst.mid(2);
 
         while(flags.size() > 1)
         {
@@ -366,18 +367,29 @@
             switch(c)
             {
                 case 'r':
-                {
-                    for(int i = 2; i < lst.size(); ++i)
-                    {
-                        if (lst[i] == mynick)
+                        foreach (const QString & nick, nicks)
                         {
-                            if (isChief && !setFlag) ToggleReady();
-                            else emit setMyReadyStatus(setFlag);
+                            if (nick == mynick)
+                            {
+                                if (isChief && !setFlag) ToggleReady();
+                                else emit setMyReadyStatus(setFlag);
+                            }
+                            emit setReadyStatus(nick, setFlag);
                         }
+                        break;
 
-                        emit setReadyStatus(lst[i], setFlag);
-                    }
-                }
+                case 'a':
+                        foreach (const QString & nick, nicks)
+                        {
+                            if (nick == mynick)
+                                emit adminAccess(setFlag);
+
+                            emit setAdminStatus(nick, setFlag);
+                        }
+                        break;
+
+                default:
+                        qWarning() << "Net: Unknown client-flag: " << c;
             }
         }
 
@@ -503,7 +515,7 @@
 
     if (lst[0] == "ADMIN_ACCESS")
     {
-        emit adminAccess(true);
+        // obsolete, see +a client flag
         return;
     }
 
--- a/QTfrontend/net/newnetclient.h	Sun Sep 09 19:57:13 2012 +0400
+++ b/QTfrontend/net/newnetclient.h	Sun Sep 09 20:11:07 2012 +0200
@@ -139,6 +139,7 @@
 
         void setReadyStatus(const QString & nick, bool isReady);
         void setMyReadyStatus(bool isReady);
+        void setAdminStatus(const QString & nick, bool isReady);
 
     public slots:
         void ToggleReady();