[nostalgia/core] Fix possible div by zero in idxToPt

This commit is contained in:
Gary Talent 2022-09-24 20:38:49 -05:00
parent cef415d34f
commit ea55a33b60

View File

@ -28,6 +28,10 @@ constexpr std::size_t ptToIdx(const geo::Point &pt, int c) noexcept {
[[nodiscard]]
constexpr geo::Point idxToPt(int i, int c) noexcept {
// prevent divide by zeros
if (!c) {
++c;
}
const auto t = i / PixelsPerTile; // tile number
const auto iti = i % PixelsPerTile; // in tile index
const auto tc = t % c; // tile column