OpenNaja / cobra-tools

A suite of GUI tools for extracting and modifying OVL and OVS archives, as well as editing the associated in-house file formats. Also includes a model plugin for Blender. For downloads, guides, and FAQs visit:
https://opennaja.github.io/cobra-tools/
GNU General Public License v3.0
98 stars 28 forks source link

Recursive fix - further working out #321

Closed Candoran2 closed 1 year ago

Candoran2 commented 1 year ago

Same content as in #314, with the following additional changes:

  1. All access to format types in generated code is now done through name_type_map['SomeType']. name_type_map is a dictionary containing all the classes for any specific format, and is located in generated/formats/<format_name>/imports.py. This dictionary is imported in the __init__.py of that format as the first thing, in order to ensure that all classes are loaded in the correct order.
  2. The init_attributes call has been moved to that format's imports.py, so that every class is defined before that function is run. This way, there can be no import errors when running that function, since every relevant module will have already been loaded.
  3. Xmls were reordered to ensure that child classes are located after their parents, and types are already defined before their use in a field.
  4. The special treatment of basic tag initialization in structs was removed, meaning that we no longer have to load the class in order to find out what the return types are. Instead, basics are initialized like every other type: BasicClass(context, arg, template).
  5. Because of 4, stashing the __init__.py files is no longer necessary, and this has been removed.
  6. Removed unnecessary exception in get_condition_attributes_recursive that was cluttering up the log - fields failing a condition is not unexpected.
  7. Removed import_map functionality - access to types is now done through name_type_map, so this is no longer necessary.

Because #314 was already merged, but subsequently reverted, there is probably going to be some trouble merging this PR. A simple rebase removed changes from that PR, whereas they are necessary.