diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-02-07 16:18:13 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-02-07 16:18:13 +0300 |
commit | 9fe21fcd8883b37bdc30224822e6e42afb35b8f0 (patch) | |
tree | 798117abd4dc7e610997d59d530a96ddc1509f53 /src/resources/inventory | |
parent | 4429cb14e9e187edef27aba692a4266733f79c17 (diff) | |
download | manaplus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.gz manaplus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.bz2 manaplus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.xz manaplus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.zip |
Replace most static_cast<Type> to shorter versions from defines.
Diffstat (limited to 'src/resources/inventory')
-rw-r--r-- | src/resources/inventory/complexinventory.cpp | 4 | ||||
-rw-r--r-- | src/resources/inventory/inventory.cpp | 24 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/resources/inventory/complexinventory.cpp b/src/resources/inventory/complexinventory.cpp index 06a8cf5c0..5264406cb 100644 --- a/src/resources/inventory/complexinventory.cpp +++ b/src/resources/inventory/complexinventory.cpp @@ -47,7 +47,7 @@ bool ComplexInventory::addVirtualItem(const Item *const item, if (!item || PlayerInfo::isItemProtected(item->getId())) return false; - if (index >= 0 && index < static_cast<int>(mSize)) + if (index >= 0 && index < CAST_S32(mSize)) { ComplexItem *citem = nullptr; if (mItems[index] != nullptr) @@ -126,7 +126,7 @@ void ComplexInventory::setItem(const int index, const Equipm equipment, const Equipped equipped) { - if (index < 0 || index >= static_cast<int>(mSize)) + if (index < 0 || index >= CAST_S32(mSize)) { logger->log("Warning: invalid inventory index: %d", index); return; diff --git a/src/resources/inventory/inventory.cpp b/src/resources/inventory/inventory.cpp index c73d9d8b6..f7f6dcaee 100644 --- a/src/resources/inventory/inventory.cpp +++ b/src/resources/inventory/inventory.cpp @@ -58,9 +58,9 @@ Inventory::Inventory(const InventoryTypeT type, const int size1) : mInventoryListeners(), mVirtualRemove(), mType(type), - mSize(size1 == -1 ? static_cast<unsigned>( + mSize(size1 == -1 ? CAST_U32( inventoryHandler->getSize(type)) - : static_cast<unsigned>(size1)), + : CAST_U32(size1)), mItems(new Item*[mSize]), mUsed(0) { @@ -78,7 +78,7 @@ Inventory::~Inventory() Item *Inventory::getItem(const int index) const { - if (index < 0 || index >= static_cast<int>(mSize) || !mItems[index] + if (index < 0 || index >= CAST_S32(mSize) || !mItems[index] || mItems[index]->mQuantity <= 0) { return nullptr; @@ -137,7 +137,7 @@ void Inventory::setItem(const int index, const Equipm equipment, const Equipped equipped) { - if (index < 0 || index >= static_cast<int>(mSize)) + if (index < 0 || index >= CAST_S32(mSize)) { logger->log("Warning: invalid inventory index: %d", index); return; @@ -173,7 +173,7 @@ void Inventory::setCards(const int index, const int *const cards, const int size) const { - if (index < 0 || index >= static_cast<int>(mSize)) + if (index < 0 || index >= CAST_S32(mSize)) { logger->log("Warning: invalid inventory index: %d", index); return; @@ -232,7 +232,7 @@ int Inventory::getFreeSlot() const Item **const i = std::find_if(mItems, mItems + mSize, std::not1(SlotUsed())); return (i == mItems + mSize) ? -1 - : static_cast<int>(i - mItems); + : CAST_S32(i - mItems); } int Inventory::getLastUsedSlot() const @@ -355,7 +355,7 @@ void Inventory::resize(const unsigned int newSize) delete [] mItems; mSize = newSize; - mItems = new Item*[static_cast<size_t>(mSize)]; + mItems = new Item*[CAST_SIZE(mSize)]; std::fill_n(mItems, mSize, static_cast<Item*>(nullptr)); } @@ -377,7 +377,7 @@ bool Inventory::addVirtualItem(const Item *const item, { if (item && !PlayerInfo::isItemProtected(item->getId())) { - if (index >= 0 && index < static_cast<int>(mSize)) + if (index >= 0 && index < CAST_S32(mSize)) { if (mItems[index] != nullptr) return false; @@ -434,7 +434,7 @@ void Inventory::virtualRemove(Item *const item, void Inventory::restoreVirtuals() { - const int sz = static_cast<int>(mSize); + const int sz = CAST_S32(mSize); logger->log("Inventory::restoreVirtuals 1"); FOR_EACH (IntMapCIter, it, mVirtualRemove) @@ -461,7 +461,7 @@ void Inventory::virtualRestore(const Item *const item, mVirtualRemove[index] -= amount; if (mVirtualRemove[index] < 0) mVirtualRemove.erase(index); - if (index < 0 || index >= static_cast<int>(mSize) || !mItems[index]) + if (index < 0 || index >= CAST_S32(mSize) || !mItems[index]) return; mItems[index]->mQuantity += amount; } @@ -471,9 +471,9 @@ void Inventory::moveItem(const int index1, const int index2) { if (index1 < 0 || - index1 >= static_cast<int>(mSize) || + index1 >= CAST_S32(mSize) || index2 < 0 || - index2 >= static_cast<int>(mSize)) + index2 >= CAST_S32(mSize)) { return; } |