Exemple #1
0
 // everywhere
 public int GetVisitsCount(string name)
 {
     if (Visited.TryGetValue(name, out var he))
     {
         return(he.Visits);
     }
     else
     {
         return(0);
     }
 }
Exemple #2
0
 public int Visits(string name)
 {
     return(Visited.TryGetValue(name, out var res) ? res.Visits : 0);
 }
        public void AddToVisitsScan(Action <string> logerror)
        {
            HistoryEntry he = GetLast;

            if ((LastSystem == null || he.System.Name != LastSystem) && he.System.Name != "Unknown")     // if system is not last, we moved somehow (FSD, location, carrier jump), add
            {
                if (Visited.TryGetValue(he.System.Name, out var value))
                {
                    he.Visits = value.Visits + 1;          // visits is 1 more than previous entry
                    Visited[he.System.Name] = he;          // reset to point to latest he
                }
                else
                {
                    he.Visits = 1;                         // first visit
                    Visited[he.System.Name] = he;          // point to he
                }

                LastSystem = he.System.Name;
            }

            int pos = historylist.Count - 1;                // current entry index

            if (he.EntryType == JournalTypeEnum.Scan)
            {
                JournalScan js = he.journalEntry as JournalScan;

                if (!StarScan.AddScanToBestSystem(js, pos - 1, 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);
                    }
                }
            }
            else if (he.EntryType == JournalTypeEnum.SAAScanComplete)
            {
                StarScan.AddSAAScanToBestSystem((JournalSAAScanComplete)he.journalEntry, pos, historylist);
            }
            else if (he.EntryType == JournalTypeEnum.SAASignalsFound)
            {
                StarScan.AddSAASignalsFoundToBestSystem((JournalSAASignalsFound)he.journalEntry, pos, historylist);
            }
            else if (he.EntryType == JournalTypeEnum.FSSDiscoveryScan)
            {
                StarScan.SetFSSDiscoveryScan((JournalFSSDiscoveryScan)he.journalEntry, he.System);
            }
            else if (he.EntryType == JournalTypeEnum.FSSSignalDiscovered)
            {
                StarScan.AddFSSSignalsDiscoveredToSystem((JournalFSSSignalDiscovered)he.journalEntry, he.System);
            }
            else if (he.journalEntry is IBodyNameAndID)
            {
                StarScan.AddBodyToBestSystem((IBodyNameAndID)he.journalEntry, pos, historylist);
            }
        }