From 0eda70fcf10dbdd5f08b1e94cfe377f71072a0ac Mon Sep 17 00:00:00 2001 From: TheCrankLarson <68806777+TheCrankLarson@users.noreply.github.com> Date: Fri, 21 Aug 2020 23:06:13 +0100 Subject: [PATCH] Bugfixes due to updated server code. --- DataCollator/NotificationServer.cs | 14 +- FormRaceMonitor.Designer.cs | 319 +++++++++++++++-------------- FormRaceMonitor.cs | 11 +- FormTracker.cs | 34 +-- 4 files changed, 200 insertions(+), 178 deletions(-) diff --git a/DataCollator/NotificationServer.cs b/DataCollator/NotificationServer.cs index e86a08a..d79f351 100644 --- a/DataCollator/NotificationServer.cs +++ b/DataCollator/NotificationServer.cs @@ -105,9 +105,17 @@ public int Port private void UpdateCommanderStatus(string status) { - EDEvent updateEvent = EDEvent.FromJson(status); - if (String.IsNullOrEmpty(updateEvent.Commander)) - return; + EDEvent updateEvent = null; + try + { + updateEvent = EDEvent.FromJson(status); + if (String.IsNullOrEmpty(updateEvent.Commander)) + return; + } + catch (Exception ex) + { + Log($"Error creating event: {ex.Message}"); + } if (_races.Count > 0) Task.Run(new Action(() => diff --git a/FormRaceMonitor.Designer.cs b/FormRaceMonitor.Designer.cs index e236a8a..bdbb9e6 100644 --- a/FormRaceMonitor.Designer.cs +++ b/FormRaceMonitor.Designer.cs @@ -31,29 +31,16 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.listBoxWaypoints = new System.Windows.Forms.ListBox(); - this.buttonLoadRoute = new System.Windows.Forms.Button(); this.textBoxRouteName = new System.Windows.Forms.TextBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.buttonLoadRace = new System.Windows.Forms.Button(); - this.buttonSaveRaceAs = new System.Windows.Forms.Button(); - this.buttonSaveRace = new System.Windows.Forms.Button(); this.textBoxRaceName = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.textBoxPlanet = new System.Windows.Forms.TextBox(); this.textBoxSystem = new System.Windows.Forms.TextBox(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.buttonRaceHistory = new System.Windows.Forms.Button(); - this.buttonReset = new System.Windows.Forms.Button(); - this.buttonEditStatusMessages = new System.Windows.Forms.Button(); this.groupBoxAddCommander = new System.Windows.Forms.GroupBox(); this.comboBoxAddCommander = new System.Windows.Forms.ComboBox(); - this.buttonAddCommander = new System.Windows.Forms.Button(); - this.buttonStopRace = new System.Windows.Forms.Button(); - this.buttonStartRace = new System.Windows.Forms.Button(); - this.buttonTrackParticipant = new System.Windows.Forms.Button(); - this.buttonRemoveParticipant = new System.Windows.Forms.Button(); - this.buttonAddParticipant = new System.Windows.Forms.Button(); this.listViewParticipants = new System.Windows.Forms.ListView(); this.columnHeaderPosition = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -94,6 +81,19 @@ private void InitializeComponent() this.label5 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.textBoxHTMLTemplateFile = new System.Windows.Forms.TextBox(); + this.buttonRaceHistory = new System.Windows.Forms.Button(); + this.buttonReset = new System.Windows.Forms.Button(); + this.buttonEditStatusMessages = new System.Windows.Forms.Button(); + this.buttonAddCommander = new System.Windows.Forms.Button(); + this.buttonStopRace = new System.Windows.Forms.Button(); + this.buttonStartRace = new System.Windows.Forms.Button(); + this.buttonTrackParticipant = new System.Windows.Forms.Button(); + this.buttonRemoveParticipant = new System.Windows.Forms.Button(); + this.buttonAddParticipant = new System.Windows.Forms.Button(); + this.buttonLoadRace = new System.Windows.Forms.Button(); + this.buttonSaveRaceAs = new System.Windows.Forms.Button(); + this.buttonSaveRace = new System.Windows.Forms.Button(); + this.buttonLoadRoute = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -131,17 +131,6 @@ private void InitializeComponent() this.listBoxWaypoints.TabIndex = 2; this.listBoxWaypoints.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.listBoxWaypoints_DrawItem); // - // buttonLoadRoute - // - this.buttonLoadRoute.Image = global::SRVTracker.Properties.Resources.OpenFile_16x; - this.buttonLoadRoute.Location = new System.Drawing.Point(256, 17); - this.buttonLoadRoute.Name = "buttonLoadRoute"; - this.buttonLoadRoute.Size = new System.Drawing.Size(38, 23); - this.buttonLoadRoute.TabIndex = 1; - this.toolTip1.SetToolTip(this.buttonLoadRoute, "Load route from file"); - this.buttonLoadRoute.UseVisualStyleBackColor = true; - this.buttonLoadRoute.Click += new System.EventHandler(this.buttonLoadRoute_Click); - // // textBoxRouteName // this.textBoxRouteName.Location = new System.Drawing.Point(6, 19); @@ -163,39 +152,6 @@ private void InitializeComponent() this.groupBox2.TabStop = false; this.groupBox2.Text = "Event"; // - // buttonLoadRace - // - this.buttonLoadRace.Image = global::SRVTracker.Properties.Resources.OpenFile_16x; - this.buttonLoadRace.Location = new System.Drawing.Point(291, 16); - this.buttonLoadRace.Name = "buttonLoadRace"; - this.buttonLoadRace.Size = new System.Drawing.Size(29, 23); - this.buttonLoadRace.TabIndex = 10; - this.toolTip1.SetToolTip(this.buttonLoadRace, "Load race from file"); - this.buttonLoadRace.UseVisualStyleBackColor = true; - this.buttonLoadRace.Click += new System.EventHandler(this.buttonLoadRace_Click); - // - // buttonSaveRaceAs - // - this.buttonSaveRaceAs.Image = global::SRVTracker.Properties.Resources.SaveAs_16x; - this.buttonSaveRaceAs.Location = new System.Drawing.Point(326, 16); - this.buttonSaveRaceAs.Name = "buttonSaveRaceAs"; - this.buttonSaveRaceAs.Size = new System.Drawing.Size(29, 23); - this.buttonSaveRaceAs.TabIndex = 9; - this.toolTip1.SetToolTip(this.buttonSaveRaceAs, "Save race as..."); - this.buttonSaveRaceAs.UseVisualStyleBackColor = true; - this.buttonSaveRaceAs.Click += new System.EventHandler(this.buttonSaveRaceAs_Click); - // - // buttonSaveRace - // - this.buttonSaveRace.Image = global::SRVTracker.Properties.Resources.Save_16x; - this.buttonSaveRace.Location = new System.Drawing.Point(361, 16); - this.buttonSaveRace.Name = "buttonSaveRace"; - this.buttonSaveRace.Size = new System.Drawing.Size(29, 23); - this.buttonSaveRace.TabIndex = 8; - this.toolTip1.SetToolTip(this.buttonSaveRace, "Save race"); - this.buttonSaveRace.UseVisualStyleBackColor = true; - this.buttonSaveRace.Click += new System.EventHandler(this.buttonSaveRace_Click); - // // textBoxRaceName // this.textBoxRaceName.Location = new System.Drawing.Point(6, 19); @@ -257,41 +213,6 @@ private void InitializeComponent() this.groupBox3.TabStop = false; this.groupBox3.Text = "Participants"; // - // buttonRaceHistory - // - this.buttonRaceHistory.Enabled = false; - this.buttonRaceHistory.Image = global::SRVTracker.Properties.Resources.History_16x; - this.buttonRaceHistory.Location = new System.Drawing.Point(361, 202); - this.buttonRaceHistory.Name = "buttonRaceHistory"; - this.buttonRaceHistory.Size = new System.Drawing.Size(29, 23); - this.buttonRaceHistory.TabIndex = 9; - this.toolTip1.SetToolTip(this.buttonRaceHistory, "Show race history"); - this.buttonRaceHistory.UseVisualStyleBackColor = true; - this.buttonRaceHistory.Click += new System.EventHandler(this.buttonRaceHistory_Click); - // - // buttonReset - // - this.buttonReset.Enabled = false; - this.buttonReset.Image = global::SRVTracker.Properties.Resources.Restart_16x; - this.buttonReset.Location = new System.Drawing.Point(361, 318); - this.buttonReset.Name = "buttonReset"; - this.buttonReset.Size = new System.Drawing.Size(29, 23); - this.buttonReset.TabIndex = 8; - this.toolTip1.SetToolTip(this.buttonReset, "Reset race"); - this.buttonReset.UseVisualStyleBackColor = true; - this.buttonReset.Click += new System.EventHandler(this.buttonReset_Click); - // - // buttonEditStatusMessages - // - this.buttonEditStatusMessages.Image = global::SRVTracker.Properties.Resources.Text_16x; - this.buttonEditStatusMessages.Location = new System.Drawing.Point(361, 231); - this.buttonEditStatusMessages.Name = "buttonEditStatusMessages"; - this.buttonEditStatusMessages.Size = new System.Drawing.Size(29, 23); - this.buttonEditStatusMessages.TabIndex = 7; - this.toolTip1.SetToolTip(this.buttonEditStatusMessages, "Edit status messages"); - this.buttonEditStatusMessages.UseVisualStyleBackColor = true; - this.buttonEditStatusMessages.Click += new System.EventHandler(this.buttonEditStatusMessages_Click); - // // groupBoxAddCommander // this.groupBoxAddCommander.Controls.Add(this.comboBoxAddCommander); @@ -314,73 +235,6 @@ private void InitializeComponent() this.comboBoxAddCommander.SelectedIndexChanged += new System.EventHandler(this.comboBoxAddCommander_SelectedIndexChanged); this.comboBoxAddCommander.Leave += new System.EventHandler(this.comboBoxAddCommander_Leave); // - // buttonAddCommander - // - this.buttonAddCommander.Image = global::SRVTracker.Properties.Resources.Return_16x; - this.buttonAddCommander.Location = new System.Drawing.Point(249, 16); - this.buttonAddCommander.Name = "buttonAddCommander"; - this.buttonAddCommander.Size = new System.Drawing.Size(29, 23); - this.buttonAddCommander.TabIndex = 8; - this.buttonAddCommander.UseVisualStyleBackColor = true; - this.buttonAddCommander.Click += new System.EventHandler(this.buttonAddCommander_Click); - // - // buttonStopRace - // - this.buttonStopRace.Enabled = false; - this.buttonStopRace.Image = global::SRVTracker.Properties.Resources.Stop_16x; - this.buttonStopRace.Location = new System.Drawing.Point(361, 289); - this.buttonStopRace.Name = "buttonStopRace"; - this.buttonStopRace.Size = new System.Drawing.Size(29, 23); - this.buttonStopRace.TabIndex = 6; - this.toolTip1.SetToolTip(this.buttonStopRace, "Stop race"); - this.buttonStopRace.UseVisualStyleBackColor = true; - this.buttonStopRace.Click += new System.EventHandler(this.buttonStopRace_Click); - // - // buttonStartRace - // - this.buttonStartRace.Enabled = false; - this.buttonStartRace.Image = global::SRVTracker.Properties.Resources.Run_16x; - this.buttonStartRace.Location = new System.Drawing.Point(361, 260); - this.buttonStartRace.Name = "buttonStartRace"; - this.buttonStartRace.Size = new System.Drawing.Size(29, 23); - this.buttonStartRace.TabIndex = 5; - this.toolTip1.SetToolTip(this.buttonStartRace, "Start race"); - this.buttonStartRace.UseVisualStyleBackColor = true; - this.buttonStartRace.Click += new System.EventHandler(this.buttonStartRace_Click); - // - // buttonTrackParticipant - // - this.buttonTrackParticipant.Image = global::SRVTracker.Properties.Resources.Target_16x; - this.buttonTrackParticipant.Location = new System.Drawing.Point(361, 77); - this.buttonTrackParticipant.Name = "buttonTrackParticipant"; - this.buttonTrackParticipant.Size = new System.Drawing.Size(29, 23); - this.buttonTrackParticipant.TabIndex = 3; - this.toolTip1.SetToolTip(this.buttonTrackParticipant, "Track participant"); - this.buttonTrackParticipant.UseVisualStyleBackColor = true; - this.buttonTrackParticipant.Click += new System.EventHandler(this.buttonTrackParticipant_Click); - // - // buttonRemoveParticipant - // - this.buttonRemoveParticipant.Image = global::SRVTracker.Properties.Resources.Remove_color_16x; - this.buttonRemoveParticipant.Location = new System.Drawing.Point(361, 48); - this.buttonRemoveParticipant.Name = "buttonRemoveParticipant"; - this.buttonRemoveParticipant.Size = new System.Drawing.Size(29, 23); - this.buttonRemoveParticipant.TabIndex = 2; - this.toolTip1.SetToolTip(this.buttonRemoveParticipant, "Remove participant"); - this.buttonRemoveParticipant.UseVisualStyleBackColor = true; - this.buttonRemoveParticipant.Click += new System.EventHandler(this.buttonRemoveParticipant_Click); - // - // buttonAddParticipant - // - this.buttonAddParticipant.Image = global::SRVTracker.Properties.Resources.Add_16x; - this.buttonAddParticipant.Location = new System.Drawing.Point(361, 19); - this.buttonAddParticipant.Name = "buttonAddParticipant"; - this.buttonAddParticipant.Size = new System.Drawing.Size(29, 23); - this.buttonAddParticipant.TabIndex = 1; - this.toolTip1.SetToolTip(this.buttonAddParticipant, "Add commander"); - this.buttonAddParticipant.UseVisualStyleBackColor = true; - this.buttonAddParticipant.Click += new System.EventHandler(this.buttonAddParticipant_Click); - // // listViewParticipants // this.listViewParticipants.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { @@ -811,6 +665,152 @@ private void InitializeComponent() this.textBoxHTMLTemplateFile.TabIndex = 0; this.textBoxHTMLTemplateFile.Text = "Leaderboard Template.html"; // + // buttonRaceHistory + // + this.buttonRaceHistory.Enabled = false; + this.buttonRaceHistory.Image = global::SRVTracker.Properties.Resources.History_16x; + this.buttonRaceHistory.Location = new System.Drawing.Point(361, 202); + this.buttonRaceHistory.Name = "buttonRaceHistory"; + this.buttonRaceHistory.Size = new System.Drawing.Size(29, 23); + this.buttonRaceHistory.TabIndex = 9; + this.toolTip1.SetToolTip(this.buttonRaceHistory, "Show race history"); + this.buttonRaceHistory.UseVisualStyleBackColor = true; + this.buttonRaceHistory.Click += new System.EventHandler(this.buttonRaceHistory_Click); + // + // buttonReset + // + this.buttonReset.Enabled = false; + this.buttonReset.Image = global::SRVTracker.Properties.Resources.Restart_16x; + this.buttonReset.Location = new System.Drawing.Point(361, 318); + this.buttonReset.Name = "buttonReset"; + this.buttonReset.Size = new System.Drawing.Size(29, 23); + this.buttonReset.TabIndex = 8; + this.toolTip1.SetToolTip(this.buttonReset, "Reset race"); + this.buttonReset.UseVisualStyleBackColor = true; + this.buttonReset.Click += new System.EventHandler(this.buttonReset_Click); + // + // buttonEditStatusMessages + // + this.buttonEditStatusMessages.Image = global::SRVTracker.Properties.Resources.Text_16x; + this.buttonEditStatusMessages.Location = new System.Drawing.Point(361, 231); + this.buttonEditStatusMessages.Name = "buttonEditStatusMessages"; + this.buttonEditStatusMessages.Size = new System.Drawing.Size(29, 23); + this.buttonEditStatusMessages.TabIndex = 7; + this.toolTip1.SetToolTip(this.buttonEditStatusMessages, "Edit status messages"); + this.buttonEditStatusMessages.UseVisualStyleBackColor = true; + this.buttonEditStatusMessages.Click += new System.EventHandler(this.buttonEditStatusMessages_Click); + // + // buttonAddCommander + // + this.buttonAddCommander.Image = global::SRVTracker.Properties.Resources.Return_16x; + this.buttonAddCommander.Location = new System.Drawing.Point(249, 16); + this.buttonAddCommander.Name = "buttonAddCommander"; + this.buttonAddCommander.Size = new System.Drawing.Size(29, 23); + this.buttonAddCommander.TabIndex = 8; + this.buttonAddCommander.UseVisualStyleBackColor = true; + this.buttonAddCommander.Click += new System.EventHandler(this.buttonAddCommander_Click); + // + // buttonStopRace + // + this.buttonStopRace.Enabled = false; + this.buttonStopRace.Image = global::SRVTracker.Properties.Resources.Stop_16x; + this.buttonStopRace.Location = new System.Drawing.Point(361, 289); + this.buttonStopRace.Name = "buttonStopRace"; + this.buttonStopRace.Size = new System.Drawing.Size(29, 23); + this.buttonStopRace.TabIndex = 6; + this.toolTip1.SetToolTip(this.buttonStopRace, "Stop race"); + this.buttonStopRace.UseVisualStyleBackColor = true; + this.buttonStopRace.Click += new System.EventHandler(this.buttonStopRace_Click); + // + // buttonStartRace + // + this.buttonStartRace.Enabled = false; + this.buttonStartRace.Image = global::SRVTracker.Properties.Resources.Run_16x; + this.buttonStartRace.Location = new System.Drawing.Point(361, 260); + this.buttonStartRace.Name = "buttonStartRace"; + this.buttonStartRace.Size = new System.Drawing.Size(29, 23); + this.buttonStartRace.TabIndex = 5; + this.toolTip1.SetToolTip(this.buttonStartRace, "Start race"); + this.buttonStartRace.UseVisualStyleBackColor = true; + this.buttonStartRace.Click += new System.EventHandler(this.buttonStartRace_Click); + // + // buttonTrackParticipant + // + this.buttonTrackParticipant.Image = global::SRVTracker.Properties.Resources.Target_16x; + this.buttonTrackParticipant.Location = new System.Drawing.Point(361, 77); + this.buttonTrackParticipant.Name = "buttonTrackParticipant"; + this.buttonTrackParticipant.Size = new System.Drawing.Size(29, 23); + this.buttonTrackParticipant.TabIndex = 3; + this.toolTip1.SetToolTip(this.buttonTrackParticipant, "Track participant"); + this.buttonTrackParticipant.UseVisualStyleBackColor = true; + this.buttonTrackParticipant.Click += new System.EventHandler(this.buttonTrackParticipant_Click); + // + // buttonRemoveParticipant + // + this.buttonRemoveParticipant.Image = global::SRVTracker.Properties.Resources.Remove_color_16x; + this.buttonRemoveParticipant.Location = new System.Drawing.Point(361, 48); + this.buttonRemoveParticipant.Name = "buttonRemoveParticipant"; + this.buttonRemoveParticipant.Size = new System.Drawing.Size(29, 23); + this.buttonRemoveParticipant.TabIndex = 2; + this.toolTip1.SetToolTip(this.buttonRemoveParticipant, "Remove participant"); + this.buttonRemoveParticipant.UseVisualStyleBackColor = true; + this.buttonRemoveParticipant.Click += new System.EventHandler(this.buttonRemoveParticipant_Click); + // + // buttonAddParticipant + // + this.buttonAddParticipant.Image = global::SRVTracker.Properties.Resources.Add_16x; + this.buttonAddParticipant.Location = new System.Drawing.Point(361, 19); + this.buttonAddParticipant.Name = "buttonAddParticipant"; + this.buttonAddParticipant.Size = new System.Drawing.Size(29, 23); + this.buttonAddParticipant.TabIndex = 1; + this.toolTip1.SetToolTip(this.buttonAddParticipant, "Add commander"); + this.buttonAddParticipant.UseVisualStyleBackColor = true; + this.buttonAddParticipant.Click += new System.EventHandler(this.buttonAddParticipant_Click); + // + // buttonLoadRace + // + this.buttonLoadRace.Image = global::SRVTracker.Properties.Resources.OpenFile_16x; + this.buttonLoadRace.Location = new System.Drawing.Point(291, 16); + this.buttonLoadRace.Name = "buttonLoadRace"; + this.buttonLoadRace.Size = new System.Drawing.Size(29, 23); + this.buttonLoadRace.TabIndex = 10; + this.toolTip1.SetToolTip(this.buttonLoadRace, "Load race from file"); + this.buttonLoadRace.UseVisualStyleBackColor = true; + this.buttonLoadRace.Click += new System.EventHandler(this.buttonLoadRace_Click); + // + // buttonSaveRaceAs + // + this.buttonSaveRaceAs.Image = global::SRVTracker.Properties.Resources.SaveAs_16x; + this.buttonSaveRaceAs.Location = new System.Drawing.Point(326, 16); + this.buttonSaveRaceAs.Name = "buttonSaveRaceAs"; + this.buttonSaveRaceAs.Size = new System.Drawing.Size(29, 23); + this.buttonSaveRaceAs.TabIndex = 9; + this.toolTip1.SetToolTip(this.buttonSaveRaceAs, "Save race as..."); + this.buttonSaveRaceAs.UseVisualStyleBackColor = true; + this.buttonSaveRaceAs.Click += new System.EventHandler(this.buttonSaveRaceAs_Click); + // + // buttonSaveRace + // + this.buttonSaveRace.Image = global::SRVTracker.Properties.Resources.Save_16x; + this.buttonSaveRace.Location = new System.Drawing.Point(361, 16); + this.buttonSaveRace.Name = "buttonSaveRace"; + this.buttonSaveRace.Size = new System.Drawing.Size(29, 23); + this.buttonSaveRace.TabIndex = 8; + this.toolTip1.SetToolTip(this.buttonSaveRace, "Save race"); + this.buttonSaveRace.UseVisualStyleBackColor = true; + this.buttonSaveRace.Click += new System.EventHandler(this.buttonSaveRace_Click); + // + // buttonLoadRoute + // + this.buttonLoadRoute.Image = global::SRVTracker.Properties.Resources.OpenFile_16x; + this.buttonLoadRoute.Location = new System.Drawing.Point(256, 17); + this.buttonLoadRoute.Name = "buttonLoadRoute"; + this.buttonLoadRoute.Size = new System.Drawing.Size(38, 23); + this.buttonLoadRoute.TabIndex = 1; + this.toolTip1.SetToolTip(this.buttonLoadRoute, "Load route from file"); + this.buttonLoadRoute.UseVisualStyleBackColor = true; + this.buttonLoadRoute.Click += new System.EventHandler(this.buttonLoadRoute_Click); + // // FormRaceMonitor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -825,6 +825,7 @@ private void InitializeComponent() this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; this.Name = "FormRaceMonitor"; this.Text = "Race Monitor"; this.Deactivate += new System.EventHandler(this.FormRaceMonitor_Deactivate); diff --git a/FormRaceMonitor.cs b/FormRaceMonitor.cs index 51ab44e..f3f8ea7 100644 --- a/FormRaceMonitor.cs +++ b/FormRaceMonitor.cs @@ -339,14 +339,14 @@ private List RacePositions() // Move past anyone who is at a higher waypoint while ((i < positions.Count) && _racersStatus[positions[i]].WaypointIndex < _racersStatus[racer].WaypointIndex && !_racersStatus[positions[i]].Eliminated) i++; - if (i < positions.Count && _racersStatus[positions[i]].Eliminated) + if ( (i < positions.Count) && _racersStatus[positions[i]].Eliminated && (i>0) ) i--; else { // Now we check distances (as these positions are heading to the same waypoint) while ((i < positions.Count) && (_racersStatus[positions[i]].WaypointIndex == _racersStatus[racer].WaypointIndex) && (_racersStatus[positions[i]].DistanceToWaypoint < _racersStatus[racer].DistanceToWaypoint) && (!_racersStatus[positions[i]].Eliminated)) i++; - if (i < positions.Count && _racersStatus[positions[i]].Eliminated) + if ( (i < positions.Count) && _racersStatus[positions[i]].Eliminated && (i>0) ) i--; } } @@ -384,7 +384,12 @@ private void ExportLeaderboard(ListleaderBoard = null) else { if (checkBoxExportDistance.Checked && !_racersStatus[leaderBoard[i]].Eliminated) - status.AppendLine($"{(_racersStatus[leaderBoard[i]].DistanceToWaypoint / 1000):F1}"); + { + if ((_racersStatus[leaderBoard[i]].DistanceToWaypoint == double.MaxValue)) + status.AppendLine("NA"); + else + status.AppendLine($"{(_racersStatus[leaderBoard[i]].DistanceToWaypoint / 1000):F1}"); + } else status.AppendLine(_racersStatus[leaderBoard[i]].ToString()); } diff --git a/FormTracker.cs b/FormTracker.cs index 7eaefe7..852805d 100644 --- a/FormTracker.cs +++ b/FormTracker.cs @@ -422,9 +422,11 @@ private void SaveToFile(EDEvent edEvent) private void UploadToServer(EDEvent edEvent) { + if (_udpClient == null) + CreateUdpClient(); try { - string eventData = $"{textBoxClientId.Text}:{edEvent.ToJson()}"; + string eventData = edEvent.ToJson();// $"{textBoxClientId.Text}:{edEvent.ToJson()}"; //if (checkBoxSendLocationOnly.Checked || String.IsNullOrEmpty(edEvent.RawData)) // eventData = $"{textBoxClientId.Text},{edEvent.TrackingInfo}"; //else @@ -514,24 +516,30 @@ private void textBoxUploadServer_TextChanged(object sender, EventArgs e) FormLocator.ServerAddress = textBoxUploadServer.Text; } + private void CreateUdpClient() + { + // Create the UDP client for sending tracking data + try + { + string serverUrl = (string)radioButtonUseDefaultServer.Tag; + if (radioButtonUseCustomServer.Checked) + serverUrl = textBoxUploadServer.Text; + _udpClient = new UdpClient(serverUrl, 11938); + } + catch (Exception ex) + { + AddLog($"Error creating UDP client: {ex.Message}"); + checkBoxUpload.Checked = false; + } + } + private void checkBoxUpload_CheckedChanged(object sender, EventArgs e) { UpdateServerSettings(); if (checkBoxUpload.Checked) { // Create the UDP client for sending tracking data - try - { - string serverUrl = (string)radioButtonUseDefaultServer.Tag; - if (radioButtonUseCustomServer.Checked) - serverUrl = textBoxUploadServer.Text; - _udpClient = new UdpClient(serverUrl, 11938); - } - catch (Exception ex) - { - AddLog($"Error creating UDP client: {ex.Message}"); - checkBoxUpload.Checked = false; - } + CreateUdpClient(); } else if (_udpClient != null) {