NaN bug
Posted: 11 Nov 2009, 20:33
Someone in #main made me aware of a bug in either Spring or BA. It appeared to be BA.
The problem is that if you reclaim a feature with 0 metal and 0 energy, the feature will change to give NaN m/e (rez bot) or -2147483648 m/e (commander). During reclaiming the resource bar may also display an energy pull of -nan.
How to reproduce: Load therockjungle and reclaim some shrubs.
I suspect the bug is in here (LuaRules/Gadgets/unit_reclaim_fix.lua):
Since there are no checks there for resource == 0 (or reclaimtime == 0).
The problem is that if you reclaim a feature with 0 metal and 0 energy, the feature will change to give NaN m/e (rez bot) or -2147483648 m/e (commander). During reclaiming the resource bar may also display an energy pull of -nan.
How to reproduce: Load therockjungle and reclaim some shrubs.
I suspect the bug is in here (LuaRules/Gadgets/unit_reclaim_fix.lua):
Code: Select all
local resource = math.max(FeatureDefs[featureDefID].metal,FeatureDefs[featureDefID].energy)
local newpercent = select(5,GetFeatureResources(featureID)) - ((((resource * oldformula) * 6) - (resource * newformula)) / resource)