aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/StitchedTexture.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.Client/StitchedTexture.cpp
parent88798b501d0cf6287b6f87acb2592676e3cec58d (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/StitchedTexture.cpp')
-rw-r--r--Minecraft.Client/StitchedTexture.cpp32
1 files changed, 16 insertions, 16 deletions
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<Texture *> *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<float>(source->getWidth()) + marginX;
+ this->u1 = (x + width) / static_cast<float>(source->getWidth()) - marginX;
+ this->v0 = y / static_cast<float>(source->getHeight()) + marginY;
+ this->v1 = (y + height) / static_cast<float>(source->getHeight()) - marginY;
#ifndef _CONTENT_PACKAGE
bool addBreakpoint = false;
@@ -112,8 +112,8 @@ void StitchedTexture::init(Texture *source, vector<Texture *> *frames, int x, in
}
#endif
- this->widthTranslation = width / (float) SharedConstants::WORLD_RESOLUTION;
- this->heightTranslation = height / (float) SharedConstants::WORLD_RESOLUTION;
+ this->widthTranslation = width / static_cast<float>(SharedConstants::WORLD_RESOLUTION);
+ this->heightTranslation = height / static_cast<float>(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<float>(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<float>(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<int, int> 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;