From a9be52c41a02d207233199e98898fe7483d7e817 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sat, 7 Mar 2026 21:56:03 -0500 Subject: 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 --- Minecraft.World/Villages.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Minecraft.World/Villages.cpp') 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(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 = shared_ptr(new Village(level)); + shared_ptr village = std::make_shared(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 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 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(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(new DoorInfo(x, y, z, canSeeX > 0 ? -2 : 2, 0, _tick))); + if (canSeeX != 0) unclustered.push_back(std::make_shared(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(new DoorInfo(x, y, z, 0, canSeeZ > 0 ? -2 : 2, _tick))); + if (canSeeZ != 0) unclustered.push_back(std::make_shared(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 = shared_ptr(new Village()); + shared_ptr village = std::make_shared(); village->readAdditionalSaveData(compoundTag); villages.push_back(village); } -- cgit v1.2.3