summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-02-17 13:33:56 +0300
committerAndrei Karas <akaras@inbox.ru>2015-02-17 13:33:56 +0300
commit1e21393782af0df7c528dba5a2f0a80ea0c7e4ab (patch)
tree3ff648f4638426b6401bd8a62d5d0babc65bde30 /src
parentc7a03f4a20ae7a39277417ee566211f7dd94130a (diff)
downloadevol-hercules-1e21393782af0df7c528dba5a2f0a80ea0c7e4ab.tar.gz
evol-hercules-1e21393782af0df7c528dba5a2f0a80ea0c7e4ab.tar.bz2
evol-hercules-1e21393782af0df7c528dba5a2f0a80ea0c7e4ab.tar.xz
evol-hercules-1e21393782af0df7c528dba5a2f0a80ea0c7e4ab.zip
add pet talk packet.
Changed server version to 5.
Diffstat (limited to 'src')
-rw-r--r--src/login/send.c2
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/parse.c12
-rw-r--r--src/map/parse.h1
-rw-r--r--src/map/send.c17
-rw-r--r--src/map/send.h1
6 files changed, 33 insertions, 1 deletions
diff --git a/src/login/send.c b/src/login/send.c
index 937ce85..eca884d 100644
--- a/src/login/send.c
+++ b/src/login/send.c
@@ -21,7 +21,7 @@ void send_server_version(int fd)
WFIFOW(fd, 0) = 0x7531;
WFIFOW(fd, 2) = 4 + 8;
WFIFOL(fd, 4) = 0; // unused
- WFIFOL(fd, 8) = 4; // server version
+ WFIFOL(fd, 8) = 5; // server version
WFIFOSET(fd, WFIFOW(fd,2));
}
diff --git a/src/map/init.c b/src/map/init.c
index 60d8540..0617c21 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -107,6 +107,7 @@ HPExport void plugin_init (void)
addPacket(0x7530, 22, map_parse_version, hpClif_Parse);
addPacket(0xb07, 26, map_parse_join_channel, hpClif_Parse);
addPacket(0xb09, 26, map_parse_part_channel, hpClif_Parse);
+ addPacket(0xb0c, -1, map_parse_pet_say, hpClif_Parse);
addHookPre("pc->readparam", epc_readparam_pre);
addHookPre("pc->setregistry", epc_setregistry);
addHookPre("pc->equipitem_pos", epc_equipitem_pos);
diff --git a/src/map/parse.c b/src/map/parse.c
index 2e145dc..b2d66c0 100644
--- a/src/map/parse.c
+++ b/src/map/parse.c
@@ -96,3 +96,15 @@ void map_parse_part_channel(int fd)
channel->leave(sd->channels[k], sd);
}
}
+
+void map_parse_pet_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);
+ send_pet_say(sd, message);
+}
diff --git a/src/map/parse.h b/src/map/parse.h
index dc5f020..8badfc5 100644
--- a/src/map/parse.h
+++ b/src/map/parse.h
@@ -7,5 +7,6 @@
void map_parse_version(int fd);
void map_parse_join_channel(int fd);
void map_parse_part_channel(int fd);
+void map_parse_pet_say(int fd);
#endif // EVOL_MAP_PARSE
diff --git a/src/map/send.c b/src/map/send.c
index 179e199..097622a 100644
--- a/src/map/send.c
+++ b/src/map/send.c
@@ -10,9 +10,11 @@
#include "../../../common/mmo.h"
#include "../../../common/socket.h"
#include "../../../common/strlib.h"
+#include "../../../map/clif.h"
#include "../../../map/mob.h"
#include "../../../map/npc.h"
#include "../../../map/pc.h"
+#include "../../../map/pet.h"
#include "../../../map/unit.h"
#include "map/send.h"
@@ -257,3 +259,18 @@ void send_join_ack(int fd, const char *const name, int flag)
WFIFOB (fd, 26) = flag;
WFIFOSET (fd, 27);
}
+
+void send_pet_say(struct map_session_data *sd, const char *const message)
+{
+ if (!sd || !sd->pd)
+ return;
+
+ const char *const name = sd->pd->pet.name;
+ const int len = 24 + 4 + strlen(message);
+ char *buf = NULL;
+ CREATE(buf, char, len);
+
+ snprintf(buf, len, "%s : %s", name, message);
+ buf[len - 1] = 0;
+ clif->GlobalMessage(&sd->pd->bl, buf);
+}
diff --git a/src/map/send.h b/src/map/send.h
index 0c6bb9c..04ba9aa 100644
--- a/src/map/send.h
+++ b/src/map/send.h
@@ -21,5 +21,6 @@ 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);
#endif // EVOL_MAP_PC