返回提交历史
Modified
src/models/inventoryModels/inventoryModel.ts
+10
-0
XFEstudio/SpaceNinjaServer
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: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1432 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2173bdb8
代码差异
1 个文件
+10
-0
@@ -102,6 +102,16 @@ import { EquipmentSelectionSchema } from "./loadoutModel";
102
102
103
103
export const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
104
104
105
typeCountSchema.set("toJSON", {
106
transform(_doc, obj) {
107
if (obj.ItemCount > 2147483647) {
108
obj.ItemCount = 2147483647;
109
} else if (obj.ItemCount < -2147483648) {
110
obj.ItemCount = -2147483648;
111
}
112
}
113
});
114
105
115
const focusXPSchema = new Schema<IFocusXP>(
106
116
{
107
117
AP_POWER: Number,