返回提交历史
Modified
src/controllers/api/arcaneCommonController.ts
+4
-8
Modified
src/controllers/api/inventoryController.ts
+10
-0
XFEstudio/SpaceNinjaServer
fix: convert arcane fingerprints for pre-U18.18 clients (#3811)
Closes #3810 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3811 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2c25f3b4
代码差异
2 个文件
+14
-8
@@ -4,20 +4,16 @@ import { getAccountForRequest } from "../../services/loginService.ts";
4
4
import { getInventory, addMods, addMiscItem } from "../../services/inventoryService.ts";
5
5
import type { IOid } from "../../types/commonTypes.ts";
6
6
import { logger } from "../../utils/logger.ts";
7
import { JSONParse } from "json-with-bigint";
8
7
import gameToBuildVersion from "../../constants/gameToBuildVersion.ts";
9
8
import { version_compare } from "../../helpers/inventoryHelpers.ts";
10
9
11
10
export const arcaneCommonController: RequestHandler = async (req, res) => {
12
11
const account = await getAccountForRequest(req);
13
12
const inventory = await getInventory(account._id.toString());
14
const body = String(req.body);
15
16
const parsed: unknown = JSONParse(body.substring(0, body.lastIndexOf("}") + 1));
17
if (typeof parsed === "object" && parsed !== null && !("newRank" in parsed) && "skinId" in parsed) {
18
const json = getJSONfromString<IArcaneLegacyRequest>(body);
13
const json = getJSONfromString<IArcaneCommonRequest | IArcaneLegacyRequest>(String(req.body));
14
if (!("newRank" in json) && "skinId" in json) {
15
//logger.debug(`legacy arcane request:`, json);
19
16
const item = inventory.WeaponSkins.id(json.skinId);
20
const legacyArcaneLevelCounts = [1, 3, 6, 10];
21
17
if (item) {
22
18
if (json.operationType == "Install") {
23
19
const resp: IArcaneLegacyInstallResp = { newLevel: 0 };
@@ -69,7 +65,6 @@ export const arcaneCommonController: RequestHandler = async (req, res) => {
69
65
await inventory.save();
70
66
return;
71
67
}
72
const json = getJSONfromString<IArcaneCommonRequest>(body);
73
68
const upgrade = inventory.Upgrades.id(json.arcane.ItemId.$oid);
74
69
if (json.newRank == -1) {
75
70
// Break down request?
@@ -123,6 +118,7 @@ export const arcaneCommonController: RequestHandler = async (req, res) => {
123
118
};
124
119
125
120
const arcaneLevelCounts = [0, 3, 6, 10, 15, 21];
121
const legacyArcaneLevelCounts = [1, 3, 6, 10];
126
122
127
123
interface IArcaneCommonRequest {
128
124
arcane: {
@@ -755,6 +755,16 @@ export const getInventoryResponse = async (
755
755
}
756
756
}
757
757
758
if (version_compare(buildLabel, gameToBuildVersion["18.18.0"]) < 0) {
759
for (const skin of inventoryResponse.WeaponSkins) {
760
if (skin.UpgradeType) {
761
skin.UpgradeFingerprint = convertToLegacyFingerprint(
762
skin.UpgradeFingerprint || '{"lvl":0}'
763
);
764
}
765
}
766
}
767
758
768
if (version_compare(buildLabel, "2014.02.05.00.00") < 0) {
759
769
// Convert installed mods for pre-U12 builds
760
770
for (const category of equipmentKeys) {