Skip to content

Commit 8adcfa2

Browse files
committed
Mishaps and enhancements on reading the WatchDog's ConfigNode.
1 parent aed39da commit 8adcfa2

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

Source/ModuleManagerWatchDog/Util/SanityLib.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static class SanityLib
2828
private static string _EnforcedVersion;
2929
public static bool IsExempted(int kspMajor, int kspMinor)
3030
{
31-
ConfigNode cn = GameDatabase.Instance.GetConfigNode("ModuleManagerWatchDog/WatchDoc.cfg");
31+
ConfigNode cn = GameDatabase.Instance.GetConfigNode("ModuleManagerWatchDog/WatchDog");
3232
if (null != cn)
3333
{
3434
string value = cn.GetValue("EnforceRulesFromKSPVersion");
@@ -38,15 +38,21 @@ public static bool IsExempted(int kspMajor, int kspMinor)
3838
try
3939
{
4040
string[] v = _EnforcedVersion.Split('.');
41-
return
41+
bool r =
4242
kspMajor <= Int16.Parse(v[0])
4343
&&
4444
kspMinor < Int16.Parse(v[1])
4545
;
46+
Log.dbg("Current version {0}.{1} is{2}exempted, as the the rules are enforced from KSP {3}."
47+
, kspMajor, kspMinor
48+
, r ? " " : " not "
49+
, _EnforcedVersion
50+
);
51+
return r;
4652
}
4753
catch (Exception e)
4854
{
49-
Log.error("CheckIsEnvorceable : {0}", e.ToString());
55+
Log.error("CheckIsEnvorceable : {0}. Rules are being enforced.", e.ToString());
5056
return true;
5157
}
5258
}
@@ -69,15 +75,11 @@ public static bool CheckIsOnGameData(string path, string filename = null)
6975

7076
public static string[] GetFromConfig(string nodeName, string valueName)
7177
{
72-
ConfigNode cn = GameDatabase.Instance.GetConfigNode("ModuleManagerWatchDog/WatchDoc.cfg");
78+
ConfigNode cn = GameDatabase.Instance.GetConfigNode("ModuleManagerWatchDog/WatchDog");
7379
if (null == cn) return new string[]{};
74-
75-
cn = cn.GetNode("WatchDog");
76-
if (null == cn) return new string[]{};
77-
80+
if ("WatchDog" != cn.name) return new string[]{};
7881
cn = cn.GetNode(nodeName);
7982
if (null == cn) return new string[]{};
80-
8183
return cn.GetValues(valueName);
8284
}
8385
}

0 commit comments

Comments
 (0)