From 7074f35e4ba831e358117842b99ee35b87f85ae5 Mon Sep 17 00:00:00 2001 From: void_17 Date: Mon, 2 Mar 2026 15:58:20 +0700 Subject: shared_ptr -> std::shared_ptr This is one of the first commits in a plan to remove all `using namespace std;` lines in the entire codebase as it is considered anti-pattern today. --- Minecraft.World/MerchantMenu.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'Minecraft.World/MerchantMenu.cpp') diff --git a/Minecraft.World/MerchantMenu.cpp b/Minecraft.World/MerchantMenu.cpp index a6dfca1f..50f9fbdf 100644 --- a/Minecraft.World/MerchantMenu.cpp +++ b/Minecraft.World/MerchantMenu.cpp @@ -5,12 +5,12 @@ #include "net.minecraft.world.level.h" #include "MerchantMenu.h" -MerchantMenu::MerchantMenu(shared_ptr inventory, shared_ptr merchant, Level *level) +MerchantMenu::MerchantMenu(std::shared_ptr inventory, std::shared_ptr merchant, Level *level) { trader = merchant; this->level = level; - tradeContainer = shared_ptr( new MerchantContainer(dynamic_pointer_cast(inventory->player->shared_from_this()), merchant) ); + tradeContainer = std::shared_ptr( new MerchantContainer(dynamic_pointer_cast(inventory->player->shared_from_this()), merchant) ); addSlot(new Slot(tradeContainer, PAYMENT1_SLOT, SELLSLOT1_X, ROW2_Y)); addSlot(new Slot(tradeContainer, PAYMENT2_SLOT, SELLSLOT2_X, ROW2_Y)); addSlot(new MerchantResultSlot(inventory->player, merchant, tradeContainer, RESULT_SLOT, BUYSLOT_X, ROW2_Y)); @@ -28,7 +28,7 @@ MerchantMenu::MerchantMenu(shared_ptr inventory, shared_ptr } } -shared_ptr MerchantMenu::getTradeContainer() +std::shared_ptr MerchantMenu::getTradeContainer() { return tradeContainer; } @@ -43,7 +43,7 @@ void MerchantMenu::broadcastChanges() AbstractContainerMenu::broadcastChanges(); } -// 4J used to take a shared_ptr but wasn't using it, so removed to simplify things +// 4J used to take a std::shared_ptr but wasn't using it, so removed to simplify things void MerchantMenu::slotsChanged() { tradeContainer->updateSellItem(); @@ -59,20 +59,20 @@ void MerchantMenu::setData(int id, int value) { } -bool MerchantMenu::stillValid(shared_ptr player) +bool MerchantMenu::stillValid(std::shared_ptr player) { return trader->getTradingPlayer() == player; } -shared_ptr MerchantMenu::quickMoveStack(shared_ptr player, int slotIndex) +std::shared_ptr MerchantMenu::quickMoveStack(std::shared_ptr player, int slotIndex) { - shared_ptr clicked = nullptr; + std::shared_ptr clicked = nullptr; Slot *slot = NULL; - + if(slotIndex < slots->size()) slot = slots->at(slotIndex); if (slot != NULL && slot->hasItem()) { - shared_ptr stack = slot->getItem(); + std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); if (slotIndex == RESULT_SLOT) @@ -124,7 +124,7 @@ shared_ptr MerchantMenu::quickMoveStack(shared_ptr player, return clicked; } -void MerchantMenu::removed(shared_ptr player) +void MerchantMenu::removed(std::shared_ptr player) { AbstractContainerMenu::removed(player); trader->setTradingPlayer(nullptr); @@ -132,7 +132,7 @@ void MerchantMenu::removed(shared_ptr player) AbstractContainerMenu::removed(player); if (level->isClientSide) return; - shared_ptr item = tradeContainer->removeItemNoUpdate(PAYMENT1_SLOT); + std::shared_ptr item = tradeContainer->removeItemNoUpdate(PAYMENT1_SLOT); if (item) { player->drop(item); @@ -144,7 +144,7 @@ void MerchantMenu::removed(shared_ptr player) } } -shared_ptr MerchantMenu::getMerchant() +std::shared_ptr MerchantMenu::getMerchant() { return trader; } \ No newline at end of file -- cgit v1.2.3