diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-09-17 13:51:37 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-09-17 13:51:37 +0000 |
commit | e846d4502b59a1a3b8d658a37ae5b5ce4aa1c00c (patch) | |
tree | 8feb8b51d731057412a59aeddbbe83b75b09912a /src/gui | |
parent | 3bfcee0d9c033a46fe1b13795d89909c8fb6a239 (diff) | |
download | mana-e846d4502b59a1a3b8d658a37ae5b5ce4aa1c00c.tar.gz mana-e846d4502b59a1a3b8d658a37ae5b5ce4aa1c00c.tar.bz2 mana-e846d4502b59a1a3b8d658a37ae5b5ce4aa1c00c.tar.xz mana-e846d4502b59a1a3b8d658a37ae5b5ce4aa1c00c.zip |
Completed transition to use MessageOut.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/buy.cpp | 11 | ||||
-rw-r--r-- | src/gui/buysell.cpp | 12 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 38 | ||||
-rw-r--r-- | src/gui/char_server.cpp | 14 | ||||
-rw-r--r-- | src/gui/chat.cpp | 20 | ||||
-rw-r--r-- | src/gui/npc.cpp | 41 | ||||
-rw-r--r-- | src/gui/npc_text.cpp | 10 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 19 | ||||
-rw-r--r-- | src/gui/requesttrade.cpp | 22 | ||||
-rw-r--r-- | src/gui/sell.cpp | 13 | ||||
-rw-r--r-- | src/gui/skill.cpp | 7 | ||||
-rw-r--r-- | src/gui/status.cpp | 42 | ||||
-rw-r--r-- | src/gui/trade.cpp | 27 |
13 files changed, 168 insertions, 108 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 3a32824a..c825c82e 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -38,7 +38,9 @@ #include "../resources/iteminfo.h" #include "../resources/itemmanager.h" +#include "../net/messageout.h" #include "../net/network.h" +#include "../net/protocol.h" BuyDialog::BuyDialog(): @@ -235,10 +237,11 @@ void BuyDialog::action(const std::string& eventId) // there a better way to ensure this fails in an _obivous_ way in C++? else if (eventId == "buy" && (m_amountItems > 0 && m_amountItems <= m_maxItems)) { - writeWord(0, 0x00c8); - writeWord(2, 8); - writeWord(4, m_amountItems); - writeWord(6, shopInventory[selectedItem].id); + MessageOut outMsg; + outMsg.writeShort(CMSG_NPC_BUY_REQUEST); + outMsg.writeShort(8); + outMsg.writeShort(m_amountItems); + outMsg.writeShort(shopInventory[selectedItem].id); writeSet(8); // update money ! diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index 6a56e67f..47777ca0 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -22,9 +22,14 @@ */ #include "buysell.h" + #include "button.h" + #include "../game.h" + +#include "../net/messageout.h" #include "../net/network.h" +#include "../net/protocol.h" BuySellDialog::BuySellDialog(): Window("Shop") @@ -77,9 +82,10 @@ void BuySellDialog::action(const std::string& eventId) current_npc = 0; } if (actionId > -1) { - writeWord(0, 0x00c5); - writeLong(2, current_npc); - writeByte(6, actionId); + MessageOut outMsg; + outMsg.writeShort(CMSG_NPC_BUY_SELL_REQUEST); + outMsg.writeLong(current_npc); + outMsg.writeByte(actionId); writeSet(7); } diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 44165707..4b52f49e 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -41,9 +41,12 @@ #include "../playerinfo.h" #include "../net/messagein.h" +#include "../net/messageout.h" #include "../net/network.h" #include "../net/protocol.h" + + CharSelectDialog::CharDeleteConfirm::CharDeleteConfirm(CharSelectDialog *m): ConfirmDialog(m, "Confirm", "Are you sure you want to delete this character?"), @@ -192,8 +195,10 @@ void CharSelectDialog::setPlayerInfo(PLAYER_INFO *pi) void CharSelectDialog::serverCharDelete() { // Request character deletion - writeWord(0, 0x0068); - writeLong(2, char_info[0]->id); + MessageOut outMsg; + outMsg.writeShort(0x0068); + outMsg.writeLong(char_info[0]->id); + outMsg.writeString("a@a.com", 40); writeSet(46); MessageIn msg = get_next_message(); @@ -221,8 +226,9 @@ void CharSelectDialog::serverCharDelete() void CharSelectDialog::serverCharSelect() { // Request character selection - writeWord(0, 0x0066); - writeByte(2, 0); + MessageOut outMsg; + outMsg.writeShort(0x0066); + outMsg.writeByte(0); writeSet(3); MessageIn msg = get_next_message(); @@ -407,17 +413,19 @@ std::string CharCreateDialog::getName() void CharCreateDialog::serverCharCreate() { - writeWord(0, 0x0067); - strcpy(writePointer(2), getName().c_str()); - writeByte(26, 5); - writeByte(27, 5); - writeByte(28, 5); - writeByte(29, 5); - writeByte(30, 5); - writeByte(31, 5); - writeByte(32, 0); - writeWord(33, playerBox->hairColor + 1); - writeWord(35, playerBox->hairStyle + 1); + // Send character infos + MessageOut outMsg; + outMsg.writeShort(0x0067); + outMsg.writeString(getName(), 24); + outMsg.writeByte(5); + outMsg.writeByte(5); + outMsg.writeByte(5); + outMsg.writeByte(5); + outMsg.writeByte(5); + outMsg.writeByte(5); + outMsg.writeByte(0); + outMsg.writeShort(playerBox->hairColor + 1); + outMsg.writeShort(playerBox->hairStyle + 1); writeSet(37); MessageIn msg = get_next_message(); diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index 4da8db84..3b6312e4 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -37,6 +37,7 @@ #include "../serverinfo.h" #include "../net/messagein.h" +#include "../net/messageout.h" #include "../net/network.h" extern SERVER_INFO **server_info; @@ -149,12 +150,13 @@ void server_char_server(int serverIndex) } // Send login infos - writeWord(0, 0x0065); - writeLong(2, account_ID); - writeLong(6, session_ID1); - writeLong(10, session_ID2); - writeWord(14, 0); - writeByte(16, sex); + MessageOut outMsg; + outMsg.writeShort(0x0065); + outMsg.writeLong(account_ID); + outMsg.writeLong(session_ID1); + outMsg.writeLong(session_ID2); + outMsg.writeShort(0); // unknown + outMsg.writeByte(sex); writeSet(17); // Skipping a mysterious 4 bytes diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index e6dabaaa..3ef6703c 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -31,8 +31,11 @@ #include "scrollarea.h" #include "../playerinfo.h" +#include "../log.h" +#include "../net/messageout.h" #include "../net/network.h" +#include "../net/protocol.h" ChatWindow::ChatWindow(const std::string &logfile): Window("") @@ -194,7 +197,7 @@ bool ChatWindow::isFocused() char *ChatWindow::chat_send(std::string nick, std::string msg) { - short packid = 0x008c; + short packetId = CMSG_CHAT_MESSAGE; // prepare command if (msg.substr(0, 1) == "/") { @@ -211,17 +214,16 @@ char *ChatWindow::chat_send(std::string nick, std::string msg) nick += " : "; nick += msg; msg = nick; - packid = 0x008c; + //packetId = 0x008c; } - msg += "\0"; - // send processed message - writeWord(0, packid); - writeWord(2, (unsigned short)(msg.length() + 4)); - memcpy(writePointer(4), msg.c_str(), msg.length()); - writeSet((int)msg.length()+4); - nick = msg = ""; + MessageOut outMsg; + outMsg.writeShort(packetId); + outMsg.writeShort(msg.length() + 4); + outMsg.writeString(msg, msg.length()); + writeSet(msg.length() + 4); + return ""; } diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp index c8d426f3..696b2825 100644 --- a/src/gui/npc.cpp +++ b/src/gui/npc.cpp @@ -22,11 +22,16 @@ */ #include "npc.h" + #include "button.h" #include "scrollarea.h" #include "listbox.h" + #include "../game.h" + +#include "../net/messageout.h" #include "../net/network.h" +#include "../net/protocol.h" NpcListDialog::NpcListDialog(): Window("NPC") @@ -106,27 +111,27 @@ NpcListDialog::reset() void NpcListDialog::action(const std::string& eventId) { - if (eventId == "ok") { + int choice = 0xff; // 0xff means cancel + + if (eventId == "ok") + { // Send the selected index back to the server int selectedIndex = itemList->getSelected(); - if (selectedIndex > -1) { - writeWord(0, 0x00b8); - writeLong(2, current_npc); - writeByte(6, selectedIndex + 1); - writeSet(7); - setVisible(false); - current_npc = 0; - reset(); + if (selectedIndex > -1) + { + choice = selectedIndex + 1; } } - else if (eventId == "cancel") { - // 0xff packet means cancel - writeWord(0, 0x00b8); - writeLong(2, current_npc); - writeByte(6, 0xff); - writeSet(7); - setVisible(false); - reset(); - current_npc = 0; + else if (eventId == "cancel") + { } + + MessageOut outMsg; + outMsg.writeShort(CMSG_NPC_LIST_CHOICE); + outMsg.writeLong(current_npc); + outMsg.writeByte(choice); + writeSet(7); + setVisible(false); + reset(); + current_npc = 0; } diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 67a9e9a3..8596796f 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -22,11 +22,16 @@ */ #include "npc_text.h" + #include "scrollarea.h" #include "button.h" #include "textbox.h" + #include "../game.h" + +#include "../net/messageout.h" #include "../net/network.h" +#include "../net/protocol.h" NpcTextDialog::NpcTextDialog(): Window("NPC") @@ -76,8 +81,9 @@ NpcTextDialog::addText(const std::string &text) void NpcTextDialog::action(const std::string& eventId) { - writeWord(0, 0x00b9); - writeLong(2, current_npc); + MessageOut outMsg; + outMsg.writeShort(CMSG_NPC_NEXT_REQUEST); + outMsg.writeLong(current_npc); writeSet(6); setText(""); setVisible(false); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 6a88cdfd..77f74f4c 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -40,7 +40,9 @@ #include "../inventory.h" #include "../item.h" +#include "../net/messageout.h" #include "../net/network.h" +#include "../net/protocol.h" #include "../resources/iteminfo.h" #include "../resources/itemmanager.h" @@ -130,9 +132,10 @@ void PopupMenu::handleLink(const std::string& link) if ((link == "talk") && being && being->getType() == Being::NPC && (current_npc == 0)) { - writeWord(0, 0x0090); - writeLong(2, being->getId()); - writeByte(6, 0); + MessageOut outMsg; + outMsg.writeShort(CMSG_NPC_TALK); + outMsg.writeLong(being->getId()); + outMsg.writeByte(0); writeSet(7); current_npc = being->getId(); } @@ -140,8 +143,9 @@ void PopupMenu::handleLink(const std::string& link) // Trade action else if ((link == "trade") && being && being->getType() == Being::PLAYER) { - writeWord(0, 0x00e4); - writeLong(2, being->getId()); + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_REQUEST); + outMsg.writeLong(being->getId()); writeSet(6); //tradePartner.flush(); //tradePartner << "Trade: You and " << being->name<< ""; @@ -166,8 +170,9 @@ void PopupMenu::handleLink(const std::string& link) // Pick Up Floor Item action else if ((link == "pickup") && floorItem) { - writeWord(0, 0x009f); - writeLong(2, floorItem->getId()); + MessageOut outMsg; + outMsg.writeShort(CMSG_ITEM_PICKUP); + outMsg.writeLong(floorItem->getId()); writeSet(6); } diff --git a/src/gui/requesttrade.cpp b/src/gui/requesttrade.cpp index e3b70fd3..992b0c0f 100644 --- a/src/gui/requesttrade.cpp +++ b/src/gui/requesttrade.cpp @@ -27,7 +27,10 @@ #include <guichan/widgets/label.hpp> #include "button.h" + +#include "../net/messageout.h" #include "../net/network.h" +#include "../net/protocol.h" bool requestTradeDialogOpen = false; @@ -84,19 +87,18 @@ RequestTradeDialog::~RequestTradeDialog() void RequestTradeDialog::action(const std::string& eventId) { + int choice = 4; // 4 means trade canceled + if (eventId == "accept") { - // Send the selected index back to the server - writeWord(0, 0x00e6); - writeByte(2, 3); - writeSet(3); - scheduleDelete(); + choice = 3; // ok to trade } else if (eventId == "cancel") { - // 0xff packet means cancel - writeWord(0, 0x00e6); - writeByte(2, 4); - writeSet(3); requestTradeDialogOpen = false; - scheduleDelete(); } + + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_RESPONSE); + outMsg.writeByte(choice); + writeSet(3); + scheduleDelete(); } diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 7c030eb1..c3596503 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -40,7 +40,9 @@ #include "../resources/iteminfo.h" #include "../resources/itemmanager.h" +#include "../net/messageout.h" #include "../net/network.h" +#include "../net/protocol.h" SellDialog::SellDialog(): @@ -229,11 +231,12 @@ void SellDialog::action(const std::string& eventId) else if (eventId == "sell") { // Attempt sell assert(m_amountItems > 0 && m_amountItems <= m_maxItems); - - writeWord(0, 0x00c9); - writeWord(2, 8); - writeWord(4, shopInventory[selectedItem].index); - writeWord(6, m_amountItems); + + MessageOut outMsg; + outMsg.writeShort(CMSG_NPC_SELL_REQUEST); + outMsg.writeShort(8); + outMsg.writeShort(shopInventory[selectedItem].index); + outMsg.writeShort(m_amountItems); writeSet(8); m_maxItems -= m_amountItems; diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 5b065e47..0059ec25 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -31,7 +31,9 @@ #include "../playerinfo.h" +#include "../net/messageout.h" #include "../net/network.h" +#include "../net/protocol.h" char *skill_db[] = { // 0-99 @@ -124,8 +126,9 @@ void SkillDialog::action(const std::string& eventId) int selectedSkill = skillListBox->getSelected(); if (player_info->skillPoint > 0 && selectedSkill >= 0) { - writeWord(0, 0x0112); - writeWord(2, skillList[selectedSkill]->id); + MessageOut outMsg; + outMsg.writeShort(CMSG_SKILL_LEVELUP_REQUEST); + outMsg.writeShort(skillList[selectedSkill]->id); writeSet(4); } } diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 9bdb95a6..5a117982 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -30,7 +30,10 @@ #include "progressbar.h" #include "../playerinfo.h" + +#include "../net/messageout.h" #include "../net/network.h" +#include "../net/protocol.h" StatusWindow::StatusWindow(): Window(player_info->name) @@ -415,31 +418,36 @@ void StatusWindow::draw(gcn::Graphics *graphics) void StatusWindow::action(const std::string& eventId) { // Stats Part - if ( eventId.length() == 3 ) + if (eventId.length() == 3) { - writeWord(0, 0x00bb); + MessageOut outMsg; + outMsg.writeShort(CMSG_STAT_UPDATE_REQUEST); - if (eventId == "STR") { - writeWord(2, 0x000d); + if (eventId == "STR") + { + outMsg.writeShort(0x000d); } - if (eventId == "AGI") { - writeWord(2, 0x000e); + if (eventId == "AGI") + { + outMsg.writeShort(0x000e); } - if (eventId == "VIT") { - writeWord(2, 0x000f); + if (eventId == "VIT") + { + outMsg.writeShort(0x000f); } - if (eventId == "INT") { - writeWord(2, 0x0010); + if (eventId == "INT") + { + outMsg.writeShort(0x0010); } - if (eventId == "DEX") { - writeWord(2, 0x0011); + if (eventId == "DEX") + { + outMsg.writeShort(0x0011); } - if (eventId == "LUK") { - writeWord(2, 0x0012); + if (eventId == "LUK") + { + outMsg.writeShort(0x0012); } - - flush(); - writeByte(4, 1); + outMsg.writeByte(1); writeSet(5); } } diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index e18dc969..6069b768 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -38,7 +38,9 @@ #include "../inventory.h" #include "../item.h" +#include "../net/messageout.h" #include "../net/network.h" +#include "../net/protocol.h" #include "../resources/iteminfo.h" @@ -240,9 +242,10 @@ void TradeWindow::receivedOk(bool own) void TradeWindow::tradeItem(Item *item, int quantity) { - writeWord(0, 0x00e8); - writeWord(2, item->getInvIndex()); - writeLong(4, quantity); + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_ITEM_ADD_REQUEST); + outMsg.writeShort(item->getInvIndex()); + outMsg.writeLong(quantity); writeSet(8); flush(); } @@ -313,7 +316,8 @@ void TradeWindow::action(const std::string &eventId) } else if (eventId == "cancel") { - writeWord(0, 0x00ed); + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_CANCEL_REQUEST); writeSet(2); flush(); } @@ -326,23 +330,26 @@ void TradeWindow::action(const std::string &eventId) { tempMoney[1] << tempInt; moneyField->setText(tempMoney[1].str()); - - writeWord(0, 0x00e8); - writeWord(2, 0); - writeLong(4, tempInt); + + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_ITEM_ADD_REQUEST); + outMsg.writeShort(0); + outMsg.writeLong(tempInt); writeSet(8); flush(); } else { moneyField->setText(""); } moneyField->setEnabled(false); - writeWord(0, 0x00eb); + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_ADD_COMPLETE); writeSet(2); flush(); } else if (eventId == "trade") { - writeWord(0, 0x00ef); + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_OK); writeSet(2); flush(); } |