diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index bb79469be..ef18ef1d7 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -66,8 +66,6 @@ namespace IW4MAdmin client.CurrentServer = this; Clients[client.ClientNumber] = client; - - client.State = ClientState.Connected; #if DEBUG == true Logger.WriteDebug($"End PreConnect for {client}"); #endif @@ -80,6 +78,7 @@ namespace IW4MAdmin Manager.GetEventHandler().AddEvent(e); await client.OnJoin(client.IPAddress); + client.State = ClientState.Connected; } catch (Exception ex) @@ -460,7 +459,7 @@ namespace IW4MAdmin private async Task OnClientUpdate(EFClient origin) { - var client = Clients.FirstOrDefault(_client => _client.Equals(origin)); + var client = GetClientsAsList().FirstOrDefault(_client => _client.Equals(origin)); if (client != null) { @@ -468,7 +467,9 @@ namespace IW4MAdmin client.Score = origin.Score; // update their IP if it hasn't been set yet - if (client.IPAddress == null && !client.IsBot) + if (client.IPAddress == null && + !client.IsBot && + client.State == ClientState.Connected) { await client.OnJoin(origin.IPAddress); } diff --git a/SharedLibraryCore/Dtos/ServerInfo.cs b/SharedLibraryCore/Dtos/ServerInfo.cs index 103432984..29b430c5e 100644 --- a/SharedLibraryCore/Dtos/ServerInfo.cs +++ b/SharedLibraryCore/Dtos/ServerInfo.cs @@ -19,5 +19,6 @@ namespace SharedLibraryCore.Dtos public Helpers.PlayerHistory[] PlayerHistory { get; set; } public long ID { get; set; } public bool Online { get; set; } + public string ConnectProtocolUrl { get; set; } } } diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index d8a3381f9..e91ef6dbc 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -135,7 +135,7 @@ namespace SharedLibraryCore.Services // this happens when the link we found is different than the one we create before adding an IP if (isAliasLinkUpdated) { - entity.CurrentServer.Logger.WriteDebug($"found a link for {entity} so we are updating link from {entity.AliasLink.AliasLinkId} to {newAliasLink.AliasLinkId}"); + entity.CurrentServer.Logger.WriteDebug($"[updatealias] found a link for {entity} so we are updating link from {entity.AliasLink.AliasLinkId} to {newAliasLink.AliasLinkId}"); var oldAliasLink = entity.AliasLink; @@ -161,7 +161,7 @@ namespace SharedLibraryCore.Services // the existing alias matches ip and name, so we can just ignore the temporary one if (hasExactAliasMatch) { - entity.CurrentServer.Logger.WriteDebug($"{entity} has exact alias match"); + entity.CurrentServer.Logger.WriteDebug($"[updatealias] {entity} has exact alias match"); var oldAlias = entity.CurrentAlias; entity.CurrentAliasId = existingExactAlias.AliasId; @@ -169,8 +169,9 @@ namespace SharedLibraryCore.Services await context.SaveChangesAsync(); // the alias is the same so we can just remove it - if (oldAlias.AliasId != existingExactAlias.AliasId) + if (oldAlias.AliasId != existingExactAlias.AliasId && oldAlias.AliasId > 0) { + entity.CurrentServer.Logger.WriteDebug($"[updatealias] {entity} has exact alias match, so we're going to try to remove aliasId {oldAlias.AliasId} with linkId {oldAlias.AliasId}"); context.Aliases.Remove(oldAlias); await context.SaveChangesAsync(); } @@ -179,7 +180,7 @@ namespace SharedLibraryCore.Services // theres no exact match, but they've played before with the GUID or IP else { - entity.CurrentServer.Logger.WriteDebug($"Connecting player is using a new alias {entity}"); + entity.CurrentServer.Logger.WriteDebug($"[updatealias] {entity} is using a new alias"); var newAlias = new EFAlias() { diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs index fecbb60cc..34fde6905 100644 --- a/SharedLibraryCore/Utilities.cs +++ b/SharedLibraryCore/Utilities.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; +using System.IO; using System.Linq; using System.Reflection; using System.Text; diff --git a/WebfrontCore/Controllers/BaseController.cs b/WebfrontCore/Controllers/BaseController.cs index d4f2978b2..c46c71e1b 100644 --- a/WebfrontCore/Controllers/BaseController.cs +++ b/WebfrontCore/Controllers/BaseController.cs @@ -66,11 +66,16 @@ namespace WebfrontCore.Controllers { try { - Client.ClientId = Convert.ToInt32(base.User.Claims.First(c => c.Type == ClaimTypes.Sid).Value); - Client.NetworkId = User.Claims.First(_claim => _claim.Type == ClaimTypes.PrimarySid).Value.ConvertLong(); - Client.Level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value); - Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value }; - Authorized = Client.ClientId >= 0; + int clientId = Convert.ToInt32(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid)?.Value ?? "-1"); + + if (clientId > 0) + { + Client.ClientId = clientId; + Client.NetworkId = User.Claims.First(_claim => _claim.Type == ClaimTypes.PrimarySid).Value.ConvertLong(); + Client.Level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value); + Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value }; + Authorized = Client.ClientId >= 0; + } } catch (InvalidOperationException) diff --git a/WebfrontCore/Controllers/ServerController.cs b/WebfrontCore/Controllers/ServerController.cs index de4c1d2d0..4b5601ce4 100644 --- a/WebfrontCore/Controllers/ServerController.cs +++ b/WebfrontCore/Controllers/ServerController.cs @@ -36,7 +36,7 @@ namespace WebfrontCore.Controllers LevelInt = (int)p.Level }).ToList(), ChatHistory = s.ChatHistory.ToList(), - PlayerHistory = s.ClientHistory.ToArray(), + PlayerHistory = s.ClientHistory.ToArray() }; return PartialView("_ClientActivity", serverInfo); } diff --git a/WebfrontCore/ViewComponents/ServerListViewComponent.cs b/WebfrontCore/ViewComponents/ServerListViewComponent.cs index e87703385..29df5c5ae 100644 --- a/WebfrontCore/ViewComponents/ServerListViewComponent.cs +++ b/WebfrontCore/ViewComponents/ServerListViewComponent.cs @@ -29,7 +29,8 @@ namespace WebfrontCore.ViewComponents LevelInt = (int)p.Level }).ToList(), ChatHistory = s.ChatHistory.ToList(), - Online = !s.Throttled + Online = !s.Throttled, + ConnectProtocolUrl = s.EventParser.URLProtocolFormat.FormatExt(s.IP, s.GetPort()) }).ToList(); return View("_List", serverInfo); } diff --git a/WebfrontCore/Views/Server/_Server.cshtml b/WebfrontCore/Views/Server/_Server.cshtml index 2345fbbb6..31b15577d 100644 --- a/WebfrontCore/Views/Server/_Server.cshtml +++ b/WebfrontCore/Views/Server/_Server.cshtml @@ -3,21 +3,21 @@ Layout = null; } -
-
@Model.Name
-
@Model.Map
-
@Model.ClientCount/@Model.MaxClients
+
+
+ @Model.Name + + + +
+
@Model.Map
+
@Model.ClientCount/@Model.MaxClients
-
-
-
-
- @await Html.PartialAsync("../Server/_ClientActivity", Model) -
+ @await Html.PartialAsync("../Server/_ClientActivity", Model)
-
+
diff --git a/WebfrontCore/wwwroot/css/bootstrap-custom.css b/WebfrontCore/wwwroot/css/bootstrap-custom.css index 4075b2dcf..59470f44d 100644 --- a/WebfrontCore/wwwroot/css/bootstrap-custom.css +++ b/WebfrontCore/wwwroot/css/bootstrap-custom.css @@ -6299,6 +6299,9 @@ a.nav-link { .border-bottom { border-bottom: 1px solid #007ACC !important; } +.server-history { + background-color: #191919; } + .border-top { border-top: 1px solid #007ACC !important; } @@ -6308,6 +6311,9 @@ a.nav-link { border: 1px solid #fd7e14; color: #fff; } +.server-join-button, .server-join-button:hover { + color: #fff !important; } + a.link-inverse { color: #007ACC; } @@ -6413,7 +6419,7 @@ form *, select { .client-rating-change-amount { font-size: 1rem; } -.client-message, .automated-penalty-info-detailed { +.client-message, .automated-penalty-info-detailed, .oi { cursor: pointer; } #footer_text { diff --git a/WebfrontCore/wwwroot/css/bootstrap-custom.scss b/WebfrontCore/wwwroot/css/bootstrap-custom.scss index 6bf67b0d3..e78ce8026 100644 --- a/WebfrontCore/wwwroot/css/bootstrap-custom.scss +++ b/WebfrontCore/wwwroot/css/bootstrap-custom.scss @@ -8,6 +8,7 @@ $secondary: $orange !default; $light: rgb(204, 204, 204) !default; $dark: rgb(24, 24, 24) !default; $body-bg: rgb(34,34,34) !default; +$big-dark: #191919; $body-color: $white !default; $link-color: $white !default; $link-decoration: none !default; @@ -67,6 +68,10 @@ a.nav-link { border-bottom: 1px solid $primary !important; } +.server-history { + background-color: $big-dark; +} + .border-top { border-top: 1px solid $primary !important; } @@ -78,6 +83,10 @@ a.nav-link { color: $white; } +.server-join-button, .server-join-button:hover { + color: $white !important; +} + a.link-inverse { color: $primary; } @@ -216,7 +225,7 @@ form *, select { font-size: 1rem; } -.client-message, .automated-penalty-info-detailed { +.client-message, .automated-penalty-info-detailed, .oi { cursor: pointer; } @@ -277,6 +286,6 @@ form *, select { border: 1px solid $orange; } -.hide { +.hide { display: none; -} \ No newline at end of file +}