Fix IDE0004
This commit is contained in:
@@ -135,6 +135,9 @@ dotnet_diagnostic.IDE0001.severity = warning
|
||||
# Simplify member access.
|
||||
dotnet_diagnostic.IDE0002.severity = warning
|
||||
|
||||
# Remove unnecessary cast.
|
||||
dotnet_diagnostic.IDE0004.severity = warning
|
||||
|
||||
# Use 'var' instead of explicit type.
|
||||
dotnet_diagnostic.IDE0007.severity = warning
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA
|
||||
public readonly struct WAngle : IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, IEquatable<WAngle>
|
||||
{
|
||||
public readonly int Angle;
|
||||
public int AngleSquared => (int)Angle * Angle;
|
||||
public int AngleSquared => Angle * Angle;
|
||||
|
||||
public WAngle(int a)
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA
|
||||
// Add an additional quadratic variation to height
|
||||
// Uses decimal to avoid integer overflow
|
||||
var offset = (decimal)(b - a).Length * pitch.Tan() * mul * (div - mul) / (1024 * div * div);
|
||||
var clampedOffset = (int)(offset + (decimal)ret.Z).Clamp((decimal)int.MinValue, (decimal)int.MaxValue);
|
||||
var clampedOffset = (int)(offset + ret.Z).Clamp(int.MinValue, int.MaxValue);
|
||||
|
||||
return new WPos(ret.X, ret.Y, clampedOffset);
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ namespace OpenRA
|
||||
public void RemoveAll(Predicate<IEffect> predicate)
|
||||
{
|
||||
effects.RemoveAll(predicate);
|
||||
unpartitionedEffects.RemoveAll(e => predicate((IEffect)e));
|
||||
unpartitionedEffects.RemoveAll(e => predicate(e));
|
||||
syncedEffects.RemoveAll(e => predicate((IEffect)e));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var sellValue = self.GetSellValue();
|
||||
|
||||
// Cast to long to avoid overflow when multiplying by the health
|
||||
var hp = health != null ? (long)health.HP : 1L;
|
||||
var maxHP = health != null ? (long)health.MaxHP : 1L;
|
||||
var hp = health != null ? health.HP : 1L;
|
||||
var maxHP = health != null ? health.MaxHP : 1L;
|
||||
var refund = (int)(sellValue * sellableInfo.RefundPercent * hp / (100 * maxHP));
|
||||
refund = playerResources.ChangeCash(refund);
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
return !double.IsNaN(attackChance) && attackChance < 30.0;
|
||||
}
|
||||
|
||||
static float NormalizedHealth(IEnumerable<Actor> actors, float normalizeByValue)
|
||||
static float NormalizedHealth(IEnumerable<Actor> actors, int normalizeByValue)
|
||||
{
|
||||
var sumOfMaxHp = 0;
|
||||
var sumOfHp = 0;
|
||||
|
||||
@@ -109,8 +109,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var sellValue = self.GetSellValue();
|
||||
|
||||
// Cast to long to avoid overflow when multiplying by the health
|
||||
var hp = health != null ? (long)health.Value.HP : 1L;
|
||||
var maxHP = health != null ? (long)health.Value.MaxHP : 1L;
|
||||
var hp = health != null ? health.Value.HP : 1L;
|
||||
var maxHP = health != null ? health.Value.MaxHP : 1L;
|
||||
var refund = (int)(sellValue * info.RefundPercent * hp / (100 * maxHP));
|
||||
|
||||
return "Refund: $" + refund;
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var content = resources[cell];
|
||||
var oldDensity = content.Type == resourceInfo.ResourceIndex ? content.Index : 0;
|
||||
var density = (byte)Math.Min(resourceInfo.MaxDensity, oldDensity + amount);
|
||||
Map.Resources[cell] = new ResourceTile((byte)resourceInfo.ResourceIndex, density);
|
||||
Map.Resources[cell] = new ResourceTile(resourceInfo.ResourceIndex, density);
|
||||
|
||||
return density - oldDensity;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
if (dropdownColumns.Count == 0)
|
||||
{
|
||||
row = dropdownRowTemplate.Clone() as Widget;
|
||||
row = dropdownRowTemplate.Clone();
|
||||
row.Bounds.Y = optionsContainer.Bounds.Height;
|
||||
optionsContainer.Bounds.Height += row.Bounds.Height;
|
||||
foreach (var child in row.Children)
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
.ToList();
|
||||
|
||||
// 'all game types' extra item
|
||||
categories.Insert(0, (null as string, tabMaps[tab].Length));
|
||||
categories.Insert(0, (null, tabMaps[tab].Length));
|
||||
|
||||
string ShowItem((string Category, int Count) x) => (x.Category ?? allMaps) + $" ({x.Count})";
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
throw new InvalidOperationException($"{group.GetType().Name} does not contain a preference type {pref}");
|
||||
|
||||
var ss = parent.Get<SliderWidget>(id);
|
||||
ss.Value = (float)(int)field.GetValue(group);
|
||||
ss.Value = (int)field.GetValue(group);
|
||||
ss.OnChange += x => field.SetValue(group, (int)x);
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace OpenRA.Platforms.Default
|
||||
{
|
||||
fixed (byte* ptr = &data[0])
|
||||
{
|
||||
var intPtr = new IntPtr((void*)ptr);
|
||||
var intPtr = new IntPtr(ptr);
|
||||
OpenGL.glGetTexImage(OpenGL.GL_TEXTURE_2D, 0, OpenGL.GL_BGRA,
|
||||
OpenGL.GL_UNSIGNED_BYTE, intPtr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user