[nostalgia/core/studio] Fix click bounds checking for TileSheet editor

This commit is contained in:
Gary Talent 2022-03-17 04:15:54 -05:00
parent 2a552326e9
commit 2881a28dc8

View File

@ -380,10 +380,10 @@ void TileSheetEditorModel::paste() {
void TileSheetEditorModel::drawCommand(const geo::Point &pt, std::size_t palIdx) noexcept {
const auto &activeSubSheet = m_img.getSubSheet(m_activeSubsSheetIdx);
const auto idx = activeSubSheet.idx(pt);
if (idx >= activeSubSheet.pixelCnt(m_img.bpp)) {
if (pt.x >= activeSubSheet.columns * TileWidth || pt.y >= activeSubSheet.rows * TileHeight) {
return;
}
const auto idx = activeSubSheet.idx(pt);
if (m_ongoingDrawCommand) {
m_updated = m_updated || m_ongoingDrawCommand->append(idx);
} 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 {
const auto s = m_img.getSubSheet(m_activeSubsSheetIdx);
const auto &s = m_img.getSubSheet(m_activeSubsSheetIdx);
// build idx list
ox::Array<bool, PixelsPerTile> updateMap = {};
const auto oldColor = s.getPixel(m_img.bpp, pt);
if (oldColor == palIdx) {
if (pt.x >= s.columns * TileWidth || pt.y >= s.rows * TileHeight) {
return;
}
getFillPixels(updateMap.data(), pt, oldColor);