diff --git a/src/nostalgia/core/gfx.hpp b/src/nostalgia/core/gfx.hpp index b171de9d..48c30af3 100644 --- a/src/nostalgia/core/gfx.hpp +++ b/src/nostalgia/core/gfx.hpp @@ -247,7 +247,11 @@ struct TileSheet { const auto currentIdx = pIdx[pIdxIt]; if (pSubsheet->subsheets.size() <= currentIdx) { auto out = pIdx; - out.back().value = pSubsheet->subsheets.size() - 1; + if (pSubsheet->subsheets.size()) { + out.back().value = pSubsheet->subsheets.size() - 1; + } else { + out.pop_back(); + } return out; } return validateSubSheetIdx(pIdx, pIdxIt + 1, &pSubsheet->subsheets[pIdx[pIdxIt]]);