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/StemTile.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Minecraft.World/StemTile.cpp') diff --git a/Minecraft.World/StemTile.cpp b/Minecraft.World/StemTile.cpp index 62b0d57b..476b643c 100644 --- a/Minecraft.World/StemTile.cpp +++ b/Minecraft.World/StemTile.cpp @@ -17,7 +17,7 @@ StemTile::StemTile(int id, Tile *fruit) : Bush(id) float ss = 0.125f; this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, 0.25f, 0.5f + ss); - iconAngled = NULL; + iconAngled = nullptr; } bool StemTile::mayPlaceOn(int tile) @@ -34,7 +34,7 @@ void StemTile::tick(Level *level, int x, int y, int z, Random *random) float growthSpeed = getGrowthSpeed(level, x, y, z); // 4J Stu - Brought forward change from 1.2.3 to make fruit more likely to grow - if (random->nextInt((int) (25 / growthSpeed) + 1) == 0) + if (random->nextInt(static_cast(25 / growthSpeed) + 1) == 0) { int age = level->getData(x, y, z); if (age < 7) @@ -149,10 +149,10 @@ void StemTile::updateDefaultShape() void StemTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr forceEntity) // 4J added forceData, forceEntity param { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); tls->yy1 = (level->getData(x, y, z) * 2 + 2) / 16.0f; float ss = 0.125f; - setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, (float) tls->yy1, 0.5f + ss); + setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, static_cast(tls->yy1), 0.5f + ss); } int StemTile::getRenderShape() @@ -184,12 +184,12 @@ void StemTile::spawnResources(Level *level, int x, int y, int z, int data, float return; } - Item *seed = NULL; + Item *seed = nullptr; if (fruit == Tile::pumpkin) seed = Item::seeds_pumpkin; if (fruit == Tile::melon) seed = Item::seeds_melon; - if (seed != NULL) + if (seed != nullptr) { - popResource(level, x, y, z, shared_ptr(new ItemInstance(seed))); + popResource(level, x, y, z, std::make_shared(seed)); } } -- cgit v1.2.3