From fbee8b6c35e3bf55ad02c30f354bd42b2c245a1b Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 15 Mar 2022 12:13:45 -0400 Subject: lit tiles in unloaded chunk should count toward total lit tiles for zooming --- src/map.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/map.h') diff --git a/src/map.h b/src/map.h index 13b2b32..2faac85 100644 --- a/src/map.h +++ b/src/map.h @@ -120,6 +120,8 @@ public: return loaded_; } + inline int getUnloadedLitTiles() const { return unloadedLitTiles_; } + void load(int newLeftChunk, int newTopChunk, int newWidthChunks, int newHeightChunks, std::mt19937& rng) { // Flush the currently loaded data as long as there is any (this isn't the first load). if (!loaded_.empty()) { @@ -143,6 +145,8 @@ public: } } } + + unloadedLitTiles_ += chunk.litTiles; } } @@ -183,6 +187,7 @@ public: Chunk& chunk = chunks_[chunkIndex]; chunk.x = leftmostChunk_ + chunkX; chunk.y = topmostChunk_ + chunkY; + chunk.litTiles = 0; for (MapData& md : chunk.data) { @@ -205,6 +210,8 @@ public: std::next(std::begin(chunk.data), (y+1)*CHUNK_WIDTH), std::next(std::begin(loaded_), (chunkY*CHUNK_HEIGHT + y)*width_ + chunkX*CHUNK_WIDTH)); } + + unloadedLitTiles_ -= chunk.litTiles; } } @@ -225,6 +232,8 @@ private: std::vector chunks_; std::list freeList_; std::map> chunkByPos_; // chunkByPos_[X][Y] + + int unloadedLitTiles_ = 0; }; #endif /* end of include guard: MAP_H_3AB00D12 */ -- cgit 1.4.1