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/4JLibs/STO_TitleSmallStorage.cpp | 16 ++++++++-------- Minecraft.Client/PS3/4JLibs/inc/4J_Input.h | 4 ++-- Minecraft.Client/PS3/4JLibs/inc/4J_Profile.h | 2 +- Minecraft.Client/PS3/4JLibs/inc/4J_Render.h | 6 +++--- Minecraft.Client/PS3/4JLibs/inc/4J_Storage.h | 10 +++++----- 5 files changed, 19 insertions(+), 19 deletions(-) (limited to 'Minecraft.Client/PS3/4JLibs') diff --git a/Minecraft.Client/PS3/4JLibs/STO_TitleSmallStorage.cpp b/Minecraft.Client/PS3/4JLibs/STO_TitleSmallStorage.cpp index f3d2729f..bb7c88c7 100644 --- a/Minecraft.Client/PS3/4JLibs/STO_TitleSmallStorage.cpp +++ b/Minecraft.Client/PS3/4JLibs/STO_TitleSmallStorage.cpp @@ -58,7 +58,7 @@ int32_t CTSS::doLookupTitleSmallStorage(void) { int32_t ret = 0; int32_t transId = 0; - void *data=NULL; + void *data=nullptr; size_t dataSize=0; SceNpId npId; @@ -100,7 +100,7 @@ int32_t CTSS::doLookupTitleSmallStorage(void) //memset(&npclient_info, 0x00, sizeof(npclient_info)); data = malloc(SCE_NET_NP_TSS_MAX_SIZE); - if (data == NULL) + if (data == nullptr) { printf("out of memory: can't allocate memory for titleSmallStorage\n"); ret = -1; @@ -121,7 +121,7 @@ int32_t CTSS::doLookupTitleSmallStorage(void) // data, // SCE_NET_NP_TSS_MAX_SIZE, // &dataSize, -// NULL); +// nullptr); // if (ret < 0) // { // printf("sceNpLookupTitleSmallStorage() failed. ret = 0x%x\n", ret); @@ -150,7 +150,7 @@ int32_t CTSS::doLookupTitleSmallStorage(void) size_t dataSize; SceNpTssSlotId slotId=SLOTID; SceNpTssDataStatus dataStatus; - const char *ptr =NULL; + const char *ptr =nullptr; size_t recvdSize=0; size_t totalSize=0; size_t recvSize=0; @@ -163,7 +163,7 @@ int32_t CTSS::doLookupTitleSmallStorage(void) sizeof(SceNpTssDataStatus), ptr, recvSize, - NULL); + nullptr); if (ret < 0) { // Error handling @@ -174,10 +174,10 @@ int32_t CTSS::doLookupTitleSmallStorage(void) // Processing when there is no data goto finish; } - if (ptr == NULL) + if (ptr == nullptr) { ptr = malloc(dataStatus.contentLength); - if (ptr == NULL){ + if (ptr == nullptr){ // Error handling goto error; } @@ -197,7 +197,7 @@ error: ret = sceNpLookupDestroyTransactionCtx(transId); printf("sceNpLookupDestroyTransactionCtx() done. ret = 0x%x\n", ret); } - if (data != NULL) + if (data != nullptr) { free(data); } diff --git a/Minecraft.Client/PS3/4JLibs/inc/4J_Input.h b/Minecraft.Client/PS3/4JLibs/inc/4J_Input.h index 6f51bba5..9d46e741 100644 --- a/Minecraft.Client/PS3/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/PS3/4JLibs/inc/4J_Input.h @@ -130,8 +130,8 @@ public: void SetMenuDisplayed(int iPad, bool bVal); -// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); -// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); +// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=nullptr); +// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=nullptr); EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode); void DestroyKeyboard(); void GetText(uint16_t *UTF16String); diff --git a/Minecraft.Client/PS3/4JLibs/inc/4J_Profile.h b/Minecraft.Client/PS3/4JLibs/inc/4J_Profile.h index 888c38cc..4a65dcb9 100644 --- a/Minecraft.Client/PS3/4JLibs/inc/4J_Profile.h +++ b/Minecraft.Client/PS3/4JLibs/inc/4J_Profile.h @@ -109,7 +109,7 @@ public: // ACHIEVEMENTS & AWARDS void RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected=false, - CXuiStringTable*pStringTable=NULL, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=NULL, unsigned int uiThemeSize=0L); + CXuiStringTable*pStringTable=nullptr, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=nullptr, unsigned int uiThemeSize=0L); int GetAwardId(int iAwardNumber); eAwardType GetAwardType(int iAwardNumber); bool CanBeAwarded(int iQuadrant, int iAwardNumber); diff --git a/Minecraft.Client/PS3/4JLibs/inc/4J_Render.h b/Minecraft.Client/PS3/4JLibs/inc/4J_Render.h index d55f440b..1b68695f 100644 --- a/Minecraft.Client/PS3/4JLibs/inc/4J_Render.h +++ b/Minecraft.Client/PS3/4JLibs/inc/4J_Render.h @@ -17,8 +17,8 @@ public: int GetType() { return m_type; } void *GetBufferPointer() { return m_pBuffer; } int GetBufferSize() { return m_bufferSize; } - void Release() { delete m_pBuffer; m_pBuffer = NULL; } - bool Allocated() { return m_pBuffer != NULL; } + void Release() { delete m_pBuffer; m_pBuffer = nullptr; } + bool Allocated() { return m_pBuffer != nullptr; } }; typedef struct @@ -60,7 +60,7 @@ public: void InitialiseContext(); void StartFrame(); void Present(); - void Clear(int flags, D3D11_RECT *pRect = NULL); + void Clear(int flags, D3D11_RECT *pRect = nullptr); void SetClearColour(const float colourRGBA[4]); bool IsWidescreen(); bool IsHiDef(); diff --git a/Minecraft.Client/PS3/4JLibs/inc/4J_Storage.h b/Minecraft.Client/PS3/4JLibs/inc/4J_Storage.h index 3950bbad..b95325b3 100644 --- a/Minecraft.Client/PS3/4JLibs/inc/4J_Storage.h +++ b/Minecraft.Client/PS3/4JLibs/inc/4J_Storage.h @@ -293,7 +293,7 @@ typedef struct // Messages C4JStorage::EMessageResult RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=USER_INDEX_ANY, - int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=NULL,LPVOID lpParam=NULL, StringTable *pStringTable=NULL, WCHAR *pwchFormatString=NULL,DWORD dwFocusButton=0); + int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=nullptr,LPVOID lpParam=nullptr, StringTable *pStringTable=nullptr, WCHAR *pwchFormatString=nullptr,DWORD dwFocusButton=0); C4JStorage::EMessageResult GetMessageBoxResult(); @@ -350,7 +350,7 @@ typedef struct void FreeSaveData(); void SetSaveDataSize(unsigned int uiBytes); // after a successful compression, update the size of the gamedata - //void SaveSaveData(unsigned int uiBytes,PBYTE pbThumbnail=NULL,DWORD cbThumbnail=0,PBYTE pbTextData=NULL, DWORD dwTextLen=0); + //void SaveSaveData(unsigned int uiBytes,PBYTE pbThumbnail=nullptr,DWORD cbThumbnail=0,PBYTE pbTextData=nullptr, DWORD dwTextLen=0); C4JStorage::ESaveGameState SaveSaveData(int( *Func)(LPVOID ,const bool),LPVOID lpParam, bool bDataFileOnly = false); void CopySaveDataToNewSave(PBYTE pbThumbnail,DWORD cbThumbnail,WCHAR *wchNewName,int ( *Func)(LPVOID lpParam, bool), LPVOID lpParam); void SetSaveDeviceSelected(unsigned int uiPad,bool bSelected); @@ -383,8 +383,8 @@ typedef struct DWORD GetAvailableDLCCount( int iPad); CONTENT_DATA& GetDLC(DWORD dw); C4JStorage::EDLCStatus GetInstalledDLC(int iPad,int( *Func)(LPVOID, int, int),LPVOID lpParam); - DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive = NULL); - DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL); + DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive = nullptr); + DWORD UnmountInstalledDLC(LPCSTR szMountDrive = nullptr); void GetMountedDLCFileList(const char* szMountDrive, std::vector& fileList); std::string GetMountedPath(std::string szMount); C4JStorage::ETMSStatus ReadTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,C4JStorage::eTMS_FileType eFileType, WCHAR *pwchFilename,BYTE **ppBuffer,DWORD *pdwBufferSize,int( *Func)(LPVOID, WCHAR *,int, bool, int),LPVOID lpParam, int iAction) { return C4JStorage::ETMSStatus_Idle; } @@ -400,7 +400,7 @@ typedef struct bool CheckForTrialUpgradeKey(void( *Func)(LPVOID, bool),LPVOID lpParam); - C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)/*=NULL*/,LPVOID lpParam/*=NULL*/, int iUserData/*=0*/) {return C4JStorage::ETMSStatus_Idle;} + C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)/*=nullptr*/,LPVOID lpParam/*=nullptr*/, int iUserData/*=0*/) {return C4JStorage::ETMSStatus_Idle;} // PROFILE DATA int SetDefaultOptionsCallback(int( *Func)(LPVOID,PROFILESETTINGS *, const int iPad),LPVOID lpParam); -- cgit v1.2.3