diff --git a/src/components/gameMaster/zoneEditor/zonePartials/ZoneTiles.vue b/src/components/gameMaster/zoneEditor/zonePartials/ZoneTiles.vue index 548c867..d2dbf34 100644 --- a/src/components/gameMaster/zoneEditor/zonePartials/ZoneTiles.vue +++ b/src/components/gameMaster/zoneEditor/zonePartials/ZoneTiles.vue @@ -192,14 +192,17 @@ onMounted(() => { return } - // First fill the entire map with blank tiles - const blankTiles = createTileArray(tileMap.width, tileMap.height, 'blank_tile') + // First fill the entire map with blank tiles using current zone dimensions + const blankTiles = createTileArray(zoneEditorStore.zone.width, zoneEditorStore.zone.height, 'blank_tile') - // Then overlay the zone tiles on top + // Then overlay the zone tiles, but only within the current zone dimensions const zoneTiles = zoneEditorStore.zone.tiles - for (let y = 0; y < zoneTiles.length; y++) { - for (let x = 0; x < zoneTiles[y].length; x++) { - blankTiles[y][x] = zoneTiles[y][x] + for (let y = 0; y < zoneEditorStore.zone.height; y++) { + for (let x = 0; x < zoneEditorStore.zone.width; x++) { + // Only copy if the source tiles array has this position + if (zoneTiles[y] && zoneTiles[y][x] !== undefined) { + blankTiles[y][x] = zoneTiles[y][x] + } } }