返回提交历史
Modified
src/controllers/api/claimLibraryDailyTaskRewardController.ts
+2
-2
Modified
src/controllers/api/contributeGuildClassController.ts
+2
-2
Modified
src/controllers/api/sellController.ts
+3
-2
Modified
src/controllers/custom/addCurrencyController.ts
+7
-3
Modified
src/services/inventoryService.ts
+10
-1
Modified
src/services/missionInventoryUpdateService.ts
+7
-6
XFEstudio/SpaceNinjaServer
chore: cap FusionPoints balance at 2147483647 (#1797)
Same idea as with typeCountSchema. The game needs to be able to store these safely in an i32 on the C++ side. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1797 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
7a8b12b3
代码差异
6 个文件
+31
-16
@@ -1,4 +1,4 @@
1
import { getInventory } from "@/src/services/inventoryService";
1
import { addFusionPoints, getInventory } from "@/src/services/inventoryService";
2
2
import { getAccountIdForRequest } from "@/src/services/loginService";
3
3
import { RequestHandler } from "express";
4
4
@@ -17,7 +17,7 @@ export const claimLibraryDailyTaskRewardController: RequestHandler = async (req,
17
17
}
18
18
syndicate.Standing += rewardStanding;
19
19
20
inventory.FusionPoints += 80 * rewardQuantity;
20
addFusionPoints(inventory, 80 * rewardQuantity);
21
21
await inventory.save();
22
22
23
23
res.json({
@@ -2,7 +2,7 @@ import { toMongoDate } from "@/src/helpers/inventoryHelpers";
2
2
import { getJSONfromString } from "@/src/helpers/stringHelpers";
3
3
import { Guild } from "@/src/models/guildModel";
4
4
import { checkClanAscensionHasRequiredContributors } from "@/src/services/guildService";
5
import { getInventory } from "@/src/services/inventoryService";
5
import { addFusionPoints, getInventory } from "@/src/services/inventoryService";
6
6
import { getAccountIdForRequest } from "@/src/services/loginService";
7
7
import { RequestHandler } from "express";
8
8
import { Types } from "mongoose";
@@ -36,7 +36,7 @@ export const contributeGuildClassController: RequestHandler = async (req, res) =
36
36
37
37
// Either way, endo is given to the contributor.
38
38
const inventory = await getInventory(accountId, "FusionPoints");
39
inventory.FusionPoints += guild.CeremonyEndo!;
39
addFusionPoints(inventory, guild.CeremonyEndo!);
40
40
await inventory.save();
41
41
42
42
res.json({
@@ -8,7 +8,8 @@ import {
8
8
addConsumables,
9
9
freeUpSlot,
10
10
combineInventoryChanges,
11
addCrewShipRawSalvage
11
addCrewShipRawSalvage,
12
addFusionPoints
12
13
} from "@/src/services/inventoryService";
13
14
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
14
15
import { ExportDojoRecipes } from "warframe-public-export-plus";
@@ -69,7 +70,7 @@ export const sellController: RequestHandler = async (req, res) => {
69
70
if (payload.SellCurrency == "SC_RegularCredits") {
70
71
inventory.RegularCredits += payload.SellPrice;
71
72
} else if (payload.SellCurrency == "SC_FusionPoints") {
72
inventory.FusionPoints += payload.SellPrice;
73
addFusionPoints(inventory, payload.SellPrice);
73
74
} else if (payload.SellCurrency == "SC_PrimeBucks") {
74
75
addMiscItems(inventory, [
75
76
{
@@ -1,12 +1,16 @@
1
1
import { RequestHandler } from "express";
2
2
import { getAccountIdForRequest } from "@/src/services/loginService";
3
import { getInventory } from "@/src/services/inventoryService";
3
import { addFusionPoints, getInventory } from "@/src/services/inventoryService";
4
4
5
5
export const addCurrencyController: RequestHandler = async (req, res) => {
6
6
const accountId = await getAccountIdForRequest(req);
7
const inventory = await getInventory(accountId);
8
7
const request = req.body as IAddCurrencyRequest;
9
inventory[request.currency] += request.delta;
8
const inventory = await getInventory(accountId, request.currency);
9
if (request.currency == "FusionPoints") {
10
addFusionPoints(inventory, request.delta);
11
} else {
12
inventory[request.currency] += request.delta;
13
}
10
14
await inventory.save();
11
15
res.end();
12
16
};
@@ -580,7 +580,7 @@ export const addItem = async (
580
580
}
581
581
if (typeName in ExportFusionBundles) {
582
582
const fusionPointsTotal = ExportFusionBundles[typeName].fusionPoints * quantity;
583
inventory.FusionPoints += fusionPointsTotal;
583
addFusionPoints(inventory, fusionPointsTotal);
584
584
return {
585
585
FusionPoints: fusionPointsTotal
586
586
};
@@ -1069,6 +1069,15 @@ export const updateCurrency = (
1069
1069
return currencyChanges;
1070
1070
};
1071
1071
1072
export const addFusionPoints = (inventory: TInventoryDatabaseDocument, add: number): number => {
1073
if (inventory.FusionPoints + add > 2147483647) {
1074
logger.warn(`capping FusionPoints balance at 2147483647`);
1075
add = 2147483647 - inventory.FusionPoints;
1076
}
1077
inventory.FusionPoints += add;
1078
return add;
1079
};
1080
1072
1081
const standingLimitBinToInventoryKey: Record<
1073
1082
Exclude<TStandingLimitBin, "STANDING_LIMIT_BIN_NONE">,
1074
1083
keyof IDailyAffiliations
@@ -19,6 +19,7 @@ import {
19
19
addCrewShipRawSalvage,
20
20
addEmailItem,
21
21
addFocusXpIncreases,
22
addFusionPoints,
22
23
addFusionTreasures,
23
24
addGearExpByCategory,
24
25
addItem,
@@ -287,14 +288,14 @@ export const addMissionInventoryUpdates = async (
287
288
addShipDecorations(inventory, value);
288
289
break;
289
290
case "FusionBundles": {
290
let fusionPoints = 0;
291
let fusionPointsDelta = 0;
291
292
for (const fusionBundle of value) {
292
const fusionPointsTotal =
293
ExportFusionBundles[fusionBundle.ItemType].fusionPoints * fusionBundle.ItemCount;
294
inventory.FusionPoints += fusionPointsTotal;
295
fusionPoints += fusionPointsTotal;
293
fusionPointsDelta += addFusionPoints(
294
inventory,
295
ExportFusionBundles[fusionBundle.ItemType].fusionPoints * fusionBundle.ItemCount
296
);
296
297
}
297
inventoryChanges.FusionPoints = fusionPoints;
298
inventoryChanges.FusionPoints = fusionPointsDelta;
298
299
break;
299
300
}
300
301
case "EmailItems": {