Add bounds-checking to coord_to_ter in the scenario editor

This commit is contained in:
2023-01-18 10:00:08 -05:00
parent d0d7765d2d
commit 6b56f4af86

View File

@@ -2707,13 +2707,14 @@ bool is_lava(short x,short y) {
} }
ter_num_t coord_to_ter(short x,short y) { ter_num_t coord_to_ter(short x,short y) {
ter_num_t what_terrain; if(x < 0 || y < 0) return 0;
if(editing_town) {
if(editing_town) if(x >= town->max_dim || y >= town->max_dim) return 0;
what_terrain = town->terrain(x,y); return town->terrain(x,y);
else what_terrain = current_terrain->terrain[x][y]; } else {
if(x >= current_terrain->max_dim || y >= current_terrain->max_dim) return 0;
return what_terrain; return current_terrain->terrain[x][y];
}
} }
bool monst_on_space(location loc,short m_num) { bool monst_on_space(location loc,short m_num) {