summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2006-01-03 17:54:26 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2006-01-03 17:54:26 +0000
commit65ef705d73144167aa6e3eeef87fd55a691fc9e0 (patch)
tree1d4884c74c177a125d444a81554730693695c346
parent08310d2bad4f7d2f00ef506630a350bff2f4a951 (diff)
downloadmana-client-65ef705d73144167aa6e3eeef87fd55a691fc9e0.tar.gz
mana-client-65ef705d73144167aa6e3eeef87fd55a691fc9e0.tar.bz2
mana-client-65ef705d73144167aa6e3eeef87fd55a691fc9e0.tar.xz
mana-client-65ef705d73144167aa6e3eeef87fd55a691fc9e0.zip
Enabled some /commands.
-rw-r--r--ChangeLog2
-rw-r--r--src/game.cpp11
-rw-r--r--src/gui/chat.cpp54
-rw-r--r--src/gui/chat.h8
-rw-r--r--src/net/protocol.h1
5 files changed, 61 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index db7e6270..72d1115b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,8 @@
* src/game.cpp, src/gui/chat.cpp, src/gui/chat.h, src/gui/login.cpp,
src/gui/trade.cpp: Really disabled /commands and added proper message
when logging in and banned.
+ * src/game.cpp, src/gui/chat.cpp, src/gui/chat.h, src/net/protocol.h:
+ Enabled some /commands.
2006-01-02 Eugenio Favalli <elvenprogrammer@gmail.com>
diff --git a/src/game.cpp b/src/game.cpp
index 37b2e995..7f873aef 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -196,7 +196,7 @@ void createGuiWindows()
{
// Create dialogs
chatWindow = new ChatWindow(
- config.getValue("homeDir", "") + std::string("/chatlog.txt"));
+ config.getValue("homeDir", "") + std::string("/chatlog.txt"));
menuWindow = new MenuWindow();
statusWindow = new StatusWindow();
miniStatusWindow = new MiniStatusWindow();
@@ -1913,6 +1913,15 @@ void do_parse()
being->setName(msg.readString(24));
}
break;
+
+ case SMSG_WHO_ANSWER:
+ {
+ std::stringstream userMsg;
+ userMsg << "Online users: ";
+ userMsg << msg.readInt32();
+ chatWindow->chatLog(userMsg.str(), BY_SERVER);
+ }
+ break;
case 0x0119:
// Change in players look
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 91b6be91..748f4848 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -32,15 +32,16 @@
#include "chatinput.h"
#include "scrollarea.h"
-#include "../playerinfo.h"
-#include "../log.h"
-
+#include "../game.h"
#include "../graphics.h"
-extern Graphics *graphics;
+#include "../log.h"
+#include "../playerinfo.h"
#include "../net/messageout.h"
#include "../net/protocol.h"
+extern Graphics *graphics;
+
ChatWindow::ChatWindow(const std::string &logfile):
Window(""),
mTmpVisible(false)
@@ -194,7 +195,6 @@ ChatWindow::action(const std::string& eventId)
if (eventId == "chatinput")
{
std::string message = chatInput->getText();
- printf("Message: %s\n", message.c_str());
if (message.length() > 0) {
// If message different from previous, put it in the history
@@ -253,20 +253,50 @@ ChatWindow::isFocused()
void
ChatWindow::chatSend(std::string nick, std::string msg)
{
- short packetId = CMSG_CHAT_MESSAGE;
-
- // prepare command
- if (msg.substr(0, 1) == "/") {
- // prepare ordinary message
- chatLog("Sorry but /commands are not available yet", BY_SERVER);
+ // Prepare command
+ if (msg.substr(0, 1) == "/")
+ {
+ /* Some messages are managed client side, while others
+ * require server handling by proper packet. Probably
+ * those if elses should be replaced by protocol calls */
+ if (msg.substr(0, IS_ANNOUNCE_LENGTH) == IS_ANNOUNCE)
+ {
+ msg.erase(0, IS_ANNOUNCE_LENGTH);
+ MessageOut outMsg;
+ outMsg.writeInt16(0x0099);
+ outMsg.writeInt16(msg.length() + 4);
+ outMsg.writeString(msg, msg.length());
+ }
+ 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);
+ }
+ else if (msg.substr(0, IS_WHERE_LENGTH) == IS_WHERE)
+ {
+ chatLog(map_path, BY_SERVER);
+ }
+ else if (msg.substr(0, IS_WHO_LENGTH) == IS_WHO)
+ {
+ MessageOut outMsg;
+ outMsg.writeInt16(0x00c1);
+ }
+ else
+ {
+ chatLog("Unknown command", BY_SERVER);
+ }
}
+ // Prepare ordinary message
else {
nick += " : ";
nick += msg;
msg = nick;
MessageOut outMsg;
- outMsg.writeInt16(packetId);
+ outMsg.writeInt16(CMSG_CHAT_MESSAGE);
outMsg.writeInt16(msg.length() + 4);
outMsg.writeString(msg, msg.length());
}
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 80189665..5b470e27 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -48,8 +48,12 @@ class ScrollArea;
#define IS_ANNOUNCE "/announce "
#define IS_ANNOUNCE_LENGTH 10
-#define IS_WHERE "/where "
-#define IS_WHERE_LENGTH 7
+#define IS_HELP "/help"
+#define IS_HELP_LENGTH 5
+#define IS_WHERE "/where"
+#define IS_WHERE_LENGTH 6
+#define IS_WHO "/who"
+#define IS_WHO_LENGTH 4
/**
* gets in between usernick and message text depending on
diff --git a/src/net/protocol.h b/src/net/protocol.h
index 8ac0f16d..e7d6f286 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -39,6 +39,7 @@ class Being;
#define SMSG_PLAYER_STAT_UPDATE_4 0x00bc
#define SMSG_PLAYER_STAT_UPDATE_5 0x00bd
#define SMSG_PLAYER_STAT_UPDATE_6 0x00be
+#define SMSG_WHO_ANSWER 0x00c2
#define SMSG_PLAYER_WARP 0x0091 /**< Warp player to map/location */
#define SMSG_PLAYER_INVENTORY 0x01ee
#define SMSG_PLAYER_INVENTORY_ADD 0x00a0