Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ModuleManager/ModListGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,17 @@ public static IEnumerable<string> GenerateModList(IEnumerable<ModAddedByAssembly
mods.Add(dependency);
modListInfo.AppendFormat(" {0}\n", dependency);
}

if (name.Contains(":NEEDS["))
{
string needs = (name.Substring(name.IndexOf(":NEEDS[") + 7));
needs = needs.Substring(0, needs.IndexOf(']'));
needs = needs.Replace("!", "").Replace('&', ',').Replace('|', ',');
foreach (string s in needs.Split(',')) if (dependency.Equals(s))
progress.ForWithInvalidNeedsWarning(dependency, cfgmod);
}
}

catch (ArgumentOutOfRangeException)
{
progress.Error(cfgmod, "Skipping :FOR init for line " + name +
Expand Down
1 change: 1 addition & 0 deletions ModuleManager/Progress/IPatchProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface IPatchProgress
EventData<IPass> OnPassStarted { get; }

void Warning(UrlDir.UrlConfig url, string message);
void ForWithInvalidNeedsWarning(string modName, UrlDir.UrlConfig cfgmod);
void Error(UrlDir.UrlConfig url, string message);
void Error(string message);
void Exception(string message, Exception exception);
Expand Down
7 changes: 7 additions & 0 deletions ModuleManager/Progress/PatchProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ public void Warning(UrlDir.UrlConfig url, string message)
RecordWarningFile(url);
}

public void ForWithInvalidNeedsWarning(string tag, UrlDir.UrlConfig url)
{
Counter.warnings.Increment();
logger.Warning($"Name {tag} shouldn't be used both on :FOR and :NEEDS, as :FOR takes precedence rendering :NEEDS innocuous. Check file {url.parent.url} node: {url.type}");
RecordWarningFile(url);
}

public void Error(UrlDir.UrlConfig url, string message)
{
Counter.errors.Increment();
Expand Down
15 changes: 15 additions & 0 deletions Tests/ForNeedsSameName.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@PART[HeatShield0]:FOR[forneedstest]:NEEDS[forneedstest]
{
}

@PART[HeatShield0]:FOR[forneedstest]:NEEDS[forneedstest,Squad,Something,Else]
{
}

@PART[HeatShield0]:FOR[forneedstest]:NEEDS[!forneedstest&Squad|Something,!Else]
{
}

@PART[HeatShield0]:FOR[forneedstest]:NEEDS[Squad|!Something]
{
}