diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 6805d5431..c234be94c 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -222,6 +222,7 @@ #include "wlfPanel_AdvSettings.h" //Lower right Windlight and Rendering options #include "lldaycyclemanager.h" #include "llfloaterblacklist.h" +#include "scriptcounter.h" #include "shfloatermediaticker.h" #include "llpacketring.h" // @@ -2961,6 +2962,22 @@ void pass_processObjectPropertiesFamily(LLMessageSystem *msg, void**) JCFloaterAreaSearch::processObjectPropertiesFamily(msg, NULL); } +void process_script_running_reply(LLMessageSystem* msg, void** v) +{ + LLLiveLSLEditor::processScriptRunningReply(msg, v); + if (ScriptCounter::sCheckMap.size()) + { + LLUUID item_id; + msg->getUUIDFast(_PREHASH_Script, _PREHASH_ItemID, item_id); + std::map::iterator it = ScriptCounter::sCheckMap.find(item_id); + if (it != ScriptCounter::sCheckMap.end()) + { + it->second->processRunningReply(msg); + ScriptCounter::sCheckMap.erase(it); + } + } +} + void register_viewer_callbacks(LLMessageSystem* msg) { msg->setHandlerFuncFast(_PREHASH_LayerData, process_layer_data ); @@ -3011,8 +3028,7 @@ void register_viewer_callbacks(LLMessageSystem* msg) msg->setHandlerFuncFast(_PREHASH_CoarseLocationUpdate, LLWorld::processCoarseUpdate, NULL); msg->setHandlerFuncFast(_PREHASH_ReplyTaskInventory, LLViewerObject::processTaskInv, NULL); msg->setHandlerFuncFast(_PREHASH_DerezContainer, process_derez_container, NULL); - msg->setHandlerFuncFast(_PREHASH_ScriptRunningReply, - &LLLiveLSLEditor::processScriptRunningReply); + msg->setHandlerFuncFast(_PREHASH_ScriptRunningReply, process_script_running_reply); msg->setHandlerFuncFast(_PREHASH_DeRezAck, process_derez_ack); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index db59ca53b..7f73a760d 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -3008,6 +3008,7 @@ class LLScriptCount : public view_listener_t { if (LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject()) { + if (ScriptCounter::getInstance(object->getID())) return true; ScriptCounter* sc = new ScriptCounter(false, object); sc->requestInventories(); // sc will destroy itself @@ -3022,6 +3023,7 @@ class LLScriptDelete : public view_listener_t { if (LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject()) { + if (ScriptCounter::getInstance(object->getID())) return true; ScriptCounter* sc = new ScriptCounter(true, object); sc->requestInventories(); // sc will destroy itself diff --git a/indra/newview/scriptcounter.cpp b/indra/newview/scriptcounter.cpp index 3d9ea682f..f8d2aafd4 100644 --- a/indra/newview/scriptcounter.cpp +++ b/indra/newview/scriptcounter.cpp @@ -34,6 +34,7 @@ #include "scriptcounter.h" #include "llavatarnamecache.h" +#include "llviewerregion.h" #include "llselectmgr.h" #include "lltrans.h" #include "llvoavatar.h" @@ -54,13 +55,19 @@ namespace } } +std::map ScriptCounter::sCheckMap; + ScriptCounter::ScriptCounter(bool do_delete, LLViewerObject* object) -: doDelete(do_delete) +: LLInstanceTracker(object->getID()) +, doDelete(do_delete) , foo(object) , inventories() , objectCount() , requesting(true) , scriptcount() +, checking() +, mRunningCount() +, mMonoCount() { llassert(foo); // Object to ScriptCount must not be null } @@ -152,15 +159,47 @@ void ScriptCounter::inventoryChanged(LLViewerObject* obj, LLInventoryObject::obj end = inv->end(); } } + else + { + const LLUUID& id = asset->getUUID(); + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_GetScriptRunning); + msg->nextBlockFast(_PREHASH_Script); + msg->addUUIDFast(_PREHASH_ObjectID, obj->getID()); + msg->addUUIDFast(_PREHASH_ItemID, id); + msg->sendReliable(obj->getRegion()->getHost()); + sCheckMap[id] = this; + ++checking; + } } } + summarize(); +} + +void ScriptCounter::processRunningReply(LLMessageSystem* msg) +{ + BOOL is; + msg->getBOOLFast(_PREHASH_Script, _PREHASH_Running, is); + if (is) ++mRunningCount; + msg->getBOOLFast(_PREHASH_Script, "Mono", is); + if (is) ++mMonoCount; + --checking; + + summarize(); +} + +void ScriptCounter::summarize() +{ // Done requesting and there are no more inventories to receive - if (!requesting && !inventories) + // And we're not checking any scripts for running/mono properties + if (!requesting && !inventories && !checking) { LLStringUtil::format_map_t args; args["SCRIPTS"] = stringize(scriptcount); args["OBJECTS"] = stringize(objectCount); + args["RUNNING"] = stringize(mRunningCount); + args["MONO"] = stringize(mMonoCount); if (foo->isAvatar()) LLAvatarNameCache::get(foo->getID(), boost::bind(countedScriptsOnAvatar, args, _2)); else diff --git a/indra/newview/scriptcounter.h b/indra/newview/scriptcounter.h index 0f3afcf75..78fd32058 100644 --- a/indra/newview/scriptcounter.h +++ b/indra/newview/scriptcounter.h @@ -33,7 +33,7 @@ #include "llvoinventorylistener.h" -class ScriptCounter : public LLVOInventoryListener +class ScriptCounter : public LLInstanceTracker, public LLVOInventoryListener { public: ScriptCounter(bool do_delete, LLViewerObject* object); @@ -45,6 +45,9 @@ public: private: void requestInventoriesFor(LLViewerObject* object); void requestInventoryFor(LLViewerObject* object); + friend void process_script_running_reply(LLMessageSystem* msg, void**); + void processRunningReply(LLMessageSystem* msg); + void summarize(); // Check if finished, if so, output and destroy. bool doDelete; LLViewerObject* foo; @@ -52,6 +55,10 @@ private: int objectCount; bool requesting; int scriptcount; + static std::map sCheckMap; // Map of scripts being checked running/mono and by which instance + int checking; // Number of scripts being counter by this instance + int mRunningCount; + int mMonoCount; }; #endif //SCRIPTCOUNTER_H diff --git a/indra/newview/skins/default/xui/en-us/strings.xml b/indra/newview/skins/default/xui/en-us/strings.xml index 4550ba486..a33f27d48 100644 --- a/indra/newview/skins/default/xui/en-us/strings.xml +++ b/indra/newview/skins/default/xui/en-us/strings.xml @@ -3075,8 +3075,8 @@ Where tag = tag string to match. Removes bot's matching the tag. Counting scripts, please wait... - Counted [SCRIPTS] scripts in [OBJECTS] attachments on [NAME]. - Counted [SCRIPTS] scripts in [OBJECTS] objects. + Counted [SCRIPTS] scripts in [OBJECTS] attachments on [NAME]. ([RUNNING] running, [MONO] mono.) + Counted [SCRIPTS] scripts in [OBJECTS] objects. ([RUNNING] running, [MONO] mono.) Deleted [SCRIPTS] scripts in [OBJECTS] objects. took a snapshot