Inheritance: System.IO.BinaryReader
Esempio n. 1
0
        protected override void LoadOrThrow()
        {
            base.LoadOrThrow();

            Size = new FileInfo(Location).Length;

            if (Id == PreviousReplayName)
            {
                IsNew = true;
            }

            if (!SettingsHolder.Drive.TryToLoadReplays)
            {
                return;
            }

            try {
                using (var reader = new ReplayReader(Location)) {
                    var version = reader.ReadInt32();

                    if (version >= 0xe)
                    {
                        reader.ReadBytes(8);

                        WeatherId          = reader.ReadString();
                        TrackId            = reader.ReadString();
                        TrackConfiguration = reader.ReadString();
                    }
                    else
                    {
                        TrackId = reader.ReadString();
                    }

                    ErrorIf(TracksManager.Instance.GetWrapperById(TrackId) == null, AcErrorType.Replay_TrackIsMissing, TrackId);

                    CarId = reader.TryToReadNextString();
                    try {
                        DriverName = reader.ReadString();
                        reader.ReadInt64();
                        CarSkinId = reader.ReadString();
                    } catch (Exception) {
                        // ignored
                    }
                }
                ParsedSuccessfully = true;
            } catch (Exception e) {
                ParsedSuccessfully = false;
                throw new AcErrorException(this, AcErrorType.Load_Base, e);
            }
        }
Esempio n. 2
0
        protected override void LoadOrThrow() {
            base.LoadOrThrow();

            Size = new FileInfo(Location).Length;

            if (Id == PreviousReplayName) {
                IsNew = true;
            }

            if (!SettingsHolder.Drive.TryToLoadReplays) return;

            try {
                using (var reader = new ReplayReader(Location)) {
                    var version = reader.ReadInt32();

                    if (version >= 0xe) {
                        reader.ReadBytes(8);

                        WeatherId = reader.ReadString();
                        TrackId = reader.ReadString();
                        TrackConfiguration = reader.ReadString();
                    } else {
                        TrackId = reader.ReadString();
                    }
                    
                    ErrorIf(TracksManager.Instance.GetWrapperById(TrackId) == null, AcErrorType.Replay_TrackIsMissing, TrackId);

                    CarId = reader.TryToReadNextString();
                    try {
                        DriverName = reader.ReadString();
                        reader.ReadInt64();
                        CarSkinId = reader.ReadString();
                    } catch (Exception) {
                        // ignored
                    }
                }
                ParsedSuccessfully = true;
            } catch (Exception e) {
                ParsedSuccessfully = false;
                throw new AcErrorException(this, AcErrorType.Load_Base, e);
            }
        }