Пример #1
0
        /// <summary>
        /// Used to validate that a mod contains correct information.
        /// </summary>
        /// <param name="mod"></param>
        /// <returns></returns>
        private bool IsValid(ModInformation info)
        {
            if (info == null)
            {
                MasterLog.DebugWriteLine("Mod rejected due to ModInformation being invalid.");
                return(false);
            }
            if (info.AuthorName == null || info.AuthorName.Equals(string.Empty))
            {
                MasterLog.DebugWriteLine("Mod rejected due to AuthorName in ModInformation being invalid.");
                return(false);
            }
            if (info.Description == null)
            {
                MasterLog.DebugWriteLine("Mod rejected due to Description in ModInformation being invalid.");
                return(false);
            }
            if (info.DisplayName == null || info.DisplayName.Equals(string.Empty))
            {
                MasterLog.DebugWriteLine("Mod rejected due to DisplayName in ModInformation being invalid.");
                return(false);
            }
            if (info.Version == null)
            {
                MasterLog.DebugWriteLine("Mod rejected due to Version in ModInformation being invalid.");
                return(false);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Removes all mods that have invalid/duplicate mod ids from the passed in list.
        /// </summary>
        /// <param name="mods"></param>
        /// <returns></returns>
        private void RemoveInvalidMods(List <IMod> mods)
        {
            Dictionary <string, IMod> idToMods = new Dictionary <string, IMod>();

            foreach (IMod item in mods)
            {
                ModInformation info = item.GetInfo();
                if (idToMods.ContainsKey(info.ModID))
                {
                    idToMods.TryGetValue(info.ModID, out IMod value);
                    MasterLog.DebugWriteLine("Mod conflict: " + info.DisplayName + "(" + info.ModID +
                                             ") has an identical ModID to " + value.GetInfo().DisplayName + "(" + value.GetInfo().ModID + ")");
                    mods.Remove(item);
                    mods.Remove(value);
                    MasterLog.DebugWriteLine("Refusing to load either mod due to the ModID conflict");
                }
                else
                {
                    if (!this.IsValid(info))
                    {
                        mods.Remove(item);
                    }
                }
            }
        }