Ejemplo n.º 1
0
        public void WriteToFiles(FileSet files, int carNumber)
        {
            List <long> indexes = new List <long>(3);

            foreach (Stream file in files.CarInfoFiles)
            {
                file.Position = (carNumber + 1) * 8;
                file.WriteUInt(CarName.ToCarID());
                long index = file.Length;
                file.WriteUShort((ushort)index);
                indexes.Add(index);
                file.WriteUShort(GetColourCountAndRegionBlockingFlags());
            }
            WriteColoursToFiles(files, indexes, carNumber);
            WriteName(files.JPCarInfo, JPName, indexes[0], Colours.Count);
            WriteName(files.USCarInfo, USName, indexes[1], Colours.Count);
            WriteName(files.EUCarInfo, EUName, indexes[2], Colours.Count);
        }
Ejemplo n.º 2
0
        public void ReadFromFiles()
        {
            using (FileSet files = FileSet.OpenRead())
            {
                files.JPCarInfo.Position = 0x04; // Skip header
                uint carCount = files.JPCarInfo.ReadUInt();

                Cars = new List <Car>();

                for (uint i = 0; i < carCount; i++)
                {
                    Car car = new Car();
                    car.ReadFromFiles(files, i);
                    Cars.Add(car);
                }

                CarColour.ClearCache();
            }
        }
Ejemplo n.º 3
0
        public void SaveToFiles()
        {
            using (FileSet files = FileSet.OpenWrite())
            {
                byte[] header = "CAR\0".ToByteArray();
                foreach (Stream file in files.CarInfoFiles)
                {
                    file.Write(header);
                    file.WriteUInt((uint)Cars.Count);
                    file.SetLength((Cars.Count + 1) * 8);
                }

                files.CarColours.Write("CCOL00\0\0".ToByteArray());
                files.CarColours.SetLength((Cars.Count * 2) + 8);

                for (int i = 0; i < Cars.Count; i++)
                {
                    Cars[i].WriteToFiles(files, i);
                }

                CarColour.WriteCachedNames(files);
                CarColour.ClearCache();
            }
        }
Ejemplo n.º 4
0
 public static void WriteCachedNames(FileSet files)
 {
     WriteCachedNames(files.CCJapanese, CachedJapaneseNames, true);
     WriteCachedNames(files.CCLatin, CachedLatinNames, false);
 }
Ejemplo n.º 5
0
 public void WriteName(FileSet files, long index, byte colourNumber)
 {
     files.CarColours.Position = index + (colourNumber * 2);
     files.CarColours.WriteUShort(CacheNames());
 }