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: using ILoadoutConfigClient to write to database (#190)

7b3f9b30
Sainan <sainan@calamity.gg>
提交于

代码差异

1 个文件 +9 -7
Modified src/services/saveLoadoutService.ts +9 -7
@@ -2,6 +2,7 @@ import {
2 2 IItemEntry,
3 3 ILoadoutClient,
4 4 ILoadoutEntry,
5 ILoadoutConfigDatabase,
5 6 IOperatorConfigEntry,
6 7 ISaveLoadoutRequestNoUpgradeVer
7 8 } from "@/src/types/saveLoadoutTypes";
@@ -86,10 +87,14 @@ export const handleInventoryItemConfigChange = async (
86 87 loadout => loadout._id.toString() === loadoutId
87 88 );
88 89
90 const { ItemId, ...loadoutConfigItemIdRemoved } = loadoutConfig;
91 const loadoutConfigDatabase: ILoadoutConfigDatabase = {
92 _id: new Types.ObjectId(ItemId.$oid),
93 ...loadoutConfigItemIdRemoved
94 };
95
89 96 // if no config with this id exists, create a new one
90 97 if (!oldLoadoutConfig) {
91 const { ItemId, ...loadoutConfigItemIdRemoved } = loadoutConfig;
92
93 98 //save the new object id and assign it for every ffff return at the end
94 99 if (ItemId.$oid === "ffffffffffffffffffffffff") {
95 100 if (!newLoadoutId) {
@@ -99,10 +104,7 @@ export const handleInventoryItemConfigChange = async (
99 104 continue;
100 105 }
101 106
102 loadout[loadoutSlot].push({
103 _id: ItemId.$oid,
104 ...loadoutConfigItemIdRemoved
105 });
107 loadout[loadoutSlot].push(loadoutConfigDatabase);
106 108 continue;
107 109 }
108 110
@@ -111,7 +113,7 @@ export const handleInventoryItemConfigChange = async (
111 113 throw new Error("loadout index not found");
112 114 }
113 115
114 loadout[loadoutSlot][loadoutIndex].overwrite(loadoutConfig);
116 loadout[loadoutSlot][loadoutIndex].overwrite(loadoutConfigDatabase);
115 117 }
116 118 }
117 119 await loadout.save();