From 4b6a8e49aeda77f5640f4e6581d9dc83dbd1a196 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Tue, 24 Nov 2020 01:31:09 -0700 Subject: [PATCH] Fix errors when drawing outside the level in the editor --- js/main-editor.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/js/main-editor.js b/js/main-editor.js index 05e4110..0b485a0 100644 --- a/js/main-editor.js +++ b/js/main-editor.js @@ -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) { // TODO weird api? if (! name) 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 direction; if (type.is_actor) {