aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/MineShaftPieces.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.World/MineShaftPieces.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.World/MineShaftPieces.cpp')
-rw-r--r--Minecraft.World/MineShaftPieces.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/Minecraft.World/MineShaftPieces.cpp b/Minecraft.World/MineShaftPieces.cpp
index 3fda1bfc..97caf366 100644
--- a/Minecraft.World/MineShaftPieces.cpp
+++ b/Minecraft.World/MineShaftPieces.cpp
@@ -44,7 +44,7 @@ StructurePiece *MineShaftPieces::createRandomShaftPiece(list<StructurePiece *> *
if (randomSelection >= 80)
{
BoundingBox *crossingBox = MineShaftCrossing::findCrossing(pieces, random, footX, footY, footZ, direction);
- if (crossingBox != NULL)
+ if (crossingBox != nullptr)
{
return new MineShaftCrossing(genDepth, random, crossingBox, direction);
}
@@ -52,7 +52,7 @@ StructurePiece *MineShaftPieces::createRandomShaftPiece(list<StructurePiece *> *
else if (randomSelection >= 70)
{
BoundingBox *stairsBox = MineShaftStairs::findStairs(pieces, random, footX, footY, footZ, direction);
- if (stairsBox != NULL)
+ if (stairsBox != nullptr)
{
return new MineShaftPieces::MineShaftStairs(genDepth, random, stairsBox, direction);
}
@@ -60,28 +60,28 @@ StructurePiece *MineShaftPieces::createRandomShaftPiece(list<StructurePiece *> *
else
{
BoundingBox *corridorBox = MineShaftCorridor::findCorridorSize(pieces, random, footX, footY, footZ, direction);
- if (corridorBox != NULL)
+ if (corridorBox != nullptr)
{
return new MineShaftCorridor(genDepth, random, corridorBox, direction);
}
}
- return NULL;
+ return nullptr;
}
StructurePiece *MineShaftPieces::generateAndAddPiece(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth)
{
if (depth > MAX_DEPTH)
{
- return NULL;
+ return nullptr;
}
if (abs(footX - startPiece->getBoundingBox()->x0) > 5 * 16 || abs(footZ - startPiece->getBoundingBox()->z0) > 5 * 16)
{
- return NULL;
+ return nullptr;
}
StructurePiece *newPiece = createRandomShaftPiece(pieces, random, footX, footY, footZ, direction, depth + 1);
- if (newPiece != NULL)
+ if (newPiece != nullptr)
{
MemSect(50);
pieces->push_back(newPiece);
@@ -132,7 +132,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis
break;
}
StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + pos, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z0 - 1, Direction::NORTH, depth);
- if (child != NULL)
+ if (child != nullptr)
{
BoundingBox *childBox = child->getBoundingBox();
childEntranceBoxes.push_back(new BoundingBox(childBox->x0, childBox->y0, boundingBox->z0, childBox->x1, childBox->y1, boundingBox->z0 + 1));
@@ -149,7 +149,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis
break;
}
StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + pos, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z1 + 1, Direction::SOUTH, depth);
- if (child != NULL)
+ if (child != nullptr)
{
BoundingBox *childBox = child->getBoundingBox();
childEntranceBoxes.push_back(new BoundingBox(childBox->x0, childBox->y0, boundingBox->z1 - 1, childBox->x1, childBox->y1, boundingBox->z1));
@@ -166,7 +166,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis
break;
}
StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 - 1, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z0 + pos, Direction::WEST, depth);
- if (child != NULL)
+ if (child != nullptr)
{
BoundingBox *childBox = child->getBoundingBox();
childEntranceBoxes.push_back(new BoundingBox(boundingBox->x0, childBox->y0, childBox->z0, boundingBox->x0 + 1, childBox->y1, childBox->z1));
@@ -183,7 +183,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis
break;
}
StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z0 + pos, Direction::EAST, depth);
- if (child != NULL)
+ if (child != nullptr)
{
BoundingBox *childBox = child->getBoundingBox();
childEntranceBoxes.push_back(new BoundingBox(boundingBox->x1 - 1, childBox->y0, childBox->z0, boundingBox->x1, childBox->y1, childBox->z1));
@@ -304,7 +304,7 @@ BoundingBox *MineShaftPieces::MineShaftCorridor::findCorridorSize(list<Structure
break;
}
- if (StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
corridorLength--;
}
@@ -320,7 +320,7 @@ BoundingBox *MineShaftPieces::MineShaftCorridor::findCorridorSize(list<Structure
}
delete box;
// unable to place corridor here
- return NULL;
+ return nullptr;
}
void MineShaftPieces::MineShaftCorridor::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
@@ -434,7 +434,7 @@ bool MineShaftPieces::MineShaftCorridor::createChest(Level *level, BoundingBox *
if (level->getTile(worldX, worldY, worldZ) == 0)
{
level->setTileAndData(worldX, worldY, worldZ, Tile::rail_Id, getOrientationData(Tile::rail_Id, random->nextBoolean() ? RailTile::DIR_FLAT_X : RailTile::DIR_FLAT_Z), Tile::UPDATE_CLIENTS);
- shared_ptr<MinecartChest> chest = shared_ptr<MinecartChest>( new MinecartChest(level, worldX + 0.5f, worldY + 0.5f, worldZ + 0.5f) );
+ shared_ptr<MinecartChest> chest = std::make_shared<MinecartChest>(level, worldX + 0.5f, worldY + 0.5f, worldZ + 0.5f);
WeighedTreasure::addChestItems(random, treasure, chest, numRolls);
level->addEntity(chest);
return true;
@@ -515,7 +515,7 @@ bool MineShaftPieces::MineShaftCorridor::postProcess(Level *level, Random *rando
hasPlacedSpider = true;
level->setTileAndData(x, y, newZ, Tile::mobSpawner_Id, 0, Tile::UPDATE_CLIENTS);
shared_ptr<MobSpawnerTileEntity> entity = dynamic_pointer_cast<MobSpawnerTileEntity>( level->getTileEntity(x, y, newZ) );
- if (entity != NULL) entity->getSpawner()->setEntityId(L"CaveSpider");
+ if (entity != nullptr) entity->getSpawner()->setEntityId(L"CaveSpider");
}
}
}
@@ -605,10 +605,10 @@ BoundingBox *MineShaftPieces::MineShaftCrossing::findCrossing(list<StructurePiec
break;
}
- if (StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return box;
@@ -746,10 +746,10 @@ BoundingBox *MineShaftPieces::MineShaftStairs::findStairs(list<StructurePiece *>
break;
}
- if (StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return box;