aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/StrongholdFeature.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-07 21:56:03 -0500
committerGitHub <noreply@github.com>2026-03-08 09:56:03 +0700
commita9be52c41a02d207233199e98898fe7483d7e817 (patch)
tree71dfaec3a86b05e9ca409b97d8eb9d7f993bfdd0 /Minecraft.World/StrongholdFeature.cpp
parent1be5faaea781402e7de06b263eeca4c688b7712c (diff)
Project modernization (#630)
* 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
Diffstat (limited to 'Minecraft.World/StrongholdFeature.cpp')
-rw-r--r--Minecraft.World/StrongholdFeature.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/Minecraft.World/StrongholdFeature.cpp b/Minecraft.World/StrongholdFeature.cpp
index fa85dc42..83f05cf3 100644
--- a/Minecraft.World/StrongholdFeature.cpp
+++ b/Minecraft.World/StrongholdFeature.cpp
@@ -39,7 +39,7 @@ void StrongholdFeature::_init()
// 4J added initialisers
for (int i = 0; i < strongholdPos_length; i++)
{
- strongholdPos[i] = NULL;
+ strongholdPos[i] = nullptr;
}
isSpotSelected = false;
}
@@ -136,11 +136,11 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
}
#endif
- int selectedX = (int) (Math::round(cos(angle) * dist));
- int selectedZ = (int) (Math::round(sin(angle) * dist));
+ int selectedX = static_cast<int>(Math::round(cos(angle) * dist));
+ int selectedZ = static_cast<int>(Math::round(sin(angle) * dist));
TilePos *position = level->getBiomeSource()->findBiome((selectedX << 4) + 8, (selectedZ << 4) + 8, 7 << 4, allowedBiomes, &random);
- if (position != NULL)
+ if (position != nullptr)
{
selectedX = position->x >> 4;
selectedZ = position->z >> 4;
@@ -164,7 +164,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
delete strongholdPos[i];
strongholdPos[i] = new ChunkPos(selectedX, selectedZ);
- angle += PI * 2.0 / (double) strongholdPos_length;
+ angle += PI * 2.0 / static_cast<double>(strongholdPos_length);
}
// 4J Stu - We want to make sure that we have at least one stronghold in this world
@@ -172,7 +172,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
// 4J Stu - Randomise the angles for retries as well
#ifdef _LARGE_WORLDS
- angle = random.nextDouble() * PI * 2.0 * circle / (double) spread;
+ angle = random.nextDouble() * PI * 2.0 * circle / static_cast<double>(spread);
#endif
}
while(!hasFoundValidPos && findAttempts < MAX_STRONGHOLD_ATTEMPTS);
@@ -191,7 +191,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
{
bool forcePlacement = false;
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
- if( levelGenOptions != NULL )
+ if( levelGenOptions != nullptr )
{
forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_Stronghold);
}
@@ -211,7 +211,7 @@ vector<TilePos> *StrongholdFeature::getGuesstimatedFeaturePositions()
for( int i = 0; i < strongholdPos_length; i++ )
{
ChunkPos *chunkPos = strongholdPos[i];
- if (chunkPos != NULL)
+ if (chunkPos != nullptr)
{
positions->push_back(chunkPos->getMiddleBlockPosition(64));
}
@@ -225,7 +225,7 @@ StructureStart *StrongholdFeature::createStructureStart(int x, int z)
StrongholdStart *start = new StrongholdStart(level, random, x, z);
// 4J - front() was get(0)
- while (start->getPieces()->empty() || ((StrongholdPieces::StartPiece *) start->getPieces()->front())->portalRoomPiece == NULL)
+ while (start->getPieces()->empty() || static_cast<StrongholdPieces::StartPiece *>(start->getPieces()->front())->portalRoomPiece == nullptr)
{
delete start;
// regenerate stronghold without changing seed
@@ -254,7 +254,7 @@ StrongholdFeature::StrongholdStart::StrongholdStart(Level *level, Random *random
vector<StructurePiece *> *pendingChildren = &startRoom->pendingChildren;
while (!pendingChildren->empty())
{
- int pos = random->nextInt((int)pendingChildren->size());
+ int pos = random->nextInt(static_cast<int>(pendingChildren->size()));
auto it = pendingChildren->begin() + pos;
StructurePiece *structurePiece = *it;
pendingChildren->erase(it);