Example #1
0
        private void DeSerialisationFixes(StreamingContext like_i_could_care)
        {
            // Make sure our version fields are populated.
            // TODO: There's got to be a better way of doing this, right?

            if (ksp_version_min == null)
            {
                ksp_version_min = new KSPVersion(null);
            }
            else
            {
                ksp_version_min.ToLongMin();
            }

            if (ksp_version_max == null)
            {
                ksp_version_max = new KSPVersion(null);
            }
            else
            {
                ksp_version_max.ToLongMax();
            }

            if (ksp_version == null)
            {
                ksp_version = new KSPVersion(null);
            }

            // Now see if we've got version with version min/max.
            if (ksp_version.IsNotAny() && (ksp_version_max.IsNotAny() || ksp_version_min.IsNotAny()))
            {
                // KSP version mixed with min/max.
                throw new InvalidModuleAttributesException("ksp_version mixed wtih ksp_version_(min|max)", this);
            }
        }
Example #2
0
        public bool Compatible(KSPVersion gameVersion, CkanModule module)
        {
            KSPVersion ksp_version     = module.ksp_version;
            KSPVersion ksp_version_min = module.ksp_version_min;
            KSPVersion ksp_version_max = module.ksp_version_max;

            // Check the min and max versions.

            if (ksp_version_min.IsNotAny() && gameVersion < ksp_version_min)
            {
                return(false);
            }

            if (ksp_version_max.IsNotAny() && gameVersion > ksp_version_max)
            {
                return(false);
            }

            // We didn't hit the min/max guards. They may not have existed.

            // Note that since ksp_version is "any" if not specified, this
            // will work fine if there's no target, or if there were min/max
            // fields and we passed them successfully.

            return(ksp_version.Targets(gameVersion));
        }