summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/parse.c22
-rw-r--r--src/map/parse.h1
-rw-r--r--src/map/send.c11
-rw-r--r--src/map/send.h5
5 files changed, 32 insertions, 8 deletions
diff --git a/src/map/init.c b/src/map/init.c
index 2b58fc5..c5ed8eb 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -114,6 +114,7 @@ HPExport void plugin_init (void)
addPacket(0xb0f, 2, map_parse_get_online_list, hpClif_Parse);
addPacket(0xb11, 10, map_parse_pet_move, hpClif_Parse);
addPacket(0xb12, 9, map_parse_pet_dir, hpClif_Parse);
+ addPacket(0xb13, -1, map_parse_homun_say, hpClif_Parse);
addHookPre("pc->readparam", epc_readparam_pre);
addHookPre("pc->setregistry", epc_setregistry);
diff --git a/src/map/parse.c b/src/map/parse.c
index 97aac6f..ba73516 100644
--- a/src/map/parse.c
+++ b/src/map/parse.c
@@ -12,6 +12,8 @@
#include "../../../common/strlib.h"
#include "../../../map/channel.h"
#include "../../../map/clif.h"
+#include "../../../map/homunculus.h"
+#include "../../../map/mercenary.h"
#include "../../../map/pc.h"
#include "../../../map/pet.h"
#include "../../../map/unit.h"
@@ -110,11 +112,14 @@ void map_parse_pet_say(int fd)
char message[500];
struct map_session_data* sd = (struct map_session_data*)session[fd]->session_data;
+ if (!sd || !sd->pd)
+ return;
+
const int len = RFIFOW(fd, 2);
if (len > 500 || len < 6)
return;
safestrncpy(message, (char*)RFIFOP(fd, 4), len - 4);
- send_pet_say(sd, message);
+ send_slave_say(sd, &sd->pd->bl, sd->pd->pet.name, message);
}
void map_parse_pet_emote(int fd)
@@ -166,3 +171,18 @@ void map_parse_pet_dir(int fd)
return;
unit->setdir(&sd->pd->bl, RFIFOB(fd, 8));
}
+
+void map_parse_homun_say(int fd)
+{
+ char message[500];
+
+ struct map_session_data* sd = (struct map_session_data*)session[fd]->session_data;
+ const int len = RFIFOW(fd, 2);
+ if (len > 500 || len < 6)
+ return;
+ safestrncpy(message, (char*)RFIFOP(fd, 4), len - 4);
+ if (sd->md && sd->md->db)
+ send_slave_say(sd, &sd->md->bl, sd->md->db->name, message);
+ else if (sd->hd && homun_alive(sd->hd))
+ send_slave_say(sd, &sd->hd->bl, sd->hd->homunculus.name, message);
+}
diff --git a/src/map/parse.h b/src/map/parse.h
index 8db1fca..d59fd87 100644
--- a/src/map/parse.h
+++ b/src/map/parse.h
@@ -13,5 +13,6 @@ void map_parse_set_status(int fd);
void map_parse_get_online_list(int fd);
void map_parse_pet_move(int fd);
void map_parse_pet_dir(int fd);
+void map_parse_homun_say(int fd);
#endif // EVOL_MAP_PARSE
diff --git a/src/map/send.c b/src/map/send.c
index 61522ac..c2e79fc 100644
--- a/src/map/send.c
+++ b/src/map/send.c
@@ -261,19 +261,18 @@ void send_join_ack(int fd, const char *const name, int flag)
WFIFOSET (fd, 27);
}
-void send_pet_say(struct map_session_data *sd, const char *const message)
+void send_slave_say(struct map_session_data *sd,
+ struct block_list *bl,
+ const char *const name,
+ const char *const message)
{
- if (!sd || !sd->pd || !message)
- return;
-
- const char *const name = sd->pd->pet.name;
const int len = 24 + 7 + strlen(message);
char *buf = NULL;
CREATE(buf, char, len);
snprintf(buf, len, "%s's %s : %s", sd->status.name, name, message);
buf[len - 1] = 0;
- clif->GlobalMessage(&sd->pd->bl, buf);
+ clif->GlobalMessage(bl, buf);
aFree(buf);
}
diff --git a/src/map/send.h b/src/map/send.h
index 54bd844..0e18ff2 100644
--- a/src/map/send.h
+++ b/src/map/send.h
@@ -21,7 +21,10 @@ void send_pc_info(struct block_list* bl1,
void send_npc_info(struct block_list* bl1,
struct block_list* bl2,
enum send_target target);
-void send_pet_say(struct map_session_data *sd, const char *const message);
+void send_slave_say(struct map_session_data *sd,
+ struct block_list *bl,
+ const char *const name,
+ const char *const message);
void send_pet_emote(struct map_session_data *sd, const int emote);
void send_online_list(int fd, const char *buf, unsigned size);