From b67f55cff725e8c7cde9fe9e919e7da166d4eafa Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Tue, 16 Dec 2014 19:57:46 -0500 Subject: [PATCH] Prevent failure to create SLURL when an object chats but is not on the object list. Fixes an issue I couldn't remember nor find on the issue tracker. SLURLs for found objects remain unchanged. SLURLs for objects that are not found, but we could find their owners now display the owner's position and region, with "?owner_not_object" appended to the slurl as a note to the user SLURLs for objects that are not found, and we could not find their owners, now display as being from the position 0, 0, 0 in the users region --- indra/newview/llviewermessage.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index a5033696f..6659fe835 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3939,9 +3939,10 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) is_owned_by_me = chatter->permYouOwner(); } + else is_owned_by_me = owner_id == gAgentID; U32 links_for_chatting_objects = gSavedSettings.getU32("LinksForChattingObjects"); - if (links_for_chatting_objects != 0 && chatter && chat.mSourceType == CHAT_SOURCE_OBJECT && + if (links_for_chatting_objects != 0 /*&& chatter*/ && chat.mSourceType == CHAT_SOURCE_OBJECT && (!is_owned_by_me || links_for_chatting_objects == 2) // [RLVa:KB] && !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES) @@ -3956,13 +3957,16 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) if( !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC) ) // [/RLVa:KB] { + // Fallback on the owner, if the chatter isn't present, lastly use the agent's region at the origin. + const LLViewerObject* obj(chatter ? chatter : gObjectList.findObject(owner_id)); // Compute the object SLURL. - LLVector3 pos = chatter->getPositionRegion(); + LLVector3 pos = obj ? obj->getPositionRegion() : LLVector3::zero; S32 x = llround((F32)fmod((F64)pos.mV[VX], (F64)REGION_WIDTH_METERS)); S32 y = llround((F32)fmod((F64)pos.mV[VY], (F64)REGION_WIDTH_METERS)); S32 z = llround((F32)pos.mV[VZ]); std::ostringstream location; - location << chatter->getRegion()->getName() << "/" << x << "/" << y << "/" << z; + location << (obj ? obj->getRegion() : gAgent.getRegion())->getName() << "/" << x << "/" << y << "/" << z; + if (chatter != obj) location << "?owner_not_object"; query_string["slurl"] = location.str(); }