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

Convert defines to enums #32

Open
sean-gilliam opened this issue Oct 16, 2019 · 12 comments
Open

Convert defines to enums #32

sean-gilliam opened this issue Oct 16, 2019 · 12 comments

Comments

@sean-gilliam
Copy link
Collaborator

There are quite a few places where defines are used instead of enumerations.

For example:

#define TEMP_HOT 0
#define TEMP_WARM 1
#define TEMP_COOL 2
#define TEMP_COLD 3

This is better expressed as an enumeration

enum Temperature
{
	Hot,
	Warm,
	Cool,
	Cold,
	Unknown
};

We should consider using enumerations instead of defines.

@rezalas
Copy link
Owner

rezalas commented Oct 16, 2019

I see someone is working in the weather system! Also I completely agree.

@rezalas
Copy link
Owner

rezalas commented Oct 24, 2021

I'm almost done converting the weather-related vnums as a start.

@rezalas
Copy link
Owner

rezalas commented Oct 24, 2021

There will be multiple PRs for this most likely to keep them all clean most likely. There are so many defines spread across the game right now...

@Psypher9
Copy link
Collaborator

Psypher9 commented Nov 1, 2021

What about in code/interp.h?

#define ML				MAX_LEVEL		/* implementor */
#define L1				MAX_LEVEL - 1	/* creator */
#define L2				MAX_LEVEL - 2	/* supreme being */
#define L3				MAX_LEVEL - 3	/* deity */
#define L4				MAX_LEVEL - 4	/* god */
#define L5				MAX_LEVEL - 5	/* immortal */
#define L6				MAX_LEVEL - 6	/* demigod */
#define L7				MAX_LEVEL - 7	/* angel */
#define L8				MAX_LEVEL - 8	/* avatar */
#define IM				LEVEL_IMMORTAL	/* avatar */
#define HE				LEVEL_HERO		/* hero */

Is this something that would make more sense as an enum?

@rezalas
Copy link
Owner

rezalas commented Nov 1, 2021

Honestly these look like something that should be in the configuration files

@Psypher9
Copy link
Collaborator

Psypher9 commented Nov 1, 2021

Just found a whole bunch of these that seem more like enums in code/merc.h#L323-446

@rezalas
Copy link
Owner

rezalas commented Nov 1, 2021

I don't know if the telnet colors will, but the others are definitely enumerated values that need converted

@Psypher9
Copy link
Collaborator

What do we think about this one for the ASCII Characters? merc.h lines 1117-1159

#define ASCII_A							0
#define ASCII_B							1
#define ASCII_C							2
#define ASCII_D							3
#define ASCII_E							4
#define ASCII_F							5
#define ASCII_G							6
#define ASCII_H							7
#define ASCII_I							8
#define ASCII_J							9
#define ASCII_K							10
#define ASCII_L							11
#define ASCII_M							12
#define ASCII_N							13
#define ASCII_O							14
#define ASCII_P							15
#define ASCII_Q							16
#define ASCII_R							17
#define ASCII_S							18
#define ASCII_T							19
#define ASCII_U							20
#define ASCII_V							21
#define ASCII_W							22
#define ASCII_X							23
#define ASCII_Y							24
#define ASCII_Z							25
#define ASCII_aa						26
#define ASCII_bb						27
#define ASCII_cc						28
#define ASCII_dd						29
#define ASCII_ee						30
#define ASCII_ff						31
#define ASCII_gg						32
#define ASCII_hh						33
#define ASCII_ii						34
#define ASCII_jj						35
#define ASCII_kk						36
#define ASCII_ll						37
#define ASCII_mm						38
#define ASCII_nn						39
#define ASCII_oo						40
#define ASCII_pp						41
#define MAX_BIT							42

@sean-gilliam
Copy link
Collaborator Author

That would be a good one to convert.

@Psypher9
Copy link
Collaborator

@sean-gilliam I've noticed that you have moved some of the weather #defines to enums in a spearate file. Is there a certain pattern you guys are wanting to follow for where these new enums end up?

@sean-gilliam
Copy link
Collaborator Author

@sean-gilliam I've noticed that you have moved some of the weather #defines to enums in a spearate file. Is there a certain pattern you guys are wanting to follow for where these new enums end up?

It was @rezalas who moved them. I think grouping them logically is the best course so that we can eventually transition to enum classes. This will help in our continuing effort to move to C++.

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

No branches or pull requests

3 participants