draw_terrain: protect also town's out of bounds...

This commit is contained in:
Laurent Alonso(fr)
2020-05-31 20:44:25 +02:00
committed by Celtic Minstrel
parent 23a0e022a7
commit 974e614c3b

View File

@@ -862,8 +862,12 @@ void draw_terrain(short mode) {
if(is_town() || is_combat())
draw_items(where_draw);
// ASAN: where_draw.y can be equal to -1, ...
if(is_out() && where_draw.x>=0 && where_draw.x<96 && where_draw.y>=0 && where_draw.y<96 &&
univ.out.out_e[where_draw.x][where_draw.y] && univ.out.is_road(where_draw.x,where_draw.y))
int max_dim = is_town() ? univ.town->max_dim : 96;
if (where_draw.x<0 || where_draw.x>=max_dim || where_draw.y<0 || where_draw.y>=max_dim) {
place_road(q,r,where_draw,false);
continue;
}
if(is_out() && univ.out.out_e[where_draw.x][where_draw.y] && univ.out.is_road(where_draw.x,where_draw.y))
place_road(q,r,where_draw,true);
else if(is_town() && univ.town.is_explored(where_draw.x,where_draw.y) && univ.town.is_road(where_draw.x, where_draw.y))
place_road(q,r,where_draw,true);