Fix revealing the void under a block hiding an item in CC1

This commit is contained in:
Eevee (Evelyn Woods) 2020-09-12 20:58:28 -06:00
parent d3dfcba63b
commit b26820d99b

View File

@ -187,6 +187,18 @@ function parse_level(buf) {
throw new Error(`Expected 1024 cells (32x32 map); found ${c}`); 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 // Optional metadata fields
let meta_length = view.getUint16(p, true); let meta_length = view.getUint16(p, true);
p += 2; p += 2;