RGO2JV5HFKZFXO7KJWDXGDMNBR6NIAOMJW34NHRTLLVN2N7XGW7QC
delete[] dead_rays;
delete[] smoke_rays;
for (int x = 0; x <= LOS_MAX_RANGE; x++)
for (int y = 0; y <= LOS_MAX_RANGE; y++)
delete[] los_blockrays[x][y];
delete dead_rays;
delete smoke_rays;
for (int x = 0; x <= LOS_MAX_RANGE; x++)
for (int y = 0; y <= LOS_MAX_RANGE; y++)
delete los_blockrays[x][y];
bool _get_bit_in_long_array(const unsigned long* data, int where)
{
int wordloc = where / LONGSIZE;
int bitloc = where % LONGSIZE;
return ((data[wordloc] & (1UL << bitloc)) != 0);
}
static void _set_bit_in_long_array(unsigned long* data, int where)
{
int wordloc = where / LONGSIZE;
int bitloc = where % LONGSIZE;
data[wordloc] |= (1UL << bitloc);
}
full_los_blockrays[x][y] = new unsigned long[num_words];
memset((void*)full_los_blockrays[x][y], 0, sizeof(unsigned long) * num_words);
los_blockrays[x][y] = new unsigned long[num_nondupe_words];
memset((void*)los_blockrays[x][y], 0, sizeof(unsigned long) * num_nondupe_words);
full_los_blockrays[x][y] = new bit_array(num_cellrays);
los_blockrays[x][y] = new bit_array(num_nondupe_rays);
if (_get_bit_in_long_array(full_los_blockrays[x][y],
nondupe_cellrays[i]))
_set_bit_in_long_array(los_blockrays[x][y], i);
}
los_blockrays[x][y]->set(i,
full_los_blockrays[x][y]->get(nondupe_cellrays[i]));
for (int i = 0; i < num_words; ++i)
{
dead_rays[i] |= (smoke_rays[i] & los_blockrays[x][y][i]);
smoke_rays[i] |= los_blockrays[x][y][i];
}
*dead_rays |= (*smoke_rays & *los_blockrays[x][y]);
*smoke_rays |= *los_blockrays[x][y];
// make the cells seen by this ray at this point visible
if ( ((curword >> bitloc) & 1UL) == 0 )
{
// this ray is alive!
const coord_def p = coord_def(sx * compressed_ray_x[rayidx],
sy * compressed_ray_y[rayidx]);
// update shadow map
if (dat.los_bounds(p))
sh(p+sh_o) = dat.appearance(p);
}
++rayidx;
if (rayidx == num_cellrays)
break;
// this ray is alive!
const coord_def p = coord_def(sx * compressed_ray_x[rayidx],
sy * compressed_ray_y[rayidx]);
// update shadow map
if (dat.los_bounds(p))
sh(p+sh_o) = dat.appearance(p);