From 28614b922fb77149a54da1a87bebfbc98736f296 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:08:36 -0400 Subject: Modernize project codebase (#906) * Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides * Add safety checks and fix a issue with vector going OOR --- Minecraft.Client/BufferedImage.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Minecraft.Client/BufferedImage.cpp') diff --git a/Minecraft.Client/BufferedImage.cpp b/Minecraft.Client/BufferedImage.cpp index 89e37e4f..8777d307 100644 --- a/Minecraft.Client/BufferedImage.cpp +++ b/Minecraft.Client/BufferedImage.cpp @@ -31,7 +31,7 @@ BufferedImage::BufferedImage(int width,int height,int type) for( int i = 1 ; i < 10; i++ ) { - data[i] = NULL; + data[i] = nullptr; } this->width = width; this->height = height; @@ -140,7 +140,7 @@ BufferedImage::BufferedImage(const wstring& File, bool filenameHasExtension /*=f for( int l = 0 ; l < 10; l++ ) { - data[l] = NULL; + data[l] = nullptr; } for( int l = 0; l < 10; l++ ) @@ -193,12 +193,12 @@ BufferedImage::BufferedImage(DLCPack *dlcPack, const wstring& File, bool filenam { HRESULT hr; wstring filePath = File; - BYTE *pbData = NULL; + BYTE *pbData = nullptr; DWORD dwBytes = 0; for( int l = 0 ; l < 10; l++ ) { - data[l] = NULL; + data[l] = nullptr; } for( int l = 0; l < 10; l++ ) @@ -230,7 +230,7 @@ BufferedImage::BufferedImage(DLCPack *dlcPack, const wstring& File, bool filenam DLCFile *dlcFile = dlcPack->getFile(DLCManager::e_DLCType_All, name); pbData = dlcFile->getData(dwBytes); - if(pbData == NULL || dwBytes == 0) + if(pbData == nullptr || dwBytes == 0) { // 4J - If we haven't loaded the non-mipmap version then exit the game if( l == 0 ) @@ -269,7 +269,7 @@ BufferedImage::BufferedImage(BYTE *pbData, DWORD dwBytes) int iCurrentByte=0; for( int l = 0 ; l < 10; l++ ) { - data[l] = NULL; + data[l] = nullptr; } D3DXIMAGE_INFO ImageInfo; @@ -329,7 +329,7 @@ int *BufferedImage::getData(int level) Graphics *BufferedImage::getGraphics() { - return NULL; + return nullptr; } //Returns the transparency. Returns either OPAQUE, BITMASK, or TRANSLUCENT. @@ -359,7 +359,7 @@ BufferedImage *BufferedImage::getSubimage(int x ,int y, int w, int h) this->getRGB(x, y, w, h, arrayWrapper,0,w); int level = 1; - while(getData(level) != NULL) + while(getData(level) != nullptr) { int ww = w >> level; int hh = h >> level; @@ -391,9 +391,9 @@ void BufferedImage::preMultiplyAlpha() { cur = curData[i]; alpha = (cur >> 24) & 0xff; - r = ((cur >> 16) & 0xff) * (float)alpha/255; - g = ((cur >> 8) & 0xff) * (float)alpha/255; - b = (cur & 0xff) * (float)alpha/255; + r = ((cur >> 16) & 0xff) * static_cast(alpha)/255; + g = ((cur >> 8) & 0xff) * static_cast(alpha)/255; + b = (cur & 0xff) * static_cast(alpha)/255; curData[i] = (r << 16) | (g << 8) | (b ) | (alpha << 24); } -- cgit v1.2.3