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/EnderDragon.cpp | 80 ++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 36 deletions(-) (limited to 'Minecraft.World/EnderDragon.cpp') diff --git a/Minecraft.World/EnderDragon.cpp b/Minecraft.World/EnderDragon.cpp index 2dc0c434..e1dea172 100644 --- a/Minecraft.World/EnderDragon.cpp +++ b/Minecraft.World/EnderDragon.cpp @@ -444,13 +444,16 @@ void EnderDragon::aiStep() { vector > *targets = level->getEntities(shared_from_this(), m_acidArea); - for( AUTO_VAR(it, targets->begin() ); it != targets->end(); ++it) + if ( targets ) { - if ( (*it)->instanceof(eTYPE_LIVINGENTITY) ) + for (auto& it : *targets ) { - //app.DebugPrintf("Attacking entity with acid\n"); - shared_ptr e = dynamic_pointer_cast( *it ); - e->hurt(DamageSource::dragonbreath, 2); + if ( it->instanceof(eTYPE_LIVINGENTITY)) + { + //app.DebugPrintf("Attacking entity with acid\n"); + shared_ptr e = dynamic_pointer_cast(it); + e->hurt(DamageSource::dragonbreath, 2); + } } } } @@ -796,24 +799,23 @@ void EnderDragon::checkCrystals() { float maxDist = 32; vector > *crystals = level->getEntitiesOfClass(typeid(EnderCrystal), bb->grow(maxDist, maxDist, maxDist)); - - shared_ptr crystal = nullptr; - double nearest = Double::MAX_VALUE; - //for (Entity ec : crystals) - for(AUTO_VAR(it, crystals->begin()); it != crystals->end(); ++it) + if ( crystals ) { - shared_ptr ec = dynamic_pointer_cast( *it ); - double dist = ec->distanceToSqr(shared_from_this() ); - if (dist < nearest) + shared_ptr crystal = nullptr; + double nearest = Double::MAX_VALUE; + for (auto& it : *crystals ) { - nearest = dist; - crystal = ec; + shared_ptr ec = dynamic_pointer_cast(it); + double dist = ec->distanceToSqr(shared_from_this()); + if (dist < nearest) + { + nearest = dist; + crystal = ec; + } } + delete crystals; + nearestCrystal = crystal; } - delete crystals; - - - nearestCrystal = crystal; } } @@ -839,33 +841,39 @@ void EnderDragon::knockBack(vector > *entities) // double ym = (body.bb.y0 + body.bb.y1) / 2; double zm = (body->bb->z0 + body->bb->z1) / 2; - //for (Entity e : entities) - for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) + if ( entities ) { - - if ( (*it)->instanceof(eTYPE_LIVINGENTITY) )//(e instanceof Mob) + for ( auto& it : *entities ) { - shared_ptr e = dynamic_pointer_cast( *it ); - double xd = e->x - xm; - double zd = e->z - zm; - double dd = xd * xd + zd * zd; - e->push(xd / dd * 4, 0.2f, zd / dd * 4); + if (it->instanceof(eTYPE_LIVINGENTITY)) + { + shared_ptr e = dynamic_pointer_cast(it); + double xd = e->x - xm; + double zd = e->z - zm; + double dd = xd * xd + zd * zd; + e->push(xd / dd * 4, 0.2f, zd / dd * 4); + } } } } void EnderDragon::hurt(vector > *entities) { - //for (int i = 0; i < entities->size(); i++) - for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) + if ( entities ) { - - if ( (*it)->instanceof(eTYPE_LIVINGENTITY) ) //(e instanceof Mob) + for ( auto& it : *entities ) { - shared_ptr e = dynamic_pointer_cast( *it );//entities.get(i); - DamageSource *damageSource = DamageSource::mobAttack( dynamic_pointer_cast( shared_from_this() )); - e->hurt(damageSource, 10); - delete damageSource; + + if ( it->instanceof(eTYPE_LIVINGENTITY)) + { + shared_ptr e = dynamic_pointer_cast(it); + DamageSource* damageSource = DamageSource::mobAttack(dynamic_pointer_cast(shared_from_this())); + if ( damageSource ) + { + e->hurt(damageSource, 10); + delete damageSource; + } + } } } } -- cgit v1.2.3