diff options
author | Alexander Lyons Harkness <me@bearbin.net> | 2017-12-23 13:49:08 +0100 |
---|---|---|
committer | Alexander Lyons Harkness <me@bearbin.net> | 2017-12-24 15:23:23 +0100 |
commit | 1926181cb7c8570fe57ec1b39d4241b9dd156333 (patch) | |
tree | 8ac9c6f24285846fa3f97f0a4ade9b0f9996f295 /Tools/BlockZapper | |
parent | Fixed item ID raw rabbit (#4103) (diff) | |
download | cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar.gz cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar.bz2 cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar.lz cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar.xz cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar.zst cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.zip |
Diffstat (limited to '')
-rw-r--r-- | Tools/BlockZapper/BlockZapper.cpp | 16 | ||||
-rw-r--r-- | Tools/BlockZapper/Regions.cpp | 20 | ||||
-rw-r--r-- | Tools/BlockZapper/Regions.h | 24 | ||||
-rw-r--r-- | Tools/BlockZapper/Zapper.cpp | 20 | ||||
-rw-r--r-- | Tools/BlockZapper/Zapper.h | 50 |
5 files changed, 55 insertions, 75 deletions
diff --git a/Tools/BlockZapper/BlockZapper.cpp b/Tools/BlockZapper/BlockZapper.cpp index c2a0a4fac..9db9e3c99 100644 --- a/Tools/BlockZapper/BlockZapper.cpp +++ b/Tools/BlockZapper/BlockZapper.cpp @@ -50,7 +50,7 @@ void ShowHelp(const char * a_ProgramFullName) int main(int argc, char * argv[]) { new cMCLogger; // Create a new logger, it will assign itself as the main logger instance - + AString MCAFolder = "."; for (int i = 1; i < argc; i++) { @@ -74,24 +74,20 @@ int main(int argc, char * argv[]) return 0; } } - + cRegions Regions; - + /* // DEBUG: Read input from a file instead of stdin: std::fstream fs("test_in.txt"); Regions.Read(fs); //*/ - + Regions.Read(std::cin); - + cZapper Zapper(MCAFolder); Zapper.ZapRegions(Regions.GetAll()); - + LOGINFO("Done"); return 0; } ; - - - - diff --git a/Tools/BlockZapper/Regions.cpp b/Tools/BlockZapper/Regions.cpp index 515699532..7a205a138 100644 --- a/Tools/BlockZapper/Regions.cpp +++ b/Tools/BlockZapper/Regions.cpp @@ -11,7 +11,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRegion: cRegion::cRegion(void) : @@ -66,7 +66,7 @@ bool cRegion::TouchesChunk(int a_ChunkX, int a_ChunkZ) const -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRegions: void cRegions::Read(std::istream & a_Stream) @@ -75,7 +75,7 @@ void cRegions::Read(std::istream & a_Stream) { AString Line; std::getline(a_Stream, Line); - + // Process the line AStringVector Split = StringSplit(Line, " \t"); AStringVector NonEmpty; @@ -110,7 +110,7 @@ void cRegions::Read(std::istream & a_Stream) void cRegions::AddRegion(const AStringVector & a_Split) { ASSERT((a_Split.size() == 6) || (a_Split.size() == 7)); - + int Coords[6]; for (int i = 0; i < 6; i++) { @@ -121,10 +121,10 @@ void cRegions::AddRegion(const AStringVector & a_Split) return; } } // for i - a_Split[] - + bool ShouldZapBlocks = true; bool ShouldZapEntities = false; - + if (a_Split.size() == 7) { AString Upper = a_Split[6]; @@ -148,7 +148,7 @@ void cRegions::AddRegion(const AStringVector & a_Split) return; } } - + // Swap coords, if needed: for (int i = 0; i < 3; i++) { @@ -157,11 +157,7 @@ void cRegions::AddRegion(const AStringVector & a_Split) std::swap(Coords[2 * i], Coords[2 * i + 1]); } } - + // Store the region m_Regions.push_back(cRegion(Coords[0], Coords[1], Coords[2], Coords[3], Coords[4], Coords[5], ShouldZapBlocks, ShouldZapEntities)); } - - - - diff --git a/Tools/BlockZapper/Regions.h b/Tools/BlockZapper/Regions.h index 997b9a047..2fe50a9b4 100644 --- a/Tools/BlockZapper/Regions.h +++ b/Tools/BlockZapper/Regions.h @@ -20,13 +20,13 @@ struct cRegion int m_MinX, m_MaxX; int m_MinY, m_MaxY; int m_MinZ, m_MaxZ; - + bool m_ShouldZapBlocks; bool m_ShouldZapEntities; - + cRegion(void); cRegion(int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ, bool a_ShouldZapBlocks, bool a_ShouldZapEntities); - + bool TouchesChunk(int a_ChunkX, int a_ChunkZ) const; } ; @@ -39,20 +39,16 @@ typedef std::vector<cRegion> cRegionVector; class cRegions { public: - /// Reads the list of regions from the specified stream + /** Reads the list of regions from the specified stream */ void Read(std::istream & a_Stream); - - /// Returns all regions in this container + + /** Returns all regions in this container */ const cRegionVector & GetAll(void) const { return m_Regions; } - + protected: cRegionVector m_Regions; - - /// Adds a new region based on the contents of the split line. The split must already be the correct size - void AddRegion(const AStringVector & a_Split); - -} ; - - + /** Adds a new region based on the contents of the split line. The split must already be the correct size */ + void AddRegion(const AStringVector & a_Split); +} ; diff --git a/Tools/BlockZapper/Zapper.cpp b/Tools/BlockZapper/Zapper.cpp index 304d49770..83c9657ce 100644 --- a/Tools/BlockZapper/Zapper.cpp +++ b/Tools/BlockZapper/Zapper.cpp @@ -15,7 +15,7 @@ -/// The maximum size of an inflated chunk; raw chunk data is 192 KiB, allow 64 KiB more of entities +/** The maximum size of an inflated chunk; raw chunk data is 192 KiB, allow 64 KiB more of entities */ #define CHUNK_INFLATE_MAX 256 KiB @@ -115,7 +115,7 @@ void cZapper::ZapRegionInMCAFile(const cRegion & a_Region, int a_MCAX, int a_MCA int ChunkZ = a_MCAZ * ChunksPerMCAZ + (i / ChunksPerMCAX); LoadChunkData(fIn, HeaderIn[i], ChunkData, ChunkX, ChunkZ); - + if (a_Region.TouchesChunk(ChunkX, ChunkZ)) { ZapRegionInRawChunkData(a_Region, ChunkData, ChunkX, ChunkZ); @@ -218,14 +218,14 @@ void cZapper::ZapRegionInRawChunkData(const cRegion & a_Region, AString & a_Chun return; } ZapRegionInNBTChunk(a_Region, NBT, a_ChunkX, a_ChunkZ); - + cFastNBTWriter Writer; for (int ch = NBT.GetFirstChild(0); ch >= 0; ch = NBT.GetNextSibling(ch)) { SerializeNBTTag(NBT, ch, Writer); } Writer.Finish(); - + /* // DEBUG: Output dst to a file: cFile f2; @@ -251,7 +251,7 @@ void cZapper::ZapRegionInNBTChunk(const cRegion & a_Region, cParsedNBT & a_NBT, fprintf(stderr, "Cannot find Level tag in chunk [%d, %d]'s NBT. Skipping chunk.", a_ChunkX, a_ChunkZ); return; } - + // Create a copy of the region and limit it to the current chunk: int BlockX = a_ChunkX * 16; int BlockZ = a_ChunkZ * 16; @@ -273,7 +273,7 @@ void cZapper::ZapRegionInNBTChunk(const cRegion & a_Region, cParsedNBT & a_NBT, } ZapRegionBlocksInNBT(Local, a_NBT, SectionsTag); } - + if (a_Region.m_ShouldZapEntities) { int EntitiesTag = a_NBT.FindChildByName(LevelTag, "Entities"); @@ -320,7 +320,7 @@ void cZapper::ZapRegionBlocksInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, { ZapRegionInNBTSectionNibbles(a_Region, y, (unsigned char *)(a_NBT.GetData(BlockAddTag))); } - } // for Child - Level/Sections/[] + } // for Child - Level / Sections / [] } @@ -426,7 +426,7 @@ void cZapper::SerializeNBTTag(const cParsedNBT & a_NBT, int a_Tag, cFastNBTWrite a_Writer.EndCompound(); break; } - + default: { ASSERT(!"Unknown NBT tag"); @@ -434,7 +434,3 @@ void cZapper::SerializeNBTTag(const cParsedNBT & a_NBT, int a_Tag, cFastNBTWrite } } } - - - - diff --git a/Tools/BlockZapper/Zapper.h b/Tools/BlockZapper/Zapper.h index 6bcd6aa2a..e156848af 100644 --- a/Tools/BlockZapper/Zapper.h +++ b/Tools/BlockZapper/Zapper.h @@ -27,54 +27,50 @@ class cZapper { public: cZapper(const AString & a_MCAFolder); - - /// Zaps all the specified regions + + /** Zaps all the specified regions */ void ZapRegions(const cRegionVector & a_Regions); - + protected: static const int BlocksPerChunkX = 16; static const int BlocksPerChunkZ = 16; static const int ChunksPerMCAX = 32; static const int ChunksPerMCAZ = 32; - + AString m_MCAFolder; - /// Converts from block coords to MCA coords + /** Converts from block coords to MCA coords */ void BlockToMCA(int a_BlockX, int a_BlockZ, int & a_MCAX, int & a_MCAZ); - - /// Converts from block coords to chunk coords + + /** Converts from block coords to chunk coords */ void BlockToChunk(int a_BlockX, int a_BlockZ, int & a_ChunkX, int & a_ChunkZ); - - /// Zaps the specified region in the MCA file with the specified MCA coords + + /** Zaps the specified region in the MCA file with the specified MCA coords */ void ZapRegionInMCAFile(const cRegion & a_Region, int a_MCAX, int a_MCAZ); - + /** Loads raw compressed chunk data from the specified file * chunk is specified by ChunkHeaderValue, which is the int describing the chunk in file header. */ void LoadChunkData(cFile & a_InFile, int a_ChunkHeaderValue, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ); - - /// Zaps the specified region in the raw (compressed) chunk data. + + /** Zaps the specified region in the raw (compressed) chunk data. */ void ZapRegionInRawChunkData(const cRegion & a_Region, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ); - - /// Zaps the specified region in the specified NBT structure + + /** Zaps the specified region in the specified NBT structure */ void ZapRegionInNBTChunk(const cRegion & a_Region, cParsedNBT & a_NBT, int a_ChunkX, int a_ChunkZ); - - /// Zaps the blocks in the specified region from the specified NBT + + /** Zaps the blocks in the specified region from the specified NBT */ void ZapRegionBlocksInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_SectionsTag); - - /// Zaps the blocks in the specified bytes (types) from one vertical section (16^3 blocks) of a chunk. + + /** Zaps the blocks in the specified bytes (types) from one vertical section (16^3 blocks) of a chunk. */ void ZapRegionInNBTSectionBytes(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockBytes); - /// Zaps the blocks in the specified nibbles (meta, add) from one vertical section (16^3 blocks) of a chunk. + /** Zaps the blocks in the specified nibbles (meta, add) from one vertical section (16^3 blocks) of a chunk. */ void ZapRegionInNBTSectionNibbles(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockNibbles); - - /// Zaps entities in the specified region from the specified NBT + + /** Zaps entities in the specified region from the specified NBT */ void ZapRegionEntitiesInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_EntitiesTag); - - /// Serializes the NBT subtree into a writer + + /** Serializes the NBT subtree into a writer */ void SerializeNBTTag(const cParsedNBT & a_NBT, int a_Tag, cFastNBTWriter & a_Writer); } ; - - - - |