[nostalgia/core/studio] Fix click bounds checking for TileSheet editor
This commit is contained in:
parent
2a552326e9
commit
2881a28dc8
@ -380,10 +380,10 @@ void TileSheetEditorModel::paste() {
|
|||||||
|
|
||||||
void TileSheetEditorModel::drawCommand(const geo::Point &pt, std::size_t palIdx) noexcept {
|
void TileSheetEditorModel::drawCommand(const geo::Point &pt, std::size_t palIdx) noexcept {
|
||||||
const auto &activeSubSheet = m_img.getSubSheet(m_activeSubsSheetIdx);
|
const auto &activeSubSheet = m_img.getSubSheet(m_activeSubsSheetIdx);
|
||||||
const auto idx = activeSubSheet.idx(pt);
|
if (pt.x >= activeSubSheet.columns * TileWidth || pt.y >= activeSubSheet.rows * TileHeight) {
|
||||||
if (idx >= activeSubSheet.pixelCnt(m_img.bpp)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const auto idx = activeSubSheet.idx(pt);
|
||||||
if (m_ongoingDrawCommand) {
|
if (m_ongoingDrawCommand) {
|
||||||
m_updated = m_updated || m_ongoingDrawCommand->append(idx);
|
m_updated = m_updated || m_ongoingDrawCommand->append(idx);
|
||||||
} else if (activeSubSheet.getPixel(m_img.bpp, idx) != palIdx) {
|
} else if (activeSubSheet.getPixel(m_img.bpp, idx) != palIdx) {
|
||||||
@ -414,11 +414,11 @@ void TileSheetEditorModel::setActiveSubsheet(const TileSheet::SubSheetIdx &idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditorModel::fill(const geo::Point &pt, int palIdx) noexcept {
|
void TileSheetEditorModel::fill(const geo::Point &pt, int palIdx) noexcept {
|
||||||
const auto s = m_img.getSubSheet(m_activeSubsSheetIdx);
|
const auto &s = m_img.getSubSheet(m_activeSubsSheetIdx);
|
||||||
// build idx list
|
// build idx list
|
||||||
ox::Array<bool, PixelsPerTile> updateMap = {};
|
ox::Array<bool, PixelsPerTile> updateMap = {};
|
||||||
const auto oldColor = s.getPixel(m_img.bpp, pt);
|
const auto oldColor = s.getPixel(m_img.bpp, pt);
|
||||||
if (oldColor == palIdx) {
|
if (pt.x >= s.columns * TileWidth || pt.y >= s.rows * TileHeight) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getFillPixels(updateMap.data(), pt, oldColor);
|
getFillPixels(updateMap.data(), pt, oldColor);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user