diff options
| author | ModMaker101 <119018978+ModMaker101@users.noreply.github.com> | 2026-03-07 21:56:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-08 09:56:03 +0700 |
| commit | a9be52c41a02d207233199e98898fe7483d7e817 (patch) | |
| tree | 71dfaec3a86b05e9ca409b97d8eb9d7f993bfdd0 /Minecraft.World/AnvilMenu.cpp | |
| parent | 1be5faaea781402e7de06b263eeca4c688b7712c (diff) | |
Project modernization (#630)
* Fixed boats falling and a TP glitch #266
* Replaced every C-style cast with C++ ones
* Replaced every C-style cast with C++ ones
* Fixed boats falling and a TP glitch #266
* Updated NULL to nullptr and fixing some type issues
* Modernized and fixed a few bugs
- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.
* Fixing more conflicts
* Replace int loops with size_t and start work on overrides
Diffstat (limited to 'Minecraft.World/AnvilMenu.cpp')
| -rw-r--r-- | Minecraft.World/AnvilMenu.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Minecraft.World/AnvilMenu.cpp b/Minecraft.World/AnvilMenu.cpp index 83d38142..78d72daf 100644 --- a/Minecraft.World/AnvilMenu.cpp +++ b/Minecraft.World/AnvilMenu.cpp @@ -8,8 +8,8 @@ AnvilMenu::AnvilMenu(shared_ptr<Inventory> inventory, Level *level, int xt, int yt, int zt, shared_ptr<Player> player) { - resultSlots = shared_ptr<ResultContainer>( new ResultContainer() ); - repairSlots = shared_ptr<RepairContainer>( new RepairContainer(this,IDS_REPAIR_AND_NAME, true, 2) ); + resultSlots = std::make_shared<ResultContainer>(); + repairSlots = std::make_shared<RepairContainer>(this,IDS_REPAIR_AND_NAME, true, 2); cost = 0; repairItemCountCost = 0; @@ -55,7 +55,7 @@ void AnvilMenu::createResult() if (DEBUG_COST) app.DebugPrintf("----"); - if (input == NULL) + if (input == nullptr) { resultSlots->setItem(0, nullptr); cost = 0; @@ -68,15 +68,15 @@ void AnvilMenu::createResult() unordered_map<int,int> *enchantments = EnchantmentHelper::getEnchantments(result); bool usingBook = false; - tax += input->getBaseRepairCost() + (addition == NULL ? 0 : addition->getBaseRepairCost()); + tax += input->getBaseRepairCost() + (addition == nullptr ? 0 : addition->getBaseRepairCost()); if (DEBUG_COST) { - app.DebugPrintf("Starting with base repair tax of %d (%d + %d)\n", tax, input->getBaseRepairCost(), (addition == NULL ? 0 : addition->getBaseRepairCost())); + app.DebugPrintf("Starting with base repair tax of %d (%d + %d)\n", tax, input->getBaseRepairCost(), (addition == nullptr ? 0 : addition->getBaseRepairCost())); } repairItemCountCost = 0; - if (addition != NULL) + if (addition != nullptr) { usingBook = addition->id == Item::enchantedBook_Id && Item::enchantedBook->getEnchantments(addition)->size() > 0; @@ -290,10 +290,10 @@ void AnvilMenu::createResult() result = nullptr; } - if (result != NULL) + if (result != nullptr) { int baseCost = result->getBaseRepairCost(); - if (addition != NULL && baseCost < addition->getBaseRepairCost()) baseCost = addition->getBaseRepairCost(); + if (addition != nullptr && baseCost < addition->getBaseRepairCost()) baseCost = addition->getBaseRepairCost(); if (result->hasCustomHoverName()) baseCost -= 9; if (baseCost < 0) baseCost = 0; baseCost += 2; @@ -344,7 +344,7 @@ void AnvilMenu::removed(shared_ptr<Player> player) for (int i = 0; i < repairSlots->getContainerSize(); i++) { shared_ptr<ItemInstance> item = repairSlots->removeItemNoUpdate(i); - if (item != NULL) + if (item != nullptr) { player->drop(item); } @@ -362,7 +362,7 @@ shared_ptr<ItemInstance> AnvilMenu::quickMoveStack(shared_ptr<Player> player, in { shared_ptr<ItemInstance> clicked = nullptr; Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr<ItemInstance> stack = slot->getItem(); clicked = stack->copy(); |
