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

@@ -12,7 +12,7 @@ ArmorSlot::ArmorSlot(int slotNum, shared_ptr<Container> container, int id, int x
{ {
} }
int ArmorSlot::getMaxStackSize() int ArmorSlot::getMaxStackSize() const
{ {
return 1; return 1;
} }

View File

@@ -16,7 +16,7 @@ public:
ArmorSlot(int slotNum, shared_ptr<Container> container, int id, int x, int y); ArmorSlot(int slotNum, shared_ptr<Container> container, int id, int x, int y);
virtual ~ArmorSlot() {} virtual ~ArmorSlot() {}
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual bool mayPlace(shared_ptr<ItemInstance> item); virtual bool mayPlace(shared_ptr<ItemInstance> item);
Icon *getNoItemIcon(); Icon *getNoItemIcon();
//virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added //virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added

View File

@@ -134,7 +134,7 @@ bool BeaconMenu::PaymentSlot::mayPlace(shared_ptr<ItemInstance> item)
return false; return false;
} }
int BeaconMenu::PaymentSlot::getMaxStackSize() int BeaconMenu::PaymentSlot::getMaxStackSize() const
{ {
return 1; return 1;
} }

View File

@@ -14,7 +14,7 @@ private:
PaymentSlot(shared_ptr<Container> container, int slot, int x, int y); PaymentSlot(shared_ptr<Container> container, int slot, int x, int y);
bool mayPlace(shared_ptr<ItemInstance> item); bool mayPlace(shared_ptr<ItemInstance> item);
int getMaxStackSize(); int getMaxStackSize() const;
}; };
public: public:

View File

@@ -346,7 +346,7 @@ void BeaconTileEntity::setCustomName(const wstring &name)
this->name = name; this->name = name;
} }
int BeaconTileEntity::getMaxStackSize() int BeaconTileEntity::getMaxStackSize() const
{ {
return 1; return 1;
} }

View File

@@ -64,7 +64,7 @@ public:
wstring getCustomName(); wstring getCustomName();
bool hasCustomName(); bool hasCustomName();
void setCustomName(const wstring &name); void setCustomName(const wstring &name);
int getMaxStackSize(); int getMaxStackSize() const;
bool stillValid(shared_ptr<Player> player); bool stillValid(shared_ptr<Player> player);
void startOpen(); void startOpen();
void stopOpen(); void stopOpen();

View File

@@ -183,7 +183,7 @@ bool BrewingStandMenu::PotionSlot::mayPlace(shared_ptr<ItemInstance> item)
return mayPlaceItem(item); return mayPlaceItem(item);
} }
int BrewingStandMenu::PotionSlot::getMaxStackSize() int BrewingStandMenu::PotionSlot::getMaxStackSize() const
{ {
return 1; return 1;
} }
@@ -231,7 +231,7 @@ bool BrewingStandMenu::IngredientsSlot::mayCombine(shared_ptr<ItemInstance> seco
return false; return false;
} }
int BrewingStandMenu::IngredientsSlot::getMaxStackSize() int BrewingStandMenu::IngredientsSlot::getMaxStackSize() const
{ {
return 64; return 64;
} }

View File

@@ -47,7 +47,7 @@ private:
PotionSlot(shared_ptr<Player> player, shared_ptr<Container> container, int slot, int x, int y); PotionSlot(shared_ptr<Player> player, shared_ptr<Container> container, int slot, int x, int y);
virtual bool mayPlace(shared_ptr<ItemInstance> item); virtual bool mayPlace(shared_ptr<ItemInstance> item);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual void onTake(shared_ptr<Player> player, shared_ptr<ItemInstance> carried); virtual void onTake(shared_ptr<Player> player, shared_ptr<ItemInstance> carried);
static bool mayPlaceItem(shared_ptr<ItemInstance> item); static bool mayPlaceItem(shared_ptr<ItemInstance> item);
virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added
@@ -59,7 +59,7 @@ private:
IngredientsSlot(shared_ptr<Container> container, int slot, int x, int y); IngredientsSlot(shared_ptr<Container> container, int slot, int x, int y);
virtual bool mayPlace(shared_ptr<ItemInstance> item); virtual bool mayPlace(shared_ptr<ItemInstance> item);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added
}; };
}; };

View File

