示例#1
0
 public int Compare(ModuleConfig x, ModuleConfig y)
 {
     for (int i = 0; i < y.Dependencies.Count; i++)
     {
         ModuleDependency moduleDependency = y.Dependencies[i];
         if (moduleDependency.Name == x.Name)
         {
             return(-1);
         }
     }
     for (int j = 0; j < x.Dependencies.Count; j++)
     {
         ModuleDependency moduleDependency2 = x.Dependencies[j];
         if (moduleDependency2.Name == y.Name)
         {
             return(1);
         }
     }
     return(x.Dependencies.Count - y.Dependencies.Count);
 }
示例#2
0
        // Token: 0x06000EF6 RID: 3830 RVA: 0x00065F28 File Offset: 0x00064328
        private static bool areModuleDependenciesEnabled(int moduleIndex)
        {
            Module       module = ModuleHook.modules[moduleIndex];
            ModuleConfig config = module.config;

            for (int i = 0; i < config.Dependencies.Count; i++)
            {
                ModuleDependency moduleDependency = config.Dependencies[i];
                int index = moduleIndex - 1;
                while (moduleIndex >= 0)
                {
                    if (ModuleHook.modules[index].config.Name == moduleDependency.Name && !ModuleHook.modules[index].isEnabled)
                    {
                        return(false);
                    }
                    moduleIndex--;
                }
            }
            return(true);
        }
示例#3
0
 // Token: 0x06000EF7 RID: 3831 RVA: 0x00065FC8 File Offset: 0x000643C8
 private static void updateModuleEnabled(int index, bool enable)
 {
     if (enable)
     {
         if (ModuleHook.modules[index].config.IsEnabled && ModuleHook.areModuleDependenciesEnabled(index) && !ModuleHook.isModuleDisabledByCommandLine(ModuleHook.modules[index].config.Name))
         {
             ModuleHook.modules[index].isEnabled = true;
             for (int i = index + 1; i < ModuleHook.modules.Count; i++)
             {
                 for (int j = 0; j < ModuleHook.modules[i].config.Dependencies.Count; j++)
                 {
                     ModuleDependency moduleDependency = ModuleHook.modules[i].config.Dependencies[j];
                     if (moduleDependency.Name == ModuleHook.modules[index].config.Name)
                     {
                         ModuleHook.updateModuleEnabled(i, true);
                         break;
                     }
                 }
             }
         }
     }
     else
     {
         for (int k = ModuleHook.modules.Count - 1; k > index; k--)
         {
             for (int l = 0; l < ModuleHook.modules[k].config.Dependencies.Count; l++)
             {
                 ModuleDependency moduleDependency2 = ModuleHook.modules[k].config.Dependencies[l];
                 if (moduleDependency2.Name == ModuleHook.modules[index].config.Name)
                 {
                     ModuleHook.updateModuleEnabled(k, false);
                     break;
                 }
             }
         }
         ModuleHook.modules[index].isEnabled = false;
     }
 }
示例#4
0
 // Token: 0x06000EFA RID: 3834 RVA: 0x000661E0 File Offset: 0x000645E0
 private void findModules(string path, List <ModuleConfig> configs)
 {
     foreach (string text in Directory.GetFiles(path, "*.module"))
     {
         ModuleConfig moduleConfig = IOUtility.jsonDeserializer.deserialize <ModuleConfig>(text);
         if (moduleConfig != null)
         {
             moduleConfig.DirectoryPath    = path;
             moduleConfig.FilePath         = text;
             moduleConfig.Version_Internal = Parser.getUInt32FromIP(moduleConfig.Version);
             for (int j = 0; j < moduleConfig.Dependencies.Count; j++)
             {
                 ModuleDependency moduleDependency = moduleConfig.Dependencies[j];
                 moduleDependency.Version_Internal = Parser.getUInt32FromIP(moduleDependency.Version);
             }
             configs.Add(moduleConfig);
         }
     }
     foreach (string path2 in Directory.GetDirectories(path))
     {
         this.findModules(path2, configs);
     }
 }
示例#5
0
        // Token: 0x06000EFB RID: 3835 RVA: 0x000662C4 File Offset: 0x000646C4
        private void sortModules(List <ModuleConfig> configs)
        {
            ModuleComparer comparer = new ModuleComparer();

            configs.Sort(comparer);
            for (int i = 0; i < configs.Count; i++)
            {
                ModuleConfig moduleConfig = configs[i];
                bool         flag         = true;
                for (int j = moduleConfig.Assemblies.Count - 1; j >= 0; j--)
                {
                    ModuleAssembly moduleAssembly = moduleConfig.Assemblies[j];
                    if (moduleAssembly.Role == EModuleRole.Client && Dedicator.isDedicated)
                    {
                        moduleConfig.Assemblies.RemoveAt(j);
                    }
                    else if (moduleAssembly.Role == EModuleRole.Server && !Dedicator.isDedicated)
                    {
                        moduleConfig.Assemblies.RemoveAt(j);
                    }
                    else
                    {
                        bool flag2 = false;
                        for (int k = 1; k < moduleAssembly.Path.Length; k++)
                        {
                            if (moduleAssembly.Path[k] == '.' && moduleAssembly.Path[k - 1] == '.')
                            {
                                flag2 = true;
                                break;
                            }
                        }
                        if (flag2)
                        {
                            flag = false;
                            break;
                        }
                        string path = moduleConfig.DirectoryPath + moduleAssembly.Path;
                        if (!File.Exists(path))
                        {
                            flag = false;
                            break;
                        }
                    }
                }
                if (!flag || moduleConfig.Assemblies.Count == 0)
                {
                    configs.RemoveAt(i);
                    i--;
                }
                else
                {
                    for (int l = 0; l < moduleConfig.Dependencies.Count; l++)
                    {
                        ModuleDependency moduleDependency = moduleConfig.Dependencies[l];
                        bool             flag3            = false;
                        for (int m = i - 1; m >= 0; m--)
                        {
                            if (configs[m].Name == moduleDependency.Name)
                            {
                                if (configs[m].Version_Internal >= moduleDependency.Version_Internal)
                                {
                                    flag3 = true;
                                }
                                break;
                            }
                        }
                        if (!flag3)
                        {
                            configs.RemoveAtFast(i);
                            i--;
                            break;
                        }
                    }
                }
            }
        }