Example #1
0
        private void UpdateData(Ets2Telemetry data, bool updated)
        {
            try
            {
                if (data != null)
                {
                    if (this.InvokeRequired)
                    {
                        this.Invoke(new TelemetryData(UpdateData), new object[2] {
                            data, updated
                        });
                        return;
                    }

                    UpdateDamage(data);

                    if (data.Job.OnJob)
                    {
                        if ((int)data.Physics.SpeedKmh > maxSpeed)
                        {
                            maxSpeed = (int)data.Physics.SpeedKmh;
                        }
                        avgFuelConsumption = data.Drivetrain.FuelAvgConsumption;
                        if (data.Paused)
                        {
                            string oldJobId = save.GetLastJobId();
                            save.UpdateAllSavedValues(true);
                            string newJobId = save.GetLastJobId();
                            if (newJobId != oldJobId)
                            {
                                TelemetryOnJobFinished(null, null);
                                maxSpeed           = 0;
                                avgFuelConsumption = 0;
                            }
                        }
                    }
                }
            }
            catch { }
        }