@@ -397,7 +397,7 @@ void BrewingStandTileEntity::setItem(unsigned int slot, shared_ptr<ItemInstance>
} }
} }
int BrewingStandTileEntity::getMaxStackSize() int BrewingStandTileEntity::getMaxStackSize() const
{ {
// this value is not used for the potion slots // this value is not used for the potion slots
return 64; return 64;

View File

@@ -45,7 +45,7 @@ public:
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int i); virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int i);
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot); virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item); virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual bool stillValid(shared_ptr<Player> player); virtual bool stillValid(shared_ptr<Player> player);
virtual void startOpen(); virtual void startOpen();
virtual void stopOpen(); virtual void stopOpen();

View File

@@ -167,7 +167,7 @@ void ChestTileEntity::save(CompoundTag *base)
base->putBoolean(L"bonus", isBonusChest); base->putBoolean(L"bonus", isBonusChest);
} }
int ChestTileEntity::getMaxStackSize() int ChestTileEntity::getMaxStackSize() const
{ {
return Container::LARGE_MAX_STACK_SIZE; return Container::LARGE_MAX_STACK_SIZE;
} }

View File

@@ -59,7 +59,7 @@ public:
virtual void setCustomName(const wstring &name); virtual void setCustomName(const wstring &name);
virtual void load(CompoundTag *base); virtual void load(CompoundTag *base);
virtual void save(CompoundTag *base); virtual void save(CompoundTag *base);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual bool stillValid(shared_ptr<Player> player); virtual bool stillValid(shared_ptr<Player> player);
virtual void setChanged(); virtual void setChanged();
virtual void clearCache(); virtual void clearCache();

View File

@@ -70,7 +70,7 @@ void CompoundContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item
else c1->setItem(slot, item); else c1->setItem(slot, item);
} }
int CompoundContainer::getMaxStackSize() int CompoundContainer::getMaxStackSize() const
{ {
return c1->getMaxStackSize(); return c1->getMaxStackSize();
} }

View File

@@ -24,7 +24,7 @@ public:
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int i); virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int i);
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot); virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item); virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual void setChanged(); virtual void setChanged();
virtual bool stillValid(shared_ptr<Player> player); virtual bool stillValid(shared_ptr<Player> player);

View File

@@ -20,7 +20,7 @@ public:
virtual wstring getName() = 0; virtual wstring getName() = 0;
virtual wstring getCustomName() = 0; // 4J Stu added for sending over the network virtual wstring getCustomName() = 0; // 4J Stu added for sending over the network
virtual bool hasCustomName() = 0; virtual bool hasCustomName() = 0;
virtual int getMaxStackSize() = 0; virtual int getMaxStackSize() const = 0;
virtual void setChanged() = 0; virtual void setChanged() = 0;
virtual bool stillValid(shared_ptr<Player> player) = 0; virtual bool stillValid(shared_ptr<Player> player) = 0;
virtual void startOpen() = 0; virtual void startOpen() = 0;

View File

@@ -95,7 +95,7 @@ void CraftingContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item
if(menu) menu->slotsChanged(); if(menu) menu->slotsChanged();
} }
int CraftingContainer::getMaxStackSize() int CraftingContainer::getMaxStackSize() const
{ {
return Container::LARGE_MAX_STACK_SIZE; return Container::LARGE_MAX_STACK_SIZE;
} }

View File

@@ -24,7 +24,7 @@ public:
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot); virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count); virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item); virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual void setChanged(); virtual void setChanged();
bool stillValid(shared_ptr<Player> player); bool stillValid(shared_ptr<Player> player);

View File

@@ -198,7 +198,7 @@ void DispenserTileEntity::save(CompoundTag *base)
if (hasCustomName()) base->putString(L"CustomName", name); if (hasCustomName()) base->putString(L"CustomName", name);
} }
int DispenserTileEntity::getMaxStackSize() int DispenserTileEntity::getMaxStackSize() const
{ {
return Container::LARGE_MAX_STACK_SIZE; return Container::LARGE_MAX_STACK_SIZE;
} }

View File

@@ -45,7 +45,7 @@ public:
virtual bool hasCustomName(); virtual bool hasCustomName();
virtual void load(CompoundTag *base); virtual void load(CompoundTag *base);
virtual void save(CompoundTag *base); virtual void save(CompoundTag *base);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual bool stillValid(shared_ptr<Player> player); virtual bool stillValid(shared_ptr<Player> player);
virtual void setChanged(); virtual void setChanged();

