Пример #1
0
        /// <summary>
        /// Detect a game in the specified folder.
        /// </summary>
        /// <param name="container">Game container.</param>
        /// <returns>Detection result.</returns>
        GameDetectorResult IGameDetectorAlgorithm.Detect(IGameContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            var result = new GameDetectorResult();

            var files = container.GetGameFiles();
            var id    = container.GetGameId();

            bool inventoryFound  = false;
            bool vocabularyFound = false;
            bool volumeFound     = false;
            bool amigaMapFound   = false;

            foreach (string file in files)
            {
                if (string.Compare("object", file, true, CultureInfo.InvariantCulture) == 0)
                {
                    inventoryFound = true;
                    continue;
                }

                if (string.Compare("words.tok", file, true, CultureInfo.InvariantCulture) == 0)
                {
                    vocabularyFound = true;
                    continue;
                }

                if (file.ToLower(CultureInfo.InvariantCulture).EndsWith("vol.0"))
                {
                    volumeFound = true;
                    continue;
                }

                if (string.Compare("dirs", file, true, CultureInfo.InvariantCulture) == 0)
                {
                    amigaMapFound = true;
                    continue;
                }
            }

            if (inventoryFound && vocabularyFound && volumeFound)
            {
                var name        = container.Name;
                var platform    = amigaMapFound ? Platform.Amiga : Platform.PC;
                var interpreter = id.Length > 0 ? InterpreterVersion.V3002149 : InterpreterVersion.V2936;
                var version     = string.Empty;

                result = new GameDetectorResult(name, interpreter, platform, version);
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Get all the files in the specified container that are game data files and calculate
        /// the crc for them.
        /// </summary>
        /// <param name="container">Game container.</param>
        /// <returns>List of files.</returns>
        internal static GameFileCollection GetFolderGameFiles(IGameContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            string[] gameFiles = container.GetGameFiles();

            // Calculate the checksum for each game file
            GameFileCollection crcs = new GameFileCollection();

            foreach (string file in gameFiles)
            {
                GameFile crc = GameFile.FromFile(container, file);
                crcs.Add(crc);
            }

            return(crcs);
        }