Ejemplo n.º 1
0
        public override IEnumerable <ContentRepairSuggestion> GetSuggestions(CarObject car)
        {
            var soundDonor = car.GetSoundOrigin().ConfigureAwait(false).GetAwaiter().GetResult();

            if (soundDonor != null && soundDonor != "tatuusfa1")
            {
                var soundDonorObject = CarsManager.Instance.GetById(soundDonor);
                if (soundDonorObject != null)
                {
                    var thisLimiter  = car.AcdData?.GetIniFile("engine.ini")["ENGINE_DATA"].GetFloat("LIMITER", 0) ?? 0;
                    var donorLimiter = soundDonorObject.AcdData?.GetIniFile("engine.ini")["ENGINE_DATA"].GetFloat("LIMITER", 0) ?? 0;
                    if (thisLimiter > 1000 && donorLimiter > 500 && donorLimiter <= thisLimiter - CarSoundReplacer.RpmLimiterThreshold)
                    {
                        return(new ContentRepairSuggestion[] {
                            new CommonErrorSuggestion("RPM limiter is way too different from sound origin’s one",
                                                      $"Sound is taken from {soundDonorObject.DisplayName} with RPM limiter at {donorLimiter:F0}, but here limiter is at {thisLimiter:F0}. You might want to change sound to something more appropriate.",
                                                      (progress, token) => CarSoundReplacer.Replace(car))
                            {
                                ShowProgressDialog = false,
                                AffectsData = false
                            },
                        });
                    }
                }
            }

            return(new ContentRepairSuggestion[0]);
        }
Ejemplo n.º 2
0
        private ContentRepairSuggestion CheckMissingSound(CarObject car)
        {
            if (car.Author == "Kunos" || File.Exists(car.SoundbankFilename))
            {
                return(null);
            }

            if (CheapRun)
            {
                return(new CommonErrorSuggestion("Missing soundbank", "",
                                                 (p, c) => Task.FromResult(false)));
            }

            var renamed = new DirectoryInfo(Path.GetDirectoryName(car.SoundbankFilename) ?? ".").GetFiles("*.bank")
                          .Where(x => x.Length > 1e6 && x.Length < 200e6).ToList();

            if (renamed.Count > 0)
            {
                var target = renamed.Count == 1 ? renamed[0].Name : "it";
                var ret    = new CommonErrorSuggestion("Missing soundbank",
                                                       $"Seems like soundbank has an incorrect name. Would you like to rename {target} back to “{Path.GetFileName(car.SoundbankFilename)}”?",
                                                       RenameAsync(car, renamed[0].FullName))
                {
                    AffectsData = false
                };
                if (renamed.Count > 1)
                {
                    ret.FixCaption = $"Use “{renamed[0].Name}”";
                }
                foreach (var alternative in renamed.Skip(1))
                {
                    ret.AlternateFix($"Use “{alternative.Name}”", RenameAsync(car, alternative.FullName));
                }
                return(ret);
            }

            var soundDonor       = car.GetSoundOrigin().ConfigureAwait(false).GetAwaiter().GetResult();
            var soundDonorObject = soundDonor == null ? null : CarsManager.Instance.GetById(soundDonor);

            if (soundDonorObject != null && soundDonor != @"tatuusfa1")
            {
                return(new CommonErrorSuggestion("Missing soundbank",
                                                 $"Judging by GUIDs, it looks like sound for this car is taken from {soundDonorObject.DisplayName}, but soundbank is missing. Copy it here to stop AC from crashing?",
                                                 FixAsync(car, soundDonorObject))
                {
                    AffectsData = false
                });
            }

            return(new CommonErrorSuggestion("Missing soundbank",
                                             $"Seems like soundbank is missing and it might cause AC to crash. Replace it with something else?",
                                             (progress, token) => CarSoundReplacer.Replace(car))
            {
                ShowProgressDialog = false,
                AffectsData = false
            });
        }
Ejemplo n.º 3
0
        public override IEnumerable <ContentRepairSuggestion> GetSuggestions(CarObject car)
        {
            var guids = car.GuidsFilename;

            if (File.Exists(guids) && File.ReadAllText(guids).Contains("bus:/Wind and Wheels/wheels (open wheels)"))
            {
                return(new ContentRepairSuggestion[] {
                    new ContentObsoleteSuggestion("Obsolete sound (possibly)",
                                                  "Judging by GUIDs, it appears that car won’t have an external sound in AC 1.9 and later. As a temporary solution, you could replace it with a sound of a Kunos car.",
                                                  (progress, token) => CarSoundReplacer.Replace(car))
                    {
                        ShowProgressDialog = false,
                        AffectsData = false
                    },
                });
            }

            return(new ContentRepairSuggestion[0]);
        }