From 42e1df9e61f8efb6340ed1c9238cd247d553d9b8 Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 23 Jan 2014 18:40:29 +0100 Subject: Replaced some of the hardcoded values with constants (char) - 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 --- src/map/atcommand.c | 10 ++++++---- src/map/chrif.c | 47 +++++++++++++++++++++-------------------------- src/map/clif.c | 12 +++--------- src/map/guild.c | 8 +++----- src/map/map.h | 10 ---------- src/map/status.h | 43 ------------------------------------------- src/map/trade.c | 4 ++-- 7 files changed, 35 insertions(+), 99 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index a1666b44e..93321e047 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2730,7 +2730,7 @@ ACMD(char_block) return false; } - chrif->char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block + chrif->char_ask_name(sd->status.account_id, atcmd_player_name, CHAR_ASK_NAME_BLOCK, 0, 0, 0, 0, 0, 0); clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it. return true; @@ -2826,7 +2826,8 @@ ACMD(char_ban) return false; } - chrif->char_ask_name(sd->status.account_id, atcmd_player_name, !strcmpi(info->command,"charban") ? 6 : 2, year, month, day, hour, minute, second); // type: 2 - ban; 6 - charban + chrif->char_ask_name(sd->status.account_id, atcmd_player_name, + !strcmpi(info->command,"charban") ? CHAR_ASK_NAME_BAN : CHAR_ASK_NAME_BAN, year, month, day, hour, minute, second); clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it. return true; @@ -2845,7 +2846,7 @@ ACMD(char_unblock) } // send answer to login server via char-server - chrif->char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock + chrif->char_ask_name(sd->status.account_id, atcmd_player_name, CHAR_ASK_NAME_UNBLOCK, 0, 0, 0, 0, 0, 0); clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it. return true; @@ -2864,7 +2865,8 @@ ACMD(char_unban) } // send answer to login server via char-server - chrif->char_ask_name(sd->status.account_id, atcmd_player_name, !strcmpi(info->command,"charunban") ? 7 : 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban account; type 7 - unban character + chrif->char_ask_name(sd->status.account_id, atcmd_player_name, + !strcmpi(info->command,"charunban") ? CHAR_ASK_NAME_CHARUNBAN : CHAR_ASK_NAME_UNBAN, 0, 0, 0, 0, 0, 0); clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it. return true; diff --git a/src/map/chrif.c b/src/map/chrif.c index 6ac7d5695..2e9ced1ce 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -747,15 +747,15 @@ bool chrif_changeemail(int id, const char *actual_email, const char *new_email) * S 2b0e .l .24B .w { .12B } * { .w .w .w .w .w .w } * Send an account modification request to the login server (via char server). - * type of operation {additional fields}: - * 1: block { n/a } - * 2: ban { .w .w .w .w .w .w } - * 3: unblock { n/a } - * 4: unban { n/a } - * 5: changesex { n/a } -- use chrif_changesex - * 6: charban { .w .w .w .w .w .w } - * 7: charunban { n/a } - * 8: changecharsex { .b } -- use chrif_changesex + * type of operation: @see enum zh_char_ask_name + * block { n/a } + * ban { .w .w .w .w .w .w } + * unblock { n/a } + * unban { n/a } + * changesex { n/a } -- use chrif_changesex + * charban { .w .w .w .w .w .w } + * charunban { n/a } + * changecharsex { .b } -- use chrif_changesex *------------------------------------------*/ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second) { @@ -767,7 +767,7 @@ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short ope safestrncpy((char*)WFIFOP(chrif->fd,6), character_name, NAME_LENGTH); WFIFOW(chrif->fd,30) = operation_type; - if ( operation_type == 2 || operation_type == 6 ) { + if (operation_type == CHAR_ASK_NAME_BAN || operation_type == CHAR_ASK_NAME_CHARBAN) { WFIFOW(chrif->fd,32) = year; WFIFOW(chrif->fd,34) = month; WFIFOW(chrif->fd,36) = day; @@ -795,7 +795,7 @@ bool chrif_changesex(struct map_session_data *sd, bool change_account) WFIFOW(chrif->fd,0) = 0x2b0e; WFIFOL(chrif->fd,2) = sd->status.account_id; safestrncpy((char*)WFIFOP(chrif->fd,6), sd->status.name, NAME_LENGTH); - WFIFOW(chrif->fd,30) = change_account ? 5 : 8; + WFIFOW(chrif->fd,30) = change_account ? CHAR_ASK_NAME_CHANGESEX : CHAR_ASK_NAME_CHANGECHARSEX; if (!change_account) WFIFOB(chrif->fd,32) = sd->status.sex == SEX_MALE ? SEX_FEMALE : SEX_MALE; WFIFOSET(chrif->fd,44); @@ -812,19 +812,14 @@ bool chrif_changesex(struct map_session_data *sd, bool change_account) /*========================================== * R 2b0f .l .24B .w .w * Processing a reply to chrif->char_ask_name() (request to modify an account). - * type of operation: - * 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex, 6: charban, 7: charunban, 8: changecharsex - * type of answer: - * 0: login-server request done - * 1: player not found - * 2: gm level too low - * 3: login-server offline + * type of operation: @see chrif_char_ask_name + * type of answer: @see hz_char_ask_name_answer *------------------------------------------*/ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, uint16 answer) { struct map_session_data* sd; char action[25]; char output[256]; - bool charsrv = ( type == 6 || type == 7 ) ? true : false; + bool charsrv = ( type == CHAR_ASK_NAME_CHARBAN || type == CHAR_ASK_NAME_CHARUNBAN ) ? true : false; sd = map->id2sd(acc); @@ -834,19 +829,19 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u } /* re-use previous msg_number */ - if( type == 6 ) type = 2; - if( type == 7 ) type = 4; + if( type == CHAR_ASK_NAME_CHARBAN ) type = CHAR_ASK_NAME_BAN; + if( type == CHAR_ASK_NAME_CHARUNBAN ) type = CHAR_ASK_NAME_UNBAN; - if( type > 0 && type <= 5 ) + if( type >= CHAR_ASK_NAME_BLOCK && type <= CHAR_ASK_NAME_CHANGESEX ) snprintf(action,25,"%s",msg_sd(sd,427+type)); //block|ban|unblock|unban|change the sex of else snprintf(action,25,"???"); switch( answer ) { - case 0 : sprintf(output, msg_sd(sd,charsrv?434:424), action, NAME_LENGTH, player_name); break; - case 1 : sprintf(output, msg_sd(sd,425), NAME_LENGTH, player_name); break; - case 2 : sprintf(output, msg_sd(sd,426), action, NAME_LENGTH, player_name); break; - case 3 : sprintf(output, msg_sd(sd,427), action, NAME_LENGTH, player_name); break; + case CHAR_ASK_NAME_ANS_DONE: sprintf(output, msg_sd(sd,charsrv?434:424), action, NAME_LENGTH, player_name); break; + case CHAR_ASK_NAME_ANS_NOTFOUND: sprintf(output, msg_sd(sd,425), NAME_LENGTH, player_name); break; + case CHAR_ASK_NAME_ANS_GMLOW: sprintf(output, msg_sd(sd,426), action, NAME_LENGTH, player_name); break; + case CHAR_ASK_NAME_ANS_OFFLINE: sprintf(output, msg_sd(sd,427), action, NAME_LENGTH, player_name); break; default: output[0] = '\0'; break; } diff --git a/src/map/clif.c b/src/map/clif.c index 16bb6172c..7d0d98891 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -7071,9 +7071,7 @@ void clif_guild_created(struct map_session_data *sd,int flag) /// Notifies the client that it is belonging to a guild (ZC_UPDATE_GDID). /// 016c .L .L .L .B .L .24B -/// mode: -/// &0x01 = allow invite -/// &0x10 = allow expel +/// mode: @see enum guild_permission void clif_guild_belonginfo(struct map_session_data *sd, struct guild *g) { int ps,fd; @@ -7323,9 +7321,7 @@ void clif_guild_positionnamelist(struct map_session_data *sd) { /// Guild position information (ZC_POSITION_INFO). /// 0160 .W { .L .L .L .L }* -/// mode: -/// &0x01 = allow invite -/// &0x10 = allow expel +/// mode: @see enum guild_permission /// ranking: /// TODO void clif_guild_positioninfolist(struct map_session_data *sd) { @@ -7353,9 +7349,7 @@ void clif_guild_positioninfolist(struct map_session_data *sd) { /// Notifies clients in a guild about updated position information (ZC_ACK_CHANGE_GUILD_POSITIONINFO). /// 0174 .W { .L .L .L .L .24B }* -/// mode: -/// &0x01 = allow invite -/// &0x10 = allow expel +/// mode: @see enum guild_permission /// ranking: /// TODO void clif_guild_positionchanged(struct guild *g,int idx) diff --git a/src/map/guild.c b/src/map/guild.c index 936b4c900..c776cf2fc 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -615,7 +615,7 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) { if(tsd==NULL || g==NULL) return 0; - if( (i=guild->getposition(g,sd))<0 || !(g->position[i].mode&0x0001) ) + if( (i=guild->getposition(g,sd)) < 0 || !(g->position[i].mode&GPERM_INVITE) ) return 0; //Invite permission. if(!battle_config.invite_request_check) { @@ -840,7 +840,7 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i if(sd->status.guild_id!=guild_id) return 0; - if( (ps=guild->getposition(g,sd))<0 || !(g->position[ps].mode&0x0010) ) + if ((ps=guild->getposition(g,sd))<0 || !(g->position[ps].mode&GPERM_EXPEL)) return 0; //Expulsion permission //Can't leave inside guild castles. @@ -1095,9 +1095,7 @@ int guild_change_position(int guild_id,int idx,int mode,int exp_mode,const char struct guild_position p; exp_mode = cap_value(exp_mode, 0, battle_config.guild_exp_limit); - //Mode 0x01 <- Invite - //Mode 0x10 <- Expel. - p.mode=mode&0x11; + p.mode=mode&GPERM_BOTH; // Invite and Expel p.exp_mode=exp_mode; safestrncpy(p.name,name,NAME_LENGTH); return intif->guild_position(guild_id,idx,&p); diff --git a/src/map/map.h b/src/map/map.h index 02e93b7bb..28ad6bf6f 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -65,16 +65,6 @@ enum MOBID { MOBID_MAGICDECOY_WIND = 2046, }; -// The following system marks a different job ID system used by the map server, -// which makes a lot more sense than the normal one. [Skotlex] -// These marks the "level" of the job. -#define JOBL_2_1 0x100 //256 -#define JOBL_2_2 0x200 //512 -#define JOBL_2 0x300 -#define JOBL_UPPER 0x1000 //4096 -#define JOBL_BABY 0x2000 //8192 -#define JOBL_THIRD 0x4000 //16384 - // For filtering and quick checking. #define MAPID_BASEMASK 0x00ff #define MAPID_UPPERMASK 0x0fff diff --git a/src/map/status.h b/src/map/status.h index b370a9c88..af11683a0 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1655,49 +1655,6 @@ enum { OPT3_CONTRACT = 0x00020000, }; -enum { - OPTION_NOTHING = 0x00000000, - OPTION_SIGHT = 0x00000001, - OPTION_HIDE = 0x00000002, - OPTION_CLOAK = 0x00000004, - OPTION_FALCON = 0x00000010, - OPTION_RIDING = 0x00000020, - OPTION_INVISIBLE = 0x00000040, - OPTION_ORCISH = 0x00000800, - OPTION_WEDDING = 0x00001000, - OPTION_RUWACH = 0x00002000, - OPTION_CHASEWALK = 0x00004000, - OPTION_FLYING = 0x00008000, //Note that clientside Flying and Xmas are 0x8000 for clients prior to 2007. - OPTION_XMAS = 0x00010000, - OPTION_TRANSFORM = 0x00020000, - OPTION_SUMMER = 0x00040000, - OPTION_DRAGON1 = 0x00080000, - OPTION_WUG = 0x00100000, - OPTION_WUGRIDER = 0x00200000, - OPTION_MADOGEAR = 0x00400000, - OPTION_DRAGON2 = 0x00800000, - OPTION_DRAGON3 = 0x01000000, - OPTION_DRAGON4 = 0x02000000, - OPTION_DRAGON5 = 0x04000000, - OPTION_HANBOK = 0x08000000, - OPTION_OKTOBERFEST = 0x10000000, - -#ifndef NEW_CARTS - OPTION_CART1 = 0x00000008, - OPTION_CART2 = 0x00000080, - OPTION_CART3 = 0x00000100, - OPTION_CART4 = 0x00000200, - OPTION_CART5 = 0x00000400, - - /* compound constant for older carts */ - OPTION_CART = OPTION_CART1|OPTION_CART2|OPTION_CART3|OPTION_CART4|OPTION_CART5, -#endif - - // compound constants - OPTION_DRAGON = OPTION_DRAGON1|OPTION_DRAGON2|OPTION_DRAGON3|OPTION_DRAGON4|OPTION_DRAGON5, - OPTION_COSTUME = OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK|OPTION_OKTOBERFEST, -}; - //Defines for the manner system [Skotlex] enum manner_flags { diff --git a/src/map/trade.c b/src/map/trade.c index 7417f05af..72e64e45d 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -208,13 +208,13 @@ int impossible_trade_check(struct map_session_data *sd) intif->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); // if we block people if (battle_config.ban_hack_trade < 0) { - chrif->char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block + chrif->char_ask_name(-1, sd->status.name, CHAR_ASK_NAME_BLOCK, 0, 0, 0, 0, 0, 0); set_eof(sd->fd); // forced to disconnect because of the hack // message about the ban safestrncpy(message_to_gm, msg_txt(540), sizeof(message_to_gm)); // This player has been definitively blocked. // if we ban people } else if (battle_config.ban_hack_trade > 0) { - chrif->char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_hack_trade, 0); // type: 2 - ban (year, month, day, hour, minute, second) + chrif->char_ask_name(-1, sd->status.name, CHAR_ASK_NAME_BAN, 0, 0, 0, 0, battle_config.ban_hack_trade, 0); // type: 2 - ban (year, month, day, hour, minute, second) set_eof(sd->fd); // forced to disconnect because of the hack // message about the ban sprintf(message_to_gm, msg_txt(507), battle_config.ban_hack_trade); // This player has been banned for %d minute(s). -- cgit v1.2.3-60-g2f50