Пример #1
0
        public List <CarColour> ReadColoursFromFiles(FileSet files, ushort index, uint carNumber, byte colourCount)
        {
            var colours = new List <CarColour>();

            for (byte i = 0; i < colourCount; i++)
            {
                CarColour colour = new CarColour();
                colour.ReadFromFiles(files, index, carNumber, colourCount, i);
                colours.Add(colour);
            }

            return(colours);
        }
Пример #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();
            }
        }
Пример #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();
            }
        }