Project modernization (#630)

* 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
This commit is contained in:
ModMaker101
2026-03-07 21:56:03 -05:00
committed by GitHub
parent 1be5faaea7
commit a9be52c41a
1373 changed files with 19903 additions and 19449 deletions

View File

@@ -15,7 +15,7 @@ AttributeModifier *PathfinderMob::SPEED_MODIFIER_FLEEING = (new AttributeModifie
PathfinderMob::PathfinderMob(Level *level) : Mob( level )
{
path = NULL;
path = nullptr;
attackTarget = nullptr;
holdGround = false;
fleeTime = 0;
@@ -51,10 +51,10 @@ void PathfinderMob::serverAiStep()
holdGround = shouldHoldGround();
float maxDist = 16;
if (attackTarget == NULL)
if (attackTarget == nullptr)
{
attackTarget = findAttackTarget();
if (attackTarget != NULL)
if (attackTarget != nullptr)
{
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 != NULL && (path == NULL || random->nextInt(20) == 0)))
if (!holdGround && (attackTarget != nullptr && (path == nullptr || 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 == NULL && (random->nextInt(180) == 0) || fleeTime > 0) || (random->nextInt(120) == 0 || fleeTime > 0)))
else if (!holdGround && ((path == nullptr && (random->nextInt(180) == 0) || fleeTime > 0) || (random->nextInt(120) == 0 || fleeTime > 0)))
{
if(noActionTime < SharedConstants::TICKS_PER_SECOND * 5)
{
findRandomStrollLocation();
}
}
else if (!holdGround && (path == NULL ) )
else if (!holdGround && (path == nullptr ) )
{
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 == NULL || random->nextInt(100) == 0)
if (path == nullptr || random->nextInt(100) == 0)
{
this->Mob::serverAiStep();
setPath(NULL);// 4J - changed to setPath from path =
setPath(nullptr);// 4J - changed to setPath from path =
return;
}
Vec3 *target = path->currentPos(shared_from_this());
double r = bbWidth * 2;
while (target != NULL && target->distanceToSqr(x, target->y, z) < r * r)
while (target != nullptr && target->distanceToSqr(x, target->y, z) < r * r)
{
path->next();
if (path->isDone())
{
target = NULL;
setPath(NULL); // 4J - changed to setPath from path =
target = nullptr;
setPath(nullptr); // 4J - changed to setPath from path =
}
else target = path->currentPos(shared_from_this());
}
jumping = false;
if (target != NULL)
if (target != nullptr)
{
double xd = target->x - x;
double zd = target->z - z;
double yd = target->y - yFloor;
float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90;
float yRotD = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90;
float rotDiff = Mth::wrapDegrees(yRotD - yRot);
yya = (float) getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue();
yya = static_cast<float>(getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue());
if (rotDiff > MAX_TURN)
{
rotDiff = MAX_TURN;
@@ -156,13 +156,13 @@ void PathfinderMob::serverAiStep()
if (holdGround)
{
if (attackTarget != NULL)
if (attackTarget != nullptr)
{
double xd2 = attackTarget->x - x;
double zd2 = attackTarget->z - z;
float oldyRot = yRot;
yRot = (float) (atan2(zd2, xd2) * 180 / PI) - 90;
yRot = static_cast<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 != NULL)
if (attackTarget != nullptr)
{
lookAt(attackTarget, 30, 30);
}
@@ -250,7 +250,7 @@ bool PathfinderMob::canSpawn()
bool PathfinderMob::isPathFinding()
{
return path != NULL;
return path != nullptr;
}
void PathfinderMob::setPath(Path *path)
@@ -311,16 +311,16 @@ void PathfinderMob::tickLeash()
{
Mob::tickLeash();
if (isLeashed() && getLeashHolder() != NULL && getLeashHolder()->level == this->level)
if (isLeashed() && getLeashHolder() != nullptr && getLeashHolder()->level == this->level)
{
// soft restriction
shared_ptr<Entity> leashHolder = getLeashHolder();
restrictTo((int) leashHolder->x, (int) leashHolder->y, (int) leashHolder->z, 5);
restrictTo(static_cast<int>(leashHolder->x), static_cast<int>(leashHolder->y), static_cast<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 != NULL) && tamabaleAnimal->isSitting() )
if ( (tamabaleAnimal != nullptr) && tamabaleAnimal->isSitting() )
{
if (_distanceTo > 10)
{