wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src multiplayer_ui.cpp


From: David White
Subject: [Wesnoth-cvs-commits] wesnoth/src multiplayer_ui.cpp
Date: Fri, 22 Apr 2005 17:40:35 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     David White <address@hidden>    05/04/22 21:40:34

Modified files:
        src            : multiplayer_ui.cpp 

Log message:
        made /query commands work on the server again

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_ui.cpp.diff?tr1=1.19&tr2=1.20&r1=text&r2=text

Patches:
Index: wesnoth/src/multiplayer_ui.cpp
diff -u wesnoth/src/multiplayer_ui.cpp:1.19 wesnoth/src/multiplayer_ui.cpp:1.20
--- wesnoth/src/multiplayer_ui.cpp:1.19 Thu Apr 14 18:44:05 2005
+++ wesnoth/src/multiplayer_ui.cpp      Fri Apr 22 21:40:34 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_ui.cpp,v 1.19 2005/04/14 18:44:05 gruikya Exp $ */
+/* $Id: multiplayer_ui.cpp,v 1.20 2005/04/22 21:40:34 Sirp Exp $ */
 /*
    Copyright (C) 
    Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -243,17 +243,34 @@
 {
        //On enter, adds the current chat message to the chat textbox.
        if(event.keysym.sym == SDLK_RETURN && !entry_textbox_.text().empty()) {
-
-               // Sends the message to the network
-               config msg;
-               msg["message"] = entry_textbox_.text();
-               msg["sender"] = preferences::login();
-               config data;
-               data.add_child("message", msg);
+
+               const std::string& text = entry_textbox_.text();
+
+               //if the text starts with '/query' it's a query to the server.
+               //otherwise it's just a chat message
+               static const std::string query = "/query ";
+
+               config data;
+
+               if(text.size() >= query.size() && 
std::equal(query.begin(),query.end(),text.begin())) {
+                       const std::string args = text.substr(query.size());
+
+                       data.add_child("query")["type"] = args;
+
+               } else {
+
+                       // Sends the message to the network
+                       config msg;
+                       msg["message"] = text;
+                       msg["sender"] = preferences::login();
+                       data.add_child("message", msg);
+
+                       chat_.add_message(preferences::login(), 
entry_textbox_.text());
+                       chat_.update_textbox(chat_textbox_);
+
+               }
+                       
                network::send_data(data);
-
-               chat_.add_message(preferences::login(), entry_textbox_.text());
-               chat_.update_textbox(chat_textbox_);
                entry_textbox_.clear();
        }
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]