diff options
| author | ModMaker101 <119018978+ModMaker101@users.noreply.github.com> | 2026-03-08 19:08:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-08 18:08:36 -0500 |
| commit | 28614b922fb77149a54da1a87bebfbc98736f296 (patch) | |
| tree | 7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.Client/Durango | |
| parent | 88798b501d0cf6287b6f87acb2592676e3cec58d (diff) | |
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
Diffstat (limited to 'Minecraft.Client/Durango')
37 files changed, 424 insertions, 424 deletions
diff --git a/Minecraft.Client/Durango/4JLibs/inc/4J_Input.h b/Minecraft.Client/Durango/4JLibs/inc/4J_Input.h index 884f281e..a24d6116 100644 --- a/Minecraft.Client/Durango/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/Durango/4JLibs/inc/4J_Input.h @@ -61,8 +61,8 @@ STRING_VERIFY_RESPONSE; class C4JStringTable { public: - LPCWSTR Lookup(LPCWSTR szId) {return NULL;} - LPCWSTR Lookup(UINT nIndex) {return NULL;} + LPCWSTR Lookup(LPCWSTR szId) {return nullptr;} + LPCWSTR Lookup(UINT nIndex) {return nullptr;} void Clear(); HRESULT Load(LPCWSTR szId) {return S_OK;} }; @@ -126,8 +126,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, int iMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode); void DestroyKeyboard(); diff --git a/Minecraft.Client/Durango/4JLibs/inc/4J_Profile.h b/Minecraft.Client/Durango/4JLibs/inc/4J_Profile.h index dab46417..961b5d2a 100644 --- a/Minecraft.Client/Durango/4JLibs/inc/4J_Profile.h +++ b/Minecraft.Client/Durango/4JLibs/inc/4J_Profile.h @@ -132,7 +132,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/Durango/4JLibs/inc/4J_Render.h b/Minecraft.Client/Durango/4JLibs/inc/4J_Render.h index 737caa98..fb16ccb3 100644 --- a/Minecraft.Client/Durango/4JLibs/inc/4J_Render.h +++ b/Minecraft.Client/Durango/4JLibs/inc/4J_Render.h @@ -16,8 +16,8 @@ public: int GetType() { return m_type; } void *GetBufferPointer() { return m_pBuffer; } int GetBufferSize() { return m_bufferSize; } - void Release() { free(m_pBuffer); m_pBuffer = NULL; } - bool Allocated() { return m_pBuffer != NULL; } + void Release() { free(m_pBuffer); m_pBuffer = nullptr; } + bool Allocated() { return m_pBuffer != nullptr; } }; typedef struct @@ -60,7 +60,7 @@ public: void StartFrame(); void DoScreenGrabOnNextPresent(); 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/Durango/4JLibs/inc/4J_Storage.h b/Minecraft.Client/Durango/4JLibs/inc/4J_Storage.h index be5d57fd..62493952 100644 --- a/Minecraft.Client/Durango/4JLibs/inc/4J_Storage.h +++ b/Minecraft.Client/Durango/4JLibs/inc/4J_Storage.h @@ -378,7 +378,7 @@ public: // Get details of existing savedata C4JStorage::ESaveGameState GetSavesInfo(int iPad,int ( *Func)(LPVOID lpParam,SAVE_DETAILS *pSaveDetails,const bool),LPVOID lpParam,char *pszSavePackName); // Start search - PSAVE_DETAILS ReturnSavesInfo(); // Returns result of search (or NULL if not yet received) + PSAVE_DETAILS ReturnSavesInfo(); // Returns result of search (or nullptr if not yet received) void ClearSavesInfo(); // Clears results C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam, bool force=false); // Get the thumbnail for an individual save referenced by pSaveInfo @@ -442,8 +442,8 @@ public: void SetLicenseChangeFn(void( *Func)(void)); XCONTENT_DATA& GetDLC(DWORD dw); - DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPWSTR szMountDrive = NULL); - DWORD UnmountInstalledDLC(LPWSTR szMountDrive = NULL); + DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPWSTR szMountDrive = nullptr); + DWORD UnmountInstalledDLC(LPWSTR szMountDrive = nullptr); void GetMountedDLCFileList(const char* szMountDrive, std::vector<std::wstring>& fileList); std::wstring GetMountedPath(std::wstring szMount); XCONTENT_DATA * GetInstalledDLC(WCHAR *wszProductID); @@ -470,10 +470,10 @@ public: // TMS++ C4JStorage::ETMSStatus TMSPP_GetUserQuotaInfo(C4JStorage::eGlobalStorage eStorageFacility,int iPad);//,TMSCLIENT_CALLBACK Func,LPVOID lpParam, int iUserData=0); - eTitleStorageState TMSPP_WriteFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,BYTE *pbBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=NULL,LPVOID lpParam=NULL, int iUserData=0); + eTitleStorageState TMSPP_WriteFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,BYTE *pbBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=nullptr,LPVOID lpParam=nullptr, int iUserData=0); eTitleStorageState TMSPP_ReadFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,int( *Func)(LPVOID,int,int,LPVOID, WCHAR *),LPVOID lpParam, int iUserData); eTitleStorageState TMSPP_DeleteFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,int( *Func)(LPVOID,int,int),LPVOID lpParam, int iUserData); - eTitleStorageState TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,int( *Func)(LPVOID,int,int,LPVOID,WCHAR *)=NULL,LPVOID lpParam=NULL, int iUserData=0); + eTitleStorageState TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,int( *Func)(LPVOID,int,int,LPVOID,WCHAR *)=nullptr,LPVOID lpParam=nullptr, int iUserData=0); bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const wstring &Filename); eTitleStorageState TMSPP_GetTitleStorageState(int iPad); diff --git a/Minecraft.Client/Durango/ApplicationView.cpp b/Minecraft.Client/Durango/ApplicationView.cpp index 2af86496..6c195938 100644 --- a/Minecraft.Client/Durango/ApplicationView.cpp +++ b/Minecraft.Client/Durango/ApplicationView.cpp @@ -22,7 +22,7 @@ ApplicationView::ApplicationView() XALLOC_ATTRIBUTES ExpandAllocAttributes( _In_ LONGLONG dwAttributes ) { XALLOC_ATTRIBUTES attr; - attr = *((XALLOC_ATTRIBUTES *)&dwAttributes); + attr = *static_cast<XALLOC_ATTRIBUTES *>(&dwAttributes); return attr; } @@ -247,7 +247,7 @@ void ApplicationView::OnSuspending(Platform::Object^ sender, SuspendingEventArgs LARGE_INTEGER qwTicksPerSec, qwTime, qwNewTime, qwDeltaTime; float fElapsedTime = 0.0f; QueryPerformanceFrequency( &qwTicksPerSec ); - float fSecsPerTick = 1.0f / (float)qwTicksPerSec.QuadPart; + float fSecsPerTick = 1.0f / static_cast<float>(qwTicksPerSec.QuadPart); // Save the start time QueryPerformanceCounter( &qwTime ); @@ -275,7 +275,7 @@ void ApplicationView::OnSuspending(Platform::Object^ sender, SuspendingEventArgs QueryPerformanceCounter( &qwNewTime ); qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; - fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); + fElapsedTime = fSecsPerTick * static_cast<FLOAT>(qwDeltaTime.QuadPart); app.DebugPrintf("Entire suspend process: Elapsed time %f\n", fElapsedTime); } diff --git a/Minecraft.Client/Durango/DurangoExtras/DurangoStubs.cpp b/Minecraft.Client/Durango/DurangoExtras/DurangoStubs.cpp index 81b9d7cf..463756bc 100644 --- a/Minecraft.Client/Durango/DurangoExtras/DurangoStubs.cpp +++ b/Minecraft.Client/Durango/DurangoExtras/DurangoStubs.cpp @@ -32,7 +32,7 @@ DWORD XGetLanguage() WCHAR wchLocaleName[LOCALE_NAME_MAX_LENGTH]; GetUserDefaultLocaleName(wchLocaleName,LOCALE_NAME_MAX_LENGTH); - eMCLang eLang=(eMCLang)app.get_eMCLang(wchLocaleName); + eMCLang eLang=static_cast<eMCLang>(app.get_eMCLang(wchLocaleName)); #ifdef _DEBUG app.DebugPrintf("XGetLanguage() ==> '%ls'\n", wchLocaleName); diff --git a/Minecraft.Client/Durango/Durango_App.cpp b/Minecraft.Client/Durango/Durango_App.cpp index 672d6435..efef93b4 100644 --- a/Minecraft.Client/Durango/Durango_App.cpp +++ b/Minecraft.Client/Durango/Durango_App.cpp @@ -12,6 +12,7 @@ #include "ServiceConfig\Events-XBLA.8-149E11AEEvents.h" #include "..\..\Minecraft.World\DurangoStats.h" #include "..\..\Minecraft.Client\Durango\XML\xmlFilesCallback.h" +#include "Common/UI/UI.h" CConsoleMinecraftApp app; @@ -42,7 +43,7 @@ void CConsoleMinecraftApp::HandleDLCLicenseChange() XCONTENT_DATA *pContentData=StorageManager.GetInstalledDLC(xOffer.wszProductID); - if((pContentData!=NULL) &&(pContentData->bTrialLicense==false)) + if((pContentData!=nullptr) &&(pContentData->bTrialLicense==false)) { DLCPack *pack = app.m_dlcManager.getPackFromProductID(xOffer.wszProductID); if(pack) @@ -193,7 +194,7 @@ void CConsoleMinecraftApp::FreeLocalDLCImages() { free(pDLCInfo->pbImageData); pDLCInfo->dwImageBytes=0; - pDLCInfo->pbImageData=NULL; + pDLCInfo->pbImageData=nullptr; } } } @@ -207,7 +208,7 @@ int CConsoleMinecraftApp::LoadLocalDLCImage(WCHAR *wchName,PBYTE *ppbImageData,D // 4J-PB - Read the file containing the product codes. This will be different for the SCEE/SCEA/SCEJ builds swprintf(wchFilename,L"DLCImages/%s",wchName); - HANDLE hFile = CreateFile(wchFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFile(wchFilename, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( hFile == INVALID_HANDLE_VALUE ) { @@ -221,9 +222,9 @@ int CConsoleMinecraftApp::LoadLocalDLCImage(WCHAR *wchName,PBYTE *ppbImageData,D if(*pdwBytes!=0) { DWORD dwBytesRead; - PBYTE pbImageData=(PBYTE)malloc(*pdwBytes); + PBYTE pbImageData=static_cast<PBYTE>(malloc(*pdwBytes)); - if(ReadFile(hFile,pbImageData,*pdwBytes,&dwBytesRead,NULL)==FALSE) + if(ReadFile(hFile,pbImageData,*pdwBytes,&dwBytesRead,nullptr)==FALSE) { // failed free(pbImageData); @@ -244,7 +245,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() { ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit - app.setLevelGenerationOptions(NULL); + app.setLevelGenerationOptions(nullptr); // From CScene_Main::RunPlayGame Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -273,7 +274,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() NetworkGameInitData *param = new NetworkGameInitData(); param->seed = seedValue; - param->saveData = NULL; + param->saveData = nullptr; app.SetGameHostOption(eGameHostOption_Difficulty,0); app.SetGameHostOption(eGameHostOption_FriendsOfFriends,0); @@ -299,7 +300,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast<LPVOID>(param); // Reset the autosave time app.SetAutosaveTimerTime(); @@ -386,7 +387,7 @@ bool CConsoleMinecraftApp::UpdateProductId(XCONTENT_DATA &Data) // Do we have a product id for this? DLC_INFO *pDLCInfo=app.GetDLCInfoForProductName(Data.wszDisplayName); - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { app.DebugPrintf("Updating product id for %ls\n",Data.wszDisplayName); swprintf_s(Data.wszProductID, 64,L"%ls",pDLCInfo->wsProductId.c_str()); @@ -454,9 +455,9 @@ bool CConsoleMinecraftApp::TMSPP_ReadBannedList(int iPad,eTMSAction NextAction) int CConsoleMinecraftApp::Callback_TMSPPReadBannedList(void *pParam,int iPad, int iUserData, LPVOID lpvData,WCHAR *wchFilename) { app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPReadBannedList\n"); - C4JStorage::PTMSPP_FILEDATA pFileData=(C4JStorage::PTMSPP_FILEDATA)lpvData; + C4JStorage::PTMSPP_FILEDATA pFileData=static_cast<C4JStorage::PTMSPP_FILEDATA>(lpvData); - CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + CConsoleMinecraftApp* pClass = static_cast<CConsoleMinecraftApp *>(pParam); if(pFileData) { @@ -486,7 +487,7 @@ int CConsoleMinecraftApp::Callback_TMSPPReadBannedList(void *pParam,int iPad, in } // change the state to the next action - pClass->SetTMSAction(iPad,(eTMSAction)iUserData); + pClass->SetTMSAction(iPad,static_cast<eTMSAction>(iUserData)); return 0; } @@ -555,11 +556,11 @@ void CConsoleMinecraftApp::TMSPP_RetrieveFileList(int iPad,C4JStorage::eGlobalSt int CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList(void *pParam,int iPad, int iUserData, LPVOID lpvData, WCHAR *wchFilename) { - CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + CConsoleMinecraftApp* pClass = static_cast<CConsoleMinecraftApp *>(pParam); app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList\n"); - if(lpvData!=NULL) + if(lpvData!= nullptr) { - vector<C4JStorage::PTMSPP_FILE_DETAILS> *pvTmsFileDetails=(vector<C4JStorage::PTMSPP_FILE_DETAILS> *)lpvData; + vector<C4JStorage::PTMSPP_FILE_DETAILS> *pvTmsFileDetails=static_cast<vector<C4JStorage::PTMSPP_FILE_DETAILS> *>(lpvData); if(pvTmsFileDetails->size()>0) { @@ -578,7 +579,7 @@ int CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList(void *pParam,int iPad, } } // change the state to the next action - pClass->SetTMSAction(iPad,(eTMSAction)iUserData); + pClass->SetTMSAction(iPad,static_cast<eTMSAction>(iUserData)); return 0; } @@ -586,8 +587,8 @@ int CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList(void *pParam,int iPad, int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int iUserData, LPVOID lpvData ,WCHAR *pwchFilename) { app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPReadDLCFile\n"); - C4JStorage::PTMSPP_FILEDATA pFileData= (C4JStorage::PTMSPP_FILEDATA)lpvData; - CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + C4JStorage::PTMSPP_FILEDATA pFileData= static_cast<C4JStorage::PTMSPP_FILEDATA>(lpvData); + CConsoleMinecraftApp* pClass = static_cast<CConsoleMinecraftApp *>(pParam); #ifdef WRITE_DLCINFO if(0) @@ -635,7 +636,7 @@ int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int i // hack for now to upload the file // open the local file - file = CreateFile(L"DLCXbox1.cmp", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile(L"DLCXbox1.cmp", GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( file == INVALID_HANDLE_VALUE ) { DWORD error = GetLastError(); @@ -653,12 +654,12 @@ int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int i PBYTE pbData= new BYTE [dwFileSize]; - ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); + ReadFile(file,pbData,dwFileSize,&bytesRead,nullptr); if(bytesRead==dwFileSize) { - //StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"DLCXbox1.cmp",(PBYTE) pbData, dwFileSize,NULL,NULL, 0); - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.cmp",(PBYTE) pbData, dwFileSize,NULL,NULL, 0); + //StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"DLCXbox1.cmp",(PBYTE) pbData, dwFileSize,nullptr,nullptr, 0); + StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.cmp",(PBYTE) pbData, dwFileSize,nullptr,nullptr, 0); } Sleep(5000); } @@ -667,7 +668,7 @@ int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int i /* // now the icon - file = CreateFile(L"TP06.png", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile(L"TP06.png", GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( file == INVALID_HANDLE_VALUE ) { DWORD error = GetLastError(); @@ -684,11 +685,11 @@ int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int i PBYTE pbData= new BYTE [dwFileSize]; - ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); + ReadFile(file,pbData,dwFileSize,&bytesRead,nullptr); if(bytesRead==dwFileSize) { - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.png",(PBYTE) pbData, dwFileSize,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.png",(PBYTE) pbData, dwFileSize,nullptr,nullptr, 0); } Sleep(5000); } @@ -698,14 +699,14 @@ int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int i } // change the state to the next action - pClass->SetTMSAction(iPad,(eTMSAction)iUserData); + pClass->SetTMSAction(iPad,static_cast<eTMSAction>(iUserData)); return 0; } void CConsoleMinecraftApp::Callback_SaveGameIncomplete(void *pParam, C4JStorage::ESaveIncompleteType saveIncompleteType) { - CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + CConsoleMinecraftApp* pClass = static_cast<CConsoleMinecraftApp *>(pParam); if ( saveIncompleteType == C4JStorage::ESaveIncomplete_OutOfQuota || saveIncompleteType == C4JStorage::ESaveIncomplete_OutOfLocalStorage ) @@ -740,7 +741,7 @@ void CConsoleMinecraftApp::Callback_SaveGameIncomplete(void *pParam, C4JStorage: int CConsoleMinecraftApp::Callback_SaveGameIncompleteMessageBoxReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + CConsoleMinecraftApp* pClass = static_cast<CConsoleMinecraftApp *>(pParam); switch(result) { @@ -757,7 +758,7 @@ int CConsoleMinecraftApp::Callback_SaveGameIncompleteMessageBoxReturned(void *pP StorageManager.CancelIncompleteOperation(); break; case C4JStorage::EMessage_ResultThirdOption: - ui.NavigateToScene(iPad, eUIScene_InGameSaveManagementMenu, NULL, eUILayer_Error, eUIGroup_Fullscreen); + ui.NavigateToScene(iPad, eUIScene_InGameSaveManagementMenu, nullptr, eUILayer_Error, eUIGroup_Fullscreen); break; } return 0; diff --git a/Minecraft.Client/Durango/Durango_App.h b/Minecraft.Client/Durango/Durango_App.h index 6e021232..ba4b26fb 100644 --- a/Minecraft.Client/Durango/Durango_App.h +++ b/Minecraft.Client/Durango/Durango_App.h @@ -37,7 +37,7 @@ public: virtual int GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT=eFileExtensionType_PNG); // BANNED LEVEL LIST - virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false) {} + virtual void ReadBannedList(int iPad, eTMSAction action=static_cast<eTMSAction>(0), bool bCallback=false) {} // TMS++ void TMSPP_RetrieveFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,eTMSAction NextAction); @@ -58,7 +58,7 @@ public: static void Callback_SaveGameIncomplete(void *pParam, C4JStorage::ESaveIncompleteType saveIncompleteType); static int Callback_SaveGameIncompleteMessageBoxReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - C4JStringTable *GetStringTable() { return NULL;} + C4JStringTable *GetStringTable() { return nullptr;} // original code virtual void TemporaryCreateGameStart(); diff --git a/Minecraft.Client/Durango/Durango_Minecraft.cpp b/Minecraft.Client/Durango/Durango_Minecraft.cpp index 7fdab1be..350c4dbf 100644 --- a/Minecraft.Client/Durango/Durango_Minecraft.cpp +++ b/Minecraft.Client/Durango/Durango_Minecraft.cpp @@ -272,7 +272,7 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice, return pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, - NULL, + nullptr, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES, pd3dPP, ppDevice ); @@ -291,7 +291,7 @@ void MemSect(int sect) #endif -HINSTANCE g_hInst = NULL; +HINSTANCE g_hInst = nullptr; Platform::Agile<Windows::UI::Core::CoreWindow> g_window; Windows::Foundation::Rect g_windowBounds; @@ -474,7 +474,7 @@ void oldWinMainInit() MSG msg = {0}; while( WM_QUIT != msg.message ) { - if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) + if( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); @@ -546,7 +546,7 @@ void oldWinMainInit() } // Create an XAudio2 mastering voice (utilized by XHV2 when voice data is mixed to main speakers) - hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL); + hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, nullptr); if ( FAILED( hr ) ) { app.DebugPrintf( "Creating XAudio2 mastering voice failed (err = 0x%08x)!\n", hr ); @@ -583,7 +583,7 @@ void oldWinMainInit() app.ReadLocalDLCList(); // initialise the storage manager with a default save display name, a Minimum save size, and a callback for displaying the saving message - StorageManager.Init(0,app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,(LPVOID)&app, app.UpdateProductId,SERVICE_CONFIG_ID,TITLE_PRODUCT_ID); + StorageManager.Init(0,app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,static_cast<LPVOID>(&app), app.UpdateProductId,SERVICE_CONFIG_ID,TITLE_PRODUCT_ID); StorageManager.SetMaxSaves(99); @@ -596,21 +596,21 @@ void oldWinMainInit() app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, &app.uiGameDefinedDataChangedBitmask); - StorageManager.SetDefaultImages((PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); + StorageManager.SetDefaultImages(static_cast<PBYTE>(baSaveThumbnail.data), baSaveThumbnail.length); // Set function to be called if a save game operation can't complete due to running out of storage space etc. - StorageManager.SetIncompleteSaveCallback(CConsoleMinecraftApp::Callback_SaveGameIncomplete, (LPVOID)&app); + StorageManager.SetIncompleteSaveCallback(CConsoleMinecraftApp::Callback_SaveGameIncomplete, static_cast<LPVOID>(&app)); // set a function to be called when there's a sign in change, so we can exit a level if the primary player signs out ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app); // Set a callback for the default player options to be set - when there is no profile data for the player - StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app); - StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,(LPVOID)&app); + StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,static_cast<LPVOID>(&app)); + StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,static_cast<LPVOID>(&app)); // Set a callback to deal with old profile versions needing updated to new versions - StorageManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app); + StorageManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,static_cast<LPVOID>(&app)); g_NetworkManager.Initialise(); @@ -785,7 +785,7 @@ void oldWinMainTick() else { MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); + pMinecraft->soundEngine->tick(nullptr, 0.0f); MemSect(0); pMinecraft->textures->tick(true,false); IntCache::Reset(); diff --git a/Minecraft.Client/Durango/Durango_UIController.cpp b/Minecraft.Client/Durango/Durango_UIController.cpp index 446ab87e..e27d91d2 100644 --- a/Minecraft.Client/Durango/Durango_UIController.cpp +++ b/Minecraft.Client/Durango/Durango_UIController.cpp @@ -75,7 +75,7 @@ void ConsoleUIController::render() example, no resolve targets are required. */ gdraw_D3D11_SetTileOrigin( m_pRenderTargetView.Get(), m_pDepthStencilView.Get(), - NULL, + nullptr, 0, 0 ); @@ -153,7 +153,7 @@ void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) { gdraw_D3D11_SetTileOrigin( m_pRenderTargetView.Get(), m_pDepthStencilView.Get(), - NULL, + nullptr, xPos, yPos ); } @@ -169,7 +169,7 @@ GDrawTexture *ConsoleUIController::getSubstitutionTexture(int textureId) ID3D11ShaderResourceView *tex = RenderManager.TextureGetTexture(textureId); ID3D11Resource *resource; tex->GetResource(&resource); - ID3D11Texture2D *tex2d = (ID3D11Texture2D *)resource; + ID3D11Texture2D *tex2d = static_cast<ID3D11Texture2D *>(resource); D3D11_TEXTURE2D_DESC desc; tex2d->GetDesc(&desc); GDrawTexture *gdrawTex = gdraw_D3D11_WrappedTextureCreate(tex); diff --git a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d10_shaders.inl b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d10_shaders.inl index d4d2bb22..6ea0d142 100644 --- a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d10_shaders.inl +++ b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d10_shaders.inl @@ -1364,7 +1364,7 @@ static DWORD pshader_exceptional_blend_12[276] = { }; static ProgramWithCachedVariableLocations pshader_exceptional_blend_arr[13] = { - { NULL, 0, }, + { nullptr, 0, }, { pshader_exceptional_blend_1, 1340, }, { pshader_exceptional_blend_2, 1444, }, { pshader_exceptional_blend_3, 1424, }, @@ -2672,10 +2672,10 @@ static ProgramWithCachedVariableLocations pshader_filter_arr[32] = { { pshader_filter_9, 708, }, { pshader_filter_10, 1644, }, { pshader_filter_11, 1372, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, { pshader_filter_16, 1740, }, { pshader_filter_17, 1732, }, { pshader_filter_18, 1820, }, @@ -2688,10 +2688,10 @@ static ProgramWithCachedVariableLocations pshader_filter_arr[32] = { { pshader_filter_25, 1468, }, { pshader_filter_26, 1820, }, { pshader_filter_27, 1548, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, }; static DWORD pshader_blur_2[320] = { @@ -3193,8 +3193,8 @@ static DWORD pshader_blur_9[621] = { }; static ProgramWithCachedVariableLocations pshader_blur_arr[10] = { - { NULL, 0, }, - { NULL, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, { pshader_blur_2, 1280, }, { pshader_blur_3, 1452, }, { pshader_blur_4, 1624, }, diff --git a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.cpp b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.cpp index 0c106b3f..b5bfe1f6 100644 --- a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.cpp +++ b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.cpp @@ -64,7 +64,7 @@ static void *map_buffer(ID3D1XContext *ctx, ID3D11Buffer *buf, bool discard) HRESULT hr = ctx->Map(buf, 0, discard ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE, 0, &msr); if (FAILED(hr)) { report_d3d_error(hr, "Map", "of buffer"); - return NULL; + return nullptr; } else return msr.pData; } @@ -76,12 +76,12 @@ static void unmap_buffer(ID3D1XContext *ctx, ID3D11Buffer *buf) static RADINLINE void set_pixel_shader(ID3D11DeviceContext *ctx, ID3D11PixelShader *shader) { - ctx->PSSetShader(shader, NULL, 0); + ctx->PSSetShader(shader, nullptr, 0); } static RADINLINE void set_vertex_shader(ID3D11DeviceContext *ctx, ID3D11VertexShader *shader) { - ctx->VSSetShader(shader, NULL, 0); + ctx->VSSetShader(shader, nullptr, 0); } static ID3D11BlendState *create_blend_state(ID3D11Device *dev, BOOL blend, D3D11_BLEND src, D3D11_BLEND dst) @@ -100,7 +100,7 @@ static ID3D11BlendState *create_blend_state(ID3D11Device *dev, BOOL blend, D3D11 HRESULT hr = dev->CreateBlendState(&desc, &res); if (FAILED(hr)) { report_d3d_error(hr, "CreateBlendState", ""); - res = NULL; + res = nullptr; } return res; @@ -113,10 +113,10 @@ static void create_pixel_shader(ProgramWithCachedVariableLocations *p, ProgramWi { *p = *src; if(p->bytecode) { - HRESULT hr = gdraw->d3d_device->CreatePixelShader(p->bytecode, p->size, NULL, &p->pshader); + HRESULT hr = gdraw->d3d_device->CreatePixelShader(p->bytecode, p->size, nullptr, &p->pshader); if (FAILED(hr)) { report_d3d_error(hr, "CreatePixelShader", ""); - p->pshader = NULL; + p->pshader = nullptr; return; } } @@ -126,10 +126,10 @@ static void create_vertex_shader(ProgramWithCachedVariableLocations *p, ProgramW { *p = *src; if(p->bytecode) { - HRESULT hr = gdraw->d3d_device->CreateVertexShader(p->bytecode, p->size, NULL, &p->vshader); + HRESULT hr = gdraw->d3d_device->CreateVertexShader(p->bytecode, p->size, nullptr, &p->vshader); if (FAILED(hr)) { report_d3d_error(hr, "CreateVertexShader", ""); - p->vshader = NULL; + p->vshader = nullptr; return; } } diff --git a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.h b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.h index c8db492a..f8a5dc6d 100644 --- a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.h +++ b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.h @@ -41,7 +41,7 @@ IDOC extern GDrawFunctions * gdraw_D3D11_CreateContext(ID3D11Device *dev, ID3D11 There can only be one D3D GDraw context active at any one time. If initialization fails for some reason (the main reason would be an out of memory condition), - NULL is returned. Otherwise, you can pass the return value to IggySetGDraw. */ + nullptr is returned. Otherwise, you can pass the return value to IggySetGDraw. */ IDOC extern void gdraw_D3D11_DestroyContext(void); /* Destroys the current GDraw context, if any. */ @@ -69,7 +69,7 @@ IDOC extern void gdraw_D3D11_SetTileOrigin(ID3D11RenderTargetView *main_rt, ID3D If your rendertarget uses multisampling, you also need to specify a shader resource view for a non-MSAA rendertarget texture (identically sized to main_rt) in non_msaa_rt. This is only used if the Flash content includes non-standard - blend modes which have to use a special blend shader, so you can leave it NULL + blend modes which have to use a special blend shader, so you can leave it nullptr if you forbid such content. You need to call this before Iggy calls any rendering functions. */ diff --git a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d1x_shared.inl b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d1x_shared.inl index 1ab1f13f..1cbac10f 100644 --- a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d1x_shared.inl +++ b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d1x_shared.inl @@ -196,16 +196,16 @@ static void safe_release(T *&p) { if (p) { p->Release(); - p = NULL; + p = nullptr; } } static void report_d3d_error(HRESULT hr, char *call, char *context) { if (hr == E_OUTOFMEMORY) - IggyGDrawSendWarning(NULL, "GDraw D3D out of memory in %s%s", call, context); + IggyGDrawSendWarning(nullptr, "GDraw D3D out of memory in %s%s", call, context); else - IggyGDrawSendWarning(NULL, "GDraw D3D error in %s%s: 0x%08x", call, context, hr); + IggyGDrawSendWarning(nullptr, "GDraw D3D error in %s%s: 0x%08x", call, context, hr); } static void unbind_resources(void) @@ -215,12 +215,12 @@ static void unbind_resources(void) // unset active textures and vertex/index buffers, // to make sure there are no dangling refs static ID3D1X(ShaderResourceView) *no_views[3] = { 0 }; - ID3D1X(Buffer) *no_vb = NULL; + ID3D1X(Buffer) *no_vb = nullptr; UINT no_offs = 0; d3d->PSSetShaderResources(0, 3, no_views); d3d->IASetVertexBuffers(0, 1, &no_vb, &no_offs, &no_offs); - d3d->IASetIndexBuffer(NULL, DXGI_FORMAT_UNKNOWN, 0); + d3d->IASetIndexBuffer(nullptr, DXGI_FORMAT_UNKNOWN, 0); } static void api_free_resource(GDrawHandle *r) @@ -251,11 +251,11 @@ static void RADLINK gdraw_UnlockHandles(GDrawStats * /*stats*/) static void *start_write_dyn(DynBuffer *buf, U32 size) { - U8 *ptr = NULL; + U8 *ptr = nullptr; if (size > buf->size) { - IggyGDrawSendWarning(NULL, "GDraw dynamic vertex buffer usage of %d bytes in one call larger than buffer size %d", size, buf->size); - return NULL; + IggyGDrawSendWarning(nullptr, "GDraw dynamic vertex buffer usage of %d bytes in one call larger than buffer size %d", size, buf->size); + return nullptr; } // update statistics @@ -373,19 +373,19 @@ extern GDrawTexture *gdraw_D3D1X_(WrappedTextureCreate)(ID3D1X(ShaderResourceVie { GDrawStats stats={0}; GDrawHandle *p = gdraw_res_alloc_begin(gdraw->texturecache, 0, &stats); // it may need to free one item to give us a handle - p->handle.tex.d3d = NULL; + p->handle.tex.d3d = nullptr; p->handle.tex.d3d_view = tex_view; - p->handle.tex.d3d_rtview = NULL; + p->handle.tex.d3d_rtview = nullptr; p->handle.tex.w = 1; p->handle.tex.h = 1; - gdraw_HandleCacheAllocateEnd(p, 0, NULL, GDRAW_HANDLE_STATE_user_owned); + gdraw_HandleCacheAllocateEnd(p, 0, nullptr, GDRAW_HANDLE_STATE_user_owned); return (GDrawTexture *) p; } extern void gdraw_D3D1X_(WrappedTextureChange)(GDrawTexture *tex, ID3D1X(ShaderResourceView) *tex_view) { GDrawHandle *p = (GDrawHandle *) tex; - p->handle.tex.d3d = NULL; + p->handle.tex.d3d = nullptr; p->handle.tex.d3d_view = tex_view; } @@ -407,12 +407,12 @@ static void RADLINK gdraw_SetTextureUniqueID(GDrawTexture *tex, void *old_id, vo static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, gdraw_texture_format format, U32 flags, GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *stats) { - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; DXGI_FORMAT dxgi_fmt; S32 bpp, size = 0, nmips = 0; if (width >= 16384 || height >= 16384) { - IggyGDrawSendWarning(NULL, "GDraw texture size too large (%d x %d), dimension limit is 16384", width, height); + IggyGDrawSendWarning(nullptr, "GDraw texture size too large (%d x %d), dimension limit is 16384", width, height); return false; } @@ -433,7 +433,7 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, // try to allocate memory for the client to write to p->texture_data = (U8 *) IggyGDrawMalloc(size); if (!p->texture_data) { - IggyGDrawSendWarning(NULL, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); + IggyGDrawSendWarning(nullptr, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); return false; } @@ -446,9 +446,9 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, t->handle.tex.w = width; t->handle.tex.h = height; - t->handle.tex.d3d = NULL; - t->handle.tex.d3d_view = NULL; - t->handle.tex.d3d_rtview = NULL; + t->handle.tex.d3d = nullptr; + t->handle.tex.d3d_view = nullptr; + t->handle.tex.d3d_rtview = nullptr; p->texture_type = GDRAW_TEXTURE_TYPE_rgba; p->p0 = t; @@ -512,7 +512,7 @@ static GDrawTexture * RADLINK gdraw_MakeTextureEnd(GDraw_MakeTexture_ProcessingI // and create a corresponding shader resource view failed_call = "CreateShaderResourceView"; - hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_view); + hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_view); done: if (!FAILED(hr)) { @@ -525,7 +525,7 @@ done: safe_release(t->handle.tex.d3d_view); gdraw_HandleCacheAllocateFail(t); - t = NULL; + t = nullptr; report_d3d_error(hr, failed_call, " while creating texture"); } @@ -554,8 +554,8 @@ static void RADLINK gdraw_UpdateTextureEnd(GDrawTexture *t, void * /*unique_id*/ static void RADLINK gdraw_FreeTexture(GDrawTexture *tt, void *unique_id, GDrawStats *stats) { GDrawHandle *t = (GDrawHandle *) tt; - assert(t != NULL); // @GDRAW_ASSERT - if (t->owner == unique_id || unique_id == NULL) { + assert(t != nullptr); // @GDRAW_ASSERT + if (t->owner == unique_id || unique_id == nullptr) { if (t->cache == &gdraw->rendertargets) { gdraw_HandleCacheUnlock(t); // cache it by simply not freeing it @@ -595,7 +595,7 @@ static void RADLINK gdraw_SetAntialiasTexture(S32 width, U8 *rgba) return; } - hr = gdraw->d3d_device->CreateShaderResourceView(gdraw->aa_tex, NULL, &gdraw->aa_tex_view); + hr = gdraw->d3d_device->CreateShaderResourceView(gdraw->aa_tex, nullptr, &gdraw->aa_tex_view); if (FAILED(hr)) { report_d3d_error(hr, "CreateShaderResourceView", " while creating texture"); safe_release(gdraw->aa_tex); @@ -616,8 +616,8 @@ static rrbool RADLINK gdraw_MakeVertexBufferBegin(void *unique_id, gdraw_vformat if (p->vertex_data && p->index_data) { GDrawHandle *vb = gdraw_res_alloc_begin(gdraw->vbufcache, vbuf_size + ibuf_size, stats); if (vb) { - vb->handle.vbuf.verts = NULL; - vb->handle.vbuf.inds = NULL; + vb->handle.vbuf.verts = nullptr; + vb->handle.vbuf.inds = nullptr; p->vertex_data_length = vbuf_size; p->index_data_length = ibuf_size; @@ -661,7 +661,7 @@ static GDrawVertexBuffer * RADLINK gdraw_MakeVertexBufferEnd(GDraw_MakeVertexBuf safe_release(vb->handle.vbuf.inds); gdraw_HandleCacheAllocateFail(vb); - vb = NULL; + vb = nullptr; report_d3d_error(hr, "CreateBuffer", " creating vertex buffer"); } else { @@ -682,7 +682,7 @@ static rrbool RADLINK gdraw_TryLockVertexBuffer(GDrawVertexBuffer *vb, void *uni static void RADLINK gdraw_FreeVertexBuffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats) { GDrawHandle *h = (GDrawHandle *) vb; - assert(h != NULL); // @GDRAW_ASSERT + assert(h != nullptr); // @GDRAW_ASSERT if (h->owner == unique_id) gdraw_res_free(h, stats); } @@ -712,31 +712,31 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats) // ran out of RTs, allocate a new one S32 size = gdraw->frametex_width * gdraw->frametex_height * 4; if (gdraw->rendertargets.bytes_free < size) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: hit size limit of %d bytes", gdraw->rendertargets.total_bytes); - return NULL; + IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: hit size limit of %d bytes", gdraw->rendertargets.total_bytes); + return nullptr; } t = gdraw_HandleCacheAllocateBegin(&gdraw->rendertargets); if (!t) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: hit handle limit"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: hit handle limit"); return t; } D3D1X_(TEXTURE2D_DESC) desc = { gdraw->frametex_width, gdraw->frametex_height, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 }, D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_SHADER_RESOURCE) | D3D1X_(BIND_RENDER_TARGET), 0, 0 }; - t->handle.tex.d3d = NULL; - t->handle.tex.d3d_view = NULL; - t->handle.tex.d3d_rtview = NULL; + t->handle.tex.d3d = nullptr; + t->handle.tex.d3d_view = nullptr; + t->handle.tex.d3d_rtview = nullptr; - HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, NULL, &t->handle.tex.d3d); + HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, nullptr, &t->handle.tex.d3d); failed_call = "CreateTexture2D"; if (!FAILED(hr)) { - hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_view); + hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_view); failed_call = "CreateTexture2D"; } if (!FAILED(hr)) { - hr = gdraw->d3d_device->CreateRenderTargetView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_rtview); + hr = gdraw->d3d_device->CreateRenderTargetView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_rtview); failed_call = "CreateRenderTargetView"; } @@ -748,7 +748,7 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats) report_d3d_error(hr, failed_call, " creating rendertarget"); - return NULL; + return nullptr; } gdraw_HandleCacheAllocateEnd(t, size, (void *) 1, GDRAW_HANDLE_STATE_locked); @@ -768,10 +768,10 @@ static ID3D1X(DepthStencilView) *get_rendertarget_depthbuffer(GDrawStats *stats) D3D1X_(TEXTURE2D_DESC) desc = { gdraw->frametex_width, gdraw->frametex_height, 1, 1, DXGI_FORMAT_D24_UNORM_S8_UINT, { 1, 0 }, D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_DEPTH_STENCIL), 0, 0 }; - HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, NULL, &gdraw->rt_depth_buffer); + HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, nullptr, &gdraw->rt_depth_buffer); failed_call = "CreateTexture2D"; if (!FAILED(hr)) { - hr = gdraw->d3d_device->CreateDepthStencilView(gdraw->rt_depth_buffer, NULL, &gdraw->depth_buffer[1]); + hr = gdraw->d3d_device->CreateDepthStencilView(gdraw->rt_depth_buffer, nullptr, &gdraw->depth_buffer[1]); failed_call = "CreateDepthStencilView while creating rendertarget"; } @@ -1110,7 +1110,7 @@ static void set_render_target(GDrawStats *stats) gdraw->d3d_context->OMSetRenderTargets(1, &target, gdraw->depth_buffer[0]); gdraw->d3d_context->RSSetState(gdraw->raster_state[gdraw->main_msaa]); } else { - ID3D1X(DepthStencilView) *depth = NULL; + ID3D1X(DepthStencilView) *depth = nullptr; if (gdraw->cur->flags & (GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_id | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_stencil)) depth = get_rendertarget_depthbuffer(stats); @@ -1125,15 +1125,15 @@ static void set_render_target(GDrawStats *stats) static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_texture_format /*format*/, U32 flags, void *owner, GDrawStats *stats) { GDrawFramebufferState *n = gdraw->cur+1; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; if (gdraw->tw == 0 || gdraw->th == 0) { - IggyGDrawSendWarning(NULL, "GDraw warning: w=0,h=0 rendertarget"); + IggyGDrawSendWarning(nullptr, "GDraw warning: w=0,h=0 rendertarget"); return false; } if (n >= &gdraw->frame[MAX_RENDER_STACK_DEPTH]) { assert(0); - IggyGDrawSendWarning(NULL, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH"); return false; } @@ -1147,10 +1147,10 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex n->flags = flags; n->color_buffer = t; - assert(n->color_buffer != NULL); // @GDRAW_ASSERT + assert(n->color_buffer != nullptr); // @GDRAW_ASSERT ++gdraw->cur; - gdraw->cur->cached = owner != NULL; + gdraw->cur->cached = owner != nullptr; if (owner) { gdraw->cur->base_x = region->x0; gdraw->cur->base_y = region->y0; @@ -1229,9 +1229,9 @@ static GDrawTexture *RADLINK gdraw_TextureDrawBufferEnd(GDrawStats *stats) assert(m >= gdraw->frame); // bug in Iggy -- unbalanced if (m != gdraw->frame) { - assert(m->color_buffer != NULL); // @GDRAW_ASSERT + assert(m->color_buffer != nullptr); // @GDRAW_ASSERT } - assert(n->color_buffer != NULL); // @GDRAW_ASSERT + assert(n->color_buffer != nullptr); // @GDRAW_ASSERT // switch back to old render target set_render_target(stats); @@ -1288,8 +1288,8 @@ static void set_texture(S32 texunit, GDrawTexture *tex, rrbool nearest, S32 wrap { ID3D1XContext *d3d = gdraw->d3d_context; - if (tex == NULL) { - ID3D1X(ShaderResourceView) *notex = NULL; + if (tex == nullptr) { + ID3D1X(ShaderResourceView) *notex = nullptr; d3d->PSSetShaderResources(texunit, 1, ¬ex); } else { GDrawHandle *h = (GDrawHandle *) tex; @@ -1300,7 +1300,7 @@ static void set_texture(S32 texunit, GDrawTexture *tex, rrbool nearest, S32 wrap static void RADLINK gdraw_Set3DTransform(F32 *mat) { - if (mat == NULL) + if (mat == nullptr) gdraw->use_3d = 0; else { gdraw->use_3d = 1; @@ -1363,9 +1363,9 @@ static int set_renderstate_full(S32 vertex_format, GDrawRenderState *r, GDrawSta // in stencil set mode, prefer not doing any shading at all // but if alpha test is on, we need to make an exception -#ifndef GDRAW_D3D11_LEVEL9 // level9 can't do NULL PS it seems +#ifndef GDRAW_D3D11_LEVEL9 // level9 can't do nullptr PS it seems if (which != GDRAW_TEXTURE_alpha_test) - program = NULL; + program = nullptr; else #endif { @@ -1475,7 +1475,7 @@ static int vertsize[GDRAW_vformat__basic_count] = { // Draw triangles with a given renderstate // -static void tag_resources(void *r1, void *r2=NULL, void *r3=NULL, void *r4=NULL) +static void tag_resources(void *r1, void *r2=nullptr, void *r3=nullptr, void *r4=nullptr) { U64 now = gdraw->frame_counter; if (r1) ((GDrawHandle *) r1)->fence.value = now; @@ -1687,7 +1687,7 @@ static void set_clamp_constant(F32 *constant, GDrawTexture *tex) static void gdraw_Filter(GDrawRenderState *r, gswf_recti *s, float *tc, int isbevel, GDrawStats *stats) { - if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, NULL, stats)) + if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, nullptr, stats)) return; set_texture(0, r->tex[0], false, GDRAW_WRAP_clamp); @@ -1775,7 +1775,7 @@ static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1 assert(0); } } else { - GDrawHandle *blend_tex = NULL; + GDrawHandle *blend_tex = nullptr; // for crazy blend modes, we need to read back from the framebuffer // and do the blending in the pixel shader. we do this with copies @@ -1859,18 +1859,18 @@ static void destroy_shader(ProgramWithCachedVariableLocations *p) { if (p->pshader) { p->pshader->Release(); - p->pshader = NULL; + p->pshader = nullptr; } } static ID3D1X(Buffer) *create_dynamic_buffer(U32 size, U32 bind) { D3D1X_(BUFFER_DESC) desc = { size, D3D1X_(USAGE_DYNAMIC), bind, D3D1X_(CPU_ACCESS_WRITE), 0 }; - ID3D1X(Buffer) *buf = NULL; - HRESULT hr = gdraw->d3d_device->CreateBuffer(&desc, NULL, &buf); + ID3D1X(Buffer) *buf = nullptr; + HRESULT hr = gdraw->d3d_device->CreateBuffer(&desc, nullptr, &buf); if (FAILED(hr)) { report_d3d_error(hr, "CreateBuffer", " creating dynamic vertex buffer"); - buf = NULL; + buf = nullptr; } return buf; } @@ -1907,7 +1907,7 @@ static void create_all_shaders_and_state(void) HRESULT hr = d3d->CreateInputLayout(vformats[i].desc, vformats[i].nelem, vsh->bytecode, vsh->size, &gdraw->inlayout[i]); if (FAILED(hr)) { report_d3d_error(hr, "CreateInputLayout", ""); - gdraw->inlayout[i] = NULL; + gdraw->inlayout[i] = nullptr; } } @@ -2026,11 +2026,11 @@ static void create_all_shaders_and_state(void) hr = gdraw->d3d_device->CreateBuffer(&bufdesc, &data, &gdraw->quad_ib); if (FAILED(hr)) { report_d3d_error(hr, "CreateBuffer", " for constants"); - gdraw->quad_ib = NULL; + gdraw->quad_ib = nullptr; } IggyGDrawFree(inds); } else - gdraw->quad_ib = NULL; + gdraw->quad_ib = nullptr; } static void destroy_all_shaders_and_state() @@ -2103,7 +2103,7 @@ static void free_gdraw() if (gdraw->texturecache) IggyGDrawFree(gdraw->texturecache); if (gdraw->vbufcache) IggyGDrawFree(gdraw->vbufcache); IggyGDrawFree(gdraw); - gdraw = NULL; + gdraw = nullptr; } static bool alloc_dynbuffer(U32 size) @@ -2139,7 +2139,7 @@ static bool alloc_dynbuffer(U32 size) gdraw->max_quad_vert_count = RR_MIN(size / sizeof(gswf_vertex_xyst), QUAD_IB_COUNT * 4); gdraw->max_quad_vert_count &= ~3; // must be multiple of four - return gdraw->dyn_vb.buffer != NULL && gdraw->dyn_ib.buffer != NULL; + return gdraw->dyn_vb.buffer != nullptr && gdraw->dyn_ib.buffer != nullptr; } int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S32 num_bytes) @@ -2178,7 +2178,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3 IggyGDrawFree(gdraw->texturecache); } gdraw->texturecache = make_handle_cache(GDRAW_D3D1X_(RESOURCE_texture)); - return gdraw->texturecache != NULL; + return gdraw->texturecache != nullptr; case GDRAW_D3D1X_(RESOURCE_vertexbuffer): if (gdraw->vbufcache) { @@ -2186,7 +2186,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3 IggyGDrawFree(gdraw->vbufcache); } gdraw->vbufcache = make_handle_cache(GDRAW_D3D1X_(RESOURCE_vertexbuffer)); - return gdraw->vbufcache != NULL; + return gdraw->vbufcache != nullptr; case GDRAW_D3D1X_(RESOURCE_dynbuffer): unbind_resources(); @@ -2202,7 +2202,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3 static GDrawFunctions *create_context(ID3D1XDevice *dev, ID3D1XContext *ctx, S32 w, S32 h) { gdraw = (GDraw *) IggyGDrawMalloc(sizeof(*gdraw)); - if (!gdraw) return NULL; + if (!gdraw) return nullptr; memset(gdraw, 0, sizeof(*gdraw)); @@ -2217,7 +2217,7 @@ static GDrawFunctions *create_context(ID3D1XDevice *dev, ID3D1XContext *ctx, S32 if (!gdraw->texturecache || !gdraw->vbufcache || !alloc_dynbuffer(gdraw_limits[GDRAW_D3D1X_(RESOURCE_dynbuffer)].num_bytes)) { free_gdraw(); - return NULL; + return nullptr; } create_all_shaders_and_state(); @@ -2288,7 +2288,7 @@ void gdraw_D3D1X_(DestroyContext)(void) if (gdraw->texturecache) gdraw_res_flush(gdraw->texturecache, &stats); if (gdraw->vbufcache) gdraw_res_flush(gdraw->vbufcache, &stats); - gdraw->d3d_device = NULL; + gdraw->d3d_device = nullptr; } free_gdraw(); @@ -2351,7 +2351,7 @@ void RADLINK gdraw_D3D1X_(GetResourceUsageStats)(gdraw_resourcetype type, S32 *h case GDRAW_D3D1X_(RESOURCE_texture): cache = gdraw->texturecache; break; case GDRAW_D3D1X_(RESOURCE_vertexbuffer): cache = gdraw->vbufcache; break; case GDRAW_D3D1X_(RESOURCE_dynbuffer): *handles_used = 0; *bytes_used = gdraw->last_dyn_maxalloc; return; - default: cache = NULL; break; + default: cache = nullptr; break; } *handles_used = *bytes_used = 0; @@ -2408,7 +2408,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file, case IFT_FORMAT_DXT3 : size=16; d3dfmt = DXGI_FORMAT_BC2_UNORM; blk = 4; break; case IFT_FORMAT_DXT5 : size=16; d3dfmt = DXGI_FORMAT_BC3_UNORM; blk = 4; break; default: { - IggyGDrawSendWarning(NULL, "GDraw .iggytex raw texture format %d not supported by hardware", texture->format); + IggyGDrawSendWarning(nullptr, "GDraw .iggytex raw texture format %d not supported by hardware", texture->format); goto done; } } @@ -2424,7 +2424,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file, free_data = (U8 *) IggyGDrawMalloc(total_size); if (!free_data) { - IggyGDrawSendWarning(NULL, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); + IggyGDrawSendWarning(nullptr, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); goto done; } @@ -2457,7 +2457,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file, if (FAILED(hr)) goto done; failed_call = "CreateShaderResourceView for texture creation"; - hr = gdraw->d3d_device->CreateShaderResourceView(tex, NULL, &view); + hr = gdraw->d3d_device->CreateShaderResourceView(tex, nullptr, &view); if (FAILED(hr)) goto done; t = gdraw_D3D1X_(WrappedTextureCreate)(view); diff --git a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl index a60fa520..1790de77 100644 --- a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl +++ b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl @@ -226,7 +226,7 @@ static void debug_check_raw_values(GDrawHandleCache *c) s = s->next; } s = c->active; - while (s != NULL) { + while (s != nullptr) { assert(s->raw_ptr != t->raw_ptr); s = s->next; } @@ -368,7 +368,7 @@ static void gdraw_HandleTransitionInsertBefore(GDrawHandle *t, GDrawHandleState { check_lists(t->cache); assert(t->state != GDRAW_HANDLE_STATE_sentinel); // sentinels should never get here! - assert(t->state != (U32) new_state); // code should never call "transition" if it's not transitioning! + assert(t->state != static_cast<U32>(new_state)); // code should never call "transition" if it's not transitioning! // unlink from prev state t->prev->next = t->next; t->next->prev = t->prev; @@ -433,7 +433,7 @@ static rrbool gdraw_HandleCacheLockStats(GDrawHandle *t, void *owner, GDrawStats static rrbool gdraw_HandleCacheLock(GDrawHandle *t, void *owner) { - return gdraw_HandleCacheLockStats(t, owner, NULL); + return gdraw_HandleCacheLockStats(t, owner, nullptr); } static void gdraw_HandleCacheUnlock(GDrawHandle *t) @@ -461,11 +461,11 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->is_thrashing = false; c->did_defragment = false; for (i=0; i < GDRAW_HANDLE_STATE__count; i++) { - c->state[i].owner = NULL; - c->state[i].cache = NULL; // should never follow cache link from sentinels! + c->state[i].owner = nullptr; + c->state[i].cache = nullptr; // should never follow cache link from sentinels! c->state[i].next = c->state[i].prev = &c->state[i]; #ifdef GDRAW_MANAGE_MEM - c->state[i].raw_ptr = NULL; + c->state[i].raw_ptr = nullptr; #endif c->state[i].fence.value = 0; c->state[i].bytes = 0; @@ -478,7 +478,7 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->handle[i].bytes = 0; c->handle[i].state = GDRAW_HANDLE_STATE_free; #ifdef GDRAW_MANAGE_MEM - c->handle[i].raw_ptr = NULL; + c->handle[i].raw_ptr = nullptr; #endif } c->state[GDRAW_HANDLE_STATE_free].next = &c->handle[0]; @@ -486,10 +486,10 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->prev_frame_start.value = 0; c->prev_frame_end.value = 0; #ifdef GDRAW_MANAGE_MEM - c->alloc = NULL; + c->alloc = nullptr; #endif #ifdef GDRAW_MANAGE_MEM_TWOPOOL - c->alloc_other = NULL; + c->alloc_other = nullptr; #endif check_lists(c); } @@ -497,14 +497,14 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte static GDrawHandle *gdraw_HandleCacheAllocateBegin(GDrawHandleCache *c) { GDrawHandle *free_list = &c->state[GDRAW_HANDLE_STATE_free]; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; if (free_list->next != free_list) { t = free_list->next; gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_alloc); t->bytes = 0; t->owner = 0; #ifdef GDRAW_MANAGE_MEM - t->raw_ptr = NULL; + t->raw_ptr = nullptr; #endif #ifdef GDRAW_CORRUPTION_CHECK t->has_check_value = false; @@ -558,7 +558,7 @@ static GDrawHandle *gdraw_HandleCacheGetLRU(GDrawHandleCache *c) // at the front of the LRU list are the oldest ones, since in-use resources // will get appended on every transition from "locked" to "live". GDrawHandle *sentinel = &c->state[GDRAW_HANDLE_STATE_live]; - return (sentinel->next != sentinel) ? sentinel->next : NULL; + return (sentinel->next != sentinel) ? sentinel->next : nullptr; } static void gdraw_HandleCacheTick(GDrawHandleCache *c, GDrawFence now) @@ -773,7 +773,7 @@ static GDrawTexture *gdraw_BlurPass(GDrawFunctions *g, GDrawBlurInfo *c, GDrawRe if (!g->TextureDrawBufferBegin(draw_bounds, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, 0, gstats)) return r->tex[0]; - c->BlurPass(r, taps, data, draw_bounds, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, draw_bounds, tc, static_cast<F32>(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -825,7 +825,7 @@ static GDrawTexture *gdraw_BlurPassDownsample(GDrawFunctions *g, GDrawBlurInfo * assert(clamp[0] <= clamp[2]); assert(clamp[1] <= clamp[3]); - c->BlurPass(r, taps, data, &z, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, &z, tc, static_cast<F32>(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -837,7 +837,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR GDrawTexture *t; F32 data[MAX_TAPS][4]; S32 off_axis = 1-axis; - S32 w = ((S32) ceil((blur_width-1)/2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 + S32 w = static_cast<S32>(ceil((blur_width - 1) / 2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 F32 edge_weight = 1 - (w - blur_width)/2; // 3 => 0 => 1; 1.2 => 1.8 => 0.9 => 0.1 F32 inverse_weight = 1.0f / blur_width; @@ -944,7 +944,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR // max coverage is 25 samples, or a filter width of 13. with 7 taps, we sample // 13 samples in one pass, max coverage is 13*13 samples or (13*13-1)/2 width, // which is ((2T-1)*(2T-1)-1)/2 or (4T^2 - 4T + 1 -1)/2 or 2T^2 - 2T or 2T*(T-1) - S32 w_mip = (S32) ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS)); + S32 w_mip = static_cast<S32>(ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS))); S32 downsample = w_mip; F32 sample_spacing = texel; if (downsample < 2) downsample = 2; @@ -1090,7 +1090,7 @@ static void make_pool_aligned(void **start, S32 *num_bytes, U32 alignment) if (addr_aligned != addr_orig) { S32 diff = (S32) (addr_aligned - addr_orig); if (*num_bytes < diff) { - *start = NULL; + *start = nullptr; *num_bytes = 0; return; } else { @@ -1127,7 +1127,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) UINTa remaining = arena->end - arena->current; UINTa total_size = (ptr - arena->current) + size; if (remaining < total_size) // doesn't fit - return NULL; + return nullptr; arena->current = ptr + size; return ptr; @@ -1152,7 +1152,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // (i.e. block->next->prev == block->prev->next == block) // - All allocated blocks are also kept in a hash table, indexed by their // pointer (to allow free to locate the corresponding block_info quickly). -// There's a single-linked, NULL-terminated list of elements in each hash +// There's a single-linked, nullptr-terminated list of elements in each hash // bucket. // - The physical block list is ordered. It always contains all currently // active blocks and spans the whole managed memory range. There are no @@ -1161,7 +1161,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // they are coalesced immediately. // - The maximum number of blocks that could ever be necessary is allocated // on initialization. All block_infos not currently in use are kept in a -// single-linked, NULL-terminated list of unused blocks. Every block is either +// single-linked, nullptr-terminated list of unused blocks. Every block is either // in the physical block list or the unused list, and the total number of // blocks is constant. // These invariants always hold before and after an allocation/free. @@ -1379,7 +1379,7 @@ static void gfxalloc_check2(gfx_allocator *alloc) static gfx_block_info *gfxalloc_pop_unused(gfx_allocator *alloc) { - GFXALLOC_ASSERT(alloc->unused_list != NULL); + GFXALLOC_ASSERT(alloc->unused_list != nullptr); GFXALLOC_ASSERT(alloc->unused_list->is_unused); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_unused);) @@ -1452,7 +1452,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma U32 i, max_blocks, size; if (!align || (align & (align - 1)) != 0) // align must be >0 and a power of 2 - return NULL; + return nullptr; // for <= max_allocs live allocs, there's <= 2*max_allocs+1 blocks. worst case: // [free][used][free] .... [free][used][free] @@ -1460,7 +1460,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma size = sizeof(gfx_allocator) + max_blocks * sizeof(gfx_block_info); a = (gfx_allocator *) IggyGDrawMalloc(size); if (!a) - return NULL; + return nullptr; memset(a, 0, size); @@ -1501,16 +1501,16 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma a->blocks[i].is_unused = 1; gfxalloc_check(a); - debug_complete_check(a, NULL, 0,0); + debug_complete_check(a, nullptr, 0,0); return a; } static void *gfxalloc_alloc(gfx_allocator *alloc, U32 size_in_bytes) { - gfx_block_info *cur, *best = NULL; + gfx_block_info *cur, *best = nullptr; U32 i, best_wasted = ~0u; U32 size = size_in_bytes; -debug_complete_check(alloc, NULL, 0,0); +debug_complete_check(alloc, nullptr, 0,0); gfxalloc_check(alloc); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) @@ -1560,7 +1560,7 @@ gfxalloc_check(alloc); debug_check_overlap(alloc->cache, best->ptr, best->size); return best->ptr; } else - return NULL; // not enough space! + return nullptr; // not enough space! } static void gfxalloc_free(gfx_allocator *alloc, void *ptr) @@ -1730,7 +1730,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta // (unused for allocated blocks, we'll use it to store a back-pointer to the corresponding handle) for (b = alloc->blocks[0].next_phys; b != alloc->blocks; b=b->next_phys) if (!b->is_free) - b->prev = NULL; + b->prev = nullptr; // go through all handles and store a pointer to the handle in the corresponding memory block for (i=0; i < c->max_handles; i++) @@ -1743,7 +1743,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta break; } - GFXALLOC_ASSERT(b != NULL); // didn't find this block anywhere! + GFXALLOC_ASSERT(b != nullptr); // didn't find this block anywhere! } // clear alloc hash table (we rebuild it during defrag) @@ -1905,7 +1905,7 @@ static rrbool gdraw_CanDefragment(GDrawHandleCache *c) static rrbool gdraw_MigrateResource(GDrawHandle *t, GDrawStats *stats) { GDrawHandleCache *c = t->cache; - void *ptr = NULL; + void *ptr = nullptr; assert(t->state == GDRAW_HANDLE_STATE_live || t->state == GDRAW_HANDLE_STATE_locked || t->state == GDRAW_HANDLE_STATE_pinned); // anything we migrate should be in the "other" (old) pool @@ -2295,7 +2295,7 @@ static void gdraw_bufring_init(gdraw_bufring * RADRESTRICT ring, void *ptr, U32 static void gdraw_bufring_shutdown(gdraw_bufring * RADRESTRICT ring) { - ring->cur = NULL; + ring->cur = nullptr; ring->seg_size = 0; } @@ -2305,7 +2305,7 @@ static void *gdraw_bufring_alloc(gdraw_bufring * RADRESTRICT ring, U32 size, U32 gdraw_bufring_seg *seg; if (size > ring->seg_size) - return NULL; // nope, won't fit + return nullptr; // nope, won't fit assert(align <= ring->align); @@ -2410,7 +2410,7 @@ static rrbool gdraw_res_free_lru(GDrawHandleCache *c, GDrawStats *stats) // was it referenced since end of previous frame (=in this frame)? // if some, we're thrashing; report it to the user, but only once per frame. if (c->prev_frame_end.value < r->fence.value && !c->is_thrashing) { - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); c->is_thrashing = true; } @@ -2430,8 +2430,8 @@ static GDrawHandle *gdraw_res_alloc_outofmem(GDrawHandleCache *c, GDrawHandle *t { if (t) gdraw_HandleCacheAllocateFail(t); - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); - return NULL; + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); + return nullptr; } #ifndef GDRAW_MANAGE_MEM @@ -2440,7 +2440,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt { GDrawHandle *t; if (size > c->total_bytes) - gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); else { // given how much data we're going to allocate, throw out // data until there's "room" (this basically lets us use @@ -2448,7 +2448,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // packing it and being exact) while (c->bytes_free < size) { if (!gdraw_res_free_lru(c, stats)) { - gdraw_res_alloc_outofmem(c, NULL, "memory"); + gdraw_res_alloc_outofmem(c, nullptr, "memory"); break; } } @@ -2463,8 +2463,8 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // we'd trade off cost of regenerating) if (gdraw_res_free_lru(c, stats)) { t = gdraw_HandleCacheAllocateBegin(c); - if (t == NULL) { - gdraw_res_alloc_outofmem(c, NULL, "handles"); + if (t == nullptr) { + gdraw_res_alloc_outofmem(c, nullptr, "handles"); } } } @@ -2508,7 +2508,7 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) { GDRAW_FENCE_FLUSH(); // dead list is sorted by fence index - make sure all fence values are current. - r->owner = NULL; + r->owner = nullptr; gdraw_HandleCacheInsertDead(r); gdraw_res_reap(r->cache, stats); } @@ -2516,11 +2516,11 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawStats *stats) { GDrawHandle *t; - void *ptr = NULL; + void *ptr = nullptr; gdraw_res_reap(c, stats); // NB this also does GDRAW_FENCE_FLUSH(); if (size > c->total_bytes) - return gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + return gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); // now try to allocate a handle t = gdraw_HandleCacheAllocateBegin(c); @@ -2532,7 +2532,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt gdraw_res_free_lru(c, stats); t = gdraw_HandleCacheAllocateBegin(c); if (!t) - return gdraw_res_alloc_outofmem(c, NULL, "handles"); + return gdraw_res_alloc_outofmem(c, nullptr, "handles"); } // try to allocate first diff --git a/Minecraft.Client/Durango/Iggy/include/gdraw.h b/Minecraft.Client/Durango/Iggy/include/gdraw.h index 404a2642..7cc4ddd0 100644 --- a/Minecraft.Client/Durango/Iggy/include/gdraw.h +++ b/Minecraft.Client/Durango/Iggy/include/gdraw.h @@ -356,13 +356,13 @@ IDOC typedef struct GDrawPrimitive IDOC typedef void RADLINK gdraw_draw_indexed_triangles(GDrawRenderState *r, GDrawPrimitive *prim, GDrawVertexBuffer *buf, GDrawStats *stats); /* Draws a collection of indexed triangles, ignoring special filters or blend modes. - If buf is NULL, then the pointers in 'prim' are machine pointers, and + If buf is nullptr, then the pointers in 'prim' are machine pointers, and you need to make a copy of the data (note currently all triangles implementing strokes (wide lines) go this path). - If buf is non-NULL, then use the appropriate vertex buffer, and the + If buf is non-nullptr, then use the appropriate vertex buffer, and the pointers in prim are actually offsets from the beginning of the - vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) NULL; + vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) nullptr; (note there are separate spaces for vertices and indices; e.g. the first mesh in a given vertex buffer will normally have a 0 offset for the vertices and a 0 offset for the indices) @@ -455,7 +455,7 @@ IDOC typedef GDrawTexture * RADLINK gdraw_make_texture_end(GDraw_MakeTexture_Pro /* Ends specification of a new texture. $:info The same handle initially passed to $gdraw_make_texture_begin - $:return Handle for the newly created texture, or NULL if an error occured + $:return Handle for the newly created texture, or nullptr if an error occured */ IDOC typedef rrbool RADLINK gdraw_update_texture_begin(GDrawTexture *tex, void *unique_id, GDrawStats *stats); diff --git a/Minecraft.Client/Durango/Iggy/include/iggyexpruntime.h b/Minecraft.Client/Durango/Iggy/include/iggyexpruntime.h index 1f1a90a1..a42ccbff 100644 --- a/Minecraft.Client/Durango/Iggy/include/iggyexpruntime.h +++ b/Minecraft.Client/Durango/Iggy/include/iggyexpruntime.h @@ -25,8 +25,8 @@ IDOC RADEXPFUNC HIGGYEXP RADEXPLINK IggyExpCreate(char *ip_address, S32 port, vo $:storage A small block of storage that needed to store the $HIGGYEXP, must be at least $IGGYEXP_MIN_STORAGE $:storage_size_in_bytes The size of the block pointer to by <tt>storage</tt> -Returns a NULL HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer -can be contacted at the specified address/port. Otherwise returns a non-NULL $HIGGYEXP +Returns a nullptr HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer +can be contacted at the specified address/port. Otherwise returns a non-nullptr $HIGGYEXP which you can pass to $IggyUseExplorer. */ IDOC RADEXPFUNC void RADEXPLINK IggyExpDestroy(HIGGYEXP p); diff --git a/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp b/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp index 46b04606..cc19b738 100644 --- a/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp +++ b/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp @@ -14,7 +14,7 @@ DurangoLeaderboardManager::DurangoLeaderboardManager() m_openSessions = 0; m_xboxLiveContext = nullptr; - m_scores = NULL; + m_scores = nullptr; m_readCount = 0; m_maxRank = 0; m_waitingForProfiles = false; @@ -160,7 +160,7 @@ void DurangoLeaderboardManager::Tick() m_displayNames.clear(); } - //assert(m_scores != NULL || m_readCount == 0); + //assert(m_scores != nullptr || m_readCount == 0); view.m_numQueries = m_readCount; view.m_queries = m_scores; @@ -170,7 +170,7 @@ void DurangoLeaderboardManager::Tick() eStatsReturn ret = view.m_numQueries > 0 ? eStatsReturn_Success : eStatsReturn_NoResults; - if (m_readListener != NULL) + if (m_readListener != nullptr) { app.DebugPrintf("[LeaderboardManager] OnStatsReadComplete(%i, %i, _)\n", ret, m_readCount); m_readListener->OnStatsReadComplete(ret, m_maxRank, view); @@ -178,7 +178,7 @@ void DurangoLeaderboardManager::Tick() app.DebugPrintf("[LeaderboardManager] Deleting scores\n"); delete [] m_scores; - m_scores = NULL; + m_scores = nullptr; setState(eStatsState_Idle); } @@ -186,9 +186,9 @@ void DurangoLeaderboardManager::Tick() case eStatsState_Failed: view.m_numQueries = 0; - view.m_queries = NULL; + view.m_queries = nullptr; - if ( m_readListener != NULL ) + if ( m_readListener != nullptr ) { m_readListener->OnStatsReadComplete(eStatsReturn_NetworkError, 0, view); } @@ -371,7 +371,7 @@ void DurangoLeaderboardManager::FlushStats() //Cancel the current operation void DurangoLeaderboardManager::CancelOperation() { - m_readListener = NULL; + m_readListener = nullptr; setState(eStatsState_Canceled); if(m_leaderboardAsyncOp) m_leaderboardAsyncOp->Cancel(); @@ -428,7 +428,7 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperation<MXSL:: app.DebugPrintf( "Name: %ls - Filter: %ls - Rows: Retrieved=%d Total=%d Requested=%d.\n", lastResult->DisplayName->Data(), - LeaderboardManager::filterNames[ (int) filter ].c_str(), + LeaderboardManager::filterNames[ static_cast<int>(filter) ].c_str(), lastResult->Rows->Size, lastResult->TotalRowCount, readCount ); @@ -458,7 +458,7 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperation<MXSL:: m_maxRank = lastResult->TotalRowCount; m_readCount = lastResult->Rows->Size; - if (m_scores != NULL) delete [] m_scores; + if (m_scores != nullptr) delete [] m_scores; m_scores = new ReadScore[m_readCount]; ZeroMemory(m_scores, sizeof(ReadScore) * m_readCount); @@ -480,10 +480,10 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperation<MXSL:: m_scores[index].m_name = row->Gamertag->Data(); m_scores[index].m_rank = row->Rank; - m_scores[index].m_uid = PlayerUID(row->XboxUserId->Data()); + m_scores[index].m_uid = static_cast<PlayerUID>(row->XboxUserId->Data()); // 4J-JEV: Added to help determine if this player's score is hidden due to their privacy settings. - m_scores[index].m_totalScore = (unsigned long) _fromString<long long>(row->Values->GetAt(0)->Data()); + m_scores[index].m_totalScore = static_cast<unsigned long>(_fromString<long long>(row->Values->GetAt(0)->Data())); m_xboxUserIds->Append(row->XboxUserId); } @@ -493,7 +493,7 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperation<MXSL:: vector<PlayerUID> xuids = vector<PlayerUID>(); for(int i = 0; i < lastResult->Rows->Size; i++) { - xuids.push_back(PlayerUID(lastResult->Rows->GetAt(i)->XboxUserId->Data())); + xuids.push_back(static_cast<PlayerUID>(lastResult->Rows->GetAt(i)->XboxUserId->Data())); } m_waitingForProfiles = true; ProfileManager.GetProfiles(xuids, &GetProfilesCallback, this); @@ -579,7 +579,7 @@ void DurangoLeaderboardManager::updateStatsInfo(int userIndex, int difficulty, E void DurangoLeaderboardManager::GetProfilesCallback(LPVOID param, std::vector<Microsoft::Xbox::Services::Social::XboxUserProfile^> profiles) { - DurangoLeaderboardManager *dlm = (DurangoLeaderboardManager *)param; + DurangoLeaderboardManager *dlm = static_cast<DurangoLeaderboardManager *>(param); app.DebugPrintf("[LeaderboardManager] GetProfilesCallback, profiles.size() == %d.\n", profiles.size()); diff --git a/Minecraft.Client/Durango/Leaderboards/DurangoStatsDebugger.cpp b/Minecraft.Client/Durango/Leaderboards/DurangoStatsDebugger.cpp index caa5857e..5ac71141 100644 --- a/Minecraft.Client/Durango/Leaderboards/DurangoStatsDebugger.cpp +++ b/Minecraft.Client/Durango/Leaderboards/DurangoStatsDebugger.cpp @@ -84,7 +84,7 @@ vector<wstring> *StatParam::getStats() return out; } -DurangoStatsDebugger *DurangoStatsDebugger::instance = NULL; +DurangoStatsDebugger *DurangoStatsDebugger::instance = nullptr; DurangoStatsDebugger::DurangoStatsDebugger() { @@ -320,7 +320,7 @@ DurangoStatsDebugger *DurangoStatsDebugger::Initialize() void DurangoStatsDebugger::PrintStats(int iPad) { - if (instance == NULL) instance = Initialize(); + if (instance == nullptr) instance = Initialize(); vector<wstring> *tmp = instance->getStats(); instance->m_printQueue.insert(instance->m_printQueue.end(), tmp->begin(), tmp->end()); diff --git a/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp b/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp index dd07f3e9..f97f9bb3 100644 --- a/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp +++ b/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp @@ -10,11 +10,11 @@ namespace WFC = Windows::Foundation::Collections; namespace MXSA = Microsoft::Xbox::Services::Achievements; namespace CC = concurrency; -GameProgress *GameProgress::instance = NULL; +GameProgress *GameProgress::instance = nullptr; void GameProgress::Flush(int iPad) { - if (instance == NULL) + if (instance == nullptr) instance = new GameProgress(); instance->updatePlayer(iPad); @@ -22,7 +22,7 @@ void GameProgress::Flush(int iPad) void GameProgress::Tick() { - if (instance == NULL) + if (instance == nullptr) instance = new GameProgress(); long long currentTime = System::currentTimeMillis(); @@ -103,5 +103,5 @@ void GameProgress::updatePlayer(int iPad) float GameProgress::calcGameProgress(int achievementsUnlocked) { - return (float) achievementsUnlocked / 0.60f; + return static_cast<float>(achievementsUnlocked) / 0.60f; }
\ No newline at end of file diff --git a/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h b/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h index 80b4e10a..f81a0f1f 100644 --- a/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h +++ b/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h @@ -238,7 +238,7 @@ private: __in ChatPacketType chatPacketType ); Concurrency::critical_section m_chatPacketStatsLock; - int m_chatVoicePacketsStatistic[2][(int)Microsoft::Xbox::GameChat::ChatMessageType::InvalidMessage+1]; + int m_chatVoicePacketsStatistic[2][static_cast<int>(Microsoft::Xbox::GameChat::ChatMessageType::InvalidMessage)+1]; }; std::shared_ptr<ChatIntegrationLayer> GetChatIntegrationLayer();
\ No newline at end of file diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp index 39dc53a9..9e9e78c0 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp @@ -25,7 +25,7 @@ int DQRNetworkManager::m_bootUserIndex; wstring DQRNetworkManager::m_bootSessionName; wstring DQRNetworkManager::m_bootServiceConfig; wstring DQRNetworkManager::m_bootSessionTemplate; -DQRNetworkManager * DQRNetworkManager::s_pDQRManager = NULL; +DQRNetworkManager * DQRNetworkManager::s_pDQRManager = nullptr; //using namespace Windows::Xbox::Networking; @@ -87,16 +87,16 @@ DQRNetworkManager::DQRNetworkManager(IDQRNetworkManagerListener *listener) memset(&m_roomSyncData, 0, sizeof(m_roomSyncData)); memset(m_players, 0, sizeof(m_players)); - m_CreateSessionThread = NULL; - m_GetFriendPartyThread = NULL; - m_UpdateCustomSessionDataThread = NULL; + m_CreateSessionThread = nullptr; + m_GetFriendPartyThread = nullptr; + m_UpdateCustomSessionDataThread = nullptr; - m_CheckPartyInviteThread = NULL; + m_CheckPartyInviteThread = nullptr; m_notifyForFullParty = false; m_customDataDirtyUpdateTicks = 0; m_sessionResultCount = 0; - m_sessionSearchResults = NULL; + m_sessionSearchResults = nullptr; m_joinSessionUserMask = 0; m_cancelJoinFromSearchResult = false; @@ -274,7 +274,7 @@ void DQRNetworkManager::JoinSession(int playerMask) // If we found the session, then set the status of this member to be active (should be reserved). This will stop our slot timing out and us being dropped out of the session. if( session != nullptr ) { - if(!IsPlayerInSession(joiningUser->XboxUserId, session, NULL) ) + if(!IsPlayerInSession(joiningUser->XboxUserId, session, nullptr) ) { app.DebugPrintf("DNM_INT_STATE_JOINING_FAILED didn't find required player in session\n"); SetState(DNM_INT_STATE_JOINING_FAILED); @@ -515,7 +515,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex) pPlayer->SetSmallId(smallId); pPlayer->SetName(ProfileManager.GetUser(userIndex)->DisplayInfo->Gamertag->Data()); pPlayer->SetDisplayName(ProfileManager.GetDisplayName(userIndex)); - pPlayer->SetUID(PlayerUID(ProfileManager.GetUser(userIndex)->XboxUserId->Data())); + pPlayer->SetUID(static_cast<PlayerUID>(ProfileManager.GetUser(userIndex)->XboxUserId->Data())); // Also add to the party so that our friends can find us. The host will get notified of this additional player in the party, but we should ignore since we're already in the session m_partyController->AddLocalUsersToParty(1 << userIndex, ProfileManager.GetUser(0)); @@ -550,7 +550,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex) pPlayer->SetSmallId(m_currentSmallId++); pPlayer->SetName(ProfileManager.GetUser(userIndex)->DisplayInfo->Gamertag->Data()); pPlayer->SetDisplayName(ProfileManager.GetDisplayName(userIndex)); - pPlayer->SetUID(PlayerUID(ProfileManager.GetUser(userIndex)->XboxUserId->Data())); + pPlayer->SetUID(static_cast<PlayerUID>(ProfileManager.GetUser(userIndex)->XboxUserId->Data())); // TODO - could this add fail? if(AddRoomSyncPlayer( pPlayer, 0, userIndex)) @@ -600,7 +600,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex) m_joinSessionXUIDs[userIndex] = ProfileManager.GetUser(userIndex)->XboxUserId; m_partyController->AddLocalUsersToParty(1 << userIndex, ProfileManager.GetUser(0)); - m_addLocalPlayerSuccessPlayer = NULL; + m_addLocalPlayerSuccessPlayer = nullptr; m_addLocalPlayerState = DNM_ADD_PLAYER_STATE_COMPLETE_SUCCESS; } } @@ -763,7 +763,7 @@ DQRNetworkPlayer *DQRNetworkManager::GetPlayerBySmallId(int idx) } } } - return NULL; + return nullptr; } DQRNetworkPlayer *DQRNetworkManager::GetPlayerByXuid(PlayerUID xuid) @@ -778,7 +778,7 @@ DQRNetworkPlayer *DQRNetworkManager::GetPlayerByXuid(PlayerUID xuid) } } } - return NULL; + return nullptr; } // Retrieve player display name by gamertag @@ -809,7 +809,7 @@ DQRNetworkPlayer *DQRNetworkManager::GetLocalPlayerByUserIndex(int idx) } } } - return NULL; + return nullptr; } DQRNetworkPlayer *DQRNetworkManager::GetHostPlayer() @@ -892,7 +892,7 @@ void DQRNetworkManager::Tick_VoiceChat() #endif // If we have to inform the chat integration layer of any players that have joined, do that now EnterCriticalSection(&m_csVecChatPlayers); - for( int i = 0; i < m_vecChatPlayersJoined.size(); i++ ) + for( size_t i = 0; i < m_vecChatPlayersJoined.size(); i++ ) { int idx = m_vecChatPlayersJoined[i]; if( m_chat ) @@ -967,19 +967,19 @@ void DQRNetworkManager::Tick_Party() void DQRNetworkManager::Tick_CustomSessionData() { // If there was a thread updaing our custom session data, then clear it up if it is done - if( m_UpdateCustomSessionDataThread != NULL ) + if( m_UpdateCustomSessionDataThread != nullptr ) { if( !m_UpdateCustomSessionDataThread->isRunning() ) { delete m_UpdateCustomSessionDataThread; - m_UpdateCustomSessionDataThread = NULL; + m_UpdateCustomSessionDataThread = nullptr; } } // If our custom data is dirty, and we aren't currently updating, then kick off a thread to update it if( m_isHosting && ( !m_isOfflineGame ) ) { - if( m_UpdateCustomSessionDataThread == NULL ) + if( m_UpdateCustomSessionDataThread == nullptr ) { if( m_customDataDirtyUpdateTicks ) { @@ -1003,7 +1003,7 @@ void DQRNetworkManager::Tick_AddAndRemoveLocalPlayers() // A lot of handling adding local players is handled asynchronously. Trying to avoid having the callbacks that may result from this being called from the task threads, so handling this aspect of it here in the tick if( m_addLocalPlayerState == DNM_ADD_PLAYER_STATE_COMPLETE_SUCCESS ) { - // If we've completed, and we're the host, then we should have the new player to create stored here in m_localPlayerSuccessCreated. For clients, this will just be NULL as the actual + // If we've completed, and we're the host, then we should have the new player to create stored here in m_localPlayerSuccessCreated. For clients, this will just be nullptr as the actual // adding of the player happens as part of a longer process of the host creating us a reserved slot etc. etc. if( m_addLocalPlayerSuccessPlayer ) { @@ -1201,7 +1201,7 @@ void DQRNetworkManager::Tick_StateMachine() break; case DNM_INT_STATE_HOSTING_WAITING_TO_PLAY: delete m_CreateSessionThread; - m_CreateSessionThread = NULL; + m_CreateSessionThread = nullptr; // If the game is offline we can transition straight to playing if (m_isOfflineGame) StartGame(); break; @@ -1247,10 +1247,10 @@ void DQRNetworkManager::Tick_CheckInviteParty() if( !m_CheckPartyInviteThread->isRunning() ) { delete m_CheckPartyInviteThread; - m_CheckPartyInviteThread = NULL; + m_CheckPartyInviteThread = nullptr; } } - if( m_CheckPartyInviteThread == NULL ) + if( m_CheckPartyInviteThread == nullptr ) { m_inviteReceived = false; m_CheckPartyInviteThread = new C4JThread(&DQRNetworkManager::_CheckInviteThreadProc, this, "Check invite thread"); @@ -1326,11 +1326,11 @@ void DQRNetworkManager::HandleSessionChange(MXSM::MultiplayerSession^ multiplaye { // 4J-JEV: This id is needed to link stats together. // I thought setting the value from here would be less intrusive than adding an accessor. - ((DurangoStats*)GenericStats::getInstance())->setMultiplayerCorrelationId(multiplayerSession->MultiplayerCorrelationId); + static_cast<DurangoStats *>(GenericStats::getInstance())->setMultiplayerCorrelationId(multiplayerSession->MultiplayerCorrelationId); } else { - ((DurangoStats*)GenericStats::getInstance())->setMultiplayerCorrelationId( nullptr ); + static_cast<DurangoStats *>(GenericStats::getInstance())->setMultiplayerCorrelationId( nullptr ); } m_multiplayerSession = multiplayerSession; @@ -1403,7 +1403,7 @@ bool DQRNetworkManager::IsPlayerInSession( Platform::String^ xboxUserId, MXSM::M { Windows::Data::Json::JsonObject^ customConstant = Windows::Data::Json::JsonObject::Parse(member->MemberCustomConstantsJson); Windows::Data::Json::JsonValue^ customValue = customConstant->GetNamedValue(L"smallId"); - *smallId = (int)(customValue->GetNumber()) & 255; + *smallId = static_cast<int>(customValue->GetNumber()) & 255; } catch (Platform::COMException^ ex) { @@ -1449,7 +1449,7 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData) for( int j = 0; j < m_roomSyncData.playerCount; j++ ) { tempPlayers.push_back(m_players[j]); - m_players[j] = NULL; + m_players[j] = nullptr; } // For each new player, it's either: @@ -1509,12 +1509,12 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData) } memcpy(&m_roomSyncData, pNewSyncData, sizeof(m_roomSyncData)); - for( int i = 0; i < tempPlayers.size(); i++ ) + for( size_t i = 0; i < tempPlayers.size(); i++ ) { m_listener->HandlePlayerLeaving(tempPlayers[i]); delete tempPlayers[i]; } - for( int i = 0; i < newPlayers.size(); i++ ) + for( size_t i = 0; i < newPlayers.size(); i++ ) { m_listener->HandlePlayerJoined(newPlayers[i]); // For clients, this is where we get notified of local and remote players joining } @@ -1592,12 +1592,12 @@ void DQRNetworkManager::RemoveRoomSyncPlayersWithSessionAddress(unsigned int ses } m_roomSyncData.playerCount = iWriteIdx; - for( int i = 0; i < removedPlayers.size(); i++ ) + for( size_t i = 0; i < removedPlayers.size(); i++ ) { m_listener->HandlePlayerLeaving(removedPlayers[i]); delete removedPlayers[i]; memset(&m_roomSyncData.players[m_roomSyncData.playerCount + i], 0, sizeof(PlayerSyncData)); - m_players[m_roomSyncData.playerCount + i] = NULL; + m_players[m_roomSyncData.playerCount + i] = nullptr; } LeaveCriticalSection(&m_csRoomSyncData); } @@ -1623,12 +1623,12 @@ void DQRNetworkManager::RemoveRoomSyncPlayer(DQRNetworkPlayer *pPlayer) } m_roomSyncData.playerCount = iWriteIdx; - for( int i = 0; i < removedPlayers.size(); i++ ) + for( size_t i = 0; i < removedPlayers.size(); i++ ) { m_listener->HandlePlayerLeaving(removedPlayers[i]); delete removedPlayers[i]; memset(&m_roomSyncData.players[m_roomSyncData.playerCount + i], 0, sizeof(PlayerSyncData)); - m_players[m_roomSyncData.playerCount + i] = NULL; + m_players[m_roomSyncData.playerCount + i] = nullptr; } } @@ -1643,7 +1643,7 @@ void DQRNetworkManager::SendRoomSyncInfo() // (2) A single byte internal data tag // (3) An unsigned int encoding the size of the combined size of all the strings in stage (5) // (4) The RoomSyncData structure itself - // (5) A wchar NULL terminated string for every active player to encode the XUID + // (5) A wchar nullptr terminated string for every active player to encode the XUID unsigned int xuidBytes = 0; for( int i = 0 ; i < m_roomSyncData.playerCount; i++ ) { @@ -1689,7 +1689,7 @@ void DQRNetworkManager::SendAddPlayerFailed(Platform::String^ xuid) // (1) 2 byte general header // (2) A single byte internal data tag // (3) An unsigned int encoding the size size of the string - // (5) A wchar NULL terminated string storing the xuid of the player which has failed to join + // (5) A wchar nullptr terminated string storing the xuid of the player which has failed to join unsigned int xuidBytes = sizeof(wchar_t) * ( xuid->Length() + 1 ); @@ -1745,7 +1745,7 @@ void DQRNetworkManager::SendSmallId(bool reliableAndSequential, int playerMask) { Windows::Data::Json::JsonObject^ customConstant = Windows::Data::Json::JsonObject::Parse(member->MemberCustomConstantsJson); Windows::Data::Json::JsonValue^ customValue = customConstant->GetNamedValue(L"smallId"); - smallId = (BYTE)(customValue->GetNumber()); + smallId = static_cast<BYTE>(customValue->GetNumber()); bFound = true; } catch (Platform::COMException^ ex) @@ -1797,7 +1797,7 @@ int DQRNetworkManager::GetSessionIndexForSmallId(unsigned char smallId) { Windows::Data::Json::JsonObject^ customConstant = Windows::Data::Json::JsonObject::Parse(member->MemberCustomConstantsJson); Windows::Data::Json::JsonValue^ customValue = customConstant->GetNamedValue(L"smallId"); - smallIdMember = (BYTE)(customValue->GetNumber()); + smallIdMember = static_cast<BYTE>(customValue->GetNumber()); } catch (Platform::COMException^ ex) { @@ -1830,7 +1830,7 @@ int DQRNetworkManager::GetSessionIndexAndSmallIdForHost(unsigned char *smallId) } if( smallIdMember > 255 ) { - *smallId = (BYTE)(smallIdMember); + *smallId = static_cast<BYTE>(smallIdMember); return i; } } @@ -1877,7 +1877,7 @@ Platform::String^ DQRNetworkManager::GetNextSmallIdAsJsonString() int DQRNetworkManager::_HostGameThreadProc( void* lpParameter ) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter); return pDQR->HostGameThreadProc(); } @@ -2190,7 +2190,7 @@ int DQRNetworkManager::HostGameThreadProc() pPlayer->SetSmallId(smallId); pPlayer->SetName(user->DisplayInfo->Gamertag->Data()); pPlayer->SetDisplayName(displayName); - pPlayer->SetUID(PlayerUID(user->XboxUserId->Data())); + pPlayer->SetUID(static_cast<PlayerUID>(user->XboxUserId->Data())); AddRoomSyncPlayer( pPlayer, localSessionAddress, i); @@ -2208,7 +2208,7 @@ int DQRNetworkManager::HostGameThreadProc() int DQRNetworkManager::_LeaveRoomThreadProc( void* lpParameter ) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter); return pDQR->LeaveRoomThreadProc(); } @@ -2311,7 +2311,7 @@ int DQRNetworkManager::LeaveRoomThreadProc() int DQRNetworkManager::_TidyUpJoinThreadProc( void* lpParameter ) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter); return pDQR->TidyUpJoinThreadProc(); } @@ -2416,7 +2416,7 @@ int DQRNetworkManager::TidyUpJoinThreadProc() int DQRNetworkManager::_UpdateCustomSessionDataThreadProc( void* lpParameter ) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter); return pDQR->UpdateCustomSessionDataThreadProc(); } @@ -2491,7 +2491,7 @@ int DQRNetworkManager::UpdateCustomSessionDataThreadProc() int DQRNetworkManager::_CheckInviteThreadProc(void* lpParameter) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter); return pDQR->CheckInviteThreadProc(); } @@ -2614,7 +2614,7 @@ void DQRNetworkManager::LeaveRoom() for( int i = 0; i < m_roomSyncData.playerCount; i++ ) { delete m_players[i]; - m_players[i] = NULL; + m_players[i] = nullptr; } memset(&m_roomSyncData, 0, sizeof(m_roomSyncData)); m_displayNames.clear(); @@ -3026,8 +3026,8 @@ void DQRNetworkManager::RequestDisplayName(DQRNetworkPlayer *player) void DQRNetworkManager::GetProfileCallback(LPVOID pParam, Microsoft::Xbox::Services::Social::XboxUserProfile^ profile) { - DQRNetworkManager *dqnm = (DQRNetworkManager *)pParam; - dqnm->SetDisplayName(PlayerUID(profile->XboxUserId->Data()), profile->GameDisplayName->Data()); + DQRNetworkManager *dqnm = static_cast<DQRNetworkManager *>(pParam); + dqnm->SetDisplayName(static_cast<PlayerUID>(profile->XboxUserId->Data()), profile->GameDisplayName->Data()); } // Set player display name diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager.h b/Minecraft.Client/Durango/Network/DQRNetworkManager.h index 3c4a742c..b74e079c 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager.h +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager.h @@ -221,7 +221,7 @@ public: class SessionSearchResult { public: - SessionSearchResult() { m_extData = NULL; } + SessionSearchResult() { m_extData = nullptr; } ~SessionSearchResult() { free(m_extData); } wstring m_partyId; wstring m_sessionName; diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp index 3a14a2d5..0822a93c 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp @@ -49,7 +49,7 @@ bool DQRNetworkManager::FriendPartyManagerSearch() m_sessionResultCount = 0; delete [] m_sessionSearchResults; - m_sessionSearchResults = NULL; + m_sessionSearchResults = nullptr; m_GetFriendPartyThread = new C4JThread(&_GetFriendsThreadProc,this,"GetFriendsThreadProc"); m_GetFriendPartyThread->Run(); @@ -61,7 +61,7 @@ bool DQRNetworkManager::FriendPartyManagerSearch() void DQRNetworkManager::FriendPartyManagerGetSessionInfo(int idx, SessionSearchResult *searchResult) { assert( idx < m_sessionResultCount ); - assert( ( m_GetFriendPartyThread == NULL ) || ( !m_GetFriendPartyThread->isRunning()) ); + assert( ( m_GetFriendPartyThread == nullptr ) || ( !m_GetFriendPartyThread->isRunning()) ); // Need to make sure that copied data has independently allocated m_extData, so both copies can be freed *searchResult = m_sessionSearchResults[idx]; @@ -71,7 +71,7 @@ void DQRNetworkManager::FriendPartyManagerGetSessionInfo(int idx, SessionSearchR int DQRNetworkManager::_GetFriendsThreadProc(void* lpParameter) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter); return pDQR->GetFriendsThreadProc(); } @@ -410,7 +410,7 @@ int DQRNetworkManager::GetFriendsThreadProc() for( int j = 0; j < nameResolveVector[i]->Size; j++ ) { m_sessionSearchResults[i].m_playerNames[j] = nameResolveVector[i]->GetAt(j)->GameDisplayName->Data(); - m_sessionSearchResults[i].m_playerXuids[j] = PlayerUID(nameResolveVector[i]->GetAt(j)->XboxUserId->Data()); + m_sessionSearchResults[i].m_playerXuids[j] = static_cast<PlayerUID>(nameResolveVector[i]->GetAt(j)->XboxUserId->Data()); } m_sessionSearchResults[i].m_playerCount = nameResolveVector[i]->Size; m_sessionSearchResults[i].m_usedSlotCount = newSessionVector[i]->Members->Size; @@ -556,7 +556,7 @@ bool DQRNetworkManager::IsSessionFriendsOfFriends(MXSM::MultiplayerSession^ sess if (result) { - friendsOfFriends = app.GetGameHostOption(((GameSessionData *)gameSessionData)->m_uiGameHostSettings, eGameHostOption_FriendsOfFriends); + friendsOfFriends = app.GetGameHostOption(static_cast<GameSessionData *>(gameSessionData)->m_uiGameHostSettings, eGameHostOption_FriendsOfFriends); } free(gameSessionData); @@ -577,7 +577,7 @@ bool DQRNetworkManager::GetGameSessionData(MXSM::MultiplayerSession^ session, vo Platform::String ^customValueString = customValue->GetString(); if( customValueString ) { - base64_decode( customValueString, (unsigned char *)gameSessionData, sizeof(GameSessionData) ); + base64_decode( customValueString, static_cast<unsigned char *>(gameSessionData), sizeof(GameSessionData) ); return true; } } diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp index 9232d095..eed3e851 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp @@ -24,7 +24,7 @@ void DQRNetworkManager::BytesReceived(int smallId, BYTE *bytes, int byteCount) DQRNetworkPlayer *host = GetPlayerBySmallId(m_hostSmallId); DQRNetworkPlayer *client = GetPlayerBySmallId(smallId); - if( ( host == NULL ) || ( client == NULL ) ) + if( ( host == nullptr ) || ( client == nullptr ) ) { return; } @@ -113,7 +113,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo, case DQRConnectionInfo::ConnectionState_InternalAssignSmallId2: case DQRConnectionInfo::ConnectionState_InternalAssignSmallId3: { - int channel = ((int)connectionInfo->m_internalDataState) - DQRConnectionInfo::ConnectionState_InternalAssignSmallId0; + int channel = static_cast<int>(connectionInfo->m_internalDataState) - DQRConnectionInfo::ConnectionState_InternalAssignSmallId0; if( ( connectionInfo->m_smallIdReadMask & ( 1 << channel ) ) && ( !connectionInfo->m_channelActive[channel] ) ) { @@ -137,7 +137,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo, DQRNetworkPlayer *pPlayer = new DQRNetworkPlayer(this, DQRNetworkPlayer::DNP_TYPE_REMOTE, true, 0, sessionAddress); pPlayer->SetSmallId(byte); - pPlayer->SetUID(PlayerUID(m_multiplayerSession->Members->GetAt(sessionIndex)->XboxUserId->Data())); + pPlayer->SetUID(static_cast<PlayerUID>(m_multiplayerSession->Members->GetAt(sessionIndex)->XboxUserId->Data())); HostGamertagResolveDetails *resolveDetails = new HostGamertagResolveDetails(); resolveDetails->m_pPlayer = pPlayer; @@ -238,7 +238,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo, UpdateRoomSyncPlayers((RoomSyncData *)connectionInfo->m_pucRoomSyncData); delete connectionInfo->m_pucRoomSyncData; - connectionInfo->m_pucRoomSyncData = NULL; + connectionInfo->m_pucRoomSyncData = nullptr; connectionInfo->m_internalDataState = DQRConnectionInfo::ConnectionState_InternalHeaderByte; // If we haven't actually established a connection yet for this channel, then this is the point where we can consider this active @@ -267,7 +267,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo, { if( m_currentUserMask & ( 1 << i ) ) { - if( GetLocalPlayerByUserIndex(i) == NULL ) + if( GetLocalPlayerByUserIndex(i) == nullptr ) { allLocalPlayersHere = false; } @@ -307,7 +307,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo, // XUID fully read, can now handle what to do with it AddPlayerFailed(ref new Platform::String( (wchar_t *)connectionInfo->m_pucAddFailedPlayerData ) ); delete [] connectionInfo->m_pucAddFailedPlayerData; - connectionInfo->m_pucAddFailedPlayerData = NULL; + connectionInfo->m_pucAddFailedPlayerData = nullptr; connectionInfo->m_internalDataState = DQRConnectionInfo::ConnectionState_InternalHeaderByte; } @@ -371,7 +371,7 @@ void DQRNetworkManager::SendBytesChat(unsigned int address, BYTE *bytes, int byt void DQRNetworkManager::SendBytes(int smallId, BYTE *bytes, int byteCount) { EnterCriticalSection(&m_csSendBytes); - unsigned char *tempSendBuffer = (unsigned char *)malloc(8191 + 2); + unsigned char *tempSendBuffer = static_cast<unsigned char *>(malloc(8191 + 2)); BYTE *data = bytes; BYTE *dataEnd = bytes + byteCount; @@ -381,7 +381,7 @@ void DQRNetworkManager::SendBytes(int smallId, BYTE *bytes, int byteCount) // blocks of this size. do { - int bytesToSend = (int)(dataEnd - data); + int bytesToSend = static_cast<int>(dataEnd - data); if( bytesToSend > 8191 ) bytesToSend = 8191; // Send header with data sending mode - see full comment in DQRNetworkManagerEventHandlers::DataReceivedHandler diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp index c985a191..ae7094fb 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp @@ -84,7 +84,7 @@ void DQRNetworkManagerEventHandlers::DataReceivedHandler(Platform::Object^ sessi } rtsMessage.m_sessionAddress = args->SessionAddress; rtsMessage.m_dataSize = args->Data->Length; - rtsMessage.m_pucData = (unsigned char *)malloc(rtsMessage.m_dataSize); + rtsMessage.m_pucData = static_cast<unsigned char *>(malloc(rtsMessage.m_dataSize)); memcpy( rtsMessage.m_pucData, args->Data->Data, rtsMessage.m_dataSize ); m_pDQRNet->m_RTSMessageQueueIncoming.push(rtsMessage); LeaveCriticalSection(&m_pDQRNet->m_csRTSMessageQueueIncoming); @@ -311,7 +311,7 @@ void DQRNetworkManager::Process_RTS_MESSAGE_DATA_RECEIVED(RTS_Message &message) break; case DQRConnectionInfo::ConnectionState_ReadBytes: // At this stage we can send up to connectionInfo->m_bytesRemaining bytes, or the number of bytes that we have remaining in the data received, whichever is lowest. - int bytesInBuffer = (int)(pEndByte - pNextByte); + int bytesInBuffer = static_cast<int>(pEndByte - pNextByte); int bytesToReceive = ( ( connectionInfo->m_bytesRemaining < bytesInBuffer ) ? connectionInfo->m_bytesRemaining : bytesInBuffer ); if( connectionInfo->m_internalFlag ) @@ -438,7 +438,7 @@ void DQRNetworkManager::Process_RTS_MESSAGE_STATUS_TERMINATED(RTS_Message &messa int DQRNetworkManager::_RTSDoWorkThread(void* lpParameter) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter); return pDQR->RTSDoWorkThread(); } @@ -603,7 +603,7 @@ void DQRNetworkManager::RTS_StartCient() EnterCriticalSection(&m_csRTSMessageQueueOutgoing); RTS_Message message; message.m_eType = eRTSMessageType::RTS_MESSAGE_START_CLIENT; - message.m_pucData = NULL; + message.m_pucData = nullptr; message.m_dataSize = 0; m_RTSMessageQueueOutgoing.push(message); LeaveCriticalSection(&m_csRTSMessageQueueOutgoing); @@ -614,7 +614,7 @@ void DQRNetworkManager::RTS_StartHost() EnterCriticalSection(&m_csRTSMessageQueueOutgoing); RTS_Message message; message.m_eType = eRTSMessageType::RTS_MESSAGE_START_HOST; - message.m_pucData = NULL; + message.m_pucData = nullptr; message.m_dataSize = 0; m_RTSMessageQueueOutgoing.push(message); LeaveCriticalSection(&m_csRTSMessageQueueOutgoing); @@ -625,7 +625,7 @@ void DQRNetworkManager::RTS_Terminate() EnterCriticalSection(&m_csRTSMessageQueueOutgoing); RTS_Message message; message.m_eType = eRTSMessageType::RTS_MESSAGE_TERMINATE; - message.m_pucData = NULL; + message.m_pucData = nullptr; message.m_dataSize = 0; m_RTSMessageQueueOutgoing.push(message); LeaveCriticalSection(&m_csRTSMessageQueueOutgoing); @@ -636,7 +636,7 @@ void DQRNetworkManager::RTS_SendData(unsigned char *pucData, unsigned int dataSi EnterCriticalSection(&m_csRTSMessageQueueOutgoing); RTS_Message message; message.m_eType = eRTSMessageType::RTS_MESSAGE_SEND_DATA; - message.m_pucData = (unsigned char *)malloc(dataSize); + message.m_pucData = static_cast<unsigned char *>(malloc(dataSize)); memcpy(message.m_pucData, pucData, dataSize); message.m_dataSize = dataSize; message.m_sessionAddress = sessionAddress; diff --git a/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp b/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp index e2d82a90..a8140764 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp @@ -97,7 +97,7 @@ bool DQRNetworkPlayer::HasVoice() Microsoft::Xbox::GameChat::ChatUser^ chatUser = m_manager->m_chat->GetChatUserByXboxUserId(ref new Platform::String(m_UID.toString().c_str())); if( chatUser == nullptr ) return false; - if( ((int)chatUser->ParticipantType) & ((int)Windows::Xbox::Chat::ChatParticipantTypes::Talker) ) + if( static_cast<int>(chatUser->ParticipantType) & static_cast<int>(Windows::Xbox::Chat::ChatParticipantTypes::Talker) ) { return true; } diff --git a/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp b/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp index fd2181df..84a34a97 100644 --- a/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp +++ b/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp @@ -4,7 +4,7 @@ NetworkPlayerDurango::NetworkPlayerDurango(DQRNetworkPlayer *qnetPlayer) { m_dqrPlayer = qnetPlayer; - m_pSocket = NULL; + m_pSocket = nullptr; } unsigned char NetworkPlayerDurango::GetSmallId() @@ -14,12 +14,12 @@ unsigned char NetworkPlayerDurango::GetSmallId() void NetworkPlayerDurango::SendData(INetworkPlayer *player, const void *pvData, int dataSize, bool lowPriority) { - m_dqrPlayer->SendData( ((NetworkPlayerDurango *)player)->m_dqrPlayer, pvData, dataSize ); + m_dqrPlayer->SendData( static_cast<NetworkPlayerDurango *>(player)->m_dqrPlayer, pvData, dataSize ); } bool NetworkPlayerDurango::IsSameSystem(INetworkPlayer *player) { - return m_dqrPlayer->IsSameSystem(((NetworkPlayerDurango *)player)->m_dqrPlayer); + return m_dqrPlayer->IsSameSystem(static_cast<NetworkPlayerDurango *>(player)->m_dqrPlayer); } int NetworkPlayerDurango::GetSendQueueSizeBytes( INetworkPlayer *player, bool lowPriority ) diff --git a/Minecraft.Client/Durango/Network/PartyController.cpp b/Minecraft.Client/Durango/Network/PartyController.cpp index 753a71ac..1dfd5eb0 100644 --- a/Minecraft.Client/Durango/Network/PartyController.cpp +++ b/Minecraft.Client/Durango/Network/PartyController.cpp @@ -103,7 +103,7 @@ void PartyController::RefreshPartyView() } catch ( Platform::Exception^ ex ) { - if( ex->HResult != (int)Windows::Xbox::Multiplayer::PartyErrorStatus::EmptyParty ) + if( ex->HResult != static_cast<int>(Windows::Xbox::Multiplayer::PartyErrorStatus::EmptyParty) ) { // LogCommentWithError( L"GetPartyView failed", ex->HResult ); } @@ -181,7 +181,7 @@ bool PartyController::AddLocalUsersToParty(int userMask, Windows::Xbox::System:: bool alreadyInSession = false; if( session ) { - if( m_pDQRNet->IsPlayerInSession( ProfileManager.GetUser(i, true)->XboxUserId, session, NULL ) ) + if( m_pDQRNet->IsPlayerInSession( ProfileManager.GetUser(i, true)->XboxUserId, session, nullptr ) ) { alreadyInSession = true; } @@ -577,7 +577,7 @@ void PartyController::OnPartyRosterChanged( PartyRosterChangedEventArgs^ eventAr // Still a party, find out who left for( int i = 0; i < eventArgs->RemovedMembers->Size; i++ ) { - DQRNetworkPlayer *player = m_pDQRNet->GetPlayerByXuid(PlayerUID(eventArgs->RemovedMembers->GetAt(i)->Data())); + DQRNetworkPlayer *player = m_pDQRNet->GetPlayerByXuid(static_cast<PlayerUID>(eventArgs->RemovedMembers->GetAt(i)->Data())); if( player ) { if( player->IsLocal() ) @@ -621,7 +621,7 @@ void PartyController::AddAvailableGamePlayers(IVectorView<GamePlayer^>^ availabl } #endif - if( m_pDQRNet->IsPlayerInSession(player->XboxUserId, currentSession, NULL)) + if( m_pDQRNet->IsPlayerInSession(player->XboxUserId, currentSession, nullptr)) { DQRNetworkManager::LogComment( L"Player is already in session; skipping join request: " + player->XboxUserId->ToString() ); continue; @@ -639,7 +639,7 @@ void PartyController::AddAvailableGamePlayers(IVectorView<GamePlayer^>^ availabl { bFoundLocal = true; // Check that they aren't in the game already (don't see how this could be the case anyway) - if( m_pDQRNet->GetPlayerByXuid( PlayerUID(player->XboxUserId->Data()) ) == NULL ) + if( m_pDQRNet->GetPlayerByXuid( static_cast<PlayerUID>(player->XboxUserId->Data()) ) == nullptr ) { // And check whether they are signed in yet or not int userIdx = -1; @@ -838,7 +838,7 @@ void PartyController::OnGameSessionReady( GameSessionReadyEventArgs^ eventArgs ) if( !isAJoiningXuid ) // Isn't someone we are actively trying to join { if( (!bInSession) || // If not in a game session at all - ( ( m_pDQRNet->GetState() == DQRNetworkManager::DNM_INT_STATE_PLAYING ) && ( m_pDQRNet->GetPlayerByXuid( PlayerUID(memberXUID->Data()) ) == NULL ) ) // Or we're fully in, and this player isn't in it + ( ( m_pDQRNet->GetState() == DQRNetworkManager::DNM_INT_STATE_PLAYING ) && ( m_pDQRNet->GetPlayerByXuid( static_cast<PlayerUID>(memberXUID->Data()) ) == nullptr ) ) // Or we're fully in, and this player isn't in it ) { for( int j = 4; j < 12; j++ ) // Final check that we have a gamepad for this xuid so that we might possibly be able to pair someone up @@ -1201,5 +1201,5 @@ double PartyController::GetTimeBetweenInSeconds(Windows::Foundation::DateTime dt { const uint64 tickPerSecond = 10000000i64; uint64 deltaTime = dt2.UniversalTime - dt1.UniversalTime; - return (double)deltaTime / (double)tickPerSecond; + return static_cast<double>(deltaTime) / static_cast<double>(tickPerSecond); }
\ No newline at end of file diff --git a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp index 925a37a8..5e3a0824 100644 --- a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp +++ b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp @@ -87,7 +87,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerJoined(DQRNetworkPlayer *pDQRPl bool createFakeSocket = false; bool localPlayer = false; - NetworkPlayerDurango *networkPlayer = (NetworkPlayerDurango *)addNetworkPlayer(pDQRPlayer); + NetworkPlayerDurango *networkPlayer = static_cast<NetworkPlayerDurango *>(addNetworkPlayer(pDQRPlayer)); // Request full display name for this player m_pDQRNet->RequestDisplayName(pDQRPlayer); @@ -166,7 +166,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerJoined(DQRNetworkPlayer *pDQRPl for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(playerChangedCallback[idx] != NULL) + if(playerChangedCallback[idx] != nullptr) playerChangedCallback[idx]( playerChangedCallbackParam[idx], networkPlayer, false ); } @@ -175,7 +175,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerJoined(DQRNetworkPlayer *pDQRPl int localPlayerCount = 0; for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != NULL ) ++localPlayerCount; + if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != nullptr ) ++localPlayerCount; } float appTime = app.getAppTime(); @@ -198,7 +198,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP { // Get our wrapper object associated with this player. Socket *socket = networkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { // If we are in game then remove this player from the game as well. // We may get here either from the player requesting to exit the game, @@ -214,14 +214,14 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP // We need this as long as the game server still needs to communicate with the player //delete socket; - networkPlayer->SetSocket( NULL ); + networkPlayer->SetSocket( nullptr ); } if( m_pDQRNet->IsHost() && !m_bHostChanged ) { if( isSystemPrimaryPlayer(pDQRPlayer) ) { - DQRNetworkPlayer *pNewDQRPrimaryPlayer = NULL; + DQRNetworkPlayer *pNewDQRPrimaryPlayer = nullptr; for(unsigned int i = 0; i < m_pDQRNet->GetPlayerCount(); ++i ) { DQRNetworkPlayer *pDQRPlayer2 = m_pDQRNet->GetPlayerByIndex( i ); @@ -238,7 +238,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP m_machineDQRPrimaryPlayers.erase( it ); } - if( pNewDQRPrimaryPlayer != NULL ) + if( pNewDQRPrimaryPlayer != nullptr ) m_machineDQRPrimaryPlayers.push_back( pNewDQRPrimaryPlayer ); } @@ -251,7 +251,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(playerChangedCallback[idx] != NULL) + if(playerChangedCallback[idx] != nullptr) playerChangedCallback[idx]( playerChangedCallbackParam[idx], networkPlayer, true ); } @@ -260,7 +260,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP int localPlayerCount = 0; for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != NULL ) ++localPlayerCount; + if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != nullptr ) ++localPlayerCount; } float appTime = app.getAppTime(); @@ -289,7 +289,7 @@ void CPlatformNetworkManagerDurango::HandleDataReceived(DQRNetworkPlayer *player INetworkPlayer *pPlayerFrom = getNetworkPlayer(playerFrom); Socket *socket = pPlayerFrom->GetSocket(); - if(socket != NULL) + if(socket != nullptr) socket->pushDataToQueue(data, dataSize, false); } else @@ -298,7 +298,7 @@ void CPlatformNetworkManagerDurango::HandleDataReceived(DQRNetworkPlayer *player INetworkPlayer *pPlayerTo = getNetworkPlayer(playerTo); Socket *socket = pPlayerTo->GetSocket(); //app.DebugPrintf( "Pushing data into read queue for user \"%ls\"\n", apPlayersTo[dwPlayer]->GetGamertag()); - if(socket != NULL) + if(socket != nullptr) socket->pushDataToQueue(data, dataSize); } } @@ -319,7 +319,7 @@ bool CPlatformNetworkManagerDurango::Initialise(CGameNetworkManager *pGameNetwor g_pPlatformNetworkManager = this; for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - playerChangedCallback[ i ] = NULL; + playerChangedCallback[ i ] = nullptr; } m_bLeavingGame = false; @@ -330,14 +330,14 @@ bool CPlatformNetworkManagerDurango::Initialise(CGameNetworkManager *pGameNetwor m_bSearchPending = false; m_bIsOfflineGame = false; - m_pSearchParam = NULL; - m_SessionsUpdatedCallback = NULL; + m_pSearchParam = nullptr; + m_SessionsUpdatedCallback = nullptr; m_searchResultsCount = 0; m_lastSearchStartTime = 0; // The results that will be filled in with the current search - m_pSearchResults = NULL; + m_pSearchResults = nullptr; Windows::Networking::Connectivity::NetworkInformation::NetworkStatusChanged += ref new Windows::Networking::Connectivity::NetworkStatusChangedEventHandler( []( Platform::Object^ pxObject ) { @@ -585,8 +585,8 @@ void CPlatformNetworkManagerDurango::UnRegisterPlayerChangedCallback(int iPad, v { if(playerChangedCallbackParam[iPad] == callbackParam) { - playerChangedCallback[iPad] = NULL; - playerChangedCallbackParam[iPad] = NULL; + playerChangedCallback[iPad] = nullptr; + playerChangedCallbackParam[iPad] = nullptr; } } @@ -613,12 +613,12 @@ bool CPlatformNetworkManagerDurango::_RunNetworkGame() return true; } -void CPlatformNetworkManagerDurango::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= NULL*/) +void CPlatformNetworkManagerDurango::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= nullptr*/) { if( this->m_bLeavingGame ) return; - if( GetHostPlayer() == NULL ) + if( GetHostPlayer() == nullptr ) return; m_hostGameSessionData.m_uiGameHostSettings = app.GetGameHostOption(eGameHostOption_All); @@ -628,18 +628,18 @@ void CPlatformNetworkManagerDurango::UpdateAndSetGameSessionData(INetworkPlayer int CPlatformNetworkManagerDurango::RemovePlayerOnSocketClosedThreadProc( void* lpParam ) { - INetworkPlayer *pNetworkPlayer = (INetworkPlayer *)lpParam; + INetworkPlayer *pNetworkPlayer = static_cast<INetworkPlayer *>(lpParam); Socket *socket = pNetworkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { //printf("Waiting for socket closed event\n"); socket->m_socketClosedEvent->WaitForSignal(INFINITE); //printf("Socket closed event has fired\n"); // 4J Stu - Clear our reference to this socket - pNetworkPlayer->SetSocket( NULL ); + pNetworkPlayer->SetSocket( nullptr ); delete socket; } @@ -712,7 +712,7 @@ void CPlatformNetworkManagerDurango::SystemFlagReset() void CPlatformNetworkManagerDurango::SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index) { if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return; - if( pNetworkPlayer == NULL ) return; + if( pNetworkPlayer == nullptr ) return; for( unsigned int i = 0; i < m_playerFlags.size(); i++ ) { @@ -728,7 +728,7 @@ void CPlatformNetworkManagerDurango::SystemFlagSet(INetworkPlayer *pNetworkPlaye bool CPlatformNetworkManagerDurango::SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index) { if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return false; - if( pNetworkPlayer == NULL ) + if( pNetworkPlayer == nullptr ) { return false; } @@ -769,7 +769,7 @@ void CPlatformNetworkManagerDurango::TickSearch() } m_bSearchPending = false; - if( m_SessionsUpdatedCallback != NULL ) m_SessionsUpdatedCallback(m_pSearchParam); + if( m_SessionsUpdatedCallback != nullptr ) m_SessionsUpdatedCallback(m_pSearchParam); } } else @@ -777,7 +777,7 @@ void CPlatformNetworkManagerDurango::TickSearch() if( !m_pDQRNet->FriendPartyManagerIsBusy() ) { // Don't start searches unless we have registered a callback - if( m_SessionsUpdatedCallback != NULL && (m_lastSearchStartTime + MINECRAFT_DURANGO_PARTY_SEARCH_DELAY_MILLISECONDS) < GetTickCount() ) + if( m_SessionsUpdatedCallback != nullptr && (m_lastSearchStartTime + MINECRAFT_DURANGO_PARTY_SEARCH_DELAY_MILLISECONDS) < GetTickCount() ) { if( m_pDQRNet->FriendPartyManagerSearch() ); { @@ -794,13 +794,13 @@ vector<FriendSessionInfo *> *CPlatformNetworkManagerDurango::GetSessionList(int vector<FriendSessionInfo *> *filteredList = new vector<FriendSessionInfo *>(); for( int i = 0; i < m_searchResultsCount; i++ ) { - GameSessionData *gameSessionData = (GameSessionData *)m_pSearchResults[i].m_extData; + GameSessionData *gameSessionData = static_cast<GameSessionData *>(m_pSearchResults[i].m_extData); if( ( gameSessionData->netVersion == MINECRAFT_NET_VERSION ) && ( gameSessionData->isReadyToJoin ) ) { FriendSessionInfo *session = new FriendSessionInfo(); session->searchResult = m_pSearchResults[i]; - session->searchResult.m_extData = NULL; // We have another copy of the GameSessionData, so don't need to make another copy of this here + session->searchResult.m_extData = nullptr; // We have another copy of the GameSessionData, so don't need to make another copy of this here session->displayLabelLength = session->searchResult.m_playerNames[0].size(); session->displayLabel = new wchar_t[ session->displayLabelLength + 1 ]; memcpy(&session->data, gameSessionData, sizeof(GameSessionData)); @@ -832,7 +832,7 @@ void CPlatformNetworkManagerDurango::ForceFriendsSessionRefresh() m_lastSearchStartTime = 0; m_searchResultsCount = 0; delete [] m_pSearchResults; - m_pSearchResults = NULL; + m_pSearchResults = nullptr; } INetworkPlayer *CPlatformNetworkManagerDurango::addNetworkPlayer(DQRNetworkPlayer *pDQRPlayer) @@ -858,7 +858,7 @@ void CPlatformNetworkManagerDurango::removeNetworkPlayer(DQRNetworkPlayer *pDQRP INetworkPlayer *CPlatformNetworkManagerDurango::getNetworkPlayer(DQRNetworkPlayer *pDQRPlayer) { - return pDQRPlayer ? (INetworkPlayer *)(pDQRPlayer->GetCustomDataValue()) : NULL; + return pDQRPlayer ? (INetworkPlayer *)(pDQRPlayer->GetCustomDataValue()) : nullptr; } diff --git a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h index 55807227..5626b012 100644 --- a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h +++ b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h @@ -87,7 +87,7 @@ private: bool m_hostGameSessionIsJoinable; CGameNetworkManager *m_pGameNetworkManager; public: - virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL); + virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = nullptr); private: // TODO 4J Stu - Do we need to be able to have more than one of these? diff --git a/Minecraft.Client/Durango/Network/base64.cpp b/Minecraft.Client/Durango/Network/base64.cpp index c5af745c..c916725f 100644 --- a/Minecraft.Client/Durango/Network/base64.cpp +++ b/Minecraft.Client/Durango/Network/base64.cpp @@ -109,13 +109,13 @@ void base64_decode(Platform::String ^encoded_string, unsigned char *output, unsi while (in_len-- && ( encoded_string->Data()[in_] != L'=') && is_base64(encoded_string->Data()[in_])) { - char_array_4[i++] = (unsigned char)(encoded_string->Data()[in_]); + char_array_4[i++] = static_cast<unsigned char>(encoded_string->Data()[in_]); in_++; if (i ==4) { for (i = 0; i <4; i++) { - char_array_4[i] = (unsigned char )base64_chars.find(char_array_4[i]); + char_array_4[i] = static_cast<unsigned char>(base64_chars.find(char_array_4[i])); } char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); @@ -140,7 +140,7 @@ void base64_decode(Platform::String ^encoded_string, unsigned char *output, unsi for (j = 0; j <4; j++) { - char_array_4[j] = (unsigned char )base64_chars.find(char_array_4[j]); + char_array_4[j] = static_cast<unsigned char>(base64_chars.find(char_array_4[j])); } char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); diff --git a/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp b/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp index 2386a348..31ab9d64 100644 --- a/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp +++ b/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp @@ -64,7 +64,7 @@ bool CDurangoTelemetryManager::RecordPlayerSessionExit(int iPad, int exitStatus) // 4J-JEV: Still needed to flush cached travel stats. DurangoStats::playerSessionEnd(iPad); - if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL) + if (plr != nullptr && plr->level != nullptr && plr->level->getLevelData() != nullptr) { ULONG hr = EventWritePlayerSessionEnd( DurangoStats::getUserId(iPad), @@ -131,7 +131,7 @@ bool CDurangoTelemetryManager::RecordLevelStart(int iPad, ESen_FriendOrMatch fri ProfileManager.GetXUID(iPad, &puid, true); plr = Minecraft::GetInstance()->localplayers[iPad]; - if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL) + if (plr != nullptr && plr->level != nullptr && plr->level->getLevelData() != nullptr) { hr = EventWritePlayerSessionStart( DurangoStats::getUserId(iPad), @@ -968,7 +968,7 @@ bool CDurangoTelemetryManager::RecordUnBanLevel(int iPad) DurangoStats *CDurangoTelemetryManager::durangoStats() { - return (DurangoStats*) GenericStats::getInstance(); + return static_cast<DurangoStats *>(GenericStats::getInstance()); } wstring CDurangoTelemetryManager::guid2str(LPCGUID guid) diff --git a/Minecraft.Client/Durango/ServiceConfig/Events-XBLA.8-149E11AEEvents.h b/Minecraft.Client/Durango/ServiceConfig/Events-XBLA.8-149E11AEEvents.h index 5fc80438..8bd11354 100644 --- a/Minecraft.Client/Durango/ServiceConfig/Events-XBLA.8-149E11AEEvents.h +++ b/Minecraft.Client/Durango/ServiceConfig/Events-XBLA.8-149E11AEEvents.h @@ -195,7 +195,7 @@ EventWriteAchievementGet(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, _ EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &AchievementId, sizeof(AchievementId)); @@ -216,7 +216,7 @@ EventWriteAchievemntUnlocked(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionI EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -246,7 +246,7 @@ EventWriteBanLevel(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in co EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -274,7 +274,7 @@ EventWriteBlockBroken(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[4], &BlockId, sizeof(BlockId)); @@ -298,7 +298,7 @@ EventWriteBlockPlaced(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[4], &BlockId, sizeof(BlockId)); @@ -322,7 +322,7 @@ EventWriteChestfulOfCobblestone(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessi EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &Cobblecount, sizeof(Cobblecount)); @@ -343,7 +343,7 @@ EventWriteEnteredNewBiome(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &BiomeId, sizeof(BiomeId)); @@ -364,7 +364,7 @@ EventWriteGameProgress(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __i EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &CompletionPercent, sizeof(CompletionPercent)); @@ -385,7 +385,7 @@ EventWriteIncDistanceTravelled(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessio EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[4], &Distance, sizeof(Distance)); @@ -408,7 +408,7 @@ EventWriteIncTimePlayed(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __ EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[4], &TimePlayed, sizeof(TimePlayed)); @@ -430,7 +430,7 @@ EventWriteLeaderboardTotals(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[4], &LeaderboardId, sizeof(LeaderboardId)); @@ -453,7 +453,7 @@ EventWriteLevelExit(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in c EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -482,7 +482,7 @@ EventWriteLevelResume(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -516,7 +516,7 @@ EventWriteLevelSaveOrCheckpoint(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessi EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -546,7 +546,7 @@ EventWriteLevelStart(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -579,10 +579,10 @@ EventWriteMcItemAcquired(__in_opt PCWSTR UserId, __in const signed int SectionId EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], &SectionId, sizeof(SectionId)); EventDataDescCreate(&EventData[3], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[5], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[6], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[7], &ItemId, sizeof(ItemId)); @@ -610,10 +610,10 @@ EventWriteMcItemUsed(__in_opt PCWSTR UserId, __in const signed int SectionId, __ EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], &SectionId, sizeof(SectionId)); EventDataDescCreate(&EventData[3], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[5], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[6], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[7], &ItemId, sizeof(ItemId)); @@ -641,7 +641,7 @@ EventWriteMenuShown(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in c EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -671,7 +671,7 @@ EventWriteMobInteract(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &MobId, sizeof(MobId)); EventDataDescCreate(&EventData[4], &InteractionId, sizeof(InteractionId)); @@ -693,10 +693,10 @@ EventWriteMobKilled(__in_opt PCWSTR UserId, __in const signed int SectionId, __i EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], &SectionId, sizeof(SectionId)); EventDataDescCreate(&EventData[3], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[5], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[6], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[7], RoundId, sizeof(GUID)); @@ -728,11 +728,11 @@ EventWriteMultiplayerRoundEnd(__in_opt PCWSTR UserId, __in LPCGUID RoundId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], RoundId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SectionId, sizeof(SectionId)); EventDataDescCreate(&EventData[4], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[5], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[5], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[6], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[7], &MatchTypeId, sizeof(MatchTypeId)); EventDataDescCreate(&EventData[8], &DifficultyLevelId, sizeof(DifficultyLevelId)); @@ -756,11 +756,11 @@ EventWriteMultiplayerRoundStart(__in_opt PCWSTR UserId, __in LPCGUID RoundId, __ EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], RoundId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SectionId, sizeof(SectionId)); EventDataDescCreate(&EventData[4], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[5], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[5], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[6], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[7], &MatchTypeId, sizeof(MatchTypeId)); EventDataDescCreate(&EventData[8], &DifficultyLevelId, sizeof(DifficultyLevelId)); @@ -782,7 +782,7 @@ EventWriteOnARail(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in con EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &Distance, sizeof(Distance)); @@ -803,7 +803,7 @@ EventWriteOverkill(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in co EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &Damage, sizeof(Damage)); @@ -824,7 +824,7 @@ EventWritePauseOrInactive(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -852,7 +852,7 @@ EventWritePlayedMusicDisc(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DiscId, sizeof(DiscId)); @@ -873,7 +873,7 @@ EventWritePlayerDiedOrFailed(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionI EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -908,9 +908,9 @@ EventWritePlayerSessionEnd(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[4], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[5], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[6], &ExitStatusId, sizeof(ExitStatusId)); @@ -932,9 +932,9 @@ EventWritePlayerSessionPause(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionI EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); return EtxEventWrite(&XBLA_149E11AEEvents[28], &XBLA_149E11AEProvider, XBLA_149E11AEHandle, ARGUMENT_COUNT_XBLA_149E11AE_PlayerSessionPause, EventData); } @@ -953,9 +953,9 @@ EventWritePlayerSessionResume(__in_opt PCWSTR UserId, __in LPCGUID PlayerSession EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[4], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[5], &DifficultyLevelId, sizeof(DifficultyLevelId)); @@ -976,9 +976,9 @@ EventWritePlayerSessionStart(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionI EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[4], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[5], &DifficultyLevelId, sizeof(DifficultyLevelId)); @@ -999,7 +999,7 @@ EventWriteRecordMediaShareUpload(__in_opt PCWSTR UserId, __in LPCGUID PlayerSess EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1027,7 +1027,7 @@ EventWriteRichPresenceState(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &ContextID, sizeof(ContextID)); @@ -1048,7 +1048,7 @@ EventWriteSkinChanged(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1077,7 +1077,7 @@ EventWriteTexturePackLoaded(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1107,7 +1107,7 @@ EventWriteUnbanLevel(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1135,7 +1135,7 @@ EventWriteUnpauseOrActive(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1163,7 +1163,7 @@ EventWriteUpsellPresented(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1193,7 +1193,7 @@ EventWriteUpsellResponded(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); diff --git a/Minecraft.Client/Durango/XML/ATGXmlParser.cpp b/Minecraft.Client/Durango/XML/ATGXmlParser.cpp index 771ba268..89ca7714 100644 --- a/Minecraft.Client/Durango/XML/ATGXmlParser.cpp +++ b/Minecraft.Client/Durango/XML/ATGXmlParser.cpp @@ -27,7 +27,7 @@ XMLParser::XMLParser() { m_pWritePtr = m_pWriteBuf; m_pReadPtr = m_pReadBuf; - m_pISAXCallback = NULL; + m_pISAXCallback = nullptr; m_hFile = INVALID_HANDLE_VALUE; } @@ -49,7 +49,7 @@ VOID XMLParser::FillBuffer() m_pReadPtr = m_pReadBuf; - if( m_hFile == NULL ) + if( m_hFile == nullptr ) { if( m_uInXMLBufferCharsLeft > XML_READ_BUFFER_SIZE ) NChars = XML_READ_BUFFER_SIZE; @@ -62,15 +62,15 @@ VOID XMLParser::FillBuffer() } else { - if( !ReadFile( m_hFile, m_pReadBuf, XML_READ_BUFFER_SIZE, &NChars, NULL )) + if( !ReadFile( m_hFile, m_pReadBuf, XML_READ_BUFFER_SIZE, &NChars, nullptr )) { return; } } m_dwCharsConsumed += NChars; - int64_t iProgress = m_dwCharsTotal ? (( (int64_t)m_dwCharsConsumed * 1000 ) / (int64_t)m_dwCharsTotal) : 0; - m_pISAXCallback->SetParseProgress( (DWORD)iProgress ); + int64_t iProgress = m_dwCharsTotal ? (( static_cast<int64_t>(m_dwCharsConsumed) * 1000 ) / static_cast<int64_t>(m_dwCharsTotal)) : 0; + m_pISAXCallback->SetParseProgress( static_cast<DWORD>(iProgress) ); m_pReadBuf[ NChars ] = '\0'; m_pReadBuf[ NChars + 1] = '\0'; @@ -198,7 +198,7 @@ HRESULT XMLParser::ConvertEscape() if( FAILED( hr = AdvanceName() ) ) return hr; - EntityRefLen = (UINT)( m_pWritePtr - pEntityRefVal ); + EntityRefLen = static_cast<UINT>(m_pWritePtr - pEntityRefVal); m_pWritePtr = pEntityRefVal; if ( EntityRefLen == 0 ) @@ -359,7 +359,7 @@ HRESULT XMLParser::AdvanceCharacter( BOOL bOkToFail ) // Read more from the file FillBuffer(); - // We are at EOF if it is still NULL + // We are at EOF if it is still nullptr if ( ( m_pReadPtr[0] == '\0' ) && ( m_pReadPtr[1] == '\0' ) ) { if( !bOkToFail ) @@ -497,8 +497,8 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceName() ) ) return hr; - if( FAILED( m_pISAXCallback->ElementEnd( pEntityRefVal, - (UINT) ( m_pWritePtr - pEntityRefVal ) ) ) ) + if (FAILED(m_pISAXCallback->ElementEnd( pEntityRefVal, + static_cast<UINT>(m_pWritePtr - pEntityRefVal) ))) return E_ABORT; if( FAILED( hr = ConsumeSpace() ) ) @@ -541,7 +541,7 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceName() ) ) return hr; - EntityRefLen = (UINT)( m_pWritePtr - pEntityRefVal ); + EntityRefLen = static_cast<UINT>(m_pWritePtr - pEntityRefVal); if( FAILED( hr = ConsumeSpace() ) ) return hr; @@ -566,7 +566,7 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceName() ) ) return hr; - Attributes[ NumAttrs ].NameLen = (UINT)( m_pWritePtr - Attributes[ NumAttrs ].strName ); + Attributes[ NumAttrs ].NameLen = static_cast<UINT>(m_pWritePtr - Attributes[NumAttrs].strName); if( FAILED( hr = ConsumeSpace() ) ) return hr; @@ -588,8 +588,8 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceAttrVal() ) ) return hr; - Attributes[ NumAttrs ].ValueLen = (UINT)( m_pWritePtr - - Attributes[ NumAttrs ].strValue ); + Attributes[ NumAttrs ].ValueLen = static_cast<UINT>(m_pWritePtr - + Attributes[NumAttrs].strValue); ++NumAttrs; @@ -663,13 +663,13 @@ HRESULT XMLParser::AdvanceCDATA() if( m_pWritePtr - m_pWriteBuf >= XML_WRITE_BUFFER_SIZE ) { - if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), TRUE ) ) ) + if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, static_cast<UINT>(m_pWritePtr - m_pWriteBuf), TRUE ) ) ) return E_ABORT; m_pWritePtr = m_pWriteBuf; } } - if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) ) + if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, static_cast<UINT>(m_pWritePtr - m_pWriteBuf), FALSE ) ) ) return E_ABORT; m_pWritePtr = m_pWriteBuf; @@ -782,11 +782,10 @@ HRESULT XMLParser::MainParseLoop() { if( FAILED( AdvanceCharacter( TRUE ) ) ) { - if ( ( (UINT) ( m_pWritePtr - m_pWriteBuf ) != 0 ) && ( !bWhiteSpaceOnly ) ) + if ( ( static_cast<UINT>(m_pWritePtr - m_pWriteBuf) != 0 ) && ( !bWhiteSpaceOnly ) ) { - if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) ) + if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, static_cast<UINT>(m_pWritePtr - m_pWriteBuf), FALSE ) ) ) return E_ABORT; - bWhiteSpaceOnly = TRUE; } @@ -798,9 +797,10 @@ HRESULT XMLParser::MainParseLoop() if( m_Ch == '<' ) { - if( ( (UINT) ( m_pWritePtr - m_pWriteBuf ) != 0 ) && ( !bWhiteSpaceOnly ) ) +\ + if( ( static_cast<UINT>(m_pWritePtr - m_pWriteBuf) != 0 ) && ( !bWhiteSpaceOnly ) ) { - if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) ) + if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, static_cast<UINT>(m_pWritePtr - m_pWriteBuf), FALSE ) ) ) return E_ABORT; bWhiteSpaceOnly = TRUE; @@ -838,8 +838,7 @@ HRESULT XMLParser::MainParseLoop() if( !bWhiteSpaceOnly ) { if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, - ( UINT ) ( m_pWritePtr - m_pWriteBuf ), - TRUE ) ) ) + static_cast<UINT>(m_pWritePtr - m_pWriteBuf), TRUE ) ) ) { return E_ABORT; } @@ -861,7 +860,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) { HRESULT hr; - if( m_pISAXCallback == NULL ) + if( m_pISAXCallback == nullptr ) return E_NOINTERFACE; m_pISAXCallback->m_LineNum = 1; @@ -872,16 +871,17 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) m_pReadPtr = m_pReadBuf; m_pReadBuf[ 0 ] = '\0'; + m_pReadBuf[ 1 ] = '\0'; - m_pInXMLBuffer = NULL; + m_pInXMLBuffer = nullptr; m_uInXMLBufferCharsLeft = 0; WCHAR wchFilename[ 64 ]; swprintf_s(wchFilename,64,L"%s",strFilename); - m_hFile = CreateFile( wchFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL ); + m_hFile = CreateFile(wchFilename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, nullptr); if( m_hFile == INVALID_HANDLE_VALUE ) { @@ -893,7 +893,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) { LARGE_INTEGER iFileSize; GetFileSizeEx( m_hFile, &iFileSize ); - m_dwCharsTotal = (DWORD)iFileSize.QuadPart; + m_dwCharsTotal = static_cast<DWORD>(iFileSize.QuadPart); m_dwCharsConsumed = 0; hr = MainParseLoop(); } @@ -904,8 +904,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) m_hFile = INVALID_HANDLE_VALUE; // we no longer own strFilename, so un-set it - m_pISAXCallback->m_strFilename = NULL; - + m_pISAXCallback->m_strFilename = nullptr; return hr; } @@ -917,7 +916,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize ) { HRESULT hr; - if( m_pISAXCallback == NULL ) + if( m_pISAXCallback == nullptr ) return E_NOINTERFACE; m_pISAXCallback->m_LineNum = 1; @@ -930,7 +929,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize ) m_pReadBuf[ 0 ] = '\0'; m_pReadBuf[ 1 ] = '\0'; - m_hFile = NULL; + m_hFile = nullptr; m_pInXMLBuffer = strBuffer; m_uInXMLBufferCharsLeft = uBufferSize; m_dwCharsTotal = uBufferSize; @@ -939,7 +938,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize ) hr = MainParseLoop(); // we no longer own strFilename, so un-set it - m_pISAXCallback->m_strFilename = NULL; + m_pISAXCallback->m_strFilename = nullptr; return hr; } diff --git a/Minecraft.Client/Durango/XML/ATGXmlParser.h b/Minecraft.Client/Durango/XML/ATGXmlParser.h index 75142e3e..12f59737 100644 --- a/Minecraft.Client/Durango/XML/ATGXmlParser.h +++ b/Minecraft.Client/Durango/XML/ATGXmlParser.h @@ -138,7 +138,7 @@ private: DWORD m_dwCharsTotal; DWORD m_dwCharsConsumed; - BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing NULL + BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing nullptr WCHAR m_pWriteBuf[ XML_WRITE_BUFFER_SIZE ]; BYTE* m_pReadPtr; diff --git a/Minecraft.Client/Durango/XML/xmlFilesCallback.h b/Minecraft.Client/Durango/XML/xmlFilesCallback.h index deba843d..16149340 100644 --- a/Minecraft.Client/Durango/XML/xmlFilesCallback.h +++ b/Minecraft.Client/Durango/XML/xmlFilesCallback.h @@ -47,7 +47,7 @@ public: { ZeroMemory(wTemp,sizeof(WCHAR)*35); wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); - xuid=_wcstoui64(wTemp,NULL,10); + xuid=_wcstoui64(wTemp,nullptr,10); } } else if (_wcsicmp(wAttName,L"cape")==0) @@ -138,7 +138,7 @@ public: #ifdef _XBOX iValue=_wtoi(wValue); #else - iValue=wcstol(wValue, NULL, 10); + iValue=wcstol(wValue, nullptr, 10); #endif } } @@ -220,7 +220,7 @@ public: { ZeroMemory(wTemp,sizeof(WCHAR)*35); wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); - uiSortIndex=wcstoul(wTemp,NULL,10); + uiSortIndex=wcstoul(wTemp,nullptr,10); } } else if (_wcsicmp(wAttName,L"Banner")==0) @@ -269,7 +269,7 @@ public: #ifdef _XBOX iConfig=_wtoi(wConfig); #else - iConfig=wcstol(wConfig, NULL, 10); + iConfig=wcstol(wConfig, nullptr, 10); #endif } } |
