diff --git a/Assembly.version b/Assembly.version
index b9ef449..a99e644 100644
--- a/Assembly.version
+++ b/Assembly.version
@@ -2,6 +2,6 @@
2
1
- 3
+ 4
\ No newline at end of file
diff --git a/TweaksAndThings/Patches/AutoEngineerOrdersHelper_SendAutoEngineerCommand_Patch.cs b/TweaksAndThings/Patches/AutoEngineerOrdersHelper_SendAutoEngineerCommand_Patch.cs
index 9f84153..d398bed 100644
--- a/TweaksAndThings/Patches/AutoEngineerOrdersHelper_SendAutoEngineerCommand_Patch.cs
+++ b/TweaksAndThings/Patches/AutoEngineerOrdersHelper_SendAutoEngineerCommand_Patch.cs
@@ -86,6 +86,8 @@ internal class AutoEngineerOrdersHelper_SendAutoEngineerCommand_Patch
noCaboose();
logMessage += $"\nGovern AE? {output}";
+ if (_log.IsEnabled(Serilog.Events.LogEventLevel.Debug))
+ logMessage += $"\n{Environment.StackTrace}";
_log.Information(logMessage);
diff --git a/TweaksAndThings/Patches/AutoEngineerWaypointControls_ConfigureOptionsDropdown_Patch.cs b/TweaksAndThings/Patches/AutoEngineerWaypointControls_ConfigureOptionsDropdown_Patch.cs
index 6833a81..bb1d42b 100644
--- a/TweaksAndThings/Patches/AutoEngineerWaypointControls_ConfigureOptionsDropdown_Patch.cs
+++ b/TweaksAndThings/Patches/AutoEngineerWaypointControls_ConfigureOptionsDropdown_Patch.cs
@@ -30,9 +30,7 @@ internal class AutoEngineerWaypointControls_ConfigureOptionsDropdown_Patch
private static readonly HashSet _keyChangeObservers = new();
private static readonly Dictionary> locoConsistDestinations = new();
- private static readonly HashSet consist = new();
- private static string _lastLocoCarId = string.Empty;
- private static bool recalcing = false;
+ private static string _lastSelectedLoco = string.Empty;
static string getDictKey(Car car) => car.DisplayName;
@@ -40,7 +38,9 @@ internal class AutoEngineerWaypointControls_ConfigureOptionsDropdown_Patch
{
PrepLocoUsage(out BaseLocomotive selectedLoco, out int numberOfCars);
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase.Shared;
- if (!tweaksAndThings.IsEnabled()) return;
+ if (!tweaksAndThings.IsEnabled() || (locoConsistDestinations.TryGetValue(getDictKey(selectedLoco), out Dictionary cars) && cars != null && _lastSelectedLoco == getDictKey(selectedLoco))) return;
+
+ _lastSelectedLoco = getDictKey(selectedLoco);
IterateCarsDetectDestinations(
__instance,
@@ -220,7 +220,6 @@ internal class AutoEngineerWaypointControls_ConfigureOptionsDropdown_Patch
_log.Debug($"{getDictKey(selectedLoco)} --> HI BOB[{numberOfCars}]");
foreach (var o in _keyChangeObservers) o.Dispose();
_keyChangeObservers.Clear();
- recalcing = false;
}
private static OpsCarPosition? GetCarDestinationIdentifier(Car c)
@@ -276,7 +275,11 @@ internal class AutoEngineerWaypointControls_ConfigureOptionsDropdown_Patch
key,
delegate (Value value)
{
- if (recalcing) return;
+
+ _log.Debug($"{getDictKey(car)} OBSV {key}: {value}");
+
+ if (locoConsistDestinations.TryGetValue(getDictKey(TrainController.Shared.SelectedLocomotive), out Dictionary cars) && cars == null) return;
+
bool waybillChng = (new[] { Car.KeyOpsWaybill, Car.KeyOpsRepairDestination }).Contains(key);
string? destId =
waybillChng ?
@@ -284,8 +287,7 @@ internal class AutoEngineerWaypointControls_ConfigureOptionsDropdown_Patch
null;
if (waybillChng)
{
- if (locoConsistDestinations.TryGetValue(getDictKey(TrainController.Shared.SelectedLocomotive), out Dictionary cars)
- && cars.TryGetValue(getDictKey(car), out OpsCarPosition pos)
+ if (cars.TryGetValue(getDictKey(car), out OpsCarPosition pos)
&& pos.Identifier == destId)
{
return;
@@ -307,7 +309,7 @@ internal class AutoEngineerWaypointControls_ConfigureOptionsDropdown_Patch
var loco = TrainController.Shared.SelectedLocomotive;
if (!TrainController.Shared.SelectRecall()) TrainController.Shared.SelectedCar = null;
_keyChangeObservers.Clear();
- recalcing = true;
+ if (locoConsistDestinations.TryGetValue(getDictKey(TrainController.Shared.SelectedLocomotive), out _)) locoConsistDestinations[getDictKey(TrainController.Shared.SelectedLocomotive)] = null;
TrainController.Shared.SelectedCar = loco;
}
catch (Exception ex)