summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2017-03-20 19:43:35 +0100
committerGitHub <noreply@github.com>2017-03-20 19:43:35 +0100
commit2ea08e0e58004667f51e56a5295767ac6d1be49b (patch)
tree716991f4bfd485d4405523be650b12a69d8c462e /src
parent7aae8b0769efadbe42cdaed7ea29cfbc22eca7ab (diff)
parent1885e79a35b841b0f720d461171f00e1c4e7fa63 (diff)
downloadhercules-2ea08e0e58004667f51e56a5295767ac6d1be49b.tar.gz
hercules-2ea08e0e58004667f51e56a5295767ac6d1be49b.tar.bz2
hercules-2ea08e0e58004667f51e56a5295767ac6d1be49b.tar.xz
hercules-2ea08e0e58004667f51e56a5295767ac6d1be49b.zip
Merge pull request #1641 from 4144/inputfix
Fix npc text input For 2015 clients (Fixes #1640).
Diffstat (limited to 'src')
-rw-r--r--src/common/strlib.c1
-rw-r--r--src/map/clif.c7
2 files changed, 7 insertions, 1 deletions
diff --git a/src/common/strlib.c b/src/common/strlib.c
index 75ce2a272..df8093456 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -344,6 +344,7 @@ int strlib_config_switch(const char *str) {
}
/// strncpy that always null-terminates the string
+/// @remark this function will read at most `n` - 1 bytes from `src` (from 0 to `n` - 2)
char *strlib_safestrncpy(char *dst, const char *src, size_t n)
{
if( n > 0 )
diff --git a/src/map/clif.c b/src/map/clif.c
index 597a890ae..8fae28e74 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11626,7 +11626,12 @@ void clif_parse_NpcStringInput(int fd, struct map_session_data* sd) __attribute_
/// 01d5 <packet len>.W <npc id>.L <string>.?B
void clif_parse_NpcStringInput(int fd, struct map_session_data* sd)
{
- int message_len = RFIFOW(fd,2)-8;
+// [4144] can't confirm exact client version. At least >= correct for 20150513
+#if PACKETVER >= 20151029
+ int message_len = RFIFOW(fd, 2) - 7;
+#else
+ int message_len = RFIFOW(fd, 2) - 8;
+#endif
int npcid = RFIFOL(fd,4);
const char *message = RFIFOP(fd,8);