Пример #1
0
        public void ReadData(string filename)
        {
            using (FileStream file = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                var blocks = new List <DataBlock>();

                for (int i = 1; i <= 34; i++)
                {
                    file.Position = 8 * i;
                    uint blockStart = file.ReadUInt();
                    uint blockSize  = file.ReadUInt();
                    blocks.Add(new DataBlock {
                        BlockStart = blockStart, BlockSize = blockSize
                    });
                }

                BrakeParts.Read(file, blocks[0].BlockStart, blocks[0].BlockSize);
                BrakeControllerParts.Read(file, blocks[1].BlockStart, blocks[1].BlockSize);
                SteerParts.Read(file, blocks[2].BlockStart, blocks[2].BlockSize);
                ChassisParts.Read(file, blocks[3].BlockStart, blocks[3].BlockSize);
                LightweightParts.Read(file, blocks[4].BlockStart, blocks[4].BlockSize);
                RacingModifyParts.Read(file, blocks[5].BlockStart, blocks[5].BlockSize);
                EngineParts.Read(file, blocks[6].BlockStart, blocks[6].BlockSize);
                PortPolishParts.Read(file, blocks[7].BlockStart, blocks[7].BlockSize);
                EngineBalanceParts.Read(file, blocks[8].BlockStart, blocks[8].BlockSize);
                DisplacementParts.Read(file, blocks[9].BlockStart, blocks[9].BlockSize);
                ComputerParts.Read(file, blocks[10].BlockStart, blocks[10].BlockSize);
                NATuneParts.Read(file, blocks[11].BlockStart, blocks[11].BlockSize);
                TurbineKitParts.Read(file, blocks[12].BlockStart, blocks[12].BlockSize);
                DrivetrainParts.Read(file, blocks[13].BlockStart, blocks[13].BlockSize);
                FlywheelParts.Read(file, blocks[14].BlockStart, blocks[14].BlockSize);
                ClutchParts.Read(file, blocks[15].BlockStart, blocks[15].BlockSize);
                PropellerShaftParts.Read(file, blocks[16].BlockStart, blocks[16].BlockSize);
                GearParts.Read(file, blocks[17].BlockStart, blocks[17].BlockSize);
                SuspensionParts.Read(file, blocks[18].BlockStart, blocks[18].BlockSize);
                IntercoolerParts.Read(file, blocks[19].BlockStart, blocks[19].BlockSize);
                MufflerParts.Read(file, blocks[20].BlockStart, blocks[20].BlockSize);
                LSDParts.Read(file, blocks[21].BlockStart, blocks[21].BlockSize);
                TiresFrontParts.Read(file, blocks[22].BlockStart, blocks[22].BlockSize);
                TiresRearParts.Read(file, blocks[23].BlockStart, blocks[23].BlockSize);
                Unknown1.Read(file, blocks[24].BlockStart, blocks[24].BlockSize);
                Unknown2.Read(file, blocks[25].BlockStart, blocks[25].BlockSize);
                Unknown3.Read(file, blocks[26].BlockStart, blocks[26].BlockSize);
                Unknown4.Read(file, blocks[27].BlockStart, blocks[27].BlockSize);
                Unknown5.Read(file, blocks[28].BlockStart, blocks[28].BlockSize);
                Unknown6.Read(file, blocks[29].BlockStart, blocks[29].BlockSize);
                Events.Read(file, blocks[30].BlockStart, blocks[30].BlockSize);
                EnemyCars.Read(file, blocks[31].BlockStart, blocks[31].BlockSize);
                Cars.Read(file, blocks[32].BlockStart, blocks[32].BlockSize);
                CarsSports.Read(file, blocks[33].BlockStart, blocks[33].BlockSize);

                uint stringTableStart = blocks[33].BlockStart + blocks[33].BlockSize;
                RaceStringTable.Read(file, stringTableStart, (uint)file.Length - stringTableStart);
            }
        }