View File

@@ -6,7 +6,7 @@ EnchantmentContainer::EnchantmentContainer(EnchantmentMenu *menu) : SimpleContai
{ {
} }
int EnchantmentContainer::getMaxStackSize() int EnchantmentContainer::getMaxStackSize() const
{ {
return 1; return 1;
} }

View File

@@ -13,7 +13,7 @@ private:
EnchantmentMenu *m_menu; EnchantmentMenu *m_menu;
public: public:
EnchantmentContainer(EnchantmentMenu *menu); EnchantmentContainer(EnchantmentMenu *menu);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual void setChanged(); virtual void setChanged();
virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item); virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
}; };

View File

@@ -1468,25 +1468,17 @@ void Entity::onLoadedFromSave()
} }
ListTag<DoubleTag> *Entity::newDoubleList(unsigned int number, double firstValue, ...) template<typename ...Args>
ListTag<DoubleTag> *Entity::newDoubleList(unsigned int, double firstValue, Args... args)
{ {
ListTag<DoubleTag> *res = new ListTag<DoubleTag>(); ListTag<DoubleTag> *res = new ListTag<DoubleTag>();
// Add the first parameter to the ListTag // Add the first parameter to the ListTag
res->add( new DoubleTag(L"", firstValue ) ); res->add( new DoubleTag(L"", firstValue ) );
va_list vl; // use pre-C++17 fold trick (TODO: once we drop C++14 support, use C++14 fold expression)
va_start(vl,firstValue); using expander = int[];
(void)expander{0, (res->add(new DoubleTag(L"", static_cast<double>(args))), 0)...};
double val;
for (unsigned int i=1;i<number;i++)
{
val=va_arg(vl,double);
res->add(new DoubleTag(L"", val));
}
va_end(vl);
return res; return res;
} }

View File

@@ -304,7 +304,8 @@ public:
virtual void onLoadedFromSave(); virtual void onLoadedFromSave();
protected: protected:
ListTag<DoubleTag> *newDoubleList(unsigned int number, double firstValue, ...); template<typename ...Args>
ListTag<DoubleTag> *newDoubleList(unsigned int, double firstValue, Args... args);
ListTag<FloatTag> *newFloatList(unsigned int number, float firstValue, float secondValue); ListTag<FloatTag> *newFloatList(unsigned int number, float firstValue, float secondValue);
public: public:

View File

@@ -160,7 +160,7 @@ void FurnaceTileEntity::save(CompoundTag *base)
} }
int FurnaceTileEntity::getMaxStackSize() int FurnaceTileEntity::getMaxStackSize() const
{ {
return Container::LARGE_MAX_STACK_SIZE; return Container::LARGE_MAX_STACK_SIZE;
} }
@@ -250,7 +250,7 @@ void FurnaceTileEntity::tick()
bool FurnaceTileEntity::canBurn() bool FurnaceTileEntity::canBurn()
{ {
if (items[SLOT_INPUT] == NULL) return false; if (items[SLOT_INPUT] == NULL) return false;
ItemInstance *burnResult = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id); const ItemInstance *burnResult = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
if (burnResult == NULL) return false; if (burnResult == NULL) return false;
if (items[SLOT_RESULT] == NULL) return true; if (items[SLOT_RESULT] == NULL) return true;
if (!items[SLOT_RESULT]->sameItem_not_shared(burnResult)) return false; if (!items[SLOT_RESULT]->sameItem_not_shared(burnResult)) return false;
@@ -264,7 +264,7 @@ void FurnaceTileEntity::burn()
{ {
if (!canBurn()) return; if (!canBurn()) return;
ItemInstance *result = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id); const ItemInstance *result = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
if (items[SLOT_RESULT] == NULL) items[SLOT_RESULT] = result->copy(); if (items[SLOT_RESULT] == NULL) items[SLOT_RESULT] = result->copy();
else if (items[SLOT_RESULT]->id == result->id) items[SLOT_RESULT]->count++; else if (items[SLOT_RESULT]->id == result->id) items[SLOT_RESULT]->count++;

View File

@@ -57,7 +57,7 @@ public:
virtual void setCustomName(const wstring &name); virtual void setCustomName(const wstring &name);
virtual void load(CompoundTag *base); virtual void load(CompoundTag *base);
virtual void save(CompoundTag *base); virtual void save(CompoundTag *base);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
int getBurnProgress(int max); int getBurnProgress(int max);
int getLitProgress(int max); int getLitProgress(int max);
bool isLit(); bool isLit();

View File

@@ -131,7 +131,7 @@ void HopperTileEntity::setCustomName(const wstring &name)
this->name = name; this->name = name;
} }
int HopperTileEntity::getMaxStackSize() int HopperTileEntity::getMaxStackSize() const
{ {
return Container::LARGE_MAX_STACK_SIZE; return Container::LARGE_MAX_STACK_SIZE;
} }

