コード例 #1
0
        // go through the history list and recalculate the materials ledger and the materials count, plus any other stuff..
        public void ProcessUserHistoryListEntries(Func <HistoryList, List <HistoryEntry> > hlfilter)
        {
            List <HistoryEntry> hl = hlfilter(this);

            using (SQLiteConnectionUser conn = new SQLiteConnectionUser())      // splitting the update into two, one using system, one using user helped
            {
                for (int i = 0; i < hl.Count; i++)
                {
                    HistoryEntry he = hl[i];
                    JournalEntry je = he.journalEntry;
                    he.ProcessWithUserDb(je, (i > 0) ? hl[i - 1] : null, this, conn);        // let the HE do what it wants to with the user db

                    Debug.Assert(he.MaterialCommodity != null);

                    // **** REMEMBER NEW Journal entry needs this too *****************

                    cashledger.Process(je, conn);            // update the ledger
                    he.Credits = cashledger.CashTotal;

                    Tuple <ShipInformation, ModulesInStore> ret = shipinformationlist.Process(je, conn);  // the ships
                    he.ShipInformation = ret.Item1;
                    he.StoredModules   = ret.Item2;

                    he.MissionList = missionlistaccumulator.Process(je, he.System, he.WhereAmI, conn);                           // the missions

                    if (je.EventTypeID == JournalTypeEnum.Scan)
                    {
                        if (!this.starscan.AddScanToBestSystem(je as JournalScan, i, hl))
                        {
                            System.Diagnostics.Debug.WriteLine("******** Cannot add scan to system " + (je as JournalScan).BodyName + " in " + he.System.name);
                        }
                    }
                }
            }
        }
