diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 54 | ||||
-rw-r--r-- | src/map/chrif.c | 24 | ||||
-rw-r--r-- | src/map/clif.c | 32 | ||||
-rw-r--r-- | src/map/clif.h | 2 |
4 files changed, 80 insertions, 32 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index cdd257195..a2bea32a8 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -549,16 +549,16 @@ ACMD(who) { int display_type = 1; int map_id = -1; - if (strstr(command, "map") != NULL) { + if (stristr(info->command, "map") != NULL) { if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map->mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } else { sscanf(message, "%23s", player_name); } - if (strstr(command, "2") != NULL) + if (stristr(info->command, "2") != NULL) display_type = 2; - else if (strstr(command, "3") != NULL) + else if (stristr(info->command, "3") != NULL) display_type = 3; level = pc->get_group_level(sd); @@ -1002,17 +1002,17 @@ ACMD(kami) memset(atcmd_output, '\0', sizeof(atcmd_output)); - if(*(command + 5) != 'c' && *(command + 5) != 'C') { + if(*(info->command + 4) != 'c' && *(info->command + 4) != 'C') { if (!message || !*message) { clif->message(fd, msg_txt(980)); // Please enter a message (usage: @kami <message>). return false; } sscanf(message, "%199[^\n]", atcmd_output); - if (strstr(command, "l") != NULL) + if (stristr(info->command, "l") != NULL) clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); else - intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_YELLOW); + intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(info->command + 4) == 'b' || *(info->command + 4) == 'B') ? BC_BLUE : BC_YELLOW); } else { if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) { clif->message(fd, msg_txt(981)); // Please enter color and message (usage: @kamic <color> <message>). @@ -1099,7 +1099,7 @@ ACMD(item) memset(item_name, '\0', sizeof(item_name)); - if (!strcmpi(command+1,"itembound") && (!message || !*message || ( + if (!strcmpi(info->command,"itembound") && (!message || !*message || ( sscanf(message, "\"%99[^\"]\" %d %d", item_name, &number, &bound) < 2 && sscanf(message, "%99s %d %d", item_name, &number, &bound) < 2 ))) { @@ -1123,7 +1123,7 @@ ACMD(item) return false; } - if(!strcmpi(command+1,"itembound") && !(bound >= IBT_MIN && bound <= IBT_MAX) ) { + if(!strcmpi(info->command,"itembound") && !(bound >= IBT_MIN && bound <= IBT_MAX) ) { clif->message(fd, msg_txt(298)); // Invalid bound type return false; } @@ -1171,7 +1171,7 @@ ACMD(item2) memset(item_name, '\0', sizeof(item_name)); - if (!strcmpi(command+1,"itembound2") && (!message || !*message || ( + if (!strcmpi(info->command,"itembound2") && (!message || !*message || ( sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 && sscanf(message, "%99s %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))) { clif->message(fd, msg_txt(296)); // Please enter all parameters (usage: @itembound2 <item name/ID> <quantity> @@ -1189,7 +1189,7 @@ ACMD(item2) if (number <= 0) number = 1; - if( !strcmpi(command+1,"itembound2") && !(bound >= IBT_MIN && bound <= IBT_MAX) ) { + if( !strcmpi(info->command,"itembound2") && !(bound >= IBT_MIN && bound <= IBT_MAX) ) { clif->message(fd, msg_txt(298)); // Invalid bound type return false; } @@ -1204,7 +1204,7 @@ ACMD(item2) int loop, get_count, i; loop = 1; get_count = number; - if( !strcmpi(command+1,"itembound2") ) + if( !strcmpi(info->command,"itembound2") ) bound = 1; if( !itemdb->isstackable2(item_data) ) { if( bound && (item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) ) { @@ -1930,9 +1930,9 @@ ACMD(monster) if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit) number = battle_config.atc_spawn_quantity_limit; - if (strcmp(command+1, "monstersmall") == 0) + if (strcmpi(info->command, "monstersmall") == 0) size = SZ_MEDIUM; // This is just gorgeous [mkbu95] - else if (strcmp(command+1, "monsterbig") == 0) + else if (strcmpi(info->command, "monsterbig") == 0) size = SZ_BIG; else size = SZ_SMALL; @@ -1997,7 +1997,7 @@ ACMD(killmonster) { map_id = sd->bl.m; } - drop_flag = strcmp(command+1, "killmonster2"); + drop_flag = strcmpi(info->command, "killmonster2"); map->foreachinmap(atcommand->atkillmonster_sub, map_id, BL_MOB, -drop_flag); @@ -2358,7 +2358,7 @@ ACMD(param) { return false; } - ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 ); + ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(info->command, param[i]) == 0 ); if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible... clif->message(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>). @@ -2798,7 +2798,7 @@ ACMD(char_ban) return false; } - chrif->char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban + 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 clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it. return true; @@ -2838,7 +2838,7 @@ ACMD(char_unban) } // send answer to login server via char-server - chrif->char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban + 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 clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it. return true; @@ -3138,7 +3138,7 @@ ACMD(spiritball) if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs ) { char msg[CHAT_SIZE_MAX]; - safesnprintf(msg, sizeof(msg), msg_txt(1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>). + safesnprintf(msg, sizeof(msg), msg_txt(1028), max_spiritballs); // Please enter an amount (usage: @spiritball <number: 0-%d>). clif->message(fd, msg); return false; } @@ -6070,7 +6070,7 @@ ACMD(npctalk) { char name[NAME_LENGTH],mes[100],temp[100]; struct npc_data *nd; - bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1; + bool ifcolor=(*(info->command + 7) != 'c' && *(info->command + 7) != 'C')?0:1; unsigned long color=0; if (sd->sc.count && //no "chatting" while muted. @@ -7754,7 +7754,7 @@ ACMD(cash) return false; } - if( !strcmpi(command+1,"cash") ) { + if( !strcmpi(info->command,"cash") ) { if( value > 0 ) { if( (ret=pc->getcash(sd, value, 0)) >= 0){ // If this option is set, the message is already sent by pc function @@ -7813,9 +7813,9 @@ ACMD(clone) { return true; } - if (strcmpi(command+1, "clone") == 0) + if (strcmpi(info->command, "clone") == 0) flag = 1; - else if (strcmpi(command+1, "slaveclone") == 0) { + else if (strcmpi(info->command, "slaveclone") == 0) { flag = 2; if(pc_isdead(sd)){ clif->message(fd, msg_txt(129+flag*2)); @@ -7983,15 +7983,15 @@ ACMD(itemlist) int size; StringBuf buf; - if( strcmp(command+1, "storagelist") == 0 ) { + if( strcmpi(info->command, "storagelist") == 0 ) { location = "storage"; items = sd->status.storage.items; size = MAX_STORAGE; - } else if( strcmp(command+1, "cartlist") == 0 ) { + } else if( strcmpi(info->command, "cartlist") == 0 ) { location = "cart"; items = sd->status.cart; size = MAX_CART; - } else if( strcmp(command+1, "itemlist") == 0 ) { + } else if( strcmpi(info->command, "itemlist") == 0 ) { location = "inventory"; items = sd->status.inventory; size = MAX_INVENTORY; @@ -8512,7 +8512,7 @@ ACMD(reloadquestdb) { } ACMD(addperm) { int perm_size = pcg->permission_count; - bool add = (strcmpi(command+1, "addperm") == 0) ? true : false; + bool add = (strcmpi(info->command, "addperm") == 0) ? true : false; int i; if( !message || !*message ) { @@ -9448,7 +9448,9 @@ void atcommand_basecommands(void) { ACMD_DEF2("allstats", stat_all), ACMD_DEF2("block", char_block), ACMD_DEF2("ban", char_ban), + ACMD_DEF2("charban", char_ban),/* char-specific ban time */ ACMD_DEF2("unblock", char_unblock), + ACMD_DEF2("charunban", char_unban),/* char-specific ban time */ ACMD_DEF2("unban", char_unban), ACMD_DEF2("mount", mount_peco), ACMD_DEF(guildspy), diff --git a/src/map/chrif.c b/src/map/chrif.c index 87ec71ec5..56572d492 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -752,7 +752,7 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email) { * S 2b0e <accid>.l <name>.24B <type>.w { <year>.w <month>.w <day>.w <hour>.w <minute>.w <second>.w } * Send an account modification request to the login server (via char server). * type of operation: - * 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex (use next function for 5) + * 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex (use next function for 5), 6: charban *------------------------------------------*/ int 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) { @@ -764,7 +764,7 @@ int chrif_char_ask_name(int acc, const char* character_name, unsigned short oper safestrncpy((char*)WFIFOP(chrif->fd,6), character_name, NAME_LENGTH); WFIFOW(chrif->fd,30) = operation_type; - if ( operation_type == 2 ) { + if ( operation_type == 2 || operation_type == 6 ) { WFIFOW(chrif->fd,32) = year; WFIFOW(chrif->fd,34) = month; WFIFOW(chrif->fd,36) = day; @@ -800,7 +800,7 @@ int chrif_changesex(struct map_session_data *sd) { * R 2b0f <accid>.l <name>.24B <type>.w <answer>.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 + * 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex, 6: charban, 7: charunban * type of answer: * 0: login-server request done * 1: player not found @@ -811,6 +811,7 @@ void chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u struct map_session_data* sd; char action[25]; char output[256]; + bool charsrv = ( type == 6 || type == 7 ) ? true : false; sd = map->id2sd(acc); @@ -819,13 +820,17 @@ void chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u return; } + /* re-use previous msg_txt */ + if( type == 6 ) type = 2; + if( type == 7 ) type = 4; + if( type > 0 && type <= 5 ) snprintf(action,25,"%s",msg_txt(427+type)); //block|ban|unblock|unban|change the sex of else snprintf(action,25,"???"); switch( answer ) { - case 0 : sprintf(output, msg_txt(424), action, NAME_LENGTH, player_name); break; + case 0 : sprintf(output, msg_txt(charsrv?434:424), action, NAME_LENGTH, player_name); break; case 1 : sprintf(output, msg_txt(425), NAME_LENGTH, player_name); break; case 2 : sprintf(output, msg_txt(426), action, NAME_LENGTH, player_name); break; case 3 : sprintf(output, msg_txt(427), action, NAME_LENGTH, player_name); break; @@ -980,7 +985,7 @@ int chrif_accountban(int fd) { } sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters - if (RFIFOB(fd,6) == 0) { // 0: change of statut, 1: ban + if (RFIFOB(fd,6) == 0) { // 0: change of statut int ret_status = RFIFOL(fd,7); // status or final date of a banishment if(0<ret_status && ret_status<=9) clif->message(sd->fd, msg_txt(411+ret_status)); @@ -988,13 +993,20 @@ int chrif_accountban(int fd) { clif->message(sd->fd, msg_txt(421)); else clif->message(sd->fd, msg_txt(420)); //"Your account has not more authorised." - } else if (RFIFOB(fd,6) == 1) { // 0: change of statut, 1: ban + } else if (RFIFOB(fd,6) == 1) { // 1: ban time_t timestamp; char tmpstr[2048]; timestamp = (time_t)RFIFOL(fd,7); // status or final date of a banishment strcpy(tmpstr, msg_txt(423)); //"Your account has been banished until " strftime(tmpstr + strlen(tmpstr), 24, "%d-%m-%Y %H:%M:%S", localtime(×tamp)); clif->message(sd->fd, tmpstr); + } else if (RFIFOB(fd,6) == 2) { // 2: change of status for character + time_t timestamp; + char tmpstr[2048]; + timestamp = (time_t)RFIFOL(fd,7); // status or final date of a banishment + strcpy(tmpstr, msg_txt(433)); //"This character has been banned until " + strftime(tmpstr + strlen(tmpstr), 24, "%d-%m-%Y %H:%M:%S", localtime(×tamp)); + clif->message(sd->fd, tmpstr); } set_eof(sd->fd); // forced to disconnect for the change diff --git a/src/map/clif.c b/src/map/clif.c index d84a0dea8..6740c7a74 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5634,7 +5634,38 @@ void clif_displaymessage2(const int fd, const char* mes) { aFree(message); } } +/* oh noo! another version of 0x8e! */ +void clif_displaymessage_sprintf(const int fd, const char* mes, ...) { + va_list ap; + if( fd == -2 ) { + ShowInfo("HCP: "); + va_start(ap,mes); + _vShowMessage(MSG_NONE,mes,ap); + va_end(ap); + ShowMessage("\n"); + } else if ( fd > 0 ) { + int len = 1; + char *ptr; + + WFIFOHEAD(fd, 5 + 255);/* ensure the maximum */ + + /* process */ + va_start(ap,mes); + len += vsnprintf((char *)WFIFOP(fd,4), 255, mes, ap); + va_end(ap); + + /* adjusting */ + ptr = (char *)WFIFOP(fd,4); + ptr[len - 1] = '\0'; + + /* */ + WFIFOW(fd,0) = 0x8e; + WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate + + WFIFOSET(fd, 5 + len); + } +} /// Send broadcast message in yellow or blue without font formatting (ZC_BROADCAST). /// 009a <packet len>.W <message>.?B void clif_broadcast(struct block_list* bl, const char* mes, int len, int type, enum send_target target) @@ -18407,6 +18438,7 @@ void clif_defaults(void) { clif->msgtable_num = clif_msgtable_num; clif->message = clif_displaymessage; clif->messageln = clif_displaymessage2; + clif->messages = clif_displaymessage_sprintf; clif->colormes = clif_colormes; clif->process_message = clif_process_message; clif->wisexin = clif_wisexin; diff --git a/src/map/clif.h b/src/map/clif.h index e50af7432..043f7dd3a 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -787,6 +787,8 @@ struct clif_interface { void (*msgtable_num) (int fd, int line, int num); void (*message) (const int fd, const char* mes); void (*messageln) (const int fd, const char* mes); + /* message+s(printf) */ + void (*messages) (const int fd, const char* mes, ...); int (*colormes) (int fd, enum clif_colors color, const char* msg); bool (*process_message) (struct map_session_data* sd, int format, char** name_, int* namelen_, char** message_, int* messagelen_); void (*wisexin) (struct map_session_data *sd,int type,int flag); |