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/PS3/PS3_App.cpp | 60 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'Minecraft.Client/PS3/PS3_App.cpp') diff --git a/Minecraft.Client/PS3/PS3_App.cpp b/Minecraft.Client/PS3/PS3_App.cpp index 780ab03c..762866fb 100644 --- a/Minecraft.Client/PS3/PS3_App.cpp +++ b/Minecraft.Client/PS3/PS3_App.cpp @@ -35,7 +35,7 @@ CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() // debugOverlayCreated = false; // #endif - m_ProductListA=NULL; + m_ProductListA=nullptr; m_bBootedFromDiscPatch=false; memset(m_usrdirPathBDPatch,0,128); m_pRemoteStorage = new SonyRemoteStorage_PS3; @@ -117,7 +117,7 @@ BOOL CConsoleMinecraftApp::ReadProductCodes() char chDLCTitle[64]; // 4J-PB - Read the file containing the product codes. This will be different for the SCEE/SCEA/SCEJ builds - HANDLE file = CreateFile("PS3/PS3ProductCodes.bin", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile("PS3/PS3ProductCodes.bin", GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( file == INVALID_HANDLE_VALUE ) { //DWORD error = GetLastError(); @@ -132,14 +132,14 @@ BOOL CConsoleMinecraftApp::ReadProductCodes() { DWORD bytesRead; - WRAPPED_READFILE(file,ProductCodes.chProductCode,PRODUCT_CODE_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chDiscProductCode,PRODUCT_CODE_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chDiscSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chCommerceCategory,COMMERCE_CATEGORY_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chTexturePackID,SCE_NP_COMMERCE2_CATEGORY_ID_LEN,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chUpgradeKey,UPGRADE_KEY_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chSkuPostfix,SKU_POSTFIX_SIZE,&bytesRead,NULL); + WRAPPED_READFILE(file,ProductCodes.chProductCode,PRODUCT_CODE_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chDiscProductCode,PRODUCT_CODE_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chDiscSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chCommerceCategory,COMMERCE_CATEGORY_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chTexturePackID,SCE_NP_COMMERCE2_CATEGORY_ID_LEN,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chUpgradeKey,UPGRADE_KEY_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chSkuPostfix,SKU_POSTFIX_SIZE,&bytesRead,nullptr); app.DebugPrintf("ProductCodes.chProductCode %s\n",ProductCodes.chProductCode); app.DebugPrintf("ProductCodes.chDiscProductCode %s\n",ProductCodes.chDiscProductCode); @@ -152,7 +152,7 @@ BOOL CConsoleMinecraftApp::ReadProductCodes() // DLC unsigned int uiDLC; - WRAPPED_READFILE(file,&uiDLC,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,&uiDLC,sizeof(int),&bytesRead,nullptr); for(unsigned int i=0;ichDLCKeyname,sizeof(char)*uiVal,&bytesRead,NULL); + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,pDLCInfo->chDLCKeyname,sizeof(char)*uiVal,&bytesRead,nullptr); - WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,chDLCTitle,sizeof(char)*uiVal,&bytesRead,NULL); + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,chDLCTitle,sizeof(char)*uiVal,&bytesRead,nullptr); app.DebugPrintf("DLC title %s\n",chDLCTitle); - WRAPPED_READFILE(file,&pDLCInfo->eDLCType,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,&pDLCInfo->iFirstSkin,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,&pDLCInfo->iConfig,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,&pDLCInfo->eDLCType,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,&pDLCInfo->iFirstSkin,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,&pDLCInfo->iConfig,sizeof(int),&bytesRead,nullptr); // push this into a vector @@ -345,7 +345,7 @@ void CConsoleMinecraftApp::FatalLoadError() } app.DebugPrintf("Requesting Message Box for Fatal Error\n"); - EMsgBoxResult eResult=InputManager.RequestMessageBox(EMSgBoxType_None,0,NULL,this,(char *)u8Message,0); + EMsgBoxResult eResult=InputManager.RequestMessageBox(EMSgBoxType_None,0,nullptr,this,(char *)u8Message,0); while ((eResult==EMsgBox_Busy) || (eResult==EMsgBox_SysUtilBusy)) { @@ -359,7 +359,7 @@ void CConsoleMinecraftApp::FatalLoadError() _Exit(0); } app.DebugPrintf("Requesting Message Box for Fatal Error again due to BUSY\n"); - eResult=InputManager.RequestMessageBox(EMSgBoxType_None,0,NULL,this,(char *)u8Message,0); + eResult=InputManager.RequestMessageBox(EMSgBoxType_None,0,nullptr,this,(char *)u8Message,0); } while(1) @@ -483,7 +483,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() { ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit - app.setLevelGenerationOptions(NULL); + app.setLevelGenerationOptions(nullptr); // From CScene_Main::RunPlayGame Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -521,7 +521,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() #ifdef SAVE_GAME_TO_LOAD param->saveData = LoadSaveFromDisk(wstring(SAVE_GAME_TO_LOAD)); #else - param->saveData = NULL; + param->saveData = nullptr; #endif app.SetGameHostOption(eGameHostOption_Difficulty,0); app.SetGameHostOption(eGameHostOption_FriendsOfFriends,0); @@ -728,7 +728,7 @@ SonyCommerce::CategoryInfo *CConsoleMinecraftApp::GetCategoryInfo() { if(m_bCommerceCategoriesRetrieved==false) { - return NULL; + return nullptr; } return &m_CategoryInfo; @@ -742,10 +742,10 @@ void CConsoleMinecraftApp::ClearCommerceDetails() pProductList->clear(); } - if(m_ProductListA!=NULL) + if(m_ProductListA!=nullptr) { delete [] m_ProductListA; - m_ProductListA=NULL; + m_ProductListA=nullptr; } m_ProductListRetrievedC=0; @@ -769,7 +769,7 @@ void CConsoleMinecraftApp::GetDLCSkuIDFromProductList(char * pchDLCProductID, ch // find the DLC for(int i=0;i* pProductList=&m_ProductListA[i]; auto itEnd = pProductList->end(); @@ -831,7 +831,7 @@ std::vector* CConsoleMinecraftApp::GetProductList(int { if((m_bCommerceProductListRetrieved==false) || (m_bProductListAdditionalDetailsRetrieved==false) ) { - return NULL; + return nullptr; } return &m_ProductListA[iIndex]; @@ -842,7 +842,7 @@ bool CConsoleMinecraftApp::DLCAlreadyPurchased(char *pchTitle) // find the DLC for(int i=0;i* pProductList=&m_ProductListA[i]; auto itEnd = pProductList->end(); @@ -1181,7 +1181,7 @@ char *PatchFilelist[] = - NULL + nullptr }; bool CConsoleMinecraftApp::IsFileInPatchList(LPCSTR lpFileName) @@ -1226,7 +1226,7 @@ bool CConsoleMinecraftApp::CheckForEmptyStore(int iPad) SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); bool bEmptyStore=true; - if(pCategories!=NULL) + if(pCategories!=nullptr) { if(pCategories->countOfProducts>0) { -- cgit v1.2.3