fix: clamp ItemCount within 32-bit integer range
All checks were successful
Build / build (20) (push) Successful in 41s
Build / build (18) (push) Successful in 1m15s
Build / build (18) (pull_request) Successful in 42s
Build / build (22) (push) Successful in 1m9s
Build / build (20) (pull_request) Successful in 1m14s
Build / build (22) (pull_request) Successful in 1m9s

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.
This commit is contained in:
Sainan 2025-04-02 14:22:31 +02:00
parent 24ed580a97
commit ddf7a658ca

View File

@ -102,6 +102,16 @@ import { EquipmentSelectionSchema } from "./loadoutModel";
export const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false }); 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>( const focusXPSchema = new Schema<IFocusXP>(
{ {
AP_POWER: Number, AP_POWER: Number,