Exemplo n.º 1
0
 private void FillOrCheckCurrentWeekend(Session session, CurrentWeekend te)
 {
     if (session.Weekend.Settings == null || session.Weekend.Realism == null)
     {
         FillByCurrentWeekend(session.Weekend, te);
     }
 }
Exemplo n.º 2
0
        public void Fill(RaceSession session, CurrentWeekend te)
        {
            if (te.AtTrack == false)
            {
                return;
            }

            FillOrCheckCurrentWeekend(session, te);
        }
        private static SessionBlock BuildNewSessionBlock(CurrentWeekend currentWeekend, SessionInfo currentSession, List <TelemetryEvent> currentSessionEvents, List <DriverEntry> globalDrivers, List <DriverEntry> localDrivers)
        {
            SessionBlock sb = new SessionBlock();

            sb.CurrentWeekend = currentWeekend;
            sb.SessionInfo    = currentSession;
            sb.Drivers.AddRange(globalDrivers);
            sb.Drivers.AddRange(localDrivers);
            sb.Events = currentSessionEvents;
            return(sb);
        }
Exemplo n.º 4
0
        public void Fill(NonRaceSession session, CurrentWeekend te)
        {
            if (te.AtTrack == false)
            {
                return;
            }

            CheckForValidTrack(te.Track, session.Weekend.Track);
            session.Weekend.Track.AdjustedLengthInFeet = (int)te.TrackLength;

            FillOrCheckCurrentWeekend(session, te);
        }
Exemplo n.º 5
0
        public void Update(CurrentWeekend e)
        {
            if (e.AtTrack == false)
            {
                return;
            }

            //w.Clear();

            w.Track              = e.Track;
            w.TrackLength        = e.TrackLength;
            w.Practice.Length    = new TimeLength(e.Sessions.PracticeLength);
            w.Qualify.Length     = new LapsLength(e.Sessions.QualifyLapCount);
            w.HappyHour.Length   = new TimeLength(e.Sessions.HappyHourLength);
            w.Race.Length        = new TimeLength(e.Sessions.RaceLapCount);
            w.Race.TotalLapCount = e.Sessions.RaceLapCount;
        }
Exemplo n.º 6
0
        private void FillByCurrentWeekend(Weekend weekend, CurrentWeekend te)
        {
            weekend.Settings = new WeekendSettings();
            weekend.Settings.PracticeLength  = new Time(te.Sessions.PracticeLength);
            weekend.Settings.QualifyLapCount = te.Sessions.QualifyLapCount;
            weekend.Settings.PreRaceLength   = new Time(te.Sessions.HappyHourLength);
            weekend.Settings.RaceLapCount    = te.Sessions.RaceLapCount;

            weekend.Realism = new WeekendRealism();
            switch (te.Options.DamageLevel)
            {
            case CurrentWeekend.cwOptions.eDamageLevel.Full:
                weekend.Realism.DamageLevel = WeekendRealism.eDamageLevel.Full;
                break;

            case CurrentWeekend.cwOptions.eDamageLevel.Moderate:
                weekend.Realism.DamageLevel = WeekendRealism.eDamageLevel.Moderate;
                break;

            case CurrentWeekend.cwOptions.eDamageLevel.None:
                weekend.Realism.DamageLevel = WeekendRealism.eDamageLevel.None;
                break;
            }
            weekend.Realism.IsAdaptiveSpeedControlEnabled = te.Options.IsAdaptiveSpeedControlEnabled;
            weekend.Realism.IsDoubleFileRestartEnabled    = te.Options.IsDoubleFileRestartEnabled;
            weekend.Realism.IsFullPaceLapEnabled          = te.Options.IsFullPaceLapEnabled;
            weekend.Realism.IsRealWeatherEnabled          = te.Options.IsRealWeatherEnabled;
            weekend.Realism.IsYellowFlagEnabled           = te.Options.IsYellowFlagEnabled;
            weekend.Realism.PitFuelMultiplier             = te.Options.PitFuelMultiplier;
            switch (te.Options.GameType)
            {
            case CurrentWeekend.cwOptions.eGameType.Arcade:
                weekend.Realism.Mode = WeekendRealism.eMode.Arcade;
                break;

            case CurrentWeekend.cwOptions.eGameType.Simulation:
                weekend.Realism.Mode = WeekendRealism.eMode.Simulation;
                break;
            }
        }
        internal static SessionBlock[] AnalyseTelemetry(TelemetryEvent[] events)
        {
            List <SessionBlock> ret = new List <SessionBlock>();

            CurrentWeekend        currentWeekend       = null;
            SessionInfo           currentSession       = null;
            List <TelemetryEvent> currentSessionEvents = new List <TelemetryEvent>();
            List <DriverEntry>    globalDrivers        = new List <DriverEntry>();
            List <DriverEntry>    localDrivers         = new List <DriverEntry>();
            double lastSessionTime = 0;

            for (int f = 0; f < events.Length; f++)
            {
                TelemetryEvent te = events[f];

                if (te is DriverEntry)
                {
                    if (currentWeekend == null)
                    {
                        DriverEntry existing = globalDrivers.FirstOrDefault(i => (i.CarIdx == (te as DriverEntry).CarIdx));
                        if (existing != null)
                        {
                            if (AreDriverEntriesTheSame(existing, te as DriverEntry) == false)
                            {
                                throw new ApplicationException("Duplicit driver entry CarIdx.");
                            }
                        }
                        else
                        {
                            globalDrivers.Add(te as DriverEntry);
                        }
                    }
                    else
                    {
                        if (localDrivers.FirstOrDefault(i => (i.CarIdx == (te as DriverEntry).CarIdx)) != null)
                        {
                            throw new ApplicationException("Duplicit driver entry CarIdx.");
                        }
                        localDrivers.Add(te as DriverEntry);
                    }
                }
                else if (te is DriverWithdrawl)
                {
                }
                else if (te is CurrentWeekend)
                {
                    if (currentWeekend != null)
                    {
                        SessionBlock sb = BuildNewSessionBlock(
                            currentWeekend, currentSession, currentSessionEvents,
                            globalDrivers, localDrivers);
                        ret.Add(sb);

                        currentWeekend = null;
                        localDrivers   = new List <DriverEntry>();
                    }
                    CurrentWeekend x = te as CurrentWeekend;
                    if (x.AtTrack == false)
                    {
                        currentWeekend = null;
                    }
                    else
                    {
                        currentWeekend = x;
                    }
                }
                else if (te is SessionInfo)
                {
                    //if (currentWeekend == null && currentSession == null) continue;

                    SessionInfo x = te as SessionInfo;
                    //bool isNewSession = (currentSession == null
                    //  || IsNewSession(x));
                    bool isNewSession = (currentSession == null ||
                                         x.CurrentTime <= lastSessionTime);

                    if (isNewSession)
                    {
                        if (currentSession != null && currentWeekend != null)
                        {
                            SessionBlock sb = BuildNewSessionBlock(
                                currentWeekend, currentSession, currentSessionEvents,
                                globalDrivers, localDrivers);
                            ret.Add(sb);
                        }
                        currentSession       = x;
                        currentSessionEvents = new List <TelemetryEvent>();
                    }
                    else
                    {
                        currentSessionEvents.Add(te);
                    }

                    lastSessionTime = x.CurrentTime;
                }
                else
                {
                    if (currentSession != null)
                    {
                        currentSessionEvents.Add(te);
                    }
                }
            }

            return(ret.ToArray());
        }