added perms checking, duplicated functionality to methods that do not require perms and have higher threat level
parent
c677c04f10
commit
ce7694c108
|
@ -3549,11 +3549,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (m_UrlModule != null)
|
||||
m_UrlModule.HttpContentType(new UUID(id),type);
|
||||
}
|
||||
|
||||
public void osDropAttachment()
|
||||
/// Shout an error if the object owner did not grant the script the specified permissions.
|
||||
/// </summary>
|
||||
/// <param name="perms"></param>
|
||||
/// <returns>boolean indicating whether an error was shouted.</returns>
|
||||
protected bool ShoutErrorOnLackingOwnerPerms(int perms, string errorPrefix)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachment");
|
||||
m_host.AddScriptLPS(1);
|
||||
bool fail = false;
|
||||
if (m_item.PermsGranter != m_host.OwnerID)
|
||||
{
|
||||
fail = true;
|
||||
OSSLShoutError(string.Format("{0}. Permissions not granted to owner.", errorPrefix));
|
||||
}
|
||||
else if ((m_item.PermsMask & perms) == 0)
|
||||
{
|
||||
fail = true;
|
||||
OSSLShoutError(string.Format("{0}. Permissions not granted.", errorPrefix));
|
||||
}
|
||||
|
||||
return fail;
|
||||
}
|
||||
|
||||
protected void DropAttachment(bool checkPerms)
|
||||
{
|
||||
if (checkPerms && ShoutErrorOnLackingOwnerPerms(ScriptBaseClass.PERMISSION_ATTACH, "Cannot drop attachment"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
|
||||
ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID);
|
||||
|
@ -3564,10 +3588,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
}
|
||||
|
||||
public void osDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot)
|
||||
protected void DropAttachemntAt(bool checkPerms, LSL_Vector pos, LSL_Rotation rot)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachmentAt");
|
||||
m_host.AddScriptLPS(1);
|
||||
if (checkPerms && ShoutErrorOnLackingOwnerPerms(ScriptBaseClass.PERMISSION_ATTACH, "Cannot drop attachment"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
|
||||
ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID);
|
||||
|
@ -3579,5 +3605,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
attachmentsModule.DetachSingleAttachmentToGround(sp, m_host.ParentGroup.LocalId, omvPos, omvRot);
|
||||
}
|
||||
}
|
||||
|
||||
public void osDropAttachment()
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachment");
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
DropAttachment(true);
|
||||
}
|
||||
|
||||
public void osForceDropAttachment()
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osForceDropAttachment");
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
DropAttachment(false);
|
||||
}
|
||||
|
||||
public void osDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachmentAt");
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
DropAttachemntAt(true, pos, rot);
|
||||
}
|
||||
|
||||
public void osForceDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osForceDropAttachmentAt");
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
DropAttachemntAt(false, pos, rot);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -400,11 +400,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
|||
/// </summary>
|
||||
void osDropAttachment();
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to drop an attachment to the ground while bypassing the script permissions
|
||||
/// </summary>
|
||||
void osForceDropAttachment();
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to drop an attachment at the specified coordinates.
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
/// <param name="rot"></param>
|
||||
void osDropAttachmentAt(vector pos, rotation rot);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to drop an attachment at the specified coordinates while bypassing the script permissions
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
/// <param name="rot"></param>
|
||||
void osForceDropAttachmentAt(vector pos, rotation rot);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -978,9 +978,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
|||
m_OSSL_Functions.osDropAttachment();
|
||||
}
|
||||
|
||||
public void osForceDropAttachment()
|
||||
{
|
||||
m_OSSL_Functions.osForceDropAttachment();
|
||||
}
|
||||
|
||||
public void osDropAttachmentAt(vector pos, rotation rot)
|
||||
{
|
||||
m_OSSL_Functions.osDropAttachmentAt(pos, rot);
|
||||
}
|
||||
|
||||
public void osForceDropAttachmentAt(vector pos, rotation rot)
|
||||
{
|
||||
m_OSSL_Functions.osForceDropAttachmentAt(pos, rot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue