//Called from networkWorker
        public void QueueVesselRemove(Guid vesselID, double planetTime, bool isDockingUpdate, string dockingPlayer)
        {
            lock (updateQueueLock)
            {

                if (!vesselRemoveQueue.ContainsKey(vesselID))
                {
                    vesselRemoveQueue.Add(vesselID, new Queue<VesselRemoveEntry>());
                }

                Queue<VesselRemoveEntry> vrQueue = vesselRemoveQueue[vesselID];
                if (vesselRemoveHistoryTime.ContainsKey(vesselID))
                {
                    //If we get a remove older than the current queue peek, then someone has gone back in time and the timeline needs to be fixed.
                    if (planetTime < vesselRemoveHistoryTime[vesselID])
                    {
                        DarkLog.Debug("Vessel " + vesselID + " went back in time - rewriting the remove history for it.");
                        Queue<VesselRemoveEntry> newQueue = new Queue<VesselRemoveEntry>();
                        while (vrQueue.Count > 0)
                        {
                            VesselRemoveEntry oldVre = vrQueue.Dequeue();
                            //Save the updates from before the revert
                            if (oldVre.planetTime < planetTime)
                            {
                                newQueue.Enqueue(oldVre);
                            }
                        }
                        vrQueue = newQueue;
                        vesselRemoveQueue[vesselID] = newQueue;
                        //Clean the history too
                        if (Settings.fetch.revertEnabled)
                        {
                            if (vesselRemoveHistory.ContainsKey(vesselID))
                            {
                                List<VesselRemoveEntry> vrh = vesselRemoveHistory[vesselID];
                                foreach (VesselRemoveEntry oldVr in vrh.ToArray())
                                {
                                    if (oldVr.planetTime > planetTime)
                                    {
                                        vrh.Remove(oldVr);
                                    }
                                }
                            }
                        }
                    }
                }

                VesselRemoveEntry vre = new VesselRemoveEntry();
                vre.planetTime = planetTime;
                vre.vesselID = vesselID;
                vre.isDockingUpdate = isDockingUpdate;
                vre.dockingPlayer = dockingPlayer;
                vrQueue.Enqueue(vre);
                if (latestVesselUpdate.ContainsKey(vesselID) ? latestVesselUpdate[vesselID] < planetTime : true)
                {
                    latestVesselUpdate[vesselID] = planetTime;
                }
                if (Settings.fetch.revertEnabled)
                {
                    if (!vesselRemoveHistory.ContainsKey(vesselID))
                    {
                        vesselRemoveHistory.Add(vesselID, new List<VesselRemoveEntry>());
                    }
                    vesselRemoveHistory[vesselID].Add(vre);
                }
                vesselRemoveHistoryTime[vesselID] = planetTime;
            }
        }
示例#2
0
 //Called from networkWorker
 public void QueueVesselRemove(string vesselID, double planetTime, bool isDockingUpdate, string dockingPlayer)
 {
     lock (updateQueueLock)
     {
         if (!vesselRemoveQueue.ContainsKey(vesselID))
         {
             vesselRemoveQueue.Add(vesselID, new Queue<VesselRemoveEntry>());
         }
         VesselRemoveEntry vre = new VesselRemoveEntry();
         vre.planetTime = planetTime;
         vre.vesselID = vesselID;
         vre.isDockingUpdate = isDockingUpdate;
         vre.dockingPlayer = dockingPlayer;
         vesselRemoveQueue[vesselID].Enqueue(vre);
         if (latestVesselUpdate.ContainsKey(vesselID) ? latestVesselUpdate[vesselID] < planetTime : true)
         {
             latestVesselUpdate[vesselID] = planetTime;
         }
     }
 }
示例#3
0
 //Called from networkWorker
 public void QueueVesselRemove(int subspace, double planetTime, string vesselID, bool isDockingUpdate, string dockingPlayer)
 {
     if (!vesselRemoveQueue.ContainsKey(subspace))
     {
         SetupSubspace(subspace);
     }
     VesselRemoveEntry vre = new VesselRemoveEntry();
     vre.planetTime = planetTime;
     vre.vesselID = vesselID;
     vre.isDockingUpdate = isDockingUpdate;
     vre.dockingPlayer = dockingPlayer;
     vesselRemoveQueue[subspace].Enqueue(vre);
     if (latestVesselUpdate.ContainsKey(vesselID) ? latestVesselUpdate[vesselID] < planetTime : true)
     {
         latestVesselUpdate[vesselID] = planetTime;
     }
 }