From e1d4c10f13a372fb91a63e17fc225dc0224d8fca Mon Sep 17 00:00:00 2001 From: Itms Date: Thu, 17 Jul 2014 19:08:06 +0000 Subject: [PATCH] Recompute the number of LoS tiles whenever these tiles are reset (especially when loading serialized data). Also add a verification about LoS tiles in the tests. Fixes #2678 Refs #599 This was SVN commit r15538. --- source/simulation2/components/CCmpRangeManager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/simulation2/components/CCmpRangeManager.cpp b/source/simulation2/components/CCmpRangeManager.cpp index a9c9e6e476..2c5ec4c194 100644 --- a/source/simulation2/components/CCmpRangeManager.cpp +++ b/source/simulation2/components/CCmpRangeManager.cpp @@ -588,8 +588,6 @@ public: m_WorldX1 = x1; m_WorldZ1 = z1; m_TerrainVerticesPerSide = (i32)vertices; - - m_LosTilesPerSide = (m_TerrainVerticesPerSide - 1)/LOS_TILES_RATIO; ResetDerivedData(false); } @@ -606,6 +604,7 @@ public: std::vector > oldPlayerCounts = m_LosPlayerCounts; std::vector oldStateRevealed = m_LosStateRevealed; SpatialSubdivision oldSubdivision = m_Subdivision; + std::vector > oldLosTiles = m_LosTiles; ResetDerivedData(true); @@ -631,6 +630,8 @@ public: debug_warn(L"inconsistent revealed"); if (oldSubdivision != m_Subdivision) debug_warn(L"inconsistent subdivs"); + if (oldLosTiles != m_LosTiles) + debug_warn(L"inconsistent los tiles"); } SpatialSubdivision* GetSubdivision() @@ -644,6 +645,8 @@ public: ENSURE(m_WorldX0.IsZero() && m_WorldZ0.IsZero()); // don't bother implementing non-zero offsets yet ResetSubdivisions(m_WorldX1, m_WorldZ1); + m_LosTilesPerSide = (m_TerrainVerticesPerSide - 1)/LOS_TILES_RATIO; + m_LosPlayerCounts.clear(); m_LosPlayerCounts.resize(MAX_LOS_PLAYER_ID+1); m_ExploredVertices.clear();