diff options
author | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-10-03 09:21:54 +0000 |
---|---|---|
committer | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-10-03 09:21:54 +0000 |
commit | 3eb270dcc69016eea6a5e5ea602c895e4a779443 (patch) | |
tree | 5d7c159f821a8bb0dd98d64872667c00fea720f3 /src/map/clif.c | |
parent | 00cd3323420435f2c3b186352492ebf42ed452ca (diff) | |
download | hercules-3eb270dcc69016eea6a5e5ea602c895e4a779443.tar.gz hercules-3eb270dcc69016eea6a5e5ea602c895e4a779443.tar.bz2 hercules-3eb270dcc69016eea6a5e5ea602c895e4a779443.tar.xz hercules-3eb270dcc69016eea6a5e5ea602c895e4a779443.zip |
Minor improvements on pm processing ( prompted by data i found when testing bugreport:6740 ), also applied my curly brace love on the way.
1. removed double min_chat_delay check in the case of a @main message
2. moved autotrade check over the ignore list check, so that if user is in autotrade it doesnt waste time going thru the characters ignore list array.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16811 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index ed717ff28..49751b7d4 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9928,14 +9928,13 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) if( !clif_process_message(sd, 1, &target, &namelen, &message, &messagelen) ) return; - if (is_atcommand(fd, sd, message, 1) ) + if ( is_atcommand(fd, sd, message, 1) ) return; if (sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)) return; - if (battle_config.min_chat_delay) - { //[Skotlex] + if (battle_config.min_chat_delay) { //[Skotlex] if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0) { return; } @@ -9952,8 +9951,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) { char* str = target+4; //Skip the NPC: string part. struct npc_data* npc; - if ((npc = npc_name2id(str))) - { + if ((npc = npc_name2id(str))) { char split_data[NUM_WHISPER_VAR][CHAT_SIZE_MAX]; char *split; char output[256]; @@ -9962,11 +9960,9 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) // skip codepage indicator, if detected if( str[0] == '|' && strlen(str) >= 4 ) str += 3; - for( i = 0; i < NUM_WHISPER_VAR; ++i ) - {// Splits the message using '#' as separators + for( i = 0; i < NUM_WHISPER_VAR; ++i ) {// Splits the message using '#' as separators split = strchr(str,'#'); - if( split == NULL ) - { // use the remaining string + if( split == NULL ) { // use the remaining string safestrncpy(split_data[i], str, ARRAYLENGTH(split_data[i])); for( ++i; i < NUM_WHISPER_VAR; ++i ) split_data[i][0] = '\0'; @@ -9977,8 +9973,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) str = split+1; } - for( i = 0; i < NUM_WHISPER_VAR; ++i ) - { + for( i = 0; i < NUM_WHISPER_VAR; ++i ) { sprintf(output, "@whispervar%d$", i); set_var(sd,output,(char *) split_data[i]); } @@ -9988,19 +9983,10 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) return; } - } - - // Main chat [LuzZza] - if(strcmpi(target, main_chat_nick) == 0) - { + } else if(strcmpi(target, main_chat_nick) == 0) { // Main chat [LuzZza] if(!sd->state.mainchat) clif_displaymessage(fd, msg_txt(388)); // You should enable main chat with "@main on" command. else { - if ( battle_config.min_chat_delay ) { - if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 ) - return; - sd->cantalk_tick = gettick() + battle_config.min_chat_delay; - } // send the main message using inter-server system intif_main_message( sd, message ); } @@ -10011,8 +9997,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) // searching destination character dstsd = map_nick2sd(target); - if (dstsd == NULL || strcmp(dstsd->status.name, target) != 0) - { + if (dstsd == NULL || strcmp(dstsd->status.name, target) != 0) { // player is not on this map-server // At this point, don't send wisp/page if it's not exactly the same name, because (example) // if there are 'Test' player on an other map-server and 'test' player on this map-server, @@ -10023,31 +10008,29 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) } // if player ignores everyone - if (dstsd->state.ignoreAll) - { + if (dstsd->state.ignoreAll) { if (dstsd->sc.option & OPTION_INVISIBLE && pc_get_group_level(sd) < pc_get_group_level(dstsd)) clif_wis_end(fd, 1); // 1: target character is not loged in else clif_wis_end(fd, 3); // 3: everyone ignored by target return; } - // if player ignores the source character - ARR_FIND(0, MAX_IGNORE_LIST, i, dstsd->ignore[i].name[0] == '\0' || strcmp(dstsd->ignore[i].name, sd->status.name) == 0); - if(i < MAX_IGNORE_LIST && dstsd->ignore[i].name[0] != '\0') - { // source char present in ignore list - clif_wis_end(fd, 2); // 2: ignored by target - return; - } // if player is autotrading - if( dstsd->state.autotrade == 1 ) - { + if( dstsd->state.autotrade == 1 ) { char output[256]; sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name); clif_wis_message(fd, wisp_server_name, output, strlen(output) + 1); return; } + // if player ignores the source character + ARR_FIND(0, MAX_IGNORE_LIST, i, dstsd->ignore[i].name[0] == '\0' || strcmp(dstsd->ignore[i].name, sd->status.name) == 0); + if(i < MAX_IGNORE_LIST && dstsd->ignore[i].name[0] != '\0') { // source char present in ignore list + clif_wis_end(fd, 2); // 2: ignored by target + return; + } + // notify sender of success clif_wis_end(fd, 0); // 0: success to send wisper |