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/MoveThroughVillageGoal.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Minecraft.World/MoveThroughVillageGoal.cpp') diff --git a/Minecraft.World/MoveThroughVillageGoal.cpp b/Minecraft.World/MoveThroughVillageGoal.cpp index f112c109..81476aec 100644 --- a/Minecraft.World/MoveThroughVillageGoal.cpp +++ b/Minecraft.World/MoveThroughVillageGoal.cpp @@ -11,7 +11,7 @@ MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob *mob, double speedModifier, bool onlyAtNight) { - path = NULL; + path = nullptr; doorInfo = weak_ptr(); this->mob = mob; @@ -22,7 +22,7 @@ MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob *mob, double speedM MoveThroughVillageGoal::~MoveThroughVillageGoal() { - if(path != NULL) delete path; + if(path != nullptr) delete path; } bool MoveThroughVillageGoal::canUse() @@ -32,10 +32,10 @@ bool MoveThroughVillageGoal::canUse() if (onlyAtNight && mob->level->isDay()) return false; shared_ptr village = mob->level->villages->getClosestVillage(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 0); - if (village == NULL) return false; + if (village == nullptr) return false; shared_ptr _doorInfo = getNextDoorInfo(village); - if (_doorInfo == NULL) return false; + if (_doorInfo == nullptr) return false; doorInfo = _doorInfo; bool oldCanOpenDoors = mob->getNavigation()->canOpenDoors(); @@ -44,15 +44,15 @@ bool MoveThroughVillageGoal::canUse() path = mob->getNavigation()->createPath(_doorInfo->x, _doorInfo->y, _doorInfo->z); mob->getNavigation()->setCanOpenDoors(oldCanOpenDoors); - if (path != NULL) return true; + if (path != nullptr) return true; Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast(mob->shared_from_this()), 10, 7, Vec3::newTemp(_doorInfo->x, _doorInfo->y, _doorInfo->z)); - if (pos == NULL) return false; + if (pos == nullptr) return false; mob->getNavigation()->setCanOpenDoors(false); delete path; path = mob->getNavigation()->createPath(pos->x, pos->y, pos->z); mob->getNavigation()->setCanOpenDoors(oldCanOpenDoors); - return path != NULL; + return path != nullptr; } bool MoveThroughVillageGoal::canContinueToUse() @@ -60,7 +60,7 @@ bool MoveThroughVillageGoal::canContinueToUse() if (mob->getNavigation()->isDone()) return false; float dist = mob->bbWidth + 4.f; shared_ptr _doorInfo = doorInfo.lock(); - if( _doorInfo == NULL ) return false; + if( _doorInfo == nullptr ) return false; return mob->distanceToSqr(_doorInfo->x, _doorInfo->y, _doorInfo->z) > dist * dist; } @@ -68,13 +68,13 @@ bool MoveThroughVillageGoal::canContinueToUse() void MoveThroughVillageGoal::start() { mob->getNavigation()->moveTo(path, speedModifier); - path = NULL; + path = nullptr; } void MoveThroughVillageGoal::stop() { shared_ptr _doorInfo = doorInfo.lock(); - if( _doorInfo == NULL ) return; + if( _doorInfo == nullptr ) return; if (mob->getNavigation()->isDone() || mob->distanceToSqr(_doorInfo->x, _doorInfo->y, _doorInfo->z) < 4 * 4) { -- cgit v1.2.3