From a9be52c41a02d207233199e98898fe7483d7e817 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sat, 7 Mar 2026 21:56:03 -0500 Subject: Project modernization (#630) * Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides --- Minecraft.Client/Common/DLC/DLCAudioFile.cpp | 18 ++-- Minecraft.Client/Common/DLC/DLCAudioFile.h | 10 +- Minecraft.Client/Common/DLC/DLCCapeFile.h | 2 +- Minecraft.Client/Common/DLC/DLCColourTableFile.cpp | 4 +- Minecraft.Client/Common/DLC/DLCColourTableFile.h | 6 +- Minecraft.Client/Common/DLC/DLCFile.h | 6 +- Minecraft.Client/Common/DLC/DLCGameRulesFile.cpp | 2 +- Minecraft.Client/Common/DLC/DLCGameRulesFile.h | 4 +- Minecraft.Client/Common/DLC/DLCGameRulesHeader.cpp | 4 +- Minecraft.Client/Common/DLC/DLCGameRulesHeader.h | 55 +++++++---- .../Common/DLC/DLCLocalisationFile.cpp | 2 +- Minecraft.Client/Common/DLC/DLCLocalisationFile.h | 2 +- Minecraft.Client/Common/DLC/DLCManager.cpp | 101 +++++++++++---------- Minecraft.Client/Common/DLC/DLCPack.cpp | 46 +++++----- Minecraft.Client/Common/DLC/DLCPack.h | 4 +- Minecraft.Client/Common/DLC/DLCSkinFile.cpp | 6 +- Minecraft.Client/Common/DLC/DLCSkinFile.h | 8 +- Minecraft.Client/Common/DLC/DLCTextureFile.cpp | 2 +- Minecraft.Client/Common/DLC/DLCTextureFile.h | 10 +- Minecraft.Client/Common/DLC/DLCUIDataFile.cpp | 4 +- Minecraft.Client/Common/DLC/DLCUIDataFile.h | 4 +- 21 files changed, 162 insertions(+), 138 deletions(-) (limited to 'Minecraft.Client/Common/DLC') diff --git a/Minecraft.Client/Common/DLC/DLCAudioFile.cpp b/Minecraft.Client/Common/DLC/DLCAudioFile.cpp index 7116f62d..ee0cb7a7 100644 --- a/Minecraft.Client/Common/DLC/DLCAudioFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCAudioFile.cpp @@ -8,7 +8,7 @@ DLCAudioFile::DLCAudioFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_Audio,path) { - m_pbData = NULL; + m_pbData = nullptr; m_dwBytes = 0; } @@ -40,7 +40,7 @@ DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(const wstring & { if(paramName.compare(wchTypeNamesA[i]) == 0) { - type = (EAudioParameterType)i; + type = static_cast(i); break; } } @@ -87,7 +87,7 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype, cons { i++; } - int iLast=(int)creditValue.find_last_of(L" ",i); + size_t iLast=creditValue.find_last_of(L" ", i); switch(XGetLanguage()) { case XC_LANGUAGE_JAPANESE: @@ -96,7 +96,7 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype, cons iLast = maximumChars; break; default: - iLast=(int)creditValue.find_last_of(L" ",i); + iLast=creditValue.find_last_of(L" ", i); break; } @@ -133,7 +133,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) if(uiVersion < CURRENT_AUDIO_VERSION_NUM) { - if(pbData!=NULL) delete [] pbData; + if(pbData!=nullptr) delete [] pbData; app.DebugPrintf("DLC version of %d is too old to be read\n", uiVersion); return false; } @@ -145,7 +145,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) for(unsigned int i=0;iwchData); + wstring parameterName(static_cast(pParams->wchData)); EAudioParameterType type = getParameterType(parameterName); if( type != e_AudioParamType_Invalid ) { @@ -169,7 +169,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) for(unsigned int i=0;idwType; + EAudioType type = static_cast(pFile->dwType); // Params unsigned int uiParameterCount=*(unsigned int *)pbTemp; pbTemp+=sizeof(int); @@ -182,7 +182,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) if(it != parameterMapping.end() ) { - addParameter(type,(EAudioParameterType)pParams->dwType,(WCHAR *)pParams->wchData); + addParameter(type,static_cast(pParams->dwType),(WCHAR *)pParams->wchData); } pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount); pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp; @@ -198,7 +198,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) return true; } -int DLCAudioFile::GetCountofType(DLCAudioFile::EAudioType eType) +int DLCAudioFile::GetCountofType(EAudioType eType) { return m_parameters[eType].size(); } diff --git a/Minecraft.Client/Common/DLC/DLCAudioFile.h b/Minecraft.Client/Common/DLC/DLCAudioFile.h index f1a356fe..50131785 100644 --- a/Minecraft.Client/Common/DLC/DLCAudioFile.h +++ b/Minecraft.Client/Common/DLC/DLCAudioFile.h @@ -32,11 +32,11 @@ public: DLCAudioFile(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; + PBYTE getData(DWORD &dwBytes) override; bool processDLCDataFile(PBYTE pbData, DWORD dwLength); - int GetCountofType(DLCAudioFile::EAudioType ptype); + int GetCountofType(EAudioType ptype); wstring &GetSoundName(int iIndex); private: @@ -49,6 +49,6 @@ private: vector m_parameters[e_AudioType_Max]; // use the EAudioType to order these - void addParameter(DLCAudioFile::EAudioType type, DLCAudioFile::EAudioParameterType ptype, const wstring &value); - DLCAudioFile::EAudioParameterType getParameterType(const wstring ¶mName); + void addParameter(EAudioType type, EAudioParameterType ptype, const wstring &value); + EAudioParameterType getParameterType(const wstring ¶mName); }; diff --git a/Minecraft.Client/Common/DLC/DLCCapeFile.h b/Minecraft.Client/Common/DLC/DLCCapeFile.h index 8373d340..9e9466c6 100644 --- a/Minecraft.Client/Common/DLC/DLCCapeFile.h +++ b/Minecraft.Client/Common/DLC/DLCCapeFile.h @@ -6,5 +6,5 @@ class DLCCapeFile : public DLCFile public: DLCCapeFile(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCColourTableFile.cpp b/Minecraft.Client/Common/DLC/DLCColourTableFile.cpp index ec800dac..a0c818a7 100644 --- a/Minecraft.Client/Common/DLC/DLCColourTableFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCColourTableFile.cpp @@ -7,12 +7,12 @@ DLCColourTableFile::DLCColourTableFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_ColourTable,path) { - m_colourTable = NULL; + m_colourTable = nullptr; } DLCColourTableFile::~DLCColourTableFile() { - if(m_colourTable != NULL) + if(m_colourTable != nullptr) { app.DebugPrintf("Deleting DLCColourTableFile data\n"); delete m_colourTable; diff --git a/Minecraft.Client/Common/DLC/DLCColourTableFile.h b/Minecraft.Client/Common/DLC/DLCColourTableFile.h index 84269739..ded6f515 100644 --- a/Minecraft.Client/Common/DLC/DLCColourTableFile.h +++ b/Minecraft.Client/Common/DLC/DLCColourTableFile.h @@ -10,9 +10,9 @@ private: public: DLCColourTableFile(const wstring &path); - ~DLCColourTableFile(); + ~DLCColourTableFile() override; - virtual void addData(PBYTE pbData, DWORD dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; - ColourTable *getColourTable() { return m_colourTable; } + ColourTable *getColourTable() const { return m_colourTable; } }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCFile.h b/Minecraft.Client/Common/DLC/DLCFile.h index 3a40dbc7..31b638ef 100644 --- a/Minecraft.Client/Common/DLC/DLCFile.h +++ b/Minecraft.Client/Common/DLC/DLCFile.h @@ -12,12 +12,12 @@ public: DLCFile(DLCManager::EDLCType type, const wstring &path); virtual ~DLCFile() {} - DLCManager::EDLCType getType() { return m_type; } + DLCManager::EDLCType getType() const { return m_type; } wstring getPath() { return m_path; } - DWORD getSkinID() { return m_dwSkinId; } + DWORD getSkinID() const { return m_dwSkinId; } virtual void addData(PBYTE pbData, DWORD dwBytes) {} - virtual PBYTE getData(DWORD &dwBytes) { dwBytes = 0; return NULL; } + virtual PBYTE getData(DWORD &dwBytes) { dwBytes = 0; return nullptr; } virtual void addParameter(DLCManager::EDLCParameterType type, const wstring &value) {} virtual wstring getParameterAsString(DLCManager::EDLCParameterType type) { return L""; } diff --git a/Minecraft.Client/Common/DLC/DLCGameRulesFile.cpp b/Minecraft.Client/Common/DLC/DLCGameRulesFile.cpp index 8ca520d6..d84e2a60 100644 --- a/Minecraft.Client/Common/DLC/DLCGameRulesFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCGameRulesFile.cpp @@ -4,7 +4,7 @@ DLCGameRulesFile::DLCGameRulesFile(const wstring &path) : DLCGameRules(DLCManager::e_DLCType_GameRules,path) { - m_pbData = NULL; + m_pbData = nullptr; m_dwBytes = 0; } diff --git a/Minecraft.Client/Common/DLC/DLCGameRulesFile.h b/Minecraft.Client/Common/DLC/DLCGameRulesFile.h index e6456d73..671cab6a 100644 --- a/Minecraft.Client/Common/DLC/DLCGameRulesFile.h +++ b/Minecraft.Client/Common/DLC/DLCGameRulesFile.h @@ -10,6 +10,6 @@ private: public: DLCGameRulesFile(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; + PBYTE getData(DWORD &dwBytes) override; }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCGameRulesHeader.cpp b/Minecraft.Client/Common/DLC/DLCGameRulesHeader.cpp index 39b85219..2b785998 100644 --- a/Minecraft.Client/Common/DLC/DLCGameRulesHeader.cpp +++ b/Minecraft.Client/Common/DLC/DLCGameRulesHeader.cpp @@ -11,14 +11,14 @@ DLCGameRulesHeader::DLCGameRulesHeader(const wstring &path) : DLCGameRules(DLCManager::e_DLCType_GameRulesHeader,path) { - m_pbData = NULL; + m_pbData = nullptr; m_dwBytes = 0; m_hasData = false; m_grfPath = path.substr(0, path.length() - 4) + L".grf"; - lgo = NULL; + lgo = nullptr; } void DLCGameRulesHeader::addData(PBYTE pbData, DWORD dwBytes) diff --git a/Minecraft.Client/Common/DLC/DLCGameRulesHeader.h b/Minecraft.Client/Common/DLC/DLCGameRulesHeader.h index 4521ae11..7409540d 100644 --- a/Minecraft.Client/Common/DLC/DLCGameRulesHeader.h +++ b/Minecraft.Client/Common/DLC/DLCGameRulesHeader.h @@ -14,29 +14,52 @@ private: bool m_hasData; public: - virtual bool requiresTexturePack() {return m_bRequiresTexturePack;} - virtual UINT getRequiredTexturePackId() {return m_requiredTexturePackId;} - virtual wstring getDefaultSaveName() {return m_defaultSaveName;} - virtual LPCWSTR getWorldName() {return m_worldName.c_str();} - virtual LPCWSTR getDisplayName() {return m_displayName.c_str();} - virtual wstring getGrfPath() {return L"GameRules.grf";} - - virtual void setRequiresTexturePack(bool x) {m_bRequiresTexturePack = x;} - virtual void setRequiredTexturePackId(UINT x) {m_requiredTexturePackId = x;} - virtual void setDefaultSaveName(const wstring &x) {m_defaultSaveName = x;} - virtual void setWorldName(const wstring & x) {m_worldName = x;} - virtual void setDisplayName(const wstring & x) {m_displayName = x;} - virtual void setGrfPath(const wstring & x) {m_grfPath = x;} + bool requiresTexturePack() override + {return m_bRequiresTexturePack;} + + UINT getRequiredTexturePackId() override + {return m_requiredTexturePackId;} + + wstring getDefaultSaveName() override + {return m_defaultSaveName;} + + LPCWSTR getWorldName() override + {return m_worldName.c_str();} + + LPCWSTR getDisplayName() override + {return m_displayName.c_str();} + + wstring getGrfPath() override + {return L"GameRules.grf";} + + void setRequiresTexturePack(bool x) override + {m_bRequiresTexturePack = x;} + + void setRequiredTexturePackId(UINT x) override + {m_requiredTexturePackId = x;} + + void setDefaultSaveName(const wstring &x) override + {m_defaultSaveName = x;} + + void setWorldName(const wstring & x) override + {m_worldName = x;} + + void setDisplayName(const wstring & x) override + {m_displayName = x;} + + void setGrfPath(const wstring & x) override + {m_grfPath = x;} LevelGenerationOptions *lgo; public: DLCGameRulesHeader(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; + PBYTE getData(DWORD &dwBytes) override; void setGrfData(PBYTE fData, DWORD fSize, StringTable *); - virtual bool ready() { return m_hasData; } + bool ready() override + { return m_hasData; } }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCLocalisationFile.cpp b/Minecraft.Client/Common/DLC/DLCLocalisationFile.cpp index 358a93e5..90921434 100644 --- a/Minecraft.Client/Common/DLC/DLCLocalisationFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCLocalisationFile.cpp @@ -5,7 +5,7 @@ DLCLocalisationFile::DLCLocalisationFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_LocalisationData,path) { - m_strings = NULL; + m_strings = nullptr; } void DLCLocalisationFile::addData(PBYTE pbData, DWORD dwBytes) diff --git a/Minecraft.Client/Common/DLC/DLCLocalisationFile.h b/Minecraft.Client/Common/DLC/DLCLocalisationFile.h index 083e60d8..419d714d 100644 --- a/Minecraft.Client/Common/DLC/DLCLocalisationFile.h +++ b/Minecraft.Client/Common/DLC/DLCLocalisationFile.h @@ -12,7 +12,7 @@ public: DLCLocalisationFile(const wstring &path); DLCLocalisationFile(PBYTE pbData, DWORD dwBytes); // when we load in a texture pack details file from TMS++ - virtual void addData(PBYTE pbData, DWORD dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; StringTable *getStringTable() { return m_strings; } }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCManager.cpp b/Minecraft.Client/Common/DLC/DLCManager.cpp index dd34e67f..931b0e1d 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Common/DLC/DLCManager.cpp @@ -6,6 +6,7 @@ #include "..\..\..\Minecraft.World\StringHelpers.h" #include "..\..\Minecraft.h" #include "..\..\TexturePackRepository.h" +#include "Common/UI/UI.h" const WCHAR *DLCManager::wchTypeNamesA[]= { @@ -47,7 +48,7 @@ DLCManager::EDLCParameterType DLCManager::getParameterType(const wstring ¶mN { if(paramName.compare(wchTypeNamesA[i]) == 0) { - type = (EDLCParameterType)i; + type = static_cast(i); break; } } @@ -70,7 +71,7 @@ DWORD DLCManager::getPackCount(EDLCType type /*= e_DLCType_All*/) } else { - packCount = (DWORD)m_packs.size(); + packCount = static_cast(m_packs.size()); } return packCount; } @@ -82,7 +83,7 @@ void DLCManager::addPack(DLCPack *pack) void DLCManager::removePack(DLCPack *pack) { - if(pack != NULL) + if(pack != nullptr) { auto it = find(m_packs.begin(), m_packs.end(), pack); if(it != m_packs.end() ) m_packs.erase(it); @@ -112,7 +113,7 @@ void DLCManager::LanguageChanged(void) DLCPack *DLCManager::getPack(const wstring &name) { - DLCPack *pack = NULL; + DLCPack *pack = nullptr; //DWORD currentIndex = 0; for( DLCPack * currentPack : m_packs ) { @@ -130,7 +131,7 @@ DLCPack *DLCManager::getPack(const wstring &name) #ifdef _XBOX_ONE DLCPack *DLCManager::getPackFromProductID(const wstring &productID) { - DLCPack *pack = NULL; + DLCPack *pack = nullptr; for( DLCPack *currentPack : m_packs ) { wstring wsName=currentPack->getPurchaseOfferId(); @@ -147,7 +148,7 @@ DLCPack *DLCManager::getPackFromProductID(const wstring &productID) DLCPack *DLCManager::getPack(DWORD index, EDLCType type /*= e_DLCType_All*/) { - DLCPack *pack = NULL; + DLCPack *pack = nullptr; if( type != e_DLCType_All ) { DWORD currentIndex = 0; @@ -181,9 +182,9 @@ DWORD DLCManager::getPackIndex(DLCPack *pack, bool &found, EDLCType type /*= e_D { DWORD foundIndex = 0; found = false; - if(pack == NULL) + if(pack == nullptr) { - app.DebugPrintf("DLCManager: Attempting to find the index for a NULL pack\n"); + app.DebugPrintf("DLCManager: Attempting to find the index for a nullptr pack\n"); //__debugbreak(); return foundIndex; } @@ -244,7 +245,7 @@ DWORD DLCManager::getPackIndexContainingSkin(const wstring &path, bool &found) DLCPack *DLCManager::getPackContainingSkin(const wstring &path) { - DLCPack *foundPack = NULL; + DLCPack *foundPack = nullptr; for( DLCPack *pack : m_packs ) { if(pack->getDLCItemsCount(e_DLCType_Skin)>0) @@ -261,11 +262,11 @@ DLCPack *DLCManager::getPackContainingSkin(const wstring &path) DLCSkinFile *DLCManager::getSkinFile(const wstring &path) { - DLCSkinFile *foundSkinfile = NULL; + DLCSkinFile *foundSkinfile = nullptr; for( DLCPack *pack : m_packs ) { foundSkinfile=pack->getSkinFile(path); - if(foundSkinfile!=NULL) + if(foundSkinfile!=nullptr) { break; } @@ -276,14 +277,14 @@ DLCSkinFile *DLCManager::getSkinFile(const wstring &path) DWORD DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/) { DWORD corruptDLCCount = m_dwUnnamedCorruptDLCCount; - DLCPack *firstCorruptPack = NULL; + DLCPack *firstCorruptPack = nullptr; for( DLCPack *pack : m_packs ) { if( pack->IsCorrupt() ) { ++corruptDLCCount; - if(firstCorruptPack == NULL) firstCorruptPack = pack; + if(firstCorruptPack == nullptr) firstCorruptPack = pack; } } @@ -291,13 +292,13 @@ DWORD DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/) { UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - if(corruptDLCCount == 1 && firstCorruptPack != NULL) + if(corruptDLCCount == 1 && firstCorruptPack != nullptr) { // pass in the pack format string WCHAR wchFormat[132]; swprintf(wchFormat, 132, L"%ls\n\n%%ls", firstCorruptPack->getName().c_str()); - C4JStorage::EMessageResult result = ui.RequestErrorMessage( IDS_CORRUPT_DLC_TITLE, IDS_CORRUPT_DLC, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL,wchFormat); + C4JStorage::EMessageResult result = ui.RequestErrorMessage( IDS_CORRUPT_DLC_TITLE, IDS_CORRUPT_DLC, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr,wchFormat); } else @@ -330,13 +331,13 @@ bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const string &path, DL #ifdef _WINDOWS64 string finalPath = StorageManager.GetMountedPath(path.c_str()); if(finalPath.size() == 0) finalPath = path; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #elif defined(_DURANGO) wstring finalPath = StorageManager.GetMountedPath(wPath.c_str()); if(finalPath.size() == 0) finalPath = wPath; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #else - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if( file == INVALID_HANDLE_VALUE ) { @@ -347,9 +348,9 @@ bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const string &path, DL return false; } - DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); + DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr); PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { // need to treat the file as corrupt, and flag it, so can't call fatal error @@ -372,7 +373,7 @@ bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const string &path, DL bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD dwLength, DLCPack *pack) { - unordered_map parameterMapping; + unordered_map parameterMapping; unsigned int uiCurrentByte=0; // File format defined in the DLC_Creator @@ -391,7 +392,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD if(uiVersion < CURRENT_DLC_VERSION_NUM) { - if(pbData!=NULL) delete [] pbData; + if(pbData!=nullptr) delete [] pbData; app.DebugPrintf("DLC version of %d is too old to be read\n", uiVersion); return false; } @@ -403,9 +404,9 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD for(unsigned int i=0;iwchData); - DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName); - if( type != DLCManager::e_DLCParamType_Invalid ) + wstring parameterName(static_cast(pParams->wchData)); + EDLCParameterType type = getParameterType(parameterName); + if( type != e_DLCParamType_Invalid ) { parameterMapping[pParams->dwType] = type; } @@ -429,10 +430,10 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD for(unsigned int i=0;idwType; + EDLCType type = static_cast(pFile->dwType); - DLCFile *dlcFile = NULL; - DLCPack *dlcTexturePack = NULL; + DLCFile *dlcFile = nullptr; + DLCPack *dlcTexturePack = nullptr; if(type == e_DLCType_TexturePack) { @@ -461,8 +462,8 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD } else { - if(dlcFile != NULL) dlcFile->addParameter(it->second,(WCHAR *)pParams->wchData); - else if(dlcTexturePack != NULL) dlcTexturePack->addParameter(it->second, (WCHAR *)pParams->wchData); + if(dlcFile != nullptr) dlcFile->addParameter(it->second,(WCHAR *)pParams->wchData); + else if(dlcTexturePack != nullptr) dlcTexturePack->addParameter(it->second, (WCHAR *)pParams->wchData); } } pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount); @@ -470,28 +471,28 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD } //pbTemp+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM); - if(dlcTexturePack != NULL) + if(dlcTexturePack != nullptr) { DWORD texturePackFilesProcessed = 0; bool validPack = processDLCDataFile(texturePackFilesProcessed,pbTemp,pFile->uiFileSize,dlcTexturePack); - pack->SetDataPointer(NULL); // If it's a child pack, it doesn't own the data + pack->SetDataPointer(nullptr); // If it's a child pack, it doesn't own the data if(!validPack || texturePackFilesProcessed == 0) { delete dlcTexturePack; - dlcTexturePack = NULL; + dlcTexturePack = nullptr; } else { pack->addChildPack(dlcTexturePack); - if(dlcTexturePack->getDLCItemsCount(DLCManager::e_DLCType_Texture) > 0) + if(dlcTexturePack->getDLCItemsCount(e_DLCType_Texture) > 0) { Minecraft::GetInstance()->skins->addTexturePackFromDLC(dlcTexturePack, dlcTexturePack->GetPackId() ); } } ++dwFilesProcessed; } - else if(dlcFile != NULL) + else if(dlcFile != nullptr) { // Data dlcFile->addData(pbTemp,pFile->uiFileSize); @@ -499,7 +500,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD // TODO - 4J Stu Remove the need for this vSkinNames vector, or manage it differently switch(pFile->dwType) { - case DLCManager::e_DLCType_Skin: + case e_DLCType_Skin: app.vSkinNames.push_back((WCHAR *)pFile->wchFile); break; } @@ -514,13 +515,13 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; } - if( pack->getDLCItemsCount(DLCManager::e_DLCType_GameRules) > 0 - || pack->getDLCItemsCount(DLCManager::e_DLCType_GameRulesHeader) > 0) + if( pack->getDLCItemsCount(e_DLCType_GameRules) > 0 + || pack->getDLCItemsCount(e_DLCType_GameRulesHeader) > 0) { app.m_gameRules.loadGameRules(pack); } - if(pack->getDLCItemsCount(DLCManager::e_DLCType_Audio) > 0) + if(pack->getDLCItemsCount(e_DLCType_Audio) > 0) { //app.m_Audio.loadAudioDetails(pack); } @@ -537,22 +538,22 @@ DWORD DLCManager::retrievePackIDFromDLCDataFile(const string &path, DLCPack *pac #ifdef _WINDOWS64 string finalPath = StorageManager.GetMountedPath(path.c_str()); if(finalPath.size() == 0) finalPath = path; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #elif defined(_DURANGO) wstring finalPath = StorageManager.GetMountedPath(wPath.c_str()); if(finalPath.size() == 0) finalPath = wPath; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #else - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if( file == INVALID_HANDLE_VALUE ) { return 0; } - DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); + DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr); PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { // need to treat the file as corrupt, and flag it, so can't call fatal error @@ -579,7 +580,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) { DWORD packId=0; bool bPackIDSet=false; - unordered_map parameterMapping; + unordered_map parameterMapping; unsigned int uiCurrentByte=0; // File format defined in the DLC_Creator @@ -608,9 +609,9 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) for(unsigned int i=0;iwchData); - DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName); - if( type != DLCManager::e_DLCParamType_Invalid ) + wstring parameterName(static_cast(pParams->wchData)); + EDLCParameterType type = getParameterType(parameterName); + if( type != e_DLCParamType_Invalid ) { parameterMapping[pParams->dwType] = type; } @@ -633,7 +634,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) for(unsigned int i=0;idwType; + EDLCType type = static_cast(pFile->dwType); // Params uiParameterCount=*(unsigned int *)pbTemp; @@ -649,7 +650,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) { if(it->second==e_DLCParamType_PackId) { - wstring wsTemp=(WCHAR *)pParams->wchData; + wstring wsTemp=static_cast(pParams->wchData); std::wstringstream ss; // 4J Stu - numbered using decimal to make it easier for artists/people to number manually ss << std::dec << wsTemp.c_str(); diff --git a/Minecraft.Client/Common/DLC/DLCPack.cpp b/Minecraft.Client/Common/DLC/DLCPack.cpp index ea8a270f..110008c6 100644 --- a/Minecraft.Client/Common/DLC/DLCPack.cpp +++ b/Minecraft.Client/Common/DLC/DLCPack.cpp @@ -24,14 +24,14 @@ DLCPack::DLCPack(const wstring &name,DWORD dwLicenseMask) m_isCorrupt = false; m_packId = 0; m_packVersion = 0; - m_parentPack = NULL; + m_parentPack = nullptr; m_dlcMountIndex = -1; #ifdef _XBOX m_dlcDeviceID = XCONTENTDEVICE_ANY; #endif // This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children. - m_data = NULL; + m_data = nullptr; } #ifdef _XBOX_ONE @@ -44,11 +44,11 @@ DLCPack::DLCPack(const wstring &name,const wstring &productID,DWORD dwLicenseMas m_isCorrupt = false; m_packId = 0; m_packVersion = 0; - m_parentPack = NULL; + m_parentPack = nullptr; m_dlcMountIndex = -1; // This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children. - m_data = NULL; + m_data = nullptr; } #endif @@ -76,7 +76,7 @@ DLCPack::~DLCPack() wprintf(L"Deleting data for DLC pack %ls\n", m_packName.c_str()); #endif // For the same reason, don't delete data pointer for any child pack as it just points to a region within the parent pack that has already been freed - if( m_parentPack == NULL ) + if( m_parentPack == nullptr ) { delete [] m_data; } @@ -85,7 +85,7 @@ DLCPack::~DLCPack() DWORD DLCPack::GetDLCMountIndex() { - if(m_parentPack != NULL) + if(m_parentPack != nullptr) { return m_parentPack->GetDLCMountIndex(); } @@ -94,7 +94,7 @@ DWORD DLCPack::GetDLCMountIndex() XCONTENTDEVICEID DLCPack::GetDLCDeviceID() { - if(m_parentPack != NULL ) + if(m_parentPack != nullptr ) { return m_parentPack->GetDLCDeviceID(); } @@ -156,7 +156,7 @@ void DLCPack::addParameter(DLCManager::EDLCParameterType type, const wstring &va m_dataPath = value; break; default: - m_parameters[(int)type] = value; + m_parameters[static_cast(type)] = value; break; } } @@ -187,7 +187,7 @@ bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type, unsigned in DLCFile *DLCPack::addFile(DLCManager::EDLCType type, const wstring &path) { - DLCFile *newFile = NULL; + DLCFile *newFile = nullptr; switch(type) { @@ -243,7 +243,7 @@ DLCFile *DLCPack::addFile(DLCManager::EDLCType type, const wstring &path) break; }; - if( newFile != NULL ) + if( newFile != nullptr ) { m_files[newFile->getType()].push_back(newFile); } @@ -252,7 +252,7 @@ DLCFile *DLCPack::addFile(DLCManager::EDLCType type, const wstring &path) } // MGH - added this comp func, as the embedded func in find_if was confusing the PS3 compiler -static const wstring *g_pathCmpString = NULL; +static const wstring *g_pathCmpString = nullptr; static bool pathCmp(DLCFile *val) { return (g_pathCmpString->compare(val->getPath()) == 0); @@ -263,7 +263,7 @@ bool DLCPack::doesPackContainFile(DLCManager::EDLCType type, const wstring &path bool hasFile = false; if(type == DLCManager::e_DLCType_All) { - for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1)) + for(DLCManager::EDLCType currentType = static_cast(0); currentType < DLCManager::e_DLCType_Max; currentType = static_cast(currentType + 1)) { hasFile = doesPackContainFile(currentType,path); if(hasFile) break; @@ -284,13 +284,13 @@ bool DLCPack::doesPackContainFile(DLCManager::EDLCType type, const wstring &path DLCFile *DLCPack::getFile(DLCManager::EDLCType type, DWORD index) { - DLCFile *file = NULL; + DLCFile *file = nullptr; if(type == DLCManager::e_DLCType_All) { - for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1)) + for(DLCManager::EDLCType currentType = static_cast(0); currentType < DLCManager::e_DLCType_Max; currentType = static_cast(currentType + 1)) { file = getFile(currentType,index); - if(file != NULL) break; + if(file != nullptr) break; } } else @@ -306,13 +306,13 @@ DLCFile *DLCPack::getFile(DLCManager::EDLCType type, DWORD index) DLCFile *DLCPack::getFile(DLCManager::EDLCType type, const wstring &path) { - DLCFile *file = NULL; + DLCFile *file = nullptr; if(type == DLCManager::e_DLCType_All) { - for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1)) + for(DLCManager::EDLCType currentType = static_cast(0); currentType < DLCManager::e_DLCType_Max; currentType = static_cast(currentType + 1)) { file = getFile(currentType,path); - if(file != NULL) break; + if(file != nullptr) break; } } else @@ -323,7 +323,7 @@ DLCFile *DLCPack::getFile(DLCManager::EDLCType type, const wstring &path) if(it == m_files[type].end()) { // Not found - file = NULL; + file = nullptr; } else { @@ -346,11 +346,11 @@ DWORD DLCPack::getDLCItemsCount(DLCManager::EDLCType type /*= DLCManager::e_DLCT case DLCManager::e_DLCType_All: for(int i = 0; i < DLCManager::e_DLCType_Max; ++i) { - count += getDLCItemsCount((DLCManager::EDLCType)i); + count += getDLCItemsCount(static_cast(i)); } break; default: - count = (DWORD)m_files[(int)type].size(); + count = static_cast(m_files[(int)type].size()); break; }; return count; @@ -420,12 +420,12 @@ void DLCPack::UpdateLanguage() { // find the language file DLCManager::e_DLCType_LocalisationData; - DLCFile *file = NULL; + DLCFile *file = nullptr; if(m_files[DLCManager::e_DLCType_LocalisationData].size() > 0) { file = m_files[DLCManager::e_DLCType_LocalisationData][0]; - DLCLocalisationFile *localisationFile = (DLCLocalisationFile *)getFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc"); + DLCLocalisationFile *localisationFile = static_cast(getFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc")); StringTable *strTable = localisationFile->getStringTable(); strTable->ReloadStringTable(); } diff --git a/Minecraft.Client/Common/DLC/DLCPack.h b/Minecraft.Client/Common/DLC/DLCPack.h index df1f65f0..14129cbe 100644 --- a/Minecraft.Client/Common/DLC/DLCPack.h +++ b/Minecraft.Client/Common/DLC/DLCPack.h @@ -87,8 +87,8 @@ public: DWORD getSkinCount() { return getDLCItemsCount(DLCManager::e_DLCType_Skin); } DWORD getSkinIndexAt(const wstring &path, bool &found) { return getFileIndexAt(DLCManager::e_DLCType_Skin, path, found); } - DLCSkinFile *getSkinFile(const wstring &path) { return (DLCSkinFile *)getFile(DLCManager::e_DLCType_Skin, path); } - DLCSkinFile *getSkinFile(DWORD index) { return (DLCSkinFile *)getFile(DLCManager::e_DLCType_Skin, index); } + DLCSkinFile *getSkinFile(const wstring &path) { return static_cast(getFile(DLCManager::e_DLCType_Skin, path)); } + DLCSkinFile *getSkinFile(DWORD index) { return static_cast(getFile(DLCManager::e_DLCType_Skin, index)); } bool doesPackContainSkin(const wstring &path) { return doesPackContainFile(DLCManager::e_DLCType_Skin, path); } bool hasPurchasedFile(DLCManager::EDLCType type, const wstring &path); diff --git a/Minecraft.Client/Common/DLC/DLCSkinFile.cpp b/Minecraft.Client/Common/DLC/DLCSkinFile.cpp index c845acd9..f7ef2ad0 100644 --- a/Minecraft.Client/Common/DLC/DLCSkinFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCSkinFile.cpp @@ -79,7 +79,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring { i++; } - int iLast=(int)creditValue.find_last_of(L" ",i); + size_t iLast=creditValue.find_last_of(L" ", i); switch(XGetLanguage()) { case XC_LANGUAGE_JAPANESE: @@ -88,7 +88,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring iLast = maximumChars; break; default: - iLast=(int)creditValue.find_last_of(L" ",i); + iLast=creditValue.find_last_of(L" ", i); break; } @@ -178,7 +178,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring int DLCSkinFile::getAdditionalBoxesCount() { - return (int)m_AdditionalBoxes.size(); + return static_cast(m_AdditionalBoxes.size()); } vector *DLCSkinFile::getAdditionalBoxes() { diff --git a/Minecraft.Client/Common/DLC/DLCSkinFile.h b/Minecraft.Client/Common/DLC/DLCSkinFile.h index c8dcf0e9..15a50e71 100644 --- a/Minecraft.Client/Common/DLC/DLCSkinFile.h +++ b/Minecraft.Client/Common/DLC/DLCSkinFile.h @@ -17,11 +17,11 @@ public: DLCSkinFile(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual void addParameter(DLCManager::EDLCParameterType type, const wstring &value); + void addData(PBYTE pbData, DWORD dwBytes) override; + void addParameter(DLCManager::EDLCParameterType type, const wstring &value) override; - virtual wstring getParameterAsString(DLCManager::EDLCParameterType type); - virtual bool getParameterAsBool(DLCManager::EDLCParameterType type); + wstring getParameterAsString(DLCManager::EDLCParameterType type) override; + bool getParameterAsBool(DLCManager::EDLCParameterType type) override; vector *getAdditionalBoxes(); int getAdditionalBoxesCount(); unsigned int getAnimOverrideBitmask() { return m_uiAnimOverrideBitmask;} diff --git a/Minecraft.Client/Common/DLC/DLCTextureFile.cpp b/Minecraft.Client/Common/DLC/DLCTextureFile.cpp index edf071c6..fb9c5b03 100644 --- a/Minecraft.Client/Common/DLC/DLCTextureFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCTextureFile.cpp @@ -7,7 +7,7 @@ DLCTextureFile::DLCTextureFile(const wstring &path) : DLCFile(DLCManager::e_DLCT m_bIsAnim = false; m_animString = L""; - m_pbData = NULL; + m_pbData = nullptr; m_dwBytes = 0; } diff --git a/Minecraft.Client/Common/DLC/DLCTextureFile.h b/Minecraft.Client/Common/DLC/DLCTextureFile.h index bc791686..2b397e8e 100644 --- a/Minecraft.Client/Common/DLC/DLCTextureFile.h +++ b/Minecraft.Client/Common/DLC/DLCTextureFile.h @@ -14,11 +14,11 @@ private: public: DLCTextureFile(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; + PBYTE getData(DWORD &dwBytes) override; - virtual void addParameter(DLCManager::EDLCParameterType type, const wstring &value); + void addParameter(DLCManager::EDLCParameterType type, const wstring &value) override; - virtual wstring getParameterAsString(DLCManager::EDLCParameterType type); - virtual bool getParameterAsBool(DLCManager::EDLCParameterType type); + wstring getParameterAsString(DLCManager::EDLCParameterType type) override; + bool getParameterAsBool(DLCManager::EDLCParameterType type) override; }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCUIDataFile.cpp b/Minecraft.Client/Common/DLC/DLCUIDataFile.cpp index a2a56bca..597c4b7b 100644 --- a/Minecraft.Client/Common/DLC/DLCUIDataFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCUIDataFile.cpp @@ -4,14 +4,14 @@ DLCUIDataFile::DLCUIDataFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_UIData,path) { - m_pbData = NULL; + m_pbData = nullptr; m_dwBytes = 0; m_canDeleteData = false; } DLCUIDataFile::~DLCUIDataFile() { - if(m_canDeleteData && m_pbData != NULL) + if(m_canDeleteData && m_pbData != nullptr) { app.DebugPrintf("Deleting DLCUIDataFile data\n"); delete [] m_pbData; diff --git a/Minecraft.Client/Common/DLC/DLCUIDataFile.h b/Minecraft.Client/Common/DLC/DLCUIDataFile.h index 105ad0df..c858933c 100644 --- a/Minecraft.Client/Common/DLC/DLCUIDataFile.h +++ b/Minecraft.Client/Common/DLC/DLCUIDataFile.h @@ -10,11 +10,11 @@ private: public: DLCUIDataFile(const wstring &path); - ~DLCUIDataFile(); + ~DLCUIDataFile() override; using DLCFile::addData; using DLCFile::addParameter; virtual void addData(PBYTE pbData, DWORD dwBytes,bool canDeleteData = false); - virtual PBYTE getData(DWORD &dwBytes); + PBYTE getData(DWORD &dwBytes) override; }; -- cgit v1.2.3