Resolved General Problem related mpclassdivisions.xml - ConditionalEffects causes crash / xml merge error

Users who are viewing this thread

Version number
1.9.0
Branch
Beta
Modded/unmodded
Modded

Errayn

Sergeant Knight at Arms
So, I was having difficulties with modding mpclassdivisions.xml since 1.8.0 and now I found the reason of the crash.

<ConditionalEffect> has an XML merge issue and if you have mpclassdivisions.xml with perks that haves <ConditionalEffect> </ConditionalEffect> in a different module for your mod, the game gives you this warning on loading, and the game crashes.

unknown.png


if you delete every <ConditionalEffect> </ConditionalEffect> in perks located in mpclassdivisions.xml. Game merges xmls correctly and you can enjoy the game without passive perks. Tough that creates balance issues and needs to be fixed. I don't want to change mpclassdivisions.xml in Native to mod multiplayer.

---
How to reproduce:
-Copy original mpclassdivisions.xml from Native ModuleData
-Paste mpclassdivisions.xml to Different multiplayer module
-add this simple xlst file to your module called mpclassdivisions.xslt
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="MPClassDivision"/>
   
</xsl:stylesheet>
-add a reference for the mpclassdivisions.xml to the mods submodule
-Run your game. And you will see the error.

how to run your mod with modified mpclassdivisions.xml :
- delete every <ConditionalEffect> </ConditionalEffect> inside mpclassdivisions.xml
run your game and you are inside the game without issues with your modified mpclassdivisions.xml
 
Last edited:
Could you please send the latest logs that show up here once you close the game after the error please:
  • C:\ProgramData\Mount and Blade II Bannerlord\logs
 
Could you please send the latest logs that show up here once you close the game after the error please:
  • C:\ProgramData\Mount and Blade II Bannerlord\logs
I am also sending the test modules I am using. there is 2 modules on this file, TestmoduleCrash and TestmoduleWorking.

Testmodulecrash has <ConditionalEffect> </ConditionalEffect> in perks located in mpclassdivisions.xml
Testmoduleworking doesnt have <ConditionalEffect> </ConditionalEffect> in perks located in mpclassdivisions.xml and it is working.

Testmodulesformpclassdivisions.zip

Bannerlord 1.8.1
crash report:
2022-10-24_16.15.52_982f9daef7eab5c8767c30f74a89ca6e

Code:
[18:15:49.479] opening ..\..\Modules\Native/ModuleData/mpclassdivisions.xml

[18:15:49.479] opening ../../XmlSchemas/MPClassDivisions.xsd

[18:15:49.495] opening ..\..\Modules\TestmoduleCrash/ModuleData/mpclassdivisions.xml

[18:15:49.496] opening ../../XmlSchemas/MPClassDivisions.xsd

[18:15:49.535]
<##########################################################################################>

[18:15:49.535]
ERROR: Could not load merged xml file correctly: MPClassDivisionsError: Value cannot be null.

