Posted: Fri May 26, 2023 7:49 am Post subject:
AICLEAN - a script to clean and organize rules/art/ai.ini
Subject description: (also supports merging Ares/Phobos 'include' files into the main ini)
This script started out as a way to remove junk and duplicated or orphan code within the ai.ini, but has since been expanded to cover rules.ini and art.ini for cleaning, and has recently learned a few new tricks. The original goal was to simplify the inis, strip comments and anything else not suitable for a public release in a mod, thus prevent publishing internal notes or unused code, but some authors like the ability to organize the ini on a routine basis instead. This script should not really be considered an error-checking script and more of a housekeeping script, one concerned with layout and structure instead of correctness. As such, AICHECK should still be used to find errors in the cleaned inis, but the aiclean.log may contain vital information that should be corrected or used to correct related problems.
The recent updates have added more Ares/Phobos awareness in a few key ways, namely the include function, which has prevented my other cross-checking scripts from reading/parsing the mod. By using AICLEAN to merge the inis, it no longer matters that the other scripts don't support reading such includes, however as all the examples used to test this functionality, the very paradigm of dividing the ini code across multiple files does in fact lead to a lot of unnecessary mistakes. Merging all the files, eliminating duplicates and making sure the include code overrides the core code, can undo a runaway file organizing system. This Ares-awareness also extends to [WeaponTypes] support, to which can be added declarations with proper indexing with the right options set, and the Ares method of specifying alternate theater art, which is used to group related art in the art.ini restructuring.
The script will restructure the rules.ini according to the aiclean.cfg settings, which encompasses the basic section ordering, and has additional settings to sort the tags within unit classes and buildings, so as to make them visually consistent, which is easier to edit or catch mistakes. As of the latest updates overhauling the code, it will automatically organize all the declaration lists first, and all the object code later, with a few specific sections placed at the end. Within this organization, the objects are also sorted alphabetically, and objects not subject to the tag ordering sequence defined in the cfg, are also sorted alphabetically. In the process, anything duplicated is culled from the list and mentioned in the log. With the reindex option enabled, AICLEAN will also reset all the indexes on all the declaration lists to start at 0 and remove any numbering gaps, except for [OverlayTypes] where they must remain as they are.
A final function of AICLEAN is it will automatically add declarations for referenced objects (ie. used) if the code for them exists. So if there's a building in a Prerequisites= tag on a unit, and the building code has been added, but the [BuildingTypes] declaration is missing, it will add it to the end of the list, with the appropriate index number -- unless the reindex option is turned off, then it will start at 10000. Entirely orphaned code, with no references won't be deleted in rules/art.ini but will not be declared either, the script doesn't try to determine what class is the orphaned object, so without the declarations/references for guidance it won't know where it belongs.
As with all such scripts, the aiclean.tcl will have to be edited to set basic settings like filenames and the game path.
There was an oversight that caused [$Include] sections to be discarded even if mergemode was off, it now saves it. Although it doesn't place it automatically at the beginning, maybe that will come in the next update.
First change is that the script will no longer exit before writing the log, so if art.ini or ai.ini aren't found/cleaned, the clean.log will still include all the messages up to that point.
The second change is to add a total processing time like AICHECK has at the end of the log.
This release adds requested change I've been meaning to do, forcing include sections to write before other sections, if mergemode is off.
Since a big part of this script has become the ability to merge include sections, so that AICHECK can process the mod inis, this is likely not going to be overly important. That said, it is entirely logical to write them this way.
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum