AvionicsSystems icon indicating copy to clipboard operation
AvionicsSystems copied to clipboard

Exceptions spewed from VesselDistanceComparer when vessels are far apart from each other

Open JonnyOThan opened this issue 7 months ago • 1 comments

https://github.com/MOARdV/AvionicsSystems/blob/c9a8777e7a14d19667d93b17bf3fe2e2430bf68e/Source/MASFlightComputerProxy.cs#L262

I suspect the issue here is the cast - it's completely plausible that distA - distB is outside the range that is representable by an int.

[ERR 12:10:00.637] [MASFlightComputer] System.ArgumentException: Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: 'AvionicsSystems.MASFlightComputerProxy+VesselDistanceComparer'.
  at System.Collections.Generic.IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer (System.Object comparer) [0x0000b] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Collections.Generic.ArraySortHelper1[T].Sort (T[] keys, System.Int32 index, System.Int32 length, System.Collections.Generic.IComparer1[T] comparer) [0x00022] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Array.Sort[T] (T[] array, System.Int32 index, System.Int32 length, System.Collections.Generic.IComparer1[T] comparer) [0x00048] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Array.Sort[T] (T[] array, System.Collections.Generic.IComparer1[T] comparer) [0x0000e] in <9577ac7a62ef43179789031239ba8798>:0 
  at AvionicsSystems.MASFlightComputerProxy.UpdateNeighboringVessels () [0x000f7] in <db10995086534affaad527490c5182ef>:0 
  at AvionicsSystems.MASFlightComputerProxy.TargetVesselName (System.Double id) [0x00000] in <db10995086534affaad527490c5182ef>:0 
  at (wrapper dynamic-method) AvionicsSystems.DynamicMethodFactory.(object,double)
  at (wrapper delegate-invoke) System.Func`3[System.Object,System.Double,System.String].invoke_TResult_T1_T2(object,double)
  at AvionicsSystems.MASFlightComputer+<>cDisplayClass70_2.<Generate1ParmCallVariable>b1 () [0x00023] in <db10995086534affaad527490c5182ef>:0 
  at AvionicsSystems.StringVariable.Evaluate (System.Boolean invokeCallbacks) [0x00019] in <db10995086534affaad527490c5182ef>:0 
  at AvionicsSystems.MASFlightComputer.FixedUpdate () [0x00395] in <db10995086534affaad527490c5182ef>:0

JonnyOThan avatar Nov 18 '23 12:11 JonnyOThan