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/AvoidPlayerGoal.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Minecraft.World/AvoidPlayerGoal.cpp') diff --git a/Minecraft.World/AvoidPlayerGoal.cpp b/Minecraft.World/AvoidPlayerGoal.cpp index 53aebe89..f9c6641a 100644 --- a/Minecraft.World/AvoidPlayerGoal.cpp +++ b/Minecraft.World/AvoidPlayerGoal.cpp @@ -33,12 +33,12 @@ AvoidPlayerGoal::AvoidPlayerGoal(PathfinderMob *mob, const type_info& avoidType, entitySelector = new AvoidPlayerGoalEntitySelector(this); toAvoid = weak_ptr(); - path = NULL; + path = nullptr; } AvoidPlayerGoal::~AvoidPlayerGoal() { - if(path != NULL) delete path; + if(path != nullptr) delete path; delete entitySelector; } @@ -47,9 +47,9 @@ bool AvoidPlayerGoal::canUse() if (avoidType == typeid(Player)) { shared_ptr tamableAnimal = dynamic_pointer_cast(mob->shared_from_this()); - if (tamableAnimal != NULL && tamableAnimal->isTame()) return false; + if (tamableAnimal != nullptr && tamableAnimal->isTame()) return false; toAvoid = weak_ptr(mob->level->getNearestPlayer(mob->shared_from_this(), maxDist)); - if (toAvoid.lock() == NULL) return false; + if (toAvoid.lock() == nullptr) return false; } else { @@ -64,24 +64,24 @@ bool AvoidPlayerGoal::canUse() } Vec3 *pos = RandomPos::getPosAvoid(dynamic_pointer_cast(mob->shared_from_this()), 16, 7, Vec3::newTemp(toAvoid.lock()->x, toAvoid.lock()->y, toAvoid.lock()->z)); - if (pos == NULL) return false; + if (pos == nullptr) return false; if (toAvoid.lock()->distanceToSqr(pos->x, pos->y, pos->z) < toAvoid.lock()->distanceToSqr(mob->shared_from_this())) return false; delete path; path = pathNav->createPath(pos->x, pos->y, pos->z); - if (path == NULL) return false; + if (path == nullptr) return false; if (!path->endsInXZ(pos)) return false; return true; } bool AvoidPlayerGoal::canContinueToUse() { - return toAvoid.lock() != NULL && !pathNav->isDone(); + return toAvoid.lock() != nullptr && !pathNav->isDone(); } void AvoidPlayerGoal::start() { pathNav->moveTo(path, walkSpeedModifier); - path = NULL; + path = nullptr; } void AvoidPlayerGoal::stop() -- cgit v1.2.3