diff options
author | Haru <haru@dotalux.com> | 2014-01-18 21:18:04 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2015-06-01 10:11:39 +0200 |
commit | 2e5e04c5b6e248cb05df4814dbe0d7eed2fe0293 (patch) | |
tree | a4533fa3136e43ab6f3a185019539bd0ae0c50b6 | |
parent | 41583070c88948264eee4e3683686606f88734eb (diff) | |
download | hercules-2e5e04c5b6e248cb05df4814dbe0d7eed2fe0293.tar.gz hercules-2e5e04c5b6e248cb05df4814dbe0d7eed2fe0293.tar.bz2 hercules-2e5e04c5b6e248cb05df4814dbe0d7eed2fe0293.tar.xz hercules-2e5e04c5b6e248cb05df4814dbe0d7eed2fe0293.zip |
Replaced some of the hardcoded values with constants (misc)
- Replaced several hardcoded values with the appropriate enums.
- Added documentation for some hardcoded values that haven't been
replaced by enums (yet)
- Minor code legibility improvements.
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r-- | src/common/db.h | 22 | ||||
-rw-r--r-- | src/common/ers.h | 10 | ||||
-rw-r--r-- | src/common/grfio.c | 2 | ||||
-rw-r--r-- | src/common/mapindex.c | 2 | ||||
-rw-r--r-- | src/common/showmsg.h | 85 | ||||
-rw-r--r-- | src/config/renewal.h | 1 |
6 files changed, 59 insertions, 63 deletions
diff --git a/src/common/db.h b/src/common/db.h index cd61e1543..4883489d7 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -71,10 +71,10 @@ * @see #db_custom_release(DBRelease) */ typedef enum DBRelease { - DB_RELEASE_NOTHING = 0, - DB_RELEASE_KEY = 1, - DB_RELEASE_DATA = 2, - DB_RELEASE_BOTH = 3 + DB_RELEASE_NOTHING = 0x0, + DB_RELEASE_KEY = 0x1, + DB_RELEASE_DATA = 0x2, + DB_RELEASE_BOTH = DB_RELEASE_KEY|DB_RELEASE_DATA, } DBRelease; /** @@ -127,13 +127,13 @@ typedef enum DBType { * @see #db_alloc(const char *,int,DBType,DBOptions,unsigned short) */ typedef enum DBOptions { - DB_OPT_BASE = 0, - DB_OPT_DUP_KEY = 1, - DB_OPT_RELEASE_KEY = 2, - DB_OPT_RELEASE_DATA = 4, - DB_OPT_RELEASE_BOTH = 6, - DB_OPT_ALLOW_NULL_KEY = 8, - DB_OPT_ALLOW_NULL_DATA = 16, + DB_OPT_BASE = 0x00, + DB_OPT_DUP_KEY = 0x01, + DB_OPT_RELEASE_KEY = 0x02, + DB_OPT_RELEASE_DATA = 0x04, + DB_OPT_RELEASE_BOTH = DB_OPT_RELEASE_KEY|DB_OPT_RELEASE_DATA, + DB_OPT_ALLOW_NULL_KEY = 0x08, + DB_OPT_ALLOW_NULL_DATA = 0x10, } DBOptions; /** diff --git a/src/common/ers.h b/src/common/ers.h index 85ddfed7a..0117237d7 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -71,11 +71,11 @@ #endif /* not ERS_ALIGN_ENTRY */ enum ERSOptions { - ERS_OPT_NONE = 0x0, - ERS_OPT_CLEAR = 0x1,/* silently clears any entries left in the manager upon destruction */ - ERS_OPT_WAIT = 0x2,/* wait for entries to come in order to list! */ - ERS_OPT_FREE_NAME = 0x4,/* name is dynamic memory, and should be freed */ - ERS_OPT_CLEAN = 0x8,/* clears used memory upon ers_free so that its all new to be reused on the next alloc */ + ERS_OPT_NONE = 0x00, + ERS_OPT_CLEAR = 0x01,/* silently clears any entries left in the manager upon destruction */ + ERS_OPT_WAIT = 0x02,/* wait for entries to come in order to list! */ + ERS_OPT_FREE_NAME = 0x04,/* name is dynamic memory, and should be freed */ + ERS_OPT_CLEAN = 0x08,/* clears used memory upon ers_free so that its all new to be reused on the next alloc */ ERS_OPT_FLEX_CHUNK = 0x10,/* signs that it should look for its own cache given it'll have a dynamic chunk size, so that it doesn't affect the other ERS it'd otherwise be sharing */ /* Compound, is used to determine whether it should be looking for a cache of matching options */ diff --git a/src/common/grfio.c b/src/common/grfio.c index e95163569..41a888267 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -36,8 +36,8 @@ typedef struct FILELIST { } FILELIST; #define FILELIST_TYPE_FILE 0x01 // entry is a file -#define FILELIST_TYPE_ENCRYPT_HEADER 0x04 // encryption mode 1 (header DES only) #define FILELIST_TYPE_ENCRYPT_MIXED 0x02 // encryption mode 0 (header DES + periodic DES/shuffle) +#define FILELIST_TYPE_ENCRYPT_HEADER 0x04 // encryption mode 1 (header DES only) //gentry ... > 0 : data read from a grf file (gentry_table[gentry-1]) //gentry ... 0 : data read from a local file (data directory) diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 035518f68..e07ccd679 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -193,7 +193,7 @@ void mapindex_defaults(void) { mapindex = &mapindex_s; /* TODO: place it in inter-server.conf? */ - snprintf(mapindex->config_file, 80, "%s","db/map_index.txt"); + snprintf(mapindex->config_file, sizeof(mapindex->config_file), "%s","db/map_index.txt"); /* */ mapindex->db = NULL; mapindex->num = 0; diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 48e763c25..0624f1786 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -23,58 +23,55 @@ // \033[0m : reset color parameter // \033[1m : use bold for font -#define CL_RESET "\033[0m" -#define CL_CLS "\033[2J" -#define CL_CLL "\033[K" +#define CL_RESET "\033[0m" +#define CL_CLS "\033[2J" +#define CL_CLL "\033[K" // font settings -#define CL_BOLD "\033[1m" -#define CL_NORM CL_RESET -#define CL_NORMAL CL_RESET -#define CL_NONE CL_RESET -// foreground color and bold font (bright color on windows) -#define CL_WHITE "\033[1;37m" -#define CL_GRAY "\033[1;30m" -#define CL_RED "\033[1;31m" -#define CL_GREEN "\033[1;32m" -#define CL_YELLOW "\033[1;33m" -#define CL_BLUE "\033[1;34m" -#define CL_MAGENTA "\033[1;35m" -#define CL_CYAN "\033[1;36m" +#define CL_BOLD "\033[1m" +#define CL_NORM CL_RESET +#define CL_NORMAL CL_RESET +#define CL_NONE CL_RESET // background color -#define CL_BG_BLACK "\033[40m" -#define CL_BG_RED "\033[41m" -#define CL_BG_GREEN "\033[42m" -#define CL_BG_YELLOW "\033[43m" -#define CL_BG_BLUE "\033[44m" -#define CL_BG_MAGENTA "\033[45m" -#define CL_BG_CYAN "\033[46m" -#define CL_BG_WHITE "\033[47m" +#define CL_BG_BLACK "\033[40m" +#define CL_BG_RED "\033[41m" +#define CL_BG_GREEN "\033[42m" +#define CL_BG_YELLOW "\033[43m" +#define CL_BG_BLUE "\033[44m" +#define CL_BG_MAGENTA "\033[45m" +#define CL_BG_CYAN "\033[46m" +#define CL_BG_WHITE "\033[47m" // foreground color and normal font (normal color on windows) -#define CL_LT_BLACK "\033[0;30m" -#define CL_LT_RED "\033[0;31m" -#define CL_LT_GREEN "\033[0;32m" -#define CL_LT_YELLOW "\033[0;33m" -#define CL_LT_BLUE "\033[0;34m" -#define CL_LT_MAGENTA "\033[0;35m" -#define CL_LT_CYAN "\033[0;36m" -#define CL_LT_WHITE "\033[0;37m" +#define CL_LT_BLACK "\033[0;30m" +#define CL_LT_RED "\033[0;31m" +#define CL_LT_GREEN "\033[0;32m" +#define CL_LT_YELLOW "\033[0;33m" +#define CL_LT_BLUE "\033[0;34m" +#define CL_LT_MAGENTA "\033[0;35m" +#define CL_LT_CYAN "\033[0;36m" +#define CL_LT_WHITE "\033[0;37m" // foreground color and bold font (bright color on windows) -#define CL_BT_BLACK "\033[1;30m" -#define CL_BT_RED "\033[1;31m" -#define CL_BT_GREEN "\033[1;32m" -#define CL_BT_YELLOW "\033[1;33m" -#define CL_BT_BLUE "\033[1;34m" -#define CL_BT_MAGENTA "\033[1;35m" -#define CL_BT_CYAN "\033[1;36m" -#define CL_BT_WHITE "\033[1;37m" +#define CL_BT_BLACK "\033[1;30m" +#define CL_BT_RED "\033[1;31m" +#define CL_BT_GREEN "\033[1;32m" +#define CL_BT_YELLOW "\033[1;33m" +#define CL_BT_BLUE "\033[1;34m" +#define CL_BT_MAGENTA "\033[1;35m" +#define CL_BT_CYAN "\033[1;36m" +#define CL_BT_WHITE "\033[1;37m" -#define CL_WTBL "\033[37;44m" // white on blue -#define CL_XXBL "\033[0;44m" // default on blue -#define CL_PASS "\033[0;32;42m" // green on green +// foreground color and bold font (bright color on windows) +#define CL_WHITE CL_BT_WHITE +#define CL_GRAY CL_BT_BLACK +#define CL_RED CL_BT_RED +#define CL_GREEN CL_BT_GREEN +#define CL_YELLOW CL_BT_YELLOW +#define CL_BLUE CL_BT_BLUE +#define CL_MAGENTA CL_BT_MAGENTA +#define CL_CYAN CL_BT_CYAN -#define CL_SPACE " " // space equivalent of the print messages +#define CL_SPACE " " // space aquivalent of the print messages enum msg_type { MSG_NONE, diff --git a/src/config/renewal.h b/src/config/renewal.h index 939ad9b73..6a3cdf86d 100644 --- a/src/config/renewal.h +++ b/src/config/renewal.h @@ -74,7 +74,6 @@ #define RENEWAL_EDP /// renewal ASPD [malufett] -/// (disable by commenting the line) /// /// leave this line to enable renewal ASPD /// - shield penalty is applied |