summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/game.cpp7
-rw-r--r--src/map.h9
2 files changed, 11 insertions, 5 deletions
diff --git a/src/game.cpp b/src/game.cpp index e9a9fbe..7c67daa 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -119,11 +119,7 @@ void Game::tick(bool onlyDark)
119 119
120bool Game::movePlayer(int x, int y) 120bool Game::movePlayer(int x, int y)
121{ 121{
122 if (/*x >= curBoundX && 122 if (map.at(x,y).tile == Tile::Floor)
123 y >= curBoundY &&
124 x < curBoundX + curZoom * ZOOM_X_FACTOR &&
125 y < curBoundY + curZoom * ZOOM_Y_FACTOR &&*/
126 map.at(x,y).tile == Tile::Floor)
127 { 123 {
128 if (map.at(player_x, player_y).tile == Tile::Floor) 124 if (map.at(player_x, player_y).tile == Tile::Floor)
129 { 125 {
@@ -249,6 +245,7 @@ void Game::recalculateLighting()
249 } 245 }
250 } 246 }
251 247
248 litSpots += map.getUnloadedLitTiles();
252 dirtyLighting = false; 249 dirtyLighting = false;
253} 250}
254 251
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 */