Code consolidation. Redundant code moved into single function (checkMediaURL).

This commit is contained in:
Shyotl
2011-10-08 03:01:32 -05:00
parent 4b08f52332
commit 464b16e621
3 changed files with 55 additions and 56 deletions

View File

@@ -1880,7 +1880,7 @@ void LLSelectMgr::selectionSetFullbright(U8 fullbright)
void LLSelectMgr::selectionSetMediaTypeAndURL(U8 media_type, const std::string& media_url)
{
U8 media_flags = LLTextureEntry::MF_NONE;
if (media_type == LLViewerObject::MEDIA_TYPE_WEB_PAGE)
if (media_type == LLViewerObject::MEDIA_SET)
{
media_flags = LLTextureEntry::MF_HAS_MEDIA;
}

View File

@@ -740,6 +740,42 @@ void LLViewerObject::hideExtraDisplayItems( BOOL hidden )
}
}
U32 LLViewerObject::checkMediaURL(const std::string &media_url)
{
U32 retval = (U32)0x0;
if (!mMedia && !media_url.empty())
{
retval |= MEDIA_URL_ADDED;
mMedia = new LLViewerObjectMedia;
mMedia->mMediaURL = media_url;
mMedia->mMediaType = LLViewerObject::MEDIA_SET;
mMedia->mPassedWhitelist = FALSE;
}
else if (mMedia)
{
if (media_url.empty())
{
retval |= MEDIA_URL_REMOVED;
delete mMedia;
mMedia = NULL;
}
else if (mMedia->mMediaURL != media_url) // <-- This is an optimization. If they are equal don't bother with below's test.
{
/*if (! (LLTextureEntry::getAgentIDFromMediaVersionString(media_url) == gAgent.getID() &&
LLTextureEntry::getVersionFromMediaVersionString(media_url) ==
LLTextureEntry::getVersionFromMediaVersionString(mMedia->mMediaURL) + 1))
*/
{
// If the media URL is different and WE were not the one who
// changed it, mark dirty.
retval |= MEDIA_URL_UPDATED;
}
mMedia->mMediaURL = media_url;
mMedia->mPassedWhitelist = FALSE;
}
}
return retval;
}
U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
void **user_data,
@@ -1118,35 +1154,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
std::string media_url;
mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_MediaURL, media_url, block_num);
//if (!media_url.empty())
//{
// llinfos << "WEBONPRIM media_url " << media_url << llendl;
//}
if (!mMedia && !media_url.empty())
{
retval |= MEDIA_URL_ADDED;
mMedia = new LLViewerObjectMedia;
mMedia->mMediaURL = media_url;
mMedia->mMediaType = LLViewerObject::MEDIA_TYPE_WEB_PAGE;
mMedia->mPassedWhitelist = FALSE;
}
else if (mMedia)
{
if (media_url.empty())
{
retval |= MEDIA_URL_REMOVED;
delete mMedia;
mMedia = NULL;
}
else if (mMedia->mMediaURL != media_url)
{
// We just added or changed a web page.
retval |= MEDIA_URL_UPDATED;
mMedia->mMediaURL = media_url;
mMedia->mPassedWhitelist = FALSE;
}
}
retval |= checkMediaURL(media_url);
//
// Unpack particle system data
//
@@ -1546,31 +1555,12 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
mText = NULL;
}
std::string media_url;
if (value & 0x200)
{
std::string media_url;
dp->unpackString(media_url, "MediaURL");
if (!mMedia)
{
retval |= MEDIA_URL_ADDED;
mMedia = new LLViewerObjectMedia;
mMedia->mMediaURL = media_url;
mMedia->mMediaType = LLViewerObject::MEDIA_TYPE_WEB_PAGE;
mMedia->mPassedWhitelist = FALSE;
}
else if (mMedia->mMediaURL != media_url)
{
retval |= MEDIA_URL_UPDATED;
mMedia->mMediaURL = media_url;
mMedia->mPassedWhitelist = FALSE;
}
}
else if (mMedia)
{
retval |= MEDIA_URL_REMOVED;
delete mMedia;
mMedia = NULL;
}
retval |= checkMediaURL(media_url);
//
// Unpack particle system data
@@ -3863,7 +3853,7 @@ U8 LLViewerObject::getMediaType() const
}
else
{
return LLViewerObject::MEDIA_TYPE_NONE;
return LLViewerObject::MEDIA_NONE;
}
}

View File

@@ -158,10 +158,15 @@ public:
virtual BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
// Types of media we can associate
enum { MEDIA_TYPE_NONE = 0, MEDIA_TYPE_WEB_PAGE = 1 };
enum { MEDIA_NONE = 0, MEDIA_SET = 1 };
// Return codes for processUpdateMessage
enum { MEDIA_URL_REMOVED = 0x1, MEDIA_URL_ADDED = 0x2, MEDIA_URL_UPDATED = 0x4, INVALID_UPDATE = 0x80000000 };
enum {
MEDIA_URL_REMOVED = 0x1,
MEDIA_URL_ADDED = 0x2,
MEDIA_URL_UPDATED = 0x4,
INVALID_UPDATE = 0x80000000
};
virtual U32 processUpdateMessage(LLMessageSystem *mesgsys,
void **user_data,
@@ -546,6 +551,10 @@ private:
ExtraParameter* getExtraParameterEntry(U16 param_type) const;
ExtraParameter* getExtraParameterEntryCreate(U16 param_type);
bool unpackParameterEntry(U16 param_type, LLDataPacker *dp);
// This function checks to see if the given media URL has changed its version
// and the update wasn't due to this agent's last action.
U32 checkMediaURL(const std::string &media_url);
// Motion prediction between updates
void interpolateLinearMotion(const F64 & time, const F32 & dt);
@@ -812,8 +821,8 @@ public:
class LLAlphaObject : public LLViewerObject
{
public:
LLAlphaObject(const LLUUID &id, const LLPCode type, LLViewerRegion *regionp)
: LLViewerObject(id,type,regionp)
LLAlphaObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
: LLViewerObject(id,pcode,regionp)
{ mDepth = 0.f; }
virtual F32 getPartSize(S32 idx);