diff options
author | Andrei Karas <akaras@inbox.ru> | 2018-11-06 00:50:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2018-11-14 06:00:50 +0300 |
commit | 27fb22d9f492cffe206594e5af0f854cf8fa3ce5 (patch) | |
tree | 4772665b8623529df9a048e24a9bbd858b406e4c /src/map | |
parent | a9caa4ea37115869eb3926ca6e4c53709e7d9337 (diff) | |
download | hercules-27fb22d9f492cffe206594e5af0f854cf8fa3ce5.tar.gz hercules-27fb22d9f492cffe206594e5af0f854cf8fa3ce5.tar.bz2 hercules-27fb22d9f492cffe206594e5af0f854cf8fa3ce5.tar.xz hercules-27fb22d9f492cffe206594e5af0f854cf8fa3ce5.zip |
Use new packet tables for packets len.
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 9 | ||||
-rw-r--r-- | src/map/clif.c | 14 | ||||
-rw-r--r-- | src/map/clif.h | 3 |
3 files changed, 14 insertions, 12 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index d65af9dd1..e6f022a10 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -263,12 +263,15 @@ ACMD(send) if (len) { // show packet length - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, clif->packet(type)->len); // Packet 0x%x length: %d + Assert_retr(false, type <= MAX_PACKET_DB && type >= MIN_PACKET_DB); + len = packets->db[type]; + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, len); // Packet 0x%x length: %d clif->message(fd, atcmd_output); return true; } - len = clif->packet(type)->len; + Assert_retr(false, type <= MAX_PACKET_DB && type >= MIN_PACKET_DB); + len = packets->db[type]; if (len == -1) { // dynamic packet @@ -416,7 +419,7 @@ ACMD(send) SKIP_VALUE(message); } - if (clif->packet(type)->len == -1) { // send dynamic packet + if (packets->db[type] == -1) { // send dynamic packet WFIFOW(sd->fd,2)=TOW(off); WFIFOSET(sd->fd,off); } else {// send static packet diff --git a/src/map/clif.c b/src/map/clif.c index 6d21e8e0e..d4c378f27 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -18468,7 +18468,7 @@ static void clif_parse_debug(int fd, struct map_session_data *sd) cmd = RFIFOW(fd,0); if( sd ) { - packet_len = packet_db[cmd].len; + packet_len = packets->db[cmd]; if( packet_len == -1 ) {// variable length packet_len = RFIFOW(fd,2); // clif_parse ensures, that this amount of data is already received @@ -18897,7 +18897,7 @@ static void clif_parse_dull(int fd, struct map_session_data *sd) const int cmd = clif->cmd; Assert_retv(cmd <= MAX_PACKET_DB && cmd >= MIN_PACKET_DB); - int packet_len = packet_db[cmd].len; + int packet_len = packets->db[cmd]; if (packet_len == -1) { // variable-length packet packet_len = RFIFOW(fd, 2); } @@ -20526,7 +20526,7 @@ static unsigned short clif_parse_cmd_optional(int fd, struct map_session_data *s unsigned short cmd = RFIFOW(fd,0); // filter out invalid / unsupported packets - if( cmd > MAX_PACKET_DB || cmd < MIN_PACKET_DB || packet_db[cmd].len == 0 ) { + if( cmd > MAX_PACKET_DB || cmd < MIN_PACKET_DB || packets->db[cmd] == 0 ) { if( sd ) sd->parse_cmd_func = clif_parse_cmd_decrypt; return clif_parse_cmd_decrypt(fd, sd); @@ -22045,7 +22045,7 @@ static int clif_parse(int fd) } // filter out invalid / unsupported packets - if (cmd > MAX_PACKET_DB || cmd < MIN_PACKET_DB || packet_db[cmd].len == 0) { + if (cmd > MAX_PACKET_DB || cmd < MIN_PACKET_DB || packets->db[cmd] == 0) { ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x (0x%04x), %"PRIuS" bytes received), disconnecting session #%d.\n", (unsigned int)cmd, RFIFOW(fd,0), RFIFOREST(fd), fd); #ifdef DUMP_INVALID_PACKET @@ -22056,7 +22056,7 @@ static int clif_parse(int fd) } // determine real packet length - if ( ( packet_len = packet_db[cmd].len ) == -1) { // variable-length packet + if ((packet_len = packets->db[cmd]) == -1) { // variable-length packet if (RFIFOREST(fd) < 4) return 0; @@ -22145,7 +22145,7 @@ static int clif_parse(int fd) */ static const struct s_packet_db *clif_packet(int packet_id) { - if (packet_id < MIN_PACKET_DB || packet_id > MAX_PACKET_DB || packet_db[packet_id].len == 0) + if (packet_id < MIN_PACKET_DB || packet_id > MAX_PACKET_DB || packets->db[packet_id] == 0) return NULL; return &packet_db[packet_id]; } @@ -22167,7 +22167,7 @@ static void __attribute__ ((unused)) packetdb_addpacket(short cmd, int len, ...) return; } - packet_db[cmd].len = len; +// packet_db[cmd].len = len; va_start(va,len); diff --git a/src/map/clif.h b/src/map/clif.h index b76c5ed70..593dc15c1 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -64,7 +64,7 @@ enum rodex_get_items; /** * Defines **/ -#define packet_len(cmd) packet_db[cmd].len +#define packet_len(cmd) packets->db[cmd] #define clif_menuskill_clear(sd) ((sd)->menuskill_id = (sd)->menuskill_val = (sd)->menuskill_val2 = 0) #define clif_disp_onlyself(sd, mes) clif->disp_message(&(sd)->bl, (mes), SELF) #define MAX_ROULETTE_LEVEL 7 /** client-defined value **/ @@ -626,7 +626,6 @@ enum inventory_type { **/ typedef void (*pFunc)(int, struct map_session_data *); //cant help but put it first struct s_packet_db { - short len; pFunc func; short pos[MAX_PACKET_POS]; }; |