diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-01-17 18:36:21 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-01-17 19:19:58 +0300 |
commit | 55cbf74cbe2c40b4592e72621e40f8858fc376d9 (patch) | |
tree | 1adb70df7ddddde9a504d572a789e7afb5cae58c /src | |
parent | 261a118937d8b1cd41cf16d983f880e5957f84b1 (diff) | |
download | plus-55cbf74cbe2c40b4592e72621e40f8858fc376d9.tar.gz plus-55cbf74cbe2c40b4592e72621e40f8858fc376d9.tar.bz2 plus-55cbf74cbe2c40b4592e72621e40f8858fc376d9.tar.xz plus-55cbf74cbe2c40b4592e72621e40f8858fc376d9.zip |
Move cards constants into separate file.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/being/flooritem.h | 4 | ||||
-rw-r--r-- | src/const/resources/item/cards.h | 27 | ||||
-rw-r--r-- | src/gui/mailmessage.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/itemlinkhandler.cpp | 4 | ||||
-rw-r--r-- | src/itemcolormanager.cpp | 4 | ||||
-rw-r--r-- | src/net/ea/inventoryitem.h | 4 | ||||
-rw-r--r-- | src/net/eathena/auctionrecv.cpp | 4 | ||||
-rw-r--r-- | src/net/eathena/beingrecv.cpp | 8 | ||||
-rw-r--r-- | src/net/eathena/inventoryrecv.cpp | 40 | ||||
-rw-r--r-- | src/net/eathena/itemrecv.cpp | 10 | ||||
-rw-r--r-- | src/net/eathena/mailrecv.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/partyrecv.cpp | 4 | ||||
-rw-r--r-- | src/net/eathena/searchstorerecv.cpp | 4 | ||||
-rw-r--r-- | src/net/eathena/traderecv.cpp | 4 | ||||
-rw-r--r-- | src/net/eathena/vendingrecv.cpp | 6 | ||||
-rw-r--r-- | src/net/tmwa/inventoryrecv.cpp | 24 | ||||
-rw-r--r-- | src/net/tmwa/traderecv.cpp | 4 | ||||
-rw-r--r-- | src/resources/item/item.cpp | 2 | ||||
-rw-r--r-- | src/resources/item/item.h | 4 |
22 files changed, 110 insertions, 59 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d67bfc654..4c796f1eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1006,6 +1006,7 @@ SET(SRCS resources/map/location.h resources/map/map.cpp resources/map/map.h + const/resources/item/cards.h const/resources/map/map.h resources/map/mapheights.cpp resources/map/mapheights.h diff --git a/src/Makefile.am b/src/Makefile.am index 2a96c66bd..f290d33ed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1191,6 +1191,7 @@ manaplus_SOURCES += main.cpp \ resources/map/location.h \ resources/map/map.cpp \ resources/map/map.h \ + const/resources/item/cards.h \ const/resources/map/map.h \ resources/map/mapheights.cpp \ resources/map/mapheights.h \ diff --git a/src/being/flooritem.h b/src/being/flooritem.h index 343e50c40..cedcaf96e 100644 --- a/src/being/flooritem.h +++ b/src/being/flooritem.h @@ -23,6 +23,8 @@ #ifndef BEING_FLOORITEM_H #define BEING_FLOORITEM_H +#include "const/resources/item/cards.h" + #include "enums/simpletypes/damaged.h" #include "enums/simpletypes/identified.h" #include "enums/simpletypes/itemcolor.h" @@ -127,7 +129,7 @@ class FloorItem final : public ActorSprite { return mDamaged; } private: - int mCards[4]; + int mCards[maxCards]; int mItemId; int mX, mY; int mDropTime; diff --git a/src/const/resources/item/cards.h b/src/const/resources/item/cards.h new file mode 100644 index 000000000..7a58ed3ea --- /dev/null +++ b/src/const/resources/item/cards.h @@ -0,0 +1,27 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2016 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef CONST_RESOURCES_ITEM_ITEM_H +#define CONST_RESOURCES_ITEM_ITEM_H + +const int maxCards = 4; +const int maxMailCards = 4; + +#endif // CONST_RESOURCES_ITEM_ITEM_H diff --git a/src/gui/mailmessage.h b/src/gui/mailmessage.h index c4e61b49b..099cc2e34 100644 --- a/src/gui/mailmessage.h +++ b/src/gui/mailmessage.h @@ -21,6 +21,8 @@ #ifndef GUI_MAILMESSAGE_H #define GUI_MAILMESSAGE_H +#include "const/resources/item/cards.h" + #include <string> #include "localconsts.h" @@ -53,7 +55,7 @@ struct MailMessage final std::string sender; std::string strTime; std::string text; - uint16_t card[4]; + uint16_t card[maxMailCards]; int id; int time; int money; diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 9ffead378..9c5dcc77c 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -26,6 +26,8 @@ #include "itemcolormanager.h" #include "settings.h" +#include "const/resources/item/cards.h" + #include "input/inputmanager.h" #include "gui/gui.h" @@ -246,7 +248,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) { std::vector<int> parts; splitToIntVector(parts, bLink.link.substr(idx), ','); - while (parts.size() < 4) + while (parts.size() < maxCards) parts.push_back(0); const ItemColor itemColor = ItemColorManager::getColorFromCards(&parts[0]); diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 1f30c5da6..e363fe671 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -24,6 +24,8 @@ #include "itemcolormanager.h" +#include "const/resources/item/cards.h" + #include "gui/viewport.h" #include "gui/popups/itempopup.h" @@ -119,7 +121,7 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event) if (id > 0) { str.erase(str.begin()); - while (str.size() < 4) + while (str.size() < maxCards) str.push_back(0); const ItemColor color = ItemColorManager::getColorFromCards(&str[0]); diff --git a/src/itemcolormanager.cpp b/src/itemcolormanager.cpp index 7653b0ad9..9344ff856 100644 --- a/src/itemcolormanager.cpp +++ b/src/itemcolormanager.cpp @@ -20,6 +20,8 @@ #include "itemcolormanager.h" +#include "const/resources/item/cards.h" + #include "resources/iteminfo.h" #include "resources/db/itemdb.h" @@ -30,7 +32,7 @@ ItemColor ItemColorManager::getColorFromCards(const int *const cards) { if (!cards) return ItemColor_one; - for (int f = 0; f < 4; f ++) + for (int f = 0; f < maxCards; f ++) { const ItemInfo &info = ItemDB::get(cards[f]); const ItemColor &color = info.getCardColor(); diff --git a/src/net/ea/inventoryitem.h b/src/net/ea/inventoryitem.h index a32b0bfde..7971c9584 100644 --- a/src/net/ea/inventoryitem.h +++ b/src/net/ea/inventoryitem.h @@ -23,6 +23,8 @@ #ifndef NET_EA_INVENTORYITEM_H #define NET_EA_INVENTORYITEM_H +#include "const/resources/item/cards.h" + #include "enums/simpletypes/damaged.h" #include "enums/simpletypes/equipm.h" #include "enums/simpletypes/favorite.h" @@ -51,7 +53,7 @@ class InventoryItem final int slot; int id; int type; - int cards[4]; + int cards[maxCards]; int quantity; uint8_t refine; ItemColor color; diff --git a/src/net/eathena/auctionrecv.cpp b/src/net/eathena/auctionrecv.cpp index e097be551..cc7723e5f 100644 --- a/src/net/eathena/auctionrecv.cpp +++ b/src/net/eathena/auctionrecv.cpp @@ -22,6 +22,8 @@ #include "logger.h" +#include "const/resources/item/cards.h" + #include "net/messagein.h" #include "debug.h" @@ -51,7 +53,7 @@ void AuctionRecv::processAuctionResults(Net::MessageIn &msg) msg.readUInt8("identify"); msg.readUInt8("attribute"); msg.readUInt8("refine"); - for (int d = 0; d < 4; d ++) + for (int d = 0; d < maxCards; d ++) msg.readInt16("card"); msg.readInt32("price"); msg.readInt32("buy now"); diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp index 2d66f5152..bb6fff382 100644 --- a/src/net/eathena/beingrecv.cpp +++ b/src/net/eathena/beingrecv.cpp @@ -31,6 +31,8 @@ #include "being/mercenaryinfo.h" +#include "const/resources/item/cards.h" + #include "enums/resources/notifytypes.h" #include "particle/particle.h" @@ -94,7 +96,7 @@ void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg) void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg) { Being *dstBeing = nullptr; - int cards[4]; + int cards[maxCards]; if (!actorManager) { // here can be look from char server @@ -126,7 +128,7 @@ void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg) if (type != 2) id2 = 1; - for (int f = 0; f < 4; f ++) + for (int f = 0; f < maxCards; f ++) cards[f] = msg.readInt16("card"); if (!dstBeing) @@ -1585,7 +1587,7 @@ void BeingRecv::processBeingViewEquipment(Net::MessageIn &msg) msg.readInt32("location"); msg.readInt32("wear state"); msg.readInt8("refine"); - for (int d = 0; d < 4; d ++) + for (int d = 0; d < maxCards; d ++) msg.readInt16("card"); msg.readInt32("hire expire date (?)"); msg.readInt16("equip type"); diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp index ecd0a8257..fcaada26a 100644 --- a/src/net/eathena/inventoryrecv.cpp +++ b/src/net/eathena/inventoryrecv.cpp @@ -98,8 +98,8 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) msg.readInt32("location"); const int equipType = msg.readInt32("wear state"); const uint8_t refine = static_cast<uint8_t>(msg.readInt8("refine")); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); msg.readInt32("hire expire date (?)"); msg.readInt16("equip type"); @@ -159,8 +159,8 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) uint8_t identified = msg.readUInt8("identified"); const uint8_t damaged = msg.readUInt8("is damaged"); const uint8_t refine = msg.readUInt8("refine"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); const int equipType = msg.readInt32("location"); const int itemType = msg.readUInt8("item type"); @@ -289,8 +289,8 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) const int itemType = msg.readUInt8("item type"); const int amount = msg.readInt16("count"); msg.readInt32("wear state / equip"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); msg.readInt32("hire expire date (?)"); ItemFlags flags; @@ -332,8 +332,8 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) const int itemType = msg.readUInt8("item type"); const int amount = msg.readInt16("count"); msg.readInt32("wear state / equip"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); msg.readInt32("hire expire date (?)"); ItemFlags flags; @@ -488,8 +488,8 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) msg.readInt32("location"); msg.readInt32("wear state"); const uint8_t refine = msg.readUInt8("refine level"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); msg.readInt32("hire expire date"); msg.readInt16("bind on equip"); @@ -535,8 +535,8 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg) const unsigned char identified = msg.readUInt8("identify"); const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged); const uint8_t refine = msg.readUInt8("refine"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); if (serverVersion >= 8 && packetVersion >= 20150226) { @@ -736,8 +736,8 @@ void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg) uint8_t identified = msg.readUInt8("identified"); const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged); const uint8_t refine = msg.readUInt8("refine"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); if (serverVersion >= 8 && packetVersion >= 20150226) { @@ -807,8 +807,8 @@ void InventoryRecv::processPlayerCartEquip(Net::MessageIn &msg) msg.readInt32("location"); msg.readInt32("wear state"); const uint8_t refine = msg.readUInt8("refine level"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); msg.readInt32("hire expire date"); msg.readInt16("bind on equip"); @@ -856,8 +856,8 @@ void InventoryRecv::processPlayerCartItems(Net::MessageIn &msg) const int itemType = msg.readUInt8("item type"); const int amount = msg.readInt16("count"); msg.readInt32("wear state / equip"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); msg.readInt32("hire expire date (?)"); ItemFlags flags; @@ -964,7 +964,7 @@ void InventoryRecv::processPlayerRepairList(Net::MessageIn &msg) msg.readInt16("index"); msg.readInt16("item id"); msg.readUInt8("refine"); - for (int d = 0; d < 4; d ++) + for (int d = 0; d < maxCards; d ++) msg.readInt16("card"); } menu = MenuType::RepairWespon; @@ -989,7 +989,7 @@ void InventoryRecv::processPlayerRefineList(Net::MessageIn &msg) msg.readInt16("item index"); msg.readInt16("item id"); msg.readUInt8("refine"); - for (int d = 0; d < 4; d ++) + for (int d = 0; d < maxCards; d ++) msg.readInt16("card"); } menu = MenuType::WeaponeRefine; diff --git a/src/net/eathena/itemrecv.cpp b/src/net/eathena/itemrecv.cpp index de0eacd08..79892ebf7 100644 --- a/src/net/eathena/itemrecv.cpp +++ b/src/net/eathena/itemrecv.cpp @@ -26,6 +26,8 @@ #include "itemcolormanager.h" #include "logger.h" +#include "const/resources/item/cards.h" + #include "net/messagein.h" #include "debug.h" @@ -71,8 +73,8 @@ void ItemRecv::processItemDropped2(Net::MessageIn &msg) msg.readUInt8("identify"), Identified); const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged); const uint8_t refine = msg.readUInt8("refine"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); const int x = msg.readInt16("x"); const int y = msg.readInt16("y"); @@ -145,8 +147,8 @@ void ItemRecv::processItemVisible2(Net::MessageIn &msg) msg.readUInt8("identify"), Identified); const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged); const uint8_t refine = msg.readUInt8("refine"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); const int x = msg.readInt16("x"); const int y = msg.readInt16("y"); diff --git a/src/net/eathena/mailrecv.cpp b/src/net/eathena/mailrecv.cpp index 1198968ac..67ba37cf2 100644 --- a/src/net/eathena/mailrecv.cpp +++ b/src/net/eathena/mailrecv.cpp @@ -92,7 +92,7 @@ void MailRecv::processReadMail(Net::MessageIn &msg) mail->itemIdentify = msg.readUInt8("identify"); mail->itemAttribute = msg.readUInt8("attribute"); mail->itemRefine = msg.readUInt8("refine"); - for (int f = 0; f < 4; f ++) + for (int f = 0; f < maxCards; f ++) mail->card[f] = msg.readInt16("card"); const int msgLen = msg.readUInt8("msg len"); if (msgLen != sz) diff --git a/src/net/eathena/partyrecv.cpp b/src/net/eathena/partyrecv.cpp index b71b8d882..c5f04008f 100644 --- a/src/net/eathena/partyrecv.cpp +++ b/src/net/eathena/partyrecv.cpp @@ -26,6 +26,8 @@ #include "being/localplayer.h" +#include "const/resources/item/cards.h" + #include "enums/resources/notifytypes.h" #include "gui/windows/chatwindow.h" @@ -282,7 +284,7 @@ void PartyRecv::processPartyItemPickup(Net::MessageIn &msg) msg.readUInt8("identify"); msg.readUInt8("attribute"); msg.readUInt8("refine"); - for (int f = 0; f < 4; f++) + for (int f = 0; f < maxCards; f++) msg.readInt16("card"); msg.readInt16("equip location"); msg.readUInt8("item type"); diff --git a/src/net/eathena/searchstorerecv.cpp b/src/net/eathena/searchstorerecv.cpp index 5d2d57265..3fc2c26b8 100644 --- a/src/net/eathena/searchstorerecv.cpp +++ b/src/net/eathena/searchstorerecv.cpp @@ -23,6 +23,8 @@ #include "logger.h" #include "notifymanager.h" +#include "const/resources/item/cards.h" + #include "enums/resources/notifytypes.h" #include "net/messagein.h" @@ -49,7 +51,7 @@ void SearchStoreRecv::processSearchAck(Net::MessageIn &msg) msg.readInt32("price"); msg.readInt16("amount"); msg.readUInt8("refine"); - for (int d = 0; d < 4; d++) + for (int d = 0; d < maxCards; d++) msg.readInt16("card"); // +++ need use ItemColorManager for colors diff --git a/src/net/eathena/traderecv.cpp b/src/net/eathena/traderecv.cpp index 97dc6affd..cdae4788e 100644 --- a/src/net/eathena/traderecv.cpp +++ b/src/net/eathena/traderecv.cpp @@ -77,8 +77,8 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) const uint8_t identify = msg.readUInt8("identify"); const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged); const uint8_t refine = msg.readUInt8("refine"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); if (serverVersion >= 8 && packetVersion >= 20150226) { diff --git a/src/net/eathena/vendingrecv.cpp b/src/net/eathena/vendingrecv.cpp index 27e186d40..00618d53d 100644 --- a/src/net/eathena/vendingrecv.cpp +++ b/src/net/eathena/vendingrecv.cpp @@ -84,7 +84,7 @@ void VendingRecv::processItemsList(Net::MessageIn &msg) Being *const being = actorManager->findBeing(id); if (!being) return; - int cards[4]; + int cards[maxCards]; CREATEWIDGETV(mBuyDialog, BuyDialog, being->getName()); mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); msg.readInt32("vender id"); @@ -98,7 +98,7 @@ void VendingRecv::processItemsList(Net::MessageIn &msg) msg.readUInt8("identify"); msg.readUInt8("attribute"); msg.readUInt8("refine"); - for (int d = 0; d < 4; d ++) + for (int d = 0; d < maxCards; d ++) cards[d] = msg.readInt16("card"); if (serverVersion >= 8 && packetVersion >= 20150226) { @@ -141,7 +141,7 @@ void VendingRecv::processOpen(Net::MessageIn &msg) msg.readUInt8("identify"); msg.readUInt8("attribute"); msg.readUInt8("refine"); - for (int d = 0; d < 4; d ++) + for (int d = 0; d < maxCards; d ++) msg.readInt16("card"); if (serverVersion >= 8 && packetVersion >= 20150226) { diff --git a/src/net/tmwa/inventoryrecv.cpp b/src/net/tmwa/inventoryrecv.cpp index 897b8a274..ce59dc274 100644 --- a/src/net/tmwa/inventoryrecv.cpp +++ b/src/net/tmwa/inventoryrecv.cpp @@ -68,8 +68,8 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) const int equipType = msg.readInt16("equip type"); msg.readUInt8("attribute"); const uint8_t refine = msg.readUInt8("refine"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); if (Ea::InventoryRecv::mDebugInventory) @@ -121,8 +121,8 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) const uint8_t identified = msg.readUInt8("identified"); msg.readUInt8("attribute"); const uint8_t refine = msg.readUInt8("refine"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); const int equipType = msg.readInt16("equip type"); const int type = msg.readUInt8("item type"); @@ -234,14 +234,14 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) for (int loop = 0; loop < number; loop++) { - int cards[4]; + int cards[maxCards]; const int index = msg.readInt16("index") - INVENTORY_OFFSET; const int itemId = msg.readInt16("item id"); const uint8_t itemType = msg.readUInt8("item type"); const uint8_t identified = msg.readUInt8("identified"); const int amount = msg.readInt16("amount"); const int arrow = msg.readInt16("arrow"); - for (int i = 0; i < 4; i++) + for (int i = 0; i < maxCards; i++) cards[i] = msg.readInt16("card"); if (Ea::InventoryRecv::mDebugInventory) @@ -284,14 +284,14 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) for (int loop = 0; loop < number; loop++) { - int cards[4]; + int cards[maxCards]; const int index = msg.readInt16("index") - STORAGE_OFFSET; const int itemId = msg.readInt16("item id"); const uint8_t itemType = msg.readUInt8("item type"); const uint8_t identified = msg.readUInt8("identified"); const int amount = msg.readInt16("amount"); msg.readInt16("arrow"); - for (int i = 0; i < 4; i++) + for (int i = 0; i < maxCards; i++) cards[i] = msg.readInt16("card"); if (Ea::InventoryRecv::mDebugInventory) @@ -362,7 +362,7 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) for (int loop = 0; loop < number; loop++) { - int cards[4]; + int cards[maxCards]; const int index = msg.readInt16("index") - STORAGE_OFFSET; const int itemId = msg.readInt16("item id"); const uint8_t itemType = msg.readUInt8("item type"); @@ -372,7 +372,7 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) msg.readInt16("another equip point?"); msg.readUInt8("attribute (broken)"); const uint8_t refine = msg.readUInt8("refine"); - for (int i = 0; i < 4; i++) + for (int i = 0; i < maxCards; i++) cards[i] = msg.readInt16("card"); if (Ea::InventoryRecv::mDebugInventory) @@ -411,8 +411,8 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg) const unsigned char identified = msg.readUInt8("identified"); msg.readUInt8("attribute"); const uint8_t refine = msg.readUInt8("refine"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); if (Item *const item = Ea::InventoryRecv::mStorage->getItem(index)) diff --git a/src/net/tmwa/traderecv.cpp b/src/net/tmwa/traderecv.cpp index 48020eca3..feb65c3a6 100644 --- a/src/net/tmwa/traderecv.cpp +++ b/src/net/tmwa/traderecv.cpp @@ -64,8 +64,8 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) const uint8_t identify = msg.readUInt8("identify"); msg.readUInt8("attribute"); const uint8_t refine = msg.readUInt8("refine"); - int cards[4]; - for (int f = 0; f < 4; f++) + int cards[maxCards]; + for (int f = 0; f < maxCards; f++) cards[f] = msg.readInt16("card"); if (tradeWindow) diff --git a/src/resources/item/item.cpp b/src/resources/item/item.cpp index 3f67585ac..ae31dd94c 100644 --- a/src/resources/item/item.cpp +++ b/src/resources/item/item.cpp @@ -66,7 +66,7 @@ Item::Item(const int id, mFavorite(favorite) { setId(id, color); - for (int f = 0; f < 4; f ++) + for (int f = 0; f < maxCards; f ++) mCards[f] = 0; } diff --git a/src/resources/item/item.h b/src/resources/item/item.h index c287abd8c..9a910c31b 100644 --- a/src/resources/item/item.h +++ b/src/resources/item/item.h @@ -23,6 +23,8 @@ #ifndef RESOURCES_ITEM_ITEM_H #define RESOURCES_ITEM_ITEM_H +#include "const/resources/item/cards.h" + #include "enums/simpletypes/damaged.h" #include "enums/simpletypes/equipm.h" #include "enums/simpletypes/equipped.h" @@ -36,8 +38,6 @@ class Image; -const int maxCards = 4; - /** * Represents one or more instances of a certain item type. */ |