Skip to content

Commit

Permalink
Fix #13 (stock CommNet logic runs in DarkMultiPlayer session)
Browse files Browse the repository at this point in the history
  • Loading branch information
KSP-TaxiService committed Oct 8, 2019
1 parent 70a2110 commit ab49e03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/CommNetConstellation/CommNetLayer/CNCCommNetHome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void OnGUI()
if ((!HighLogic.CurrentGame.Parameters.CustomParams<CommNetParams>().enableGroundStations && !this.isKSC) || !MapView.MapIsEnabled || MapView.MapCamera == null)
return;

if (CNCCommNetScenario.Instance.hideGroundStations)
if (CNCCommNetScenario.Instance == null || CNCCommNetScenario.Instance.hideGroundStations)
return;

Vector3d worldPos = ScaledSpace.LocalToScaledSpace(nodeTransform.transform.position);
Expand Down
8 changes: 8 additions & 0 deletions src/CommNetConstellation/CommNetLayer/CNCCommNetScenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ protected override void Start()

CNCLog.Verbose("CommNet Scenario loading ...");

//Issue #13: Commnet behaves like vanilla when joining a DMP server for the second time.
//if stock CommNet logic somehow runs (such as the order of CNCCommNetScenario and CommNetScenario in persisten.sfs)
if (CommNetScenario.Instance != null)
{
UnityEngine.Object.DestroyImmediate(CommNetScenario.Instance);
CNCCommNetScenario.Instance = this;
}

//Replace the CommNet user interface
CommNetUI ui = FindObjectOfType<CommNetUI>(); // the order of the three lines is important
CustomCommNetUI = gameObject.AddComponent<CNCCommNetUI>(); // gameObject.AddComponent<>() is "new" keyword for Monohebaviour class
Expand Down

0 comments on commit ab49e03

Please sign in to comment.