mickelson / attract

A graphical front-end for command line emulators that hides the underlying operating system and is intended to be controlled with a joystick or gamepad.
http://attractmode.org
GNU General Public License v3.0
393 stars 115 forks source link

Conveyor module - on_transition - division by zero #653

Open ghost opened 4 years ago

ghost commented 4 years ago

If conveyor ms_transition is set to a low value like 1 ms, initiating a long perpetual navigation of the wheel (press and hold the down or up key when navigating a long list) will result in an the following error in the console:

AN ERROR HAS OCCURED [division by zero]

CALLSTACK
*FUNCTION [on_transition()] D:\Arcade\attract\modules\conveyor.nut line [244]

LOCALS
[move_duration] 0
[jump_adjust] 0
[moves] 6
[ttime] 0
[var] -6
[ttype] 2
[this] INSTANCE
Script Error in transition function: on_transition - division by zero
 ! Unexpectedly lost focus to: None

Adding this check in line 244 avoids the error and it doesn't create any new issues with the wheel (to the best of my knowledge):

local curr_move;
if ( move_duration > 0 )
    curr_move = ttime / move_duration;