Exemple #1
0
        private void ProcessTorrentAdded(ShortTorrentInfo e)
        {
            if (e.Type == "MOD")
            {
                foreach (var mi in modList.Values)
                {
                    if (mi.Checksum == e.Hash)
                    {
                        return;
                    }
                }

                double version;
                string baseName;
                ModInfo.ExtractNameAndVersion(e.Name, out baseName, out version);
                ModInfo closestMi  = null;
                double  difference = double.MaxValue;
                foreach (var mi in loadedModList.Values)
                {
                    if (mi.ShortBaseName == baseName)
                    {
                        var nd = Math.Abs(mi.Version - version);
                        if (nd < difference)
                        {
                            difference = nd;
                            closestMi  = mi;
                        }
                    }
                }

                if (closestMi != null)
                {
                    var newMi = (ModInfo)closestMi.Clone();
                    newMi.Checksum      = e.Hash;
                    newMi.Name          = e.Name;
                    modList[newMi.Name] = newMi;
                    if (Downloader.IsTorrentListDone && NotifyModsChanged != null)
                    {
                        NotifyModsChanged(this, EventArgs.Empty);
                    }
                }
            }
            else if (e.Type == "MAP")
            {
                foreach (var mi in mapList.Values)
                {
                    if (mi.Checksum == e.Hash)
                    {
                        return;
                    }
                }
                mapList[e.Name] = new MapInfo(e.Name)
                {
                    Checksum = e.Hash
                };
            }
        }
Exemple #2
0
 private void ProcessTorrentRemoved(ShortTorrentInfo e)
 {
     if (e.Type == "MOD")
     {
         bool found = false;
         foreach (var mi in modList.Values)
         {
             if (mi.Checksum == e.Hash)
             {
                 found = true;
                 break;
             }
         }
         if (found)
         {
             modList.Remove(e.Name);
         }
         if (Downloader.IsTorrentListDone && NotifyModsChanged != null)
         {
             NotifyModsChanged(this, EventArgs.Empty);
         }
     }
     else if (e.Type == "MAP")
     {
         bool found = false;
         foreach (var mi in mapList.Values)
         {
             if (mi.Checksum == e.Hash)
             {
                 found = true;
                 break;
             }
         }
         if (found)
         {
             mapList.Remove(e.Name);
         }
     }
 }
Exemple #3
0
 private void downloader_TorrentRemoved(object sender, ShortTorrentInfo e)
 {
     ProcessTorrentRemoved(e);
 }