View File

@@ -35,7 +35,7 @@ public:
virtual wstring getCustomName(); virtual wstring getCustomName();
virtual bool hasCustomName(); virtual bool hasCustomName();
virtual void setCustomName(const wstring &name); virtual void setCustomName(const wstring &name);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual bool stillValid(shared_ptr<Player> player); virtual bool stillValid(shared_ptr<Player> player);
virtual void startOpen(); virtual void startOpen();
virtual void stopOpen(); virtual void stopOpen();

View File

@@ -3,20 +3,3 @@
#include "I18n.h" #include "I18n.h"
Language *I18n::lang = Language::getInstance(); Language *I18n::lang = Language::getInstance();
wstring I18n::get(const wstring& id, ...)
{
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
return L"";
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
return id;
#else
va_list va;
va_start(va, id);
return I18n::get(id, va);
#endif
}
wstring I18n::get(const wstring& id, va_list args)
{
return lang->getElement(id, args);
}

View File

@@ -10,6 +10,9 @@ private:
static Language *lang; static Language *lang;
public: public:
static wstring get(const wstring& id, ...); template<typename ...Args>
static wstring get(const wstring& id, va_list args); static wstring get(Args... args)
{
return lang->getElement(std::forward<Args>(args)...);
}
}; };

View File

@@ -592,7 +592,7 @@ bool Inventory::hasCustomName()
return false; return false;
} }
int Inventory::getMaxStackSize() int Inventory::getMaxStackSize() const
{ {
return MAX_INVENTORY_STACK_SIZE; return MAX_INVENTORY_STACK_SIZE;
} }

View File

@@ -81,7 +81,7 @@ public:
wstring getName(); wstring getName();
wstring getCustomName(); wstring getCustomName();
bool hasCustomName(); bool hasCustomName();
int getMaxStackSize(); int getMaxStackSize() const;
bool canDestroy(Tile *tile); bool canDestroy(Tile *tile);
shared_ptr<ItemInstance> getArmor(int layer); shared_ptr<ItemInstance> getArmor(int layer);
int getArmorValue(); int getArmorValue();

View File

@@ -668,7 +668,7 @@ shared_ptr<ItemInstance> Item::useTimeDepleted(shared_ptr<ItemInstance> itemInst
return itemInstance; return itemInstance;
} }
int Item::getMaxStackSize() int Item::getMaxStackSize() const
{ {
return maxStackSize; return maxStackSize;
} }

View File

@@ -668,7 +668,7 @@ public:
virtual bool TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player); virtual bool TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
virtual shared_ptr<ItemInstance> use(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player); virtual shared_ptr<ItemInstance> use(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
virtual shared_ptr<ItemInstance> useTimeDepleted(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player); virtual shared_ptr<ItemInstance> useTimeDepleted(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual int getLevelDataForAuxValue(int auxValue); virtual int getLevelDataForAuxValue(int auxValue);
bool isStackedByData(); bool isStackedByData();

View File

@@ -169,7 +169,7 @@ void ItemInstance::load(CompoundTag *compoundTag)
} }
} }
int ItemInstance::getMaxStackSize() int ItemInstance::getMaxStackSize() const
{ {
return getItem()->getMaxStackSize(); return getItem()->getMaxStackSize();
} }
@@ -393,7 +393,7 @@ bool ItemInstance::sameItemWithTags(shared_ptr<ItemInstance> b)
} }
// 4J Stu - Added this for the one time when we compare with a non-shared pointer // 4J Stu - Added this for the one time when we compare with a non-shared pointer
bool ItemInstance::sameItem_not_shared(ItemInstance *b) bool ItemInstance::sameItem_not_shared(const ItemInstance *b)
{ {
return id == b->id && auxValue == b->auxValue; return id == b->id && auxValue == b->auxValue;
} }

