diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-13 11:36:36 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-13 11:36:36 +0000 |
commit | afc770043be553998555e9ac1cffca68dc482d48 (patch) | |
tree | 60e99ade9464b0a1de2ec246724a7bfe0957eec4 /src/gui/chat.cpp | |
parent | cfcc1bc3a756185bd39dd858ebbe69b5916ac11b (diff) | |
download | mana-afc770043be553998555e9ac1cffca68dc482d48.tar.gz mana-afc770043be553998555e9ac1cffca68dc482d48.tar.bz2 mana-afc770043be553998555e9ac1cffca68dc482d48.tar.xz mana-afc770043be553998555e9ac1cffca68dc482d48.zip |
Merged cleanups and content changes from the trunk. Also fixed compiling with
OpenGL enabled.
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r-- | src/gui/chat.cpp | 81 |
1 files changed, 35 insertions, 46 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 133e5e3a..592439fc 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -35,18 +35,16 @@ #include "../game.h" #include "../localplayer.h" -#include "../log.h" #include "../net/messageout.h" #include "../net/protocol.h" -ChatWindow::ChatWindow(const std::string &logfile, Network *network): +ChatWindow::ChatWindow(Network *network): Window(""), mNetwork(network), mTmpVisible(false) { setWindowName("Chat"); - mChatlogFile.open(logfile.c_str(), std::ios::out | std::ios::app); mItems = 0; mItemsKeep = 20; @@ -76,12 +74,6 @@ ChatWindow::ChatWindow(const std::string &logfile, Network *network): mCurHist = mHistory.end(); } -ChatWindow::~ChatWindow() -{ - mChatlogFile.flush(); - mChatlogFile.close(); -} - void ChatWindow::logic() { @@ -251,44 +243,12 @@ ChatWindow::isFocused() void ChatWindow::chatSend(const std::string &nick, std::string msg) { - // 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.writeShort(0x0099); - outMsg.writeShort(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.writeShort(0x00c1); - } - else - { - chatLog("Unknown command", BY_SERVER); - } - } + /* Some messages are managed client side, while others + * require server handling by proper packet. Probably + * those if elses should be replaced by protocol calls */ + // Prepare ordinary message - else { + if (msg.substr(0, 1) != "/") { msg = nick + " : " + msg; MessageOut outMsg; @@ -296,6 +256,35 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) outMsg.writeShort(msg.length() + 4); outMsg.writeString(msg, msg.length()); } + else if (msg.substr(0, IS_ANNOUNCE_LENGTH) == IS_ANNOUNCE) + { + msg.erase(0, IS_ANNOUNCE_LENGTH); + MessageOut outMsg; + outMsg.writeShort(0x0099); + outMsg.writeShort(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.writeShort(0x00c1); + } + else + { + chatLog("Unknown command", BY_SERVER); + } } std::string |