From 068a2102b923f8d07b664f45d6847a893860372f Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Mon, 15 Nov 2021 19:54:04 +0100 Subject: [PATCH] add new objectives if entries does not match existing ones --- BGS/Report.cs | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/BGS/Report.cs b/BGS/Report.cs index 37a967e..3ce65aa 100644 --- a/BGS/Report.cs +++ b/BGS/Report.cs @@ -34,6 +34,7 @@ namespace EliteBGS.BGS { e.Is(Events.MissionAccepted) || e.Is(Events.Docked) || e.Is(Events.FSDJump) || + e.Is(Events.Location) || e.Is(Events.MultiSellExplorationData) || e.Is(Events.SellMicroResources) || e.Is(Events.RedeemVoucher) || @@ -73,6 +74,18 @@ namespace EliteBGS.BGS { */ current_system = (e as FSDJumpEntry).StarSystem; controlling_faction = (e as FSDJumpEntry).SystemFaction; + } else if (e.Is(Events.Location)) { + /* Get current system, faction name and station from Location message + */ + LocationEntry location = e as LocationEntry; + + current_system = location.StarSystem; + if (!string.IsNullOrEmpty(location.SystemFaction)) { + controlling_faction = location.SystemFaction; + } + if (!string.IsNullOrEmpty(location.StationName)) { + current_station = location.StationName; + } } else if (e.Is(Events.MissionCompleted)) { var completed = e as MissionCompletedEntry; entry = new MissionCompleted(completed) { System = current_system, Station = current_station }; @@ -145,20 +158,24 @@ namespace EliteBGS.BGS { .Where(x => x.Matches(entry) > 0) .OrderBy(x => x.Matches(entry)) ; - if (matches == null || matches.Count() <= 0) { - continue; - } - /* Then select the one that matches the most. - */ - var objective = matches - .OrderBy(x => x.Matches(entry)) - .Reverse() - .First() - ; - - if (objective == null) { - continue; + Objective objective = null; + if (matches != null && matches.Count() > 0) { + /* Then select the one that matches the most. + */ + objective = matches + .OrderBy(x => x.Matches(entry)) + .Reverse() + .First() + ; + } else { + /* create a new objective if we don't have one */ + objective = new Objective() { + Station = entry.Station, + Faction = entry.Faction, + System = entry.System, + }; + objectives.Add(objective); } LogEntry existing = null;