diff --git a/Minecraft.World/ArmorSlot.cpp b/Minecraft.World/ArmorSlot.cpp index 27993d77..7707635a 100644 --- a/Minecraft.World/ArmorSlot.cpp +++ b/Minecraft.World/ArmorSlot.cpp @@ -12,7 +12,7 @@ ArmorSlot::ArmorSlot(int slotNum, shared_ptr container, int id, int x { } -int ArmorSlot::getMaxStackSize() +int ArmorSlot::getMaxStackSize() const { return 1; } diff --git a/Minecraft.World/ArmorSlot.h b/Minecraft.World/ArmorSlot.h index a9797be2..d9d769ce 100644 --- a/Minecraft.World/ArmorSlot.h +++ b/Minecraft.World/ArmorSlot.h @@ -16,7 +16,7 @@ public: ArmorSlot(int slotNum, shared_ptr container, int id, int x, int y); virtual ~ArmorSlot() {} - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual bool mayPlace(shared_ptr item); Icon *getNoItemIcon(); //virtual bool mayCombine(shared_ptr item); // 4J Added diff --git a/Minecraft.World/BeaconMenu.cpp b/Minecraft.World/BeaconMenu.cpp index 707e9ebf..62908b4f 100644 --- a/Minecraft.World/BeaconMenu.cpp +++ b/Minecraft.World/BeaconMenu.cpp @@ -134,7 +134,7 @@ bool BeaconMenu::PaymentSlot::mayPlace(shared_ptr item) return false; } -int BeaconMenu::PaymentSlot::getMaxStackSize() +int BeaconMenu::PaymentSlot::getMaxStackSize() const { return 1; } \ No newline at end of file diff --git a/Minecraft.World/BeaconMenu.h b/Minecraft.World/BeaconMenu.h index 8d3afba6..9394d83f 100644 --- a/Minecraft.World/BeaconMenu.h +++ b/Minecraft.World/BeaconMenu.h @@ -14,7 +14,7 @@ private: PaymentSlot(shared_ptr container, int slot, int x, int y); bool mayPlace(shared_ptr item); - int getMaxStackSize(); + int getMaxStackSize() const; }; public: diff --git a/Minecraft.World/BeaconTileEntity.cpp b/Minecraft.World/BeaconTileEntity.cpp index 4b9a3882..9cfb0d67 100644 --- a/Minecraft.World/BeaconTileEntity.cpp +++ b/Minecraft.World/BeaconTileEntity.cpp @@ -346,7 +346,7 @@ void BeaconTileEntity::setCustomName(const wstring &name) this->name = name; } -int BeaconTileEntity::getMaxStackSize() +int BeaconTileEntity::getMaxStackSize() const { return 1; } diff --git a/Minecraft.World/BeaconTileEntity.h b/Minecraft.World/BeaconTileEntity.h index 1b6067a1..caab25e7 100644 --- a/Minecraft.World/BeaconTileEntity.h +++ b/Minecraft.World/BeaconTileEntity.h @@ -64,7 +64,7 @@ public: wstring getCustomName(); bool hasCustomName(); void setCustomName(const wstring &name); - int getMaxStackSize(); + int getMaxStackSize() const; bool stillValid(shared_ptr player); void startOpen(); void stopOpen(); diff --git a/Minecraft.World/BrewingStandMenu.cpp b/Minecraft.World/BrewingStandMenu.cpp index 55eb953f..eaf78329 100644 --- a/Minecraft.World/BrewingStandMenu.cpp +++ b/Minecraft.World/BrewingStandMenu.cpp @@ -101,7 +101,7 @@ shared_ptr BrewingStandMenu::quickMoveStack(shared_ptr pla else if (slotIndex >= INV_SLOT_START && slotIndex < INV_SLOT_END) { // 4J-PB - if the item is an ingredient, quickmove it into the ingredient slot - if( (Item::items[stack->id]->hasPotionBrewingFormula() || (stack->id == Item::netherwart_seeds_Id) ) && + if( (Item::items[stack->id]->hasPotionBrewingFormula() || (stack->id == Item::netherwart_seeds_Id) ) && (!IngredientSlot->hasItem() || (stack->id==IngredientSlot->getItem()->id) ) ) { if(!moveItemStackTo(stack, INGREDIENT_SLOT, INGREDIENT_SLOT+1, false)) @@ -125,7 +125,7 @@ shared_ptr BrewingStandMenu::quickMoveStack(shared_ptr pla else if (slotIndex >= USE_ROW_SLOT_START && slotIndex < USE_ROW_SLOT_END) { // 4J-PB - if the item is an ingredient, quickmove it into the ingredient slot - if((Item::items[stack->id]->hasPotionBrewingFormula() || (stack->id == Item::netherwart_seeds_Id)) && + if((Item::items[stack->id]->hasPotionBrewingFormula() || (stack->id == Item::netherwart_seeds_Id)) && (!IngredientSlot->hasItem() || (stack->id==IngredientSlot->getItem()->id) )) { if(!moveItemStackTo(stack, INGREDIENT_SLOT, INGREDIENT_SLOT+1, false)) @@ -140,7 +140,7 @@ shared_ptr BrewingStandMenu::quickMoveStack(shared_ptr pla { return nullptr; } - } + } else if (!moveItemStackTo(stack, INV_SLOT_START, INV_SLOT_END, false)) { return nullptr; @@ -183,7 +183,7 @@ bool BrewingStandMenu::PotionSlot::mayPlace(shared_ptr item) return mayPlaceItem(item); } -int BrewingStandMenu::PotionSlot::getMaxStackSize() +int BrewingStandMenu::PotionSlot::getMaxStackSize() const { return 1; } @@ -231,7 +231,7 @@ bool BrewingStandMenu::IngredientsSlot::mayCombine(shared_ptr seco return false; } -int BrewingStandMenu::IngredientsSlot::getMaxStackSize() +int BrewingStandMenu::IngredientsSlot::getMaxStackSize() const { return 64; } diff --git a/Minecraft.World/BrewingStandMenu.h b/Minecraft.World/BrewingStandMenu.h index 1f8d705d..fded12d2 100644 --- a/Minecraft.World/BrewingStandMenu.h +++ b/Minecraft.World/BrewingStandMenu.h @@ -47,7 +47,7 @@ private: PotionSlot(shared_ptr player, shared_ptr container, int slot, int x, int y); virtual bool mayPlace(shared_ptr item); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual void onTake(shared_ptr player, shared_ptr carried); static bool mayPlaceItem(shared_ptr item); virtual bool mayCombine(shared_ptr item); // 4J Added @@ -59,7 +59,7 @@ private: IngredientsSlot(shared_ptr container, int slot, int x, int y); virtual bool mayPlace(shared_ptr item); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual bool mayCombine(shared_ptr item); // 4J Added }; }; \ No newline at end of file diff --git a/Minecraft.World/BrewingStandTileEntity.cpp b/Minecraft.World/BrewingStandTileEntity.cpp index 00170d7b..5bc6fd27 100644 --- a/Minecraft.World/BrewingStandTileEntity.cpp +++ b/Minecraft.World/BrewingStandTileEntity.cpp @@ -10,7 +10,7 @@ int slotsForUp [] = { BrewingStandTileEntity::INGREDIENT_SLOT }; int slotsForOtherFaces [] = { 0, 1, 2 }; -intArray BrewingStandTileEntity::SLOTS_FOR_UP = intArray(slotsForUp, 1); +intArray BrewingStandTileEntity::SLOTS_FOR_UP = intArray(slotsForUp, 1); intArray BrewingStandTileEntity::SLOTS_FOR_OTHER_FACES = intArray(slotsForOtherFaces, 3); BrewingStandTileEntity::BrewingStandTileEntity() @@ -156,7 +156,7 @@ bool BrewingStandTileEntity::isBrewable() } else { - if (!Item::items[ingredient->id]->hasPotionBrewingFormula() && ingredient->id != Item::bucket_water_Id && ingredient->id != Item::netherwart_seeds_Id) + if (!Item::items[ingredient->id]->hasPotionBrewingFormula() && ingredient->id != Item::bucket_water_Id && ingredient->id != Item::netherwart_seeds_Id) { return false; } @@ -327,7 +327,7 @@ void BrewingStandTileEntity::save(CompoundTag *base) for (int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != NULL) { CompoundTag *tag = new CompoundTag(); tag->putByte(L"Slot", (byte) i); @@ -356,7 +356,7 @@ shared_ptr BrewingStandTileEntity::removeItem(unsigned int slot, i if (slot >= 0 && slot < items.length && items[slot] != NULL) { - if (items[slot]->count <= count) + if (items[slot]->count <= count) { shared_ptr item = items[slot]; items[slot] = nullptr; @@ -364,8 +364,8 @@ shared_ptr BrewingStandTileEntity::removeItem(unsigned int slot, i // 4J Stu - Fix for duplication glitch if(item->count <= 0) return nullptr; return item; - } - else + } + else { shared_ptr i = items[slot]->remove(count); if (items[slot]->count == 0) items[slot] = nullptr; @@ -397,7 +397,7 @@ void BrewingStandTileEntity::setItem(unsigned int slot, shared_ptr } } -int BrewingStandTileEntity::getMaxStackSize() +int BrewingStandTileEntity::getMaxStackSize() const { // this value is not used for the potion slots return 64; diff --git a/Minecraft.World/BrewingStandTileEntity.h b/Minecraft.World/BrewingStandTileEntity.h index 52d3a0f1..c848767e 100644 --- a/Minecraft.World/BrewingStandTileEntity.h +++ b/Minecraft.World/BrewingStandTileEntity.h @@ -12,7 +12,7 @@ public: private: ItemInstanceArray items; - static intArray SLOTS_FOR_UP; + static intArray SLOTS_FOR_UP; static intArray SLOTS_FOR_OTHER_FACES; int brewTime; @@ -37,7 +37,7 @@ private: void doBrew(); int applyIngredient(int currentBrew, shared_ptr ingredient); - + public: virtual void load(CompoundTag *base); virtual void save(CompoundTag *base); @@ -45,7 +45,7 @@ public: virtual shared_ptr removeItem(unsigned int slot, int i); virtual shared_ptr removeItemNoUpdate(int slot); virtual void setItem(unsigned int slot, shared_ptr item); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual bool stillValid(shared_ptr player); virtual void startOpen(); virtual void stopOpen(); diff --git a/Minecraft.World/ChestTileEntity.cpp b/Minecraft.World/ChestTileEntity.cpp index 39f957bd..fded7d28 100644 --- a/Minecraft.World/ChestTileEntity.cpp +++ b/Minecraft.World/ChestTileEntity.cpp @@ -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 ChestTileEntity::getItem(unsigned int slot) return items->data[slot]; } -shared_ptr ChestTileEntity::removeItem(unsigned int slot, int count) +shared_ptr 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 item = items->data[slot]; items->data[slot] = nullptr; @@ -75,8 +75,8 @@ shared_ptr 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 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) 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); } } diff --git a/Minecraft.World/ChestTileEntity.h b/Minecraft.World/ChestTileEntity.h index 77c11e99..d655340f 100644 --- a/Minecraft.World/ChestTileEntity.h +++ b/Minecraft.World/ChestTileEntity.h @@ -59,7 +59,7 @@ public: virtual void setCustomName(const wstring &name); virtual void load(CompoundTag *base); virtual void save(CompoundTag *base); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual bool stillValid(shared_ptr player); virtual void setChanged(); virtual void clearCache(); diff --git a/Minecraft.World/CompoundContainer.cpp b/Minecraft.World/CompoundContainer.cpp index 674f15db..39da0e58 100644 --- a/Minecraft.World/CompoundContainer.cpp +++ b/Minecraft.World/CompoundContainer.cpp @@ -70,7 +70,7 @@ void CompoundContainer::setItem(unsigned int slot, shared_ptr item else c1->setItem(slot, item); } -int CompoundContainer::getMaxStackSize() +int CompoundContainer::getMaxStackSize() const { return c1->getMaxStackSize(); } diff --git a/Minecraft.World/CompoundContainer.h b/Minecraft.World/CompoundContainer.h index 126a712a..906a0618 100644 --- a/Minecraft.World/CompoundContainer.h +++ b/Minecraft.World/CompoundContainer.h @@ -24,7 +24,7 @@ public: virtual shared_ptr removeItem(unsigned int slot, int i); virtual shared_ptr removeItemNoUpdate(int slot); virtual void setItem(unsigned int slot, shared_ptr item); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual void setChanged(); virtual bool stillValid(shared_ptr player); diff --git a/Minecraft.World/Container.h b/Minecraft.World/Container.h index 8fa21345..bfd7a9b7 100644 --- a/Minecraft.World/Container.h +++ b/Minecraft.World/Container.h @@ -20,7 +20,7 @@ public: virtual wstring getName() = 0; virtual wstring getCustomName() = 0; // 4J Stu added for sending over the network virtual bool hasCustomName() = 0; - virtual int getMaxStackSize() = 0; + virtual int getMaxStackSize() const = 0; virtual void setChanged() = 0; virtual bool stillValid(shared_ptr player) = 0; virtual void startOpen() = 0; diff --git a/Minecraft.World/CraftingContainer.cpp b/Minecraft.World/CraftingContainer.cpp index 7057edfe..47a11eb4 100644 --- a/Minecraft.World/CraftingContainer.cpp +++ b/Minecraft.World/CraftingContainer.cpp @@ -95,7 +95,7 @@ void CraftingContainer::setItem(unsigned int slot, shared_ptr item if(menu) menu->slotsChanged(); } -int CraftingContainer::getMaxStackSize() +int CraftingContainer::getMaxStackSize() const { return Container::LARGE_MAX_STACK_SIZE; } diff --git a/Minecraft.World/CraftingContainer.h b/Minecraft.World/CraftingContainer.h index fc8c2967..489dc84d 100644 --- a/Minecraft.World/CraftingContainer.h +++ b/Minecraft.World/CraftingContainer.h @@ -24,7 +24,7 @@ public: virtual shared_ptr removeItemNoUpdate(int slot); virtual shared_ptr removeItem(unsigned int slot, int count); virtual void setItem(unsigned int slot, shared_ptr item); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual void setChanged(); bool stillValid(shared_ptr player); diff --git a/Minecraft.World/DispenserTileEntity.cpp b/Minecraft.World/DispenserTileEntity.cpp index b087e535..3e743e22 100644 --- a/Minecraft.World/DispenserTileEntity.cpp +++ b/Minecraft.World/DispenserTileEntity.cpp @@ -23,7 +23,7 @@ DispenserTileEntity::~DispenserTileEntity() delete random; } -unsigned int DispenserTileEntity::getContainerSize() +unsigned int DispenserTileEntity::getContainerSize() { return 9; } @@ -33,7 +33,7 @@ shared_ptr DispenserTileEntity::getItem(unsigned int slot) return items[slot]; } -shared_ptr DispenserTileEntity::removeItem(unsigned int slot, int count) +shared_ptr DispenserTileEntity::removeItem(unsigned int slot, int count) { if (items[slot] != NULL) { @@ -45,8 +45,8 @@ shared_ptr DispenserTileEntity::removeItem(unsigned int slot, int // 4J Stu - Fix for duplication glitch if(item->count <= 0) return nullptr; return item; - } - else + } + else { shared_ptr i = items[slot]->remove(count); if (items[slot]->count == 0) items[slot] = nullptr; @@ -71,7 +71,7 @@ shared_ptr DispenserTileEntity::removeItemNoUpdate(int slot) } // 4J-PB added for spawn eggs not being useable due to limits, so add them in again -void DispenserTileEntity::AddItemBack(shared_ptritem, unsigned int slot) +void DispenserTileEntity::AddItemBack(shared_ptritem, unsigned int slot) { if (items[slot] != NULL) { @@ -80,7 +80,7 @@ void DispenserTileEntity::AddItemBack(shared_ptritem, unsigned int { items[slot]->count++; setChanged(); - } + } } else { @@ -91,7 +91,7 @@ void DispenserTileEntity::AddItemBack(shared_ptritem, unsigned int } /** * Removes an item with the given id and returns true if one was found. -* +* * @param itemId * @return */ @@ -114,7 +114,7 @@ int DispenserTileEntity::getRandomSlot() int replaceOdds = 1; for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL && random->nextInt(replaceOdds++) == 0) + if (items[i] != NULL && random->nextInt(replaceOdds++) == 0) { replaceSlot = i; } @@ -123,7 +123,7 @@ int DispenserTileEntity::getRandomSlot() return replaceSlot; } -void DispenserTileEntity::setItem(unsigned int slot, shared_ptr item) +void DispenserTileEntity::setItem(unsigned int slot, shared_ptr item) { items[slot] = item; if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); @@ -144,7 +144,7 @@ int DispenserTileEntity::addItem(shared_ptr item) return -1; } -wstring DispenserTileEntity::getName() +wstring DispenserTileEntity::getName() { return hasCustomName() ? name : app.GetString(IDS_TILE_DISPENSER); } @@ -184,7 +184,7 @@ void DispenserTileEntity::save(CompoundTag *base) TileEntity::save(base); ListTag *listTag = new ListTag; - for (unsigned int i = 0; i < items.length; i++) + for (unsigned int i = 0; i < items.length; i++) { if (items[i] != NULL) { @@ -198,7 +198,7 @@ void DispenserTileEntity::save(CompoundTag *base) if (hasCustomName()) base->putString(L"CustomName", name); } -int DispenserTileEntity::getMaxStackSize() +int DispenserTileEntity::getMaxStackSize() const { return Container::LARGE_MAX_STACK_SIZE; } diff --git a/Minecraft.World/DispenserTileEntity.h b/Minecraft.World/DispenserTileEntity.h index fc0c1f39..6c87d924 100644 --- a/Minecraft.World/DispenserTileEntity.h +++ b/Minecraft.World/DispenserTileEntity.h @@ -45,7 +45,7 @@ public: virtual bool hasCustomName(); virtual void load(CompoundTag *base); virtual void save(CompoundTag *base); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual bool stillValid(shared_ptr player); virtual void setChanged(); @@ -55,5 +55,5 @@ public: // 4J Added virtual shared_ptr clone(); - void AddItemBack(shared_ptritem, unsigned int slot); + void AddItemBack(shared_ptritem, unsigned int slot); }; \ No newline at end of file diff --git a/Minecraft.World/EnchantmentContainer.cpp b/Minecraft.World/EnchantmentContainer.cpp index 166e8d5f..068b6672 100644 --- a/Minecraft.World/EnchantmentContainer.cpp +++ b/Minecraft.World/EnchantmentContainer.cpp @@ -6,7 +6,7 @@ EnchantmentContainer::EnchantmentContainer(EnchantmentMenu *menu) : SimpleContai { } -int EnchantmentContainer::getMaxStackSize() +int EnchantmentContainer::getMaxStackSize() const { return 1; } diff --git a/Minecraft.World/EnchantmentContainer.h b/Minecraft.World/EnchantmentContainer.h index 8b337f48..4ccbea69 100644 --- a/Minecraft.World/EnchantmentContainer.h +++ b/Minecraft.World/EnchantmentContainer.h @@ -13,7 +13,7 @@ private: EnchantmentMenu *m_menu; public: EnchantmentContainer(EnchantmentMenu *menu); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual void setChanged(); virtual bool canPlaceItem(int slot, shared_ptr item); }; \ No newline at end of file diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index f1c2259c..cfae1772 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -420,7 +420,7 @@ void Entity::remove() void Entity::setSize(float w, float h) { - if (w != bbWidth || h != bbHeight) + if (w != bbWidth || h != bbHeight) { float oldW = bbWidth; @@ -431,7 +431,7 @@ void Entity::setSize(float w, float h) bb->z1 = bb->z0 + bbWidth; bb->y1 = bb->y0 + bbHeight; - if (bbWidth > oldW && !firstTick && !level->isClientSide) + if (bbWidth > oldW && !firstTick && !level->isClientSide) { move(oldW - bbWidth, 0, oldW - bbWidth); } @@ -449,7 +449,7 @@ void Entity::setPos(EntityPos *pos) void Entity::setRot(float yRot, float xRot) { - /* JAVA: + /* JAVA: this->yRot = yRot % 360.0f; this->xRot = xRot % 360.0f; @@ -585,7 +585,7 @@ void Entity::baseTick() { onFire = 0; } - else + else { if (onFire > 0) { @@ -1031,7 +1031,7 @@ void Entity::checkFallDamage(double ya, bool onGround) causeFallDamage(fallDistance); fallDistance = 0; } - } + } else { if (ya < 0) fallDistance -= (float) ya; @@ -1100,7 +1100,7 @@ bool Entity::updateInWaterState() fallDistance = 0; wasInWater = true; onFire = 0; - } + } else { wasInWater = false; @@ -1468,25 +1468,17 @@ void Entity::onLoadedFromSave() } -ListTag *Entity::newDoubleList(unsigned int number, double firstValue, ...) +template +ListTag *Entity::newDoubleList(unsigned int, double firstValue, Args... args) { ListTag *res = new ListTag(); // Add the first parameter to the ListTag res->add( new DoubleTag(L"", firstValue ) ); - va_list vl; - va_start(vl,firstValue); - - double val; - - for (unsigned int i=1;iadd(new DoubleTag(L"", val)); - } - - va_end(vl); + // use pre-C++17 fold trick (TODO: once we drop C++14 support, use C++14 fold expression) + using expander = int[]; + (void)expander{0, (res->add(new DoubleTag(L"", static_cast(args))), 0)...}; return res; } @@ -1573,7 +1565,7 @@ bool Entity::interact(shared_ptr player) return false; } -AABB *Entity::getCollideAgainstBox(shared_ptr entity) +AABB *Entity::getCollideAgainstBox(shared_ptr entity) { return NULL; } @@ -1842,7 +1834,7 @@ void Entity::setSharedFlag(int flag, bool value) if( entityData ) { byte currentValue = entityData->getByte(DATA_SHARED_FLAGS_ID); - if (value) + if (value) { entityData->set(DATA_SHARED_FLAGS_ID, (byte) (currentValue | (1 << flag))); } @@ -2121,13 +2113,13 @@ wstring Entity::getNetworkName() return getDisplayName(); } -void Entity::setAnimOverrideBitmask(unsigned int uiBitmask) +void Entity::setAnimOverrideBitmask(unsigned int uiBitmask) { m_uiAnimOverrideBitmask=uiBitmask; app.DebugPrintf("!!! Setting anim override bitmask to %d\n",uiBitmask); } -unsigned int Entity::getAnimOverrideBitmask() -{ +unsigned int Entity::getAnimOverrideBitmask() +{ if(app.GetGameSettings(eGameSetting_CustomSkinAnim)==0 ) { // We have a force animation for some skins (claptrap) diff --git a/Minecraft.World/Entity.h b/Minecraft.World/Entity.h index e2a26290..a738c2ba 100644 --- a/Minecraft.World/Entity.h +++ b/Minecraft.World/Entity.h @@ -304,7 +304,8 @@ public: virtual void onLoadedFromSave(); protected: - ListTag *newDoubleList(unsigned int number, double firstValue, ...); + template + ListTag *newDoubleList(unsigned int, double firstValue, Args... args); ListTag *newFloatList(unsigned int number, float firstValue, float secondValue); public: diff --git a/Minecraft.World/FurnaceTileEntity.cpp b/Minecraft.World/FurnaceTileEntity.cpp index a11e8527..1aa2c300 100644 --- a/Minecraft.World/FurnaceTileEntity.cpp +++ b/Minecraft.World/FurnaceTileEntity.cpp @@ -160,7 +160,7 @@ void FurnaceTileEntity::save(CompoundTag *base) } -int FurnaceTileEntity::getMaxStackSize() +int FurnaceTileEntity::getMaxStackSize() const { return Container::LARGE_MAX_STACK_SIZE; } @@ -205,7 +205,7 @@ void FurnaceTileEntity::tick() if (items[SLOT_FUEL] != NULL) { // 4J Added: Keep track of whether charcoal was used in production of current stack. - if ( items[SLOT_FUEL]->getItem()->id == Item::coal_Id + if ( items[SLOT_FUEL]->getItem()->id == Item::coal_Id && items[SLOT_FUEL]->getAuxValue() == CoalItem::CHAR_COAL) { m_charcoalUsed = true; @@ -250,7 +250,7 @@ void FurnaceTileEntity::tick() bool FurnaceTileEntity::canBurn() { 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 (items[SLOT_RESULT] == NULL) return true; if (!items[SLOT_RESULT]->sameItem_not_shared(burnResult)) return false; @@ -264,7 +264,7 @@ void FurnaceTileEntity::burn() { 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(); else if (items[SLOT_RESULT]->id == result->id) items[SLOT_RESULT]->count++; diff --git a/Minecraft.World/FurnaceTileEntity.h b/Minecraft.World/FurnaceTileEntity.h index 2907a4ca..c77f8e44 100644 --- a/Minecraft.World/FurnaceTileEntity.h +++ b/Minecraft.World/FurnaceTileEntity.h @@ -57,7 +57,7 @@ public: virtual void setCustomName(const wstring &name); virtual void load(CompoundTag *base); virtual void save(CompoundTag *base); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; int getBurnProgress(int max); int getLitProgress(int max); bool isLit(); diff --git a/Minecraft.World/HopperTileEntity.cpp b/Minecraft.World/HopperTileEntity.cpp index 77cb8152..38a0e817 100644 --- a/Minecraft.World/HopperTileEntity.cpp +++ b/Minecraft.World/HopperTileEntity.cpp @@ -131,7 +131,7 @@ void HopperTileEntity::setCustomName(const wstring &name) this->name = name; } -int HopperTileEntity::getMaxStackSize() +int HopperTileEntity::getMaxStackSize() const { return Container::LARGE_MAX_STACK_SIZE; } diff --git a/Minecraft.World/HopperTileEntity.h b/Minecraft.World/HopperTileEntity.h index 2e84ffdb..cfd2fabf 100644 --- a/Minecraft.World/HopperTileEntity.h +++ b/Minecraft.World/HopperTileEntity.h @@ -35,7 +35,7 @@ public: virtual wstring getCustomName(); virtual bool hasCustomName(); virtual void setCustomName(const wstring &name); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual bool stillValid(shared_ptr player); virtual void startOpen(); virtual void stopOpen(); diff --git a/Minecraft.World/I18n.cpp b/Minecraft.World/I18n.cpp index 81d3dff5..4805cdfe 100644 --- a/Minecraft.World/I18n.cpp +++ b/Minecraft.World/I18n.cpp @@ -3,20 +3,3 @@ #include "I18n.h" 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); -} diff --git a/Minecraft.World/I18n.h b/Minecraft.World/I18n.h index 0a43fe20..f459f4de 100644 --- a/Minecraft.World/I18n.h +++ b/Minecraft.World/I18n.h @@ -10,6 +10,9 @@ private: static Language *lang; public: - static wstring get(const wstring& id, ...); - static wstring get(const wstring& id, va_list args); + template + static wstring get(Args... args) + { + return lang->getElement(std::forward(args)...); + } }; \ No newline at end of file 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; } diff --git a/Minecraft.World/Inventory.h b/Minecraft.World/Inventory.h index 5c49e904..db5f42d6 100644 --- a/Minecraft.World/Inventory.h +++ b/Minecraft.World/Inventory.h @@ -81,7 +81,7 @@ public: wstring getName(); wstring getCustomName(); bool hasCustomName(); - int getMaxStackSize(); + int getMaxStackSize() const; bool canDestroy(Tile *tile); shared_ptr getArmor(int layer); int getArmorValue(); diff --git a/Minecraft.World/Item.cpp b/Minecraft.World/Item.cpp index 35768ac1..2f23ab8c 100644 --- a/Minecraft.World/Item.cpp +++ b/Minecraft.World/Item.cpp @@ -291,12 +291,12 @@ void Item::staticCtor() Item::helmet_iron = (ArmorItem *) ( ( new ArmorItem(50, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_iron) ->setIconName(L"helmetIron")->setDescriptionId(IDS_ITEM_HELMET_IRON)->setUseDescriptionId(IDS_DESC_HELMET_IRON) ); Item::helmet_diamond = (ArmorItem *) ( ( new ArmorItem(54, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_diamond) ->setIconName(L"helmetDiamond")->setDescriptionId(IDS_ITEM_HELMET_DIAMOND)->setUseDescriptionId(IDS_DESC_HELMET_DIAMOND) ); Item::helmet_gold = (ArmorItem *) ( ( new ArmorItem(58, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_gold) ->setIconName(L"helmetGold")->setDescriptionId(IDS_ITEM_HELMET_GOLD)->setUseDescriptionId(IDS_DESC_HELMET_GOLD) ); - + Item::chestplate_leather = (ArmorItem *) ( ( new ArmorItem(43, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_cloth) ->setIconName(L"chestplateCloth")->setDescriptionId(IDS_ITEM_CHESTPLATE_CLOTH)->setUseDescriptionId(IDS_DESC_CHESTPLATE_LEATHER) ); Item::chestplate_iron = (ArmorItem *) ( ( new ArmorItem(51, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_iron) ->setIconName(L"chestplateIron")->setDescriptionId(IDS_ITEM_CHESTPLATE_IRON)->setUseDescriptionId(IDS_DESC_CHESTPLATE_IRON) ); Item::chestplate_diamond = (ArmorItem *) ( ( new ArmorItem(55, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_diamond) ->setIconName(L"chestplateDiamond")->setDescriptionId(IDS_ITEM_CHESTPLATE_DIAMOND)->setUseDescriptionId(IDS_DESC_CHESTPLATE_DIAMOND) ); Item::chestplate_gold = (ArmorItem *) ( ( new ArmorItem(59, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_gold) ->setIconName(L"chestplateGold")->setDescriptionId(IDS_ITEM_CHESTPLATE_GOLD)->setUseDescriptionId(IDS_DESC_CHESTPLATE_GOLD) ); - + Item::leggings_leather = (ArmorItem *) ( ( new ArmorItem(44, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_cloth) ->setIconName(L"leggingsCloth")->setDescriptionId(IDS_ITEM_LEGGINGS_CLOTH)->setUseDescriptionId(IDS_DESC_LEGGINGS_LEATHER) ); Item::leggings_iron = (ArmorItem *) ( ( new ArmorItem(52, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_iron) ->setIconName(L"leggingsIron")->setDescriptionId(IDS_ITEM_LEGGINGS_IRON)->setUseDescriptionId(IDS_DESC_LEGGINGS_IRON) ); Item::leggings_diamond = (ArmorItem *) ( ( new ArmorItem(56, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_diamond) ->setIconName(L"leggingsDiamond")->setDescriptionId(IDS_ITEM_LEGGINGS_DIAMOND)->setUseDescriptionId(IDS_DESC_LEGGINGS_DIAMOND) ); @@ -319,14 +319,14 @@ void Item::staticCtor() // 4J-PB - todo - add materials and base types to the ones below Item::bucket_empty = ( new BucketItem(69, 0) ) ->setBaseItemTypeAndMaterial(eBaseItemType_utensil, eMaterial_water)->setIconName(L"bucket")->setDescriptionId(IDS_ITEM_BUCKET)->setUseDescriptionId(IDS_DESC_BUCKET)->setMaxStackSize(16); Item::bowl = ( new Item(25) ) ->setBaseItemTypeAndMaterial(eBaseItemType_utensil, eMaterial_wood)->setIconName(L"bowl")->setDescriptionId(IDS_ITEM_BOWL)->setUseDescriptionId(IDS_DESC_BOWL)->setMaxStackSize(64); - + Item::bucket_water = ( new BucketItem(70, Tile::water_Id) ) ->setIconName(L"bucketWater")->setDescriptionId(IDS_ITEM_BUCKET_WATER)->setCraftingRemainingItem(Item::bucket_empty)->setUseDescriptionId(IDS_DESC_BUCKET_WATER); Item::bucket_lava = ( new BucketItem(71, Tile::lava_Id) ) ->setIconName(L"bucketLava")->setDescriptionId(IDS_ITEM_BUCKET_LAVA)->setCraftingRemainingItem(Item::bucket_empty)->setUseDescriptionId(IDS_DESC_BUCKET_LAVA); Item::bucket_milk = ( new MilkBucketItem(79) )->setIconName(L"milk")->setDescriptionId(IDS_ITEM_BUCKET_MILK)->setCraftingRemainingItem(Item::bucket_empty)->setUseDescriptionId(IDS_DESC_BUCKET_MILK); Item::bow = (BowItem *)( new BowItem(5) ) ->setIconName(L"bow")->setBaseItemTypeAndMaterial(eBaseItemType_bow, eMaterial_bow) ->setDescriptionId(IDS_ITEM_BOW)->setUseDescriptionId(IDS_DESC_BOW); Item::arrow = ( new Item(6) ) ->setIconName(L"arrow")->setBaseItemTypeAndMaterial(eBaseItemType_bow, eMaterial_arrow) ->setDescriptionId(IDS_ITEM_ARROW)->setUseDescriptionId(IDS_DESC_ARROW); - + Item::compass = ( new CompassItem(89) ) ->setIconName(L"compass")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_compass) ->setDescriptionId(IDS_ITEM_COMPASS)->setUseDescriptionId(IDS_DESC_COMPASS); Item::clock = ( new ClockItem(91) ) ->setIconName(L"clock")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_clock) ->setDescriptionId(IDS_ITEM_CLOCK)->setUseDescriptionId(IDS_DESC_CLOCK); Item::map = (MapItem *) ( new MapItem(102) ) ->setIconName(L"map")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_map) ->setDescriptionId(IDS_ITEM_MAP)->setUseDescriptionId(IDS_DESC_MAP); @@ -357,7 +357,7 @@ void Item::staticCtor() ->setBaseItemTypeAndMaterial(eBaseItemType_giltFruit,eMaterial_apple)->setIconName(L"appleGold")->setDescriptionId(IDS_ITEM_APPLE_GOLD);//->setUseDescriptionId(IDS_DESC_GOLDENAPPLE); Item::sign = ( new SignItem(67) ) ->setBaseItemTypeAndMaterial(eBaseItemType_HangingItem, eMaterial_wood)->setIconName(L"sign")->setDescriptionId(IDS_ITEM_SIGN)->setUseDescriptionId(IDS_DESC_SIGN); - + Item::minecart = ( new MinecartItem(72, Minecart::TYPE_RIDEABLE) ) ->setIconName(L"minecart")->setDescriptionId(IDS_ITEM_MINECART)->setUseDescriptionId(IDS_DESC_MINECART); @@ -396,7 +396,7 @@ void Item::staticCtor() Item::cookie = ( new FoodItem(101, 2, FoodConstants::FOOD_SATURATION_POOR, false) ) ->setIconName(L"cookie")->setDescriptionId(IDS_ITEM_COOKIE)->setUseDescriptionId(IDS_DESC_COOKIE); - Item::shears = (ShearsItem *)( new ShearsItem(103) ) ->setIconName(L"shears")->setBaseItemTypeAndMaterial(eBaseItemType_devicetool, eMaterial_shears)->setDescriptionId(IDS_ITEM_SHEARS)->setUseDescriptionId(IDS_DESC_SHEARS); + Item::shears = (ShearsItem *)( new ShearsItem(103) ) ->setIconName(L"shears")->setBaseItemTypeAndMaterial(eBaseItemType_devicetool, eMaterial_shears)->setDescriptionId(IDS_ITEM_SHEARS)->setUseDescriptionId(IDS_DESC_SHEARS); Item::melon = (new FoodItem(104, 2, FoodConstants::FOOD_SATURATION_LOW, false)) ->setIconName(L"melon")->setDescriptionId(IDS_ITEM_MELON_SLICE)->setUseDescriptionId(IDS_DESC_MELON_SLICE); @@ -455,7 +455,7 @@ void Item::staticCtor() // putting the fire charge in as a torch, so that it stacks without being near the middle of the selection boxes Item::fireball = (new FireChargeItem(129)) ->setBaseItemTypeAndMaterial(eBaseItemType_torch, eMaterial_setfire)->setIconName(L"fireball")->setDescriptionId(IDS_ITEM_FIREBALL)->setUseDescriptionId(IDS_DESC_FIREBALL); Item::frame = (new HangingEntityItem(133,eTYPE_ITEM_FRAME)) ->setBaseItemTypeAndMaterial(eBaseItemType_HangingItem, eMaterial_glass)->setIconName(L"frame")->setDescriptionId(IDS_ITEM_ITEMFRAME)->setUseDescriptionId(IDS_DESC_ITEMFRAME); - + // TU12 Item::skull = (new SkullItem(141)) ->setIconName(L"skull")->setDescriptionId(IDS_ITEM_SKULL)->setUseDescriptionId(IDS_DESC_SKULL); @@ -501,7 +501,7 @@ void Item::staticCtor() void Item::staticInit() { Stats::buildItemStats(); -} +} _Tier::Tier(int level, int uses, float speed, float damage, int enchantmentValue) : @@ -668,7 +668,7 @@ shared_ptr Item::useTimeDepleted(shared_ptr itemInst return itemInstance; } -int Item::getMaxStackSize() +int Item::getMaxStackSize() const { return maxStackSize; } @@ -711,7 +711,7 @@ bool Item::canBeDepleted() /** * Returns true when the item was used to deal more than default damage -* +* * @param itemInstance * @param mob * @param attacker @@ -724,7 +724,7 @@ bool Item::hurtEnemy(shared_ptr itemInstance, shared_ptr itemInstance, Level *level, shared_ptr player); virtual shared_ptr use(shared_ptr itemInstance, Level *level, shared_ptr player); virtual shared_ptr useTimeDepleted(shared_ptr itemInstance, Level *level, shared_ptr player); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual int getLevelDataForAuxValue(int auxValue); bool isStackedByData(); @@ -686,7 +686,7 @@ public: /** * Returns true when the item was used to deal more than default damage - * + * * @param itemInstance * @param mob * @param attacker @@ -696,7 +696,7 @@ public: /** * Returns true when the item was used to mine more efficiently - * + * * @param itemInstance * @param tile * @param x diff --git a/Minecraft.World/ItemInstance.cpp b/Minecraft.World/ItemInstance.cpp index c83b67dd..32367b12 100644 --- a/Minecraft.World/ItemInstance.cpp +++ b/Minecraft.World/ItemInstance.cpp @@ -31,17 +31,17 @@ void ItemInstance::_init(int id, int count, int auxValue) this->m_bForceNumberDisplay=false; } -ItemInstance::ItemInstance(Tile *tile) +ItemInstance::ItemInstance(Tile *tile) { _init(tile->id, 1, 0); } -ItemInstance::ItemInstance(Tile *tile, int count) +ItemInstance::ItemInstance(Tile *tile, int count) { _init(tile->id, count, 0); } // 4J-PB - added -ItemInstance::ItemInstance(MapItem *item, int count) +ItemInstance::ItemInstance(MapItem *item, int count) { _init(item->id, count, 0); } @@ -51,19 +51,19 @@ ItemInstance::ItemInstance(Tile *tile, int count, int auxValue) _init(tile->id, count, auxValue); } -ItemInstance::ItemInstance(Item *item) +ItemInstance::ItemInstance(Item *item) { _init(item->id, 1, 0); } -ItemInstance::ItemInstance(Item *item, int count) +ItemInstance::ItemInstance(Item *item, int count) { _init(item->id, count, 0); } -ItemInstance::ItemInstance(Item *item, int count, int auxValue) +ItemInstance::ItemInstance(Item *item, int count, int auxValue) { _init(item->id, count, auxValue); } @@ -89,7 +89,7 @@ ItemInstance::~ItemInstance() if(tag != NULL) delete tag; } -shared_ptr ItemInstance::remove(int count) +shared_ptr ItemInstance::remove(int count) { shared_ptr ii = shared_ptr( new ItemInstance(id, count, auxValue) ); if (tag != NULL) ii->tag = (CompoundTag *) tag->copy(); @@ -123,17 +123,17 @@ bool ItemInstance::useOn(shared_ptr player, Level *level, int x, int y, return getItem()->useOn(shared_from_this(), player, level, x, y, z, face, clickX, clickY, clickZ, bTestUseOnOnly); } -float ItemInstance::getDestroySpeed(Tile *tile) +float ItemInstance::getDestroySpeed(Tile *tile) { return getItem()->getDestroySpeed(shared_from_this(), tile); } -bool ItemInstance::TestUse(shared_ptr itemInstance, Level *level, shared_ptr player) +bool ItemInstance::TestUse(shared_ptr itemInstance, Level *level, shared_ptr player) { return getItem()->TestUse( itemInstance, level, player); } -shared_ptr ItemInstance::use(Level *level, shared_ptr player) +shared_ptr ItemInstance::use(Level *level, shared_ptr player) { return getItem()->use(shared_from_this(), level, player); } @@ -143,7 +143,7 @@ shared_ptr ItemInstance::useTimeDepleted(Level *level, shared_ptr< return getItem()->useTimeDepleted(shared_from_this(), level, player); } -CompoundTag *ItemInstance::save(CompoundTag *compoundTag) +CompoundTag *ItemInstance::save(CompoundTag *compoundTag) { compoundTag->putShort(L"id", (short) id); compoundTag->putByte(L"Count", (byte) count); @@ -169,7 +169,7 @@ void ItemInstance::load(CompoundTag *compoundTag) } } -int ItemInstance::getMaxStackSize() +int ItemInstance::getMaxStackSize() const { return getItem()->getMaxStackSize(); } @@ -179,7 +179,7 @@ bool ItemInstance::isStackable() return getMaxStackSize() > 1 && (!isDamageableItem() || !isDamaged()); } -bool ItemInstance::isDamageableItem() +bool ItemInstance::isDamageableItem() { return Item::items[id]->getMaxDamage() > 0; } @@ -187,7 +187,7 @@ bool ItemInstance::isDamageableItem() /** * Returns true if this item type only can be stacked with items that have * the same auxValue data. -* +* * @return */ @@ -196,7 +196,7 @@ bool ItemInstance::isStackedByData() return Item::items[id]->isStackedByData(); } -bool ItemInstance::isDamaged() +bool ItemInstance::isDamaged() { return isDamageableItem() && auxValue > 0; } @@ -280,13 +280,13 @@ void ItemInstance::hurtAndBreak(int dmg, shared_ptr owner) void ItemInstance::hurtEnemy(shared_ptr mob, shared_ptr attacker) { - //bool used = + //bool used = Item::items[id]->hurtEnemy(shared_from_this(), mob, attacker); } -void ItemInstance::mineBlock(Level *level, int tile, int x, int y, int z, shared_ptr owner) +void ItemInstance::mineBlock(Level *level, int tile, int x, int y, int z, shared_ptr owner) { - //bool used = + //bool used = Item::items[id]->mineBlock( shared_from_this(), level, tile, x, y, z, owner); } @@ -342,7 +342,7 @@ bool ItemInstance::tagMatches(shared_ptr a, shared_ptr a, shared_ptr b) +bool ItemInstance::matches(shared_ptr a, shared_ptr b) { if (a == NULL && b == NULL) return true; if (a == NULL || b == NULL) return false; @@ -368,7 +368,7 @@ bool ItemInstance::matches(shared_ptr b) /** * Checks if this item is the same item as the other one, disregarding the * 'count' value. -* +* * @param b * @return */ @@ -393,17 +393,17 @@ bool ItemInstance::sameItemWithTags(shared_ptr b) } // 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; } -unsigned int ItemInstance::getUseDescriptionId() +unsigned int ItemInstance::getUseDescriptionId() { return Item::items[id]->getUseDescriptionId(shared_from_this()); } -unsigned int ItemInstance::getDescriptionId(int iData /*= -1*/) +unsigned int ItemInstance::getDescriptionId(int iData /*= -1*/) { return Item::items[id]->getDescriptionId(shared_from_this()); } @@ -420,7 +420,7 @@ shared_ptr ItemInstance::clone(shared_ptr item) return item == NULL ? nullptr : item->copy(); } -wstring ItemInstance::toString() +wstring ItemInstance::toString() { //return count + "x" + Item::items[id]->getDescriptionId() + "@" + auxValue; @@ -661,7 +661,7 @@ vector *ItemInstance::getHoverText(shared_ptr player, bool a lines->push_back(it->second->getHoverText(it->first)); } } - + // Delete modifiers map for (AUTO_VAR(it, modifiers->begin()); it != modifiers->end(); ++it) { @@ -760,17 +760,17 @@ bool ItemInstance::mayBePlacedInAdventureMode() return getItem()->mayBePlacedInAdventureMode(); } -bool ItemInstance::isFramed() +bool ItemInstance::isFramed() { return frame != NULL; } -void ItemInstance::setFramed(shared_ptr frame) +void ItemInstance::setFramed(shared_ptr frame) { this->frame = frame; } -shared_ptr ItemInstance::getFrame() +shared_ptr ItemInstance::getFrame() { return frame; } @@ -807,8 +807,8 @@ attrAttrModMap *ItemInstance::getAttributeModifiers() CompoundTag *entry = entries->get(i); AttributeModifier *attribute = SharedMonsterAttributes::loadAttributeModifier(entry); - // 4J Not sure why but this is a check that the attribute ID is not empty - /*if (attribute->getId()->getLeastSignificantBits() != 0 && attribute->getId()->getMostSignificantBits() != 0) + // 4J Not sure why but this is a check that the attribute ID is not empty + /*if (attribute->getId()->getLeastSignificantBits() != 0 && attribute->getId()->getMostSignificantBits() != 0) {*/ result->insert(std::pair(static_cast(entry->getInt(L"ID")), attribute)); /*}*/ @@ -848,7 +848,7 @@ int ItemInstance::get4JData() } } // 4J Added - to show strength on potions -bool ItemInstance::hasPotionStrengthBar() +bool ItemInstance::hasPotionStrengthBar() { // exclude a bottle of water from this if((id==Item::potion_Id) && (auxValue !=0))// && (!MACRO_POTION_IS_AKWARD(auxValue))) 4J-PB leaving the bar on an awkward potion so we can differentiate it from a water bottle @@ -859,7 +859,7 @@ bool ItemInstance::hasPotionStrengthBar() return false; } -int ItemInstance::GetPotionStrength() +int ItemInstance::GetPotionStrength() { if(MACRO_POTION_IS_INSTANTDAMAGE(auxValue) || MACRO_POTION_IS_INSTANTHEALTH(auxValue) ) { diff --git a/Minecraft.World/ItemInstance.h b/Minecraft.World/ItemInstance.h index 034c72f8..cff33a97 100644 --- a/Minecraft.World/ItemInstance.h +++ b/Minecraft.World/ItemInstance.h @@ -77,12 +77,12 @@ public: int getIconType(); bool useOn(shared_ptr player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly=false); float getDestroySpeed(Tile *tile); - bool TestUse(shared_ptr itemInstance, Level *level, shared_ptr player); + bool TestUse(shared_ptr itemInstance, Level *level, shared_ptr player); shared_ptr use(Level *level, shared_ptr player); shared_ptr useTimeDepleted(Level *level, shared_ptr player); CompoundTag *save(CompoundTag *compoundTag); void load(CompoundTag *compoundTag); - int getMaxStackSize(); + int getMaxStackSize() const; bool isStackable(); bool isDamageableItem(); bool isStackedByData(); @@ -113,7 +113,7 @@ private: public: bool sameItem(shared_ptr b); bool sameItemWithTags(shared_ptr 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 getDescriptionId(int iData = -1); virtual ItemInstance *setDescriptionId(unsigned int id); diff --git a/Minecraft.World/Language.cpp b/Minecraft.World/Language.cpp index 73e56a47..2fdc4755 100644 --- a/Minecraft.World/Language.cpp +++ b/Minecraft.World/Language.cpp @@ -14,37 +14,12 @@ Language *Language::getInstance() return singleton; } -/* 4J Jev, creates 2 identical functions. -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) +std::wstring Language::getElementName(const std::wstring& elementId) { return elementId; } -wstring Language::getElementDescription(const wstring& elementId) +std::wstring Language::getElementDescription(const std::wstring& elementId) { return elementId; } \ No newline at end of file diff --git a/Minecraft.World/Language.h b/Minecraft.World/Language.h index 10e2951f..9c7c8524 100644 --- a/Minecraft.World/Language.h +++ b/Minecraft.World/Language.h @@ -1,5 +1,7 @@ #pragma once +#include + class Language { private: @@ -7,8 +9,11 @@ private: public: Language(); static Language *getInstance(); - wstring getElement(const wstring& elementId, ...); - wstring getElement(const wstring& elementId, va_list args); - wstring getElementName(const wstring& elementId); - wstring getElementDescription(const wstring& elementId); + template + inline std::wstring getElement(const std::wstring& elementId, Args...) + { + return elementId; + } + std::wstring getElementName(const std::wstring& elementId); + std::wstring getElementDescription(const std::wstring& elementId); }; \ No newline at end of file diff --git a/Minecraft.World/MerchantContainer.cpp b/Minecraft.World/MerchantContainer.cpp index cd3fde5e..7ceb4745 100644 --- a/Minecraft.World/MerchantContainer.cpp +++ b/Minecraft.World/MerchantContainer.cpp @@ -105,7 +105,7 @@ bool MerchantContainer::hasCustomName() return false; } -int MerchantContainer::getMaxStackSize() +int MerchantContainer::getMaxStackSize() const { return Container::LARGE_MAX_STACK_SIZE; } diff --git a/Minecraft.World/MerchantContainer.h b/Minecraft.World/MerchantContainer.h index 91893c1b..e2e63970 100644 --- a/Minecraft.World/MerchantContainer.h +++ b/Minecraft.World/MerchantContainer.h @@ -33,7 +33,7 @@ public: wstring getName(); wstring getCustomName(); bool hasCustomName(); - int getMaxStackSize(); + int getMaxStackSize() const; bool stillValid(shared_ptr player); void startOpen(); void stopOpen(); diff --git a/Minecraft.World/MinecartContainer.cpp b/Minecraft.World/MinecartContainer.cpp index 61d0d32b..20bfc4ea 100644 --- a/Minecraft.World/MinecartContainer.cpp +++ b/Minecraft.World/MinecartContainer.cpp @@ -127,7 +127,7 @@ wstring MinecartContainer::getName() return hasCustomName() ? getCustomName() : app.GetString(IDS_CONTAINER_MINECART); } -int MinecartContainer::getMaxStackSize() +int MinecartContainer::getMaxStackSize() const { return Container::LARGE_MAX_STACK_SIZE; } diff --git a/Minecraft.World/MinecartContainer.h b/Minecraft.World/MinecartContainer.h index 89517658..c7bb7298 100644 --- a/Minecraft.World/MinecartContainer.h +++ b/Minecraft.World/MinecartContainer.h @@ -26,7 +26,7 @@ public: virtual void stopOpen(); virtual bool canPlaceItem(int slot, shared_ptr item); virtual wstring getName(); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual void changeDimension(int i); virtual void remove(); @@ -41,7 +41,7 @@ protected: virtual void applyNaturalSlowdown(); public: - + // 4J Stu - For container virtual bool hasCustomName() { return Minecart::hasCustomName(); } virtual wstring getCustomName() { return Minecart::getCustomName(); } diff --git a/Minecraft.World/MinecartHopper.h b/Minecraft.World/MinecartHopper.h index 874bab6a..54c97b38 100644 --- a/Minecraft.World/MinecartHopper.h +++ b/Minecraft.World/MinecartHopper.h @@ -54,7 +54,7 @@ public: virtual wstring getName() { return MinecartContainer::getName(); } virtual wstring getCustomName() { return MinecartContainer::getCustomName(); } 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 bool stillValid(shared_ptr player) { return MinecartContainer::stillValid(player); } diff --git a/Minecraft.World/ResultContainer.cpp b/Minecraft.World/ResultContainer.cpp index f2f273c2..8c85d0c3 100644 --- a/Minecraft.World/ResultContainer.cpp +++ b/Minecraft.World/ResultContainer.cpp @@ -58,7 +58,7 @@ void ResultContainer::setItem(unsigned int slot, shared_ptr item) items[0] = item; } -int ResultContainer::getMaxStackSize() +int ResultContainer::getMaxStackSize() const { return Container::LARGE_MAX_STACK_SIZE; } diff --git a/Minecraft.World/ResultContainer.h b/Minecraft.World/ResultContainer.h index f99cf806..53d80403 100644 --- a/Minecraft.World/ResultContainer.h +++ b/Minecraft.World/ResultContainer.h @@ -19,7 +19,7 @@ public: virtual shared_ptr removeItem(unsigned int slot, int count); virtual shared_ptr removeItemNoUpdate(int slot); virtual void setItem(unsigned int slot, shared_ptr item); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual void setChanged(); virtual bool stillValid(shared_ptr player); virtual void startOpen() { } // TODO Auto-generated method stub diff --git a/Minecraft.World/SimpleContainer.cpp b/Minecraft.World/SimpleContainer.cpp index 147bab0a..a5f551e2 100644 --- a/Minecraft.World/SimpleContainer.cpp +++ b/Minecraft.World/SimpleContainer.cpp @@ -106,7 +106,7 @@ void SimpleContainer::setCustomName(const wstring &name) this->stringName = name; } -int SimpleContainer::getMaxStackSize() +int SimpleContainer::getMaxStackSize() const { return Container::LARGE_MAX_STACK_SIZE; } diff --git a/Minecraft.World/SimpleContainer.h b/Minecraft.World/SimpleContainer.h index b0baed70..bb22d141 100644 --- a/Minecraft.World/SimpleContainer.h +++ b/Minecraft.World/SimpleContainer.h @@ -28,7 +28,7 @@ public: virtual wstring getCustomName(); virtual bool hasCustomName(); virtual void setCustomName(const wstring &name); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual void setChanged(); virtual bool stillValid(shared_ptr player); virtual void startOpen() { } // TODO Auto-generated method stub diff --git a/Minecraft.World/Slot.cpp b/Minecraft.World/Slot.cpp index c7d1a029..a5a53a48 100644 --- a/Minecraft.World/Slot.cpp +++ b/Minecraft.World/Slot.cpp @@ -91,7 +91,7 @@ void Slot::setChanged() container->setChanged(); } -int Slot::getMaxStackSize() +int Slot::getMaxStackSize() const { return container->getMaxStackSize(); } diff --git a/Minecraft.World/Slot.h b/Minecraft.World/Slot.h index 12399783..70f9a3c3 100644 --- a/Minecraft.World/Slot.h +++ b/Minecraft.World/Slot.h @@ -31,7 +31,7 @@ public: virtual bool hasItem(); virtual void set(shared_ptr item); virtual void setChanged(); - virtual int getMaxStackSize(); + virtual int getMaxStackSize() const; virtual Icon *getNoItemIcon(); virtual shared_ptr remove(int c); virtual bool isAt(shared_ptr c, int s);