Skip to content

Commit

Permalink
Eliminate mods instance variable
Browse files Browse the repository at this point in the history
  • Loading branch information
blowfishpro committed Sep 23, 2017
1 parent 45a4c0c commit d397a80
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions ModuleManager/MMPatchLoader.cs
Expand Up @@ -23,9 +23,6 @@ namespace ModuleManager
[SuppressMessage("ReSharper", "StringIndexOfIsCultureSpecific.1")]
public class MMPatchLoader : LoadingSystem
{

private List<string> mods;

public string status = "";

public string errors = "";
Expand Down Expand Up @@ -137,7 +134,7 @@ public static void AddPostPatchCallback(ModuleManagerPostPatchCallback callback)
if (!postPatchCallbacks.Contains(callback))
postPatchCallbacks.Add(callback);
}
private void PrePatchInit()
private IEnumerable<string> GenerateModList()
{
#region List of mods

Expand All @@ -150,7 +147,7 @@ private void PrePatchInit()
//
//log(envInfo);

mods = new List<string>();
List<string> mods = new List<string>();

string modlist = "compiling list of loaded mods...\nMod DLLs found:\n";

Expand Down Expand Up @@ -228,6 +225,8 @@ private void PrePatchInit()
mods.Sort();

#endregion List of mods

return mods;
}

private IEnumerator ProcessPatch()
Expand Down Expand Up @@ -255,7 +254,7 @@ private IEnumerator ProcessPatch()
{
status = "Pre patch init";
logger.Info(status);
PrePatchInit();
IEnumerable<string> mods = GenerateModList();

yield return null;

Expand All @@ -273,7 +272,7 @@ private IEnumerator ProcessPatch()
status = "Checking NEEDS.";
logger.Info(status);
yield return null;
CheckNeeds();
CheckNeeds(mods);

#endregion Check Needs

Expand Down Expand Up @@ -781,7 +780,7 @@ private void StatusUpdate()

#region Needs checking

private void CheckNeeds()
private void CheckNeeds(IEnumerable<string> mods)
{
UrlDir.UrlConfig[] allConfigs = GameDatabase.Instance.root.AllConfigs.ToArray();

Expand All @@ -802,7 +801,7 @@ private void CheckNeeds()
mod.parent.configs.Remove(currentMod);
string type = currentMod.type;

if (!CheckNeeds(ref type))
if (!CheckNeeds(ref type, mods))
{
progress.NeedsUnsatisfiedRoot(currentMod);
continue;
Expand All @@ -815,7 +814,8 @@ private void CheckNeeds()
}

// Recursively check the contents
CheckNeeds(new NodeStack(mod.config), new PatchContext(mod, GameDatabase.Instance.root, logger, progress));
PatchContext context = new PatchContext(mod, GameDatabase.Instance.root, logger, progress);
CheckNeeds(new NodeStack(mod.config), context, mods);
}
catch (Exception ex)
{
Expand All @@ -825,7 +825,7 @@ private void CheckNeeds()
}
}

private void CheckNeeds(NodeStack stack, PatchContext context)
private void CheckNeeds(NodeStack stack, PatchContext context, IEnumerable<string> mods)
{
bool needsCopy = false;
ConfigNode original = stack.value;
Expand All @@ -836,7 +836,7 @@ private void CheckNeeds(NodeStack stack, PatchContext context)
string valname = val.name;
try
{
if (CheckNeeds(ref valname))
if (CheckNeeds(ref valname, mods))
{
copy.AddValue(valname, val.value);
}
Expand Down Expand Up @@ -871,10 +871,10 @@ private void CheckNeeds(NodeStack stack, PatchContext context)

try
{
if (CheckNeeds(ref nodeName))
if (CheckNeeds(ref nodeName, mods))
{
node.name = nodeName;
CheckNeeds(stack.Push(node), context);
CheckNeeds(stack.Push(node), context, mods);
copy.AddNode(node);
}
else
Expand Down Expand Up @@ -902,7 +902,7 @@ private void CheckNeeds(NodeStack stack, PatchContext context)
/// <summary>
/// Returns true if needs are satisfied.
/// </summary>
private bool CheckNeeds(ref string name)
private bool CheckNeeds(ref string name, IEnumerable<string> mods)
{
if (name == null)
return true;
Expand Down

0 comments on commit d397a80

Please sign in to comment.