Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpTerritoryManager.cpp
Show First 20 Lines • Show All 575 Lines • ▼ Show 20 Lines | std::vector<STerritoryBoundary> CCmpTerritoryManager::ComputeBoundaries() | ||||
CalculateTerritories(); | CalculateTerritories(); | ||||
ENSURE(m_Territories); | ENSURE(m_Territories); | ||||
return CTerritoryBoundaryCalculator::ComputeBoundaries(m_Territories); | return CTerritoryBoundaryCalculator::ComputeBoundaries(m_Territories); | ||||
} | } | ||||
u8 CCmpTerritoryManager::GetTerritoryPercentage(player_id_t player) | u8 CCmpTerritoryManager::GetTerritoryPercentage(player_id_t player) | ||||
{ | { | ||||
if (player <= 0 || (size_t)player > m_TerritoryCellCounts.size()) | if (player <= 0 || (size_t)player >= m_TerritoryCellCounts.size()) | ||||
Silier: we probably should check against number of players in game and if it is not out of scope then… | |||||
StanUnsubmitted Not Done Inline ActionsThere is a flag for whether the territories are dirty. Maybe we should use that? Stan: There is a flag for whether the territories are dirty. Maybe we should use that? | |||||
SilierAuthorUnsubmitted Done Inline Actionswell actually no, CalculateTerritories has early return if m_Territories exists, so it recomputes only if really needed. Silier: well actually no, CalculateTerritories has early return if m_Territories exists, so it… | |||||
return 0; | return 0; | ||||
CalculateTerritories(); | CalculateTerritories(); | ||||
// We just recalculated territories for all players | |||||
// so check player is still there | |||||
if ((size_t)player >= m_TerritoryCellCounts.size()) | |||||
StanUnsubmitted Not Done Inline Actionsstatic_cast Stan: static_cast | |||||
return 0; | |||||
if (m_TerritoryTotalPassableCellCount == 0) | if (m_TerritoryTotalPassableCellCount == 0) | ||||
Not Done Inline Actions// Territories may have been recalculated, check whether player is still there. ? Stan: // Territories may have been recalculated, check whether player is still there. ? | |||||
return 0; | return 0; | ||||
u8 percentage = (m_TerritoryCellCounts[player] * 100) / m_TerritoryTotalPassableCellCount; | u8 percentage = (m_TerritoryCellCounts[player] * 100) / m_TerritoryTotalPassableCellCount; | ||||
ENSURE(percentage <= 100); | ENSURE(percentage <= 100); | ||||
return percentage; | return percentage; | ||||
} | } | ||||
void CCmpTerritoryManager::UpdateBoundaryLines() | void CCmpTerritoryManager::UpdateBoundaryLines() | ||||
▲ Show 20 Lines • Show All 258 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
we probably should check against number of players in game and if it is not out of scope then let to recompute territories