Fix errors when drawing outside the level in the editor

This commit is contained in:
Eevee (Evelyn Woods) 2020-11-24 01:31:09 -07:00
parent 5cb29c8f7d
commit 4b6a8e49ae

View File

@ -766,11 +766,20 @@ export class Editor extends PrimaryView {
} }
} }
is_in_level(x, y) {
return 0 <= x && x < this.stored_level.size_x && 0 <= y && y < this.stored_level.size_y;
}
place_in_cell(x, y, name) { place_in_cell(x, y, name) {
// TODO weird api? // TODO weird api?
if (! name) if (! name)
return; return;
// TODO seems like a big problem to silently ignore, but it can happen from mouse
// coordinates while drawing
if (! this.is_in_level(x, y))
return;
let type = TILE_TYPES[name]; let type = TILE_TYPES[name];
let direction; let direction;
if (type.is_actor) { if (type.is_actor) {