1
0

AnvilStats: Added per-height spawner stats.

This commit is contained in:
Mattes D 2014-08-27 12:24:56 +03:00
parent 751d345c59
commit af47b5ece2
2 changed files with 47 additions and 4 deletions

View File

@ -342,6 +342,8 @@ cStatisticsFactory::~cStatisticsFactory()
SaveBiomeBlockTypes();
LOG(" Spawners.xls");
SaveSpawners();
LOG(" PerHeightSpawners.xls");
SavePerHeightSpawners();
}
@ -429,7 +431,7 @@ void cStatisticsFactory::SavePerHeightBlockTypes(void)
}
// Write header:
f.Printf("Blocks 0 - 127:\nHeight\t");
f.Printf("Blocks 0 - 127:\nHeight");
for (int i = 0; i < 128; i++)
{
f.Printf("\t%s(%d)", GetBlockTypeString(i), i);
@ -442,14 +444,14 @@ void cStatisticsFactory::SavePerHeightBlockTypes(void)
f.Printf("%d", y);
for (int BlockType = 0; BlockType < 128; BlockType++)
{
f.Printf("\t%d", m_CombinedStats.m_PerHeightBlockCounts[y][BlockType]);
f.Printf("\t%llu", m_CombinedStats.m_PerHeightBlockCounts[y][BlockType]);
} // for BlockType
f.Printf("\n");
} // for y - height (0 - 127)
f.Printf("\n");
// Write second header:
f.Printf("Blocks 128 - 255:\nHeight\t");
f.Printf("Blocks 128 - 255:\nHeight");
for (int i = 128; i < 256; i++)
{
f.Printf("\t%s(%d)", GetBlockTypeString(i), i);
@ -462,7 +464,7 @@ void cStatisticsFactory::SavePerHeightBlockTypes(void)
f.Printf("%d", y);
for (int BlockType = 128; BlockType < 256; BlockType++)
{
f.Printf("\t%d", m_CombinedStats.m_PerHeightBlockCounts[y][BlockType]);
f.Printf("\t%llu", m_CombinedStats.m_PerHeightBlockCounts[y][BlockType]);
} // for BlockType
f.Printf("\n");
} // for y - height (0 - 127)
@ -598,3 +600,41 @@ void cStatisticsFactory::SaveSpawners(void)
void cStatisticsFactory::SavePerHeightSpawners(void)
{
cFile f;
if (!f.Open("PerHeightSpawners.xls", cFile::fmWrite))
{
LOG("Cannot write to file PerHeightSpawners.xls. Statistics not written.");
return;
}
// Write header:
f.Printf("Height\tTotal");
for (int i = 0; i < entMax; i++)
{
f.Printf("\t%s", GetEntityTypeString((eEntityType)i));
}
f.Printf("\n");
// Write individual lines:
for (int y = 0; y < 256; y++)
{
UInt64 Total = 0;
for (int i = 0; i < entMax; i++)
{
Total += m_CombinedStats.m_PerHeightSpawners[y][i];
}
f.Printf("%d\t%llu", y, Total);
for (int i = 0; i < entMax; i++)
{
f.Printf("\t%llu", m_CombinedStats.m_PerHeightSpawners[y][i]);
}
f.Printf("\n");
}
}

View File

@ -76,6 +76,8 @@ protected:
virtual bool OnEmptySection(unsigned char a_Y) override;
virtual bool OnSectionsFinished(void) override { return false; } // continue processing
virtual bool OnEntity(
const AString & a_EntityType,
double a_PosX, double a_PosY, double a_PosZ,
@ -134,6 +136,7 @@ protected:
void SaveBiomeBlockTypes(void);
void SaveStatistics(void);
void SaveSpawners(void);
void SavePerHeightSpawners(void);
} ;