EasyRPG / Player

RPG Maker 2000/2003 and EasyRPG games interpreter
https://easyrpg.org/player/
GNU General Public License v3.0
1.01k stars 192 forks source link

Setting --fps-limit 0 causes floating point exception crash #2679

Closed fmatthew5876 closed 3 years ago

fmatthew5876 commented 3 years ago

Try --fps-limit 0 to disable fps limit, you get an immediate crash. Probably a divide by 0 bug somewhere.

ghost commented 3 years ago

The crash is triggered here when fps-limit is set to 0, the cause is indeed a division by 0. Does it make sense to add a check if fps is 0 and if yes, then set ns to a sufficiently low value to emulate (near) infinite FPS?

Ghabry commented 3 years ago

You mean set fps to a very high value? Like numeric_limit::max() or how that was called... imo that is the easiest solution here...

ghost commented 3 years ago

Your suggestion sounds even better. Is better than setting ns to a certain value if fps is 0.

fmatthew5876 commented 3 years ago

Using an arbitrarily high number could work.

Otherwise, I believe https://github.com/EasyRPG/Player/blob/master/src/baseui.cpp#L63 setting this frame_limit to 0 if the fps_limit is 0 would also work. Needs testing

ghost commented 3 years ago

@fmatthew5876 Your suggestion works for me. I have added a PR (#2684) to fix this issue.