diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-09-13 22:56:29 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-09-13 22:56:29 +0000 |
commit | 3dc311a652d1fda1252903a974920395e56e5668 (patch) | |
tree | 7098d55015d28a4d973c5073d7c9e45ae03ec400 /src/gui/npc.cpp | |
parent | 78771718bf7af14273d7bb0090dccff97b00b397 (diff) | |
download | mana-3dc311a652d1fda1252903a974920395e56e5668.tar.gz mana-3dc311a652d1fda1252903a974920395e56e5668.tar.bz2 mana-3dc311a652d1fda1252903a974920395e56e5668.tar.xz mana-3dc311a652d1fda1252903a974920395e56e5668.zip |
Merged with SDL_NET_TEST branch.
Diffstat (limited to 'src/gui/npc.cpp')
-rw-r--r-- | src/gui/npc.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp index 0756d809..c8d426f3 100644 --- a/src/gui/npc.cpp +++ b/src/gui/npc.cpp @@ -70,20 +70,23 @@ NpcListDialog::~NpcListDialog() delete scrollArea; } -int NpcListDialog::getNumberOfElements() +int +NpcListDialog::getNumberOfElements() { return items.size(); } -std::string NpcListDialog::getElementAt(int i) +std::string +NpcListDialog::getElementAt(int i) { return items[i]; } -void NpcListDialog::parseItems(const char *string, unsigned short len) { - char *copy = new char[len + 1]; - strncpy(copy, string, len); - copy[len] = 0; +void +NpcListDialog::parseItems(const std::string &itemString) +{ + char *copy = new char[itemString.length() + 1]; + strcpy(copy, itemString.c_str()); char *token = strtok(copy, ":"); while (token) { @@ -94,20 +97,23 @@ void NpcListDialog::parseItems(const char *string, unsigned short len) { delete[] copy; } -void NpcListDialog::reset() { +void +NpcListDialog::reset() +{ items.clear(); } -void NpcListDialog::action(const std::string& eventId) +void +NpcListDialog::action(const std::string& eventId) { if (eventId == "ok") { // Send the selected index back to the server int selectedIndex = itemList->getSelected(); if (selectedIndex > -1) { - WFIFOW(0) = net_w_value(0x00b8); - WFIFOL(2) = net_l_value(current_npc); - WFIFOB(6) = net_b_value(selectedIndex + 1); - WFIFOSET(7); + writeWord(0, 0x00b8); + writeLong(2, current_npc); + writeByte(6, selectedIndex + 1); + writeSet(7); setVisible(false); current_npc = 0; reset(); @@ -115,10 +121,10 @@ void NpcListDialog::action(const std::string& eventId) } else if (eventId == "cancel") { // 0xff packet means cancel - WFIFOW(0) = net_w_value(0x00b8); - WFIFOL(2) = net_l_value(current_npc); - WFIFOB(6) = net_b_value(0xff); - WFIFOSET(7); + writeWord(0, 0x00b8); + writeLong(2, current_npc); + writeByte(6, 0xff); + writeSet(7); setVisible(false); reset(); current_npc = 0; |