Opened 3 years ago
Last modified 2 years ago
#6256 new enhancement
[PetraAI] - Use more enum-like variables instead of special values.
Reported by: | Freagarach | Owned by: | JCWasmx86 |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Work In Progress |
Component: | AI | Keywords: | simple |
Cc: | Patch: | Phab:D4334 Phab:D4343 |
Description
In quite some places there are e.g. string literals, or numbers, representing specific cases for a decision. See e.g. baseManager state == "unconstructed"
or the subroles of workers.
It would be nice if these kind of cases would be set in enum-like properties. E.g. state == BaseManager.UNCONSTRUCTED
.
This would lead to better readability of the code (for numbers at least) and less errors due to mistyping.
Change History (10)
comment:1 by , 3 years ago
Keywords: | design removed |
---|
comment:2 by , 3 years ago
comment:3 by , 3 years ago
Keywords: | simple removed |
---|---|
severity: | → simple |
comment:4 by , 3 years ago
Keywords: | simple added |
---|
comment:6 by , 2 years ago
Owner: | set to |
---|---|
Patch: | → Phab:D4334 |
comment:7 by , 2 years ago
Milestone: | Alpha 26 → Work In Progress |
---|
comment:8 by , 2 years ago
Patch: | Phab:D4334 → Phab:D4334,Phab:D4343 |
---|
comment:9 by , 2 years ago
Patch: | Phab:D4334,Phab:D4343 → Phab:D4334 Phab:D4343 |
---|
In [26029]:
[PetraAI] - Use enum-like variables instead of magic values. -- [1]
Improved readability. Easier find-and-replace.
This commit is focused on:
Patch by: @JCWasmx86
Differential revision: https://code.wildfiregames.com/D4334
Refs. #6256
Comments by: @Silier, @Stan
For the record I like the idea too. With little luck it'll be faster because the strings will be the same memory address. I also like enums.