Imported new revoke anim perms code and refactored related bits

This commit is contained in:
Drake Arconis
2013-11-15 19:51:21 -05:00
parent 14c43aa9a2
commit 924908f2ad
4 changed files with 90 additions and 12 deletions

View File

@@ -84,6 +84,7 @@
#include "llworld.h"
#include "llworldmap.h"
#include "llworldmapmessage.h"
#include "../lscript/lscript_byteformat.h"
//Misc non-standard includes
#include "llurldispatcher.h"
@@ -3061,7 +3062,7 @@ LLQuaternion LLAgent::getHeadRotation()
return rot;
}
void LLAgent::sendAnimationRequests(LLDynamicArray<LLUUID> &anim_ids, EAnimRequest request)
void LLAgent::sendAnimationRequests(const std::vector<LLUUID> &anim_ids, EAnimRequest request)
{
if (gAgentID.isNull())
{
@@ -3076,7 +3077,7 @@ void LLAgent::sendAnimationRequests(LLDynamicArray<LLUUID> &anim_ids, EAnimReque
msg->addUUIDFast(_PREHASH_AgentID, getID());
msg->addUUIDFast(_PREHASH_SessionID, getSessionID());
for (S32 i = 0; i < anim_ids.count(); i++)
for (U32 i = 0; i < anim_ids.size(); i++)
{
if (anim_ids[i].isNull())
{
@@ -3118,6 +3119,55 @@ void LLAgent::sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request)
sendReliableMessage();
}
// Send a message to the region to stop the NULL animation state
// This will reset animation state overrides for the agent.
void LLAgent::sendAnimationStateReset()
{
if (gAgentID.isNull() || !mRegionp)
{
return;
}
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_AgentAnimation);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, getID());
msg->addUUIDFast(_PREHASH_SessionID, getSessionID());
msg->nextBlockFast(_PREHASH_AnimationList);
msg->addUUIDFast(_PREHASH_AnimID, LLUUID::null );
msg->addBOOLFast(_PREHASH_StartAnim, FALSE);
msg->nextBlockFast(_PREHASH_PhysicalAvatarEventList);
msg->addBinaryDataFast(_PREHASH_TypeData, NULL, 0);
sendReliableMessage();
}
// Send a message to the region to revoke sepecified permissions on ALL scripts in the region
// If the target is an object in the region, permissions in scripts on that object are cleared.
// If it is the region ID, all scripts clear the permissions for this agent
void LLAgent::sendRevokePermissions(const LLUUID & target, U32 permissions)
{
// Currently only the bits for SCRIPT_PERMISSION_TRIGGER_ANIMATION and SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS
// are supported by the server. Sending any other bits will cause the message to be dropped without changing permissions
if (gAgentID.notNull() && gMessageSystem)
{
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_RevokePermissions);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, getID()); // Must be our ID
msg->addUUIDFast(_PREHASH_SessionID, getSessionID());
msg->nextBlockFast(_PREHASH_Data);
msg->addUUIDFast(_PREHASH_ObjectID, target); // Must be in the region
msg->addU32Fast(_PREHASH_ObjectPermissions, permissions);
sendReliableMessage();
}
}
// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
void LLAgent::setAlwaysRun()
{
@@ -4338,6 +4388,8 @@ void LLAgent::stopCurrentAnimations()
// avatar, propagating this change back to the server.
if (isAgentAvatarValid())
{
std::vector<LLUUID> anim_ids;
for ( LLVOAvatar::AnimIterator anim_it =
gAgentAvatarp->mPlayingAnimations.begin();
anim_it != gAgentAvatarp->mPlayingAnimations.end();
@@ -4355,7 +4407,24 @@ void LLAgent::stopCurrentAnimations()
// stop this animation locally
gAgentAvatarp->stopMotion(anim_it->first, TRUE);
// ...and tell the server to tell everyone.
sendAnimationRequest(anim_it->first, ANIM_REQUEST_STOP);
anim_ids.push_back(anim_it->first);
}
}
sendAnimationRequests(anim_ids, ANIM_REQUEST_STOP);
// Tell the region to clear any animation state overrides
sendAnimationStateReset();
// Revoke all animation permissions
if (mRegionp &&
gSavedSettings.getBOOL("RevokePermsOnStopAnimation"))
{
U32 permissions = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TRIGGER_ANIMATION] | LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS];
sendRevokePermissions(mRegionp->getRegionID(), permissions);
if (gAgentAvatarp->isSitting())
{ // Also stand up, since auto-granted sit animation permission has been revoked
gAgent.standUp();
}
}