aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Villages.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/Villages.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/Villages.cpp')
-rw-r--r--Minecraft.World/Villages.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/Minecraft.World/Villages.cpp b/Minecraft.World/Villages.cpp
index e636ed74..432a8b6b 100644
--- a/Minecraft.World/Villages.cpp
+++ b/Minecraft.World/Villages.cpp
@@ -11,7 +11,7 @@ const wstring Villages::VILLAGE_FILE_ID = L"villages";
Villages::Villages(const wstring &id) : SavedData(id)
{
_tick = 0;
- level = NULL;
+ level = nullptr;
}
Villages::Villages(Level *level) : SavedData(VILLAGE_FILE_ID)
@@ -117,7 +117,7 @@ void Villages::cluster()
bool found = false;
for(auto& village : villages)
{
- int dist = (int) village->getCenter()->distSqr(di->x, di->y, di->z);
+ int dist = static_cast<int>(village->getCenter()->distSqr(di->x, di->y, di->z));
int radius = MaxDoorDist + village->getRadius();
if (dist > radius * radius) continue;
village->addDoorInfo(di);
@@ -127,7 +127,7 @@ void Villages::cluster()
if (found) continue;
// create new Village
- shared_ptr<Village> village = shared_ptr<Village>(new Village(level));
+ shared_ptr<Village> village = std::make_shared<Village>(level);
village->addDoorInfo(di);
villages.push_back(village);
setDirty();
@@ -147,7 +147,7 @@ void Villages::addDoorInfos(Pos *pos)
if (isDoor(xx, yy, zz))
{
shared_ptr<DoorInfo> currentDoor = getDoorInfo(xx, yy, zz);
- if (currentDoor == NULL) createDoorInfo(xx, yy, zz);
+ if (currentDoor == nullptr) createDoorInfo(xx, yy, zz);
else currentDoor->timeStamp = _tick;
}
}
@@ -173,7 +173,7 @@ shared_ptr<DoorInfo> Villages::getDoorInfo(int x, int y, int z)
void Villages::createDoorInfo(int x, int y, int z)
{
- int dir = ((DoorTile *) Tile::door_wood)->getDir(level, x, y, z);
+ int dir = static_cast<DoorTile *>(Tile::door_wood)->getDir(level, x, y, z);
if (dir == 0 || dir == 2)
{
int canSeeX = 0;
@@ -181,7 +181,7 @@ void Villages::createDoorInfo(int x, int y, int z)
if (level->canSeeSky(x + i, y, z)) canSeeX--;
for (int i = 1; i <= 5; ++i)
if (level->canSeeSky(x + i, y, z)) canSeeX++;
- if (canSeeX != 0) unclustered.push_back(shared_ptr<DoorInfo>(new DoorInfo(x, y, z, canSeeX > 0 ? -2 : 2, 0, _tick)));
+ if (canSeeX != 0) unclustered.push_back(std::make_shared<DoorInfo>(x, y, z, canSeeX > 0 ? -2 : 2, 0, _tick));
}
else
{
@@ -190,7 +190,7 @@ void Villages::createDoorInfo(int x, int y, int z)
if (level->canSeeSky(x, y, z + i)) canSeeZ--;
for (int i = 1; i <= 5; ++i)
if (level->canSeeSky(x, y, z + i)) canSeeZ++;
- if (canSeeZ != 0) unclustered.push_back(shared_ptr<DoorInfo>(new DoorInfo(x, y, z, 0, canSeeZ > 0 ? -2 : 2, _tick)));
+ if (canSeeZ != 0) unclustered.push_back(std::make_shared<DoorInfo>(x, y, z, 0, canSeeZ > 0 ? -2 : 2, _tick));
}
}
@@ -218,7 +218,7 @@ void Villages::load(CompoundTag *tag)
for (int i = 0; i < villageTags->size(); i++)
{
CompoundTag *compoundTag = villageTags->get(i);
- shared_ptr<Village> village = shared_ptr<Village>(new Village());
+ shared_ptr<Village> village = std::make_shared<Village>();
village->readAdditionalSaveData(compoundTag);
villages.push_back(village);
}