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 Silier, 3 years ago

Keywords: design removed

comment:2 by Stan, 3 years ago

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.

comment:3 by Silier, 3 years ago

Keywords: simple removed
severity: simple

comment:4 by Silier, 3 years ago

Keywords: simple added

comment:5 by Silier, 3 years ago

In 25883:

Remove passability magic numbers from terrain-analysis

Put passability values to prototype variables.
Code looks more readable.

Differential revision: D4236
Refs: #6256
Comments by: @Freagarach, @Stan

comment:6 by Silier, 2 years ago

Owner: set to JCWasmx86
Patch: Phab:D4334

comment:7 by Silier, 2 years ago

Milestone: Alpha 26Work In Progress

comment:8 by Freagarach, 2 years ago

Patch: Phab:D4334Phab:D4334,Phab:D4343

comment:9 by Freagarach, 2 years ago

Patch: Phab:D4334,Phab:D4343Phab: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:

BaseManager
AttackPlan
GarrisonManager

Patch by: @JCWasmx86
Differential revision: https://code.wildfiregames.com/D4334
Refs. #6256
Comments by: @Silier, @Stan

comment:10 by Freagarach, 2 years ago

In 26063:

[PetraAI] - Use enum-like variables instead of magic values. -- [2]

Improved readability. Easier find-and-replace.

This commit focused on:

Patch by: @JCWasmx86
Differential revision: https://code.wildfiregames.com/D4343
Refs. #6256
Comments by: @nani, @Silier, @Stan

Note: See TracTickets for help on using tickets.