Prevent duplicate metatile pastes in the tileset editor

This commit is contained in:
GriffinR 2022-06-29 14:53:14 -04:00 committed by t
parent cd481892ae
commit 73eabc92ca
3 changed files with 26 additions and 1 deletions

View file

@ -54,4 +54,18 @@ public:
static int getAttributesSize(BaseGameVersion version);
};
inline bool operator==(const Metatile &a, const Metatile &b) {
return a.behavior == b.behavior &&
a.layerType == b.layerType &&
a.encounterType == b.encounterType &&
a.terrainType == b.terrainType &&
a.unusedAttributes == b.unusedAttributes &&
a.label == b.label &&
a.tiles == b.tiles;
}
inline bool operator!=(const Metatile &a, const Metatile &b) {
return !(operator==(a, b));
}
#endif // METATILE_H

View file

@ -22,4 +22,15 @@ public:
static int getIndexInTileset(int);
};
inline bool operator==(const Tile &a, const Tile &b) {
return a.tileId == b.tileId &&
a.xflip == b.xflip &&
a.yflip == b.yflip &&
a.palette == b.palette;
}
inline bool operator!=(const Tile &a, const Tile &b) {
return !(operator==(a, b));
}
#endif // TILE_H

View file

@ -815,7 +815,7 @@ void TilesetEditor::onPaletteEditorChangedPalette(int paletteId) {
bool TilesetEditor::replaceMetatile(uint16_t metatileId, Metatile * src)
{
Metatile * dest = Tileset::getMetatile(metatileId, this->primaryTileset, this->secondaryTileset);
if (!dest || !src)
if (!dest || !src || *dest == *src)
return false;
this->metatile = dest;