Esempio n. 1
0
        public bool DidCut(out string cornerName)
        {
            cornerName = String.Empty;

            // If the driver is on their first update since connecting, they obviously can't cut.
            if (Double.IsNaN(LastPosition.X))
            {
                return(false);
            }


            // Do speed test. May not be going fast enough to punish for cutting.
            if (m_speed < 50)
            {
                return(false);
            }

            // Absurd speeds are down to lag, so should also ignore.
            if (m_speed > 400)
            {
                return(false);
            }

            bool didCut = CutTester.TestCutLines(new Vector2F(LastPosition.X, LastPosition.Z),
                                                 new Vector2F(CurrentPosition.X, CurrentPosition.Z), out cornerName);

            DidCutThisLap |= didCut;

            return(didCut);
        }
Esempio n. 2
0
        private static void HandleNewSessionInfo(BinaryReader reader, ACSProtocol packetID)
        {
            reader.ReadByte();         // Version.
            reader.ReadByte();         // Session index.
            reader.ReadByte();         // Current session index.
            reader.ReadByte();         // Session count.
            ReadUnicodeString(reader); // Server name.

            string track       = ReadAsciiString(reader);
            string trackLayout = ReadAsciiString(reader);

            ReadAsciiString(reader);   // Session name.

            var prevSessionType = m_sessionType;

            m_sessionType = (SessionType)reader.ReadByte();

            if (packetID == ACSProtocol.NewSession)
            {
                if (!m_forwardingEnabled || m_overrideUpdateRate)
                {
                    ActivateRealTimeReporting();
                }

                string currentLayout = $"{track}-{trackLayout}";

                if (m_lastTrackLayout != currentLayout)
                {
                    Console.WriteLine($"Loading cut file for {track}-{trackLayout}");
                    CutTester.LoadTrack(track, trackLayout);
                    m_lastTrackLayout = $"{track}-{trackLayout}";
                }

                Console.WriteLine($"New session started: {m_sessionType}");

                if (prevSessionType == SessionType.Qualifying)
                {
                    OutputCutBestLaps();
                }

                WriteLog($"[Session] : Session ended {prevSessionType}");

                foreach (var driver in m_driversFromGUID)
                {
                    driver.Value.ResetLapCount();
                    driver.Value.ResetCutCount();
                }
            }
        }