aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-07 21:12:22 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-07 21:12:22 -0600
commit087b7e7abfe81dd7f0fdcdea36ac9f245950df1a (patch)
tree69454763e73ca764af4e682d3573080b13138a0e /Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp
parenta9be52c41a02d207233199e98898fe7483d7e817 (diff)
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.
Diffstat (limited to 'Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp')
-rw-r--r--Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp38
1 files changed, 18 insertions, 20 deletions
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<MultiplayerLocalPlayer> 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<TradeItemPacket>(m_menu->containerId, actualShopItem));
+ player->connection->send( shared_ptr<TradeItemPacket>( 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>(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray()));
+ Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr<CustomPayloadPacket>( 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>(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray()));
+ Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr<CustomPayloadPacket>( 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;