diff --git a/Library/Utils/ModXmlPatcher.cs b/Library/Utils/ModXmlPatcher.cs index 13d82de..a4730dd 100644 --- a/Library/Utils/ModXmlPatcher.cs +++ b/Library/Utils/ModXmlPatcher.cs @@ -27,7 +27,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using System.Text; using System.Xml; using System.Xml.Linq; @@ -181,9 +180,6 @@ private static void ReplaceTemplateOccurences( kv.Value); } - // We need to call into the private function to proceed with XML patching - private static readonly MethodInfo MethodSinglePatch = AccessTools.Method(typeof(XmlPatcher), "singlePatch"); - // Function to load another XML file and basically call the same PatchXML function again private static bool IncludeAnotherDocument(XmlFile target, XmlFile parent, XElement element, Mod mod) { @@ -223,7 +219,7 @@ private static bool IncludeAnotherDocument(XmlFile target, XmlFile parent, XElem continue; } result &= XmlPatcher.PatchXml( - target, element, _patchXml, mod); + target, _patchXml.XmlDoc.Root, _patchXml, mod); } catch (Exception ex) { @@ -272,7 +268,7 @@ public static bool PatchXml(XmlFile xmlFile, } } // Otherwise try to apply the patches found in child element - else if (!ApplyPatchEntry(xmlFile, child, patchXml, mod, ref stack)) + else if (!ApplyPatchEntry(xmlFile, patchXml, child, mod, ref stack)) { IXmlLineInfo lineInfo = child; Log.Warning(string.Format("XML patch for \"{0}\" from mod \"{1}\" did not apply: {2} (line {3} at pos {4})", @@ -293,8 +289,8 @@ public struct ParserStack // Entry point instead of (private) `XmlPatcher.singlePatch` // Implements conditional patching and also allows includes - private static bool ApplyPatchEntry(XmlFile _targetFile, XElement _patchElement, - XmlFile _patchFile, Mod _patchingMod, ref ParserStack stack) + private static bool ApplyPatchEntry(XmlFile _targetFile, XmlFile _patchFile, + XElement _patchElement, Mod _patchingMod, ref ParserStack stack) { // Only support root level @@ -381,8 +377,8 @@ private static bool ApplyPatchEntry(XmlFile _targetFile, XElement _patchElement, stack.IfClauseParsed = false; stack.PreviousResult = true; // Dispatch to original function - return (bool)MethodSinglePatch.Invoke(null, - new object[] { _targetFile, _patchElement, _patchFile, _patchingMod }); + return XmlPatcher.singlePatch(_targetFile, + _patchElement, _patchFile, _patchingMod); } } @@ -416,9 +412,8 @@ static bool Prefix( if (int.Parse(version) > 5) return true; } // Call out to static helper function - __result = PatchXml( - _xmlFile, _patchFile, - element, _patchingMod); + __result = PatchXml(_xmlFile, _patchFile, + _containerElement, _patchingMod); // First one wins _patchFile = null; return false; diff --git a/MicroSplat.dll b/MicroSplat.dll index dfc157f..a0ee49f 100644 Binary files a/MicroSplat.dll and b/MicroSplat.dll differ diff --git a/ModInfo.xml b/ModInfo.xml index f0ffce2..979682f 100644 --- a/ModInfo.xml +++ b/ModInfo.xml @@ -5,5 +5,5 @@ - + \ No newline at end of file diff --git a/README.md b/README.md index 0c04809..c3ccb8e 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,10 @@ Download from https://github.com/OCB7D2D/OcbMicroSplatHelper/releases ## Changelog +### Version 0.9.2 + +- Fix XML-Patcher for V1 compatibility + ### Version 0.9.1 - Fix potential NRE when unloading textures