Esempio n. 1
0
 private void Uctg_OnTravelSelectionChanged(HistoryEntry he, HistoryList hl, bool selectedEntry)
 {
     if (he != null)
     {
         if (last_sys == null || last_sys.Name != he.System.Name) // if new entry is scan, may be new data.. or not presenting or diff sys
         {
             last_sys = he.System;
             DrawSystem(last_sys, last_sys.Name);
         }
         else if (he.EntryType == JournalTypeEnum.StartJump)  // we ignore start jump if overriden
         {
             JournalStartJump jsj = he.journalEntry as JournalStartJump;
             last_sys = new SystemClass(jsj.StarSystem);
             DrawSystem(last_sys, last_sys.Name);
         }
         else if (he.EntryType == JournalTypeEnum.FSSAllBodiesFound)
         {
             DrawSystem(last_sys, last_sys.Name + " " + "System scan complete.".T(EDTx.UserControlSurveyor_Systemscancomplete));
         }
         else if (he.EntryType == JournalTypeEnum.FSSDiscoveryScan)
         {
             var je           = he.journalEntry as JournalFSSDiscoveryScan;
             var bodies_found = je.BodyCount;
             DrawSystem(last_sys, last_sys.Name + " " + bodies_found + " bodies found.".T(EDTx.UserControlSurveyor_bodiesfound));
         }
         else if (he.EntryType == JournalTypeEnum.Scan)
         {
             DrawSystem(last_sys);
         }
     }
 }
Esempio n. 2
0
 private void Uctg_OnTravelSelectionChanged(HistoryEntry he, HistoryList hl, bool selectedEntry)
 {
     if (he != null)
     {
         if (last_sys == null || last_sys.Name != he.System.Name) // if new entry is scan, may be new data.. or not presenting or diff sys
         {
             last_sys = he.System;
             DrawSystem(last_sys, last_sys.Name);
         }
         else if (he.EntryType == JournalTypeEnum.StartJump)         // so we can pre-present
         {
             JournalStartJump jsj = he.journalEntry as JournalStartJump;
             last_sys = new SystemClass(jsj.SystemAddress, jsj.StarSystem);       // important need system address as scan uses it for quick lookup
             DrawSystem(last_sys, last_sys.Name);
         }
         else if (he.EntryType == JournalTypeEnum.FSSAllBodiesFound)     // since we present body counts
         {
             DrawSystem(last_sys, last_sys.Name + " " + "System scan complete.".T(EDTx.UserControlSurveyor_Systemscancomplete));
         }
         else if (he.EntryType == JournalTypeEnum.FSSDiscoveryScan)      // since we present body counts
         {
             var je           = he.journalEntry as JournalFSSDiscoveryScan;
             var bodies_found = je.BodyCount;
             DrawSystem(last_sys, last_sys.Name + " " + bodies_found + " bodies found.".T(EDTx.UserControlSurveyor_bodiesfound));
         }
         else if (he.EntryType == JournalTypeEnum.Scan || he.EntryType == JournalTypeEnum.SAASignalsFound)       // a new scan, or signals found (since we present signals)
         {
             //System.Diagnostics.Debug.WriteLine("Scan got, sys " + he.System.Name + " " + last_sys.Name);
             DrawSystem(last_sys);
         }
     }
 }
Esempio n. 3
0
        private void Uctg_OnTravelSelectionChanged(HistoryEntry he, HistoryList hl, bool selectedEntry)
        {
            if (he != null) // paranoia
            {
                // If not tracked last system, or name differs, its a new system..

                bool nosys = last_sys_tracked == null;

                if (nosys || last_sys_tracked.Name != he.System.Name)
                {
                    last_sys_tracked = he.System;                                        // we want to track system always

                    if (override_system == null && (checkBoxAutoTrack.Checked || nosys)) // if no overridden, and tracking (or no sys), present
                    {
                        PresentSystem(last_sys_tracked);
                    }
                }
                else if (he.EntryType == JournalTypeEnum.StartJump)           // start jump prepresent system..
                {
                    if (override_system == null && checkBoxAutoTrack.Checked) // if not overriding, and tracking, present
                    {
                        JournalStartJump jsj = he.journalEntry as JournalStartJump;
                        last_sys_tracked = new SystemClass(jsj.SystemAddress, jsj.StarSystem);
                        PresentSystem(last_sys_tracked);
                    }
                }
            }
        }
