From d6729233e62670e9ce35dff8b0e93afb32e58509 Mon Sep 17 00:00:00 2001 From: JoKeRZH429 <83122870+JoKeRZH429@users.noreply.github.com> Date: Tue, 8 Sep 2026 23:09:23 +0500 Subject: [PATCH] feat: store in-game duration in player match outcome --- GenOnlineService/Controllers/Lobby/LobbyController.cs | 4 +++- GenOnlineService/Database/Database.MatchHistory.cs | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/GenOnlineService/Controllers/Lobby/LobbyController.cs b/GenOnlineService/Controllers/Lobby/LobbyController.cs index 46e0896..f53d46f 100644 --- a/GenOnlineService/Controllers/Lobby/LobbyController.cs +++ b/GenOnlineService/Controllers/Lobby/LobbyController.cs @@ -304,6 +304,7 @@ public async Task Delete(Int64 lobbyID) && data.ContainsKey("won") && data.ContainsKey("side") && data.ContainsKey("desynced") + && data.ContainsKey("duration") ) { Int64 user_id = TokenHelper.GetUserID(this); @@ -323,6 +324,7 @@ public async Task Delete(Int64 lobbyID) int side = data["side"].GetInt32(); bool won = data["won"].GetBoolean(); bool desynced = data["desynced"].GetBoolean(); + uint duration = data["duration"].GetUInt32(); UInt64 match_id = data["match_id"].GetUInt64(); // were they really in the match they claim to be in? @@ -359,7 +361,7 @@ public async Task Delete(Int64 lobbyID) // store in DB await using var db = await _dbFactory.CreateDbContextAsync(); await Database.MatchHistory.CommitPlayerOutcome(db, slotIndexInLobby, match_id, side, - buildings_built, buildings_killed, buildings_lost, units_built, units_killed, units_lost, total_money, won, desynced); + buildings_built, buildings_killed, buildings_lost, units_built, units_killed, units_lost, total_money, won, desynced, duration); } } } diff --git a/GenOnlineService/Database/Database.MatchHistory.cs b/GenOnlineService/Database/Database.MatchHistory.cs index f3c6674..dc944bf 100644 --- a/GenOnlineService/Database/Database.MatchHistory.cs +++ b/GenOnlineService/Database/Database.MatchHistory.cs @@ -244,6 +244,8 @@ public struct MatchdataMemberModel [JsonConverter(typeof(BoolFromIntConverter))] public bool desynced {get; set; } = false; + public uint? duration { get; set; } = null; + public List metadata { get; set; } = new List(); public MatchdataMemberModel() @@ -373,7 +375,8 @@ public static async Task CommitPlayerOutcome( int unitsLost, int totalMoney, bool won, - bool desynced) + bool desynced, + uint duration) { if (slotIndex < 0 || slotIndex > 7) return; @@ -402,6 +405,7 @@ public static async Task CommitPlayerOutcome( model.total_money = totalMoney; model.won = won; model.desynced = desynced; + model.duration = duration; // 4. Serialize back string updatedJson = JsonSerializer.Serialize(model);