Redid ScriptCounter entirely, should fix 182, if not just prevent the permanent failure condition.
Script Counter now shows the names of avatars in the user's desired format. Adds "Count Scripts in Selection" to the Tools menu. (Can count for multiple objects, quite useful for land owners, no?) Makes the Script Counting strings translatable. (ScriptCounting, ScriptCountAvatar, ScriptCountObject, and ScriptDeleteObject) ScriptCounter is no longer a giant pile of static, it goes away when it has run its course and multiple instances can exist simultaneously. Removes the silly unneeded parts of ScriptCounter, and thus removes it from llstartup.cpp Adds some nice documentation in comments, and moves some log output to proper places (although I commented it out, it proved quite spammy for high primcount objects, initial loop runs super fast) Trying to view this diff with no space changes is the best course of action, but even that will be tough... Adds a header guard to scriptcounter.h Hooks up menu function LLObjectVisibleScriptCount to Object.VisibleScriptCount, apparently this was never hooked up.... strange
This commit is contained in:
@@ -221,7 +221,6 @@
|
|||||||
#include "wlfPanel_AdvSettings.h" //Lower right Windlight and Rendering options
|
#include "wlfPanel_AdvSettings.h" //Lower right Windlight and Rendering options
|
||||||
#include "lldaycyclemanager.h"
|
#include "lldaycyclemanager.h"
|
||||||
#include "llfloaterblacklist.h"
|
#include "llfloaterblacklist.h"
|
||||||
#include "scriptcounter.h"
|
|
||||||
#include "shfloatermediaticker.h"
|
#include "shfloatermediaticker.h"
|
||||||
#include "llpacketring.h"
|
#include "llpacketring.h"
|
||||||
// </edit>
|
// </edit>
|
||||||
@@ -3225,7 +3224,6 @@ void pass_processObjectPropertiesFamily(LLMessageSystem *msg, void**)
|
|||||||
// Send the result to the corresponding requesters.
|
// Send the result to the corresponding requesters.
|
||||||
LLSelectMgr::processObjectPropertiesFamily(msg, NULL);
|
LLSelectMgr::processObjectPropertiesFamily(msg, NULL);
|
||||||
JCFloaterAreaSearch::processObjectPropertiesFamily(msg, NULL);
|
JCFloaterAreaSearch::processObjectPropertiesFamily(msg, NULL);
|
||||||
ScriptCounter::processObjectPropertiesFamily(msg,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_viewer_callbacks(LLMessageSystem* msg)
|
void register_viewer_callbacks(LLMessageSystem* msg)
|
||||||
|
|||||||
@@ -3009,7 +3009,12 @@ class LLScriptCount : public view_listener_t
|
|||||||
{
|
{
|
||||||
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
||||||
{
|
{
|
||||||
ScriptCounter::serializeSelection(false);
|
if (LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject())
|
||||||
|
{
|
||||||
|
ScriptCounter* sc = new ScriptCounter(false, object);
|
||||||
|
sc->requestInventories();
|
||||||
|
// sc will destroy itself
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -3018,7 +3023,12 @@ class LLScriptDelete : public view_listener_t
|
|||||||
{
|
{
|
||||||
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
||||||
{
|
{
|
||||||
ScriptCounter::serializeSelection(true);
|
if (LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject())
|
||||||
|
{
|
||||||
|
ScriptCounter* sc = new ScriptCounter(true, object);
|
||||||
|
sc->requestInventories();
|
||||||
|
// sc will destroy itself
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -9552,6 +9562,7 @@ void initialize_menus()
|
|||||||
addMenu(new LLObjectMeasure(), "Object.Measure");
|
addMenu(new LLObjectMeasure(), "Object.Measure");
|
||||||
addMenu(new LLObjectData(), "Object.Data");
|
addMenu(new LLObjectData(), "Object.Data");
|
||||||
addMenu(new LLScriptCount(), "Object.ScriptCount");
|
addMenu(new LLScriptCount(), "Object.ScriptCount");
|
||||||
|
addMenu(new LLObjectVisibleScriptCount(), "Object.VisibleScriptCount");
|
||||||
addMenu(new LLKillEmAll(), "Object.Destroy");
|
addMenu(new LLKillEmAll(), "Object.Destroy");
|
||||||
addMenu(new LLPowerfulWizard(), "Object.Explode");
|
addMenu(new LLPowerfulWizard(), "Object.Explode");
|
||||||
addMenu(new LLCanIHasKillEmAll(), "Object.EnableDestroy");
|
addMenu(new LLCanIHasKillEmAll(), "Object.EnableDestroy");
|
||||||
|
|||||||
@@ -31,378 +31,135 @@
|
|||||||
|
|
||||||
#include "llviewerprecompiledheaders.h"
|
#include "llviewerprecompiledheaders.h"
|
||||||
|
|
||||||
#include "llchat.h"
|
|
||||||
#include "llfloaterchat.h"
|
|
||||||
#include "scriptcounter.h"
|
#include "scriptcounter.h"
|
||||||
|
|
||||||
|
#include "llavatarnamecache.h"
|
||||||
#include "llselectmgr.h"
|
#include "llselectmgr.h"
|
||||||
#include "llviewerobjectlist.h"
|
#include "lltrans.h"
|
||||||
#include "llvoavatar.h"
|
#include "llvoavatar.h"
|
||||||
#include "llviewerregion.h"
|
#include "stringize.h"
|
||||||
#include "llwindow.h"
|
|
||||||
#include "lltransfersourceasset.h"
|
|
||||||
#include "llviewercontrol.h"
|
|
||||||
#include "llviewernetwork.h"
|
|
||||||
#include "llviewerobject.h"
|
|
||||||
#include "llpacketring.h"
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
ScriptCounter* ScriptCounter::sInstance;
|
|
||||||
U32 ScriptCounter::invqueries;
|
|
||||||
U32 ScriptCounter::status;
|
|
||||||
U32 ScriptCounter::scriptcount;
|
|
||||||
LLUUID ScriptCounter::reqObjectID;
|
|
||||||
LLDynamicArray<LLUUID> ScriptCounter::delUUIDS;
|
|
||||||
bool ScriptCounter::doDelete;
|
|
||||||
std::set<std::string> ScriptCounter::objIDS;
|
|
||||||
int ScriptCounter::objectCount;
|
|
||||||
LLViewerObject* ScriptCounter::foo;
|
|
||||||
void cmdline_printchat(std::string chat);
|
void cmdline_printchat(std::string chat);
|
||||||
std::stringstream ScriptCounter::sstr;
|
|
||||||
int ScriptCounter::countingDone;
|
|
||||||
|
|
||||||
ScriptCounter::ScriptCounter()
|
|
||||||
{
|
|
||||||
llassert_always(sInstance == NULL);
|
|
||||||
sInstance = this;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptCounter::~ScriptCounter()
|
|
||||||
{
|
|
||||||
sInstance = NULL;
|
|
||||||
}
|
|
||||||
void ScriptCounter::init()
|
|
||||||
{
|
|
||||||
if(!sInstance)
|
|
||||||
sInstance = new ScriptCounter();
|
|
||||||
status = IDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
LLVOAvatar* find_avatar_from_object( LLViewerObject* object );
|
LLVOAvatar* find_avatar_from_object( LLViewerObject* object );
|
||||||
|
|
||||||
LLVOAvatar* find_avatar_from_object( const LLUUID& object_id );
|
namespace
|
||||||
|
|
||||||
void ScriptCounter::showResult(std::string output)
|
|
||||||
{
|
{
|
||||||
LLChat chat;
|
void countedScriptsOnAvatar(LLStringUtil::format_map_t args, const LLAvatarName& av_name)
|
||||||
chat.mSourceType = CHAT_SOURCE_SYSTEM;
|
|
||||||
chat.mText = output;
|
|
||||||
LLFloaterChat::addChat(chat);
|
|
||||||
//sstr << scriptcount;
|
|
||||||
//cmdline_printchat(sstr.str());
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptCounter::processObjectPropertiesFamily(LLMessageSystem* msg, void** user_data)
|
|
||||||
{
|
{
|
||||||
LLUUID object_id;
|
|
||||||
msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_ObjectID,object_id );
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string user_msg;
|
LLAvatarNameCache::getPNSName(av_name, name);
|
||||||
msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Name, name);
|
args["NAME"] = name;
|
||||||
if(reqObjectID.notNull())
|
cmdline_printchat(LLTrans::getString("ScriptCountAvatar", args));
|
||||||
if(object_id == reqObjectID)
|
|
||||||
{
|
|
||||||
if(doDelete)
|
|
||||||
{
|
|
||||||
user_msg = llformat("Deleted %u scripts from object %s.", scriptcount, name.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
user_msg = llformat("Counted %u scripts in object %s.", scriptcount, name.c_str());
|
|
||||||
}
|
|
||||||
reqObjectID.setNull();
|
|
||||||
if(countingDone)
|
|
||||||
{
|
|
||||||
showResult(user_msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptCounter::processObjectProperties(LLMessageSystem* msg, void** user_data)
|
|
||||||
{
|
|
||||||
std::string user_msg;
|
|
||||||
LLUUID object_id;
|
|
||||||
msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_ObjectID,object_id );
|
|
||||||
std::string name;
|
|
||||||
msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Name, name);
|
|
||||||
if(reqObjectID.notNull())
|
|
||||||
if(object_id == reqObjectID)
|
|
||||||
{
|
|
||||||
if(doDelete)
|
|
||||||
{
|
|
||||||
user_msg = llformat("Deleted %u scripts from object %s.", scriptcount, name.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
user_msg = llformat("Counted %u scripts in object %s.", scriptcount, name.c_str());
|
|
||||||
}
|
|
||||||
reqObjectID.setNull();
|
|
||||||
if(countingDone)
|
|
||||||
{
|
|
||||||
showResult(user_msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptCounter::serializeSelection(bool delScript)
|
|
||||||
{
|
|
||||||
LLDynamicArray<LLViewerObject*> objectArray;
|
|
||||||
foo=LLSelectMgr::getInstance()->getSelection()->getPrimaryObject();
|
|
||||||
sstr.str("");
|
|
||||||
doDelete=false;
|
|
||||||
scriptcount=0;
|
|
||||||
objIDS.clear();
|
|
||||||
delUUIDS.clear();
|
|
||||||
objectCount=0;
|
|
||||||
countingDone=false;
|
|
||||||
reqObjectID.setNull();
|
|
||||||
if(foo)
|
|
||||||
{
|
|
||||||
if(foo->isAvatar())
|
|
||||||
{
|
|
||||||
LLVOAvatar* av=find_avatar_from_object(foo);
|
|
||||||
if(av)
|
|
||||||
{
|
|
||||||
for (LLVOAvatar::attachment_map_t::iterator iter = av->mAttachmentPoints.begin();
|
|
||||||
iter != av->mAttachmentPoints.end();
|
|
||||||
++iter)
|
|
||||||
{
|
|
||||||
LLViewerJointAttachment* attachment = iter->second;
|
|
||||||
if (!attachment->getValid())
|
|
||||||
continue ;
|
|
||||||
for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itObj = attachment->mAttachedObjects.begin();
|
|
||||||
itObj != attachment->mAttachedObjects.end(); ++itObj)
|
|
||||||
{
|
|
||||||
LLViewerObject* object = *itObj;
|
|
||||||
if(object)
|
|
||||||
{
|
|
||||||
objectArray.put(object);
|
|
||||||
objectCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (LLObjectSelection::valid_root_iterator iter = LLSelectMgr::getInstance()->getSelection()->valid_root_begin();
|
|
||||||
iter != LLSelectMgr::getInstance()->getSelection()->valid_root_end(); iter++)
|
|
||||||
{
|
|
||||||
LLSelectNode* selectNode = *iter;
|
|
||||||
LLViewerObject* object = selectNode->getObject();
|
|
||||||
if(object)
|
|
||||||
{
|
|
||||||
objectArray.put(object);
|
|
||||||
objectCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
doDelete=delScript;
|
|
||||||
}
|
|
||||||
F32 throttle = gSavedSettings.getF32("OutBandwidth");
|
|
||||||
if((throttle == 0.f) || (throttle > 128000.f))
|
|
||||||
{
|
|
||||||
gMessageSystem->mPacketRing->setOutBandwidth(128000);
|
|
||||||
gMessageSystem->mPacketRing->setUseOutThrottle(TRUE);
|
|
||||||
}
|
|
||||||
showResult(llformat("Counting scripts, please wait..."));
|
|
||||||
if((objectCount == 1) && !(foo->isAvatar()))
|
|
||||||
{
|
|
||||||
LLViewerObject *reqObject=((LLViewerObject*)foo->getRoot());
|
|
||||||
if(reqObject->isAvatar())
|
|
||||||
{
|
|
||||||
for (LLObjectSelection::iterator iter = LLSelectMgr::getInstance()->getSelection()->begin();
|
|
||||||
iter != LLSelectMgr::getInstance()->getSelection()->end(); iter++ )
|
|
||||||
{
|
|
||||||
LLSelectNode *nodep = *iter;
|
|
||||||
LLViewerObject* objectp = nodep->getObject();
|
|
||||||
if (objectp->isRootEdit())
|
|
||||||
{
|
|
||||||
reqObjectID=objectp->getID();
|
|
||||||
LLMessageSystem* msg = gMessageSystem;
|
|
||||||
msg->newMessageFast(_PREHASH_ObjectSelect);
|
|
||||||
msg->nextBlockFast(_PREHASH_AgentData);
|
|
||||||
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
|
|
||||||
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
|
|
||||||
msg->nextBlockFast(_PREHASH_ObjectData);
|
|
||||||
msg->addU32Fast(_PREHASH_ObjectLocalID, objectp->getLocalID());
|
|
||||||
msg->sendReliable(gAgent.getRegionHost());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reqObjectID=reqObject->getID();
|
|
||||||
LLMessageSystem* msg = gMessageSystem;
|
|
||||||
msg->newMessageFast(_PREHASH_RequestObjectPropertiesFamily);
|
|
||||||
msg->nextBlockFast(_PREHASH_AgentData);
|
|
||||||
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
|
|
||||||
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
|
|
||||||
msg->nextBlockFast(_PREHASH_ObjectData);
|
|
||||||
msg->addU32Fast(_PREHASH_RequestFlags, 0 );
|
|
||||||
msg->addUUIDFast(_PREHASH_ObjectID, reqObjectID);
|
|
||||||
gAgent.sendReliableMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
serialize(objectArray);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptCounter::serialize(LLDynamicArray<LLViewerObject*> objects)
|
ScriptCounter::ScriptCounter(bool do_delete, LLViewerObject* object)
|
||||||
|
: doDelete(do_delete)
|
||||||
|
, foo(object)
|
||||||
|
, inventories()
|
||||||
|
, objectCount()
|
||||||
|
, requesting(true)
|
||||||
|
, scriptcount()
|
||||||
{
|
{
|
||||||
init();
|
llassert(foo); // Object to ScriptCount must not be null
|
||||||
status = COUNTING;
|
|
||||||
for(LLDynamicArray<LLViewerObject*>::iterator itr = objects.begin(); itr != objects.end(); ++itr)
|
|
||||||
{
|
|
||||||
LLViewerObject* object = *itr;
|
|
||||||
if (object)
|
|
||||||
subserialize(object);
|
|
||||||
}
|
|
||||||
if(invqueries == 0)
|
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptCounter::subserialize(LLViewerObject* linkset)
|
ScriptCounter::~ScriptCounter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Request the inventory for all parts
|
||||||
|
void ScriptCounter::requestInventories()
|
||||||
{
|
{
|
||||||
LLViewerObject* object = linkset;
|
if (foo->isAvatar()) // If it's an avatar, iterate through all the attachments
|
||||||
LLDynamicArray<LLViewerObject*> count_objects;
|
{
|
||||||
count_objects.put(object);
|
doDelete = false; // We don't support deleting all scripts in all attachments, such a feature could be dangerous.
|
||||||
|
LLVOAvatar* av = static_cast<LLVOAvatar*>(foo);
|
||||||
|
|
||||||
|
// Iterate through all the attachment points
|
||||||
|
for (LLVOAvatar::attachment_map_t::iterator i = av->mAttachmentPoints.begin(); i != av->mAttachmentPoints.end(); ++i)
|
||||||
|
{
|
||||||
|
if (LLViewerJointAttachment* attachment = i->second)
|
||||||
|
{
|
||||||
|
if (!attachment->getValid()) continue;
|
||||||
|
|
||||||
|
// Iterate through all the attachments on this point
|
||||||
|
for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator j = attachment->mAttachedObjects.begin(); j != attachment->mAttachedObjects.end(); ++j)
|
||||||
|
if (LLViewerObject* object = *j)
|
||||||
|
requestInventoriesFor(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // Iterate through all the selected objects
|
||||||
|
{
|
||||||
|
for (LLObjectSelection::valid_root_iterator i = LLSelectMgr::getInstance()->getSelection()->valid_root_begin(); i != LLSelectMgr::getInstance()->getSelection()->valid_root_end(); ++i)
|
||||||
|
if (LLSelectNode* selectNode = *i)
|
||||||
|
if (LLViewerObject* object = selectNode->getObject())
|
||||||
|
requestInventoriesFor(object);
|
||||||
|
}
|
||||||
|
cmdline_printchat(LLTrans::getString("ScriptCounting"));
|
||||||
|
requesting = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request the inventories of each object and its child prims
|
||||||
|
void ScriptCounter::requestInventoriesFor(LLViewerObject* object)
|
||||||
|
{
|
||||||
|
++objectCount;
|
||||||
|
requestInventoryFor(object);
|
||||||
LLViewerObject::child_list_t child_list = object->getChildren();
|
LLViewerObject::child_list_t child_list = object->getChildren();
|
||||||
for (LLViewerObject::child_list_t::iterator i = child_list.begin(); i != child_list.end(); ++i)
|
for (LLViewerObject::child_list_t::iterator i = child_list.begin(); i != child_list.end(); ++i)
|
||||||
{
|
{
|
||||||
LLViewerObject* child = *i;
|
LLViewerObject* child = *i;
|
||||||
if(!child->isAvatar())
|
if (child->isAvatar()) continue;
|
||||||
count_objects.put(child);
|
requestInventoryFor(child);
|
||||||
}
|
}
|
||||||
S32 object_index = 0;
|
}
|
||||||
while ((object_index < count_objects.count()))
|
|
||||||
|
// Request inventory for each individual prim
|
||||||
|
void ScriptCounter::requestInventoryFor(LLViewerObject* object)
|
||||||
{
|
{
|
||||||
object = count_objects.get(object_index++);
|
//llinfos << "Requesting inventory of " << object->getID() << llendl;
|
||||||
LLUUID id = object->getID();
|
++inventories;
|
||||||
objIDS.insert(id.asString());
|
object->registerInventoryListener(this, NULL);
|
||||||
llinfos << "Counting scripts in prim " << object->getID().asString() << llendl;
|
|
||||||
object->registerInventoryListener(sInstance,NULL);
|
|
||||||
object->dirtyInventory();
|
object->dirtyInventory();
|
||||||
object->requestInventory();
|
object->requestInventory();
|
||||||
invqueries += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptCounter::completechk()
|
// An inventory has been received, count/delete the scripts in it
|
||||||
|
void ScriptCounter::inventoryChanged(LLViewerObject* obj, LLInventoryObject::object_list_t* inv, S32, void*)
|
||||||
{
|
{
|
||||||
std::string user_msg;
|
obj->removeInventoryListener(this);
|
||||||
llinfos << "Completechk called." << llendl;
|
--inventories;
|
||||||
if(invqueries == 0)
|
//llinfos << "Counting scripts in " << obj->getID() << llendl;
|
||||||
{
|
|
||||||
llinfos << "InvQueries = 0..." << llendl;
|
|
||||||
if(reqObjectID.isNull())
|
|
||||||
{
|
|
||||||
llinfos << "reqObjectId is null..." << llendl;
|
|
||||||
if(foo->isAvatar())
|
|
||||||
{
|
|
||||||
int valid=1;
|
|
||||||
LLVOAvatar *av=find_avatar_from_object(foo);
|
|
||||||
LLNameValue *firstname;
|
|
||||||
LLNameValue *lastname;
|
|
||||||
if(!av)
|
|
||||||
valid=0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
firstname = av->getNVPair("FirstName");
|
|
||||||
lastname = av->getNVPair("LastName");
|
|
||||||
if(!firstname || !lastname)
|
|
||||||
valid=0;
|
|
||||||
if(valid)
|
|
||||||
{
|
|
||||||
user_msg = llformat("Counted %u scripts in %u attachments on %s %s.", scriptcount, objectCount, firstname->getString() , lastname->getString());
|
|
||||||
//sstr << "Counted scripts from " << << " attachments on " << firstname->getString() << " " << lastname->getString() << ": ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!valid)
|
|
||||||
{
|
|
||||||
user_msg = llformat("Counted %u scripts in %u attachments on selected avatar.", scriptcount, objectCount);
|
|
||||||
//sstr << "Counted scripts from " << objectCount << " attachments on avatar: ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(doDelete)
|
|
||||||
{
|
|
||||||
user_msg = llformat("Deleted %u scripts in %u objects.", scriptcount, objectCount);
|
|
||||||
//sstr << "Deleted scripts in " << objectCount << " objects: ";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
user_msg = llformat("Counted %u scripts in %u objects.", scriptcount, objectCount);
|
|
||||||
//sstr << "Counted scripts in " << objectCount << " objects: ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
F32 throttle = gSavedSettings.getF32("OutBandwidth");
|
|
||||||
if(throttle != 0.f)
|
|
||||||
{
|
|
||||||
gMessageSystem->mPacketRing->setOutBandwidth(throttle);
|
|
||||||
gMessageSystem->mPacketRing->setUseOutThrottle(TRUE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gMessageSystem->mPacketRing->setOutBandwidth(0.0);
|
|
||||||
gMessageSystem->mPacketRing->setUseOutThrottle(FALSE);
|
|
||||||
}
|
|
||||||
llinfos << "Sending readout to chat..." << llendl;
|
|
||||||
showResult(user_msg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
countingDone=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptCounter::inventoryChanged(LLViewerObject* obj,
|
|
||||||
LLInventoryObject::object_list_t* inv,
|
|
||||||
S32 serial_num,
|
|
||||||
void* user_data)
|
|
||||||
{
|
|
||||||
llinfos << "InventoryChanged called..." << llendl;
|
|
||||||
if(status == IDLE)
|
|
||||||
{
|
|
||||||
obj->removeInventoryListener(sInstance);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(objIDS.find(obj->getID().asString()) != objIDS.end())
|
|
||||||
{
|
|
||||||
if (inv)
|
if (inv)
|
||||||
{
|
{
|
||||||
LLInventoryObject::object_list_t::const_iterator it = inv->begin();
|
|
||||||
LLInventoryObject::object_list_t::const_iterator end = inv->end();
|
LLInventoryObject::object_list_t::const_iterator end = inv->end();
|
||||||
for( ; it != end; ++it)
|
for (LLInventoryObject::object_list_t::const_iterator i = inv->begin(); i != end; ++i)
|
||||||
{
|
if (LLInventoryObject* asset = (*i))
|
||||||
LLInventoryObject* asset = (*it);
|
|
||||||
if(asset)
|
|
||||||
{
|
|
||||||
if (asset->getType() == LLAssetType::AT_LSL_TEXT)
|
if (asset->getType() == LLAssetType::AT_LSL_TEXT)
|
||||||
{
|
{
|
||||||
scriptcount+=1;
|
++scriptcount;
|
||||||
if(doDelete==true)
|
if (doDelete)
|
||||||
delUUIDS.push_back(asset->getUUID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(doDelete==true)
|
|
||||||
{
|
{
|
||||||
while (delUUIDS.count() > 0)
|
const LLUUID& id = asset->getUUID();
|
||||||
|
if (id.notNull())
|
||||||
|
obj->removeInventory(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Done requesting and there are no more inventories to receive
|
||||||
|
if (!requesting && !inventories)
|
||||||
{
|
{
|
||||||
const LLUUID toDelete=delUUIDS[0];
|
LLStringUtil::format_map_t args;
|
||||||
delUUIDS.remove(0);
|
args["SCRIPTS"] = stringize(scriptcount);
|
||||||
if(toDelete.notNull())
|
args["OBJECTS"] = stringize(objectCount);
|
||||||
obj->removeInventory(toDelete);
|
if (foo->isAvatar())
|
||||||
}
|
LLAvatarNameCache::get(foo->getID(), boost::bind(countedScriptsOnAvatar, args, _2));
|
||||||
}
|
else
|
||||||
}
|
cmdline_printchat(LLTrans::getString(doDelete ? "ScriptDeleteObject" : "ScriptCountObject", args));
|
||||||
llinfos << "Attempting completechk..." << llendl;
|
|
||||||
invqueries -= 1;
|
delete this;
|
||||||
objIDS.erase(obj->getID().asString());
|
|
||||||
reqObjectID.setNull();
|
|
||||||
obj->removeInventoryListener(sInstance);
|
|
||||||
completechk();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,51 +28,31 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
#ifndef SCRIPTCOUNTER_H
|
||||||
|
#define SCRIPTCOUNTER_H
|
||||||
|
|
||||||
|
|
||||||
#include "llagent.h"
|
|
||||||
#include "llvoinventorylistener.h"
|
#include "llvoinventorylistener.h"
|
||||||
|
|
||||||
class ScriptCounter : public LLVOInventoryListener
|
class ScriptCounter : public LLVOInventoryListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScriptCounter();
|
ScriptCounter(bool do_delete, LLViewerObject* object);
|
||||||
~ScriptCounter();
|
~ScriptCounter();
|
||||||
|
|
||||||
private:
|
/*virtual*/ void inventoryChanged(LLViewerObject* obj, LLInventoryObject::object_list_t* inv, S32, void*);
|
||||||
static ScriptCounter* sInstance;
|
void requestInventories();
|
||||||
static void init();
|
|
||||||
static LLSD* getprim(LLUUID id);
|
|
||||||
static void completechk();
|
|
||||||
public:
|
|
||||||
static void processObjectPropertiesFamily(LLMessageSystem* msg, void** user_data);
|
|
||||||
static void processObjectProperties(LLMessageSystem* msg, void** user_data);
|
|
||||||
void inventoryChanged(LLViewerObject* obj,
|
|
||||||
LLInventoryObject::object_list_t* inv,
|
|
||||||
S32 serial_num,
|
|
||||||
void* data);
|
|
||||||
|
|
||||||
static ScriptCounter* getInstance(){ init(); return sInstance; }
|
|
||||||
|
|
||||||
static void serialize(LLDynamicArray<LLViewerObject*> objects);
|
|
||||||
static void serializeSelection(bool delScript);
|
|
||||||
static void finalize(LLSD data);
|
|
||||||
static void showResult(std::string output);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void subserialize(LLViewerObject* linkset);
|
void requestInventoriesFor(LLViewerObject* object);
|
||||||
|
void requestInventoryFor(LLViewerObject* object);
|
||||||
|
|
||||||
enum ExportState { IDLE, COUNTING };
|
bool doDelete;
|
||||||
|
LLViewerObject* foo;
|
||||||
static U32 status;
|
int inventories;
|
||||||
static U32 invqueries;
|
int objectCount;
|
||||||
static U32 scriptcount;
|
bool requesting;
|
||||||
static LLUUID reqObjectID;
|
int scriptcount;
|
||||||
static std::set<std::string> objIDS;
|
|
||||||
static LLDynamicArray<LLUUID> delUUIDS;
|
|
||||||
static int objectCount;
|
|
||||||
static LLViewerObject* foo;
|
|
||||||
static bool doDelete;
|
|
||||||
static std::stringstream sstr;
|
|
||||||
static int countingDone;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif //SCRIPTCOUNTER_H
|
||||||
|
|
||||||
|
|||||||
@@ -861,6 +861,10 @@
|
|||||||
width="250">
|
width="250">
|
||||||
<on_click function="Tools.ScriptDelete" />
|
<on_click function="Tools.ScriptDelete" />
|
||||||
<on_enable function="Tools.EnableScriptDelete" />
|
<on_enable function="Tools.EnableScriptDelete" />
|
||||||
|
</menu_item_call>
|
||||||
|
<menu_item_call mouse_opaque="true" label="Count Scripts in Selection" name="Count Scripts in Selection">
|
||||||
|
<on_click function="Object.ScriptCount" />
|
||||||
|
<on_enable function="Object.VisibleScriptCount" />
|
||||||
</menu_item_call>
|
</menu_item_call>
|
||||||
<menu create_jump_keys="true" label="Pathfinding" name="Pathfinding" opaque="true" tear_off="true">
|
<menu create_jump_keys="true" label="Pathfinding" name="Pathfinding" opaque="true" tear_off="true">
|
||||||
<menu_item_check label="Linksets..." name="pathfinding_linksets_menu_item">
|
<menu_item_check label="Linksets..." name="pathfinding_linksets_menu_item">
|
||||||
|
|||||||
@@ -2966,6 +2966,10 @@ Where tag = tag string to match. Removes bot's matching the tag.
|
|||||||
<string name="NotLoggedIn">Not logged in</string>
|
<string name="NotLoggedIn">Not logged in</string>
|
||||||
|
|
||||||
<!-- Non-standard LLChat strings -->
|
<!-- Non-standard LLChat strings -->
|
||||||
|
<string name="ScriptCounting">Counting scripts, please wait...</string>
|
||||||
|
<string name="ScriptCountAvatar">Counted [SCRIPTS] scripts in [OBJECTS] attachments on [NAME].</string>
|
||||||
|
<string name="ScriptCountObject">Counted [SCRIPTS] scripts in [OBJECTS] objects.</string>
|
||||||
|
<string name="ScriptDeleteObject">Deleted [SCRIPTS] scripts in [OBJECTS] objects.</string>
|
||||||
<string name="took_a_snapshot">took a snapshot</string>
|
<string name="took_a_snapshot">took a snapshot</string>
|
||||||
|
|
||||||
<!-- Avatar busy/away mode -->
|
<!-- Avatar busy/away mode -->
|
||||||
|
|||||||
Reference in New Issue
Block a user