summaryrefslogtreecommitdiffstats
path: root/Tools/AnvilStats
diff options
context:
space:
mode:
authorAlexander Lyons Harkness <me@bearbin.net>2017-12-23 13:49:08 +0100
committerAlexander Lyons Harkness <me@bearbin.net>2017-12-24 15:23:23 +0100
commit1926181cb7c8570fe57ec1b39d4241b9dd156333 (patch)
tree8ac9c6f24285846fa3f97f0a4ade9b0f9996f295 /Tools/AnvilStats
parentFixed item ID raw rabbit (#4103) (diff)
downloadcuberite-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 'Tools/AnvilStats')
-rw-r--r--Tools/AnvilStats/AnvilStats.cpp14
-rw-r--r--Tools/AnvilStats/BiomeMap.cpp6
-rw-r--r--Tools/AnvilStats/BiomeMap.h14
-rw-r--r--Tools/AnvilStats/Callback.h66
-rw-r--r--Tools/AnvilStats/ChunkExtract.cpp6
-rw-r--r--Tools/AnvilStats/ChunkExtract.h14
-rw-r--r--Tools/AnvilStats/Globals.h51
-rw-r--r--Tools/AnvilStats/HeightBiomeMap.cpp22
-rw-r--r--Tools/AnvilStats/HeightBiomeMap.h25
-rw-r--r--Tools/AnvilStats/HeightMap.cpp8
-rw-r--r--Tools/AnvilStats/HeightMap.h20
-rw-r--r--Tools/AnvilStats/ImageComposingCallback.cpp16
-rw-r--r--Tools/AnvilStats/ImageComposingCallback.h74
-rw-r--r--Tools/AnvilStats/Processor.cpp84
-rw-r--r--Tools/AnvilStats/Processor.h26
-rw-r--r--Tools/AnvilStats/SpringStats.cpp16
-rw-r--r--Tools/AnvilStats/SpringStats.h39
-rw-r--r--Tools/AnvilStats/Statistics.cpp56
-rw-r--r--Tools/AnvilStats/Statistics.h30
-rw-r--r--Tools/AnvilStats/Utils.cpp6
20 files changed, 261 insertions, 332 deletions
diff --git a/Tools/AnvilStats/AnvilStats.cpp b/Tools/AnvilStats/AnvilStats.cpp
index d98c21985..5c3a1708a 100644
--- a/Tools/AnvilStats/AnvilStats.cpp
+++ b/Tools/AnvilStats/AnvilStats.cpp
@@ -31,7 +31,7 @@ int main(int argc, char * argv[])
LOG("\nNo method number present, aborting.");
return -1;
}
-
+
AString WorldFolder;
if (argc > 2)
{
@@ -41,7 +41,7 @@ int main(int argc, char * argv[])
{
WorldFolder = "." + cFile::PathSeparator;
}
-
+
cCallbackFactory * Factory = NULL;
switch (atol(argv[1]))
{
@@ -59,14 +59,10 @@ int main(int argc, char * argv[])
}
cProcessor Processor;
Processor.ProcessWorld(WorldFolder, *Factory);
-
+
LOG("Processing finished");
-
+
delete Factory;
-
+
LOG("Done");
}
-
-
-
-
diff --git a/Tools/AnvilStats/BiomeMap.cpp b/Tools/AnvilStats/BiomeMap.cpp
index de8fc4ad7..edb971f85 100644
--- a/Tools/AnvilStats/BiomeMap.cpp
+++ b/Tools/AnvilStats/BiomeMap.cpp
@@ -123,7 +123,7 @@ void cBiomeMap::StartNewRegion(int a_RegionX, int a_RegionZ)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBiomeMapFactory:
cBiomeMapFactory::~cBiomeMapFactory()
@@ -135,7 +135,3 @@ cBiomeMapFactory::~cBiomeMapFactory()
}
// TODO: Join all the files into one giant image file
}
-
-
-
-
diff --git a/Tools/AnvilStats/BiomeMap.h b/Tools/AnvilStats/BiomeMap.h
index f662094a5..a2eb12a41 100644
--- a/Tools/AnvilStats/BiomeMap.h
+++ b/Tools/AnvilStats/BiomeMap.h
@@ -20,8 +20,8 @@ class cBiomeMap :
{
public:
cBiomeMap(void);
-
- /// Saves the last region that it was processing
+
+ /** Saves the last region that it was processing */
void Finish(void);
protected:
@@ -33,7 +33,7 @@ protected:
int m_CurrentRegionZ;
bool m_IsCurrentRegionValid;
char m_Biomes[16 * 32 * 16 * 32]; // Biome map of the entire current region [x + 16 * 32 * z]
-
+
// cCallback overrides:
virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
@@ -43,7 +43,7 @@ protected:
virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
virtual bool OnTerrainPopulated(bool a_Populated) override { return false; } // We don't care about "populated", the biomes are the same
virtual bool OnBiomes(const unsigned char * a_BiomeData) override;
-
+
void StartNewRegion(int a_RegionX, int a_RegionZ);
} ;
@@ -56,14 +56,10 @@ class cBiomeMapFactory :
{
public:
virtual ~cBiomeMapFactory();
-
+
virtual cCallback * CreateNewCallback(void) override
{
return new cBiomeMap;
}
} ;
-
-
-
-
diff --git a/Tools/AnvilStats/Callback.h b/Tools/AnvilStats/Callback.h
index eda4a8478..9b6554a8d 100644
--- a/Tools/AnvilStats/Callback.h
+++ b/Tools/AnvilStats/Callback.h
@@ -37,39 +37,39 @@ public:
CALLBACK_CONTINUE = false,
CALLBACK_ABORT = true,
} ;
-
+
virtual ~cCallback() {} // Force a virtual destructor in each descendant
- /// Called when a new region file is about to be opened; by default allow the region
+ /** Called when a new region file is about to be opened; by default allow the region */
virtual bool OnNewRegion(int a_RegionX, int a_RegionZ) { return CALLBACK_CONTINUE; }
-
- /// Called to inform the stats module of the chunk coords for newly processing chunk
+
+ /** Called to inform the stats module of the chunk coords for newly processing chunk */
virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) = 0;
-
- /// Called to inform about the chunk's data offset in the file (chunk mini-header), the number of sectors it uses and the timestamp field value
+
+ /** Called to inform about the chunk's data offset in the file (chunk mini-header), the number of sectors it uses and the timestamp field value */
virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) { return CALLBACK_ABORT; }
-
- /// Called to inform of the compressed chunk data size and position in the file (offset from file start to the actual data)
+
+ /** Called to inform of the compressed chunk data size and position in the file (offset from file start to the actual data) */
virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) { return CALLBACK_ABORT; }
-
- /// Just in case you wanted to process the NBT yourself ;)
+
+ /** Just in case you wanted to process the NBT yourself ;) */
virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) { return CALLBACK_ABORT; }
-
- /// The chunk's NBT should specify chunk coords, these are sent here:
+
+ /** The chunk's NBT should specify chunk coords, these are sent here: */
virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) { return CALLBACK_ABORT; }
-
- /// The chunk contains a LastUpdate value specifying the last tick in which it was saved.
+
+ /** The chunk contains a LastUpdate value specifying the last tick in which it was saved. */
virtual bool OnLastUpdate(Int64 a_LastUpdate) { return CALLBACK_ABORT; }
-
+
virtual bool OnTerrainPopulated(bool a_Populated) { return CALLBACK_ABORT; }
-
+
virtual bool OnBiomes(const unsigned char * a_BiomeData) { return CALLBACK_ABORT; }
-
+
/** Called when a heightmap for the chunk is read from the file.
Note that the heightmap is given in big-endian ints, so if you want it, you need to ntohl() it first!
*/
virtual bool OnHeightMap(const int * a_HeightMapBE) { return CALLBACK_ABORT; }
-
+
/** If there is data for the section, this callback is called; otherwise OnEmptySection() is called instead.
All OnSection() callbacks are called first, and only then all the remaining sections are reported in OnEmptySection().
*/
@@ -81,16 +81,16 @@ public:
const NIBBLETYPE * a_BlockLight,
const NIBBLETYPE * a_BlockSkyLight
) { return CALLBACK_ABORT; }
-
- /** If there is no data for a section, this callback is called; otherwise OnSection() is called instead.
+
+ /** If there is no data for a section, this callback is called; otherwise OnSection() is called instead.
OnEmptySection() callbacks are called after all OnSection() callbacks.
*/
virtual bool OnEmptySection(unsigned char a_Y) { return CALLBACK_CONTINUE; }
-
+
/** Called after all sections have been processed via either OnSection() or OnEmptySection().
*/
virtual bool OnSectionsFinished(void) { return CALLBACK_ABORT; }
-
+
/** Called for each entity in the chunk.
Common parameters are parsed from the NBT.
The callback may parse any other param from the a_NBT and a_NBTTag parameters.
@@ -108,7 +108,7 @@ public:
cParsedNBT & a_NBT,
int a_NBTTag
) { return CALLBACK_ABORT; }
-
+
/** Called for each tile entity in the chunk.
Common parameters are parsed from the NBT.
The callback may parse any other param from the a_NBT and a_NBTTag parameters.
@@ -121,14 +121,14 @@ public:
int a_NBTTag
) { return CALLBACK_ABORT; }
- /// Called for each tile tick in the chunk
+ /** Called for each tile tick in the chunk */
virtual bool OnTileTick(
int a_BlockType,
int a_TicksLeft,
int a_PosX, int a_PosY, int a_PosZ
) { return CALLBACK_ABORT; }
-
- /// Called after the entire region file has been processed. No more callbacks for this region will be called. No processing by default
+
+ /** Called after the entire region file has been processed. No more callbacks for this region will be called. No processing by default */
virtual void OnRegionFinished(int a_RegionX, int a_RegionZ) {}
} ;
@@ -153,11 +153,11 @@ public:
delete *itr;
}
}
-
- /// Descendants override this method to return the correct callback type
+
+ /** Descendants override this method to return the correct callback type */
virtual cCallback * CreateNewCallback(void) = 0;
-
- /// cProcessor uses this method to request a new callback
+
+ /** cProcessor uses this method to request a new callback */
cCallback * GetNewCallback(void)
{
cCallback * Callback = CreateNewCallback();
@@ -167,11 +167,7 @@ public:
}
return Callback;
}
-
+
protected:
cCallbacks m_Callbacks;
} ;
-
-
-
-
diff --git a/Tools/AnvilStats/ChunkExtract.cpp b/Tools/AnvilStats/ChunkExtract.cpp
index 96287ebef..fda09dfbd 100644
--- a/Tools/AnvilStats/ChunkExtract.cpp
+++ b/Tools/AnvilStats/ChunkExtract.cpp
@@ -50,10 +50,10 @@ bool cChunkExtract::OnCompressedDataSizePos(int a_CompressedDataSize, int a_Data
LOG("Cannot open zchunk file \"%s\" for writing. Chunk [%d, %d] skipped.", ChunkPath.c_str(), mCurChunkX, mCurChunkZ);
return false;
}
-
+
// Copy data from mAnvilFile to ChunkFile:
mAnvilFile.Seek(a_DataOffset);
- for (int BytesToCopy = a_CompressedDataSize; BytesToCopy > 0; )
+ for (int BytesToCopy = a_CompressedDataSize; BytesToCopy > 0;)
{
char Buffer[64000];
int NumBytes = std::min(BytesToCopy, (int)sizeof(Buffer));
@@ -101,4 +101,4 @@ void cChunkExtract::OpenAnvilFile(int a_AnvilX, int a_AnvilZ)
}
mCurAnvilX = a_AnvilX;
mCurAnvilZ = a_AnvilZ;
-} \ No newline at end of file
+}
diff --git a/Tools/AnvilStats/ChunkExtract.h b/Tools/AnvilStats/ChunkExtract.h
index 767523354..a5be2bc25 100644
--- a/Tools/AnvilStats/ChunkExtract.h
+++ b/Tools/AnvilStats/ChunkExtract.h
@@ -20,7 +20,7 @@ class cChunkExtract :
{
public:
cChunkExtract(const AString & iWorldFolder);
-
+
protected:
AString mWorldFolder;
cFile mAnvilFile;
@@ -28,10 +28,10 @@ protected:
int mCurAnvilZ; // Z-coord of mAnvilFile, -"-
int mCurChunkX; // X-coord of the chunk being processed
int mCurChunkZ; // Z-coord of the chunk being processed
-
- /// Opens new anvil file into mAnvilFile, sets mCurAnvilX and mCurAnvilZ
+
+ /** Opens new anvil file into mAnvilFile, sets mCurAnvilX and mCurAnvilZ */
void OpenAnvilFile(int a_AnvilX, int a_AnvilZ);
-
+
// cCallback overrides:
virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
@@ -51,7 +51,7 @@ public:
mWorldFolder(iWorldFolder)
{
}
-
+
virtual cCallback * CreateNewCallback(void) override
{
return new cChunkExtract(mWorldFolder);
@@ -60,7 +60,3 @@ public:
protected:
AString mWorldFolder;
} ;
-
-
-
-
diff --git a/Tools/AnvilStats/Globals.h b/Tools/AnvilStats/Globals.h
index 21d54739a..4a8b0d433 100644
--- a/Tools/AnvilStats/Globals.h
+++ b/Tools/AnvilStats/Globals.h
@@ -12,35 +12,35 @@
#if defined(_MSC_VER)
// MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
#pragma warning(disable:4481)
-
+
// Disable some warnings that we don't care about:
#pragma warning(disable:4100)
-
+
#define _CRT_SECURE_NO_WARNINGS
#define OBSOLETE __declspec(deprecated)
-
+
// No alignment needed in MSVC
#define ALIGN_8
#define ALIGN_16
-
+
#define FORMATSTRING(formatIndex, va_argsIndex)
// MSVC has its own custom version of zu format
#define SIZE_T_FMT "%Iu"
#define SIZE_T_FMT_PRECISION(x) "%" #x "Iu"
#define SIZE_T_FMT_HEX "%Ix"
-
+
#define NORETURN __declspec(noreturn)
#elif defined(__GNUC__)
// TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
#define abstract
-
+
// TODO: Can GCC mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
#define override
-
+
#define OBSOLETE __attribute__((deprecated))
#define ALIGN_8 __attribute__((aligned(8)))
@@ -54,19 +54,19 @@
#define SIZE_T_FMT "%zu"
#define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
#define SIZE_T_FMT_HEX "%zx"
-
+
#define NORETURN __attribute((__noreturn__))
#else
#error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
-
+
/*
// Copy and uncomment this into another #elif section based on your compiler identification
-
+
// Explicitly mark classes as abstract (no instances can be created)
#define abstract
-
+
// Mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
#define override
@@ -114,11 +114,11 @@ typedef unsigned short UInt16;
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <winsock2.h>
-
+
// Windows SDK defines min and max macros, messing up with our std::min and std::max usage
#undef min
#undef max
-
+
// Windows SDK defines GetFreeSpace as a constant, probably a Win16 API remnant
#ifdef GetFreeSpace
#undef GetFreeSpace
@@ -193,35 +193,35 @@ typedef unsigned short UInt16;
// Common definitions:
-#define LOG(x,...) printf(x "\n", __VA_ARGS__)
+#define LOG(x, ...) printf(x "\n", __VA_ARGS__)
#define LOGERROR LOG
#define LOGWARNING LOG
#define LOGINFO LOG
#define LOGWARN LOG
-/// Evaluates to the number of elements in an array (compile-time!)
+/** Evaluates to the number of elements in an array (compile-time!) */
#define ARRAYCOUNT(X) (sizeof(X) / sizeof(*(X)))
-/// Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)" )
+/** Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)") */
#define KiB * 1024
-/// Allows arithmetic expressions like "32 MiB" (but consider using parenthesis around it, "(32 MiB)" )
+/** Allows arithmetic expressions like "32 MiB" (but consider using parenthesis around it, "(32 MiB)") */
#define MiB * 1024 * 1024
-/// Faster than (int)floorf((float)x / (float)div)
-#define FAST_FLOOR_DIV( x, div ) ( (x) < 0 ? (((int)x / div) - 1) : ((int)x / div) )
+/** Faster than (int)floorf((float)x / (float)div) */
+#define FAST_FLOOR_DIV(x, div) ((x) < 0 ? (((int)x / div) - 1) : ((int)x / div))
#define TOLUA_TEMPLATE_BIND(...)
// Own version of assert() that writes failed assertions to the log for review
#ifdef _DEBUG
- #define ASSERT( x ) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), assert(0), 0 ) )
+ #define ASSERT(x) (!!(x) || (LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__), assert(0), 0))
#else
#define ASSERT(x) ((void)0)
#endif
// Pretty much the same as ASSERT() but stays in Release builds
-#define VERIFY( x ) ( !!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), exit(1), 0 ) )
+#define VERIFY(x) (!!(x) || (LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__), exit(1), 0))
typedef unsigned char Byte;
@@ -229,11 +229,11 @@ typedef unsigned char Byte;
-/// A generic interface used mainly in ForEach() functions
+/** A generic interface used mainly in ForEach() functions */
template <typename Type> class cItemCallback
{
public:
- /// Called for each item in the internal list; return true to stop the loop, or false to continue enumerating
+ /** Called for each item in the internal list; return true to stop the loop, or false to continue enumerating */
virtual bool Item(Type * a_Type) = 0;
} ;
@@ -255,8 +255,3 @@ T Clamp(T a_Value, T a_Min, T a_Max)
// Common headers (part 2, with macros):
#include "../../src/ChunkDef.h"
#include "../../src/BlockID.h"
-
-
-
-
-
diff --git a/Tools/AnvilStats/HeightBiomeMap.cpp b/Tools/AnvilStats/HeightBiomeMap.cpp
index 36918f644..fcbc5f4df 100644
--- a/Tools/AnvilStats/HeightBiomeMap.cpp
+++ b/Tools/AnvilStats/HeightBiomeMap.cpp
@@ -55,12 +55,12 @@ bool cHeightBiomeMap::OnNewChunk(int a_ChunkX, int a_ChunkZ)
m_CurrentChunkZ = a_ChunkZ;
m_CurrentChunkRelX = m_CurrentChunkX - m_CurrentRegionX * 32;
m_CurrentChunkRelZ = m_CurrentChunkZ - m_CurrentRegionZ * 32;
-
+
ASSERT((m_CurrentChunkRelX >= 0) && (m_CurrentChunkRelX < 32));
ASSERT((m_CurrentChunkRelZ >= 0) && (m_CurrentChunkRelZ < 32));
-
+
memset(m_BlockTypes, 0, sizeof(m_BlockTypes));
-
+
return CALLBACK_CONTINUE;
}
@@ -72,7 +72,7 @@ bool cHeightBiomeMap::OnNewChunk(int a_ChunkX, int a_ChunkZ)
bool cHeightBiomeMap::OnBiomes(const unsigned char * a_BiomeData)
{
memcpy(m_ChunkBiomes, a_BiomeData, sizeof(m_ChunkBiomes));
-
+
return CALLBACK_CONTINUE;
}
@@ -86,7 +86,7 @@ bool cHeightBiomeMap::OnHeightMap(const int * a_HeightMapBE)
{
m_ChunkHeight[i] = ntohl(a_HeightMapBE[i]);
} // for i - m_ChunkHeight
-
+
return CALLBACK_CONTINUE;
}
@@ -157,12 +157,12 @@ bool cHeightBiomeMap::OnSectionsFinished(void)
break; // for y
}
} // for y
-
+
// Set the color based on the biome and height:
char Biome = m_ChunkBiomes[16 * z + x];
PixelLine[x] = ShadeColor(BiomePalette[Biome], Height);
} // for x
-
+
// Set the pixelline into the image:
SetPixelURow(m_CurrentChunkRelX * 16, m_CurrentChunkRelZ * 16 + z, 16, PixelLine);
} // for z
@@ -173,7 +173,7 @@ bool cHeightBiomeMap::OnSectionsFinished(void)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cHeightBiomeMapFactory:
cHeightBiomeMapFactory::~cHeightBiomeMapFactory()
@@ -203,7 +203,7 @@ cHeightBiomeMapFactory::~cHeightBiomeMapFactory()
MaxRegionZ = cb->m_MaxRegionZ;
}
}
-
+
// If the size is small enough, write an HTML file referencing all the images in a table:
if ((MaxRegionX >= MinRegionX) && (MaxRegionZ >= MinRegionZ) && (MaxRegionX - MinRegionX < 100) && (MaxRegionZ - MinRegionZ < 100))
{
@@ -224,7 +224,3 @@ cHeightBiomeMapFactory::~cHeightBiomeMapFactory()
}
}
}
-
-
-
-
diff --git a/Tools/AnvilStats/HeightBiomeMap.h b/Tools/AnvilStats/HeightBiomeMap.h
index d38fa4733..8a2cb9726 100644
--- a/Tools/AnvilStats/HeightBiomeMap.h
+++ b/Tools/AnvilStats/HeightBiomeMap.h
@@ -19,23 +19,26 @@ class cHeightBiomeMap :
public cImageComposingCallback
{
typedef cImageComposingCallback super;
-
+
public:
// Minima and maxima for the regions processed through this callback
int m_MinRegionX, m_MaxRegionX;
int m_MinRegionZ, m_MaxRegionZ;
-
+
cHeightBiomeMap(void);
-
+
protected:
int m_CurrentChunkX; // Absolute chunk coords
int m_CurrentChunkZ;
int m_CurrentChunkRelX; // Chunk offset from the start of the region
int m_CurrentChunkRelZ;
-
- char m_ChunkBiomes[16 * 16]; ///< Biome-map for the current chunk
- int m_ChunkHeight[16 * 16]; ///< Height-map for the current chunk
- BLOCKTYPE m_BlockTypes [16 * 16 * 256]; ///< Block data for the current chunk (between OnSection() and OnSectionsFinished() )
+
+ /** Biome-map for the current chunk */
+ char m_ChunkBiomes[16 * 16];
+ /** Height-map for the current chunk */
+ int m_ChunkHeight[16 * 16];
+ /** Block data for the current chunk (between OnSection() and OnSectionsFinished()) */
+ BLOCKTYPE m_BlockTypes [16 * 16 * 256];
// cCallback overrides:
virtual bool OnNewRegion(int a_RegionX, int a_RegionZ) override;
@@ -57,7 +60,7 @@ protected:
const NIBBLETYPE * a_BlockSkyLight
) override;
virtual bool OnSectionsFinished(void) override;
-
+
} ;
@@ -69,13 +72,9 @@ class cHeightBiomeMapFactory :
{
public:
virtual ~cHeightBiomeMapFactory();
-
+
virtual cCallback * CreateNewCallback(void) override
{
return new cHeightBiomeMap;
}
} ;
-
-
-
-
diff --git a/Tools/AnvilStats/HeightMap.cpp b/Tools/AnvilStats/HeightMap.cpp
index d00ed248f..74ce1bf50 100644
--- a/Tools/AnvilStats/HeightMap.cpp
+++ b/Tools/AnvilStats/HeightMap.cpp
@@ -1,7 +1,7 @@
// HeightMap.cpp
-// Implements the cHeightMap class representing a cCallback descendant that draws a B&W map of heights for the world
+// Implements the cHeightMap class representing a cCallback descendant that draws a B & W map of heights for the world
#include "Globals.h"
#include "HeightMap.h"
@@ -253,7 +253,7 @@ bool cHeightMap::IsGround(BLOCKTYPE a_BlockType)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cHeightMapFactory:
cHeightMapFactory::~cHeightMapFactory()
@@ -265,7 +265,3 @@ cHeightMapFactory::~cHeightMapFactory()
}
// TODO: Join all the files into one giant image file
}
-
-
-
-
diff --git a/Tools/AnvilStats/HeightMap.h b/Tools/AnvilStats/HeightMap.h
index e1d73f300..69deb5bab 100644
--- a/Tools/AnvilStats/HeightMap.h
+++ b/Tools/AnvilStats/HeightMap.h
@@ -1,7 +1,7 @@
// HeightMap.h
-// Declares the cHeightMap class representing a cCallback descendant that draws a B&W map of heights for the world
+// Declares the cHeightMap class representing a cCallback descendant that draws a B & W map of heights for the world
@@ -20,9 +20,9 @@ class cHeightMap :
{
public:
cHeightMap(void);
-
+
void Finish(void);
-
+
static bool IsGround(BLOCKTYPE a_BlockType);
protected:
@@ -33,9 +33,11 @@ protected:
int m_CurrentRegionX;
int m_CurrentRegionZ;
bool m_IsCurrentRegionValid;
- int m_Height[16 * 32 * 16 * 32]; ///< Height-map of the entire current region [x + 16 * 32 * z]
- BLOCKTYPE m_BlockTypes[16 * 16 * 256]; ///< Block data of the currently processed chunk (between OnSection() and OnSectionsFinished() )
-
+ /** Height-map of the entire current region [x + 16 * 32 * z] */
+ int m_Height[16 * 32 * 16 * 32];
+ /** Block data of the currently processed chunk (between OnSection() and OnSectionsFinished()) */
+ BLOCKTYPE m_BlockTypes[16 * 16 * 256];
+
// cCallback overrides:
virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
@@ -68,14 +70,10 @@ class cHeightMapFactory :
{
public:
virtual ~cHeightMapFactory();
-
+
virtual cCallback * CreateNewCallback(void) override
{
return new cHeightMap;
}
} ;
-
-
-
-
diff --git a/Tools/AnvilStats/ImageComposingCallback.cpp b/Tools/AnvilStats/ImageComposingCallback.cpp
index eb43ad49f..cc200b9a4 100644
--- a/Tools/AnvilStats/ImageComposingCallback.cpp
+++ b/Tools/AnvilStats/ImageComposingCallback.cpp
@@ -35,11 +35,11 @@ bool cImageComposingCallback::OnNewRegion(int a_RegionX, int a_RegionZ)
{
ASSERT(m_CurrentRegionX == INVALID_REGION_COORD);
ASSERT(m_CurrentRegionZ == INVALID_REGION_COORD); // Has any previous region been finished properly?
-
+
m_CurrentRegionX = a_RegionX;
m_CurrentRegionZ = a_RegionZ;
OnEraseImage();
-
+
return CALLBACK_CONTINUE;
}
@@ -53,7 +53,7 @@ void cImageComposingCallback::OnRegionFinished(int a_RegionX, int a_RegionZ)
ASSERT(m_CurrentRegionZ != INVALID_REGION_COORD); // Has a region been started properly?
ASSERT(m_CurrentRegionX == a_RegionX);
ASSERT(m_CurrentRegionZ == a_RegionZ); // Is it the same region that has been started?
-
+
AString FileName = GetFileName(a_RegionX, a_RegionZ);
if (!FileName.empty())
{
@@ -61,7 +61,7 @@ void cImageComposingCallback::OnRegionFinished(int a_RegionX, int a_RegionZ)
SaveImage(FileName);
OnAfterImageSaved(a_RegionX, a_RegionZ, FileName);
}
-
+
m_CurrentRegionX = INVALID_REGION_COORD;
m_CurrentRegionZ = INVALID_REGION_COORD;
}
@@ -122,7 +122,7 @@ void cImageComposingCallback::SetPixel(int a_RelU, int a_RelV, int a_Color)
{
ASSERT((a_RelU >= 0) && (a_RelU < IMAGE_WIDTH));
ASSERT((a_RelV >= 0) && (a_RelV < IMAGE_HEIGHT));
-
+
m_ImageData[a_RelU + IMAGE_WIDTH * a_RelV] = a_Color;
}
@@ -137,7 +137,7 @@ int cImageComposingCallback::GetPixel(int a_RelU, int a_RelV)
// Outside the image data
return -1;
}
-
+
return m_ImageData[a_RelU + IMAGE_WIDTH * a_RelV];
}
@@ -213,7 +213,3 @@ void cImageComposingCallback::SaveImage(const AString & a_FileName)
f.Write(BMPHeader, sizeof(BMPHeader));
f.Write(m_ImageData, PIXEL_COUNT * 4);
}
-
-
-
-
diff --git a/Tools/AnvilStats/ImageComposingCallback.h b/Tools/AnvilStats/ImageComposingCallback.h
index 2936361d6..916e61d92 100644
--- a/Tools/AnvilStats/ImageComposingCallback.h
+++ b/Tools/AnvilStats/ImageComposingCallback.h
@@ -32,74 +32,70 @@ public:
IMAGE_HEIGHT = 32 * 16,
PIXEL_COUNT = IMAGE_WIDTH * IMAGE_HEIGHT, ///< Total pixel count of the image data
} ;
-
+
cImageComposingCallback(const AString & a_FileNamePrefix);
virtual ~cImageComposingCallback();
// cCallback overrides:
virtual bool OnNewRegion(int a_RegionX, int a_RegionZ) override;
virtual void OnRegionFinished(int a_RegionX, int a_RegionZ) override;
-
+
// New introduced overridable functions:
-
- /// Called when a file is about to be saved, to generate the filename
+
+ /** Called when a file is about to be saved, to generate the filename */
virtual AString GetFileName(int a_RegionX, int a_RegionZ);
-
- /// Called before the file is saved
+
+ /** Called before the file is saved */
virtual void OnBeforeImageSaved(int a_RegionX, int a_RegionZ, const AString & a_FileName) {}
-
- /// Called after the image is saved to a file
+
+ /** Called after the image is saved to a file */
virtual void OnAfterImageSaved(int a_RegionX, int a_RegionZ, const AString & a_FileName) {}
-
- /// Called when a new region is beginning, to erase the image data
+
+ /** Called when a new region is beginning, to erase the image data */
virtual void OnEraseImage(void);
-
+
// Functions for manipulating the image:
-
- /// Erases the entire image with the specified color
+
+ /** Erases the entire image with the specified color */
void EraseImage(int a_Color);
-
- /// Erases the specified chunk's portion of the image with the specified color. Note that chunk coords are relative to the current region
+
+ /** Erases the specified chunk's portion of the image with the specified color. Note that chunk coords are relative to the current region */
void EraseChunk(int a_Color, int a_RelChunkX, int a_RelChunkZ);
-
- /// Returns the current region X coord
+
+ /** Returns the current region X coord */
int GetCurrentRegionX(void) const { return m_CurrentRegionX; }
-
- /// Returns the current region Z coord
+
+ /** Returns the current region Z coord */
int GetCurrentRegionZ(void) const { return m_CurrentRegionZ; }
-
- /// Sets the pixel at the specified UV coords to the specified color
+
+ /** Sets the pixel at the specified UV coords to the specified color */
void SetPixel(int a_RelU, int a_RelV, int a_Color);
-
- /// Returns the color of the pixel at the specified UV coords; -1 if outside
+
+ /** Returns the color of the pixel at the specified UV coords; -1 if outside */
int GetPixel(int a_RelU, int a_RelV);
-
- /// Sets a row of pixels. a_Pixels is expected to be a_CountU pixels wide. a_RelUStart + a_CountU is assumed less than image width
+
+ /** Sets a row of pixels. a_Pixels is expected to be a_CountU pixels wide. a_RelUStart + a_CountU is assumed less than image width */
void SetPixelURow(int a_RelUStart, int a_RelV, int a_CountU, int * a_Pixels);
-
+
/** "Shades" the given color based on the shade amount given
Shade amount 0 .. 63 shades the color from black to a_Color.
Shade amount 64 .. 127 shades the color from a_Color to white.
All other shade amounts have undefined results.
*/
static int ShadeColor(int a_Color, int a_Shade);
-
- /// Mixes the two colors in the specified ratio; a_Ratio is between 0 and 256, 0 returning a_Src
+
+ /** Mixes the two colors in the specified ratio; a_Ratio is between 0 and 256, 0 returning a_Src */
static int MixColor(int a_Src, int a_Dest, int a_Ratio);
-
+
protected:
- /// Prefix for the filenames, when generated by the default GetFileName() function
+ /** Prefix for the filenames, when generated by the default GetFileName() function */
AString m_FileNamePrefix;
-
- /// Coords of the currently processed region
+
+ /** Coords of the currently processed region */
int m_CurrentRegionX, m_CurrentRegionZ;
-
- /// Raw image data; 1 MiB worth of data, therefore unsuitable for stack allocation. [u + IMAGE_WIDTH * v]
+
+ /** Raw image data; 1 MiB worth of data, therefore unsuitable for stack allocation. [u + IMAGE_WIDTH * v] */
int * m_ImageData;
-
+
void SaveImage(const AString & a_FileName);
} ;
-
-
-
-
diff --git a/Tools/AnvilStats/Processor.cpp b/Tools/AnvilStats/Processor.cpp
index 6c4bb0ad5..d0bdad0ca 100644
--- a/Tools/AnvilStats/Processor.cpp
+++ b/Tools/AnvilStats/Processor.cpp
@@ -20,7 +20,7 @@ const int CHUNK_INFLATE_MAX = 1 MiB;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProcessor::cThread:
cProcessor::cThread::cThread(cCallback & a_Callback, cProcessor & a_ParentProcessor) :
@@ -48,9 +48,9 @@ void cProcessor::cThread::WaitForStart(void)
void cProcessor::cThread::Execute(void)
{
LOG("Started a new thread: %p, ID %d", this, cIsThread::GetCurrentID());
-
+
m_HasStarted.Set();
-
+
for (;;)
{
AString FileName = m_ParentProcessor.GetOneFileName();
@@ -61,7 +61,7 @@ void cProcessor::cThread::Execute(void)
}
ProcessFile(FileName);
} // for-ever
-
+
LOG("Thread %p (ID %d) terminated", this, cIsThread::GetCurrentID());
}
@@ -72,7 +72,7 @@ void cProcessor::cThread::Execute(void)
void cProcessor::cThread::ProcessFile(const AString & a_FileName)
{
LOG("Processing file \"%s\"", a_FileName.c_str());
-
+
size_t idx = a_FileName.rfind("r.");
if (idx == AString::npos)
{
@@ -91,14 +91,14 @@ void cProcessor::cThread::ProcessFile(const AString & a_FileName)
// Callback doesn't want the region file processed
return;
}
-
+
cFile f;
if (!f.Open(a_FileName, cFile::fmRead))
{
LOG("Cannot open file \"%s\", skipping file.", a_FileName.c_str());
return;
}
-
+
AString FileContents;
f.ReadRestOfFile(FileContents);
if (FileContents.size() < sizeof(8 KiB))
@@ -106,9 +106,9 @@ void cProcessor::cThread::ProcessFile(const AString & a_FileName)
LOG("Cannot read header in file \"%s\", skipping file.", a_FileName.c_str());
return;
}
-
+
ProcessFileData(FileContents.data(), FileContents.size(), RegionX * 32, RegionZ * 32);
-
+
m_Callback.OnRegionFinished(RegionX, RegionZ);
}
@@ -124,16 +124,16 @@ void cProcessor::cThread::ProcessFileData(const char * a_FileData, size_t a_Size
{
Header[i] = ntohl(HeaderPtr[i]);
}
-
+
for (int i = 0; i < 1024; i++)
{
unsigned Location = Header[i];
unsigned Timestamp = Header[i + 1024];
if (
- ((Location == 0) && (Timestamp == 0)) || // Official docs' "not present"
- (Location >> 8 < 2) || // Logical - no chunk can start inside the header
- ((Location & 0xff) == 0) || // Logical - no chunk can be zero bytes
- ((Location >> 8) * 4096 > a_Size) // Logical - no chunk can start at beyond the file end
+ ((Location == 0) && (Timestamp == 0)) || // Official docs' "not present"
+ (Location >> 8 < 2) || // Logical - no chunk can start inside the header
+ ((Location & 0xff) == 0) || // Logical - no chunk can be zero bytes
+ ((Location >> 8) * 4096 > a_Size) // Logical - no chunk can start at beyond the file end
)
{
// Chunk not present in the file
@@ -159,11 +159,11 @@ void cProcessor::cThread::ProcessChunk(const char * a_FileData, int a_ChunkX, in
{
return;
}
-
+
const char * ChunkStart = a_FileData + a_SectorStart * 4096;
int ByteSize = ntohl(*(int *)ChunkStart);
char CompressionMethod = ChunkStart[4];
-
+
if (m_Callback.OnCompressedDataSizePos(ByteSize, a_SectorStart * 4096 + 5, CompressionMethod))
{
return;
@@ -195,7 +195,7 @@ void cProcessor::cThread::ProcessCompressedChunkData(int a_ChunkX, int a_ChunkZ,
LOG("Decompression failed, skipping chunk [%d, %d]", a_ChunkX, a_ChunkZ);
return;
}
-
+
if (m_Callback.OnDecompressedData(Decompressed, strm.total_out))
{
return;
@@ -208,7 +208,7 @@ void cProcessor::cThread::ProcessCompressedChunkData(int a_ChunkX, int a_ChunkZ,
LOG("NBT Parsing failed, skipping chunk [%d, %d]", a_ChunkX, a_ChunkZ);
return;
}
-
+
ProcessParsedChunkData(a_ChunkX, a_ChunkZ, NBT);
}
@@ -235,7 +235,7 @@ void cProcessor::cThread::ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cPa
{
return;
}
-
+
int LastUpdateTag = a_NBT.FindChildByName(LevelTag, "LastUpdate");
if (LastUpdateTag > 0)
{
@@ -244,14 +244,14 @@ void cProcessor::cThread::ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cPa
return;
}
}
-
+
int TerrainPopulatedTag = a_NBT.FindChildByName(LevelTag, "TerrainPopulated");
bool TerrainPopulated = (TerrainPopulatedTag < 0) ? false : (a_NBT.GetByte(TerrainPopulatedTag) != 0);
if (m_Callback.OnTerrainPopulated(TerrainPopulated))
{
return;
}
-
+
int BiomesTag = a_NBT.FindChildByName(LevelTag, "Biomes");
if (BiomesTag > 0)
{
@@ -260,7 +260,7 @@ void cProcessor::cThread::ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cPa
return;
}
}
-
+
int HeightMapTag = a_NBT.FindChildByName(LevelTag, "HeightMap");
if (HeightMapTag > 0)
{
@@ -269,22 +269,22 @@ void cProcessor::cThread::ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cPa
return;
}
}
-
+
if (ProcessChunkSections(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
{
return;
}
-
+
if (ProcessChunkEntities(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
{
return;
}
-
+
if (ProcessChunkTileEntities(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
{
return;
}
-
+
if (ProcessChunkTileTicks(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
{
return;
@@ -302,7 +302,7 @@ bool cProcessor::cThread::ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cPars
{
return false;
}
-
+
bool SectionProcessed[16];
memset(SectionProcessed, 0, sizeof(SectionProcessed));
for (int Tag = a_NBT.GetFirstChild(Sections); Tag > 0; Tag = a_NBT.GetNextSibling(Tag))
@@ -313,12 +313,12 @@ bool cProcessor::cThread::ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cPars
int DataTag = a_NBT.FindChildByName(Tag, "Data");
int BlockLightTag = a_NBT.FindChildByName(Tag, "BlockLightTag");
int SkyLightTag = a_NBT.FindChildByName(Tag, "SkyLight");
-
+
if ((YTag < 0) || (BlocksTag < 0) || (DataTag < 0))
{
continue;
}
-
+
unsigned char SectionY = a_NBT.GetByte(YTag);
if (SectionY >= 16)
{
@@ -338,7 +338,7 @@ bool cProcessor::cThread::ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cPars
}
SectionProcessed[SectionY] = true;
} // for Tag - Sections[]
-
+
// Call the callback for empty sections:
for (unsigned char y = 0; y < 16; y++)
{
@@ -350,12 +350,12 @@ bool cProcessor::cThread::ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cPars
}
}
}
-
+
if (m_Callback.OnSectionsFinished())
{
return true;
}
-
+
return false;
}
@@ -370,7 +370,7 @@ bool cProcessor::cThread::ProcessChunkEntities(int a_ChunkX, int a_ChunkZ, cPars
{
return false;
}
-
+
for (int EntityTag = a_NBT.GetFirstChild(EntitiesTag); EntityTag > 0; EntityTag = a_NBT.GetNextSibling(EntityTag))
{
int PosTag = a_NBT.FindChildByName(EntityTag, "Pos");
@@ -433,7 +433,7 @@ bool cProcessor::cThread::ProcessChunkTileEntities(int a_ChunkX, int a_ChunkZ, c
{
return false;
}
-
+
for (int TileEntityTag = a_NBT.GetFirstChild(TileEntitiesTag); TileEntityTag > 0; TileEntityTag = a_NBT.GetNextSibling(TileEntityTag))
{
if (m_Callback.OnTileEntity(
@@ -461,7 +461,7 @@ bool cProcessor::cThread::ProcessChunkTileTicks(int a_ChunkX, int a_ChunkZ, cPar
{
return false;
}
-
+
for (int TileTickTag = a_NBT.GetFirstChild(TileTicksTag); TileTickTag > 0; TileTickTag = a_NBT.GetNextSibling(TileTickTag))
{
int iTag = a_NBT.FindChildByName(TileTicksTag, "i");
@@ -491,7 +491,7 @@ bool cProcessor::cThread::ProcessChunkTileTicks(int a_ChunkX, int a_ChunkZ, cPar
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProcessor:
cProcessor::cProcessor(void) :
@@ -514,24 +514,24 @@ cProcessor::~cProcessor()
void cProcessor::ProcessWorld(const AString & a_WorldFolder, cCallbackFactory & a_CallbackFactory)
{
PopulateFileQueue(a_WorldFolder);
-
+
if (m_FileQueue.empty())
{
LOG("No files to process, exitting.");
return;
}
-
+
// Start as many threads as there are cores, plus one:
// (One more thread can be in the file-read IO block while all other threads crunch the numbers)
int NumThreads = GetNumCores() + 1;
-
+
/*
// Limit the number of threads in DEBUG mode to 1 for easier debugging
#ifdef _DEBUG
NumThreads = 1;
#endif // _DEBUG
//*/
-
+
// Start all the threads:
for (int i = 0; i < NumThreads; i++)
{
@@ -589,7 +589,3 @@ AString cProcessor::GetOneFileName(void)
m_FileQueue.pop_back();
return res;
}
-
-
-
-
diff --git a/Tools/AnvilStats/Processor.h b/Tools/AnvilStats/Processor.h
index db50ec619..30f160404 100644
--- a/Tools/AnvilStats/Processor.h
+++ b/Tools/AnvilStats/Processor.h
@@ -27,20 +27,20 @@ class cProcessor
public cIsThread
{
typedef cIsThread super;
-
+
cCallback & m_Callback;
cProcessor & m_ParentProcessor;
cEvent m_HasStarted;
-
+
// cIsThread override:
virtual void Execute(void) override;
-
+
void ProcessFile(const AString & a_FileName);
void ProcessFileData(const char * a_FileData, size_t a_Size, int a_ChunkBaseX, int a_ChunkBaseZ);
void ProcessChunk(const char * a_FileData, int a_ChunkX, int a_ChunkZ, unsigned a_SectorStart, unsigned a_SectorSize, unsigned a_TimeStamp);
void ProcessCompressedChunkData(int a_ChunkX, int a_ChunkZ, const char * a_CompressedData, int a_CompressedSize);
void ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT);
-
+
// The following processing parts return true if they were interrupted by the callback, causing the processing of current chunk to abort
bool ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
bool ProcessChunkEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
@@ -53,31 +53,27 @@ class cProcessor
/** Waits until the thread starts processing the callback code. */
void WaitForStart(void);
} ;
-
+
typedef std::vector<cThread *> cThreads;
-
+
public:
cProcessor(void);
~cProcessor();
-
+
void ProcessWorld(const AString & a_WorldFolder, cCallbackFactory & a_CallbackFactory);
-
+
protected:
bool m_IsShuttingDown; // If true, the threads should stop ASAP
-
+
cCriticalSection m_CS;
AStringList m_FileQueue;
-
+
cThreads m_Threads;
/** Populates m_FileQueue with Anvil files from the specified folder. */
void PopulateFileQueue(const AString & a_WorldFolder);
-
+
/** Returns one filename from m_FileQueue, and removes the name from the queue. */
AString GetOneFileName(void);
} ;
-
-
-
-
diff --git a/Tools/AnvilStats/SpringStats.cpp b/Tools/AnvilStats/SpringStats.cpp
index 51b7f9d5d..ccc0c8e45 100644
--- a/Tools/AnvilStats/SpringStats.cpp
+++ b/Tools/AnvilStats/SpringStats.cpp
@@ -10,7 +10,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSpringStats::cStats
cSpringStats::cStats::cStats(void) :
@@ -41,7 +41,7 @@ void cSpringStats::cStats::Add(const cSpringStats::cStats & a_Other)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSpringStats:
cSpringStats::cSpringStats(void) :
@@ -99,7 +99,7 @@ bool cSpringStats::OnSectionsFinished(void)
{
return true;
}
-
+
// Calc the spring stats:
for (int y = 1; y < 255; y++)
{
@@ -173,14 +173,14 @@ void cSpringStats::TestSpring(int a_RelX, int a_RelY, int a_RelZ, cSpringStats::
}
} // switch (BlockType)
} // for i - Coords[]
-
+
if (!HasFluidNextToIt)
{
// Surrounded by solids on all sides, this is probably not a spring,
// but rather a bedrocked lake or something similar. Dont want.
return;
}
-
+
// No source blocks next to the specified block, so it is a spring. Add it to stats:
a_Stats[a_RelY][((unsigned char *)m_Biomes)[a_RelX + 16 * a_RelZ]] += 1;
}
@@ -189,7 +189,7 @@ void cSpringStats::TestSpring(int a_RelX, int a_RelY, int a_RelZ, cSpringStats::
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSpringStatsFactory:
cSpringStatsFactory::~cSpringStatsFactory()
@@ -273,7 +273,3 @@ void cSpringStatsFactory::SaveStatistics(const cSpringStats::cStats::SpringStats
f.Write(Line.c_str(), Line.size());
}
}
-
-
-
-
diff --git a/Tools/AnvilStats/SpringStats.h b/Tools/AnvilStats/SpringStats.h
index 43b9f00d5..83651b7e6 100644
--- a/Tools/AnvilStats/SpringStats.h
+++ b/Tools/AnvilStats/SpringStats.h
@@ -22,31 +22,32 @@ public:
class cStats
{
public:
- /// Per-height, per-biome frequencies of springs
+ /** Per-height, per-biome frequencies of springs */
typedef UInt64 SpringStats[256][256];
-
+
SpringStats m_LavaSprings;
SpringStats m_WaterSprings;
-
- UInt64 m_TotalChunks; ///< Total number of chunks that are fully processed through this callback(OnSectionsFinished())
-
+
+ /** Total number of chunks that are fully processed through this callback(OnSectionsFinished()) */
+ UInt64 m_TotalChunks;
+
cStats(void);
void Add(const cStats & a_Other);
} ;
-
+
cSpringStats(void);
-
+
const cStats & GetStats(void) const { return m_Stats; }
-
+
protected:
BLOCKTYPE m_BlockTypes[16 * 16 * 256];
NIBBLETYPE m_BlockMetas[16 * 16 * 256 / 2];
char m_Biomes[16 * 16];
bool m_AreBiomesValid;
-
+
cStats m_Stats;
-
+
// cCallback overrides:
virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
@@ -67,7 +68,7 @@ protected:
) override;
virtual bool OnSectionsFinished(void) override;
- /// Tests the specified block, if it appears to be a spring, it is added to a_Stats
+ /** Tests the specified block, if it appears to be a spring, it is added to a_Stats */
void TestSpring(int a_RelX, int a_RelY, int a_RelZ, cStats::SpringStats & a_Stats);
} ;
@@ -80,23 +81,19 @@ class cSpringStatsFactory :
{
public:
virtual ~cSpringStatsFactory();
-
+
virtual cCallback * CreateNewCallback(void) override
{
return new cSpringStats;
}
cSpringStats::cStats m_CombinedStats;
-
+
void JoinResults(void);
-
- /// Saves total per-height data (summed through biomes) for both spring types to the file
+
+ /** Saves total per-height data (summed through biomes) for both spring types to the file */
void SaveTotals(const AString & a_FileName);
-
- /// Saves complete per-height, per-biome statistics for the springs to the file
+
+ /** Saves complete per-height, per-biome statistics for the springs to the file */
void SaveStatistics(const cSpringStats::cStats::SpringStats & a_Stats, const AString & a_FileName);
} ;
-
-
-
-
diff --git a/Tools/AnvilStats/Statistics.cpp b/Tools/AnvilStats/Statistics.cpp
index c8a98b488..d5ad360f3 100644
--- a/Tools/AnvilStats/Statistics.cpp
+++ b/Tools/AnvilStats/Statistics.cpp
@@ -11,7 +11,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStatistics::cStats:
cStatistics::cStats::cStats(void) :
@@ -97,7 +97,7 @@ void cStatistics::cStats::UpdateCoordsRange(int a_ChunkX, int a_ChunkZ)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStatistics:
cStatistics::cStatistics(void)
@@ -153,7 +153,7 @@ bool cStatistics::OnSection
// The current biome data is not valid, we don't have the means for sorting the BlockTypes into per-biome arrays
return true;
}
-
+
for (int y = 0; y < 16; y++)
{
int Height = (int)a_Y * 16 + y;
@@ -168,10 +168,10 @@ bool cStatistics::OnSection
}
}
}
-
+
m_Stats.m_BlockNumChunks += m_IsFirstSectionInChunk ? 1 : 0;
m_IsFirstSectionInChunk = false;
-
+
return false;
}
@@ -187,7 +187,7 @@ bool cStatistics::OnEmptySection(unsigned char a_Y)
return true;
}
- // Add air to all columns:
+ // Add air to all columns:
for (int z = 0; z < 16; z++)
{
for (int x = 0; x < 16; x++)
@@ -196,10 +196,10 @@ bool cStatistics::OnEmptySection(unsigned char a_Y)
m_Stats.m_BlockCounts[Biome][0] += 16; // 16 blocks in a column, all air
}
}
-
+
m_Stats.m_BlockNumChunks += m_IsFirstSectionInChunk ? 1 : 0;
m_IsFirstSectionInChunk = false;
-
+
return false;
}
@@ -221,9 +221,9 @@ bool cStatistics::OnEntity(
)
{
m_Stats.m_NumEntities += 1;
-
+
// TODO
-
+
return false;
}
@@ -239,12 +239,12 @@ bool cStatistics::OnTileEntity(
)
{
m_Stats.m_NumTileEntities += 1;
-
+
if (a_EntityType == "MobSpawner")
{
OnSpawner(a_NBT, a_NBTTag);
}
-
+
return false;
}
@@ -280,7 +280,7 @@ void cStatistics::OnSpawner(cParsedNBT & a_NBT, int a_TileEntityTag)
return;
}
m_Stats.m_SpawnerEntity[Ent] += 1;
-
+
// Get the spawner pos:
int PosYTag = a_NBT.FindChildByName(a_TileEntityTag, "y");
if ((PosYTag < 0) || (a_NBT.GetType(PosYTag) != TAG_Int))
@@ -295,7 +295,7 @@ void cStatistics::OnSpawner(cParsedNBT & a_NBT, int a_TileEntityTag)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStatisticsFactory:
cStatisticsFactory::cStatisticsFactory(void) :
@@ -315,7 +315,7 @@ cStatisticsFactory::~cStatisticsFactory()
JoinResults();
LOG(" Total %llu chunks went through", m_CombinedStats.m_TotalChunks);
LOG(" Biomes processed for %llu chunks", m_CombinedStats.m_BiomeNumChunks);
-
+
// Check the number of blocks processed
UInt64 TotalBlocks = 0;
for (int i = 0; i <= 255; i++)
@@ -327,7 +327,7 @@ cStatisticsFactory::~cStatisticsFactory()
}
UInt64 ExpTotalBlocks = m_CombinedStats.m_BlockNumChunks * 16LL * 16LL * 256LL;
LOG(" BlockIDs processed for %llu chunks, %llu blocks (exp %llu; %s)", m_CombinedStats.m_BlockNumChunks, TotalBlocks, ExpTotalBlocks, (TotalBlocks == ExpTotalBlocks) ? "match" : "failed");
-
+
// Save statistics:
LOG(" Saving statistics into files:");
LOG(" Statistics.txt");
@@ -429,7 +429,7 @@ void cStatisticsFactory::SavePerHeightBlockTypes(void)
LOG("Cannot write to file PerHeightBlockTypes.xls. Statistics not written.");
return;
}
-
+
// Write header:
f.Printf("Blocks 0 - 127:\nHeight");
for (int i = 0; i < 128; i++)
@@ -437,7 +437,7 @@ void cStatisticsFactory::SavePerHeightBlockTypes(void)
f.Printf("\t%s(%d)", GetBlockTypeString(i), i);
}
f.Printf("\n");
-
+
// Write first half:
for (int y = 0; y < 256; y++)
{
@@ -457,7 +457,7 @@ void cStatisticsFactory::SavePerHeightBlockTypes(void)
f.Printf("\t%s(%d)", GetBlockTypeString(i), i);
}
f.Printf("\n");
-
+
// Write second half:
for (int y = 0; y < 256; y++)
{
@@ -483,10 +483,10 @@ void cStatisticsFactory::SaveBiomeBlockTypes(void)
LOG("Cannot write to file BiomeBlockTypes.xls. Statistics not written.");
return;
}
-
+
AString FileHeader("Biomes 0-127:\n");
f.Write(FileHeader.c_str(), FileHeader.length());
-
+
AString Header("BlockType\tBlockType");
for (int Biome = 0; Biome <= 127; Biome++)
{
@@ -502,7 +502,7 @@ void cStatisticsFactory::SaveBiomeBlockTypes(void)
}
Header.append("\n");
f.Write(Header.c_str(), Header.length());
-
+
for (int BlockType = 0; BlockType <= 255; BlockType++)
{
AString Line;
@@ -530,7 +530,7 @@ void cStatisticsFactory::SaveBiomeBlockTypes(void)
}
Header.append("\n");
f.Write(Header.c_str(), Header.length());
-
+
for (int BlockType = 0; BlockType <= 255; BlockType++)
{
AString Line;
@@ -557,7 +557,7 @@ void cStatisticsFactory::SaveStatistics(void)
LOG("Cannot write to file Statistics.txt. Statistics not written.");
return;
}
-
+
int Elapsed = (clock() - m_BeginTick) / CLOCKS_PER_SEC;
f.Printf("Time elapsed: %d seconds (%d hours, %d minutes and %d seconds)\n", Elapsed, Elapsed / 3600, (Elapsed / 60) % 60, Elapsed % 60);
f.Printf("Total chunks processed: %llu\n", m_CombinedStats.m_TotalChunks);
@@ -589,7 +589,7 @@ void cStatisticsFactory::SaveSpawners(void)
LOG("Cannot write to file Spawners.xls. Statistics not written.");
return;
}
-
+
f.Printf("Entity type\tTotal count\tCount per chunk\n");
for (int i = 0; i < entMax; i++)
{
@@ -609,7 +609,7 @@ void cStatisticsFactory::SavePerHeightSpawners(void)
LOG("Cannot write to file PerHeightSpawners.xls. Statistics not written.");
return;
}
-
+
// Write header:
f.Printf("Height\tTotal");
for (int i = 0; i < entMax; i++)
@@ -634,7 +634,3 @@ void cStatisticsFactory::SavePerHeightSpawners(void)
f.Printf("\n");
}
}
-
-
-
-
diff --git a/Tools/AnvilStats/Statistics.h b/Tools/AnvilStats/Statistics.h
index 1b012e283..2c8c61685 100644
--- a/Tools/AnvilStats/Statistics.h
+++ b/Tools/AnvilStats/Statistics.h
@@ -35,19 +35,19 @@ public:
UInt64 m_PerHeightSpawners[256][entMax + 1]; // First dimension is the height, second dimension is spawned entity type
int m_MinChunkX, m_MaxChunkX; // X coords range
int m_MinChunkZ, m_MaxChunkZ; // Z coords range
-
+
Int64 m;
UInt64 m_SpawnerEntity[entMax + 1];
-
+
cStats(void);
void Add(const cStats & a_Stats);
void UpdateCoordsRange(int a_ChunkX, int a_ChunkZ);
} ;
-
+
cStatistics(void);
-
+
const cStats & GetStats(void) const { return m_Stats; }
-
+
protected:
cStats m_Stats;
@@ -73,9 +73,9 @@ protected:
const NIBBLETYPE * a_BlockLight,
const NIBBLETYPE * a_BlockSkyLight
) override;
-
+
virtual bool OnEmptySection(unsigned char a_Y) override;
-
+
virtual bool OnSectionsFinished(void) override { return false; } // continue processing
virtual bool OnEntity(
@@ -90,20 +90,20 @@ protected:
cParsedNBT & a_NBT,
int a_NBTTag
) override;
-
+
virtual bool OnTileEntity(
const AString & a_EntityType,
int a_PosX, int a_PosY, int a_PosZ,
cParsedNBT & a_NBT,
int a_NBTTag
) override;
-
+
virtual bool OnTileTick(
int a_BlockType,
int a_TicksLeft,
int a_PosX, int a_PosY, int a_PosZ
) override;
-
+
void OnSpawner(cParsedNBT & a_NBT, int a_TileEntityTag);
} ;
@@ -117,16 +117,16 @@ class cStatisticsFactory :
public:
cStatisticsFactory(void);
virtual ~cStatisticsFactory();
-
+
virtual cCallback * CreateNewCallback(void)
{
return new cStatistics;
}
-
+
protected:
// The results, combined, are stored here:
cStatistics::cStats m_CombinedStats;
-
+
clock_t m_BeginTick;
void JoinResults(void);
@@ -138,7 +138,3 @@ protected:
void SaveSpawners(void);
void SavePerHeightSpawners(void);
} ;
-
-
-
-
diff --git a/Tools/AnvilStats/Utils.cpp b/Tools/AnvilStats/Utils.cpp
index 34374647b..741c01667 100644
--- a/Tools/AnvilStats/Utils.cpp
+++ b/Tools/AnvilStats/Utils.cpp
@@ -238,7 +238,7 @@ const char * GetBlockTypeString(unsigned char a_BlockType)
"Wooden Button",
"Head",
} ;
-
+
return (a_BlockType < ARRAYCOUNT(BlockTypeNames)) ? BlockTypeNames[a_BlockType] : "";
}
@@ -287,7 +287,3 @@ int GetNumCores(void)
} // while (Affinity > 0)
return NumCores;
}
-
-
-
-