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/TexturePackRepository.cpp | |
| 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/TexturePackRepository.cpp')
| -rw-r--r-- | Minecraft.Client/TexturePackRepository.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/Minecraft.Client/TexturePackRepository.cpp b/Minecraft.Client/TexturePackRepository.cpp index 6bb3cccc..ef926d78 100644 --- a/Minecraft.Client/TexturePackRepository.cpp +++ b/Minecraft.Client/TexturePackRepository.cpp @@ -8,8 +8,9 @@ #include "..\Minecraft.World\File.h" #include "..\Minecraft.World\StringHelpers.h" #include "Minimap.h" +#include "Common/UI/UI.h" -TexturePack *TexturePackRepository::DEFAULT_TEXTURE_PACK = NULL; +TexturePack *TexturePackRepository::DEFAULT_TEXTURE_PACK = nullptr; TexturePackRepository::TexturePackRepository(File workingDirectory, Minecraft *minecraft) { @@ -17,7 +18,7 @@ TexturePackRepository::TexturePackRepository(File workingDirectory, Minecraft *m // 4J - added usingWeb = false; - selected = NULL; + selected = nullptr; texturePacks = new vector<TexturePack *>; this->minecraft = minecraft; @@ -28,9 +29,9 @@ TexturePackRepository::TexturePackRepository(File workingDirectory, Minecraft *m DEFAULT_TEXTURE_PACK->loadColourTable(); - m_dummyTexturePack = NULL; - m_dummyDLCTexturePack = NULL; - lastSelected = NULL; + m_dummyTexturePack = nullptr; + m_dummyDLCTexturePack = nullptr; + lastSelected = nullptr; updateList(); } @@ -49,13 +50,13 @@ void TexturePackRepository::addDebugPacks() { DLCPack *pack = app.m_dlcManager.getPack(L"DLCTestPack"); - if( pack != NULL && pack->IsCorrupt() ) + if( pack != nullptr && pack->IsCorrupt() ) { app.m_dlcManager.removePack(pack); - pack = NULL; + pack = nullptr; } - if(pack == NULL) + if(pack == nullptr) { wprintf(L"Pack \"%ls\" is not installed, so adding it\n", L"DLCTestPack"); pack = new DLCPack(L"DLCTestPack",0xffffffff); @@ -164,7 +165,7 @@ void TexturePackRepository::updateList() currentPacks->push_back(m_dummyTexturePack); cacheById[m_dummyTexturePack->getId()] = m_dummyTexturePack; - if(m_dummyDLCTexturePack != NULL) + if(m_dummyDLCTexturePack != nullptr) { currentPacks->push_back(m_dummyDLCTexturePack); cacheById[m_dummyDLCTexturePack->getId()] = m_dummyDLCTexturePack; @@ -227,7 +228,7 @@ wstring TexturePackRepository::getIdOrNull(File file) return file.getName() + ":folder:" + file.lastModified(); } - return NULL; + return nullptr; #endif return L""; } @@ -357,17 +358,17 @@ TexturePack *TexturePackRepository::getTexturePackById(DWORD id) return it->second; } - return NULL; + return nullptr; } TexturePack *TexturePackRepository::addTexturePackFromDLC(DLCPack *dlcPack, DWORD id) { - TexturePack *newPack = NULL; + TexturePack *newPack = nullptr; // 4J-PB - The City texture pack went out with a child id for the texture pack of 1 instead of zero // we need to mask off the child id here to deal with this DWORD dwParentID=id&0xFFFFFF; // child id is <<24 and Or'd with parent - if(dlcPack != NULL) + if(dlcPack != nullptr) { newPack = new DLCTexturePack(dwParentID, dlcPack, DEFAULT_TEXTURE_PACK); texturePacks->push_back(newPack); @@ -408,7 +409,7 @@ void TexturePackRepository::removeTexturePackById(DWORD id) texturePacks->erase(it2); if(lastSelected == oldPack) { - lastSelected = NULL; + lastSelected = nullptr; } } m_texturePacksToDelete.push_back(oldPack); @@ -417,19 +418,19 @@ void TexturePackRepository::removeTexturePackById(DWORD id) void TexturePackRepository::updateUI() { - if(lastSelected != NULL && lastSelected != selected) + if(lastSelected != nullptr && lastSelected != selected) { lastSelected->unloadUI(); selected->loadUI(); Minimap::reloadColours(); ui.StartReloadSkinThread(); - lastSelected = NULL; + lastSelected = nullptr; } } bool TexturePackRepository::needsUIUpdate() { - return lastSelected != NULL && lastSelected != selected; + return lastSelected != nullptr && lastSelected != selected; } unsigned int TexturePackRepository::getTexturePackCount() @@ -439,7 +440,7 @@ unsigned int TexturePackRepository::getTexturePackCount() TexturePack *TexturePackRepository::getTexturePackByIndex(unsigned int index) { - TexturePack *pack = NULL; + TexturePack *pack = nullptr; if(index < texturePacks->size()) { pack = texturePacks->at(index); |
