summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-08-25 17:34:19 +0200
committerHaru <haru@dotalux.com>2019-08-25 21:04:08 +0200
commit2af8281a53ea7bdc02a9750388aebbae1fa73f4e (patch)
tree3c05ffa4d39410b114a4987f4cf5e981ca951b0c /src/char
parent0edf2360b185f0e1c68bb6ddbbbe3720af5651b3 (diff)
downloadhercules-2af8281a53ea7bdc02a9750388aebbae1fa73f4e.tar.gz
hercules-2af8281a53ea7bdc02a9750388aebbae1fa73f4e.tar.bz2
hercules-2af8281a53ea7bdc02a9750388aebbae1fa73f4e.tar.xz
hercules-2af8281a53ea7bdc02a9750388aebbae1fa73f4e.zip
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 <haru@dotalux.com>
Diffstat (limited to 'src/char')
-rw-r--r--src/char/inter.c89
-rw-r--r--src/char/inter.h11
-rw-r--r--src/char/mapif.c109
-rw-r--r--src/char/mapif.h6
4 files changed, 1 insertions, 214 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 <stdio.h>
#include <stdlib.h>
-#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);