Beispiel #1
0
        /// <summary>
        /// Check settings. If it fails, the application settings are not valid of corrupted, and the application MUST be
        /// re-configurad to work properly and safaty.
        /// </summary>
        /// <param name="gameName"></param>
        /// <returns></returns>
        public static int checkConfig(string gameName)
        {
            // game name
            if (!SettingsFactory.gameExist(gameName))
            {
                return(Errors.ERR_INVALID_GAME_NAME_1);
            }

            // load settings
            SPSettings settings     = SettingsFactory.getSettings();
            SPGame     gameSettings = SettingsFactory.getGameSettings(gameName);

            // game name
            if (gameSettings.game == null || gameSettings.game.Trim().Equals(""))
            {
                return(Errors.ERR_INVALID_GAME_NAME_2);
            }
            // steam path
            else if (settings.steamPath == null ||
                     settings.steamPath.Trim().Equals("") ||
                     !Directory.Exists(settings.steamPath))
            {
                return(Errors.ERR_STEAM_DIRRECTORY_MISSING_1);
            }
            // documents
            else if (!gameSettings.isDocumentsPathOptional())
            {
                if (settings.documentsPath == null ||
                    settings.documentsPath.Trim().Equals("") ||
                    !Directory.Exists(settings.documentsPath))
                {
                    return(Errors.ERR_DOCUMENTS_DIRRECTORY_MISSING_1);
                }
            }
            // app data
            else if (!gameSettings.isAppDataPathOptional())
            {
                if (settings.appDataPath == null ||
                    settings.appDataPath.Trim().Equals("") ||
                    !Directory.Exists(settings.appDataPath))
                {
                    return(Errors.ERR_APPDATA_DIRRECTORY_MISSING_2);
                }
            }
            // game folder
            else if (gameSettings.gameFolder == null || gameSettings.gameFolder.Trim().Equals(""))
            {
                return(Errors.ERR_INVALID_GAME_FOLDER);
            }
            // game exe
            else if (gameSettings.gameExe == null || gameSettings.gameExe.Trim().Equals(""))
            {
                return(Errors.ERR_INVALID_GAME_EXE);
            }
            // backup folder name
            else if (gameSettings.backupFolder == null || gameSettings.backupFolder.Trim().Equals(""))
            {
                return(Errors.ERR_INVALID_BACKUP_FOLDER);
            }
            // arquivo de configuração está ok no formato.
            // agora entradas redundantes ou invalidas devem ser eliminadas se existirem.
            return(Errors.SUCCESS);
        }