Exemplo n.º 1
0
 //Called from networkWorker
 public void QueueKerbal(double planetTime, string kerbalName, ConfigNode kerbalNode)
 {
     KerbalEntry newEntry = new KerbalEntry();
     newEntry.planetTime = planetTime;
     newEntry.kerbalNode = kerbalNode;
     if (!kerbalProtoQueue.ContainsKey(kerbalName))
     {
         kerbalProtoQueue.Add(kerbalName, new Queue<KerbalEntry>());
     }
     kerbalProtoQueue[kerbalName].Enqueue(newEntry);
 }
Exemplo n.º 2
0
 //Called from networkWorker
 public void QueueKerbal(int subspace, double planetTime, int kerbalID, ConfigNode kerbalNode)
 {
     KerbalEntry newEntry = new KerbalEntry();
     newEntry.kerbalID = kerbalID;
     newEntry.planetTime = planetTime;
     newEntry.kerbalNode = kerbalNode;
     if (!kerbalProtoQueue.ContainsKey(subspace))
     {
         kerbalProtoQueue.Add(subspace, new Queue<KerbalEntry>());
     }
     kerbalProtoQueue[subspace].Enqueue(newEntry);
 }
Exemplo n.º 3
0
        //Called from networkWorker
        public void QueueKerbal(double planetTime, string kerbalName, ConfigNode kerbalNode)
        {
            lock (updateQueueLock)
            {
                KerbalEntry newEntry = new KerbalEntry();
                newEntry.planetTime = planetTime;
                newEntry.kerbalNode = kerbalNode;
                if (!kerbalProtoQueue.ContainsKey(kerbalName))
                {
                    kerbalProtoQueue.Add(kerbalName, new Queue<KerbalEntry>());
                }

                Queue<KerbalEntry> keQueue = kerbalProtoQueue[kerbalName];
                if (kerbalProtoHistoryTime.ContainsKey(kerbalName))
                {
                    //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 < kerbalProtoHistoryTime[kerbalName])
                    {
                        DarkLog.Debug("Kerbal " + kerbalName + " went back in time - rewriting the remove history for it.");
                        Queue<KerbalEntry> newQueue = new Queue<KerbalEntry>();
                        while (keQueue.Count > 0)
                        {
                            KerbalEntry oldKe = keQueue.Dequeue();
                            //Save the updates from before the revert
                            if (oldKe.planetTime < planetTime)
                            {
                                newQueue.Enqueue(oldKe);
                            }
                        }
                        keQueue = newQueue;
                        kerbalProtoQueue[kerbalName] = newQueue;
                        //Clean the history too
                        if (Settings.fetch.revertEnabled)
                        {
                            if (kerbalProtoHistory.ContainsKey(kerbalName))
                            {
                                List<KerbalEntry> keh = kerbalProtoHistory[kerbalName];
                                foreach (KerbalEntry oldKe in keh.ToArray())
                                {
                                    if (oldKe.planetTime > planetTime)
                                    {
                                        keh.Remove(oldKe);
                                    }
                                }
                            }
                        }
                    }
                }

                keQueue.Enqueue(newEntry);
                if (Settings.fetch.revertEnabled)
                {
                    if (!kerbalProtoHistory.ContainsKey(kerbalName))
                    {
                        kerbalProtoHistory.Add(kerbalName, new List<KerbalEntry>());
                    }
                    kerbalProtoHistory[kerbalName].Add(newEntry);
                }
                kerbalProtoHistoryTime[kerbalName] = planetTime;
            }
        }
Exemplo n.º 4
0
 //Called from networkWorker
 public void QueueKerbal(int subspace, double planetTime, int kerbalID, ConfigNode kerbalNode)
 {
     KerbalEntry newEntry = new KerbalEntry();
     newEntry.kerbalID = kerbalID;
     newEntry.planetTime = planetTime;
     newEntry.kerbalNode = kerbalNode;
     if (!vesselRemoveQueue.ContainsKey(subspace))
     {
         SetupSubspace(subspace);
     }
     kerbalProtoQueue[subspace].Enqueue(newEntry);
 }