diff --git a/UT4MasterServer.Models/Database/GameServer.cs b/UT4MasterServer.Models/Database/GameServer.cs index 002baa9c..c03b2eb5 100644 --- a/UT4MasterServer.Models/Database/GameServer.cs +++ b/UT4MasterServer.Models/Database/GameServer.cs @@ -42,8 +42,8 @@ public class GameServer #if DEBUG [JsonPropertyName("UT4MS__LAST_KNOWN_MATCH_START_TIME__DEBUG_ONLY_VALUE")] #endif - [BsonElement("LastKnownMatchStartTime")] - public DateTime LastKnownMatchStartTime { get; set; } = DateTime.UtcNow; + [BsonElement("LastKnownMatchStartTime"), BsonIgnoreIfDefault] + public DateTime LastKnownMatchStartTime { get; set; } = default; #if DEBUG [BsonElement("SessionAccessToken")] @@ -220,12 +220,6 @@ public void Update(GameServer update) // Update custom properties SessionID = update.SessionID; OwningClientID = update.OwningClientID; - - var matchDuration = (int?)update.Attributes.Get("UT_MATCHDURATION_i"); - if (matchDuration is not null) - { - LastKnownMatchStartTime = DateTime.UtcNow - TimeSpan.FromSeconds(matchDuration.Value); - } } public JsonObject ToJson(bool isResponseToClient) @@ -234,10 +228,6 @@ public JsonObject ToJson(bool isResponseToClient) // Do some preprocessing on attributes var attrs = Attributes.ToJObject(); - if (attrs["UT_MATCHSTATE_s"]?.ToString() == "InProgress" && attrs.ContainsKey("UT_MATCHDURATION_i")) - { - attrs["UT_MATCHDURATION_i"] = (int)(DateTime.UtcNow - LastKnownMatchStartTime).TotalSeconds; - } // build json var obj = new List>(); @@ -247,7 +237,6 @@ public JsonObject ToJson(bool isResponseToClient) obj.Add(new("UT4MS__SESSION_ID__DEBUG_ONLY_VALUE", SessionID.ToString())); obj.Add(new("UT4MS__SESSION_TOKEN__DEBUG_ONLY_VALUE", SessionAccessToken)); obj.Add(new("UT4MS__OWNING_CLIENT_ID__DEBUG_ONLY_VALUE", OwningClientID.ToString())); - obj.Add(new("UT4MS__LAST_KNOWN_MATCH_START_TIME__DEBUG_ONLY_VALUE", LastKnownMatchStartTime.ToStringISO())); #endif obj.Add(new("ownerId", OwnerID.ToString().ToUpper())); obj.Add(new("ownerName", OwnerName)); diff --git a/UT4MasterServer/Controllers/UT/MatchmakingController.cs b/UT4MasterServer/Controllers/UT/MatchmakingController.cs index f2f21ef1..b93097dc 100644 --- a/UT4MasterServer/Controllers/UT/MatchmakingController.cs +++ b/UT4MasterServer/Controllers/UT/MatchmakingController.cs @@ -95,7 +95,7 @@ public async Task CreateGameServer([FromBody] GameServer server) throw new Exception("This should never happen"); } - var serverName = server.Attributes.Get(GameServerAttributes.UT_SERVERNAME_s) as string; + var serverName = server.Attributes.Get(GameServerAttributes.UT_SERVERNAME_s) as string ?? string.Empty; var isRanked = (int?)server.Attributes.Get(GameServerAttributes.UT_RANKED_i) == 1; if (trust != GameServerTrust.Epic && !isRanked && serverName.Trim() != client.Name.Trim()) {