Actually, there is an explanation for this and it is quite easy to "hide".
Lines 263-267 of serialize.h:
Code: Select all
inline void writeF1000(u8 *data, f32 i)
assert(i >= F1000_MIN && i <= F1000_MAX);
writeS32(data, i * FIXEDPOINT_FACTOR);
The assert above crashes the game.
But I see no reason for using "assert" because of the lines 35-43 of serialize.h:
// 0x7FFFFFFF / 1000.0f is not serializable.
// The limited float precision at this magnitude may cause the result to round
// to a greater value than can be represented by a 32 bit integer when increased
// by a factor of FIXEDPOINT_FACTOR. As a result, [F1000_MIN..F1000_MAX] does
// not represent the full range, but rather the largest safe range, of values on
// all supported architectures. Note: This definition makes assumptions on
// platform float-to-int conversion behavior.
#define F1000_MIN ((float)(s32)((-0x7FFFFFFF - 1) / FIXEDPOINT_FACTOR))
#define F1000_MAX ((float)(s32)((0x7FFFFFFF) / FIXEDPOINT_FACTOR))
So, the game *knows* there may be values outside the range, but uses assert instead of a simple check nevertheless.
That results in a crash instead of error/warning.
Thus, the first step would be to change the code above to throw warning/error instead of asserting the range.
The second step would be to ensure that there's no numbers smaller than F1000_MIN or bigger that F1000_MAX in your Lua code.
BTW, that assertion is something that was added quite recently (a month or so) as Magichet does not contain that check and I've seen no consequences yet.
(I hope, me mentioning MCG won't be treated as the ads of sorts yet another time. My intentions are pure "comparative" and "bug-tracking").