From 28614b922fb77149a54da1a87bebfbc98736f296 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:08:36 -0400 Subject: Modernize project codebase (#906) * 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 * Add safety checks and fix a issue with vector going OOR --- Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp | 48 ++++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp') diff --git a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp index 6f502db8..7cec38b3 100644 --- a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp @@ -101,9 +101,9 @@ UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLa TelemetryManager->RecordPauseOrInactive(m_iPad); Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft != NULL && pMinecraft->localgameModes[iPad] != NULL ) + if(pMinecraft != nullptr && pMinecraft->localgameModes[iPad] != nullptr ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[iPad]); // This just allows it to be shown gameMode->getTutorial()->showTutorialPopup(false); @@ -114,9 +114,9 @@ UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLa UIScene_PauseMenu::~UIScene_PauseMenu() { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft != NULL && pMinecraft->localgameModes[m_iPad] != NULL ) + if(pMinecraft != nullptr && pMinecraft->localgameModes[m_iPad] != nullptr ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); // This just allows it to be shown gameMode->getTutorial()->showTutorialPopup(true); @@ -506,7 +506,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { if(m_bIgnoreInput) return; - switch((int)controlId) + switch(static_cast(controlId)) { case BUTTON_PAUSE_RESUMEGAME: if( m_iPad == ProfileManager.GetPrimaryPad() && g_NetworkManager.IsLocalGame() ) @@ -593,7 +593,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { bool bContentRestricted=false; #if defined(__PS3__) || defined(__PSVITA__) - ProfileManager.GetChatAndContentRestrictions(m_iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(m_iPad,true,nullptr,&bContentRestricted,nullptr); #endif if(bContentRestricted) { @@ -654,9 +654,9 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) if(m_iPad==ProfileManager.GetPrimaryPad()) { int playTime = -1; - if( pMinecraft->localplayers[m_iPad] != NULL ) + if( pMinecraft->localplayers[m_iPad] != nullptr ) { - playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } #if defined(_XBOX_ONE) || defined(__ORBIS__) @@ -723,9 +723,9 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) else { int playTime = -1; - if( pMinecraft->localplayers[m_iPad] != NULL ) + if( pMinecraft->localplayers[m_iPad] != nullptr ) { - playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } TelemetryManager->RecordLevelExit(m_iPad, eSen_LevelExitStatus_Exited); @@ -741,9 +741,9 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) if(m_iPad==ProfileManager.GetPrimaryPad()) { int playTime = -1; - if( pMinecraft->localplayers[m_iPad] != NULL ) + if( pMinecraft->localplayers[m_iPad] != nullptr ) { - playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } // adjust the trial time played @@ -759,9 +759,9 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) else { int playTime = -1; - if( pMinecraft->localplayers[m_iPad] != NULL ) + if( pMinecraft->localplayers[m_iPad] != nullptr ) { - playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } TelemetryManager->RecordLevelExit(m_iPad, eSen_LevelExitStatus_Exited); @@ -839,7 +839,7 @@ void UIScene_PauseMenu::PerformActionSaveGame() if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; + DLCTexturePack *pDLCTexPack=static_cast(tPack); m_pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack(); @@ -979,7 +979,7 @@ int UIScene_PauseMenu::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage:: // 4J-PB - need to check this user can access the store #if defined(__PS3__) || defined(__PSVITA__) bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -1003,7 +1003,7 @@ int UIScene_PauseMenu::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage:: int UIScene_PauseMenu::SaveGame_SignInReturned(void *pParam,bool bContinue, int iPad) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam); + UIScene_PauseMenu* pClass = static_cast(ui.GetSceneFromCallbackId((size_t)pParam)); if(pClass) pClass->SetIgnoreInput(false); if(bContinue==true) @@ -1112,7 +1112,7 @@ int UIScene_PauseMenu::ViewLeaderboards_SignInReturned(void *pParam,bool bContin { #ifndef __ORBIS__ bool bContentRestricted=false; - ProfileManager.GetChatAndContentRestrictions(pClass->m_iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(pClass->m_iPad,true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { // you can't see leaderboards @@ -1183,7 +1183,7 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4J #ifndef __ORBIS__ // 4J-PB - need to check this user can access the store bool bContentRestricted=false; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -1203,7 +1203,7 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4J app.DebugPrintf("Texture Pack - %s\n",pchPackName); SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName); - if(pSONYDLCInfo!=NULL) + if(pSONYDLCInfo!=nullptr) { char chName[42]; char chKeyName[20]; @@ -1214,7 +1214,7 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4J // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it. // So we assume the first sku for the product is the one we want - // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char + // MGH - keyname in the DLC file is 16 chars long, but there's no space for a nullptr terminating char memset(chKeyName, 0, sizeof(chKeyName)); strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); @@ -1260,7 +1260,7 @@ int UIScene_PauseMenu::BuyTexturePack_SignInReturned(void *pParam,bool bContinue #ifndef __ORBIS__ // 4J-PB - need to check this user can access the store bool bContentRestricted=false; - ProfileManager.GetChatAndContentRestrictions(iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(iPad,true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -1280,7 +1280,7 @@ int UIScene_PauseMenu::BuyTexturePack_SignInReturned(void *pParam,bool bContinue app.DebugPrintf("Texture Pack - %s\n",pchPackName); SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName); - if(pSONYDLCInfo!=NULL) + if(pSONYDLCInfo!=nullptr) { char chName[42]; char chKeyName[20]; @@ -1291,7 +1291,7 @@ int UIScene_PauseMenu::BuyTexturePack_SignInReturned(void *pParam,bool bContinue // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it. // So we assume the first sku for the product is the one we want - // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char + // MGH - keyname in the DLC file is 16 chars long, but there's no space for a nullptr terminating char memset(chKeyName, 0, sizeof(chKeyName)); strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); -- cgit v1.2.3