コード例 #1
0
        protected override IniFile ConvertConfig(IniFile ini) {
            ini = base.ConvertConfig(ini);

            if (SettingsHolder.Drive.KunosCareerUserAiLevel) {
                ini["RACE"].Set("AI_LEVEL", UserAiLevel);
            }

            // why, Kunos, why
            ini.Remove("SPECIAL_EVENT");

            // well, just in case
            ini["BENCHMARK"].Set("ACTIVE", false);
            ini["REPLAY"].Set("ACTIVE", false);
            ini["REMOTE"].Set("ACTIVE", false);

            IniFile opponentsIniFile = null;
            foreach (var i in Enumerable.Range(0, ini["RACE"].GetInt("CARS", 0)).Skip(1)) {
                var sectionKey = @"CAR_" + i;
                if (!ini.ContainsKey(sectionKey) || string.IsNullOrWhiteSpace(ini[sectionKey].GetPossiblyEmpty("DRIVER_NAME"))) {
                    if (opponentsIniFile == null) {
                        var career = KunosCareerManager.Instance.GetById(KunosCareerId);
                        if (career == null) throw new Exception($"Can’t find parent career with ID={KunosCareerId}");

                        opponentsIniFile = new IniFile(career.OpponentsIniFilename);
                        if (opponentsIniFile.IsEmptyOrDamaged()) break;
                    }

                    ini[sectionKey] = opponentsIniFile["AI" + i];
                }

                ini[sectionKey].SetId("MODEL", ini[sectionKey].GetPossiblyEmpty("MODEL"));
                ini[sectionKey].SetId("SKIN", ini[sectionKey].GetPossiblyEmpty("SKIN"));
            }

            return ini;
        }