From a9be52c41a02d207233199e98898fe7483d7e817 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sat, 7 Mar 2026 21:56:03 -0500 Subject: 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 --- .../Common/UI/UIScene_DebugOverlay.cpp | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp') diff --git a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp index fafcea02..c997fb31 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp @@ -21,16 +21,16 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void *initData, UILayer *pa // Setup all the Iggy references we need for this scene initialiseMovie(); - Minecraft *pMinecraft = Minecraft::GetInstance(); - WCHAR TempString[256]; - int fovSliderVal = app.GetGameSettings(m_iPad, eGameSetting_FOV); - int fovDeg = 70 + fovSliderVal * 40 / 100; - swprintf( (WCHAR *)TempString, 256, L"Set fov (%d)", fovDeg); - m_sliderFov.init(TempString,eControl_FOV,0,100,fovSliderVal); + const Minecraft *pMinecraft = Minecraft::GetInstance(); + WCHAR tempString[256]; + const int fovSliderVal = app.GetGameSettings(m_iPad, eGameSetting_FOV); + const int fovDeg = 70 + fovSliderVal * 40 / 100; + swprintf( tempString, 256, L"Set fov (%d)", fovDeg); + m_sliderFov.init(tempString,eControl_FOV,0,100,fovSliderVal); - float currentTime = pMinecraft->level->getLevelData()->getGameTime() % 24000; - swprintf( (WCHAR *)TempString, 256, L"Set time (unsafe) (%d)", (int)currentTime); - m_sliderTime.init(TempString,eControl_Time,0,240,currentTime/100); + const float currentTime = pMinecraft->level->getLevelData()->getGameTime() % 24000; + swprintf( tempString, 256, L"Set time (unsafe) (%d)", static_cast(currentTime)); + m_sliderTime.init(tempString,eControl_Time,0,240,currentTime/100); m_buttonRain.init(L"Toggle Rain",eControl_Rain); m_buttonThunder.init(L"Toggle Thunder",eControl_Thunder); @@ -46,7 +46,7 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void *initData, UILayer *pa std::vector> sortedItems; for (size_t i = 0; i < Item::items.length; ++i) { - if (Item::items[i] != NULL) + if (Item::items[i] != nullptr) { sortedItems.emplace_back(std::wstring(app.GetString(Item::items[i]->getDescriptionId())), i); } @@ -138,19 +138,19 @@ wstring UIScene_DebugOverlay::getMoviePath() void UIScene_DebugOverlay::customDraw(IggyCustomDrawCallbackRegion *region) { - Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; + const Minecraft *pMinecraft = Minecraft::GetInstance(); + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return; int itemId = -1; - swscanf((wchar_t*)region->name,L"item_%d",&itemId); - if (itemId == -1 || itemId > Item::ITEM_NUM_COUNT || Item::items[itemId] == NULL) + swscanf(static_cast(region->name),L"item_%d",&itemId); + if (itemId == -1 || itemId > Item::ITEM_NUM_COUNT || Item::items[itemId] == nullptr) { app.DebugPrintf("This is not the control we are looking for\n"); } else { - shared_ptr item = shared_ptr( new ItemInstance(itemId,1,0) ); - if(item != NULL) customDrawSlotControl(region,m_iPad,item,1.0f,false,false); + const auto item = std::make_shared(itemId, 1, 0); + if(item != nullptr) customDrawSlotControl(region,m_iPad,item,1.0f,false,false); } } @@ -183,7 +183,7 @@ void UIScene_DebugOverlay::handleInput(int iPad, int key, bool repeat, bool pres void UIScene_DebugOverlay::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Items: { @@ -213,14 +213,14 @@ void UIScene_DebugOverlay::handlePress(F64 controlId, F64 childId) case eControl_Schematic: { #ifndef _CONTENT_PACKAGE - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic,NULL,eUILayer_Debug); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic,nullptr,eUILayer_Debug); #endif } break; case eControl_SetCamera: { #ifndef _CONTENT_PACKAGE - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugSetCamera,NULL,eUILayer_Debug); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugSetCamera,nullptr,eUILayer_Debug); #endif } break; @@ -254,7 +254,7 @@ void UIScene_DebugOverlay::handlePress(F64 controlId, F64 childId) void UIScene_DebugOverlay::handleSliderMove(F64 sliderId, F64 currentValue) { - switch((int)sliderId) + switch(static_cast(sliderId)) { case eControl_Time: { @@ -266,25 +266,25 @@ void UIScene_DebugOverlay::handleSliderMove(F64 sliderId, F64 currentValue) MinecraftServer::SetTime(currentValue * 100); pMinecraft->level->getLevelData()->setGameTime(currentValue * 100); - WCHAR TempString[256]; + WCHAR tempString[256]; float currentTime = currentValue * 100; - swprintf( (WCHAR *)TempString, 256, L"Set time (unsafe) (%d)", (int)currentTime); - m_sliderTime.setLabel(TempString); + swprintf( tempString, 256, L"Set time (unsafe) (%d)", static_cast(currentTime)); + m_sliderTime.setLabel(tempString); } break; case eControl_FOV: { Minecraft *pMinecraft = Minecraft::GetInstance(); - int v = (int)currentValue; + int v = static_cast(currentValue); if (v < 0) v = 0; if (v > 100) v = 100; int fovDeg = 70 + v * 40 / 100; - pMinecraft->gameRenderer->SetFovVal((float)fovDeg); + pMinecraft->gameRenderer->SetFovVal(static_cast(fovDeg)); app.SetGameSettings(m_iPad, eGameSetting_FOV, v); - WCHAR TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"Set fov (%d)", fovDeg); - m_sliderFov.setLabel(TempString); + WCHAR tempString[256]; + swprintf( tempString, 256, L"Set fov (%d)", fovDeg); + m_sliderFov.setLabel(tempString); } break; }; -- cgit v1.2.3