Skip to content

Commit

Permalink
Updated dependencies
Browse files Browse the repository at this point in the history
Fixed security issues
Fixed Mac issues
Improved code
  • Loading branch information
MarkenJaden committed Nov 29, 2023
1 parent 2dcfbb0 commit ef5467d
Show file tree
Hide file tree
Showing 87 changed files with 676 additions and 570 deletions.
22 changes: 11 additions & 11 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageVersion Include="Blazored.LocalStorage" Version="4.4.0" />
<PackageVersion Include="coverlet.collector" Version="1.3.0" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.13" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.13" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.13" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.25" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.25" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.25" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.4.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />
<PackageVersion Include="Microsoft.Net.Compilers.Toolset" Version="4.4.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Microsoft.Net.Compilers.Toolset" Version="4.8.0" />
<PackageVersion Include="SixLabors.ImageSharp" Version="1.0.4" />
<PackageVersion Include="SkiaSharp" Version="2.88.3" />
<PackageVersion Include="SkiaSharp.Views.Blazor" Version="2.88.3" />
<PackageVersion Include="Svg.SourceGenerator.Skia" Version="0.5.18" />
<PackageVersion Include="SkiaSharp" Version="2.88.6" />
<PackageVersion Include="SkiaSharp.Views.Blazor" Version="2.88.6" />
<PackageVersion Include="Svg.SourceGenerator.Skia" Version="1.0.0.6" />
<PackageVersion Include="MudBlazor" Version="6.1.7" />
<PackageVersion Include="MudBlazor.ThemeManager" Version="1.0.7" />
</ItemGroup>
</Project>
</Project>
6 changes: 3 additions & 3 deletions LandOfSignals-Signalbox/Client/BlazorGameStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ public class BlazorGameStorage : ISignalboxStorage

public IServiceProvider? AspNetCoreServices { get; set; }

private ISyncLocalStorageService? SyncLocalStorageService => (_syncLocalStorageService ??= this.AspNetCoreServices?.GetService<ISyncLocalStorageService>());
private ISyncLocalStorageService? SyncLocalStorageService => (_syncLocalStorageService ??= AspNetCoreServices?.GetService<ISyncLocalStorageService>());

public string? Read(string key)
{
var data = this.SyncLocalStorageService?.GetItemAsString(key);
var data = SyncLocalStorageService?.GetItemAsString(key);
return data;
}

Expand All @@ -24,7 +24,7 @@ public void Write(string key, string value)
if (!valueExists || previousValue != value)
{
_lastSavedValue[key] = value;
this.SyncLocalStorageService?.SetItemAsString(key, value);
SyncLocalStorageService?.SetItemAsString(key, value);
}
}
}
6 changes: 3 additions & 3 deletions LandOfSignals-Signalbox/Client/BlazorTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public void Start()

private async Task StartTimer()
{
var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(this.Interval));
var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(Interval));
while (await timer.WaitForNextTickAsync(_cts!.Token))
{
long time = _stopwatch.ElapsedMilliseconds;
this.TimeSinceLastTick = time - _lastTick;
var time = _stopwatch.ElapsedMilliseconds;
TimeSinceLastTick = time - _lastTick;
_lastTick = time;
Elapsed?.Invoke(this, EventArgs.Empty);
}
Expand Down
7 changes: 4 additions & 3 deletions LandOfSignals-Signalbox/Client/Game.razor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components.Web;
using DI;
using Microsoft.AspNetCore.Components.Web;
using Signalbox.Instrumentation;
using Signalbox.Instrumentation.Stats;
using Signalbox.Rendering.Signalbox;
Expand All @@ -19,8 +20,8 @@ public partial class Game

