Adjust rate control code to work better

now it'll run at full speed if there's enough time
else it'll throttle back to 1/3.
(at that point, the movement imprecision caused by this
will become hidden behind lag-induced imprecision)
This commit is contained in:
Vanessa Ezekowitz 2017-07-03 18:38:18 -04:00
parent 3c20e91029
commit 769dd7fe7b

View File

@ -362,13 +362,12 @@ local move_entities_globalstep_part2 = function(dtime)
end end
end end
local handle_active_blocks_step = 0.2
local handle_active_blocks_timer = 0.1 local handle_active_blocks_timer = 0.1
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
handle_active_blocks_timer = handle_active_blocks_timer + dtime handle_active_blocks_timer = handle_active_blocks_timer + dtime
if handle_active_blocks_timer >= handle_active_blocks_step then if dtime < 0.2 or handle_active_blocks_timer >= (dtime * 3) then
handle_active_blocks_timer = handle_active_blocks_timer - handle_active_blocks_step handle_active_blocks_timer = 0.1
move_entities_globalstep_part1(dtime) move_entities_globalstep_part1(dtime)
move_entities_globalstep_part2(dtime) move_entities_globalstep_part2(dtime)
end end