diff options
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r-- | indra/newview/llviewermessage.cpp | 864 |
1 files changed, 350 insertions, 514 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 52bc2d9654..c4ea8db3cd 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -118,6 +118,8 @@ #include "llpanelplaceprofile.h" #include "llviewerregion.h" #include "llfloaterregionrestarting.h" +#include "rlvactions.h" +#include "rlvhandler.h" #include "llnotificationmanager.h" // #include "llexperiencecache.h" @@ -127,7 +129,7 @@ extern void on_new_message(const LLSD& msg); -extern BOOL gCubeSnapshot; +extern bool gCubeSnapshot; // // Constants @@ -139,7 +141,7 @@ const F32 CAMERA_POSITION_THRESHOLD_SQUARED = 0.001f * 0.001f; static const U32 LLREQUEST_PERMISSION_THROTTLE_LIMIT = 5; // requests static const F32 LLREQUEST_PERMISSION_THROTTLE_INTERVAL = 10.0f; // seconds -extern BOOL gDebugClicks; +extern bool gDebugClicks; extern bool gShiftFrame; // function prototypes @@ -187,7 +189,7 @@ void accept_friendship_coro(std::string url, LLSD notification) } else { - if (!result.has("success") || result["success"].asBoolean() == false) + if (!result.has("success") || !result["success"].asBoolean()) { LL_WARNS("Friendship") << "Server failed to process accepted friendship. " << httpResults << LL_ENDL; } @@ -230,7 +232,7 @@ void decline_friendship_coro(std::string url, LLSD notification, S32 option) } else { - if (!result.has("success") || result["success"].asBoolean() == false) + if (!result.has("success") || !result["success"].asBoolean()) { LL_WARNS("Friendship") << "Server failed to process declined friendship. " << httpResults << LL_ENDL; } @@ -274,7 +276,7 @@ bool friendship_offer_callback(const LLSD& notification, const LLSD& response) // This will also trigger an onlinenotification if the user is online std::string url = gAgent.getRegionCapability("AcceptFriendship"); LL_DEBUGS("Friendship") << "Cap string: " << url << LL_ENDL; - if (!url.empty() && payload.has("online") && payload["online"].asBoolean() == false) + if (!url.empty() && payload.has("online") && !payload["online"].asBoolean()) { LL_DEBUGS("Friendship") << "Accepting friendship via capability" << LL_ENDL; LLCoros::instance().launch("LLMessageSystem::acceptFriendshipOffer", @@ -314,7 +316,7 @@ bool friendship_offer_callback(const LLSD& notification, const LLSD& response) // the rejection to the simulator to delete the pending userop. std::string url = gAgent.getRegionCapability("DeclineFriendship"); LL_DEBUGS("Friendship") << "Cap string: " << url << LL_ENDL; - if (!url.empty() && payload.has("online") && payload["online"].asBoolean() == false) + if (!url.empty() && payload.has("online") && !payload["online"].asBoolean()) { LL_DEBUGS("Friendship") << "Declining friendship via capability" << LL_ENDL; LLCoros::instance().launch("LLMessageSystem::declineFriendshipOffer", @@ -371,7 +373,7 @@ static LLNotificationFunctorRegistration friendship_offer_callback_reg_nm("Offer // Functions // -void give_money(const LLUUID& uuid, LLViewerRegion* region, S32 amount, BOOL is_group, +void give_money(const LLUUID& uuid, LLViewerRegion* region, S32 amount, bool is_group, S32 trx_type, const std::string& desc) { if(0 == amount || !region) return; @@ -393,7 +395,7 @@ void give_money(const LLUUID& uuid, LLViewerRegion* region, S32 amount, BOOL is_ msg->nextBlockFast(_PREHASH_MoneyData); msg->addUUIDFast(_PREHASH_SourceID, gAgent.getID() ); msg->addUUIDFast(_PREHASH_DestID, uuid); - msg->addU8Fast(_PREHASH_Flags, pack_transaction_flags(FALSE, is_group)); + msg->addU8Fast(_PREHASH_Flags, pack_transaction_flags(false, is_group)); msg->addS32Fast(_PREHASH_Amount, amount); msg->addU8Fast(_PREHASH_AggregatePermNextOwner, (U8)LLAggregatePermissions::AP_EMPTY); msg->addU8Fast(_PREHASH_AggregatePermInventory, (U8)LLAggregatePermissions::AP_EMPTY); @@ -507,192 +509,6 @@ void process_layer_data(LLMessageSystem *mesgsys, void **user_data) } } -// S32 exported_object_count = 0; -// S32 exported_image_count = 0; -// S32 current_object_count = 0; -// S32 current_image_count = 0; - -// extern LLNotifyBox *gExporterNotify; -// extern LLUUID gExporterRequestID; -// extern std::string gExportDirectory; - -// extern LLUploadDialog *gExportDialog; - -// std::string gExportedFile; - -// std::map<LLUUID, std::string> gImageChecksums; - -// void export_complete() -// { -// LLUploadDialog::modalUploadFinished(); -// gExporterRequestID.setNull(); -// gExportDirectory = ""; - -// LLFILE* fXML = LLFile::fopen(gExportedFile, "rb"); /* Flawfinder: ignore */ -// fseek(fXML, 0, SEEK_END); -// long length = ftell(fXML); -// fseek(fXML, 0, SEEK_SET); -// U8 *buffer = new U8[length + 1]; -// size_t nread = fread(buffer, 1, length, fXML); -// if (nread < (size_t) length) -// { -// LL_WARNS("Messaging") << "Short read" << LL_ENDL; -// } -// buffer[nread] = '\0'; -// fclose(fXML); - -// char *pos = (char *)buffer; -// while ((pos = strstr(pos+1, "<sl:image ")) != 0) -// { -// char *pos_check = strstr(pos, "checksum=\""); - -// if (pos_check) -// { -// char *pos_uuid = strstr(pos_check, "\">"); - -// if (pos_uuid) -// { -// char image_uuid_str[UUID_STR_SIZE]; /* Flawfinder: ignore */ -// memcpy(image_uuid_str, pos_uuid+2, UUID_STR_SIZE-1); /* Flawfinder: ignore */ -// image_uuid_str[UUID_STR_SIZE-1] = 0; - -// LLUUID image_uuid(image_uuid_str); - -// LL_INFOS("Messaging") << "Found UUID: " << image_uuid << LL_ENDL; - -// std::map<LLUUID, std::string>::iterator itor = gImageChecksums.find(image_uuid); -// if (itor != gImageChecksums.end()) -// { -// LL_INFOS("Messaging") << "Replacing with checksum: " << itor->second << LL_ENDL; -// if (!itor->second.empty()) -// { -// memcpy(&pos_check[10], itor->second.c_str(), 32); /* Flawfinder: ignore */ -// } -// } -// } -// } -// } - -// LLFILE* fXMLOut = LLFile::fopen(gExportedFile, "wb"); /* Flawfinder: ignore */ -// if (fwrite(buffer, 1, length, fXMLOut) != length) -// { -// LL_WARNS("Messaging") << "Short write" << LL_ENDL; -// } -// fclose(fXMLOut); - -// delete [] buffer; -// } - - -// void exported_item_complete(const LLTSCode status, void *user_data) -// { -// //std::string *filename = (std::string *)user_data; - -// if (status < LLTS_OK) -// { -// LL_WARNS("Messaging") << "Export failed!" << LL_ENDL; -// } -// else -// { -// ++current_object_count; -// if (current_image_count == exported_image_count && current_object_count == exported_object_count) -// { -// LL_INFOS("Messaging") << "*** Export complete ***" << LL_ENDL; - -// export_complete(); -// } -// else -// { -// gExportDialog->setMessage(llformat("Exported %d/%d object files, %d/%d textures.", current_object_count, exported_object_count, current_image_count, exported_image_count)); -// } -// } -// } - -// struct exported_image_info -// { -// LLUUID image_id; -// std::string filename; -// U32 image_num; -// }; - -// void exported_j2c_complete(const LLTSCode status, void *user_data) -// { -// exported_image_info *info = (exported_image_info *)user_data; -// LLUUID image_id = info->image_id; -// U32 image_num = info->image_num; -// std::string filename = info->filename; -// delete info; - -// if (status < LLTS_OK) -// { -// LL_WARNS("Messaging") << "Image download failed!" << LL_ENDL; -// } -// else -// { -// LLFILE* fIn = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */ -// if (fIn) -// { -// LLPointer<LLImageJ2C> ImageUtility = new LLImageJ2C; -// LLPointer<LLImageTGA> TargaUtility = new LLImageTGA; - -// fseek(fIn, 0, SEEK_END); -// S32 length = ftell(fIn); -// fseek(fIn, 0, SEEK_SET); -// U8 *buffer = ImageUtility->allocateData(length); -// if (fread(buffer, 1, length, fIn) != length) -// { -// LL_WARNS("Messaging") << "Short read" << LL_ENDL; -// } -// fclose(fIn); -// LLFile::remove(filename); - -// // Convert to TGA -// LLPointer<LLImageRaw> image = new LLImageRaw(); - -// ImageUtility->updateData(); -// ImageUtility->decode(image, 100000.0f); - -// TargaUtility->encode(image); -// U8 *data = TargaUtility->getData(); -// S32 data_size = TargaUtility->getDataSize(); - -// std::string file_path = gDirUtilp->getDirName(filename); - -// std::string output_file = llformat("%s/image-%03d.tga", file_path.c_str(), image_num);//filename; -// //S32 name_len = output_file.length(); -// //strcpy(&output_file[name_len-3], "tga"); -// LLFILE* fOut = LLFile::fopen(output_file, "wb"); /* Flawfinder: ignore */ -// char md5_hash_string[33]; /* Flawfinder: ignore */ -// strcpy(md5_hash_string, "00000000000000000000000000000000"); /* Flawfinder: ignore */ -// if (fOut) -// { -// if (fwrite(data, 1, data_size, fOut) != data_size) -// { -// LL_WARNS("Messaging") << "Short write" << LL_ENDL; -// } -// fseek(fOut, 0, SEEK_SET); -// fclose(fOut); -// fOut = LLFile::fopen(output_file, "rb"); /* Flawfinder: ignore */ -// LLMD5 my_md5_hash(fOut); -// my_md5_hash.hex_digest(md5_hash_string); -// } - -// gImageChecksums.insert(std::pair<LLUUID, std::string>(image_id, md5_hash_string)); -// } -// } - -// ++current_image_count; -// if (current_image_count == exported_image_count && current_object_count == exported_object_count) -// { -// LL_INFOS("Messaging") << "*** Export textures complete ***" << LL_ENDL; -// export_complete(); -// } -// else -// { -// gExportDialog->setMessage(llformat("Exported %d/%d object files, %d/%d textures.", current_object_count, exported_object_count, current_image_count, exported_image_count)); -// } -//} - void process_derez_ack(LLMessageSystem*, void**) { if(gViewerWindow) gViewerWindow->getWindow()->decBusyCount(); @@ -774,7 +590,7 @@ void response_group_invitation_coro(std::string url, LLUUID group_id, bool notif } else { - if (!result.has("success") || result["success"].asBoolean() == false) + if (!result.has("success") || !result["success"].asBoolean()) { LL_WARNS("GroupInvite") << "Server failed to process group " << group_id << " invitation response. " << httpResults << LL_ENDL; } @@ -974,13 +790,13 @@ static void highlight_inventory_objects_in_panel(const std::vector<LLUUID>& item // Parent folders can be different in case of 2 consecutive drag and drop // operations when the second one is started before the first one completes. LL_DEBUGS("Inventory_Move") << "Open folder: " << fv_folder->getName() << LL_ENDL; - fv_folder->setOpen(TRUE); + fv_folder->setOpen(true); if (fv_folder->isSelected()) { - fv->changeSelection(fv_folder, FALSE); + fv->changeSelection(fv_folder, false); } } - fv->changeSelection(fv_item, TRUE); + fv->changeSelection(fv_item, true); } } } @@ -1344,7 +1160,7 @@ protected: }; -//Returns TRUE if we are OK, FALSE if we are throttled +//Returns true if we are OK, false if we are throttled //Set check_only true if you want to know the throttle status //without registering a hit bool check_offer_throttle(const std::string& from_name, bool check_only) @@ -1465,7 +1281,7 @@ void open_inventory_offer(const uuid_vec_t& objects, const std::string& from_nam { LL_DEBUGS("Messaging") << "Highlighting inventory item: " << item->getUUID() << LL_ENDL; // If we opened this ourselves, focus it - const BOOL take_focus = from_name.empty() ? TAKE_FOCUS_YES : TAKE_FOCUS_NO; + const bool take_focus = from_name.empty() ? TAKE_FOCUS_YES : TAKE_FOCUS_NO; switch(asset_type) { case LLAssetType::AT_NOTECARD: @@ -1564,7 +1380,7 @@ void open_inventory_offer(const uuid_vec_t& objects, const std::string& from_nam // Highlight item bool show_in_inventory = gSavedSettings.get<bool>("ShowInInventory"); bool auto_open = - show_in_inventory && // don't open if ShowInInventory is FALSE + show_in_inventory && // don't open if ShowInInventory is false !from_name.empty(); // don't open if it's not from anyone // SL-20419 : Don't change active tab if floater is visible @@ -1646,7 +1462,7 @@ void inventory_offer_mute_callback(const LLUUID& blocked_id, { return (notification->getPayload()["from_id"].asUUID() == blocked_id); } - return FALSE; + return false; } private: const LLUUID& blocked_id; @@ -1669,8 +1485,8 @@ std::string LLOfferInfo::mResponderType = "offer_info"; LLOfferInfo::LLOfferInfo() : LLNotificationResponderInterface() - , mFromGroup(FALSE) - , mFromObject(FALSE) + , mFromGroup(false) + , mFromObject(false) , mIM(IM_NOTHING_SPECIAL) , mType(LLAssetType::AT_NONE) , mPersist(false) @@ -1753,7 +1569,7 @@ void LLOfferInfo::sendReceiveResponse(bool accept, const LLUUID &destination_fol msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_MessageBlock); - msg->addBOOLFast(_PREHASH_FromGroup, FALSE); + msg->addBOOLFast(_PREHASH_FromGroup, false); msg->addUUIDFast(_PREHASH_ToAgentID, mFromID); msg->addU8Fast(_PREHASH_Offline, IM_ONLINE); msg->addUUIDFast(_PREHASH_ID, mTransactionID); @@ -1947,7 +1763,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& chat.mText = log_message; if( LLMuteList::getInstance()->isMuted(mFromID ) && ! LLMuteList::isLinden(mFromName) ) // muting for SL-42269 { - chat.mMuted = TRUE; + chat.mMuted = true; accept_to_trash = false; // will send decline message } @@ -2042,25 +1858,29 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const std::string from_string; // Used in the pop-up. std::string chatHistory_string; // Used in chat history. - if (mFromObject == TRUE) + if (mFromObject) { + std::string quot = LLTrans::getString("'"); if (mFromGroup) { std::string group_name; if (gCacheName->getGroupName(mFromID, group_name)) { - from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+"'" - + mFromName + LLTrans::getString("'") +" " + LLTrans::getString("InvOfferOwnedByGroup") - + " "+ "'" + group_name + "'"; - - chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedByGroup") - + " " + group_name + "'"; + from_string = LLTrans::getString("InvOfferAnObjectNamed") + " " + + quot + mFromName + quot + " " + + LLTrans::getString("InvOfferOwnedByGroup") + " " + + quot + group_name + quot; + chatHistory_string = mFromName + " " + + LLTrans::getString("InvOfferOwnedByGroup") + " " + + quot + group_name + quot; } else { - from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+"'" - + mFromName +"'"+ " " + LLTrans::getString("InvOfferOwnedByUnknownGroup"); - chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedByUnknownGroup"); + from_string = LLTrans::getString("InvOfferAnObjectNamed") + " " + + quot + mFromName + quot + " " + + LLTrans::getString("InvOfferOwnedByUnknownGroup"); + chatHistory_string = mFromName + " " + + LLTrans::getString("InvOfferOwnedByUnknownGroup"); } } else @@ -2068,15 +1888,19 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const LLAvatarName av_name; if (LLAvatarNameCache::get(mFromID, &av_name)) { - from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+ LLTrans::getString("'") + mFromName - + LLTrans::getString("'")+" " + LLTrans::getString("InvOfferOwnedBy") + av_name.getUserName(); - chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedBy") + " " + av_name.getUserName(); + from_string = LLTrans::getString("InvOfferAnObjectNamed") + " " + + quot + mFromName + quot + " " + + LLTrans::getString("InvOfferOwnedBy") + " " + av_name.getUserName(); + chatHistory_string = mFromName + " " + + LLTrans::getString("InvOfferOwnedBy") + " " + av_name.getUserName(); } else { - from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+LLTrans::getString("'") - + mFromName + LLTrans::getString("'")+" " + LLTrans::getString("InvOfferOwnedByUnknownUser"); - chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedByUnknownUser"); + from_string = LLTrans::getString("InvOfferAnObjectNamed") + " " + + quot + mFromName + quot + " " + + LLTrans::getString("InvOfferOwnedByUnknownUser"); + chatHistory_string = mFromName + " " + + LLTrans::getString("InvOfferOwnedByUnknownUser"); } } } @@ -2168,7 +1992,7 @@ bool lure_callback(const LLSD& notification, const LLSD& response) LLUUID from_id = notification["payload"]["from_id"].asUUID(); LLUUID lure_id = notification["payload"]["lure_id"].asUUID(); - BOOL godlike = notification["payload"]["godlike"].asBoolean(); + bool godlike = notification["payload"]["godlike"].asBoolean(); switch(option) { @@ -2217,7 +2041,7 @@ bool mature_lure_callback(const LLSD& notification, const LLSD& response) LLUUID from_id = notification["payload"]["from_id"].asUUID(); LLUUID lure_id = notification["payload"]["lure_id"].asUUID(); - BOOL godlike = notification["payload"]["godlike"].asBoolean(); + bool godlike = notification["payload"]["godlike"].asBoolean(); U8 region_access = static_cast<U8>(notification["payload"]["region_maturity"].asInteger()); switch(option) @@ -2282,7 +2106,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) LL_PROFILE_ZONE_SCOPED; LLUUID from_id; - BOOL from_group; + bool from_group; LLUUID to_id; U8 offline; U8 d = 0; @@ -2342,7 +2166,7 @@ void send_do_not_disturb_message (LLMessageSystem* msg, const LLUUID& from_id, c pack_instant_message( msg, gAgent.getID(), - FALSE, + false, gAgent.getSessionID(), from_id, my_name, @@ -2542,10 +2366,10 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) chat.mFromName = from_name; } - BOOL is_do_not_disturb = gAgent.isDoNotDisturb(); + bool is_do_not_disturb = gAgent.isDoNotDisturb(); - BOOL is_muted = FALSE; - BOOL is_linden = FALSE; + bool is_muted = false; + bool is_linden = false; is_muted = LLMuteList::getInstance()->isMuted( from_id, from_name, @@ -2559,16 +2383,17 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) return; } - BOOL is_audible = (CHAT_AUDIBLE_FULLY == chat.mAudible); + bool is_audible = (CHAT_AUDIBLE_FULLY == chat.mAudible); + bool show_script_chat_particles = chat.mSourceType == CHAT_SOURCE_OBJECT + && chat.mChatType != CHAT_TYPE_DEBUG_MSG + && gSavedSettings.getBOOL("EffectScriptChatParticles"); chatter = gObjectList.findObject(from_id); if (chatter) { chat.mPosAgent = chatter->getPositionAgent(); // Make swirly things only for talking objects. (not script debug messages, though) - if (chat.mSourceType == CHAT_SOURCE_OBJECT - && chat.mChatType != CHAT_TYPE_DEBUG_MSG - && gSavedSettings.getBOOL("EffectScriptChatParticles") ) + if (show_script_chat_particles && (!RlvActions::isRlvEnabled() || CHAT_TYPE_OWNER != chat.mChatType) ) { LLPointer<LLViewerPartSourceChat> psc = new LLViewerPartSourceChat(chatter->getPositionAgent()); psc->setSourceObject(chatter); @@ -2593,25 +2418,28 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) if (is_audible) { - //BOOL visible_in_chat_bubble = FALSE; + //bool visible_in_chat_bubble = false; color.setVec(1.f,1.f,1.f,1.f); msg->getStringFast(_PREHASH_ChatData, _PREHASH_Message, mesg); - BOOL ircstyle = FALSE; + bool ircstyle = false; + + auto [message, is_script] = LLStringUtil::withoutPrefix(mesg, LUA_PREFIX); + chat.mIsScript = is_script; // Look for IRC-style emotes here so chatbubbles work - std::string prefix = mesg.substr(0, 4); + std::string prefix = message.substr(0, 4); if (prefix == "/me " || prefix == "/me'") { - ircstyle = TRUE; + ircstyle = true; } chat.mText = mesg; // Look for the start of typing so we can put "..." in the bubbles. if (CHAT_TYPE_START == chat.mChatType) { - LLLocalSpeakerMgr::getInstance()->setSpeakerTyping(from_id, TRUE); + LLLocalSpeakerMgr::getInstance()->setSpeakerTyping(from_id, true); // Might not have the avatar constructed yet, eg on login. if (chatter && chatter->isAvatar()) @@ -2622,7 +2450,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) } else if (CHAT_TYPE_STOP == chat.mChatType) { - LLLocalSpeakerMgr::getInstance()->setSpeakerTyping(from_id, FALSE); + LLLocalSpeakerMgr::getInstance()->setSpeakerTyping(from_id, false); // Might not have the avatar constructed yet, eg on login. if (chatter && chatter->isAvatar()) @@ -2643,19 +2471,42 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) else { chat.mText = ""; + auto [msg_without_prefix, is_lua] = LLStringUtil::withoutPrefix(mesg, LUA_PREFIX); + std::string prefix; + if (is_lua) + { + prefix = LUA_PREFIX; + } switch(chat.mChatType) { case CHAT_TYPE_WHISPER: - chat.mText = LLTrans::getString("whisper") + " "; + prefix += LLTrans::getString("whisper") + " "; + break; + case CHAT_TYPE_SHOUT: + prefix += LLTrans::getString("shout") + " "; break; - case CHAT_TYPE_DEBUG_MSG: case CHAT_TYPE_OWNER: + if (RlvActions::isRlvEnabled()) + { + if (RlvHandler::instance().handleSimulatorChat(mesg, chat, chatter)) + { + break; + } + else if (show_script_chat_particles) + { + LLPointer<LLViewerPartSourceChat> psc = new LLViewerPartSourceChat(chatter->getPositionAgent()); + psc->setSourceObject(chatter); + psc->setColor(color); + //We set the particles to be owned by the object's owner, + //just in case they should be muted by the mute list + psc->setOwnerUUID(owner_id); + LLViewerPartSim::getInstance()->addPartSource(psc); + } + } + case CHAT_TYPE_DEBUG_MSG: case CHAT_TYPE_NORMAL: case CHAT_TYPE_DIRECT: break; - case CHAT_TYPE_SHOUT: - chat.mText = LLTrans::getString("shout") + " "; - break; case CHAT_TYPE_START: case CHAT_TYPE_STOP: LL_WARNS("Messaging") << "Got chat type start/stop in main chat processing." << LL_ENDL; @@ -2665,13 +2516,13 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) break; } - chat.mText += mesg; + chat.mText = prefix + msg_without_prefix; } // We have a real utterance now, so can stop showing "..." and proceed. if (chatter && chatter->isAvatar()) { - LLLocalSpeakerMgr::getInstance()->setSpeakerTyping(from_id, FALSE); + LLLocalSpeakerMgr::getInstance()->setSpeakerTyping(from_id, false); ((LLVOAvatar*)chatter)->stopTyping(); if (!is_muted && !is_do_not_disturb) @@ -2746,6 +2597,11 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) msg_notify["from_id"] = chat.mFromID; msg_notify["source_type"] = chat.mSourceType; on_new_message(msg_notify); + + + msg_notify["chat_type"] = chat.mChatType; + msg_notify["message"] = mesg; + LLEventPumps::instance().obtain("LLNearbyChat").post(msg_notify); } } @@ -2778,11 +2634,11 @@ void process_teleport_start(LLMessageSystem *msg, void**) if (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL) { - gViewerWindow->setProgressCancelButtonVisible(FALSE); + gViewerWindow->setProgressCancelButtonVisible(false); } else { - gViewerWindow->setProgressCancelButtonVisible(TRUE, LLTrans::getString("Cancel")); + gViewerWindow->setProgressCancelButtonVisible(true, LLTrans::getString("Cancel")); } // Freeze the UI and show progress bar @@ -2790,7 +2646,7 @@ void process_teleport_start(LLMessageSystem *msg, void**) if( gAgent.getTeleportState() == LLAgent::TELEPORT_NONE ) { - gTeleportDisplay = TRUE; + gTeleportDisplay = true; gAgent.setTeleportState( LLAgent::TELEPORT_START ); make_ui_sound("UISndTeleportOut"); @@ -2820,11 +2676,11 @@ void process_teleport_progress(LLMessageSystem* msg, void**) msg->getU32("Info", "TeleportFlags", teleport_flags); if (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL) { - gViewerWindow->setProgressCancelButtonVisible(FALSE); + gViewerWindow->setProgressCancelButtonVisible(false); } else { - gViewerWindow->setProgressCancelButtonVisible(TRUE, LLTrans::getString("Cancel")); + gViewerWindow->setProgressCancelButtonVisible(true, LLTrans::getString("Cancel")); } std::string buffer; msg->getString("Info", "Message", buffer); @@ -2891,7 +2747,7 @@ public: virtual ~LLPostTeleportNotifiers(); //function to be called at the supplied frequency - virtual BOOL tick(); + bool tick() override; }; LLPostTeleportNotifiers::LLPostTeleportNotifiers() : LLEventTimer( 2.0 ) @@ -2902,9 +2758,9 @@ LLPostTeleportNotifiers::~LLPostTeleportNotifiers() { } -BOOL LLPostTeleportNotifiers::tick() +bool LLPostTeleportNotifiers::tick() { - BOOL all_done = FALSE; + bool all_done = false; if ( gAgent.getTeleportState() == LLAgent::TELEPORT_NONE ) { // get callingcards and landmarks available to the user arriving. @@ -2928,7 +2784,7 @@ BOOL LLPostTeleportNotifiers::tick() gInventory.addObserver(fetcher); } } - all_done = TRUE; + all_done = true; } return all_done; @@ -2962,7 +2818,7 @@ void process_teleport_finish(LLMessageSystem* msg, void**) { // Race condition? Make sure all variables are set correctly for teleport to work LL_WARNS("Teleport","Messaging") << "Teleport 'finish' message without 'start'. Setting state to TELEPORT_REQUESTED" << LL_ENDL; - gTeleportDisplay = TRUE; + gTeleportDisplay = true; LLViewerMessage::getInstance()->mTeleportStartedSignal(); gAgent.setTeleportState(LLAgent::TELEPORT_REQUESTED); make_ui_sound("UISndTeleportOut"); @@ -2974,11 +2830,11 @@ void process_teleport_finish(LLMessageSystem* msg, void**) } // Teleport is finished; it can't be cancelled now. - gViewerWindow->setProgressCancelButtonVisible(FALSE); + gViewerWindow->setProgressCancelButtonVisible(false); // Do teleport effect for where you're leaving // VEFFECT: TeleportStart - LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINT, TRUE); + LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINT, true); effectp->setPositionGlobal(gAgent.getPositionGlobal()); effectp->setColor(LLColor4U(gAgent.getEffectColor())); LLHUDManager::getInstance()->sendEffects(); @@ -3022,7 +2878,7 @@ void process_teleport_finish(LLMessageSystem* msg, void**) LLHost sim_host(sim_ip, sim_port); // Viewer trusts the simulator. - gMessageSystem->enableCircuit(sim_host, TRUE); + gMessageSystem->enableCircuit(sim_host, true); LLViewerRegion* regionp = LLWorld::getInstance()->addRegion(region_handle, sim_host); /* @@ -3030,7 +2886,7 @@ void process_teleport_finish(LLMessageSystem* msg, void**) gAgentCamera.updateCamera(); // likewise make sure the camera is behind the avatar - gAgentCamera.resetView(TRUE); + gAgentCamera.resetView(true); LLVector3 shift_vector = regionp->getPosRegionFromGlobal(gAgent.getRegion()->getOriginGlobal()); gAgent.setRegion(regionp); gObjectList.shiftObjects(shift_vector); @@ -3073,15 +2929,15 @@ void process_teleport_finish(LLMessageSystem* msg, void**) // Now do teleport effect for where you're going. // VEFFECT: TeleportEnd - effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINT, TRUE); + effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINT, true); effectp->setPositionGlobal(gAgent.getPositionGlobal()); effectp->setColor(LLColor4U(gAgent.getEffectColor())); LLHUDManager::getInstance()->sendEffects(); -// gTeleportDisplay = TRUE; +// gTeleportDisplay = true; // gTeleportDisplayTimer.reset(); -// gViewerWindow->setShowProgress(TRUE); +// gViewerWindow->setShowProgress(true); } // stuff we have to do every time we get an AvatarInitComplete from a sim @@ -3178,7 +3034,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) look_at = LLViewerCamera::getInstance()->getAtAxis(); } // Force the camera back onto the agent, don't animate. - gAgentCamera.setFocusOnAvatar(TRUE, FALSE); + gAgentCamera.setFocusOnAvatar(true, false); gAgentCamera.slamLookAt(look_at); gAgentCamera.updateCamera(); @@ -3238,15 +3094,15 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) /* if (teleport_flags & TELEPORT_FLAGS_IS_FLYING) { - gAgent.setFlying(TRUE); + gAgent.setFlying(true); } else { - gAgent.setFlying(FALSE); + gAgent.setFlying(false); } */ - send_agent_update(TRUE, TRUE); + send_agent_update(true, true); if (gAgent.getRegion()->getBlockFly()) { @@ -3317,87 +3173,56 @@ void process_crossed_region(LLMessageSystem* msg, void**) } - -// Sends avatar and camera information to simulator. -// Sent roughly once per frame, or 20 times per second, whichever is less often - -const F32 THRESHOLD_HEAD_ROT_QDOT = 0.9997f; // ~= 2.5 degrees -- if its less than this we need to update head_rot -const F32 MAX_HEAD_ROT_QDOT = 0.99999f; // ~= 0.5 degrees -- if its greater than this then no need to update head_rot - // between these values we delay the updates (but no more than one second) - -void send_agent_update(BOOL force_send, BOOL send_reliable) +// sends an AgentUpdate message to the server... or not +// e.g. only when force_send is 'true' OR +// something changed AND the update is not being throttled +void send_agent_update(bool force_send, bool send_reliable) { LL_PROFILE_ZONE_SCOPED; llassert(!gCubeSnapshot); if (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE) { - // We don't care if they want to send an agent update, they're not allowed to until the simulator - // that's the target is ready to receive them (after avatar_init_complete is received) + // We don't care if they want to send an agent update, they're not allowed + // until the target simulator is ready to receive them + // (e.g. after avatar_init_complete is received) return; } - // We have already requested to log out. Don't send agent updates. - if(LLAppViewer::instance()->logoutRequestSent()) + if (LLAppViewer::instance()->logoutRequestSent()) { + // We have already requested to log out. Don't send agent updates. return; } - // no region to send update to - if(gAgent.getRegion() == NULL) + if (gAgent.getRegion() == nullptr || gDisconnected) { + // no region to send update to return; } - const F32 TRANSLATE_THRESHOLD = 0.01f; - - // NOTA BENE: This is (intentionally?) using the small angle sine approximation to test for rotation - // Plus, there is an extra 0.5 in the mix since the perpendicular between last_camera_at and getAtAxis() bisects cam_rot_change - // Thus, we're actually testing against 0.2 degrees - const F32 ROTATION_THRESHOLD = 0.1f * 2.f*F_PI/360.f; // Rotation thresh 0.2 deg, see note above - - const U8 DUP_MSGS = 1; // HACK! number of times to repeat data on motionless agent - - // Store data on last sent update so that if no changes, no send - static LLVector3 last_camera_pos_agent, - last_camera_at, - last_camera_left, - last_camera_up; - - static LLVector3 cam_center_chg, - cam_rot_chg; - - static LLQuaternion last_head_rot; - static U32 last_control_flags = 0; - static U8 last_render_state; - static U8 duplicate_count = 0; - static F32 head_rot_chg = 1.0; - static U8 last_flags; - - LLMessageSystem *msg = gMessageSystem; - LLVector3 camera_pos_agent; // local to avatar's region - U8 render_state; - - LLQuaternion body_rotation = gAgent.getFrameAgent().getQuaternion(); - LLQuaternion head_rotation = gAgent.getHeadRotation(); - - camera_pos_agent = gAgentCamera.getCameraPositionAgent(); - - render_state = gAgent.getRenderState(); + static F64 last_send_time = 0.0; + static U32 last_control_flags = 0; + static U8 last_render_state = 0; + static U8 last_flags = AU_FLAGS_NONE; + static LLQuaternion last_body_rot, + last_head_rot; + static LLVector3 last_camera_pos_agent, + last_camera_at; - U32 control_flag_change = 0; - U8 flag_change = 0; - - cam_center_chg = last_camera_pos_agent - camera_pos_agent; - cam_rot_chg = last_camera_at - LLViewerCamera::getInstance()->getAtAxis(); + // compute sec_since_last_send + constexpr F64 MAX_AGENT_UPDATES_PER_SECOND = 125.0; // Value derived experimentally to avoid Input Delays with latest PBR-Capable Viewers when viewer FPS is highly volatile. + constexpr F64 MIN_AGENT_UPDATES_PER_SECOND = 1.0; // keep-alive rate + constexpr F64 MIN_AGENT_UPDATE_PERIOD = 1.0 / MAX_AGENT_UPDATES_PER_SECOND; + constexpr F64 MAX_AGENT_UPDATE_PERIOD = 1.0 / MIN_AGENT_UPDATES_PER_SECOND; + F64 now = LLFrameTimer::getTotalSeconds(); + F64 sec_since_last_send = now - last_send_time; // If a modifier key is held down, turn off // LBUTTON and ML_LBUTTON so that using the camera (alt-key) doesn't // trigger a control event. U32 control_flags = gAgent.getControlFlags(); - - MASK key_mask = gKeyboard->currentMask(TRUE); - + MASK key_mask = gKeyboard->currentMask(true); if (key_mask & MASK_ALT || key_mask & MASK_CONTROL) { control_flags &= ~( AGENT_CONTROL_LBUTTON_DOWN | @@ -3406,7 +3231,20 @@ void send_agent_update(BOOL force_send, BOOL send_reliable) AGENT_CONTROL_ML_LBUTTON_UP ; } - control_flag_change = last_control_flags ^ control_flags; + // any change in control_flags should be sent ASAP, so we fold that into force_send + force_send = force_send || (control_flags != last_control_flags); + + if (! force_send && sec_since_last_send < MIN_AGENT_UPDATE_PERIOD) + { + // throttle less-important AgentUpdates + return; + } + + LLVector3 camera_pos_agent = gAgentCamera.getCameraPositionAgent(); // local to avatar's region + LLVector3 camera_at = LLViewerCamera::getInstance()->getAtAxis(); + LLQuaternion body_rotation = gAgent.getFrameAgent().getQuaternion(); + LLQuaternion head_rotation = gAgent.getHeadRotation(); + U8 render_state = gAgent.getRenderState(); U8 flags = AU_FLAGS_NONE; if (gAgent.isGroupTitleHidden()) @@ -3418,159 +3256,141 @@ void send_agent_update(BOOL force_send, BOOL send_reliable) flags |= AU_FLAGS_CLIENT_AUTOPILOT; } - flag_change = last_flags ^ flags; - - head_rot_chg = dot(last_head_rot, head_rotation); - - //static S32 msg_number = 0; // Used for diagnostic log messages - - if (force_send || - (cam_center_chg.magVec() > TRANSLATE_THRESHOLD) || - (head_rot_chg < THRESHOLD_HEAD_ROT_QDOT) || - (last_render_state != render_state) || - (cam_rot_chg.magVec() > ROTATION_THRESHOLD) || - control_flag_change != 0 || - flag_change != 0) + bool send_update = force_send || sec_since_last_send > MAX_AGENT_UPDATE_PERIOD; + if (!send_update) { - /* Diagnotics to show why we send the AgentUpdate message. Also un-commment the msg_number code above and below this block - msg_number += 1; - if (head_rot_chg < THRESHOLD_HEAD_ROT_QDOT) - { - //LL_INFOS("Messaging") << "head rot " << head_rotation << LL_ENDL; - LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", head_rot_chg " << head_rot_chg << LL_ENDL; - } - if (cam_rot_chg.magVec() > ROTATION_THRESHOLD) - { - LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", cam rot " << cam_rot_chg.magVec() << LL_ENDL; - } - if (cam_center_chg.magVec() > TRANSLATE_THRESHOLD) - { - LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", cam center " << cam_center_chg.magVec() << LL_ENDL; - } -// if (drag_delta_chg.magVec() > TRANSLATE_THRESHOLD) -// { -// LL_INFOS("Messaging") << "drag delta " << drag_delta_chg.magVec() << LL_ENDL; -// } - if (control_flag_change) + // check to see if anything changed + // use a do-while-false to provide easy way to break out as soon as we find something changed + do { - LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", dcf = " << control_flag_change << LL_ENDL; - } -*/ + // start with the easy evaluations and progress to more complicated - duplicate_count = 0; - } - else - { - duplicate_count++; - - if (head_rot_chg < MAX_HEAD_ROT_QDOT && duplicate_count < AGENT_UPDATES_PER_SECOND) - { - // The head_rotation is sent for updating things like attached guns. - // We only trigger a new update when head_rotation deviates beyond - // some threshold from the last update, however this can break fine - // adjustments when trying to aim an attached gun, so what we do here - // (where we would normally skip sending an update when nothing has changed) - // is gradually reduce the threshold to allow a better update to - // eventually get sent... should update to within 0.5 degrees in less - // than a second. - if (head_rot_chg < THRESHOLD_HEAD_ROT_QDOT + (MAX_HEAD_ROT_QDOT - THRESHOLD_HEAD_ROT_QDOT) * duplicate_count / AGENT_UPDATES_PER_SECOND) + // check render_state + if (last_render_state != render_state) { - duplicate_count = 0; + send_update = true; + break; } - else + + // check flags + if (last_flags != flags) { - return; + send_update = true; + break; } - } - else - { - return; - } - } - if (duplicate_count < DUP_MSGS && !gDisconnected) - { - /* More diagnostics to count AgentUpdate messages - static S32 update_sec = 0; - static S32 update_count = 0; - static S32 max_update_count = 0; - S32 cur_sec = lltrunc( LLTimer::getTotalSeconds() ); - update_count += 1; - if (cur_sec != update_sec) - { - if (update_sec != 0) + // check translation + constexpr F32 TRANSLATE_THRESHOLD = 0.01f; + if ((last_camera_pos_agent - camera_pos_agent).magVec() > TRANSLATE_THRESHOLD) { - update_sec = cur_sec; - //msg_number = 0; - max_update_count = llmax(max_update_count, update_count); - LL_INFOS() << "Sent " << update_count << " AgentUpdate messages per second, max is " << max_update_count << LL_ENDL; + send_update = true; + break; } - update_sec = cur_sec; - update_count = 0; - } - */ - - // Build the message - msg->newMessageFast(_PREHASH_AgentUpdate); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->addQuatFast(_PREHASH_BodyRotation, body_rotation); - msg->addQuatFast(_PREHASH_HeadRotation, head_rotation); - msg->addU8Fast(_PREHASH_State, render_state); - msg->addU8Fast(_PREHASH_Flags, flags); -// if (camera_pos_agent.mV[VY] > 255.f) -// { -// LL_INFOS("Messaging") << "Sending camera center " << camera_pos_agent << LL_ENDL; -// } - - msg->addVector3Fast(_PREHASH_CameraCenter, camera_pos_agent); - msg->addVector3Fast(_PREHASH_CameraAtAxis, LLViewerCamera::getInstance()->getAtAxis()); - msg->addVector3Fast(_PREHASH_CameraLeftAxis, LLViewerCamera::getInstance()->getLeftAxis()); - msg->addVector3Fast(_PREHASH_CameraUpAxis, LLViewerCamera::getInstance()->getUpAxis()); - msg->addF32Fast(_PREHASH_Far, gAgentCamera.mDrawDistance); + // check camera rotation + // Note: we are using the sine small angle approximation trick here + constexpr F32 RADIANS_PER_DEGREE = F_PI / 360.f; + constexpr F32 CAMERA_AT_THRESHOLD = 0.2f * RADIANS_PER_DEGREE; + if ((last_camera_at - camera_at).magVec() > CAMERA_AT_THRESHOLD) + { + send_update = true; + break; + } - msg->addU32Fast(_PREHASH_ControlFlags, control_flags); + // check head rotation + constexpr F64 MIN_HEAD_ROT_QDOT = 0.9997; // ~= 2.5 degrees -- if its less than this we need to update head_rot + constexpr F64 MAX_HEAD_ROT_QDOT = 0.99999; // ~= 0.5 degrees -- if its greater than this then we consider it close enough - if (gDebugClicks) - { - if (control_flags & AGENT_CONTROL_LBUTTON_DOWN) + if (fabs((F64)(dot(last_body_rot, body_rotation))) < MIN_HEAD_ROT_QDOT) { - LL_INFOS("Messaging") << "AgentUpdate left button down" << LL_ENDL; + send_update = true; + break; } - if (control_flags & AGENT_CONTROL_LBUTTON_UP) + F64 head_rot_qdot = fabs((F64)(dot(last_head_rot, head_rotation))); + if (head_rot_qdot > MAX_HEAD_ROT_QDOT) { - LL_INFOS("Messaging") << "AgentUpdate left button up" << LL_ENDL; + // close enough + return; } - } + else if (head_rot_qdot < MIN_HEAD_ROT_QDOT) + { + // way off + send_update = true; + break; + } + + // Finally, if we get here then head_rot_qdot is somewhere between MIN_ and MAX_HEAD_ROT_QDOT + + // The head_rotation is sent for updating things like attached guns. + // We only trigger a new update when head_rotation deviates beyond + // some threshold from the last update, however this can break fine + // adjustments when trying to aim an attached gun, so what we do here + // (where we would normally skip sending an update when nothing has changed) + // is linearly increase the min threshold until an update is sent. + // Min threshold should update to MAX_HEAD_ROT_QDOT within THRESHOLD_GROWTH_PERIOD. + constexpr F64 THRESHOLD_GROWTH_PERIOD = 0.5; + constexpr F64 threshold_growth_per_sec = (MAX_HEAD_ROT_QDOT - MIN_HEAD_ROT_QDOT) / THRESHOLD_GROWTH_PERIOD; + send_update = head_rot_qdot < MIN_HEAD_ROT_QDOT + sec_since_last_send * threshold_growth_per_sec; + } while (false); + } + + if (!send_update) + { + return; + } - gAgent.enableControlFlagReset(); + // Build the message + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_AgentUpdate); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->addQuatFast(_PREHASH_BodyRotation, body_rotation); + msg->addQuatFast(_PREHASH_HeadRotation, head_rotation); + msg->addU8Fast(_PREHASH_State, render_state); + msg->addU8Fast(_PREHASH_Flags, flags); - if (!send_reliable) + msg->addVector3Fast(_PREHASH_CameraCenter, camera_pos_agent); + msg->addVector3Fast(_PREHASH_CameraAtAxis, camera_at); + msg->addVector3Fast(_PREHASH_CameraLeftAxis, LLViewerCamera::getInstance()->getLeftAxis()); + msg->addVector3Fast(_PREHASH_CameraUpAxis, LLViewerCamera::getInstance()->getUpAxis()); + msg->addF32Fast(_PREHASH_Far, gAgentCamera.mDrawDistance); + + msg->addU32Fast(_PREHASH_ControlFlags, control_flags); + + if (gDebugClicks) + { + if (control_flags & AGENT_CONTROL_LBUTTON_DOWN) { - gAgent.sendMessage(); + LL_INFOS("Messaging") << "AgentUpdate left button down" << LL_ENDL; } - else + + if (control_flags & AGENT_CONTROL_LBUTTON_UP) { - gAgent.sendReliableMessage(); + LL_INFOS("Messaging") << "AgentUpdate left button up" << LL_ENDL; } + } -// LL_DEBUGS("Messaging") << "agent " << avatar_pos_agent << " cam " << camera_pos_agent << LL_ENDL; - - // Copy the old data - last_head_rot = head_rotation; - last_render_state = render_state; - last_camera_pos_agent = camera_pos_agent; - last_camera_at = LLViewerCamera::getInstance()->getAtAxis(); - last_camera_left = LLViewerCamera::getInstance()->getLeftAxis(); - last_camera_up = LLViewerCamera::getInstance()->getUpAxis(); - last_control_flags = control_flags; - last_flags = flags; + if (send_reliable) + { + gAgent.sendReliableMessage(); + } + else + { + gAgent.sendMessage(); } -} + // remember last update data + last_send_time = now; + last_control_flags = control_flags; + last_render_state = render_state; + last_flags = flags; + last_body_rot = body_rotation; + last_head_rot = head_rotation; + last_camera_pos_agent = camera_pos_agent; + last_camera_at = camera_at; +} // sounds can arrive before objects, store them for a short time // Note: this is a workaround for MAINT-4743, real fix would be to make @@ -3780,7 +3600,7 @@ void process_kill_object(LLMessageSystem *mesgsys, void **user_data) U32 local_id; mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i); - LLViewerObjectList::getUUIDFromLocal(id, local_id, ip, port); + gObjectList.getUUIDFromLocal(id, local_id, ip, port); if (id == LLUUID::null) { LL_DEBUGS("Messaging") << "Unknown kill for local " << local_id << LL_ENDL; @@ -3850,7 +3670,7 @@ void process_time_synch(LLMessageSystem *mesgsys, void **user_data) LLWorld::getInstance()->setSpaceTimeUSec(space_time_usec); - LL_DEBUGS("WindlightSync") << "Sun phase: " << phase << " rad = " << fmodf(phase / F_TWO_PI + 0.25, 1.f) * 24.f << " h" << LL_ENDL; + LL_DEBUGS("WindlightSync") << "Sun phase: " << phase << " rad = " << fmodf(phase / F_TWO_PI + 0.25f, 1.f) * 24.f << " h" << LL_ENDL; /* LAPRAS We decode these parts of the message but ignore them @@ -3869,7 +3689,7 @@ void process_sound_trigger(LLMessageSystem *msg, void **) } U64 region_handle = 0; - F32 gain = 0; + F32 gain = 0.f; LLUUID sound_id; LLUUID owner_id; LLUUID object_id; @@ -3970,7 +3790,7 @@ void process_preload_sound(LLMessageSystem *msg, void **user_data) if (gAgent.canAccessMaturityAtGlobal(pos_global)) { // Add audioData starts a transfer internally. - sourcep->addAudioData(datap, FALSE); + sourcep->addAudioData(datap, false); } } @@ -4085,7 +3905,7 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data) LLViewerRegion* regionp = gAgent.getRegion(); if (regionp) { - BOOL was_flying = gAgent.getFlying(); + bool was_flying = gAgent.getFlying(); regionp->setRegionFlags(region_flags); regionp->setMaxTasks(max_tasks_per_region); // HACK: This makes agents drop from the sky if the region is @@ -4148,7 +3968,7 @@ void process_avatar_animation(LLMessageSystem *mesgsys, void **user_data) // See EXT-2781. if (animation_id == ANIM_AGENT_STANDUP && gAgent.getFlying()) { - gAgent.setFlying(FALSE); + gAgent.setFlying(false); } if (i < num_source_blocks) @@ -4158,9 +3978,9 @@ void process_avatar_animation(LLMessageSystem *mesgsys, void **user_data) LLViewerObject* object = gObjectList.findObject(object_id); if (object) { - object->setFlagsWithoutUpdate(FLAGS_ANIM_SOURCE, TRUE); + object->setFlagsWithoutUpdate(FLAGS_ANIM_SOURCE, true); - BOOL anim_found = FALSE; + bool anim_found = false; LLVOAvatar::AnimSourceIterator anim_it = avatarp->mAnimationSources.find(object_id); for (;anim_it != avatarp->mAnimationSources.end(); ++anim_it) { @@ -4172,7 +3992,7 @@ void process_avatar_animation(LLMessageSystem *mesgsys, void **user_data) } if (anim_it->second == animation_id) { - anim_found = TRUE; + anim_found = true; break; } } @@ -4299,7 +4119,7 @@ void process_camera_constraint(LLMessageSystem *mesgsys, void **user_data) gAgentCamera.setCameraCollidePlane(cameraCollidePlane); } -void near_sit_object(BOOL success, void *data) +void near_sit_object(bool success, void *data) { if (success) { @@ -4317,7 +4137,7 @@ void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data) LLVector3 sitPosition; LLQuaternion sitRotation; LLUUID sitObjectID; - BOOL use_autopilot; + bool use_autopilot; mesgsys->getUUIDFast(_PREHASH_SitObject, _PREHASH_ID, sitObjectID); mesgsys->getBOOLFast(_PREHASH_SitTransform, _PREHASH_AutoPilot, use_autopilot); mesgsys->getVector3Fast(_PREHASH_SitTransform, _PREHASH_SitPosition, sitPosition); @@ -4326,7 +4146,7 @@ void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data) mesgsys->getVector3Fast(_PREHASH_SitTransform, _PREHASH_CameraEyeOffset, camera_eye); LLVector3 camera_at; mesgsys->getVector3Fast(_PREHASH_SitTransform, _PREHASH_CameraAtOffset, camera_at); - BOOL force_mouselook; + bool force_mouselook; mesgsys->getBOOLFast(_PREHASH_SitTransform, _PREHASH_ForceMouselook, force_mouselook); if (isAgentAvatarValid() && dist_vec_squared(camera_eye, camera_at) > CAMERA_POSITION_THRESHOLD_SQUARED) @@ -4337,7 +4157,7 @@ void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data) gAgentCamera.setForceMouselook(force_mouselook); // Forcing turning off flying here to prevent flying after pressing "Stand" // to stand up from an object. See EXT-1655. - gAgent.setFlying(FALSE); + gAgent.setFlying(false); LLViewerObject* object = gObjectList.findObject(sitObjectID); if (object) @@ -4385,7 +4205,7 @@ void process_set_follow_cam_properties(LLMessageSystem *mesgsys, void **user_dat LLViewerObject* objectp = gObjectList.findObject(source_id); if (objectp) { - objectp->setFlagsWithoutUpdate(FLAGS_CAMERA_SOURCE, TRUE); + objectp->setFlagsWithoutUpdate(FLAGS_CAMERA_SOURCE, true); } S32 num_objects = mesgsys->getNumberOfBlocks("CameraProperty"); @@ -4570,11 +4390,11 @@ void process_user_list_reply(LLMessageSystem *msg, void **user_data) if (status & 0x01) { - dialog_friends_add_friend(buffer, TRUE); + dialog_friends_add_friend(buffer, true); } else { - dialog_friends_add_friend(buffer, FALSE); + dialog_friends_add_friend(buffer, false); } } @@ -4751,12 +4571,12 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg) // and agent ids for name lookup. S32 transaction_type = 0; LLUUID source_id; - BOOL is_source_group = FALSE; + bool is_source_group = false; LLUUID dest_id; - BOOL is_dest_group = FALSE; + bool is_dest_group = false; S32 amount = 0; std::string item_description; - BOOL success = FALSE; + bool success = false; msg->getS32("TransactionInfo", "TransactionType", transaction_type); msg->getUUID("TransactionInfo", "SourceID", source_id); @@ -5218,9 +5038,9 @@ bool attempt_standard_notification(LLMessageSystem* msgsystem) gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), - FALSE, //UI + false, //UI gSavedSettings.getBOOL("RenderHUDInSnapshot"), - FALSE, + false, LLSnapshotModel::SNAPSHOT_TYPE_COLOR, LLSnapshotModel::SNAPSHOT_FORMAT_PNG); } @@ -5323,9 +5143,9 @@ static void process_special_alert_messages(const std::string & message) gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), - FALSE, + false, gSavedSettings.getBOOL("RenderHUDInSnapshot"), - FALSE, + false, LLSnapshotModel::SNAPSHOT_TYPE_COLOR, LLSnapshotModel::SNAPSHOT_FORMAT_PNG); } @@ -5346,7 +5166,7 @@ void process_agent_alert_message(LLMessageSystem* msgsystem, void** user_data) if (!attempt_standard_notification(msgsystem)) { - BOOL modal = FALSE; + bool modal = false; msgsystem->getBOOL("AlertData", "Modal", modal); process_alert_core(message, modal); } @@ -5369,7 +5189,7 @@ void process_alert_message(LLMessageSystem *msgsystem, void **user_data) if (!attempt_standard_notification(msgsystem)) { - BOOL modal = FALSE; + bool modal = false; process_alert_core(message, modal); static LLCachedControl<S32> ban_lines_mode(gSavedSettings , "ShowBanLines" , LLViewerParcelMgr::PARCEL_BAN_LINES_ON_COLLISION); @@ -5404,7 +5224,7 @@ bool handle_special_alerts(const std::string &pAlertName) return isHandled; } -void process_alert_core(const std::string& message, BOOL modal) +void process_alert_core(const std::string& message, bool modal) { const std::string ALERT_PREFIX("ALERT: "); const std::string NOTIFY_PREFIX("NOTIFY: "); @@ -5528,7 +5348,7 @@ void process_mean_collision_alert_message(LLMessageSystem *msgsystem, void **use type = (EMeanCollisionType)u8type; - BOOL b_found = FALSE; + bool b_found = false; for (mean_collision_list_t::iterator iter = gMeanCollisionList.begin(); iter != gMeanCollisionList.end(); ++iter) @@ -5538,7 +5358,7 @@ void process_mean_collision_alert_message(LLMessageSystem *msgsystem, void **use { mcd->mTime = time; mcd->mMag = mag; - b_found = TRUE; + b_found = true; break; } } @@ -5562,7 +5382,7 @@ void process_frozen_message(LLMessageSystem *msgsystem, void **user_data) // make sure the cursor is back to the usual default since the // alert is probably due to some kind of error. gViewerWindow->getWindow()->resetBusyCount(); - BOOL b_frozen; + bool b_frozen; msgsystem->getBOOL("FrozenData", "Data", b_frozen); @@ -5581,7 +5401,7 @@ void process_economy_data(LLMessageSystem *msg, void** /*user_data*/) LL_DEBUGS("Benefits") << "Received economy data, not currently used" << LL_ENDL; } -void notify_cautioned_script_question(const LLSD& notification, const LLSD& response, S32 orig_questions, BOOL granted) +void notify_cautioned_script_question(const LLSD& notification, const LLSD& response, S32 orig_questions, bool granted) { // only continue if at least some permissions were requested if (orig_questions) @@ -5600,7 +5420,7 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp // try to lookup viewerobject that corresponds to the object that // requested permissions (here, taskid->requesting object id) - BOOL foundpos = FALSE; + bool foundpos = false; LLViewerObject* viewobj = gObjectList.findObject(notification["payload"]["task_id"].asUUID()); if (viewobj) { @@ -5616,7 +5436,7 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp std::string formatpos = llformat("%.1f, %.1f,%.1f", objpos[VX], objpos[VY], objpos[VZ]); notice.setArg("[REGIONPOS]", formatpos); - foundpos = TRUE; + foundpos = true; } } @@ -5629,7 +5449,7 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp // check each permission that was requested, and list each // permission that has been flagged as a caution permission - BOOL caution = FALSE; + bool caution = false; S32 count = 0; std::string perms; for (const script_perm_t& script_perm : SCRIPT_PERMISSIONS) @@ -5638,7 +5458,7 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp && script_perm.caution) { count++; - caution = TRUE; + caution = true; // add a comma before the permission description if it is not the first permission // added to the list or the last permission to check @@ -5658,7 +5478,7 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp if (caution) { LLChat chat(notice.getString()); - // LLFloaterChat::addChat(chat, FALSE, FALSE); + // LLFloaterChat::addChat(chat, false, false); } } } @@ -5699,13 +5519,13 @@ bool script_question_cb(const LLSD& notification, const LLSD& response) } // check whether permissions were granted or denied - BOOL allowed = TRUE; + bool allowed = true; // the "yes/accept" button is the first button in the template, making it button 0 // if any other button was clicked, the permissions were denied if (option != 0) { new_questions = 0; - allowed = FALSE; + allowed = false; } else if(experience.notNull()) { @@ -5991,7 +5811,7 @@ void container_inventory_arrived(LLViewerObject* object, LLSaleInfo::DEFAULT, item->getFlags(), creation_date_utc); - new_item->updateServer(TRUE); + new_item->updateServer(true); gInventory.updateItem(new_item); } } @@ -6032,7 +5852,7 @@ void container_inventory_arrived(LLViewerObject* object, LLSaleInfo::DEFAULT, item->getFlags(), creation_date_utc); - new_item->updateServer(TRUE); + new_item->updateServer(true); gInventory.updateItem(new_item); gInventory.notifyObservers(); if(active_panel) @@ -6042,7 +5862,7 @@ void container_inventory_arrived(LLViewerObject* object, } // we've got the inventory, now delete this object if this was a take - BOOL delete_object = (BOOL)(intptr_t)data; + bool delete_object = (bool)(intptr_t)data; LLViewerRegion *region = gAgent.getRegion(); if (delete_object && region) { @@ -6192,7 +6012,7 @@ void process_teleport_local(LLMessageSystem *msg,void**) // after tp, keep the teleport state and let progress screen clear it after a short delay // (progress screen is active but not visible) *TODO: remove when SVC-5290 is fixed gTeleportDisplayTimer.reset(); - gTeleportDisplay = TRUE; + gTeleportDisplay = true; } else { @@ -6205,11 +6025,11 @@ void process_teleport_local(LLMessageSystem *msg,void**) // Sim tells us whether the new position is off the ground if (teleport_flags & TELEPORT_FLAGS_IS_FLYING) { - gAgent.setFlying(TRUE); + gAgent.setFlying(true); } else { - gAgent.setFlying(FALSE); + gAgent.setFlying(false); } gAgent.setPositionAgent(pos); @@ -6217,13 +6037,13 @@ void process_teleport_local(LLMessageSystem *msg,void**) if ( !(gAgent.getTeleportKeepsLookAt() && LLViewerJoystick::getInstance()->getOverrideCamera()) ) { - gAgentCamera.resetView(TRUE, TRUE); + gAgentCamera.resetView(true, true); } // send camera update to new region gAgentCamera.updateCamera(); - send_agent_update(TRUE, TRUE); + send_agent_update(true, true); // Let the interested parties know we've teleported. // Vadim *HACK: Agent position seems to get reset (to render position?) @@ -6278,8 +6098,8 @@ void send_group_notice(const LLUUID& group_id, item_def["owner_id"] = item->getPermissions().getOwner(); std::ostringstream ostr; LLSDSerialize::serialize(item_def, ostr, LLSDSerialize::LLSD_XML); - bin_bucket_size = ostr.str().copy( - (char*)bin_bucket, ostr.str().size()); + bin_bucket_size = static_cast<S32>(ostr.str().copy( + (char*)bin_bucket, ostr.str().size())); bin_bucket[bin_bucket_size] = '\0'; } else @@ -6469,7 +6289,7 @@ void send_improved_im(const LLUUID& to_id, pack_instant_message( gMessageSystem, gAgent.getID(), - FALSE, + false, gAgent.getSessionID(), to_id, name, @@ -6740,7 +6560,7 @@ void process_load_url(LLMessageSystem* msg, void**) { LLUUID object_id; LLUUID owner_id; - BOOL owner_is_group; + bool owner_is_group; char object_name[256]; /* Flawfinder: ignore */ char message[256]; /* Flawfinder: ignore */ char url[256]; /* Flawfinder: ignore */ @@ -6818,7 +6638,7 @@ void process_initiate_download(LLMessageSystem* msg, void**) sim_filename, LL_PATH_NONE, msg->getSender(), - FALSE, // don't delete remote + false, // don't delete remote callback_download_complete, (void**)new std::string(viewer_filename)); } @@ -6852,7 +6672,7 @@ void process_script_teleport_request(LLMessageSystem* msg, void**) // remove above two lines and replace with below line // to re-enable parcel browser for llMapDestination() - // LLURLDispatcher::dispatch(LLSLURL::buildSLURL(sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]), FALSE); + // LLURLDispatcher::dispatch(LLSLURL::buildSLURL(sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]), false); } @@ -6911,7 +6731,7 @@ void process_covenant_reply(LLMessageSystem* msg, void**) LLFloaterBuyLand::updateLastModified(last_modified); // load the actual covenant asset data - const BOOL high_priority = TRUE; + const bool high_priority = true; if (covenant_id.notNull()) { gAssetStorage->getEstateAsset(gAgent.getRegionHost(), @@ -6952,7 +6772,8 @@ void onCovenantLoadComplete(const LLUUID& asset_uuid, { LL_DEBUGS("Messaging") << "onCovenantLoadComplete()" << LL_ENDL; std::string covenant_text; - if(0 == status) + std::unique_ptr<LLViewerTextEditor> editorp; + if (0 == status) { LLFileSystem file(asset_uuid, type, LLFileSystem::READ); @@ -6973,13 +6794,13 @@ void onCovenantLoadComplete(const LLUUID& asset_uuid, { LL_WARNS("Messaging") << "Problem importing estate covenant." << LL_ENDL; covenant_text = "Problem importing estate covenant."; + delete editor; } else { // Version 0 (just text, doesn't include version number) - covenant_text = editor->getText(); + editorp.reset(editor); // Use covenant from editorp; } - delete editor; } else { @@ -7005,17 +6826,32 @@ void onCovenantLoadComplete(const LLUUID& asset_uuid, LL_WARNS("Messaging") << "Problem loading notecard: " << status << LL_ENDL; } - LLPanelEstateCovenant::updateCovenantText(covenant_text, asset_uuid); - LLPanelLandCovenant::updateCovenantText(covenant_text); - LLFloaterBuyLand::updateCovenantText(covenant_text, asset_uuid); - LLPanelPlaceProfile* panel = LLFloaterSidePanelContainer::getPanel<LLPanelPlaceProfile>("places", "panel_place_profile"); - if (panel) + if (editorp) { - panel->updateCovenantText(covenant_text); + LLPanelEstateCovenant::updateCovenant(editorp.get(), asset_uuid); + LLPanelLandCovenant::updateCovenant(editorp.get()); + LLFloaterBuyLand::updateCovenant(editorp.get(), asset_uuid); + } + else + { + LLPanelEstateCovenant::updateCovenantText(covenant_text, asset_uuid); + LLPanelLandCovenant::updateCovenantText(covenant_text); + LLFloaterBuyLand::updateCovenantText(covenant_text, asset_uuid); } -} + if (LLPanelPlaceProfile* panel = LLFloaterSidePanelContainer::getPanel<LLPanelPlaceProfile>("places", "panel_place_profile")) + { + if (editorp) + { + panel->updateCovenant(editorp.get()); + } + else + { + panel->updateCovenantText(covenant_text); + } + } +} void process_feature_disabled_message(LLMessageSystem* msg, void**) { |