summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-01 17:07:14 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-01 17:07:14 +0000
commitf1586c89c9aed81d85d72ebbe0a0829f9a9237e9 (patch)
tree826057a2560bee09d3afb5979c7bcb28c262b94d
parent64d0f3dd32f08a148e4d29e3a33644777e00d6e2 (diff)
downloadhercules-f1586c89c9aed81d85d72ebbe0a0829f9a9237e9.tar.gz
hercules-f1586c89c9aed81d85d72ebbe0a0829f9a9237e9.tar.bz2
hercules-f1586c89c9aed81d85d72ebbe0a0829f9a9237e9.tar.xz
hercules-f1586c89c9aed81d85d72ebbe0a0829f9a9237e9.zip
* Fixed NPC_TALK message being displayed with EOL character attached (bugreport:4596, since r14270).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14535 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt1
-rw-r--r--src/map/mob.c20
2 files changed, 20 insertions, 1 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 908bfb555..42a463ccb 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -1,6 +1,7 @@
Date Added
2010/12/01
+ * Fixed NPC_TALK message being displayed with EOL character attached (bugreport:4596, since r14270). [Ai4rei]
* Reverted change from r14533 and restored the 3rd field of mob_avail.txt being optional (bugreport:4599, since r14532). [Ai4rei]
* Monster database reading now utilizes sv_readdb. [Ai4rei]
2010/11/30
diff --git a/src/map/mob.c b/src/map/mob.c
index 56a9f1961..a5bdbe267 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -3830,8 +3830,10 @@ static int mob_read_randommonster(void)
*------------------------------------------*/
static bool mob_parse_row_chatdb(char** str, const char* source, int line, int* last_msg_id)
{
+ char* msg;
struct mob_chat *ms;
int msg_id;
+ size_t len;
msg_id = atoi(str[0]);
@@ -3853,13 +3855,29 @@ static bool mob_parse_row_chatdb(char** str, const char* source, int line, int*
//Color
ms->color=strtoul(str[1],NULL,0);
//Message
- if(strlen(str[2])>(CHAT_SIZE_MAX-1)){
+ msg = str[2];
+ len = strlen(msg);
+
+ while( len && ( msg[len-1]=='\r' || msg[len-1]=='\n' ) )
+ {// find EOL to strip
+ len--;
+ }
+
+ if(len>(CHAT_SIZE_MAX-1))
+ {
if (msg_id != *last_msg_id) {
ShowError("mob_chat: readdb: Message too long! Line %d, id: %d\n", line, msg_id);
*last_msg_id = msg_id;
}
return false;
}
+ else if( !len )
+ {
+ ShowWarning("mob_parse_row_chatdb: Empty message for id %d.\n", msg_id);
+ return false;
+ }
+
+ msg[len] = 0; // strip previously found EOL
strncpy(ms->msg, str[2], CHAT_SIZE_MAX);
return true;