Fix a time format bug. Fix subsequent gps bug.

This commit is contained in:
Paul Chote
2010-12-05 23:04:33 +13:00
parent c465a58976
commit d1850e8b4b
2 changed files with 14 additions and 14 deletions

View File

@@ -132,7 +132,7 @@ namespace OpenRA.Widgets
public static string FormatTime(int ticks) public static string FormatTime(int ticks)
{ {
var seconds = ticks / 25; var seconds = (int)Math.Ceiling(ticks / 25f);
var minutes = seconds / 60; var minutes = seconds / 60;
if (minutes >= 60) if (minutes >= 60)

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Mods.RA
{ {
var key = (t.Info.AllowMultiple) ? t.Info.OrderName+"_"+a.ActorID : t.Info.OrderName; var key = (t.Info.AllowMultiple) ? t.Info.OrderName+"_"+a.ActorID : t.Info.OrderName;
Powers[key].Instances.Remove(t); Powers[key].Instances.Remove(t);
if (Powers[key].Instances.Count == 0) if (Powers[key].Instances.Count == 0 && !Powers[key].Disabled)
Powers.Remove(key); Powers.Remove(key);
} }
} }
@@ -96,14 +96,14 @@ namespace OpenRA.Mods.RA
public class SupportPowerInstance public class SupportPowerInstance
{ {
SupportPowerManager Manager; readonly SupportPowerManager Manager;
string Key; readonly string Key;
public List<SupportPower> Instances; public List<SupportPower> Instances;
public int RemainingTime; public int RemainingTime;
public int TotalTime; public int TotalTime;
public bool Active; public bool Active { get; private set; }
public bool Disabled; public bool Disabled { get; private set; }
public SupportPowerInfo Info { get { return Instances.First().Info; } } public SupportPowerInfo Info { get { return Instances.First().Info; } }
public bool Ready { get { return Active && RemainingTime == 0; } } public bool Ready { get { return Active && RemainingTime == 0; } }
@@ -119,23 +119,23 @@ namespace OpenRA.Mods.RA
public void Tick() public void Tick()
{ {
Active = !Disabled && Instances.Any(i => !i.self.TraitsImplementing<IDisable>().Any(d => d.Disabled)); Active = !Disabled && Instances.Any(i => !i.self.TraitsImplementing<IDisable>().Any(d => d.Disabled));
var power = Instances.First();
if (Active) if (Active)
{ {
var power = Instances.First();
if (RemainingTime > 0) --RemainingTime; if (RemainingTime > 0) --RemainingTime;
if (!notifiedCharging) if (!notifiedCharging)
{ {
power.Charging(power.self, Key); power.Charging(power.self, Key);
notifiedCharging = true; notifiedCharging = true;
} }
}
if (RemainingTime == 0
if (RemainingTime == 0 && !notifiedReady)
&& !notifiedReady) {
{ power.Charged(power.self, Key);
power.Charged(power.self, Key); notifiedReady = true;
notifiedReady = true; }
} }
} }