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.Client/Chunk.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.Client/Chunk.cpp')
| -rw-r--r-- | Minecraft.Client/Chunk.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/Minecraft.Client/Chunk.cpp b/Minecraft.Client/Chunk.cpp index 850b79fb..6f0ad736 100644 --- a/Minecraft.Client/Chunk.cpp +++ b/Minecraft.Client/Chunk.cpp @@ -32,13 +32,13 @@ void Chunk::CreateNewThreadStorage() void Chunk::ReleaseThreadStorage() { - unsigned char *tileIds = (unsigned char *)TlsGetValue(tlsIdx); + unsigned char *tileIds = static_cast<unsigned char *>(TlsGetValue(tlsIdx)); delete tileIds; } unsigned char *Chunk::GetTileIdsStorage() { - unsigned char *tileIds = (unsigned char *)TlsGetValue(tlsIdx); + unsigned char *tileIds = static_cast<unsigned char *>(TlsGetValue(tlsIdx)); return tileIds; } #else @@ -148,7 +148,7 @@ void Chunk::setPos(int x, int y, int z) void Chunk::translateToPos() { - glTranslatef((float)xRenderOffs, (float)yRenderOffs, (float)zRenderOffs); + glTranslatef(static_cast<float>(xRenderOffs), static_cast<float>(yRenderOffs), static_cast<float>(zRenderOffs)); } @@ -173,7 +173,7 @@ void Chunk::makeCopyForRebuild(Chunk *source) this->ym = source->ym; this->zm = source->zm; this->bb = source->bb; - this->clipChunk = NULL; + this->clipChunk = nullptr; this->id = source->id; this->globalRenderableTileEntities = source->globalRenderableTileEntities; this->globalRenderableTileEntities_cs = source->globalRenderableTileEntities_cs; @@ -399,7 +399,7 @@ void Chunk::rebuild() glTranslatef(zs / 2.0f, ys / 2.0f, zs / 2.0f); #endif t->begin(); - t->offset((float)(-this->x), (float)(-this->y), (float)(-this->z)); + t->offset(static_cast<float>(-this->x), static_cast<float>(-this->y), static_cast<float>(-this->z)); } Tile *tile = Tile::tiles[tileId]; @@ -521,7 +521,7 @@ void Chunk::rebuild() else { // Easy case - nothing already existing for this chunk. Add them all in. - for( int i = 0; i < renderableTileEntities.size(); i++ ) + for( size_t i = 0; i < renderableTileEntities.size(); i++ ) { (*globalRenderableTileEntities)[key].push_back(renderableTileEntities[i]); } @@ -680,7 +680,7 @@ void Chunk::rebuild_SPU() // render chunk is 16 x 16 x 16. We wouldn't have to actually get all of it if the data was ordered differently, but currently // it is ordered by x then z then y so just getting a small range of y out of it would involve getting the whole thing into // the cache anyway. - ChunkRebuildData* pOutData = NULL; + ChunkRebuildData* pOutData = nullptr; g_rebuildDataIn.buildForChunk(®ion, level, x0, y0, z0); Tesselator::Bounds bounds; @@ -826,7 +826,7 @@ void Chunk::rebuild_SPU() } // Now go through the current list. If these are already in the list, then unflag the remove flag. If they aren't, then add - for( int i = 0; i < renderableTileEntities.size(); i++ ) + for( size_t i = 0; i < renderableTileEntities.size(); i++ ) { auto it2 = find( it->second.begin(), it->second.end(), renderableTileEntities[i] ); if( it2 == it->second.end() ) @@ -842,7 +842,7 @@ void Chunk::rebuild_SPU() else { // Easy case - nothing already existing for this chunk. Add them all in. - for( int i = 0; i < renderableTileEntities.size(); i++ ) + for( size_t i = 0; i < renderableTileEntities.size(); i++ ) { (*globalRenderableTileEntities)[key].push_back(renderableTileEntities[i]); } @@ -936,17 +936,17 @@ void Chunk::rebuild_SPU() float Chunk::distanceToSqr(shared_ptr<Entity> player) const { - float xd = (float) (player->x - xm); - float yd = (float) (player->y - ym); - float zd = (float) (player->z - zm); + float xd = static_cast<float>(player->x - xm); + float yd = static_cast<float>(player->y - ym); + float zd = static_cast<float>(player->z - zm); return xd * xd + yd * yd + zd * zd; } float Chunk::squishedDistanceToSqr(shared_ptr<Entity> player) { - float xd = (float) (player->x - xm); - float yd = (float) (player->y - ym) * 2; - float zd = (float) (player->z - zm); + float xd = static_cast<float>(player->x - xm); + float yd = static_cast<float>(player->y - ym) * 2; + float zd = static_cast<float>(player->z - zm); return xd * xd + yd * yd + zd * zd; } @@ -981,7 +981,7 @@ void Chunk::reset() void Chunk::_delete() { reset(); - level = NULL; + level = nullptr; } int Chunk::getList(int layer) |
