Circle iterator now compensates for the matrix size and won't overflow.

This commit is contained in:
Zed A. Shaw 2024-12-25 01:15:33 -05:00
parent 35f2defc11
commit 857cd2f910
5 changed files with 25 additions and 23 deletions

View file

@ -7,14 +7,10 @@ using std::vector;
namespace lighting {
void LightRender::render_circle_light(LightSource source, Point at, PointList &has_light) {
for(matrix::circle it{at, source.distance + 1}; it.next();) {
for(matrix::circle it{$lightmap, at, source.distance + 1}; it.next();) {
for(int x = it.left; x < it.right; x++) {
if(matrix::inbounds($paths.$paths, x, it.y) &&
$paths.$paths[it.y][x] != WALL_PATH_LIMIT)
{
$lightmap[it.y][x] = light_level(source.strength, x, it.y);
has_light.push_back({(size_t)x, (size_t)it.y});
}
$lightmap[it.y][x] = light_level(source.strength, x, it.y);
has_light.push_back({(size_t)x, (size_t)it.y});
}
}
}