More robust logic for ThisMinute stats

This commit is contained in:
teinarss
2019-08-28 20:20:45 +02:00
committed by reaperrr
parent 6795fb6967
commit 6fe31e44cb

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
@@ -60,6 +61,7 @@ namespace OpenRA.Mods.Common.Traits
public int ArmyValue; public int ArmyValue;
int replayTimestep; int replayTimestep;
int ticks;
public PlayerStatistics(Actor self) { } public PlayerStatistics(Actor self) { }
@@ -86,10 +88,12 @@ namespace OpenRA.Mods.Common.Traits
void ITick.Tick(Actor self) void ITick.Tick(Actor self)
{ {
ticks++;
var timestep = self.World.IsReplay ? replayTimestep : self.World.Timestep; var timestep = self.World.IsReplay ? replayTimestep : self.World.Timestep;
if (timestep * self.World.WorldTick % 60000 == 0) if (ticks * timestep >= 60000)
{ {
ticks = 0;
UpdateEarnedThisMinute(); UpdateEarnedThisMinute();
UpdateArmyThisMinute(); UpdateArmyThisMinute();
} }