From 35d8994da948239aa663a08e8df86b96c2763241 Mon Sep 17 00:00:00 2001 From: phr0z3nt04st Date: Mon, 14 Jun 2010 23:39:43 -0500 Subject: [PATCH] Radar Keys is gangsta business. --- indra/newview/llfloateravatarlist.cpp | 112 +++++++++++++++++++++++++- indra/newview/llfloateravatarlist.h | 4 + indra/newview/llstartup.cpp | 7 +- 3 files changed, 121 insertions(+), 2 deletions(-) diff --git a/indra/newview/llfloateravatarlist.cpp b/indra/newview/llfloateravatarlist.cpp index 1584a1396..c6b6acf82 100644 --- a/indra/newview/llfloateravatarlist.cpp +++ b/indra/newview/llfloateravatarlist.cpp @@ -172,6 +172,20 @@ bool LLAvatarListEntry::getAlive() { mInSimFrame = U32_MAX; chat_avatar_status(mName, mID, ALERT_TYPE_SIM, false); + if(gSavedSettings.getBOOL("RadarChatKeys")) + { + gMessageSystem->newMessage("ScriptDialogReply"); + gMessageSystem->nextBlock("AgentData"); + gMessageSystem->addUUID("AgentID", gAgent.getID()); + gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); + gMessageSystem->nextBlock("Data"); + gMessageSystem->addUUID("ObjectID", gAgent.getID()); + gMessageSystem->addS32("ChatChannel", -777777777); + gMessageSystem->addS32("ButtonIndex", 1); + gMessageSystem->addString("ButtonLabel",llformat("%d,%d,", gFrameCount, 0) + mID.asString()); + gAgent.sendReliableMessage(); + } + } if (mInDrawFrame != U32_MAX && (current - mInDrawFrame) >= 2) { @@ -1030,10 +1044,106 @@ void LLFloaterAvatarList::onClickGetKey(void *userdata) gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(buffer)); } +//static +void LLFloaterAvatarList::sendKeys() +{ + LLViewerRegion* regionp = gAgent.getRegion(); + if(!regionp)return;//ALWAYS VALIDATE DATA + std::ostringstream ids; + static int last_transact_num = 0; + int transact_num = (int)gFrameCount; + int num_ids = 0; + if(!gSavedSettings.getBOOL("RadarChatKeys")) + { + return; + } + + if(transact_num > last_transact_num) + { + last_transact_num = transact_num; + } + else + { + //on purpose, avatar IDs on map don't change until the next frame. + //no need to send more than once a frame. + return; + } + + if (!regionp) return; // caused crash if logged out/connection lost + for (int i = 0; i < regionp->mMapAvatarIDs.count(); i++) + { + const LLUUID &id = regionp->mMapAvatarIDs.get(i); + + ids << "," << id.asString(); + ++num_ids; + + + if(ids.tellp() > 200) + { + gMessageSystem->newMessage("ScriptDialogReply"); + gMessageSystem->nextBlock("AgentData"); + gMessageSystem->addUUID("AgentID", gAgent.getID()); + gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); + gMessageSystem->nextBlock("Data"); + gMessageSystem->addUUID("ObjectID", gAgent.getID()); + gMessageSystem->addS32("ChatChannel", -777777777); + gMessageSystem->addS32("ButtonIndex", 1); + gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); + gAgent.sendReliableMessage(); + + num_ids = 0; + ids.seekp(0); + ids.str(""); + } + } + if(num_ids > 0) + { + gMessageSystem->newMessage("ScriptDialogReply"); + gMessageSystem->nextBlock("AgentData"); + gMessageSystem->addUUID("AgentID", gAgent.getID()); + gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); + gMessageSystem->nextBlock("Data"); + gMessageSystem->addUUID("ObjectID", gAgent.getID()); + gMessageSystem->addS32("ChatChannel", -777777777); + gMessageSystem->addS32("ButtonIndex", 1); + gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); + gAgent.sendReliableMessage(); + } +} +//static +void LLFloaterAvatarList::sound_trigger_hook(LLMessageSystem* msg,void **) +{ + LLUUID sound_id,owner_id; + msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_SoundID, sound_id); + msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_OwnerID, owner_id); + if(owner_id == gAgent.getID() && sound_id == LLUUID("76c78607-93f9-f55a-5238-e19b1a181389")) + { + //lets ask if they want to turn it on. + if(gSavedSettings.getBOOL("RadarChatKeys")) + { + LLFloaterAvatarList::getInstance()->sendKeys(); + }else + { + LLSD args; + args["MESSAGE"] = "An object owned by you has request the keys from your radar.\nWould you like to enable announcing keys to objects in the sim?"; + LLNotifications::instance().add("GenericAlertYesCancel", args, LLSD(), onConfirmRadarChatKeys); + } + } +} +// static +void LLFloaterAvatarList::onConfirmRadarChatKeys(S32 option, LLSD payload) +{ + if(option == 0) // yes + { + gSavedSettings.setBOOL("RadarChatKeys",TRUE); + LLFloaterAvatarList::getInstance()->sendKeys(); + } +} +//static void LLFloaterAvatarList::onClickSendKeys(void *userdata) { - //TODO remove + LLFloaterAvatarList::getInstance()->sendKeys(); } static void send_freeze(const LLUUID& avatar_id, bool freeze) diff --git a/indra/newview/llfloateravatarlist.h b/indra/newview/llfloateravatarlist.h index de0a3f8f3..e3a5d11f9 100644 --- a/indra/newview/llfloateravatarlist.h +++ b/indra/newview/llfloateravatarlist.h @@ -181,6 +181,9 @@ public: std::string getSelectedName(); LLUUID getSelectedID(); + static void sound_trigger_hook(LLMessageSystem* msg,void **); + static void sendKeys(); + private: static LLFloaterAvatarList* sInstance; @@ -261,6 +264,7 @@ private: static void onCommitUpdateRate(LLUICtrl*, void *userdata); static void onClickSendKeys(void *userdata); + static void onConfirmRadarChatKeys(S32 option, LLSD payload); static void callbackIdle(void *userdata); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 99dceaf4c..5106580ca 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -725,6 +725,11 @@ void update_texture_fetch() gImageList.updateImages(0.10f); } +void hooked_process_sound_trigger(LLMessageSystem *msg, void **) +{ + process_sound_trigger(msg,NULL); + LLFloaterAvatarList::sound_trigger_hook(msg,NULL); +} // Returns false to skip other idle processing. Should only return // true when all initialization done. @@ -3195,7 +3200,7 @@ bool idle_startup() gDisplaySwapBuffers = TRUE; LLMessageSystem* msg = gMessageSystem; - msg->setHandlerFuncFast(_PREHASH_SoundTrigger, process_sound_trigger); + msg->setHandlerFuncFast(_PREHASH_SoundTrigger, hooked_process_sound_trigger); msg->setHandlerFuncFast(_PREHASH_PreloadSound, process_preload_sound); msg->setHandlerFuncFast(_PREHASH_AttachedSound, process_attached_sound); msg->setHandlerFuncFast(_PREHASH_AttachedSoundGainChange, process_attached_sound_gain_change);