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/OldChunkStorage.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/OldChunkStorage.cpp')
| -rw-r--r-- | Minecraft.World/OldChunkStorage.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/Minecraft.World/OldChunkStorage.cpp b/Minecraft.World/OldChunkStorage.cpp index 983c517d..9a8822fa 100644 --- a/Minecraft.World/OldChunkStorage.cpp +++ b/Minecraft.World/OldChunkStorage.cpp @@ -9,7 +9,7 @@ #include "FileHeader.h" #include "OldChunkStorage.h" DWORD OldChunkStorage::tlsIdx = 0; -OldChunkStorage::ThreadStorage *OldChunkStorage::tlsDefault = NULL; +OldChunkStorage::ThreadStorage *OldChunkStorage::tlsDefault = nullptr; OldChunkStorage::ThreadStorage::ThreadStorage() { @@ -30,7 +30,7 @@ OldChunkStorage::ThreadStorage::~ThreadStorage() void OldChunkStorage::CreateNewThreadStorage() { ThreadStorage *tls = new ThreadStorage(); - if(tlsDefault == NULL ) + if(tlsDefault == nullptr ) { tlsIdx = TlsAlloc(); tlsDefault = tls; @@ -45,7 +45,7 @@ void OldChunkStorage::UseDefaultThreadStorage() void OldChunkStorage::ReleaseThreadStorage() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx)); if( tls == tlsDefault ) return; delete tls; @@ -126,14 +126,14 @@ LevelChunk *OldChunkStorage::load(Level *level, int x, int z) char buf[256]; sprintf(buf,"Chunk file at %d, %d is missing level data, skipping\n",x,z); app.DebugPrintf(buf); - return NULL; + return nullptr; } if (!tag->getCompound(L"Level")->contains(L"Blocks")) { char buf[256]; sprintf(buf,"Chunk file at %d, %d is missing block data, skipping\n",x,z); app.DebugPrintf(buf); - return NULL; + return nullptr; } LevelChunk *levelChunk = OldChunkStorage::load(level, tag->getCompound(L"Level")); if (!levelChunk->isAt(x, z)) @@ -152,7 +152,7 @@ LevelChunk *OldChunkStorage::load(Level *level, int x, int z) // e.printStackTrace(); // } } - return NULL; + return nullptr; } void OldChunkStorage::save(Level *level, LevelChunk *levelChunk) @@ -277,7 +277,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, DataOutputStream *dos) PIXBeginNamedEvent(0,"Saving tile tick data"); vector<TickNextTickData > *ticksInChunk = level->fetchTicksInChunk(lc, false); - if (ticksInChunk != NULL) + if (ticksInChunk != nullptr) { int64_t levelTime = level->getGameTime(); @@ -290,7 +290,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, DataOutputStream *dos) teTag->putInt(L"x", td.x); teTag->putInt(L"y", td.y); teTag->putInt(L"z", td.z); - teTag->putInt(L"t", (int) (td.m_delay - levelTime)); + teTag->putInt(L"t", static_cast<int>(td.m_delay - levelTime)); tickTags->add(teTag); } @@ -318,7 +318,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag) // Will be fine so long as we only actually create tags for once chunk at a time. // 4J Stu - As we now save on multiple threads, the static data has been moved to TLS - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx)); PIXBeginNamedEvent(0,"Getting block data"); //static byteArray blockData = byteArray(32768); @@ -365,7 +365,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag) PIXBeginNamedEvent(0,"Saving tile tick data"); vector<TickNextTickData > *ticksInChunk = level->fetchTicksInChunk(lc, false); - if (ticksInChunk != NULL) + if (ticksInChunk != nullptr) { int64_t levelTime = level->getGameTime(); @@ -378,7 +378,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag) teTag->putInt(L"x", td.x); teTag->putInt(L"y", td.y); teTag->putInt(L"z", td.z); - teTag->putInt(L"t", (int) (td.m_delay - levelTime)); + teTag->putInt(L"t", static_cast<int>(td.m_delay - levelTime)); teTag->putInt(L"p", td.priorityTilt); tickTags->add(teTag); @@ -393,14 +393,14 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag) void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *tag) { ListTag<CompoundTag> *entityTags = (ListTag<CompoundTag> *) tag->getList(L"Entities"); - if (entityTags != NULL) + if (entityTags != nullptr) { for (int i = 0; i < entityTags->size(); i++) { CompoundTag *teTag = entityTags->get(i); shared_ptr<Entity> te = EntityIO::loadStatic(teTag, level); lc->lastSaveHadEntities = true; - if (te != NULL) + if (te != nullptr) { lc->addEntity(te); } @@ -408,13 +408,13 @@ void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *ta } ListTag<CompoundTag> *tileEntityTags = (ListTag<CompoundTag> *) tag->getList(L"TileEntities"); - if (tileEntityTags != NULL) + if (tileEntityTags != nullptr) { for (int i = 0; i < tileEntityTags->size(); i++) { CompoundTag *teTag = tileEntityTags->get(i); shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag); - if (te != NULL) + if (te != nullptr) { lc->addTileEntity(te); } @@ -476,7 +476,7 @@ LevelChunk *OldChunkStorage::load(Level *level, DataInputStream *dis) PIXBeginNamedEvent(0,"Loading TileTicks"); ListTag<CompoundTag> *tileTicks = (ListTag<CompoundTag> *) tag->getList(L"TileTicks"); - if (tileTicks != NULL) + if (tileTicks != nullptr) { for (int i = 0; i < tileTicks->size(); i++) { @@ -556,7 +556,7 @@ LevelChunk *OldChunkStorage::load(Level *level, CompoundTag *tag) // 4J removed - we shouldn't need this any more #if 0 - if (levelChunk->heightmap.data == NULL || !levelChunk->skyLight->isValid()) + if (levelChunk->heightmap.data == nullptr || !levelChunk->skyLight->isValid()) { static int chunksUpdated = 0; delete [] levelChunk->heightmap.data; @@ -594,7 +594,7 @@ LevelChunk *OldChunkStorage::load(Level *level, CompoundTag *tag) { ListTag<CompoundTag> *tileTicks = (ListTag<CompoundTag> *) tag->getList(L"TileTicks"); - if (tileTicks != NULL) + if (tileTicks != nullptr) { for (int i = 0; i < tileTicks->size(); i++) { |