Parameter name: key
[18:15:49.535] #TaleWorlds.Native.pdb@{5A06E247E6964956920A1EDDE77DF9EC} (1): 0:6448973
#TaleWorlds.Native.pdb@{5A06E247E6964956920A1EDDE77DF9EC} (1): 0:1011328
#TaleWorlds.Native.pdb@{5A06E247E6964956920A1EDDE77DF9EC} (1): 0:450416
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
#clr.pdb@{4062B44F2B924DFD8694C322DE0A3612} (2): 0:302850
#clr.pdb@{4062B44F2B924DFD8694C322DE0A3612} (2): 0:302552
#clr.pdb@{4062B44F2B924DFD8694C322DE0A3612} (2): 0:302302
#ntdll.pdb@{CCC0E36120F424BE044DE630C3BD80C4} (1): 0:664735
#ntdll.pdb@{CCC0E36120F424BE044DE630C3BD80C4} (1): 0:198969
#clr.pdb@{4062B44F2B924DFD8694C322DE0A3612} (2): 0:307320
#clr.pdb@{4062B44F2B924DFD8694C322DE0A3612} (2): 0:307254
#ntdll.pdb@{CCC0E36120F424BE044DE630C3BD80C4} (1): 0:664607
#ntdll.pdb@{CCC0E36120F424BE044DE630C3BD80C4} (1): 0:332964
#ntdll.pdb@{CCC0E36120F424BE044DE630C3BD80C4} (1): 0:332277
#kernelbase.pdb@{DE5A7522B6B3E2FB826514EA1DF2BE1B} (1): 0:183593
#clr.pdb@{4062B44F2B924DFD8694C322DE0A3612} (2): 0:304493
#clr.pdb@{4062B44F2B924DFD8694C322DE0A3612} (2): 0:310260
#mscorlib.pdb@{6C335E37967F4A2C86F3568B9973CB7E} (2): 0:14349476
#mscorlib.pdb@{6C335E37967F4A2C86F3568B9973CB7E} (2): 0:20093931
#mscorlib.pdb@{6C335E37967F4A2C86F3568B9973CB7E} (2): 0:5890593
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
@unknown_module@unknown_source (unknown_line): unknown_function
#clr.pdb@{4062B44F2B924DFD8694C322DE0A3612} (2): 0:8734
#TaleWorlds.Native.pdb@{5A06E247E6964956920A1EDDE77DF9EC} (1): 0:327916
#TaleWorlds.Native.pdb@{5A06E247E6964956920A1EDDE77DF9EC} (1): 0:325191
#TaleWorlds.Native.pdb@{5A06E247E6964956920A1EDDE77DF9EC} (1): 0:275813
#TaleWorlds.Native.pdb@{5A06E247E6964956920A1EDDE77DF9EC} (1): 0:2129943
#TaleWorlds.Native.pdb@{5A06E247E6964956920A1EDDE77DF9EC} (1): 0:2129227
#TaleWorlds.Native.pdb@{5A06E247E6964956920A1EDDE77DF9EC} (1): 0:2133031
#ucrtbase.pdb@{152B3C4F5E1CE0FE6BC36E9F0F2B10E6} (1): 0:138162
#kernel32.pdb@{9CF2BCBC4D0E03503C68E569FAA6DC93} (1): 0:94260
#ntdll.pdb@{CCC0E36120F424BE044DE630C3BD80C4} (1): 0:337569
-----------------------------------------------
#TaleWorlds.DotNet.AutoGenerated.pdb@{6B7AF7494CE342D6A954BFB64A260B54} (1): 100663315:0
#TaleWorlds.Engine.pdb@{729AB3709879485AB2E512F17494C051} (1): 100665213:0
#TaleWorlds.Library.pdb@{8C7DC091CC5646CEB81510B17011DBE9} (1): 100663547:18
#TaleWorlds.ObjectSystem.pdb@{5A73B1C8328841FA9A1BC61A50689E28} (1): 100663380:15
#TaleWorlds.Core.pdb@{80DE1E1E81234D619F255FF9667ABCCC} (1): 100665298:56
#TaleWorlds.MountAndBlade.pdb@{A941517623B44D699383BA8C1EDCE11D} (1): 100673153:184
#TaleWorlds.MountAndBlade.pdb@{A941517623B44D699383BA8C1EDCE11D} (1): 100673158:37
#TaleWorlds.Core.pdb@{80DE1E1E81234D619F255FF9667ABCCC} (1): 100663967:44
#TaleWorlds.MountAndBlade.pdb@{A941517623B44D699383BA8C1EDCE11D} (1): 100673165:88
#TaleWorlds.Core.pdb@{80DE1E1E81234D619F255FF9667ABCCC} (1): 100664952:101
#TaleWorlds.MountAndBlade.pdb@{A941517623B44D699383BA8C1EDCE11D} (1): 100670710:15
#TaleWorlds.Core.pdb@{80DE1E1E81234D619F255FF9667ABCCC} (1): 100665052:47
#TaleWorlds.MountAndBlade.pdb@{A941517623B44D699383BA8C1EDCE11D} (1): 100673057:420
#TaleWorlds.DotNet.pdb@{E28C814FBB8543E68C725354FF416542} (1): 100663421:56

[18:15:52.902]
[18:15:52.902] Working Memory: 2229 MB
[18:15:52.902] Commit Memory: 4188 MB

[18:15:52.902] Page Allocator Memory:
[18:15:52.902] DumpTimeStamp: /2022-10-24_16.15.52
[18:15:52.902] AutoReport: Disabled
 
I was about to post the same bug and found this thread. I have gathered lots of data that the team can find useful. I will post them here.
There seems to be 2 different bugs that together cause this crash.
First bug happens at TaleWorlds.MountAndBlade.MPPerkCondition.CreateFrom and TaleWorlds.MountAndBlade.MPPerkEffect.CreateFrom methods.
mtqmwor.png

Your source code will be different but at line 24 "MPPerkCondition.Registered[key]" the key that is beign passed is null so it crashes.
Why the key becomes null ? Because when two MPClassDivisions xml files are merged at TaleWorlds.ObjectSystem.MBObjectManager.LoadXML (image below) at line 6,
M2vq7dV.png

the mergedXmlForManaged document contains text nodes like "\n " inside "Conditions" and "Effects" nodes. For some reason these text nodes stay inside the document and not filtered properly at TaleWorlds.MountAndBlade.MPConditionalEffect constructer method (image for the method and the unintentional text node below).
mPamw55.png

I think adding "xmlNode.NodeType != XmlNodeType.Text" at the lines 18 and 31 would be a quick fix but this issue seems to be a complicated one at least for me :smile:
Some notes:
- This issue only happens when two MPClassDivisions xml files are merged. Since native has one we cannot really add our own.
- The crash happens at the Native's MPClassDivision "mp_shock_infantry_vlandia". will probably crash at all of "ConditionalEffect"s.
 
Last edited:
Hello guys, this issue should be resolved with Beta v1.0.2. Not sure you'll be able to verify until the Beta reaches Live but letting you know anyways!
 
Back
Top Bottom