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/npc.cpp | |
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/npc.cpp')
-rw-r--r-- | src/gui/npc.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
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; } |