From 74f23fd3d0e1fb3be8e5419193d57d91746c887a Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Fri, 27 Mar 2009 13:12:24 -0600 Subject: Clean up chat and chat tabs some more --- src/commandhandler.cpp | 12 +------- src/gui/chat.cpp | 12 ++++---- src/gui/chat.h | 17 +++-------- src/gui/guildwindow.cpp | 40 ++++++++++++------------- src/gui/npcpostdialog.cpp | 18 ++++++----- src/gui/partywindow.cpp | 11 +++---- src/gui/skill.h | 5 ++-- src/gui/trade.cpp | 2 +- src/gui/widgets/channeltab.cpp | 34 ++++----------------- src/gui/widgets/channeltab.h | 2 +- src/gui/widgets/chattab.cpp | 64 ++++++++++++++++++---------------------- src/gui/widgets/chattab.h | 21 ++++++++----- src/gui/widgets/whispertab.cpp | 34 ++++++++------------- src/gui/widgets/whispertab.h | 4 +-- src/log.cpp | 2 +- src/net/ea/buysellhandler.cpp | 5 ++-- src/net/ea/chathandler.cpp | 2 +- src/net/ea/equipmenthandler.cpp | 2 +- src/net/ea/inventoryhandler.cpp | 3 +- src/net/ea/playerhandler.cpp | 3 +- src/net/ea/skillhandler.cpp | 3 +- src/net/ea/tradehandler.cpp | 3 +- src/net/tmwserv/partyhandler.cpp | 3 +- src/net/tmwserv/tradehandler.cpp | 3 +- src/statuseffect.cpp | 4 ++- 25 files changed, 135 insertions(+), 174 deletions(-) diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 7ccd7d80..14c5434a 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -339,12 +339,6 @@ void CommandHandler::handleWho() void CommandHandler::handleMsg(const std::string &args) { -#ifdef TMWSERV_SUPPORT - std::string::size_type pos = args.find(' '); - std::string recipient(args, 0, pos); - std::string text(args, pos+1); - Net::ChatServer::privMsg(recipient, text); -#else std::string recvnick = ""; std::string msg = ""; @@ -391,7 +385,6 @@ void CommandHandler::handleMsg(const std::string &args) } else localChatTab->chatLog("Cannont send empty whispers!"); -#endif } void CommandHandler::handleClear() @@ -547,10 +540,7 @@ void CommandHandler::handleParty(const std::string &args) void CommandHandler::handleMe(const std::string &args) { std::string action = strprintf("*%s*", args.c_str()); - chatWindow->chatSend(action); - //std::stringstream actionStr; - //actionStr << "*" << args << "*"; - //chatWindow->chatSend(actionStr.str()); + chatWindow->chatInput(action); } void CommandHandler::handleRecord(const std::string &args) diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index b0b15dbc..48858bf6 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -27,6 +27,7 @@ #include "gui/scrollarea.h" #include "gui/sdlinput.h" +#include "gui/widgets/chattab.h" #include "gui/widgets/tabbedarea.h" #include "gui/widgets/whispertab.h" @@ -82,7 +83,7 @@ ChatWindow::ChatWindow(Network * network): // run the @assert command for the player again. Convenience for GMs. if (config.getValue(player_node->getName() + "GMassert", 0)) { std::string cmd = "@assert"; - chatSend(cmd); + chatInput(cmd); } #endif mRecorder = new Recorder(this); @@ -180,7 +181,7 @@ void ChatWindow::action(const gcn::ActionEvent &event) mCurHist = mHistory.end(); // Send the message to the server - chatSend(message); + chatInput(message); // Clear the text from the chat input mChatInput->setText(""); @@ -258,10 +259,10 @@ void ChatWindow::removeWhisper(std::string nick) mWhispers.erase(nick); } -void ChatWindow::chatSend(std::string &msg) +void ChatWindow::chatInput(std::string &msg) { ChatTab *tab = getFocused(); - tab->chatSend(msg); + tab->chatInput(msg); } void ChatWindow::doPresent() @@ -377,6 +378,7 @@ void ChatWindow::setRecordingFile(const std::string &msg) void ChatWindow::whisper(std::string nick, std::string mes, bool own) { if (mes.length() == 0) return; + std::string playerName = player_node->getName(); std::string tempNick = nick; @@ -395,7 +397,7 @@ void ChatWindow::whisper(std::string nick, std::string mes, bool own) } if (own) - tab->chatSend(mes); + tab->chatInput(mes); else tab->chatLog(nick, mes); } diff --git a/src/gui/chat.h b/src/gui/chat.h index 177aa38f..ac4e491e 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -22,6 +22,8 @@ #ifndef CHAT_H #define CHAT_H +#include "window.h" + #include #include #include @@ -31,10 +33,6 @@ #include #include -#include "widgets/chattab.h" - -#include "window.h" - class BrowserBox; class Channel; class ChatTab; @@ -45,16 +43,9 @@ class ItemLinkHandler; #ifdef EATHENA_SUPPORT class Network; #endif +class Tab; class WhisperTab; -/** - * gets in between usernick and message text depending on - * message type - */ -#define CAT_NORMAL ": " -#define CAT_IS "" -#define CAT_WHISPER " whispers: " - #define DEFAULT_CHAT_WINDOW_SCROLL 7 // 1 means `1/8th of the window size'. /** One item in the chat log */ @@ -142,7 +133,7 @@ class ChatWindow : public Window, * @param msg The message text which is to be sent. * */ - void chatSend(std::string &msg); + void chatInput(std::string &msg); /** Called when key is pressed */ void keyPressed(gcn::KeyEvent &event); diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp index c8a1872f..fb14235b 100644 --- a/src/gui/guildwindow.cpp +++ b/src/gui/guildwindow.cpp @@ -20,26 +20,26 @@ * $$ */ -#include "guildwindow.h" - -#include "button.h" -#include "chat.h" -#include "confirm_dialog.h" -#include "guildlistbox.h" -#include "scrollarea.h" -#include "textdialog.h" -#include "windowcontainer.h" - -#include "widgets/layout.h" -#include "widgets/tabbedarea.h" - -#include "../guild.h" -#include "../log.h" -#include "../localplayer.h" - -#include "../net/tmwserv/chatserver/guild.h" -#include "../utils/dtor.h" -#include "../utils/gettext.h" +#include "gui/guildwindow.h" + +#include "gui/button.h" +#include "gui/confirm_dialog.h" +#include "gui/guildlistbox.h" +#include "gui/scrollarea.h" +#include "gui/textdialog.h" +#include "gui/windowcontainer.h" + +#include "gui/widgets/chattab.h" +#include "gui/widgets/layout.h" +#include "gui/widgets/tabbedarea.h" + +#include "guild.h" +#include "log.h" +#include "localplayer.h" + +#include "net/tmwserv/chatserver/guild.h" +#include "utils/dtor.h" +#include "utils/gettext.h" #include diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 278bc397..e0133473 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -19,15 +19,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "npcpostdialog.h" -#include "textbox.h" -#include "textfield.h" -#include "button.h" -#include "scrollarea.h" -#include "chat.h" +#include "gui/npcpostdialog.h" -#include "../net/tmwserv/gameserver/player.h" -#include "../utils/gettext.h" +#include "gui/textbox.h" +#include "gui/textfield.h" +#include "gui/button.h" +#include "gui/scrollarea.h" + +#include "gui/widgets/chattab.h" + +#include "net/tmwserv/gameserver/player.h" +#include "utils/gettext.h" #include diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 3f857b5c..1f87b26f 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -19,13 +19,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "partywindow.h" -#include "chat.h" +#include "gui/partywindow.h" -#include "widgets/avatar.h" +#include "gui/widgets/avatar.h" +#include "gui/widgets/chattab.h" -#include "../utils/gettext.h" -#include "../net/tmwserv/chatserver/party.h" +#include "net/tmwserv/chatserver/party.h" + +#include "utils/gettext.h" PartyWindow::PartyWindow() : Window(_("Party")) { diff --git a/src/gui/skill.h b/src/gui/skill.h index 0600d106..0d6336f3 100644 --- a/src/gui/skill.h +++ b/src/gui/skill.h @@ -22,18 +22,19 @@ #ifndef SKILL_H #define SKILL_H +#include "gui/window.h" + #include #include -#include "window.h" - struct SKILL { short id; /**< Index into "skill_db" array */ short lv, sp; }; class GuiTable; +class ScrollArea; class SkillGuiTableModel; /** diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 8aa3c3ea..4ecdede8 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -24,7 +24,7 @@ #include #include "button.h" -#include "chat.h" +#include "widgets/chattab.h" #include "inventorywindow.h" #include "item_amount.h" #include "itemcontainer.h" diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp index c17aec0a..375ead26 100644 --- a/src/gui/widgets/channeltab.cpp +++ b/src/gui/widgets/channeltab.cpp @@ -19,40 +19,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "channeltab.h" -#include "../browserbox.h" -#include "../chatinput.h" -#include "../itemlinkhandler.h" -#include "../recorder.h" -#include "../scrollarea.h" - -#include "../../beingmanager.h" -#include "../../commandhandler.h" -#include "../../channel.h" -#include "../../configuration.h" -#include "../../game.h" -#include "../../localplayer.h" +#include "channel.h" #ifdef TMWSERV_SUPPORT -#include "../../net/tmwserv/chatserver/chatserver.h" -#include "../../net/tmwserv/gameserver/player.h" +#include "net/tmwserv/chatserver/chatserver.h" +#include "net/tmwserv/gameserver/player.h" #else -#include "../../party.h" -#include "../../net/messageout.h" -#include "../../net/ea/protocol.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" #endif -#include "../../resources/iteminfo.h" -#include "../../resources/itemdb.h" - -#include "../../utils/dtor.h" -#include "../../utils/gettext.h" -#include "../../utils/strprintf.h" -#include "../../utils/stringutils.h" - ChannelTab::ChannelTab(Channel *channel) : ChatTab(channel->getName()), mChannel(channel) { @@ -63,7 +41,7 @@ ChannelTab::~ChannelTab() { } -void ChannelTab::sendChat(const std::string &msg) { +void ChannelTab::handleInput(const std::string &msg) { #ifdef TMSERV_SUPPORT Net::ChatServer::chat(getId(), msg); #endif diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h index 04a11e29..8c98189b 100644 --- a/src/gui/widgets/channeltab.h +++ b/src/gui/widgets/channeltab.h @@ -48,7 +48,7 @@ class ChannelTab : public ChatTab */ ~ChannelTab(); - void sendChat(const std::string &msg); + void handleInput(const std::string &msg); private: Channel *mChannel; diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 0594761d..715aaf20 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -19,34 +19,31 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "chattab.h" -#include "layouthelper.h" -#include "../browserbox.h" -#include "../chatinput.h" -#include "../itemlinkhandler.h" -#include "../recorder.h" -#include "../scrollarea.h" +#include "commandhandler.h" +#include "configuration.h" +#include "localplayer.h" -#include "../../commandhandler.h" -#include "../../configuration.h" -#include "../../localplayer.h" +#include "gui/browserbox.h" +#include "gui/itemlinkhandler.h" +#include "gui/recorder.h" +#include "gui/scrollarea.h" #ifdef TMWSERV_SUPPORT -#include "../../net/tmwserv/chatserver/chatserver.h" -#include "../../net/tmwserv/gameserver/player.h" +#include "net/tmwserv/chatserver/chatserver.h" +#include "net/tmwserv/gameserver/player.h" #else -#include "../../net/messageout.h" -#include "../../net/ea/protocol.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" #endif -#include "../../resources/iteminfo.h" -#include "../../resources/itemdb.h" +#include "resources/iteminfo.h" +#include "resources/itemdb.h" -#include "../../utils/strprintf.h" -#include "../../utils/stringutils.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" +#include "utils/stringutils.h" ChatTab::ChatTab(const std::string &name) : Tab() { @@ -160,10 +157,9 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) break; #endif case ACT_WHISPER: - tmp.nick = strprintf(_("%s whispers:"), tmp.nick.c_str()); - tmp.nick += " "; - lineColor = "##W"; - break; + // Resend whisper through normal mechanism + chatWindow->whisper(tmp.nick, tmp.text); + return; case ACT_IS: tmp.nick += CAT_IS; lineColor = "##I"; @@ -221,10 +217,11 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) void ChatTab::chatLog(std::string &nick, std::string &msg) { - chatLog(nick + ": " + msg, nick == player_node->getName() ? BY_PLAYER : BY_OTHER, false); + chatLog(nick + CAT_NORMAL + msg, nick == player_node->getName() ? + BY_PLAYER : BY_OTHER, false); } -void ChatTab::chatSend(std::string &msg) +void ChatTab::chatInput(std::string &msg) { trim(msg); @@ -282,16 +279,11 @@ void ChatTab::chatSend(std::string &msg) start = msg.find('[', start + 1); } - // Prepare ordinary message if (msg[0] != '/') - { - sendChat(msg); - } + handleInput(msg); else - { handleCommand(std::string(msg, 1)); - } } void ChatTab::scroll(int amount) @@ -308,22 +300,22 @@ void ChatTab::clearText() mTextOutput->clearRows(); } -void ChatTab::sendChat(std::string &msg) { +void ChatTab::handleInput(const std::string &msg) { #ifdef TMWSERV_SUPPORT Net::GameServer::Player::say(msg); #else - msg = player_node->getName() + " : " + msg; + std::string mes = player_node->getName() + " : " + msg; MessageOut outMsg(chatWindow->mNetwork); outMsg.writeInt16(CMSG_CHAT_MESSAGE); // Added + 1 in order to let eAthena parse admin commands correctly - outMsg.writeInt16(msg.length() + 4 + 1); - outMsg.writeString(msg, msg.length() + 1); + outMsg.writeInt16(mes.length() + 4 + 1); + outMsg.writeString(mes, mes.length() + 1); return; #endif } -void ChatTab::handleCommand(const std::string msg) +void ChatTab::handleCommand(std::string msg) { commandHandler->handleCommand(msg); } diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 3e64242c..52449f6f 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -22,11 +22,10 @@ #ifndef CHATTAB_H #define CHATTAB_H -#include - -#include "tab.h" +#include "gui/widgets/tab.h" +#include "gui/chat.h" -#include "../chat.h" +#include class BrowserBox; class Recorder; @@ -47,6 +46,13 @@ enum BY_LOGGER }; +/** + * gets in between usernick and message text depending on + * message type + */ +#define CAT_NORMAL ": " +#define CAT_IS "" + /** * A tab for the chat window. This is special to ease chat handling. */ @@ -90,7 +96,7 @@ class ChatTab : public Tab * @param msg The message text which is to be sent. * */ - void chatSend(std::string &msg); + void chatInput(std::string &msg); /** * Scrolls the chat window @@ -105,10 +111,11 @@ class ChatTab : public Tab protected: friend class ChatWindow; + friend class WhisperWindow; - virtual void sendChat(std::string &msg); + virtual void handleInput(const std::string &msg); - virtual void handleCommand(const std::string msg); + virtual void handleCommand(std::string msg); ScrollArea *mScrollArea; BrowserBox *mTextOutput; diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index 1c63d1c9..0ae042df 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -19,38 +19,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "whispertab.h" -#include "../../beingmanager.h" -#include "../../commandhandler.h" -#include "../../channel.h" -#include "../../configuration.h" -#include "../../game.h" -#include "../../localplayer.h" +#include "localplayer.h" + +#include "gui/palette.h" #ifdef TMWSERV_SUPPORT -#include "../../net/tmwserv/chatserver/chatserver.h" -#include "../../net/tmwserv/gameserver/player.h" +#include "net/tmwserv/chatserver/chatserver.h" #else -#include "../../party.h" -#include "../../net/messageout.h" -#include "../../net/ea/protocol.h" +#include "party.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" #endif -#include "../../resources/iteminfo.h" -#include "../../resources/itemdb.h" - -#include "../../utils/dtor.h" -#include "../../utils/gettext.h" -#include "../../utils/strprintf.h" -#include "../../utils/stringutils.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" WhisperTab::WhisperTab(const std::string &nick) : ChatTab(nick), mNick(nick) { + setForegroundColor(guiPalette->getColor(Palette::WHISPER)); } WhisperTab::~WhisperTab() @@ -58,7 +48,7 @@ WhisperTab::~WhisperTab() chatWindow->removeWhisper(mNick); } -void WhisperTab::sendChat(const std::string &msg) { +void WhisperTab::handleInput(const std::string &msg) { if (msg.length() == 0) { chatLog(_("Cannot send empty chat!"), BY_SERVER, false); return; @@ -78,7 +68,7 @@ void WhisperTab::sendChat(const std::string &msg) { msg.c_str()), BY_PLAYER, false); } -void WhisperTab::handleCommand(const std::string msg) +void WhisperTab::handleCommand(std::string msg) { if (msg == "close") delete this; diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h index 1d2f968d..739ae159 100644 --- a/src/gui/widgets/whispertab.h +++ b/src/gui/widgets/whispertab.h @@ -46,9 +46,9 @@ class WhisperTab : public ChatTab ~WhisperTab(); - void sendChat(const std::string &msg); + void handleInput(const std::string &msg); - void handleCommand(const std::string msg); + void handleCommand(std::string msg); private: std::string mNick; diff --git a/src/log.cpp b/src/log.cpp index 75b015da..322fcdae 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -32,7 +32,7 @@ #include "log.h" -#include "gui/chat.h" +#include "gui/widgets/chattab.h" Logger::Logger(): mLogToStandardOut(false), diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index b99db6a4..56d6a986 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -33,12 +33,11 @@ #include "gui/buy.h" #include "gui/buysell.h" -#include "gui/chat.h" #include "gui/sell.h" -#include "utils/gettext.h" +#include "gui/widgets/chattab.h" -#include +#include "utils/gettext.h" BuySellHandler::BuySellHandler() { diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 14432b28..6aca58a3 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -30,7 +30,7 @@ #include "game.h" #include "player_relations.h" -#include "gui/chat.h" +#include "gui/widgets/chattab.h" #include "utils/gettext.h" #include "utils/stringutils.h" diff --git a/src/net/ea/equipmenthandler.cpp b/src/net/ea/equipmenthandler.cpp index 7a287bea..f81bf7ed 100644 --- a/src/net/ea/equipmenthandler.cpp +++ b/src/net/ea/equipmenthandler.cpp @@ -31,7 +31,7 @@ #include "localplayer.h" #include "log.h" -#include "gui/chat.h" +#include "gui/widgets/chattab.h" #include "utils/gettext.h" diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 21ae6dcb..5f7e6c6c 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -32,9 +32,10 @@ #include "localplayer.h" #include "log.h" -#include "gui/chat.h" #include "gui/storagewindow.h" +#include "gui/widgets/chattab.h" + #include "resources/iteminfo.h" #include "utils/gettext.h" diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 00230ea3..bf775f51 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -33,7 +33,6 @@ #include "gui/buy.h" #include "gui/buysell.h" -#include "gui/chat.h" #include "gui/gui.h" #include "gui/npc_text.h" #include "gui/npcintegerdialog.h" @@ -45,6 +44,8 @@ #include "gui/storagewindow.h" #include "gui/viewport.h" +#include "gui/widgets/chattab.h" + #include "utils/stringutils.h" #include "utils/gettext.h" diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp index fcc0f4b2..477f96bf 100644 --- a/src/net/ea/skillhandler.cpp +++ b/src/net/ea/skillhandler.cpp @@ -27,9 +27,10 @@ #include "log.h" -#include "gui/chat.h" #include "gui/skill.h" +#include "gui/widgets/chattab.h" + #include "utils/gettext.h" /** job dependend identifiers (?) */ diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index ea41ed70..1df02a1e 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -30,10 +30,11 @@ #include "localplayer.h" #include "player_relations.h" -#include "gui/chat.h" #include "gui/confirm_dialog.h" #include "gui/trade.h" +#include "gui/widgets/chattab.h" + #include "utils/gettext.h" std::string tradePartnerName; diff --git a/src/net/tmwserv/partyhandler.cpp b/src/net/tmwserv/partyhandler.cpp index dfbcea80..510eb77a 100644 --- a/src/net/tmwserv/partyhandler.cpp +++ b/src/net/tmwserv/partyhandler.cpp @@ -26,9 +26,10 @@ #include "net/messagein.h" -#include "gui/chat.h" #include "gui/partywindow.h" +#include "gui/widgets/chattab.h" + #include "log.h" #include "localplayer.h" diff --git a/src/net/tmwserv/tradehandler.cpp b/src/net/tmwserv/tradehandler.cpp index 85228355..8b3e06c6 100644 --- a/src/net/tmwserv/tradehandler.cpp +++ b/src/net/tmwserv/tradehandler.cpp @@ -30,10 +30,11 @@ #include "item.h" #include "localplayer.h" -#include "gui/chat.h" #include "gui/confirm_dialog.h" #include "gui/trade.h" +#include "gui/widgets/chattab.h" + std::string tradePartnerName; int tradePartnerID; diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 077fbb63..fe076a55 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -21,10 +21,12 @@ #include -#include "gui/chat.h" #include "statuseffect.h" #include "log.h" + +#include "gui/widgets/chattab.h" + #include "utils/xml.h" -- cgit v1.2.3-70-g09d2 From ff5e1957dd4fde40e41e4c5e4b9e04e1f36e5ef2 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 27 Mar 2009 19:23:34 +0100 Subject: Removed unnecessary parenthesis on constructors --- src/game.cpp | 22 +++++++++++----------- src/gui/changeemaildialog.cpp | 6 +++--- src/gui/changepassworddialog.cpp | 8 ++++---- src/gui/chat.cpp | 2 +- src/gui/guildwindow.cpp | 4 ++-- src/gui/itemcontainer.cpp | 2 +- src/gui/npcpostdialog.cpp | 4 ++-- src/gui/serverdialog.cpp | 4 ++-- src/gui/setup_colors.cpp | 2 +- src/gui/skilldialog.cpp | 2 +- src/gui/unregisterdialog.cpp | 2 +- src/gui/window.cpp | 2 +- src/main.cpp | 4 ++-- 13 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 91d8fa3a..4687ed1f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -255,12 +255,12 @@ void createGuiWindows(Network *network) npcIntegerDialog = new NpcIntegerDialog; npcListDialog = new NpcListDialog; npcStringDialog = new NpcStringDialog; - npcPostDialog = new NpcPostDialog(); - magicDialog = new MagicDialog(); + npcPostDialog = new NpcPostDialog; + magicDialog = new MagicDialog; equipmentWindow = new EquipmentWindow(player_node->mEquipment.get()); - buddyWindow = new BuddyWindow(); - guildWindow = new GuildWindow(); - partyWindow = new PartyWindow(); + buddyWindow = new BuddyWindow; + guildWindow = new GuildWindow; + partyWindow = new PartyWindow; #else chatWindow = new ChatWindow(network); buyDialog = new BuyDialog(network); @@ -369,10 +369,10 @@ void destroyGuiWindows() #ifdef TMWSERV_SUPPORT Game::Game(): - mBeingHandler(new BeingHandler()), - mGuildHandler(new GuildHandler()), - mPartyHandler(new PartyHandler()), - mEffectHandler(new EffectHandler()), + mBeingHandler(new BeingHandler), + mGuildHandler(new GuildHandler), + mPartyHandler(new PartyHandler), + mEffectHandler(new EffectHandler), #else Game::Game(Network *network): mNetwork(network), @@ -397,7 +397,7 @@ Game::Game(Network *network): engine = new Engine; beingManager = new BeingManager; - commandHandler = new CommandHandler(); + commandHandler = new CommandHandler; #else createGuiWindows(network); engine = new Engine(network); @@ -407,7 +407,7 @@ Game::Game(Network *network): #endif floorItemManager = new FloorItemManager; - channelManager = new ChannelManager(); + channelManager = new ChannelManager; effectManager = new EffectManager; particleEngine = new Particle(NULL); diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index 0ed95bd7..14cfb1e7 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -40,14 +40,14 @@ ChangeEmailDialog::ChangeEmailDialog(Window *parent, LoginData *loginData): Window(_("Change Email Address"), true, parent), - mWrongDataNoticeListener(new WrongDataNoticeListener()), + mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { gcn::Label *accountLabel = new gcn::Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); gcn::Label *newEmailLabel = new gcn::Label(_("Type New Email Address twice:")); - mFirstEmailField = new TextField(); - mSecondEmailField = new TextField(); + mFirstEmailField = new TextField; + mSecondEmailField = new TextField; mChangeEmailButton = new Button(_("Change Email Address"), "change_email", this); mCancelButton = new Button(_("Cancel"), "cancel", this); diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 7c1e5bcd..4bc97326 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -41,16 +41,16 @@ ChangePasswordDialog::ChangePasswordDialog(Window *parent, LoginData *loginData): Window(_("Change Password"), true, parent), - mWrongDataNoticeListener(new WrongDataNoticeListener()), + mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { gcn::Label *accountLabel = new gcn::Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); gcn::Label *oldPassLabel = new gcn::Label(_("Password:")); - mOldPassField = new PasswordField(); + mOldPassField = new PasswordField; gcn::Label *newPassLabel = new gcn::Label(_("Type New Password twice:")); - mFirstPassField = new PasswordField(); - mSecondPassField = new PasswordField(); + mFirstPassField = new PasswordField; + mSecondPassField = new PasswordField; mChangePassButton = new Button(_("Change Password"), "change_password", this); mCancelButton = new Button(_("Cancel"), "cancel", this); diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 48858bf6..5b07980b 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -62,7 +62,7 @@ ChatWindow::ChatWindow(Network * network): mChatInput->setActionEventId("chatinput"); mChatInput->addActionListener(this); - mChatTabs = new TabbedArea(); + mChatTabs = new TabbedArea; add(mChatTabs); add(mChatInput); diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp index fb14235b..0d48b4f3 100644 --- a/src/gui/guildwindow.cpp +++ b/src/gui/guildwindow.cpp @@ -64,7 +64,7 @@ GuildWindow::GuildWindow(): mGuildButton[1]->setEnabled(false); mGuildButton[2]->setEnabled(false); - mGuildTabs = new TabbedArea(); + mGuildTabs = new TabbedArea; place(0, 0, mGuildButton[0]); place(1, 0, mGuildButton[1]); @@ -169,7 +169,7 @@ void GuildWindow::action(const gcn::ActionEvent &event) void GuildWindow::newGuildTab(const std::string &guildName) { // Create new tab - GuildListBox *list = new GuildListBox(); + GuildListBox *list = new GuildListBox; list->setListModel(player_node->getGuild(guildName)); ScrollArea *sa = new ScrollArea(list); sa->setDimension(gcn::Rectangle(5, 5, 135, 250)); diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index abce257d..bd180f28 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -61,7 +61,7 @@ ItemContainer::ItemContainer(Inventory *inventory, mSwapItems(false), mDescItems(false) { - mItemPopup = new ItemPopup(); + mItemPopup = new ItemPopup; setFocusable(true); ResourceManager *resman = ResourceManager::getInstance(); diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index e0133473..5c083612 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -41,7 +41,7 @@ NpcPostDialog::NpcPostDialog(): // create text field for receiver gcn::Label *senderText = new gcn::Label("To:"); senderText->setPosition(5, 5); - mSender = new TextField(); + mSender = new TextField; mSender->setPosition(senderText->getWidth() + 5, 5); mSender->setWidth(65); @@ -54,7 +54,7 @@ NpcPostDialog::NpcPostDialog(): sendButton->getY()); // create textfield for letter - mText = new TextBox(); + mText = new TextBox; mText->setHeight(400 - (mSender->getHeight() + sendButton->getHeight())); mText->setEditable(true); diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index a57be06c..9d679acb 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -80,7 +80,7 @@ ServerDialog::ServerDialog(LoginData *loginData): mPortField = new TextField(toString(mLoginData->port)); // Add the most used servers from config - mMostUsedServersListModel = new ServersListModel(); + mMostUsedServersListModel = new ServersListModel; Server currentServer; std::string currentConfig = ""; for (int i=0; i<=MAX_SERVERLIST; i++) @@ -101,7 +101,7 @@ ServerDialog::ServerDialog(LoginData *loginData): mMostUsedServersListBox = new ListBox(NULL); mMostUsedServersListBox->setListModel(mMostUsedServersListModel); - mMostUsedServersScrollArea = new ScrollArea(); + mMostUsedServersScrollArea = new ScrollArea; mMostUsedServersDropDown = new DropDown(mMostUsedServersListModel, mMostUsedServersScrollArea, mMostUsedServersListBox); diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index 073bbc1a..dcd0b73d 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -79,7 +79,7 @@ Setup_Colors::Setup_Colors() : mGradTypeSlider->addActionListener(this); mGradTypeSlider->setEnabled(false); - mGradTypeText = new Label(); + mGradTypeText = new Label; mRedLabel = new Label(_("Red: ")); diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index e30299d4..16c983ad 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -102,7 +102,7 @@ SkillDialog::SkillDialog(): setCloseButton(true); setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425); - TabbedArea *panel = new TabbedArea(); + TabbedArea *panel = new TabbedArea; panel->setDimension(gcn::Rectangle(5, 5, 270, 420)); Skill_Tab *tab; diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 7906afc1..c133c9f7 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -42,7 +42,7 @@ UnRegisterDialog::UnRegisterDialog(Window *parent, LoginData *loginData): Window("Unregister", true, parent), - mWrongDataNoticeListener(new WrongDataNoticeListener()), + mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { gcn::Label *userLabel = new gcn::Label(strprintf(_("Name: %s"), mLoginData->username.c_str())); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 3bc03fb8..5dd32e00 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -60,7 +60,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent, const std throw GCN_EXCEPTION("Window::Window(): no windowContainer set"); if (instances == 0) - skinLoader = new SkinLoader(); + skinLoader = new SkinLoader; instances++; diff --git a/src/main.cpp b/src/main.cpp index 8fe1de86..321a4ee0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1048,7 +1048,7 @@ int main(int argc, char *argv[]) initHomeDir(); // Configure logger - logger = new Logger(); + logger = new Logger; logger->setLogFile(homeDir + std::string("/tmw.log")); logger->setLogToStandardOut(config.getValue("logToStandardOut", 0)); @@ -1088,7 +1088,7 @@ int main(int argc, char *argv[]) top->add(versionLabel, 25, 2); #endif ProgressBar *progressBar = new ProgressBar(0.0f, 100, 20, 168, 116, 31); - gcn::Label *progressLabel = new Label(); + gcn::Label *progressLabel = new Label; top->add(progressBar, 5, top->getHeight() - 5 - progressBar->getHeight()); top->add(progressLabel, 15 + progressBar->getWidth(), progressBar->getY() + 4); -- cgit v1.2.3-70-g09d2 From 712ca58c011123505c807266dcc8d9d84ca1aa44 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 27 Mar 2009 19:44:23 +0100 Subject: Made eAthena's Network class statically accessible Now the instance doesn't need to be passed into the MessageOut class anymore. Expect a lot of cleanup in the next commit. --- src/beingmanager.cpp | 3 +-- src/commandhandler.cpp | 6 ++---- src/engine.cpp | 3 +-- src/game.cpp | 3 +-- src/gui/buy.cpp | 3 +-- src/gui/buysell.cpp | 3 +-- src/gui/char_select.cpp | 9 +++------ src/gui/npc_text.cpp | 6 ++---- src/gui/npcintegerdialog.cpp | 3 +-- src/gui/npclistdialog.cpp | 3 +-- src/gui/npcstringdialog.cpp | 3 +-- src/gui/popupmenu.cpp | 3 +-- src/gui/sell.cpp | 4 +--- src/gui/storagewindow.cpp | 9 +++------ src/gui/trade.cpp | 18 ++++++------------ src/gui/widgets/chattab.cpp | 7 ++----- src/gui/widgets/whispertab.cpp | 3 +-- src/localplayer.cpp | 42 ++++++++++++++---------------------------- src/main.cpp | 10 +++------- src/net/ea/network.cpp | 9 +++++++++ src/net/ea/network.h | 6 +++++- src/net/messageout.cpp | 11 +++-------- src/net/messageout.h | 4 +--- src/npc.cpp | 3 +-- src/party.cpp | 12 ++++-------- 25 files changed, 69 insertions(+), 117 deletions(-) diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index d72c4ee4..ae9ee787 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -120,8 +120,7 @@ Being *BeingManager::createBeing(int id, Uint16 job) // Player or NPC if (job <= 1000 || (job >= 4001 && job <= 4049)) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0094); + MessageOut outMsg(0x0094); outMsg.writeInt32(id);//readLong(2)); } #endif diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 14c5434a..73e41554 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -142,8 +142,7 @@ void CommandHandler::handleAnnounce(const std::string &args) #ifdef TMWSERV_SUPPORT Net::ChatServer::announce(args); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0099); + MessageOut outMsg(0x0099); outMsg.writeInt16(args.length() + 4); outMsg.writeString(args, args.length()); #endif @@ -332,8 +331,7 @@ void CommandHandler::handleWho() #ifdef TMWSERV_SUPPORT //TODO #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x00c1); + MessageOut outMsg(0x00c1); #endif } diff --git a/src/engine.cpp b/src/engine.cpp index da4eb336..13563e66 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -151,8 +151,7 @@ void Engine::changeMap(const std::string &mapPath) #ifdef EATHENA_SUPPORT // Send "map loaded" - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_MAP_LOADED); + MessageOut outMsg(CMSG_MAP_LOADED); #endif } diff --git a/src/game.cpp b/src/game.cpp index 4687ed1f..5b389c3f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -468,8 +468,7 @@ Game::Game(Network *network): * packet is handled by the older version, but its response * is ignored by the client */ - MessageOut msg(mNetwork); - msg.writeInt16(CMSG_CLIENT_PING); + MessageOut msg(CMSG_CLIENT_PING); msg.writeInt32(tick_time); engine->changeMap(map_path); diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 6df2ae25..003e730e 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -199,8 +199,7 @@ void BuyDialog::action(const gcn::ActionEvent &event) Net::GameServer::Player::tradeWithNPC (mShopItems->at(selectedItem)->getId(), mAmountItems); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_BUY_REQUEST); + MessageOut outMsg(CMSG_NPC_BUY_REQUEST); outMsg.writeInt16(8); outMsg.writeInt16(mAmountItems); outMsg.writeInt16(mShopItems->at(selectedItem)->getId()); diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index b9a6a1dc..f45a5adb 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -97,8 +97,7 @@ void BuySellDialog::action(const gcn::ActionEvent &event) } #ifdef EATHENA_SUPPORT - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_BUY_SELL_REQUEST); + MessageOut outMsg(CMSG_NPC_BUY_SELL_REQUEST); outMsg.writeInt32(current_npc); outMsg.writeInt8(action); #endif diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 4ab3d9ef..b6cd47d4 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -348,8 +348,7 @@ void CharSelectDialog::attemptCharDelete() Net::AccountServer::Account::deleteCharacter(mCharInfo->getPos()); #else // Request character deletion - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0068); + MessageOut outMsg(0x0068); outMsg.writeInt32(mCharInfo->getEntry()->mCharId); outMsg.writeString("a@a.com", 40); #endif @@ -362,8 +361,7 @@ void CharSelectDialog::attemptCharSelect() Net::AccountServer::Account::selectCharacter(mCharInfo->getPos()); #else // Request character selection - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0066); + MessageOut outMsg(0x0066); outMsg.writeInt8(mCharInfo->getPos()); #endif mCharInfo->lock(); @@ -693,8 +691,7 @@ int CharCreateDialog::getDistributedPoints() void CharCreateDialog::attemptCharCreate() { // Send character infos - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0067); + MessageOut outMsg(0x0067); outMsg.writeString(getName(), 24); outMsg.writeInt8(5); outMsg.writeInt8(5); diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 9fa57be8..bf7b60ed 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -136,8 +136,7 @@ void NpcTextDialog::nextDialog(int npcID) #ifdef TMWSERV_SUPPORT Net::GameServer::Player::talkToNPC(npcID, false); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_NEXT_REQUEST); + MessageOut outMsg(CMSG_NPC_NEXT_REQUEST); outMsg.writeInt32(npcID); #endif } @@ -145,8 +144,7 @@ void NpcTextDialog::nextDialog(int npcID) void NpcTextDialog::closeDialog(int npcID) { #ifdef EATHENA_SUPPORT - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_CLOSE); + MessageOut outMsg(CMSG_NPC_CLOSE); outMsg.writeInt32(npcID); #endif } diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index a7ae2748..4dae8d83 100644 --- a/src/gui/npcintegerdialog.cpp +++ b/src/gui/npcintegerdialog.cpp @@ -127,8 +127,7 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event) NPC::isTalking = false; #ifdef EATHENA_SUPPORT - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_INT_RESPONSE); + MessageOut outMsg(CMSG_NPC_INT_RESPONSE); outMsg.writeInt32(current_npc); outMsg.writeInt32(mValueField->getValue()); #endif diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index ff91c9fc..6df0979f 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -143,8 +143,7 @@ void NpcListDialog::action(const gcn::ActionEvent &event) #ifdef TMWSERV_SUPPORT Net::GameServer::Player::selectFromNPC(current_npc, choice); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_LIST_CHOICE); + MessageOut outMsg(CMSG_NPC_LIST_CHOICE); outMsg.writeInt32(current_npc); outMsg.writeInt8(choice); #endif diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index c84de015..7297d7e8 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -95,8 +95,7 @@ void NpcStringDialog::action(const gcn::ActionEvent &event) mValueField->setText(""); #ifdef EATHENA_SUPPORT - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_STR_RESPONSE); + MessageOut outMsg(CMSG_NPC_STR_RESPONSE); outMsg.writeInt16(text.length() + 9); outMsg.writeInt32(current_npc); outMsg.writeString(text, text.length()); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 5b5b2b8c..1f36ef45 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -297,8 +297,7 @@ void PopupMenu::handleLink(const std::string &link) being && being->getType() == Being::PLAYER) { - MessageOut outMsg(player_node->getNetwork()); - outMsg.writeInt16(CMSG_PARTY_INVITE); + MessageOut outMsg(CMSG_PARTY_INVITE); outMsg.writeInt32(being->getId()); } #endif diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index e7671110..648bff08 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -207,15 +207,13 @@ void SellDialog::action(const gcn::ActionEvent &event) (mShopItems->at(selectedItem)->getId(), mAmountItems); #else // Attempt sell - MessageOut outMsg(mNetwork); - ShopItem *item = mShopItems->at(selectedItem); int sellCount; mPlayerMoney += mAmountItems * mShopItems->at(selectedItem)->getPrice(); mMaxItems -= mAmountItems; while (mAmountItems > 0) { - outMsg.writeInt16(CMSG_NPC_SELL_REQUEST); + MessageOut outMsg(CMSG_NPC_SELL_REQUEST); outMsg.writeInt16(8); outMsg.writeInt16(item->getCurrentInvIndex()); // This order is important, item->getCurrentInvIndex() would return diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp index 1289a4e7..847886cb 100644 --- a/src/gui/storagewindow.cpp +++ b/src/gui/storagewindow.cpp @@ -190,22 +190,19 @@ Item* StorageWindow::getSelectedItem() const void StorageWindow::addStore(Item* item, int ammount) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_MOVE_TO_STORAGE); + MessageOut outMsg(CMSG_MOVE_TO_STORAGE); outMsg.writeInt16(item->getInvIndex()); outMsg.writeInt32(ammount); } void StorageWindow::removeStore(Item* item, int ammount) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CSMG_MOVE_FROM_STORAGE); + MessageOut outMsg(CSMG_MOVE_FROM_STORAGE); outMsg.writeInt16(item->getInvIndex()); outMsg.writeInt32(ammount); } void StorageWindow::close() { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_CLOSE_STORAGE); + MessageOut outMsg(CMSG_CLOSE_STORAGE); } diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 4ecdede8..6cba1c41 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -252,8 +252,7 @@ void TradeWindow::tradeItem(Item *item, int quantity) // function. Detect the actual server version, and re-enable this // for that version only. //addItem(item->getId(), true, quantity, item->isEquipment()); - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST); + MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST); outMsg.writeInt16(item->getInvIndex()); outMsg.writeInt32(quantity); #endif @@ -329,8 +328,7 @@ void TradeWindow::action(const gcn::ActionEvent &event) #ifdef TMWSERV_SUPPORT Net::GameServer::Player::acceptTrade(false); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_CANCEL_REQUEST); + MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST); #endif } #ifdef EATHENA_SUPPORT @@ -342,8 +340,7 @@ void TradeWindow::action(const gcn::ActionEvent &event) { mMoneyField->setText(toString(tempInt)); - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST); + MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST); outMsg.writeInt16(0); outMsg.writeInt32(tempInt); } @@ -352,8 +349,7 @@ void TradeWindow::action(const gcn::ActionEvent &event) mMoneyField->setText(""); } mMoneyField->setEnabled(false); - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_ADD_COMPLETE); + MessageOut outMsg(CMSG_TRADE_ADD_COMPLETE); } #endif else if (event.getId() == "trade") @@ -362,8 +358,7 @@ void TradeWindow::action(const gcn::ActionEvent &event) Net::GameServer::Player::acceptTrade(true); setStatus(PROPOSING); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_OK); + MessageOut outMsg(CMSG_TRADE_OK); #endif } #ifdef TMWSERV_SUPPORT @@ -382,7 +377,6 @@ void TradeWindow::close() #ifdef TMWSERV_SUPPORT Net::GameServer::Player::acceptTrade(false); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_CANCEL_REQUEST); + MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST); #endif } diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 715aaf20..c4b2196b 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -239,9 +239,7 @@ void ChatTab::chatInput(std::string &msg) chatLog(_("Trying to send a blank party message."), BY_SERVER, true); return; } - MessageOut outMsg(chatWindow->mNetwork); - - outMsg.writeInt16(CMSG_PARTY_MESSAGE); + MessageOut outMsg(CMSG_PARTY_MESSAGE); outMsg.writeInt16(length + 4); outMsg.writeString(msg, length); return; @@ -306,8 +304,7 @@ void ChatTab::handleInput(const std::string &msg) { #else std::string mes = player_node->getName() + " : " + msg; - MessageOut outMsg(chatWindow->mNetwork); - outMsg.writeInt16(CMSG_CHAT_MESSAGE); + 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); diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index 0ae042df..1621e965 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -57,8 +57,7 @@ void WhisperTab::handleInput(const std::string &msg) { #ifdef TMWSERV_SUPPORT Net::ChatServer::privMsg(mNick, msg); #else - MessageOut outMsg(chatWindow->mNetwork); - outMsg.writeInt16(CMSG_CHAT_WHISPER); + MessageOut outMsg(CMSG_CHAT_WHISPER); outMsg.writeInt16(msg.length() + 28); outMsg.writeString(mNick, 24); outMsg.writeString(msg, msg.length()); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index f8fad1e8..8b2d6907 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -399,8 +399,7 @@ void LocalPlayer::equipItem(Item *item) #ifdef TMWSERV_SUPPORT Net::GameServer::Player::equip(item->getInvIndex()); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_PLAYER_EQUIP); + MessageOut outMsg(CMSG_PLAYER_EQUIP); outMsg.writeInt16(item->getInvIndex()); outMsg.writeInt16(0); #endif @@ -428,8 +427,7 @@ void LocalPlayer::unequipItem(Item *item) if (!item) return; - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_PLAYER_UNEQUIP); + MessageOut outMsg(CMSG_PLAYER_UNEQUIP); outMsg.writeInt16(item->getInvIndex()); // Tidy equipment directly to avoid weapon still shown bug, for instance @@ -438,8 +436,7 @@ void LocalPlayer::unequipItem(Item *item) void LocalPlayer::useItem(Item *item) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_PLAYER_INVENTORY_USE); + MessageOut outMsg(CMSG_PLAYER_INVENTORY_USE); outMsg.writeInt16(item->getInvIndex()); outMsg.writeInt32(item->getId()); // Note: id is dest of item, usually player_node->account_ID ?? @@ -453,8 +450,7 @@ void LocalPlayer::dropItem(Item *item, int quantity) Net::GameServer::Player::drop(item->getInvIndex(), quantity); #else // TODO: Fix wrong coordinates of drops, serverside? - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_PLAYER_INVENTORY_DROP); + MessageOut outMsg(CMSG_PLAYER_INVENTORY_DROP); outMsg.writeInt16(item->getInvIndex()); outMsg.writeInt16(quantity); #endif @@ -488,8 +484,7 @@ void LocalPlayer::pickUp(FloorItem *item) int id = item->getId(); Net::GameServer::Player::pickUp(id >> 16, id & 0xFFFF); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_ITEM_PICKUP); + MessageOut outMsg(CMSG_ITEM_PICKUP); outMsg.writeInt32(item->getId()); #endif mPickUpTarget = NULL; @@ -689,9 +684,8 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y) effectManager->trigger(15,x,y); #else char temp[4] = ""; - MessageOut outMsg(mNetwork); set_coordinates(temp, x, y, mDirection); - outMsg.writeInt16(0x0085); + MessageOut outMsg(0x0085); outMsg.writeString(temp, 3); #endif } @@ -734,8 +728,7 @@ void LocalPlayer::stopWalking(bool sendToServer) #ifdef EATHENA_SUPPORT void LocalPlayer::raiseAttribute(Attribute attr) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_STAT_UPDATE_REQUEST); + MessageOut outMsg(CMSG_STAT_UPDATE_REQUEST); switch (attr) { @@ -771,8 +764,7 @@ void LocalPlayer::raiseSkill(Uint16 skillId) if (mSkillPoint <= 0) return; - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_SKILL_LEVELUP_REQUEST); + MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST); outMsg.writeInt16(skillId); } #endif @@ -795,8 +787,7 @@ void LocalPlayer::toggleSit() setAction(newAction); Net::GameServer::Player::changeAction(newAction); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0089); + MessageOut outMsg(0x0089); outMsg.writeInt32(0); outMsg.writeInt8((newAction == SIT) ? 2 : 3); #endif @@ -810,8 +801,7 @@ void LocalPlayer::emote(Uint8 emotion) // XXX Convert for new server #ifdef EATHENA_SUPPORT - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x00bf); + MessageOut outMsg(0x00bf); outMsg.writeInt8(emotion); #endif } @@ -822,8 +812,7 @@ void LocalPlayer::tradeReply(bool accept) if (!accept) mTrading = false; - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_RESPONSE); + MessageOut outMsg(CMSG_TRADE_RESPONSE); outMsg.writeInt8(accept ? 3 : 4); } #endif @@ -837,8 +826,7 @@ void LocalPlayer::trade(Being *being) const tradePartnerID = being->getId(); Net::GameServer::Player::requestTrade(tradePartnerID); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_REQUEST); + MessageOut outMsg(CMSG_TRADE_REQUEST); outMsg.writeInt32(being->getId()); #endif } @@ -957,8 +945,7 @@ void LocalPlayer::attack(Being *target, bool keep) sound.playSfx("sfx/fist-swish.ogg"); } - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0089); + MessageOut outMsg(0x0089); outMsg.writeInt32(target->getId()); outMsg.writeInt8(0); @@ -983,8 +970,7 @@ void LocalPlayer::revive() { // XXX Convert for new server #ifdef EATHENA_SUPPORT - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x00b2); + MessageOut outMsg(0x00b2); outMsg.writeInt8(0); #endif } diff --git a/src/main.cpp b/src/main.cpp index 321a4ee0..bd17ce9c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -752,8 +752,7 @@ static void accountLogin(Network *network, LoginData *loginData) loginData->username, loginData->password); #else - MessageOut outMsg(network); - outMsg.writeInt16(0x0064); + MessageOut outMsg(0x0064); outMsg.writeInt32(0); // client version outMsg.writeString(loginData->username, 24); outMsg.writeString(loginData->password, 24); @@ -807,8 +806,7 @@ static void charLogin(Network *network, LoginData *loginData) charServerHandler.setLoginData(loginData); // Send login infos - MessageOut outMsg(network); - outMsg.writeInt16(0x0065); + MessageOut outMsg(0x0065); outMsg.writeInt32(loginData->account_ID); outMsg.writeInt32(loginData->session_ID1); outMsg.writeInt32(loginData->session_ID2); @@ -827,8 +825,6 @@ static void mapLogin(Network *network, LoginData *loginData) player_node->getName().c_str()); config.setValue("lastCharacter", player_node->getName()); - MessageOut outMsg(network); - logger->log("Trying to connect to map server..."); logger->log("Map: %s", map_path.c_str()); @@ -836,7 +832,7 @@ static void mapLogin(Network *network, LoginData *loginData) network->registerHandler(&mapLoginHandler); // Send login infos - outMsg.writeInt16(0x0072); + MessageOut outMsg(0x0072); outMsg.writeInt32(loginData->account_ID); outMsg.writeInt32(player_node->mCharId); outMsg.writeInt32(loginData->session_ID1); diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index e17b8f3b..4aecb268 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -91,6 +91,8 @@ int networkThread(void *data) return 0; } +Network *Network::mInstance = 0; + Network::Network(): mSocket(0), mAddress(), mPort(0), @@ -102,6 +104,7 @@ Network::Network(): mWorkerThread(0) { mMutex = SDL_CreateMutex(); + mInstance = this; } Network::~Network() @@ -112,6 +115,7 @@ Network::~Network() disconnect(); SDL_DestroyMutex(mMutex); + mInstance = 0; delete[] mInBuffer; delete[] mOutBuffer; @@ -420,6 +424,11 @@ void Network::receive() SDLNet_FreeSocketSet(set); } +Network *Network::instance() +{ + return mInstance; +} + void Network::setError(const std::string &error) { logger->log("Network error: %s", error.c_str()); diff --git a/src/net/ea/network.h b/src/net/ea/network.h index 651b1182..40d563aa 100644 --- a/src/net/ea/network.h +++ b/src/net/ea/network.h @@ -85,7 +85,9 @@ class Network NET_ERROR }; - protected: + private: + static Network *instance(); + void setError(const std::string &error); Uint16 readWord(int pos); @@ -113,6 +115,8 @@ class Network typedef std::map MessageHandlers; typedef MessageHandlers::iterator MessageHandlerIterator; MessageHandlers mMessageHandlers; + + static Network *mInstance; }; #endif diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index 4cb4dc36..35e9a425 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -33,21 +33,16 @@ #include #include -#ifdef TMWSERV_SUPPORT MessageOut::MessageOut(short id): mData(0), -#else -MessageOut::MessageOut(Network *network): - mNetwork(network), -#endif mDataSize(0), mPos(0) { -#ifdef TMWSERV_SUPPORT - writeInt16(id); -#else +#ifdef EATHENA_SUPPORT + mNetwork = Network::instance(); mData = mNetwork->mOutBuffer + mNetwork->mOutSize; #endif + writeInt16(id); } #ifdef TMWSERV_SUPPORT diff --git a/src/net/messageout.h b/src/net/messageout.h index 1ddd040d..9dc31525 100644 --- a/src/net/messageout.h +++ b/src/net/messageout.h @@ -43,15 +43,13 @@ class MessageOut /** * Constructor. */ -#ifdef TMWSERV_SUPPORT MessageOut(short id); +#ifdef TMWSERV_SUPPORT /** * Destructor. */ ~MessageOut(); -#else - MessageOut(Network *network); #endif void writeInt8(Sint8 value); /**< Writes a byte. */ diff --git a/src/npc.cpp b/src/npc.cpp index b75d74b3..98c3e0eb 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -129,8 +129,7 @@ void NPC::talk() if (!mNetwork) return; - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_TALK); + MessageOut outMsg(CMSG_NPC_TALK); outMsg.writeInt32(mId); outMsg.writeInt8(0); #endif diff --git a/src/party.cpp b/src/party.cpp index 51a86360..4a7912ee 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -56,8 +56,7 @@ void Party::respond(const std::string &command, const std::string &args) localChatTab->chatLog(_("Not yet implemented!"), BY_SERVER); return; /* - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_PARTY_SETTINGS); + MessageOut outMsg(CMSG_PARTY_SETTINGS); outMsg.writeInt16(0); // Experience outMsg.writeInt16(0); // Item */ @@ -72,16 +71,14 @@ void Party::create(const std::string &party) localChatTab->chatLog(_("Party name is missing."), BY_SERVER); return; } - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_PARTY_CREATE); + MessageOut outMsg(CMSG_PARTY_CREATE); outMsg.writeString(party.substr(0, 23), 24); mCreating = true; } void Party::leave(const std::string &args) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_PARTY_LEAVE); + MessageOut outMsg(CMSG_PARTY_LEAVE); localChatTab->chatLog(_("Left party."), BY_SERVER); mInParty = false; } @@ -137,8 +134,7 @@ void Party::invitedAsk(const std::string &nick, int gender, void Party::InviteListener::action(const gcn::ActionEvent &event) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_PARTY_INVITED); + MessageOut outMsg(CMSG_PARTY_INVITED); outMsg.writeInt32(player_node->getId()); bool accept = event.getId() == "yes"; outMsg.writeInt32(accept ? 1 : 0); -- cgit v1.2.3-70-g09d2 From 60f10c242fc4f99b0ab0f8d8c6d4b4acde0022cd Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 27 Mar 2009 21:13:02 +0100 Subject: Clean up of most of the Network pointers Now that messages can be sent without requiring a pointer to the Network instance, a lot of cleanup was possible. --- src/beingmanager.cpp | 7 ++----- src/beingmanager.h | 10 +--------- src/commandhandler.cpp | 5 ----- src/commandhandler.h | 12 ------------ src/engine.cpp | 6 ------ src/engine.h | 10 ---------- src/game.cpp | 34 ++++++---------------------------- src/gui/buy.cpp | 7 ------- src/gui/buy.h | 10 ---------- src/gui/buysell.cpp | 4 ++-- src/gui/buysell.h | 7 +------ src/gui/char_select.cpp | 17 +++++++---------- src/gui/char_select.h | 14 ++------------ src/gui/chat.cpp | 7 +------ src/gui/chat.h | 8 -------- src/gui/npc_text.cpp | 7 ------- src/gui/npc_text.h | 10 ---------- src/gui/npcintegerdialog.cpp | 7 ------- src/gui/npcintegerdialog.h | 10 ---------- src/gui/npclistdialog.cpp | 7 ------- src/gui/npclistdialog.h | 11 ----------- src/gui/npcstringdialog.cpp | 7 ------- src/gui/npcstringdialog.h | 11 ----------- src/gui/sell.cpp | 6 ------ src/gui/sell.h | 10 ---------- src/gui/storagewindow.cpp | 3 +-- src/gui/storagewindow.h | 4 +--- src/gui/trade.cpp | 5 ----- src/gui/trade.h | 11 ----------- src/localplayer.cpp | 1 - src/localplayer.h | 8 -------- src/main.cpp | 2 +- src/net/ea/network.h | 2 -- src/npc.cpp | 9 --------- src/npc.h | 14 +++----------- src/party.cpp | 5 ++--- src/party.h | 11 ++++------- 37 files changed, 34 insertions(+), 285 deletions(-) diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index ae9ee787..9c671808 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -59,12 +59,9 @@ class FindBeingFunctor Being::Type type; } beingFinder; -#ifdef EATHENA_SUPPORT -BeingManager::BeingManager(Network *network): - mNetwork(network) +BeingManager::BeingManager() { } -#endif BeingManager::~BeingManager() { @@ -111,7 +108,7 @@ Being *BeingManager::createBeing(int id, Uint16 job) if (job <= 25 || (job >= 4001 && job <= 4049)) being = new Player(id, job, mMap); else if (job >= 46 && job <= 1000) - being = new NPC(id, job, mMap, mNetwork); + being = new NPC(id, job, mMap); else if (job > 1000 && job <= 2000) being = new Monster(id, job, mMap); else diff --git a/src/beingmanager.h b/src/beingmanager.h index 109564fa..891a8ccb 100644 --- a/src/beingmanager.h +++ b/src/beingmanager.h @@ -26,9 +26,6 @@ class LocalPlayer; class Map; -#ifdef EATHENA_SUPPORT -class Network; -#endif typedef std::list Beings; typedef Beings::iterator BeingIterator; @@ -36,9 +33,7 @@ typedef Beings::iterator BeingIterator; class BeingManager { public: -#ifdef EATHENA_SUPPORT - BeingManager(Network *network); -#endif + BeingManager(); ~BeingManager(); @@ -130,9 +125,6 @@ class BeingManager protected: Beings mBeings; Map *mMap; -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif }; extern BeingManager *beingManager; diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 73e41554..a2de2c63 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -43,12 +43,7 @@ #include "utils/stringutils.h" #include "utils/strprintf.h" -#ifdef TMWSERV_SUPPORT CommandHandler::CommandHandler() -#else -CommandHandler::CommandHandler(Network *network): - mNetwork(network) -#endif {} void CommandHandler::handleCommand(const std::string &command) diff --git a/src/commandhandler.h b/src/commandhandler.h index 2adf4e1b..43ce172f 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -24,10 +24,6 @@ #include -#ifdef EATHENA_SUPPORT -class Network; -#endif - /** * A class to parse and handle user commands */ @@ -37,11 +33,7 @@ class CommandHandler /** * Constructor */ -#ifdef TMWSERV_SUPPORT CommandHandler(); -#else - CommandHandler(Network *network); -#endif /** * Destructor @@ -143,10 +135,6 @@ class CommandHandler * Handle a present command. */ void handlePresent(const std::string &args); - -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif }; extern CommandHandler *commandHandler; diff --git a/src/engine.cpp b/src/engine.cpp index 13563e66..d13fbf3f 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -44,14 +44,8 @@ #include "utils/stringutils.h" -#ifdef TMWSERV_SUPPORT Engine::Engine(): mCurrentMap(NULL) -#else -Engine::Engine(Network *network): - mCurrentMap(NULL), - mNetwork(network) -#endif { } diff --git a/src/engine.h b/src/engine.h index 60b1f6c8..eafce3b9 100644 --- a/src/engine.h +++ b/src/engine.h @@ -25,9 +25,6 @@ #include class Map; -#ifdef EATHENA_SUPPORT -class Network; -#endif /** * Game engine. Actually hardly does anything anymore except keeping track of @@ -39,11 +36,7 @@ class Engine /** * Constructor. */ -#ifdef EATHENA_SUPPORT - Engine(Network *network); -#else Engine(); -#endif /** * Destructor. @@ -69,9 +62,6 @@ class Engine private: Map *mCurrentMap; -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif std::string mMapName; }; diff --git a/src/game.cpp b/src/game.cpp index 5b389c3f..856a5c11 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -239,14 +239,9 @@ int get_elapsed_time(int start_time) /** * Create all the various globally accessible gui windows */ -#ifdef TMWSERV_SUPPORT -void createGuiWindows() -#else -void createGuiWindows(Network *network) -#endif +static void createGuiWindows() { // Create dialogs -#ifdef TMWSERV_SUPPORT chatWindow = new ChatWindow; buyDialog = new BuyDialog; sellDialog = new SellDialog; @@ -255,6 +250,7 @@ void createGuiWindows(Network *network) npcIntegerDialog = new NpcIntegerDialog; npcListDialog = new NpcListDialog; npcStringDialog = new NpcStringDialog; +#ifdef TMWSERV_SUPPORT npcPostDialog = new NpcPostDialog; magicDialog = new MagicDialog; equipmentWindow = new EquipmentWindow(player_node->mEquipment.get()); @@ -262,17 +258,9 @@ void createGuiWindows(Network *network) guildWindow = new GuildWindow; partyWindow = new PartyWindow; #else - chatWindow = new ChatWindow(network); - buyDialog = new BuyDialog(network); - sellDialog = new SellDialog(network); - buySellDialog = new BuySellDialog(network); - tradeWindow = new TradeWindow(network); + buySellDialog = new BuySellDialog; equipmentWindow = new EquipmentWindow; - npcTextDialog = new NpcTextDialog(network); - npcIntegerDialog = new NpcIntegerDialog(network); - npcListDialog = new NpcListDialog(network); - npcStringDialog = new NpcStringDialog(network); - storageWindow = new StorageWindow(network); + storageWindow = new StorageWindow; #endif menuWindow = new MenuWindow; statusWindow = new StatusWindow(player_node); @@ -328,7 +316,7 @@ void createGuiWindows(Network *network) /** * Destroy all the globally accessible gui windows */ -void destroyGuiWindows() +static void destroyGuiWindows() { logger->setChatWindow(NULL); delete localChatTab; // Need to do this first, so it can remove itself @@ -392,20 +380,11 @@ Game::Game(Network *network): { done = false; -#ifdef TMWSERV_SUPPORT createGuiWindows(); engine = new Engine; beingManager = new BeingManager; commandHandler = new CommandHandler; -#else - createGuiWindows(network); - engine = new Engine(network); - - beingManager = new BeingManager(network); - commandHandler = new CommandHandler(network); -#endif - floorItemManager = new FloorItemManager; channelManager = new ChannelManager; effectManager = new EffectManager; @@ -425,8 +404,7 @@ Game::Game(Network *network): // Initialize beings beingManager->setPlayer(player_node); #ifdef EATHENA_SUPPORT - player_node->setNetwork(network); - playerParty = new Party(network); + playerParty = new Party; #endif Joystick::init(); diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 003e730e..6d336e4c 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -46,15 +46,8 @@ #include "utils/gettext.h" #include "utils/strprintf.h" -#ifdef TMWSERV_SUPPORT BuyDialog::BuyDialog(): -#else -BuyDialog::BuyDialog(Network *network): -#endif Window(_("Buy")), -#ifndef TMWSERV_SUPPORT - mNetwork(network), -#endif mMoney(0), mAmountItems(0), mMaxItems(0) { setWindowName("Buy"); diff --git a/src/gui/buy.h b/src/gui/buy.h index 200394b9..1e022652 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -29,9 +29,6 @@ #include "../guichanfwd.h" -#ifndef TMWSERV_SUPPORT -class Network; -#endif class ShopItems; class ShopListBox; class ListBox; @@ -50,11 +47,7 @@ class BuyDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT BuyDialog(); -#else - BuyDialog(Network *network); -#endif /** * Destructor @@ -116,9 +109,6 @@ class BuyDialog : public Window, public gcn::ActionListener, */ void close(); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::Button *mBuyButton; gcn::Button *mQuitButton; gcn::Button *mAddMaxButton; diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index f45a5adb..8fffd3d5 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -31,8 +31,8 @@ #include "../utils/gettext.h" -BuySellDialog::BuySellDialog(Network *network): - Window(_("Shop")), mNetwork(network) +BuySellDialog::BuySellDialog(): + Window(_("Shop")) { setWindowName("BuySell"); Button *buyButton = 0; diff --git a/src/gui/buysell.h b/src/gui/buysell.h index 4b137554..ff956e09 100644 --- a/src/gui/buysell.h +++ b/src/gui/buysell.h @@ -26,8 +26,6 @@ #include "window.h" -class Network; - /** * A dialog to choose between buying or selling at a shop. * @@ -42,7 +40,7 @@ class BuySellDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - BuySellDialog(Network *network); + BuySellDialog(); /** * Check for current NPC @@ -55,9 +53,6 @@ class BuySellDialog : public Window, public gcn::ActionListener * Called when receiving actions from the widgets. */ void action(const gcn::ActionEvent &event); - - private: - Network *mNetwork; }; extern BuySellDialog *buySellDialog; diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index b6cd47d4..a0f7230e 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -100,12 +100,13 @@ void CharDeleteConfirm::action(const gcn::ActionEvent &event) CharSelectDialog::CharSelectDialog(LockedArray *charInfo, LoginData *loginData): Window(_("Account and Character Management")), - mCharInfo(charInfo), mCharSelected(false), mLoginData(loginData) + mCharInfo(charInfo), + mCharSelected(false), + mLoginData(loginData) #else -CharSelectDialog::CharSelectDialog(Network *network, - LockedArray *charInfo, +CharSelectDialog::CharSelectDialog(LockedArray *charInfo, Gender gender): - Window(_("Select Character")), mNetwork(network), + Window(_("Select Character")), mCharInfo(charInfo), mCharSelected(false), mGender(gender) @@ -261,8 +262,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) { // Start new character dialog CharCreateDialog *charCreateDialog = - new CharCreateDialog(this, mCharInfo->getPos(), - mNetwork, mGender); + new CharCreateDialog(this, mCharInfo->getPos(), mGender); charServerHandler.setCharCreateDialog(charCreateDialog); } } @@ -398,13 +398,10 @@ bool CharSelectDialog::selectByName(const std::string &name) #ifdef TMWSERV_SUPPORT CharCreateDialog::CharCreateDialog(Window *parent, int slot): #else -CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network, +CharCreateDialog::CharCreateDialog(Window *parent, int slot, Gender gender): #endif Window(_("Create Character"), true, parent), -#ifndef TMWSERV_SUPPORT - mNetwork(network), -#endif mSlot(slot) { mPlayer = new Player(0, 0, NULL); diff --git a/src/gui/char_select.h b/src/gui/char_select.h index b29953d3..cf770010 100644 --- a/src/gui/char_select.h +++ b/src/gui/char_select.h @@ -32,8 +32,6 @@ #ifdef TMWSERV_SUPPORT #include "../logindata.h" -#else -class Network; #endif class LocalPlayer; @@ -56,8 +54,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener CharSelectDialog(LockedArray *charInfo, LoginData *loginData); #else - CharSelectDialog(Network *network, - LockedArray *charInfo, + CharSelectDialog(LockedArray *charInfo, Gender gender); #endif @@ -70,9 +67,6 @@ class CharSelectDialog : public Window, public gcn::ActionListener bool selectByName(const std::string &name); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif LockedArray *mCharInfo; gcn::Button *mSelectButton; @@ -129,8 +123,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener #ifdef TMWSERV_SUPPORT CharCreateDialog(Window *parent, int slot); #else - CharCreateDialog(Window *parent, int slot, Network *network, - Gender gender); + CharCreateDialog(Window *parent, int slot, Gender gender); #endif /** @@ -162,9 +155,6 @@ class CharCreateDialog : public Window, public gcn::ActionListener */ void attemptCharCreate(); -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::TextField *mNameField; gcn::Label *mNameLabel; gcn::Button *mNextHairColorButton; diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 5b07980b..987de11e 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -40,13 +40,8 @@ #include -#ifdef TMWSERV_SUPPORT ChatWindow::ChatWindow(): - Window("Chat"), -#else -ChatWindow::ChatWindow(Network * network): - Window(""), mNetwork(network), -#endif + Window(_("Chat")), mTmpVisible(false) { setWindowName("Chat"); diff --git a/src/gui/chat.h b/src/gui/chat.h index ac4e491e..54270055 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -40,9 +40,6 @@ class Recorder; class ScrollArea; class TabbedArea; class ItemLinkHandler; -#ifdef EATHENA_SUPPORT -class Network; -#endif class Tab; class WhisperTab; @@ -69,11 +66,7 @@ class ChatWindow : public Window, /** * Constructor. */ -#ifdef TMWSERV_SUPPORT ChatWindow(); -#else - ChatWindow(Network *network); -#endif /** * Destructor: used to write back values to the config file @@ -190,7 +183,6 @@ class ChatWindow : public Window, void adjustTabSize(); #ifdef EATHENA_SUPPORT - Network *mNetwork; char mPartyPrefix; /**< Messages beginning with the prefix are sent to the party */ #endif diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index bf7b60ed..31f48486 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -37,15 +37,8 @@ #include "../utils/gettext.h" -#ifdef TMWSERV_SUPPORT NpcTextDialog::NpcTextDialog() -#else -NpcTextDialog::NpcTextDialog(Network *network) -#endif : Window(_("NPC")) -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif , mState(NPC_TEXT_STATE_WAITING) { setWindowName("NPCText"); diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 16c1d5fd..231ac684 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -30,9 +30,6 @@ #include "../npc.h" -#ifdef EATHENA_SUPPORT -class Network; -#endif class TextBox; /** @@ -48,11 +45,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcTextDialog(); -#else - NpcTextDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -101,9 +94,6 @@ class NpcTextDialog : public Window, public gcn::ActionListener void widgetResized(const gcn::Event &event); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::ScrollArea *mScrollArea; TextBox *mTextBox; gcn::Button *mButton; diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index 4dae8d83..4d2ae1ce 100644 --- a/src/gui/npcintegerdialog.cpp +++ b/src/gui/npcintegerdialog.cpp @@ -36,15 +36,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT NpcIntegerDialog::NpcIntegerDialog() -#else -NpcIntegerDialog::NpcIntegerDialog(Network *network) -#endif : Window(_("NPC Number Request")) -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif { setWindowName("NPCInteger"); mValueField = new IntTextField; diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h index df74c904..bb3a8e20 100644 --- a/src/gui/npcintegerdialog.h +++ b/src/gui/npcintegerdialog.h @@ -26,9 +26,6 @@ #include "window.h" -#ifdef EATHENA_SUPPORT -class Network; -#endif class IntTextField; /** @@ -44,11 +41,7 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcIntegerDialog(); -#else - NpcIntegerDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -93,9 +86,6 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener void setVisible(bool visible); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::Button *mDecButton; gcn::Button *mIncButton; IntTextField *mValueField; diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 6df0979f..efac8954 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -41,15 +41,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT NpcListDialog::NpcListDialog() -#else -NpcListDialog::NpcListDialog(Network *network) -#endif : Window("NPC") -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif { setWindowName("NPCList"); setResizable(true); diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index 6c1e02e3..fa297304 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -29,10 +29,6 @@ #include -#ifdef EATHENA_SUPPORT -class Network; -#endif - /** * The npc list dialog. * @@ -47,11 +43,7 @@ class NpcListDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcListDialog(); -#else - NpcListDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -94,9 +86,6 @@ class NpcListDialog : public Window, public gcn::ActionListener, void requestFocus(); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::ListBox *mItemList; std::vector mItems; diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index 7297d7e8..e5137d9c 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -36,15 +36,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT NpcStringDialog::NpcStringDialog() -#else -NpcStringDialog::NpcStringDialog(Network *network) -#endif : Window(_("NPC Text Request")) -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif { setWindowName("NPCString"); mValueField = new TextField(""); diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h index 94cd59b2..37d46cc0 100644 --- a/src/gui/npcstringdialog.h +++ b/src/gui/npcstringdialog.h @@ -26,10 +26,6 @@ #include -#ifdef EATHENA_SUPPORT -class Network; -#endif - /** * The npc integer input dialog. * @@ -43,11 +39,7 @@ class NpcStringDialog : public Window, public gcn::ActionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcStringDialog(); -#else - NpcStringDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -79,9 +71,6 @@ class NpcStringDialog : public Window, public gcn::ActionListener void setVisible(bool visible); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::TextField *mValueField; std::string mDefault; }; diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 648bff08..1e1155a7 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -46,14 +46,8 @@ #include "utils/gettext.h" #include "utils/strprintf.h" -#ifdef TMWSERV_SUPPORT SellDialog::SellDialog(): Window(_("Sell")), -#else -SellDialog::SellDialog(Network *network): - Window(_("Sell")), - mNetwork(network), -#endif mMaxItems(0), mAmountItems(0) { setWindowName("Sell"); diff --git a/src/gui/sell.h b/src/gui/sell.h index b6388a1f..b3e59b4f 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -30,9 +30,6 @@ #include "window.h" class Item; -#ifdef EATHENA_SUPPORT -class Network; -#endif class ShopItems; class ShopListBox; @@ -49,11 +46,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT SellDialog(); -#else - SellDialog(Network *network); -#endif /** * Destructor @@ -111,9 +104,6 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener */ void updateButtonsAndLabels(); -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::Button *mSellButton; gcn::Button *mQuitButton; gcn::Button *mAddMaxButton; diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp index 847886cb..690758ed 100644 --- a/src/gui/storagewindow.cpp +++ b/src/gui/storagewindow.cpp @@ -51,9 +51,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -StorageWindow::StorageWindow(Network *network, int invSize): +StorageWindow::StorageWindow(int invSize): Window(_("Storage")), - mNetwork(network), mMaxSlots(invSize), mItemDesc(false) { diff --git a/src/gui/storagewindow.h b/src/gui/storagewindow.h index cc0df2af..de0937b5 100644 --- a/src/gui/storagewindow.h +++ b/src/gui/storagewindow.h @@ -31,7 +31,6 @@ class Item; class ItemContainer; -class Network; class ProgressBar; class TextBox; @@ -47,7 +46,7 @@ class StorageWindow : public Window, gcn::ActionListener, /** * Constructor. */ - StorageWindow(Network *network, int invSize = (STORAGE_SIZE - 1)); + StorageWindow(int invSize = (STORAGE_SIZE - 1)); /** * Destructor. @@ -88,7 +87,6 @@ class StorageWindow : public Window, gcn::ActionListener, void close(); private: - Network *mNetwork; ItemContainer *mItems; int mSlots; diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 6cba1c41..6926eb82 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -51,14 +51,9 @@ #include "../utils/stringutils.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT TradeWindow::TradeWindow(): -#else -TradeWindow::TradeWindow(Network *network): -#endif Window(_("Trade: You")), #ifdef EATHENA_SUPPORT - mNetwork(network), mMyInventory(new Inventory(INVENTORY_SIZE, 2)), mPartnerInventory(new Inventory(INVENTORY_SIZE, 2)) #else diff --git a/src/gui/trade.h b/src/gui/trade.h index 4c215ba6..e2767c5b 100644 --- a/src/gui/trade.h +++ b/src/gui/trade.h @@ -34,9 +34,6 @@ class Inventory; class Item; class ItemContainer; -#ifdef EATHENA_SUPPORT -class Network; -#endif class ScrollArea; /** @@ -50,11 +47,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener /** * Constructor. */ -#ifdef TMWSERV_SUPPORT TradeWindow(); -#else - TradeWindow(Network *network); -#endif /** * Destructor. @@ -139,10 +132,6 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener void setStatus(Status); #endif -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif - typedef const std::auto_ptr InventoryPtr; InventoryPtr mMyInventory; InventoryPtr mPartnerInventory; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 8b2d6907..68f9e4bc 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -96,7 +96,6 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map): mStatPoint(0), mSkillPoint(0), mStatsPointsToAttribute(0), mEquipment(new Equipment), - mNetwork(0), mXp(0), mInStorage(false), mTargetTime(-1), diff --git a/src/localplayer.h b/src/localplayer.h index 77e9ac02..bff38796 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -33,9 +33,6 @@ class ImageSet; class Inventory; class Item; class Map; -#ifdef EATHENA_SUPPORT -class Network; -#endif #ifdef TMWSERV_SUPPORT @@ -155,10 +152,6 @@ class LocalPlayer : public Player virtual void setName(const std::string &name); -#ifdef EATHENA_SUPPORT - void setNetwork(Network *network) { mNetwork = network; } - Network *getNetwork() {return mNetwork; } -#endif virtual void logic(); /** @@ -500,7 +493,6 @@ class LocalPlayer : public Player void walk(unsigned char dir); #ifdef EATHENA_SUPPORT - Network *mNetwork; int mXp; /**< Experience points. */ bool mInStorage; /**< Whether storage is currently accessible */ int mTargetTime; /** How long the being has been targeted **/ diff --git a/src/main.cpp b/src/main.cpp index bd17ce9c..ad3063f6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1653,7 +1653,7 @@ int main(int argc, char *argv[]) break; case STATE_CHAR_SELECT: logger->log("State: CHAR_SELECT"); - currentDialog = new CharSelectDialog(network, &charInfo, + currentDialog = new CharSelectDialog(&charInfo, (loginData.sex == 0) ? GENDER_FEMALE : GENDER_MALE); positionDialog(currentDialog, screenWidth, screenHeight); diff --git a/src/net/ea/network.h b/src/net/ea/network.h index 40d563aa..c246ab8e 100644 --- a/src/net/ea/network.h +++ b/src/net/ea/network.h @@ -36,8 +36,6 @@ class MessageHandler; class MessageIn; -class Network; - class Network { public: diff --git a/src/npc.cpp b/src/npc.cpp index 98c3e0eb..359546e2 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -40,14 +40,8 @@ bool NPC::isTalking = false; int current_npc = 0; -#ifdef TMWSERV_SUPPORT NPC::NPC(int id, int job, Map *map): Player(id, job, map) -#else -NPC::NPC(int id, int job, Map *map, Network *network): - Player(id, job, map), - mNetwork(network) -#endif { NPCInfo info = NPCDB::get(job); @@ -126,9 +120,6 @@ void NPC::talk() #ifdef TMWSERV_SUPPORT Net::GameServer::Player::talkToNPC(mId, true); #else - if (!mNetwork) - return; - MessageOut outMsg(CMSG_NPC_TALK); outMsg.writeInt32(mId); outMsg.writeInt8(0); diff --git a/src/npc.h b/src/npc.h index c2cab6f0..57e6d5a8 100644 --- a/src/npc.h +++ b/src/npc.h @@ -24,20 +24,13 @@ #include "player.h" -#ifdef EATHENA_SUPPORT -class Network; -#endif class Graphics; class Text; class NPC : public Player { public: -#ifdef TMWSERV_SUPPORT - NPC(int id, int sprite, Map *map); -#else - NPC(int id, int job, Map *map, Network *network); -#endif + NPC(int id, int job, Map *map); ~NPC(); @@ -56,6 +49,7 @@ class NPC : public Player { return 0x83; } // blocked like a monster by walls, monsters and characters ( bin 1000 0011) static bool isTalking; + protected: /** * Gets the way a monster blocks pathfinding for other objects @@ -63,10 +57,8 @@ class NPC : public Player virtual Map::BlockType getBlockType() const { return Map::BLOCKTYPE_CHARACTER; } //blocks like a player character -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif void updateCoords(); + private: Text *mName; }; diff --git a/src/party.cpp b/src/party.cpp index 4a7912ee..2295cb81 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -33,9 +33,8 @@ #include "utils/gettext.h" #include "utils/strprintf.h" -Party::Party(Network *network) : - mNetwork(network), - mInviteListener(network, &mInParty) +Party::Party() : + mInviteListener(&mInParty) { } diff --git a/src/party.h b/src/party.h index d73b4a0f..25af80b3 100644 --- a/src/party.h +++ b/src/party.h @@ -29,12 +29,11 @@ class PartyHandler; class Being; class ChatWindow; -class Network; class Party { public: - Party(Network *network); + Party(); void respond(const std::string &command, const std::string &args); void create(const std::string &party); @@ -43,7 +42,7 @@ class Party void createResponse(bool ok); void inviteResponse(const std::string &nick, int status); void invitedAsk(const std::string &nick, int gender, - const std::string &partyName); + const std::string &partyName); void leftResponse(const std::string &nick); void receiveChat(Being *being, const std::string &msg); @@ -51,7 +50,6 @@ class Party private: std::string mPartyName; - Network *mNetwork; bool mInParty; bool mCreating; /**< Used to give an appropriate response to failure */ @@ -60,12 +58,11 @@ class Party class InviteListener : public gcn::ActionListener { public: - InviteListener(Network *network, bool *inParty) : - mNetwork(network), + InviteListener(bool *inParty) : mInParty(inParty) {} void action(const gcn::ActionEvent &event); - Network *mNetwork; + private: bool *mInParty; }; -- cgit v1.2.3-70-g09d2 From f67237cb69599753192c301f0f2eb38b88f7b57a Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Fri, 27 Mar 2009 16:24:01 -0600 Subject: Clean up some ifdefs and start cleanup of parties --- src/Makefile.am | 6 +- src/commandhandler.cpp | 2 +- src/engine.cpp | 16 +-- src/engine.h | 2 +- src/game.cpp | 5 +- src/gui/widgets/whispertab.cpp | 1 - src/map.cpp | 4 - src/net/ea/gui/partytab.cpp | 53 ++++++++++ src/net/ea/gui/partytab.h | 49 +++++++++ src/net/ea/party.cpp | 215 ++++++++++++++++++++++++++++++++++++++ src/net/ea/party.h | 74 +++++++++++++ src/net/ea/playerhandler.cpp | 5 +- src/net/tmwserv/playerhandler.cpp | 3 - src/party.cpp | 215 -------------------------------------- src/party.h | 74 ------------- 15 files changed, 404 insertions(+), 320 deletions(-) create mode 100644 src/net/ea/gui/partytab.cpp create mode 100644 src/net/ea/gui/partytab.h create mode 100644 src/net/ea/party.cpp create mode 100644 src/net/ea/party.h delete mode 100644 src/party.cpp delete mode 100644 src/party.h diff --git a/src/Makefile.am b/src/Makefile.am index 4c5893ac..3768b7cd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -461,6 +461,8 @@ tmw_SOURCES += \ net/ea/network.h \ net/ea/npchandler.cpp \ net/ea/npchandler.h \ + net/ea/party.cpp \ + net/ea/party.h \ net/ea/partyhandler.cpp \ net/ea/partyhandler.h \ net/ea/playerhandler.cpp \ @@ -470,9 +472,7 @@ tmw_SOURCES += \ net/ea/skillhandler.cpp \ net/ea/skillhandler.h \ net/ea/tradehandler.cpp \ - net/ea/tradehandler.h \ - party.cpp \ - party.h + net/ea/tradehandler.h endif # set the include path found by configure diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index a2de2c63..5431cf88 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -34,8 +34,8 @@ #include "net/tmwserv/chatserver/chatserver.h" #include "net/tmwserv/gameserver/player.h" #else -#include "party.h" #include "net/messageout.h" +#include "net/ea/party.h" #include "net/ea/protocol.h" #endif diff --git a/src/engine.cpp b/src/engine.cpp index d13fbf3f..04d06e38 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -33,11 +33,6 @@ #include "gui/minimap.h" #include "gui/viewport.h" -#ifdef EATHENA_SUPPORT -#include "net/messageout.h" -#include "net/ea/protocol.h" -#endif - #include "resources/mapreader.h" #include "resources/monsterdb.h" #include "resources/resourcemanager.h" @@ -54,7 +49,7 @@ Engine::~Engine() delete mCurrentMap; } -void Engine::changeMap(const std::string &mapPath) +bool Engine::changeMap(const std::string &mapPath) { // Clean up floor items, beings and particles floorItemManager->clear(); @@ -71,11 +66,7 @@ void Engine::changeMap(const std::string &mapPath) mMapName = mapPath; // Store full map path in global var -#ifdef TMWSERV_SUPPORT map_path = "maps/" + mapPath + ".tmx"; -#else - map_path = "maps/" + mapPath.substr(0, mapPath.rfind(".")) + ".tmx"; -#endif ResourceManager *resman = ResourceManager::getInstance(); if (!resman->exists(map_path)) map_path += ".gz"; @@ -143,10 +134,7 @@ void Engine::changeMap(const std::string &mapPath) mCurrentMap = newMap; -#ifdef EATHENA_SUPPORT - // Send "map loaded" - MessageOut outMsg(CMSG_MAP_LOADED); -#endif + return true; } void Engine::logic() diff --git a/src/engine.h b/src/engine.h index eafce3b9..963270e8 100644 --- a/src/engine.h +++ b/src/engine.h @@ -53,7 +53,7 @@ class Engine /** * Sets the currently active map. */ - void changeMap(const std::string &mapName); + bool changeMap(const std::string &mapName); /** * Performs engine logic. This method is called 100 times per second. diff --git a/src/game.cpp b/src/game.cpp index 856a5c11..6b9a829f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -43,9 +43,6 @@ #include "log.h" #include "npc.h" #include "particle.h" -#ifdef EATHENA_SUPPORT -#include "party.h" -#endif #include "player_relations.h" #include "gui/widgets/chattab.h" @@ -110,6 +107,7 @@ #include "net/ea/inventoryhandler.h" #include "net/ea/itemhandler.h" #include "net/ea/npchandler.h" +#include "net/ea/party.h" #include "net/ea/playerhandler.h" #include "net/ea/tradehandler.h" #include "net/ea/protocol.h" @@ -450,6 +448,7 @@ Game::Game(Network *network): msg.writeInt32(tick_time); engine->changeMap(map_path); + MessageOut outMsg(CMSG_MAP_LOADED); #endif setupWindow->setInGame(true); diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index 1621e965..9e6d9336 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -28,7 +28,6 @@ #ifdef TMWSERV_SUPPORT #include "net/tmwserv/chatserver/chatserver.h" #else -#include "party.h" #include "net/messageout.h" #include "net/ea/protocol.h" #endif diff --git a/src/map.cpp b/src/map.cpp index 59e6201f..8f736424 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -141,11 +141,7 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY, // tiles have been drawn if (mIsFringeLayer) { -#ifdef TMWSERV_SUPPORT while (si != sprites.end() && (*si)->getPixelY() <= y * 32) -#else - while (si != sprites.end() && (*si)->getPixelY() <= y * 32) -#endif { (*si)->draw(graphics, -scrollX, -scrollY); si++; diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp new file mode 100644 index 00000000..a55d2492 --- /dev/null +++ b/src/net/ea/gui/partytab.cpp @@ -0,0 +1,53 @@ +/* + * The Mana World + * Copyright (C) 2008 The Mana World Development Team + * + * This file is part of The Mana World. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "partytab.h" + +#include "net/messageout.h" + +#include "net/ea/party.h" +#include "net/ea/protocol.h" + +#include "resources/iteminfo.h" +#include "resources/itemdb.h" + +#include "utils/dtor.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" +#include "utils/stringutils.h" + +PartyTab::PartyTab() : ChatTab(_("Party")) +{ +} + +PartyTab::~PartyTab() +{ +} + +void PartyTab::handleInput(std::string &msg) { + // TODO +} + +void PartyTab::handleCommand(std::string &msg) { + // TODO +} diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h new file mode 100644 index 00000000..b2aaca68 --- /dev/null +++ b/src/net/ea/gui/partytab.h @@ -0,0 +1,49 @@ +/* + * The Mana World + * Copyright (C) 2009 The Mana World Development Team + * + * This file is part of The Mana World. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef CHANNELTAB_H +#define CHANNELTAB_H + +#include "gui/widgets/chattab.h" + +/** + * A tab for a chat channel. + */ +class PartyTab : public ChatTab +{ + public: + /** + * Constructor. + */ + PartyTab(); + + /** + * Destructor. + */ + ~PartyTab(); + + protected: + void handleInput(const std::string &msg); + + void handleCommand(std::string msg); +}; + +#endif // CHANNELTAB_H diff --git a/src/net/ea/party.cpp b/src/net/ea/party.cpp new file mode 100644 index 00000000..2295cb81 --- /dev/null +++ b/src/net/ea/party.cpp @@ -0,0 +1,215 @@ +/* + * The Mana World + * Copyright (C) 2008 Lloyd Bryant + * + * This file is part of The Mana World. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "being.h" +#include "localplayer.h" +#include "party.h" + +#include "gui/widgets/chattab.h" +#include "gui/chat.h" +#include "gui/confirm_dialog.h" + +#include "net/messageout.h" +#include "net/ea/protocol.h" + +#include "utils/gettext.h" +#include "utils/strprintf.h" + +Party::Party() : + mInviteListener(&mInParty) +{ +} + +void Party::respond(const std::string &command, const std::string &args) +{ + if (command == "new" || command == "create") + { + create(args); + return; + } + if (command == "leave") + { + leave(args); + return; + } + if (command == "settings") + { + localChatTab->chatLog(_("Not yet implemented!"), BY_SERVER); + return; + /* + MessageOut outMsg(CMSG_PARTY_SETTINGS); + outMsg.writeInt16(0); // Experience + outMsg.writeInt16(0); // Item + */ + } + localChatTab->chatLog(_("Party command not known."), BY_SERVER); +} + +void Party::create(const std::string &party) +{ + if (party.empty()) + { + localChatTab->chatLog(_("Party name is missing."), BY_SERVER); + return; + } + MessageOut outMsg(CMSG_PARTY_CREATE); + outMsg.writeString(party.substr(0, 23), 24); + mCreating = true; +} + +void Party::leave(const std::string &args) +{ + MessageOut outMsg(CMSG_PARTY_LEAVE); + localChatTab->chatLog(_("Left party."), BY_SERVER); + mInParty = false; +} + +void Party::createResponse(bool ok) +{ + if (ok) + { + localChatTab->chatLog(_("Party successfully created."), BY_SERVER); + mInParty = true; + } + else + { + localChatTab->chatLog(_("Could not create party."), BY_SERVER); + } +} + +void Party::inviteResponse(const std::string &nick, int status) +{ + switch (status) + { + case 0: + localChatTab->chatLog(strprintf(_("%s is already a member of a party."), + nick.c_str()), BY_SERVER); + break; + case 1: + localChatTab->chatLog(strprintf(_("%s refused your invitation."), + nick.c_str()), BY_SERVER); + break; + case 2: + localChatTab->chatLog(strprintf(_("%s is now a member of your party."), + nick.c_str()), BY_SERVER); + break; + } +} + +void Party::invitedAsk(const std::string &nick, int gender, + const std::string &partyName) +{ + mPartyName = partyName; /* Quick and nasty - needs redoing */ + if (nick.empty()) + { + localChatTab->chatLog(_("You can\'t have a blank party name!"), BY_SERVER); + return; + } + mCreating = false; + ConfirmDialog *dlg = new ConfirmDialog(_("Invite to party"), + strprintf(_("%s invites you to join" + " the %s party, do you accept?"), + nick.c_str(), partyName.c_str())); + dlg->addActionListener(&mInviteListener); +} + +void Party::InviteListener::action(const gcn::ActionEvent &event) +{ + MessageOut outMsg(CMSG_PARTY_INVITED); + outMsg.writeInt32(player_node->getId()); + bool accept = event.getId() == "yes"; + outMsg.writeInt32(accept ? 1 : 0); + *mInParty = *mInParty || accept; +} + +void Party::leftResponse(const std::string &nick) +{ + localChatTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()), + BY_SERVER); +} + +void Party::receiveChat(Being *being, const std::string &msg) +{ + if (!being) + { + return; + } + if (being->getType() != Being::PLAYER) + { + localChatTab->chatLog(_("Party chat received, but being is not a player"), + BY_SERVER); + return; + } + being->setSpeech(msg, SPEECH_TIME); + localChatTab->chatLog(being->getName() + " : " + msg, BY_PARTY); +} + +void Party::help(const std::string &args) +{ + // Strip "party " from the front + std::string msg = args.substr(6, args.length()); + + if (msg.empty()) + { + localChatTab->chatLog(_("Command: /party "), BY_SERVER); + localChatTab->chatLog(_("where can be one of:"), BY_SERVER); + localChatTab->chatLog(_(" /new"), BY_SERVER); + localChatTab->chatLog(_(" /create"), BY_SERVER); + localChatTab->chatLog(_(" /prefix"), BY_SERVER); + localChatTab->chatLog(_(" /leave"), BY_SERVER); + localChatTab->chatLog(_("This command implements the partying function."), + BY_SERVER); + localChatTab->chatLog(_("Type /help party for further help."), + BY_SERVER); + return; + } + if (msg == "new" || msg == "create") + { + localChatTab->chatLog(_("Command: /party new "), BY_SERVER); + localChatTab->chatLog(_("Command: /party create "), BY_SERVER); + localChatTab->chatLog(_("These commands create a new party chatLog(_("Command: /party prefix "), BY_SERVER); + localChatTab->chatLog(_("This command sets the party prefix character."), + BY_SERVER); + localChatTab->chatLog(_("Any message preceded by is sent to " + "the party instead of everyone."), BY_SERVER); + localChatTab->chatLog(_("Command: /party prefix"), BY_SERVER); + localChatTab->chatLog(_("This command reports the current party prefix " + "character."), BY_SERVER); + return; + } + //if (msg == "settings") + //if (msg == "info") + if (msg == "leave") + { + localChatTab->chatLog(_("Command: /party leave"), BY_SERVER); + localChatTab->chatLog(_("This command causes the player to leave the party."), + BY_SERVER); + return; + } + localChatTab->chatLog(_("Unknown /party command."), BY_SERVER); + localChatTab->chatLog(_("Type /help party for a list of options."), BY_SERVER); +} diff --git a/src/net/ea/party.h b/src/net/ea/party.h new file mode 100644 index 00000000..25af80b3 --- /dev/null +++ b/src/net/ea/party.h @@ -0,0 +1,74 @@ +/* + * The Mana World + * Copyright (C) 2008 Lloyd Bryant + * + * This file is part of The Mana World. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PARTY_H +#define PARTY_H + +#include + +#include + +class PartyHandler; +class Being; +class ChatWindow; + +class Party +{ + public: + Party(); + void respond(const std::string &command, const std::string &args); + + void create(const std::string &party); + void leave(const std::string &args); + + void createResponse(bool ok); + void inviteResponse(const std::string &nick, int status); + void invitedAsk(const std::string &nick, int gender, + const std::string &partyName); + void leftResponse(const std::string &nick); + void receiveChat(Being *being, const std::string &msg); + + void help(const std::string &args); + + private: + std::string mPartyName; + bool mInParty; + bool mCreating; /**< Used to give an appropriate response to + failure */ + PartyHandler *handler; + + class InviteListener : public gcn::ActionListener + { + public: + InviteListener(bool *inParty) : + mInParty(inParty) + {} + void action(const gcn::ActionEvent &event); + + private: + bool *mInParty; + }; + InviteListener mInviteListener; +}; + +extern Party *playerParty; + +#endif diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index bf775f51..05f74630 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -24,6 +24,7 @@ #include "net/ea/protocol.h" #include "net/messagein.h" +#include "net/messageout.h" #include "engine.h" #include "localplayer.h" @@ -193,7 +194,9 @@ void PlayerHandler::handleMessage(MessageIn &msg) nearby = (engine->getCurrentMapName() == mapPath); // Switch the actual map, deleting the previous one if necessary - engine->changeMap(mapPath); + mapPath = mapPath.substr(0, mapPath.rfind(".")); + if (engine->changeMap(mapPath)) + MessageOut outMsg(CMSG_MAP_LOADED); float scrollOffsetX = 0.0f; float scrollOffsetY = 0.0f; diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp index f02ed4c1..106894a1 100644 --- a/src/net/tmwserv/playerhandler.cpp +++ b/src/net/tmwserv/playerhandler.cpp @@ -85,9 +85,6 @@ namespace { npcTextDialog->setVisible(false); buyDialog->setVisible(false); sellDialog->setVisible(false); -#ifdef EATHENA_SUPPORT - buySellDialog->setVisible(false); -#endif current_npc = 0; } } deathListener; diff --git a/src/party.cpp b/src/party.cpp deleted file mode 100644 index 2295cb81..00000000 --- a/src/party.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * The Mana World - * Copyright (C) 2008 Lloyd Bryant - * - * This file is part of The Mana World. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "being.h" -#include "localplayer.h" -#include "party.h" - -#include "gui/widgets/chattab.h" -#include "gui/chat.h" -#include "gui/confirm_dialog.h" - -#include "net/messageout.h" -#include "net/ea/protocol.h" - -#include "utils/gettext.h" -#include "utils/strprintf.h" - -Party::Party() : - mInviteListener(&mInParty) -{ -} - -void Party::respond(const std::string &command, const std::string &args) -{ - if (command == "new" || command == "create") - { - create(args); - return; - } - if (command == "leave") - { - leave(args); - return; - } - if (command == "settings") - { - localChatTab->chatLog(_("Not yet implemented!"), BY_SERVER); - return; - /* - MessageOut outMsg(CMSG_PARTY_SETTINGS); - outMsg.writeInt16(0); // Experience - outMsg.writeInt16(0); // Item - */ - } - localChatTab->chatLog(_("Party command not known."), BY_SERVER); -} - -void Party::create(const std::string &party) -{ - if (party.empty()) - { - localChatTab->chatLog(_("Party name is missing."), BY_SERVER); - return; - } - MessageOut outMsg(CMSG_PARTY_CREATE); - outMsg.writeString(party.substr(0, 23), 24); - mCreating = true; -} - -void Party::leave(const std::string &args) -{ - MessageOut outMsg(CMSG_PARTY_LEAVE); - localChatTab->chatLog(_("Left party."), BY_SERVER); - mInParty = false; -} - -void Party::createResponse(bool ok) -{ - if (ok) - { - localChatTab->chatLog(_("Party successfully created."), BY_SERVER); - mInParty = true; - } - else - { - localChatTab->chatLog(_("Could not create party."), BY_SERVER); - } -} - -void Party::inviteResponse(const std::string &nick, int status) -{ - switch (status) - { - case 0: - localChatTab->chatLog(strprintf(_("%s is already a member of a party."), - nick.c_str()), BY_SERVER); - break; - case 1: - localChatTab->chatLog(strprintf(_("%s refused your invitation."), - nick.c_str()), BY_SERVER); - break; - case 2: - localChatTab->chatLog(strprintf(_("%s is now a member of your party."), - nick.c_str()), BY_SERVER); - break; - } -} - -void Party::invitedAsk(const std::string &nick, int gender, - const std::string &partyName) -{ - mPartyName = partyName; /* Quick and nasty - needs redoing */ - if (nick.empty()) - { - localChatTab->chatLog(_("You can\'t have a blank party name!"), BY_SERVER); - return; - } - mCreating = false; - ConfirmDialog *dlg = new ConfirmDialog(_("Invite to party"), - strprintf(_("%s invites you to join" - " the %s party, do you accept?"), - nick.c_str(), partyName.c_str())); - dlg->addActionListener(&mInviteListener); -} - -void Party::InviteListener::action(const gcn::ActionEvent &event) -{ - MessageOut outMsg(CMSG_PARTY_INVITED); - outMsg.writeInt32(player_node->getId()); - bool accept = event.getId() == "yes"; - outMsg.writeInt32(accept ? 1 : 0); - *mInParty = *mInParty || accept; -} - -void Party::leftResponse(const std::string &nick) -{ - localChatTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()), - BY_SERVER); -} - -void Party::receiveChat(Being *being, const std::string &msg) -{ - if (!being) - { - return; - } - if (being->getType() != Being::PLAYER) - { - localChatTab->chatLog(_("Party chat received, but being is not a player"), - BY_SERVER); - return; - } - being->setSpeech(msg, SPEECH_TIME); - localChatTab->chatLog(being->getName() + " : " + msg, BY_PARTY); -} - -void Party::help(const std::string &args) -{ - // Strip "party " from the front - std::string msg = args.substr(6, args.length()); - - if (msg.empty()) - { - localChatTab->chatLog(_("Command: /party "), BY_SERVER); - localChatTab->chatLog(_("where can be one of:"), BY_SERVER); - localChatTab->chatLog(_(" /new"), BY_SERVER); - localChatTab->chatLog(_(" /create"), BY_SERVER); - localChatTab->chatLog(_(" /prefix"), BY_SERVER); - localChatTab->chatLog(_(" /leave"), BY_SERVER); - localChatTab->chatLog(_("This command implements the partying function."), - BY_SERVER); - localChatTab->chatLog(_("Type /help party for further help."), - BY_SERVER); - return; - } - if (msg == "new" || msg == "create") - { - localChatTab->chatLog(_("Command: /party new "), BY_SERVER); - localChatTab->chatLog(_("Command: /party create "), BY_SERVER); - localChatTab->chatLog(_("These commands create a new party chatLog(_("Command: /party prefix "), BY_SERVER); - localChatTab->chatLog(_("This command sets the party prefix character."), - BY_SERVER); - localChatTab->chatLog(_("Any message preceded by is sent to " - "the party instead of everyone."), BY_SERVER); - localChatTab->chatLog(_("Command: /party prefix"), BY_SERVER); - localChatTab->chatLog(_("This command reports the current party prefix " - "character."), BY_SERVER); - return; - } - //if (msg == "settings") - //if (msg == "info") - if (msg == "leave") - { - localChatTab->chatLog(_("Command: /party leave"), BY_SERVER); - localChatTab->chatLog(_("This command causes the player to leave the party."), - BY_SERVER); - return; - } - localChatTab->chatLog(_("Unknown /party command."), BY_SERVER); - localChatTab->chatLog(_("Type /help party for a list of options."), BY_SERVER); -} diff --git a/src/party.h b/src/party.h deleted file mode 100644 index 25af80b3..00000000 --- a/src/party.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * The Mana World - * Copyright (C) 2008 Lloyd Bryant - * - * This file is part of The Mana World. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PARTY_H -#define PARTY_H - -#include - -#include - -class PartyHandler; -class Being; -class ChatWindow; - -class Party -{ - public: - Party(); - void respond(const std::string &command, const std::string &args); - - void create(const std::string &party); - void leave(const std::string &args); - - void createResponse(bool ok); - void inviteResponse(const std::string &nick, int status); - void invitedAsk(const std::string &nick, int gender, - const std::string &partyName); - void leftResponse(const std::string &nick); - void receiveChat(Being *being, const std::string &msg); - - void help(const std::string &args); - - private: - std::string mPartyName; - bool mInParty; - bool mCreating; /**< Used to give an appropriate response to - failure */ - PartyHandler *handler; - - class InviteListener : public gcn::ActionListener - { - public: - InviteListener(bool *inParty) : - mInParty(inParty) - {} - void action(const gcn::ActionEvent &event); - - private: - bool *mInParty; - }; - InviteListener mInviteListener; -}; - -extern Party *playerParty; - -#endif -- cgit v1.2.3-70-g09d2 From 4f02ad59df9ee3314fb0d429a031ecbfa3206e3a Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 27 Mar 2009 23:25:43 +0100 Subject: Moved the inventory and storage offset handling into netcode No need to complicate the item containers and inventory classes with a silly offset used by the eAthena server. Also fixed the logToStandardOut option by reading it from the config after the configuration has been initialized. --- src/equipment.cpp | 8 +++- src/equipment.h | 4 +- src/gui/storagewindow.cpp | 8 ++-- src/gui/trade.cpp | 11 ++--- src/inventory.cpp | 12 ++--- src/inventory.h | 13 ++--- src/localplayer.cpp | 26 +++++----- src/localplayer.h | 10 ++-- src/main.cpp | 19 ++++---- src/map.cpp | 4 +- src/net/ea/equipmenthandler.cpp | 45 +++++++++++------ src/net/ea/inventoryhandler.cpp | 104 +++++++++++++++++++++++++--------------- src/net/ea/protocol.h | 3 ++ 13 files changed, 154 insertions(+), 113 deletions(-) diff --git a/src/equipment.cpp b/src/equipment.cpp index c8e58b8c..8fc09fa9 100644 --- a/src/equipment.cpp +++ b/src/equipment.cpp @@ -36,7 +36,7 @@ Equipment::Equipment() #ifdef TMWSERV_SUPPORT std::fill_n(mEquipment, EQUIPMENT_SIZE, (Item*) 0); #else - std::fill_n(mEquipment, EQUIPMENT_SIZE, 0); + std::fill_n(mEquipment, EQUIPMENT_SIZE, -1); #endif } @@ -74,4 +74,10 @@ void Equipment::setEquipment(int index, int inventoryIndex) item->setEquipped(true); } +void Equipment::removeEquipment(int index) +{ + if (index >= 0 && index < EQUIPMENT_SIZE) + mEquipment[index] = -1; +} + #endif diff --git a/src/equipment.h b/src/equipment.h index 7605175a..63555361 100644 --- a/src/equipment.h +++ b/src/equipment.h @@ -75,7 +75,7 @@ class Equipment /** * Remove equipment from the given slot. */ - void removeEquipment(int index) { if (index >= 0 && index < EQUIPMENT_SIZE) mEquipment[index] = 0; } + void removeEquipment(int index); /** * Returns the item used in the arrow slot. @@ -90,7 +90,7 @@ class Equipment private: #ifdef TMWSERV_SUPPORT - Item* mEquipment[EQUIPMENT_SIZE]; + Item *mEquipment[EQUIPMENT_SIZE]; #else int mEquipment[EQUIPMENT_SIZE]; int mArrows; diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp index 690758ed..8c25401d 100644 --- a/src/gui/storagewindow.cpp +++ b/src/gui/storagewindow.cpp @@ -187,17 +187,17 @@ Item* StorageWindow::getSelectedItem() const return mItems->getSelectedItem(); } -void StorageWindow::addStore(Item* item, int ammount) +void StorageWindow::addStore(Item *item, int ammount) { MessageOut outMsg(CMSG_MOVE_TO_STORAGE); - outMsg.writeInt16(item->getInvIndex()); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); outMsg.writeInt32(ammount); } -void StorageWindow::removeStore(Item* item, int ammount) +void StorageWindow::removeStore(Item *item, int ammount) { MessageOut outMsg(CSMG_MOVE_FROM_STORAGE); - outMsg.writeInt16(item->getInvIndex()); + outMsg.writeInt16(item->getInvIndex() + STORAGE_OFFSET); outMsg.writeInt32(ammount); } diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 6926eb82..e6df9ad8 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -53,13 +53,10 @@ TradeWindow::TradeWindow(): Window(_("Trade: You")), -#ifdef EATHENA_SUPPORT - mMyInventory(new Inventory(INVENTORY_SIZE, 2)), - mPartnerInventory(new Inventory(INVENTORY_SIZE, 2)) -#else mMyInventory(new Inventory(INVENTORY_SIZE)), - mPartnerInventory(new Inventory(INVENTORY_SIZE)), - mStatus(PREPARING) + mPartnerInventory(new Inventory(INVENTORY_SIZE)) +#ifdef TMWSERV_SUPPORT + , mStatus(PREPARING) #endif { setWindowName("Trade"); @@ -248,7 +245,7 @@ void TradeWindow::tradeItem(Item *item, int quantity) // for that version only. //addItem(item->getId(), true, quantity, item->isEquipment()); MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST); - outMsg.writeInt16(item->getInvIndex()); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); outMsg.writeInt32(quantity); #endif } diff --git a/src/inventory.cpp b/src/inventory.cpp index 59f51e39..532d9ab6 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -37,9 +37,8 @@ struct SlotUsed : public std::unary_function } }; -Inventory::Inventory(int size, int offset): - mSize(size), - mOffset(offset) +Inventory::Inventory(int size): + mSize(size) { mItems = new Item*[mSize]; std::fill_n(mItems, mSize, (Item*) 0); @@ -135,7 +134,7 @@ bool Inventory::contains(Item *item) const int Inventory::getFreeSlot() const { - Item **i = std::find_if(mItems + mOffset, mItems + mSize, + Item **i = std::find_if(mItems, mItems + mSize, std::not1(SlotUsed())); return (i == mItems + mSize) ? -1 : (i - mItems); } @@ -153,8 +152,3 @@ int Inventory::getLastUsedSlot() const return -1; } - -int Inventory::getInventorySize() const -{ - return mSize - mOffset; -} diff --git a/src/inventory.h b/src/inventory.h index 008b7ec4..07a9276e 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -19,8 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _INVENTORY_H -#define _INVENTORY_H +#ifndef INVENTORY_H +#define INVENTORY_H class Item; @@ -37,7 +37,7 @@ class Inventory /** * Constructor. */ - Inventory(int size, int offset = 0); + Inventory(int size); /** * Destructor. @@ -107,16 +107,11 @@ class Inventory */ int getLastUsedSlot() const; - /** - * Returns the number of slots available in the inventory. - */ - int getInventorySize() const; - static const int NO_SLOT_INDEX = -1; /**< Slot has no index. */ + protected: Item **mItems; /**< The holder of items */ int mSize; /**< The max number of inventory items */ - int mOffset; /**< Offset used by the inventory */ }; #endif diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 68f9e4bc..553e473b 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -18,7 +18,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include + +#include "localplayer.h" #include "configuration.h" #include "equipment.h" @@ -27,7 +28,6 @@ #include "graphics.h" #include "inventory.h" #include "item.h" -#include "localplayer.h" #include "map.h" #include "monster.h" #include "particle.h" @@ -65,6 +65,8 @@ #include "utils/gettext.h" #include "utils/stringutils.h" +#include + #ifdef TMWSERV_SUPPORT const short walkingKeyboardDelay = 100; #endif @@ -110,13 +112,12 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map): mLastAction(-1), mWalkingDir(0), mDestX(0), mDestY(0), + mInventory(new Inventory(INVENTORY_SIZE)), #ifdef TMWSERV_SUPPORT mLocalWalkTime(-1), - mInventory(new Inventory(INVENTORY_SIZE)), mExpMessageTime(0) #else - mInventory(new Inventory(INVENTORY_SIZE, 2)), - mStorage(new Inventory(STORAGE_SIZE, 1)) + mStorage(new Inventory(STORAGE_SIZE)) #endif { // Variable to keep the local player from doing certain actions before a map @@ -399,7 +400,7 @@ void LocalPlayer::equipItem(Item *item) Net::GameServer::Player::equip(item->getInvIndex()); #else MessageOut outMsg(CMSG_PLAYER_EQUIP); - outMsg.writeInt16(item->getInvIndex()); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); outMsg.writeInt16(0); #endif } @@ -427,7 +428,7 @@ void LocalPlayer::unequipItem(Item *item) return; MessageOut outMsg(CMSG_PLAYER_UNEQUIP); - outMsg.writeInt16(item->getInvIndex()); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); // Tidy equipment directly to avoid weapon still shown bug, for instance mEquipment->removeEquipment(item->getInvIndex()); @@ -436,7 +437,7 @@ void LocalPlayer::unequipItem(Item *item) void LocalPlayer::useItem(Item *item) { MessageOut outMsg(CMSG_PLAYER_INVENTORY_USE); - outMsg.writeInt16(item->getInvIndex()); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); outMsg.writeInt32(item->getId()); // Note: id is dest of item, usually player_node->account_ID ?? } @@ -450,7 +451,7 @@ void LocalPlayer::dropItem(Item *item, int quantity) #else // TODO: Fix wrong coordinates of drops, serverside? MessageOut outMsg(CMSG_PLAYER_INVENTORY_DROP); - outMsg.writeInt16(item->getInvIndex()); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); outMsg.writeInt16(quantity); #endif } @@ -1194,12 +1195,9 @@ void LocalPlayer::loadTargetCursor(std::string filename, int width, int height, assert(size > -1); assert(size < 3); - ImageSet* currentImageSet; - SimpleAnimation* currentCursor; - ResourceManager *resman = ResourceManager::getInstance(); - currentImageSet = resman->getImageSet(filename, width, height); + ImageSet *currentImageSet = resman->getImageSet(filename, width, height); Animation *anim = new Animation; for (unsigned int i = 0; i < currentImageSet->size(); ++i) @@ -1209,7 +1207,7 @@ void LocalPlayer::loadTargetCursor(std::string filename, int width, int height, (16 - (currentImageSet->getHeight() / 2))); } - currentCursor = new SimpleAnimation(anim); + SimpleAnimation *currentCursor = new SimpleAnimation(anim); const int index = outRange ? 1 : 0; diff --git a/src/localplayer.h b/src/localplayer.h index bff38796..7e48530e 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -526,14 +526,16 @@ class LocalPlayer : public Player int mWalkingDir; /**< The direction the player is walking in. */ int mDestX; /**< X coordinate of destination. */ int mDestY; /**< Y coordinate of destination. */ -#ifdef TMWSERV_SUPPORT - int mLocalWalkTime; /**< Timestamp used to control keyboard walk - messages flooding */ -#endif std::vector mStatusEffectIcons; Inventory *mInventory; + +#ifdef TMWSERV_SUPPORT + int mLocalWalkTime; /**< Timestamp used to control keyboard walk + messages flooding */ +#endif + #ifdef EATHENA_SUPPORT Inventory *mStorage; #endif diff --git a/src/main.cpp b/src/main.cpp index ad3063f6..b10a8c42 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1039,27 +1039,30 @@ int main(int argc, char *argv[]) initXML(); - // load branding information + // Load branding information branding.init("data/branding.xml"); initHomeDir(); + // Configure logger logger = new Logger; logger->setLogFile(homeDir + std::string("/tmw.log")); - logger->setLogToStandardOut(config.getValue("logToStandardOut", 0)); // Log the tmw version + logger->log("The Mana World %s (%s)", #ifdef PACKAGE_VERSION -#ifdef TMWSERV_SUPPORT - logger->log("The Mana World v%s TMWServ", PACKAGE_VERSION); + "v" PACKAGE_VERSION, #else - logger->log("The Mana World v%s eAthena", PACKAGE_VERSION); + "- version not defined", #endif +#ifdef TMWSERV_SUPPORT + "tmwserv"); #else - logger->log("The Mana World - version not defined"); + "eAthena"); #endif initConfiguration(options); + logger->setLogToStandardOut(config.getValue("logToStandardOut", 0)); initEngine(options); @@ -1077,9 +1080,9 @@ int main(int argc, char *argv[]) gcn::Container *top = static_cast(gui->getTop()); #ifdef PACKAGE_VERSION #ifdef TMWSERV_SUPPORT - gcn::Label *versionLabel = new Label(strprintf("%s TMWserv", PACKAGE_VERSION)); + gcn::Label *versionLabel = new Label(strprintf("%s (tmwserv)", PACKAGE_VERSION)); #else - gcn::Label *versionLabel = new Label(strprintf("%s eAthena", PACKAGE_VERSION)); + gcn::Label *versionLabel = new Label(strprintf("%s (eAthena)", PACKAGE_VERSION)); #endif top->add(versionLabel, 25, 2); #endif diff --git a/src/map.cpp b/src/map.cpp index 8f736424..0dc4759e 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -48,7 +48,9 @@ struct Location /** * Constructor. */ - Location(int px, int py, MetaTile *ptile):x(px),y(py),tile(ptile) {}; + Location(int px, int py, MetaTile *ptile): + x(px), y(py), tile(ptile) + {} /** * Comparison operator. diff --git a/src/net/ea/equipmenthandler.cpp b/src/net/ea/equipmenthandler.cpp index f81bf7ed..d30b2681 100644 --- a/src/net/ea/equipmenthandler.cpp +++ b/src/net/ea/equipmenthandler.cpp @@ -35,6 +35,8 @@ #include "utils/gettext.h" +enum { debugEquipment = 1 }; + EquipmentHandler::EquipmentHandler() { static const Uint16 _messages[] = { @@ -65,7 +67,7 @@ void EquipmentHandler::handleMessage(MessageIn &msg) for (int loop = 0; loop < itemCount; loop++) { - index = msg.readInt16(); + index = msg.readInt16() - INVENTORY_OFFSET; itemId = msg.readInt16(); msg.readInt8(); // type msg.readInt8(); // identify flag @@ -75,6 +77,11 @@ void EquipmentHandler::handleMessage(MessageIn &msg) msg.readInt8(); // refine msg.skip(8); // card + if (debugEquipment) + { + logger->log("Index: %d, ID: %d", index, itemId); + } + inventory->setItem(index, itemId, 1, true); if (equipPoint) @@ -93,21 +100,19 @@ void EquipmentHandler::handleMessage(MessageIn &msg) break; case SMSG_PLAYER_EQUIP: - index = msg.readInt16(); + index = msg.readInt16() - INVENTORY_OFFSET; equipPoint = msg.readInt16(); type = msg.readInt8(); - logger->log("Equipping: %i %i %i", index, equipPoint, type); - - if (!type) { + if (!type) + { localChatTab->chatLog(_("Unable to equip."), BY_SERVER); break; } - if (!equipPoint) { - // No point given, no point in searching + // No point in searching when no point given + if (!equipPoint) break; - } /* * An item may occupy more than 1 slot. If so, it's @@ -119,21 +124,25 @@ void EquipmentHandler::handleMessage(MessageIn &msg) mask <<= 1; position++; } - logger->log("Position %i", position); - item = player_node->getInventory()->getItem(player_node->mEquipment->getEquipment(position)); + if (debugEquipment) + { + logger->log("Equipping: %i %i %i at position %i", + index, equipPoint, type, position); + } + + item = inventory->getItem(player_node->mEquipment->getEquipment(position)); // Unequip any existing equipped item in this position - if (item) { + if (item) item->setEquipped(false); - } item = inventory->getItem(index); player_node->mEquipment->setEquipment(position, index); break; case SMSG_PLAYER_UNEQUIP: - index = msg.readInt16(); + index = msg.readInt16() - INVENTORY_OFFSET; equipPoint = msg.readInt16(); type = msg.readInt8(); @@ -166,8 +175,12 @@ void EquipmentHandler::handleMessage(MessageIn &msg) else { player_node->mEquipment->removeEquipment(position); } - logger->log("Unequipping: %i %i(%i) %i", - index, equipPoint, type, position); + + if (debugEquipment) + { + logger->log("Unequipping: %i %i(%i) %i", + index, equipPoint, type, position); + } break; case SMSG_PLAYER_ATTACK_RANGE: @@ -180,6 +193,8 @@ void EquipmentHandler::handleMessage(MessageIn &msg) if (index <= 1) break; + index -= INVENTORY_OFFSET; + item = inventory->getItem(index); if (item) { diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 5f7e6c6c..e1429093 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -44,6 +44,8 @@ #include +enum { debugInventory = 1 }; + InventoryHandler::InventoryHandler() { static const Uint16 _messages[] = { @@ -75,28 +77,26 @@ void InventoryHandler::handleMessage(MessageIn &msg) { case SMSG_PLAYER_INVENTORY: case SMSG_PLAYER_STORAGE_ITEMS: - switch (msg.getId()) { - case SMSG_PLAYER_INVENTORY: - // Clear inventory - this will be a complete refresh - inventory->clear(); - break; - case SMSG_PLAYER_STORAGE_ITEMS: - /* - * This packet will always be followed by a - * SMSG_PLAYER_STORAGE_EQUIP packet. The two packets - * together comprise a complete refresh of storage, so - * clear storage here - */ - storage->clear(); - break; - default: - logger->log("HOW DID WE GET HERE?"); - return; + if (msg.getId() == SMSG_PLAYER_INVENTORY) + { + // Clear inventory - this will be a complete refresh + inventory->clear(); + } + else + { + /* + * This packet will always be followed by a + * SMSG_PLAYER_STORAGE_EQUIP packet. The two packets + * together comprise a complete refresh of storage, so + * clear storage here + */ + storage->clear(); } msg.readInt16(); // length number = (msg.getLength() - 4) / 18; - for (int loop = 0; loop < number; loop++) { + for (int loop = 0; loop < number; loop++) + { index = msg.readInt16(); itemId = msg.readInt16(); itemType = msg.readInt8(); @@ -106,6 +106,17 @@ void InventoryHandler::handleMessage(MessageIn &msg) for (int i = 0; i < 4; i++) cards[i] = msg.readInt16(); + index -= (msg.getId() == SMSG_PLAYER_INVENTORY) ? + INVENTORY_OFFSET : STORAGE_OFFSET; + + if (debugInventory) + { + logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, " + "Qty: %d, Cards: %d, %d, %d, %d", + index, itemId, itemType, identified, amount, + cards[0], cards[1], cards[2], cards[3]); + } + if (msg.getId() == SMSG_PLAYER_INVENTORY) { inventory->setItem(index, itemId, amount, false); @@ -115,8 +126,6 @@ void InventoryHandler::handleMessage(MessageIn &msg) item->setEquipment(true); } } else { - logger->log("Index:%d, ID:%d, Type:%d, Identified:%d, Qty:%d, Cards:%d, %d, %d, %d", - index, itemId, itemType, identified, amount, cards[0], cards[1], cards[2], cards[3]); storage->setItem(index, itemId, amount, false); } } @@ -127,7 +136,7 @@ void InventoryHandler::handleMessage(MessageIn &msg) number = (msg.getLength() - 4) / 20; for (int loop = 0; loop < number; loop++) { - index = msg.readInt16(); + index = msg.readInt16() - STORAGE_OFFSET; itemId = msg.readInt16(); itemType = msg.readInt8(); identified = msg.readInt8(); @@ -139,14 +148,20 @@ void InventoryHandler::handleMessage(MessageIn &msg) for (int i = 0; i < 4; i++) cards[i] = msg.readInt16(); - logger->log("Index:%d, ID:%d, Type:%d, Identified:%d, Qty:%d, Cards:%d, %d, %d, %d", - index, itemId, itemType, identified, amount, cards[0], cards[1], cards[2], cards[3]); + if (debugInventory) + { + logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, " + "Qty: %d, Cards: %d, %d, %d, %d", + index, itemId, itemType, identified, amount, + cards[0], cards[1], cards[2], cards[3]); + } + storage->setItem(index, itemId, amount, false); } break; case SMSG_PLAYER_INVENTORY_ADD: - index = msg.readInt16(); + index = msg.readInt16() - INVENTORY_OFFSET; amount = msg.readInt16(); itemId = msg.readInt16(); identified = msg.readInt8(); @@ -157,20 +172,26 @@ void InventoryHandler::handleMessage(MessageIn &msg) equipType = msg.readInt16(); itemType = msg.readInt8(); - if (msg.readInt8() > 0) { - if (config.getValue("showpickupchat", true)) { + if (msg.readInt8() > 0) + { + if (config.getValue("showpickupchat", true)) localChatTab->chatLog(_("Unable to pick up item"), BY_SERVER); - } - } else { + } + else + { const ItemInfo &itemInfo = ItemDB::get(itemId); const std::string amountStr = (amount > 1) ? toString(amount) : "a"; - if (config.getValue("showpickupchat", true)) { + + if (config.getValue("showpickupchat", true)) + { localChatTab->chatLog(strprintf(_("You picked up %s [%s]"), amountStr.c_str(), itemInfo.getName().c_str()), BY_SERVER); } - if (config.getValue("showpickupparticle", false)) { + + if (config.getValue("showpickupparticle", false)) + { player_node->pickedUp(itemInfo.getName()); } @@ -184,9 +205,10 @@ void InventoryHandler::handleMessage(MessageIn &msg) break; case SMSG_PLAYER_INVENTORY_REMOVE: - index = msg.readInt16(); + index = msg.readInt16() - INVENTORY_OFFSET; amount = msg.readInt16(); - if (Item *item = inventory->getItem(index)) { + if (Item *item = inventory->getItem(index)) + { item->increaseQuantity(-amount); if (item->getQuantity() == 0) inventory->removeItemAt(index); @@ -194,7 +216,7 @@ void InventoryHandler::handleMessage(MessageIn &msg) break; case SMSG_PLAYER_INVENTORY_USE: - index = msg.readInt16(); + index = msg.readInt16() - INVENTORY_OFFSET; msg.readInt16(); // item id msg.readInt32(); // id amount = msg.readInt16(); @@ -205,7 +227,7 @@ void InventoryHandler::handleMessage(MessageIn &msg) break; case SMSG_ITEM_USE_RESPONSE: - index = msg.readInt16(); + index = msg.readInt16() - INVENTORY_OFFSET; amount = msg.readInt16(); if (msg.readInt8() == 0) { @@ -231,7 +253,7 @@ void InventoryHandler::handleMessage(MessageIn &msg) /* * Move an item into storage */ - index = msg.readInt16(); + index = msg.readInt16() - STORAGE_OFFSET; amount = msg.readInt32(); itemId = msg.readInt16(); identified = msg.readInt8(); @@ -240,10 +262,13 @@ void InventoryHandler::handleMessage(MessageIn &msg) for (int i = 0; i < 4; i++) cards[i] = msg.readInt16(); - if (Item *item = storage->getItem(index)) { + if (Item *item = storage->getItem(index)) + { item->setId(itemId); item->increaseQuantity(amount); - } else { + } + else + { storage->setItem(index, itemId, amount, false); } break; @@ -252,9 +277,10 @@ void InventoryHandler::handleMessage(MessageIn &msg) /* * Move an item out of storage */ - index = msg.readInt16(); + index = msg.readInt16() - STORAGE_OFFSET; amount = msg.readInt16(); - if (Item *item = storage->getItem(index)) { + if (Item *item = storage->getItem(index)) + { item->increaseQuantity(-amount); if (item->getQuantity() == 0) storage->removeItemAt(index); diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h index c96ff7b6..a70e47b4 100644 --- a/src/net/ea/protocol.h +++ b/src/net/ea/protocol.h @@ -22,6 +22,9 @@ #ifndef EA_PROTOCOL_H #define EA_PROTOCOL_H +static const int INVENTORY_OFFSET = 2; +static const int STORAGE_OFFSET = 1; + /********************************* * Packets from server to client * *********************************/ -- cgit v1.2.3-70-g09d2 From a96ad66d345807d6021f28c9b05b02328f76cc0f Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Fri, 27 Mar 2009 16:59:18 -0600 Subject: FIx loading of initial map under eAthena --- src/game.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/game.cpp b/src/game.cpp index 6b9a829f..109ae071 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -447,6 +447,7 @@ Game::Game(Network *network): MessageOut msg(CMSG_CLIENT_PING); msg.writeInt32(tick_time); + map_path = map_path.substr(0, map_path.rfind(".")); engine->changeMap(map_path); MessageOut outMsg(CMSG_MAP_LOADED); #endif -- cgit v1.2.3-70-g09d2 From e083abd148c70982a098d3f2fff8e61eee5c4f91 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 28 Mar 2009 00:02:01 +0100 Subject: Removed a lot of useless isVisible() checks The draw() method of a widget isn't called when a widget is not visible. --- src/game.cpp | 1 - src/gui/browserbox.cpp | 3 --- src/gui/emotecontainer.cpp | 3 --- src/gui/emoteshortcutcontainer.cpp | 3 --- src/gui/equipmentwindow.cpp | 3 --- src/gui/itemshortcutcontainer.cpp | 3 --- src/gui/listbox.cpp | 2 +- src/gui/minimap.cpp | 11 ++--------- src/gui/playerbox.cpp | 3 --- src/gui/popup.cpp | 3 --- src/gui/radiobutton.cpp | 3 --- src/gui/scrollarea.cpp | 3 --- src/gui/shoplistbox.cpp | 2 +- src/gui/status.cpp | 3 --- src/gui/table.cpp | 2 +- src/gui/textfield.cpp | 3 --- src/gui/widgets/dropdown.cpp | 3 --- src/gui/window.cpp | 3 --- src/net/ea/playerhandler.cpp | 3 ++- 19 files changed, 7 insertions(+), 53 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 109ae071..ba756df3 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -880,7 +880,6 @@ void Game::handleInput() break; case KeyboardConfig::KEY_WINDOW_MINIMAP: minimap->toggle(); - requestedWindow = minimap; break; case KeyboardConfig::KEY_WINDOW_CHAT: requestedWindow = chatWindow; diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 2f667237..0240b67b 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -244,9 +244,6 @@ void BrowserBox::mouseMoved(gcn::MouseEvent &event) void BrowserBox::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (mOpaque) { graphics->setColor(guiPalette->getColor(Palette::BACKGROUND)); diff --git a/src/gui/emotecontainer.cpp b/src/gui/emotecontainer.cpp index b4caf4f1..3425cde8 100644 --- a/src/gui/emotecontainer.cpp +++ b/src/gui/emotecontainer.cpp @@ -79,9 +79,6 @@ EmoteContainer::~EmoteContainer() void EmoteContainer::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - int columns = getWidth() / gridWidth; // Have at least 1 column diff --git a/src/gui/emoteshortcutcontainer.cpp b/src/gui/emoteshortcutcontainer.cpp index 661f42a7..ae5eb859 100644 --- a/src/gui/emoteshortcutcontainer.cpp +++ b/src/gui/emoteshortcutcontainer.cpp @@ -76,9 +76,6 @@ EmoteShortcutContainer::~EmoteShortcutContainer() void EmoteShortcutContainer::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (config.getValue("guialpha", 0.8) != mAlpha) { mAlpha = config.getValue("guialpha", 0.8); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 96500e88..0be33ca6 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -121,9 +121,6 @@ EquipmentWindow::~EquipmentWindow() void EquipmentWindow::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - // Draw window graphics Window::draw(graphics); diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index d4de3477..a7bb229f 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -70,9 +70,6 @@ ItemShortcutContainer::~ItemShortcutContainer() void ItemShortcutContainer::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (config.getValue("guialpha", 0.8) != mAlpha) { mAlpha = config.getValue("guialpha", 0.8); diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index dbd8e674..70b4fc55 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -38,7 +38,7 @@ ListBox::ListBox(gcn::ListModel *listModel): void ListBox::draw(gcn::Graphics *graphics) { - if (!mListModel || !isVisible()) + if (!mListModel) return; if (config.getValue("guialpha", 0.8) != mAlpha) diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 6bca796d..75ee7e3d 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -92,21 +92,14 @@ void Minimap::setMapImage(Image *img) void Minimap::toggle() { - mShow = !mShow; + mShow = ! isVisible(); + setVisible(mShow); } void Minimap::draw(gcn::Graphics *graphics) { - setVisible(mShow); - - if (!isVisible()) - return; - Window::draw(graphics); - if (!mShow) - return; - const gcn::Rectangle a = getChildrenArea(); graphics->pushClipArea(a); diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index 58ef4cd7..d00194bd 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -78,9 +78,6 @@ PlayerBox::~PlayerBox() void PlayerBox::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (mPlayer) { // Draw character diff --git a/src/gui/popup.cpp b/src/gui/popup.cpp index 648a9d6a..46246639 100644 --- a/src/gui/popup.cpp +++ b/src/gui/popup.cpp @@ -108,9 +108,6 @@ void Popup::savePopupConfiguration() void Popup::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - Graphics *g = static_cast(graphics); g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder()); diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp index 4a98e29a..d563a2db 100644 --- a/src/gui/radiobutton.cpp +++ b/src/gui/radiobutton.cpp @@ -69,9 +69,6 @@ RadioButton::~RadioButton() void RadioButton::drawBox(gcn::Graphics* graphics) { - if (!isVisible()) - return; - if (config.getValue("guialpha", 0.8) != mAlpha) { mAlpha = config.getValue("guialpha", 0.8); diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index a867822e..2fa087c1 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -170,9 +170,6 @@ void ScrollArea::logic() void ScrollArea::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (mVBarVisible) { drawUpButton(graphics); diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 8801c51a..b35c1d80 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -58,7 +58,7 @@ void ShopListBox::setPlayersMoney(int money) void ShopListBox::draw(gcn::Graphics *gcnGraphics) { - if (!mListModel || !isVisible()) + if (!mListModel) return; if (config.getValue("guialpha", 0.8) != mAlpha) diff --git a/src/gui/status.cpp b/src/gui/status.cpp index e298c3e2..e6f57de5 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -253,9 +253,6 @@ void StatusWindow::update() void StatusWindow::draw(gcn::Graphics *g) { - if (!isVisible()) - return; - update(); Window::draw(g); diff --git a/src/gui/table.cpp b/src/gui/table.cpp index 4dda9246..e98d76e5 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -265,7 +265,7 @@ void GuiTable::installActionListeners() // -- widget ops void GuiTable::draw(gcn::Graphics* graphics) { - if (!mModel || !isVisible()) + if (!mModel) return; if (config.getValue("guialpha", 0.8) != mAlpha) diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp index c94710b3..48a00dcc 100644 --- a/src/gui/textfield.cpp +++ b/src/gui/textfield.cpp @@ -84,9 +84,6 @@ TextField::~TextField() void TextField::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (isFocused()) { drawCaret(graphics, diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index d8c66789..68c7e093 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -111,9 +111,6 @@ DropDown::~DropDown() void DropDown::draw(gcn::Graphics* graphics) { - if (!isVisible()) - return; - int h; if (mDroppedDown) diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 5dd32e00..a916ba38 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -118,9 +118,6 @@ void Window::setWindowContainer(WindowContainer *wc) void Window::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - Graphics *g = static_cast(graphics); g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder()); diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 05f74630..534c1b7b 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -93,7 +93,8 @@ namespace { sellDialog->setVisible(false); buySellDialog->setVisible(false); - if (storageWindow->isVisible()) storageWindow->close(); + if (storageWindow->isVisible()) + storageWindow->close(); } } deathListener; -- cgit v1.2.3-70-g09d2 From a5ed5126e8498d53a5f843d591ff183951418d1f Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 28 Mar 2009 00:30:58 +0100 Subject: Take the server port out of the updates dir It doesn't make much sense to combine the update host with the server port. Either use the update host (and path) or the server and its port. To me it makes more sense that if different servers share the same update host, this data should be shared by the client. Ultimately we should store the updates by their hash, so that we can stick everything in the same place and avoid storing any duplicates. --- src/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b10a8c42..5de5f365 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -250,8 +250,7 @@ static void setUpdatesDir() { if (pos + 3 < updateHost.length()) { - updates << "updates/" << updateHost.substr(pos + 3) - << "/" << loginData.port; + updates << "updates/" << updateHost.substr(pos + 3); updatesDir = updates.str(); } else -- cgit v1.2.3-70-g09d2 From b2df8047e6c2d1215ef7debf1a42e02188725471 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 28 Mar 2009 01:01:10 +0100 Subject: Make the full inventory accessible again Was broken due to tmwserv having only 50 as opposed to 100 places in the inventory at the moment. --- src/gui/inventorywindow.cpp | 9 ++++----- src/gui/itemcontainer.cpp | 12 +++++++----- src/gui/itemcontainer.h | 12 ++++++------ src/gui/itemshortcutcontainer.cpp | 1 - 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 612c978a..51c1372c 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -57,7 +57,7 @@ InventoryWindow::InventoryWindow(int invSize): setResizable(false); setCloseButton(true); - setDefaultSize(375, 307, ImageRect::CENTER); + setDefaultSize(387, 307, ImageRect::CENTER); addKeyListener(this); std::string longestUseString = getFont()->getWidth(_("Equip")) > @@ -74,14 +74,13 @@ InventoryWindow::InventoryWindow(int invSize): mDropButton = new Button(_("Drop"), "drop", this); #ifdef TMWSERV_SUPPORT mSplitButton = new Button(_("Split"), "split", this); -#endif - mItems = new ItemContainer(player_node->getInventory(), 10, 5); +#else + mItems = new ItemContainer(player_node->getInventory(), 10, 10); +#endif mItems->addSelectionListener(this); - // The window is supposed to be exactly large enough for now mInvenScroll = new ScrollArea(mItems); - mInvenScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mInvenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mTotalWeight = -1; diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index bd180f28..70cf8176 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -281,9 +281,11 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event) }; int index = getSlotIndex(event.getX(), event.getY()); - if (index == Inventory::NO_SLOT_INDEX) return; + if (index == Inventory::NO_SLOT_INDEX) + return; Item *item = mInventory->getItem(index); - if (item == mSelectedItem) return; + if (item == mSelectedItem) + return; player_node->moveInvItem(mSelectedItem, index); setSelectedItem(NULL); mSelectionStatus = SEL_NONE; @@ -314,12 +316,12 @@ void ItemContainer::mouseExited(gcn::MouseEvent &event) mItemPopup->setVisible(false); } -int ItemContainer::getSlotIndex(const int posX, const int posY) const +int ItemContainer::getSlotIndex(int x, int y) const { - if (getDimension().isPointInRect(posX, posY)) + if (x < getWidth() && y < getHeight()) { // Takes into account, boxes are overlapping each other. - return (posY / (BOX_HEIGHT - 1)) * mGridColumns + (posX / (BOX_WIDTH - 1)); + return (y / (BOX_HEIGHT - 1)) * mGridColumns + (x / (BOX_WIDTH - 1)); } return Inventory::NO_SLOT_INDEX; } diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index a28ca392..b2857563 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -69,9 +69,12 @@ class ItemContainer : public gcn::Widget, void keyPressed(gcn::KeyEvent &event); void keyReleased(gcn::KeyEvent &event); + void mousePressed(gcn::MouseEvent &event); void mouseDragged(gcn::MouseEvent &event); void mouseReleased(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event); /** * Returns the selected item. @@ -125,9 +128,6 @@ class ItemContainer : public gcn::Widget, */ void keyAction(); - void mouseExited(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); - /** * Moves the highlight in the direction specified. * @@ -158,11 +158,11 @@ class ItemContainer : public gcn::Widget, /** * Gets the slot index based on the cursor position. * - * @param posX The X Coordinate position. - * @param posY The Y Coordinate position. + * @param x The X coordinate position. + * @param y The Y coordinate position. * @return The slot index on success, -1 on failure. */ - int getSlotIndex(int posX, int posY) const; + int getSlotIndex(int x, int y) const; Inventory *mInventory; int mGridColumns, mGridRows; diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index a7bb229f..97c3b640 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -252,4 +252,3 @@ void ItemShortcutContainer::mouseExited(gcn::MouseEvent &event) { mItemPopup->setVisible(false); } - -- cgit v1.2.3-70-g09d2 From 38f30a158a73bf2e6481d32e90a85684e4542fdf Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Fri, 27 Mar 2009 18:03:16 -0600 Subject: Make chat wrap --- src/gui/widgets/chattab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index c4b2196b..95606281 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -49,7 +49,7 @@ ChatTab::ChatTab(const std::string &name) : Tab() { setCaption(name); - mTextOutput = new BrowserBox; + mTextOutput = new BrowserBox(BrowserBox::AUTO_WRAP); mTextOutput->setOpaque(false); mTextOutput->setMaxRow((int) config.getValue("ChatLogLength", 0)); mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler); -- cgit v1.2.3-70-g09d2 From ad9036cb9026091ae0d5b0150513a907e092613f Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 28 Mar 2009 01:44:25 +0100 Subject: Fixed the wrapping of item and emoticon shortcut windows Take into account incomplete rows. --- src/gui/shortcutcontainer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/shortcutcontainer.cpp b/src/gui/shortcutcontainer.cpp index 9067e921..228a484e 100644 --- a/src/gui/shortcutcontainer.cpp +++ b/src/gui/shortcutcontainer.cpp @@ -42,12 +42,12 @@ void ShortcutContainer::widgetResized(const gcn::Event &event) if (mGridWidth < 1) mGridWidth = 1; - setHeight((mMaxItems / mGridWidth) * mBoxHeight); + mGridHeight = mMaxItems / mGridWidth; - mGridHeight = getHeight() / mBoxHeight; + if (mMaxItems % mGridWidth != 0 || mGridHeight < 1) + ++mGridHeight; - if (mGridHeight < 1) - mGridHeight = 1; + setHeight(mGridHeight * mBoxHeight); } int ShortcutContainer::getIndexFromGrid(int pointX, int pointY) const -- cgit v1.2.3-70-g09d2 From 91da5b104a0895578a0a2a7debbfb495e50ef4f4 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 28 Mar 2009 02:17:35 +0100 Subject: Some more cleanup Renamed Skill_Tab to SkillTab and got rid of MAX_SLOT, using maxSlot instead. --- src/gui/char_select.cpp | 62 ++++++++++++++++++++++++------------------------- src/gui/skilldialog.cpp | 58 +++++++++++++++++++++++---------------------- src/gui/skilldialog.h | 15 ++++++------ 3 files changed, 67 insertions(+), 68 deletions(-) diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index a0f7230e..bf885de9 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -19,50 +19,48 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - -#include - -#include "button.h" -#include "char_select.h" -#include "confirm_dialog.h" -#include "label.h" -#include "ok_dialog.h" -#include "playerbox.h" -#include "textfield.h" +#include "gui/button.h" +#include "gui/char_select.h" +#include "gui/confirm_dialog.h" +#include "gui/label.h" +#include "gui/ok_dialog.h" +#include "gui/playerbox.h" +#include "gui/textfield.h" #ifdef TMWSERV_SUPPORT -#include "radiobutton.h" -#include "slider.h" +#include "gui/radiobutton.h" +#include "gui/slider.h" -#include "unregisterdialog.h" -#include "changepassworddialog.h" -#include "changeemaildialog.h" +#include "gui/unregisterdialog.h" +#include "gui/changepassworddialog.h" +#include "gui/changeemaildialog.h" -#include "../logindata.h" +#include "logindata.h" -#include "../net/tmwserv/accountserver/account.h" -#include "../net/tmwserv/charserverhandler.h" +#include "net/tmwserv/accountserver/account.h" +#include "net/tmwserv/charserverhandler.h" #else -#include "../net/ea/charserverhandler.h" +#include "net/ea/charserverhandler.h" #endif -#include "widgets/layout.h" +#include "gui/widgets/layout.h" -#include "../game.h" -#include "../localplayer.h" -#include "../main.h" -#include "../units.h" +#include "game.h" +#include "localplayer.h" +#include "main.h" +#include "units.h" -#include "../net/messageout.h" +#include "net/messageout.h" -#include "../resources/colordb.h" +#include "resources/colordb.h" -#include "../utils/gettext.h" -#include "../utils/strprintf.h" -#include "../utils/stringutils.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" +#include "utils/stringutils.h" -#define MAX_SLOT 2 +#include + +#include // Defined in main.cpp, used here for setting the char create dialog extern CharServerHandler charServerHandler; @@ -258,7 +256,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) { new CharDeleteConfirm(this); } - else if (n_character <= MAX_SLOT) + else if (n_character <= maxSlot) { // Start new character dialog CharCreateDialog *charCreateDialog = diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 16c983ad..4afd92ac 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -19,28 +19,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include +#include "gui/skilldialog.h" + +#include "gui/icon.h" +#include "gui/button.h" +#include "gui/listbox.h" +#include "gui/scrollarea.h" +#include "gui/windowcontainer.h" +#include "gui/progressbar.h" -#include "skilldialog.h" +#include "gui/widgets/tabbedarea.h" -#include "icon.h" -#include "button.h" -#include "listbox.h" -#include "scrollarea.h" -#include "windowcontainer.h" -#include "progressbar.h" +#include "localplayer.h" -#include "widgets/tabbedarea.h" +#include "utils/dtor.h" +#include "utils/gettext.h" +#include "utils/stringutils.h" -#include "../localplayer.h" +#include +#include +#include -#include "../utils/dtor.h" -#include "../utils/gettext.h" -#include "../utils/stringutils.h" +#include -class Skill_Tab : public GCContainer, public gcn::ActionListener +class SkillTab : public GCContainer, public gcn::ActionListener { public: /** @@ -51,7 +53,7 @@ class Skill_Tab : public GCContainer, public gcn::ActionListener /** * Constructor */ - Skill_Tab(const std::string &type); + SkillTab(const std::string &type); /** * Update this tab @@ -105,18 +107,18 @@ SkillDialog::SkillDialog(): TabbedArea *panel = new TabbedArea; panel->setDimension(gcn::Rectangle(5, 5, 270, 420)); - Skill_Tab *tab; + SkillTab *tab; // Add each type of skill tab to the panel - tab = new Skill_Tab("Weapon"); + tab = new SkillTab("Weapon"); panel->addTab(_("Weapons"), tab); mTabs.push_back(tab); - tab = new Skill_Tab("Magic"); + tab = new SkillTab("Magic"); panel->addTab(_("Magic"), tab); mTabs.push_back(tab); - tab = new Skill_Tab("Craft"); + tab = new SkillTab("Craft"); panel->addTab(_("Crafts"), tab); mTabs.push_back(tab); @@ -153,14 +155,14 @@ void SkillDialog::draw(gcn::Graphics *g) void SkillDialog::update() { - for(std::list::const_iterator i = mTabs.begin(); + for(std::list::const_iterator i = mTabs.begin(); i != mTabs.end(); ++i) { (*i)->update(); } } -Skill_Tab::Skill_Tab(const std::string &type): type(type) +SkillTab::SkillTab(const std::string &type): type(type) { setOpaque(false); setDimension(gcn::Rectangle(0, 0, 270, 420)); @@ -200,7 +202,7 @@ Skill_Tab::Skill_Tab(const std::string &type): type(type) } -int Skill_Tab::getSkillNum() +int SkillTab::getSkillNum() { int skillNum = 0; @@ -222,7 +224,7 @@ int Skill_Tab::getSkillNum() else return skillNum; } -int Skill_Tab::getSkillBegin() +int SkillTab::getSkillBegin() { int skillBegin = 0; @@ -244,14 +246,14 @@ int Skill_Tab::getSkillBegin() else return skillBegin; } -Icon* Skill_Tab::getIcon(int index) +Icon* SkillTab::getIcon(int index) { int skillBegin = getSkillBegin(); std::string icon = LocalPlayer::getSkillInfo(index + skillBegin).icon; return new Icon(icon); } -void Skill_Tab::updateSkill(int index) +void SkillTab::updateSkill(int index) { int skillBegin = getSkillBegin(); @@ -306,7 +308,7 @@ void Skill_Tab::updateSkill(int index) } } -void Skill_Tab::update() +void SkillTab::update() { int skillNum = getSkillNum(); diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index b79be800..8d1f6a88 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -22,20 +22,19 @@ #ifndef SKILL_H #define SKILL_H -#include -#include +#include "gui/window.h" +#include "gui/gccontainer.h" + +#include "guichanfwd.h" #include #include -#include "window.h" -#include "gccontainer.h" - -#include "../guichanfwd.h" +#include class ProgressBar; class Icon; -class Skill_Tab; +class SkillTab; /** * The skill dialog. @@ -71,7 +70,7 @@ class SkillDialog : public Window, public gcn::ActionListener void draw(gcn::Graphics *g); private: - std::list mTabs; + std::list mTabs; }; extern SkillDialog *skillDialog; -- cgit v1.2.3-70-g09d2 From ef2e1bafa7c5f19b0353e0bf01a7ad9d7f8cddf5 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 28 Mar 2009 07:55:54 -0600 Subject: Allow changing chat tabs with the keyboard Defaults to: [ for previous tab ] for next tab --- src/game.cpp | 11 +++++++++++ src/gui/chat.cpp | 22 ++++++++++++++++++++++ src/gui/chat.h | 10 ++++++++++ src/keyboardconfig.cpp | 2 ++ src/keyboardconfig.h | 2 ++ 5 files changed, 47 insertions(+) diff --git a/src/game.cpp b/src/game.cpp index ba756df3..2dc62b05 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -722,6 +722,17 @@ void Game::handleInput() used = true; } + if (keyboard.isKeyActive(keyboard.KEY_PREV_CHAT_TAB)) + { + chatWindow->prevTab(); + return; + } + else if (keyboard.isKeyActive(keyboard.KEY_NEXT_CHAT_TAB)) + { + chatWindow->nextTab(); + return; + } + const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); switch (tKey) { diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 987de11e..398b5792 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -159,6 +159,28 @@ void ChatWindow::clearTab() clearTab(getFocused()); } +void ChatWindow::prevTab() +{ + int tab = mChatTabs->getSelectedTabIndex(); + + if (tab == 0) + tab = mChatTabs->getNumberOfTabs(); + tab--; + + mChatTabs->setSelectedTab(tab); +} + +void ChatWindow::nextTab() +{ + int tab = mChatTabs->getSelectedTabIndex(); + + tab++; + if (tab == mChatTabs->getNumberOfTabs()) + tab = 0; + + mChatTabs->setSelectedTab(tab); +} + void ChatWindow::action(const gcn::ActionEvent &event) { if (event.getId() == "chatinput") diff --git a/src/gui/chat.h b/src/gui/chat.h index 54270055..3a2f7fdb 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -102,6 +102,16 @@ class ChatWindow : public Window, */ void clearTab(); + /** + * Switch to the previous tab in order + */ + void prevTab(); + + /** + * Switch to the next tab in order + */ + void nextTab(); + /** * Performs action. */ diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 06ce4ac7..e13af147 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -94,6 +94,8 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = { {"keyChat", SDLK_RETURN, _("Toggle Chat")}, {"keyChatScrollUp", SDLK_PAGEUP, _("Scroll Chat Up")}, {"keyChatScrollDown", SDLK_PAGEDOWN, _("Scroll Chat Down")}, + {"keyChatPrevTab", SDLK_LEFTBRACKET, _("Previous Chat Tab")}, + {"keyChatNextTab", SDLK_RIGHTBRACKET, _("Next Chat Tab")}, {"keyOK", SDLK_RETURN, _("Select OK")}, {"keyQuit", SDLK_ESCAPE, _("Quit")}, {"keyIgnoreInput1", SDLK_LSUPER, _("Ignore input 1")}, diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index f7750b30..ecbe5de5 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -205,6 +205,8 @@ class KeyboardConfig KEY_TOGGLE_CHAT, KEY_SCROLL_CHAT_UP, KEY_SCROLL_CHAT_DOWN, + KEY_PREV_CHAT_TAB, + KEY_NEXT_CHAT_TAB, KEY_OK, KEY_QUIT, KEY_IGNORE_INPUT_1, -- cgit v1.2.3-70-g09d2 From 42a095de15649f0f00ef6c681268d6623205900c Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 28 Mar 2009 10:35:49 -0600 Subject: Add a sticky button to the Window class The Minimap window uses this so you can froce it to always be open. The Minimap toggle button can be used to show or hide it temporarily, as warping will reset it's visibility based on the sticky state and weather the 'new' map has a minimap. --- data/graphics/gui/sticky_button.png | Bin 0 -> 640 bytes src/gui/minimap.cpp | 6 ++-- src/gui/skin.cpp | 15 ++++++++-- src/gui/skin.h | 10 ++++++- src/gui/window.cpp | 58 ++++++++++++++++++++++++++++++++---- src/gui/window.h | 18 +++++++++-- 6 files changed, 93 insertions(+), 14 deletions(-) create mode 100644 data/graphics/gui/sticky_button.png diff --git a/data/graphics/gui/sticky_button.png b/data/graphics/gui/sticky_button.png new file mode 100644 index 00000000..d25fa81c Binary files /dev/null and b/data/graphics/gui/sticky_button.png differ diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 75ee7e3d..bfd34390 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -45,6 +45,9 @@ Minimap::Minimap(): setDefaultSize(5, 25, 100, 100); setResizable(true); + setStickyButton(true); + setSticky(false); + loadWindowState(); } @@ -92,8 +95,7 @@ void Minimap::setMapImage(Image *img) void Minimap::toggle() { - mShow = ! isVisible(); - setVisible(mShow); + setVisible(!isVisible(), true); } void Minimap::draw(gcn::Graphics *graphics) diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp index b16bdfe6..0130ad71 100644 --- a/src/gui/skin.cpp +++ b/src/gui/skin.cpp @@ -47,14 +47,16 @@ class SkinConfigListener : public ConfigListener } }; -Skin::Skin(ImageRect skin, Image *close, +Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, const std::string &filePath, const std::string &name): instances(0), mFilePath(filePath), mName(name), border(skin), - closeImage(close) + closeImage(close), + stickyImageUp(stickyUp), + stickyImageDown(stickyDown) { } @@ -219,7 +221,14 @@ Skin *SkinLoader::load(const std::string &filename, // Hard-coded for now until we update the above code to look for window buttons. Image *closeImage = resman->getImage("graphics/gui/close_button.png"); - Skin *skin = new Skin(border, closeImage, filename); + Image *sticky = resman->getImage("graphics/gui/sticky_button.png"); + Image *stickyImageUp = sticky->getSubImage(0, 0, 15, 15); + Image *stickyImageDown = sticky->getSubImage(15, 0, 15, 15); + + sticky->decRef(); + + Skin *skin = new Skin(border, closeImage, stickyImageUp, stickyImageDown, + filename); mSkins[filename] = skin; diff --git a/src/gui/skin.h b/src/gui/skin.h index df905b05..30f7f360 100644 --- a/src/gui/skin.h +++ b/src/gui/skin.h @@ -34,7 +34,7 @@ class Image; class Skin { public: - Skin(ImageRect skin, Image *close, + Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, const std::string &filePath, const std::string &name = ""); @@ -62,6 +62,12 @@ class Skin */ Image *getCloseImage() const { return closeImage; } + /** + * Returns the image used by a sticky button for this skin. + */ + Image *getStickyImage(bool state) const + { return state ? stickyImageDown : stickyImageUp; } + /** * Returns the number of instances which use this skin. */ @@ -89,6 +95,8 @@ class Skin std::string mName; /**< Name of the skin to use */ ImageRect border; /**< The window border and background */ Image *closeImage; /**< Close Button Image */ + Image *stickyImageUp; /**< Sticky Button Image */ + Image *stickyImageDown; /**< Sticky Button Image */ }; // Map containing all window skins diff --git a/src/gui/window.cpp b/src/gui/window.cpp index a916ba38..1f9dab5b 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -48,6 +48,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent, const std mShowTitle(true), mModal(modal), mCloseButton(false), + mStickyButton(false), mSticky(false), mMinWinWidth(100), mMinWinHeight(40), @@ -135,8 +136,18 @@ void Window::draw(gcn::Graphics *graphics) { g->drawImage(mSkin->getCloseImage(), getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(), - getPadding() - ); + getPadding()); + } + + // Draw Sticky Button + if (mStickyButton) + { + Image *button = mSkin->getStickyImage(mSticky); + int x = getWidth() - button->getWidth() - getPadding(); + if (mCloseButton) + x -= mSkin->getCloseImage()->getWidth(); + + g->drawImage(button, x, getPadding()); } drawChildren(graphics); @@ -283,6 +294,11 @@ bool Window::isResizable() const return mGrip; } +void Window::setStickyButton(bool flag) +{ + mStickyButton = flag; +} + void Window::setSticky(bool sticky) { mSticky = sticky; @@ -290,7 +306,12 @@ void Window::setSticky(bool sticky) void Window::setVisible(bool visible) { - gcn::Window::setVisible(isSticky() || visible); + setVisible(visible, false); +} + +void Window::setVisible(bool visible, bool forceSticky) +{ + gcn::Window::setVisible((!forceSticky && isSticky()) || visible); } void Window::scheduleDelete() @@ -323,6 +344,22 @@ void Window::mousePressed(gcn::MouseEvent &event) } } + // Handle sticky button + if (mStickyButton) + { + Image *button = mSkin->getStickyImage(mSticky); + int rx = getWidth() - button->getWidth() - getPadding(); + if (mCloseButton) + rx -= mSkin->getCloseImage()->getWidth(); + gcn::Rectangle stickyButtonRect(rx, getPadding(), + button->getWidth(), button->getHeight()); + + if (stickyButtonRect.isPointInRect(x, y)) + { + setSticky(!isSticky()); + } + } + // Handle window resizing mouseResize = getResizeHandles(event); } @@ -467,7 +504,12 @@ void Window::loadWindowState() setPosition((int) config.getValue(name + "WinX", mDefaultX), (int) config.getValue(name + "WinY", mDefaultY)); - setVisible((bool) config.getValue(name + "Visible", false)); + + if (mCloseButton) + setVisible((bool) config.getValue(name + "Visible", false)); + + if (mStickyButton) + setSticky((bool) config.getValue(name + "Sticky", isSticky())); if (skinName.compare(mSkin->getFilePath()) != 0) { @@ -504,7 +546,13 @@ void Window::saveWindowState() { config.setValue(mWindowName + "WinX", getX()); config.setValue(mWindowName + "WinY", getY()); - config.setValue(mWindowName + "Visible", isVisible()); + + if (mCloseButton) + config.setValue(mWindowName + "Visible", isVisible()); + + if (mStickyButton) + config.setValue(mWindowName + "Sticky", isSticky()); + config.setValue(mWindowName + "Skin", mSkin->getFilePath()); if (mGrip) diff --git a/src/gui/window.h b/src/gui/window.h index c41a4221..18a64532 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -144,17 +144,22 @@ class Window : public gcn::Window, gcn::WidgetListener */ void setShowTitle(bool flag) { mShowTitle = flag; } + /** + * Sets whether or not the window has a sticky button. + */ + void setStickyButton(bool flag); + /** * Sets whether the window is sticky. A sticky window will not have * its visibility set to false on a general setVisible(false) call. + * Use this to set the default before you call loadWindowState(). */ void setSticky(bool sticky); /** * Returns whether the window is sticky. */ - bool isSticky() const - { return mSticky; } + bool isSticky() const { return mSticky; } /** * Overloads window setVisible by Guichan to allow sticky window @@ -162,6 +167,12 @@ class Window : public gcn::Window, gcn::WidgetListener */ void setVisible(bool visible); + /** + * Overloads window setVisible by Guichan to allow sticky window + * handling, or not, if you force the sticky state. + */ + void setVisible(bool visible, bool forceSticky); + /** * Returns the parent window. * @@ -325,7 +336,8 @@ class Window : public gcn::Window, gcn::WidgetListener bool mShowTitle; /**< Window has a title bar */ bool mModal; /**< Window is modal */ bool mCloseButton; /**< Window has a close button */ - bool mSticky; /**< Window resists minimization */ + bool mStickyButton; /**< Window has a sticky button */ + bool mSticky; /**< Window resists hiding*/ int mMinWinWidth; /**< Minimum window width */ int mMinWinHeight; /**< Minimum window height */ int mMaxWinWidth; /**< Maximum window width */ -- cgit v1.2.3-70-g09d2 From df095c66fdf7af74849454dbf8c4c2284616ecd7 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 28 Mar 2009 11:22:46 -0600 Subject: Remove #ifdefs related to Being creation Also move the Monster type offset handling into the eAthena netcode. --- src/beingmanager.cpp | 33 +++++++----------------------- src/beingmanager.h | 6 +----- src/monster.cpp | 4 ---- src/net/ea/beinghandler.cpp | 43 +++++++++++++++++++++++++++++++++++----- src/net/tmwserv/beinghandler.cpp | 5 +++-- 5 files changed, 49 insertions(+), 42 deletions(-) diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 9c671808..8c07aaab 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -81,46 +81,27 @@ void BeingManager::setPlayer(LocalPlayer *player) mBeings.push_back(player); } -#ifdef TMWSERV_SUPPORT -Being *BeingManager::createBeing(int id, int type, int subtype) -#else -Being *BeingManager::createBeing(int id, Uint16 job) -#endif +Being *BeingManager::createBeing(int id, Being::Type type, int subtype) { Being *being; -#ifdef TMWSERV_SUPPORT switch (type) { - case OBJECT_PLAYER: + case Being::PLAYER: being = new Player(id, subtype, mMap); break; - case OBJECT_NPC: + case Being::NPC: being = new NPC(id, subtype, mMap); break; - case OBJECT_MONSTER: + case Being::MONSTER: being = new Monster(id, subtype, mMap); break; + case Being::UNKNOWN: + being = new Being(id, subtype, mMap); + break; default: assert(false); } -#else - if (job <= 25 || (job >= 4001 && job <= 4049)) - being = new Player(id, job, mMap); - else if (job >= 46 && job <= 1000) - being = new NPC(id, job, mMap); - else if (job > 1000 && job <= 2000) - being = new Monster(id, job, mMap); - else - being = new Being(id, job, mMap); - - // Player or NPC - if (job <= 1000 || (job >= 4001 && job <= 4049)) - { - MessageOut outMsg(0x0094); - outMsg.writeInt32(id);//readLong(2)); - } -#endif mBeings.push_back(being); return being; diff --git a/src/beingmanager.h b/src/beingmanager.h index 891a8ccb..727918a8 100644 --- a/src/beingmanager.h +++ b/src/beingmanager.h @@ -50,11 +50,7 @@ class BeingManager /** * Create a being and add it to the list of beings. */ -#ifdef TMWSERV_SUPPORT - Being *createBeing(int id, int type, int subtype); -#else - Being *createBeing(int id, Uint16 job); -#endif + Being *createBeing(int id, Being::Type type, int subtype); /** * Remove a Being. diff --git a/src/monster.cpp b/src/monster.cpp index c2632028..08a614ea 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -201,11 +201,7 @@ Being::TargetCursorSize Monster::getTargetCursorSize() const const MonsterInfo &Monster::getInfo() const { -#ifdef TMWSERV_SUPPORT return MonsterDB::get(mJob); -#else - return MonsterDB::get(mJob - 1002); -#endif } void Monster::setShowName(bool show) diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 237c9f1f..0ad15d7d 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -24,6 +24,7 @@ #include "net/ea/protocol.h" #include "net/messagein.h" +#include "net/messageout.h" #include "being.h" #include "beingmanager.h" @@ -37,7 +38,6 @@ #include "gui/npc_text.h" #include -#include extern NpcTextDialog *npcTextDialog; @@ -69,10 +69,34 @@ BeingHandler::BeingHandler(bool enableSync): handledMessages = _messages; } +Being *createBeing(int id, short job) +{ + Being::Type type = Being::UNKNOWN; + if (job <= 25 || (job >= 4001 && job <= 4049)) + type = Being::PLAYER; + else if (job >= 46 && job <= 1000) + type = Being::NPC; + else if (job > 1000 && job <= 2000) + { + type = Being::MONSTER; + job -= 1002; + } + + Being *being = beingManager->createBeing(id, type, job); + + if (type == Being::PLAYER || type == Being::NPC) + { + MessageOut outMsg(0x0094); + outMsg.writeInt32(id);//readLong(2)); + } + + return being; +} + void BeingHandler::handleMessage(MessageIn &msg) { int id; - Uint16 job, speed; + short job, speed; Uint16 headTop, headMid, headBottom; Uint16 shoes, gloves; Uint16 weapon, shield; @@ -108,9 +132,14 @@ void BeingHandler::handleMessage(MessageIn &msg) break; } - dstBeing = beingManager->createBeing(id, job); + dstBeing = createBeing(id, job); } - else if (msg.getId() == 0x0078) + else if (dstBeing->getType() == Being::MONSTER) + { + job -= 1002; + } + + if (msg.getId() == 0x0078) { dstBeing->clearPath(); dstBeing->mFrame = 0; @@ -399,7 +428,11 @@ void BeingHandler::handleMessage(MessageIn &msg) if (!dstBeing) { - dstBeing = beingManager->createBeing(id, job); + dstBeing = createBeing(id, job); + } + else if (dstBeing->getType() == Being::MONSTER) + { + job -= 1002; } dstBeing->setWalkSpeed(speed); diff --git a/src/net/tmwserv/beinghandler.cpp b/src/net/tmwserv/beinghandler.cpp index 1a1744cc..08847d7d 100644 --- a/src/net/tmwserv/beinghandler.cpp +++ b/src/net/tmwserv/beinghandler.cpp @@ -139,7 +139,7 @@ void BeingHandler::handleBeingEnterMessage(MessageIn &msg) } else { - being = beingManager->createBeing(id, type, 0); + being = beingManager->createBeing(id, Being::PLAYER, 0); being->setName(name); } Player *p = static_cast< Player * >(being); @@ -154,7 +154,8 @@ void BeingHandler::handleBeingEnterMessage(MessageIn &msg) case OBJECT_NPC: { int subtype = msg.readInt16(); - being = beingManager->createBeing(id, type, subtype); + being = beingManager->createBeing(id, type == OBJECT_MONSTER ? + Being::MONSTER : Being::NPC, subtype); std::string name = msg.readString(); if (name.length() > 0) being->setName(name); } break; -- cgit v1.2.3-70-g09d2 From f7b0dd65a06ae7785c25659850584964565da3ff Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 28 Mar 2009 12:55:51 -0600 Subject: Make the BuySellWindow eAthena only --- src/Makefile.am | 6 +++--- src/gui/buysell.cpp | 15 ++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 3768b7cd..ae9fa827 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,9 +32,7 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ gui/button.cpp \ gui/button.h \ gui/buy.cpp \ - gui/buy.h \ - gui/buysell.cpp \ - gui/buysell.h \ + gui/buy.h \ gui/char_select.cpp \ gui/char_select.h \ gui/chat.cpp \ @@ -431,6 +429,8 @@ endif if SERVER_EATHENA tmw_CXXFLAGS += -DEATHENA_SUPPORT tmw_SOURCES += \ + gui/buysell.cpp \ + gui/buysell.h \ gui/char_server.cpp \ gui/char_server.h \ gui/skill.cpp \ diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index 8fffd3d5..a0e2fc93 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -19,17 +19,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "button.h" #include "buysell.h" -#include "../npc.h" +#include "npc.h" -#include "../net/messageout.h" -#ifdef EATHENA_SUPPORT -#include "../net/ea/protocol.h" -#endif +#include "gui/button.h" -#include "../utils/gettext.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" + +#include "utils/gettext.h" BuySellDialog::BuySellDialog(): Window(_("Shop")) @@ -96,9 +95,7 @@ void BuySellDialog::action(const gcn::ActionEvent &event) return; } -#ifdef EATHENA_SUPPORT MessageOut outMsg(CMSG_NPC_BUY_SELL_REQUEST); outMsg.writeInt32(current_npc); outMsg.writeInt8(action); -#endif } -- cgit v1.2.3-70-g09d2 From d7ffc90de680965edef7aa432d3bc3fd15986850 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 28 Mar 2009 17:43:58 -0600 Subject: Forgot to add the sticky button graphics to make --- data/graphics/gui/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am index aaaac211..78541225 100644 --- a/data/graphics/gui/Makefile.am +++ b/data/graphics/gui/Makefile.am @@ -28,6 +28,7 @@ gui_DATA = \ resize.png \ selection.png \ slider.png \ + sticky_button.png \ speechbubble.xml \ tab.png \ tabselected.png \ -- cgit v1.2.3-70-g09d2 From 088c0e4680d8013f01bdc70ac4f340f98afa2394 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 28 Mar 2009 18:13:57 -0600 Subject: Clean up eAthena party handling a bit more --- src/Makefile.am | 18 +++++++------ src/commandhandler.cpp | 4 +-- src/game.cpp | 17 +++---------- src/gui/partywindow.cpp | 27 ++++++++++++++++++-- src/gui/partywindow.h | 3 ++- src/localplayer.cpp | 14 +++++++---- src/localplayer.h | 8 +++--- src/net/ea/gui/partytab.cpp | 4 +-- src/net/ea/gui/partytab.h | 2 ++ src/net/ea/party.cpp | 61 +++++++++++++++------------------------------ src/net/ea/party.h | 48 ++++++++++++----------------------- src/net/ea/partyhandler.cpp | 31 +++++++++++++++++------ src/net/ea/partyhandler.h | 9 +++---- src/net/ea/protocol.h | 2 +- src/player.cpp | 4 +-- src/player.h | 5 ++-- 16 files changed, 127 insertions(+), 130 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index ae9fa827..81e40d06 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,7 +32,7 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ gui/button.cpp \ gui/button.h \ gui/buy.cpp \ - gui/buy.h \ + gui/buy.h \ gui/char_select.cpp \ gui/char_select.h \ gui/chat.cpp \ @@ -102,6 +102,8 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ gui/ok_dialog.h \ gui/palette.cpp \ gui/palette.h \ + gui/partywindow.cpp \ + gui/partywindow.h \ gui/passwordfield.cpp \ gui/passwordfield.h \ gui/playerbox.cpp \ @@ -355,8 +357,6 @@ tmw_SOURCES += \ gui/magic.h \ gui/npcpostdialog.cpp \ gui/npcpostdialog.h \ - gui/partywindow.cpp \ - gui/partywindow.h \ gui/quitdialog.cpp \ gui/quitdialog.h \ gui/serverdialog.cpp \ @@ -429,8 +429,8 @@ endif if SERVER_EATHENA tmw_CXXFLAGS += -DEATHENA_SUPPORT tmw_SOURCES += \ - gui/buysell.cpp \ - gui/buysell.h \ + gui/buysell.cpp \ + gui/buysell.h \ gui/char_server.cpp \ gui/char_server.h \ gui/skill.cpp \ @@ -439,6 +439,8 @@ tmw_SOURCES += \ gui/status.h \ gui/storagewindow.cpp \ gui/storagewindow.h \ + net/ea/gui/partytab.cpp \ + net/ea/gui/partytab.h \ net/ea/beinghandler.cpp \ net/ea/beinghandler.h \ net/ea/buysellhandler.cpp \ @@ -461,8 +463,8 @@ tmw_SOURCES += \ net/ea/network.h \ net/ea/npchandler.cpp \ net/ea/npchandler.h \ - net/ea/party.cpp \ - net/ea/party.h \ + net/ea/party.cpp \ + net/ea/party.h \ net/ea/partyhandler.cpp \ net/ea/partyhandler.h \ net/ea/playerhandler.cpp \ @@ -472,7 +474,7 @@ tmw_SOURCES += \ net/ea/skillhandler.cpp \ net/ea/skillhandler.h \ net/ea/tradehandler.cpp \ - net/ea/tradehandler.h + net/ea/tradehandler.h endif # set the include path found by configure diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 5431cf88..19791aa8 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -252,7 +252,7 @@ void CommandHandler::handleHelp(const std::string &args) #else else if (args.substr(0, 5) == "party") { - playerParty->help(args); + eAthena::Party::help(args); #endif } else if (args == "present") @@ -526,7 +526,7 @@ void CommandHandler::handleParty(const std::string &args) } } else - playerParty->respond(command, rest); + eAthena::Party::respond(command, rest); #endif } diff --git a/src/game.cpp b/src/game.cpp index 2dc62b05..20bf1af1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -74,12 +74,12 @@ #include "gui/status.h" #include "gui/trade.h" #include "gui/viewport.h" +#include "gui/partywindow.h" #ifdef TMWSERV_SUPPORT #include "gui/buddywindow.h" #include "gui/guildwindow.h" #include "gui/magic.h" #include "gui/npcpostdialog.h" -#include "gui/partywindow.h" #include "gui/quitdialog.h" #else #include "gui/storagewindow.h" @@ -107,7 +107,6 @@ #include "net/ea/inventoryhandler.h" #include "net/ea/itemhandler.h" #include "net/ea/npchandler.h" -#include "net/ea/party.h" #include "net/ea/playerhandler.h" #include "net/ea/tradehandler.h" #include "net/ea/protocol.h" @@ -155,12 +154,12 @@ NpcListDialog *npcListDialog; NpcTextDialog *npcTextDialog; NpcStringDialog *npcStringDialog; SkillDialog *skillDialog; +PartyWindow *partyWindow; #ifdef TMWSERV_SUPPORT BuddyWindow *buddyWindow; GuildWindow *guildWindow; MagicDialog *magicDialog; NpcPostDialog *npcPostDialog; -PartyWindow *partyWindow; #else StorageWindow *storageWindow; #endif @@ -180,9 +179,6 @@ Particle *particleEngine = NULL; EffectManager *effectManager = NULL; ChatTab *localChatTab = NULL; -#ifdef EATHENA_SUPPORT -Party *playerParty = NULL; -#endif const int MAX_TIME = 10000; @@ -248,13 +244,13 @@ static void createGuiWindows() npcIntegerDialog = new NpcIntegerDialog; npcListDialog = new NpcListDialog; npcStringDialog = new NpcStringDialog; + partyWindow = new PartyWindow; #ifdef TMWSERV_SUPPORT npcPostDialog = new NpcPostDialog; magicDialog = new MagicDialog; equipmentWindow = new EquipmentWindow(player_node->mEquipment.get()); buddyWindow = new BuddyWindow; guildWindow = new GuildWindow; - partyWindow = new PartyWindow; #else buySellDialog = new BuySellDialog; equipmentWindow = new EquipmentWindow; @@ -333,12 +329,12 @@ static void destroyGuiWindows() delete npcListDialog; delete npcTextDialog; delete npcStringDialog; + delete partyWindow; #ifdef TMWSERV_SUPPORT delete npcPostDialog; delete magicDialog; delete buddyWindow; delete guildWindow; - delete partyWindow; #endif delete skillDialog; delete minimap; @@ -401,9 +397,6 @@ Game::Game(Network *network): // Initialize beings beingManager->setPlayer(player_node); -#ifdef EATHENA_SUPPORT - playerParty = new Party; -#endif Joystick::init(); // TODO: The user should be able to choose which one to use @@ -459,8 +452,6 @@ Game::~Game() { #ifdef TMWSERV_SUPPORT Net::clearHandlers(); -#else - delete playerParty; #endif destroyGuiWindows(); diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 1f87b26f..f5cebdfd 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -24,9 +24,14 @@ #include "gui/widgets/avatar.h" #include "gui/widgets/chattab.h" +#ifdef TMWSERV_SUPPORT #include "net/tmwserv/chatserver/party.h" +#else +#include "net/ea/party.h" +#endif #include "utils/gettext.h" +#include "utils/strprintf.h" PartyWindow::PartyWindow() : Window(_("Party")) { @@ -107,7 +112,8 @@ void PartyWindow::removePartyMember(const std::string &memberName) } } -void PartyWindow::showPartyInvite(const std::string &inviter) +void PartyWindow::showPartyInvite(const std::string &inviter, + const std::string &partyName) { // check there isnt already an invite showing if (mPartyInviter != "") @@ -117,8 +123,15 @@ void PartyWindow::showPartyInvite(const std::string &inviter) return; } + std::string msg; // log invite - std::string msg = inviter + " has invited you to join their party"; + if (partyName.empty()) + msg = strprintf("%s has invited you to join their party", + inviter.c_str()); + else + msg = strprintf("%s has invited you to join the %s party", + inviter.c_str(), partyName.c_str()); + localChatTab->chatLog(msg, BY_SERVER); // show invite @@ -136,11 +149,21 @@ void PartyWindow::action(const gcn::ActionEvent &event) if (eventId == "yes") { localChatTab->chatLog("Accepted invite from " + mPartyInviter); +#ifdef TMWSERV_SUPPORT Net::ChatServer::Party::acceptInvite(mPartyInviter); +#else + eAthena::Party::respondToInvite(true); +#endif mPartyInviter = ""; } else if (eventId == "no") { + localChatTab->chatLog("Rejected invite from " + mPartyInviter); +#ifdef TMWSERV_SUPPORT + // TODO +#else + eAthena::Party::respondToInvite(false); +#endif mPartyInviter = ""; } } diff --git a/src/gui/partywindow.h b/src/gui/partywindow.h index b587cc42..64cfb582 100644 --- a/src/gui/partywindow.h +++ b/src/gui/partywindow.h @@ -77,7 +77,8 @@ class PartyWindow : public Window, gcn::ActionListener /** * Show party invite */ - void showPartyInvite(const std::string &inviter); + void showPartyInvite(const std::string &inviter, + const std::string &partyName = ""); /** * Handle events diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 553e473b..eb54b4b1 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -363,11 +363,6 @@ void LocalPlayer::inviteToGuild(Being *being) } } -void LocalPlayer::inviteToParty(const std::string &name) -{ - Net::ChatServer::Party::invitePlayer(name); -} - void LocalPlayer::clearInventory() { mEquipment->clear(); @@ -381,6 +376,15 @@ void LocalPlayer::setInvItem(int index, int id, int amount) #endif +void LocalPlayer::inviteToParty(const std::string &name) +{ +#ifdef TMWSERV_SUPPORT + Net::ChatServer::Party::invitePlayer(name); +#else + +#endif +} + void LocalPlayer::moveInvItem(Item *item, int newIndex) { // special case, the old and new cannot copy over each other. diff --git a/src/localplayer.h b/src/localplayer.h index 7e48530e..4fd68d8f 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -183,15 +183,15 @@ class LocalPlayer : public Player */ void inviteToGuild(Being *being); + void clearInventory(); + void setInvItem(int index, int id, int amount); +#endif + /** * Invite a player to join their party */ void inviteToParty(const std::string &name); - void clearInventory(); - void setInvItem(int index, int id, int amount); -#endif - /** * Move the Inventory item from the old slot to the new slot. */ diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index a55d2492..4e486bf0 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -44,10 +44,10 @@ PartyTab::~PartyTab() { } -void PartyTab::handleInput(std::string &msg) { +void PartyTab::handleInput(const std::string &msg) { // TODO } -void PartyTab::handleCommand(std::string &msg) { +void PartyTab::handleCommand(std::string msg) { // TODO } diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h index b2aaca68..fce4b515 100644 --- a/src/net/ea/gui/partytab.h +++ b/src/net/ea/gui/partytab.h @@ -46,4 +46,6 @@ class PartyTab : public ChatTab void handleCommand(std::string msg); }; +extern PartyTab *partyTab; + #endif // CHANNELTAB_H diff --git a/src/net/ea/party.cpp b/src/net/ea/party.cpp index 2295cb81..0fbba2f1 100644 --- a/src/net/ea/party.cpp +++ b/src/net/ea/party.cpp @@ -26,19 +26,16 @@ #include "gui/widgets/chattab.h" #include "gui/chat.h" #include "gui/confirm_dialog.h" +#include "gui/partywindow.h" #include "net/messageout.h" #include "net/ea/protocol.h" +#include "net/ea/gui/partytab.h" #include "utils/gettext.h" #include "utils/strprintf.h" -Party::Party() : - mInviteListener(&mInParty) -{ -} - -void Party::respond(const std::string &command, const std::string &args) +void eAthena::Party::respond(const std::string &command, const std::string &args) { if (command == "new" || command == "create") { @@ -52,7 +49,7 @@ void Party::respond(const std::string &command, const std::string &args) } if (command == "settings") { - localChatTab->chatLog(_("Not yet implemented!"), BY_SERVER); + partyTab->chatLog(_("Not yet implemented!"), BY_SERVER); return; /* MessageOut outMsg(CMSG_PARTY_SETTINGS); @@ -60,10 +57,10 @@ void Party::respond(const std::string &command, const std::string &args) outMsg.writeInt16(0); // Item */ } - localChatTab->chatLog(_("Party command not known."), BY_SERVER); + partyTab->chatLog(_("Party command not known."), BY_SERVER); } -void Party::create(const std::string &party) +void eAthena::Party::create(const std::string &party) { if (party.empty()) { @@ -72,22 +69,21 @@ void Party::create(const std::string &party) } MessageOut outMsg(CMSG_PARTY_CREATE); outMsg.writeString(party.substr(0, 23), 24); - mCreating = true; } -void Party::leave(const std::string &args) +void eAthena::Party::leave(const std::string &args) { MessageOut outMsg(CMSG_PARTY_LEAVE); localChatTab->chatLog(_("Left party."), BY_SERVER); - mInParty = false; + player_node->setInParty(false); } -void Party::createResponse(bool ok) +void eAthena::Party::createResponse(bool ok) { if (ok) { localChatTab->chatLog(_("Party successfully created."), BY_SERVER); - mInParty = true; + player_node->setInParty(true); } else { @@ -95,58 +91,41 @@ void Party::createResponse(bool ok) } } -void Party::inviteResponse(const std::string &nick, int status) +void eAthena::Party::inviteResponse(const std::string &nick, int status) { switch (status) { case 0: - localChatTab->chatLog(strprintf(_("%s is already a member of a party."), + partyTab->chatLog(strprintf(_("%s is already a member of a party."), nick.c_str()), BY_SERVER); break; case 1: - localChatTab->chatLog(strprintf(_("%s refused your invitation."), + partyTab->chatLog(strprintf(_("%s refused your invitation."), nick.c_str()), BY_SERVER); break; case 2: - localChatTab->chatLog(strprintf(_("%s is now a member of your party."), + partyTab->chatLog(strprintf(_("%s is now a member of your party."), nick.c_str()), BY_SERVER); break; } } -void Party::invitedAsk(const std::string &nick, int gender, - const std::string &partyName) -{ - mPartyName = partyName; /* Quick and nasty - needs redoing */ - if (nick.empty()) - { - localChatTab->chatLog(_("You can\'t have a blank party name!"), BY_SERVER); - return; - } - mCreating = false; - ConfirmDialog *dlg = new ConfirmDialog(_("Invite to party"), - strprintf(_("%s invites you to join" - " the %s party, do you accept?"), - nick.c_str(), partyName.c_str())); - dlg->addActionListener(&mInviteListener); -} - -void Party::InviteListener::action(const gcn::ActionEvent &event) +void eAthena::Party::respondToInvite(bool accept) { MessageOut outMsg(CMSG_PARTY_INVITED); outMsg.writeInt32(player_node->getId()); - bool accept = event.getId() == "yes"; outMsg.writeInt32(accept ? 1 : 0); - *mInParty = *mInParty || accept; + player_node->setInParty(player_node->getInParty() || accept); } -void Party::leftResponse(const std::string &nick) +void eAthena::Party::leftResponse(const std::string &nick) { localChatTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()), BY_SERVER); + partyWindow->removePartyMember(nick); } -void Party::receiveChat(Being *being, const std::string &msg) +void eAthena::Party::receiveChat(Being *being, const std::string &msg) { if (!being) { @@ -162,7 +141,7 @@ void Party::receiveChat(Being *being, const std::string &msg) localChatTab->chatLog(being->getName() + " : " + msg, BY_PARTY); } -void Party::help(const std::string &args) +void eAthena::Party::help(const std::string &args) { // Strip "party " from the front std::string msg = args.substr(6, args.length()); diff --git a/src/net/ea/party.h b/src/net/ea/party.h index 25af80b3..6907de47 100644 --- a/src/net/ea/party.h +++ b/src/net/ea/party.h @@ -22,18 +22,14 @@ #ifndef PARTY_H #define PARTY_H -#include - -#include +#include "being.h" -class PartyHandler; -class Being; -class ChatWindow; +#include -class Party +namespace eAthena { - public: - Party(); + namespace Party + { void respond(const std::string &command, const std::string &args); void create(const std::string &party); @@ -43,32 +39,20 @@ class Party void inviteResponse(const std::string &nick, int status); void invitedAsk(const std::string &nick, int gender, const std::string &partyName); + + /** + * Send invite response to the server + */ + void respondToInvite(bool accept); + + /** + * The player has left your party + */ void leftResponse(const std::string &nick); void receiveChat(Being *being, const std::string &msg); void help(const std::string &args); - - private: - std::string mPartyName; - bool mInParty; - bool mCreating; /**< Used to give an appropriate response to - failure */ - PartyHandler *handler; - - class InviteListener : public gcn::ActionListener - { - public: - InviteListener(bool *inParty) : - mInParty(inParty) - {} - void action(const gcn::ActionEvent &event); - - private: - bool *mInParty; - }; - InviteListener mInviteListener; -}; - -extern Party *playerParty; + } +} #endif diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index d903976e..7ecf0863 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -21,21 +21,29 @@ #include "net/ea/partyhandler.h" +#include "net/ea/gui/partytab.h" + #include "net/ea/protocol.h" #include "net/messagein.h" #include "gui/chat.h" +#include "gui/partywindow.h" #include "beingmanager.h" #include "party.h" -PartyHandler::PartyHandler(Party *party) : mParty(party) +PartyTab *partyTab; + +static void newPartyTab() { partyTab = new PartyTab(); } +static void deletePartyTab() { delete partyTab ; } + +PartyHandler::PartyHandler() { static const Uint16 _messages[] = { SMSG_PARTY_CREATE, SMSG_PARTY_INFO, - SMSG_PARTY_INVITE, + SMSG_PARTY_INVITE_RESPONSE, SMSG_PARTY_INVITED, SMSG_PARTY_SETTINGS, SMSG_PARTY_MEMBER_INFO, @@ -46,6 +54,13 @@ PartyHandler::PartyHandler(Party *party) : mParty(party) 0 }; handledMessages = _messages; + + newPartyTab(); +} + +PartyHandler::~PartyHandler() +{ + deletePartyTab(); } void PartyHandler::handleMessage(MessageIn &msg) @@ -53,15 +68,15 @@ void PartyHandler::handleMessage(MessageIn &msg) switch (msg.getId()) { case SMSG_PARTY_CREATE: - mParty->createResponse(msg.readInt8()); + eAthena::Party::createResponse(msg.readInt8()); break; case SMSG_PARTY_INFO: break; - case SMSG_PARTY_INVITE: + case SMSG_PARTY_INVITE_RESPONSE: { std::string nick = msg.readString(24); int status = msg.readInt8(); - mParty->inviteResponse(nick, status); + eAthena::Party::inviteResponse(nick, status); break; } case SMSG_PARTY_INVITED: @@ -85,7 +100,7 @@ void PartyHandler::handleMessage(MessageIn &msg) gender = being->getGender(); partyName = msg.readString(24); } - mParty->invitedAsk(nick, gender, partyName); + partyWindow->showPartyInvite(nick, partyName); break; } case SMSG_PARTY_SETTINGS: @@ -97,7 +112,7 @@ void PartyHandler::handleMessage(MessageIn &msg) /*int id = */msg.readInt32(); std::string nick = msg.readString(24); /*int fail = */msg.readInt8(); - mParty->leftResponse(nick); + eAthena::Party::leftResponse(nick); break; } case SMSG_PARTY_UPDATE_HP: @@ -114,7 +129,7 @@ void PartyHandler::handleMessage(MessageIn &msg) int id = msg.readInt32(); Being *being = beingManager->findBeing(id); std::string chatMsg = msg.readString(msgLength); - mParty->receiveChat(being, chatMsg); + eAthena::Party::receiveChat(being, chatMsg); } break; } diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h index 851c4ae3..c6ee261b 100644 --- a/src/net/ea/partyhandler.h +++ b/src/net/ea/partyhandler.h @@ -24,17 +24,14 @@ #include "net/messagehandler.h" -class Party; - class PartyHandler : public MessageHandler { public: - PartyHandler(Party *party); + PartyHandler(); - void handleMessage(MessageIn &msg); + ~PartyHandler(); - private: - Party *mParty; + void handleMessage(MessageIn &msg); }; #endif // NET_EA_PARTYHANDLER_H diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h index a70e47b4..ff13cce9 100644 --- a/src/net/ea/protocol.h +++ b/src/net/ea/protocol.h @@ -101,7 +101,7 @@ static const int STORAGE_OFFSET = 1; #define SMSG_PARTY_CREATE 0x00fa #define SMSG_PARTY_INFO 0x00fb -#define SMSG_PARTY_INVITE 0x00fd +#define SMSG_PARTY_INVITE_RESPONSE 0x00fd #define SMSG_PARTY_INVITED 0x00fe #define SMSG_PARTY_SETTINGS 0x0102 #define SMSG_PARTY_MEMBER_INFO 0x0104 diff --git a/src/player.cpp b/src/player.cpp index a75d4e35..839959b0 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -283,9 +283,9 @@ short Player::getNumberOfGuilds() return mGuilds.size(); } +#endif + void Player::setInParty(bool value) { mInParty = value; } - -#endif diff --git a/src/player.h b/src/player.h index 1904c6d9..d1155f4b 100644 --- a/src/player.h +++ b/src/player.h @@ -107,6 +107,8 @@ class Player : public Being */ short getNumberOfGuilds(); +#endif + /** * Set the player in party */ @@ -116,7 +118,6 @@ class Player : public Being * Returns whether player is in the party */ bool getInParty() const { return mInParty; } -#endif /** * Gets the way the character is blocked by other objects. @@ -140,10 +141,8 @@ class Player : public Being FlashText *mName; -#ifdef TMWSERV_SUPPORT private: bool mInParty; -#endif }; #endif -- cgit v1.2.3-70-g09d2 From 8748f26234bba1e71bbe059147fb02256f8cec2a Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 28 Mar 2009 23:06:32 -0600 Subject: Fix output location for CommandHandler --- src/commandhandler.cpp | 284 ++++++++++++++++++++++---------------------- src/commandhandler.h | 42 ++++--- src/gui/chat.cpp | 4 +- src/gui/widgets/chattab.cpp | 2 +- 4 files changed, 168 insertions(+), 164 deletions(-) diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 19791aa8..f2da21e0 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -46,7 +46,7 @@ CommandHandler::CommandHandler() {} -void CommandHandler::handleCommand(const std::string &command) +void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) { std::string::size_type pos = command.find(' '); std::string type(command, 0, pos); @@ -54,85 +54,85 @@ void CommandHandler::handleCommand(const std::string &command) if (type == "announce") { - handleAnnounce(args); + handleAnnounce(args, tab); } else if (type == "help") { - handleHelp(args); + handleHelp(args, tab); } else if (type == "where") { - handleWhere(); + handleWhere(args, tab); } else if (type == "who") { - handleWho(); + handleWho(args, tab); } else if (type == "msg" || type == "whisper" || type == "w") { - handleMsg(args); + handleMsg(args, tab); } #ifdef TMWSERV_SUPPORT else if (type == "join") { - handleJoin(args); + handleJoin(args, tab); } else if (type == "list") { - handleListChannels(); + handleListChannels(args, tab); } else if (type == "users") { - handleListUsers(); + handleListUsers(args, tab); } else if (type == "quit") { - handleQuit(); + handleQuit(args, tab); } else if (type == "topic") { - handleTopic(args); + handleTopic(args, tab); } else if (type == "clear") { - handleClear(); + handleClear(args, tab); } else if (type == "op") { - handleOp(args); + handleOp(args, tab); } else if (type == "kick") { - handleKick(args); + handleKick(args, tab); } #endif else if (type == "party") { - handleParty(args); + handleParty(args, tab); } else if (type == "me") { - handleMe(args); + handleMe(args, tab); } else if (type == "record") { - handleRecord(args); + handleRecord(args, tab); } else if (type == "toggle") { - handleToggle(args); + handleToggle(args, tab); } else if (type == "present") { - handlePresent(args); + handlePresent(args, tab); } else { - localChatTab->chatLog("Unknown command"); + tab->chatLog("Unknown command"); } } -void CommandHandler::handleAnnounce(const std::string &args) +void CommandHandler::handleAnnounce(const std::string &args, ChatTab *tab) { #ifdef TMWSERV_SUPPORT Net::ChatServer::announce(args); @@ -143,111 +143,111 @@ void CommandHandler::handleAnnounce(const std::string &args) #endif } -void CommandHandler::handleHelp(const std::string &args) +void CommandHandler::handleHelp(const std::string &args, ChatTab *tab) { if (args == "") { - localChatTab->chatLog(_("-- Help --")); - localChatTab->chatLog(_("/help > Display this help.")); + tab->chatLog(_("-- Help --")); + tab->chatLog(_("/help > Display this help.")); - localChatTab->chatLog(_("/where > Display map name")); - localChatTab->chatLog(_("/who > Display number of online users")); - localChatTab->chatLog(_("/me > Tell something about yourself")); + tab->chatLog(_("/where > Display map name")); + tab->chatLog(_("/who > Display number of online users")); + tab->chatLog(_("/me > Tell something about yourself")); - localChatTab->chatLog(_("/msg > Send a private message to a user")); - localChatTab->chatLog(_("/whisper > Alias of msg")); - localChatTab->chatLog(_("/w > Alias of msg")); - localChatTab->chatLog(_("/close > Close the whisper tab (only works in whisper tabs)")); + tab->chatLog(_("/msg > Send a private message to a user")); + tab->chatLog(_("/whisper > Alias of msg")); + tab->chatLog(_("/w > Alias of msg")); + tab->chatLog(_("/close > Close the whisper tab (only works in whisper tabs)")); #ifdef TMWSERV_SUPPORT - localChatTab->chatLog(_("/list > Display all public channels")); - localChatTab->chatLog(_("/users > Lists the users in the current channel")); - localChatTab->chatLog(_("/join > Join or create a channel")); - localChatTab->chatLog(_("/topic > Set the topic of the current channel")); - localChatTab->chatLog(_("/quit > Leave a channel")); - localChatTab->chatLog(_("/clear > Clears this window")); - localChatTab->chatLog(_("/op > Make a user a channel operator")); - localChatTab->chatLog(_("/kick > Kick a user from the channel")); - - localChatTab->chatLog(_("/party > Invite a user to party")); + tab->chatLog(_("/list > Display all public channels")); + tab->chatLog(_("/users > Lists the users in the current channel")); + tab->chatLog(_("/join > Join or create a channel")); + tab->chatLog(_("/topic > Set the topic of the current channel")); + tab->chatLog(_("/quit > Leave a channel")); + tab->chatLog(_("/clear > Clears this window")); + tab->chatLog(_("/op > Make a user a channel operator")); + tab->chatLog(_("/kick > Kick a user from the channel")); + + tab->chatLog(_("/party > Invite a user to party")); #else - localChatTab->chatLog(_("/party > Party-related commands")); + tab->chatLog(_("/party > Party-related commands")); #endif - localChatTab->chatLog(_("/record > Start recording the chat to an external file")); - localChatTab->chatLog(_("/toggle > Determine whether toggles the chat log")); - localChatTab->chatLog(_("/present > Get list of players present (sent to chat log, if logging)")); + tab->chatLog(_("/record > Start recording the chat to an external file")); + tab->chatLog(_("/toggle > Determine whether toggles the chat log")); + tab->chatLog(_("/present > Get list of players present (sent to chat log, if logging)")); - localChatTab->chatLog(_("/announce > Global announcement (GM only)")); + tab->chatLog(_("/announce > Global announcement (GM only)")); - localChatTab->chatLog(_("For more information, type /help ")); + tab->chatLog(_("For more information, type /help ")); } else if (args == "announce") { - localChatTab->chatLog(_("Command: /announce ")); - localChatTab->chatLog(_("*** only available to a GM ***")); - localChatTab->chatLog(_("This command sends the message to " + tab->chatLog(_("Command: /announce ")); + tab->chatLog(_("*** only available to a GM ***")); + tab->chatLog(_("This command sends the message to " "all players currently online.")); } else if (args == "clear") { - localChatTab->chatLog(_("Command: /clear")); - localChatTab->chatLog(_("This command clears the chat log of previous chat.")); + tab->chatLog(_("Command: /clear")); + tab->chatLog(_("This command clears the chat log of previous chat.")); } else if (args == "help") { - localChatTab->chatLog(_("Command: /help")); - localChatTab->chatLog(_("This command displays a list of all commands available.")); - localChatTab->chatLog(_("Command: /help ")); - localChatTab->chatLog(_("This command displays help on .")); + tab->chatLog(_("Command: /help")); + tab->chatLog(_("This command displays a list of all commands available.")); + tab->chatLog(_("Command: /help ")); + tab->chatLog(_("This command displays help on .")); } else if (args == "join") { - localChatTab->chatLog(_("Command: /join ")); - localChatTab->chatLog(_("This command makes you enter .")); - localChatTab->chatLog(_("If doesn't exist, it's created.")); + tab->chatLog(_("Command: /join ")); + tab->chatLog(_("This command makes you enter .")); + tab->chatLog(_("If doesn't exist, it's created.")); } else if (args == "kick") { - localChatTab->chatLog(_("Command: /kick ")); - localChatTab->chatLog(_("This command makes leave the channel.")); - localChatTab->chatLog(_("If the has spaces in it, enclose it in " + tab->chatLog(_("Command: /kick ")); + tab->chatLog(_("This command makes leave the channel.")); + tab->chatLog(_("If the has spaces in it, enclose it in " "double quotes (\").")); } else if (args == "list") { - localChatTab->chatLog(_("Command: /list")); - localChatTab->chatLog(_("This command shows a list of all channels.")); + tab->chatLog(_("Command: /list")); + tab->chatLog(_("This command shows a list of all channels.")); } else if (args == "me") { - localChatTab->chatLog(_("Command: /me ")); - localChatTab->chatLog(_("This command tell others you are (doing) .")); + tab->chatLog(_("Command: /me ")); + tab->chatLog(_("This command tell others you are (doing) .")); } else if (args == "msg" || args == "whisper" || args == "w") { - localChatTab->chatLog(_("Command: /msg ")); - localChatTab->chatLog(_("Command: /whisper ")); - localChatTab->chatLog(_("Command: /w ")); - localChatTab->chatLog(_("This command sends the text to .")); - localChatTab->chatLog(_("If the has spaces in it, enclose it in " + tab->chatLog(_("Command: /msg ")); + tab->chatLog(_("Command: /whisper ")); + tab->chatLog(_("Command: /w ")); + tab->chatLog(_("This command sends the text to .")); + tab->chatLog(_("If the has spaces in it, enclose it in " "double quotes (\").")); } else if (args == "op") { - localChatTab->chatLog(_("Command: /op ")); - localChatTab->chatLog(_("This command makes a channel operator.")); - localChatTab->chatLog(_("If the has spaces in it, enclose it in " + tab->chatLog(_("Command: /op ")); + tab->chatLog(_("This command makes a channel operator.")); + tab->chatLog(_("If the has spaces in it, enclose it in " "double quotes (\").")); - localChatTab->chatLog(_("Channel operators can kick and op other users " + tab->chatLog(_("Channel operators can kick and op other users " "from the channel.")); } #ifdef TMWSERV_SUPPORT else if (args == "party") { - localChatTab->chatLog(_("Command: /party ")); - localChatTab->chatLog(_("This command invites to party with you.")); - localChatTab->chatLog(_("If the has spaces in it, enclose it in " + tab->chatLog(_("Command: /party ")); + tab->chatLog(_("This command invites to party with you.")); + tab->chatLog(_("If the has spaces in it, enclose it in " "double quotes (\").")); #else else if (args.substr(0, 5) == "party") @@ -257,71 +257,71 @@ void CommandHandler::handleHelp(const std::string &args) } else if (args == "present") { - localChatTab->chatLog(_("Command: /present")); - localChatTab->chatLog(_("This command gets a list of players within hearing and " + tab->chatLog(_("Command: /present")); + tab->chatLog(_("This command gets a list of players within hearing and " "sends it to either the record log if recording, or the chat " "log otherwise.")); } else if (args == "quit") { - localChatTab->chatLog(_("Command: /quit")); - localChatTab->chatLog(_("This command leaves the current channel.")); - localChatTab->chatLog(_("If you're the last person in the channel, it will be deleted.")); + tab->chatLog(_("Command: /quit")); + tab->chatLog(_("This command leaves the current channel.")); + tab->chatLog(_("If you're the last person in the channel, it will be deleted.")); } else if (args == "record") { - localChatTab->chatLog(_("Command: /record ")); - localChatTab->chatLog(_("This command starts recording the chat log to the file " + tab->chatLog(_("Command: /record ")); + tab->chatLog(_("This command starts recording the chat log to the file " ".")); - localChatTab->chatLog(_("Command: /record")); - localChatTab->chatLog(_("This command finishes a recording session.")); + tab->chatLog(_("Command: /record")); + tab->chatLog(_("This command finishes a recording session.")); } else if (args == "toggle") { - localChatTab->chatLog(_("Command: /toggle ")); - localChatTab->chatLog(_("This command sets whether the return key should toggle the " + tab->chatLog(_("Command: /toggle ")); + tab->chatLog(_("This command sets whether the return key should toggle the " "chat log, or whether the chat log turns off automatically.")); - localChatTab->chatLog(_(" can be one of \"1\", \"yes\", \"true\" to " + tab->chatLog(_(" can be one of \"1\", \"yes\", \"true\" to " "turn the toggle on, or \"0\", \"no\", \"false\" to turn the " "toggle off.")); - localChatTab->chatLog(_("Command: /toggle")); - localChatTab->chatLog(_("This command displays the return toggle status.")); + tab->chatLog(_("Command: /toggle")); + tab->chatLog(_("This command displays the return toggle status.")); } else if (args == "topic") { - localChatTab->chatLog(_("Command: /topic ")); - localChatTab->chatLog(_("This command sets the topic to .")); + tab->chatLog(_("Command: /topic ")); + tab->chatLog(_("This command sets the topic to .")); } else if (args == "users") { - localChatTab->chatLog(_("Command: /users ")); - localChatTab->chatLog(_("This command shows the users in .")); + tab->chatLog(_("Command: /users ")); + tab->chatLog(_("This command shows the users in .")); } else if (args == "where") { - localChatTab->chatLog(_("Command: /where")); - localChatTab->chatLog(_("This command displays the name of the current map.")); + tab->chatLog(_("Command: /where")); + tab->chatLog(_("This command displays the name of the current map.")); } else if (args == "who") { - localChatTab->chatLog(_("Command: /who")); - localChatTab->chatLog(_("This command displays the number of players currently " + tab->chatLog(_("Command: /who")); + tab->chatLog(_("This command displays the number of players currently " "online.")); } else { - localChatTab->chatLog(_("Unknown command.")); - localChatTab->chatLog(_("Type /help for a list of commands.")); + tab->chatLog(_("Unknown command.")); + tab->chatLog(_("Type /help for a list of commands.")); } } -void CommandHandler::handleWhere() +void CommandHandler::handleWhere(const std::string &args, ChatTab *tab) { // TODO: add position - localChatTab->chatLog(map_path, BY_SERVER); + tab->chatLog(map_path, BY_SERVER); } -void CommandHandler::handleWho() +void CommandHandler::handleWho(const std::string &args, ChatTab *tab) { #ifdef TMWSERV_SUPPORT //TODO @@ -330,7 +330,7 @@ void CommandHandler::handleWho() #endif } -void CommandHandler::handleMsg(const std::string &args) +void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) { std::string recvnick = ""; std::string msg = ""; @@ -377,67 +377,67 @@ void CommandHandler::handleMsg(const std::string &args) chatWindow->whisper(recvnick, msg, true); } else - localChatTab->chatLog("Cannont send empty whispers!"); + tab->chatLog("Cannont send empty whispers!"); } -void CommandHandler::handleClear() +void CommandHandler::handleClear(const std::string &args, ChatTab *tab) { chatWindow->clearTab(); } #ifdef TMWSERV_SUPPORT -void CommandHandler::handleJoin(const std::string &args) +void CommandHandler::handleJoin(const std::string &args, ChatTab *tab) { std::string::size_type pos = args.find(' '); std::string name(args, 0, pos); std::string password(args, pos+1); - localChatTab->chatLog("Requesting to join channel " + name); + tab->chatLog("Requesting to join channel " + name); Net::ChatServer::enterChannel(name, password); } -void CommandHandler::handleListChannels() +void CommandHandler::handleListChannels(const std::string &args, ChatTab *tab) { Net::ChatServer::getChannelList(); } -void CommandHandler::handleListUsers() +void CommandHandler::handleListUsers(const std::string &args, ChatTab *tab) { Net::ChatServer::getUserList(chatWindow->getFocused()->getCaption()); } -void CommandHandler::handleTopic(const std::string &args) +void CommandHandler::handleTopic(const std::string &args, ChatTab *tab) { - ChannelTab *tab = dynamic_cast(chatWindow->getFocused()); - Channel *channel = tab ? tab->getChannel() : NULL; + ChannelTab *channelTab = dynamic_cast(tab); + Channel *channel = channelTab ? channelTab->getChannel() : NULL; if (channel) { Net::ChatServer::setChannelTopic(channel->getId(), args); } else { - localChatTab->chatLog("Unable to set this channel's topic", BY_CHANNEL); + tab->chatLog("Unable to set this channel's topic", BY_CHANNEL); } } -void CommandHandler::handleQuit() +void CommandHandler::handleQuit(const std::string &args, ChatTab *tab) { - ChannelTab *tab = dynamic_cast(chatWindow->getFocused()); - Channel *channel = tab ? tab->getChannel() : NULL; + ChannelTab *channelTab = dynamic_cast(tab); + Channel *channel = channelTab ? channelTab->getChannel() : NULL; if (channel) { Net::ChatServer::quitChannel(channel->getId()); } else { - localChatTab->chatLog("Unable to quit this channel", BY_CHANNEL); + tab->chatLog("Unable to quit this channel", BY_CHANNEL); } } -void CommandHandler::handleOp(const std::string &args) +void CommandHandler::handleOp(const std::string &args, ChatTab *tab) { - ChannelTab *tab = dynamic_cast(chatWindow->getFocused()); - Channel *channel = tab ? tab->getChannel() : NULL; + ChannelTab *channelTab = dynamic_cast(tab); + Channel *channel = channelTab ? channelTab->getChannel() : NULL; if (channel) { // set the user mode 'o' to op a user @@ -448,14 +448,14 @@ void CommandHandler::handleOp(const std::string &args) } else { - localChatTab->chatLog("Unable to set this user's mode", BY_CHANNEL); + tab->chatLog("Unable to set this user's mode", BY_CHANNEL); } } -void CommandHandler::handleKick(const std::string &args) +void CommandHandler::handleKick(const std::string &args, ChatTab *tab) { - ChannelTab *tab = dynamic_cast(chatWindow->getFocused()); - Channel *channel = tab ? tab->getChannel() : NULL; + ChannelTab *channelTab = dynamic_cast(tab); + Channel *channel = channelTab ? channelTab->getChannel() : NULL; if (channel) { if (args != "") @@ -465,13 +465,13 @@ void CommandHandler::handleKick(const std::string &args) } else { - localChatTab->chatLog("Unable to kick user", BY_CHANNEL); + tab->chatLog("Unable to kick user", BY_CHANNEL); } } #endif -void CommandHandler::handleParty(const std::string &args) +void CommandHandler::handleParty(const std::string &args, ChatTab *tab) { #ifdef TMWSERV_SUPPORT if (args != "") @@ -481,7 +481,7 @@ void CommandHandler::handleParty(const std::string &args) #else if (args.empty()) { - localChatTab->chatLog(_("Unknown party command... Type \"/help\" party for more " + tab->chatLog(_("Unknown party command... Type \"/help\" party for more " "information."), BY_SERVER); return; } @@ -506,22 +506,22 @@ void CommandHandler::handleParty(const std::string &args) { char temp[2] = "."; *temp = chatWindow->getPartyPrefix(); - localChatTab->chatLog(_("The current party prefix is ") + std::string(temp)); + tab->chatLog(_("The current party prefix is ") + std::string(temp)); } else if (rest.length() != 1) { - localChatTab->chatLog(_("Party prefix must be one character long.")); + tab->chatLog(_("Party prefix must be one character long.")); } else { if (rest == "/") { - localChatTab->chatLog(_("Cannot use a '/' as the prefix.")); + tab->chatLog(_("Cannot use a '/' as the prefix.")); } else { chatWindow->setPartyPrefix(rest.at(0)); - localChatTab->chatLog(_("Changing prefix to ") + rest); + tab->chatLog(_("Changing prefix to ") + rest); } } } @@ -530,22 +530,22 @@ void CommandHandler::handleParty(const std::string &args) #endif } -void CommandHandler::handleMe(const std::string &args) +void CommandHandler::handleMe(const std::string &args, ChatTab *tab) { std::string action = strprintf("*%s*", args.c_str()); chatWindow->chatInput(action); } -void CommandHandler::handleRecord(const std::string &args) +void CommandHandler::handleRecord(const std::string &args, ChatTab *tab) { chatWindow->setRecordingFile(args); } -void CommandHandler::handleToggle(const std::string &args) +void CommandHandler::handleToggle(const std::string &args, ChatTab *tab) { if (args.empty()) { - localChatTab->chatLog(chatWindow->getReturnTogglesChat() ? + tab->chatLog(chatWindow->getReturnTogglesChat() ? _("Return toggles chat.") : _("Message closes chat.")); return; } @@ -556,7 +556,7 @@ void CommandHandler::handleToggle(const std::string &args) opt == "y" || opt == "Y" || opt == "t" || opt == "T") { - localChatTab->chatLog(_("Return now toggles chat.")); + tab->chatLog(_("Return now toggles chat.")); chatWindow->setReturnTogglesChat(true); return; } @@ -564,16 +564,16 @@ void CommandHandler::handleToggle(const std::string &args) opt == "n" || opt == "N" || opt == "f" || opt == "F") { - localChatTab->chatLog(_("Message now closes chat.")); + tab->chatLog(_("Message now closes chat.")); chatWindow->setReturnTogglesChat(false); return; } else - localChatTab->chatLog(_("Options to /toggle are \"yes\", \"no\", \"true\", " + tab->chatLog(_("Options to /toggle are \"yes\", \"no\", \"true\", " "\"false\", \"1\", \"0\".")); } -void CommandHandler::handlePresent(const std::string &args) +void CommandHandler::handlePresent(const std::string &args, ChatTab *tab) { chatWindow->doPresent(); } diff --git a/src/commandhandler.h b/src/commandhandler.h index 43ce172f..b9b61647 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -24,6 +24,10 @@ #include +class ChatTab; + +extern ChatTab *localChatTab; + /** * A class to parse and handle user commands */ @@ -43,98 +47,98 @@ class CommandHandler /** * Parse and handle the given command. */ - void handleCommand(const std::string &command); + void handleCommand(const std::string &command, ChatTab *tab = localChatTab); private: /** * Handle an announce command. */ - void handleAnnounce(const std::string &args); + void handleAnnounce(const std::string &args, ChatTab *tab); /** * Handle a help command. */ - void handleHelp(const std::string &args); + void handleHelp(const std::string &args, ChatTab *tab); /** * Handle a where command. */ - void handleWhere(); + void handleWhere(const std::string &args, ChatTab *tab); /** * Handle a who command. */ - void handleWho(); + void handleWho(const std::string &args, ChatTab *tab); /** * Handle a msg command. */ - void handleMsg(const std::string &args); + void handleMsg(const std::string &args, ChatTab *tab); /** * Handle a join command. */ - void handleJoin(const std::string &args); + void handleJoin(const std::string &args, ChatTab *tab); /** * Handle a listchannels command. */ - void handleListChannels(); + void handleListChannels(const std::string &args, ChatTab *tab); /** * Handle a listusers command. */ - void handleListUsers(); + void handleListUsers(const std::string &args, ChatTab *tab); /** * Handle a topic command. */ - void handleTopic(const std::string &args); + void handleTopic(const std::string &args, ChatTab *tab); /** * Handle a quit command. */ - void handleQuit(); + void handleQuit(const std::string &args, ChatTab *tab); /** * Handle a clear command. */ - void handleClear(); + void handleClear(const std::string &args, ChatTab *tab); /** * Handle a party command. */ - void handleParty(const std::string &args); + void handleParty(const std::string &args, ChatTab *tab); /** * Handle a op command. */ - void handleOp(const std::string &args); + void handleOp(const std::string &args, ChatTab *tab); /** * Handle a kick command. */ - void handleKick(const std::string &args); + void handleKick(const std::string &args, ChatTab *tab); /** * Handle a me command. */ - void handleMe(const std::string &args); + void handleMe(const std::string &args, ChatTab *tab); /** * Handle a record command. */ - void handleRecord(const std::string &args); + void handleRecord(const std::string &args, ChatTab *tab); /** * Handle a toggle command. */ - void handleToggle(const std::string &args); + void handleToggle(const std::string &args, ChatTab *tab); /** * Handle a present command. */ - void handlePresent(const std::string &args); + void handlePresent(const std::string &args, ChatTab *tab); }; extern CommandHandler *commandHandler; diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 398b5792..10993027 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -316,12 +316,12 @@ void ChatWindow::doPresent() mRecorder->record(timeStr.str() + _("Present: ") + response + "."); - localChatTab->chatLog(_("Attendance written to record log."), + getFocused()->chatLog(_("Attendance written to record log."), BY_SERVER, true); } else { - localChatTab->chatLog(_("Present: ") + response, BY_SERVER); + getFocused()->chatLog(_("Present: ") + response, BY_SERVER); } } diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 95606281..c4563cc9 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -314,5 +314,5 @@ void ChatTab::handleInput(const std::string &msg) { void ChatTab::handleCommand(std::string msg) { - commandHandler->handleCommand(msg); + commandHandler->handleCommand(msg, this); } -- cgit v1.2.3-70-g09d2