From b26820d99b6cbb4d345b369a512ee53ea82bd0e3 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Sat, 12 Sep 2020 20:58:28 -0600 Subject: [PATCH] Fix revealing the void under a block hiding an item in CC1 --- js/format-dat.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/format-dat.js b/js/format-dat.js index af80c89..452fca9 100644 --- a/js/format-dat.js +++ b/js/format-dat.js @@ -187,6 +187,18 @@ function parse_level(buf) { throw new Error(`Expected 1024 cells (32x32 map); found ${c}`); } + // The MSCC1 format allows a lot of weird things, so check all the cells. In particular we want + // to be sure there's terrain in every cell; MSCC1 allows a block on the top layer and an item + // on the bottom layer, and will consider the item to be the "terrain" and draw a floor under it + for (let cell of level.linear_cells) { + if (TILE_TYPES[cell[0].name].draw_layer !== 0) { + // No terrain; insert a floor + cell.unshift({ name: 'floor' }); + } + // TODO we could also deal with weird cases where there's terrain /on top of/ something + // else: things underwater, the quirk where a glider will erase the item underneath... + } + // Optional metadata fields let meta_length = view.getUint16(p, true); p += 2;