2012-09-27 16:02:25 -04:00
|
|
|
|
|
|
|
// Statistics.h
|
|
|
|
|
|
|
|
// Interfaces to the cStatistics class representing a statistics-collecting callback
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Callback.h"
|
2012-09-29 09:33:45 -04:00
|
|
|
#include "Utils.h"
|
2012-09-27 16:02:25 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cStatistics :
|
|
|
|
public cCallback
|
|
|
|
{
|
|
|
|
public:
|
2012-09-29 09:33:45 -04:00
|
|
|
class cStats
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
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
|
|
|
|
int m_NumEntities;
|
|
|
|
int m_NumTileEntities;
|
|
|
|
int m_NumTileTicks;
|
|
|
|
|
|
|
|
int m_SpawnerEntity[entMax + 1];
|
|
|
|
|
|
|
|
cStats(void);
|
|
|
|
void Add(const cStats & a_Stats);
|
|
|
|
} ;
|
|
|
|
|
2012-09-27 16:02:25 -04:00
|
|
|
cStatistics(void);
|
|
|
|
|
2012-09-29 09:33:45 -04:00
|
|
|
const cStats & GetStats(void) const { return m_Stats; }
|
|
|
|
|
2012-09-27 16:02:25 -04:00
|
|
|
protected:
|
2012-09-29 09:33:45 -04:00
|
|
|
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()
|
2012-09-27 16:02:25 -04:00
|
|
|
|
|
|
|
// 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;
|
2012-09-29 09:33:45 -04:00
|
|
|
|
2012-09-28 16:17:29 -04:00
|
|
|
virtual bool OnEmptySection(unsigned char a_Y) override;
|
2012-09-29 09:33:45 -04:00
|
|
|
|
|
|
|
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,
|
|
|
|
float a_FallDistance,
|
|
|
|
short a_FireTicksLeft,
|
|
|
|
short a_AirTicks,
|
|
|
|
char a_IsOnGround,
|
|
|
|
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);
|
2012-09-27 16:02:25 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cStatisticsFactory :
|
|
|
|
public cCallbackFactory
|
|
|
|
{
|
|
|
|
public:
|
2012-09-29 09:33:45 -04:00
|
|
|
cStatisticsFactory(void);
|
2012-09-27 16:02:25 -04:00
|
|
|
virtual ~cStatisticsFactory();
|
|
|
|
|
|
|
|
virtual cCallback * CreateNewCallback(void)
|
|
|
|
{
|
|
|
|
return new cStatistics;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// The results, combined, are stored here:
|
2012-09-29 09:33:45 -04:00
|
|
|
cStatistics::cStats m_CombinedStats;
|
|
|
|
|
|
|
|
clock_t m_BeginTick;
|
2012-09-27 16:02:25 -04:00
|
|
|
|
|
|
|
void JoinResults(void);
|
|
|
|
void SaveBiomes(void);
|
|
|
|
void SaveBlockTypes(void);
|
|
|
|
void SaveBiomeBlockTypes(void);
|
2012-09-29 09:33:45 -04:00
|
|
|
void SaveStatistics(void);
|
|
|
|
void SaveSpawners(void);
|
2012-09-27 16:02:25 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|