Skip to content

Commit

Permalink
Populate modules when storing a part to verify that forbidden modules…
Browse files Browse the repository at this point in the history
… are not included. Fix for forbidden modules not working.
  • Loading branch information
magico13 committed Mar 4, 2018
1 parent 1a19885 commit 723f8ca
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions ScrapYard/InventoryPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,21 @@ public class InventoryPart

public string Name { get { return _name; } }
public float DryCost { get { return _dryCost; } }
public bool DoNotStore { get; set; } = false;

private bool _doNotStore = false;
public bool DoNotStore
{
get
{
//populate the saved modules
if (savedModules.Any())
{
return _doNotStore;
}
return _doNotStore;
}
set { _doNotStore = value; }
}
public TrackerModuleWrapper TrackerModule { get; private set; } = new TrackerModuleWrapper(null);
public Guid? ID
{
Expand Down Expand Up @@ -500,26 +514,17 @@ private bool storeModuleNode(string partName, ConfigNode moduleNode)
//If it matches a template, save it
if (ScrapYard.Instance.Settings.ModuleTemplates.CheckForMatch(partName, moduleNode))
{
savedModules.Add(moduleNode);
_savedModules.Add(moduleNode);
saved = true;
}

//check if this is one of the forbidden modules, and if so then set DoNotStore
//If we already have DoNotStore set, there's no reason to check again
if (!DoNotStore && ScrapYard.Instance.Settings.ForbiddenTemplates.CheckForMatch(partName, moduleNode))
if (!_doNotStore && ScrapYard.Instance.Settings.ForbiddenTemplates.CheckForMatch(partName, moduleNode))
{
Logging.DebugLog("Matched forbidden template with module "+moduleNode.GetValue("name"));
DoNotStore = true;
}

//check for the part tracker and add it
//done in constructor
//if (moduleNode.GetValue("name").Equals("ModuleSYPartTracker"))
//{
// TrackerModule = new TrackerModuleWrapper(moduleNode);
// saved = true;
//}

return saved;
}
}
Expand Down

0 comments on commit 723f8ca

Please sign in to comment.