diff options
| author | ModMaker101 <119018978+ModMaker101@users.noreply.github.com> | 2026-03-08 19:08:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-08 18:08:36 -0500 |
| commit | 28614b922fb77149a54da1a87bebfbc98736f296 (patch) | |
| tree | 7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.World/Village.cpp | |
| parent | 88798b501d0cf6287b6f87acb2592676e3cec58d (diff) | |
Modernize project codebase (#906)
* 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
* Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.World/Village.cpp')
| -rw-r--r-- | Minecraft.World/Village.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Minecraft.World/Village.cpp b/Minecraft.World/Village.cpp index a72319fe..b7c82fa4 100644 --- a/Minecraft.World/Village.cpp +++ b/Minecraft.World/Village.cpp @@ -25,7 +25,7 @@ Village::Village() golemCount = 0; noBreedTimer = 0; - level = NULL; + level = nullptr; } Village::Village(Level *level) @@ -69,9 +69,9 @@ void Village::tick(int tick) if (golemCount < idealGolemCount && doorInfos.size() > 20 && level->random->nextInt(7000) == 0) { Vec3 *spawnPos = findRandomSpawnPos(center->x, center->y, center->z, 2, 4, 2); - if (spawnPos != NULL) + if (spawnPos != nullptr) { - shared_ptr<VillagerGolem> vg = shared_ptr<VillagerGolem>( new VillagerGolem(level) ); + shared_ptr<VillagerGolem> vg = std::make_shared<VillagerGolem>(level); vg->setPos(spawnPos->x, spawnPos->y, spawnPos->z); level->addEntity(vg); ++golemCount; @@ -103,7 +103,7 @@ Vec3 *Village::findRandomSpawnPos(int x, int y, int z, int sx, int sy, int sz) if (!isInside(xx, yy, zz)) continue; if (canSpawnAt(xx, yy, zz, sx, sy, sz)) return Vec3::newTemp(xx, yy, zz); } - return NULL; + return nullptr; } bool Village::canSpawnAt(int x, int y, int z, int sx, int sy, int sz) @@ -215,7 +215,7 @@ shared_ptr<DoorInfo>Village::getBestDoorInfo(int x, int y, int z) bool Village::hasDoorInfo(int x, int y, int z) { - return getDoorInfo(x, y, z) != NULL; + return getDoorInfo(x, y, z) != nullptr; } shared_ptr<DoorInfo> Village::getDoorInfo(int x, int y, int z) @@ -260,7 +260,7 @@ void Village::addAggressor(shared_ptr<LivingEntity> mob) shared_ptr<LivingEntity> Village::getClosestAggressor(shared_ptr<LivingEntity> from) { double closestSqr = Double::MAX_VALUE; - Aggressor *closest = NULL; + Aggressor *closest = nullptr; for(auto& a : aggressors) { double distSqr = a->mob->distanceToSqr(from); @@ -268,7 +268,7 @@ shared_ptr<LivingEntity> Village::getClosestAggressor(shared_ptr<LivingEntity> f closest = a; closestSqr = distSqr; } - return closest != NULL ? closest->mob : nullptr; + return closest != nullptr ? closest->mob : nullptr; } shared_ptr<Player> Village::getClosestBadStandingPlayer(shared_ptr<LivingEntity> from) @@ -282,7 +282,7 @@ shared_ptr<Player> Village::getClosestBadStandingPlayer(shared_ptr<LivingEntity> if (isVeryBadStanding(player)) { shared_ptr<Player> mob = level->getPlayerByName(player); - if (mob != NULL) + if (mob != nullptr) { double distSqr = mob->distanceToSqr(from); if (distSqr > closestSqr) continue; @@ -422,7 +422,7 @@ void Village::readAdditionalSaveData(CompoundTag *tag) { CompoundTag *dTag = doorTags->get(i); - shared_ptr<DoorInfo> door = shared_ptr<DoorInfo>(new DoorInfo(dTag->getInt(L"X"), dTag->getInt(L"Y"), dTag->getInt(L"Z"), dTag->getInt(L"IDX"), dTag->getInt(L"IDZ"), dTag->getInt(L"TS"))); + shared_ptr<DoorInfo> door = std::make_shared<DoorInfo>(dTag->getInt(L"X"), dTag->getInt(L"Y"), dTag->getInt(L"Z"), dTag->getInt(L"IDX"), dTag->getInt(L"IDZ"), dTag->getInt(L"TS")); doorInfos.push_back(door); } |
