diff --git a/CHANGELOG.md b/CHANGELOG.md index f3591a0d..7f87bff4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d ### Fixed - Fix New Map settings being preserved when switching projects. - Fix scripting API callback `onMapResized` not triggering. +- Fix crash when importing AdvanceMap metatiles while `enable_triple_layer_metatiles` is enabled. ## [5.0.0] - 2022-10-30 ### Breaking Changes diff --git a/src/core/metatileparser.cpp b/src/core/metatileparser.cpp index 0bae75e0..fc242e82 100644 --- a/src/core/metatileparser.cpp +++ b/src/core/metatileparser.cpp @@ -78,6 +78,14 @@ QList MetatileParser::parse(QString filepath, bool *error, bool prima tiles.append(tile); } + // AdvanceMap .bvd files only contain 8 tiles of data per metatile. + // If the user has triple-layer metatiles enabled we need to fill the remaining 4 tiles ourselves. + if (projectConfig.getTripleLayerMetatilesEnabled()) { + Tile tile = Tile(); + for (int j = 0; j < 4; j++) + tiles.append(tile); + } + int attrOffset = 4 + (numMetatiles * metatileSize) + (i * attrSize); uint32_t attributes = 0; for (int j = 0; j < attrSize; j++)