diff options
| author | void_17 <61356189+void2012@users.noreply.github.com> | 2026-03-06 02:11:18 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-06 02:11:18 +0700 |
| commit | 55231bb8d3e1a4e2752ac3d444c4287eb0ca4e8b (patch) | |
| tree | 953c537a5c66e328e9f4ab29626cf738112d53c0 /Minecraft.World/BreedGoal.cpp | |
| parent | 7d6658fe5b3095f35093701b5ab669ffc291e875 (diff) | |
Remove AUTO_VAR macro and _toString function (#592)
Diffstat (limited to 'Minecraft.World/BreedGoal.cpp')
| -rw-r--r-- | Minecraft.World/BreedGoal.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
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<Animal> BreedGoal::getFreePartner() vector<shared_ptr<Entity> > *others = level->getEntitiesOfClass(typeid(*animal), animal->bb->grow(r, r, r)); double dist = Double::MAX_VALUE; shared_ptr<Animal> partner = nullptr; - for(AUTO_VAR(it, others->begin()); it != others->end(); ++it) + if ( others ) { - shared_ptr<Animal> p = dynamic_pointer_cast<Animal>(*it); - if (animal->canMate(p) && animal->distanceToSqr(p) < dist) + for ( auto& it : *others ) { - partner = p; - dist = animal->distanceToSqr(p); + shared_ptr<Animal> p = dynamic_pointer_cast<Animal>(it); + if ( p && animal->canMate(p) && animal->distanceToSqr(p) < dist) + { + partner = p; + dist = animal->distanceToSqr(p); + } } + delete others; } - delete others; return partner; } |
