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/StructurePiece.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Minecraft.World/StructurePiece.cpp') diff --git a/Minecraft.World/StructurePiece.cpp b/Minecraft.World/StructurePiece.cpp index 85a19ab4..bb3887c0 100644 --- a/Minecraft.World/StructurePiece.cpp +++ b/Minecraft.World/StructurePiece.cpp @@ -44,7 +44,7 @@ StructurePiece::StructurePiece() { - boundingBox = NULL; + boundingBox = nullptr; orientation = 0; genDepth = 0; // for reflection @@ -52,14 +52,14 @@ StructurePiece::StructurePiece() StructurePiece::StructurePiece( int genDepth ) { - boundingBox = NULL; + boundingBox = nullptr; this->genDepth = genDepth; orientation = Direction::UNDEFINED; } StructurePiece::~StructurePiece() { - if(boundingBox != NULL) delete boundingBox; + if(boundingBox != nullptr) delete boundingBox; } CompoundTag *StructurePiece::createTag() @@ -120,7 +120,7 @@ StructurePiece* StructurePiece::findCollisionPiece( list< StructurePiece* > *pie return piece; } } - return NULL; + return nullptr; } // 4J-PB - Added from 1.2.3 @@ -437,7 +437,7 @@ int StructurePiece::getOrientationData( int tile, int data ) } } } - else if (tile == Tile::tripWireSource_Id || (Tile::tiles[tile] != NULL && dynamic_cast(Tile::tiles[tile]))) + else if (tile == Tile::tripWireSource_Id || (Tile::tiles[tile] != nullptr && dynamic_cast(Tile::tiles[tile]))) { if (orientation == Direction::SOUTH) { @@ -730,15 +730,15 @@ void StructurePiece::maybeGenerateBlock( Level* level, BoundingBox* chunkBB, Ran void StructurePiece::generateUpperHalfSphere( Level* level, BoundingBox* chunkBB, int x0, int y0, int z0, int x1, int y1, int z1, int fillTile, bool skipAir ) { - float diagX = (float)( x1 - x0 + 1 ); - float diagY = (float)( y1 - y0 + 1 ); - float diagZ = (float)( z1 - z0 + 1 ); + float diagX = static_cast(x1 - x0 + 1); + float diagY = static_cast(y1 - y0 + 1); + float diagZ = static_cast(z1 - z0 + 1); float cx = x0 + diagX / 2; float cz = z0 + diagZ / 2; for ( int y = y0; y <= y1; y++ ) { - float normalizedYDistance = ( float )( y - y0 ) / diagY; + float normalizedYDistance = static_cast(y - y0) / diagY; for ( int x = x0; x <= x1; x++ ) { @@ -816,7 +816,7 @@ bool StructurePiece::createChest( Level* level, BoundingBox* chunkBB, Random* ra { level->setTileAndData( worldX, worldY, worldZ, Tile::chest->id, 0, Tile::UPDATE_CLIENTS ); shared_ptr chest = dynamic_pointer_cast(level->getTileEntity( worldX, worldY, worldZ )); - if ( chest != NULL ) WeighedTreasure::addChestItems( random, treasure, chest, numRolls ); + if ( chest != nullptr ) WeighedTreasure::addChestItems( random, treasure, chest, numRolls ); return true; } } @@ -835,7 +835,7 @@ bool StructurePiece::createDispenser(Level *level, BoundingBox *chunkBB, Random { level->setTileAndData(worldX, worldY, worldZ, Tile::dispenser_Id, getOrientationData(Tile::dispenser_Id, facing), Tile::UPDATE_CLIENTS); shared_ptr dispenser = dynamic_pointer_cast(level->getTileEntity(worldX, worldY, worldZ)); - if (dispenser != NULL) WeighedTreasure::addDispenserItems(random, items, dispenser, numRolls); + if (dispenser != nullptr) WeighedTreasure::addDispenserItems(random, items, dispenser, numRolls); return true; } } -- cgit v1.2.3