From 48e3f324e22cf921ab76082c45acfbaa3f983673 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Wed, 30 Jul 2025 01:49:34 -0700 Subject: [PATCH] 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> --- src/services/worldStateService.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/services/worldStateService.ts b/src/services/worldStateService.ts index 7f5268c94..ac4f9b5de 100644 --- a/src/services/worldStateService.ts +++ b/src/services/worldStateService.ts @@ -1038,13 +1038,13 @@ const pushVoidStorms = (arr: IVoidStorm[], hour: number): void => { }; interface ITimeConstraint { - //name: string; + name: string; isValidTime: (timeSecs: number) => boolean; getIdealTimeBefore: (timeSecs: number) => number; } const eidolonDayConstraint: ITimeConstraint = { - //name: "eidolon day", + name: "eidolon day", isValidTime: (timeSecs: number): boolean => { const eidolonEpoch = 1391992660; const eidolonCycle = Math.trunc((timeSecs - eidolonEpoch) / 9000); @@ -1062,7 +1062,7 @@ const eidolonDayConstraint: ITimeConstraint = { }; const eidolonNightConstraint: ITimeConstraint = { - //name: "eidolon night", + name: "eidolon night", isValidTime: (timeSecs: number): boolean => { const eidolonEpoch = 1391992660; const eidolonCycle = Math.trunc((timeSecs - eidolonEpoch) / 9000); @@ -1089,7 +1089,7 @@ const eidolonNightConstraint: ITimeConstraint = { }; const venusColdConstraint: ITimeConstraint = { - //name: "venus cold", + name: "venus cold", isValidTime: (timeSecs: number): boolean => { const vallisEpoch = 1541837628; const vallisCycle = Math.trunc((timeSecs - vallisEpoch) / 1600); @@ -1115,7 +1115,7 @@ const venusColdConstraint: ITimeConstraint = { }; const venusWarmConstraint: ITimeConstraint = { - //name: "venus warm", + name: "venus warm", isValidTime: (timeSecs: number): boolean => { const vallisEpoch = 1541837628; const vallisCycle = Math.trunc((timeSecs - vallisEpoch) / 1600); @@ -1321,7 +1321,7 @@ export const getWorldState = (buildLabel?: string): IWorldState => { }); } else { constraints.push({ - //name: `duviri ${config.worldState.duviriOverride}`, + name: `duviri ${config.worldState.duviriOverride}`, isValidTime: (timeSecs: number): boolean => { const moodIndex = Math.trunc(timeSecs / 7200); return moodIndex % 5 == desiredMood; @@ -1336,6 +1336,14 @@ export const getWorldState = (buildLabel?: string): IWorldState => { } } const timeSecs = getIdealTimeSatsifyingConstraints(constraints); + if (constraints.length != 0) { + const delta = Math.trunc(Date.now() / 1000) - timeSecs; + if (delta > 1) { + logger.debug( + `reported time is ${delta} seconds behind real time to satisfy selected constraints (${constraints.map(x => x.name).join(", ")})` + ); + } + } const timeMs = timeSecs * 1000; const day = Math.trunc((timeMs - EPOCH) / 86400000); const week = Math.trunc(day / 7); @@ -1823,7 +1831,10 @@ export const populateFissures = async (worldState: IWorldState): Promise = _id: toOid(fissure._id), Region: meta.systemIndex + 1, Seed: 1337, - Activation: toMongoDate(fissure.Activation), + Activation: + fissure.Activation.getTime() < Date.now() // Activation is in the past? + ? { $date: { $numberLong: "1000000000000" } } // Let the client know 'explicitly' to avoid interference from time constraints. + : toMongoDate(fissure.Activation), Expiry: toMongoDate(fissure.Expiry), Node: fissure.Node, MissionType: eMissionType[meta.missionIndex].tag,