summary refs log tree commit diff stats
path: root/src/map.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.h')
-rw-r--r--src/map.h9
1 files changed, 9 insertions, 0 deletions
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:
120 return loaded_; 120 return loaded_;
121 } 121 }
122 122
123 inline int getUnloadedLitTiles() const { return unloadedLitTiles_; }
124
123 void load(int newLeftChunk, int newTopChunk, int newWidthChunks, int newHeightChunks, std::mt19937& rng) { 125 void load(int newLeftChunk, int newTopChunk, int newWidthChunks, int newHeightChunks, std::mt19937& rng) {
124 // Flush the currently loaded data as long as there is any (this isn't the first load). 126 // Flush the currently loaded data as long as there is any (this isn't the first load).
125 if (!loaded_.empty()) { 127 if (!loaded_.empty()) {
@@ -143,6 +145,8 @@ public:
143 } 145 }
144 } 146 }
145 } 147 }
148
149 unloadedLitTiles_ += chunk.litTiles;
146 } 150 }
147 } 151 }
148 152
@@ -183,6 +187,7 @@ public:
183 Chunk& chunk = chunks_[chunkIndex]; 187 Chunk& chunk = chunks_[chunkIndex];
184 chunk.x = leftmostChunk_ + chunkX; 188 chunk.x = leftmostChunk_ + chunkX;
185 chunk.y = topmostChunk_ + chunkY; 189 chunk.y = topmostChunk_ + chunkY;
190 chunk.litTiles = 0;
186 191
187 for (MapData& md : chunk.data) 192 for (MapData& md : chunk.data)
188 { 193 {
@@ -205,6 +210,8 @@ public:
205 std::next(std::begin(chunk.data), (y+1)*CHUNK_WIDTH), 210 std::next(std::begin(chunk.data), (y+1)*CHUNK_WIDTH),
206 std::next(std::begin(loaded_), (chunkY*CHUNK_HEIGHT + y)*width_ + chunkX*CHUNK_WIDTH)); 211 std::next(std::begin(loaded_), (chunkY*CHUNK_HEIGHT + y)*width_ + chunkX*CHUNK_WIDTH));
207 } 212 }
213
214 unloadedLitTiles_ -= chunk.litTiles;
208 } 215 }
209 } 216 }
210 217
@@ -225,6 +232,8 @@ private:
225 std::vector<Chunk> chunks_; 232 std::vector<Chunk> chunks_;
226 std::list<size_t> freeList_; 233 std::list<size_t> freeList_;
227 std::map<int, std::map<int, size_t>> chunkByPos_; // chunkByPos_[X][Y] 234 std::map<int, std::map<int, size_t>> chunkByPos_; // chunkByPos_[X][Y]
235
236 int unloadedLitTiles_ = 0;
228}; 237};
229 238
230#endif /* end of include guard: MAP_H_3AB00D12 */ 239#endif /* end of include guard: MAP_H_3AB00D12 */