Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup the isUnitSelf() method #108

Merged
merged 1 commit into from
Sep 16, 2022

Conversation

tdaugaard
Copy link
Contributor

@tdaugaard tdaugaard commented Sep 16, 2022

  • Add enum UnitFlag to types for easier identification of the various flags that a unit can have.

  • Add isUnitPlayer() to easier identify a player controlled unit.

  • Refactor isUnitSelf() to make use of isUnitPlayer() and UnitFlags.

To prove that nothing has change logically, the old isUnitSelf() method checked the flags against the hexadecimal value 0x511 which consists of the flags:

UnitFlags.AFFILIATION_MINE = 1
UnitFlags.REACTION_FRIENDLY = 16
UnitFlags.CONTROL_PLAYER = 256
UnitFlags.TYPE_PLAYER = 1024

1297 decimal, 0x511 hex.

Add `enum UnitFlag` to types for easier identification of the various
flags that a unit can have.

Add `isUnitPlayer()` to easier identify a player controlled unit.

Refactor `isUnitSelf()` to make use of `isUnitPlayer()` and `UnitFlags`.
Copy link
Owner

@aza547 aza547 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aza547 aza547 merged commit e2bf656 into aza547:main Sep 16, 2022
@tdaugaard tdaugaard deleted the cleanup/unit_flag_methods branch September 16, 2022 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants