summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--src/gui/chat.cpp9
-rw-r--r--src/net/beinghandler.cpp27
-rw-r--r--src/net/chathandler.cpp17
-rw-r--r--src/net/protocol.h2
5 files changed, 45 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 035f2688..3406dbdc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-08-26 Guillaume Melquiond <guillaume.melquiond@gmail.com>
+
+ * src/net/chathandler.cpp, src/gui/chat.cpp, src/net/protocol.h: Added
+ support for "say around" messages.
+ * src/net/beinghandler.cpp: Partly implemented being creation, so that
+ chat works.
+
2006-08-21 Eugenio Favalli <elvenprogrammer@gmail.com>
* The Mana World.dev, tmw.cbp: Updated project files.
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 592439fc..e8bb1cc6 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -37,6 +37,7 @@
#include "../localplayer.h"
#include "../net/messageout.h"
+#include "../net/network.h"
#include "../net/protocol.h"
ChatWindow::ChatWindow(Network *network):
@@ -249,12 +250,10 @@ ChatWindow::chatSend(const std::string &nick, std::string msg)
// Prepare ordinary message
if (msg.substr(0, 1) != "/") {
- msg = nick + " : " + msg;
-
MessageOut outMsg;
- outMsg.writeShort(CMSG_CHAT_MESSAGE);
- outMsg.writeShort(msg.length() + 4);
- outMsg.writeString(msg, msg.length());
+ outMsg.writeShort(PGMSG_SAY);
+ outMsg.writeString(msg);
+ network->send(Network::GAME, outMsg);
}
else if (msg.substr(0, IS_ANNOUNCE_LENGTH) == IS_ANNOUNCE)
{
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index ed0fc4b2..10de5351 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -383,17 +383,22 @@ void BeingHandler::handleMessage(MessageIn &msg)
void
BeingHandler::handleBeingEnterMessage(MessageIn &msg)
{
- // Not sure what do to exactly with this message yet.
- /*
- unsigned char type = msg.readByte();
- unsigned long id = msg.readLong();
-
- if (type == OBJECT_PLAYER)
+ msg.readByte(); // type
+ int id = msg.readLong();
+ std::string name = msg.readString();
+ Being *being;
+ if (player_node->getName() == name)
+ {
+ being = player_node;
+ being->setId(id);
+ }
+ else
{
- std::string name = msg.readString();
- unsigned char hairStyle = msg.readByte();
- unsigned char hairColor = msg.readByte();
- unsigned char gender = msg.readByte();
+ // assume type is player for now, so job 0, TODO
+ being = beingManager->createBeing(id, 0);
+ being->setName(name);
}
- */
+ being->setHairStyle(msg.readByte() + 1);
+ being->setHairColor(msg.readByte() + 1);
+ being->setSex(msg.readByte());
}
diff --git a/src/net/chathandler.cpp b/src/net/chathandler.cpp
index 795b2a27..02f99c41 100644
--- a/src/net/chathandler.cpp
+++ b/src/net/chathandler.cpp
@@ -42,11 +42,14 @@ extern Being *player_node;
ChatHandler::ChatHandler()
{
static const Uint16 _messages[] = {
+ GPMSG_SAY,
+ /*
SMSG_BEING_CHAT,
SMSG_PLAYER_CHAT,
SMSG_GM_CHAT,
SMSG_WHO_ANSWER,
0x10c, // MVP
+ */
0
};
handledMessages = _messages;
@@ -60,6 +63,20 @@ void ChatHandler::handleMessage(MessageIn &msg)
switch (msg.getId())
{
+ case GPMSG_SAY:
+ being = beingManager->findBeing(msg.readLong());
+ chatMsg = msg.readString();
+ if (being)
+ {
+ chatWindow->chatLog(being->getName() + " : " + chatMsg, being == player_node ? BY_PLAYER : BY_OTHER);
+ being->setSpeech(chatMsg, SPEECH_TIME);
+ }
+ else
+ {
+ chatWindow->chatLog("John Doe : " + chatMsg, BY_OTHER);
+ }
+ break;
+
// Received speech from being
case SMSG_BEING_CHAT:
chatMsgLength = msg.readShort() - 8;
diff --git a/src/net/protocol.h b/src/net/protocol.h
index 6927f3fd..33d72c96 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -157,7 +157,7 @@ enum {
GPMSG_BEING_LEAVE = 0x0201, // B type, L being id
PGMSG_WALK = 0x0260, // L*2 destination
PGMSG_SAY = 0x02A0, // S text
- GPMSG_SAY = 0x02A1, // S being, S text
+ GPMSG_SAY = 0x02A1, // L being id, S text
PGMSG_USE_ITEM = 0x0300, // L item id
GPMSG_USE_RESPONSE = 0x0301, // B error
PGMSG_EQUIP = 0x0302, // L item id, B slot