Author: mir3x
Date: Sat Dec  5 19:34:52 2015
New Revision: 30856

URL: http://svn.gna.org/viewcvs/freeciv?rev=30856&view=rev
Log:
Qt-client - Fixed private and global messages not being 
correctly sent when allies button is checked.

See bug #24134


Modified:
    branches/S2_6/client/gui-qt/chatline.cpp

Modified: branches/S2_6/client/gui-qt/chatline.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/chatline.cpp?rev=30856&r1=30855&r2=30856&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/chatline.cpp    (original)
+++ branches/S2_6/client/gui-qt/chatline.cpp    Sat Dec  5 19:34:52 2015
@@ -450,13 +450,43 @@
 {
   const char ALLIES_CHAT_PREFIX = '.';
   const char SERVER_COMMAND_PREFIX = '/';
-  QString str;
+  const char MESSAGE_PREFIX = ':';
+  QString s1, str;
+  int i;
 
   str = s.trimmed();
   if (str.at(0) == SERVER_COMMAND_PREFIX
-      || str.at(0) == ALLIES_CHAT_PREFIX) {
+      || str.at(0) == ALLIES_CHAT_PREFIX
+      || str.at(0) == MESSAGE_PREFIX) {
     return false;
   }
+
+  /* Search for private message */
+  if (!str.contains(':')) {
+    return true;
+  }
+  i = str.indexOf(':');
+  str = str.left(i);
+
+  /* Compare all players and connections looking for match */
+  conn_list_iterate(game.all_connections, pconn) {
+    s1 = pconn->username;
+    if (s1.length() < i) {
+      continue;
+    }
+    if (s1.left(i) == str) {
+      return false;
+    }
+  } conn_list_iterate_end;
+  players_iterate(pplayer) {
+    s1 = pplayer->name;
+    if (s1.length() < i) {
+      continue;
+    }
+    if (s1.left(i) == str) {
+      return false;
+    }
+  } players_iterate_end;
 
   return true;
 }


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to