From 13c8bafad57bd081a3e87eb7e67a3a0d98734706 Mon Sep 17 00:00:00 2001 From: void_17 Date: Tue, 3 Mar 2026 06:14:34 +0700 Subject: Minor fixes 1. Improve const correctness in a few places (such as `Container::getMaxStackSize()` -> `Container::getMaxStackSize() const`) 2. Use C++11 varargs for `I18n::get`, `Entity::newDoubleList` and `Language::getElement` --- Minecraft.World/Inventory.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Minecraft.World/Inventory.cpp') diff --git a/Minecraft.World/Inventory.cpp b/Minecraft.World/Inventory.cpp index f6a136c9..1b9ff630 100644 --- a/Minecraft.World/Inventory.cpp +++ b/Minecraft.World/Inventory.cpp @@ -87,7 +87,7 @@ int Inventory::getSlotWithRemainingSpace(shared_ptr item) { for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL && items[i]->id == item->id && items[i]->isStackable() + if (items[i] != NULL && items[i]->id == item->id && items[i]->isStackable() && items[i]->count < items[i]->getMaxStackSize() && items[i]->count < getMaxStackSize() && (!items[i]->isStackedByData() || items[i]->getAuxValue() == item->getAuxValue()) && ItemInstance::tagMatches(items[i], item)) @@ -228,7 +228,7 @@ int Inventory::addResource(shared_ptr itemInstance) if (slot < 0) return count; if (items[slot] == NULL) { - items[slot] = ItemInstance::clone(itemInstance); + items[slot] = ItemInstance::clone(itemInstance); player->handleCollectItem(itemInstance); } return 0; @@ -299,14 +299,14 @@ bool Inventory::removeResource(int type,int iAuxVal) void Inventory::removeResources(shared_ptr item) { - if(item == NULL) return; + if(item == NULL) return; int countToRemove = item->count; for (unsigned int i = 0; i < items.length; i++) { if (items[i] != NULL && items[i]->sameItemWithTags(item)) { - int slotCount = items[i]->count; + int slotCount = items[i]->count; items[i]->count -= countToRemove; if(slotCount < countToRemove) { @@ -387,7 +387,7 @@ bool Inventory::add(shared_ptr item) { player->handleCollectItem(item); - player->awardStat( + player->awardStat( GenericStats::itemsCollected(item->id, item->getAuxValue()), GenericStats::param_itemsCollected(item->id, item->getAuxValue(), item->GetCount())); @@ -475,7 +475,7 @@ void Inventory::setItem(unsigned int slot, shared_ptr item) else { items[slot] = item; - } + } player->handleCollectItem(item); /* ItemInstanceArray& pile = items; @@ -592,7 +592,7 @@ bool Inventory::hasCustomName() return false; } -int Inventory::getMaxStackSize() +int Inventory::getMaxStackSize() const { return MAX_INVENTORY_STACK_SIZE; } -- cgit v1.2.3