Skip to content
  • triallax's avatar
    vector: fix out-of-bounds double-to-int conversion · fab16c2b
    triallax authored and Corentin Noël's avatar Corentin Noël committed
    At least with Clang 18 on Chimera Linux, the out-of-bounds conversion
    causes the vector-sprite-sheet test to fail:
    
    ```
    ok 1 /vector-sprite-sheet/sprites
    ok 2 /vector-sprite-sheet/fallback
    not ok /vector-sprite-sheet/scale-factor - shumate-FATAL-CRITICAL: shumate_vector_sprite_get_scale_factor: assertion 'SHUMATE_IS_VECTOR_SPRITE (self)' failed
    Bail out!
    ```
    
    `best_scale` is only used in the function are for comparisons against
    `sprite_scale` inside the `for` loop, and that variable is already a
    `double` anyway, so there is no good reason for `best_scale` to not be
    a `double` instead of an `int`.
    
    Credits go to q66 (Daniel Kolesa) for telling me about the proper fix
    here.
    fab16c2b