update servicepoint to branch with better codegen
This commit is contained in:
		
							parent
							
								
									4fad4612b7
								
							
						
					
					
						commit
						416c8f2165
					
				
					 5 changed files with 24 additions and 10 deletions
				
			
		|  | @ -42,7 +42,7 @@ internal sealed class MapService | |||
|         if (!_mapPrototypes.TryGetValue(name, out var prototype)) | ||||
|             return false; // name not found | ||||
| 
 | ||||
|         pixelGrid = Bitmap.New(PixelsPerRow, PixelsPerColumn); | ||||
|         pixelGrid = new Bitmap(PixelsPerRow, PixelsPerColumn); | ||||
|         DrawMapStep.Draw(pixelGrid, prototype.CreateInstance()); | ||||
| 
 | ||||
|         _mapPreviews.TryAdd(name, pixelGrid); // another thread may have added the map already | ||||
|  |  | |||
|  | @ -7,12 +7,12 @@ namespace TanksServer.Graphics; | |||
| internal sealed class GeneratePixelsTickStep( | ||||
|     IEnumerable<IDrawStep> drawSteps, | ||||
|     IEnumerable<IFrameConsumer> consumers | ||||
| ) : ITickStep | ||||
| ) : ITickStep, IDisposable | ||||
| { | ||||
|     private GamePixelGrid _lastGamePixelGrid = new(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
|     private Bitmap _lastObserverPixelGrid = Bitmap.New(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
|     private Bitmap _lastObserverPixelGrid = new(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
|     private GamePixelGrid _gamePixelGrid = new(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
|     private Bitmap _observerPixelGrid = Bitmap.New(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
|     private Bitmap _observerPixelGrid = new(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
| 
 | ||||
|     private readonly List<IDrawStep> _drawSteps = drawSteps.ToList(); | ||||
|     private readonly List<IFrameConsumer> _consumers = consumers.ToList(); | ||||
|  | @ -44,4 +44,10 @@ internal sealed class GeneratePixelsTickStep( | |||
|                 observerPixelGrid[(ushort)x, (ushort)y] = true; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void Dispose() | ||||
|     { | ||||
|         _lastObserverPixelGrid.Dispose(); | ||||
|         _observerPixelGrid.Dispose(); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -4,11 +4,10 @@ using System.Net.Sockets; | |||
| using ServicePoint; | ||||
| using TanksServer.GameLogic; | ||||
| using TanksServer.Graphics; | ||||
| using CompressionCode = ServicePoint.BindGen.CompressionCode; | ||||
| 
 | ||||
| namespace TanksServer.Interactivity; | ||||
| 
 | ||||
| internal sealed class SendToServicePointDisplay : IFrameConsumer | ||||
| internal sealed class SendToServicePointDisplay : IFrameConsumer, IDisposable | ||||
| { | ||||
|     private const int ScoresWidth = 12; | ||||
|     private const int ScoresHeight = 20; | ||||
|  | @ -43,7 +42,7 @@ internal sealed class SendToServicePointDisplay : IFrameConsumer | |||
| 
 | ||||
|         var localIp = GetLocalIPv4(displayConfig.Value).Split('.'); | ||||
|         Debug.Assert(localIp.Length == 4); | ||||
|         _scoresBuffer = Cp437Grid.New(12, 20); | ||||
|         _scoresBuffer = new Cp437Grid(12, 20); | ||||
| 
 | ||||
|         _scoresBuffer[00] = "== TANKS! =="; | ||||
|         _scoresBuffer[01] = "-- scores --"; | ||||
|  | @ -113,4 +112,10 @@ internal sealed class SendToServicePointDisplay : IFrameConsumer | |||
|         var endPoint = socket.LocalEndPoint as IPEndPoint ?? throw new NotSupportedException(); | ||||
|         return endPoint.Address.ToString(); | ||||
|     } | ||||
| 
 | ||||
|     public void Dispose() | ||||
|     { | ||||
|         _displayConnection.Dispose(); | ||||
|         _scoresBuffer.Dispose(); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ using Microsoft.AspNetCore.Builder; | |||
| using Microsoft.Extensions.DependencyInjection; | ||||
| using Microsoft.Extensions.FileProviders; | ||||
| using ServicePoint; | ||||
| using SixLabors.ImageSharp; | ||||
| using TanksServer.GameLogic; | ||||
| using TanksServer.Graphics; | ||||
| using TanksServer.Interactivity; | ||||
|  | @ -101,7 +100,11 @@ public static class Program | |||
|         builder.Services.AddSingleton<Connection>(sp => | ||||
|         { | ||||
|             var config = sp.GetRequiredService<IOptions<DisplayConfiguration>>().Value; | ||||
|             return Connection.Open($"{config.Hostname}:{config.Port}"); | ||||
|             var connection = Connection.Open($"{config.Hostname}:{config.Port}"); | ||||
|             if (connection == null) | ||||
|                 throw new IOException($"Could not open connection to {config.Hostname}:{config.Port}"); | ||||
| 
 | ||||
|             return connection; | ||||
|         }); | ||||
| 
 | ||||
|         var app = builder.Build(); | ||||
|  |  | |||
|  | @ -1 +1 @@ | |||
| Subproject commit 9193cfec10c72d99ad01b1ae09a935007588d7d9 | ||||
| Subproject commit f968f929173c6646acb7d9a3ed19112e626732b3 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter