From 2af8281a53ea7bdc02a9750388aebbae1fa73f4e Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 25 Aug 2019 17:34:19 +0200 Subject: Remove whisper dispatch code from the inter server The code was currently not in use (assuming the only officially supported case of a single-zone server) Signed-off-by: Haru --- src/char/inter.c | 89 +------------------------------------ src/char/inter.h | 11 ----- src/char/mapif.c | 109 ---------------------------------------------- src/char/mapif.h | 6 --- src/common/HPMDataCheck.h | 1 - src/map/clif.c | 8 +--- src/map/intif.c | 105 +------------------------------------------- src/map/intif.h | 3 -- 8 files changed, 4 insertions(+), 328 deletions(-) diff --git a/src/char/inter.c b/src/char/inter.c index 64c840c16..53bcd6de1 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -53,9 +53,6 @@ #include #include -#define WISDATA_TTL (60*1000) // Wis data Time To Live (60 seconds) -#define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis - static struct inter_interface inter_s; struct inter_interface *inter; @@ -70,7 +67,7 @@ int party_share_level = 10; // recv. packet list static int inter_recv_packet_length[] = { - -1,-1, 7,-1, -1,13,36, (2 + 4 + 4 + 4 + NAME_LENGTH), 0, 0, 0, 0, 0, 0, 0, 0, // 3000- + -1, 0, 0,-1, -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- @@ -82,9 +79,6 @@ static int inter_recv_packet_length[] = { -1,10,-1, 6, 0, 20,10,20, -1,6 + NAME_LENGTH, 0, 0, 0, 0, 0, 0, // 3090- Homunculus packets [albator], RoDEX packets }; -static struct DBMap *wis_db = NULL; // int wis_id -> struct WisData* -static int wis_dellist[WISDELLIST_MAX], wis_delnum; - #define MAX_JOB_NAMES 150 static char *msg_table[MAX_JOB_NAMES]; // messages 550 ~ 699 are job names @@ -964,7 +958,6 @@ static int inter_init_sql(const char *file) Sql_ShowDebug(inter->sql_handle); } - wis_db = idb_alloc(DB_OPT_RELEASE_DATA); inter_guild->sql_init(); inter_storage->sql_init(); inter_party->sql_init(); @@ -985,8 +978,6 @@ static int inter_init_sql(const char *file) // finalize static void inter_final(void) { - wis_db->destroy(wis_db, NULL); - inter_guild->sql_final(); inter_storage->sql_final(); inter_party->sql_final(); @@ -1011,77 +1002,6 @@ static int inter_mapif_init(int fd) //-------------------------------------------------------- -/** - * Existence check of WISP data - * @see DBApply - */ -static int inter_check_ttl_wisdata_sub(union DBKey key, struct DBData *data, va_list ap) -{ - int64 tick; - struct WisData *wd = DB->data2ptr(data); - nullpo_ret(wd); - tick = va_arg(ap, int64); - - if (DIFF_TICK(tick, wd->tick) > WISDATA_TTL && wis_delnum < WISDELLIST_MAX) - wis_dellist[wis_delnum++] = wd->id; - - return 0; -} - -static int inter_check_ttl_wisdata(void) -{ - int64 tick = timer->gettick(); - int i; - - do { - wis_delnum = 0; - wis_db->foreach(wis_db, inter->check_ttl_wisdata_sub, tick); - for(i = 0; i < wis_delnum; i++) { - struct WisData *wd = (struct WisData*)idb_get(wis_db, wis_dellist[i]); - ShowWarning("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst); - // removed. not send information after a timeout. Just no answer for the player - //mapif->wis_end(wd, 1); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target - idb_remove(wis_db, wd->id); - } - } while(wis_delnum >= WISDELLIST_MAX); - - return 0; -} - -static struct WisData *inter_add_wisdata(int fd, const unsigned char *src, const unsigned char *dst, const unsigned char *msg, int msg_len) -{ - static int wisid = 0; - struct WisData *wd; - - CREATE(wd, struct WisData, 1); - - // Whether the failure of previous wisp/page transmission (timeout) - inter->check_ttl_wisdata(); - - wd->id = ++wisid; - wd->fd = fd; - wd->len = msg_len; - memcpy(wd->src, src, NAME_LENGTH); - memcpy(wd->dst, dst, NAME_LENGTH); - memcpy(wd->msg, msg, wd->len); - wd->tick = timer->gettick(); - idb_put(wis_db, wd->id, wd); - - return wd; -} - -static struct WisData *inter_get_wisdata(int id) -{ - return idb_get(wis_db, id); -} - -static void inter_remove_wisdata(int id) -{ - idb_remove(wis_db, id); -} - -//-------------------------------------------------------- - /// Returns the length of the next complete packet to process, /// or 0 if no complete packet exists in the queue. /// @@ -1116,8 +1036,6 @@ static int inter_parse_frommap(int fd) switch(cmd) { case 0x3000: mapif->parse_broadcast(fd); break; - case 0x3001: mapif->parse_WisRequest(fd); break; - case 0x3002: mapif->parse_WisReply(fd); break; case 0x3003: mapif->parse_WisToGM(fd); break; case 0x3004: mapif->parse_Registry(fd); break; case 0x3005: mapif->parse_RegistryRequest(fd); break; @@ -1167,8 +1085,6 @@ void inter_defaults(void) inter->log = inter_log; inter->init_sql = inter_init_sql; inter->mapif_init = inter_mapif_init; - inter->check_ttl_wisdata_sub = inter_check_ttl_wisdata_sub; - inter->check_ttl_wisdata = inter_check_ttl_wisdata; inter->check_length = inter_check_length; inter->parse_frommap = inter_parse_frommap; inter->final = inter_final; @@ -1176,7 +1092,4 @@ void inter_defaults(void) inter->config_read_connection = inter_config_read_connection; inter->accinfo = inter_accinfo; inter->accinfo2 = inter_accinfo2; - inter->add_wisdata = inter_add_wisdata; - inter->get_wisdata = inter_get_wisdata; - inter->remove_wisdata = inter_remove_wisdata; } diff --git a/src/char/inter.h b/src/char/inter.h index 94ee3ab60..f97c619c0 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -30,12 +30,6 @@ struct Sql; // common/sql.h struct config_t; // common/conf.h -struct WisData { - int id, fd, count, len; - int64 tick; - unsigned char src[24], dst[24], msg[512]; -}; - /** * inter interface **/ @@ -54,8 +48,6 @@ struct inter_interface { int (*log) (char* fmt, ...); int (*init_sql) (const char *file); int (*mapif_init) (int fd); - int (*check_ttl_wisdata_sub) (union DBKey key, struct DBData *data, va_list ap); - int (*check_ttl_wisdata) (void); int (*check_length) (int fd, int length); int (*parse_frommap) (int fd); void (*final) (void); @@ -66,9 +58,6 @@ struct inter_interface { void (*accinfo2) (bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state); - struct WisData *(*add_wisdata) (int fd, const unsigned char *src, const unsigned char *dst, const unsigned char *msg, int msg_len); - struct WisData *(*get_wisdata) (int id); - void (*remove_wisdata) (int id); }; #ifdef HERCULES_CORE diff --git a/src/char/mapif.c b/src/char/mapif.c index 8f213ecb5..89cd358ec 100644 --- a/src/char/mapif.c +++ b/src/char/mapif.c @@ -2055,46 +2055,6 @@ static int mapif_broadcast(const unsigned char *mes, int len, unsigned int fontC return 0; } -// Wis sending -static int mapif_wis_message(struct WisData *wd) -{ - unsigned char buf[2048]; - nullpo_ret(wd); - //if (wd->len > 2047-56) wd->len = 2047-56; //Force it to fit to avoid crashes. [Skotlex] - if (wd->len < 0) - wd->len = 0; - if (wd->len >= (int)sizeof(wd->msg) - 1) - wd->len = (int)sizeof(wd->msg) - 1; - - WBUFW(buf, 0) = 0x3801; - WBUFW(buf, 2) = 56 + wd->len; - WBUFL(buf, 4) = wd->id; - memcpy(WBUFP(buf, 8), wd->src, NAME_LENGTH); - memcpy(WBUFP(buf, 32), wd->dst, NAME_LENGTH); - memcpy(WBUFP(buf, 56), wd->msg, wd->len); - wd->count = mapif->sendall(buf, WBUFW(buf, 2)); - - return 0; -} - -static void mapif_wis_response(int fd, const unsigned char *src, int flag) -{ - unsigned char buf[27]; - nullpo_retv(src); - WBUFW(buf, 0) = 0x3802; - memcpy(WBUFP(buf, 2), src, 24); - WBUFB(buf, 26) = flag; - mapif->send(fd, buf, 27); -} - -// Wis sending result -static int mapif_wis_end(struct WisData *wd, int flag) -{ - nullpo_ret(wd); - mapif->wis_response(wd->fd, wd->src, flag); - return 0; -} - #if 0 // Account registry transfer to map-server static void mapif_account_reg(int fd, unsigned char *src) @@ -2133,70 +2093,6 @@ static int mapif_parse_broadcast(int fd) return 0; } -// Wisp/page request to send -static int mapif_parse_WisRequest(int fd) -{ - struct WisData* wd; - char name[NAME_LENGTH]; - char *data; - size_t len; - - if (fd <= 0) // check if we have a valid fd - return 0; - - if (RFIFOW(fd, 2) - 52 >= sizeof(wd->msg)) { - ShowWarning("inter: Wis message size too long.\n"); - return 0; - } else if (RFIFOW(fd, 2) - 52 <= 0) { // normally, impossible, but who knows... - ShowError("inter: Wis message doesn't exist.\n"); - return 0; - } - - safestrncpy(name, RFIFOP(fd, 28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex] - - // search if character exists before to ask all map-servers - if (!chr->name_exists(name, NULL)) { - mapif->wis_response(fd, RFIFOP(fd, 4), 1); - } else { - // Character exists. So, ask all map-servers - - // to be sure of the correct name, rewrite it - SQL->GetData(inter->sql_handle, 0, &data, &len); - memset(name, 0, NAME_LENGTH); - memcpy(name, data, min(len, NAME_LENGTH)); - // if source is destination, don't ask other servers. - if (strncmp(RFIFOP(fd, 4), name, NAME_LENGTH) == 0) { - mapif->wis_response(fd, RFIFOP(fd, 4), 1); - } else { - wd = inter->add_wisdata(fd, RFIFOP(fd, 4), RFIFOP(fd, 28), RFIFOP(fd, 52), RFIFOW(fd, 2) - 52); - mapif->wis_message(wd); - } - } - - SQL->FreeResult(inter->sql_handle); - return 0; -} - -// Wisp/page transmission result -static int mapif_parse_WisReply(int fd) -{ - int id, flag; - struct WisData *wd; - - id = RFIFOL(fd,2); - flag = RFIFOB(fd,6); - wd = inter->get_wisdata(id); - if (wd == NULL) - return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server - - if ((--wd->count) <= 0 || flag != 1) { - mapif->wis_end(wd, flag); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target - inter->remove_wisdata(id); - } - - return 0; -} - // Received wisp message from map-server for ALL gm (just copy the message and resends it to ALL map-servers) static int mapif_parse_WisToGM(int fd) { @@ -2645,14 +2541,9 @@ void mapif_defaults(void) mapif->parse_ItemBoundRetrieve = mapif_parse_ItemBoundRetrieve; mapif->parse_accinfo = mapif_parse_accinfo; mapif->broadcast = mapif_broadcast; - mapif->wis_message = mapif_wis_message; - mapif->wis_response = mapif_wis_response; - mapif->wis_end = mapif_wis_end; mapif->account_reg_reply = mapif_account_reg_reply; mapif->disconnectplayer = mapif_disconnectplayer; mapif->parse_broadcast = mapif_parse_broadcast; - mapif->parse_WisRequest = mapif_parse_WisRequest; - mapif->parse_WisReply = mapif_parse_WisReply; mapif->parse_WisToGM = mapif_parse_WisToGM; mapif->parse_Registry = mapif_parse_Registry; mapif->parse_RegistryRequest = mapif_parse_RegistryRequest; diff --git a/src/char/mapif.h b/src/char/mapif.h index 71a41f94c..7cb7e4f3f 100644 --- a/src/char/mapif.h +++ b/src/char/mapif.h @@ -23,7 +23,6 @@ #include "common/hercules.h" #include "common/mmo.h" -struct WisData; struct rodex_item; /** @@ -183,14 +182,9 @@ struct mapif_interface { 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 (*wis_message) (struct WisData *wd); - void (*wis_response) (int fd, const unsigned char *src, int flag); - int (*wis_end) (struct WisData *wd, int flag); 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_WisRequest) (int fd); - int (*parse_WisReply) (int fd); int (*parse_WisToGM) (int fd); int (*parse_Registry) (int fd); int (*parse_RegistryRequest) (int fd); diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h index d63ed7b99..1e06cf549 100644 --- a/src/common/HPMDataCheck.h +++ b/src/common/HPMDataCheck.h @@ -52,7 +52,6 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #define CHAR_GEOIP_H #endif // CHAR_GEOIP_H #ifdef CHAR_INTER_H - { "WisData", sizeof(struct WisData), SERVER_TYPE_CHAR }, { "inter_interface", sizeof(struct inter_interface), SERVER_TYPE_CHAR }, #else #define CHAR_INTER_H diff --git a/src/map/clif.c b/src/map/clif.c index 3b7691ae4..62c621324 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11581,12 +11581,8 @@ static void clif_parse_WisMessage(int fd, struct map_session_data *sd) dstsd = map->nick2sd(target); 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, - // and if we ask for 'Test', we must not contact 'test' player - // so, we send information to inter-server, which is the only one which decide (and copy correct name). - intif->wis_message(sd, target, message, (int)strlen(message)); + // Character not found (or found through partial match). + clif->wis_end(sd->fd, 1); return; } diff --git a/src/map/intif.c b/src/map/intif.c index e25f56b63..a250b22a9 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -234,52 +234,6 @@ static int intif_main_message(struct map_session_data *sd, const char *message) return 0; } -// The transmission of Wisp/Page to inter-server (player not found on this server) -static int intif_wis_message(struct map_session_data *sd, const char *nick, const char *mes, int mes_len) -{ - if (intif->CheckForCharServer()) - return 0; - nullpo_ret(sd); - nullpo_ret(nick); - nullpo_ret(mes); - - if (chrif->other_mapserver_count < 1) { - //Character not found. - clif->wis_end(sd->fd, 1); - return 0; - } - - WFIFOHEAD(inter_fd,mes_len + 52); - WFIFOW(inter_fd,0) = 0x3001; - WFIFOW(inter_fd,2) = mes_len + 52; - memcpy(WFIFOP(inter_fd,4), sd->status.name, NAME_LENGTH); - memcpy(WFIFOP(inter_fd,4+NAME_LENGTH), nick, NAME_LENGTH); - memcpy(WFIFOP(inter_fd,4+2*NAME_LENGTH), mes, mes_len); - WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); - - if (battle_config.etc_log) - ShowInfo("intif_wis_message from %s to %s (message: '%s')\n", sd->status.name, nick, mes); - - return 0; -} - -// The reply of Wisp/page -static int intif_wis_replay(int id, int flag) -{ - if (intif->CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,7); - WFIFOW(inter_fd,0) = 0x3002; - WFIFOL(inter_fd,2) = id; - WFIFOB(inter_fd,6) = flag; // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target - WFIFOSET(inter_fd,7); - - if (battle_config.etc_log) - ShowInfo("intif_wis_replay: id: %d, flag:%d\n", id, flag); - - return 0; -} - // The transmission of GM only Wisp/Page from server to inter-server static int intif_wis_message_to_gm(char *wisp_name, int permission, char *mes) { @@ -1166,58 +1120,6 @@ static int intif_homunculus_requestdelete(int homun_id) //----------------------------------------------------------------- // Packets receive from inter server -// Wisp/Page reception // rewritten by [Yor] -static void intif_parse_WisMessage(int fd) -{ - struct map_session_data* sd; - const char *wisp_source; - char name[NAME_LENGTH]; - int id, i; - - id=RFIFOL(fd,4); - - safestrncpy(name, RFIFOP(fd,32), NAME_LENGTH); - sd = map->nick2sd(name); - if(sd == NULL || strcmp(sd->status.name, name) != 0) { - //Not found - intif_wis_replay(id,1); - return; - } - if(sd->state.ignoreAll) { - intif_wis_replay(id, 2); - return; - } - wisp_source = RFIFOP(fd,8); // speed up [Yor] - for(i=0; i < MAX_IGNORE_LIST && - sd->ignore[i].name[0] != '\0' && - strcmp(sd->ignore[i].name, wisp_source) != 0 - ; i++); - - if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0') { - //Ignored - intif_wis_replay(id, 2); - return; - } - //Success to send whisper. - clif->wis_message(sd->fd, wisp_source, RFIFOP(fd,56),RFIFOW(fd,2)-57); - intif_wis_replay(id,0); // success -} - -// Wisp/page transmission result reception -static void intif_parse_WisEnd(int fd) -{ - struct map_session_data* sd; - const char *playername = RFIFOP(fd, 2); - - if (battle_config.etc_log) - ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", playername, RFIFOB(fd,26)); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target - sd = map->nick2sd(playername); - if (sd != NULL) - clif->wis_end(sd->fd, RFIFOB(fd,26)); - - return; -} - static int intif_parse_WisToGM_sub(struct map_session_data *sd, va_list va) { int permission = va_arg(va, int); @@ -2921,8 +2823,6 @@ static int intif_parse(int fd) 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 0x3801: intif->pWisMessage(fd); break; - case 0x3802: intif->pWisEnd(fd); break; case 0x3803: intif->pWisToGM(fd); break; case 0x3804: intif->pRegisters(fd); break; case 0x3805: intif->pAccountStorage(fd); break; @@ -3028,7 +2928,7 @@ static int intif_parse(int fd) void intif_defaults(void) { const int packet_len_table [INTIF_PACKET_LEN_TABLE_SIZE] = { - -1,-1,27,-1, -1,-1,37,-1, 7, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f + -1, 0, 0,-1, -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 @@ -3051,7 +2951,6 @@ void intif_defaults(void) intif->broadcast = intif_broadcast; intif->broadcast2 = intif_broadcast2; intif->main_message = intif_main_message; - intif->wis_message = intif_wis_message; intif->wis_message_to_gm = intif_wis_message_to_gm; intif->saveregistry = intif_saveregistry; intif->request_registry = intif_request_registry; @@ -3138,8 +3037,6 @@ void intif_defaults(void) intif->achievements_request = intif_achievements_request; intif->achievements_save = intif_achievements_save; /* parse functions */ - intif->pWisMessage = intif_parse_WisMessage; - intif->pWisEnd = intif_parse_WisEnd; intif->pWisToGM_sub = intif_parse_WisToGM_sub; intif->pWisToGM = intif_parse_WisToGM; intif->pRegisters = intif_parse_Registers; diff --git a/src/map/intif.h b/src/map/intif.h index 8df669217..8aab653c2 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -63,7 +63,6 @@ struct intif_interface { 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 (*main_message) (struct map_session_data* sd, const char* message); - int (*wis_message) (struct map_session_data *sd, const char *nick, const char *mes, int mes_len); int (*wis_message_to_gm) (char *Wisp_name, int permission, char *mes); int (*saveregistry) (struct map_session_data *sd); int (*request_registry) (struct map_session_data *sd, int flag); @@ -151,8 +150,6 @@ struct intif_interface { void(*achievements_request) (struct map_session_data *sd); void(*achievements_save) (struct map_session_data *sd); /* */ - void (*pWisMessage) (int fd); - void (*pWisEnd) (int fd); int (*pWisToGM_sub) (struct map_session_data* sd,va_list va); void (*pWisToGM) (int fd); void (*pRegisters) (int fd); -- cgit v1.2.3-60-g2f50