Author: soliton
Date: Thu Apr  2 21:18:03 2009
New Revision: 34408

URL: http://svn.gna.org/viewcvs/wesnoth?rev=34408&view=rev
Log:
* Implemented the adminmsg command to allow players to send messages to 
currently available admins; fixes bug #9218: Wish: /adminmsg

Modified:
    branches/1.6/changelog
    branches/1.6/src/server/game.cpp
    branches/1.6/src/server/server.cpp

Modified: branches/1.6/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/changelog?rev=34408&r1=34407&r2=34408&view=diff
==============================================================================
--- branches/1.6/changelog (original)
+++ branches/1.6/changelog Thu Apr  2 21:18:03 2009
@@ -8,13 +8,15 @@
    * New feature: exporting of selection coordinates to system clipboard
  * Graphics:
    * New portrait for Orc Grunt, Dwarf Fighter (alternative), Goblin Spearman,
-   Ogre/Young Ogre, Trapper
+     Ogre/Young Ogre, Trapper
  * Language and i18n:
    * new translations: Icelandic
    * updated translations: British English, Catalan, Chinese (Simplified),
      Czech, German, Finnish, Hebrew, Italian, Polish, Russian, Slovak, Turkish
  * Multiplayer server:
    * Implemented automatic saving of game replays.
+   * Implemented the adminmsg command to allow players to send messages to
+     currently available admins (FR #9218)
  * Miscellaneous and bugfixes:
    * Fixed an infinite loop issue when no music tracks could be loaded
    * Fixed compilation with -D_GLIBCXX_PARALLEL

Modified: branches/1.6/src/server/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/server/game.cpp?rev=34408&r1=34407&r2=34408&view=diff
==============================================================================
--- branches/1.6/src/server/game.cpp (original)
+++ branches/1.6/src/server/game.cpp Thu Apr  2 21:18:03 2009
@@ -1234,7 +1234,8 @@
        << "[replay]\n" << replay_commands << "[/replay]\n"
        << "[replay_start]\n" << level_.output() << "[/replay_start]\n";
 
-       simple_wml::document replay(replay_data.str().c_str(), 
simple_wml::INIT_STATIC);
+       std::string replay_data_str = replay_data.str();
+       simple_wml::document replay(replay_data_str.c_str(), 
simple_wml::INIT_STATIC);
 
        std::string filename(name.str());
        std::replace(filename.begin(), filename.end(), ' ', '_');

Modified: branches/1.6/src/server/server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/server/server.cpp?rev=34408&r1=34407&r2=34408&view=diff
==============================================================================
--- branches/1.6/src/server/server.cpp (original)
+++ branches/1.6/src/server/server.cpp Thu Apr  2 21:18:03 2009
@@ -1219,12 +1219,13 @@
        }
        const simple_wml::string_span& command(query["type"]);
        std::ostringstream response;
-       const std::string& help_msg = "Available commands are: help, games, 
metrics,"
+       const std::string& help_msg = "Available commands are: adminmsg <msg>, 
help, games, metrics,"
                        " motd, netstats [all], stats, status, wml.";
        // Commands a player may issue.
        if (command == "status") {
                response << process_command(command.to_string() + " " + 
pl->second.name(), pl->second.name());
-       } else if (command == "games"
+       } else if (command.to_string().find("adminmsg") == 0
+                       || command == "games"
                        || command == "metrics"
                        || command == "motd"
                        || command == "netstats"
@@ -1295,10 +1296,11 @@
        const std::string command(query.begin(),i);
        std::string parameters = (i == query.end() ? "" : 
std::string(i+1,query.end()));
        utils::strip(parameters);
-       const std::string& help_msg = "Available commands are: ban <mask> 
[<time>] <reason>,"
-                       " bans [deleted], clones, dul|deny_unregistered_login 
[yes|no],"
-                       " kick <mask> [<reason>], k[ick]ban <mask> [<time>] 
<reason>,"
-                       " help, games, metrics, netstats [all], [lobby]msg 
<message>, motd [<message>],"
+       const std::string& help_msg = "Available commands are: adminmsg <msg>,"
+                       " ban <mask> [<time>] <reason>, bans [deleted], clones,"
+                       " dul|deny_unregistered_login [yes|no], kick <mask> 
[<reason>],"
+                       " k[ick]ban <mask> [<time>] <reason>, help, games, 
metrics,"
+                       " netstats [all], [lobby]msg <message>, motd 
[<message>],"
                        " requests, stats, status [<mask>], searchlog <mask>, 
signout, unban <ipmask>";
        // Shutdown, restart and sample commands can only be issued via the 
socket.
        if (command == "shut_down") {
@@ -1364,6 +1366,19 @@
                        out << network::get_bandwidth_stats_all();
                else
                        out << network::get_bandwidth_stats(); // stats from 
previuos hour
+       } else if (command == "adminmsg") {
+               if (parameters == "") return "You must type a message.";
+               LOG_SERVER << "Admin message: <" << issuer_name << "> " << 
parameters << "\n";
+               if (admins_.size() < 1) return "Sorry, no admin available right 
now. But your message got logged.";
+
+               simple_wml::document data;
+               simple_wml::node& msg = data.root().add_child("whisper");
+               msg.set_attr_dup("sender", ("Admin message - " + 
issuer_name).c_str());
+               msg.set_attr_dup("message", parameters.c_str());
+               for (std::set<network::connection>::const_iterator i = 
admins_.begin(); i != admins_.end(); ++i) {
+                       send_doc(data, *i);
+               }
+               out << "Message delivered to " << admins_.size() << " admins.";
        } else if (command == "msg" || command == "lobbymsg") {
                if (parameters == "") {
                        return "You must type a message.";


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to