View File

@@ -82,7 +82,7 @@ public:
shared_ptr<ItemInstance> useTimeDepleted(Level *level, shared_ptr<Player> player); shared_ptr<ItemInstance> useTimeDepleted(Level *level, shared_ptr<Player> player);
CompoundTag *save(CompoundTag *compoundTag); CompoundTag *save(CompoundTag *compoundTag);
void load(CompoundTag *compoundTag); void load(CompoundTag *compoundTag);
int getMaxStackSize(); int getMaxStackSize() const;
bool isStackable(); bool isStackable();
bool isDamageableItem(); bool isDamageableItem();
bool isStackedByData(); bool isStackedByData();
@@ -113,7 +113,7 @@ private:
public: public:
bool sameItem(shared_ptr<ItemInstance> b); bool sameItem(shared_ptr<ItemInstance> b);
bool sameItemWithTags(shared_ptr<ItemInstance> b); //4J Added bool sameItemWithTags(shared_ptr<ItemInstance> b); //4J Added
bool sameItem_not_shared(ItemInstance *b); // 4J Stu - Added this for the one time I need it bool sameItem_not_shared(const ItemInstance *b); // 4J Stu - Added this for the one time I need it
virtual unsigned int getUseDescriptionId(); // 4J Added virtual unsigned int getUseDescriptionId(); // 4J Added
virtual unsigned int getDescriptionId(int iData = -1); virtual unsigned int getDescriptionId(int iData = -1);
virtual ItemInstance *setDescriptionId(unsigned int id); virtual ItemInstance *setDescriptionId(unsigned int id);

View File

@@ -14,37 +14,12 @@ Language *Language::getInstance()
return singleton; return singleton;
} }
/* 4J Jev, creates 2 identical functions. std::wstring Language::getElementName(const std::wstring& elementId)
wstring Language::getElement(const wstring& elementId)
{
return elementId;
} */
wstring Language::getElement(const wstring& elementId, ...)
{
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
return L"";
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
return elementId;
#else
va_list args;
va_start(args, elementId);
return getElement(elementId, args);
#endif
}
wstring Language::getElement(const wstring& elementId, va_list args)
{
// 4J TODO
return elementId;
}
wstring Language::getElementName(const wstring& elementId)
{ {
return elementId; return elementId;
} }
wstring Language::getElementDescription(const wstring& elementId) std::wstring Language::getElementDescription(const std::wstring& elementId)
{ {
return elementId; return elementId;
} }

View File

@@ -1,5 +1,7 @@
#pragma once #pragma once
#include <string>
class Language class Language
{ {
private: private:
@@ -7,8 +9,11 @@ private:
public: public:
Language(); Language();
static Language *getInstance(); static Language *getInstance();
wstring getElement(const wstring& elementId, ...); template<typename...Args>
wstring getElement(const wstring& elementId, va_list args); inline std::wstring getElement(const std::wstring& elementId, Args...)
wstring getElementName(const wstring& elementId); {
wstring getElementDescription(const wstring& elementId); return elementId;
}
std::wstring getElementName(const std::wstring& elementId);
std::wstring getElementDescription(const std::wstring& elementId);
}; };

View File

@@ -105,7 +105,7 @@ bool MerchantContainer::hasCustomName()
return false; return false;
} }
int MerchantContainer::getMaxStackSize() int MerchantContainer::getMaxStackSize() const
{ {
return Container::LARGE_MAX_STACK_SIZE; return Container::LARGE_MAX_STACK_SIZE;
} }

View File

@@ -33,7 +33,7 @@ public:
wstring getName(); wstring getName();
wstring getCustomName(); wstring getCustomName();
bool hasCustomName(); bool hasCustomName();
int getMaxStackSize(); int getMaxStackSize() const;
bool stillValid(shared_ptr<Player> player); bool stillValid(shared_ptr<Player> player);
void startOpen(); void startOpen();
void stopOpen(); void stopOpen();

View File

