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`
This commit is contained in:
void_17
2026-03-03 06:14:34 +07:00
parent 41ded31af8
commit 13c8bafad5
48 changed files with 176 additions and 217 deletions

View File

@@ -53,7 +53,7 @@ ChestTileEntity::~ChestTileEntity()
delete items;
}
unsigned int ChestTileEntity::getContainerSize()
unsigned int ChestTileEntity::getContainerSize()
{
return 9 * 3;
}
@@ -63,11 +63,11 @@ shared_ptr<ItemInstance> ChestTileEntity::getItem(unsigned int slot)
return items->data[slot];
}
shared_ptr<ItemInstance> ChestTileEntity::removeItem(unsigned int slot, int count)
shared_ptr<ItemInstance> ChestTileEntity::removeItem(unsigned int slot, int count)
{
if (items->data[slot] != NULL)
{
if (items->data[slot]->count <= count)
if (items->data[slot]->count <= count)
{
shared_ptr<ItemInstance> item = items->data[slot];
items->data[slot] = nullptr;
@@ -75,8 +75,8 @@ shared_ptr<ItemInstance> ChestTileEntity::removeItem(unsigned int slot, int coun
// 4J Stu - Fix for duplication glitch
if(item->count <= 0) return nullptr;
return item;
}
else
}
else
{
shared_ptr<ItemInstance> i = items->data[slot]->remove(count);
if (items->data[slot]->count == 0) items->data[slot] = nullptr;
@@ -154,7 +154,7 @@ void ChestTileEntity::save(CompoundTag *base)
for (unsigned int i = 0; i < items->length; i++)
{
if (items->data[i] != NULL)
if (items->data[i] != NULL)
{
CompoundTag *tag = new CompoundTag();
tag->putByte(L"Slot", (byte) i);
@@ -167,7 +167,7 @@ void ChestTileEntity::save(CompoundTag *base)
base->putBoolean(L"bonus", isBonusChest);
}
int ChestTileEntity::getMaxStackSize()
int ChestTileEntity::getMaxStackSize() const
{
return Container::LARGE_MAX_STACK_SIZE;
}
@@ -179,7 +179,7 @@ bool ChestTileEntity::stillValid(shared_ptr<Player> player)
return true;
}
void ChestTileEntity::setChanged()
void ChestTileEntity::setChanged()
{
TileEntity::setChanged();
}
@@ -302,7 +302,7 @@ void ChestTileEntity::tick()
if (s.lock() != NULL) zc += 0.5;
if (e.lock() != NULL) xc += 0.5;
// 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit
// 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit
level->playSound(xc, y + 0.5, zc, eSoundType_RANDOM_CHEST_OPEN, 0.2f, level->random->nextFloat() * 0.1f + 0.9f);
}
}
@@ -327,7 +327,7 @@ void ChestTileEntity::tick()
if (s.lock() != NULL) zc += 0.5;
if (e.lock() != NULL) xc += 0.5;
// 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit
// 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit
level->playSound(xc, y + 0.5, zc, eSoundType_RANDOM_CHEST_CLOSE, 0.2f, level->random->nextFloat() * 0.1f + 0.9f);
}
}