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/StitchedTexture.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'Minecraft.Client/StitchedTexture.cpp') diff --git a/Minecraft.Client/StitchedTexture.cpp b/Minecraft.Client/StitchedTexture.cpp index 64ab2f36..b9693f3d 100644 --- a/Minecraft.Client/StitchedTexture.cpp +++ b/Minecraft.Client/StitchedTexture.cpp @@ -26,7 +26,7 @@ StitchedTexture *StitchedTexture::create(const wstring &name) StitchedTexture::StitchedTexture(const wstring &name, const wstring &filename) : name(name) { // 4J Initialisers - source = NULL; + source = nullptr; rotated = false; x = 0; y = 0; @@ -40,9 +40,9 @@ StitchedTexture::StitchedTexture(const wstring &name, const wstring &filename) : heightTranslation = 0.0f; frame = 0; subFrame = 0; - frameOverride = NULL; + frameOverride = nullptr; flags = 0; - frames = NULL; + frames = nullptr; m_fileName = filename; } @@ -94,10 +94,10 @@ void StitchedTexture::init(Texture *source, vector *frames, int x, in float marginX = 0.0f; //0.01f / source->getWidth(); float marginY = 0.0f; //0.01f / source->getHeight(); - this->u0 = x / (float) source->getWidth() + marginX; - this->u1 = (x + width) / (float) source->getWidth() - marginX; - this->v0 = y / (float) source->getHeight() + marginY; - this->v1 = (y + height) / (float) source->getHeight() - marginY; + this->u0 = x / static_cast(source->getWidth()) + marginX; + this->u1 = (x + width) / static_cast(source->getWidth()) - marginX; + this->v0 = y / static_cast(source->getHeight()) + marginY; + this->v1 = (y + height) / static_cast(source->getHeight()) - marginY; #ifndef _CONTENT_PACKAGE bool addBreakpoint = false; @@ -112,8 +112,8 @@ void StitchedTexture::init(Texture *source, vector *frames, int x, in } #endif - this->widthTranslation = width / (float) SharedConstants::WORLD_RESOLUTION; - this->heightTranslation = height / (float) SharedConstants::WORLD_RESOLUTION; + this->widthTranslation = width / static_cast(SharedConstants::WORLD_RESOLUTION); + this->heightTranslation = height / static_cast(SharedConstants::WORLD_RESOLUTION); } void StitchedTexture::replaceWith(StitchedTexture *texture) @@ -156,7 +156,7 @@ float StitchedTexture::getU1(bool adjust/*=false*/) const float StitchedTexture::getU(double offset, bool adjust/*=false*/) const { float diff = getU1(adjust) - getU0(adjust); - return getU0(adjust) + (diff * ((float) offset / SharedConstants::WORLD_RESOLUTION)); + return getU0(adjust) + (diff * (static_cast(offset) / SharedConstants::WORLD_RESOLUTION)); } float StitchedTexture::getV0(bool adjust/*=false*/) const @@ -172,7 +172,7 @@ float StitchedTexture::getV1(bool adjust/*=false*/) const float StitchedTexture::getV(double offset, bool adjust/*=false*/) const { float diff = getV1(adjust) - getV0(adjust); - return getV0(adjust) + (diff * ((float) offset / SharedConstants::WORLD_RESOLUTION)); + return getV0(adjust) + (diff * (static_cast(offset) / SharedConstants::WORLD_RESOLUTION)); } wstring StitchedTexture::getName() const @@ -192,7 +192,7 @@ int StitchedTexture::getSourceHeight() const void StitchedTexture::cycleFrames() { - if (frameOverride != NULL) + if (frameOverride != nullptr) { pair current = frameOverride->at(frame); subFrame++; @@ -250,10 +250,10 @@ int StitchedTexture::getFrames() */ void StitchedTexture::loadAnimationFrames(BufferedReader *bufferedReader) { - if(frameOverride != NULL) + if(frameOverride != nullptr) { delete frameOverride; - frameOverride = NULL; + frameOverride = nullptr; } frame = 0; subFrame = 0; @@ -303,10 +303,10 @@ void StitchedTexture::loadAnimationFrames(BufferedReader *bufferedReader) void StitchedTexture::loadAnimationFrames(const wstring &string) { - if(frameOverride != NULL) + if(frameOverride != nullptr) { delete frameOverride; - frameOverride = NULL; + frameOverride = nullptr; } frame = 0; subFrame = 0; -- cgit v1.2.3