From 9fe4b61df35ebad8df7b928af73bc798ebaf731f Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:26:55 -0700 Subject: WorldStorage/CMakeLists.txt: Replaced glob with list of files --- src/WorldStorage/CMakeLists.txt | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt index 2844f7fe5..212581400 100644 --- a/src/WorldStorage/CMakeLists.txt +++ b/src/WorldStorage/CMakeLists.txt @@ -4,11 +4,32 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + EnchantmentSerializer.cpp + FastNBT.cpp + FireworksSerializer.cpp + MapSerializer.cpp + NBTChunkSerializer.cpp + SchematicFileSerializer.cpp + ScoreboardSerializer.cpp + StatSerializer.cpp + WSSAnvil.cpp + WSSCompact.cpp + WorldStorage.cpp) -add_library(WorldStorage ${SOURCE}) +SET (HDRS + EnchantmentSerializer.h + FastNBT.h + FireworksSerializer.h + MapSerializer.h + NBTChunkSerializer.h + SchematicFileSerializer.h + ScoreboardSerializer.h + StatSerializer.h + WSSAnvil.h + WSSCompact.h + WorldStorage.h) + +add_library(WorldStorage ${SRCS} ${HDRS}) target_link_libraries(WorldStorage OSSupport) -- cgit v1.2.3 From 725d1fd1e2995b1720673c280fea1125ac338b3c Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 13:26:43 -0700 Subject: Subdirs: Only add_library if not using MSVC --- src/WorldStorage/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt index 212581400..a00ff3b2f 100644 --- a/src/WorldStorage/CMakeLists.txt +++ b/src/WorldStorage/CMakeLists.txt @@ -30,6 +30,8 @@ SET (HDRS WSSCompact.h WorldStorage.h) -add_library(WorldStorage ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(WorldStorage ${SRCS} ${HDRS}) -target_link_libraries(WorldStorage OSSupport) + target_link_libraries(WorldStorage OSSupport) +endif() -- cgit v1.2.3 From f5bcfdc58c7b5d69abbb222787bb2229c0b54088 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:51:39 -0700 Subject: Splash potions: Renamed PotionParticleType to PotionColor for clarity --- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index e68903b26..62db302ef 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -613,7 +613,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration()); m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity()); m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier()); - m_Writer.AddInt("PotionName", Potion->GetPotionParticleType()); + m_Writer.AddInt("PotionName", Potion->GetPotionColor()); } case cProjectileEntity::pkGhastFireball: { diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index b4048b097..663d489bc 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1681,7 +1681,7 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType")); SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier)); - SplashPotion->SetPotionParticleType(a_NBT.FindChildByName(a_TagIdx, "PotionName")); + SplashPotion->SetPotionColor(a_NBT.FindChildByName(a_TagIdx, "PotionName")); // Store the new splash potion in the entities list: a_Entities.push_back(SplashPotion.release()); -- cgit v1.2.3 From 00c524519ef6c7ceaf4ac91307617cfd65d7cf21 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 14:53:41 +0200 Subject: Fixed style: spaces after commas. --- src/WorldStorage/WSSAnvil.h | 2 +- src/WorldStorage/WorldStorage.cpp | 6 +++--- src/WorldStorage/WorldStorage.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 5b629f017..9f8714404 100644 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -153,7 +153,7 @@ protected: void LoadPickupFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadTNTFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadExpOrbFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); - void LoadHangingFromNBT (cHangingEntity & a_Hanging,const cParsedNBT & a_NBT, int a_TagIdx); + void LoadHangingFromNBT (cHangingEntity & a_Hanging, const cParsedNBT & a_NBT, int a_TagIdx); void LoadItemFrameFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadMinecartRFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index 155aa6b14..d0b2acf3b 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -163,7 +163,7 @@ void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ) { - m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ,true)); + m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ, true)); } @@ -182,8 +182,8 @@ void cWorldStorage::UnqueueSave(const cChunkCoords & a_Chunk) void cWorldStorage::InitSchemas(int a_StorageCompressionFactor) { // The first schema added is considered the default - m_Schemas.push_back(new cWSSAnvil (m_World,a_StorageCompressionFactor)); - m_Schemas.push_back(new cWSSCompact (m_World,a_StorageCompressionFactor)); + m_Schemas.push_back(new cWSSAnvil (m_World, a_StorageCompressionFactor)); + m_Schemas.push_back(new cWSSCompact (m_World, a_StorageCompressionFactor)); m_Schemas.push_back(new cWSSForgetful(m_World)); // Add new schemas here diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index bf764a539..4d4c46a71 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -109,7 +109,7 @@ protected: }; }; - typedef cQueue sChunkLoadQueue; + typedef cQueue sChunkLoadQueue; cWorld * m_World; AString m_StorageSchemaName; -- cgit v1.2.3 From 08748bafe26145cd61a179abd131a9dba6065450 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 15:23:40 +0200 Subject: Code style: Fixed braces on separate lines. --- src/WorldStorage/WorldStorage.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 4d4c46a71..2d5d9c830 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -101,9 +101,10 @@ protected: } } ; - struct FuncTable { + struct FuncTable + { static void Delete(sChunkLoad) {}; - static void Combine(sChunkLoad& a_orig, const sChunkLoad a_new) + static void Combine(sChunkLoad & a_orig, const sChunkLoad a_new) { a_orig.m_Generate |= a_new.m_Generate; }; -- cgit v1.2.3 From e8262373e1608c5527779953c9a677dac7b020d8 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 03:19:46 -0700 Subject: NBTChunkSerializer.cpp: Added break after serializing the splash potion --- src/WorldStorage/NBTChunkSerializer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 62db302ef..4857da1b6 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -614,6 +614,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity()); m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier()); m_Writer.AddInt("PotionName", Potion->GetPotionColor()); + break; } case cProjectileEntity::pkGhastFireball: { -- cgit v1.2.3 From 6be79575fd50e37ac275bd0cb9d16f9e51e8a225 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Jul 2014 23:10:31 +0200 Subject: Style: Normalized spaces after if, for and while. --- src/WorldStorage/WSSCompact.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index ff43b6905..aae94141c 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -486,12 +486,12 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ return; } - if( m_ChunkVersion == 1 ) // Convert chunks to version 2 + if (m_ChunkVersion == 1 ) // Convert chunks to version 2 { UpdateChunk1To2(); } #if AXIS_ORDER == AXIS_ORDER_XZY - if( m_ChunkVersion == 2 ) // Convert chunks to version 3 + if (m_ChunkVersion == 2 ) // Convert chunks to version 3 { UpdateChunk2To3(); } @@ -574,7 +574,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() { sChunkHeader * Header = *itr; - if( ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0 ) { LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); } @@ -627,9 +627,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() char ConvertedData[cChunkDef::BlockDataSize]; int Index = 0; unsigned int InChunkOffset = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) { - for( int y = 0; y < 128; ++y ) + for (int y = 0; y < 128; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 128 + x * 128 * 16 + InChunkOffset]; } @@ -638,9 +638,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 128; } InChunkOffset += (16 * 128 * 16); - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Metadata + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Metadata { - for( int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -648,9 +648,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16 * 128 * 16) / 2; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Block light + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Block light { - for( int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -658,9 +658,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16*128*16)/2; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Sky light + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Sky light { - for( int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -718,7 +718,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() { sChunkHeader * Header = *itr; - if( ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0 ) { LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); } @@ -774,7 +774,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() #define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) ) unsigned int InChunkOffset = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X { ConvertedData[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset]; ++InChunkOffset; @@ -782,7 +782,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() unsigned int index2 = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) { ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); ++index2; @@ -790,7 +790,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() InChunkOffset += index2 / 2; index2 = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) { ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); ++index2; @@ -798,7 +798,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() InChunkOffset += index2 / 2; index2 = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) { ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); ++index2; @@ -887,7 +887,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre { Json::Value root; // will contain the root value after parsing. Json::Reader reader; - if ( !reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) ) + if (!reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) ) { LOGERROR("Failed to parse trailing JSON in chunk [%d, %d]!", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ @@ -970,7 +970,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld // Compress the data: AString CompressedData; int errorcode = CompressString(Data.data(), Data.size(), CompressedData, m_CompressionFactor); - if ( errorcode != Z_OK ) + if (errorcode != Z_OK ) { LOGERROR("Error %i compressing data for chunk [%d, %d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ); return false; -- cgit v1.2.3 From 93d29555e58df172bafba530afbc593c16ec66a3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 15:19:48 +0200 Subject: Style: Normalized to no spaces before closing parenthesis. --- src/WorldStorage/WSSCompact.cpp | 108 ++++++++++++++++++++------------------ src/WorldStorage/WorldStorage.cpp | 2 +- 2 files changed, 58 insertions(+), 52 deletions(-) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index aae94141c..5382a3e01 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -196,7 +196,7 @@ cWSSCompact::cPAKFile * cWSSCompact::LoadPAKFile(const cChunkCoords & a_Chunk) // Load it anew: AString FileName; - Printf(FileName, "%s/X%i_Z%i.pak", m_World->GetName().c_str(), LayerX, LayerZ ); + Printf(FileName, "%s/X%i_Z%i.pak", m_World->GetName().c_str(), LayerX, LayerZ); cPAKFile * f = new cPAKFile(FileName, LayerX, LayerZ, m_CompressionFactor); if (f == NULL) { @@ -271,12 +271,12 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En Json::Value AllChests = a_Value.get("Chests", Json::nullValue); if (!AllChests.empty()) { - for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr ) + for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr) { std::auto_ptr ChestEntity(new cChestEntity(0, 0, 0, a_World, E_BLOCK_CHEST)); if (!ChestEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING CHEST FROM JSON!" ); + LOGWARNING("ERROR READING CHEST FROM JSON!"); } else { @@ -292,7 +292,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr DispenserEntity(new cDispenserEntity(0, 0, 0, a_World)); if (!DispenserEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING DISPENSER FROM JSON!" ); + LOGWARNING("ERROR READING DISPENSER FROM JSON!"); } else { @@ -307,7 +307,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr FlowerPotEntity(new cFlowerPotEntity(0, 0, 0, a_World)); if (!FlowerPotEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING FLOWERPOT FROM JSON!" ); + LOGWARNING("ERROR READING FLOWERPOT FROM JSON!"); } else { @@ -323,7 +323,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr FurnaceEntity(new cFurnaceEntity(0, 0, 0, E_BLOCK_FURNACE, 0, a_World)); if (!FurnaceEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING FURNACE FROM JSON!" ); + LOGWARNING("ERROR READING FURNACE FROM JSON!"); } else { @@ -353,7 +353,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr NoteEntity(new cNoteEntity(0, 0, 0, a_World)); if (!NoteEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING NOTE BLOCK FROM JSON!" ); + LOGWARNING("ERROR READING NOTE BLOCK FROM JSON!"); } else { @@ -368,7 +368,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr JukeboxEntity(new cJukeboxEntity(0, 0, 0, a_World)); if (!JukeboxEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING JUKEBOX FROM JSON!" ); + LOGWARNING("ERROR READING JUKEBOX FROM JSON!"); } else { @@ -383,7 +383,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr CommandBlockEntity(new cCommandBlockEntity(0, 0, 0, a_World)); if (!CommandBlockEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING COMMAND BLOCK FROM JSON!" ); + LOGWARNING("ERROR READING COMMAND BLOCK FROM JSON!"); } else { @@ -398,7 +398,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr MobHeadEntity(new cMobHeadEntity(0, 0, 0, a_World)); if (!MobHeadEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING MOB HEAD FROM JSON!" ); + LOGWARNING("ERROR READING MOB HEAD FROM JSON!"); } else { @@ -427,8 +427,8 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ m_LayerX(a_LayerX), m_LayerZ(a_LayerZ), m_NumDirty(0), - m_ChunkVersion( CHUNK_VERSION ), // Init with latest version - m_PakVersion( PAK_VERSION ) + m_ChunkVersion( CHUNK_VERSION), // Init with latest version + m_PakVersion( PAK_VERSION) { cFile f; if (!f.Open(m_FileName, cFile::fmRead)) @@ -445,18 +445,24 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ } READ(m_ChunkVersion); - switch( m_ChunkVersion ) + switch (m_ChunkVersion) { - case 1: - m_ChunkSize.Set(16, 128, 16); - break; - case 2: - case 3: - m_ChunkSize.Set(16, 256, 16); - break; - default: - LOGERROR("File \"%s\" is in an unknown chunk format (%d)", m_FileName.c_str(), m_ChunkVersion); - return; + case 1: + { + m_ChunkSize.Set(16, 128, 16); + break; + } + case 2: + case 3: + { + m_ChunkSize.Set(16, 256, 16); + break; + } + default: + { + LOGERROR("File \"%s\" is in an unknown chunk format (%d)", m_FileName.c_str(), m_ChunkVersion); + return; + } }; short NumChunks = 0; @@ -486,12 +492,12 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ return; } - if (m_ChunkVersion == 1 ) // Convert chunks to version 2 + if (m_ChunkVersion == 1) // Convert chunks to version 2 { UpdateChunk1To2(); } #if AXIS_ORDER == AXIS_ORDER_XZY - if (m_ChunkVersion == 2 ) // Convert chunks to version 3 + if (m_ChunkVersion == 2) // Convert chunks to version 3 { UpdateChunk2To3(); } @@ -574,9 +580,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() { sChunkHeader * Header = *itr; - if (ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0) { - LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); + LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size()); } ChunksConverted++; @@ -627,9 +633,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() char ConvertedData[cChunkDef::BlockDataSize]; int Index = 0; unsigned int InChunkOffset = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) { - for (int y = 0; y < 128; ++y ) + for (int y = 0; y < 128; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 128 + x * 128 * 16 + InChunkOffset]; } @@ -638,9 +644,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 128; } InChunkOffset += (16 * 128 * 16); - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Metadata + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Metadata { - for (int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -648,9 +654,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16 * 128 * 16) / 2; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Block light + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Block light { - for (int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -658,9 +664,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16*128*16)/2; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Sky light + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Sky light { - for (int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -674,7 +680,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() // Add JSON data afterwards if (UncompressedData.size() > InChunkOffset) { - Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end() ); + Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end()); } // Re-compress data @@ -702,7 +708,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() m_ChunkVersion = 2; SynchronizeFile(); - LOGINFO("Updated \"%s\" version 1 to version 2", m_FileName.c_str() ); + LOGINFO("Updated \"%s\" version 1 to version 2", m_FileName.c_str()); } @@ -718,9 +724,9 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() { sChunkHeader * Header = *itr; - if (ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0) { - LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); + LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size()); } ChunksConverted++; @@ -771,10 +777,10 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() // Cannot use cChunk::MakeIndex because it might change again????????? // For compatibility, use what we know is current - #define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) ) + #define MAKE_3_INDEX( x, y, z) ( x + (z * 16) + (y * 16 * 16)) unsigned int InChunkOffset = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) // YZX Loop order is important, in 1.1 Y was first then Z then X { ConvertedData[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset]; ++InChunkOffset; @@ -782,25 +788,25 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() unsigned int index2 = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) { - ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); + ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4); ++index2; } InChunkOffset += index2 / 2; index2 = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) { - ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); + ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4); ++index2; } InChunkOffset += index2 / 2; index2 = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) { - ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); + ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4); ++index2; } InChunkOffset += index2 / 2; @@ -810,7 +816,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() // Add JSON data afterwards if (UncompressedData.size() > InChunkOffset) { - Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end() ); + Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end()); } // Re-compress data @@ -838,7 +844,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() m_ChunkVersion = 3; SynchronizeFile(); - LOGINFO("Updated \"%s\" version 2 to version 3", m_FileName.c_str() ); + LOGINFO("Updated \"%s\" version 2 to version 3", m_FileName.c_str()); } @@ -887,7 +893,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre { Json::Value root; // will contain the root value after parsing. Json::Reader reader; - if (!reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) ) + if (!reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false)) { LOGERROR("Failed to parse trailing JSON in chunk [%d, %d]!", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ @@ -970,7 +976,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld // Compress the data: AString CompressedData; int errorcode = CompressString(Data.data(), Data.size(), CompressedData, m_CompressionFactor); - if (errorcode != Z_OK ) + if (errorcode != Z_OK) { LOGERROR("Error %i compressing data for chunk [%d, %d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ); return false; diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index d0b2acf3b..707e8f929 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -61,7 +61,7 @@ cWorldStorage::~cWorldStorage() -bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor ) +bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor) { m_World = a_World; m_StorageSchemaName = a_StorageSchemaName; -- cgit v1.2.3