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

chore: log when worldState time is behind real time + make sure client knows fissures are active (#2562)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2562 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

48e3f324
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +18 -7
Modified src/services/worldStateService.ts +18 -7
@@ -1038,13 +1038,13 @@ const pushVoidStorms = (arr: IVoidStorm[], hour: number): void => {
1038 1038 };
1039 1039
1040 1040 interface ITimeConstraint {
1041 //name: string;
1041 name: string;
1042 1042 isValidTime: (timeSecs: number) => boolean;
1043 1043 getIdealTimeBefore: (timeSecs: number) => number;
1044 1044 }
1045 1045
1046 1046 const eidolonDayConstraint: ITimeConstraint = {
1047 //name: "eidolon day",
1047 name: "eidolon day",
1048 1048 isValidTime: (timeSecs: number): boolean => {
1049 1049 const eidolonEpoch = 1391992660;
1050 1050 const eidolonCycle = Math.trunc((timeSecs - eidolonEpoch) / 9000);
@@ -1062,7 +1062,7 @@ const eidolonDayConstraint: ITimeConstraint = {
1062 1062 };
1063 1063
1064 1064 const eidolonNightConstraint: ITimeConstraint = {
1065 //name: "eidolon night",
1065 name: "eidolon night",
1066 1066 isValidTime: (timeSecs: number): boolean => {
1067 1067 const eidolonEpoch = 1391992660;
1068 1068 const eidolonCycle = Math.trunc((timeSecs - eidolonEpoch) / 9000);
@@ -1089,7 +1089,7 @@ const eidolonNightConstraint: ITimeConstraint = {
1089 1089 };
1090 1090
1091 1091 const venusColdConstraint: ITimeConstraint = {
1092 //name: "venus cold",
1092 name: "venus cold",
1093 1093 isValidTime: (timeSecs: number): boolean => {
1094 1094 const vallisEpoch = 1541837628;
1095 1095 const vallisCycle = Math.trunc((timeSecs - vallisEpoch) / 1600);
@@ -1115,7 +1115,7 @@ const venusColdConstraint: ITimeConstraint = {
1115 1115 };
1116 1116
1117 1117 const venusWarmConstraint: ITimeConstraint = {
1118 //name: "venus warm",
1118 name: "venus warm",
1119 1119 isValidTime: (timeSecs: number): boolean => {
1120 1120 const vallisEpoch = 1541837628;
1121 1121 const vallisCycle = Math.trunc((timeSecs - vallisEpoch) / 1600);
@@ -1321,7 +1321,7 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
1321 1321 });
1322 1322 } else {
1323 1323 constraints.push({
1324 //name: `duviri ${config.worldState.duviriOverride}`,
1324 name: `duviri ${config.worldState.duviriOverride}`,
1325 1325 isValidTime: (timeSecs: number): boolean => {
1326 1326 const moodIndex = Math.trunc(timeSecs / 7200);
1327 1327 return moodIndex % 5 == desiredMood;
@@ -1336,6 +1336,14 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
1336 1336 }
1337 1337 }
1338 1338 const timeSecs = getIdealTimeSatsifyingConstraints(constraints);
1339 if (constraints.length != 0) {
1340 const delta = Math.trunc(Date.now() / 1000) - timeSecs;
1341 if (delta > 1) {
1342 logger.debug(
1343 `reported time is ${delta} seconds behind real time to satisfy selected constraints (${constraints.map(x => x.name).join(", ")})`
1344 );
1345 }
1346 }
1339 1347 const timeMs = timeSecs * 1000;
1340 1348 const day = Math.trunc((timeMs - EPOCH) / 86400000);
1341 1349 const week = Math.trunc(day / 7);
@@ -1823,7 +1831,10 @@ export const populateFissures = async (worldState: IWorldState): Promise<void> =
1823 1831 _id: toOid(fissure._id),
1824 1832 Region: meta.systemIndex + 1,
1825 1833 Seed: 1337,
1826 Activation: toMongoDate(fissure.Activation),
1834 Activation:
1835 fissure.Activation.getTime() < Date.now() // Activation is in the past?
1836 ? { $date: { $numberLong: "1000000000000" } } // Let the client know 'explicitly' to avoid interference from time constraints.
1837 : toMongoDate(fissure.Activation),
1827 1838 Expiry: toMongoDate(fissure.Expiry),
1828 1839 Node: fissure.Node,
1829 1840 MissionType: eMissionType[meta.missionIndex].tag,