From 0ca24c219b8a5a7cd4beb15d8384380f7e6fa9b5 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 25 Aug 2019 17:44:10 +0200 Subject: Remove round-trip to the inter-server for the whisper-to-gm messages Signed-off-by: Haru --- src/map/pc.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index 84d49e1db..827619be8 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -12311,6 +12311,54 @@ static void pc_check_supernovice_call(struct map_session_data *sd, const char *m } } +/** + * Sends a message t all online GMs having the specified permission. + * + * @param sender_name Sender character name. + * @param permission The required permission to receive this message. + * @param message The message body. + * + * @return The amount of characters the message was delivered to. + */ +// The transmission of GM only Wisp/Page from server to inter-server +static int pc_wis_message_to_gm(const char *sender_name, int permission, const char *message) +{ + nullpo_ret(sender_name); + nullpo_ret(message); + int mes_len = (int)strlen(message) + 1; // + null + int count = 0; + + // information is sent to all online GM + map->foreachpc(pc->wis_message_to_gm_sub, permission, sender_name, message, mes_len, &count); + + return count; +} + +/** + * Helper function for pc_wis_message_to_gm(). + */ +static int pc_wis_message_to_gm_sub(struct map_session_data *sd, va_list va) +{ + nullpo_ret(sd); + + int permission = va_arg(va, int); + if (!pc_has_permission(sd, permission)) + return 0; + + const char *sender_name = va_arg(va, const char *); + const char *message = va_arg(va, const char *); + int len = va_arg(va, int); + int *count = va_arg(va, int *); + + nullpo_ret(sender_name); + nullpo_ret(message); + nullpo_ret(count); + + clif->wis_message(sd->fd, sender_name, message, len); + ++*count; + return 1; +} + static void pc_update_job_and_level(struct map_session_data *sd) { nullpo_retv(sd); @@ -12758,6 +12806,8 @@ void pc_defaults(void) pc->check_supernovice_call = pc_check_supernovice_call; pc->process_chat_message = pc_process_chat_message; + pc->wis_message_to_gm = pc_wis_message_to_gm; + pc->wis_message_to_gm_sub = pc_wis_message_to_gm_sub; /** * Autotrade persistency [Ind/Hercules <3] -- cgit v1.2.3-70-g09d2 From 0ef788e46f678e546ec28b602dcfeeb359d0417c Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 25 Aug 2019 17:55:31 +0200 Subject: Remove round-trip to the inter-server for the broadcast messages Signed-off-by: Haru --- src/char/inter.c | 3 +-- src/char/mapif.c | 30 ----------------------- src/char/mapif.h | 2 -- src/map/atcommand.c | 8 ++++--- src/map/intif.c | 69 +---------------------------------------------------- src/map/intif.h | 2 -- src/map/pc.c | 4 ++-- src/map/script.c | 20 +++++++--------- 8 files changed, 17 insertions(+), 121 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/char/inter.c b/src/char/inter.c index 4f49dab7d..a70a81eb0 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -67,7 +67,7 @@ int party_share_level = 10; // recv. packet list static int inter_recv_packet_length[] = { - -1, 0, 0, 0, -1,13,36, (2 + 4 + 4 + 4 + NAME_LENGTH), 0, 0, 0, 0, 0, 0, 0, 0, // 3000- + 0, 0, 0, 0, -1,13,36, (2 + 4 + 4 + 4 + NAME_LENGTH), 0, 0, 0, 0, 0, 0, 0, 0, // 3000- 6,-1, 6,-1, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010- Account Storage, Achievements [Smokexyz] -1,10,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020- Party -1, 6,-1,-1, 55,23, 6,-1, 14,-1,-1,-1, 18,19,186,-1, // 3030- @@ -1035,7 +1035,6 @@ static int inter_parse_frommap(int fd) return 2; switch(cmd) { - case 0x3000: mapif->parse_broadcast(fd); break; case 0x3004: mapif->parse_Registry(fd); break; case 0x3005: mapif->parse_RegistryRequest(fd); break; case 0x3006: mapif->parse_NameChangeRequest(fd); break; diff --git a/src/char/mapif.c b/src/char/mapif.c index 7e29727c7..a2e7499d9 100644 --- a/src/char/mapif.c +++ b/src/char/mapif.c @@ -2034,27 +2034,6 @@ static void mapif_parse_accinfo(int fd) inter->accinfo(u_fd, aid, castergroup, query, fd); } -// broadcast sending -static int mapif_broadcast(const unsigned char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd) -{ - unsigned char *buf = (unsigned char*)aMalloc((len)*sizeof(unsigned char)); - - nullpo_ret(mes); - Assert_ret(len >= 16); - WBUFW(buf, 0) = 0x3800; - WBUFW(buf, 2) = len; - WBUFL(buf, 4) = fontColor; - WBUFW(buf, 8) = fontType; - WBUFW(buf, 10) = fontSize; - WBUFW(buf, 12) = fontAlign; - WBUFW(buf, 14) = fontY; - memcpy(WBUFP(buf, 16), mes, len - 16); - mapif->sendallwos(sfd, buf, len); - - aFree(buf); - return 0; -} - #if 0 // Account registry transfer to map-server static void mapif_account_reg(int fd, unsigned char *src) @@ -2086,13 +2065,6 @@ static int mapif_disconnectplayer(int fd, int account_id, int char_id, int reaso return 0; } -// broadcast sending -static int mapif_parse_broadcast(int fd) -{ - mapif->broadcast(RFIFOP(fd, 16), RFIFOW(fd, 2), RFIFOL(fd, 4), RFIFOW(fd, 8), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), fd); - return 0; -} - // Save account_reg into sql (type=2) static int mapif_parse_Registry(int fd) { @@ -2528,10 +2500,8 @@ void mapif_defaults(void) mapif->itembound_ack = mapif_itembound_ack; mapif->parse_ItemBoundRetrieve = mapif_parse_ItemBoundRetrieve; mapif->parse_accinfo = mapif_parse_accinfo; - mapif->broadcast = mapif_broadcast; mapif->account_reg_reply = mapif_account_reg_reply; mapif->disconnectplayer = mapif_disconnectplayer; - mapif->parse_broadcast = mapif_parse_broadcast; mapif->parse_Registry = mapif_parse_Registry; mapif->parse_RegistryRequest = mapif_parse_RegistryRequest; mapif->namechange_ack = mapif_namechange_ack; diff --git a/src/char/mapif.h b/src/char/mapif.h index 1b83243eb..284be6a19 100644 --- a/src/char/mapif.h +++ b/src/char/mapif.h @@ -181,10 +181,8 @@ struct mapif_interface { int (*itembound_ack) (int fd, int aid, int guild_id); void (*parse_ItemBoundRetrieve) (int fd); void (*parse_accinfo) (int fd); - int (*broadcast) (const unsigned char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd); int (*account_reg_reply) (int fd,int account_id,int char_id, int type); int (*disconnectplayer) (int fd, int account_id, int char_id, int reason); - int (*parse_broadcast) (int fd); int (*parse_Registry) (int fd); int (*parse_RegistryRequest) (int fd); void (*namechange_ack) (int fd, int account_id, int char_id, int type, int flag, const char *name); diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 3bdc43875..22969606d 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1107,8 +1107,10 @@ ACMD(kami) sscanf(message, "%199[^\n]", atcmd_output); if (stristr(info->command, "l") != NULL) clif->broadcast(&sd->bl, atcmd_output, (int)strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); + else if (info->command[4] == 'b' || info->command[4] == 'B') + clif->broadcast(NULL, atcmd_output, (int)strlen(atcmd_output) + 1, BC_BLUE, ALL_CLIENT); else - intif->broadcast(atcmd_output, (int)strlen(atcmd_output) + 1, (*(info->command + 4) == 'b' || *(info->command + 4) == 'B') ? BC_BLUE : BC_YELLOW); + clif->broadcast(NULL, atcmd_output, (int)strlen(atcmd_output) + 1, BC_YELLOW, ALL_CLIENT); } else { if(!*message || (sscanf(message, "%10u %199[^\n]", &color, atcmd_output) < 2)) { clif->message(fd, msg_fd(fd,981)); // Please enter color and message (usage: @kamic ). @@ -1119,7 +1121,7 @@ ACMD(kami) clif->message(fd, msg_fd(fd,982)); // Invalid color. return false; } - intif->broadcast2(atcmd_output, (int)strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0); + clif->broadcast2(NULL, atcmd_output, (int)strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0, ALL_CLIENT); } return true; } @@ -5125,7 +5127,7 @@ ACMD(broadcast) } safesnprintf(atcmd_output, sizeof(atcmd_output), "%s: %s", sd->status.name, message); - intif->broadcast(atcmd_output, (int)strlen(atcmd_output) + 1, BC_DEFAULT); + clif->broadcast(NULL, atcmd_output, (int)strlen(atcmd_output) + 1, BC_DEFAULT, ALL_CLIENT); return true; } diff --git a/src/map/intif.c b/src/map/intif.c index 7a87d3639..ba79a024b 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -153,65 +153,6 @@ static int intif_rename(struct map_session_data *sd, int type, const char *name) return 0; } -// GM Send a message -static int intif_broadcast(const char *mes, int len, int type) -{ - int lp = (type&BC_COLOR_MASK) ? 4 : 0; - - nullpo_ret(mes); - Assert_ret(len < 32000); - // Send to the local players - clif->broadcast(NULL, mes, len, type, ALL_CLIENT); - - if (intif->CheckForCharServer()) - return 0; - - if (chrif->other_mapserver_count < 1) - return 0; //No need to send. - - WFIFOHEAD(inter_fd, 16 + lp + len); - WFIFOW(inter_fd,0) = 0x3000; - WFIFOW(inter_fd,2) = 16 + lp + len; - WFIFOL(inter_fd,4) = 0xFF000000; // 0xFF000000 color signals standard broadcast - WFIFOW(inter_fd,8) = 0; // fontType not used with standard broadcast - WFIFOW(inter_fd,10) = 0; // fontSize not used with standard broadcast - WFIFOW(inter_fd,12) = 0; // fontAlign not used with standard broadcast - WFIFOW(inter_fd,14) = 0; // fontY not used with standard broadcast - if (type&BC_BLUE) - WFIFOL(inter_fd,16) = 0x65756c62; //If there's "blue" at the beginning of the message, game client will display it in blue instead of yellow. - else if (type&BC_WOE) - WFIFOL(inter_fd,16) = 0x73737373; //If there's "ssss", game client will recognize message as 'WoE broadcast'. - memcpy(WFIFOP(inter_fd,16 + lp), mes, len); - WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); - return 0; -} - -static int intif_broadcast2(const char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY) -{ - nullpo_ret(mes); - Assert_ret(len < 32000); - // Send to the local players - clif->broadcast2(NULL, mes, len, fontColor, fontType, fontSize, fontAlign, fontY, ALL_CLIENT); - - if (intif->CheckForCharServer()) - return 0; - - if (chrif->other_mapserver_count < 1) - return 0; //No need to send. - - WFIFOHEAD(inter_fd, 16 + len); - WFIFOW(inter_fd,0) = 0x3000; - WFIFOW(inter_fd,2) = 16 + len; - WFIFOL(inter_fd,4) = fontColor; - WFIFOW(inter_fd,8) = fontType; - WFIFOW(inter_fd,10) = fontSize; - WFIFOW(inter_fd,12) = fontAlign; - WFIFOW(inter_fd,14) = fontY; - memcpy(WFIFOP(inter_fd,16), mes, len); - WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); - return 0; -} - //Request for saving registry values. static int intif_saveregistry(struct map_session_data *sd) { @@ -2730,12 +2671,6 @@ static int intif_parse(int fd) } // Processing branch switch(cmd){ - case 0x3800: - if (RFIFOL(fd,4) == 0xFF000000) //Normal announce. - clif->broadcast(NULL, RFIFOP(fd,16), packet_len-16, BC_DEFAULT, ALL_CLIENT); - else //Color announce. - clif->broadcast2(NULL, RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT); - break; case 0x3804: intif->pRegisters(fd); break; case 0x3805: intif->pAccountStorage(fd); break; case 0x3806: intif->pChangeNameOk(fd); break; @@ -2840,7 +2775,7 @@ static int intif_parse(int fd) void intif_defaults(void) { const int packet_len_table [INTIF_PACKET_LEN_TABLE_SIZE] = { - -1, 0, 0, 0, -1,-1,37,-1, 7, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f + 0, 0, 0, 0, -1,-1,37,-1, 7, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f -1, 0, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810 Achievements [Smokexyz/Hercules] 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820 10,-1,15, 0, 79,25, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830 @@ -2860,8 +2795,6 @@ void intif_defaults(void) /* funcs */ intif->parse = intif_parse; intif->create_pet = intif_create_pet; - intif->broadcast = intif_broadcast; - intif->broadcast2 = intif_broadcast2; intif->saveregistry = intif_saveregistry; intif->request_registry = intif_request_registry; intif->request_account_storage = intif_request_account_storage; diff --git a/src/map/intif.h b/src/map/intif.h index 8f8cefbee..134c7a97e 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -60,8 +60,6 @@ struct intif_interface { int (*parse) (int fd); int (*create_pet)(int account_id, int char_id, int pet_type, int pet_lv, int pet_egg_id, int pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name); - int (*broadcast) (const char *mes, int len, int type); - int (*broadcast2) (const char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY); int (*saveregistry) (struct map_session_data *sd); int (*request_registry) (struct map_session_data *sd, int flag); void (*request_account_storage) (const struct map_session_data *sd); diff --git a/src/map/pc.c b/src/map/pc.c index 827619be8..8c7663d54 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -10990,7 +10990,7 @@ static int map_day_timer(int tid, int64 tick, int id, intptr_t data) map->night_flag = 0; // 0=day, 1=night [Yor] map->foreachpc(pc->daynight_timer_sub); safestrncpy(tmp_soutput, (data == 0) ? msg_txt(502) : msg_txt(60), sizeof(tmp_soutput)); // The day has arrived! - intif->broadcast(tmp_soutput, (int)strlen(tmp_soutput) + 1, BC_DEFAULT); + clif->broadcast(NULL, tmp_soutput, (int)strlen(tmp_soutput) + 1, BC_DEFAULT, ALL_CLIENT); return 0; } @@ -11011,7 +11011,7 @@ static int map_night_timer(int tid, int64 tick, int id, intptr_t data) map->night_flag = 1; // 0=day, 1=night [Yor] map->foreachpc(pc->daynight_timer_sub); safestrncpy(tmp_soutput, (data == 0) ? msg_txt(503) : msg_txt(59), sizeof(tmp_soutput)); // The night has fallen... - intif->broadcast(tmp_soutput, (int)strlen(tmp_soutput) + 1, BC_DEFAULT); + clif->broadcast(NULL, tmp_soutput, (int)strlen(tmp_soutput) + 1, BC_DEFAULT, ALL_CLIENT); return 0; } diff --git a/src/map/script.c b/src/map/script.c index f515d4403..20fb7ae27 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11912,12 +11912,12 @@ static BUILDIN(announce) int fontAlign = script_hasdata(st,7) ? script_getnum(st,7) : 0; // default fontAlign int fontY = script_hasdata(st,8) ? script_getnum(st,8) : 0; // default fontY size_t len = strlen(mes); + send_target target = ALL_CLIENT; + struct block_list *bl = NULL; Assert_retr(false, len < INT_MAX); if( flag&(BC_TARGET_MASK|BC_SOURCE_MASK) ) { // Broadcast source or broadcast region defined - send_target target; - struct block_list *bl = NULL; if (flag&BC_NPC) { // If bc_npc flag is set, use NPC as broadcast source bl = map->id2bl(st->oid); @@ -11935,17 +11935,13 @@ static BUILDIN(announce) case BC_SELF: target = SELF; break; default: target = ALL_CLIENT; break; // BC_ALL } - - if (fontColor) - clif->broadcast2(bl, mes, (int)len+1, (unsigned int)strtoul(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY, target); - else - clif->broadcast(bl, mes, (int)len+1, flag&BC_COLOR_MASK, target); - } else { - if (fontColor) - intif->broadcast2(mes, (int)len+1, (unsigned int)strtoul(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY); - else - intif->broadcast(mes, (int)len+1, flag&BC_COLOR_MASK); } + + if (fontColor) + clif->broadcast2(bl, mes, (int)len+1, (unsigned int)strtoul(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY, target); + else + clif->broadcast(bl, mes, (int)len+1, flag&BC_COLOR_MASK, target); + return true; } /*========================================== -- cgit v1.2.3-70-g09d2