From 8cc96fc6a97376a020b31fbb16196e3476f79ec5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 20 Jan 2015 16:38:41 +0300 Subject: map: add support for sending npc activate distance to client --- src/map/clif.c | 28 +++++++++++++++++++++++++++- src/map/send.c | 22 +++++++++++++++++++--- src/map/send.h | 3 +++ 3 files changed, 49 insertions(+), 4 deletions(-) (limited to 'src/map') diff --git a/src/map/clif.c b/src/map/clif.c index 3c6675e..d0634bd 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -218,7 +218,31 @@ int eclif_send_actual(int *fd, void *buf, int *len) return 0; if (data->clientVersion < 3) { // not sending new packets to old clients - ShowWarning("skip packet %d\n", packet); +// ShowWarning("skip packet %d\n", packet); + hookStop(); + return 0; + } + } + if (packet >= 0xb03 && packet <= 0xb0a) + { + struct SessionExt *data = session_get(*fd); + if (!data) + return 0; + if (data->clientVersion < 4) + { // not sending new packets to old clients +// ShowWarning("skip packet %d\n", packet); + hookStop(); + return 0; + } + } + if (packet == 0xb0b) + { + struct SessionExt *data = session_get(*fd); + if (!data) + return 0; + if (data->clientVersion < 5) + { // not sending new packets to old clients +// ShowWarning("skip packet %d\n", packet); hookStop(); return 0; } @@ -237,6 +261,8 @@ void eclif_set_unit_idle_post(struct block_list* bl, struct map_session_data *ts send_mob_info(bl, &tsd->bl, *target); else if (bl->type == BL_PC) send_pc_info(bl, &tsd->bl, *target); + else if (bl->type == BL_NPC) + send_npc_info(bl, &tsd->bl, *target); } void eclif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, diff --git a/src/map/send.c b/src/map/send.c index aa03de0..98772ff 100644 --- a/src/map/send.c +++ b/src/map/send.c @@ -11,6 +11,7 @@ #include "../../../common/socket.h" #include "../../../common/strlib.h" #include "../../../map/mob.h" +#include "../../../map/npc.h" #include "../../../map/pc.h" #include "../../../map/unit.h" @@ -134,12 +135,9 @@ void send_pc_info(struct block_list* bl1, return; struct map_session_data *sd = (struct map_session_data *)bl1; - struct SessionExt *data = session_get_bysd(sd); if (!data) return; - if (data->clientVersion < 4) - return; WBUFW (buf, 0) = 0xb0a; WBUFW (buf, 2) = 12; // len @@ -152,6 +150,24 @@ void send_pc_info(struct block_list* bl1, clif->send(&buf, sizeof(buf), bl2, target); } +void send_npc_info(struct block_list* bl1, + struct block_list* bl2, + enum send_target target) +{ + if (!bl1 || bl1->type != BL_NPC) + return; + + TBL_NPC *const nd = (TBL_NPC*)bl1; + + char buf[12]; + WBUFW (buf, 0) = 0xb0b; + WBUFW (buf, 2) = 12; // len + WBUFL (buf, 4) = nd->bl.id; + WBUFL (buf, 8) = nd->area_size; + + clif->send(&buf, sizeof(buf), bl2, target); +} + void send_advmoving(struct unit_data* ud, struct block_list *tbl, enum send_target target) { if (!ud) diff --git a/src/map/send.h b/src/map/send.h index e7bdd2a..0c6bb9c 100644 --- a/src/map/send.h +++ b/src/map/send.h @@ -18,5 +18,8 @@ void send_join_ack(int fd, const char *const name, int flag); void send_pc_info(struct block_list* bl1, struct block_list* bl2, enum send_target target); +void send_npc_info(struct block_list* bl1, + struct block_list* bl2, + enum send_target target); #endif // EVOL_MAP_PC -- cgit v1.2.3-70-g09d2