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/Particle.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Minecraft.Client/Particle.cpp') diff --git a/Minecraft.Client/Particle.cpp b/Minecraft.Client/Particle.cpp index 1091a26a..643dc669 100644 --- a/Minecraft.Client/Particle.cpp +++ b/Minecraft.Client/Particle.cpp @@ -19,7 +19,7 @@ void Particle::_init(Level *level, double x, double y, double z) { // 4J - added these initialisers alpha = 1.0f; - tex = NULL; + tex = nullptr; gravity = 0.0f; setSize(0.2f, 0.2f); @@ -35,7 +35,7 @@ void Particle::_init(Level *level, double x, double y, double z) size = (random->nextFloat() * 0.5f + 0.5f) * 2; - lifetime = (int) (4 / (random->nextFloat() * 0.9f + 0.1f)); + lifetime = static_cast(4 / (random->nextFloat() * 0.9f + 0.1f)); age = 0; texX = 0; @@ -51,10 +51,10 @@ Particle::Particle(Level *level, double x, double y, double z, double xa, double { _init(level,x,y,z); - xd = xa + (float) (Math::random() * 2 - 1) * 0.4f; - yd = ya + (float) (Math::random() * 2 - 1) * 0.4f; - zd = za + (float) (Math::random() * 2 - 1) * 0.4f; - float speed = (float) (Math::random() + Math::random() + 1) * 0.15f; + xd = xa + static_cast(Math::random() * 2 - 1) * 0.4f; + yd = ya + static_cast(Math::random() * 2 - 1) * 0.4f; + zd = za + static_cast(Math::random() * 2 - 1) * 0.4f; + float speed = static_cast(Math::random() + Math::random() + 1) * 0.15f; float dd = (float) (Mth::sqrt(xd * xd + yd * yd + zd * zd)); xd = xd / dd * speed * 0.4f; @@ -156,7 +156,7 @@ void Particle::render(Tesselator *t, float a, float xa, float ya, float za, floa float v1 = v0 + 0.999f / 16.0f; float r = 0.1f * size; - if (tex != NULL) + if (tex != nullptr) { u0 = tex->getU0(); u1 = tex->getU1(); @@ -164,9 +164,9 @@ void Particle::render(Tesselator *t, float a, float xa, float ya, float za, floa v1 = tex->getV1(); } - float x = (float) (xo + (this->x - xo) * a - xOff); - float y = (float) (yo + (this->y - yo) * a - yOff); - float z = (float) (zo + (this->z - zo) * a - zOff); + float x = static_cast(xo + (this->x - xo) * a - xOff); + float y = static_cast(yo + (this->y - yo) * a - yOff); + float z = static_cast(zo + (this->z - zo) * a - zOff); float br = 1.0f; // 4J - change brought forward from 1.8.2 if( !SharedConstants::TEXTURE_LIGHTING ) -- cgit v1.2.3