Rehash the Tileset hash tablet when we remap/move tiles

This commit is contained in:
David Capello 2020-02-17 18:09:48 -03:00
parent 21fa63da76
commit 75f7346ef6
2 changed files with 12 additions and 5 deletions

View File

@ -100,6 +100,8 @@ void Tileset::remap(const Remap& remap)
m_tiles[remap[ti]] = tmp[ti];
}
}
rehash();
}
void Tileset::set(const tile_index ti,
@ -202,11 +204,7 @@ void Tileset::notifyTileContentChange(const tile_index ti)
// only way to make it work correctly)
(void)ti; // unused
tile_index tj = 0;
m_hash.clear();
for (auto tile : m_tiles)
m_hash[tile] = tj++;
rehash();
#endif
}
@ -259,4 +257,12 @@ void Tileset::assertValidHashTable()
}
#endif
void Tileset::rehash()
{
tile_index tj = 0;
m_hash.clear();
for (auto tile : m_tiles)
m_hash[tile] = tj++;
}
} // namespace doc

View File

@ -102,6 +102,7 @@ namespace doc {
private:
void removeFromHash(const tile_index ti,
const bool adjustIndexes);
void rehash();
Sprite* m_sprite;
Grid m_grid;