My database is the same as everyone else's but modified to use H3API terminology. Here are a few screens to show the process of adding enumerations (same way for structures) - you can copy them from H3API, ERM, or wherever you please.
Cleaning up IDA code
Hope
igrik doesn't mind))
We start with
igrik's database. I found the function using the FUNCTIONS WINDOW and Ctrl+F using the term 'shoot'. I've numbered some things that can be modified to enhance comprehension of the current section.
Adding an enumeration/structure to IDA. The easiest is
SHIFT+F1 but it may take some time to get used to hotkeys.
Now
Insert a new local type or use right-click menu.
You get a window like this where you can either create or
just copy-paste.
When you are done, the enum/struct exists in local types and is not available globally, so:
* scroll to the bottom
* select your new type
* press enter (or double-click it)
This makes it accessible globally and you will see it in the ENUMS tab.
Go back to PSEUDOCODE section, and set the enu
M.
Now you'll get text instead of `15`, while not perfect it shows what the code actually intends to do.
Now let's
copy some more enums and repeat the process.
Don't forget to add the type globally!
After you add some more enums, you may get more than one option when choosing what to assign, just pick the one that makes sense.
Now all enums are set for this portion of code, things are looking better; however due to how nwc wrote the BattleMgr original class, there is still some incomprehensible junk next to HeroA... it takes some time to recognize such patterns but this is because the original is an array of 2 _Hero_* instead of being split into attacking and defending hero.
Double-click the HeroA term to be taken to it in the STRUCTURES tab.
We edit this term's t
Ype or with right-click...
Finally 'HeroA' no longer makes sense, re
Name it to 'Heroes'.
Go back to PSEUDOCODE and refresh the decompilation (
F5). Now +221 is transformed to secondary skills offset which is again easier to understand.
One last step, add the secondary skills enum, and assign it to the value within.
End result... there is still some work to rename
v.. terms but usually this is only necessary when you face complicated pieces of code or are working on disassembling something new.
Actual time was about 3 minutes because I had to look up the enumerations. Now that they exist in this database, I can go elsewhere and do this process in 15 seconds and have code that is readable without relying on outside sources.
I don't ERM (and don't plan to) so I can never even fill half of igrik's shoes, but I hope this is useful. As with everything else, you get better by practice: the more you do the better you'll get at recognizing patterns and assigning the correct values/structures.