Skip to content

Commit

Permalink
Fix the NRE / Effect not working on config that uses the same name mu…
Browse files Browse the repository at this point in the history
…ltiple time
  • Loading branch information
sarbian committed Feb 10, 2020
1 parent 593bcbb commit 85053dd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ModelMultiShurikenPersistFX.cs
Expand Up @@ -765,8 +765,15 @@ private ConfigNode GetEffectConfig()
{
ConfigNode partConfig = PartLoader.getPartInfoByName(hostPart.protoPartSnapshot.partName).partConfig;
ConfigNode effectsNode = partConfig?.GetNode("EFFECTS");
ConfigNode eNode = effectsNode?.GetNode(effectName);
return eNode?.nodes.GetNode("MODEL_MULTI_SHURIKEN_PERSIST", "name", instanceName);
if (effectsNode == null) return null;
ConfigNode[] eNodes = effectsNode.GetNodes(effectName);
foreach (ConfigNode node in eNodes)
{
ConfigNode mmspNode = null; // Why does TryGetNode uses ref instead of out ????
if (node.TryGetNode("MODEL_MULTI_SHURIKEN_PERSIST", ref mmspNode) && mmspNode.GetValue("name") == instanceName)
return mmspNode;
}
return null;
}

public override void OnLoad(ConfigNode node)
Expand All @@ -781,7 +788,7 @@ public override void OnLoad(ConfigNode node)

if (node == null)
{
print("Unable to find the effect config for" +
Print("Unable to find the effect config for" +
" part " + hostPart.protoPartSnapshot.partName +
" effectName " + effectName +
" instanceName " + instanceName);
Expand Down

0 comments on commit 85053dd

Please sign in to comment.