alexbatalov / fallout2-re

Reverse engineered Fallout 2
Other
327 stars 34 forks source link

Name some unnamed vars in combat.c #121

Closed mikolaj-pirog closed 2 years ago

mikolaj-pirog commented 2 years ago

Name some unnamed vars in combat.c, mostly in the _combat_safety_invalidate_weapon_func. Some vars were also named in other functions in more or less random fashion - I was renaming things while trying to understand what vars in _combat_safety_invalidate_weapon_func do. Added some FIXME around redundant code - I hope this is the right use case.

alexbatalov commented 2 years ago

Hey, thanks for your submission and welcome to the game. Some of your deductions are slightly incorrect.

First, the note on using _compute_spray. This function populates extra targets on Attack struct. The whole purpose of _combat_safety_invalidate_weapon_func is to check if extra targets contains attackerFriend, so it's definitely not useless.

The note on objectGetDistanceBetween is right, but it's not to be fixed, since it's the way the code was written (keep in mind the goal). I have slightly refactored it to remove extra variables which confused you.

collateralDamageToAttacker is simply wrong. Put it in plain English this function is used to answer these questions:

mikolaj-pirog commented 2 years ago

Thanks for a review with explanations & fixes