From 25f61ff5f9e76bc867c0048d0e04fba849e84d24 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 6 Oct 2023 17:39:00 -0300 Subject: [PATCH] Fix bug w/auto tileset mode adjusting tiles when we replace a unique instance of a tile+flag with a new tile The assert() in remove_unused_tiles_from_tileset() checking for the tiles histograms was failing because we weren't adjusting the histogram correctly when a tile w/a flag is replaced w/another without flags. --- src/app/util/cel_ops.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/util/cel_ops.cpp b/src/app/util/cel_ops.cpp index d0da8027f..e9718e341 100644 --- a/src/app/util/cel_ops.cpp +++ b/src/app/util/cel_ops.cpp @@ -609,8 +609,9 @@ void modify_tilemap_cel_region( // We add the new one tileIndex in the histogram count. if (tilesetMode == TilesetMode::Auto && - tileIndex != doc::notile && - tileIndex >= 0 && tileIndex < tilesHistogram.size()) { + tile != doc::notile && + tileIndex >= 0 && tileIndex < tilesHistogram.size() && + ti != tileIndex) { ++tilesHistogram[tileIndex]; } }