Esempio n. 4
0
        private void Uctgtimer_Tick(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine($"Web browser UCTG timer on {uctghe.System.Name} {wbb != null}");

            if (wbb != null)        // wait till we have a webbrowser
            {
                uctgtimer.Stop();
                bool nosys = last_sys_tracked == null;

                if (nosys || last_sys_tracked.Name != uctghe.System.Name)
                {
                    last_sys_tracked = uctghe.System;                                    // we want to track system always

                    if (override_system == null && (checkBoxAutoTrack.Checked || nosys)) // if no overridden, and tracking (or no sys), present
                    {
                        PresentSystem(last_sys_tracked);
                    }
                }
                else if (uctghe.EntryType == JournalTypeEnum.StartJump)       // start jump prepresent system..
                {
                    if (override_system == null && checkBoxAutoTrack.Checked) // if not overriding, and tracking, present
                    {
                        JournalStartJump jsj = uctghe.journalEntry as JournalStartJump;
                        last_sys_tracked = new SystemClass(jsj.SystemAddress, jsj.StarSystem);
                        PresentSystem(last_sys_tracked);
                    }
                }
            }
        }
Esempio n. 5
0
        private void Uctg_OnTravelSelectionChanged(HistoryEntry he, HistoryList hl, bool selectedEntry)
        {
            if (he != null)
            {
                if (last_sys == null || last_sys.Name != he.System.Name) // if new entry is scan, may be new data.. or not presenting or diff sys
                {
                    last_sys = he.System;                                // even if overridden, we want to track system

                    if (override_system == null)
                    {
                        PresentSystem(last_sys);
                    }
                }
                else if (override_system == null && he.EntryType == JournalTypeEnum.StartJump)  // we ignore start jump if overriden
                {
                    JournalStartJump jsj = he.journalEntry as JournalStartJump;
                    last_sys = new SystemClass(jsj.StarSystem);
                    PresentSystem(last_sys);
                }
            }
        }