protected override async Task OnInitializedAsync()
{
_game = DI.ServiceLocator.GetService<ISignalbox>();
_interactionManager = DI.ServiceLocator.GetService<IInteractionManager>();
_game = ServiceLocator.GetService<ISignalbox>();
_interactionManager = ServiceLocator.GetService<IInteractionManager>();

await _game.InitializeAsync(200, 200);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,18 @@
<ProjectReference Include="..\Shared\LandOfSignals-Signalbox.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.CodeStyle">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Net.Compilers.Toolset">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion LandOfSignals-Signalbox/Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Blazored.LocalStorage;
using DI;
using LandOfSignals_Signalbox.Client;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
Expand All @@ -13,7 +14,7 @@

var host = builder.Build();

if (DI.ServiceLocator.GetService<ISignalboxStorage>() is BlazorGameStorage storage)
if (ServiceLocator.GetService<ISignalboxStorage>() is BlazorGameStorage storage)
{
storage.AspNetCoreServices = host.Services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,19 @@
<ProjectReference Include="..\Shared\LandOfSignals-Signalbox.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.CodeStyle">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Net.Compilers.Toolset">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>


</Project>
4 changes: 2 additions & 2 deletions LandOfSignals-Signalbox/Server/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace LandOfSignals_Signalbox.Server.Pages
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,18 @@
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.CodeStyle">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Net.Compilers.Toolset">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions Signalbox.Engine/Entity/FilteredLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public bool TryGet(int column, int row, [NotNullWhen(true)] out T? entity)

public IEnumerator<T> GetEnumerator()
{
foreach (T entity in _layout.OfType<T>())
foreach (var entity in _layout.OfType<T>())
{
yield return entity;
}
Expand All @@ -60,7 +60,7 @@ public void Set(int column, int row, T entity)

public void Add(int column, int row, IEnumerable<IStaticEntityFactory<T>> entityFactories, int fromColumn, int fromRow)
{
T? entity = CreateNewStaticEntity(column, row, entityFactories, fromColumn, fromRow);
var entity = CreateNewStaticEntity(column, row, entityFactories, fromColumn, fromRow);

if (entity is null)
{
Expand All @@ -83,7 +83,7 @@ public void Add(int column, int row, IEnumerable<IStaticEntityFactory<T>> entity

public bool IsAvailable(int column, int row)
{
_layout.TryGet(column, row, out IStaticEntity? entity);
_layout.TryGet(column, row, out var entity);
return entity == null || entity is T;
}

Expand Down
14 changes: 7 additions & 7 deletions Signalbox.Engine/Entity/Layout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,23 @@ private static bool IsInvalid(int column, int row)
public bool TryGet<T>(int column, int row, [NotNullWhen(true)] out T? entity)
where T : class, IStaticEntity
{
TryGet(column, row, out IStaticEntity? staticEntity);
TryGet(column, row, out var staticEntity);
entity = staticEntity as T;
return entity != null;
}

public bool IsEmptyOrT<T>(int column, int row)
where T : class, IStaticEntity
{
TryGet(column, row, out IStaticEntity? staticEntity);
TryGet(column, row, out var staticEntity);
return staticEntity == null || staticEntity is T;
}

private void ResetArrays()
{
lock (_gate)
{
for (int i = 0; i < _entities.Length; i++)
for (var i = 0; i < _entities.Length; i++)
{
_entities[i] = new IStaticEntity?[_rows];
}
Expand All @@ -148,9 +148,9 @@ private void ResetArrays()
public IEnumerator<IStaticEntity> GetEnumerator()
{
if (_entities == null) yield break;
for (int i = 0; i < _entities.Length; i++)
for (var i = 0; i < _entities.Length; i++)
{
for (int j = 0; j < _rows; j++)
for (var j = 0; j < _rows; j++)
{
var track = _entities[i][j];
if (track is not null)
Expand Down Expand Up @@ -181,7 +181,7 @@ public bool Load(ISignalboxStorage storage)

ResetArrays();

foreach (IStaticEntity entity in staticEntites)
foreach (var entity in staticEntites)
{
StoreEntity(entity.Column, entity.Row, entity);
}
Expand All @@ -206,7 +206,7 @@ void ISignalboxState.Reset()

public void Update(long timeSinceLastTick)
{
foreach (IUpdatableEntity entity in this.OfType<IUpdatableEntity>())
foreach (var entity in this.OfType<IUpdatableEntity>())
{
entity.Update();
}
Expand Down
12 changes: 6 additions & 6 deletions Signalbox.Engine/Entity/MovableLayout.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using System.Collections.Immutable;
using System.Collections;
using System.Collections.Immutable;
using Signalbox.Engine.MainManager;
using Signalbox.Engine.StateManager;
using Signalbox.Engine.Storage;
using Signalbox.Engine.Tracks;
using Signalbox.Engine.Trains;
using IMovable = Signalbox.Engine.Trains.IMovable;

namespace Signalbox.Engine.Entity;

public class MovableLayout : IMovableLayout, ISignalboxState, ISignalboxStep
{
private ImmutableList<IMovable> _movables = ImmutableList<IMovable>.Empty;
private Dictionary<Track, (Trains.Train, float)> _lastTrackLeases = new();
private Dictionary<Track, (Train, float)> _lastTrackLeases = new();
private readonly ILayout _layout;
private readonly IEntityCollectionSerializer _gameSerializer;
private readonly Trains.Train _reservedTrain;
private readonly Train _reservedTrain;

public int Count => _movables.Count;

Expand All @@ -30,7 +30,7 @@ public MovableLayout(ILayout layout, IEntityCollectionSerializer gameSerializer)
public int IndexOf(IMovable movable)
=> _movables.IndexOf(movable);

public IEnumerable<(Track, Trains.Train, float)> LastTrackLeases => _lastTrackLeases.Select(kvp => (kvp.Key, kvp.Value.Item1, kvp.Value.Item2));
public IEnumerable<(Track, Train, float)> LastTrackLeases => _lastTrackLeases.Select(kvp => (kvp.Key, kvp.Value.Item1, kvp.Value.Item2));

public void Add(IMovable movable)
=> _movables = _movables.Add(movable);
Expand Down Expand Up @@ -89,6 +89,6 @@ public void Update(long timeSinceLastTick)
public IEnumerator<IMovable> GetEnumerator()
=> _movables.GetEnumerator();

System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
IEnumerator IEnumerable.GetEnumerator()
=> _movables.GetEnumerator();
}
8 changes: 3 additions & 5 deletions Signalbox.Engine/Map/DefaultGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System.Numerics;

namespace Signalbox.Engine.Map;
namespace Signalbox.Engine.Map;

internal static class DefaultGenerator
{
public static Dictionary<(int x, int y), string> GenerateDefaultMap(int width, int height)
{
var points = new Dictionary<(int x, int y), string>();
for (int i = 0; i < width; i++)
for (var i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
for (var j = 0; j < height; j++)
{
points.Add((i, j), string.Empty);
}
Expand Down
3 changes: 1 addition & 2 deletions Signalbox.Engine/Map/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Immutable;
using Signalbox.Engine.StateManager;
using Signalbox.Engine.Storage;
using Signalbox.Engine.Trains;
using Signalbox.Engine.Utilities;

namespace Signalbox.Engine.Map;
Expand All @@ -24,7 +23,7 @@ public void Reset()
Dictionary<(int x, int y), string>? defaultMap = DefaultGenerator.GenerateDefaultMap(_columns, _rows);

ImmutableDictionary<(int, int), Tile>.Builder builder = ImmutableDictionary.CreateBuilder<(int, int), Tile>();
foreach ((int x, int y) coord in defaultMap.Keys)
foreach (var coord in defaultMap.Keys)
{
builder.Add(coord, new()
{
Expand Down
14 changes: 14 additions & 0 deletions Signalbox.Engine/Signalbox.Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,18 @@
<ProjectReference Include="..\Signalbox.Instrumentation\Signalbox.Instrumentation.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.CodeStyle">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Net.Compilers.Toolset">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions Signalbox.Engine/StateManager/SignalboxStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public bool AutosaveEnabled
// if they're turning off autosave, we want to at least save that
// otherwise if they leave before the next save, it could be back on
// on load
_storage.Write("Autosave", this.AutosaveEnabled.ToString());
_storage.Write("Autosave", AutosaveEnabled.ToString());
}
}
}
Expand Down Expand Up @@ -65,7 +65,7 @@ public void Load()
break;
}
}
this.AutosaveEnabled = _storage.Read("Autosave")?.Equals("True") ?? true;
AutosaveEnabled = _storage.Read("Autosave")?.Equals("True") ?? true;
}

public void Reset()
Expand All @@ -84,15 +84,15 @@ public void Save()
{
gameState.Save(_storage);
}
_storage.Write("Autosave", this.AutosaveEnabled.ToString());
_storage.Write("Autosave", AutosaveEnabled.ToString());
}
}

public void Update(long timeSinceLastTick)
{
_autosaveStat.Information = this.AutosaveEnabled ? "On" : "Off";
_autosaveStat.Information = AutosaveEnabled ? "On" : "Off";

if (this.AutosaveEnabled &&
if (AutosaveEnabled &&
++_autosaveCounter > AutosaveInterval)
{
Save();
Expand Down
Loading

0 comments on commit ef5467d

Please sign in to comment.