示例#1
0
        public void ToVersionRangeWorksCorrectly(GameVersion version, GameVersionRange expectedRange)
        {
            // Act
            var result = version.ToVersionRange();

            // Assert
            Assert.AreEqual(expectedRange, result);
        }
示例#2
0
        /// <summary>
        /// If the installed game version is in the given range,
        /// return the given array without the given parameter,
        /// otherwise return the array as-is.
        /// </summary>
        /// <param name="args">Command line parameters to check</param>
        /// <param name="crashyKspRange">Game versions that should not use this parameter</param>
        /// <param name="parameter">The parameter to remove on version match</param>
        /// <returns>
        /// args or args minus parameter
        /// </returns>
        private string[] filterCmdLineArgs(string[] args, GameVersion installedVersion, GameVersionRange crashyKspRange, string parameter)
        {
            var installedRange = installedVersion.ToVersionRange();

            if (crashyKspRange.IntersectWith(installedRange) != null &&
                args.Contains(parameter))
            {
                log.DebugFormat(
                    "Parameter {0} found on incompatible KSP version {1}, pruning",
                    parameter,
                    installedVersion.ToString());
                return(args.Where(s => s != parameter).ToArray());
            }
            return(args);
        }
示例#3
0
 private void loadOptions(IGame game)
 {
     options = game.KnownVersions;
     // C# won't let us foreach over an array while modifying it
     for (int i = options.Count - 1; i >= 0; --i)
     {
         GameVersion v = options[i];
         // From GUI/CompatibleGameVersionsDialog.cs
         GameVersion fullKnownVersion = v.ToVersionRange().Lower.Value;
         GameVersion toAdd            = new GameVersion(fullKnownVersion.Major, fullKnownVersion.Minor);
         if (!options.Contains(toAdd))
         {
             options.Add(toAdd);
         }
     }
 }
示例#4
0
        public override bool SingleVersionsCompatible(GameVersion gameVersion, CkanModule module)
        {
            var gameVersionRange = gameVersion.ToVersionRange();

            var moduleRange = GameVersionRange.Any;

            if (module.ksp_version != null)
            {
                moduleRange = module.ksp_version.ToVersionRange();
            }
            else if (module.ksp_version_min != null || module.ksp_version_max != null)
            {
                if (module.ksp_version_min != null && module.ksp_version_max != null)
                {
                    moduleRange = new GameVersionRange(module.ksp_version_min, module.ksp_version_max);
                    if (moduleRange.Lower.Value > moduleRange.Upper.Value)
                    {
                        log.WarnFormat("{0} is not less or equal to {1}",
                                       module.ksp_version_min, module.ksp_version_max);
                        return(false);
                    }
                }
                else if (module.ksp_version_min != null)
                {
                    moduleRange = new GameVersionRange(module.ksp_version_min, GameVersion.Any);
                }
                else if (module.ksp_version_max != null)
                {
                    moduleRange = new GameVersionRange(GameVersion.Any, module.ksp_version_max);
                }
            }
            else
            {
                return(true);
            }

            return(gameVersionRange.IntersectWith(moduleRange) != null);
        }