Skip to content

Commit

Permalink
no more failing when a load error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
GER-Space committed Dec 18, 2018
1 parent 3effda9 commit 676b79b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Core/LaunchSites/LaunchSiteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ public static void AddKSC2()
ksc2.OpenCost = 1f;
ksc2.SetClosed();
ksc2.LaunchSiteIsHidden = true;
ksc2.isSquad = true;

ksc2Instance.launchSite = ksc2;
RegisterLaunchSite(ksc2);
Expand Down
5 changes: 5 additions & 0 deletions src/Core/StaticObjects/StaticDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ internal static StaticModel GetModelByName(string name)
}
}

internal static bool HasInstance(StaticInstance instance)
{
return instancedByUUID.ContainsKey(instance.UUID);
}


internal static List<StaticInstance> GetInstancesFromModel(StaticModel model)
{
Expand Down
19 changes: 13 additions & 6 deletions src/Core/StaticObjects/StaticInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,25 @@ internal void Deactivate()

internal void Destroy()
{
if (groupCenter != null)
{
groupCenter.RemoveInstance(this);
}
if (StaticDatabase.HasInstance(this))
{

groupCenter.RemoveInstance(this);
StaticDatabase.DeleteStaticFromDB(this);

StaticDatabase.DeleteStaticFromDB(this);
}
if (_mesh != null)
{
GameObject.DestroyImmediate(_mesh);
}
wreck.transform.parent = null;
GameObject.DestroyImmediate(wreck);
if (wreck != null)
{
wreck.transform.parent = null;
GameObject.DestroyImmediate(wreck);
}
GameObject.DestroyImmediate(gameObject);
}

}
}
6 changes: 6 additions & 0 deletions src/KerbalKonstructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,12 @@ internal void LoadInstances(UrlDir.UrlConfig configurl, StaticModel model)

instance.Orientate();

if (!StaticDatabase.HasInstance(instance))
{
instance.Destroy();
continue;
}

AttachFacilities(instance, instanceCfgNode);

LaunchSiteManager.AttachLaunchSite(instance, instanceCfgNode);
Expand Down

0 comments on commit 676b79b

Please sign in to comment.