Skip to content

Commit

Permalink
Fix warnings and code cleanup/fixes (#13570)
Browse files Browse the repository at this point in the history
  • Loading branch information
Visne authored Jan 19, 2023
1 parent 3ca5a02 commit c6d3e4f
Show file tree
Hide file tree
Showing 265 changed files with 504 additions and 671 deletions.
2 changes: 1 addition & 1 deletion Content.Benchmarks/NetSerializerStringBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public static void ReadPrimitiveUnsafe(Stream stream, out string value)
throw new EndOfStreamException();

streamBytesLeft -= bytesInBuffer;
bool flush = streamBytesLeft == 0 ? true : false;
bool flush = streamBytesLeft == 0;

bool completed = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public BwoinkControl()
return a.ActiveThisRound ? -1 : 1;

// Finally, sort by the most recent message.
return bch!.LastMessage.CompareTo(ach!.LastMessage);
return bch.LastMessage.CompareTo(ach.LastMessage);
};

Bans.OnPressed += _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ private void DrawText(

var screenCenter = _eyeManager.WorldToScreen(worldCenter);

if (Intensity![i] > 9)
if (Intensity[i] > 9)
screenCenter += (-12, -8);
else
screenCenter += (-8, -8);

handle.DrawString(_font, screenCenter, Intensity![i].ToString("F2"));
handle.DrawString(_font, screenCenter, Intensity[i].ToString("F2"));
}
}

