Skip to content

Commit e9f6809

Browse files
committed
Eliminate log spam
1 parent a84e751 commit e9f6809

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

GameData/PlanningNode/PlanningNode-Changelog.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ KERBALCHANGELOG
1515
change = Pick right node for auto adjust button (xzy)
1616
type = Fix
1717
}
18+
CHANGE
19+
{
20+
change = Eliminate log spam
21+
type = Fix
22+
}
1823
}
1924
VERSION
2025
{

GameData/PlanningNode/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Other notes:
6464
- You can click the text labels for a planning node to edit it.
6565
- You can use the "New" button in the dialog to create multiple nodes for the same vessel, and the `<` and `>` buttons next to the name field to switch to other nodes.
6666
- Editing in the tracking station would be desirable but is not possible because the stock maneuver editor crashes outside of the flight scene's map view.
67-
- Similarly, you may experience extreme log spam in some instances while editing nodes due to the stock maneuver editor being extremely sensitive about being used in unexpected ways (and the difficulty of figuring out what it takes to pacify it).
6867
- Blizzy's toolbar is not and will not be supported. 0.23.5 was a **long** time ago.
6968

7069
## How to donate

Source/PlanningNodeEditor.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public PlanningNodeEditor() : base() { }
3939

4040
private IEnumerator Start()
4141
{
42+
// Fingers crossed that nobody else does this, or if they do,
43+
// that we restore our old references in the right order
44+
originalCheckEncounter = PatchedConics.CheckEncounter;
45+
PatchedConics.CheckEncounter = MyCheckEncounter;
46+
4247
// This represents our starting orbit
4348
driver = gameObject.AddComponent<OrbitDriver>();
4449
driver.lowerCamVsSmaRatio = 0.0001f;
@@ -158,6 +163,10 @@ private void OnManeuverNodeSelected()
158163

159164
private void OnDisable()
160165
{
166+
// Put the encounter checker back to normal when we're done
167+
PatchedConics.CheckEncounter = originalCheckEncounter;
168+
originalCheckEncounter = null;
169+
161170
GameEvents.onManeuverNodeSelected.Remove(OnManeuverNodeSelected);
162171
origCamTarget = null;
163172
DestroyNode();
@@ -261,6 +270,30 @@ private float SaneMax(float a, float b)
261270
return float.IsNaN(a) ? b : float.IsNaN(b) ? a : Mathf.Max(a, b);
262271
}
263272

273+
/// <summary>
274+
/// Old school style override of PatchedConics.CheckEncounter, set up in Start and reset at destroy.
275+
/// We prevent any encounter with our starting body, and otherwise hand off to the default implementation.
276+
/// </summary>
277+
/// <param name="p">The patch currently being analyzed</param>
278+
/// <param name="nextPatch">The next patch to be analyzed</param>
279+
/// <param name="startEpoch">The time when the vessel reaches p</param>
280+
/// <param name="sec">The driver of the orbit to check for an encounter; this is the only parameter that we actually use here rather than passing along to the default implementation</param>
281+
/// <param name="targetBody">The user's currently selected target</param>
282+
/// <param name="pars">Stuff that controls how the solver works</param>
283+
/// <param name="logErrors">true to print things to the log, false otherwise</param>
284+
/// <returns>
285+
/// true if encounter found, false otherwise (or if one would have been found for our starting body)
286+
/// </returns>
287+
private bool MyCheckEncounter(
288+
Orbit p, Orbit nextPatch, double startEpoch, OrbitDriver sec,
289+
CelestialBody targetBody, PatchedConics.SolverParameters pars, bool logErrors = true)
290+
{
291+
// Suppress encounters with our starting body, because it makes the solver put NaN orbits in the flight plan
292+
return sec?.celestialBody == editingNode?.origin
293+
? false
294+
: originalCheckEncounter(p, nextPatch, startEpoch, sec, targetBody, pars, logErrors);
295+
}
296+
264297
private void Update()
265298
{
266299
if (node != null && solver != null && !solver.maneuverNodes.Contains(node)) {
@@ -295,6 +328,8 @@ private void OnGizmoUpdated(Vector3d dV, double ut)
295328
}
296329
}
297330

331+
private PatchedConics.CheckEncounterDelegate originalCheckEncounter;
332+
298333
private MapObject origCamTarget;
299334
private float origCamDist;
300335

0 commit comments

Comments
 (0)