fix: clamp ItemCount within 32-bit integer range (#1432)

It seems the game uses 32-bit ints for these values on the C++ side before passing them on to Lua where they become floats. This would cause the game to have overflow/underflow semantics when receiving values outside of these bounds.

Reviewed-on: OpenWF/SpaceNinjaServer#1432
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
Sainan 2025-04-02 13:20:06 -07:00 committed by Sainan
parent 74d9428a66
commit 2173bdb8b8

View File

@ -102,6 +102,16 @@ import { EquipmentSelectionSchema } from "./loadoutModel";
export const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
typeCountSchema.set("toJSON", {
transform(_doc, obj) {
if (obj.ItemCount > 2147483647) {
obj.ItemCount = 2147483647;
} else if (obj.ItemCount < -2147483648) {
obj.ItemCount = -2147483648;
}
}
});
const focusXPSchema = new Schema<IFocusXP>(
{
AP_POWER: Number,