Skip to content

Get rid of ESM4::SubRecordTypes

Alexei Kotov requested to merge Capostrophic/openmw:esm4fourcc into master

All my homies hate ESM4::SubRecordTypes.
This removes the 600-something ESM4::SUB_1234 subrecord signatures in favor of direct fourCC calls. The justification is:

  • fourCC is constexpr. If we're bothered about possible compile time overhead, I think all the signatures would have needed to be evaluated for each symbol they are in whether they're used or not.
  • These signatures are included in every single file that depends on components/esm4/common.hpp. Changing the list of signatures to keep ESM4 read methods consistent required recompiling that every single file (usually due to components/esm/defs.hpp including it). As you can probably guess there's a lot of such files. This sucked out my soul back when I was adding initial Fallout 4 support. This changeset, too, requires recompiling half the engine. Hopefully for the final time when it comes to subrecords.
  • ESM3 reader is usually very consistent about using fourCC directly nowadays but ESM4 reader didn't get the memo.
  • There's potential to make and overlook typos in signature names or values (happened before).
  • Readability doesn't suffer.

Note this is specific to subrecords. Records themselves still have enumerated signatures, but they're much less of a concern and there seems to be much more involved use of these signatures all around the source as compared to rather localized subrecord handling. Edit: on a second glance, that use seems more localized to components/esm/defs.hpp with some logic that doesn't make a ton of sense. But this changeset is large enough and I was mainly concerned about subrecords.
This should make my life a bit easier if I decide to throw in SeventySix.esm support.

This was not manual of course. I used

sed -ri 's/(ESM4::SUB_)(....)/ESM::fourCC\("\2\"\)/' *
Edited by Alexei Kotov

Merge request reports