diff options
| author | Loki Rautio <lokirautio@gmail.com> | 2026-03-07 21:12:22 -0600 |
|---|---|---|
| committer | Loki Rautio <lokirautio@gmail.com> | 2026-03-07 21:12:22 -0600 |
| commit | 087b7e7abfe81dd7f0fdcdea36ac9f245950df1a (patch) | |
| tree | 69454763e73ca764af4e682d3573080b13138a0e /Minecraft.Client/Textures.cpp | |
| parent | a9be52c41a02d207233199e98898fe7483d7e817 (diff) | |
Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.
This reverts commit a9be52c41a02d207233199e98898fe7483d7e817.
Diffstat (limited to 'Minecraft.Client/Textures.cpp')
| -rw-r--r-- | Minecraft.Client/Textures.cpp | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/Minecraft.Client/Textures.cpp b/Minecraft.Client/Textures.cpp index f433dc5e..9a2e98a6 100644 --- a/Minecraft.Client/Textures.cpp +++ b/Minecraft.Client/Textures.cpp @@ -288,7 +288,7 @@ void Textures::loadIndexedTextures() // 4J - added - preload a set of commonly used textures that can then be referenced directly be an enumerated type rather by string for( int i = 0; i < TN_COUNT - 2; i++ ) { - preLoadedIdx[i] = loadTexture(static_cast<TEXTURE_NAME>(i), wstring(preLoaded[i]) + L".png"); + preLoadedIdx[i] = loadTexture((TEXTURE_NAME)i, wstring(preLoaded[i]) + L".png"); } } @@ -299,15 +299,15 @@ intArray Textures::loadTexturePixels(TEXTURE_NAME texId, const wstring& resource { intArray id = pixelsMap[resourceName]; // 4J - if resourceName isn't in the map, it should add an element and as that will use the default constructor, its - // internal data pointer will be nullptr - if (id.data != nullptr) return id; + // internal data pointer will be NULL + if (id.data != NULL) return id; } // 4J - removed try/catch // try { intArray res; //wstring in = skin->getResource(resourceName); - if (false)// 4J - removed - was ( in == nullptr) + if (false)// 4J - removed - was ( in == NULL) { res = loadTexturePixels(missingNo); } @@ -451,14 +451,14 @@ void Textures::bindTextureLayers(ResourceLocation *resource) for( int i = 0; i < layers; i++ ) { TEXTURE_NAME textureName = resource->getTexture(i); - if( textureName == static_cast<_TEXTURE_NAME>(-1) ) + if( textureName == (_TEXTURE_NAME)-1 ) { continue; } wstring resourceName = wstring(preLoaded[textureName]) + L".png"; BufferedImage *image = readImage(textureName, resourceName); - if( image == nullptr ) + if( image == NULL ) { continue; } @@ -500,10 +500,10 @@ void Textures::bindTextureLayers(ResourceLocation *resource) float srcFactor = srcAlpha / outAlpha; float dstFactor = (dstAlpha * (1.0f - srcAlpha)) / outAlpha; - int outA = static_cast<int>(outAlpha * 255.0f + 0.5f); - int outR = static_cast<int>((((src >> 16) & 0xff) * srcFactor) + (((dst >> 16) & 0xff) * dstFactor) + 0.5f); - int outG = static_cast<int>((((src >> 8) & 0xff) * srcFactor) + (((dst >> 8) & 0xff) * dstFactor) + 0.5f); - int outB = static_cast<int>(((src & 0xff) * srcFactor) + ((dst & 0xff) * dstFactor) + 0.5f); + int outA = (int)(outAlpha * 255.0f + 0.5f); + int outR = (int)((((src >> 16) & 0xff) * srcFactor) + (((dst >> 16) & 0xff) * dstFactor) + 0.5f); + int outG = (int)((((src >> 8) & 0xff) * srcFactor) + (((dst >> 8) & 0xff) * dstFactor) + 0.5f); + int outB = (int)(((src & 0xff) * srcFactor) + ((dst & 0xff) * dstFactor) + 0.5f); mergedPixels[p] = (outA << 24) | (outR << 16) | (outG << 8) | outB; } } @@ -618,7 +618,7 @@ int Textures::loadTexture(TEXTURE_NAME texId, const wstring& resourceName) if (clamp) pathName = resourceName.substr(7); //wstring in = skins->getSelected()->getResource(pathName); - if (false ) // 4J - removed was ( in == nullptr) + if (false ) // 4J - removed was ( in == NULL) { loadTexture(missingNo, id, blur, clamp); } @@ -711,7 +711,7 @@ void Textures::loadTexture(BufferedImage *img, int id, bool blur, bool clamp) intArray rawPixels(w*h); img->getRGB(0, 0, w, h, rawPixels, 0, w); - if (options != nullptr && options->anaglyph3d) + if (options != NULL && options->anaglyph3d) { rawPixels = anaglyph(rawPixels); } @@ -730,10 +730,10 @@ void Textures::loadTexture(BufferedImage *img, int id, bool blur, bool clamp) newPixels[i * 4 + 2] = (byte) g; newPixels[i * 4 + 3] = (byte) b; #else - newPixels[i * 4 + 0] = static_cast<byte>(r); - newPixels[i * 4 + 1] = static_cast<byte>(g); - newPixels[i * 4 + 2] = static_cast<byte>(b); - newPixels[i * 4 + 3] = static_cast<byte>(a); + newPixels[i * 4 + 0] = (byte) r; + newPixels[i * 4 + 1] = (byte) g; + newPixels[i * 4 + 2] = (byte) b; + newPixels[i * 4 + 3] = (byte) a; #endif } // 4J - now creating a buffer of the size we require dynamically @@ -877,7 +877,7 @@ void Textures::replaceTexture(intArray rawPixels, int w, int h, int id) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - if (options != nullptr && options->anaglyph3d) + if (options != NULL && options->anaglyph3d) { rawPixels = anaglyph(rawPixels); } @@ -890,7 +890,7 @@ void Textures::replaceTexture(intArray rawPixels, int w, int h, int id) int g = (rawPixels[i] >> 8) & 0xff; int b = (rawPixels[i]) & 0xff; - if (options != nullptr && options->anaglyph3d) + if (options != NULL && options->anaglyph3d) { int rr = (r * 30 + g * 59 + b * 11) / 100; int gg = (r * 30 + g * 70) / (100); @@ -901,10 +901,10 @@ void Textures::replaceTexture(intArray rawPixels, int w, int h, int id) b = bb; } - newPixels[i * 4 + 0] = static_cast<byte>(r); - newPixels[i * 4 + 1] = static_cast<byte>(g); - newPixels[i * 4 + 2] = static_cast<byte>(b); - newPixels[i * 4 + 3] = static_cast<byte>(a); + newPixels[i * 4 + 0] = (byte) r; + newPixels[i * 4 + 1] = (byte) g; + newPixels[i * 4 + 2] = (byte) b; + newPixels[i * 4 + 3] = (byte) a; } ByteBuffer *pixels = MemoryTracker::createByteBuffer(w * h * 4); // 4J - now creating dynamically pixels->put(newPixels); @@ -1004,9 +1004,9 @@ void Textures::releaseTexture(int id) int Textures::loadHttpTexture(const wstring& url, const wstring& backup) { HttpTexture *texture = httpTextures[url]; - if (texture != nullptr) + if (texture != NULL) { - if (texture->loadedImage != nullptr && !texture->isLoaded) + if (texture->loadedImage != NULL && !texture->isLoaded) { if (texture->id < 0) { @@ -1019,7 +1019,7 @@ int Textures::loadHttpTexture(const wstring& url, const wstring& backup) texture->isLoaded = true; } } - if (texture == nullptr || texture->id < 0) + if (texture == NULL || texture->id < 0) { if (backup.empty() ) return -1; return loadTexture(TN_COUNT, backup); @@ -1030,9 +1030,9 @@ int Textures::loadHttpTexture(const wstring& url, const wstring& backup) int Textures::loadHttpTexture(const wstring& url, int backup) { HttpTexture *texture = httpTextures[url]; - if (texture != nullptr) + if (texture != NULL) { - if (texture->loadedImage != nullptr && !texture->isLoaded) + if (texture->loadedImage != NULL && !texture->isLoaded) { if (texture->id < 0) { @@ -1045,7 +1045,7 @@ int Textures::loadHttpTexture(const wstring& url, int backup) texture->isLoaded = true; } } - if (texture == nullptr || texture->id < 0) + if (texture == NULL || texture->id < 0) { return loadTexture(backup); } @@ -1060,7 +1060,7 @@ bool Textures::hasHttpTexture(const wstring &url) HttpTexture *Textures::addHttpTexture(const wstring& url, HttpTextureProcessor *processor) { HttpTexture *texture = httpTextures[url]; - if (texture == nullptr) + if (texture == NULL) { httpTextures[url] = new HttpTexture(url, processor); } @@ -1074,7 +1074,7 @@ HttpTexture *Textures::addHttpTexture(const wstring& url, HttpTextureProcessor * void Textures::removeHttpTexture(const wstring& url) { HttpTexture *texture = httpTextures[url]; - if (texture != nullptr) + if (texture != NULL) { texture->count--; if (texture->count == 0) @@ -1088,20 +1088,20 @@ void Textures::removeHttpTexture(const wstring& url) // 4J-PB - adding for texture in memory (from global title storage) int Textures::loadMemTexture(const wstring& url, const wstring& backup) { - MemTexture *texture = nullptr; + MemTexture *texture = NULL; auto it = memTextures.find(url); if (it != memTextures.end()) { texture = (*it).second; } - if(texture == nullptr && app.IsFileInMemoryTextures(url)) + if(texture == NULL && app.IsFileInMemoryTextures(url)) { // If we haven't loaded it yet, but we have the data for it then add it texture = addMemTexture(url, new MobSkinMemTextureProcessor() ); } - if(texture != nullptr) + if(texture != NULL) { - if (texture->loadedImage != nullptr && !texture->isLoaded) + if (texture->loadedImage != NULL && !texture->isLoaded) { // 4J - Disable mipmapping in general for skins & capes. Have seen problems with edge-on polys for some eg mumbo jumbo if( ( url.substr(0,7) == L"dlcskin" ) || @@ -1122,7 +1122,7 @@ int Textures::loadMemTexture(const wstring& url, const wstring& backup) MIPMAP = true; } } - if (texture == nullptr || texture->id < 0) + if (texture == NULL || texture->id < 0) { if (backup.empty() ) return -1; return loadTexture(TN_COUNT,backup); @@ -1132,21 +1132,21 @@ int Textures::loadMemTexture(const wstring& url, const wstring& backup) int Textures::loadMemTexture(const wstring& url, int backup) { - MemTexture *texture = nullptr; + MemTexture *texture = NULL; auto it = memTextures.find(url); if (it != memTextures.end()) { texture = (*it).second; } - if(texture == nullptr && app.IsFileInMemoryTextures(url)) + if(texture == NULL && app.IsFileInMemoryTextures(url)) { // If we haven't loaded it yet, but we have the data for it then add it texture = addMemTexture(url, new MobSkinMemTextureProcessor() ); } - if(texture != nullptr) + if(texture != NULL) { texture->ticksSinceLastUse = 0; - if (texture->loadedImage != nullptr && !texture->isLoaded) + if (texture->loadedImage != NULL && !texture->isLoaded) { // 4J - Disable mipmapping in general for skins & capes. Have seen problems with edge-on polys for some eg mumbo jumbo if( ( url.substr(0,7) == L"dlcskin" ) || @@ -1166,7 +1166,7 @@ int Textures::loadMemTexture(const wstring& url, int backup) MIPMAP = true; } } - if (texture == nullptr || texture->id < 0) + if (texture == NULL || texture->id < 0) { return loadTexture(backup); } @@ -1175,16 +1175,16 @@ int Textures::loadMemTexture(const wstring& url, int backup) MemTexture *Textures::addMemTexture(const wstring& name,MemTextureProcessor *processor) { - MemTexture *texture = nullptr; + MemTexture *texture = NULL; auto it = memTextures.find(name); if (it != memTextures.end()) { texture = (*it).second; } - if(texture == nullptr) + if(texture == NULL) { // can we find it in the app mem files? - PBYTE pbData=nullptr; + PBYTE pbData=NULL; DWORD dwBytes=0; app.GetMemFileDetails(name,&pbData,&dwBytes); @@ -1196,7 +1196,7 @@ MemTexture *Textures::addMemTexture(const wstring& name,MemTextureProcessor *pro else { // 4J Stu - Make an entry for this anyway and we can populate it later - memTextures[name] = nullptr; + memTextures[name] = NULL; } } else @@ -1212,7 +1212,7 @@ MemTexture *Textures::addMemTexture(const wstring& name,MemTextureProcessor *pro // MemTexture *Textures::getMemTexture(const wstring& url, MemTextureProcessor *processor) // { // MemTexture *texture = memTextures[url]; -// if (texture != nullptr) +// if (texture != NULL) // { // texture->count++; // } @@ -1221,16 +1221,16 @@ MemTexture *Textures::addMemTexture(const wstring& name,MemTextureProcessor *pro void Textures::removeMemTexture(const wstring& url) { - MemTexture *texture = nullptr; + MemTexture *texture = NULL; auto it = memTextures.find(url); if (it != memTextures.end()) { texture = (*it).second; - // If it's nullptr then we should just remove the entry - if( texture == nullptr ) memTextures.erase(url); + // If it's NULL then we should just remove the entry + if( texture == NULL ) memTextures.erase(url); } - if(texture != nullptr) + if(texture != NULL) { texture->count--; if (texture->count == 0) @@ -1380,7 +1380,7 @@ Icon *Textures::getMissingIcon(int type) BufferedImage *Textures::readImage(TEXTURE_NAME texId, const wstring& name) // 4J was InputStream *in { - BufferedImage *img=nullptr; + BufferedImage *img=NULL; MemSect(32); // is this image one of the Title Update ones? bool isTu = IsTUImage(texId, name); @@ -1534,7 +1534,7 @@ const wchar_t *TUImagePaths[] = // - nullptr + NULL }; bool Textures::IsTUImage(TEXTURE_NAME texId, const wstring& name) @@ -1583,7 +1583,7 @@ const wchar_t *OriginalImagesPaths[] = { L"misc/watercolor.png", - nullptr + NULL }; bool Textures::IsOriginalImage(TEXTURE_NAME texId, const wstring& name) |
