public void WriteData() { using (FileStream file = new FileStream("paramdb_gtc_eu.db", FileMode.Create, FileAccess.ReadWrite)) { const uint DataTableCount = 0x24; file.WriteCharacters("GTAR"); file.WriteUInt(DataTableCount); uint dataStart = ((DataTableCount + 2) * 4) + 16; file.WriteUInt(dataStart); file.WriteUInt(0x07); file.Position = dataStart; ushort tableNumber = 0; BrakeParts.Write(file, dataStart, tableNumber++); BrakeBalanceControllerParts.Write(file, dataStart, tableNumber++); SteeringParts.Write(file, dataStart, tableNumber++); ChassisParts.Write(file, dataStart, tableNumber++); WeightReductionParts.Write(file, dataStart, tableNumber++); BodyParts.Write(file, dataStart, tableNumber++); EngineParts.Write(file, dataStart, tableNumber++); PortPolishingParts.Write(file, dataStart, tableNumber++); EngineBalancingParts.Write(file, dataStart, tableNumber++); DisplacementIncreaseParts.Write(file, dataStart, tableNumber++); ComputerParts.Write(file, dataStart, tableNumber++); NATuneParts.Write(file, dataStart, tableNumber++); TurboKitParts.Write(file, dataStart, tableNumber++); DrivetrainParts.Write(file, dataStart, tableNumber++); FlywheelParts.Write(file, dataStart, tableNumber++); ClutchParts.Write(file, dataStart, tableNumber++); PropellerShaftParts.Write(file, dataStart, tableNumber++); GearboxParts.Write(file, dataStart, tableNumber++); SuspensionParts.Write(file, dataStart, tableNumber++); IntercoolerParts.Write(file, dataStart, tableNumber++); MufflerParts.Write(file, dataStart, tableNumber++); LSDParts.Write(file, dataStart, tableNumber++); TCSCParts.Write(file, dataStart, tableNumber++); ASCCParts.Write(file, dataStart, tableNumber++); WheelsParts.Write(file, dataStart, tableNumber++); TyreSizeParts.Write(file, dataStart, tableNumber++); TyreForceVolParts.Write(file, dataStart, tableNumber++); TyreCompounds.Write(file, dataStart, tableNumber++); TyresFrontParts.Write(file, dataStart, tableNumber++); TyresRearParts.Write(file, dataStart, tableNumber++); Opponents.Write(file, dataStart, tableNumber++); Events.Write(file, dataStart, tableNumber++); Regulations.Write(file, dataStart, tableNumber++); Courses.Write(file, dataStart, tableNumber++); ArcadeCars.Write(file, dataStart, tableNumber++); Cars.Write(file, dataStart, tableNumber++); file.Position = dataStart - 8; file.WriteUInt((uint)file.Length - dataStart); } }
public void WriteData(string filename) { using (FileStream file = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite)) { file.Write(new byte[] { 0x47, 0x54, 0x44, 0x54, 0x6C, 0x00, 0x3E, 0x00 }, 0, 8); // The 0x3E is the number of indices file.Position = (0x3E * 8) + 7; file.WriteByte(0x00); // Data starts at 0x1F8 so position EOF uint i = 1; BrakeParts.Write(file, 8 * i++); BrakeControllerParts.Write(file, 8 * i++); SteerParts.Write(file, 8 * i++); ChassisParts.Write(file, 8 * i++); LightweightParts.Write(file, 8 * i++); RacingModifyParts.Write(file, 8 * i++); EngineParts.Write(file, 8 * i++); PortPolishParts.Write(file, 8 * i++); EngineBalanceParts.Write(file, 8 * i++); DisplacementParts.Write(file, 8 * i++); ComputerParts.Write(file, 8 * i++); NATuneParts.Write(file, 8 * i++); TurbineKitParts.Write(file, 8 * i++); DrivetrainParts.Write(file, 8 * i++); FlywheelParts.Write(file, 8 * i++); ClutchParts.Write(file, 8 * i++); PropellerShaftParts.Write(file, 8 * i++); GearParts.Write(file, 8 * i++); SuspensionParts.Write(file, 8 * i++); IntercoolerParts.Write(file, 8 * i++); MufflerParts.Write(file, 8 * i++); LSDParts.Write(file, 8 * i++); TiresFrontParts.Write(file, 8 * i++); TiresRearParts.Write(file, 8 * i++); Unknown1.Write(file, 8 * i++); Unknown2.Write(file, 8 * i++); Unknown3.Write(file, 8 * i++); Unknown4.Write(file, 8 * i++); Unknown5.Write(file, 8 * i++); Unknown6.Write(file, 8 * i++); Unknown7.Write(file, 8 * i++); Cars.Write(file, 8 * i++); file.Position = 0; using (FileStream zipFile = new FileStream(filename + ".gz", FileMode.Create, FileAccess.Write)) { using (GZipStream zip = new GZipStream(zipFile, CompressionMode.Compress)) { file.CopyTo(zip); } } } }