Skip to content

Commit

Permalink
Round values in timer target speed check
Browse files Browse the repository at this point in the history
math.floor() can result in one value being off by 1 because one
was just barely below the whole integer while the other one was not.
(floating point numbers \o/)
Adding 0.5 for actual rounding avoids that problem.

Closes #9
  • Loading branch information
christoph-heinrich authored and po5 committed Jul 26, 2023
1 parent e0e50d7 commit 4bd9993
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion evafast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ local function adjust_speed()
end
end

if math.floor(target_speed * 1000) == math.floor(current_speed * 1000) then
if math.floor(target_speed * 1000 + 0.5) == math.floor(current_speed * 1000 + 0.5) then
if forced_slowdown or (not toggled and (not speedup or options.subs_speed_cap == options.speed_cap or (not has_subtitle and not speedup_target))) then
speed_timer:kill()
toggled_display = true
Expand Down

0 comments on commit 4bd9993

Please sign in to comment.