summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-07-08 15:16:22 +0000
committerDavid Athay <ko2fan@gmail.com>2008-07-08 15:16:22 +0000
commit3be4300f12d4e936a1beea0021b14cf6313ee3b9 (patch)
treed7c7efab8b6e2c0920da42cc5fe01203e3aae044
parent4ca8675700dfae625376c4afdd30b8590d68087e (diff)
downloadmana-3be4300f12d4e936a1beea0021b14cf6313ee3b9.tar.gz
mana-3be4300f12d4e936a1beea0021b14cf6313ee3b9.tar.bz2
mana-3be4300f12d4e936a1beea0021b14cf6313ee3b9.tar.xz
mana-3be4300f12d4e936a1beea0021b14cf6313ee3b9.zip
#359 patch by Scraggy
-rw-r--r--ChangeLog4
-rw-r--r--src/gui/chat.cpp90
-rw-r--r--src/gui/chat.h9
-rw-r--r--tmw.cbp4
4 files changed, 100 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 37c6ed4a..59956b69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-07-08 David Athay <ko2fan@gmail.com>
+
+ * src/gui/chat.cpp, src/gui/chat.h: Mantis #359 patch by Scraggy.
+
2008-06-30 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/CMakeLists.txt: Updated CMake file to fix compilation. Patch by
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 5e3aaf60..2894bb70 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -275,13 +275,25 @@ ChatWindow::chatSend(const std::string &nick, std::string msg)
}
else if (msg.substr(0, IS_HELP_LENGTH) == IS_HELP)
{
- chatLog("-- Help --", BY_SERVER);
- chatLog("/help: Display this help.", BY_SERVER);
- chatLog("/announce: Global announcement (GM only)", BY_SERVER);
- chatLog("/where: Display map name", BY_SERVER);
- chatLog("/who: Display number of online users", BY_SERVER);
- chatLog("/clear: Clears this window", BY_SERVER);
- chatLog("/whisper <nick> <message>: Sends a private <message> to <nick>", BY_SERVER);
+ msg.erase(0, IS_HELP_LENGTH + 1);
+ trim(msg);
+ std::size_t space = msg.find(" ");
+ std::string msg1;
+ if (space == std::string::npos)
+ {
+ msg1 = "";
+ }
+ else
+ {
+ msg1 = msg.substr(space + 1, msg.length());
+ msg = msg.substr(0, space);
+ }
+ if (msg != "" && msg.at(0) == '/')
+ {
+ msg.erase(0, 1);
+ }
+ trim(msg1);
+ help(msg, msg1);
}
else if (msg.substr(0, IS_WHERE_LENGTH) == IS_WHERE)
{
@@ -469,3 +481,67 @@ ChatWindow::setVisible(bool isVisible)
mTmpVisible = false;
}
+void ChatWindow::help(const std::string &msg1, const std::string &msg2)
+{
+ chatLog("-- Help --", BY_SERVER);
+ if (msg1 == "")
+ {
+ chatLog("/announce: Global announcement (GM only)", BY_SERVER);
+ chatLog("/clear: Clears this window", BY_SERVER);
+ chatLog("/help: Display this help.", BY_SERVER);
+ chatLog("/where: Display map name", BY_SERVER);
+ chatLog("/whisper <nick> <message>: Sends a private <message>"
+ " to <nick>", BY_SERVER);
+ chatLog("/who: Display number of online users", BY_SERVER);
+ chatLog("For more information, type /help <command>", BY_SERVER);
+ return;
+ }
+ if (msg1 == "announce")
+ {
+ chatLog("Command: /announce <msg>", BY_SERVER);
+ chatLog("*** only available to a GM ***", BY_SERVER);
+ chatLog("This command sends the message <msg> to "
+ "all players currently online.", BY_SERVER);
+ return;
+ }
+ if (msg1 == "clear")
+ {
+ chatLog("Command: /clear", BY_SERVER);
+ chatLog("This command clears the chat log of previous chat.",
+ BY_SERVER);
+ return;
+ }
+ if (msg1 == "help")
+ {
+ chatLog("Command: /help", BY_SERVER);
+ chatLog("This command displays a list of all commands available.",
+ BY_SERVER);
+ chatLog("Command: /help <command>", BY_SERVER);
+ chatLog("This command displays help on <command>.", BY_SERVER);
+ return;
+ }
+ if (msg1 == "where")
+ {
+ chatLog("Command: /where", BY_SERVER);
+ chatLog("This command displays the name of the current map.",
+ BY_SERVER);
+ return;
+ }
+ if (msg1 == "whisper")
+ {
+ chatLog("Command: /whisper <nick> <msg>", BY_SERVER);
+ chatLog("This command sends the message <msg> to <nick.", BY_SERVER);
+ chatLog("If the <nick> has spaces in it, enclose it in "
+ "double quotes (\").", BY_SERVER);
+ return;
+ }
+ if (msg1 == "who")
+ {
+ chatLog("Command: /who", BY_SERVER);
+ chatLog("This command displays the number of players currently "
+ "online.", BY_SERVER);
+ return;
+ }
+ chatLog("Unknown command.", BY_SERVER);
+ chatLog("Type /help for a list of commands.", BY_SERVER);
+}
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 0bdc76f1..a1d659a0 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -208,6 +208,15 @@ class ChatWindow : public Window, public gcn::ActionListener,
void
scroll(int amount);
+ /**
+ * help implements the /help command
+ *
+ * @param msg1 is the command that the player needs help on
+ * @param msg2 is the sub-command relating to the command
+ */
+ void
+ help(const std::string &msg1, const std::string &msg2);
+
private:
Network *mNetwork;
bool mTmpVisible;
diff --git a/tmw.cbp b/tmw.cbp
index 5943f74e..32f2e977 100644
--- a/tmw.cbp
+++ b/tmw.cbp
@@ -325,6 +325,8 @@
<Unit filename="src/resources/monsterinfo.h" />
<Unit filename="src/resources/music.cpp" />
<Unit filename="src/resources/music.h" />
+ <Unit filename="src/resources/npcdb.cpp" />
+ <Unit filename="src/resources/npcdb.h" />
<Unit filename="src/resources/resource.cpp" />
<Unit filename="src/resources/resource.h" />
<Unit filename="src/resources/resourcemanager.cpp" />
@@ -334,6 +336,8 @@
<Unit filename="src/resources/spritedef.cpp" />
<Unit filename="src/resources/spritedef.h" />
<Unit filename="src/serverinfo.h" />
+ <Unit filename="src/shopitem.cpp" />
+ <Unit filename="src/shopitem.h" />
<Unit filename="src/simpleanimation.cpp" />
<Unit filename="src/simpleanimation.h" />
<Unit filename="src/sound.cpp" />