fix input validation

This commit is contained in:
Navid Sassan 2025-12-09 22:28:52 +01:00
parent d9c623f26e
commit 478d8902b1

View File

@ -266,11 +266,15 @@ local function updateReactorInfo()
end
-- Check for zero max values (would cause division by zero)
if reactorInfo.maxFieldStrength ~= nil and reactorInfo.maxFieldStrength <= 0 then
table.insert(fieldErrors, "maxFieldStrength <= 0")
end
if reactorInfo.maxEnergySaturation ~= nil and reactorInfo.maxEnergySaturation <= 0 then
table.insert(fieldErrors, "maxEnergySaturation <= 0")
-- Only flag as error if reactor is not offline (these are expected to be 0 when cold)
local isOffline = reactorInfo.status == "cold" or reactorInfo.status == "invalid"
if not isOffline then
if reactorInfo.maxFieldStrength ~= nil and reactorInfo.maxFieldStrength <= 0 then
table.insert(fieldErrors, "maxFieldStrength <= 0")
end
if reactorInfo.maxEnergySaturation ~= nil and reactorInfo.maxEnergySaturation <= 0 then
table.insert(fieldErrors, "maxEnergySaturation <= 0")
end
end
-- Set error message if we have field errors