Skip to content

Commit a6a408b

Browse files
authored
Minor fixes (#207)
* Fix logging error falsely when writing console input Fix nginx Dockerfile permission command Upgrade to postgres 17 * Fix playlists controller * remove h2m playlist * bump version to 2.5.4 * Fix value null exception when bindable inlines change
1 parent 07476df commit a6a408b

File tree

7 files changed

+28
-60
lines changed

7 files changed

+28
-60
lines changed

H2MLauncher.Core/Game/H2MCommunicationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private async Task<bool> ExecuteCommandAsync(string[] commands, bool bringGameWi
273273

274274
foreach (string command in commands)
275275
{
276-
if (WriteToConsoleInput(command + "\r"))
276+
if (!WriteToConsoleInput(command + "\r"))
277277
{
278278
_logger.LogWarning("Could not write command {command} to console input", command);
279279
}

H2MLauncher.UI/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515

16-
[assembly: AssemblyVersion("2.5.3.0")]
17-
[assembly: AssemblyFileVersion("2.5.3.0")]
16+
[assembly: AssemblyVersion("2.5.4.0")]
17+
[assembly: AssemblyFileVersion("2.5.4.0")]
1818
[assembly: AssemblyTitle("Better H2M-Launcher")]
1919
[assembly: SupportedOSPlatform("windows")]

H2MLauncher.UI/View/Behaviors/TextBlockExtensions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ private static void OnBindableInlinesChanged(DependencyObject d, DependencyPrope
2828
return;
2929
}
3030

31-
if (target != null)
31+
if (target is not null)
3232
{
3333
target.Inlines.Clear();
34-
target.Inlines.AddRange(((System.Collections.IEnumerable)e.NewValue));
34+
35+
if (e.NewValue is not null)
36+
{
37+
target.Inlines.AddRange(((System.Collections.IEnumerable)e.NewValue));
38+
}
3539
}
3640
}
3741
}

MatchmakingServer/Controllers/PlaylistsController.cs

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public class PlaylistsController : ControllerBase
2626
private readonly IMemoryCache _memoryCache;
2727
private readonly ServerStore _serverStore;
2828
private readonly MatchmakingService _matchmakingService;
29-
private readonly IGameServerInfoService<GameServer> _udpGameServerCommunicationService;
3029
private readonly IGameServerInfoService<GameServer> _tcpGameServerCommunicationService;
3130
private readonly ILogger<PlaylistsController> _logger;
3231

@@ -38,8 +37,7 @@ public PlaylistsController(
3837
MatchmakingService matchmakingService,
3938
ServerStore serverStore,
4039
IMemoryCache memoryCache,
41-
[FromKeyedServices("UDP")] IGameServerInfoService<GameServer> udpGameServerCommunicationService,
42-
[FromKeyedServices("TCP")] IGameServerInfoService<GameServer> tcpGameServerCommunicationService,
40+
IGameServerInfoService<GameServer> tcpGameServerCommunicationService,
4341
ILogger<PlaylistsController> logger,
4442
PlaylistStore playlistStore)
4543
{
@@ -48,7 +46,6 @@ public PlaylistsController(
4846
_matchmakingService = matchmakingService;
4947
_serverStore = serverStore;
5048
_memoryCache = memoryCache;
51-
_udpGameServerCommunicationService = udpGameServerCommunicationService;
5249
_tcpGameServerCommunicationService = tcpGameServerCommunicationService;
5350
_logger = logger;
5451
_playlistStore = playlistStore;
@@ -181,35 +178,29 @@ private async Task<int> GetPlayerCountAsync(PlaylistDbo playlist)
181178

182179
_logger.LogDebug("Requesting game server info for {numServers}", serverToRequest.Count);
183180

184-
if (playlist.Id.StartsWith("HMW", StringComparison.OrdinalIgnoreCase))
181+
CancellationTokenSource timeoutCancellation = new(3000);
182+
try
185183
{
186-
CancellationTokenSource timeoutCancellation = new(1500);
187-
try
188-
{
189-
// request HMW servers with HTTP
190-
await serverToRequest
191-
.Select((s) => _tcpGameServerCommunicationService.GetInfoAsync(s, timeoutCancellation.Token).ContinueWith(t =>
184+
// request HMW servers with HTTP
185+
await serverToRequest
186+
.Select((s) =>
187+
{
188+
return _tcpGameServerCommunicationService.GetInfoAsync(s, timeoutCancellation.Token)
189+
.ContinueWith(t =>
192190
{
193191
if (t.IsCompletedSuccessfully && t.Result is not null)
194192
{
193+
_logger.LogInformation("{serverName}: {playerCount}", t.Result.HostName, t.Result.Clients - t.Result.Bots);
195194
Interlocked.Add(ref playerCount, t.Result.Clients - t.Result.Bots);
196195
}
197-
}))
198-
.WhenAll();
199-
}
200-
catch (OperationCanceledException) { }
201-
finally
202-
{
203-
timeoutCancellation.Dispose();
204-
}
196+
});
197+
})
198+
.WhenAll();
205199
}
206-
else
200+
catch (OperationCanceledException) { }
201+
finally
207202
{
208-
// request server info of all remaining servers
209-
playerCount += await _udpGameServerCommunicationService
210-
.GetAllInfoAsync(serverToRequest, requestTimeoutInMs: 1000)
211-
.Select(r => r.info?.RealPlayerCount ?? 0)
212-
.SumAsync();
203+
timeoutCancellation.Dispose();
213204
}
214205

215206
return playerCount;

MatchmakingServer/appsettings.json

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,34 +53,6 @@
5353
"ServerSettings": {
5454
"PlayerCountCacheExpirationInS": 240,
5555
"Playlists": [
56-
{
57-
"Id": "Default",
58-
"Name": "Default Mixed Modes (H2M)",
59-
"Servers": [
60-
"23.26.130.20:27016",
61-
"188.64.33.38:5083",
62-
"154.12.244.58:27018",
63-
"57.128.171.20:27016",
64-
"185.249.225.191:27026",
65-
"149.202.89.208:27019",
66-
"51.81.110.227:27021",
67-
"51.81.110.227:27019",
68-
"51.81.110.227:27015",
69-
"116.202.156.245:27022",
70-
"38.60.136.95:27016",
71-
"103.51.114.235:27017",
72-
"45.61.162.36:27018",
73-
"45.61.162.36:27020",
74-
"136.243.124.149:27018",
75-
"94.130.65.242:27016",
76-
"157.90.6.163:27021",
77-
"h2m.sinist3r.lol:37020",
78-
"195.90.210.175:27016",
79-
"195.90.210.175:27017",
80-
"73.91.14.209:27016",
81-
"38.45.100.46:27016"
82-
]
83-
},
8456
{
8557
"Id": "HMW-Official",
8658
"Name": "HMW Official",

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ services:
6262
condition: service_healthy
6363

6464
postgres:
65-
image: postgres:15.4-alpine
65+
image: postgres:17-alpine
66+
user: ${UID:-1001}:${GID:-1001}
6667
restart: unless-stopped
6768
ports:
6869
- "127.0.0.1:5432:5432"

nginx/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM nginx:1.28.0-alpine
33
COPY nginx.conf.template /etc/nginx/nginx.conf.template
44
COPY docker-entrypoint.sh /docker-entrypoint.sh
55

6-
RUN sudo chmod +x /docker-entrypoint.sh
6+
RUN chmod +x /docker-entrypoint.sh
77

88
ENTRYPOINT ["/docker-entrypoint.sh"]
99

0 commit comments

Comments
 (0)