diff --git a/src/nostalgia/core/ptidxconv.hpp b/src/nostalgia/core/ptidxconv.hpp index 6b5ec7f92..9c78b965b 100644 --- a/src/nostalgia/core/ptidxconv.hpp +++ b/src/nostalgia/core/ptidxconv.hpp @@ -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