Author: soliton
Date: Thu Apr  2 21:24:09 2009
New Revision: 34409

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

Modified:
    trunk/changelog
    trunk/src/server/game.cpp
    trunk/src/server/server.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=34409&r1=34408&r2=34409&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Thu Apr  2 21:24:09 2009
@@ -9,7 +9,8 @@
    * Changed AI Lifecycle handling. Console AI is now persistent between 
      invocations.
    * Added AI Arena test map to test AIs in interactive mode ( ai_arena_small )
-   * Changed interaction between default AI an Formula AI - made default AI 
not fallback to formula AI
+   * Changed interaction between default AI an Formula AI - made default AI not
+     fallback to formula AI
  * Editor2:
    * New feature: exporting of selection coordinates to system clipboard
    * Made auto terrain transition mode tri-state: on (editor2's on), partial
@@ -39,6 +40,10 @@
    * Fixed word wrapping in CJK languages (patch #1140 from sylecn)
  * Multiplayer server:
    * Implemented automatic saving of game replays.
+   * Implemented the adminmsg command to allow players to send messages to
+     currently available admins. (FR #9218)
+ * Savegames
+   * Providing a new simpler interface for dealing with savegames
  * User interface:
    * Fixed bug #13257: Attack dialog always uses the active name of a weapon
      special
@@ -51,8 +56,6 @@
      now (bug #13170)
    * Added a "preload" WML event type.
    * Added support for Lua scripts in WML event actions ([lua] tag)
- * Savegames
-   * Providing a new simpler interface for dealing with savegames
  * Miscellaneous and bugfixes:
    * Fixed compilation with -D_GLIBCXX_PARALLEL
    * Fixed handling of floating-point WML constants on localized Windows

Modified: trunk/src/server/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/game.cpp?rev=34409&r1=34408&r2=34409&view=diff
==============================================================================
--- trunk/src/server/game.cpp (original)
+++ trunk/src/server/game.cpp Thu Apr  2 21:24:09 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: trunk/src/server/server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/server.cpp?rev=34409&r1=34408&r2=34409&view=diff
==============================================================================
--- trunk/src/server/server.cpp (original)
+++ trunk/src/server/server.cpp Thu Apr  2 21:24:09 2009
@@ -1216,12 +1216,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"
@@ -1292,10 +1293,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") {
@@ -1361,6 +1363,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