Fix MCV deploy erasing Iron Curtain history.

This commit is contained in:
Paul Chote
2018-07-03 22:11:20 +00:00
parent d5399aaf6b
commit fd49e487ec
5 changed files with 76 additions and 2 deletions

View File

@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Traits
return true;
}
public int GrantCondition(Actor self, object source, int duration = 0)
public int GrantCondition(Actor self, object source, int duration = 0, int remaining = 0)
{
if (!CanGrantCondition(self, source))
return ConditionManager.InvalidConditionToken;
@@ -100,6 +100,11 @@ namespace OpenRA.Mods.Common.Traits
HashSet<int> permanent;
permanentTokens.TryGetValue(source, out permanent);
// Callers can override the amount of time remaining by passing a value
// between 1 and the duration
if (remaining <= 0 || remaining > duration)
remaining = duration;
if (duration > 0)
{
// Check level caps
@@ -137,7 +142,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
var timedToken = new TimedToken(token, self, source, duration);
var timedToken = new TimedToken(token, self, source, remaining);
var index = timedTokens.FindIndex(t => t.Expires >= timedToken.Expires);
if (index >= 0)
timedTokens.Insert(index, timedToken);