diff --git a/tanks-backend/TanksServer/GameLogic/MapService.cs b/tanks-backend/TanksServer/GameLogic/MapService.cs index 1e3c0e6..3a89567 100644 --- a/tanks-backend/TanksServer/GameLogic/MapService.cs +++ b/tanks-backend/TanksServer/GameLogic/MapService.cs @@ -15,7 +15,7 @@ internal sealed class MapService public const ushort PixelsPerColumn = TilesPerColumn * TileSize; private readonly ConcurrentDictionary _mapPrototypes = new(); - private readonly ConcurrentDictionary _mapPreviews = new(); + private readonly ConcurrentDictionary _mapPreviews = new(); public IEnumerable MapNames => _mapPrototypes.Keys; @@ -35,14 +35,14 @@ internal sealed class MapService public void SwitchTo(MapPrototype prototype) => Current = prototype.CreateInstance(); - public bool TryGetPreview(string name, [MaybeNullWhen(false)] out PixelGrid pixelGrid) + public bool TryGetPreview(string name, [MaybeNullWhen(false)] out Bitmap pixelGrid) { if (_mapPreviews.TryGetValue(name, out pixelGrid)) return true; // already generated if (!_mapPrototypes.TryGetValue(name, out var prototype)) return false; // name not found - pixelGrid = PixelGrid.New(PixelsPerRow, PixelsPerColumn); + pixelGrid = Bitmap.New(PixelsPerRow, PixelsPerColumn); DrawMapStep.Draw(pixelGrid, prototype.CreateInstance()); _mapPreviews.TryAdd(name, pixelGrid); // another thread may have added the map already diff --git a/tanks-backend/TanksServer/Graphics/DrawMapStep.cs b/tanks-backend/TanksServer/Graphics/DrawMapStep.cs index 062a94f..027e9a5 100644 --- a/tanks-backend/TanksServer/Graphics/DrawMapStep.cs +++ b/tanks-backend/TanksServer/Graphics/DrawMapStep.cs @@ -19,7 +19,7 @@ internal sealed class DrawMapStep(MapService map) : IDrawStep } } - public static void Draw(PixelGrid pixels, Map map) + public static void Draw(Bitmap pixels, Map map) { for (ushort y = 0; y < MapService.PixelsPerColumn; y++) for (ushort x = 0; x < MapService.PixelsPerRow; x++) diff --git a/tanks-backend/TanksServer/Graphics/GeneratePixelsTickStep.cs b/tanks-backend/TanksServer/Graphics/GeneratePixelsTickStep.cs index 5f92056..f5ec8ad 100644 --- a/tanks-backend/TanksServer/Graphics/GeneratePixelsTickStep.cs +++ b/tanks-backend/TanksServer/Graphics/GeneratePixelsTickStep.cs @@ -10,9 +10,9 @@ internal sealed class GeneratePixelsTickStep( ) : ITickStep { private GamePixelGrid _lastGamePixelGrid = new(MapService.PixelsPerRow, MapService.PixelsPerColumn); - private PixelGrid _lastObserverPixelGrid = PixelGrid.New(MapService.PixelsPerRow, MapService.PixelsPerColumn); + private Bitmap _lastObserverPixelGrid = Bitmap.New(MapService.PixelsPerRow, MapService.PixelsPerColumn); private GamePixelGrid _gamePixelGrid = new(MapService.PixelsPerRow, MapService.PixelsPerColumn); - private PixelGrid _observerPixelGrid = PixelGrid.New(MapService.PixelsPerRow, MapService.PixelsPerColumn); + private Bitmap _observerPixelGrid = Bitmap.New(MapService.PixelsPerRow, MapService.PixelsPerColumn); private readonly List _drawSteps = drawSteps.ToList(); private readonly List _consumers = consumers.ToList(); @@ -30,7 +30,7 @@ internal sealed class GeneratePixelsTickStep( (_lastObserverPixelGrid, _observerPixelGrid) = (_observerPixelGrid, _lastObserverPixelGrid); } - private void Draw(GamePixelGrid gamePixelGrid, PixelGrid observerPixelGrid) + private void Draw(GamePixelGrid gamePixelGrid, Bitmap observerPixelGrid) { gamePixelGrid.Clear(); foreach (var step in _drawSteps) diff --git a/tanks-backend/TanksServer/Graphics/IFrameConsumer.cs b/tanks-backend/TanksServer/Graphics/IFrameConsumer.cs index d21f88b..09fc940 100644 --- a/tanks-backend/TanksServer/Graphics/IFrameConsumer.cs +++ b/tanks-backend/TanksServer/Graphics/IFrameConsumer.cs @@ -4,5 +4,5 @@ namespace TanksServer.Graphics; internal interface IFrameConsumer { - Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, PixelGrid observerPixels); + Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, Bitmap observerPixels); } diff --git a/tanks-backend/TanksServer/Interactivity/ClientScreenServer.cs b/tanks-backend/TanksServer/Interactivity/ClientScreenServer.cs index a9d1514..6c1165f 100644 --- a/tanks-backend/TanksServer/Interactivity/ClientScreenServer.cs +++ b/tanks-backend/TanksServer/Interactivity/ClientScreenServer.cs @@ -22,7 +22,7 @@ internal sealed class ClientScreenServer( return base.HandleClientAsync(connection); } - public Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, PixelGrid observerPixels) + public Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, Bitmap observerPixels) => Connections.Select(c => c.OnGameTickAsync(observerPixels, gamePixelGrid)) .WhenAll(); } diff --git a/tanks-backend/TanksServer/Interactivity/ClientScreenServerConnection.cs b/tanks-backend/TanksServer/Interactivity/ClientScreenServerConnection.cs index 8ffe7b2..01e91e2 100644 --- a/tanks-backend/TanksServer/Interactivity/ClientScreenServerConnection.cs +++ b/tanks-backend/TanksServer/Interactivity/ClientScreenServerConnection.cs @@ -27,14 +27,14 @@ internal sealed class ClientScreenServerConnection : new PlayerScreenData(logger, player); } - public async Task OnGameTickAsync(PixelGrid pixels, GamePixelGrid gamePixelGrid) + public async Task OnGameTickAsync(Bitmap pixels, GamePixelGrid gamePixelGrid) { await Task.Yield(); var next = BuildNextPackage(pixels, gamePixelGrid); SetNextPackage(next); } - private Package BuildNextPackage(PixelGrid pixels, GamePixelGrid gamePixelGrid) + private Package BuildNextPackage(Bitmap pixels, GamePixelGrid gamePixelGrid) { var pixelsData = pixels.Data; var nextPixels = _bufferPool.Rent(pixelsData.Length); diff --git a/tanks-backend/TanksServer/Interactivity/SendToServicePointDisplay.cs b/tanks-backend/TanksServer/Interactivity/SendToServicePointDisplay.cs index aa4366d..e7f8065 100644 --- a/tanks-backend/TanksServer/Interactivity/SendToServicePointDisplay.cs +++ b/tanks-backend/TanksServer/Interactivity/SendToServicePointDisplay.cs @@ -52,7 +52,7 @@ internal sealed class SendToServicePointDisplay : IFrameConsumer _scoresBuffer[19] = string.Join('.', localIp[2..]); } - public async Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, PixelGrid observerPixels) + public async Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, Bitmap observerPixels) { if (!_options.CurrentValue.EnableServicePointDisplay) return; diff --git a/tanks-backend/servicepoint b/tanks-backend/servicepoint index c5cb647..9193cfe 160000 --- a/tanks-backend/servicepoint +++ b/tanks-backend/servicepoint @@ -1 +1 @@ -Subproject commit c5cb6475b24fdcdcd073ea44457628daed4e21a6 +Subproject commit 9193cfec10c72d99ad01b1ae09a935007588d7d9