From 28614b922fb77149a54da1a87bebfbc98736f296 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:08:36 -0400 Subject: Modernize project codebase (#906) * 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 * Add safety checks and fix a issue with vector going OOR --- Minecraft.World/AnvilMenu.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Minecraft.World/AnvilMenu.cpp') 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, Level *level, int xt, int yt, int zt, shared_ptr player) { - resultSlots = shared_ptr( new ResultContainer() ); - repairSlots = shared_ptr( new RepairContainer(this,IDS_REPAIR_AND_NAME, true, 2) ); + resultSlots = std::make_shared(); + repairSlots = std::make_shared(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 *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) for (int i = 0; i < repairSlots->getContainerSize(); i++) { shared_ptr item = repairSlots->removeItemNoUpdate(i); - if (item != NULL) + if (item != nullptr) { player->drop(item); } @@ -362,7 +362,7 @@ shared_ptr AnvilMenu::quickMoveStack(shared_ptr player, in { shared_ptr clicked = nullptr; Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); -- cgit v1.2.3