1
0
forked from mirrors/0ad

Compute the actual percentage of map explored by the team in the summary screen.

Fixes #2587.

This was SVN commit r16071.
This commit is contained in:
Itms
2014-12-26 19:13:40 +00:00
parent dbb4b2c920
commit 2ef3c0c42e
8 changed files with 82 additions and 9 deletions
@@ -2048,6 +2048,32 @@ public:
{
return m_ExploredVertices.at((u8)player) * 100 / m_TotalInworldVertices;
}
virtual u8 GetUnionPercentMapExplored(std::vector<player_id_t> players)
{
u32 exploredVertices = 0;
std::vector<player_id_t>::iterator playerIt;
for (i32 j = 0; j < m_TerrainVerticesPerSide; j++)
{
for (i32 i = 0; i < m_TerrainVerticesPerSide; i++)
{
if (LosIsOffWorld(i, j))
continue;
for (playerIt = players.begin(); playerIt != players.end(); ++playerIt)
{
if (m_LosState[j*m_TerrainVerticesPerSide + i] & (LOS_EXPLORED << (2*((*playerIt)-1))))
{
exploredVertices += 1;
break;
}
}
}
}
return exploredVertices * 100 / m_TotalInworldVertices;
}
};
REGISTER_COMPONENT_TYPE(RangeManager)
@@ -56,4 +56,5 @@ DEFINE_INTERFACE_METHOD_1("SetLosCircular", void, ICmpRangeManager, SetLosCircul
DEFINE_INTERFACE_METHOD_0("GetLosCircular", bool, ICmpRangeManager, GetLosCircular)
DEFINE_INTERFACE_METHOD_2("SetSharedLos", void, ICmpRangeManager, SetSharedLos, player_id_t, std::vector<player_id_t>)
DEFINE_INTERFACE_METHOD_1("GetPercentMapExplored", u8, ICmpRangeManager, GetPercentMapExplored, player_id_t)
DEFINE_INTERFACE_METHOD_1("GetUnionPercentMapExplored", u8, ICmpRangeManager, GetUnionPercentMapExplored, std::vector<player_id_t>)
END_INTERFACE_WRAPPER(RangeManager)
@@ -380,6 +380,12 @@ public:
*/
virtual u8 GetPercentMapExplored(player_id_t player) = 0;
/**
* Get percent map explored statistics for specified set of players.
* Note: this function computes statistics from scratch and should not be called too often.
*/
virtual u8 GetUnionPercentMapExplored(std::vector<player_id_t> players) = 0;
/**
* Perform some internal consistency checks for testing/debugging.