fix: Fixing the MP power bonus + seed maintenance
This commit is contained in:
+10
-7
@@ -1,15 +1,18 @@
|
||||
/**
|
||||
* One world seed per UTC-aligned period: floor(utcUnixSeconds / rotationSeconds).
|
||||
* Changing the slot triggers a full grid wipe on the server.
|
||||
* One world seed per epoch-relative period.
|
||||
* slot = floor((nowSec - epochSec) / rotationSeconds).
|
||||
* Changing timing config resets epochSec, which resets the slot to 0.
|
||||
*/
|
||||
export function computeWorldSeedState(rotationSeconds) {
|
||||
const rot = Math.max(60, Math.floor(rotationSeconds));
|
||||
export function computeWorldSeedState(rotationSeconds, epochSec) {
|
||||
const rot = Math.max(1, Math.floor(rotationSeconds));
|
||||
const epoch = Math.max(0, Math.floor(epochSec));
|
||||
const nowSec = Math.floor(Date.now() / 1000);
|
||||
const slot = Math.floor(nowSec / rot);
|
||||
const periodStart = slot * rot;
|
||||
const elapsed = Math.max(0, nowSec - epoch);
|
||||
const slot = Math.floor(elapsed / rot);
|
||||
const periodStart = epoch + slot * rot;
|
||||
const periodEnd = periodStart + rot;
|
||||
return {
|
||||
worldSeed: `swg-${slot}`,
|
||||
worldSeed: `swg-${epoch}-${slot}`,
|
||||
seedSlot: slot,
|
||||
seedPeriodEndsAtUtc: new Date(periodEnd * 1000).toISOString(),
|
||||
seedPeriodStartsAtUtc: new Date(periodStart * 1000).toISOString(),
|
||||
|
||||
Reference in New Issue
Block a user