XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 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
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +10 -0
Modified src/models/inventoryModels/inventoryModel.ts +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,