From 82aef8fa4cf6a0c8a3e903e3b7c1b036ca3eb53b Mon Sep 17 00:00:00 2001 From: phr0z3nt04st Date: Thu, 8 Jul 2010 00:20:37 -0500 Subject: [PATCH] Massive commit, beefed up the audio crash prevention, made a blacklist for assets, added sound explorer, fixed import, added item button to vfs explorer. JELLY ROLL --- indra/llaudio/llaudiodecodemgr.cpp | 50 +- indra/llaudio/llaudioengine.cpp | 93 +++- indra/llaudio/llaudioengine.h | 47 +- indra/llmessage/llassetstorage.cpp | 11 + indra/llmessage/llassetstorage.h | 2 + indra/llmessage/llcachename.cpp | 28 +- indra/llmessage/llcachename.h | 6 +- indra/newview/CMakeLists.txt | 4 + indra/newview/app_settings/settings.xml | 60 +++ indra/newview/llaudiosourcevo.cpp | 5 +- indra/newview/llfilepicker.cpp | 15 + indra/newview/llfilepicker.h | 2 + indra/newview/llfloaterblacklist.cpp | 198 ++++++++ indra/newview/llfloaterblacklist.h | 33 ++ indra/newview/llfloaterexploresounds.cpp | 456 ++++++++++++++++++ indra/newview/llfloaterexploresounds.h | 41 ++ indra/newview/llfloatervfsexplorer.cpp | 16 +- indra/newview/llfloatervfsexplorer.h | 1 + indra/newview/llimportobject.cpp | 135 ++++-- indra/newview/llimportobject.h | 5 + indra/newview/llstartup.cpp | 2 + indra/newview/lltexturefetch.cpp | 10 + indra/newview/llviewermenu.cpp | 18 + indra/newview/llviewermessage.cpp | 4 +- .../default/xui/en-us/floater_blacklist.xml | 17 + .../xui/en-us/floater_explore_sounds.xml | 33 ++ .../xui/en-us/floater_vfs_explorer.xml | 1 + 27 files changed, 1232 insertions(+), 61 deletions(-) create mode 100644 indra/newview/llfloaterblacklist.cpp create mode 100644 indra/newview/llfloaterblacklist.h create mode 100644 indra/newview/llfloaterexploresounds.cpp create mode 100644 indra/newview/llfloaterexploresounds.h create mode 100644 indra/newview/skins/default/xui/en-us/floater_blacklist.xml create mode 100644 indra/newview/skins/default/xui/en-us/floater_explore_sounds.xml diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp index 6427addc9..37abb27e1 100644 --- a/indra/llaudio/llaudiodecodemgr.cpp +++ b/indra/llaudio/llaudiodecodemgr.cpp @@ -226,7 +226,7 @@ BOOL LLVorbisDecodeState::initDecode() size_guess += 2048; bool abort_decode = false; - + // // This magic value is equivilent to 150MiB of data. // Prevents griffers from utilizin a huge xbox sound the size of god to instafry the viewer if(size_guess >= 157286400) @@ -235,7 +235,7 @@ BOOL LLVorbisDecodeState::initDecode() abort_decode = true; } - else if( vi->channels < 1 || vi->channels > LLVORBIS_CLIP_MAX_CHANNELS ) + else /* */if( vi->channels < 1 || vi->channels > LLVORBIS_CLIP_MAX_CHANNELS ) { abort_decode = true; llwarns << "Bad channel count: " << vi->channels << llendl; @@ -251,8 +251,25 @@ BOOL LLVorbisDecodeState::initDecode() return FALSE; } - mWAVBuffer.reserve(size_guess); - mWAVBuffer.resize(WAV_HEADER_SIZE); + // + try + { + // + mWAVBuffer.reserve(size_guess); + mWAVBuffer.resize(WAV_HEADER_SIZE); + // + } + catch(std::bad_alloc) + { + llwarns << "bad_alloc" << llendl; + if(mInFilep) + { + delete mInFilep; + mInFilep = NULL; + } + return FALSE; + } + // { // write the .wav format header @@ -425,7 +442,10 @@ BOOL LLVorbisDecodeState::finishDecode() char pcmout[4096]; /*Flawfinder: ignore*/ fade_length = llmin((S32)128,(S32)(data_length-36)/8); - if((S32)mWAVBuffer.size() >= (WAV_HEADER_SIZE + 2* fade_length)) + // + //if((S32)mWAVBuffer.size() >= (WAV_HEADER_SIZE + 2* fade_length)) + if((S32)mWAVBuffer.size() > (WAV_HEADER_SIZE + 2* fade_length)) + // { memcpy(pcmout, &mWAVBuffer[WAV_HEADER_SIZE], (2 * fade_length)); /*Flawfinder: ignore*/ } @@ -444,7 +464,10 @@ BOOL LLVorbisDecodeState::finishDecode() memcpy(&mWAVBuffer[WAV_HEADER_SIZE], pcmout, (2 * fade_length)); /*Flawfinder: ignore*/ } S32 near_end = mWAVBuffer.size() - (2 * fade_length); - if ((S32)mWAVBuffer.size() >= ( near_end + 2* fade_length)) + // + //if ((S32)mWAVBuffer.size() >= ( near_end + 2* fade_length)) + if ((S32)mWAVBuffer.size() > ( near_end + 2* fade_length)) + // { memcpy(pcmout, &mWAVBuffer[near_end], (2 * fade_length)); /*Flawfinder: ignore*/ } @@ -543,13 +566,18 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs) { if (mCurrentDecodep) { - BOOL res; + // rawrning + //BOOL res; + BOOL res = false; + // // Decode in a loop until we're done or have run out of time. - while(!(res = mCurrentDecodep->decodeSection()) && (decode_timer.getElapsedTimeF32() < num_secs)) - { - // decodeSection does all of the work above - } + /* */ try{ /* */ + while(!(res = mCurrentDecodep->decodeSection()) && (decode_timer.getElapsedTimeF32() < num_secs)) + { + // decodeSection does all of the work above + } + /* */ }catch(std::bad_alloc){llerrs<<"bad_alloc whilst decoding"< */ if (mCurrentDecodep->isDone() && !mCurrentDecodep->isValid()) { diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp index 93ac42078..b0ce816c6 100644 --- a/indra/llaudio/llaudioengine.cpp +++ b/indra/llaudio/llaudioengine.cpp @@ -814,7 +814,10 @@ F64 LLAudioEngine::mapWindVecToPan(LLVector3 wind_vec) void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_id, const F32 gain, - const S32 type, const LLVector3d &pos_global) + // + //const S32 type, const LLVector3d &pos_global) + const S32 type, const LLVector3d &pos_global, const LLUUID source_object) + // { // Create a new source (since this can't be associated with an existing source. //llinfos << "Localized: " << audio_uuid << llendl; @@ -827,7 +830,10 @@ void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_i LLUUID source_id; source_id.generate(); - LLAudioSource *asp = new LLAudioSource(source_id, owner_id, gain, type); + // + //LLAudioSource *asp = new LLAudioSource(source_id, owner_id, gain, type); + LLAudioSource *asp = new LLAudioSource(source_id, owner_id, gain, type, source_object, true); + // gAudiop->addAudioSource(asp); if (pos_global.isExactlyZero()) { @@ -1254,7 +1260,10 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E // -LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32 gain, const S32 type) +// +//LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32 gain, const S32 type) +LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32 gain, const S32 type, const LLUUID source_id, const bool isTrigger) +// : mID(id), mOwnerID(owner_id), mPriority(0.f), @@ -1267,10 +1276,17 @@ LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32 mQueueSounds(false), mPlayedOnce(false), mType(type), + // + mSourceID(source_id), + mIsTrigger(isTrigger), + // mChannelp(NULL), mCurrentDatap(NULL), mQueuedDatap(NULL) { + // + mLogID.generate(); + // } @@ -1282,6 +1298,10 @@ LLAudioSource::~LLAudioSource() mChannelp->setSource(NULL); mChannelp = NULL; } + // + if(mType != LLAudioEngine::AUDIO_TYPE_UI) // && mSourceID.notNull()) + logSoundStop(mLogID); + // } @@ -1370,6 +1390,10 @@ bool LLAudioSource::setupChannel() bool LLAudioSource::play(const LLUUID &audio_uuid) { + // + if(mType != LLAudioEngine::AUDIO_TYPE_UI) //&& mSourceID.notNull()) + logSoundPlay(mLogID, this, mPositionGlobal, mType, audio_uuid, mOwnerID, mSourceID, mIsTrigger, mLoop); // is mID okay for source id? + // // Special abuse of play(); don't play a sound, but kill it. if (audio_uuid.isNull()) { @@ -1770,4 +1794,65 @@ bool LLAudioData::load() return true; } - +// +std::map gSoundHistory; + +// static +void logSoundPlay(LLUUID id, LLAudioSource* audio_source, LLVector3d position, S32 type, LLUUID assetid, LLUUID ownerid, LLUUID sourceid, bool is_trigger, bool is_looped) +{ + LLSoundHistoryItem item; + item.mID = id; + item.mAudioSource = audio_source; + item.mPosition = position; + item.mType = type; + item.mAssetID = assetid; + item.mOwnerID = ownerid; + item.mSourceID = sourceid; + item.mPlaying = true; + item.mTimeStarted = LLTimer::getElapsedSeconds(); + item.mTimeStopped = F64_MAX; + item.mIsTrigger = is_trigger; + item.mIsLooped = is_looped; + + item.mReviewed = false; + item.mReviewedCollision = false; + + gSoundHistory[id] = item; +} + +static void logSoundStop(LLUUID id) +{ + if(gSoundHistory.find(id) != gSoundHistory.end()) + { + gSoundHistory[id].mPlaying = false; + gSoundHistory[id].mTimeStopped = LLTimer::getElapsedSeconds(); + gSoundHistory[id].mAudioSource = NULL; // just in case + pruneSoundLog(); + } +} + +static void pruneSoundLog() +{ + if(++gSoundHistoryPruneCounter >= 64) + { + gSoundHistoryPruneCounter = 0; + while(gSoundHistory.size() > 256) + { + std::map::iterator iter = gSoundHistory.begin(); + std::map::iterator end = gSoundHistory.end(); + U64 lowest_time = (*iter).second.mTimeStopped; + LLUUID lowest_id = (*iter).first; + for( ; iter != end; ++iter) + { + if((*iter).second.mTimeStopped < lowest_time) + { + lowest_time = (*iter).second.mTimeStopped; + lowest_id = (*iter).first; + } + } + gSoundHistory.erase(lowest_id); + } + } +} + +// diff --git a/indra/llaudio/llaudioengine.h b/indra/llaudio/llaudioengine.h index 24433cd76..5ddbd3ce0 100644 --- a/indra/llaudio/llaudioengine.h +++ b/indra/llaudio/llaudioengine.h @@ -139,7 +139,11 @@ public: // Owner ID is the owner of the object making the request void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, const S32 type = LLAudioEngine::AUDIO_TYPE_NONE, - const LLVector3d &pos_global = LLVector3d::zero); + // + //const LLVector3d &pos_global = LLVector3d::zero); + const LLVector3d &pos_global = LLVector3d::zero, + const LLUUID source_object = LLUUID::null); + // bool preloadSound(const LLUUID &id); void addAudioSource(LLAudioSource *asp); @@ -261,7 +265,10 @@ class LLAudioSource public: // owner_id is the id of the agent responsible for making this sound // play, for example, the owner of the object currently playing it - LLAudioSource(const LLUUID &id, const LLUUID& owner_id, const F32 gain, const S32 type = LLAudioEngine::AUDIO_TYPE_NONE); + // + //LLAudioSource(const LLUUID &id, const LLUUID& owner_id, const F32 gain, const S32 type = LLAudioEngine::AUDIO_TYPE_NONE); + LLAudioSource(const LLUUID &id, const LLUUID& owner_id, const F32 gain, const S32 type = LLAudioEngine::AUDIO_TYPE_NONE, const LLUUID source_id = LLUUID::null, const bool isTrigger = true); + // virtual ~LLAudioSource(); virtual void update(); // Update this audio source @@ -301,6 +308,9 @@ public: virtual void setGain(const F32 gain) { mGain = llclamp(gain, 0.f, 1.f); } const LLUUID &getID() const { return mID; } + // + const LLUUID &getLogID() const { return mLogID; } + // bool isDone() const; bool isMuted() const { return mSourceMuted; } @@ -334,6 +344,11 @@ protected: S32 mType; LLVector3d mPositionGlobal; LLVector3 mVelocity; + // + LLUUID mLogID; + LLUUID mSourceID; + bool mIsTrigger; + // //LLAudioSource *mSyncMasterp; // If we're a slave, the source that we're synced to. LLAudioChannel *mChannelp; // If we're currently playing back, this is the channel that we're assigned to. @@ -452,4 +467,32 @@ protected: extern LLAudioEngine* gAudiop; +// +typedef struct +{ + LLUUID mID; + LLVector3d mPosition; + S32 mType; + bool mPlaying; + LLUUID mAssetID; + LLUUID mOwnerID; + LLUUID mSourceID; + bool mIsTrigger; + bool mIsLooped; + F64 mTimeStarted; + F64 mTimeStopped; + bool mReviewed; + bool mReviewedCollision; + LLAudioSource* mAudioSource; +} LLSoundHistoryItem; + +extern std::map gSoundHistory; + +static void logSoundPlay(LLUUID id, LLAudioSource* audio_source, LLVector3d position, S32 type, LLUUID assetid, LLUUID ownerid, LLUUID sourceid, bool is_trigger, bool is_looped); +static void logSoundStop(LLUUID id); +static void pruneSoundLog(); +static int gSoundHistoryPruneCounter; + +// + #endif diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp index 16a96b75b..7c659d325 100644 --- a/indra/llmessage/llassetstorage.cpp +++ b/indra/llmessage/llassetstorage.cpp @@ -422,6 +422,17 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, vo } return; } + /* */ + if(std::find(mBlackListedAsset.begin(),mBlackListedAsset.end(),uuid) != mBlackListedAsset.end()) + { + llinfos << "Blacklisted asset " << uuid.asString() << " was trying to be accessed!!!!!!" << llendl; + if (callback) + { + callback(mVFS, uuid, type, user_data, LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE, LL_EXSTAT_NULL_UUID); + } + return; + } + /* */ BOOL exists = mVFS->getExists(uuid, type); LLVFile file(mVFS, uuid, type); diff --git a/indra/llmessage/llassetstorage.h b/indra/llmessage/llassetstorage.h index c094ef487..d68c41045 100644 --- a/indra/llmessage/llassetstorage.h +++ b/indra/llmessage/llassetstorage.h @@ -262,6 +262,8 @@ public: virtual void getAssetData(const LLUUID uuid, LLAssetType::EType atype, LLGetAssetCallback cb, void *user_data, BOOL is_priority = FALSE); + std::vector mBlackListedAsset; + /* * TransactionID version * Viewer needs the store_local diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 1e6584a08..970162329 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -599,7 +599,33 @@ void LLCacheName::get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callb impl.mReplyQueue.push_back(PendingReply(id, callback, user_data)); } } - +// +BOOL LLCacheName::getIfThere(const LLUUID& id, std::string& fullname, BOOL& is_group) +{ + if(id.isNull()) + { + fullname = ""; + return FALSE; + } + + LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id ); + if (entry) + { + if (entry->mIsGroup) + { + fullname = entry->mGroupName; + } + else + { + fullname = entry->mFirstName + " " + entry->mLastName; + } + is_group = entry->mIsGroup; + return TRUE; + } + fullname = ""; + return FALSE; +} +// void LLCacheName::processPending() { const F32 SECS_BETWEEN_PROCESS = 0.1f; diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 2757b86a7..9524a88ba 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -90,7 +90,11 @@ public: // otherwise, will request the data, and will call the callback when // available. There is no garuntee the callback will ever be called. void get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callback, void* user_data = NULL); - + + // + BOOL getIfThere(const LLUUID& id, std::string& fullname, BOOL& is_group); + // + // LEGACY void getName(const LLUUID& id, LLCacheNameCallback callback, void* user_data = NULL) { get(id, FALSE, callback, user_data); } diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 5424b50a9..6dd742f00 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -138,6 +138,7 @@ set(viewer_SOURCE_FILES llfloateravatarpicker.cpp llfloateravatartextures.cpp llfloaterbeacons.cpp + llfloaterblacklist.cpp llfloaterbuildoptions.cpp llfloaterbulkpermission.cpp llfloaterbump.cpp @@ -160,6 +161,7 @@ set(viewer_SOURCE_FILES llfloaterexport.cpp llfloaterexportregion.cpp llfloaterexploreanimations.cpp + llfloaterexploresounds.cpp llfloaterfriends.cpp llfloaterfonttest.cpp llfloatergesture.cpp @@ -577,6 +579,7 @@ set(viewer_HEADER_FILES llfloateravatarpicker.h llfloateravatartextures.h llfloaterbeacons.h + llfloaterblacklist.h llfloaterbuildoptions.h llfloaterbulkpermission.h llfloaterbump.h @@ -598,6 +601,7 @@ set(viewer_HEADER_FILES llfloaterexport.h llfloaterexportregion.h llfloaterexploreanimations.h + llfloaterexploresounds.h llfloaterevent.h llfloaterfonttest.h llfloaterfriends.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f214a56a6..01fd861a7 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4494,6 +4494,66 @@ 400 + FloaterSoundsRect + + Comment + Rectangle for sounds log floater. + Persist + 1 + Type + Rect + Value + + 0 + 0 + 0 + 0 + + + FloaterSoundsLogAvatars + + Comment + Show SoundTriggers/gestures played by agents in the log. Also includes collision sounds if enabled + Persist + 1 + Type + Boolean + Value + 1 + + FloaterSoundsLogObjects + + Comment + Show sounds played by objects in the log. Also includes collision sounds if enabled + Persist + 1 + Type + Boolean + Value + 1 + + FloaterSoundsLogCollisions + + Comment + Don't filter out default collision sounds in the log + Persist + 1 + Type + Boolean + Value + 1 + + FloaterSoundsLogRepeats + + Comment + Only show one entry for each unique asset ID in the log + Persist + 1 + Type + Boolean + Value + 1 + FloaterStatisticsRect Comment diff --git a/indra/newview/llaudiosourcevo.cpp b/indra/newview/llaudiosourcevo.cpp index d286eb47e..7c3080c2d 100644 --- a/indra/newview/llaudiosourcevo.cpp +++ b/indra/newview/llaudiosourcevo.cpp @@ -40,7 +40,10 @@ #include "llviewerparcelmgr.h" LLAudioSourceVO::LLAudioSourceVO(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, LLViewerObject *objectp) - : LLAudioSource(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX), +// +// : LLAudioSource(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX), + : LLAudioSource(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX, objectp->getID(), false), +// mObjectp(objectp) { update(); diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp index fb83dc1da..28fb2f73f 100644 --- a/indra/newview/llfilepicker.cpp +++ b/indra/newview/llfilepicker.cpp @@ -55,6 +55,7 @@ LLFilePicker LLFilePicker::sInstance; #define SOUND_FILTER L"Sounds (*.wav; *.ogg)\0*.wav;*.ogg\0" #define IMAGE_FILTER L"Images (*.tga; *.bmp; *.jpg; *.jpeg; *.png; *.jp2; *.j2k; *.j2c)\0*.tga;*.bmp;*.jpg;*.jpeg;*.png;*.jp2;*.j2k;*.j2c\0" #define INVGZ_FILTER L"Inv cache (*.inv; *.inv.gz)\0*.inv;*.inv.gz\0" +#define BLACKLIST_FILTER L"Asset Blacklist (*.blacklist)\0*.blacklist;\0" // #define ANIM_FILTER L"Animations (*.bvh)\0*.bvh\0" #ifdef _CORY_TESTING @@ -206,6 +207,10 @@ BOOL LLFilePicker::setupFilter(ELoadFilter filter) L"\0"; break; */ + case FFLOAD_BLACKLIST: + mOFN.lpstrFilter = BLACKLIST_FILTER \ + L"\0"; + break; // default: res = FALSE; @@ -677,6 +682,16 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) L"InvCache (*.inv)\0*.inv\0" \ L"\0"; break; + case FFSAVE_BLACKLIST: + if(filename.empty()) + { + wcsncpy( mFilesW,L"untitled.blacklist", FILENAME_BUFFER_SIZE); + } + mOFN.lpstrDefExt = L".blacklist"; + mOFN.lpstrFilter = + L"Asset Blacklists (*.blacklist)\0*.blacklist\0" \ + L"\0"; + break; // default: return FALSE; diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h index da541cf3f..ea1e61fc2 100644 --- a/indra/newview/llfilepicker.h +++ b/indra/newview/llfilepicker.h @@ -94,6 +94,7 @@ public: // FFLOAD_INVGZ = 9, FFLOAD_AO = 10, + FFLOAD_BLACKLIST = 11 // }; @@ -137,6 +138,7 @@ public: FFSAVE_INVGZ = 33, FFSAVE_LANDMARK = 34, FFSAVE_AO = 35, + FFSAVE_BLACKLIST = 36, // }; diff --git a/indra/newview/llfloaterblacklist.cpp b/indra/newview/llfloaterblacklist.cpp new file mode 100644 index 000000000..054403f98 --- /dev/null +++ b/indra/newview/llfloaterblacklist.cpp @@ -0,0 +1,198 @@ +// +#include "llviewerprecompiledheaders.h" +#include "llfloaterblacklist.h" +#include "lluictrlfactory.h" +#include "llsdserialize.h" +#include "llscrolllistctrl.h" +#include "llcheckboxctrl.h" +#include "llfilepicker.h" +#include "llviewerwindow.h" +#include "llviewercontrol.h" + +LLFloaterBlacklist* LLFloaterBlacklist::sInstance; +LLFloaterBlacklist::LLFloaterBlacklist() +: LLFloater() +{ + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_blacklist.xml"); +} +LLFloaterBlacklist::~LLFloaterBlacklist() +{ + sInstance = NULL; +} +// static +void LLFloaterBlacklist::show() +{ + if(sInstance) + sInstance->open(); + else + { + sInstance = new LLFloaterBlacklist(); + sInstance->open(); + } +} +BOOL LLFloaterBlacklist::postBuild() +{ + childSetAction("add_btn", onClickAdd, this); + childSetAction("clear_btn", onClickClear, this); + childSetAction("copy_uuid_btn", onClickCopyUUID, this); + childSetAction("remove_btn", onClickRemove, this); + childSetAction("save_btn", onClickSave, this); + childSetAction("load_btn", onClickLoad, this); + refresh(); + return TRUE; +} +void LLFloaterBlacklist::refresh() +{ + LLScrollListCtrl* list = getChild("file_list"); + list->clearRows(); + if(gAssetStorage) // just in case + { + LLSD settings; + for(std::vector::iterator iter = gAssetStorage->mBlackListedAsset.begin(); + iter != gAssetStorage->mBlackListedAsset.end(); ++iter) + { + LLSD element; + element["id"] = (*iter); + LLSD& name_column = element["columns"][0]; + name_column["column"] = "asset_id"; + name_column["value"] = (*iter).asString(); + list->addElement(element, ADD_BOTTOM); + settings.append((*iter)); + } + setMassEnabled(!gAssetStorage->mBlackListedAsset.empty()); + gSavedSettings.setLLSD("Blacklist.Settings",settings); + } + else + setMassEnabled(FALSE); + setEditID(mSelectID); +} +void LLFloaterBlacklist::add(LLUUID uuid) +{ + if(gAssetStorage) + gAssetStorage->mBlackListedAsset.push_back(uuid); + refresh(); +} +void LLFloaterBlacklist::clear() +{ + if(gAssetStorage) // just in case + { + gAssetStorage->mBlackListedAsset.clear(); + } + refresh(); +} +void LLFloaterBlacklist::setEditID(LLUUID edit_id) +{ + LLScrollListCtrl* list = getChild("file_list"); + bool found = false; + if(gAssetStorage) + found = std::find(gAssetStorage->mBlackListedAsset.begin(), + gAssetStorage->mBlackListedAsset.end(),edit_id) != gAssetStorage->mBlackListedAsset.end(); + if(found) + { + mSelectID = edit_id; + list->selectByID(edit_id); + setEditEnabled(true); + } + else + { + mSelectID = LLUUID::null; + list->deselectAllItems(TRUE); + setEditEnabled(false); + } +} +void LLFloaterBlacklist::removeEntry() +{ + if(gAssetStorage && mSelectID.notNull()) + std::remove(gAssetStorage->mBlackListedAsset.begin(),gAssetStorage->mBlackListedAsset.end(),mSelectID); + refresh(); +} +void LLFloaterBlacklist::setMassEnabled(bool enabled) +{ + childSetEnabled("clear_btn", enabled); +} +void LLFloaterBlacklist::setEditEnabled(bool enabled) +{ + childSetEnabled("copy_uuid_btn", enabled); + childSetEnabled("remove_btn", enabled); +} +// static +void LLFloaterBlacklist::onClickAdd(void* user_data) +{ + LLFloaterBlacklist* floaterp = (LLFloaterBlacklist*)user_data; + if(!floaterp) return; + floaterp->add(LLUUID(floaterp->childGetValue("id_edit").asString())); +} +// static +void LLFloaterBlacklist::onClickClear(void* user_data) +{ + LLFloaterBlacklist* floaterp = (LLFloaterBlacklist*)user_data; + if(!floaterp) return; + floaterp->clear(); +} +// static +void LLFloaterBlacklist::onCommitFileList(LLUICtrl* ctrl, void* user_data) +{ + LLFloaterBlacklist* floaterp = (LLFloaterBlacklist*)user_data; + LLScrollListCtrl* list = floaterp->getChild("file_list"); + LLUUID selected_id; + if(list->getFirstSelected()) + selected_id = list->getFirstSelected()->getUUID(); + floaterp->setEditID(selected_id); +} +// static +void LLFloaterBlacklist::onClickCopyUUID(void* user_data) +{ + LLFloaterBlacklist* floaterp = (LLFloaterBlacklist*)user_data; + gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(floaterp->mSelectID.asString())); +} +// static +void LLFloaterBlacklist::onClickRemove(void* user_data) +{ + LLFloaterBlacklist* floaterp = (LLFloaterBlacklist*)user_data; + floaterp->removeEntry(); +} +// static +void LLFloaterBlacklist::loadFromSave() +{ + if(!gAssetStorage) return; + LLSD blacklist = gSavedSettings.getLLSD("Blacklist.Settings"); + for(LLSD::array_iterator itr = blacklist.beginArray(); itr != blacklist.endArray(); ++itr) + { + gAssetStorage->mBlackListedAsset.push_back(itr->asUUID()); + } +} +//static +void LLFloaterBlacklist::onClickSave(void* user_data) +{ + LLFilePicker& file_picker = LLFilePicker::instance(); + if(file_picker.getSaveFile( LLFilePicker::FFSAVE_BLACKLIST, LLDir::getScrubbedFileName("untitled.blacklist"))) + { + std::string file_name = file_picker.getFirstFile(); + llofstream export_file(file_name); + LLSDSerialize::toPrettyXML(gSavedSettings.getLLSD("Blacklist.Settings"), export_file); + export_file.close(); + } +} + +//static +void LLFloaterBlacklist::onClickLoad(void* user_data) +{ + LLFloaterBlacklist* floater = (LLFloaterBlacklist*)user_data; + + LLFilePicker& file_picker = LLFilePicker::instance(); + if(file_picker.getOpenFile(LLFilePicker::FFLOAD_BLACKLIST)) + { + std::string file_name = file_picker.getFirstFile(); + llifstream xml_file(file_name); + if(!xml_file.is_open()) return; + LLSD data; + if(LLSDSerialize::fromXML(data, xml_file) >= 1) + { + gSavedSettings.setLLSD("Blacklist.Settings", data); + LLFloaterBlacklist::loadFromSave(); + floater->refresh(); + } + xml_file.close(); + } +} +// diff --git a/indra/newview/llfloaterblacklist.h b/indra/newview/llfloaterblacklist.h new file mode 100644 index 000000000..e7892af84 --- /dev/null +++ b/indra/newview/llfloaterblacklist.h @@ -0,0 +1,33 @@ +// +#ifndef LL_LLFLOATERBLACKLIST_H +#define LL_LLFLOATERBLACKLIST_H +#include "llfloater.h" +class LLFloaterBlacklist : LLFloater +{ +public: + LLFloaterBlacklist(); + ~LLFloaterBlacklist(); + static void show(); + BOOL postBuild(); + void refresh(); + void add(LLUUID uuid); + void clear(); + void setEditID(LLUUID edit_id); + void removeEntry(); + static void onClickAdd(void* user_data); + static void onClickClear(void* user_data); + static void onCommitFileList(LLUICtrl* ctrl, void* user_data); + static void onClickCopyUUID(void* user_data); + static void onClickRemove(void* user_data); + static void loadFromSave(); + static void onClickSave(void* user_data); + static void onClickLoad(void* user_data); +protected: + LLUUID mSelectID; +private: + static LLFloaterBlacklist* sInstance; + void setMassEnabled(bool enabled); + void setEditEnabled(bool enabled); +}; +#endif +// diff --git a/indra/newview/llfloaterexploresounds.cpp b/indra/newview/llfloaterexploresounds.cpp new file mode 100644 index 000000000..658de90fe --- /dev/null +++ b/indra/newview/llfloaterexploresounds.cpp @@ -0,0 +1,456 @@ +// + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterexploresounds.h" +#include "lluictrlfactory.h" +#include "llscrolllistctrl.h" +#include "lllocalinventory.h" +#include "llagent.h" +#include "llviewerwindow.h" +#include "llviewerobjectlist.h" +#include "llviewerregion.h" + +static const size_t num_collision_sounds = 28; +const LLUUID collision_sounds[num_collision_sounds] = +{ + LLUUID("dce5fdd4-afe4-4ea1-822f-dd52cac46b08"), + LLUUID("51011582-fbca-4580-ae9e-1a5593f094ec"), + LLUUID("68d62208-e257-4d0c-bbe2-20c9ea9760bb"), + LLUUID("75872e8c-bc39-451b-9b0b-042d7ba36cba"), + LLUUID("6a45ba0b-5775-4ea8-8513-26008a17f873"), + LLUUID("992a6d1b-8c77-40e0-9495-4098ce539694"), + LLUUID("2de4da5a-faf8-46be-bac6-c4d74f1e5767"), + LLUUID("6e3fb0f7-6d9c-42ca-b86b-1122ff562d7d"), + LLUUID("14209133-4961-4acc-9649-53fc38ee1667"), + LLUUID("bc4a4348-cfcc-4e5e-908e-8a52a8915fe6"), + LLUUID("9e5c1297-6eed-40c0-825a-d9bcd86e3193"), + LLUUID("e534761c-1894-4b61-b20c-658a6fb68157"), + LLUUID("8761f73f-6cf9-4186-8aaa-0948ed002db1"), + LLUUID("874a26fd-142f-4173-8c5b-890cd846c74d"), + LLUUID("0e24a717-b97e-4b77-9c94-b59a5a88b2da"), + LLUUID("75cf3ade-9a5b-4c4d-bb35-f9799bda7fb2"), + LLUUID("153c8bf7-fb89-4d89-b263-47e58b1b4774"), + LLUUID("55c3e0ce-275a-46fa-82ff-e0465f5e8703"), + LLUUID("24babf58-7156-4841-9a3f-761bdbb8e237"), + LLUUID("aca261d8-e145-4610-9e20-9eff990f2c12"), + LLUUID("0642fba6-5dcf-4d62-8e7b-94dbb529d117"), + LLUUID("25a863e8-dc42-4e8a-a357-e76422ace9b5"), + LLUUID("9538f37c-456e-4047-81be-6435045608d4"), + LLUUID("8c0f84c3-9afd-4396-b5f5-9bca2c911c20"), + LLUUID("be582e5d-b123-41a2-a150-454c39e961c8"), + LLUUID("c70141d4-ba06-41ea-bcbc-35ea81cb8335"), + LLUUID("7d1826f4-24c4-4aac-8c2e-eff45df37783"), + LLUUID("063c97d3-033a-4e9b-98d8-05c8074922cb") +}; + +LLFloaterExploreSounds* LLFloaterExploreSounds::sInstance; + +LLFloaterExploreSounds::LLFloaterExploreSounds() +: LLFloater(), LLEventTimer(0.25f) +{ + LLFloaterExploreSounds::sInstance = this; + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_explore_sounds.xml"); +} + +LLFloaterExploreSounds::~LLFloaterExploreSounds() +{ + LLFloaterExploreSounds::sInstance = NULL; +} + +// static +void LLFloaterExploreSounds::toggle() +{ + if(LLFloaterExploreSounds::sInstance) LLFloaterExploreSounds::sInstance->close(FALSE); + else LLFloaterExploreSounds::sInstance = new LLFloaterExploreSounds(); +} + +void LLFloaterExploreSounds::close(bool app_quitting) +{ + LLFloater::close(app_quitting); +} + +BOOL LLFloaterExploreSounds::postBuild(void) +{ + childSetDoubleClickCallback("sound_list", handle_play_locally, this); + + childSetAction("play_locally_btn", handle_play_locally, this); + childSetAction("play_in_world_btn", handle_play_in_world, this); + childSetAction("play_ambient_btn", handle_play_ambient, this); + childSetAction("look_at_btn", handle_look_at, this); + childSetAction("open_btn", handle_open, this); + childSetAction("copy_uuid_btn", handle_copy_uuid, this); + childSetAction("stop_btn", handle_stop, this); + + LLScrollListCtrl* list = getChild("sound_list"); + list->sortByColumn("playing", TRUE); + return TRUE; +} + +LLSoundHistoryItem LLFloaterExploreSounds::getItem(LLUUID itemID) +{ + if(gSoundHistory.find(itemID) != gSoundHistory.end()) + return gSoundHistory[itemID]; + else + { + // If log is paused, hopefully we can find it in mLastHistory + std::list::iterator iter = mLastHistory.begin(); + std::list::iterator end = mLastHistory.end(); + for( ; iter != end; ++iter) + { + if((*iter).mID == itemID) return (*iter); + } + } + LLSoundHistoryItem item; + item.mID = LLUUID::null; + return item; +} + +class LLSoundHistoryItemCompare +{ +public: + bool operator() (LLSoundHistoryItem first, LLSoundHistoryItem second) + { + if(first.mPlaying) + { + if(second.mPlaying) + { + return (first.mTimeStarted > second.mTimeStarted); + } + else + { + return true; + } + } + else if(second.mPlaying) + { + return false; + } + else + { + return (first.mTimeStopped > second.mTimeStopped); + } + } +}; + +// static +BOOL LLFloaterExploreSounds::tick() +{ + //if(childGetValue("pause_chk").asBoolean()) return FALSE; + + bool show_collision_sounds = childGetValue("collision_chk").asBoolean(); + bool show_repeated_assets = childGetValue("repeated_asset_chk").asBoolean(); + bool show_avatars = childGetValue("avatars_chk").asBoolean(); + bool show_objects = childGetValue("objects_chk").asBoolean(); + + std::list history; + if(childGetValue("pause_chk").asBoolean()) + { + history = mLastHistory; + } + else + { + std::map::iterator map_iter = gSoundHistory.begin(); + std::map::iterator map_end = gSoundHistory.end(); + for( ; map_iter != map_end; ++map_iter) + { + history.push_back((*map_iter).second); + } + LLSoundHistoryItemCompare c; + history.sort(c); + mLastHistory = history; + } + + LLScrollListCtrl* list = getChild("sound_list"); + + // Save scroll pos and selection so they can be restored + S32 scroll_pos = list->getScrollPos(); + LLDynamicArray selected_ids; + std::vector selected_items = list->getAllSelected(); + std::vector::iterator selection_iter = selected_items.begin(); + std::vector::iterator selection_end = selected_items.end(); + for(; selection_iter != selection_end; ++selection_iter) + selected_ids.push_back((*selection_iter)->getUUID()); + + list->clearRows(); + + std::list unique_asset_list; + + std::list::iterator iter = history.begin(); + std::list::iterator end = history.end(); + for( ; iter != end; ++iter) + { + LLSoundHistoryItem item = (*iter); + + bool is_avatar = item.mOwnerID == item.mSourceID; + if(is_avatar && !show_avatars) continue; + + bool is_object = !is_avatar; + if(is_object && !show_objects) continue; + + bool is_repeated_asset = std::find(unique_asset_list.begin(), unique_asset_list.end(), item.mAssetID) != unique_asset_list.end(); + if(is_repeated_asset && !show_repeated_assets) continue; + + if(!item.mReviewed) + { + item.mReviewedCollision = std::find(&collision_sounds[0], &collision_sounds[num_collision_sounds], item.mAssetID) != &collision_sounds[num_collision_sounds]; + item.mReviewed = true; + } + bool is_collision_sound = item.mReviewedCollision; + if(is_collision_sound && !show_collision_sounds) continue; + + unique_asset_list.push_back(item.mAssetID); + + LLSD element; + element["id"] = item.mID; + + LLSD& playing_column = element["columns"][0]; + playing_column["column"] = "playing"; + if(item.mPlaying) + playing_column["value"] = " Playing"; + else + playing_column["value"] = llformat("%.1f min ago", (LLTimer::getElapsedSeconds() - item.mTimeStopped) / 60.f); + + LLSD& type_column = element["columns"][1]; + type_column["column"] = "type"; + if(item.mType == LLAudioEngine::AUDIO_TYPE_UI) + { + // this shouldn't happen for now, as UI is forbidden in the log + type_column["value"] = "UI"; + } + else + { + std::string type; + + if(is_avatar) + { + type = "Avatar"; + } + else + { + if(item.mIsTrigger) + { + type = "llTriggerSound"; + } + else + { + if(item.mIsLooped) + type = "llLoopSound"; + else + type = "llPlaySound"; + } + } + + type_column["value"] = type; + } + + LLSD& owner_column = element["columns"][2]; + owner_column["column"] = "owner"; + std::string fullname; + BOOL is_group; + if(gCacheName->getIfThere(item.mOwnerID, fullname, is_group)) + { + if(is_group) fullname += " (Group)"; + owner_column["value"] = fullname; + } + else + owner_column["value"] = item.mOwnerID.asString(); + + LLSD& sound_column = element["columns"][3]; + sound_column["column"] = "sound"; + sound_column["value"] = item.mAssetID.asString(); + + list->addElement(element, ADD_BOTTOM); + } + + list->selectMultiple(selected_ids); + list->setScrollPos(scroll_pos); + + return FALSE; +} + +// static +void LLFloaterExploreSounds::handle_play_locally(void* user_data) +{ + LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data; + LLScrollListCtrl* list = floater->getChild("sound_list"); + std::vector selection = list->getAllSelected(); + std::vector::iterator selection_iter = selection.begin(); + std::vector::iterator selection_end = selection.end(); + std::vector asset_list; + for( ; selection_iter != selection_end; ++selection_iter) + { + LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); + if(item.mID.isNull()) continue; + // Unique assets only + if(std::find(asset_list.begin(), asset_list.end(), item.mAssetID) == asset_list.end()) + { + asset_list.push_back(item.mAssetID); + gAudiop->triggerSound(item.mAssetID, LLUUID::null, 1.0f, LLAudioEngine::AUDIO_TYPE_UI); + } + } +} + +// static +void LLFloaterExploreSounds::handle_play_in_world(void* user_data) +{ + LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data; + LLScrollListCtrl* list = floater->getChild("sound_list"); + std::vector selection = list->getAllSelected(); + std::vector::iterator selection_iter = selection.begin(); + std::vector::iterator selection_end = selection.end(); + for( ; selection_iter != selection_end; ++selection_iter) + { + LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); + if(item.mID.isNull()) continue; + + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_SoundTrigger); + msg->nextBlockFast(_PREHASH_SoundData); + msg->addUUIDFast(_PREHASH_SoundID, item.mAssetID); + // Client untrusted, ids set on sim + msg->addUUIDFast(_PREHASH_OwnerID, LLUUID::null ); + msg->addUUIDFast(_PREHASH_ObjectID, LLUUID::null ); + msg->addUUIDFast(_PREHASH_ParentID, LLUUID::null ); + msg->addU64Fast(_PREHASH_Handle, gAgent.getRegion()->getHandle()); + LLVector3 position = gAgent.getPositionAgent(); + msg->addVector3Fast(_PREHASH_Position, position); + msg->addF32Fast(_PREHASH_Gain, 1.0f); + + gAgent.sendMessage(); + } +} + +// static +void LLFloaterExploreSounds::handle_play_ambient(void* user_data) +{ + LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data; + LLScrollListCtrl* list = floater->getChild("sound_list"); + std::vector selection = list->getAllSelected(); + std::vector::iterator selection_iter = selection.begin(); + std::vector::iterator selection_end = selection.end(); + for( ; selection_iter != selection_end; ++selection_iter) + { + LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); + if(item.mID.isNull()) continue; + int gain = 0.01f; + for(int i = 0; i < 2; i++) + { + gMessageSystem->newMessageFast(_PREHASH_SoundTrigger); + gMessageSystem->nextBlockFast(_PREHASH_SoundData); + gMessageSystem->addUUIDFast(_PREHASH_SoundID, item.mAssetID); + gMessageSystem->addUUIDFast(_PREHASH_OwnerID, LLUUID::null); + gMessageSystem->addUUIDFast(_PREHASH_ObjectID, LLUUID::null); + gMessageSystem->addUUIDFast(_PREHASH_ParentID, LLUUID::null); + gMessageSystem->addU64Fast(_PREHASH_Handle, gAgent.getRegion()->getHandle()); + LLVector3d pos = -from_region_handle(gAgent.getRegion()->getHandle()); + gMessageSystem->addVector3Fast(_PREHASH_Position, (LLVector3)pos); + gMessageSystem->addF32Fast(_PREHASH_Gain, gain); + + gMessageSystem->sendReliable(gAgent.getRegionHost()); + + gain = 1.0f; + } + } +} + + +// static +void LLFloaterExploreSounds::handle_look_at(void* user_data) +{ + LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data; + LLScrollListCtrl* list = floater->getChild("sound_list"); + LLUUID selection = list->getSelectedValue().asUUID(); + LLSoundHistoryItem item = floater->getItem(selection); // Single item only + if(item.mID.isNull()) return; + + LLVector3d pos_global = item.mPosition; + + // Try to find object position + if(item.mSourceID.notNull()) + { + LLViewerObject* object = gObjectList.findObject(item.mSourceID); + if(object) + { + pos_global = object->getPositionGlobal(); + } + } + + // Move the camera + // Find direction to self (reverse) + LLVector3d cam = gAgent.getPositionGlobal() - pos_global; + cam.normalize(); + // Go 4 meters back and 3 meters up + cam *= 4.0f; + cam += pos_global; + cam += LLVector3d(0.f, 0.f, 3.0f); + + gAgent.setFocusOnAvatar(FALSE, FALSE); + gAgent.setCameraPosAndFocusGlobal(cam, pos_global, item.mSourceID); + gAgent.setCameraAnimating(FALSE); +} + +// static +void LLFloaterExploreSounds::handle_open(void* user_data) +{ + LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data; + LLScrollListCtrl* list = floater->getChild("sound_list"); + std::vector selection = list->getAllSelected(); + std::vector::iterator selection_iter = selection.begin(); + std::vector::iterator selection_end = selection.end(); + std::vector asset_list; + for( ; selection_iter != selection_end; ++selection_iter) + { + LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); + if(item.mID.isNull()) continue; + // Unique assets only + if(std::find(asset_list.begin(), asset_list.end(), item.mAssetID) == asset_list.end()) + { + asset_list.push_back(item.mAssetID); + LLUUID inv_item = LLLocalInventory::addItem(item.mAssetID.asString(), LLAssetType::AT_SOUND, item.mAssetID, true); + } + } +} + +// static +void LLFloaterExploreSounds::handle_copy_uuid(void* user_data) +{ + LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data; + LLScrollListCtrl* list = floater->getChild("sound_list"); + LLUUID selection = list->getSelectedValue().asUUID(); // Single item only + LLSoundHistoryItem item = floater->getItem(selection); + if(item.mID.isNull()) return; + + gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(item.mAssetID.asString())); +} + +// static +void LLFloaterExploreSounds::handle_stop(void* user_data) +{ + LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data; + LLScrollListCtrl* list = floater->getChild("sound_list"); + std::vector selection = list->getAllSelected(); + std::vector::iterator selection_iter = selection.begin(); + std::vector::iterator selection_end = selection.end(); + std::vector asset_list; + for( ; selection_iter != selection_end; ++selection_iter) + { + LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); + if(item.mID.isNull()) continue; + if(item.mPlaying) + { + if(item.mAudioSource) + { + S32 type = item.mType; + item.mAudioSource->setType(LLAudioEngine::AUDIO_TYPE_UI); + if(item.mAudioSource) + item.mAudioSource->play(LLUUID::null); + if(item.mAudioSource) + item.mAudioSource->setType(type); + } + } + } +} + + +// diff --git a/indra/newview/llfloaterexploresounds.h b/indra/newview/llfloaterexploresounds.h new file mode 100644 index 000000000..90a6e4df3 --- /dev/null +++ b/indra/newview/llfloaterexploresounds.h @@ -0,0 +1,41 @@ +// + +#ifndef LL_LLFLOATEREXPLORESOUNDS_H +#define LL_LLFLOATEREXPLORESOUNDS_H + +#include "llfloater.h" +#include "llaudioengine.h" + +class LLFloaterExploreSounds +: public LLFloater, public LLEventTimer +{ +public: + LLFloaterExploreSounds(); + BOOL postBuild(void); + void close(bool app_quitting); + + BOOL tick(); + + LLSoundHistoryItem getItem(LLUUID itemID); + + static void handle_play_locally(void* user_data); + static void handle_play_in_world(void* user_data); + static void handle_play_ambient(void* user_data); + static void handle_look_at(void* user_data); + static void handle_open(void* user_data); + static void handle_copy_uuid(void* user_data); + static void handle_stop(void* user_data); + +private: + virtual ~LLFloaterExploreSounds(); + std::list mLastHistory; + +// static stuff! +public: + static LLFloaterExploreSounds* sInstance; + + static void toggle(); +}; + +#endif +// diff --git a/indra/newview/llfloatervfsexplorer.cpp b/indra/newview/llfloatervfsexplorer.cpp index a070d59c7..6f6384a37 100644 --- a/indra/newview/llfloatervfsexplorer.cpp +++ b/indra/newview/llfloatervfsexplorer.cpp @@ -43,6 +43,7 @@ BOOL LLFloaterVFSExplorer::postBuild() childSetAction("reload_all_btn", onClickReload, this); childSetAction("copy_uuid_btn", onClickCopyUUID, this); childSetAction("edit_data_btn", onClickEditData, this); + childSetAction("item_btn", onClickItem, this); refresh(); return TRUE; } @@ -178,13 +179,14 @@ void LLFloaterVFSExplorer::onClickReload(void* user_data) void LLFloaterVFSExplorer::onClickEditData(void* user_data) { LLFloaterVFSExplorer* floaterp = (LLFloaterVFSExplorer*)user_data; - LLVFSFileSpecifier file; - std::map::iterator end = sVFSFileMap.end(); - for(std::map::iterator iter = sVFSFileMap.begin(); iter != end; ++iter) - { - if((*iter).first.mFileID == floaterp->mEditID) - file = (*iter).first; - } + LLVFSFileSpecifier file = floaterp->getEditEntry(); DOFloaterHex::show(file.mFileID, true, file.mFileType); } +// static +void LLFloaterVFSExplorer::onClickItem(void* user_data) +{ + LLFloaterVFSExplorer* floaterp = (LLFloaterVFSExplorer*)user_data; + LLVFSFileSpecifier file = floaterp->getEditEntry(); + LLLocalInventory::addItem(file.mFileID.asString(),file.mFileType,file.mFileID,true); +} // diff --git a/indra/newview/llfloatervfsexplorer.h b/indra/newview/llfloatervfsexplorer.h index c945beb52..fc77def51 100644 --- a/indra/newview/llfloatervfsexplorer.h +++ b/indra/newview/llfloatervfsexplorer.h @@ -30,6 +30,7 @@ public: static void onClickRemove(void* user_data); static void onClickReload(void* user_data); static void onClickEditData(void* user_data); + static void onClickItem(void* user_data); private: static LLFloaterVFSExplorer* sInstance; static std::map sVFSFileMap; diff --git a/indra/newview/llimportobject.cpp b/indra/newview/llimportobject.cpp index 6067daa44..d2f489818 100644 --- a/indra/newview/llimportobject.cpp +++ b/indra/newview/llimportobject.cpp @@ -23,6 +23,7 @@ #include "lleconomy.h" #include "llfloaterperms.h" #include "llviewerregion.h" +#include "llviewerobjectlist.h" // static vars bool LLXmlImport::sImportInProgress = false; @@ -45,7 +46,59 @@ LLXmlImportOptions* LLXmlImport::sXmlImportOptions; std::map LLXmlImport::sTextureReplace; int LLXmlImport::sTotalAssets = 0; int LLXmlImport::sUploadedAssets = 0; +// timer for watching link +class LLLinkTimer : public LLEventTimer +{ +public: + LLLinkTimer(std::vector roots) : LLEventTimer(0.1f) + { + mOptions = LLXmlImport::sXmlImportOptions; + mRoots = roots; + } + virtual BOOL tick() + { + // Import for this timer has been cancled :< + if(!LLXmlImport::sImportInProgress || (LLXmlImport::sXmlImportOptions && mOptions && mOptions != LLXmlImport::sXmlImportOptions)) return TRUE; + // LET US CONTINUE + std::vector unlinked_roots; + for(std::vector::iterator itr = mRoots.begin();itr != mRoots.end();itr++) + { + LLViewerObject* object = gObjectList.findObject((*itr)); + if(object) + { + if(object->numChildren() == 0) + { + llinfos << "WAIT " << (*itr).asString() << llendl; + unlinked_roots.push_back((*itr)); + } + } + } + if(unlinked_roots.size() > 0) + { + mRoots = unlinked_roots; + return FALSE; + } + else + { + LLXmlImport::finish_link(); + return TRUE; + } + } + +protected: + LLXmlImportOptions* mOptions; + std::vector mRoots; +}; +bool operator==(const LLXmlImportOptions &a, const LLXmlImportOptions &b) +{ + return (a.mID == b.mID); +} + +bool operator!=(const LLXmlImportOptions &a, const LLXmlImportOptions &b) +{ + return (a.mID != b.mID); +} LLXmlImportOptions::LLXmlImportOptions(LLXmlImportOptions* options) { mName = options->mName; @@ -55,6 +108,7 @@ LLXmlImportOptions::LLXmlImportOptions(LLXmlImportOptions* options) mSupplier = options->mSupplier; mKeepPosition = options->mKeepPosition; mAssetDir = options->mAssetDir; + mID = options->mID; } LLXmlImportOptions::LLXmlImportOptions(std::string filename) : mSupplier(NULL), @@ -128,14 +182,7 @@ void LLXmlImportOptions::init(LLSD llsd) mChildObjects.push_back(unsorted_objects[i]); } - F32 throttle = gSavedSettings.getF32("OutBandwidth"); - // Gross magical value that is 128kbit/s - // Sim appears to drop requests if they come in faster than this. *sigh* - if(throttle < 128000.) - { - gMessageSystem->mPacketRing.setOutBandwidth(128000.0); - } - gMessageSystem->mPacketRing.setUseOutThrottle(TRUE); + mID.generate(); } LLImportAssetData::LLImportAssetData(std::string infilename,LLUUID inassetid,LLAssetType::EType intype) @@ -568,6 +615,15 @@ void LLXmlImport::rez_supply() // static void LLXmlImport::import(LLXmlImportOptions* import_options) { + F32 throttle = gSavedSettings.getF32("OutBandwidth"); + // Gross magical value that is 128kbit/s + // Sim appears to drop requests if they come in faster than this. *sigh* + if(throttle < 128000.) + { + gMessageSystem->mPacketRing.setOutBandwidth(128000.0); + } + gMessageSystem->mPacketRing.setUseOutThrottle(TRUE); + sXmlImportOptions = import_options; if(sXmlImportOptions->mSupplier == NULL) { @@ -994,39 +1050,54 @@ void LLXmlImport::onNewPrim(LLViewerObject* object) else { // Take attachables into inventory - std::string msg = "Wait a few moments for the attachments to attach..."; + std::string msg = "Wait a few moments for the attachments to link and attach..."; LLChat chat(msg); LLFloaterChat::addChat(chat); - - sAttachmentsDone = 0; - std::map::iterator at_iter = sId2attachpt.begin(); - std::map::iterator at_end = sId2attachpt.end(); - for( ; at_iter != at_end; ++at_iter) + U32 ip = gAgent.getRegionHost().getAddress(); + U32 port = gAgent.getRegionHost().getPort(); + std::vector roots; + roots.resize(sLinkSets.size()); + for(std::map >::iterator itr = sLinkSets.begin();itr != sLinkSets.end();++itr) { - LLUUID tid; - tid.generate(); - U32 at_localid = sId2localid[(*at_iter).first]; - gMessageSystem->newMessageFast(_PREHASH_DeRezObject); - gMessageSystem->nextBlockFast(_PREHASH_AgentData); - gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - gMessageSystem->nextBlockFast(_PREHASH_AgentBlock); - gMessageSystem->addUUIDFast(_PREHASH_GroupID, LLUUID::null); - gMessageSystem->addU8Fast(_PREHASH_Destination, DRD_TAKE_INTO_AGENT_INVENTORY); - gMessageSystem->addUUIDFast(_PREHASH_DestinationID, sFolderID); - gMessageSystem->addUUIDFast(_PREHASH_TransactionID, tid); - gMessageSystem->addU8Fast(_PREHASH_PacketCount, 1); - gMessageSystem->addU8Fast(_PREHASH_PacketNumber, 0); - gMessageSystem->nextBlockFast(_PREHASH_ObjectData); - gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, at_localid); - gMessageSystem->sendReliable(gAgent.getRegionHost()); + LLUUID id = LLUUID::null; + LLViewerObjectList::getUUIDFromLocal(id,itr->first,ip,port); + if(id.notNull()) + { + roots.push_back(id); + } } + sAttachmentsDone = 0; + new LLLinkTimer(roots); } } LLFloaterImportProgress::update(); rez_supply(); } - +void LLXmlImport::finish_link() +{ + std::map::iterator at_iter = sId2attachpt.begin(); + std::map::iterator at_end = sId2attachpt.end(); + for( ; at_iter != at_end; ++at_iter) + { + LLUUID tid; + tid.generate(); + U32 at_localid = sId2localid[(*at_iter).first]; + gMessageSystem->newMessageFast(_PREHASH_DeRezObject); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + gMessageSystem->nextBlockFast(_PREHASH_AgentBlock); + gMessageSystem->addUUIDFast(_PREHASH_GroupID, LLUUID::null); + gMessageSystem->addU8Fast(_PREHASH_Destination, DRD_TAKE_INTO_AGENT_INVENTORY); + gMessageSystem->addUUIDFast(_PREHASH_DestinationID, sFolderID); + gMessageSystem->addUUIDFast(_PREHASH_TransactionID, tid); + gMessageSystem->addU8Fast(_PREHASH_PacketCount, 1); + gMessageSystem->addU8Fast(_PREHASH_PacketNumber, 0); + gMessageSystem->nextBlockFast(_PREHASH_ObjectData); + gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, at_localid); + gMessageSystem->sendReliable(gAgent.getRegionHost()); + } +} // static void LLXmlImport::onNewItem(LLViewerInventoryItem* item) { diff --git a/indra/newview/llimportobject.h b/indra/newview/llimportobject.h index da1d4beb7..77d3bfe33 100644 --- a/indra/newview/llimportobject.h +++ b/indra/newview/llimportobject.h @@ -56,6 +56,8 @@ public: class LLXmlImportOptions { + friend bool operator==(const LLXmlImportOptions &a, const LLXmlImportOptions &b); + friend bool operator!=(const LLXmlImportOptions &a, const LLXmlImportOptions &b); public: LLXmlImportOptions(LLXmlImportOptions* options); LLXmlImportOptions(std::string filename); @@ -73,6 +75,8 @@ public: BOOL mKeepPosition; LLViewerObject* mSupplier; BOOL mReplaceTexture; +protected: + LLUUID mID; }; @@ -86,6 +90,7 @@ public: static void Cancel(void* user_data); static void rez_supply(); static void finish_init(); + static void finish_link(); static bool sImportInProgress; static bool sImportHasAttachments; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 9370e406b..30c70527c 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -198,6 +198,7 @@ //#include "llfloateravatars.h" //#include "llactivation.h" #include "llao.h" +#include "llfloaterblacklist.h" //#include "llcheats.h" // @@ -1421,6 +1422,7 @@ bool idle_startup() // LLAO::refresh(); + LLFloaterBlacklist::loadFromSave(); // if (show_connect_box) diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 62b4c8bf7..9aa2ed600 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -596,6 +596,13 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == INIT) { + if(gAssetStorage && std::find(gAssetStorage->mBlackListedAsset.begin(), + gAssetStorage->mBlackListedAsset.end(),mID) != gAssetStorage->mBlackListedAsset.end()) + { + llinfos << "Blacklisted asset " << mID.asString() << " was trying to be accessed!!!!!!" << llendl; + mState = DONE; + return true; + } mRequestedDiscard = -1; mLoadedDiscard = -1; mDecodedDiscard = -1; @@ -606,6 +613,9 @@ bool LLTextureFetchWorker::doWork(S32 param) mSentRequest = UNSENT; mDecoded = FALSE; mWritten = FALSE; + // + if(mBuffer) + // delete[] mBuffer; mBuffer = NULL; mBufferSize = 0; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 07e316a46..640a31e8f 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -64,6 +64,8 @@ #include "llfloaterimport.h" #include "llfloaterexport.h" #include "llfloaterexploreanimations.h" +#include "llfloaterexploresounds.h" +#include "llfloaterblacklist.h" // #include "lltimer.h" #include "llvfile.h" @@ -406,6 +408,8 @@ void handle_open_message_builder(void*); void handle_edit_ao(void*); void handle_local_assets(void*); void handle_vfs_explorer(void*); +void handle_sounds_explorer(void*); +void handle_blacklist(void*); // BOOL is_inventory_visible( void* user_data ); @@ -761,6 +765,10 @@ void init_client_menu(LLMenuGL* menu) &handle_local_assets, NULL)); sub->append(new LLMenuItemCallGL( "VFS Explorer", &handle_vfs_explorer, NULL)); + sub->append(new LLMenuItemCallGL( "Sound Explorer", + &handle_sounds_explorer, NULL)); + sub->append(new LLMenuItemCallGL( "Asset Blacklist", + &handle_blacklist, NULL)); sub->append(new LLMenuItemCheckGL( "Enable AO", &menu_toggle_control, @@ -3103,6 +3111,16 @@ void handle_vfs_explorer(void*) LLFloaterVFSExplorer::show(); } +void handle_sounds_explorer(void*) +{ + LLFloaterExploreSounds::toggle(); +} + +void handle_blacklist(void*) +{ + LLFloaterBlacklist::show(); +} + void handle_close_all_notifications(void*) { LLView::child_list_t child_list(*(gNotifyBoxView->getChildList())); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 4f2245f3c..f970df1b6 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3635,8 +3635,8 @@ void process_sound_trigger(LLMessageSystem *msg, void **) } // - gAudiop->triggerSound(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX, pos_global); - //gAudiop->triggerSound(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX, pos_global, object_id); + //gAudiop->triggerSound(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX, pos_global); + gAudiop->triggerSound(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX, pos_global, object_id); // } diff --git a/indra/newview/skins/default/xui/en-us/floater_blacklist.xml b/indra/newview/skins/default/xui/en-us/floater_blacklist.xml new file mode 100644 index 000000000..6a2981b46 --- /dev/null +++ b/indra/newview/skins/default/xui/en-us/floater_blacklist.xml @@ -0,0 +1,17 @@ + + +