From bf2849ef2346b41ab096c4c7ce44756e3e20cd27 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Wed, 15 Sep 2010 11:33:59 -0400
Subject: [PATCH] [STORM-176] Clean up handling of the maximum length of chat
 messages

---
 doc/contributions.txt        | 2 ++
 indra/newview/llchatbar.cpp  | 8 ++++++--
 indra/newview/llimpanel.cpp  | 2 +-
 indra/newview/llvoavatar.cpp | 2 +-
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/doc/contributions.txt b/doc/contributions.txt
index 9a2f9197fdf..5892a8081d8 100644
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -407,6 +407,7 @@ Michelle2 Zenovka
 	VWR-8310
 	VWR-9499
 Mm Alder
+	SNOW-376
 	VWR-197
 	VWR-3777
 	VWR-4232
@@ -646,6 +647,7 @@ Techwolf Lupindo
 	SNOW-649
 	SNOW-680
 	SNOW-681
+	SNOW-690
 	VWR-12385
 tenebrous pau
 	VWR-247
diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp
index 7d82ec3a71e..d251931ecab 100644
--- a/indra/newview/llchatbar.cpp
+++ b/indra/newview/llchatbar.cpp
@@ -126,7 +126,7 @@ BOOL LLChatBar::postBuild()
 	mInputEditor->setPassDelete(TRUE);
 	mInputEditor->setReplaceNewlinesWithSpaces(FALSE);
 
-	mInputEditor->setMaxTextLength(1023);
+	mInputEditor->setMaxTextLength(DB_CHAT_MSG_STR_LEN);
 	mInputEditor->setEnableLineHistory(TRUE);
 
 	mIsBuilt = TRUE;
@@ -569,8 +569,12 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL
 	S32 channel = 0;
 	LLWString out_text = stripChannelNumber(wtext, &channel);
 	std::string utf8_out_text = wstring_to_utf8str(out_text);
-	std::string utf8_text = wstring_to_utf8str(wtext);
+	if (!utf8_out_text.empty())
+	{
+		utf8_out_text = utf8str_truncate(utf8_out_text, MAX_MSG_STR_LEN);
+	}
 
+	std::string utf8_text = wstring_to_utf8str(wtext);
 	utf8_text = utf8str_trim(utf8_text);
 	if (!utf8_text.empty())
 	{
diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp
index 5f7d1a2ffa9..b3b0c93b995 100644
--- a/indra/newview/llimpanel.cpp
+++ b/indra/newview/llimpanel.cpp
@@ -168,7 +168,7 @@ LLFloaterIMPanel::LLFloaterIMPanel(const std::string& session_label,
 	LLUICtrlFactory::getInstance()->buildFloater(this, xml_filename, NULL);
 
 	setTitle(mSessionLabel);
-	mInputEditor->setMaxTextLength(1023);
+	mInputEditor->setMaxTextLength(DB_IM_MSG_STR_LEN);
 	// enable line history support for instant message bar
 	mInputEditor->setEnableLineHistory(TRUE);
 
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index cab6fbdc935..46d8f65d23d 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -176,7 +176,7 @@ const F32 TIME_BEFORE_MESH_CLEANUP = 5.f; // seconds
 const S32 AVATAR_RELEASE_THRESHOLD = 10; // number of avatar instances before releasing memory
 const F32 FOOT_GROUND_COLLISION_TOLERANCE = 0.25f;
 const F32 AVATAR_LOD_TWEAK_RANGE = 0.7f;
-const S32 MAX_BUBBLE_CHAT_LENGTH = 1023;
+const S32 MAX_BUBBLE_CHAT_LENGTH = DB_CHAT_MSG_STR_LEN;
 const S32 MAX_BUBBLE_CHAT_UTTERANCES = 12;
 const F32 CHAT_FADE_TIME = 8.0;
 const F32 BUBBLE_CHAT_TIME = CHAT_FADE_TIME * 3.f;
-- 
GitLab