set_up_lights: try to avoid a memory problem...

This commit is contained in:
Laurent Alonso(fr)
2020-05-17 09:58:12 +02:00
committed by Celtic Minstrel
parent 9f802b3fcf
commit 80daf2266b

View File

@@ -193,7 +193,9 @@ void cTown::set_up_lights() {
for(short j = 0; j < this->max_dim; j++) {
l.x = i;
l.y = j;
rad = scenario->ter_types[this->terrain(i,j)].light_radius;
unsigned short terrain=this->terrain(i,j);
rad = terrain<scenario->ter_types.size() ?
scenario->ter_types[terrain].light_radius : 0;
if(rad > 0) {
for(where.x = std::max(0,i - rad); where.x < min(this->max_dim,short(i + rad + 1)); where.x++)
for(where.y = std::max(0,j - rad); where.y < min(this->max_dim,short(j + rad + 1)); where.y++)