Expand All @@ -118,7 +118,7 @@ private void DrawText(
var epicenter = tileSets[0].First();
var worldCenter = transform.Transform(((Vector2) epicenter + 0.5f) * tileSize);
var screenCenter = _eyeManager.WorldToScreen(worldCenter) + (-24, -24);
var text = $"{Intensity![0]:F2}\nΣ={TotalIntensity:F1}\nΔ={Slope:F1}";
var text = $"{Intensity[0]:F2}\nΣ={TotalIntensity:F1}\nΔ={Slope:F1}";
handle.DrawString(_font, screenCenter, text);
}
}
Expand Down Expand Up @@ -159,7 +159,7 @@ private void DrawTiles(
{
for (var i = 0; i < Intensity.Count; i++)
{
var color = ColorMap(Intensity![i]);
var color = ColorMap(Intensity[i]);
var colorTransparent = color;
colorTransparent.A = 0.2f;

Expand All @@ -183,7 +183,7 @@ private void DrawTiles(

private Color ColorMap(float intensity)
{
var frac = 1 - intensity / Intensity![0];
var frac = 1 - intensity / Intensity[0];
Color result;
if (frac < 0.5f)
result = Color.InterpolateBetween(Color.Red, Color.Orange, frac * 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Control xmlns="https://spacestation14.io"
xmlns:pt="clr-namespace:Content.Client.Administration.UI.Tabs.PlayerTab"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ObjectsTab()
foreach (var type in Enum.GetValues(typeof(ObjectsTabSelection)))
{
_selections.Add((ObjectsTabSelection)type!);
ObjectTypeOptions.AddItem(Enum.GetName((ObjectsTabSelection)type!)!);
ObjectTypeOptions.AddItem(Enum.GetName((ObjectsTabSelection)type)!);
}

RefreshObjectList(_selections[ObjectTypeOptions.SelectedId]);
Expand All @@ -43,9 +43,9 @@ private void RefreshObjectList(ObjectsTabSelection selection)
var entities = selection switch
{
ObjectsTabSelection.Stations => _entityManager.EntitySysManager.GetEntitySystem<StationSystem>().Stations.ToList(),
ObjectsTabSelection.Grids => _entityManager.EntityQuery<MapGridComponent>(true).Select(x => ((Component) x).Owner).ToList(),
ObjectsTabSelection.Grids => _entityManager.EntityQuery<MapGridComponent>(true).Select(x => x.Owner).ToList(),
ObjectsTabSelection.Maps => _entityManager.EntityQuery<MapComponent>(true).Select(x => x.Owner).ToList(),
_ => throw new ArgumentOutOfRangeException(nameof(selection), selection, null)
_ => throw new ArgumentOutOfRangeException(nameof(selection), selection, null),
};

foreach (var control in _objects)
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Atmos/Monitor/UI/Widgets/PumpControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public PumpControl(GasVentPumpData data, string address)
PumpDataChanged?.Invoke(_address, _data);
};

_internalBound.Value = (float) _data.InternalPressureBound;
_internalBound.Value = _data.InternalPressureBound;
_internalBound.OnValueChanged += _ =>
{
_data.InternalPressureBound = _internalBound.Value;
PumpDataChanged?.Invoke(_address, _data);
};
_internalBound.IsValid += value => value >= 0;

_externalBound.Value = (float) _data.ExternalPressureBound;
_externalBound.Value = _data.ExternalPressureBound;
_externalBound.OnValueChanged += _ =>
{
_data.ExternalPressureBound = _externalBound.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private float ScaledValue
public void SetValue(float value)
{
_value = value;
CSpinner.Value = (float) ScaledValue!;
CSpinner.Value = ScaledValue;
}

public void SetEnabled(bool enabled)
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected override void Draw(in OverlayDrawArgs args)
var dataMaybeNull = _atmosDebugOverlaySystem.GetData(mapGrid.Owner, tile.GridIndices);
if (dataMaybeNull != null)
{
var data = (SharedAtmosDebugOverlaySystem.AtmosDebugOverlayData) dataMaybeNull!;
var data = (SharedAtmosDebugOverlaySystem.AtmosDebugOverlayData) dataMaybeNull;
if (pass == 0)
{
// -- Mole Count --
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Atmos/Overlays/GasTileOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public sealed class GasTileOverlay : Overlay

private int _gasCount;

public const int GasOverlayZIndex = (int) Content.Shared.DrawDepth.DrawDepth.Effects; // Under ghosts, above mostly everything else
public const int GasOverlayZIndex = (int) Shared.DrawDepth.DrawDepth.Effects; // Under ghosts, above mostly everything else

public GasTileOverlay(GasTileOverlaySystem system, IEntityManager entManager, IResourceCache resourceCache, IPrototypeManager protoMan, SpriteSystem spriteSys)
{
Expand Down
1 change: 0 additions & 1 deletion Content.Client/Atmos/UI/GasFilterWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Content.Client.Stylesheets"
MinSize="480 400" Title="Filter">
<BoxContainer Orientation="Vertical" Margin="5 5 5 5" SeparationOverride="10">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Atmos/UI/GasFilterWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public GasFilterWindow(IEnumerable<GasPrototype> gases)
FilterTransferRateInput.OnTextChanged += _ => SetFilterRate.Disabled = false;
SetFilterRate.OnPressed += _ =>
{
FilterTransferRateChanged?.Invoke(FilterTransferRateInput.Text ??= "");
FilterTransferRateChanged?.Invoke(FilterTransferRateInput.Text);
SetFilterRate.Disabled = true;
};

Expand Down
1 change: 0 additions & 1 deletion Content.Client/Atmos/UI/GasMixerWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Content.Client.Stylesheets"
MinSize="200 200" Title="Gas Mixer">
<BoxContainer Orientation="Vertical" Margin="5 5 5 5" SeparationOverride="10">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
Expand Down
1 change: 0 additions & 1 deletion Content.Client/Atmos/UI/GasPressurePumpWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Content.Client.Stylesheets"
MinSize="200 120" Title="Pressure Pump">
<BoxContainer Orientation="Vertical" Margin="5 5 5 5" SeparationOverride="10">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
Expand Down
1 change: 0 additions & 1 deletion Content.Client/Atmos/UI/GasVolumePumpWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Content.Client.Stylesheets"
MinSize="200 120" Title="Volume Pump">
<BoxContainer Orientation="Vertical" Margin="5 5 5 5" SeparationOverride="10">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ protected override void Open()
description.PushColor(Color.White); // Rich text default color is grey
if (row.MainButton.ToolTip != null)
description.AddText(row.MainButton.ToolTip);
_orderMenu.Description.SetMessage(description);

_orderMenu.Description.SetMessage(description);
_product = row.Product;
_orderMenu.ProductName.Text = row.ProductName.Text;
_orderMenu.PointCost.Text = row.PointCost.Text;
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ private string GenerateLabel(ChemMasterBoundUserInterfaceState state)
/// <param name="state">State data for the dispenser.</param>
private void UpdatePanelInfo(ChemMasterBoundUserInterfaceState state)
{
BufferTransferButton.Pressed = state.Mode == Shared.Chemistry.ChemMasterMode.Transfer;
BufferDiscardButton.Pressed = state.Mode == Shared.Chemistry.ChemMasterMode.Discard;
BufferTransferButton.Pressed = state.Mode == ChemMasterMode.Transfer;
BufferDiscardButton.Pressed = state.Mode == ChemMasterMode.Discard;

BuildContainerUI(InputContainerInfo, state.InputContainerInfo, true);
BuildContainerUI(OutputContainerInfo, state.OutputContainerInfo, false);
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Clickable/ClickMapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void OnRawTextureLoaded(TextureLoadedEventArgs obj)
var pathStr = obj.Path.ToString();
foreach (var path in IgnoreTexturePaths)
{
if (pathStr.StartsWith(path))
if (pathStr.StartsWith(path, StringComparison.Ordinal))
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Clickable/ClickableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public bool CheckClick(SpriteComponent sprite, TransformComponent transform, Ent
// Next, to get the right click map we need the "direction" of this layer that is actually being used to draw the sprite on the screen.
// This **can** differ from the dir defined before, but can also just be the same.
if (sprite.EnableDirectionOverride)
dir = sprite.DirectionOverride.Convert(rsiState.Directions);;
dir = sprite.DirectionOverride.Convert(rsiState.Directions);
dir = dir.OffsetRsiDir(layer.DirOffset);

if (_clickMapManager.IsOccluding(layer.ActualRsi!, layer.State, dir, layer.AnimationFrame, layerImagePos))
Expand Down
1 change: 0 additions & 1 deletion Content.Client/CloningConsole/UI/CloningConsoleWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'comp-pda-ui-menu-title'}"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
SetSize="400 400"
MinSize="400 400">
<TabContainer Name="MasterTabContainer">
Expand Down
6 changes: 0 additions & 6 deletions Content.Client/CloningConsole/UI/CloningConsoleWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Content.Client.Message;
using Robust.Shared.Timing;
using Content.Shared.Cloning.CloningConsole;

namespace Content.Client.CloningConsole.UI
Expand All @@ -18,11 +17,6 @@ public CloningConsoleWindow()

private CloningConsoleBoundUserInterfaceState? _lastUpdate;

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
}

public void Populate(CloningConsoleBoundUserInterfaceState state)
{
_lastUpdate = state;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Computer/ComputerBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected override void Dispose(bool disposing)
}

/// <summary>
/// This class is to avoid a lot of <> being written when we just want to refer to SendMessage.
/// This class is to avoid a lot of &lt;&gt; being written when we just want to refer to SendMessage.
/// We could instead qualify a lot of generics even further, but that is a waste of time.
/// </summary>
[Virtual]
Expand Down
1 change: 0 additions & 1 deletion Content.Client/Decals/UI/DecalPlacerWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:ui="clr-namespace:Content.Client.Decals.UI"
Title="{Loc 'decal-placer-window-title'}"
MinSize="250 500"
SetSize="250 500">
Expand Down
5 changes: 1 addition & 4 deletions Content.Client/DragDrop/DragDropHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ private enum DragState : byte
/// <param name="onBeginDrag"><see cref="OnBeginDrag"/></param>
/// <param name="onContinueDrag"><see cref="OnContinueDrag"/></param>
/// <param name="onEndDrag"><see cref="OnEndDrag"/></param>
/// <param name="deadzone">drag will be triggered when mouse leaves
/// this deadzone around the mousedown position</param>
public DragDropHelper(OnBeginDrag onBeginDrag, OnContinueDrag onContinueDrag,
OnEndDrag onEndDrag)
public DragDropHelper(OnBeginDrag onBeginDrag, OnContinueDrag onContinueDrag, OnEndDrag onEndDrag)
{
_inputManager = IoCManager.Resolve<IInputManager>();
_onBeginDrag = onBeginDrag;
Expand Down
3 changes: 1 addition & 2 deletions Content.Client/Fax/UI/FaxWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:viewport="clr-namespace:Content.Client.Viewport"
Title="{Loc 'fax-machine-ui-window'}"
MinWidth="250">
<BoxContainer Orientation="Vertical" VerticalExpand="True">
Expand Down Expand Up @@ -29,4 +28,4 @@
Text="{Loc 'fax-machine-ui-refresh-button'}" />
</BoxContainer>
</BoxContainer>
</DefaultWindow>
</DefaultWindow>
73 changes: 26 additions & 47 deletions Content.Client/Fluids/PuddleVisualizerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,57 +45,36 @@ protected override void OnAppearanceChange(EntityUid uid, PuddleVisualizerCompon
return;
}

if (args.Component.TryGetData(PuddleVisuals.VolumeScale, out float volumeScale)
&& args.Component.TryGetData(PuddleVisuals.CurrentVolume, out FixedPoint2 currentVolume)
&& args.Component.TryGetData(PuddleVisuals.SolutionColor, out Color solutionColor)
&& args.Component.TryGetData(PuddleVisuals.IsEvaporatingVisual, out bool isEvaporating))
if (!args.Component.TryGetData(PuddleVisuals.VolumeScale, out float volumeScale)
|| !args.Component.TryGetData(PuddleVisuals.CurrentVolume, out FixedPoint2 currentVolume)
|| !args.Component.TryGetData(PuddleVisuals.SolutionColor, out Color solutionColor)
|| !args.Component.TryGetData(PuddleVisuals.IsEvaporatingVisual, out bool isEvaporating))
{
// volumeScale is our opacity based on level of fullness to overflow. The lower bound is hard-capped for visibility reasons.
var cappedScale = Math.Min(1.0f, volumeScale * 0.75f + 0.25f);

Color newColor;
if (component.Recolor)
{
newColor = solutionColor.WithAlpha(cappedScale);
}
else
{
newColor = args.Sprite.Color.WithAlpha(cappedScale);
}

args.Sprite.LayerSetColor(0, newColor);

if (component.CustomPuddleSprite) //Don't consider wet floor effects if we're using a custom sprite.
{
return;
}

bool wetFloorEffectNeeded;

if (isEvaporating
&& currentVolume <= component.WetFloorEffectThreshold)
{
wetFloorEffectNeeded = true;
}
else
wetFloorEffectNeeded = false;

if (wetFloorEffectNeeded)
{
if (args.Sprite.LayerGetState(0) != "sparkles") // If we need the effect but don't already have it - start it
{
StartWetFloorEffect(args.Sprite, component.WetFloorEffectAlpha);
}
}
else
{
if (args.Sprite.LayerGetState(0) == "sparkles") // If we have the effect but don't need it - end it
EndWetFloorEffect(args.Sprite, component.OriginalRsi);
}
return;
}

// volumeScale is our opacity based on level of fullness to overflow. The lower bound is hard-capped for visibility reasons.
var cappedScale = Math.Min(1.0f, volumeScale * 0.75f + 0.25f);

var newColor = component.Recolor ? solutionColor.WithAlpha(cappedScale) : args.Sprite.Color.WithAlpha(cappedScale);

args.Sprite.LayerSetColor(0, newColor);

// Don't consider wet floor effects if we're using a custom sprite.
if (component.CustomPuddleSprite)
return;

if (isEvaporating && currentVolume <= component.WetFloorEffectThreshold)
{
// If we need the effect but don't already have it - start it
if (args.Sprite.LayerGetState(0) != "sparkles")
StartWetFloorEffect(args.Sprite, component.WetFloorEffectAlpha);
}
else
{
return;
// If we have the effect but don't need it - end it
if (args.Sprite.LayerGetState(0) == "sparkles")
EndWetFloorEffect(args.Sprite, component.OriginalRsi);
}
}

Expand Down
3 changes: 1 addition & 2 deletions Content.Client/Guidebook/Controls/GuidebookWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<controls:FancyWindow xmlns:ui="clr-namespace:Content.Client.UserInterface"
xmlns="https://spacestation14.io"
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:fancyTree="clr-namespace:Content.Client.UserInterface.Controls.FancyTree"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Guidebook/GuidebookSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public bool OpenGuidebook(
bool includeChildren = true,
string? selected = null)
{
Dictionary<string, GuideEntry>? guides = new();
Dictionary<string, GuideEntry> guides = new();
foreach (var guideId in guideList)
{
if (!_prototypeManager.TryIndex<GuideEntryPrototype>(guideId, out var guide))
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void Populate(HealthAnalyzerScannedUserMessage msg)

text.Append($"{Loc.GetString("health-analyzer-window-entity-health-text", ("entityName", entityName))}\n");

/// Status Effects / Components
// Status Effects / Components
if (entities.HasComponent<DiseasedComponent>(msg.TargetEntity))
{
text.Append($"{Loc.GetString("disease-scanner-diseased")}\n");
Expand All @@ -46,7 +46,7 @@ public void Populate(HealthAnalyzerScannedUserMessage msg)
text.Append($"{Loc.GetString("disease-scanner-not-diseased")}\n");
}

/// Damage
// Damage
text.Append($"\n{Loc.GetString("health-analyzer-window-entity-damage-total-text", ("amount", damageable.TotalDamage))}\n");

HashSet<string> shownTypes = new();
Expand Down
Loading

0 comments on commit c6d3e4f

Please sign in to comment.