Esempio n. 6
0
        public static HistoryEntry FromJournalEntry(JournalEntry je, HistoryEntry prev, bool checkedsm, out bool journalupdate, SQLiteConnectionSystem conn = null, EDCommander cmdr = null)
        {
            ISystem isys    = prev == null ? new SystemClass("Unknown") : prev.System;
            int     indexno = prev == null ? 1 : prev.Indexno + 1;

            int mapcolour = 0;

            journalupdate = false;
            bool starposfromedsm = false;
            bool firstdiscover   = false;

            if (je.EventTypeID == JournalTypeEnum.Location || je.EventTypeID == JournalTypeEnum.FSDJump ||
                (je.EventTypeID == JournalTypeEnum.StartJump && (je as JournalStartJump)?.JumpType == "Hyperspace"))
            {
                JournalLocOrJump jl   = je as JournalLocOrJump;
                JournalFSDJump   jfsd = je as JournalFSDJump;
                JournalStartJump js   = je as JournalStartJump;

                ISystem newsys;

                if (jl != null && jl.HasCoordinate)       // LAZY LOAD IF it has a co-ord.. the front end will when it needs it
                {
                    newsys = new SystemClass(jl.StarSystem, jl.StarPos.X, jl.StarPos.Y, jl.StarPos.Z)
                    {
                        id_edsm         = jl.EdsmID < 0 ? 0 : jl.EdsmID, // pass across the EDSMID for the lazy load process.
                        faction         = jl.Faction,
                        government      = jl.EDGovernment,
                        primary_economy = jl.EDEconomy,
                        security        = jl.EDSecurity,
                        population      = jl.Population ?? 0,
                        state           = jl.EDState,
                        allegiance      = jl.EDAllegiance,
                        UpdateDate      = jl.EventTimeUTC,
                        status          = SystemStatusEnum.EDDiscovery,
                    };

                    if (jfsd != null && jfsd.JumpDist <= 0 && isys.HasCoordinate) // if we don't have a jump distance (pre 2.2) but the last sys does have pos, we can compute distance and update entry
                    {
                        jfsd.JumpDist = SystemClassDB.Distance(isys, newsys);     // fill it out here
                        journalupdate = true;
                    }

                    // If it was a new system, pass the coords back to the StartJump
                    if (prev != null && prev.System.name == newsys.name && !prev.System.HasCoordinate)
                    {
                        prev.System.x = newsys.x;
                        prev.System.y = newsys.y;
                        prev.System.z = newsys.z;
                    }
                }
                else
                {                           // Default one
                    string sysname = jl?.StarSystem ?? js?.StarSystem;

                    newsys         = new SystemClass(sysname);
                    newsys.id_edsm = je.EdsmID;

                    if (checkedsm)                                                                        // see if we can find the right system
                    {
                        ISystem s = SystemCache.FindEDSM(newsys, conn: conn, usedb: true, useedsm: true); // has no co-ord, did we find it?

                        if (s != null)                                                                    // yes, use, and update the journal with the esdmid, and also the position if we have a co-ord
                        {                                                                                 // so next time we don't have to do this again..
                            if (jl != null && jl.HasCoordinate)
                            {
                                s.x = Math.Round(jl.StarPos.X * 32.0) / 32.0;
                                s.y = Math.Round(jl.StarPos.Y * 32.0) / 32.0;
                                s.z = Math.Round(jl.StarPos.Z * 32.0) / 32.0;
                            }

                            newsys = s;

                            if (jfsd != null && jfsd.JumpDist <= 0 && newsys.HasCoordinate && isys.HasCoordinate) // if we don't have a jump distance (pre 2.2) but the last sys does, we can compute
                            {
                                jfsd.JumpDist = SystemClassDB.Distance(isys, newsys);                             // fill it out here.  EDSM systems always have co-ords, but we should check anyway
                                journalupdate = true;
                            }

                            if (je.EdsmID <= 0 && newsys.id_edsm > 0)
                            {
                                journalupdate = true;
                            }
                        }
                    }
                }

                if (jfsd != null)
                {
                    if (jfsd.JumpDist <= 0 && isys.HasCoordinate && newsys.HasCoordinate) // if no JDist, its a really old entry, and if previous has a co-ord
                    {
                        jfsd.JumpDist = SystemClassDB.Distance(isys, newsys);             // fill it out here
                        journalupdate = true;
                    }

                    mapcolour = jfsd.MapColor;
                }

                isys            = newsys;
                starposfromedsm = (jl != null && jl.HasCoordinate) ? jl.StarPosFromEDSM : newsys.HasCoordinate;
                firstdiscover   = jl == null ? false : jl.EDSMFirstDiscover;
            }

            string summary, info, detailed;

            je.FillInformation(out summary, out info, out detailed);

            HistoryEntry he = new HistoryEntry
            {
                Indexno             = indexno,
                EntryType           = je.EventTypeID,
                Journalid           = je.Id,
                journalEntry        = je,
                System              = isys,
                EventTimeUTC        = je.EventTimeUTC,
                MapColour           = mapcolour,
                EdsmSync            = je.SyncedEDSM,
                EDDNSync            = je.SyncedEDDN,
                EGOSync             = je.SyncedEGO,
                StartMarker         = je.StartMarker,
                StopMarker          = je.StopMarker,
                EventSummary        = summary,
                EventDescription    = info,
                EventDetailedInfo   = detailed,
                IsStarPosFromEDSM   = starposfromedsm,
                IsEDSMFirstDiscover = firstdiscover,
                Commander           = cmdr ?? EDCommander.GetCommander(je.CommanderId)
            };


            // WORK out docked/landed state

            if (prev != null)
            {
                if (prev.docked.HasValue)                   // copy docked..
                {
                    he.docked = prev.docked;
                }
                if (prev.landed.HasValue)
                {
                    he.landed = prev.landed;
                }
                if (prev.hyperspace.HasValue)
                {
                    he.hyperspace = prev.hyperspace;
                }

                he.shiptype          = prev.shiptype;
                he.shipid            = prev.shipid;
                he.whereami          = prev.whereami;
                he.onCrewWithCaptain = prev.onCrewWithCaptain;
                he.gamemode          = prev.gamemode;
                he.group             = prev.group;
            }

            if (je.EventTypeID == JournalTypeEnum.Location)
            {
                JournalLocation jl = je as JournalLocation;
                he.docked     = jl.Docked;
                he.whereami   = jl.Docked ? jl.StationName : jl.Body;
                he.hyperspace = false;
            }
            else if (je.EventTypeID == JournalTypeEnum.Docked)
            {
                JournalDocked jl = je as JournalDocked;
                he.docked   = true;
                he.whereami = jl.StationName;
            }
            else if (je.EventTypeID == JournalTypeEnum.Undocked)
            {
                he.docked = false;
            }
            else if (je.EventTypeID == JournalTypeEnum.Touchdown)
            {
                he.landed = true;
            }
            else if (je.EventTypeID == JournalTypeEnum.Liftoff)
            {
                he.landed = false;
            }
            else if (je.EventTypeID == JournalTypeEnum.SupercruiseEntry)
            {
                he.whereami   = (je as JournalSupercruiseEntry).StarSystem;
                he.hyperspace = true;
            }
            else if (je.EventTypeID == JournalTypeEnum.SupercruiseExit)
            {
                he.whereami   = (je as JournalSupercruiseExit).Body;
                he.hyperspace = false;
            }
            else if (je.EventTypeID == JournalTypeEnum.FSDJump)
            {
                he.whereami   = (je as JournalFSDJump).StarSystem;
                he.hyperspace = true;
            }
            else if (je.EventTypeID == JournalTypeEnum.StartJump)
            {
                he.hyperspace = true;   // some of these are just to make sure, as FSDJump will also set it
            }
            else if (je.EventTypeID == JournalTypeEnum.LoadGame)
            {
                JournalLoadGame jl = je as JournalLoadGame;

                he.onCrewWithCaptain = null;        // can't be in a crew at this point
                he.gamemode          = jl.GameMode; // set game mode
                he.group             = jl.Group;    // and group, may be empty
                he.landed            = jl.StartLanded;
                he.hyperspace        = false;

                if (jl.Ship.IndexOf("buggy", StringComparison.InvariantCultureIgnoreCase) == -1)        // load game with buggy, can't tell what ship we get back into, so ignore
                {
                    he.shiptype = (je as JournalLoadGame).Ship;
                    he.shipid   = (je as JournalLoadGame).ShipId;
                }
            }
            else if (je.EventTypeID == JournalTypeEnum.ShipyardBuy)         // BUY does not have ship id, but the new entry will that is written later - journals 8.34
            {
                he.shiptype = (je as JournalShipyardBuy).ShipType;
            }
            else if (je.EventTypeID == JournalTypeEnum.ShipyardNew)
            {
                he.shiptype = (je as JournalShipyardNew).ShipType;
                he.shipid   = (je as JournalShipyardNew).ShipId;
            }
            else if (je.EventTypeID == JournalTypeEnum.ShipyardSwap)
            {
                he.shiptype = (je as JournalShipyardSwap).ShipType;
                he.shipid   = (je as JournalShipyardSwap).ShipId;
            }
            else if (je.EventTypeID == JournalTypeEnum.JoinACrew)
            {
                he.onCrewWithCaptain = (je as JournalJoinACrew).Captain;
            }
            else if (je.EventTypeID == JournalTypeEnum.QuitACrew)
            {
                he.onCrewWithCaptain = null;
            }

            if (prev != null && prev.travelling)      // if we are travelling..
            {
                he.travelled_distance    = prev.travelled_distance;
                he.travelled_missingjump = prev.travelled_missingjump;
                he.travelled_jumps       = prev.travelled_jumps;

                if (he.IsFSDJump && !he.MultiPlayer)   // if jump, and not multiplayer..
                {
                    double dist = ((JournalFSDJump)je).JumpDist;
                    if (dist <= 0)
                    {
                        he.travelled_missingjump++;
                    }
                    else
                    {
                        he.travelled_distance += dist;
                        he.travelled_jumps++;
                    }
                }

                he.travelled_seconds = prev.travelled_seconds;
                TimeSpan diff = he.EventTimeUTC.Subtract(prev.EventTimeUTC);

                if (he.EntryType != JournalTypeEnum.LoadGame && diff < new TimeSpan(2, 0, 0))   // time between last entry and load game is not real time
                {
                    he.travelled_seconds += diff;
                }

                if (he.StopMarker || he.StartMarker)
                {
                    //Debug.WriteLine("Travelling stop at " + he.Indexno);
                    he.travelling         = false;
                    he.EventDetailedInfo += ((he.EventDetailedInfo.Length > 0) ? Environment.NewLine : "") + "Travelled " + he.travelled_distance.ToStringInvariant("0.0") + " LY"
                                            + ", " + he.travelled_jumps + " jumps"
                                            + ((he.travelled_missingjump > 0) ? ", " + he.travelled_missingjump + " unknown distance jumps" : "") +
                                            ", time " + he.travelled_seconds;

                    he.travelled_distance = 0;
                    he.travelled_seconds  = new TimeSpan(0);
                }
                else
                {
                    he.travelling = true;

                    if (he.IsFSDJump)
                    {
                        he.EventDetailedInfo += ((he.EventDetailedInfo.Length > 0) ? Environment.NewLine : "") + "Travelling" +
                                                " distance " + he.travelled_distance.ToString("0.0") + " LY"
                                                + ", " + he.travelled_jumps + " jumps"
                                                + ((he.travelled_missingjump > 0) ? ", " + he.travelled_missingjump + " unknown distance jumps" : "") +
                                                ", time " + he.travelled_seconds;
                    }
                }
            }

            if (he.StartMarker)
            {
                //Debug.WriteLine("Travelling start at " + he.Indexno);
                he.travelling = true;
            }

            return(he);
        }