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 a9be52c41a.
This commit is contained in:
@@ -16,7 +16,7 @@ PathNavigation::PathNavigation(Mob *mob, Level *level)
|
||||
this->level = level;
|
||||
dist = mob->getAttribute(SharedMonsterAttributes::FOLLOW_RANGE);
|
||||
|
||||
path = nullptr;
|
||||
path = NULL;
|
||||
speedModifier = 0.0;
|
||||
avoidSun = false;
|
||||
_tick = 0;
|
||||
@@ -30,7 +30,7 @@ PathNavigation::PathNavigation(Mob *mob, Level *level)
|
||||
|
||||
PathNavigation::~PathNavigation()
|
||||
{
|
||||
if(path != nullptr) delete path;
|
||||
if(path != NULL) delete path;
|
||||
delete lastStuckCheckPos;
|
||||
}
|
||||
|
||||
@@ -81,19 +81,19 @@ void PathNavigation::setCanFloat(bool canFloat)
|
||||
|
||||
float PathNavigation::getMaxDist()
|
||||
{
|
||||
return static_cast<float>(dist->getValue());
|
||||
return (float) dist->getValue();
|
||||
}
|
||||
|
||||
Path *PathNavigation::createPath(double x, double y, double z)
|
||||
{
|
||||
if (!canUpdatePath()) return nullptr;
|
||||
return level->findPath(mob->shared_from_this(), Mth::floor(x), static_cast<int>(y), Mth::floor(z), getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat);
|
||||
if (!canUpdatePath()) return NULL;
|
||||
return level->findPath(mob->shared_from_this(), Mth::floor(x), (int) y, Mth::floor(z), getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat);
|
||||
}
|
||||
|
||||
bool PathNavigation::moveTo(double x, double y, double z, double speedModifier)
|
||||
{
|
||||
MemSect(52);
|
||||
Path *newPath = createPath(Mth::floor(x), static_cast<int>(y), Mth::floor(z));
|
||||
Path *newPath = createPath(Mth::floor(x), (int) y, Mth::floor(z));
|
||||
MemSect(0);
|
||||
// No need to delete newPath here as this will be copied into the member variable path and the class can assume responsibility for it
|
||||
return moveTo(newPath, speedModifier);
|
||||
@@ -101,7 +101,7 @@ bool PathNavigation::moveTo(double x, double y, double z, double speedModifier)
|
||||
|
||||
Path *PathNavigation::createPath(shared_ptr<Entity> target)
|
||||
{
|
||||
if (!canUpdatePath()) return nullptr;
|
||||
if (!canUpdatePath()) return NULL;
|
||||
return level->findPath(mob->shared_from_this(), target, getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat);
|
||||
}
|
||||
|
||||
@@ -111,21 +111,21 @@ bool PathNavigation::moveTo(shared_ptr<Entity> target, double speedModifier)
|
||||
Path *newPath = createPath(target);
|
||||
MemSect(0);
|
||||
// No need to delete newPath here as this will be copied into the member variable path and the class can assume responsibility for it
|
||||
if (newPath != nullptr) return moveTo(newPath, speedModifier);
|
||||
if (newPath != NULL) return moveTo(newPath, speedModifier);
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool PathNavigation::moveTo(Path *newPath, double speedModifier)
|
||||
{
|
||||
if(newPath == nullptr)
|
||||
if(newPath == NULL)
|
||||
{
|
||||
if(path != nullptr) delete path;
|
||||
path = nullptr;
|
||||
if(path != NULL) delete path;
|
||||
path = NULL;
|
||||
return false;
|
||||
}
|
||||
if(!newPath->sameAs(path))
|
||||
{
|
||||
if(path != nullptr) delete path;
|
||||
if(path != NULL) delete path;
|
||||
path = newPath;
|
||||
}
|
||||
else
|
||||
@@ -158,7 +158,7 @@ void PathNavigation::tick()
|
||||
|
||||
if (isDone()) return;
|
||||
Vec3 *target = path->currentPos(mob->shared_from_this());
|
||||
if (target == nullptr) return;
|
||||
if (target == NULL) return;
|
||||
|
||||
mob->getMoveControl()->setWantedPosition(target->x, target->y, target->z, speedModifier);
|
||||
}
|
||||
@@ -169,9 +169,9 @@ void PathNavigation::updatePath()
|
||||
|
||||
// find first elevations in path
|
||||
int firstElevation = path->getSize();
|
||||
for (int i = path->getIndex(); path != nullptr && i < path->getSize(); ++i)
|
||||
for (int i = path->getIndex(); path != NULL && i < path->getSize(); ++i)
|
||||
{
|
||||
if (static_cast<int>(path->get(i)->y) != static_cast<int>(mobPos->y))
|
||||
if ((int) path->get(i)->y != (int) mobPos->y)
|
||||
{
|
||||
firstElevation = i;
|
||||
break;
|
||||
@@ -191,8 +191,8 @@ void PathNavigation::updatePath()
|
||||
}
|
||||
|
||||
// smooth remaining on same elevation
|
||||
int sx = static_cast<int>(ceil(mob->bbWidth));
|
||||
int sy = static_cast<int>(mob->bbHeight) + 1;
|
||||
int sx = (int) ceil(mob->bbWidth);
|
||||
int sy = (int) mob->bbHeight + 1;
|
||||
int sz = sx;
|
||||
for (int i = firstElevation - 1; i >= path->getIndex(); --i)
|
||||
{
|
||||
@@ -216,13 +216,13 @@ void PathNavigation::updatePath()
|
||||
|
||||
bool PathNavigation::isDone()
|
||||
{
|
||||
return path == nullptr || path->isDone();
|
||||
return path == NULL || path->isDone();
|
||||
}
|
||||
|
||||
void PathNavigation::stop()
|
||||
{
|
||||
if(path != nullptr) delete path;
|
||||
path = nullptr;
|
||||
if(path != NULL) delete path;
|
||||
path = NULL;
|
||||
}
|
||||
|
||||
Vec3 *PathNavigation::getTempMobPos()
|
||||
@@ -232,16 +232,16 @@ Vec3 *PathNavigation::getTempMobPos()
|
||||
|
||||
int PathNavigation::getSurfaceY()
|
||||
{
|
||||
if (!mob->isInWater() || !canFloat) return static_cast<int>(mob->bb->y0 + 0.5);
|
||||
if (!mob->isInWater() || !canFloat) return (int) (mob->bb->y0 + 0.5);
|
||||
|
||||
int surface = static_cast<int>(mob->bb->y0);
|
||||
int surface = (int) (mob->bb->y0);
|
||||
int tileId = level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z));
|
||||
int steps = 0;
|
||||
while (tileId == Tile::water_Id || tileId == Tile::calmWater_Id)
|
||||
{
|
||||
++surface;
|
||||
tileId = level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z));
|
||||
if (++steps > 16) return static_cast<int>(mob->bb->y0);
|
||||
if (++steps > 16) return (int) (mob->bb->y0);
|
||||
}
|
||||
return surface;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ bool PathNavigation::isInLiquid()
|
||||
|
||||
void PathNavigation::trimPathFromSun()
|
||||
{
|
||||
if (level->canSeeSky(Mth::floor(mob->x), static_cast<int>(mob->bb->y0 + 0.5), Mth::floor(mob->z))) return;
|
||||
if (level->canSeeSky(Mth::floor(mob->x), (int) (mob->bb->y0 + 0.5), Mth::floor(mob->z))) return;
|
||||
|
||||
for (int i = 0; i < path->getSize(); ++i)
|
||||
{
|
||||
@@ -288,7 +288,7 @@ bool PathNavigation::canMoveDirectly(Vec3 *startPos, Vec3 *stopPos, int sx, int
|
||||
|
||||
sx += 2;
|
||||
sz += 2;
|
||||
if (!canWalkOn(gridPosX, static_cast<int>(startPos->y), gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false;
|
||||
if (!canWalkOn(gridPosX, (int) startPos->y, gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false;
|
||||
sx -= 2;
|
||||
sz -= 2;
|
||||
|
||||
@@ -323,7 +323,7 @@ bool PathNavigation::canMoveDirectly(Vec3 *startPos, Vec3 *stopPos, int sx, int
|
||||
currentDirZ = gridGoalZ - gridPosZ;
|
||||
}
|
||||
|
||||
if (!canWalkOn(gridPosX, static_cast<int>(startPos->y), gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false;
|
||||
if (!canWalkOn(gridPosX, (int) startPos->y, gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user