summaryrefslogtreecommitdiffstats
path: root/Tools/AnvilStats
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/AnvilStats')
-rw-r--r--Tools/AnvilStats/AnvilStats.cpp10
-rw-r--r--Tools/AnvilStats/BiomeMap.cpp20
-rw-r--r--Tools/AnvilStats/BiomeMap.h32
-rw-r--r--Tools/AnvilStats/Callback.h80
-rw-r--r--Tools/AnvilStats/ChunkExtract.cpp18
-rw-r--r--Tools/AnvilStats/ChunkExtract.h36
-rw-r--r--Tools/AnvilStats/Globals.cpp4
-rw-r--r--Tools/AnvilStats/Globals.h103
-rw-r--r--Tools/AnvilStats/HeightBiomeMap.cpp17
-rw-r--r--Tools/AnvilStats/HeightBiomeMap.h48
-rw-r--r--Tools/AnvilStats/HeightMap.cpp21
-rw-r--r--Tools/AnvilStats/HeightMap.h34
-rw-r--r--Tools/AnvilStats/ImageComposingCallback.cpp13
-rw-r--r--Tools/AnvilStats/ImageComposingCallback.h17
-rw-r--r--Tools/AnvilStats/Processor.cpp132
-rw-r--r--Tools/AnvilStats/Processor.h39
-rw-r--r--Tools/AnvilStats/SpringStats.cpp39
-rw-r--r--Tools/AnvilStats/SpringStats.h45
-rw-r--r--Tools/AnvilStats/Statistics.cpp87
-rw-r--r--Tools/AnvilStats/Statistics.h69
-rw-r--r--Tools/AnvilStats/Utils.cpp413
-rw-r--r--Tools/AnvilStats/Utils.h5
22 files changed, 679 insertions, 603 deletions
diff --git a/Tools/AnvilStats/AnvilStats.cpp b/Tools/AnvilStats/AnvilStats.cpp
index 5c3a1708a..dafeba463 100644
--- a/Tools/AnvilStats/AnvilStats.cpp
+++ b/Tools/AnvilStats/AnvilStats.cpp
@@ -45,12 +45,12 @@ int main(int argc, char * argv[])
cCallbackFactory * Factory = NULL;
switch (atol(argv[1]))
{
- case 0: Factory = new cStatisticsFactory; break;
- case 1: Factory = new cBiomeMapFactory; break;
- case 2: Factory = new cHeightMapFactory; break;
+ case 0: Factory = new cStatisticsFactory; break;
+ case 1: Factory = new cBiomeMapFactory; break;
+ case 2: Factory = new cHeightMapFactory; break;
case 3: Factory = new cChunkExtractFactory(WorldFolder); break;
- case 4: Factory = new cSpringStatsFactory; break;
- case 5: Factory = new cHeightBiomeMapFactory; break;
+ case 4: Factory = new cSpringStatsFactory; break;
+ case 5: Factory = new cHeightBiomeMapFactory; break;
default:
{
LOG("Unknown method \"%s\", aborting.", argv[1]);
diff --git a/Tools/AnvilStats/BiomeMap.cpp b/Tools/AnvilStats/BiomeMap.cpp
index edb971f85..1238bf7ac 100644
--- a/Tools/AnvilStats/BiomeMap.cpp
+++ b/Tools/AnvilStats/BiomeMap.cpp
@@ -11,22 +11,18 @@
-static const unsigned char g_BMPHeader[] =
-{
- 0x42, 0x4D, 0x36, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-} ;
+static const unsigned char g_BMPHeader[] = {0x42, 0x4D, 0x36, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36,
+ 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0xfe, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
cBiomeMap::cBiomeMap(void) :
- m_CurrentRegionX(0),
- m_CurrentRegionZ(0),
- m_IsCurrentRegionValid(false)
+ m_CurrentRegionX(0), m_CurrentRegionZ(0), m_IsCurrentRegionValid(false)
{
}
@@ -105,7 +101,7 @@ void cBiomeMap::StartNewRegion(int a_RegionX, int a_RegionZ)
for (int z = 0; z < 512; z++)
{
int RowData[512];
- unsigned char * BiomeRow = (unsigned char *)m_Biomes + z * 512;
+ unsigned char * BiomeRow = (unsigned char *) m_Biomes + z * 512;
for (int x = 0; x < 512; x++)
{
RowData[x] = g_BiomeColors[BiomeRow[x]];
@@ -131,7 +127,7 @@ cBiomeMapFactory::~cBiomeMapFactory()
// Force all threads to save their last regions:
for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
{
- ((cBiomeMap *)(*itr))->Finish();
+ ((cBiomeMap *) (*itr))->Finish();
}
// TODO: Join all the files into one giant image file
}
diff --git a/Tools/AnvilStats/BiomeMap.h b/Tools/AnvilStats/BiomeMap.h
index a2eb12a41..b61d881a5 100644
--- a/Tools/AnvilStats/BiomeMap.h
+++ b/Tools/AnvilStats/BiomeMap.h
@@ -15,16 +15,15 @@
-class cBiomeMap :
- public cCallback
+class cBiomeMap : public cCallback
{
-public:
+ public:
cBiomeMap(void);
/** Saves the last region that it was processing */
void Finish(void);
-protected:
+ protected:
int m_CurrentChunkX; // Absolute chunk coords
int m_CurrentChunkZ;
int m_CurrentChunkOffX; // Chunk offset from the start of the region
@@ -37,29 +36,30 @@ protected:
// 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; }
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
+ virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override
+ {
+ return false;
+ }
virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
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 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);
-} ;
+};
-class cBiomeMapFactory :
- public cCallbackFactory
+class cBiomeMapFactory : public cCallbackFactory
{
-public:
+ public:
virtual ~cBiomeMapFactory();
- virtual cCallback * CreateNewCallback(void) override
- {
- return new cBiomeMap;
- }
-
-} ;
+ virtual cCallback * CreateNewCallback(void) override { return new cBiomeMap; }
+};
diff --git a/Tools/AnvilStats/Callback.h b/Tools/AnvilStats/Callback.h
index 9b6554a8d..3e080f65d 100644
--- a/Tools/AnvilStats/Callback.h
+++ b/Tools/AnvilStats/Callback.h
@@ -24,19 +24,19 @@ class cParsedNBT;
The processor calls each virtual function in the order they are declared here with the specified args.
If the function returns true, the processor doesn't process the data item, moves on to the next chunk
and starts calling the callbacks again from start with the new chunk data.
-So if a statistics collector doesn't need data decompression at all, it can stop the processor from doing so early-enough
-and still get meaningful data.
-A callback is guaranteed to run in a single thread and always the same thread for the same chunk.
-A callback is guaranteed to run on all chunks in a region and one region is guaranteed to be handled by only callback.
+So if a statistics collector doesn't need data decompression at all, it can stop the processor from doing so
+early-enough and still get meaningful data. A callback is guaranteed to run in a single thread and always the same
+thread for the same chunk. A callback is guaranteed to run on all chunks in a region and one region is guaranteed to be
+handled by only callback.
*/
class cCallback abstract
{
-public:
+ public:
enum
{
CALLBACK_CONTINUE = false,
- CALLBACK_ABORT = true,
- } ;
+ CALLBACK_ABORT = true,
+ };
virtual ~cCallback() {} // Force a virtual destructor in each descendant
@@ -46,11 +46,16 @@ public:
/** 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) */
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) { 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) */
+ 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 ;) */
virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) { return CALLBACK_ABORT; }
@@ -71,7 +76,8 @@ public:
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().
+ All OnSection() callbacks are called first, and only then all the remaining sections are reported in
+ OnEmptySection().
*/
virtual bool OnSection(
unsigned char a_Y,
@@ -80,7 +86,10 @@ public:
const NIBBLETYPE * a_BlockMeta,
const NIBBLETYPE * a_BlockLight,
const NIBBLETYPE * a_BlockSkyLight
- ) { return CALLBACK_ABORT; }
+ )
+ {
+ return CALLBACK_ABORT;
+ }
/** 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.
@@ -88,7 +97,7 @@ public:
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.
@@ -98,16 +107,24 @@ public:
*/
virtual bool OnEntity(
const AString & a_EntityType,
- double a_PosX, double a_PosY, double a_PosZ,
- double a_SpeedX, double a_SpeedY, double a_SpeedZ,
- float a_Yaw, float a_Pitch,
+ double a_PosX,
+ double a_PosY,
+ double a_PosZ,
+ double a_SpeedX,
+ double a_SpeedY,
+ double a_SpeedZ,
+ float a_Yaw,
+ float a_Pitch,
float a_FallDistance,
short a_FireTicksLeft,
short a_AirTicks,
char a_IsOnGround,
cParsedNBT & a_NBT,
int a_NBTTag
- ) { return CALLBACK_ABORT; }
+ )
+ {
+ return CALLBACK_ABORT;
+ }
/** Called for each tile entity in the chunk.
Common parameters are parsed from the NBT.
@@ -116,21 +133,26 @@ public:
*/
virtual bool OnTileEntity(
const AString & a_EntityType,
- int a_PosX, int a_PosY, int a_PosZ,
+ int a_PosX,
+ int a_PosY,
+ int a_PosZ,
cParsedNBT & a_NBT,
int a_NBTTag
- ) { return CALLBACK_ABORT; }
+ )
+ {
+ return CALLBACK_ABORT;
+ }
/** 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; }
+ 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) {}
-} ;
+};
typedef std::vector<cCallback *> cCallbacks;
@@ -145,7 +167,7 @@ The factory keeps track of all the callbacks that it has created and deletes the
*/
class cCallbackFactory
{
-public:
+ public:
virtual ~cCallbackFactory()
{
for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
@@ -168,6 +190,6 @@ public:
return Callback;
}
-protected:
+ protected:
cCallbacks m_Callbacks;
-} ;
+};
diff --git a/Tools/AnvilStats/ChunkExtract.cpp b/Tools/AnvilStats/ChunkExtract.cpp
index fda09dfbd..67e8b4672 100644
--- a/Tools/AnvilStats/ChunkExtract.cpp
+++ b/Tools/AnvilStats/ChunkExtract.cpp
@@ -1,7 +1,8 @@
// ChunkExtract.cpp
-// Implements the cChunkExtract class representing a cCallback descendant that extracts raw chunk data into separate .chunk files
+// Implements the cChunkExtract class representing a cCallback descendant that extracts raw chunk data into separate
+// .chunk files
#include "Globals.h"
#include "ChunkExtract.h"
@@ -47,7 +48,10 @@ bool cChunkExtract::OnCompressedDataSizePos(int a_CompressedDataSize, int a_Data
AString ChunkPath = Printf("%d.%d.zchunk", mCurChunkX, mCurChunkZ);
if (!ChunkFile.Open(ChunkPath, cFile::fmWrite))
{
- LOG("Cannot open zchunk file \"%s\" for writing. Chunk [%d, %d] skipped.", ChunkPath.c_str(), mCurChunkX, mCurChunkZ);
+ LOG("Cannot open zchunk file \"%s\" for writing. Chunk [%d, %d] skipped.",
+ ChunkPath.c_str(),
+ mCurChunkX,
+ mCurChunkZ);
return false;
}
@@ -56,11 +60,12 @@ bool cChunkExtract::OnCompressedDataSizePos(int a_CompressedDataSize, int a_Data
for (int BytesToCopy = a_CompressedDataSize; BytesToCopy > 0;)
{
char Buffer[64000];
- int NumBytes = std::min(BytesToCopy, (int)sizeof(Buffer));
+ int NumBytes = std::min(BytesToCopy, (int) sizeof(Buffer));
int BytesRead = mAnvilFile.Read(Buffer, NumBytes);
if (BytesRead != NumBytes)
{
- LOG("Cannot copy chunk data, chunk [%d, %d] is probably corrupted. Skipping chunk.", mCurChunkX, mCurChunkZ);
+ LOG("Cannot copy chunk data, chunk [%d, %d] is probably corrupted. Skipping chunk.", mCurChunkX, mCurChunkZ
+ );
return false;
}
ChunkFile.Write(Buffer, BytesRead);
@@ -80,7 +85,10 @@ bool cChunkExtract::OnDecompressedData(const char * a_DecompressedNBT, int a_Dat
cGZipFile GZipChunk;
if (!GZipChunk.Open(FileName, cGZipFile::fmWrite))
{
- LOG("Cannot open gzchunk file \"%s\" for writing. Chunk [%d, %d] skipped.", FileName.c_str(), mCurChunkX, mCurChunkZ);
+ LOG("Cannot open gzchunk file \"%s\" for writing. Chunk [%d, %d] skipped.",
+ FileName.c_str(),
+ mCurChunkX,
+ mCurChunkZ);
return true;
}
GZipChunk.Write(a_DecompressedNBT, a_DataSize);
diff --git a/Tools/AnvilStats/ChunkExtract.h b/Tools/AnvilStats/ChunkExtract.h
index a5be2bc25..777589d5e 100644
--- a/Tools/AnvilStats/ChunkExtract.h
+++ b/Tools/AnvilStats/ChunkExtract.h
@@ -1,7 +1,8 @@
// ChunkExtract.h
-// Declares the cChunkExtract class representing a cCallback descendant that extracts raw chunk data into separate .chunk files
+// Declares the cChunkExtract class representing a cCallback descendant that extracts raw chunk data into separate
+// .chunk files
@@ -15,19 +16,18 @@
-class cChunkExtract :
- public cCallback
+class cChunkExtract : public cCallback
{
-public:
+ public:
cChunkExtract(const AString & iWorldFolder);
-protected:
+ protected:
AString mWorldFolder;
- cFile mAnvilFile;
- int mCurAnvilX; // X-coord of mAnvilFile, in Anvil-coords (1 Anvil-coord = 32 chunks)
- int mCurAnvilZ; // Z-coord of mAnvilFile, -"-
- int mCurChunkX; // X-coord of the chunk being processed
- int mCurChunkZ; // Z-coord of the chunk being processed
+ cFile mAnvilFile;
+ int mCurAnvilX; // X-coord of mAnvilFile, in Anvil-coords (1 Anvil-coord = 32 chunks)
+ 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 */
void OpenAnvilFile(int a_AnvilX, int a_AnvilZ);
@@ -37,26 +37,22 @@ protected:
virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override;
virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override;
-} ;
+};
-class cChunkExtractFactory :
- public cCallbackFactory
+class cChunkExtractFactory : public cCallbackFactory
{
-public:
+ public:
cChunkExtractFactory(const AString & iWorldFolder) :
mWorldFolder(iWorldFolder)
{
}
- virtual cCallback * CreateNewCallback(void) override
- {
- return new cChunkExtract(mWorldFolder);
- }
+ virtual cCallback * CreateNewCallback(void) override { return new cChunkExtract(mWorldFolder); }
-protected:
+ protected:
AString mWorldFolder;
-} ;
+};
diff --git a/Tools/AnvilStats/Globals.cpp b/Tools/AnvilStats/Globals.cpp
index 13c6ae709..680afbf75 100644
--- a/Tools/AnvilStats/Globals.cpp
+++ b/Tools/AnvilStats/Globals.cpp
@@ -4,7 +4,3 @@
// This file is used for precompiled header generation in MSVC environments
#include "Globals.h"
-
-
-
-
diff --git a/Tools/AnvilStats/Globals.h b/Tools/AnvilStats/Globals.h
index 18e2ab7c4..1cb3b6912 100644
--- a/Tools/AnvilStats/Globals.h
+++ b/Tools/AnvilStats/Globals.h
@@ -10,22 +10,22 @@
// Compiler-dependent stuff:
#if defined(_MSC_VER)
- // MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
- #pragma warning(disable:4481)
+// 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)
+// Disable some warnings that we don't care about:
+#pragma warning(disable : 4100)
- #define _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS
#elif defined(__GNUC__)
- // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
- #define abstract
+// TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
+#define abstract
#else
- #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
+#error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
#endif
@@ -35,12 +35,12 @@
// Integral types with predefined sizes:
typedef long long Int64;
-typedef int Int32;
-typedef short Int16;
+typedef int Int32;
+typedef short Int16;
typedef unsigned long long UInt64;
-typedef unsigned int UInt32;
-typedef unsigned short UInt16;
+typedef unsigned int UInt32;
+typedef unsigned short UInt16;
@@ -49,48 +49,48 @@ typedef unsigned short UInt16;
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for any class that shouldn't allow copying itself
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName &); \
+ TypeName(const TypeName &); \
void operator=(const TypeName &)
// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
-#define UNUSED(X) (void)(X)
+#define UNUSED(X) (void) (X)
// OS-dependent stuff:
#ifdef _WIN32
- #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
- #endif // GetFreeSpace
+#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
+#endif // GetFreeSpace
#else
- #include <sys/types.h>
- #include <sys/stat.h> // for mkdir
- #include <sys/time.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <time.h>
- #include <dirent.h>
- #include <errno.h>
- #include <iostream>
-
- #include <cstdio>
- #include <cstring>
- #include <pthread.h>
- #include <semaphore.h>
- #include <errno.h>
- #include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h> // for mkdir
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <time.h>
+#include <dirent.h>
+#include <errno.h>
+#include <iostream>
+
+#include <cstdio>
+#include <cstring>
+#include <pthread.h>
+#include <semaphore.h>
+#include <errno.h>
+#include <fcntl.h>
#endif
@@ -146,21 +146,21 @@ typedef unsigned short UInt16;
#define ARRAYCOUNT(X) (sizeof(X) / sizeof(*(X)))
/** Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)") */
-#define KiB * 1024
+#define KiB *1024
/** Allows arithmetic expressions like "32 MiB" (but consider using parenthesis around it, "(32 MiB)") */
-#define MiB * 1024 * 1024
+#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))
+#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))
+#ifdef _DEBUG
+#define ASSERT(x) (!!(x) || (LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__), assert(0), 0))
#else
- #define ASSERT(x) ((void)0)
+#define ASSERT(x) ((void) 0)
#endif
// Pretty much the same as ASSERT() but stays in Release builds
@@ -173,8 +173,7 @@ typedef unsigned char Byte;
/** Clamp value to the specified range. */
-template <typename T>
-T Clamp(T a_Value, T a_Min, T a_Max)
+template <typename T> T Clamp(T a_Value, T a_Min, T a_Max)
{
return (a_Value < a_Min) ? a_Min : ((a_Value > a_Max) ? a_Max : a_Value);
}
diff --git a/Tools/AnvilStats/HeightBiomeMap.cpp b/Tools/AnvilStats/HeightBiomeMap.cpp
index fcbc5f4df..430a1aec1 100644
--- a/Tools/AnvilStats/HeightBiomeMap.cpp
+++ b/Tools/AnvilStats/HeightBiomeMap.cpp
@@ -12,11 +12,7 @@
cHeightBiomeMap::cHeightBiomeMap(void) :
- super("HeBi"),
- m_MinRegionX(100000),
- m_MaxRegionX(-100000),
- m_MinRegionZ(100000),
- m_MaxRegionZ(-100000)
+ super("HeBi"), m_MinRegionX(100000), m_MaxRegionX(-100000), m_MinRegionZ(100000), m_MaxRegionZ(-100000)
{
}
@@ -68,7 +64,6 @@ 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));
@@ -114,8 +109,7 @@ bool cHeightBiomeMap::OnSection(
bool cHeightBiomeMap::OnSectionsFinished(void)
{
- static const int BiomePalette[] =
- {
+ static const int BiomePalette[] = {
// ARGB:
0xff0000ff, /* Ocean */
0xff00cf3f, /* Plains */
@@ -140,7 +134,7 @@ bool cHeightBiomeMap::OnSectionsFinished(void)
0xff7f8f7f, /* Extreme Hills Edge */
0xff004f00, /* Jungle */
0xff003f00, /* Jungle Hills */
- } ;
+ };
// Remove trees and other unwanted stuff from the heightmap:
for (int z = 0; z < 16; z++)
@@ -185,7 +179,7 @@ cHeightBiomeMapFactory::~cHeightBiomeMapFactory()
int MaxRegionZ = -100000;
for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
{
- cHeightBiomeMap * cb = (cHeightBiomeMap *)(*itr);
+ cHeightBiomeMap * cb = (cHeightBiomeMap *) (*itr);
if (cb->m_MinRegionX < MinRegionX)
{
MinRegionX = cb->m_MinRegionX;
@@ -205,7 +199,8 @@ cHeightBiomeMapFactory::~cHeightBiomeMapFactory()
}
// 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))
+ if ((MaxRegionX >= MinRegionX) && (MaxRegionZ >= MinRegionZ) && (MaxRegionX - MinRegionX < 100) &&
+ (MaxRegionZ - MinRegionZ < 100))
{
cFile HTML("HeBi.html", cFile::fmWrite);
if (HTML.IsOpen())
diff --git a/Tools/AnvilStats/HeightBiomeMap.h b/Tools/AnvilStats/HeightBiomeMap.h
index 8a2cb9726..16d4ef308 100644
--- a/Tools/AnvilStats/HeightBiomeMap.h
+++ b/Tools/AnvilStats/HeightBiomeMap.h
@@ -15,40 +15,51 @@
-class cHeightBiomeMap :
- public cImageComposingCallback
+class cHeightBiomeMap : public cImageComposingCallback
{
typedef cImageComposingCallback super;
-public:
+ public:
// Minima and maxima for the regions processed through this callback
int m_MinRegionX, m_MaxRegionX;
int m_MinRegionZ, m_MaxRegionZ;
cHeightBiomeMap(void);
-protected:
+ protected:
int m_CurrentChunkX; // Absolute chunk coords
int m_CurrentChunkZ;
int m_CurrentChunkRelX; // Chunk offset from the start of the region
int m_CurrentChunkRelZ;
/** Biome-map for the current chunk */
- char m_ChunkBiomes[16 * 16];
+ char m_ChunkBiomes[16 * 16];
/** Height-map for the current chunk */
- int m_ChunkHeight[16 * 16];
+ int m_ChunkHeight[16 * 16];
/** Block data for the current chunk (between OnSection() and OnSectionsFinished()) */
- BLOCKTYPE m_BlockTypes [16 * 16 * 256];
+ BLOCKTYPE m_BlockTypes[16 * 16 * 256];
// cCallback overrides:
virtual bool OnNewRegion(int a_RegionX, int a_RegionZ) override;
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 CALLBACK_CONTINUE; }
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return CALLBACK_CONTINUE; }
- virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return CALLBACK_CONTINUE; }
+ virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override
+ {
+ return CALLBACK_CONTINUE;
+ }
+ virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override
+ {
+ return CALLBACK_CONTINUE;
+ }
+ virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override
+ {
+ return CALLBACK_CONTINUE;
+ }
virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return CALLBACK_CONTINUE; }
virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return CALLBACK_CONTINUE; }
- virtual bool OnTerrainPopulated(bool a_Populated) override { return a_Populated ? CALLBACK_CONTINUE : CALLBACK_ABORT; } // If not populated, we don't want it!
+ virtual bool OnTerrainPopulated(bool a_Populated) override
+ {
+ return a_Populated ? CALLBACK_CONTINUE : CALLBACK_ABORT;
+ } // If not populated, we don't want it!
virtual bool OnBiomes(const unsigned char * a_BiomeData) override;
virtual bool OnHeightMap(const int * a_HeightMapBE) override;
virtual bool OnSection(
@@ -60,21 +71,16 @@ protected:
const NIBBLETYPE * a_BlockSkyLight
) override;
virtual bool OnSectionsFinished(void) override;
-
-} ;
+};
-class cHeightBiomeMapFactory :
- public cCallbackFactory
+class cHeightBiomeMapFactory : public cCallbackFactory
{
-public:
+ public:
virtual ~cHeightBiomeMapFactory();
- virtual cCallback * CreateNewCallback(void) override
- {
- return new cHeightBiomeMap;
- }
-} ;
+ virtual cCallback * CreateNewCallback(void) override { return new cHeightBiomeMap; }
+};
diff --git a/Tools/AnvilStats/HeightMap.cpp b/Tools/AnvilStats/HeightMap.cpp
index 74ce1bf50..ee42200ac 100644
--- a/Tools/AnvilStats/HeightMap.cpp
+++ b/Tools/AnvilStats/HeightMap.cpp
@@ -9,22 +9,18 @@
-static const unsigned char g_BMPHeader[] =
-{
- 0x42, 0x4D, 0x36, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-} ;
+static const unsigned char g_BMPHeader[] = {0x42, 0x4D, 0x36, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36,
+ 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0xfe, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
cHeightMap::cHeightMap(void) :
- m_CurrentRegionX(0),
- m_CurrentRegionZ(0),
- m_IsCurrentRegionValid(false)
+ m_CurrentRegionX(0), m_CurrentRegionZ(0), m_IsCurrentRegionValid(false)
{
}
@@ -207,7 +203,8 @@ bool cHeightMap::IsGround(BLOCKTYPE a_BlockType)
case E_BLOCK_LEAVES:
case E_BLOCK_LEVER:
case E_BLOCK_LILY_PAD:
- case E_BLOCK_LOG: // NOTE: This block is actually solid, but we don't want it because it's the thing that trees are made of, and we're getting rid of trees
+ case E_BLOCK_LOG: // NOTE: This block is actually solid, but we don't want it because it's the thing that trees
+ // are made of, and we're getting rid of trees
case E_BLOCK_MELON:
case E_BLOCK_MELON_STEM:
case E_BLOCK_NETHER_BRICK_FENCE:
@@ -261,7 +258,7 @@ cHeightMapFactory::~cHeightMapFactory()
// Force all threads to save their last regions:
for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
{
- ((cHeightMap *)(*itr))->Finish();
+ ((cHeightMap *) (*itr))->Finish();
}
// TODO: Join all the files into one giant image file
}
diff --git a/Tools/AnvilStats/HeightMap.h b/Tools/AnvilStats/HeightMap.h
index 69deb5bab..9d62febfc 100644
--- a/Tools/AnvilStats/HeightMap.h
+++ b/Tools/AnvilStats/HeightMap.h
@@ -15,17 +15,16 @@
-class cHeightMap :
- public cCallback
+class cHeightMap : public cCallback
{
-public:
+ public:
cHeightMap(void);
void Finish(void);
static bool IsGround(BLOCKTYPE a_BlockType);
-protected:
+ protected:
int m_CurrentChunkX; // Absolute chunk coords
int m_CurrentChunkZ;
int m_CurrentChunkOffX; // Chunk offset from the start of the region
@@ -34,18 +33,24 @@ protected:
int m_CurrentRegionZ;
bool m_IsCurrentRegionValid;
/** Height-map of the entire current region [x + 16 * 32 * z] */
- int m_Height[16 * 32 * 16 * 32];
+ 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; }
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
+ virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override
+ {
+ return false;
+ }
virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
- virtual bool OnTerrainPopulated(bool a_Populated) override { return !a_Populated; } // If not populated, we don't want it!
+ virtual bool OnTerrainPopulated(bool a_Populated) override
+ {
+ return !a_Populated;
+ } // If not populated, we don't want it!
virtual bool OnBiomes(const unsigned char * a_BiomeData) { return false; }
virtual bool OnHeightMap(const int * a_HeightMapBE) override;
virtual bool OnSection(
@@ -59,21 +64,16 @@ protected:
virtual bool OnSectionsFinished(void) override;
void StartNewRegion(int a_RegionX, int a_RegionZ);
-} ;
+};
-class cHeightMapFactory :
- public cCallbackFactory
+class cHeightMapFactory : public cCallbackFactory
{
-public:
+ public:
virtual ~cHeightMapFactory();
- virtual cCallback * CreateNewCallback(void) override
- {
- return new cHeightMap;
- }
-
-} ;
+ virtual cCallback * CreateNewCallback(void) override { return new cHeightMap; }
+};
diff --git a/Tools/AnvilStats/ImageComposingCallback.cpp b/Tools/AnvilStats/ImageComposingCallback.cpp
index cc200b9a4..0bf11a815 100644
--- a/Tools/AnvilStats/ImageComposingCallback.cpp
+++ b/Tools/AnvilStats/ImageComposingCallback.cpp
@@ -145,7 +145,6 @@ int cImageComposingCallback::GetPixel(int a_RelU, int a_RelV)
-
void cImageComposingCallback::SetPixelURow(int a_RelUStart, int a_RelV, int a_CountU, int * a_Pixels)
{
ASSERT((a_RelUStart >= 0) && (a_RelUStart + a_CountU <= IMAGE_WIDTH));
@@ -202,13 +201,11 @@ void cImageComposingCallback::SaveImage(const AString & a_FileName)
}
// Header for BMP files (is the same for the same-size files)
- static const unsigned char BMPHeader[] =
- {
- 0x42, 0x4D, 0x36, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- } ;
+ static const unsigned char BMPHeader[] = {0x42, 0x4D, 0x36, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36,
+ 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0xfe, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
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 916e61d92..6a1288fef 100644
--- a/Tools/AnvilStats/ImageComposingCallback.h
+++ b/Tools/AnvilStats/ImageComposingCallback.h
@@ -21,17 +21,16 @@ SetPixel() or SetPixelURow() functions.
For the purpose of this class the image data is indexed U (horz) * V (vert), to avoid confusion with other coords.
The image is a 32bpp raw imagedata, written into a BMP file.
*/
-class cImageComposingCallback :
- public cCallback
+class cImageComposingCallback : public cCallback
{
-public:
+ public:
enum
{
INVALID_REGION_COORD = 99999, ///< Used for un-assigned region coords
IMAGE_WIDTH = 32 * 16,
IMAGE_HEIGHT = 32 * 16,
PIXEL_COUNT = IMAGE_WIDTH * IMAGE_HEIGHT, ///< Total pixel count of the image data
- } ;
+ };
cImageComposingCallback(const AString & a_FileNamePrefix);
virtual ~cImageComposingCallback();
@@ -59,7 +58,8 @@ public:
/** 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 */
@@ -74,7 +74,8 @@ public:
/** 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
@@ -87,7 +88,7 @@ public:
/** 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:
+ protected:
/** Prefix for the filenames, when generated by the default GetFileName() function */
AString m_FileNamePrefix;
@@ -98,4 +99,4 @@ protected:
int * m_ImageData;
void SaveImage(const AString & a_FileName);
-} ;
+};
diff --git a/Tools/AnvilStats/Processor.cpp b/Tools/AnvilStats/Processor.cpp
index d0bdad0ca..7a1227d25 100644
--- a/Tools/AnvilStats/Processor.cpp
+++ b/Tools/AnvilStats/Processor.cpp
@@ -24,9 +24,7 @@ const int CHUNK_INFLATE_MAX = 1 MiB;
// cProcessor::cThread:
cProcessor::cThread::cThread(cCallback & a_Callback, cProcessor & a_ParentProcessor) :
- super("cProcessor::cThread"),
- m_Callback(a_Callback),
- m_ParentProcessor(a_ParentProcessor)
+ super("cProcessor::cThread"), m_Callback(a_Callback), m_ParentProcessor(a_ParentProcessor)
{
LOG("Created a new thread: %p", this);
super::Start();
@@ -119,7 +117,7 @@ void cProcessor::cThread::ProcessFile(const AString & a_FileName)
void cProcessor::cThread::ProcessFileData(const char * a_FileData, size_t a_Size, int a_ChunkBaseX, int a_ChunkBaseZ)
{
int Header[2048];
- int * HeaderPtr = (int *)a_FileData;
+ int * HeaderPtr = (int *) a_FileData;
for (int i = 0; i < ARRAYCOUNT(Header); i++)
{
Header[i] = ntohl(HeaderPtr[i]);
@@ -129,11 +127,10 @@ void cProcessor::cThread::ProcessFileData(const char * a_FileData, size_t a_Size
{
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
+ 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
)
{
// Chunk not present in the file
@@ -153,7 +150,14 @@ void cProcessor::cThread::ProcessFileData(const char * a_FileData, size_t a_Size
-void cProcessor::cThread::ProcessChunk(const char * a_FileData, int a_ChunkX, int a_ChunkZ, unsigned a_SectorStart, unsigned a_SectorSize, unsigned a_TimeStamp)
+void cProcessor::cThread::ProcessChunk(
+ const char * a_FileData,
+ int a_ChunkX,
+ int a_ChunkZ,
+ unsigned a_SectorStart,
+ unsigned a_SectorSize,
+ unsigned a_TimeStamp
+)
{
if (m_Callback.OnHeader(a_SectorStart * 4096, a_SectorSize, a_TimeStamp))
{
@@ -161,7 +165,7 @@ void cProcessor::cThread::ProcessChunk(const char * a_FileData, int a_ChunkX, in
}
const char * ChunkStart = a_FileData + a_SectorStart * 4096;
- int ByteSize = ntohl(*(int *)ChunkStart);
+ int ByteSize = ntohl(*(int *) ChunkStart);
char CompressionMethod = ChunkStart[4];
if (m_Callback.OnCompressedDataSizePos(ByteSize, a_SectorStart * 4096 + 5, CompressionMethod))
@@ -176,18 +180,23 @@ void cProcessor::cThread::ProcessChunk(const char * a_FileData, int a_ChunkX, in
-void cProcessor::cThread::ProcessCompressedChunkData(int a_ChunkX, int a_ChunkZ, const char * a_CompressedData, int a_CompressedSize)
+void cProcessor::cThread::ProcessCompressedChunkData(
+ int a_ChunkX,
+ int a_ChunkZ,
+ const char * a_CompressedData,
+ int a_CompressedSize
+)
{
char Decompressed[CHUNK_INFLATE_MAX];
z_stream strm;
- strm.zalloc = (alloc_func)NULL;
- strm.zfree = (free_func)NULL;
+ strm.zalloc = (alloc_func) NULL;
+ strm.zfree = (free_func) NULL;
strm.opaque = NULL;
inflateInit(&strm);
- strm.next_out = (Bytef *)Decompressed;
+ strm.next_out = (Bytef *) Decompressed;
strm.avail_out = sizeof(Decompressed);
- strm.next_in = (Bytef *)a_CompressedData;
- strm.avail_in = a_CompressedSize;
+ strm.next_in = (Bytef *) a_CompressedData;
+ strm.avail_in = a_CompressedSize;
int res = inflate(&strm, Z_FINISH);
inflateEnd(&strm);
if (res != Z_STREAM_END)
@@ -255,7 +264,7 @@ void cProcessor::cThread::ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cPa
int BiomesTag = a_NBT.FindChildByName(LevelTag, "Biomes");
if (BiomesTag > 0)
{
- if (m_Callback.OnBiomes((const unsigned char *)(a_NBT.GetData(BiomesTag))))
+ if (m_Callback.OnBiomes((const unsigned char *) (a_NBT.GetData(BiomesTag))))
{
return;
}
@@ -264,7 +273,7 @@ void cProcessor::cThread::ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cPa
int HeightMapTag = a_NBT.FindChildByName(LevelTag, "HeightMap");
if (HeightMapTag > 0)
{
- if (m_Callback.OnHeightMap((const int *)(a_NBT.GetData(HeightMapTag))))
+ if (m_Callback.OnHeightMap((const int *) (a_NBT.GetData(HeightMapTag))))
{
return;
}
@@ -307,12 +316,12 @@ bool cProcessor::cThread::ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cPars
memset(SectionProcessed, 0, sizeof(SectionProcessed));
for (int Tag = a_NBT.GetFirstChild(Sections); Tag > 0; Tag = a_NBT.GetNextSibling(Tag))
{
- int YTag = a_NBT.FindChildByName(Tag, "Y");
- int BlocksTag = a_NBT.FindChildByName(Tag, "Blocks");
- int AddTag = a_NBT.FindChildByName(Tag, "Add");
- int DataTag = a_NBT.FindChildByName(Tag, "Data");
+ int YTag = a_NBT.FindChildByName(Tag, "Y");
+ int BlocksTag = a_NBT.FindChildByName(Tag, "Blocks");
+ int AddTag = a_NBT.FindChildByName(Tag, "Add");
+ int DataTag = a_NBT.FindChildByName(Tag, "Data");
int BlockLightTag = a_NBT.FindChildByName(Tag, "BlockLightTag");
- int SkyLightTag = a_NBT.FindChildByName(Tag, "SkyLight");
+ int SkyLightTag = a_NBT.FindChildByName(Tag, "SkyLight");
if ((YTag < 0) || (BlocksTag < 0) || (DataTag < 0))
{
@@ -326,13 +335,13 @@ bool cProcessor::cThread::ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cPars
continue;
}
if (m_Callback.OnSection(
- SectionY,
- (const BLOCKTYPE *) (a_NBT.GetData(BlocksTag)),
- (AddTag > 0) ? (const NIBBLETYPE *)(a_NBT.GetData(AddTag)) : NULL,
- (const NIBBLETYPE *)(a_NBT.GetData(DataTag)),
- (BlockLightTag > 0) ? (const NIBBLETYPE *)(a_NBT.GetData(BlockLightTag)) : NULL,
- (BlockLightTag > 0) ? (const NIBBLETYPE *)(a_NBT.GetData(BlockLightTag)) : NULL
- ))
+ SectionY,
+ (const BLOCKTYPE *) (a_NBT.GetData(BlocksTag)),
+ (AddTag > 0) ? (const NIBBLETYPE *) (a_NBT.GetData(AddTag)) : NULL,
+ (const NIBBLETYPE *) (a_NBT.GetData(DataTag)),
+ (BlockLightTag > 0) ? (const NIBBLETYPE *) (a_NBT.GetData(BlockLightTag)) : NULL,
+ (BlockLightTag > 0) ? (const NIBBLETYPE *) (a_NBT.GetData(BlockLightTag)) : NULL
+ ))
{
return true;
}
@@ -405,16 +414,22 @@ bool cProcessor::cThread::ProcessChunkEntities(int a_ChunkX, int a_ChunkZ, cPars
}
if (m_Callback.OnEntity(
- a_NBT.GetString(a_NBT.FindChildByName(EntityTag, "id")),
- Pos[0], Pos[1], Pos[2],
- Speed[0], Speed[1], Speed[2],
- Rot[0], Rot[1],
- a_NBT.GetFloat(a_NBT.FindChildByName(EntityTag, "FallDistance")),
- a_NBT.GetShort(a_NBT.FindChildByName(EntityTag, "Fire")),
- a_NBT.GetShort(a_NBT.FindChildByName(EntityTag, "Air")),
- a_NBT.GetByte(a_NBT.FindChildByName(EntityTag, "OnGround")),
- a_NBT, EntityTag
- ))
+ a_NBT.GetString(a_NBT.FindChildByName(EntityTag, "id")),
+ Pos[0],
+ Pos[1],
+ Pos[2],
+ Speed[0],
+ Speed[1],
+ Speed[2],
+ Rot[0],
+ Rot[1],
+ a_NBT.GetFloat(a_NBT.FindChildByName(EntityTag, "FallDistance")),
+ a_NBT.GetShort(a_NBT.FindChildByName(EntityTag, "Fire")),
+ a_NBT.GetShort(a_NBT.FindChildByName(EntityTag, "Air")),
+ a_NBT.GetByte(a_NBT.FindChildByName(EntityTag, "OnGround")),
+ a_NBT,
+ EntityTag
+ ))
{
return true;
}
@@ -434,15 +449,17 @@ 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))
+ for (int TileEntityTag = a_NBT.GetFirstChild(TileEntitiesTag); TileEntityTag > 0;
+ TileEntityTag = a_NBT.GetNextSibling(TileEntityTag))
{
if (m_Callback.OnTileEntity(
- a_NBT.GetString(a_NBT.FindChildByName(TileEntityTag, "id")),
- a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "x")),
- a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "y")),
- a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "z")),
- a_NBT, TileEntityTag
- ))
+ a_NBT.GetString(a_NBT.FindChildByName(TileEntityTag, "id")),
+ a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "x")),
+ a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "y")),
+ a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "z")),
+ a_NBT,
+ TileEntityTag
+ ))
{
return true;
}
@@ -462,7 +479,8 @@ 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))
+ for (int TileTickTag = a_NBT.GetFirstChild(TileTicksTag); TileTickTag > 0;
+ TileTickTag = a_NBT.GetNextSibling(TileTickTag))
{
int iTag = a_NBT.FindChildByName(TileTicksTag, "i");
int tTag = a_NBT.FindChildByName(TileTicksTag, "t");
@@ -474,12 +492,12 @@ bool cProcessor::cThread::ProcessChunkTileTicks(int a_ChunkX, int a_ChunkZ, cPar
continue;
}
if (m_Callback.OnTileTick(
- a_NBT.GetInt(iTag),
- a_NBT.GetInt(iTag),
- a_NBT.GetInt(iTag),
- a_NBT.GetInt(iTag),
- a_NBT.GetInt(iTag)
- ))
+ a_NBT.GetInt(iTag),
+ a_NBT.GetInt(iTag),
+ a_NBT.GetInt(iTag),
+ a_NBT.GetInt(iTag),
+ a_NBT.GetInt(iTag)
+ ))
{
return true;
}
@@ -503,9 +521,7 @@ cProcessor::cProcessor(void) :
-cProcessor::~cProcessor()
-{
-}
+cProcessor::~cProcessor() {}
diff --git a/Tools/AnvilStats/Processor.h b/Tools/AnvilStats/Processor.h
index 30f160404..426e67d91 100644
--- a/Tools/AnvilStats/Processor.h
+++ b/Tools/AnvilStats/Processor.h
@@ -1,7 +1,8 @@
// Processor.h
-// Interfaces to the cProcessor class representing the overall processor engine that manages threads, calls callbacks etc.
+// Interfaces to the cProcessor class representing the overall processor engine that manages threads, calls callbacks
+// etc.
@@ -23,12 +24,11 @@ class cParsedNBT;
class cProcessor
{
- class cThread :
- public cIsThread
+ class cThread : public cIsThread
{
typedef cIsThread super;
- cCallback & m_Callback;
+ cCallback & m_Callback;
cProcessor & m_ParentProcessor;
cEvent m_HasStarted;
@@ -37,36 +37,49 @@ class cProcessor
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 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
+ // 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);
bool ProcessChunkTileEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
bool ProcessChunkTileTicks(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
- public:
+ public:
cThread(cCallback & a_Callback, cProcessor & a_ParentProcessor);
/** Waits until the thread starts processing the callback code. */
void WaitForStart(void);
- } ;
+ };
typedef std::vector<cThread *> cThreads;
-public:
+ public:
cProcessor(void);
~cProcessor();
void ProcessWorld(const AString & a_WorldFolder, cCallbackFactory & a_CallbackFactory);
-protected:
+ protected:
bool m_IsShuttingDown; // If true, the threads should stop ASAP
cCriticalSection m_CS;
- AStringList m_FileQueue;
+ AStringList m_FileQueue;
cThreads m_Threads;
@@ -76,4 +89,4 @@ protected:
/** 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 ccc0c8e45..1a3777c61 100644
--- a/Tools/AnvilStats/SpringStats.cpp
+++ b/Tools/AnvilStats/SpringStats.cpp
@@ -1,7 +1,8 @@
// SpringStats.cpp
-// Implements the cSpringStats class representing a cCallback descendant that collects statistics on lava and water springs
+// Implements the cSpringStats class representing a cCallback descendant that collects statistics on lava and water
+// springs
#include "Globals.h"
#include "SpringStats.h"
@@ -16,7 +17,7 @@
cSpringStats::cStats::cStats(void) :
m_TotalChunks(0)
{
- memset(m_LavaSprings, 0, sizeof(m_LavaSprings));
+ memset(m_LavaSprings, 0, sizeof(m_LavaSprings));
memset(m_WaterSprings, 0, sizeof(m_WaterSprings));
}
@@ -31,7 +32,7 @@ void cSpringStats::cStats::Add(const cSpringStats::cStats & a_Other)
{
for (int Height = 0; Height < 256; Height++)
{
- m_LavaSprings[Biome][Height] += a_Other.m_LavaSprings[Biome][Height];
+ m_LavaSprings[Biome][Height] += a_Other.m_LavaSprings[Biome][Height];
m_WaterSprings[Biome][Height] += a_Other.m_WaterSprings[Biome][Height];
}
}
@@ -84,8 +85,8 @@ bool cSpringStats::OnSection(
const NIBBLETYPE * a_BlockSkyLight
)
{
- memcpy(m_BlockTypes + ((int)a_Y) * 16 * 16 * 16, a_BlockTypes, 16 * 16 * 16);
- memcpy(m_BlockMetas + ((int)a_Y) * 16 * 16 * 16 / 2, a_BlockMeta, 16 * 16 * 16 / 2);
+ memcpy(m_BlockTypes + ((int) a_Y) * 16 * 16 * 16, a_BlockTypes, 16 * 16 * 16);
+ memcpy(m_BlockMetas + ((int) a_Y) * 16 * 16 * 16 / 2, a_BlockMeta, 16 * 16 * 16 / 2);
return false;
}
@@ -145,15 +146,14 @@ void cSpringStats::TestSpring(int a_RelX, int a_RelY, int a_RelZ, cSpringStats::
static const struct
{
int x, y, z;
- } Coords[] =
- {
- {-1, 0, 0},
- { 1, 0, 0},
- { 0, -1, 0},
- { 0, 1, 0},
- { 0, 0, -1},
- { 0, 0, 1},
- } ;
+ } Coords[] = {
+ {-1, 0, 0},
+ {1, 0, 0},
+ {0, -1, 0},
+ {0, 1, 0},
+ {0, 0, -1},
+ {0, 0, 1},
+ };
bool HasFluidNextToIt = false;
for (int i = 0; i < ARRAYCOUNT(Coords); i++)
{
@@ -164,7 +164,12 @@ void cSpringStats::TestSpring(int a_RelX, int a_RelY, int a_RelZ, cSpringStats::
case E_BLOCK_LAVA:
case E_BLOCK_STATIONARY_LAVA:
{
- if (cChunkDef::GetNibble(m_BlockMetas, a_RelX + Coords[i].x, a_RelY + Coords[i].y, a_RelZ + Coords[i].z) == 0)
+ if (cChunkDef::GetNibble(
+ m_BlockMetas,
+ a_RelX + Coords[i].x,
+ a_RelY + Coords[i].y,
+ a_RelZ + Coords[i].z
+ ) == 0)
{
// There is another source block next to this, so this is not a spring
return;
@@ -182,7 +187,7 @@ void cSpringStats::TestSpring(int a_RelX, int a_RelY, int a_RelZ, cSpringStats::
}
// 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;
+ a_Stats[a_RelY][((unsigned char *) m_Biomes)[a_RelX + 16 * a_RelZ]] += 1;
}
@@ -217,7 +222,7 @@ void cSpringStatsFactory::JoinResults(void)
{
for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
{
- m_CombinedStats.Add(((cSpringStats *)(*itr))->GetStats());
+ m_CombinedStats.Add(((cSpringStats *) (*itr))->GetStats());
} // for itr - m_Callbacks[]
}
diff --git a/Tools/AnvilStats/SpringStats.h b/Tools/AnvilStats/SpringStats.h
index 83651b7e6..d40259ae5 100644
--- a/Tools/AnvilStats/SpringStats.h
+++ b/Tools/AnvilStats/SpringStats.h
@@ -1,7 +1,8 @@
// SpringStats.h
-// Declares the cSpringStats class representing a cCallback descendant that collects statistics on lava and water springs
+// Declares the cSpringStats class representing a cCallback descendant that collects statistics on lava and water
+// springs
@@ -15,13 +16,12 @@
-class cSpringStats :
- public cCallback
+class cSpringStats : public cCallback
{
-public:
+ public:
class cStats
{
- public:
+ public:
/** Per-height, per-biome frequencies of springs */
typedef UInt64 SpringStats[256][256];
@@ -33,29 +33,34 @@ public:
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];
+ protected:
+ BLOCKTYPE m_BlockTypes[16 * 16 * 256];
NIBBLETYPE m_BlockMetas[16 * 16 * 256 / 2];
- char m_Biomes[16 * 16];
- bool m_AreBiomesValid;
+ 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; }
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
+ virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override
+ {
+ return false;
+ }
virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
- virtual bool OnTerrainPopulated(bool a_Populated) override { return !a_Populated; } // If not populated, we don't want it!
+ virtual bool OnTerrainPopulated(bool a_Populated) override
+ {
+ return !a_Populated;
+ } // If not populated, we don't want it!
virtual bool OnBiomes(const unsigned char * a_BiomeData) override;
virtual bool OnHeightMap(const int * a_HeightMap) override { return false; }
virtual bool OnSection(
@@ -70,22 +75,18 @@ protected:
/** 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);
-} ;
+};
-class cSpringStatsFactory :
- public cCallbackFactory
+class cSpringStatsFactory : public cCallbackFactory
{
-public:
+ public:
virtual ~cSpringStatsFactory();
- virtual cCallback * CreateNewCallback(void) override
- {
- return new cSpringStats;
- }
+ virtual cCallback * CreateNewCallback(void) override { return new cSpringStats; }
cSpringStats::cStats m_CombinedStats;
@@ -96,4 +97,4 @@ public:
/** 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 d5ad360f3..c719fbeee 100644
--- a/Tools/AnvilStats/Statistics.cpp
+++ b/Tools/AnvilStats/Statistics.cpp
@@ -26,11 +26,11 @@ cStatistics::cStats::cStats(void) :
m_MinChunkZ(0x7fffffff),
m_MaxChunkZ(0x80000000)
{
- memset(m_BiomeCounts, 0, sizeof(m_BiomeCounts));
- memset(m_BlockCounts, 0, sizeof(m_BlockCounts));
+ memset(m_BiomeCounts, 0, sizeof(m_BiomeCounts));
+ memset(m_BlockCounts, 0, sizeof(m_BlockCounts));
memset(m_PerHeightBlockCounts, 0, sizeof(m_PerHeightBlockCounts));
- memset(m_PerHeightSpawners, 0, sizeof(m_PerHeightSpawners));
- memset(m_SpawnerEntity, 0, sizeof(m_SpawnerEntity));
+ memset(m_PerHeightSpawners, 0, sizeof(m_PerHeightSpawners));
+ memset(m_SpawnerEntity, 0, sizeof(m_SpawnerEntity));
}
@@ -100,9 +100,7 @@ void cStatistics::cStats::UpdateCoordsRange(int a_ChunkX, int a_ChunkZ)
////////////////////////////////////////////////////////////////////////////////
// cStatistics:
-cStatistics::cStatistics(void)
-{
-}
+cStatistics::cStatistics(void) {}
@@ -137,9 +135,7 @@ bool cStatistics::OnBiomes(const unsigned char * a_BiomeData)
-
-bool cStatistics::OnSection
-(
+bool cStatistics::OnSection(
unsigned char a_Y,
const BLOCKTYPE * a_BlockTypes,
const NIBBLETYPE * a_BlockAdditional,
@@ -156,7 +152,7 @@ bool cStatistics::OnSection
for (int y = 0; y < 16; y++)
{
- int Height = (int)a_Y * 16 + y;
+ int Height = (int) a_Y * 16 + y;
for (int z = 0; z < 16; z++)
{
for (int x = 0; x < 16; x++)
@@ -209,9 +205,14 @@ bool cStatistics::OnEmptySection(unsigned char a_Y)
bool cStatistics::OnEntity(
const AString & a_EntityType,
- double a_PosX, double a_PosY, double a_PosZ,
- double a_SpeedX, double a_SpeedY, double a_SpeedZ,
- float a_Yaw, float a_Pitch,
+ double a_PosX,
+ double a_PosY,
+ double a_PosZ,
+ double a_SpeedX,
+ double a_SpeedY,
+ double a_SpeedZ,
+ float a_Yaw,
+ float a_Pitch,
float a_FallDistance,
short a_FireTicksLeft,
short a_AirTicks,
@@ -233,7 +234,9 @@ bool cStatistics::OnEntity(
bool cStatistics::OnTileEntity(
const AString & a_EntityType,
- int a_PosX, int a_PosY, int a_PosZ,
+ int a_PosX,
+ int a_PosY,
+ int a_PosZ,
cParsedNBT & a_NBT,
int a_NBTTag
)
@@ -252,11 +255,7 @@ bool cStatistics::OnTileEntity(
-bool cStatistics::OnTileTick(
- int a_BlockType,
- int a_TicksLeft,
- int a_PosX, int a_PosY, int a_PosZ
-)
+bool cStatistics::OnTileTick(int a_BlockType, int a_TicksLeft, int a_PosX, int a_PosY, int a_PosZ)
{
m_Stats.m_NumTileTicks += 1;
return false;
@@ -326,7 +325,11 @@ 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");
+ 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:");
@@ -354,7 +357,7 @@ void cStatisticsFactory::JoinResults(void)
{
for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
{
- m_CombinedStats.Add(((cStatistics *)(*itr))->GetStats());
+ m_CombinedStats.Add(((cStatistics *) (*itr))->GetStats());
} // for itr - m_Callbacks[]
}
@@ -370,7 +373,8 @@ void cStatisticsFactory::SaveBiomes(void)
LOG("Cannot write to file Biomes.xls. Statistics not written.");
return;
}
- double TotalColumns = (double)(m_CombinedStats.m_BiomeNumChunks) * 16 * 16 / 100; // Total number of columns processed; convert into percent
+ double TotalColumns = (double) (m_CombinedStats.m_BiomeNumChunks) * 16 * 16 /
+ 100; // Total number of columns processed; convert into percent
if (TotalColumns < 1)
{
// Avoid division by zero
@@ -379,7 +383,14 @@ void cStatisticsFactory::SaveBiomes(void)
for (int i = 0; i <= 255; i++)
{
AString Line;
- Printf(Line, "%s\t%d\t%llu\t%.05f\n", GetBiomeString(i), i, m_CombinedStats.m_BiomeCounts[i], ((double)(m_CombinedStats.m_BiomeCounts[i])) / TotalColumns);
+ Printf(
+ Line,
+ "%s\t%d\t%llu\t%.05f\n",
+ GetBiomeString(i),
+ i,
+ m_CombinedStats.m_BiomeCounts[i],
+ ((double) (m_CombinedStats.m_BiomeCounts[i])) / TotalColumns
+ );
f.Write(Line.c_str(), Line.length());
}
}
@@ -396,7 +407,8 @@ void cStatisticsFactory::SaveBlockTypes(void)
LOG("Cannot write to file Biomes.xls. Statistics not written.");
return;
}
- double TotalBlocks = ((double)(m_CombinedStats.m_BlockNumChunks)) * 16 * 16 * 256 / 100; // Total number of blocks processed; convert into percent
+ double TotalBlocks = ((double) (m_CombinedStats.m_BlockNumChunks)) * 16 * 16 * 256 /
+ 100; // Total number of blocks processed; convert into percent
if (TotalBlocks < 1)
{
// Avoid division by zero
@@ -410,7 +422,7 @@ void cStatisticsFactory::SaveBlockTypes(void)
Count += m_CombinedStats.m_BlockCounts[Biome][i];
}
AString Line;
- Printf(Line, "%s\t%d\t%llu\t%.08f\n", GetBlockTypeString(i), i, Count, ((double)Count) / TotalBlocks);
+ Printf(Line, "%s\t%d\t%llu\t%.08f\n", GetBlockTypeString(i), i, Count, ((double) Count) / TotalBlocks);
f.Write(Line.c_str(), Line.length());
}
}
@@ -548,7 +560,6 @@ void cStatisticsFactory::SaveBiomeBlockTypes(void)
-
void cStatisticsFactory::SaveStatistics(void)
{
cFile f;
@@ -559,11 +570,20 @@ void cStatisticsFactory::SaveStatistics(void)
}
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(
+ "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);
if (Elapsed > 0)
{
- f.Printf("Chunk processing speed: %.02f chunks per second\n", (double)(m_CombinedStats.m_TotalChunks) / Elapsed);
+ f.Printf(
+ "Chunk processing speed: %.02f chunks per second\n",
+ (double) (m_CombinedStats.m_TotalChunks) / Elapsed
+ );
}
f.Printf("Biomes counted for %llu chunks.\n", m_CombinedStats.m_BiomeNumChunks);
f.Printf("Blocktypes counted for %llu chunks.\n", m_CombinedStats.m_BlockNumChunks);
@@ -593,7 +613,12 @@ void cStatisticsFactory::SaveSpawners(void)
f.Printf("Entity type\tTotal count\tCount per chunk\n");
for (int i = 0; i < entMax; i++)
{
- f.Printf("%s\t%llu\t%0.4f\n", GetEntityTypeString((eEntityType)i), m_CombinedStats.m_SpawnerEntity[i], (double)(m_CombinedStats.m_SpawnerEntity[i]) / m_CombinedStats.m_BlockNumChunks);
+ f.Printf(
+ "%s\t%llu\t%0.4f\n",
+ GetEntityTypeString((eEntityType) i),
+ m_CombinedStats.m_SpawnerEntity[i],
+ (double) (m_CombinedStats.m_SpawnerEntity[i]) / m_CombinedStats.m_BlockNumChunks
+ );
}
}
@@ -614,7 +639,7 @@ void cStatisticsFactory::SavePerHeightSpawners(void)
f.Printf("Height\tTotal");
for (int i = 0; i < entMax; i++)
{
- f.Printf("\t%s", GetEntityTypeString((eEntityType)i));
+ f.Printf("\t%s", GetEntityTypeString((eEntityType) i));
}
f.Printf("\n");
diff --git a/Tools/AnvilStats/Statistics.h b/Tools/AnvilStats/Statistics.h
index 2c8c61685..2b21be562 100644
--- a/Tools/AnvilStats/Statistics.h
+++ b/Tools/AnvilStats/Statistics.h
@@ -16,13 +16,12 @@
-class cStatistics :
- public cCallback
+class cStatistics : public cCallback
{
-public:
+ public:
class cStats
{
- public:
+ public:
UInt64 m_TotalChunks; // Total number of chunks that go through this callback (OnNewChunk())
UInt64 m_BiomeCounts[256];
UInt64 m_BlockCounts[256][256]; // First dimension is the biome, second dimension is BlockType
@@ -32,7 +31,8 @@ public:
UInt64 m_NumTileEntities;
UInt64 m_NumTileTicks;
UInt64 m_PerHeightBlockCounts[256][256]; // First dimension is the height, second dimension is BlockType
- UInt64 m_PerHeightSpawners[256][entMax + 1]; // First dimension is the height, second dimension is spawned entity type
+ 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
@@ -42,27 +42,35 @@ public:
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:
+ protected:
cStats m_Stats;
- bool m_IsBiomesValid; // Set to true in OnBiomes(), reset to false in OnNewChunk(); if true, the m_BiomeData is valid for the current chunk
- unsigned char m_BiomeData[16 * 16];
- bool m_IsFirstSectionInChunk; // True if there was no section in the chunk yet. Set by OnNewChunk(), reset by OnSection()
+ bool m_IsBiomesValid; // Set to true in OnBiomes(), reset to false in OnNewChunk(); if true, the m_BiomeData is
+ // valid for the current chunk
+ unsigned char m_BiomeData[16 * 16];
+ bool m_IsFirstSectionInChunk; // True if there was no section in the chunk yet. Set by OnNewChunk(), reset by
+ // OnSection()
// 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; }
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
+ virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override
+ {
+ return false;
+ }
virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
- virtual bool OnTerrainPopulated(bool a_Populated) override { return !a_Populated; } // If not populated, we don't want it!
+ virtual bool OnTerrainPopulated(bool a_Populated) override
+ {
+ return !a_Populated;
+ } // If not populated, we don't want it!
virtual bool OnBiomes(const unsigned char * a_BiomeData) override;
virtual bool OnHeightMap(const int * a_HeightMap) override { return false; }
virtual bool OnSection(
@@ -80,9 +88,14 @@ protected:
virtual bool OnEntity(
const AString & a_EntityType,
- double a_PosX, double a_PosY, double a_PosZ,
- double a_SpeedX, double a_SpeedY, double a_SpeedZ,
- float a_Yaw, float a_Pitch,
+ double a_PosX,
+ double a_PosY,
+ double a_PosZ,
+ double a_SpeedX,
+ double a_SpeedY,
+ double a_SpeedZ,
+ float a_Yaw,
+ float a_Pitch,
float a_FallDistance,
short a_FireTicksLeft,
short a_AirTicks,
@@ -93,37 +106,31 @@ protected:
virtual bool OnTileEntity(
const AString & a_EntityType,
- int a_PosX, int a_PosY, int a_PosZ,
+ 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;
+ 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);
-} ;
+};
-class cStatisticsFactory :
- public cCallbackFactory
+class cStatisticsFactory : public cCallbackFactory
{
-public:
+ public:
cStatisticsFactory(void);
virtual ~cStatisticsFactory();
- virtual cCallback * CreateNewCallback(void)
- {
- return new cStatistics;
- }
+ virtual cCallback * CreateNewCallback(void) { return new cStatistics; }
-protected:
+ protected:
// The results, combined, are stored here:
cStatistics::cStats m_CombinedStats;
@@ -137,4 +144,4 @@ protected:
void SaveStatistics(void);
void SaveSpawners(void);
void SavePerHeightSpawners(void);
-} ;
+};
diff --git a/Tools/AnvilStats/Utils.cpp b/Tools/AnvilStats/Utils.cpp
index a3fbedf28..6ac88f12e 100644
--- a/Tools/AnvilStats/Utils.cpp
+++ b/Tools/AnvilStats/Utils.cpp
@@ -12,43 +12,42 @@
struct
{
- eEntityType Type;
+ eEntityType Type;
const char * String;
-} g_EntityTypes[] =
-{
- {entBat, "Bat"},
- {entBlaze, "Blaze"},
- {entCaveSpider, "CaveSpider"},
- {entChicken, "Chicken"},
- {entCow, "Cow"},
- {entCreeper, "Creeper"},
- {entEnderDragon, "EnderDragon"},
- {entEnderman, "Enderman"},
- {entGhast, "Ghast"},
- {entGiant, "Giant"},
- {entGuardian, "Guardian"},
- {entLavaSlime, "LavaSlime"},
- {entMushroomCow, "MushroomCow"},
- {entOzelot, "Ozelot"},
- {entPig, "Pig"},
- {entPigZombie, "PigZombie"},
- {entRabbit, "Rabbit"},
- {entSheep, "Sheep"},
- {entSilverfish, "Slverfish"},
- {entSkeleton, "Skeleton"},
- {entSlime, "Slime"},
- {entSnowMan, "SnowMan"},
- {entSpider, "Spider"},
- {entSquid, "Squid"},
- {entVillager, "Villager"},
- {entVillagerGolem, "VillagerGolem"},
- {entWitch, "Witch"},
- {entWitherBoss, "WitherBoss"},
- {entWolf, "Wolf"},
- {entZombie, "Zombie"},
+} g_EntityTypes[] = {
+ {entBat, "Bat"},
+ {entBlaze, "Blaze"},
+ {entCaveSpider, "CaveSpider"},
+ {entChicken, "Chicken"},
+ {entCow, "Cow"},
+ {entCreeper, "Creeper"},
+ {entEnderDragon, "EnderDragon"},
+ {entEnderman, "Enderman"},
+ {entGhast, "Ghast"},
+ {entGiant, "Giant"},
+ {entGuardian, "Guardian"},
+ {entLavaSlime, "LavaSlime"},
+ {entMushroomCow, "MushroomCow"},
+ {entOzelot, "Ozelot"},
+ {entPig, "Pig"},
+ {entPigZombie, "PigZombie"},
+ {entRabbit, "Rabbit"},
+ {entSheep, "Sheep"},
+ {entSilverfish, "Slverfish"},
+ {entSkeleton, "Skeleton"},
+ {entSlime, "Slime"},
+ {entSnowMan, "SnowMan"},
+ {entSpider, "Spider"},
+ {entSquid, "Squid"},
+ {entVillager, "Villager"},
+ {entVillagerGolem, "VillagerGolem"},
+ {entWitch, "Witch"},
+ {entWitherBoss, "WitherBoss"},
+ {entWolf, "Wolf"},
+ {entZombie, "Zombie"},
{entZombieVillager, "ZombieVillager"},
- {entUnknown, "Unknown"},
-} ;
+ {entUnknown, "Unknown"},
+};
@@ -57,31 +56,31 @@ struct
const char * GetBiomeString(unsigned char a_Biome)
{
static const char * BiomeNames[] = // Biome names, as equivalent to their index
- {
- "Ocean",
- "Plains",
- "Desert",
- "Extreme Hills",
- "Forest",
- "Taiga",
- "Swampland",
- "River",
- "Hell",
- "Sky",
- "Frozen Ocean",
- "Frozen River",
- "Ice Plains",
- "Ice Mountains",
- "Mushroom Island",
- "Mushroom Island Shore",
- "Beach",
- "Desert Hills",
- "Forest Hills",
- "Taiga Hills",
- "Extreme Hills Edge",
- "Jungle",
- "Jungle Hills",
- } ;
+ {
+ "Ocean",
+ "Plains",
+ "Desert",
+ "Extreme Hills",
+ "Forest",
+ "Taiga",
+ "Swampland",
+ "River",
+ "Hell",
+ "Sky",
+ "Frozen Ocean",
+ "Frozen River",
+ "Ice Plains",
+ "Ice Mountains",
+ "Mushroom Island",
+ "Mushroom Island Shore",
+ "Beach",
+ "Desert Hills",
+ "Forest Hills",
+ "Taiga Hills",
+ "Extreme Hills Edge",
+ "Jungle",
+ "Jungle Hills",
+ };
return (a_Biome < ARRAYCOUNT(BiomeNames)) ? BiomeNames[a_Biome] : "";
}
@@ -92,153 +91,153 @@ const char * GetBiomeString(unsigned char a_Biome)
const char * GetBlockTypeString(unsigned char a_BlockType)
{
static const char * BlockTypeNames[] = // Block type names, as equivalent to their index
- {
- "air",
- "stone",
- "grass",
- "dirt",
- "cobblestone",
- "planks",
- "sapling",
- "bedrock",
- "water",
- "stillwater",
- "lava",
- "stilllava",
- "sand",
- "gravel",
- "goldore",
- "ironore",
- "coalore",
- "log",
- "leaves",
- "sponge",
- "glass",
- "lapisore",
- "lapisblock",
- "dispenser",
- "sandstone",
- "noteblock",
- "bedblock",
- "poweredrail",
- "detectorrail",
- "stickypiston",
- "cobweb",
- "tallgrass",
- "deadbush",
- "piston",
- "pistonhead",
- "wool",
- "pistonmovedblock",
- "flower",
- "rose",
- "brownmushroom",
- "redmushroom",
- "goldblock",
- "ironblock",
- "doubleslab",
- "slab",
- "brickblock",
- "tnt",
- "bookcase",
- "mossycobblestone",
- "obsidian",
- "torch",
- "fire",
- "mobspawner",
- "woodstairs",
- "chest",
- "redstonedust",
- "diamondore",
- "diamondblock",
- "workbench",
- "crops",
- "soil",
- "furnace",
- "litfurnace",
- "signblock",
- "wooddoorblock",
- "ladder",
- "tracks",
- "cobblestonestairs",
- "wallsign",
- "lever",
- "stoneplate",
- "irondoorblock",
- "woodplate",
- "redstoneore",
- "redstoneorealt",
- "redstonetorchoff",
- "redstonetorchon",
- "button",
- "snow",
- "ice",
- "snowblock",
- "cactus",
- "clayblock",
- "reedblock",
- "jukebox",
- "fence",
- "pumpkin",
- "netherrack",
- "soulsand",
- "glowstone",
- "portal",
- "jack-o-lantern",
- "cakeblock",
- "repeateroff",
- "repeateron",
- "lockedchest",
- "trapdoor",
- "silverfishblock",
- "stonebricks",
- "hugebrownmushroom",
- "hugeredmushroom",
- "ironbars",
- "glasspane",
- "melon",
- "pumpkinstem",
- "melonstem",
- "vines",
- "fencegate",
- "brickstairs",
- "stonebrickstairs",
- "mycelium",
- "lilypad",
- "netherbrick",
- "netherbrickfence",
- "netherbrickstairs",
- "netherwartblock",
- "enchantmenttable",
- "brewingstandblock",
- "cauldronblock",
- "endportal",
- "endportalframe",
- "endstone",
- "dragonegg",
- "redstonelampoff",
- "redstonelampon",
- "woodendoubleslab",
- "woodenslab",
- "cocoapod",
- "sandstonestairs", /* 128 */
- "Emerald Ore",
- "Ender Chest",
- "Tripwire Hook",
- "Tripwire",
- "Block of Emerald",
- "Spruce Wood Stairs",
- "Birch Wood Stairs",
- "Jungle Wood Stairs",
- "Command Block",
- "Beacon",
- "Cobblestone Wall",
- "Flower Pot",
- "Carrots",
- "Potatoes",
- "Wooden Button",
- "Head",
- } ;
+ {
+ "air",
+ "stone",
+ "grass",
+ "dirt",
+ "cobblestone",
+ "planks",
+ "sapling",
+ "bedrock",
+ "water",
+ "stillwater",
+ "lava",
+ "stilllava",
+ "sand",
+ "gravel",
+ "goldore",
+ "ironore",
+ "coalore",
+ "log",
+ "leaves",
+ "sponge",
+ "glass",
+ "lapisore",
+ "lapisblock",
+ "dispenser",
+ "sandstone",
+ "noteblock",
+ "bedblock",
+ "poweredrail",
+ "detectorrail",
+ "stickypiston",
+ "cobweb",
+ "tallgrass",
+ "deadbush",
+ "piston",
+ "pistonhead",
+ "wool",
+ "pistonmovedblock",
+ "flower",
+ "rose",
+ "brownmushroom",
+ "redmushroom",
+ "goldblock",
+ "ironblock",
+ "doubleslab",
+ "slab",
+ "brickblock",
+ "tnt",
+ "bookcase",
+ "mossycobblestone",
+ "obsidian",
+ "torch",
+ "fire",
+ "mobspawner",
+ "woodstairs",
+ "chest",
+ "redstonedust",
+ "diamondore",
+ "diamondblock",
+ "workbench",
+ "crops",
+ "soil",
+ "furnace",
+ "litfurnace",
+ "signblock",
+ "wooddoorblock",
+ "ladder",
+ "tracks",
+ "cobblestonestairs",
+ "wallsign",
+ "lever",
+ "stoneplate",
+ "irondoorblock",
+ "woodplate",
+ "redstoneore",
+ "redstoneorealt",
+ "redstonetorchoff",
+ "redstonetorchon",
+ "button",
+ "snow",
+ "ice",
+ "snowblock",
+ "cactus",
+ "clayblock",
+ "reedblock",
+ "jukebox",
+ "fence",
+ "pumpkin",
+ "netherrack",
+ "soulsand",
+ "glowstone",
+ "portal",
+ "jack-o-lantern",
+ "cakeblock",
+ "repeateroff",
+ "repeateron",
+ "lockedchest",
+ "trapdoor",
+ "silverfishblock",
+ "stonebricks",
+ "hugebrownmushroom",
+ "hugeredmushroom",
+ "ironbars",
+ "glasspane",
+ "melon",
+ "pumpkinstem",
+ "melonstem",
+ "vines",
+ "fencegate",
+ "brickstairs",
+ "stonebrickstairs",
+ "mycelium",
+ "lilypad",
+ "netherbrick",
+ "netherbrickfence",
+ "netherbrickstairs",
+ "netherwartblock",
+ "enchantmenttable",
+ "brewingstandblock",
+ "cauldronblock",
+ "endportal",
+ "endportalframe",
+ "endstone",
+ "dragonegg",
+ "redstonelampoff",
+ "redstonelampon",
+ "woodendoubleslab",
+ "woodenslab",
+ "cocoapod",
+ "sandstonestairs", /* 128 */
+ "Emerald Ore",
+ "Ender Chest",
+ "Tripwire Hook",
+ "Tripwire",
+ "Block of Emerald",
+ "Spruce Wood Stairs",
+ "Birch Wood Stairs",
+ "Jungle Wood Stairs",
+ "Command Block",
+ "Beacon",
+ "Cobblestone Wall",
+ "Flower Pot",
+ "Carrots",
+ "Potatoes",
+ "Wooden Button",
+ "Head",
+ };
return (a_BlockType < ARRAYCOUNT(BlockTypeNames)) ? BlockTypeNames[a_BlockType] : "";
}
diff --git a/Tools/AnvilStats/Utils.h b/Tools/AnvilStats/Utils.h
index f2d23f287..51f67ede2 100644
--- a/Tools/AnvilStats/Utils.h
+++ b/Tools/AnvilStats/Utils.h
@@ -48,7 +48,7 @@ enum eEntityType
entZombieVillager,
entUnknown,
entMax = entUnknown,
-} ;
+};
@@ -59,6 +59,3 @@ extern const char * GetBlockTypeString(unsigned char a_BlockType);
extern eEntityType GetEntityType(const AString & a_EntityTypeString);
extern const char * GetEntityTypeString(eEntityType a_EntityType);
extern int GetNumCores(void);
-
-
-