예제 #1
0
 public PacketSessionData(int a)
 {
     m_marshalZones = new MarshalZone[21];
     m_header       = new PacketHeader();
     m_weather      = 0;         // Weather - 0 = clear, 1 = light cloud, 2 = overcast
                                 // 3 = light rain, 4 = heavy rain, 5 = storm
     m_trackTemperature = 0;     // Track temp. in degrees celsius
     m_airTemperature   = 0;     // Air temp. in degrees celsius
     m_totalLaps        = 0;     // Total number of laps in this race
     m_trackLength      = 0;     // Track length in metres
     m_sessionType      = 0;     // 0 = unknown, 1 = P1, 2 = P2, 3 = P3, 4 = Short P
                                 // 5 = Q1, 6 = Q2, 7 = Q3, 8 = Short Q, 9 = OSQ
                                 // 10 = R, 11 = R2, 12 = Time Trial
     m_trackId             = 0;  // -1 for unknown, 0-21 for tracks, see appendix
     m_era                 = 0;  // Era, 0 = modern, 1 = classic
     m_sessionTimeLeft     = 0;  // Time left in session in seconds
     m_sessionDuration     = 0;  // Session duration in seconds
     m_pitSpeedLimit       = 0;  // Pit speed limit in kilometres per hour
     m_gamePaused          = 0;  // Whether the game is paused
     m_isSpectating        = 0;  // Whether the player is spectating
     m_spectatorCarIndex   = 0;  // Index of the car being spectated
     m_sliProNativeSupport = 0;  // SLI Pro support, 0 = inactive, 1 = active
     m_numMarshalZones     = 0;  // Number of marshal zones to follow
     m_safetyCarStatus     = 0;  // 0 = no safety car, 1 = full safety car
                                 // 2 = virtual safety car
     m_networkGame = 0;          // 0 = offline, 1 = online
 }
예제 #2
0
        private static IPacket Session(PacketHeader packetHeader, BinaryReader reader)
        {
            var packetSessionData = new PacketSessionData(packetHeader);

            packetSessionData.Weather = (WeatherType)reader.ReadByte();

            packetSessionData.TrackTemperature = reader.ReadSByte();
            packetSessionData.AirTemperature   = reader.ReadSByte();

            packetSessionData.TotalLaps   = reader.ReadByte();
            packetSessionData.TrackLength = reader.ReadUInt16();
            packetSessionData.SessionType = (SessionType)reader.ReadByte();

            packetSessionData.TrackId = reader.ReadSByte();
            packetSessionData.Formula = reader.ReadByte();

            packetSessionData.SessionTimeLeft     = reader.ReadUInt16();
            packetSessionData.SessionDuration     = reader.ReadUInt16();
            packetSessionData.PitSpeedLimit       = reader.ReadByte();
            packetSessionData.GamePaused          = reader.ReadByte();
            packetSessionData.IsSpectating        = reader.ReadByte();
            packetSessionData.SpectatorCarIndex   = reader.ReadByte();
            packetSessionData.SliProNativeSupport = reader.ReadByte();
            packetSessionData.NumMarshalZones     = reader.ReadByte();

            for (int j = 0; j < MaxNumberOfMarshalZones; j++)
            {
                var marshalZone = new MarshalZone();

                marshalZone.ZoneStart = reader.ReadSingle();
                marshalZone.ZoneFlag  = (ZoneFlag)reader.ReadSByte();

                packetSessionData.MarshalZones[j] = marshalZone;
            }

            packetSessionData.SafetyCarStatus = reader.ReadByte();

            packetSessionData.NetworkGame = reader.ReadByte();
            packetSessionData.NumWeatherForecastSamples = reader.ReadByte();

            for (int j = 0; j < MaxNumberOfWeatherSamples; j++)
            {
                var newWeatherForecastSample = new WeatherForecastSample();

                newWeatherForecastSample.SessionType = (SessionType)reader.ReadByte();

                newWeatherForecastSample.TimeOffset = reader.ReadByte();
                newWeatherForecastSample.Weather    = (WeatherType)reader.ReadByte();

                newWeatherForecastSample.TrackTemperature = reader.ReadSByte();
                newWeatherForecastSample.AirTemperature   = reader.ReadSByte();

                packetSessionData.WeatherForecastSamples[j] = newWeatherForecastSample;
            }

            return(packetSessionData);
        }