返回提交历史
Modified
src/controllers/api/missionInventoryUpdateController.ts
+22
-20
XFEstudio/SpaceNinjaServer
chore: omit InventoryJson for early versions (#4102)
Closes #4101 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4102 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
9d732291
代码差异
1 个文件
+22
-20
@@ -142,31 +142,33 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
142
142
res.json(deltas);
143
143
} else if (missionReport.RewardInfo) {
144
144
logger.debug(`classic mission completion, sending everything`);
145
const inventoryResponse = await getInventoryResponse(
146
req,
147
inventory,
148
"xpBasedLevelCapDisabled" in req.query,
149
account.BuildLabel
150
);
151
const response: IMissionInventoryUpdateResponse = {
152
InventoryJson: JSON.stringify(inventoryResponse),
153
...deltas
154
};
145
const response: IMissionInventoryUpdateResponse = deltas;
146
// InventoryJson is not recognised by early versions, and may lead them to buffer overrun if provided.
147
if (!account.BuildLabel || version_compare(account.BuildLabel, gameToBuildVersion["8.0.0"]) > 0) {
148
response.InventoryJson = JSON.stringify(
149
await getInventoryResponse(req, inventory, "xpBasedLevelCapDisabled" in req.query, account.BuildLabel)
150
);
151
}
155
152
if (missionReport.RewardInfo.sortieTag == "Final" && firstCompletion) {
156
153
response.CompletedSortie = true;
157
154
}
158
155
res.json(response);
159
156
} else {
160
logger.debug(`no reward info, assuming this wasn't a mission completion and we should just sync inventory`);
161
const inventoryResponse = await getInventoryResponse(
162
req,
163
inventory,
164
"xpBasedLevelCapDisabled" in req.query,
165
account.BuildLabel
166
);
167
res.json({
168
InventoryJson: JSON.stringify(inventoryResponse)
169
} satisfies IMissionInventoryUpdateResponseBackToDryDock);
157
logger.debug(`no reward info, just syncing inventory`);
158
// InventoryJson is not recognised by early versions, and may lead them to buffer overrun if provided.
159
if (!account.BuildLabel || version_compare(account.BuildLabel, gameToBuildVersion["8.0.0"]) > 0) {
160
const inventoryResponse = await getInventoryResponse(
161
req,
162
inventory,
163
"xpBasedLevelCapDisabled" in req.query,
164
account.BuildLabel
165
);
166
res.json({
167
InventoryJson: JSON.stringify(inventoryResponse)
168
} satisfies IMissionInventoryUpdateResponseBackToDryDock);
169
} else {
170
res.json({});
171
}
170
172
}
171
173
172
174
sendWsBroadcastTo(account._id.toString(), { update_inventory: true });