From cb7ce32f237b57d15988c8ee6f59a9961cd38057 Mon Sep 17 00:00:00 2001 From: ExMix Date: Mon, 18 Mar 2013 18:35:43 +0300 Subject: [PATCH] in draw tile now we try to find tile in tile set and update it's sequenceID, and not redraw this tile --- map/tile_renderer.cpp | 15 +++++++++++---- map/tile_set.cpp | 6 ++++++ map/tile_set.hpp | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/map/tile_renderer.cpp b/map/tile_renderer.cpp index 6ee3bac6af..1204097b30 100644 --- a/map/tile_renderer.cpp +++ b/map/tile_renderer.cpp @@ -374,11 +374,18 @@ void TileRenderer::WaitForEmptyAndFinished() bool TileRenderer::HasTile(Tiler::RectInfo const & rectInfo) { + TileStructuresLockGuard guard(m_tileCache, m_tileSet); + + if (m_tileSet.HasTile(rectInfo)) + { + m_tileSet.SetTileSequenceID(rectInfo, m_sequenceID); + return true; + } TileCache & tileCache = GetTileCache(); - tileCache.Lock(); - bool res = tileCache.HasTile(rectInfo); - tileCache.Unlock(); - return res; + if (tileCache.HasTile(rectInfo)) + return true; + + return false; } void TileRenderer::SetIsPaused(bool flag) diff --git a/map/tile_set.cpp b/map/tile_set.cpp index 361b9e7162..af50b56482 100644 --- a/map/tile_set.cpp +++ b/map/tile_set.cpp @@ -26,6 +26,12 @@ int TileSet::GetTileSequenceID(Tiler::RectInfo const & rectInfo) return m_tiles[rectInfo].m_sequenceID; } +void TileSet::SetTileSequenceID(Tiler::RectInfo const & rectInfo, int sequenceID) +{ + ASSERT(HasTile(rectInfo), ()); + m_tiles[rectInfo].m_sequenceID = sequenceID; +} + void TileSet::RemoveTile(const Tiler::RectInfo &rectInfo) { m_tiles.erase(rectInfo); diff --git a/map/tile_set.hpp b/map/tile_set.hpp index 945fd67924..16bd58d143 100644 --- a/map/tile_set.hpp +++ b/map/tile_set.hpp @@ -26,6 +26,7 @@ public: void AddTile(Tile const & tile); /// get sequenceID in witch tile was rendered int GetTileSequenceID(Tiler::RectInfo const & rectInfo); + void SetTileSequenceID(Tiler::RectInfo const & rectInfo, int sequenceID); /// get tile from the set Tile const & GetTile(Tiler::RectInfo const & rectInfo); /// remove tile from the set