diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-26 22:09:04 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-26 22:09:04 +0000 |
commit | 40339bebb026cd553aacbbff6f2fe1aa14816d5a (patch) | |
tree | f6398430043accbc90170ac15c62c8deebd895eb | |
parent | fd279ae77295a6babedd31202078862eabcada9f (diff) | |
download | mana-40339bebb026cd553aacbbff6f2fe1aa14816d5a.tar.gz mana-40339bebb026cd553aacbbff6f2fe1aa14816d5a.tar.bz2 mana-40339bebb026cd553aacbbff6f2fe1aa14816d5a.tar.xz mana-40339bebb026cd553aacbbff6f2fe1aa14816d5a.zip |
Got rid of the default MessageOut constructor, since all messages should have
an ID.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | src/beingmanager.cpp | 3 | ||||
-rw-r--r-- | src/engine.cpp | 7 | ||||
-rw-r--r-- | src/gui/buy.cpp | 13 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 6 | ||||
-rw-r--r-- | src/gui/chat.cpp | 9 | ||||
-rw-r--r-- | src/gui/sell.cpp | 3 | ||||
-rw-r--r-- | src/gui/trade.cpp | 15 | ||||
-rw-r--r-- | src/localplayer.cpp | 42 | ||||
-rw-r--r-- | src/net/messageout.cpp | 7 | ||||
-rw-r--r-- | src/net/messageout.h | 5 | ||||
-rw-r--r-- | src/npc.cpp | 15 |
12 files changed, 49 insertions, 88 deletions
@@ -1,3 +1,11 @@ +2006-08-27 Bjørn Lindeijer <bjorn@lindeijer.nl> + + * src/localplayer.cpp, src/gui/sell.cpp, src/gui/trade.cpp, + src/gui/char_select.cpp, src/gui/chat.cpp, src/gui/buy.cpp, + src/engine.cpp, src/beingmanager.cpp, src/npc.cpp, + src/net/messageout.cpp, src/net/messageout.h: Got rid of the default + MessageOut constructor, since all messages should have an ID. + 2006-08-26 Bjørn Lindeijer <bjorn@lindeijer.nl> * src/gui/char_select.cpp, src/gui/playerbox.cpp, src/player.cpp, @@ -24,8 +32,8 @@ src/net/charserverhandler.cpp, src/net/messagehandler.cpp, src/net/network.cpp, src/localplayer.h, src/game.h: Made the Network class a purely static interface, as there is only one instance. - * src/net/beinghandler.cpp, src/net/beinghandler.h, src/net/protocol.h: - Added support for "beings move" messages. + * src/net/beinghandler.cpp, src/net/beinghandler.h, + src/net/protocol.h: Added support for "beings move" messages. 2006-08-21 Eugenio Favalli <elvenprogrammer@gmail.com> diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index caecd88e..a6c7974d 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -69,8 +69,7 @@ Being* BeingManager::createBeing(Uint32 id, Uint16 job) if (job < 10) { being = new Player(id, job, mMap); - MessageOut outMsg; - outMsg.writeShort(0x0094); + MessageOut outMsg(0x0094); outMsg.writeLong(id); } else if (job >= 100 & job < 200) diff --git a/src/engine.cpp b/src/engine.cpp index 3e6b091a..7a33dd3d 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -39,9 +39,6 @@ #include "gui/gui.h" #include "gui/minimap.h" -#include "net/messageout.h" -#include "net/protocol.h" - #include "resources/itemmanager.h" #include "resources/mapreader.h" #include "resources/resourcemanager.h" @@ -148,10 +145,6 @@ void Engine::changeMap(const std::string &mapPath) } mCurrentMap = newMap; - - // Send "map loaded" - MessageOut outMsg; - outMsg.writeShort(CMSG_MAP_LOADED); } void Engine::logic() diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 63a6e20e..165fa7dc 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -215,9 +215,9 @@ void BuyDialog::action(const std::string &eventId, gcn::Widget *widget) // of items to be bought ever fails, Bertram removed the assertions, is // there a better way to ensure this fails in an _obivous_ way in C++? else if (eventId == "buy" && (mAmountItems > 0 && - mAmountItems <= mMaxItems)) { - MessageOut outMsg; - outMsg.writeShort(CMSG_NPC_BUY_REQUEST); + mAmountItems <= mMaxItems)) + { + MessageOut outMsg(CMSG_NPC_BUY_REQUEST); outMsg.writeShort(8); outMsg.writeShort(mAmountItems); outMsg.writeShort(mShopItems->at(selectedItem).id); @@ -262,9 +262,12 @@ void BuyDialog::mouseClick(int x, int y, int button, int count) int selectedItem = mItemList->getSelected(); if (selectedItem > -1) { + int itemId = mShopItems->at(selectedItem).id; + ItemInfo *itemInfo = itemDb->getItemInfo(itemId); + mItemDescLabel->setCaption("Description: " + - itemDb->getItemInfo(mShopItems->at(selectedItem).id)->getDescription()); + itemInfo->getDescription()); mItemEffectLabel->setCaption("Effect: " + - itemDb->getItemInfo(mShopItems->at(selectedItem).id)->getEffect()); + itemInfo->getEffect()); } } diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 7e0a1a29..adcbe290 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -203,8 +203,7 @@ void CharSelectDialog::updatePlayerInfo() void CharSelectDialog::attemptCharDelete() { // Request character deletion - MessageOut msg; - msg.writeShort(PAMSG_CHAR_DELETE); + MessageOut msg(PAMSG_CHAR_DELETE); // TODO: Send the selected slot msg.writeByte(0); Network::send(Network::ACCOUNT, msg); @@ -214,8 +213,7 @@ void CharSelectDialog::attemptCharDelete() void CharSelectDialog::attemptCharSelect() { // Request character selection - MessageOut msg; - msg.writeShort(PAMSG_CHAR_SELECT); + MessageOut msg(PAMSG_CHAR_SELECT); msg.writeByte(mCharInfo->getPos()); Network::send(Network::ACCOUNT, msg); mCharInfo->lock(); diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 04ac3996..9098f9f0 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -249,16 +249,14 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) // Prepare ordinary message if (msg.substr(0, 1) != "/") { - MessageOut outMsg; - outMsg.writeShort(PGMSG_SAY); + MessageOut outMsg(PGMSG_SAY); outMsg.writeString(msg); Network::send(Network::GAME, outMsg); } else if (msg.substr(0, IS_ANNOUNCE_LENGTH) == IS_ANNOUNCE) { msg.erase(0, IS_ANNOUNCE_LENGTH); - MessageOut outMsg; - outMsg.writeShort(0x0099); + MessageOut outMsg(0x0099); outMsg.writeShort(msg.length() + 4); outMsg.writeString(msg, msg.length()); } @@ -276,8 +274,7 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) } else if (msg.substr(0, IS_WHO_LENGTH) == IS_WHO) { - MessageOut outMsg; - outMsg.writeShort(0x00c1); + MessageOut outMsg(0x00c1); } else { diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 3aa7c889..33813271 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -212,8 +212,7 @@ void SellDialog::action(const std::string &eventId, gcn::Widget *widget) // Attempt sell assert(mAmountItems > 0 && mAmountItems <= mMaxItems); - MessageOut outMsg; - outMsg.writeShort(CMSG_NPC_SELL_REQUEST); + MessageOut outMsg(CMSG_NPC_SELL_REQUEST); outMsg.writeShort(8); outMsg.writeShort(mShopItems->at(selectedItem).index); outMsg.writeShort(mAmountItems); diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 6b247901..0cd49013 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -214,8 +214,7 @@ void TradeWindow::receivedOk(bool own) void TradeWindow::tradeItem(Item *item, int quantity) { - MessageOut outMsg; - outMsg.writeShort(CMSG_TRADE_ITEM_ADD_REQUEST); + MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST); outMsg.writeShort(item->getInvIndex()); outMsg.writeLong(quantity); } @@ -286,8 +285,7 @@ void TradeWindow::action(const std::string &eventId, gcn::Widget *widget) } else if (eventId == "cancel") { - MessageOut outMsg; - outMsg.writeShort(CMSG_TRADE_CANCEL_REQUEST); + MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST); } else if (eventId == "ok") { @@ -297,20 +295,17 @@ void TradeWindow::action(const std::string &eventId, gcn::Widget *widget) { mMoneyField->setText(toString(tempInt)); - MessageOut outMsg; - outMsg.writeShort(CMSG_TRADE_ITEM_ADD_REQUEST); + MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST); outMsg.writeShort(0); outMsg.writeLong(tempInt); } else { mMoneyField->setText(""); } mMoneyField->setEnabled(false); - MessageOut outMsg; - outMsg.writeShort(CMSG_TRADE_ADD_COMPLETE); + MessageOut outMsg(CMSG_TRADE_ADD_COMPLETE); } else if (eventId == "trade") { - MessageOut outMsg; - outMsg.writeShort(CMSG_TRADE_OK); + MessageOut outMsg(CMSG_TRADE_OK); } } diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 83884b6f..f157f04c 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -116,8 +116,7 @@ Item* LocalPlayer::getInvItem(int index) void LocalPlayer::equipItem(Item *item) { - MessageOut outMsg; - outMsg.writeShort(CMSG_PLAYER_EQUIP); + MessageOut outMsg(CMSG_PLAYER_EQUIP); outMsg.writeShort(item->getInvIndex()); outMsg.writeShort(0); } @@ -127,8 +126,7 @@ void LocalPlayer::unequipItem(Item *item) if (!item) return; - MessageOut outMsg; - outMsg.writeShort(CMSG_PLAYER_UNEQUIP); + MessageOut outMsg(CMSG_PLAYER_UNEQUIP); outMsg.writeShort(item->getInvIndex()); // Tidy equipment directly to avoid weapon still shown bug, by instance @@ -137,8 +135,7 @@ void LocalPlayer::unequipItem(Item *item) void LocalPlayer::useItem(Item *item) { - MessageOut outMsg; - outMsg.writeShort(CMSG_PLAYER_INVENTORY_USE); + MessageOut outMsg(CMSG_PLAYER_INVENTORY_USE); outMsg.writeShort(item->getInvIndex()); outMsg.writeLong(item->getId()); // Note: id is dest of item, usually player_node->account_ID ?? @@ -147,8 +144,7 @@ void LocalPlayer::useItem(Item *item) void LocalPlayer::dropItem(Item *item, int quantity) { // TODO: Fix wrong coordinates of drops, serverside? - MessageOut outMsg; - outMsg.writeShort(CMSG_PLAYER_INVENTORY_DROP); + MessageOut outMsg(CMSG_PLAYER_INVENTORY_DROP); outMsg.writeShort(item->getInvIndex()); outMsg.writeShort(quantity); } @@ -159,8 +155,7 @@ void LocalPlayer::pickUp(FloorItem *item) int dy = item->getY() - mY; if (dx * dx + dy * dy < 4) { - MessageOut outMsg; - outMsg.writeShort(CMSG_ITEM_PICKUP); + MessageOut outMsg(CMSG_ITEM_PICKUP); outMsg.writeLong(item->getId()); mPickUpTarget = NULL; } else { @@ -220,9 +215,8 @@ void LocalPlayer::walk(unsigned char dir) void LocalPlayer::setDestination(Uint16 x, Uint16 y) { char temp[3]; - MessageOut outMsg; + MessageOut outMsg(0x0085); set_coordinates(temp, x, y, mDirection); - outMsg.writeShort(0x0085); outMsg.writeString(temp, 3); mPickUpTarget = NULL; @@ -232,8 +226,7 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y) void LocalPlayer::raiseAttribute(Attribute attr) { - MessageOut outMsg; - outMsg.writeShort(CMSG_STAT_UPDATE_REQUEST); + MessageOut outMsg(CMSG_STAT_UPDATE_REQUEST); switch (attr) { @@ -269,8 +262,7 @@ void LocalPlayer::raiseSkill(Uint16 skillId) if (mSkillPoint <= 0) return; - MessageOut outMsg; - outMsg.writeShort(CMSG_SKILL_LEVELUP_REQUEST); + MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST); outMsg.writeShort(skillId); } @@ -288,8 +280,7 @@ void LocalPlayer::toggleSit() default: return; } - MessageOut outMsg; - outMsg.writeShort(0x0089); + MessageOut outMsg(0x0089); outMsg.writeLong(0); outMsg.writeByte(type); } @@ -300,8 +291,7 @@ void LocalPlayer::emote(Uint8 emotion) return; mLastAction = tick_time; - MessageOut outMsg; - outMsg.writeShort(0x00bf); + MessageOut outMsg(0x00bf); outMsg.writeByte(emotion); } @@ -310,15 +300,13 @@ void LocalPlayer::tradeReply(bool accept) if (!accept) mTrading = false; - MessageOut outMsg; - outMsg.writeShort(CMSG_TRADE_RESPONSE); + MessageOut outMsg(CMSG_TRADE_RESPONSE); outMsg.writeByte(accept ? 3 : 4); } void LocalPlayer::trade(Being *being) const { - MessageOut outMsg; - outMsg.writeShort(CMSG_TRADE_REQUEST); + MessageOut outMsg(CMSG_TRADE_REQUEST); outMsg.writeLong(being->getId()); } @@ -369,8 +357,7 @@ void LocalPlayer::attack(Being *target, bool keep) else sound.playSfx("sfx/fist-swish.ogg"); - MessageOut outMsg; - outMsg.writeShort(0x0089); + MessageOut outMsg(0x0089); outMsg.writeLong(target->getId()); outMsg.writeByte(0); } @@ -387,7 +374,6 @@ Being* LocalPlayer::getTarget() const void LocalPlayer::revive() { - MessageOut outMsg; - outMsg.writeShort(0x00b2); + MessageOut outMsg(0x00b2); outMsg.writeByte(0); } diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index 4fca662a..4d68c14f 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -27,13 +27,6 @@ #include <enet/enet.h> -MessageOut::MessageOut(): - mData(0), - mDataSize(0), - mPos(0) -{ -} - MessageOut::MessageOut(short id): mData(0), mDataSize(0), diff --git a/src/net/messageout.h b/src/net/messageout.h index 81369c0e..af25e4b4 100644 --- a/src/net/messageout.h +++ b/src/net/messageout.h @@ -35,11 +35,6 @@ class MessageOut /** * Constructor. */ - MessageOut(); - - /** - * Constructor. - */ MessageOut(short id); /** diff --git a/src/npc.cpp b/src/npc.cpp index a14b6d24..13025469 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -48,8 +48,7 @@ NPC::getType() const void NPC::talk() { - MessageOut outMsg; - outMsg.writeShort(CMSG_NPC_TALK); + MessageOut outMsg(CMSG_NPC_TALK); outMsg.writeLong(mId); outMsg.writeByte(0); current_npc = this; @@ -58,16 +57,14 @@ NPC::talk() void NPC::nextDialog() { - MessageOut outMsg; - outMsg.writeShort(CMSG_NPC_NEXT_REQUEST); + MessageOut outMsg(CMSG_NPC_NEXT_REQUEST); outMsg.writeLong(mId); } void NPC::dialogChoice(char choice) { - MessageOut outMsg; - outMsg.writeShort(CMSG_NPC_LIST_CHOICE); + MessageOut outMsg(CMSG_NPC_LIST_CHOICE); outMsg.writeLong(mId); outMsg.writeByte(choice); } @@ -79,8 +76,7 @@ NPC::dialogChoice(char choice) void NPC::buy() { - MessageOut outMsg; - outMsg.writeShort(CMSG_NPC_BUY_SELL_REQUEST); + MessageOut outMsg(CMSG_NPC_BUY_SELL_REQUEST); outMsg.writeLong(mId); outMsg.writeByte(0); } @@ -88,8 +84,7 @@ NPC::buy() void NPC::sell() { - MessageOut outMsg; - outMsg.writeShort(CMSG_NPC_BUY_SELL_REQUEST); + MessageOut outMsg(CMSG_NPC_BUY_SELL_REQUEST); outMsg.writeLong(mId); outMsg.writeByte(1); } |