xienwolf
Deity
I've been working on Modular Mods for a while now, and I recently moved into modding the SDK. While I was there I ran into a nifty pattern which I recognized from the fields that fail to load in Modular XML mods.
It is explained in more depth in the spoiler, but the general gist of it is that the XML is loaded up into the DLL file and utilized from there. Once the XML has laoded upon starting the game, it is never actually touched again.
This loading is done in phases (reasons detailed more in Spoiler), and it is in moving from the first phase into the later ones that Modular Loading fails. The manifestation of this failure is that certain fields will appear on the main mod components instead of appearing on your new modular components (things like Upgrading Improvements, and Promotion Pre-Requisites).
It is part of the SDK that is responsible for loading the XML. Since the XML is loaded in a certain order, and some parts make references to pieces which are not yet loaded, those parts cannot be loaded yet, and are saved for the second pass through the XML (pass 2).
An example of this would be if a Promotion had a Pre-Req Promotion which came after it in the alphabet (since they are mostly listed in the XML alphabetically). When the game tries to load that pre-req, it would want to convert the string PROMOTION_BLAHBLAH into a number, based on the enumeration of PROMOTION_BLAHBLAH. But since that promotion is not yet loaded, it would give you an error.
Thus the Pre-reqs must wait until after each promotion was loaded (without the Pre-req information) before going back through and attaching that extra information to each field.
Anything which is loaded in the first pass works for Modules properly. But everything loaded in the second pass fails because it then tries to assign it by the Enumeration rather than by the Type name, and the enumeration starts over again at 0 when it loads the module in passes 2 & 3.
So I guess what I am mainly asking is: Does anybody know enough about the DLL to modify the linking of Passes 2 & 3 properly to Pass 1 with Modules involved? Or at least enough to provide a hint as to how I could start working on a way to fix it.
It is explained in more depth in the spoiler, but the general gist of it is that the XML is loaded up into the DLL file and utilized from there. Once the XML has laoded upon starting the game, it is never actually touched again.
This loading is done in phases (reasons detailed more in Spoiler), and it is in moving from the first phase into the later ones that Modular Loading fails. The manifestation of this failure is that certain fields will appear on the main mod components instead of appearing on your new modular components (things like Upgrading Improvements, and Promotion Pre-Requisites).
Spoiler Detailed Account :
It is part of the SDK that is responsible for loading the XML. Since the XML is loaded in a certain order, and some parts make references to pieces which are not yet loaded, those parts cannot be loaded yet, and are saved for the second pass through the XML (pass 2).
An example of this would be if a Promotion had a Pre-Req Promotion which came after it in the alphabet (since they are mostly listed in the XML alphabetically). When the game tries to load that pre-req, it would want to convert the string PROMOTION_BLAHBLAH into a number, based on the enumeration of PROMOTION_BLAHBLAH. But since that promotion is not yet loaded, it would give you an error.
Thus the Pre-reqs must wait until after each promotion was loaded (without the Pre-req information) before going back through and attaching that extra information to each field.
Anything which is loaded in the first pass works for Modules properly. But everything loaded in the second pass fails because it then tries to assign it by the Enumeration rather than by the Type name, and the enumeration starts over again at 0 when it loads the module in passes 2 & 3.
So I guess what I am mainly asking is: Does anybody know enough about the DLL to modify the linking of Passes 2 & 3 properly to Pass 1 with Modules involved? Or at least enough to provide a hint as to how I could start working on a way to fix it.