Ok, given that I'm the one making the complaints, it seems that I should also be "putting my money where my mouth is".
So I've started an attempt to begin documenting the code. I've summed it up [in this pull request](
https://github.com/MegaGlest/megaglest-source/pull/20). I hope to add more documentation over time (although it's going to be a long term thing). Due to this, I'd like to suggest that documentation changes are merged periodically. I'll make sure that the documentation branch contains no code changes, so it should be safe to merge at any time. Although, if time allows, it'd be a good idea to skim over the documentation before merging it, to catch any potential errors (I didn't write the original code, after all, so can only make educated guesses towards its intent).
I'd also like to propose that all future code is documented along the same lines of verbosity (and if you check the change request, you'll see that isn't much). It may also be a good idea to document complicated parts of the code as you make changes to them, as you'd be in a good position to understand that part of the code.
EDIT: I've further added documentation to another file. I've found, however, that I'm not sure how to handle potential easy refactorings that come up while documenting. For example,
Upgrade has a
factionIndex field that I believe is unnecessary. As far as I can tell, it's only used for checking that the
Unit we're applying
UpgradeManager::computeTotalUpgrade to is in this faction. However, I don't see an circumstances when it wouldn't be (since the
UpgradeManager already an aggregate of a
Faction and
Unit directly gets the
UpgradeManager from this
Faction. Thus, it must have the same
Faction as the
Upgrades in the
UpgradeManager).
For another example, the enum
UpgradeState has an unnecessary value for the length of the enum (I never understood why arrays and enums in C++ didn't store their length, like every other language does), but the value is unused and there's no reason to iterate over the states.
For now, I'm just adding TODO notes in the comments (I don't want to mix potentially unsafe refactoring changes with the safe documentation changes). They can probably be done after the documentation changes (this particular one is very easy -- remove the field, change the constructor to not use that field, and change the implementation of
UpgradeManager::computeTotalUpgrade to not bother checking that).