From 087b7e7abfe81dd7f0fdcdea36ac9f245950df1a Mon Sep 17 00:00:00 2001 From: Loki Rautio Date: Sat, 7 Mar 2026 21:12:22 -0600 Subject: Revert "Project modernization (#630)" This code was not tested and breaks in Release builds, reverting to restore functionality of the nightly. All in-game menus do not work and generating a world crashes. This reverts commit a9be52c41a02d207233199e98898fe7483d7e817. --- .../Common/UI/IUIScene_TradingMenu.cpp | 38 ++++++++++------------ 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp') diff --git a/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp index 0b1e0df2..059f9b75 100644 --- a/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp @@ -8,14 +8,12 @@ #include "..\..\ClientConnection.h" #include "IUIScene_TradingMenu.h" -#include "UI.h" - IUIScene_TradingMenu::IUIScene_TradingMenu() { m_validOffersCount = 0; m_selectedSlot = 0; m_offersStartIndex = 0; - m_menu = nullptr; + m_menu = NULL; m_bHasUpdatedOnce = false; } @@ -33,10 +31,10 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[getPad()] != nullptr ) + if( pMinecraft->localgameModes[getPad()] != NULL ) { Tutorial *tutorial = pMinecraft->localgameModes[getPad()]->getTutorial(); - if(tutorial != nullptr) + if(tutorial != NULL) { tutorial->handleUIInput(iAction); if(ui.IsTutorialVisible(getPad()) && !tutorial->isInputAllowed(iAction)) @@ -78,7 +76,7 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) shared_ptr player = Minecraft::GetInstance()->localplayers[getPad()]; int buyAMatches = player->inventory->countMatches(buyAItem); int buyBMatches = player->inventory->countMatches(buyBItem); - if( (buyAItem != nullptr && buyAMatches >= buyAItem->count) && (buyBItem == nullptr || buyBMatches >= buyBItem->count) ) + if( (buyAItem != NULL && buyAMatches >= buyAItem->count) && (buyBItem == NULL || buyBMatches >= buyBItem->count) ) { // 4J-JEV: Fix for PS4 #7111: [PATCH 1.12] Trading Librarian villagers for multiple �Enchanted Books� will cause the title to crash. int actualShopItem = m_activeOffers.at(selectedShopItem).second; @@ -97,7 +95,7 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) } // Send a packet to the server - player->connection->send(std::make_shared(m_menu->containerId, actualShopItem)); + player->connection->send( shared_ptr( new TradeItemPacket(m_menu->containerId, actualShopItem) ) ); updateDisplay(); } @@ -154,7 +152,7 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) ByteArrayOutputStream rawOutput; DataOutputStream output(&rawOutput); output.writeInt(actualShopItem); - Minecraft::GetInstance()->getConnection(getPad())->send(std::make_shared(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray())); + Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr( new CustomPayloadPacket(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray()))); } } return handled; @@ -164,7 +162,7 @@ void IUIScene_TradingMenu::handleTick() { int offerCount = 0; MerchantRecipeList *offers = m_merchant->getOffers(Minecraft::GetInstance()->localplayers[getPad()]); - if (offers != nullptr) + if (offers != NULL) { offerCount = offers->size(); @@ -183,7 +181,7 @@ void IUIScene_TradingMenu::updateDisplay() int iA = -1; MerchantRecipeList *unfilteredOffers = m_merchant->getOffers(Minecraft::GetInstance()->localplayers[getPad()]); - if (unfilteredOffers != nullptr) + if (unfilteredOffers != NULL) { m_activeOffers.clear(); int unfilteredIndex = 0; @@ -207,7 +205,7 @@ void IUIScene_TradingMenu::updateDisplay() ByteArrayOutputStream rawOutput; DataOutputStream output(&rawOutput); output.writeInt(firstValidTrade); - Minecraft::GetInstance()->getConnection(getPad())->send(std::make_shared(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray())); + Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr( new CustomPayloadPacket(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray()))); } } @@ -243,7 +241,7 @@ void IUIScene_TradingMenu::updateDisplay() // 4J-PB - need to get the villager type here wsTemp = app.GetString(IDS_VILLAGER_OFFERS_ITEM); wsTemp = replaceAll(wsTemp,L"{*VILLAGER_TYPE*}",m_merchant->getDisplayName()); - size_t iPos=wsTemp.find(L"%s"); + int iPos=wsTemp.find(L"%s"); wsTemp.replace(iPos,2,activeRecipe->getSellItem()->getHoverName()); setTitle(wsTemp.c_str()); @@ -257,10 +255,10 @@ void IUIScene_TradingMenu::updateDisplay() setRequest1Item(buyAItem); setRequest2Item(buyBItem); - if(buyAItem != nullptr) setRequest1Name(buyAItem->getHoverName()); + if(buyAItem != NULL) setRequest1Name(buyAItem->getHoverName()); else setRequest1Name(L""); - if(buyBItem != nullptr) setRequest2Name(buyBItem->getHoverName()); + if(buyBItem != NULL) setRequest2Name(buyBItem->getHoverName()); else setRequest2Name(L""); bool canMake = true; @@ -286,15 +284,15 @@ void IUIScene_TradingMenu::updateDisplay() } else { - if(buyBItem!=nullptr) + if(buyBItem!=NULL) { setRequest2RedBox(true); canMake = false; } else { - setRequest2RedBox(buyBItem != nullptr); - canMake = canMake && buyBItem == nullptr; + setRequest2RedBox(buyBItem != NULL); + canMake = canMake && buyBItem == NULL; } } @@ -322,7 +320,7 @@ void IUIScene_TradingMenu::updateDisplay() bool IUIScene_TradingMenu::canMake(MerchantRecipe *recipe) { bool canMake = false; - if (recipe != nullptr) + if (recipe != NULL) { if(recipe->isDeprecated()) return false; @@ -337,7 +335,7 @@ bool IUIScene_TradingMenu::canMake(MerchantRecipe *recipe) } else { - canMake = buyAItem == nullptr; + canMake = buyAItem == NULL; } int buyBMatches = player->inventory->countMatches(buyBItem); @@ -347,7 +345,7 @@ bool IUIScene_TradingMenu::canMake(MerchantRecipe *recipe) } else { - canMake = canMake && buyBItem == nullptr; + canMake = canMake && buyBItem == NULL; } } return canMake; -- cgit v1.2.3