summaryrefslogtreecommitdiffstats
path: root/AnvilStats/Statistics.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-27 22:02:25 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-27 22:02:25 +0200
commit6ccc4e36743485c50c58ec0f43d08181ba20958a (patch)
tree09de7f83dda7b2d856de21caaf2b25e73a15f45e /AnvilStats/Statistics.h
parentMade Anvil the default storage schema (diff)
downloadcuberite-6ccc4e36743485c50c58ec0f43d08181ba20958a.tar
cuberite-6ccc4e36743485c50c58ec0f43d08181ba20958a.tar.gz
cuberite-6ccc4e36743485c50c58ec0f43d08181ba20958a.tar.bz2
cuberite-6ccc4e36743485c50c58ec0f43d08181ba20958a.tar.lz
cuberite-6ccc4e36743485c50c58ec0f43d08181ba20958a.tar.xz
cuberite-6ccc4e36743485c50c58ec0f43d08181ba20958a.tar.zst
cuberite-6ccc4e36743485c50c58ec0f43d08181ba20958a.zip
Diffstat (limited to 'AnvilStats/Statistics.h')
-rw-r--r--AnvilStats/Statistics.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/AnvilStats/Statistics.h b/AnvilStats/Statistics.h
new file mode 100644
index 000000000..980241ae6
--- /dev/null
+++ b/AnvilStats/Statistics.h
@@ -0,0 +1,88 @@
+
+// Statistics.h
+
+// Interfaces to the cStatistics class representing a statistics-collecting callback
+
+
+
+
+
+#pragma once
+
+#include "Callback.h"
+
+
+
+
+
+class cStatistics :
+ public cCallback
+{
+ friend class cStatisticsFactory;
+
+public:
+ cStatistics(void);
+
+protected:
+ int m_TotalChunks; // Total number of chunks that go through this callback (OnNewChunk())
+ int m_BiomeCounts[256];
+ int m_BlockCounts[256][256]; // First dimension is the biome, second dimension is BlockType
+ int m_BiomeNumChunks; // Num chunks that have been processed for biome stats
+ int m_BlockNumChunks; // Num chunks that have been processed for block 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()
+
+ // 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 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 OnBiomes(const unsigned char * a_BiomeData) override;
+ virtual bool OnHeightMap(const int * a_HeightMap) override { return false; }
+ virtual bool OnSection(
+ unsigned char a_Y,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockAdditional,
+ const NIBBLETYPE * a_BlockMeta,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_BlockSkyLight
+ ) override;
+} ;
+
+
+
+
+
+class cStatisticsFactory :
+ public cCallbackFactory
+{
+public:
+ virtual ~cStatisticsFactory();
+
+ virtual cCallback * CreateNewCallback(void)
+ {
+ return new cStatistics;
+ }
+
+protected:
+ // The results, combined, are stored here:
+ int m_TotalChunks;
+ int m_BiomeCounts[256];
+ int m_BlockCounts[256][256]; // First dimension is the biome, second dimension is BlockType
+ int m_BiomeNumChunks; // Num chunks that have been processed for biome stats
+ int m_BlockNumChunks; // Num chunks that have been processed for block stats
+
+ void JoinResults(void);
+ void SaveBiomes(void);
+ void SaveBlockTypes(void);
+ void SaveBiomeBlockTypes(void);
+
+} ;
+
+
+
+