From 461b5450d2eae574765e771fb79ff380bee3dd92 Mon Sep 17 00:00:00 2001 From: Kris Roberts Date: Fri, 29 Mar 2024 15:12:54 -0700 Subject: [PATCH] Handle #undefined license color without thorwing an exception. --- RobertsmaniaReplay/VAPlugin_RobertsmaniaReplay.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/RobertsmaniaReplay/VAPlugin_RobertsmaniaReplay.cs b/RobertsmaniaReplay/VAPlugin_RobertsmaniaReplay.cs index fe74f38..02508ee 100644 --- a/RobertsmaniaReplay/VAPlugin_RobertsmaniaReplay.cs +++ b/RobertsmaniaReplay/VAPlugin_RobertsmaniaReplay.cs @@ -1024,12 +1024,18 @@ private static void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUp } } if (e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", i]["LicColor"].TryGetValue(out string licColorStr)) - { - if (licColorStr != "") + if (licColorStr != "" && !licColorStr.Contains("undefined")) { licColor = "#" + Convert.ToInt32(licColorStr, 16).ToString("X6"); } - } + else + { + // Handle the case where licColorStr is "undefined" or empty + // For example, you could log a warning or set a default color + _vaProxy.WriteToLog($"LicColor is not defined or is 'undefined': {licColorStr}", "yellow"); + licColor = "#FFFFFF"; // Set a default color if 'LicColor' is 'undefined' or empty + } + if (e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", i]["CarClassID"].TryGetValue(out string carClassIdStr)) { if (carClassIdStr != "")