Zero-K icon indicating copy to clipboard operation
Zero-K copied to clipboard

Invalid NaN/Inf repairspeed with random pathfinder

Open GoogleFrog opened this issue 6 months ago • 1 comments

Select random pathfinder on this commit: https://github.com/ZeroK-RTS/Zero-K/commit/47e698742d6abf34c11332ced7f6b42c2247b623

It causes unitdefs to load with NaN/Inf repairspeed. Removing all repair speed manipulation from _posts does not help. Assigning local bla = math.random() < 0.5 also triggered the bug.

GoogleFrog avatar Jun 30 '25 01:06 GoogleFrog

math.random exists but returns nil in modrules. Engine ticket https://github.com/beyond-all-reason/RecoilEngine/issues/2433

So modrules crash upon random() < 0.5 due to comparing number with a nil.

Modrules crash isn't fatal so it just discards everything and loads defaults. Engine ticket https://github.com/beyond-all-reason/RecoilEngine/issues/1702

One of the defaults is that repair energy cost multiplier is 0. This causes NaN or +inf (depending on whether the other number was 0 or not) via div0 here: https://github.com/ZeroK-RTS/Zero-K/blob/9fbbbb9e469586d205a60867b691fd8ca6380ae3/gamedata/unitdefs_post.lua#L613-L621

sprunk avatar Jul 03 '25 00:07 sprunk