-
-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve: CombatType enum handling with magic enum (#1279)
We propose the use of the Magic Enum library to simplify the handling of the CombatType_t enumeration values. This refactoring removes the need for manual conversion functions, replacing them with Magic Enum library functions, increasing the robustness and maintainability of the code. The specific changes include: • Refactoring of combatTypeToIndex function to use magic_enum::enum_index(), allowing automatic obtaining of the index for each enumeration value. • Refactoring of combatTypeToName function to use magic_enum::enum_name(), to automatically obtain the name for each enumeration value. • Addition of a new formatEnumName function to format enumeration names (replacing '_' with '' and converting to lowercase) before returning them. These changes should improve code clarity and reduce the likelihood of errors when handling CombatType_t values. This will prevent, for example, having changes (additions or removals) in the CombatType enum and forgetting to add/remove these functions, which would result in a log in the distro (false positive). Getting the information directly from the enum makes the code much easier to manage and maintain.
- Loading branch information
Showing
5 changed files
with
71 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters