summaryrefslogtreecommitdiff
path: root/src/net/tmwa/chathandler.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-04 16:06:41 +0000
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-04 16:06:41 +0000
commit12bec57276d30cd513b1f6b865ee116bce86fc17 (patch)
tree2ccbf39a687b2601696dc721e039ab8fb4f45559 /src/net/tmwa/chathandler.cpp
parenta25d857ed0bebc2c3e1473d06bea89286941886c (diff)
downloadmana-12bec57276d30cd513b1f6b865ee116bce86fc17.tar.gz
mana-12bec57276d30cd513b1f6b865ee116bce86fc17.tar.bz2
mana-12bec57276d30cd513b1f6b865ee116bce86fc17.tar.xz
mana-12bec57276d30cd513b1f6b865ee116bce86fc17.zip
Fixed duplication of player name in chat
* Fixed duplication of player name in chat Closes #49
Diffstat (limited to 'src/net/tmwa/chathandler.cpp')
-rw-r--r--src/net/tmwa/chathandler.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index beed01a1..e4a551e6 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -27,6 +27,7 @@
#include "localplayer.h"
#include "playerrelations.h"
+#include "net/tmwa/loginhandler.h"
#include "net/tmwa/messagein.h"
#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
@@ -241,16 +242,24 @@ void ChatHandler::handleMessage(MessageIn &msg)
}
}
-void ChatHandler::talk(const std::string &text)
+static void sendChatMessage(const std::string &mes)
{
- std::string mes = local_player->getName() + " : " + text;
-
MessageOut outMsg(CMSG_CHAT_MESSAGE);
// Added + 1 in order to let eAthena parse admin commands correctly
outMsg.writeInt16(mes.length() + 4 + 1);
outMsg.writeString(mes, mes.length() + 1);
}
+void ChatHandler::talk(const std::string &text)
+{
+ const auto loginHandler = static_cast<LoginHandler*>(Net::getLoginHandler());
+
+ if (loginHandler->getServerVersion() >= 0x100408)
+ sendChatMessage(text);
+ else
+ sendChatMessage(local_player->getName() + " : " + text);
+}
+
void ChatHandler::me(const std::string &text)
{
std::string action = strprintf("*%s*", text.c_str());