From 55231bb8d3e1a4e2752ac3d444c4287eb0ca4e8b Mon Sep 17 00:00:00 2001 From: void_17 <61356189+void2012@users.noreply.github.com> Date: Fri, 6 Mar 2026 02:11:18 +0700 Subject: Remove AUTO_VAR macro and _toString function (#592) --- Minecraft.World/OldChunkStorage.cpp | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'Minecraft.World/OldChunkStorage.cpp') diff --git a/Minecraft.World/OldChunkStorage.cpp b/Minecraft.World/OldChunkStorage.cpp index 31f4394f..24263d0d 100644 --- a/Minecraft.World/OldChunkStorage.cpp +++ b/Minecraft.World/OldChunkStorage.cpp @@ -103,7 +103,7 @@ File OldChunkStorage::getFile(int x, int z) file = File( file, wstring( name ) ); if ( !file.exists() ) { - if (!create) + if (!create) { return File(L""); } @@ -163,7 +163,7 @@ void OldChunkStorage::save(Level *level, LevelChunk *levelChunk) { LevelData *levelData = level->getLevelData(); levelData->setSizeOnDisk( levelData->getSizeOnDisk() - file.length() ); - } + } // 4J - removed try/catch // try { @@ -202,7 +202,7 @@ bool OldChunkStorage::saveEntities(LevelChunk *lc, Level *level, CompoundTag *ta lc->lastSaveHadEntities = false; ListTag *entityTags = new ListTag(); - + #ifdef _ENTITIES_RW_SECTION EnterCriticalRWSection(&lc->m_csEntities, true); #else @@ -210,17 +210,14 @@ bool OldChunkStorage::saveEntities(LevelChunk *lc, Level *level, CompoundTag *ta #endif for (int i = 0; i < lc->ENTITY_BLOCKS_LENGTH; i++) { - AUTO_VAR(itEnd, lc->entityBlocks[i]->end()); - for( vector >::iterator it = lc->entityBlocks[i]->begin(); it != itEnd; it++ ) + for( auto& e : *lc->entityBlocks[i] ) { - shared_ptr e = *it; lc->lastSaveHadEntities = true; CompoundTag *teTag = new CompoundTag(); - if (e->save(teTag)) + if ( e && e->save(teTag)) { entityTags->add(teTag); } - } } #ifdef _ENTITIES_RW_SECTION @@ -264,15 +261,13 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, DataOutputStream *dos) #ifndef SPLIT_SAVES saveEntities(lc, level, tag); #endif - + PIXBeginNamedEvent(0,"Saving tile entities"); ListTag *tileEntityTags = new ListTag(); - AUTO_VAR(itEnd, lc->tileEntities.end()); - for( unordered_map, TilePosKeyHash, TilePosKeyEq>::iterator it = lc->tileEntities.begin(); - it != itEnd; it++) + for(auto& it : lc->tileEntities) { - shared_ptr te = it->second; + shared_ptr te = it.second; CompoundTag *teTag = new CompoundTag(); te->save(teTag); tileEntityTags->add(teTag); @@ -358,11 +353,9 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag) PIXBeginNamedEvent(0,"Saving tile entities"); ListTag *tileEntityTags = new ListTag(); - AUTO_VAR(itEnd, lc->tileEntities.end()); - for( unordered_map, TilePosKeyHash, TilePosKeyEq>::iterator it = lc->tileEntities.begin(); - it != itEnd; it++) + for(auto& it : lc->tileEntities) { - shared_ptr te = it->second; + shared_ptr te = it.second; CompoundTag *teTag = new CompoundTag(); te->save(teTag); tileEntityTags->add(teTag); @@ -451,7 +444,7 @@ LevelChunk *OldChunkStorage::load(Level *level, DataInputStream *dis) dis->readFully(levelChunk->heightmap); - levelChunk->terrainPopulated = dis->readShort(); + levelChunk->terrainPopulated = dis->readShort(); // If all neighbours have been post-processed, then we should have done the post-post-processing now. Check that this is set as if it isn't then we won't be able // to send network data for chunks, and we won't ever try and set it again as all the directional flags are now already set - should only be an issue for old maps // before this flag was added. @@ -537,13 +530,13 @@ LevelChunk *OldChunkStorage::load(Level *level, CompoundTag *tag) if( tag->get(L"TerrainPopulated") ) { // Java bool type or byte bitfield - levelChunk->terrainPopulated = tag->getByte(L"TerrainPopulated"); + levelChunk->terrainPopulated = tag->getByte(L"TerrainPopulated"); if( levelChunk->terrainPopulated >= 1 ) levelChunk->terrainPopulated = LevelChunk::sTerrainPopulatedAllNeighbours | LevelChunk::sTerrainPostPostProcessed; // Convert from old bool type to new bitfield } else { // New style short - levelChunk->terrainPopulated = tag->getShort(L"TerrainPopulatedFlags"); + levelChunk->terrainPopulated = tag->getShort(L"TerrainPopulatedFlags"); // If all neighbours have been post-processed, then we should have done the post-post-processing now. Check that this is set as if it isn't then we won't be able // to send network data for chunks, and we won't ever try and set it again as all the directional flags are now already set - should only be an issue for old maps // before this flag was added. -- cgit v1.2.3