From 6af65004a5ab6ced39e660a28fe63903e8758553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liru=20F=C3=A6rs?= Date: Sun, 3 Nov 2019 15:32:22 -0500 Subject: [PATCH] Don't const_cast LLChat, just accept it as non-const. --- indra/newview/llfloaterchat.cpp | 41 +++++++++++++++++-------------- indra/newview/llfloaterchat.h | 8 +++--- indra/newview/llviewermessage.cpp | 2 +- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/indra/newview/llfloaterchat.cpp b/indra/newview/llfloaterchat.cpp index 712d50167..e36a41975 100644 --- a/indra/newview/llfloaterchat.cpp +++ b/indra/newview/llfloaterchat.cpp @@ -228,6 +228,12 @@ void add_timestamped_line(LLViewerTextEditor* edit, LLChat chat, const LLColor4& edit->appendText(line, false, prepend_newline, style, false); } +void LLFloaterChat::addChatHistory(const std::string& str, bool log_to_file) +{ + LLChat chat(str); + addChatHistory(chat, log_to_file); +} + void log_chat_text(const LLChat& chat) { std::string histstr; @@ -239,7 +245,7 @@ void log_chat_text(const LLChat& chat) LLLogChat::saveHistory(std::string("chat"), histstr); } // static -void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file) +void LLFloaterChat::addChatHistory(LLChat& chat, bool log_to_file) { // [RLVa:KB] - Checked: 2009-07-08 (RLVa-1.0.0e) if (rlv_handler_t::isEnabled()) @@ -247,20 +253,18 @@ void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file) // TODO-RLVa: we might cast too broad a net by filtering here, needs testing if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) && (!chat.mRlvLocFiltered) && (CHAT_SOURCE_AGENT != chat.mSourceType) ) { - LLChat& rlvChat = const_cast(chat); - RlvUtil::filterLocation(rlvChat.mText); - rlvChat.mRlvLocFiltered = TRUE; + RlvUtil::filterLocation(chat.mText); + chat.mRlvLocFiltered = TRUE; } if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (!chat.mRlvNamesFiltered) ) { // NOTE: this will also filter inventory accepted/declined text in the chat history - LLChat& rlvChat = const_cast(chat); if (CHAT_SOURCE_AGENT != chat.mSourceType) { // Filter object and system chat (names are filtered elsewhere to save ourselves an gObjectList lookup) - RlvUtil::filterNames(rlvChat.mText); + RlvUtil::filterNames(chat.mText); } - rlvChat.mRlvNamesFiltered = TRUE; + chat.mRlvNamesFiltered = TRUE; } } // [/RLVa:KB] @@ -276,10 +280,7 @@ void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file) if (chat.mChatType == CHAT_TYPE_DEBUG_MSG) { - LLFloaterScriptDebug::addScriptLine(chat.mText, - chat.mFromName, - color, - chat.mFromID); + LLFloaterScriptDebug::addScriptLine(chat, color); if (!gSavedSettings.getBOOL("ScriptErrorsAsChat")) { return; @@ -340,8 +341,14 @@ void LLFloaterChat::onClickToggleShowMute(bool show_mute, LLTextEditor* history_ (show_mute ? history_editor_with_mute : history_editor)->setCursorAndScrollToEnd(); } +void LLFloaterChat::addChat(const std::string& str, BOOL from_im, BOOL local_agent) +{ + LLChat chat(str); + addChat(chat, from_im, local_agent); +} + // Put a line of chat in all the right places -void LLFloaterChat::addChat(const LLChat& chat, +void LLFloaterChat::addChat(LLChat& chat, BOOL from_instant_message, BOOL local_agent) { @@ -357,20 +364,18 @@ void LLFloaterChat::addChat(const LLChat& chat, // TODO-RLVa: we might cast too broad a net by filtering here, needs testing if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) && (!chat.mRlvLocFiltered) && (CHAT_SOURCE_AGENT != chat.mSourceType) ) { - LLChat& rlvChat = const_cast(chat); if (!from_instant_message) - RlvUtil::filterLocation(rlvChat.mText); - rlvChat.mRlvLocFiltered = TRUE; + RlvUtil::filterLocation(chat.mText); + chat.mRlvLocFiltered = TRUE; } if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (!chat.mRlvNamesFiltered) ) { - LLChat& rlvChat = const_cast(chat); if ( (!from_instant_message) && (CHAT_SOURCE_AGENT != chat.mSourceType) ) { // Filter object and system chat (names are filtered elsewhere to save ourselves an gObjectList lookup) - RlvUtil::filterNames(rlvChat.mText); + RlvUtil::filterNames(chat.mText); } - rlvChat.mRlvNamesFiltered = TRUE; + chat.mRlvNamesFiltered = TRUE; } } // [/RLVa:KB] diff --git a/indra/newview/llfloaterchat.h b/indra/newview/llfloaterchat.h index e1c55e779..f6c6addc7 100644 --- a/indra/newview/llfloaterchat.h +++ b/indra/newview/llfloaterchat.h @@ -60,13 +60,15 @@ public: void updateConsoleVisibility(); static void setHistoryCursorAndScrollToEnd(); - + // Add chat to console and history list. // Color based on source, type, distance. - static void addChat(const LLChat& chat, BOOL from_im = FALSE, BOOL local_agent = FALSE); + static void addChat(const std::string& str, BOOL from_im = FALSE, BOOL local_agent = FALSE); + static void addChat(LLChat& chat, BOOL from_im = FALSE, BOOL local_agent = FALSE); // Add chat to history alone. - static void addChatHistory(const LLChat& chat, bool log_to_file = true); + static void addChatHistory(const std::string& str, bool log_to_file = true); + static void addChatHistory(LLChat& chat, bool log_to_file = true); static void triggerAlerts(const std::string& text); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 753c99ecd..1f23a8cca 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3731,7 +3731,7 @@ private: }; #endif -void add_floater_chat(const LLChat &chat, const BOOL history) +void add_floater_chat(LLChat &chat, const BOOL history) { if (history) {