Fix RCS1061
This commit is contained in:
@@ -980,6 +980,9 @@ dotnet_diagnostic.RCS1058.severity = warning
|
|||||||
# Avoid locking on publicly accessible instance.
|
# Avoid locking on publicly accessible instance.
|
||||||
dotnet_diagnostic.RCS1059.severity = warning
|
dotnet_diagnostic.RCS1059.severity = warning
|
||||||
|
|
||||||
|
# Merge 'if' with nested 'if'.
|
||||||
|
dotnet_diagnostic.RCS1061.severity = warning
|
||||||
|
|
||||||
# Remove empty 'finally' clause.
|
# Remove empty 'finally' clause.
|
||||||
dotnet_diagnostic.RCS1066.severity = warning
|
dotnet_diagnostic.RCS1066.severity = warning
|
||||||
|
|
||||||
|
|||||||
@@ -195,12 +195,12 @@ namespace OpenRA
|
|||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
var parts = value.Split(SplitComma);
|
var parts = value.Split(SplitComma);
|
||||||
if (parts.Length == 3)
|
if (parts.Length == 3
|
||||||
{
|
&& WDist.TryParse(parts[0], out var rx)
|
||||||
if (WDist.TryParse(parts[0], out var rx) && WDist.TryParse(parts[1], out var ry) && WDist.TryParse(parts[2], out var rz))
|
&& WDist.TryParse(parts[1], out var ry)
|
||||||
|
&& WDist.TryParse(parts[2], out var rz))
|
||||||
return new WVec(rx, ry, rz);
|
return new WVec(rx, ry, rz);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return InvalidValueAction(value, fieldType, fieldName);
|
return InvalidValueAction(value, fieldType, fieldName);
|
||||||
}
|
}
|
||||||
@@ -235,14 +235,12 @@ namespace OpenRA
|
|||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
var parts = value.Split(SplitComma);
|
var parts = value.Split(SplitComma);
|
||||||
if (parts.Length == 3)
|
if (parts.Length == 3
|
||||||
{
|
&& WDist.TryParse(parts[0], out var rx)
|
||||||
if (WDist.TryParse(parts[0], out var rx)
|
|
||||||
&& WDist.TryParse(parts[1], out var ry)
|
&& WDist.TryParse(parts[1], out var ry)
|
||||||
&& WDist.TryParse(parts[2], out var rz))
|
&& WDist.TryParse(parts[2], out var rz))
|
||||||
return new WPos(rx, ry, rz);
|
return new WPos(rx, ry, rz);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return InvalidValueAction(value, fieldType, fieldName);
|
return InvalidValueAction(value, fieldType, fieldName);
|
||||||
}
|
}
|
||||||
@@ -259,14 +257,12 @@ namespace OpenRA
|
|||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
var parts = value.Split(SplitComma);
|
var parts = value.Split(SplitComma);
|
||||||
if (parts.Length == 3)
|
if (parts.Length == 3
|
||||||
{
|
&& Exts.TryParseInt32Invariant(parts[0], out var rr)
|
||||||
if (Exts.TryParseInt32Invariant(parts[0], out var rr)
|
|
||||||
&& Exts.TryParseInt32Invariant(parts[1], out var rp)
|
&& Exts.TryParseInt32Invariant(parts[1], out var rp)
|
||||||
&& Exts.TryParseInt32Invariant(parts[2], out var ry))
|
&& Exts.TryParseInt32Invariant(parts[2], out var ry))
|
||||||
return new WRot(new WAngle(rr), new WAngle(rp), new WAngle(ry));
|
return new WRot(new WAngle(rr), new WAngle(rp), new WAngle(ry));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return InvalidValueAction(value, fieldType, fieldName);
|
return InvalidValueAction(value, fieldType, fieldName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,15 +226,12 @@ namespace OpenRA.FileSystem
|
|||||||
public bool TryOpen(string filename, out Stream s)
|
public bool TryOpen(string filename, out Stream s)
|
||||||
{
|
{
|
||||||
var explicitSplit = filename.IndexOf('|');
|
var explicitSplit = filename.IndexOf('|');
|
||||||
if (explicitSplit > 0)
|
if (explicitSplit > 0 && explicitMounts.TryGetValue(filename[..explicitSplit], out var explicitPackage))
|
||||||
{
|
|
||||||
if (explicitMounts.TryGetValue(filename[..explicitSplit], out var explicitPackage))
|
|
||||||
{
|
{
|
||||||
s = explicitPackage.GetStream(filename[(explicitSplit + 1)..]);
|
s = explicitPackage.GetStream(filename[(explicitSplit + 1)..]);
|
||||||
if (s != null)
|
if (s != null)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
s = GetFromCache(filename);
|
s = GetFromCache(filename);
|
||||||
if (s != null)
|
if (s != null)
|
||||||
@@ -262,9 +259,9 @@ namespace OpenRA.FileSystem
|
|||||||
public bool Exists(string filename)
|
public bool Exists(string filename)
|
||||||
{
|
{
|
||||||
var explicitSplit = filename.IndexOf('|');
|
var explicitSplit = filename.IndexOf('|');
|
||||||
if (explicitSplit > 0)
|
if (explicitSplit > 0 &&
|
||||||
if (explicitMounts.TryGetValue(filename[..explicitSplit], out var explicitPackage))
|
explicitMounts.TryGetValue(filename[..explicitSplit], out var explicitPackage) &&
|
||||||
if (explicitPackage.Contains(filename[(explicitSplit + 1)..]))
|
explicitPackage.Contains(filename[(explicitSplit + 1)..]))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return fileIndex.ContainsKey(filename);
|
return fileIndex.ContainsKey(filename);
|
||||||
|
|||||||
@@ -169,8 +169,7 @@ namespace OpenRA.Network
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Games advertised using the old API calculated the play time locally
|
// Games advertised using the old API calculated the play time locally
|
||||||
if (State == 2 && PlayTime < 0)
|
if (State == 2 && PlayTime < 0 && DateTime.TryParse(Started, out var startTime))
|
||||||
if (DateTime.TryParse(Started, out var startTime))
|
|
||||||
PlayTime = (int)(DateTime.UtcNow - startTime).TotalSeconds;
|
PlayTime = (int)(DateTime.UtcNow - startTime).TotalSeconds;
|
||||||
|
|
||||||
var externalKey = ExternalMod.MakeKey(Mod, Version);
|
var externalKey = ExternalMod.MakeKey(Mod, Version);
|
||||||
|
|||||||
@@ -40,14 +40,11 @@ namespace OpenRA.Scripting
|
|||||||
t = nullable;
|
t = nullable;
|
||||||
|
|
||||||
// Value wraps a CLR object
|
// Value wraps a CLR object
|
||||||
if (value.TryGetClrObject(out var temp))
|
if (value.TryGetClrObject(out var temp) && temp.GetType() == t)
|
||||||
{
|
|
||||||
if (temp.GetType() == t)
|
|
||||||
{
|
{
|
||||||
clrObject = temp;
|
clrObject = temp;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (value is LuaNil && !t.IsValueType)
|
if (value is LuaNil && !t.IsValueType)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -153,8 +153,7 @@ namespace OpenRA.Server
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Regularly check player ping
|
// Regularly check player ping
|
||||||
if (lastPingSent.ElapsedMilliseconds > 1000)
|
if (lastPingSent.ElapsedMilliseconds > 1000 && TrySendData(CreatePingFrame()))
|
||||||
if (TrySendData(CreatePingFrame()))
|
|
||||||
lastPingSent.Restart();
|
lastPingSent.Restart();
|
||||||
|
|
||||||
// Send all data immediately, we will block again on read
|
// Send all data immediately, we will block again on read
|
||||||
|
|||||||
@@ -750,12 +750,10 @@ namespace OpenRA.Support
|
|||||||
public void Push(Expression expression, ExpressionType type)
|
public void Push(Expression expression, ExpressionType type)
|
||||||
{
|
{
|
||||||
expressions.Add(expression);
|
expressions.Add(expression);
|
||||||
if (type == ExpressionType.Int)
|
if (type == ExpressionType.Int && expression.Type != typeof(int))
|
||||||
if (expression.Type != typeof(int))
|
|
||||||
throw new InvalidOperationException($"Expected System.Int type instead of {expression.Type} for {expression}");
|
throw new InvalidOperationException($"Expected System.Int type instead of {expression.Type} for {expression}");
|
||||||
|
|
||||||
if (type == ExpressionType.Bool)
|
if (type == ExpressionType.Bool && expression.Type != typeof(bool))
|
||||||
if (expression.Type != typeof(bool))
|
|
||||||
throw new InvalidOperationException($"Expected System.Boolean type instead of {expression.Type} for {expression}");
|
throw new InvalidOperationException($"Expected System.Boolean type instead of {expression.Type} for {expression}");
|
||||||
types.Add(type);
|
types.Add(type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -312,8 +312,7 @@ namespace OpenRA.Widgets
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
foreach (var child in Children)
|
foreach (var child in Children)
|
||||||
if (child.IsVisible())
|
if (child.IsVisible() && child.EventBoundsContains(location))
|
||||||
if (child.EventBoundsContains(location))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -378,13 +378,10 @@ namespace OpenRA.Mods.Cnc.FileFormats
|
|||||||
if (tmp > 0)
|
if (tmp > 0)
|
||||||
{
|
{
|
||||||
MulBignumWord(esi, globOne, tmp, 2 * len);
|
MulBignumWord(esi, globOne, tmp, 2 * len);
|
||||||
if ((*edi & 0x8000) == 0)
|
if ((*edi & 0x8000) == 0 && SubBigNum((uint*)esi, (uint*)esi, g1, 0, (int)len) != 0)
|
||||||
{
|
|
||||||
if (SubBigNum((uint*)esi, (uint*)esi, g1, 0, (int)len) != 0)
|
|
||||||
(*edi)--;
|
(*edi)--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
NegBigNum(globTwo, len);
|
NegBigNum(globTwo, len);
|
||||||
DecBigNum(globTwo, len);
|
DecBigNum(globTwo, len);
|
||||||
|
|||||||
@@ -235,8 +235,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the global mix database
|
// Load the global mix database
|
||||||
if (globalFilenames == null)
|
if (globalFilenames == null && context.TryOpen("global mix database.dat", out var mixDatabase))
|
||||||
if (context.TryOpen("global mix database.dat", out var mixDatabase))
|
|
||||||
using (var db = new XccGlobalDatabase(mixDatabase))
|
using (var db = new XccGlobalDatabase(mixDatabase))
|
||||||
globalFilenames = db.Entries.ToHashSet().ToArray();
|
globalFilenames = db.Entries.ToHashSet().ToArray();
|
||||||
|
|
||||||
|
|||||||
@@ -60,15 +60,12 @@ namespace OpenRA.Mods.Cnc.Graphics
|
|||||||
var tilesetNode = node.Value.NodeWithKeyOrDefault(tileset);
|
var tilesetNode = node.Value.NodeWithKeyOrDefault(tileset);
|
||||||
if (tilesetNode != null)
|
if (tilesetNode != null)
|
||||||
{
|
{
|
||||||
if (frames == null)
|
if (frames == null && LoadField<string>("Length", null, data) != "*")
|
||||||
{
|
|
||||||
if (LoadField<string>("Length", null, data) != "*")
|
|
||||||
{
|
{
|
||||||
var subStart = LoadField("Start", 0, data);
|
var subStart = LoadField("Start", 0, data);
|
||||||
var subLength = LoadField("Length", 1, data);
|
var subLength = LoadField("Length", 1, data);
|
||||||
frames = Exts.MakeArray(subLength, i => subStart + i);
|
frames = Exts.MakeArray(subLength, i => subStart + i);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return new[] { new ReservationInfo(tilesetNode.Value.Value, frames, frames, tilesetNode.Location) };
|
return new[] { new ReservationInfo(tilesetNode.Value.Value, frames, frames, tilesetNode.Location) };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,14 +203,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
mad.initiated = true;
|
mad.initiated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++ticks % mad.info.ThumpInterval == 0)
|
if (++ticks % mad.info.ThumpInterval == 0 && mad.info.ThumpDamageWeapon != null)
|
||||||
{
|
|
||||||
if (mad.info.ThumpDamageWeapon != null)
|
|
||||||
{
|
{
|
||||||
// Use .FromPos since this weapon needs to affect more than just the MadTank actor
|
// Use .FromPos since this weapon needs to affect more than just the MadTank actor
|
||||||
mad.info.ThumpDamageWeaponInfo.Impact(Target.FromPos(self.CenterPosition), self);
|
mad.info.ThumpDamageWeaponInfo.Impact(Target.FromPos(self.CenterPosition), self);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ticks == mad.info.ChargeDelay)
|
if (ticks == mad.info.ChargeDelay)
|
||||||
Game.Sound.Play(SoundType.World, mad.info.ChargeSound, self.CenterPosition);
|
Game.Sound.Play(SoundType.World, mad.info.ChargeSound, self.CenterPosition);
|
||||||
|
|||||||
@@ -441,13 +441,11 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
// Only import the top-left cell of multi-celled overlays
|
// Only import the top-left cell of multi-celled overlays
|
||||||
// Returning true here means this is a part of a bigger overlay that has already been handled.
|
// Returning true here means this is a part of a bigger overlay that has already been handled.
|
||||||
var aboveType = overlayPack[overlayIndex[cell - new CVec(1, 0)]];
|
var aboveType = overlayPack[overlayIndex[cell - new CVec(1, 0)]];
|
||||||
if (shape.Width > 1 && aboveType != 0xFF)
|
if (shape.Width > 1 && aboveType != 0xFF && OverlayToActor.TryGetValue(aboveType, out var a) && a == actorType)
|
||||||
if (OverlayToActor.TryGetValue(aboveType, out var a) && a == actorType)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var leftType = overlayPack[overlayIndex[cell - new CVec(0, 1)]];
|
var leftType = overlayPack[overlayIndex[cell - new CVec(0, 1)]];
|
||||||
if (shape.Height > 1 && leftType != 0xFF)
|
if (shape.Height > 1 && leftType != 0xFF && OverlayToActor.TryGetValue(leftType, out var l) && l == actorType)
|
||||||
if (OverlayToActor.TryGetValue(leftType, out var a) && a == actorType)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -282,13 +282,11 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
// Only import the top-left cell of multi-celled overlays
|
// Only import the top-left cell of multi-celled overlays
|
||||||
// Returning true here means this is a part of a bigger overlay that has already been handled.
|
// Returning true here means this is a part of a bigger overlay that has already been handled.
|
||||||
var aboveType = overlayPack[overlayIndex[cell - new CVec(1, 0)]];
|
var aboveType = overlayPack[overlayIndex[cell - new CVec(1, 0)]];
|
||||||
if (shape.Width > 1 && aboveType != 0xFF)
|
if (shape.Width > 1 && aboveType != 0xFF && OverlayToActor.TryGetValue(aboveType, out var a) && a == actorType)
|
||||||
if (OverlayToActor.TryGetValue(aboveType, out var a) && a == actorType)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var leftType = overlayPack[overlayIndex[cell - new CVec(0, 1)]];
|
var leftType = overlayPack[overlayIndex[cell - new CVec(0, 1)]];
|
||||||
if (shape.Height > 1 && leftType != 0xFF)
|
if (shape.Height > 1 && leftType != 0xFF && OverlayToActor.TryGetValue(leftType, out var l) && l == actorType)
|
||||||
if (OverlayToActor.TryGetValue(leftType, out var a) && a == actorType)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,15 +58,12 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
var tilesetNode = node.Value.NodeWithKeyOrDefault(tileset);
|
var tilesetNode = node.Value.NodeWithKeyOrDefault(tileset);
|
||||||
if (tilesetNode != null)
|
if (tilesetNode != null)
|
||||||
{
|
{
|
||||||
if (frames == null)
|
if (frames == null && LoadField<string>("Length", null, data) != "*")
|
||||||
{
|
|
||||||
if (LoadField<string>("Length", null, data) != "*")
|
|
||||||
{
|
{
|
||||||
var subStart = LoadField("Start", 0, data);
|
var subStart = LoadField("Start", 0, data);
|
||||||
var subLength = LoadField("Length", 1, data);
|
var subLength = LoadField("Length", 1, data);
|
||||||
frames = Exts.MakeArray(subLength, i => subStart + i);
|
frames = Exts.MakeArray(subLength, i => subStart + i);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return new[] { new ReservationInfo(tilesetNode.Value.Value, frames, frames, tilesetNode.Location) };
|
return new[] { new ReservationInfo(tilesetNode.Value.Value, frames, frames, tilesetNode.Location) };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,8 +109,9 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (var n in node.Value.Nodes)
|
foreach (var n in node.Value.Nodes)
|
||||||
if (checkArgKeys.Contains(n.Key))
|
if (checkArgKeys.Contains(n.Key) &&
|
||||||
if (!namedKeys.Contains(n.Value.Value) && !Hotkey.TryParse(n.Value.Value, out var unused))
|
!namedKeys.Contains(n.Value.Value) &&
|
||||||
|
!Hotkey.TryParse(n.Value.Value, out var unused))
|
||||||
emitError($"{filename} {node.Value.Value}:{n.Key} refers to a Key named `{n.Value.Value}` that does not exist.");
|
emitError($"{filename} {node.Value.Value}:{n.Key} refers to a Key named `{n.Value.Value}` that does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (!playerNames.Contains(ownerName))
|
if (!playerNames.Contains(ownerName))
|
||||||
emitError($"Actor `{kv.Key}` is owned by unknown player `{ownerName}`.");
|
emitError($"Actor `{kv.Key}` is owned by unknown player `{ownerName}`.");
|
||||||
|
|
||||||
if (actorsWithRequiredOwner.TryGetValue(kv.Value.Value, out var info))
|
if (actorsWithRequiredOwner.TryGetValue(kv.Value.Value, out var info) && !info.ValidOwnerNames.Contains(ownerName))
|
||||||
if (!info.ValidOwnerNames.Contains(ownerName))
|
|
||||||
emitError($"Actor `{kv.Key}` owner `{ownerName}` is not one of ValidOwnerNames: {info.ValidOwnerNames.JoinWith(", ")}");
|
emitError($"Actor `{kv.Key}` owner `{ownerName}` is not one of ValidOwnerNames: {info.ValidOwnerNames.JoinWith(", ")}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -256,8 +256,8 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (element is Placeable placeable)
|
if (element is Placeable placeable)
|
||||||
{
|
{
|
||||||
var expression = placeable.Expression;
|
var expression = placeable.Expression;
|
||||||
if (expression is IInlineExpression inlineExpression)
|
if (expression is IInlineExpression inlineExpression &&
|
||||||
if (inlineExpression is VariableReference variableReference)
|
inlineExpression is VariableReference variableReference)
|
||||||
CheckVariableReference(variableReference.Id.Name.ToString(), key, attribute, emitWarning, file);
|
CheckVariableReference(variableReference.Id.Name.ToString(), key, attribute, emitWarning, file);
|
||||||
|
|
||||||
if (expression is SelectExpression selectExpression)
|
if (expression is SelectExpression selectExpression)
|
||||||
@@ -269,8 +269,8 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (variantElement is Placeable variantPlaceable)
|
if (variantElement is Placeable variantPlaceable)
|
||||||
{
|
{
|
||||||
var variantExpression = variantPlaceable.Expression;
|
var variantExpression = variantPlaceable.Expression;
|
||||||
if (variantExpression is IInlineExpression variantInlineExpression)
|
if (variantExpression is IInlineExpression variantInlineExpression &&
|
||||||
if (variantInlineExpression is VariableReference variantVariableReference)
|
variantInlineExpression is VariableReference variantVariableReference)
|
||||||
CheckVariableReference(variantVariableReference.Id.Name.ToString(), key, attribute, emitWarning, file);
|
CheckVariableReference(variantVariableReference.Id.Name.ToString(), key, attribute, emitWarning, file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -377,8 +377,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
// If the impact position is within any actor's HitShape, we have a direct hit
|
// If the impact position is within any actor's HitShape, we have a direct hit
|
||||||
// PERF: Avoid using TraitsImplementing<HitShape> that needs to find the actor in the trait dictionary.
|
// PERF: Avoid using TraitsImplementing<HitShape> that needs to find the actor in the trait dictionary.
|
||||||
foreach (var targetPos in victim.EnabledTargetablePositions)
|
foreach (var targetPos in victim.EnabledTargetablePositions)
|
||||||
if (targetPos is HitShape h)
|
if (targetPos is HitShape h && h.DistanceFromEdge(victim, pos).Length <= 0)
|
||||||
if (h.DistanceFromEdge(victim, pos).Length <= 0)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,8 +94,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var pos = self.CenterPosition;
|
var pos = self.CenterPosition;
|
||||||
var armaments = ChooseArmamentsForTarget(target, forceAttack);
|
var armaments = ChooseArmamentsForTarget(target, forceAttack);
|
||||||
foreach (var a in armaments)
|
foreach (var a in armaments)
|
||||||
if (target.IsInRange(pos, a.MaxRange()) && (a.Weapon.MinRange == WDist.Zero || !target.IsInRange(pos, a.Weapon.MinRange)))
|
if (target.IsInRange(pos, a.MaxRange()) &&
|
||||||
if (TargetInFiringArc(self, target, Info.FacingTolerance))
|
(a.Weapon.MinRange == WDist.Zero || !target.IsInRange(pos, a.Weapon.MinRange)) &&
|
||||||
|
TargetInFiringArc(self, target, Info.FacingTolerance))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -247,14 +247,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
a => a.TraitInfos<PowerInfo>().Where(i => i.EnabledByDefault).Sum(p => p.Amount));
|
a => a.TraitInfos<PowerInfo>().Where(i => i.EnabledByDefault).Sum(p => p.Amount));
|
||||||
|
|
||||||
// First priority is to get out of a low power situation
|
// First priority is to get out of a low power situation
|
||||||
if (playerPower != null && playerPower.ExcessPower < minimumExcessPower)
|
if (playerPower != null && playerPower.ExcessPower < minimumExcessPower &&
|
||||||
{
|
power != null && power.TraitInfos<PowerInfo>().Where(i => i.EnabledByDefault).Sum(p => p.Amount) > 0)
|
||||||
if (power != null && power.TraitInfos<PowerInfo>().Where(i => i.EnabledByDefault).Sum(p => p.Amount) > 0)
|
|
||||||
{
|
{
|
||||||
AIUtils.BotDebug("{0} decided to build {1}: Priority override (low power)", queue.Actor.Owner, power.Name);
|
AIUtils.BotDebug("{0} decided to build {1}: Priority override (low power)", queue.Actor.Owner, power.Name);
|
||||||
return power;
|
return power;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Next is to build up a strong economy
|
// Next is to build up a strong economy
|
||||||
if (!baseBuilder.HasAdequateRefineryCount)
|
if (!baseBuilder.HasAdequateRefineryCount)
|
||||||
|
|||||||
@@ -34,9 +34,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var rb = self.TraitOrDefault<RepairableBuilding>();
|
var rb = self.TraitOrDefault<RepairableBuilding>();
|
||||||
if (rb != null)
|
if (rb != null && e.DamageState > DamageState.Light && e.PreviousDamageState <= DamageState.Light && !rb.RepairActive)
|
||||||
{
|
|
||||||
if (e.DamageState > DamageState.Light && e.PreviousDamageState <= DamageState.Light && !rb.RepairActive)
|
|
||||||
{
|
{
|
||||||
AIUtils.BotDebug("{0} noticed damage {1} {2}->{3}, repairing.",
|
AIUtils.BotDebug("{0} noticed damage {1} {2}->{3}, repairing.",
|
||||||
self.Owner, self, e.PreviousDamageState, e.DamageState);
|
self.Owner, self, e.PreviousDamageState, e.DamageState);
|
||||||
@@ -44,5 +42,4 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,11 +75,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
// Timed tokens do not count towards the source cap: the condition with the shortest
|
// Timed tokens do not count towards the source cap: the condition with the shortest
|
||||||
// remaining duration can always be revoked to make room.
|
// remaining duration can always be revoked to make room.
|
||||||
if (Info.SourceCap > 0)
|
if (Info.SourceCap > 0 &&
|
||||||
if (permanentTokens.TryGetValue(source, out var permanentTokensForSource) && permanentTokensForSource.Count >= Info.SourceCap)
|
permanentTokens.TryGetValue(source, out var permanentTokensForSource) &&
|
||||||
|
permanentTokensForSource.Count >= Info.SourceCap)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (Info.TotalCap > 0 && permanentTokens.Values.Sum(t => t.Count) >= Info.TotalCap)
|
if (Info.TotalCap > 0 &&
|
||||||
|
permanentTokens.Values.Sum(t => t.Count) >= Info.TotalCap)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -93,28 +93,33 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
static bool TargetChanged(in Target lastTarget, in Target target)
|
static bool TargetChanged(in Target lastTarget, in Target target)
|
||||||
{
|
{
|
||||||
// Invalidate reveal changing the target.
|
// Invalidate reveal changing the target.
|
||||||
if (lastTarget.Type == TargetType.FrozenActor && target.Type == TargetType.Actor)
|
if (lastTarget.Type == TargetType.FrozenActor &&
|
||||||
if (lastTarget.FrozenActor.Actor == target.Actor)
|
target.Type == TargetType.Actor &&
|
||||||
|
lastTarget.FrozenActor.Actor == target.Actor)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (lastTarget.Type == TargetType.Actor && target.Type == TargetType.FrozenActor)
|
if (lastTarget.Type == TargetType.Actor &&
|
||||||
if (target.FrozenActor.Actor == lastTarget.Actor)
|
target.Type == TargetType.FrozenActor &&
|
||||||
|
target.FrozenActor.Actor == lastTarget.Actor)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (lastTarget.Type != target.Type)
|
if (lastTarget.Type != target.Type)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Invalidate attacking different targets with shared target types.
|
// Invalidate attacking different targets with shared target types.
|
||||||
if (lastTarget.Type == TargetType.Actor && target.Type == TargetType.Actor)
|
if (lastTarget.Type == TargetType.Actor &&
|
||||||
if (lastTarget.Actor != target.Actor)
|
target.Type == TargetType.Actor &&
|
||||||
|
lastTarget.Actor != target.Actor)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (lastTarget.Type == TargetType.FrozenActor && target.Type == TargetType.FrozenActor)
|
if (lastTarget.Type == TargetType.FrozenActor &&
|
||||||
if (lastTarget.FrozenActor != target.FrozenActor)
|
target.Type == TargetType.FrozenActor &&
|
||||||
|
lastTarget.FrozenActor != target.FrozenActor)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (lastTarget.Type == TargetType.Terrain && target.Type == TargetType.Terrain)
|
if (lastTarget.Type == TargetType.Terrain &&
|
||||||
if (lastTarget.CenterPosition != target.CenterPosition)
|
target.Type == TargetType.Terrain &&
|
||||||
|
lastTarget.CenterPosition != target.CenterPosition)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void INotifyDockClient.Docked(Actor self, Actor host)
|
void INotifyDockClient.Docked(Actor self, Actor host)
|
||||||
{
|
{
|
||||||
if (info.Condition != null && (info.DockHostNames == null || info.DockHostNames.Contains(host.Info.Name)))
|
if (info.Condition != null &&
|
||||||
{
|
(info.DockHostNames == null || info.DockHostNames.Contains(host.Info.Name)) &&
|
||||||
if (token == Actor.InvalidConditionToken)
|
token == Actor.InvalidConditionToken)
|
||||||
{
|
{
|
||||||
if (delayedtoken == Actor.InvalidConditionToken)
|
if (delayedtoken == Actor.InvalidConditionToken)
|
||||||
token = self.GrantCondition(info.Condition);
|
token = self.GrantCondition(info.Condition);
|
||||||
@@ -61,7 +61,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void INotifyDockClient.Undocked(Actor self, Actor host)
|
void INotifyDockClient.Undocked(Actor self, Actor host)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void INotifyDockHost.Docked(Actor self, Actor client)
|
void INotifyDockHost.Docked(Actor self, Actor client)
|
||||||
{
|
{
|
||||||
if (info.Condition != null && (info.DockClientNames == null || info.DockClientNames.Contains(client.Info.Name)))
|
if (info.Condition != null &&
|
||||||
{
|
(info.DockClientNames == null || info.DockClientNames.Contains(client.Info.Name)) &&
|
||||||
if (token == Actor.InvalidConditionToken)
|
token == Actor.InvalidConditionToken)
|
||||||
{
|
{
|
||||||
if (delayedtoken == Actor.InvalidConditionToken)
|
if (delayedtoken == Actor.InvalidConditionToken)
|
||||||
token = self.GrantCondition(info.Condition);
|
token = self.GrantCondition(info.Condition);
|
||||||
@@ -61,7 +61,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void INotifyDockHost.Undocked(Actor self, Actor client)
|
void INotifyDockHost.Undocked(Actor self, Actor client)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -97,14 +97,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var palettePresetRows = 2;
|
var palettePresetRows = 2;
|
||||||
var paletteCustomRows = 1;
|
var paletteCustomRows = 1;
|
||||||
|
|
||||||
if (logicArgs.TryGetValue("PaletteColumns", out var yaml))
|
if (logicArgs.TryGetValue("PaletteColumns", out var yaml) && !int.TryParse(yaml.Value, out paletteCols))
|
||||||
if (!int.TryParse(yaml.Value, out paletteCols))
|
|
||||||
throw new YamlException($"Invalid value for PaletteColumns: {yaml.Value}");
|
throw new YamlException($"Invalid value for PaletteColumns: {yaml.Value}");
|
||||||
if (logicArgs.TryGetValue("PalettePresetRows", out yaml))
|
if (logicArgs.TryGetValue("PalettePresetRows", out yaml) && !int.TryParse(yaml.Value, out palettePresetRows))
|
||||||
if (!int.TryParse(yaml.Value, out palettePresetRows))
|
|
||||||
throw new YamlException($"Invalid value for PalettePresetRows: {yaml.Value}");
|
throw new YamlException($"Invalid value for PalettePresetRows: {yaml.Value}");
|
||||||
if (logicArgs.TryGetValue("PaletteCustomRows", out yaml))
|
if (logicArgs.TryGetValue("PaletteCustomRows", out yaml) && !int.TryParse(yaml.Value, out paletteCustomRows))
|
||||||
if (!int.TryParse(yaml.Value, out paletteCustomRows))
|
|
||||||
throw new YamlException($"Invalid value for PaletteCustomRows: {yaml.Value}");
|
throw new YamlException($"Invalid value for PaletteCustomRows: {yaml.Value}");
|
||||||
|
|
||||||
var presetColors = colorManager.PresetColors;
|
var presetColors = colorManager.PresetColors;
|
||||||
|
|||||||
@@ -140,16 +140,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for duplicate actor ID
|
// Check for duplicate actor ID
|
||||||
if (!CurrentActor.ID.Equals(actorId, StringComparison.OrdinalIgnoreCase))
|
if (!CurrentActor.ID.Equals(actorId, StringComparison.OrdinalIgnoreCase) && editorActorLayer[actorId] != null)
|
||||||
{
|
|
||||||
if (editorActorLayer[actorId] != null)
|
|
||||||
{
|
{
|
||||||
nextActorIDStatus = ActorIDStatus.Duplicate;
|
nextActorIDStatus = ActorIDStatus.Duplicate;
|
||||||
actorIDErrorLabel.Text = TranslationProvider.GetString(DuplicateActorId);
|
actorIDErrorLabel.Text = TranslationProvider.GetString(DuplicateActorId);
|
||||||
actorIDErrorLabel.Visible = true;
|
actorIDErrorLabel.Visible = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SetActorID(actorId);
|
SetActorID(actorId);
|
||||||
nextActorIDStatus = ActorIDStatus.Normal;
|
nextActorIDStatus = ActorIDStatus.Normal;
|
||||||
|
|||||||
@@ -100,9 +100,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
badgesVisible = false;
|
badgesVisible = false;
|
||||||
|
|
||||||
if (localProfile.State == LocalPlayerProfile.LinkState.Linked)
|
if (localProfile.State == LocalPlayerProfile.LinkState.Linked && localProfile.ProfileData.Badges.Count > 0)
|
||||||
{
|
|
||||||
if (localProfile.ProfileData.Badges.Count > 0)
|
|
||||||
{
|
{
|
||||||
Func<int, int> negotiateWidth = _ => widget.Get("PROFILE_HEADER").Bounds.Width;
|
Func<int, int> negotiateWidth = _ => widget.Get("PROFILE_HEADER").Bounds.Width;
|
||||||
|
|
||||||
@@ -122,7 +120,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
badgesVisible = true;
|
badgesVisible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ui.ResetTooltips();
|
Ui.ResetTooltips();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var keyhandler = widget.Get<LogicKeyListenerWidget>(parentName);
|
var keyhandler = widget.Get<LogicKeyListenerWidget>(parentName);
|
||||||
keyhandler.AddHandler(e =>
|
keyhandler.AddHandler(e =>
|
||||||
{
|
{
|
||||||
if (e.Event == KeyInputEvent.Down)
|
if (e.Event == KeyInputEvent.Down && namedKey.IsActivatedBy(e))
|
||||||
if (namedKey.IsActivatedBy(e))
|
|
||||||
return OnHotkeyActivated(e);
|
return OnHotkeyActivated(e);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
|
|
||||||
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up)
|
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up)
|
||||||
{
|
{
|
||||||
if (useClassicMouseStyle && HasMouseFocus)
|
if (useClassicMouseStyle && HasMouseFocus &&
|
||||||
{
|
!IsValidDragbox && World.Selection.Actors.Count != 0 &&
|
||||||
if (!IsValidDragbox && World.Selection.Actors.Count != 0 && !multiClick && uog.InputOverridesSelection(World, mousePos, mi))
|
!multiClick && uog.InputOverridesSelection(World, mousePos, mi))
|
||||||
{
|
{
|
||||||
// Order units instead of selecting
|
// Order units instead of selecting
|
||||||
ApplyOrders(World, mi);
|
ApplyOrders(World, mi);
|
||||||
@@ -117,7 +117,6 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
YieldMouseFocus(mi);
|
YieldMouseFocus(mi);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (multiClick)
|
if (multiClick)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -131,9 +131,7 @@ namespace OpenRA.Platforms.Default
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (!disposed && faceHandle.IsAllocated)
|
||||||
{
|
|
||||||
if (faceHandle.IsAllocated)
|
|
||||||
{
|
{
|
||||||
FreeType.FT_Done_Face(face);
|
FreeType.FT_Done_Face(face);
|
||||||
|
|
||||||
@@ -142,5 +140,4 @@ namespace OpenRA.Platforms.Default
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user