diff --git a/src/gfx.cpp b/src/gfx.cpp --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1132,7 +1132,7 @@ static void GfxMainBlitter(const Sprite void *clicked = _newgrf_debug_sprite_picker.clicked_pixel; if (topleft <= clicked && clicked <= bottomright) { - uint offset = (((size_t)clicked - (size_t)topleft) % bp.pitch) / blitter->GetBytesPerPixel(); + uint offset = (((size_t)clicked - (size_t)topleft) / blitter->GetBytesPerPixel()) % bp.pitch; if (offset < (uint)bp.width) { _newgrf_debug_sprite_picker.sprites.Include(sprite_id); }