From 55231bb8d3e1a4e2752ac3d444c4287eb0ca4e8b Mon Sep 17 00:00:00 2001 From: void_17 <61356189+void2012@users.noreply.github.com> Date: Fri, 6 Mar 2026 02:11:18 +0700 Subject: Remove AUTO_VAR macro and _toString function (#592) --- Minecraft.World/BreedGoal.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'Minecraft.World/BreedGoal.cpp') diff --git a/Minecraft.World/BreedGoal.cpp b/Minecraft.World/BreedGoal.cpp index ce2d8fff..1c46fd90 100644 --- a/Minecraft.World/BreedGoal.cpp +++ b/Minecraft.World/BreedGoal.cpp @@ -53,16 +53,19 @@ shared_ptr BreedGoal::getFreePartner() vector > *others = level->getEntitiesOfClass(typeid(*animal), animal->bb->grow(r, r, r)); double dist = Double::MAX_VALUE; shared_ptr partner = nullptr; - for(AUTO_VAR(it, others->begin()); it != others->end(); ++it) + if ( others ) { - shared_ptr p = dynamic_pointer_cast(*it); - if (animal->canMate(p) && animal->distanceToSqr(p) < dist) + for ( auto& it : *others ) { - partner = p; - dist = animal->distanceToSqr(p); + shared_ptr p = dynamic_pointer_cast(it); + if ( p && animal->canMate(p) && animal->distanceToSqr(p) < dist) + { + partner = p; + dist = animal->distanceToSqr(p); + } } + delete others; } - delete others; return partner; } -- cgit v1.2.3