diff options
| author | Loki Rautio <lokirautio@gmail.com> | 2026-03-07 21:12:22 -0600 |
|---|---|---|
| committer | Loki Rautio <lokirautio@gmail.com> | 2026-03-07 21:12:22 -0600 |
| commit | 087b7e7abfe81dd7f0fdcdea36ac9f245950df1a (patch) | |
| tree | 69454763e73ca764af4e682d3573080b13138a0e /Minecraft.World/PathfinderMob.cpp | |
| parent | a9be52c41a02d207233199e98898fe7483d7e817 (diff) | |
Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.
This reverts commit a9be52c41a02d207233199e98898fe7483d7e817.
Diffstat (limited to 'Minecraft.World/PathfinderMob.cpp')
| -rw-r--r-- | Minecraft.World/PathfinderMob.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/Minecraft.World/PathfinderMob.cpp b/Minecraft.World/PathfinderMob.cpp index 840a6020..c01790e7 100644 --- a/Minecraft.World/PathfinderMob.cpp +++ b/Minecraft.World/PathfinderMob.cpp @@ -15,7 +15,7 @@ AttributeModifier *PathfinderMob::SPEED_MODIFIER_FLEEING = (new AttributeModifie PathfinderMob::PathfinderMob(Level *level) : Mob( level ) { - path = nullptr; + path = NULL; attackTarget = nullptr; holdGround = false; fleeTime = 0; @@ -51,10 +51,10 @@ void PathfinderMob::serverAiStep() holdGround = shouldHoldGround(); float maxDist = 16; - if (attackTarget == nullptr) + if (attackTarget == NULL) { attackTarget = findAttackTarget(); - if (attackTarget != nullptr) + if (attackTarget != NULL) { setPath(level->findPath(shared_from_this(), attackTarget, maxDist, true, false, false, true)); // 4J - changed to setPath from path = } @@ -84,18 +84,18 @@ void PathfinderMob::serverAiStep() // they aren't enclosed. We don't want the extra network overhead of just having Everything wandering round all the time, so have put a management system in place // that selects a subset of entities which have had their flag set through the considerForExtraWandering method so that these can keep doing random strolling. - if (!holdGround && (attackTarget != nullptr && (path == nullptr || random->nextInt(20) == 0))) + if (!holdGround && (attackTarget != NULL && (path == NULL || random->nextInt(20) == 0))) { setPath(level->findPath(shared_from_this(), attackTarget, maxDist, true, false, false, true));// 4J - changed to setPath from path = } - else if (!holdGround && ((path == nullptr && (random->nextInt(180) == 0) || fleeTime > 0) || (random->nextInt(120) == 0 || fleeTime > 0))) + else if (!holdGround && ((path == NULL && (random->nextInt(180) == 0) || fleeTime > 0) || (random->nextInt(120) == 0 || fleeTime > 0))) { if(noActionTime < SharedConstants::TICKS_PER_SECOND * 5) { findRandomStrollLocation(); } } - else if (!holdGround && (path == nullptr ) ) + else if (!holdGround && (path == NULL ) ) { if( ( noActionTime >= SharedConstants::TICKS_PER_SECOND * 5 ) && isExtraWanderingEnabled() ) { @@ -115,35 +115,35 @@ void PathfinderMob::serverAiStep() bool inWater = isInWater(); bool inLava = isInLava(); xRot = 0; - if (path == nullptr || random->nextInt(100) == 0) + if (path == NULL || random->nextInt(100) == 0) { this->Mob::serverAiStep(); - setPath(nullptr);// 4J - changed to setPath from path = + setPath(NULL);// 4J - changed to setPath from path = return; } Vec3 *target = path->currentPos(shared_from_this()); double r = bbWidth * 2; - while (target != nullptr && target->distanceToSqr(x, target->y, z) < r * r) + while (target != NULL && target->distanceToSqr(x, target->y, z) < r * r) { path->next(); if (path->isDone()) { - target = nullptr; - setPath(nullptr); // 4J - changed to setPath from path = + target = NULL; + setPath(NULL); // 4J - changed to setPath from path = } else target = path->currentPos(shared_from_this()); } jumping = false; - if (target != nullptr) + if (target != NULL) { double xd = target->x - x; double zd = target->z - z; double yd = target->y - yFloor; - float yRotD = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90; + float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90; float rotDiff = Mth::wrapDegrees(yRotD - yRot); - yya = static_cast<float>(getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue()); + yya = (float) getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue(); if (rotDiff > MAX_TURN) { rotDiff = MAX_TURN; @@ -156,13 +156,13 @@ void PathfinderMob::serverAiStep() if (holdGround) { - if (attackTarget != nullptr) + if (attackTarget != NULL) { double xd2 = attackTarget->x - x; double zd2 = attackTarget->z - z; float oldyRot = yRot; - yRot = static_cast<float>(atan2(zd2, xd2) * 180 / PI) - 90; + yRot = (float) (atan2(zd2, xd2) * 180 / PI) - 90; rotDiff = ((oldyRot - yRot) + 90) * PI / 180; xxa = -Mth::sin(rotDiff) * yya * 1.0f; @@ -175,7 +175,7 @@ void PathfinderMob::serverAiStep() } } - if (attackTarget != nullptr) + if (attackTarget != NULL) { lookAt(attackTarget, 30, 30); } @@ -250,7 +250,7 @@ bool PathfinderMob::canSpawn() bool PathfinderMob::isPathFinding() { - return path != nullptr; + return path != NULL; } void PathfinderMob::setPath(Path *path) @@ -311,16 +311,16 @@ void PathfinderMob::tickLeash() { Mob::tickLeash(); - if (isLeashed() && getLeashHolder() != nullptr && getLeashHolder()->level == this->level) + if (isLeashed() && getLeashHolder() != NULL && getLeashHolder()->level == this->level) { // soft restriction shared_ptr<Entity> leashHolder = getLeashHolder(); - restrictTo(static_cast<int>(leashHolder->x), static_cast<int>(leashHolder->y), static_cast<int>(leashHolder->z), 5); + restrictTo((int) leashHolder->x, (int) leashHolder->y, (int) leashHolder->z, 5); float _distanceTo = distanceTo(leashHolder); shared_ptr<TamableAnimal> tamabaleAnimal = shared_from_this()->instanceof(eTYPE_TAMABLE_ANIMAL) ? dynamic_pointer_cast<TamableAnimal>(shared_from_this()) : nullptr; - if ( (tamabaleAnimal != nullptr) && tamabaleAnimal->isSitting() ) + if ( (tamabaleAnimal != NULL) && tamabaleAnimal->isSitting() ) { if (_distanceTo > 10) { |