@@ -127,7 +127,7 @@ wstring MinecartContainer::getName()
return hasCustomName() ? getCustomName() : app.GetString(IDS_CONTAINER_MINECART); return hasCustomName() ? getCustomName() : app.GetString(IDS_CONTAINER_MINECART);
} }
int MinecartContainer::getMaxStackSize() int MinecartContainer::getMaxStackSize() const
{ {
return Container::LARGE_MAX_STACK_SIZE; return Container::LARGE_MAX_STACK_SIZE;
} }

View File

@@ -26,7 +26,7 @@ public:
virtual void stopOpen(); virtual void stopOpen();
virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item); virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
virtual wstring getName(); virtual wstring getName();
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual void changeDimension(int i); virtual void changeDimension(int i);
virtual void remove(); virtual void remove();

View File

@@ -54,7 +54,7 @@ public:
virtual wstring getName() { return MinecartContainer::getName(); } virtual wstring getName() { return MinecartContainer::getName(); }
virtual wstring getCustomName() { return MinecartContainer::getCustomName(); } virtual wstring getCustomName() { return MinecartContainer::getCustomName(); }
virtual bool hasCustomName() { return MinecartContainer::hasCustomName(); } virtual bool hasCustomName() { return MinecartContainer::hasCustomName(); }
virtual int getMaxStackSize() { return MinecartContainer::getMaxStackSize(); } virtual int getMaxStackSize() const { return MinecartContainer::getMaxStackSize(); }
virtual void setChanged() { MinecartContainer::setChanged(); } virtual void setChanged() { MinecartContainer::setChanged(); }
virtual bool stillValid(shared_ptr<Player> player) { return MinecartContainer::stillValid(player); } virtual bool stillValid(shared_ptr<Player> player) { return MinecartContainer::stillValid(player); }

View File

@@ -58,7 +58,7 @@ void ResultContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
items[0] = item; items[0] = item;
} }
int ResultContainer::getMaxStackSize() int ResultContainer::getMaxStackSize() const
{ {
return Container::LARGE_MAX_STACK_SIZE; return Container::LARGE_MAX_STACK_SIZE;
} }

View File

@@ -19,7 +19,7 @@ public:
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count); virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot); virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item); virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual void setChanged(); virtual void setChanged();
virtual bool stillValid(shared_ptr<Player> player); virtual bool stillValid(shared_ptr<Player> player);
virtual void startOpen() { } // TODO Auto-generated method stub virtual void startOpen() { } // TODO Auto-generated method stub

View File

@@ -106,7 +106,7 @@ void SimpleContainer::setCustomName(const wstring &name)
this->stringName = name; this->stringName = name;
} }
int SimpleContainer::getMaxStackSize() int SimpleContainer::getMaxStackSize() const
{ {
return Container::LARGE_MAX_STACK_SIZE; return Container::LARGE_MAX_STACK_SIZE;
} }

View File

@@ -28,7 +28,7 @@ public:
virtual wstring getCustomName(); virtual wstring getCustomName();
virtual bool hasCustomName(); virtual bool hasCustomName();
virtual void setCustomName(const wstring &name); virtual void setCustomName(const wstring &name);
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual void setChanged(); virtual void setChanged();
virtual bool stillValid(shared_ptr<Player> player); virtual bool stillValid(shared_ptr<Player> player);
virtual void startOpen() { } // TODO Auto-generated method stub virtual void startOpen() { } // TODO Auto-generated method stub

View File

@@ -91,7 +91,7 @@ void Slot::setChanged()
container->setChanged(); container->setChanged();
} }
int Slot::getMaxStackSize() int Slot::getMaxStackSize() const
{ {
return container->getMaxStackSize(); return container->getMaxStackSize();
} }

View File

@@ -31,7 +31,7 @@ public:
virtual bool hasItem(); virtual bool hasItem();
virtual void set(shared_ptr<ItemInstance> item); virtual void set(shared_ptr<ItemInstance> item);
virtual void setChanged(); virtual void setChanged();
virtual int getMaxStackSize(); virtual int getMaxStackSize() const;
virtual Icon *getNoItemIcon(); virtual Icon *getNoItemIcon();
virtual shared_ptr<ItemInstance> remove(int c); virtual shared_ptr<ItemInstance> remove(int c);
virtual bool isAt(shared_ptr<Container> c, int s); virtual bool isAt(shared_ptr<Container> c, int s);