rezalas / riftshadow

Dedicated to the preservation of the game and modernization of a classic mud codebase.
MIT License
18 stars 14 forks source link

Convert defines to enums #32

Open sean-gilliam opened 5 years ago

sean-gilliam commented 5 years ago

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 commented 5 years ago

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

rezalas commented 3 years ago

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

rezalas commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

Psypher9 commented 3 years ago

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

rezalas commented 3 years ago

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

Psypher9 commented 3 years ago

code/merc.h

And the list goes on..

Psypher9 commented 2 years ago

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 commented 2 years ago

That would be a good one to convert.

Psypher9 commented 2 years ago

@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 commented 2 years ago

@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++.