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
This commit is contained in:
ModMaker101
2026-03-07 21:56:03 -05:00
committed by GitHub
parent 1be5faaea7
commit a9be52c41a
1373 changed files with 19903 additions and 19449 deletions

View File

@@ -8,12 +8,14 @@
#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 = NULL;
m_menu = nullptr;
m_bHasUpdatedOnce = false;
}
@@ -31,10 +33,10 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat)
Minecraft *pMinecraft = Minecraft::GetInstance();
if( pMinecraft->localgameModes[getPad()] != NULL )
if( pMinecraft->localgameModes[getPad()] != nullptr )
{
Tutorial *tutorial = pMinecraft->localgameModes[getPad()]->getTutorial();
if(tutorial != NULL)
if(tutorial != nullptr)
{
tutorial->handleUIInput(iAction);
if(ui.IsTutorialVisible(getPad()) && !tutorial->isInputAllowed(iAction))
@@ -76,7 +78,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 != NULL && buyAMatches >= buyAItem->count) && (buyBItem == NULL || buyBMatches >= buyBItem->count) )
if( (buyAItem != nullptr && buyAMatches >= buyAItem->count) && (buyBItem == nullptr || buyBMatches >= buyBItem->count) )
{
// 4J-JEV: Fix for PS4 #7111: [PATCH 1.12] Trading Librarian villagers for multiple <20>Enchanted Books<6B> will cause the title to crash.
int actualShopItem = m_activeOffers.at(selectedShopItem).second;
@@ -95,7 +97,7 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat)
}
// Send a packet to the server
player->connection->send( shared_ptr<TradeItemPacket>( new TradeItemPacket(m_menu->containerId, actualShopItem) ) );
player->connection->send(std::make_shared<TradeItemPacket>(m_menu->containerId, actualShopItem));
updateDisplay();
}
@@ -152,7 +154,7 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat)
ByteArrayOutputStream rawOutput;
DataOutputStream output(&rawOutput);
output.writeInt(actualShopItem);
Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr<CustomPayloadPacket>( new CustomPayloadPacket(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray())));
Minecraft::GetInstance()->getConnection(getPad())->send(std::make_shared<CustomPayloadPacket>(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray()));
}
}
return handled;
@@ -162,7 +164,7 @@ void IUIScene_TradingMenu::handleTick()
{
int offerCount = 0;
MerchantRecipeList *offers = m_merchant->getOffers(Minecraft::GetInstance()->localplayers[getPad()]);
if (offers != NULL)
if (offers != nullptr)
{
offerCount = offers->size();
@@ -181,7 +183,7 @@ void IUIScene_TradingMenu::updateDisplay()
int iA = -1;
MerchantRecipeList *unfilteredOffers = m_merchant->getOffers(Minecraft::GetInstance()->localplayers[getPad()]);
if (unfilteredOffers != NULL)
if (unfilteredOffers != nullptr)
{
m_activeOffers.clear();
int unfilteredIndex = 0;
@@ -205,7 +207,7 @@ void IUIScene_TradingMenu::updateDisplay()
ByteArrayOutputStream rawOutput;
DataOutputStream output(&rawOutput);
output.writeInt(firstValidTrade);
Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr<CustomPayloadPacket>( new CustomPayloadPacket(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray())));
Minecraft::GetInstance()->getConnection(getPad())->send(std::make_shared<CustomPayloadPacket>(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray()));
}
}
@@ -241,7 +243,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());
int iPos=wsTemp.find(L"%s");
size_t iPos=wsTemp.find(L"%s");
wsTemp.replace(iPos,2,activeRecipe->getSellItem()->getHoverName());
setTitle(wsTemp.c_str());
@@ -255,10 +257,10 @@ void IUIScene_TradingMenu::updateDisplay()
setRequest1Item(buyAItem);
setRequest2Item(buyBItem);
if(buyAItem != NULL) setRequest1Name(buyAItem->getHoverName());
if(buyAItem != nullptr) setRequest1Name(buyAItem->getHoverName());
else setRequest1Name(L"");
if(buyBItem != NULL) setRequest2Name(buyBItem->getHoverName());
if(buyBItem != nullptr) setRequest2Name(buyBItem->getHoverName());
else setRequest2Name(L"");
bool canMake = true;
@@ -284,15 +286,15 @@ void IUIScene_TradingMenu::updateDisplay()
}
else
{
if(buyBItem!=NULL)
if(buyBItem!=nullptr)
{
setRequest2RedBox(true);
canMake = false;
}
else
{
setRequest2RedBox(buyBItem != NULL);
canMake = canMake && buyBItem == NULL;
setRequest2RedBox(buyBItem != nullptr);
canMake = canMake && buyBItem == nullptr;
}
}
@@ -320,7 +322,7 @@ void IUIScene_TradingMenu::updateDisplay()
bool IUIScene_TradingMenu::canMake(MerchantRecipe *recipe)
{
bool canMake = false;
if (recipe != NULL)
if (recipe != nullptr)
{
if(recipe->isDeprecated()) return false;
@@ -335,7 +337,7 @@ bool IUIScene_TradingMenu::canMake(MerchantRecipe *recipe)
}
else
{
canMake = buyAItem == NULL;
canMake = buyAItem == nullptr;
}
int buyBMatches = player->inventory->countMatches(buyBItem);
@@ -345,7 +347,7 @@ bool IUIScene_TradingMenu::canMake(MerchantRecipe *recipe)
}
else
{
canMake = canMake && buyBItem == NULL;
canMake = canMake && buyBItem == nullptr;
}
}
return canMake;