Exemplo n.º 1
0
        public bool TryGetVersion(string directory, out GameVersion result)
        {
            GameVersion buildIdVersion;
            var         hasBuildId = TryGetVersionFromFile(Path.Combine(directory, "buildID.txt"), out buildIdVersion);

            GameVersion buildId64Version;
            var         hasBuildId64 = TryGetVersionFromFile(Path.Combine(directory, "buildID64.txt"), out buildId64Version);

            if (hasBuildId && hasBuildId64)
            {
                result = GameVersion.Max(buildIdVersion, buildId64Version);

                if (buildIdVersion != buildId64Version)
                {
                    Log.WarnFormat(
                        "Found different KSP versions in buildID.txt ({0}) and buildID64.txt ({1}), assuming {2}.",
                        buildIdVersion,
                        buildId64Version,
                        result
                        );
                }

                return(true);
            }
            else if (hasBuildId64)
            {
                result = buildId64Version;
                return(true);
            }
            else if (hasBuildId)
            {
                result = buildIdVersion;
                return(true);
            }
            else
            {
                result = default(GameVersion);
                return(false);
            }
        }