Exemplo n.º 1
0
        public ForzaDataStruct Read(byte[] input)
        {
            ForzaDataStruct output = new ForzaDataStruct()
            {
                Version = ReadVersion(input)
            };

            if (output.Version != ForzaDataVersion.Unknown)
            {
                using (MemoryStream stream = new MemoryStream(input))
                    using (BinaryReader reader = new BinaryReader(stream))
                    {
                        // common data
                        output.Sled = ReadSledData(reader);

                        switch (output.Version)
                        {
                        // forza motorsport 7 car dash data
                        case ForzaDataVersion.CarDash:
                            output.CarDash = ReadCarDashData(reader);
                            break;

                        // undocumented forza horizon 4 car dash data
                        case ForzaDataVersion.HorizonCarDash:
                            output.HorizonCarDash = ReadHorizonCarDashData(reader);
                            break;
                        }
                    }
            }

            return(output);
        }
Exemplo n.º 2
0
 public bool TryRead(byte[] input, out ForzaDataStruct output)
 {
     try
     {
         output = Read(input);
         return(true);
     }
     catch
     {
         output = new ForzaDataStruct()
         {
             Version = ForzaDataVersion.Unknown
         };
         return(false);
     }
 }
Exemplo n.º 3
0
        public ForzaDataStruct Read(byte[] input)
        {
            ForzaDataStruct output = new ForzaDataStruct()
            {
                Version = ReadVersion(input)
            };

            if (output.Version != ForzaDataVersion.Unknown)
            {
                using (MemoryStream stream = new MemoryStream(input))
                    using (BinaryReader reader = new BinaryReader(stream))
                    {
                        // common data
                        output.Sled = ReadSledData(reader);

                        switch (output.Version)
                        {
                        // forza motorsport 7 car dash data
                        case ForzaDataVersion.CarDash:
                        {
                            output.CarDash = ReadCarDashData(reader);
                            break;
                        }

                        // undocumented forza horizon 4 car dash data
                        case ForzaDataVersion.HorizonCarDash:
                        {
                            // Taken from forum posts, we found that the sled data is in the same place.
                            // The CarDashData is 12 Bytes after the sled data, (unknown source)
                            // Therefore we read an extra 12 Bytes, into data section 1
                            // we then read the cardash
                            // then the final data section 2
                            output.HorizonData1 = ReadHorizonData1(reader);
                            output.CarDash      = ReadCarDashData(reader);
                            output.HorizonData2 = ReadHorizonData2(reader);
                            break;
                        }
                        }
                    }
            }

            return(output);
        }