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

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

fix: worldState growing with every request (#760)

eafdd9f7
Sainan <sainan@calamity.inc>
提交于

代码差异

2 个文件 +35 -14
Modified src/controllers/dynamic/worldStateController.ts +10 -13
@@ -5,51 +5,48 @@ import { IMongoDate, IOid } from "@/src/types/commonTypes";
5 5
6 6 export const worldStateController: RequestHandler = (req, res) => {
7 7 const worldState: IWorldState = {
8 ...staticWorldState,
9 8 BuildLabel:
10 9 typeof req.query.buildLabel == "string"
11 10 ? req.query.buildLabel.split(" ").join("+")
12 11 : buildConfig.buildLabel,
13 Time: Math.round(Date.now() / 1000)
12 Time: Math.round(Date.now() / 1000),
13 EndlessXpChoices: [],
14 ...staticWorldState
14 15 };
15 16
16 17 const week = Math.trunc(new Date().getTime() / 604800000);
17 18
18 19 // Elite Sanctuary Onslaught cycling every week
19 worldState.NodeOverrides.push({
20 _id: { $oid: "5ad9f9bb6df82a56eabf3d44" },
21 Node: "SolNode802",
22 Seed: week // unfaithful
23 });
20 worldState.NodeOverrides.find(x => x.Node == "SolNode802")!.Seed = week; // unfaithful
24 21
25 22 // Holdfast, Cavia, & Hex bounties cycling every 2.5 hours; unfaithful implementation
26 23 const bountyCycle = Math.trunc(new Date().getTime() / 9000000);
27 24 const bountyCycleStart = bountyCycle * 9000000;
28 25 const bountyCycleEnd = bountyCycleStart + 9000000;
29 worldState.SyndicateMissions.push({
26 worldState.SyndicateMissions[worldState.SyndicateMissions.findIndex(x => x.Tag == "ZarimanSyndicate")] = {
30 27 _id: { $oid: bountyCycleStart.toString(16) + "0000000000000029" },
31 28 Activation: { $date: { $numberLong: bountyCycleStart.toString() } },
32 29 Expiry: { $date: { $numberLong: bountyCycleEnd.toString() } },
33 30 Tag: "ZarimanSyndicate",
34 31 Seed: bountyCycle,
35 32 Nodes: []
36 });
37 worldState.SyndicateMissions.push({
33 };
34 worldState.SyndicateMissions[worldState.SyndicateMissions.findIndex(x => x.Tag == "EntratiLabSyndicate")] = {
38 35 _id: { $oid: bountyCycleStart.toString(16) + "0000000000000004" },
39 36 Activation: { $date: { $numberLong: bountyCycleStart.toString() } },
40 37 Expiry: { $date: { $numberLong: bountyCycleEnd.toString() } },
41 38 Tag: "EntratiLabSyndicate",
42 39 Seed: bountyCycle,
43 40 Nodes: []
44 });
45 worldState.SyndicateMissions.push({
41 };
42 worldState.SyndicateMissions[worldState.SyndicateMissions.findIndex(x => x.Tag == "HexSyndicate")] = {
46 43 _id: { $oid: bountyCycleStart.toString(16) + "0000000000000006" },
47 44 Activation: { $date: { $numberLong: bountyCycleStart.toString(10) } },
48 45 Expiry: { $date: { $numberLong: bountyCycleEnd.toString(10) } },
49 46 Tag: "HexSyndicate",
50 47 Seed: bountyCycle,
51 48 Nodes: []
52 });
49 };
53 50
54 51 // Circuit choices cycling every week
55 52 worldState.EndlessXpChoices.push({
Modified static/fixed_responses/worldState.json +25 -1
@@ -340,6 +340,14 @@
340 340 }
341 341 ]
342 342 },
343 {
344 "_id": { "$oid": "663a71c80000000000000004" },
345 "Activation": { "$date": { "$numberLong": "1715106248403" } },
346 "Expiry": { "$date": { "$numberLong": "2000000000000" } },
347 "Tag": "EntratiLabSyndicate",
348 "Seed": 99562,
349 "Nodes": []
350 },
343 351 {
344 352 "_id": { "$oid": "663a71c80000000000000008" },
345 353 "Activation": { "$date": { "$numberLong": "1715106248403" } },
@@ -471,6 +479,22 @@
471 479 "xpAmounts": [780, 780, 780, 780, 1540]
472 480 }
473 481 ]
482 },
483 {
484 "_id": { "$oid": "663a71c80000000000000029" },
485 "Activation": { "$date": { "$numberLong": "1715106248403" } },
486 "Expiry": { "$date": { "$numberLong": "2000000000000" } },
487 "Tag": "ZarimanSyndicate",
488 "Seed": 99562,
489 "Nodes": []
490 },
491 {
492 "_id": { "$oid": "676b8d340000000000000006" },
493 "Activation": { "$date": { "$numberLong": "1735101748215" } },
494 "Expiry": { "$date": { "$numberLong": "2000000000000" } },
495 "Tag": "HexSyndicate",
496 "Seed": 33872,
497 "Nodes": []
474 498 }
475 499 ],
476 500 "ActiveMissions": [
@@ -666,6 +690,7 @@
666 690 { "_id": { "$oid": "549b18e9b029cef5991d6aec" }, "Node": "EuropaHUB", "Hide": true },
667 691 { "_id": { "$oid": "54a1737aeb658f6cbccf70ff" }, "Node": "ErisHUB", "Hide": true },
668 692 { "_id": { "$oid": "54a736ddec12f80bd6e9e326" }, "Node": "VenusHUB", "Hide": true },
693 { "_id": { "$oid": "5ad9f9bb6df82a56eabf3d44" }, "Node": "SolNode802", "Seed": 9969639 },
669 694 {
670 695 "_id": { "$oid": "5b8817c2bd4f253264d6aa91" },
671 696 "Node": "EarthHUB",
@@ -1078,7 +1103,6 @@
1078 1103 "ConstructionProjects": [],
1079 1104 "TwitchPromos": [],
1080 1105 "ExperimentRecommended": [],
1081 "EndlessXpChoices": [],
1082 1106 "ForceLogoutVersion": 0,
1083 1107 "SeasonInfo": {
1084 1108 "Activation": { "$date": { "$numberLong": "1715796000000" } },