parse-protection on miscInt and miscFloat

This commit is contained in:
2024-02-15 20:04:09 -07:00
parent f7077f992d
commit 2dae27daa5

View File

@@ -645,7 +645,9 @@
(director.enterString "Redefine $key from ${.value (miscInts.get key)}?"
->valStr
(let [v (Std.parseInt valStr)]
(miscInts.put key (new HInt v))
(if (= v null)
(print "Failed to parse ${valStr}. leaving value the same")
(miscInts.put key (new HInt v)))
(cc))))
]
(set lastCommand defineMiscInt)
@@ -661,7 +663,9 @@
(director.enterString "Redefine $key from ${.value (miscFloats.get key)}?"
->valStr
(let [v (Std.parseFloat valStr)]
(miscFloats.put key (new HFloat v))
(if (Math.isNaN v)
(print "Failed to parse ${valStr}. leaving value the same")
(miscFloats.put key (new HFloat v)))
(cc))))
]
(set lastCommand defineMiscFloat)