aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/VillageSiege.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-07 21:56:03 -0500
committerGitHub <noreply@github.com>2026-03-08 09:56:03 +0700
commita9be52c41a02d207233199e98898fe7483d7e817 (patch)
tree71dfaec3a86b05e9ca409b97d8eb9d7f993bfdd0 /Minecraft.World/VillageSiege.cpp
parent1be5faaea781402e7de06b263eeca4c688b7712c (diff)
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
Diffstat (limited to 'Minecraft.World/VillageSiege.cpp')
-rw-r--r--Minecraft.World/VillageSiege.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/Minecraft.World/VillageSiege.cpp b/Minecraft.World/VillageSiege.cpp
index e3d20ef3..5a39b6eb 100644
--- a/Minecraft.World/VillageSiege.cpp
+++ b/Minecraft.World/VillageSiege.cpp
@@ -80,10 +80,10 @@ bool VillageSiege::tryToSetupSiege()
vector<shared_ptr<Player> > *players = &level->players;
for(auto& player : *players)
{
- shared_ptr<Village> _village = level->villages->getClosestVillage((int) player->x, (int) player->y, (int) player->z, 1);
+ shared_ptr<Village> _village = level->villages->getClosestVillage(static_cast<int>(player->x), static_cast<int>(player->y), static_cast<int>(player->z), 1);
village = _village;
- if (_village == NULL) continue;
+ if (_village == nullptr) continue;
if (_village->getDoorCount() < 10) continue;
if (_village->getStableAge() < 20) continue;
if (_village->getPopulationSize() < 20) continue;
@@ -95,9 +95,9 @@ bool VillageSiege::tryToSetupSiege()
bool overlaps = false;
for (int i = 0; i < 10; ++i)
{
- spawnX = center->x + (int) (Mth::cos(level->random->nextFloat() * PI * 2.f) * radius * 0.9);
+ spawnX = center->x + static_cast<int>(Mth::cos(level->random->nextFloat() * PI * 2.f) * radius * 0.9);
spawnY = center->y;
- spawnZ = center->z + (int) (Mth::sin(level->random->nextFloat() * PI * 2.f) * radius * 0.9);
+ spawnZ = center->z + static_cast<int>(Mth::sin(level->random->nextFloat() * PI * 2.f) * radius * 0.9);
overlaps = false;
vector<shared_ptr<Village> > *villages = level->villages->getVillages();
//for (Village v : level.villages.getVillages())
@@ -115,7 +115,7 @@ bool VillageSiege::tryToSetupSiege()
if (overlaps) return false;
Vec3 *spawnPos = findRandomSpawnPos(spawnX, spawnY, spawnZ);
- if (spawnPos == NULL) continue;
+ if (spawnPos == nullptr) continue;
nextSpawnTime = 0;
siegeCount = 20;
@@ -127,17 +127,17 @@ bool VillageSiege::tryToSetupSiege()
bool VillageSiege::trySpawn()
{
Vec3 *spawnPos = findRandomSpawnPos(spawnX, spawnY, spawnZ);
- if (spawnPos == NULL) return false;
+ if (spawnPos == nullptr) return false;
shared_ptr<Zombie> mob;
{
- mob = shared_ptr<Zombie>( new Zombie(level) );
- mob->finalizeMobSpawn(NULL);
+ mob = std::make_shared<Zombie>(level);
+ mob->finalizeMobSpawn(nullptr);
mob->setVillager(false);
}
mob->moveTo(spawnPos->x, spawnPos->y, spawnPos->z, level->random->nextFloat() * 360, 0);
level->addEntity(mob);
shared_ptr<Village> _village = village.lock();
- if( _village == NULL ) return false;
+ if( _village == nullptr ) return false;
Pos *center = _village->getCenter();
mob->restrictTo(center->x, center->y, center->z, _village->getRadius());
@@ -147,7 +147,7 @@ bool VillageSiege::trySpawn()
Vec3 *VillageSiege::findRandomSpawnPos(int x, int y, int z)
{
shared_ptr<Village> _village = village.lock();
- if( _village == NULL ) return NULL;
+ if( _village == nullptr ) return nullptr;
for (int i = 0; i < 10; ++i)
{
@@ -157,5 +157,5 @@ Vec3 *VillageSiege::findRandomSpawnPos(int x, int y, int z)
if (!_village->isInside(xx, yy, zz)) continue;
if (MobSpawner::isSpawnPositionOk(MobCategory::monster, level, xx, yy, zz)) return Vec3::newTemp(xx, yy, zz);
}
- return NULL;
+ return nullptr;
} \ No newline at end of file