Exemplo n.º 1
0
        private void ProcessCarList(Chunk chunk)
        {
            var newSize = chunk.Size - Reader.AlignToBoundary(0x10);

            if (newSize % 0xD0 != 0)
            {
                throw new InvalidDataException("Malformed car list chunk");
            }

            Progress?.Report("Processing car list");

            while (Stream.Position < chunk.EndOffset)
            {
                var cti = BinaryHelpers.ReadStruct <CarTypeInfo>(Reader);

                //Debug.WriteLine("{0} {1} ({2})", cti.ManufacturerName, cti.BaseModelName, cti.UsageType);

                var acr = new AaronCarRecord();
                acr.BaseModelName     = cti.BaseModelName;
                acr.CarTypeName       = cti.CarTypeName;
                acr.ManufacturerName  = cti.ManufacturerName;
                acr.DefaultBasePaint  = cti.DefaultBasePaint;
                acr.DefaultSkinNumber = cti.DefaultSkinNumber;
                acr.Skinnable         = cti.Skinnable;
                acr.UsageType         = cti.UsageType;

                _carService.AddCar(acr);
                HashResolver.Add(cti.CarTypeNameHash, cti.CarTypeName);
            }

            this.GenerateHashes();
        }
Exemplo n.º 2
0
        private void GenerateHashes()
        {
            Progress?.Report("Building hash table");
            DebugTiming.BeginTiming("GenerateHashes");

            var racerHashes   = AaronHashLists.Get("RacerHashes");
            var copHashes     = AaronHashLists.Get("CopHashes");
            var trafficHashes = AaronHashLists.Get("TrafficHashes");

            foreach (var aaronCarRecord in _carService.GetCarsByType(CarUsageType.Racing))
            {
                //Debug.WriteLine($"Add racer hashes for {aaronCarRecord.CarTypeName}");
                foreach (var hashText in racerHashes.Select(s => s.Replace("%", aaronCarRecord.CarTypeName)))
                {
                    HashResolver.Add(Hashing.BinHash(hashText), hashText);
                }
            }

            foreach (var aaronCarRecord in _carService.GetCarsByType(CarUsageType.Cop))
            {
                //Debug.WriteLine($"Add cop hashes for {aaronCarRecord.CarTypeName}");
                foreach (var hashText in copHashes.Select(s => s.Replace("%", aaronCarRecord.CarTypeName)))
                {
                    //Debug.WriteLine(hashText);
                    HashResolver.Add(Hashing.BinHash(hashText), hashText);
                }
            }

            foreach (var aaronCarRecord in _carService.GetCarsByType(CarUsageType.Traffic))
            {
                //Debug.WriteLine($"Add traffic hashes for {aaronCarRecord.CarTypeName}");
                foreach (var hashText in trafficHashes.Select(s => s.Replace("%", aaronCarRecord.CarTypeName)))
                {
                    //Debug.WriteLine(hashText);
                    HashResolver.Add(Hashing.BinHash(hashText), hashText);
                }
            }

            DebugTiming.EndTiming("GenerateHashes");
        }
Exemplo n.º 3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Load hash lists
            AaronHashLists.Load("GenericHashes", @"ApplicationData\HashLists\GenericHashes.txt");
            AaronHashLists.Load("RacerHashes", @"ApplicationData\HashLists\RacerHashes.txt");
            AaronHashLists.Load("CopHashes", @"ApplicationData\HashLists\CopHashes.txt");
            AaronHashLists.Load("TrafficHashes", @"ApplicationData\HashLists\TrafficHashes.txt");

            // Register all generic hashes immediately
            foreach (var hashText in AaronHashLists.Get("GenericHashes"))
            {
                HashResolver.Add(Hashing.BinHash(hashText), hashText);
            }

            if (Directory.Exists(@"ApplicationData\CustomHashLists"))
            {
                foreach (var file in Directory.GetFiles(@"ApplicationData\CustomHashLists", "*.txt",
                                                        SearchOption.TopDirectoryOnly))
                {
                    AaronHashLists.Load(Path.GetFileNameWithoutExtension(file), file);

                    foreach (var s in AaronHashLists.Get(Path.GetFileNameWithoutExtension(file)))
                    {
                        HashResolver.Add(Hashing.BinHash(s), s);
                    }
                }
            }

            // Load templates
            AaronCarTemplates.LoadFromFile("CAR_COP", @"ApplicationData\Templates\CarTemplate_COP.json");
            AaronCarTemplates.LoadFromFile("CAR_RACER", @"ApplicationData\Templates\CarTemplate_RACER.json");
            AaronCarTemplates.LoadFromFile("CAR_TRAFFIC", @"ApplicationData\Templates\CarTemplate_TRAFFIC.json");

            // Load other data
            AaronManufacturers.LoadFromFile(@"ApplicationData\Manufacturers.txt");
        }