diff --git a/project/src/generators/WeatherGenerator.ts b/project/src/generators/WeatherGenerator.ts index 19627dda..76a3d5a9 100644 --- a/project/src/generators/WeatherGenerator.ts +++ b/project/src/generators/WeatherGenerator.ts @@ -72,9 +72,16 @@ export class WeatherGenerator .getValue(); // Get delta between now and when client connected to server in milliseconds - const deltaMSFromNow = Date.now() - gameStartTimeStampMS; - const acceleratedMS = deltaMSFromNow * (this.weatherConfig.acceleration - 1); // For some reason nodejs moves faster than client time, reducing acceleration by 1 when client is 7 helps - const clientAcceleratedDate = new Date(currentDate.valueOf() + acceleratedMS); + const deltaMSFromNow = currentDate.getTime() - gameStartTimeStampMS; + const acceleratedMS = deltaMSFromNow * (this.weatherConfig.acceleration); + + // Match client side time calculations which start from the current date + connection time, not current time + const locationTime = new Date(gameStartTimeStampMS); + locationTime.setFullYear(currentDate.getFullYear()); + locationTime.setMonth(currentDate.getMonth()); + locationTime.setDate(currentDate.getDate()); + + const clientAcceleratedDate = new Date(locationTime.getTime() + acceleratedMS); return clientAcceleratedDate; }