I made a major update to InfoArray. Now instead of telling how many ints should be read and how many of those are strings, which should be converted to ints, JIT_ARRAY_TYPES should be used instead. This mean the entire setup is done by setting a number of JIT_ARRAY_TYPES in the constructor arguments.
Examples:
PHP:
m_info_AllowsProfessions (JIT_ARRAY_PROFESSION , JIT_ARRAY_ALLOW)
m_info_ImprovementUpgradeRateModifiers (JIT_ARRAY_IMPROVEMENT , JIT_ARRAY_MODIFIER)
m_info_BuildingYieldChanges (JIT_ARRAY_BUILDING_CLASS , JIT_ARRAY_YIELD , JIT_ARRAY_INT)
m_info_FreePromotionUnitProfession (JIT_ARRAY_PROFESSION , JIT_ARRAY_PROMOTION)
They fit the current XML layout, meaning the first is an array of professions and each of them have an allowed value.
BuildingYieldChanges is a list of building classes. For each building, there is an array of yields and for each yield there is an int.
The last one is a bit special. It's a list of professions and for each profession, there is a list of promotions. However there is no int or allow or anything like that. Since the rightmost type is a type from XML, the code goes into bool mode. It will then internally create a bool, which is false by default, but will be set to true for any profession/promotion combo present.
This system should be fairly easy to set up and adding more InfoArrays shouldn't be tricky. There has to be a minimum of 1 type and there is a hard limit of max 4 types. Adding more is near impossible because I wanted to use as little memory as possible. In fact the extra data only takes up an additional 4 bytes for each array. It shouldn't be a problem because 4 is much greater than it sounds like. Currently the player cache can't handle complexity higher than 3 anyway and it will likely stay that way because moving from 2D to 3D arrays in the cache adds too much overhead to make it really efficient.
To give full modder freedom, I added some "bogus" JIT arrays, such as JIT_ARRAY_INT, JIT_ARRAY_FLOAT, JIT_ARRAY_MODIFIER and a few others like that. I can't really think of any reasonable XML code, which InfoArray is unable to read when using this setup system.
Since the array is aware that the DLL expects a certain type, it only checks for strings of that type. Also because there is such a massive amount of information regarding what the DLL modder planned, the DLL will can be picky and assert on a whole lot more of different mishaps. Here is an example of a new assert message:
New assert said:
File: InfoArray.cpp
Line: 218
Expression: iValue != -1
Message: MEDIEVAL_TECH_ROADS tag AllowsYields: the string YIELD_STONE is read as UnitClass, but it isn't present in that XML file
YIELD_STONE really is present in the XML files, but it is a yield and my test run made it expect a UnitClass, hence the assert. Until now such a mistake wouldn't be detected by any mod I have looked at so far, but writing a string from the wrong file will surely mess up something ingame.
Notice that the string has 4 strings inserted (marked in red), which will are fetched from different places in the DLL in order to provide as much human readable info as possible about what went wrong. The assert message itself will be all black though.
I would like to give the precise subtag name where the string is read from, but that name is a well guarded secret by the exe. Tag names is a one way communication. The DLL can tell the exe to go to a specific tag, but if the DLL use the command to go to the next tag, it can't ask the exe for the name of that tag. I could have used that for configuring InfoArray (like tags starting with i is int, f is float). However without this info, I figured out a different way to solve that issue, but there is no way to fix the issue regarding the info being missing in the error/assert messages
I have a plan to use this new data to control the return type for the get function. If the constructor use JIT_ARRAY_YIELD, the get function will return YieldTypes instead of int. This will cause compile error or at least asserts if somebody tries to use that value as say TechTypes. In other words, it will become much harder to mix up types without being told about it right away.