diff options
author | Chuck Miller <shadowmil@gmail.com> | 2010-07-18 23:02:25 -0400 |
---|---|---|
committer | Chuck Miller <shadowmil@gmail.com> | 2010-07-18 23:10:02 -0400 |
commit | 41a23cb4511e9ba3985990e2703fb3d680a23d14 (patch) | |
tree | 2bf03217e3c3b0f28aed5649e2e43cf2b965bd1d /src/net/tmwa | |
parent | 782158dfd719fb6d196f79075f275fb8599d393c (diff) | |
download | Mana-41a23cb4511e9ba3985990e2703fb3d680a23d14.tar.gz Mana-41a23cb4511e9ba3985990e2703fb3d680a23d14.tar.bz2 Mana-41a23cb4511e9ba3985990e2703fb3d680a23d14.tar.xz Mana-41a23cb4511e9ba3985990e2703fb3d680a23d14.zip |
Move the majority of the netcode's server messages to the event system
There is still a good way to go, but this should get us
started
Reviewed-by: Jared Adams
Diffstat (limited to 'src/net/tmwa')
-rw-r--r-- | src/net/tmwa/adminhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/tmwa/buysellhandler.cpp | 14 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.cpp | 18 | ||||
-rw-r--r-- | src/net/tmwa/gamehandler.cpp | 6 | ||||
-rw-r--r-- | src/net/tmwa/guildhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.cpp | 15 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 19 | ||||
-rw-r--r-- | src/net/tmwa/tradehandler.cpp | 40 |
9 files changed, 65 insertions, 68 deletions
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp index da089b2b..330708db 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -23,11 +23,11 @@ #include "actorspritemanager.h" #include "being.h" +#include "event.h" +#include "eventmanager.h" #include "game.h" #include "playerrelations.h" -#include "gui/widgets/chattab.h" - #include "net/chathandler.h" #include "net/net.h" @@ -60,9 +60,9 @@ void AdminHandler::handleMessage(Net::MessageIn &msg) case SMSG_ADMIN_KICK_ACK: id = msg.readInt32(); if (id == 0) - localChatTab->chatLog(_("Kick failed!"), BY_SERVER); + SERVER_NOTICE(_("Kick failed!")) else - localChatTab->chatLog(_("Kick succeeded!"), BY_SERVER); + SERVER_NOTICE(_("Kick succeeded!")) break; } } diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp index d0c8fd40..03480e45 100644 --- a/src/net/tmwa/buysellhandler.cpp +++ b/src/net/tmwa/buysellhandler.cpp @@ -22,6 +22,8 @@ #include "net/tmwa/buysellhandler.h" #include "actorspritemanager.h" +#include "event.h" +#include "eventmanager.h" #include "inventory.h" #include "item.h" #include "localplayer.h" @@ -31,8 +33,6 @@ #include "gui/buysell.h" #include "gui/sell.h" -#include "gui/widgets/chattab.h" - #include "net/messagein.h" #include "net/tmwa/protocol.h" @@ -107,29 +107,29 @@ void BuySellHandler::handleMessage(Net::MessageIn &msg) } else { - localChatTab->chatLog(_("Nothing to sell."), BY_SERVER); + SERVER_NOTICE(_("Nothing to sell.")) } break; case SMSG_NPC_BUY_RESPONSE: if (msg.readInt8() == 0) { - localChatTab->chatLog(_("Thanks for buying."), BY_SERVER); + SERVER_NOTICE(_("Thanks for buying.")) } else { // Reset player money since buy dialog already assumed purchase // would go fine mBuyDialog->setMoney(PlayerInfo::getAttribute(MONEY)); - localChatTab->chatLog(_("Unable to buy."), BY_SERVER); + SERVER_NOTICE(_("Unable to buy.")) } break; case SMSG_NPC_SELL_RESPONSE: if (msg.readInt8() == 0) - localChatTab->chatLog(_("Thanks for selling."), BY_SERVER); + SERVER_NOTICE(_("Thanks for selling.")) else - localChatTab->chatLog(_("Unable to sell."), BY_SERVER); + SERVER_NOTICE(_("Unable to sell.")) break; } diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 53af2e6b..13879152 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -23,6 +23,8 @@ #include "actorspritemanager.h" #include "being.h" +#include "event.h" +#include "eventmanager.h" #include "game.h" #include "localplayer.h" #include "playerrelations.h" @@ -212,43 +214,43 @@ void ChatHandler::privateMessage(const std::string &recipient, void ChatHandler::channelList() { - localChatTab->chatLog(_("Channels are not supported!"), BY_SERVER); + SERVER_NOTICE(_("Channels are not supported!")) } void ChatHandler::enterChannel(const std::string &channel, const std::string &password) { - localChatTab->chatLog(_("Channels are not supported!"), BY_SERVER); + SERVER_NOTICE(_("Channels are not supported!")) } void ChatHandler::quitChannel(int channelId) { - localChatTab->chatLog(_("Channels are not supported!"), BY_SERVER); + SERVER_NOTICE(_("Channels are not supported!")) } void ChatHandler::sendToChannel(int channelId, const std::string &text) { - localChatTab->chatLog(_("Channels are not supported!"), BY_SERVER); + SERVER_NOTICE(_("Channels are not supported!")) } void ChatHandler::userList(const std::string &channel) { - localChatTab->chatLog(_("Channels are not supported!"), BY_SERVER); + SERVER_NOTICE(_("Channels are not supported!")) } void ChatHandler::setChannelTopic(int channelId, const std::string &text) { - localChatTab->chatLog(_("Channels are not supported!"), BY_SERVER); + SERVER_NOTICE(_("Channels are not supported!")) } void ChatHandler::setUserMode(int channelId, const std::string &name, int mode) { - localChatTab->chatLog(_("Channels are not supported!"), BY_SERVER); + SERVER_NOTICE(_("Channels are not supported!")) } void ChatHandler::kickUser(int channelId, const std::string &name) { - localChatTab->chatLog(_("Channels are not supported!"), BY_SERVER); + SERVER_NOTICE(_("Channels are not supported!")) } void ChatHandler::who() diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index 4810a3ea..183c2c8a 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -23,12 +23,11 @@ #include "client.h" #include "event.h" +#include "eventmanager.h" #include "game.h" #include "localplayer.h" #include "log.h" -#include "gui/widgets/chattab.h" - #include "gui/okdialog.h" #include "net/messagein.h" @@ -87,8 +86,7 @@ void GameHandler::handleMessage(Net::MessageIn &msg) break; case SMSG_WHO_ANSWER: - localChatTab->chatLog(strprintf(_("Online users: %d"), - msg.readInt32()), BY_SERVER); + SERVER_NOTICE(strprintf(_("Online users: %d"), msg.readInt32())) break; case SMSG_CHAR_SWITCH_RESPONSE: diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index 3d3b0ab2..21cf9c32 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -21,6 +21,8 @@ #include "net/tmwa/guildhandler.h" #include "guild.h" +#include "event.h" +#include "eventmanager.h" #include "localplayer.h" #include "log.h" @@ -387,8 +389,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg) void GuildHandler::create(const std::string &name) { - localChatTab->chatLog(_("Guild creation isn't supported yet."), - BY_SERVER); + SERVER_NOTICE(_("Guild creation isn't supported yet.")) return; MessageOut msg(CMSG_GUILD_CREATE); diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 41049c3d..7b019085 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -23,6 +23,8 @@ #include "configuration.h" #include "equipment.h" +#include "event.h" +#include "eventmanager.h" #include "inventory.h" #include "item.h" #include "itemshortcut.h" @@ -276,7 +278,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) if (msg.readInt8() == 0) { - localChatTab->chatLog(_("Failed to use item."), BY_SERVER); + SERVER_NOTICE(_("Failed to use item.")) } else { @@ -386,7 +388,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) flag = msg.readInt8(); if (!flag) - localChatTab->chatLog(_("Unable to equip."), BY_SERVER); + SERVER_NOTICE(_("Unable to equip.")) else mEquips.setEquipment(getSlot(equipType), index); break; @@ -397,7 +399,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) flag = msg.readInt8(); if (!flag) - localChatTab->chatLog(_("Unable to unequip."), BY_SERVER); + SERVER_NOTICE(_("Unable to unequip.")) else mEquips.setEquipment(getSlot(equipType), -1); break; diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 820331e8..7f8dca0f 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -21,6 +21,8 @@ #include "net/tmwa/partyhandler.h" #include "actorspritemanager.h" +#include "event.h" +#include "eventmanager.h" #include "localplayer.h" #include "log.h" @@ -78,12 +80,9 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) { case SMSG_PARTY_CREATE: if (msg.readInt8()) - localChatTab->chatLog(_("Could not create party."), BY_SERVER); + SERVER_NOTICE(_("Could not create party.")) else - { - localChatTab->chatLog(_("Party successfully created."), - BY_SERVER); - } + SERVER_NOTICE(_("Party successfully created.")) break; case SMSG_PARTY_INFO: { @@ -235,8 +234,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) { taParty->removeFromMembers(); taParty->clearMembers(); - localChatTab->chatLog(_("You have left the party."), - BY_SERVER); + SERVER_NOTICE(_("You have left the party.")) if (partyTab) { delete partyTab; @@ -330,8 +328,7 @@ void PartyHandler::invite(const std::string &name) } else { - localChatTab->chatLog(_("You can only inivte when you are in a party!"), - BY_SERVER); + SERVER_NOTICE(_("You can only inivte when you are in a party!")) } // TODO? diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 0ada96d7..0388573f 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -21,6 +21,8 @@ #include "net/tmwa/playerhandler.h" +#include "event.h" +#include "eventmanager.h" #include "game.h" #include "localplayer.h" #include "log.h" @@ -36,8 +38,6 @@ #include "gui/statuswindow.h" #include "gui/viewport.h" -#include "gui/widgets/chattab.h" - #include "net/messagein.h" #include "net/messageout.h" @@ -308,10 +308,9 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) int oldMoney = PlayerInfo::getAttribute(MONEY); int newMoney = msg.readInt32(); if (newMoney > oldMoney) - localChatTab->chatLog(strprintf(_("You picked up " - "%s."), - Units::formatCurrency(newMoney - oldMoney).c_str()), - BY_SERVER); + SERVER_NOTICE(strprintf(_("You picked up %s."), + Units::formatCurrency(newMoney - + oldMoney).c_str())) } break; case 0x0016: @@ -344,8 +343,7 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) if (ok != 1) { - localChatTab->chatLog(_("Cannot raise skill!"), - BY_SERVER); + SERVER_NOTICE(_("Cannot raise skill!")) } PlayerInfo::setStatBase(type, value); @@ -484,8 +482,9 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) switch (type) { case 0: - localChatTab->chatLog(_("Equip arrows first."), - BY_SERVER); + { + SERVER_NOTICE(_("Equip arrows first.")) + } break; default: logger->log("0x013b: Unhandled message %i", type); diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index 2c82f1e2..0610f5be 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -21,6 +21,8 @@ #include "net/tmwa/tradehandler.h" +#include "event.h" +#include "eventmanager.h" #include "inventory.h" #include "item.h" #include "localplayer.h" @@ -30,8 +32,6 @@ #include "gui/confirmdialog.h" #include "gui/trade.h" -#include "gui/widgets/chattab.h" - #include "net/inventoryhandler.h" #include "net/messagein.h" #include "net/messageout.h" @@ -122,16 +122,16 @@ void TradeHandler::handleMessage(Net::MessageIn &msg) switch (msg.readInt8()) { case 0: // Too far away - localChatTab->chatLog(_("Trading isn't possible. Trade " - "partner is too far away."), BY_SERVER); + SERVER_NOTICE(_("Trading isn't possible. Trade " + "partner is too far away.")) break; case 1: // Character doesn't exist - localChatTab->chatLog(_("Trading isn't possible. Character " - "doesn't exist."), BY_SERVER); + SERVER_NOTICE(_("Trading isn't possible. Character " + "doesn't exist.")) break; case 2: // Invite request check failed... - localChatTab->chatLog(_("Trade cancelled due to an unknown " - "reason."), BY_SERVER); + SERVER_NOTICE(_("Trade cancelled due to an unknown " + "reason.")) break; case 3: // Trade accepted tradeWindow->reset(); @@ -142,17 +142,15 @@ void TradeHandler::handleMessage(Net::MessageIn &msg) case 4: // Trade cancelled if (player_relations.hasPermission(tradePartnerName, PlayerRelation::SPEECH_LOG)) - localChatTab->chatLog(strprintf(_("Trade with %s " - "cancelled."), tradePartnerName.c_str()), - BY_SERVER); + SERVER_NOTICE(strprintf(_("Trade with %s cancelled."), + tradePartnerName.c_str())) // otherwise ignore silently tradeWindow->setVisible(false); PlayerInfo::setTrading(false); break; default: // Shouldn't happen as well, but to be sure - localChatTab->chatLog(_("Unhandled trade cancel packet."), - BY_SERVER); + SERVER_NOTICE(_("Unhandled trade cancel packet.")) break; } break; @@ -200,17 +198,17 @@ void TradeHandler::handleMessage(Net::MessageIn &msg) break; case 1: // Add item failed - player overweighted - localChatTab->chatLog(_("Failed adding item. Trade " - "partner is over weighted."), BY_SERVER); + SERVER_NOTICE(_("Failed adding item. Trade " + "partner is over weighted.")) break; case 2: // Add item failed - player has no free slot - localChatTab->chatLog(_("Failed adding item. Trade " - "partner has no free slot."), BY_SERVER); + SERVER_NOTICE(_("Failed adding item. Trade " + "partner has no free slot.")) break; default: - localChatTab->chatLog(_("Failed adding item for " - "unknown reason."), BY_SERVER); + SERVER_NOTICE(_("Failed adding item for " + "unknown reason.")) break; } } @@ -222,14 +220,14 @@ void TradeHandler::handleMessage(Net::MessageIn &msg) break; case SMSG_TRADE_CANCEL: - localChatTab->chatLog(_("Trade canceled."), BY_SERVER); + SERVER_NOTICE(_("Trade canceled.")) tradeWindow->setVisible(false); tradeWindow->reset(); PlayerInfo::setTrading(false); break; case SMSG_TRADE_COMPLETE: - localChatTab->chatLog(_("Trade completed."), BY_SERVER); + SERVER_NOTICE(_("Trade completed.")) tradeWindow->setVisible(false); tradeWindow->reset(); PlayerInfo::setTrading(false); |