diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-01-04 20:28:57 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-01-04 20:28:57 +0000 |
commit | 34b19f52d2f4a0b8e7eecf0900d1760460390b9d (patch) | |
tree | 0e1ddf0575ec5780d988623daf4fc25d813fc1fd /src | |
parent | 180f39cb9da6e3169f95e9da5c8782c50f826af4 (diff) | |
download | mana-34b19f52d2f4a0b8e7eecf0900d1760460390b9d.tar.gz mana-34b19f52d2f4a0b8e7eecf0900d1760460390b9d.tar.bz2 mana-34b19f52d2f4a0b8e7eecf0900d1760460390b9d.tar.xz mana-34b19f52d2f4a0b8e7eecf0900d1760460390b9d.zip |
Reverted r0nny changes, enabled 3 slots to create players, smoothed player deletion.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 206 | ||||
-rw-r--r-- | src/gui/char_select.h | 17 | ||||
-rw-r--r-- | src/gui/char_server.cpp | 67 | ||||
-rw-r--r-- | src/gui/confirm_dialog.cpp | 14 | ||||
-rw-r--r-- | src/gui/confirm_dialog.h | 5 | ||||
-rw-r--r-- | src/gui/ok_dialog.cpp | 12 | ||||
-rw-r--r-- | src/gui/ok_dialog.h | 3 | ||||
-rw-r--r-- | src/gui/trade.cpp | 23 | ||||
-rw-r--r-- | src/net/protocol_trade.cpp | 50 | ||||
-rw-r--r-- | src/net/protocol_trade.h | 36 | ||||
-rw-r--r-- | src/playerinfo.h | 3 |
12 files changed, 229 insertions, 211 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 8a8d11a6..8d446363 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -126,9 +126,7 @@ tmw_SOURCES = graphic/spriteset.cpp \ net/packet.h \ net/protocol.cpp \ net/protocol.h \ - net/protocol_trade.cpp \ - net/protocol_trade.h \ - resources/image.cpp \ + resources/image.cpp \ resources/image.h \ resources/imagewriter.cpp \ resources/imagewriter.h \ diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 7ac76854..209284f7 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -45,29 +45,53 @@ #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?"), - master(m) + master(m), mStatus(0) { } void CharSelectDialog::CharDeleteConfirm::action(const std::string &eventId) { - ConfirmDialog::action(eventId); + //ConfirmDialog::action(eventId); if (eventId == "yes") { - master->serverCharDelete(); + master->attemptCharDelete(); + ConfirmDialog::yesButton->setEnabled(false); + ConfirmDialog::noButton->setEnabled(false); + mStatus = 1; + } + else + { + ConfirmDialog::action(eventId); + } +} + +void CharSelectDialog::CharDeleteConfirm::logic() +{ + if (mStatus == 1) + { + if (packetReady()) + { + master->checkCharDelete(); + ConfirmDialog::action("yes"); + } + else + { + flush(); + } } } CharSelectDialog::CharSelectDialog(): - Window("Select Character"), mStatus(0) + Window("Select Character"), mStatus(0), mCurrentSlot(0) { - selectButton = new Button("OK"); + selectButton = new Button("Ok"); cancelButton = new Button("Cancel"); newCharButton = new Button("New"); delCharButton = new Button("Delete"); + previousButton = new Button("Previous"); + nextButton = new Button("Next"); nameLabel = new gcn::Label("Name"); levelLabel = new gcn::Label("Level"); jobLevelLabel = new gcn::Label("Job Level"); @@ -78,15 +102,19 @@ CharSelectDialog::CharSelectDialog(): newCharButton->setEventId("new"); cancelButton->setEventId("cancel"); delCharButton->setEventId("delete"); + previousButton->setEventId("previous"); + nextButton->setEventId("next"); int w = 195; - int h = 195; + int h = 220; setContentSize(w, h); playerBox->setDimension(gcn::Rectangle(5, 5, w - 10, 90)); nameLabel->setDimension(gcn::Rectangle(10, 100, 128, 16)); levelLabel->setDimension(gcn::Rectangle(10, 116, 128, 16)); jobLevelLabel->setDimension(gcn::Rectangle(10, 132, 128, 16)); moneyLabel->setDimension(gcn::Rectangle(10, 148, 128, 16)); + previousButton->setPosition(5, 170); + nextButton->setPosition(previousButton->getWidth() + 10, 170); newCharButton->setPosition(5, h - 5 - newCharButton->getHeight()); delCharButton->setPosition( 5 + newCharButton->getWidth() + 5, @@ -103,6 +131,8 @@ CharSelectDialog::CharSelectDialog(): add(cancelButton); add(newCharButton); add(delCharButton); + add(previousButton); + add(nextButton); add(nameLabel); add(levelLabel); add(jobLevelLabel); @@ -113,36 +143,73 @@ CharSelectDialog::CharSelectDialog(): cancelButton->addActionListener(this); newCharButton->addActionListener(this); delCharButton->addActionListener(this); + previousButton->addActionListener(this); + nextButton->addActionListener(this); selectButton->requestFocus(); setLocationRelativeTo(getParent()); setPlayerInfo(NULL); } +void CharSelectDialog::changeSlot(int slot) +{ + mCurrentSlot = slot; + if (mCurrentSlot < 0) + { + mCurrentSlot = MAX_SLOT; + } + else if (mCurrentSlot > MAX_SLOT) + { + mCurrentSlot = 0; + } + + if (char_info[mCurrentSlot] == NULL) + { + newCharButton->setEnabled(true); + } +} + void CharSelectDialog::action(const std::string& eventId) { - if (eventId == "ok" && n_character > 0) { + if (eventId == "ok" && n_character > 0) + { // Start game - attemptCharSelect(); newCharButton->setEnabled(false); delCharButton->setEnabled(false); selectButton->setEnabled(false); + previousButton->setEnabled(false); + nextButton->setEnabled(false); + attemptCharSelect(); mStatus = 1; } - else if (eventId == "cancel") { + else if (eventId == "cancel") + { state = EXIT_STATE; } - else if (eventId == "new") { - if (n_character == 0) { + else if (eventId == "new") + { + if (n_character < MAX_SLOT + 1) + { // Start new character dialog - new CharCreateDialog(this); + new CharCreateDialog(this, mCurrentSlot); } - } else if (eventId == "delete") { + } + else if (eventId == "delete") + { // Delete character - if (n_character > 0) { + if (n_character > 0) + { new CharDeleteConfirm(this); } } + else if (eventId == "previous") + { + changeSlot(mCurrentSlot - 1); + } + else if (eventId == "next") + { + changeSlot(mCurrentSlot + 1); + } } void CharSelectDialog::setPlayerInfo(PLAYER_INFO *pi) @@ -159,10 +226,12 @@ void CharSelectDialog::setPlayerInfo(PLAYER_INFO *pi) levelLabel->setCaption(levelCaption.str()); jobLevelLabel->setCaption(jobCaption.str()); moneyLabel->setCaption(moneyCaption.str()); - newCharButton->setEnabled(false); - delCharButton->setEnabled(true); - selectButton->setEnabled(true); - + if (mStatus != 1) + { + newCharButton->setEnabled(false); + delCharButton->setEnabled(true); + selectButton->setEnabled(true); + } playerBox->hairStyle = pi->hairStyle - 1; playerBox->hairColor = pi->hairColor - 1; playerBox->showPlayer = true; @@ -182,22 +251,25 @@ void CharSelectDialog::setPlayerInfo(PLAYER_INFO *pi) } } -void CharSelectDialog::serverCharDelete() +void CharSelectDialog::attemptCharDelete() { // Request character deletion MessageOut outMsg; outMsg.writeInt16(0x0068); - outMsg.writeInt32(char_info[0]->id); + outMsg.writeInt32(char_info[mCurrentSlot]->id); outMsg.writeString("a@a.com", 40); +} +void CharSelectDialog::checkCharDelete() +{ MessageIn msg = get_next_message(); if (msg.getId() == 0x006f) { skip(msg.getLength()); - delete char_info[0]; - free(char_info); - n_character = 0; + delete char_info[mCurrentSlot]; + n_character--; + char_info[mCurrentSlot] = NULL; setPlayerInfo(NULL); new OkDialog(this, "Info", "Player deleted"); } @@ -217,7 +289,7 @@ void CharSelectDialog::attemptCharSelect() // Request character selection MessageOut outMsg; outMsg.writeInt16(0x0066); - outMsg.writeInt8(0); + outMsg.writeInt8(mCurrentSlot); } void @@ -240,7 +312,16 @@ CharSelectDialog::checkCharSelect() map_path = map_path.substr(0, map_path.rfind(".")) + ".tmx.gz"; map_address = msg.readInt32(); map_port = msg.readInt16(); - player_info = char_info[0]; + player_info = char_info[mCurrentSlot]; + // Clear unselected players infos + for (int i = 0; i < MAX_SLOT + 1; i++) + { + if (i != mCurrentSlot) + { + delete char_info[i]; + } + } + free(char_info); state = CONNECTING_STATE; logger->log("CharSelect: Map: %s", map_path.c_str()); @@ -288,8 +369,9 @@ CharSelectDialog::checkCharSelect() void CharSelectDialog::logic() { - if (n_character > 0) { - setPlayerInfo(char_info[0]); + if (n_character > 0) + { + setPlayerInfo(char_info[mCurrentSlot]); } if (mStatus == 1) @@ -305,8 +387,8 @@ void CharSelectDialog::logic() } } -CharCreateDialog::CharCreateDialog(Window *parent): - Window("Create Character", true, parent), mStatus(0) +CharCreateDialog::CharCreateDialog(Window *parent, int slot): + Window("Create Character", true, parent), mStatus(0), mSlot(slot) { nameField = new TextField(""); nameLabel = new gcn::Label("Name:"); @@ -392,8 +474,8 @@ void CharCreateDialog::action(const std::string& eventId) if (eventId == "create") { if (getName().length() >= 4) { // Attempt to create the character - attemptCharCreate(); createButton->setEnabled(false); + attemptCharCreate(); mStatus = 1; } else { @@ -438,7 +520,7 @@ void CharCreateDialog::attemptCharCreate() outMsg.writeInt8(5); outMsg.writeInt8(5); outMsg.writeInt8(5); - outMsg.writeInt8(0); + outMsg.writeInt8(mSlot); outMsg.writeInt16(playerBox->hairColor + 1); outMsg.writeInt16(playerBox->hairStyle + 1); } @@ -449,64 +531,60 @@ void CharCreateDialog::checkCharCreate() if (msg.getId() == 0x006d) { - char_info = (PLAYER_INFO**)malloc(sizeof(PLAYER_INFO*)); - char_info[0] = new PLAYER_INFO; - - char_info[0]->id = msg.readInt32(); - char_info[0]->xp = msg.readInt32(); - char_info[0]->gp = msg.readInt32(); - char_info[0]->jobXp = msg.readInt32(); - char_info[0]->jobLvl = msg.readInt32(); + PLAYER_INFO *tempPlayer = new PLAYER_INFO; + + tempPlayer->id = msg.readInt32(); + tempPlayer->xp = msg.readInt32(); + tempPlayer->gp = msg.readInt32(); + tempPlayer->jobXp = msg.readInt32(); + tempPlayer->jobLvl = msg.readInt32(); msg.skip(8); // unknown msg.readInt32(); // option msg.readInt32(); // karma msg.readInt32(); // manner msg.skip(2); // unknown - char_info[0]->hp = msg.readInt16(); - char_info[0]->maxHp = msg.readInt16(); - char_info[0]->mp = msg.readInt16(); - char_info[0]->maxMp = msg.readInt16(); + tempPlayer->hp = msg.readInt16(); + tempPlayer->maxHp = msg.readInt16(); + tempPlayer->mp = msg.readInt16(); + tempPlayer->maxMp = msg.readInt16(); msg.readInt16(); // speed msg.readInt16(); // class - char_info[0]->hairStyle = msg.readInt16(); - char_info[0]->weapon = msg.readInt16(); - char_info[0]->lvl = msg.readInt16(); + tempPlayer->hairStyle = msg.readInt16(); + tempPlayer->weapon = msg.readInt16(); + tempPlayer->lvl = msg.readInt16(); msg.readInt16(); // skill point msg.readInt16(); // head bottom msg.readInt16(); // shield msg.readInt16(); // head option top msg.readInt16(); // head option mid - char_info[0]->hairColor = msg.readInt16(); + tempPlayer->hairColor = msg.readInt16(); msg.readInt16(); // unknown - char_info[0]->name = msg.readString(24); - char_info[0]->STR = msg.readInt8(); - char_info[0]->AGI = msg.readInt8(); - char_info[0]->VIT = msg.readInt8(); - char_info[0]->INT = msg.readInt8(); - char_info[0]->DEX = msg.readInt8(); - char_info[0]->LUK = msg.readInt8(); - char_info[0]->characterNumber = msg.readInt8(); // character number + tempPlayer->name = msg.readString(24); + tempPlayer->STR = msg.readInt8(); + tempPlayer->AGI = msg.readInt8(); + tempPlayer->VIT = msg.readInt8(); + tempPlayer->INT = msg.readInt8(); + tempPlayer->DEX = msg.readInt8(); + tempPlayer->LUK = msg.readInt8(); + int slot = msg.readInt8(); // character slot msg.readInt8(); // unknown - n_character = 1; + n_character++; + char_info[slot] = tempPlayer; + windowContainer->scheduleDelete(this); } else if (msg.getId() == 0x006e) { new OkDialog(this, "Error", "Failed to create character"); - n_character = 0; + createButton->setEnabled(true); } else { new OkDialog(this, "Error", "Unknown error"); - n_character = 0; + createButton->setEnabled(true); } skip(msg.getLength()); - - // Remove window when succeeded - if (n_character == 1) { - windowContainer->scheduleDelete(this); - } } void charSelectInputHandler(SDL_KeyboardEvent *keyEvent) diff --git a/src/gui/char_select.h b/src/gui/char_select.h index a00ada26..7db67699 100644 --- a/src/gui/char_select.h +++ b/src/gui/char_select.h @@ -58,6 +58,8 @@ class CharSelectDialog : public Window, public gcn::ActionListener gcn::Button *cancelButton; gcn::Button *newCharButton; gcn::Button *delCharButton; + gcn::Button *previousButton; + gcn::Button *nextButton; gcn::Label *nameLabel; gcn::Label *levelLabel; @@ -65,13 +67,21 @@ class CharSelectDialog : public Window, public gcn::ActionListener gcn::Label *moneyLabel; int mStatus; + int mCurrentSlot; PlayerBox *playerBox; + + void changeSlot(int slot); /** * Communicate character deletion to the server. */ - void serverCharDelete(); + void attemptCharDelete(); + + /** + * Check server answer. + */ + void checkCharDelete(); /** * Communicate character selection to the server. @@ -91,8 +101,10 @@ class CharSelectDialog : public Window, public gcn::ActionListener public: CharDeleteConfirm(CharSelectDialog *master); void action(const std::string &eventId); + void logic(); private: CharSelectDialog *master; + int mStatus; }; }; @@ -107,7 +119,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener /** * Constructor. */ - CharCreateDialog(Window *parent = NULL); + CharCreateDialog(Window *parent = NULL, int slot = 0); void logic(); @@ -130,6 +142,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener PlayerBox *playerBox; int mStatus; + int mSlot; /** * Communicate character creation to the server. diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index 40b229a1..ed0818c8 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -193,61 +193,60 @@ ServerSelectDialog::checkServerSelect() // Derive number of characters from message length n_character = (msg.getLength() - 24) / 106; - char_info = (PLAYER_INFO**)malloc(sizeof(PLAYER_INFO*) * n_character); + char_info = (PLAYER_INFO**)malloc(sizeof(PLAYER_INFO*) * (MAX_SLOT+1)); + for (int i = 0; i < MAX_SLOT + 1; i++) + char_info[i] = NULL; for (int i = 0; i < n_character; i++) { - char_info[i] = new PLAYER_INFO; + PLAYER_INFO *tempPlayer = new PLAYER_INFO; - char_info[i]->totalWeight = 0; - char_info[i]->maxWeight = 0; - char_info[i]->lastAttackTime = 0; - char_info[i]->id = msg.readInt32(); - char_info[i]->xp = msg.readInt32(); - char_info[i]->gp = msg.readInt32(); - char_info[i]->jobXp = msg.readInt32(); - char_info[i]->jobLvl = msg.readInt32(); + tempPlayer->totalWeight = 0; + tempPlayer->maxWeight = 0; + tempPlayer->lastAttackTime = 0; + tempPlayer->id = msg.readInt32(); + tempPlayer->xp = msg.readInt32(); + tempPlayer->gp = msg.readInt32(); + tempPlayer->jobXp = msg.readInt32(); + tempPlayer->jobLvl = msg.readInt32(); msg.skip(8); // unknown msg.readInt32(); // option msg.readInt32(); // karma msg.readInt32(); // manner msg.skip(2); // unknown - char_info[i]->hp = msg.readInt16(); - char_info[i]->maxHp = msg.readInt16(); - char_info[i]->mp = msg.readInt16(); - char_info[i]->maxMp = msg.readInt16(); + tempPlayer->hp = msg.readInt16(); + tempPlayer->maxHp = msg.readInt16(); + tempPlayer->mp = msg.readInt16(); + tempPlayer->maxMp = msg.readInt16(); msg.readInt16(); // speed msg.readInt16(); // class - char_info[i]->hairStyle = msg.readInt16(); - char_info[i]->weapon = msg.readInt16(); - char_info[i]->lvl = msg.readInt16(); + tempPlayer->hairStyle = msg.readInt16(); + tempPlayer->weapon = msg.readInt16(); + tempPlayer->lvl = msg.readInt16(); msg.readInt16(); // skill point msg.readInt16(); // head bottom msg.readInt16(); // shield msg.readInt16(); // head option top msg.readInt16(); // head option mid - char_info[i]->hairColor = msg.readInt16(); + tempPlayer->hairColor = msg.readInt16(); msg.readInt16(); // unknown - char_info[i]->name = msg.readString(24); - char_info[i]->STR = msg.readInt8(); - char_info[i]->AGI = msg.readInt8(); - char_info[i]->VIT = msg.readInt8(); - char_info[i]->INT = msg.readInt8(); - char_info[i]->DEX = msg.readInt8(); - char_info[i]->LUK = msg.readInt8(); - char_info[i]->characterNumber = msg.readInt8(); // character number + tempPlayer->name = msg.readString(24); + tempPlayer->STR = msg.readInt8(); + tempPlayer->AGI = msg.readInt8(); + tempPlayer->VIT = msg.readInt8(); + tempPlayer->INT = msg.readInt8(); + tempPlayer->DEX = msg.readInt8(); + tempPlayer->LUK = msg.readInt8(); + int slot = msg.readInt8(); // character slot msg.readInt8(); // unknown + + char_info[slot] = tempPlayer; + + logger->log("CharServer: Player: %s (%d)", + char_info[slot]->name.c_str(), slot); } state = CHAR_SELECT_STATE; - - if (n_character > 0) - { - logger->log("CharServer: Player: %s (Packet ID: %x, Length: %d)", - char_info[0]->name.c_str(), msg.getId(), - msg.getLength()); - } - skip(msg.getLength()); } else if (msg.getId() == 0x006c) diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp index dc710961..59d48318 100644 --- a/src/gui/confirm_dialog.cpp +++ b/src/gui/confirm_dialog.cpp @@ -45,20 +45,20 @@ ConfirmDialog::ConfirmDialog(Window *parent, const std::string &title, void ConfirmDialog::init(const std::string &msg, gcn::ActionListener *listener) { - gcn::Label *userLabel = new gcn::Label(msg); - Button *yesButton = new Button("Yes"); - Button *noButton = new Button("No"); + textLabel = new gcn::Label(msg); + yesButton = new Button("Yes"); + noButton = new Button("No"); - int w = userLabel->getWidth() + 20; + int w = textLabel->getWidth() + 20; int inWidth = yesButton->getWidth() + noButton->getWidth() + 5; - int h = userLabel->getHeight() + 25 + yesButton->getHeight(); + int h = textLabel->getHeight() + 25 + yesButton->getHeight(); if (w < inWidth + 10) { w = inWidth + 10; } setContentSize(w, h); - userLabel->setPosition(10, 10); + textLabel->setPosition(10, 10); yesButton->setPosition( (w - inWidth) / 2, h - 5 - noButton->getHeight()); @@ -75,7 +75,7 @@ void ConfirmDialog::init(const std::string &msg, gcn::ActionListener *listener) noButton->addActionListener(listener); } - add(userLabel); + add(textLabel); add(yesButton); add(noButton); diff --git a/src/gui/confirm_dialog.h b/src/gui/confirm_dialog.h index fd220828..8f444057 100644 --- a/src/gui/confirm_dialog.h +++ b/src/gui/confirm_dialog.h @@ -59,12 +59,17 @@ class ConfirmDialog : public Window, public gcn::ActionListener { * Called when receiving actions from the widgets. */ void action(const std::string& eventId); + + gcn::Button *yesButton; + gcn::Button *noButton; private: /** * Initializes the dialog. */ void init(const std::string &msg, gcn::ActionListener *listener); + + gcn::Label *textLabel; }; #endif diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp index 794bc723..aca42972 100644 --- a/src/gui/ok_dialog.cpp +++ b/src/gui/ok_dialog.cpp @@ -48,18 +48,18 @@ OkDialog::~OkDialog() void OkDialog::init(const std::string &msg, gcn::ActionListener *listener) { - gcn::Label *userLabel = new gcn::Label(msg); - Button *okButton = new Button("OK"); + textLabel = new gcn::Label(msg); + okButton = new Button("Ok"); - int w = userLabel->getWidth() + 20; - int h = userLabel->getHeight() + 25 + okButton->getHeight(); + int w = textLabel->getWidth() + 20; + int h = textLabel->getHeight() + 25 + okButton->getHeight(); if (okButton->getWidth() + 10 > w) { w = okButton->getWidth() + 10; } setContentSize(w, h); - userLabel->setPosition(10, 10); + textLabel->setPosition(10, 10); okButton->setPosition((w - okButton->getWidth()) / 2, h - 5 - okButton->getHeight()); @@ -69,7 +69,7 @@ void OkDialog::init(const std::string &msg, gcn::ActionListener *listener) okButton->addActionListener(listener); } - add(userLabel); + add(textLabel); add(okButton); setLocationRelativeTo(getParent()); diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h index d444bcd8..b5c792b1 100644 --- a/src/gui/ok_dialog.h +++ b/src/gui/ok_dialog.h @@ -69,6 +69,9 @@ class OkDialog : public Window, public gcn::ActionListener { * Initializes the dialog. */ void init(const std::string &msg, gcn::ActionListener *listener); + + gcn::Label *textLabel; + gcn::Button *okButton; }; #endif diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 359782d4..767888f4 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -39,8 +39,7 @@ #include "../item.h" #include "../net/messageout.h" -#include "../net/protocol_trade.h" - +#include "../net/protocol.h" #include "../resources/iteminfo.h" @@ -228,7 +227,10 @@ void TradeWindow::receivedOk(bool own) void TradeWindow::tradeItem(Item *item, int quantity) { - trade(*item,quantity); + MessageOut outMsg; + outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST); + outMsg.writeInt16(item->getInvIndex()); + outMsg.writeInt32(quantity); } void TradeWindow::mouseClick(int x, int y, int button, int count) @@ -297,7 +299,8 @@ void TradeWindow::action(const std::string &eventId) } else if (eventId == "cancel") { - trade(cancel); + MessageOut outMsg; + outMsg.writeInt16(CMSG_TRADE_CANCEL_REQUEST); } else if (eventId == "ok") { @@ -309,16 +312,20 @@ void TradeWindow::action(const std::string &eventId) tempMoney[1] << tempInt; moneyField->setText(tempMoney[1].str()); - trade(tempInt); - + MessageOut outMsg; + outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST); + outMsg.writeInt16(0); + outMsg.writeInt32(tempInt); } else { moneyField->setText(""); } moneyField->setEnabled(false); - trade(complete); + MessageOut outMsg; + outMsg.writeInt16(CMSG_TRADE_ADD_COMPLETE); } else if (eventId == "trade") { - trade(); + MessageOut outMsg; + outMsg.writeInt16(CMSG_TRADE_OK); } } diff --git a/src/net/protocol_trade.cpp b/src/net/protocol_trade.cpp deleted file mode 100644 index 0271567e..00000000 --- a/src/net/protocol_trade.cpp +++ /dev/null @@ -1,50 +0,0 @@ - -#include "protocol_trade.h" - -#include "../item.h" -#include "../gui/trade.h" - -#include "messageout.h" - -cancel_t cancel; -complete_t complete; - -/** Start trading with someone */ -void trade(Being&); - -void trade(int id,int amount) -{ - MessageOut outMsg; - outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST); - outMsg.writeInt16(id); - outMsg.writeInt32(amount); -}; - -/** add trading item*/ - -void trade(Item& item,int amount) -{ -trade(item.getInvIndex(),amount); -} - -/** add money to trade */ -void trade(int i){trade(0,i);}; - -/** cancel courent trade */ -void trade(cancel_t&) -{ - MessageOut outMsg; - outMsg.writeInt16(CMSG_TRADE_CANCEL_REQUEST); -}; - -void trade() -{ - MessageOut outMsg; - outMsg.writeInt16(CMSG_TRADE_OK); -}; - -void trade(complete_t&) -{ - MessageOut outMsg; - outMsg.writeInt16(CMSG_TRADE_ADD_COMPLETE); -}; diff --git a/src/net/protocol_trade.h b/src/net/protocol_trade.h deleted file mode 100644 index 42908ab2..00000000 --- a/src/net/protocol_trade.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _TMW_PROTOCOL_HELPER_ -#define _TMW_PROTOCOL_HELPER_ - -#include "protocol.h" - - -/** - * Helper class for using <actionfunc>(cancel), to cancel stuff - */ -class cancel_t {}; -extern cancel_t cancel; - -class complete_t {}; -extern complete_t complete; - - -class Item; - -/** Start trading with someone */ -void trade(Being&); - -/** add trading item*/ -void trade(Item&,int amount); - -/** add money to trade */ -void trade(int); - -/** verify the trade */ -void trade(); - -void trade(complete_t&); - -/** cancel courent trade */ -void trade(cancel_t&); - -#endif diff --git a/src/playerinfo.h b/src/playerinfo.h index f0509e51..0a5b1de8 100644 --- a/src/playerinfo.h +++ b/src/playerinfo.h @@ -24,6 +24,8 @@ #ifndef _TMW_PLAYERINFO_ #define _TMW_PLAYERINFO_ +#define MAX_SLOT 2 + #include <string> struct PLAYER_INFO @@ -39,7 +41,6 @@ struct PLAYER_INFO char STRUp, AGIUp, VITUp, INTUp, DEXUp, LUKUp; int ATK, ATKBonus, MATK, MATKBonus, DEF, DEFBonus, MDEF; int MDEFBonus, HIT, FLEE, FLEEBonus; - char characterNumber; int totalWeight, maxWeight; short weapon; }; |