mirror of
https://github.com/huderlem/porymap.git
synced 2026-04-24 23:07:52 -05:00
Fix missing negative bound when painting tiles
This commit is contained in:
parent
d59b24bd6f
commit
0c6f901393
|
|
@ -17,6 +17,7 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp
|
|||
- Previously, the middle mouse button could be used as a shortcut with the pencil tool to switch to bucket-fill mode. This is now achieved using the `Alt` key.
|
||||
|
||||
### Fixed
|
||||
- Fix crash when a painted tile selection goes out of bounds of the metatile layer view in the Tileset Editor.
|
||||
- Fix crash on older versions of Qt when reopening a project with certain windows open.
|
||||
- Fix potential crash when painting and the cursor leaves the map area.
|
||||
- Fix potential crash when changing maps with the Tileset Editor open.
|
||||
|
|
|
|||
|
|
@ -547,30 +547,28 @@ void TilesetEditor::paintSelectedLayerTiles(const QPoint &pos, bool paletteOnly)
|
|||
QSize dimensions = this->tileSelector->getSelectionDimensions();
|
||||
QList<Tile> tiles = this->tileSelector->getSelectedTiles();
|
||||
int srcTileIndex = 0;
|
||||
int maxTileIndex = projectConfig.getNumTilesInMetatile();
|
||||
for (int y = 0; y < dimensions.height(); y++) {
|
||||
for (int x = 0; x < dimensions.width(); x++) {
|
||||
int destTileIndex = this->metatileLayersItem->posToTileIndex(pos.x() + x, pos.y() + y);
|
||||
if (destTileIndex < maxTileIndex) {
|
||||
Tile &destTile = this->metatile->tiles[destTileIndex];
|
||||
const Tile srcTile = tiles.value(srcTileIndex++);
|
||||
if (paletteOnly) {
|
||||
if (srcTile.palette == destTile.palette)
|
||||
continue; // Ignore no-ops for edit history
|
||||
destTile.palette = srcTile.palette;
|
||||
} else {
|
||||
if (srcTile == destTile)
|
||||
continue; // Ignore no-ops for edit history
|
||||
if (destTileIndex < 0 || destTileIndex >= this->metatile->tiles.length()) continue;
|
||||
Tile &destTile = this->metatile->tiles[destTileIndex];
|
||||
const Tile srcTile = tiles.value(srcTileIndex++);
|
||||
if (paletteOnly) {
|
||||
if (srcTile.palette == destTile.palette)
|
||||
continue; // Ignore no-ops for edit history
|
||||
destTile.palette = srcTile.palette;
|
||||
} else {
|
||||
if (srcTile == destTile)
|
||||
continue; // Ignore no-ops for edit history
|
||||
|
||||
// Update tile usage count
|
||||
if (this->tileSelector->showUnused && destTile.tileId != srcTile.tileId) {
|
||||
this->tileSelector->usedTiles[srcTile.tileId] += 1;
|
||||
this->tileSelector->usedTiles[destTile.tileId] -= 1;
|
||||
}
|
||||
destTile = srcTile;
|
||||
// Update tile usage count
|
||||
if (this->tileSelector->showUnused && destTile.tileId != srcTile.tileId) {
|
||||
this->tileSelector->usedTiles[srcTile.tileId] += 1;
|
||||
this->tileSelector->usedTiles[destTile.tileId] -= 1;
|
||||
}
|
||||
changed = true;
|
||||
destTile = srcTile;
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (!changed) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user