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.World/Dimension.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Minecraft.World/Dimension.cpp') diff --git a/Minecraft.World/Dimension.cpp b/Minecraft.World/Dimension.cpp index 479edae8..b7a2ea7c 100644 --- a/Minecraft.World/Dimension.cpp +++ b/Minecraft.World/Dimension.cpp @@ -30,7 +30,7 @@ void Dimension::updateLightRamp() float ambientLight = 0.00f; for (int i = 0; i <= Level::MAX_BRIGHTNESS; i++) { - float v = (1 - i / (float) (Level::MAX_BRIGHTNESS)); + float v = (1 - i / static_cast(Level::MAX_BRIGHTNESS)); brightnessRamp[i] = ((1 - v) / (v * 3 + 1)) * (1 - ambientLight) + ambientLight; } } @@ -70,7 +70,7 @@ Dimension::~Dimension() { delete[] brightnessRamp; - if(biomeSource != NULL) + if(biomeSource != nullptr) delete biomeSource; } @@ -115,7 +115,7 @@ bool Dimension::isValidSpawn(int x, int z) const float Dimension::getTimeOfDay(int64_t time, float a) const { - int dayStep = (int) (time % Level::TICKS_PER_DAY); + int dayStep = static_cast(time % Level::TICKS_PER_DAY); float td = (dayStep + a) / Level::TICKS_PER_DAY - 0.25f; if (td < 0) td += 1; if (td > 1) td -= 1; @@ -127,7 +127,7 @@ float Dimension::getTimeOfDay(int64_t time, float a) const int Dimension::getMoonPhase(int64_t time) const { - return ((int) (time / Level::TICKS_PER_DAY)) % 8; + return static_cast(time / Level::TICKS_PER_DAY) % 8; } bool Dimension::isNaturalDimension() @@ -161,7 +161,7 @@ float *Dimension::getSunriseColor(float td, float a) return sunriseCol; } - return NULL; + return nullptr; } Vec3 *Dimension::getFogColor(float td, float a) const @@ -192,12 +192,12 @@ Dimension *Dimension::getNew(int id) if (id == 0) return new NormalDimension(); if (id == 1) return new TheEndDimension(); - return NULL; + return nullptr; } float Dimension::getCloudHeight() { - return (float)Level::genDepth; + return static_cast(Level::genDepth); } bool Dimension::hasGround() @@ -207,7 +207,7 @@ bool Dimension::hasGround() Pos *Dimension::getSpawnPos() { - return NULL; + return nullptr; } int Dimension::getSpawnYPosition() -- cgit v1.2.3