Пример #2
0
        public void ReadData(string filename)
        {
            using (FileStream file = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                var blocks = new List <DataBlock>();

                for (int i = 1; i <= 31; i++)
                {
                    file.Position = 8 * i;
                    uint blockStart = file.ReadUInt();
                    uint blockSize  = file.ReadUInt();
                    blocks.Add(new DataBlock {
                        BlockStart = blockStart, BlockSize = blockSize
                    });
                }

                BrakeParts.Read(file, blocks[0].BlockStart, blocks[0].BlockSize);
                BrakeControllerParts.Read(file, blocks[1].BlockStart, blocks[1].BlockSize);
                SteerParts.Read(file, blocks[2].BlockStart, blocks[2].BlockSize);
                ChassisParts.Read(file, blocks[3].BlockStart, blocks[3].BlockSize);
                LightweightParts.Read(file, blocks[4].BlockStart, blocks[4].BlockSize);
                RacingModifyParts.Read(file, blocks[5].BlockStart, blocks[5].BlockSize);
                EngineParts.Read(file, blocks[6].BlockStart, blocks[6].BlockSize);
                PortPolishParts.Read(file, blocks[7].BlockStart, blocks[7].BlockSize);
                EngineBalanceParts.Read(file, blocks[8].BlockStart, blocks[8].BlockSize);
                DisplacementParts.Read(file, blocks[9].BlockStart, blocks[9].BlockSize);
                ComputerParts.Read(file, blocks[10].BlockStart, blocks[10].BlockSize);
                NATuneParts.Read(file, blocks[11].BlockStart, blocks[11].BlockSize);
                TurbineKitParts.Read(file, blocks[12].BlockStart, blocks[12].BlockSize);
                DrivetrainParts.Read(file, blocks[13].BlockStart, blocks[13].BlockSize);
                FlywheelParts.Read(file, blocks[14].BlockStart, blocks[14].BlockSize);
                ClutchParts.Read(file, blocks[15].BlockStart, blocks[15].BlockSize);
                PropellerShaftParts.Read(file, blocks[16].BlockStart, blocks[16].BlockSize);
                GearParts.Read(file, blocks[17].BlockStart, blocks[17].BlockSize);
                SuspensionParts.Read(file, blocks[18].BlockStart, blocks[18].BlockSize);
                IntercoolerParts.Read(file, blocks[19].BlockStart, blocks[19].BlockSize);
                MufflerParts.Read(file, blocks[20].BlockStart, blocks[20].BlockSize);
                LSDParts.Read(file, blocks[21].BlockStart, blocks[21].BlockSize);
                TiresFrontParts.Read(file, blocks[22].BlockStart, blocks[22].BlockSize);
                TiresRearParts.Read(file, blocks[23].BlockStart, blocks[23].BlockSize);
                TireSizes.Read(file, blocks[24].BlockStart, blocks[24].BlockSize);
                TireCompounds.Read(file, blocks[25].BlockStart, blocks[25].BlockSize);
                TireForceVols.Read(file, blocks[26].BlockStart, blocks[26].BlockSize);
                ActiveStabilityControlParts.Read(file, blocks[27].BlockStart, blocks[27].BlockSize);
                TractionControlSystemParts.Read(file, blocks[28].BlockStart, blocks[28].BlockSize);
                Unknown.Read(file, blocks[29].BlockStart, blocks[29].BlockSize);
                Cars.Read(file, blocks[30].BlockStart, blocks[30].BlockSize);
            }
        }
Пример #3
0
        public void ReadData(string filename)
        {
            using (FileStream file = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                byte[] magic = new byte[4];
                file.Read(magic);
                if (Encoding.ASCII.GetString(magic) != "GTAR")
                {
                    Console.WriteLine("Not a GTAR archive.");
                    return;
                }

                uint tableCount       = file.ReadUInt();
                uint dataStart        = file.ReadUInt();
                uint unknown          = file.ReadUInt();
                var  dataTableStreams = new MemoryStream[tableCount];

                for (int i = 0; i < tableCount; i++)
                {
                    file.Position = (i * 4) + 0x10;
                    uint start  = file.ReadUInt();
                    uint end    = file.ReadUInt();
                    uint length = end - start;

                    file.Position = start + dataStart;
                    byte[] buffer = new byte[length];
                    file.Read(buffer);
                    dataTableStreams[i] = new MemoryStream(buffer);
                }

                BrakeParts.Read(dataTableStreams[0]);
                BrakeBalanceControllerParts.Read(dataTableStreams[1]);
                SteeringParts.Read(dataTableStreams[2]);
                ChassisParts.Read(dataTableStreams[3]);
                WeightReductionParts.Read(dataTableStreams[4]);
                BodyParts.Read(dataTableStreams[5]);
                EngineParts.Read(dataTableStreams[6]);
                PortPolishingParts.Read(dataTableStreams[7]);
                EngineBalancingParts.Read(dataTableStreams[8]);
                DisplacementIncreaseParts.Read(dataTableStreams[9]);
                ComputerParts.Read(dataTableStreams[10]);
                NATuneParts.Read(dataTableStreams[11]);
                TurboKitParts.Read(dataTableStreams[12]);
                DrivetrainParts.Read(dataTableStreams[13]);
                FlywheelParts.Read(dataTableStreams[14]);
                ClutchParts.Read(dataTableStreams[15]);
                PropellerShaftParts.Read(dataTableStreams[16]);
                GearboxParts.Read(dataTableStreams[17]);
                SuspensionParts.Read(dataTableStreams[18]);
                IntercoolerParts.Read(dataTableStreams[19]);
                MufflerParts.Read(dataTableStreams[20]);
                LSDParts.Read(dataTableStreams[21]);
                TCSCParts.Read(dataTableStreams[22]);
                ASCCParts.Read(dataTableStreams[23]);
                WheelsParts.Read(dataTableStreams[24]);
                TyreSizeParts.Read(dataTableStreams[25]);
                TyreForceVolParts.Read(dataTableStreams[26]);
                TyreCompounds.Read(dataTableStreams[27]);
                TyresFrontParts.Read(dataTableStreams[28]);
                TyresRearParts.Read(dataTableStreams[29]);
                Opponents.Read(dataTableStreams[30]);
                Events.Read(dataTableStreams[31]);
                Regulations.Read(dataTableStreams[32]);
                Courses.Read(dataTableStreams[33]);
                ArcadeCars.Read(dataTableStreams[34]);
                Cars.Read(dataTableStreams[35]);

                foreach (var stream in dataTableStreams)
                {
                    stream.Dispose();
                }
            }
        }