diff options
| author | ModMaker101 <119018978+ModMaker101@users.noreply.github.com> | 2026-03-07 21:56:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-08 09:56:03 +0700 |
| commit | a9be52c41a02d207233199e98898fe7483d7e817 (patch) | |
| tree | 71dfaec3a86b05e9ca409b97d8eb9d7f993bfdd0 /Minecraft.World/BiomeCache.cpp | |
| parent | 1be5faaea781402e7de06b263eeca4c688b7712c (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/BiomeCache.cpp')
| -rw-r--r-- | Minecraft.World/BiomeCache.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Minecraft.World/BiomeCache.cpp b/Minecraft.World/BiomeCache.cpp index 54be445c..286e2f7e 100644 --- a/Minecraft.World/BiomeCache.cpp +++ b/Minecraft.World/BiomeCache.cpp @@ -10,7 +10,7 @@ BiomeCache::Block::Block(int x, int z, BiomeCache *parent) // temps = floatArray(ZONE_SIZE * ZONE_SIZE, false); // MGH - added "no clear" flag to arrayWithLength // downfall = floatArray(ZONE_SIZE * ZONE_SIZE, false); // biomes = BiomeArray(ZONE_SIZE * ZONE_SIZE, false); - biomeIndices = byteArray(ZONE_SIZE * ZONE_SIZE, false); + biomeIndices = byteArray(static_cast<unsigned int>(ZONE_SIZE * ZONE_SIZE), false); lastUse = 0; this->x = x; @@ -34,7 +34,7 @@ Biome *BiomeCache::Block::getBiome(int x, int z) { // return biomes[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)]; - int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)]; + const int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)]; return Biome::biomes[biomeIndex]; } @@ -42,7 +42,7 @@ float BiomeCache::Block::getTemperature(int x, int z) { // return temps[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)]; - int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)]; + const int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)]; return Biome::biomes[biomeIndex]->getTemperature(); } @@ -51,7 +51,7 @@ float BiomeCache::Block::getDownfall(int x, int z) { // return downfall[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)]; - int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)]; + const int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)]; return Biome::biomes[biomeIndex]->getDownfall(); } @@ -72,7 +72,7 @@ BiomeCache::~BiomeCache() // 4J Stu - Delete source? // delete source; - for( auto& it : all ) + for(const auto& it : all ) { delete it; } @@ -85,9 +85,9 @@ BiomeCache::Block *BiomeCache::getBlockAt(int x, int z) EnterCriticalSection(&m_CS); x >>= ZONE_SIZE_BITS; z >>= ZONE_SIZE_BITS; - int64_t slot = (((int64_t) x) & 0xffffffffl) | ((((int64_t) z) & 0xffffffffl) << 32l); - auto it = cached.find(slot); - Block *block = NULL; + const int64_t slot = (static_cast<int64_t>(x) & 0xffffffffl) | ((static_cast<int64_t>(z) & 0xffffffffl) << 32l); + const auto it = cached.find(slot); + Block *block = nullptr; if (it == cached.end()) { MemSect(48); @@ -124,20 +124,20 @@ float BiomeCache::getDownfall(int x, int z) void BiomeCache::update() { EnterCriticalSection(&m_CS); - int64_t now = app.getAppTime(); - int64_t utime = now - lastUpdateTime; + const int64_t now = app.getAppTime(); + const int64_t utime = now - lastUpdateTime; if (utime > DECAY_TIME / 4 || utime < 0) { lastUpdateTime = now; for (auto it = all.begin(); it != all.end();) { - Block *block = *it; - int64_t time = now - block->lastUse; + const Block *block = *it; + const int64_t time = now - block->lastUse; if (time > DECAY_TIME || time < 0) { it = all.erase(it); - int64_t slot = (((int64_t) block->x) & 0xffffffffl) | ((((int64_t) block->z) & 0xffffffffl) << 32l); + int64_t slot = (static_cast<int64_t>(block->x) & 0xffffffffl) | ((static_cast<int64_t>(block->z) & 0xffffffffl) << 32l); cached.erase(slot); delete block; } |
