diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-08-07 01:59:38 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-08-07 01:59:38 +0000 |
commit | 16793c9b9b3fb5fd64fdf434ef6b5501803cb670 (patch) | |
tree | 626ec25bb4a0b3e387621c0e998f76997a33b881 /src/gui | |
parent | d25e1c9b0dac7fcfe803083af1189489d5a9ad88 (diff) | |
download | mana-16793c9b9b3fb5fd64fdf434ef6b5501803cb670.tar.gz mana-16793c9b9b3fb5fd64fdf434ef6b5501803cb670.tar.bz2 mana-16793c9b9b3fb5fd64fdf434ef6b5501803cb670.tar.xz mana-16793c9b9b3fb5fd64fdf434ef6b5501803cb670.zip |
A bunch of cleanups.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chat.cpp | 81 | ||||
-rw-r--r-- | src/gui/chat.h | 9 |
2 files changed, 36 insertions, 54 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 64b56caf..92412dde 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() { @@ -252,44 +244,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(mNetwork); - 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(mNetwork); - outMsg.writeInt16(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(mNetwork); @@ -297,6 +257,35 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) outMsg.writeInt16(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(mNetwork); + 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(mNetwork); + outMsg.writeInt16(0x00c1); + } + else + { + chatLog("Unknown command", BY_SERVER); + } } std::string diff --git a/src/gui/chat.h b/src/gui/chat.h index 80e57a84..cd52ac46 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -24,7 +24,6 @@ #ifndef _TMW_CHAT_H #define _TMW_CHAT_H -#include <fstream> #include <list> #include <string> @@ -117,12 +116,7 @@ class ChatWindow : public Window, public gcn::ActionListener, /** * Constructor. */ - ChatWindow(const std::string &logfile, Network *network); - - /** - * Destructor. - */ - ~ChatWindow(); + ChatWindow(Network *network); /** * Logic (updates components' size) @@ -195,7 +189,6 @@ class ChatWindow : public Window, public gcn::ActionListener, private: Network *mNetwork; - std::ofstream mChatlogFile; bool mTmpVisible; /** One item in the chat log */ |