private void Discoveryform_OnNewEntry(EliteDangerousCore.HistoryEntry he, EliteDangerousCore.HistoryList hel) { if (current != null) { bool tryadd = true; // normally go for it.. if (current.Type == FilterEntry.EntryType.Time) // time is limited { tryadd = he.EventTimeUTC <= current.EndTime; } else if (current.Type == FilterEntry.EntryType.Mission) // mission is limited, lookup mission and check end time { MissionState ml = current.MissionKey != null && he.MissionList.Missions.ContainsKey(current.MissionKey) ? he.MissionList.Missions[current.MissionKey] : null; tryadd = ml != null ? (he.EventTimeUTC <= ml.MissionEndTime) : false; } if (tryadd) { if (AddToGrid(he, true)) // if did add.. { SetLabels(); } } } if (he.EntryType == JournalTypeEnum.MissionAccepted) // mission accepted means another entry.. { FillCampaignCombo(); // could only add entries, so no need to check it its disappeared } }
private void Discoveryform_OnHistoryChange(EliteDangerousCore.HistoryList obj) // called if history re-read, so need to recalc combo and display { bool firsttime = comboBoxCustomCampaign.Items.Count == 0; FillCampaignCombo(); if (firsttime) { SelectInitial(); // pick saved entry.. } else { CheckCurrent(); // someone changed history, see if we still have that entry.. } Display(); }
private void Discoveryform_OnNewEntry(EliteDangerousCore.HistoryEntry he, EliteDangerousCore.HistoryList hel) { if (current != null) { bool tryadd = true; // normally go for it.. if (current.Type == FilterEntry.EntryType.Time) // time is limited { tryadd = he.EventTimeUTC <= current.EndTimeUTC; } else if (current.Type == FilterEntry.EntryType.Mission) // mission is limited, lookup mission and check end time { MissionState ms = hel.MissionListAccumulator.GetMission(current.MissionKey ?? "-"); tryadd = ms != null ? (he.EventTimeUTC <= ms.MissionEndTime) : false; } if (tryadd) { if (insertToGrid(he)) // if did add.. { SetLabels(); } } if (he.EntryType == JournalTypeEnum.Undocked && current.Type == FilterEntry.EntryType.Lastdock) // on undock, and we are in last docked mode, refresh { Display(); } } if (he.EntryType == JournalTypeEnum.MissionAccepted) // mission accepted means another entry.. { FillCampaignCombo(); // could only add entries, so no need to check it its disappeared } SetTarget(he); }
public JToken NewSRec(EliteDangerousCore.HistoryList hl, string type, int entry) // entry = -1 means latest { HistoryEntry he = hl.EntryOrder()[entry]; JObject response = new JObject(); response["responsetype"] = type; response["entry"] = entry; JObject systemdata = new JObject(); systemdata["System"] = he.System.Name; systemdata["SystemAddress"] = he.System.SystemAddress; systemdata["PosX"] = he.System.X.ToStringInvariant("0.00"); systemdata["PosY"] = he.System.Y.ToStringInvariant("0.00"); systemdata["PosZ"] = he.System.Z.ToStringInvariant("0.00"); systemdata["EDSMID"] = he.System.EDSMID.ToStringInvariant(); systemdata["VisitCount"] = hl.GetVisitsCount(he.System.Name); response["SystemData"] = systemdata; // TBD.. if EDSMID = 0 , we may not have looked at it in the historywindow, do we want to do a lookup? JObject sysstate = new JObject(); hl.ReturnSystemInfo(he, out string allegiance, out string economy, out string gov, out string faction, out string factionstate, out string security); sysstate["State"] = factionstate; sysstate["Allegiance"] = allegiance; sysstate["Gov"] = gov; sysstate["Economy"] = economy; sysstate["Faction"] = faction; sysstate["Security"] = security; sysstate["MarketID"] = he.MarketID; response["EDDB"] = sysstate; var mcl = hl.MaterialCommoditiesMicroResources.Get(he.MaterialCommodity); int cargocount = MaterialCommoditiesMicroResourceList.CargoCount(mcl); string shipname = "N/A", fuel = "N/A", range = "N/A", tanksize = "N/A"; string cargo = cargocount.ToStringInvariant(); ShipInformation si = he.ShipInformation; if (si != null) { shipname = si.ShipFullInfo(cargo: false, fuel: false); if (si.FuelLevel > 0) { fuel = si.FuelLevel.ToStringInvariant("0.#"); } if (si.FuelCapacity > 0) { tanksize = si.FuelCapacity.ToStringInvariant("0.#"); } EliteDangerousCalculations.FSDSpec fsd = si.GetFSDSpec(); if (fsd != null) { EliteDangerousCalculations.FSDSpec.JumpInfo ji = fsd.GetJumpInfo(cargocount, si.ModuleMass() + si.HullMass(), si.FuelLevel, si.FuelCapacity / 2); range = ji.cursinglejump.ToString("N2") + "ly"; } int cargocap = si.CargoCapacity(); if (cargocap > 0) { cargo += "/" + cargocap.ToStringInvariant(); } } JObject ship = new JObject(); ship["Ship"] = shipname; ship["Fuel"] = fuel; ship["Range"] = range; ship["TankSize"] = tanksize; ship["Cargo"] = cargo; ship["Data"] = MaterialCommoditiesMicroResourceList.DataCount(mcl).ToStringInvariant(); ship["Materials"] = MaterialCommoditiesMicroResourceList.MaterialsCount(mcl).ToStringInvariant(); ship["MicroResources"] = MaterialCommoditiesMicroResourceList.MicroResourcesCount(mcl).ToStringInvariant(); response["Ship"] = ship; JObject travel = new JObject(); if (he.isTravelling) { travel["Dist"] = he.TravelledDistance.ToStringInvariant("0.0"); travel["Jumps"] = he.Travelledjumps.ToStringInvariant(); travel["UnknownJumps"] = he.TravelledMissingjump.ToStringInvariant(); travel["Time"] = he.TravelledSeconds.ToString(); } else { travel["Time"] = travel["Jumps"] = travel["Dist"] = ""; } response["Travel"] = travel; response["Bodyname"] = he.WhereAmI; if (he.System.HasCoordinate) // cursystem has them? { response["HomeDist"] = he.System.Distance(EDCommander.Current.HomeSystemIOrSol).ToString("0.##"); response["SolDist"] = he.System.Distance(0, 0, 0).ToString("0.##"); } else { response["SolDist"] = response["HomeDist"] = "-"; } response["GameMode"] = he.GameModeGroup; response["Credits"] = he.Credits.ToStringInvariant(); response["Commander"] = EDCommander.Current.Name; response["Mode"] = he.TravelState.ToString(); return(response); }
public static void AddToVisitsScan(HistoryList hist, HistoryEntry he, Action <string> logerror) { if ((hist.LastSystem == null || he.System.Name != hist.LastSystem) && he.System.Name != "Unknown") // if system is not last, we moved somehow (FSD, location, carrier jump), add { if (hist.Visited.TryGetValue(he.System.Name, out var value)) { he.Visits = value.Visits + 1; // visits is 1 more than previous entry hist.Visited[he.System.Name] = he; // reset to point to latest he } else { he.Visits = 1; // first visit hist.Visited[he.System.Name] = he; // point to he } hist.LastSystem = he.System.Name; } if (he.EntryType == JournalTypeEnum.Scan) { if (logerror != null) { BaseUtils.AppTicks.TickCountLapDelta("Scan", true); } JournalScan js = he.journalEntry as JournalScan; if (!hist.StarScan.AddScanToBestSystem(js, hist.historylist.Count - 1, hist.historylist, out HistoryEntry jlhe, out JournalLocOrJump jl)) { if (logerror != null) { // Ignore scans where the system name has been changed // Also ignore belt clusters var bodyname = js.BodyDesignation ?? js.BodyName; if (bodyname == null) { logerror("Body name not set in scan entry"); } else if (jl == null || (jl.StarSystem.Equals(jlhe.System.Name, StringComparison.InvariantCultureIgnoreCase) && !bodyname.ToLowerInvariant().Contains(" belt cluster "))) { logerror("Cannot add scan to system - alert the EDDiscovery developers using either discord or Github (see help)" + Environment.NewLine + "Scan object " + js.BodyName + " in " + he.System.Name); } } else { System.Diagnostics.Debug.WriteLine("******** Cannot add scan to system " + (he.journalEntry as JournalScan).BodyName + " in " + he.System.Name); } } if (logerror != null) { System.Diagnostics.Debug.WriteLine(BaseUtils.AppTicks.TickCountLap("Scan") + " Scan End"); } } else if (he.EntryType == JournalTypeEnum.SAAScanComplete) { hist.StarScan.AddSAAScanToBestSystem((JournalSAAScanComplete)he.journalEntry, hist.historylist.Count - 1, hist.historylist); } else if (he.EntryType == JournalTypeEnum.SAASignalsFound) { hist.StarScan.AddSAASignalsFoundToBestSystem((JournalSAASignalsFound)he.journalEntry, hist.historylist.Count - 1, hist.historylist); } else if (he.EntryType == JournalTypeEnum.FSSDiscoveryScan && he.System != null) { hist.StarScan.SetFSSDiscoveryScan((JournalFSSDiscoveryScan)he.journalEntry, he.System); } else if (he.journalEntry is IBodyNameAndID) { hist.StarScan.AddBodyToBestSystem((IBodyNameAndID)he.journalEntry, hist.historylist.Count - 1, hist.historylist); } }
public static HistoryList LoadHistory(EDJournalUIScanner journalmonitor, Func <bool> cancelRequested, Action <int, string> reportProgress, string NetLogPath = null, bool ForceNetLogReload = false, bool ForceJournalReload = false, int CurrentCommander = Int32.MinValue, int fullhistoryloaddaylimit = 0, string essentialitems = "" ) { HistoryList hist = new HistoryList(); if (CurrentCommander >= 0) { journalmonitor.SetupWatchers(); // Parse files stop monitor.. int forcereloadoflastn = ForceJournalReload ? int.MaxValue / 2 : 0; // if forcing a reload, we indicate that by setting the reload count to a very high value, but not enough to cause int wrap journalmonitor.ParseJournalFilesOnWatchers((p, s) => reportProgress(p, s), forcereloadoflastn); if (NetLogPath != null) { string errstr = null; NetLogClass.ParseFiles(NetLogPath, out errstr, EDCommander.Current.MapColour, () => cancelRequested(), (p, s) => reportProgress(p, s), ForceNetLogReload, currentcmdrid: CurrentCommander); } } Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Files read "); reportProgress(-1, "Reading Database"); List <JournalEntry> jlist; // returned in date ascending, oldest first order. System.Diagnostics.Debug.WriteLine(BaseUtils.AppTicks.TickCountLapDelta("HLL", true) + "History Load"); if (fullhistoryloaddaylimit > 0) { var list = (essentialitems == nameof(JournalEssentialEvents.JumpScanEssentialEvents)) ? JournalEssentialEvents.JumpScanEssentialEvents : (essentialitems == nameof(JournalEssentialEvents.JumpEssentialEvents)) ? JournalEssentialEvents.JumpEssentialEvents : (essentialitems == nameof(JournalEssentialEvents.NoEssentialEvents)) ? JournalEssentialEvents.NoEssentialEvents : (essentialitems == nameof(JournalEssentialEvents.FullStatsEssentialEvents)) ? JournalEssentialEvents.FullStatsEssentialEvents : JournalEssentialEvents.EssentialEvents; jlist = JournalEntry.GetAll(CurrentCommander, ids: list, allidsafterutc: DateTime.UtcNow.Subtract(new TimeSpan(fullhistoryloaddaylimit, 0, 0, 0)) ); } else { jlist = JournalEntry.GetAll(CurrentCommander); } System.Diagnostics.Debug.WriteLine(BaseUtils.AppTicks.TickCountLapDelta("HLL") + "History Load END"); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Database read " + jlist.Count); HistoryEntry hprev = null; JournalEntry jprev = null; reportProgress(-1, "Creating History"); Stopwatch sw = new Stopwatch(); sw.Start(); foreach (JournalEntry je in jlist) { if (MergeEntries(jprev, je)) // if we merge, don't store into HE { continue; } // Clean up "UnKnown" systems from EDSM log if (je is JournalFSDJump && ((JournalFSDJump)je).StarSystem == "UnKnown") { JournalEntry.Delete(je.Id); continue; } if (je is EliteDangerousCore.JournalEvents.JournalMusic) // remove music.. not shown.. now UI event. remove it for backwards compatibility { //System.Diagnostics.Debug.WriteLine("**** Filter out " + je.EventTypeStr + " on " + je.EventTimeLocal.ToString()); continue; } long timetoload = sw.ElapsedMilliseconds; HistoryEntry he = HistoryEntry.FromJournalEntry(je, hprev); // **** REMEMBER NEW Journal entry needs this too ***************** he.UpdateMaterialsCommodities(je, hprev?.MaterialCommodity); // update material commodities Debug.Assert(he.MaterialCommodity != null); if (CheckForRemoval(he, hprev)) // check here to see if we want to remove the entry.. can move this lower later, but at first point where we have the data { continue; } he.UpdateStats(je, hprev?.Stats, he.StationFaction); he.UpdateSystemNote(); hist.CashLedger.Process(je); // update the ledger he.Credits = hist.CashLedger.CashTotal; hist.Shipyards.Process(je); hist.Outfitting.Process(je); Tuple <ShipInformation, ModulesInStore> ret = hist.ShipInformationList.Process(je, he.WhereAmI, he.System); // the ships he.UpdateShipInformation(ret.Item1); he.UpdateShipStoredModules(ret.Item2); he.UpdateMissionList(hist.missionlistaccumulator.Process(je, he.System, he.WhereAmI)); hist.historylist.Add(he); // now add it to the history AddToVisitsScan(hist, he, null); // add to scan but don't complain if can't add. Do this AFTER add, as it uses the history list hprev = he; jprev = je; } //for (int i = hist.Count - 10; i < hist.Count; i++) System.Diagnostics.Debug.WriteLine("Hist {0} {1} {2}", hist[i].EventTimeUTC, hist[i].Indexno , hist[i].EventSummary); // now database has been updated due to initial fill, now fill in stuff which needs the user database hist.CommanderId = CurrentCommander; EDCommander.Current.FID = hist.GetCommanderFID(); // ensure FID is set.. the other place it gets changed is a read of LoadGame. if (NetLogPath != null) { reportProgress(-1, "Netlog Updating System Positions"); hist.FillInPositionsFSDJumps(); // if netlog reading, try and resolve systems.. } reportProgress(-1, "Done"); return(hist); }
public void ProcessWithUserDb(JournalEntry je, HistoryEntry prev, HistoryList hl) // called after above with a USER connection { MaterialCommodity = MaterialCommoditiesList.Process(je, prev?.MaterialCommodity); snc = SystemNoteClass.GetSystemNote(Journalid, IsFSDJump, System); // may be null }