コード例 #2
0
        // Called on a New Entry, by EDDiscoveryController:NewEntry, to add an journal entry in

        public HistoryEntry AddJournalEntry(JournalEntry je, Action <string> logerror)   // always return he
        {
            HistoryEntry prev = GetLast;

            bool         journalupdate = false;
            HistoryEntry he            = HistoryEntry.FromJournalEntry(je, prev, out journalupdate); // we may check edsm for this entry

            if (journalupdate)
            {
                JournalFSDJump jfsd = je as JournalFSDJump;

                if (jfsd != null)
                {
                    JournalEntry.UpdateEDSMIDPosJump(jfsd.Id, he.System, !jfsd.HasCoordinate && he.System.HasCoordinate, jfsd.JumpDist);
                }
            }

            using (SQLiteConnectionUser conn = new SQLiteConnectionUser())
            {
                he.ProcessWithUserDb(je, prev, this, conn);           // let some processes which need the user db to work

                cashledger.Process(je, conn);
                he.Credits = cashledger.CashTotal;

                Tuple <ShipInformation, ModulesInStore> ret = shipinformationlist.Process(je, conn);
                he.ShipInformation = ret.Item1;
                he.StoredModules   = ret.Item2;

                he.MissionList = missionlistaccumulator.Process(je, he.System, he.WhereAmI, conn);
            }

            historylist.Add(he);

            if (je.EventTypeID == JournalTypeEnum.Scan)
            {
                JournalScan      js = je as JournalScan;
                JournalLocOrJump jl;
                HistoryEntry     jlhe;
                if (!starscan.AddScanToBestSystem(js, Count - 1, EntryOrder, out jlhe, out jl))
                {
                    // Ignore scans where the system name has been changed
                    // Also ignore belt clusters
                    if (jl == null || (jl.StarSystem.Equals(jlhe.System.Name, StringComparison.InvariantCultureIgnoreCase) && !js.BodyDesignation.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 if (je is IBodyNameAndID)
            {
                JournalLocOrJump jl;
                HistoryEntry     jlhe;
                starscan.AddBodyToBestSystem((IBodyNameAndID)je, Count - 1, EntryOrder, out jlhe, out jl);
            }

            return(he);
        }
コード例 #3
0
        }                                                                       // SPECIAL USE ONLY - DOES NOT COMPUTE ALL THE OTHER STUFF

        #region Entry processing

        // Called on a New Entry, by EDDiscoveryController:NewEntry, to add an journal entry in.  May return null or empty list, or multiple entries.

        public List <HistoryEntry> AddJournalEntryToHistory(JournalEntry je, Action <string> logerror)
        {
            HistoryEntry he = HistoryEntry.FromJournalEntry(je, hlastprocessed);     // we may check edsm for this entry

            he.UpdateMaterialsCommodities(MaterialCommoditiesMicroResources.Process(je, hlastprocessed?.journalEntry, he.Status.TravelState == HistoryEntryStatus.TravelStateType.SRV));

            // IN THIS order, so suits can be added, then weapons, then loadouts
            he.UpdateSuits(SuitList.Process(je, he.WhereAmI, he.System));
            he.UpdateWeapons(WeaponList.Process(je, he.WhereAmI, he.System));
            he.UpdateLoadouts(SuitLoadoutList.Process(je, WeaponList, he.WhereAmI, he.System));

            // 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

            he.UpdateStats(je, statisticsaccumulator, he.StationFaction);
            he.UpdateSystemNote();

            CashLedger.Process(je);
            he.Credits = CashLedger.CashTotal;

            Shipyards.Process(je);
            Outfitting.Process(je);

            Tuple <ShipInformation, ModulesInStore> ret = ShipInformationList.Process(je, he.WhereAmI, he.System);

            he.UpdateShipInformation(ret.Item1);
            he.UpdateShipStoredModules(ret.Item2);

            he.UpdateMissionList(MissionListAccumulator.Process(je, he.System, he.WhereAmI));

            hlastprocessed = he;

            var reorderlist = ReorderRemove(he);

            foreach (var heh in reorderlist.EmptyIfNull())
            {
                heh.Index = historylist.Count; // store its index
                historylist.Add(heh);          // then add to history
                AddToVisitsScan(logerror);     // add to scan database and complain if can't add. Do this after history add, so it has a list.
            }

            return(reorderlist);
        }
コード例 #4
0
        // Called on a New Entry, by EDDiscoveryController:NewEntry, to add an journal entry in.  May return null if don't want it in history

        public HistoryEntry AddJournalEntryToHistory(JournalEntry je, Action <string> logerror)
        {
            HistoryEntry hprev = GetLast;

            HistoryEntry he = HistoryEntry.FromJournalEntry(je, hprev);     // we may check edsm for this entry

            he.UpdateMaterialsCommodities(MaterialCommoditiesMicroResources.Process(je));

            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
            {
                return(null);
            }

            he.UpdateStats(je, statisticsaccumulator, he.StationFaction);
            he.UpdateSystemNote();

            CashLedger.Process(je);
            he.Credits = CashLedger.CashTotal;

            Shipyards.Process(je);
            Outfitting.Process(je);

            Tuple <ShipInformation, ModulesInStore> ret = ShipInformationList.Process(je, he.WhereAmI, he.System);

            he.UpdateShipInformation(ret.Item1);
            he.UpdateShipStoredModules(ret.Item2);

            he.UpdateMissionList(MissionListAccumulator.Process(je, he.System, he.WhereAmI));

            he.UpdateWeapons(WeaponList.Process(je, he.WhereAmI, he.System));          // update the entries in suit entry list
            he.UpdateSuits(SuitList.Process(je, he.WhereAmI, he.System));
            he.UpdateLoadouts(SuitLoadoutList.Process(je, WeaponList, he.WhereAmI, he.System));

            historylist.Add(he);                                         // then add to history

            AddToVisitsScan(this, this.historylist.Count - 1, logerror); // add to scan database and complain if can't add. Do this after history add, so it has a list.

            return(he);
        }
コード例 #5
0
        // Called on a New Entry, by EDDiscoveryController:NewEntry, to add an journal entry in.  May return null if don't want it in history

        public HistoryEntry AddJournalEntryToHistory(JournalEntry je, Action <string> logerror)
        {
            HistoryEntry hprev = GetLast;

            HistoryEntry he = HistoryEntry.FromJournalEntry(je, hprev);     // we may check edsm for this entry

            he.UpdateMaterialsCommodities(je, hprev?.MaterialCommodity);    // let some processes which need the user db to work
            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
            {
                return(null);
            }

            he.UpdateStats(je, hprev?.Stats, he.StationFaction);
            he.UpdateSystemNote();

            CashLedger.Process(je);
            he.Credits = CashLedger.CashTotal;

            Shipyards.Process(je);
            Outfitting.Process(je);

            Tuple <ShipInformation, ModulesInStore> ret = ShipInformationList.Process(je, he.WhereAmI, he.System);

            he.UpdateShipInformation(ret.Item1);
            he.UpdateShipStoredModules(ret.Item2);

            he.UpdateMissionList(missionlistaccumulator.Process(je, he.System, he.WhereAmI));

            historylist.Add(he);                 // then add to history

            AddToVisitsScan(this, he, logerror); // add to scan database and complain if can't add. Do this after history add, so it has a list.

            return(he);
        }