LSL add a translation layer btw lsl permitions and internal permissions
parent
d1df9c9ee5
commit
7ef657c415
|
@ -115,6 +115,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
protected float m_ScriptDistanceFactor = 1.0f;
|
protected float m_ScriptDistanceFactor = 1.0f;
|
||||||
protected float m_MinTimerInterval = 0.5f;
|
protected float m_MinTimerInterval = 0.5f;
|
||||||
protected float m_recoilScaleFactor = 0.0f;
|
protected float m_recoilScaleFactor = 0.0f;
|
||||||
|
protected bool m_AllowGodFunctions;
|
||||||
|
|
||||||
protected double m_timer = Util.GetTimeStampMS();
|
protected double m_timer = Util.GetTimeStampMS();
|
||||||
protected bool m_waitingForScriptAnswer = false;
|
protected bool m_waitingForScriptAnswer = false;
|
||||||
|
@ -340,7 +341,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
// Rezzing an object with a velocity can create recoil. This feature seems to have been
|
// Rezzing an object with a velocity can create recoil. This feature seems to have been
|
||||||
// removed from recent versions of SL. The code computes recoil (vel*mass) and scales
|
// removed from recent versions of SL. The code computes recoil (vel*mass) and scales
|
||||||
// it by this factor. May be zero to turn off recoil all together.
|
// it by this factor. May be zero to turn off recoil all together.
|
||||||
m_recoilScaleFactor = m_ScriptEngine.Config.GetFloat("RecoilScaleFactor", m_recoilScaleFactor);
|
m_recoilScaleFactor = seConfig.GetFloat("RecoilScaleFactor", m_recoilScaleFactor);
|
||||||
|
m_AllowGodFunctions = seConfig.GetBoolean("AllowGodFunctions", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_notecardLineReadCharsMax > 65535)
|
if (m_notecardLineReadCharsMax > 65535)
|
||||||
|
@ -4841,8 +4843,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
|
|
||||||
byte[] bucket = new byte[1];
|
byte[] bucket = new byte[1];
|
||||||
bucket[0] = (byte)item.Type;
|
bucket[0] = (byte)item.Type;
|
||||||
//byte[] objBytes = agentItem.ID.GetBytes();
|
|
||||||
//Array.Copy(objBytes, 0, bucket, 1, 16);
|
|
||||||
|
|
||||||
GridInstantMessage msg = new GridInstantMessage(World,
|
GridInstantMessage msg = new GridInstantMessage(World,
|
||||||
m_host.OwnerID, m_host.Name, destId,
|
m_host.OwnerID, m_host.Name, destId,
|
||||||
|
@ -11161,8 +11161,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
ScenePresence presence = World.GetScenePresence(objID);
|
ScenePresence presence = World.GetScenePresence(objID);
|
||||||
if (presence != null)
|
if (presence != null)
|
||||||
{
|
{
|
||||||
// As per LSL Wiki, there is no difference between sitting
|
|
||||||
// and standing avatar since server 1.36
|
|
||||||
LSL_Vector lower;
|
LSL_Vector lower;
|
||||||
LSL_Vector upper;
|
LSL_Vector upper;
|
||||||
|
|
||||||
|
@ -12667,74 +12665,132 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
return new LSL_List(outlist);
|
return new LSL_List(outlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const uint fullperms = (uint)PermissionMask.All; // no export for now
|
||||||
|
|
||||||
|
private int PermissionMaskToLSLPerm(uint value)
|
||||||
|
{
|
||||||
|
value &= fullperms;
|
||||||
|
if (value == fullperms)
|
||||||
|
return ScriptBaseClass.PERM_ALL;
|
||||||
|
if( value == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if ((value & (uint)PermissionMask.Copy) != 0)
|
||||||
|
ret |= ScriptBaseClass.PERM_COPY;
|
||||||
|
|
||||||
|
if ((value & (uint)PermissionMask.Modify) != 0)
|
||||||
|
ret |= ScriptBaseClass.PERM_MODIFY;
|
||||||
|
|
||||||
|
if ((value & (uint)PermissionMask.Move) != 0)
|
||||||
|
ret |= ScriptBaseClass.PERM_MOVE;
|
||||||
|
|
||||||
|
if ((value & (uint)PermissionMask.Transfer) != 0)
|
||||||
|
ret |= ScriptBaseClass.PERM_TRANSFER;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private uint LSLPermToPermissionMask(int lslperm, uint oldvalue)
|
||||||
|
{
|
||||||
|
lslperm &= ScriptBaseClass.PERM_ALL;
|
||||||
|
if (lslperm == ScriptBaseClass.PERM_ALL)
|
||||||
|
return oldvalue |= fullperms;
|
||||||
|
|
||||||
|
oldvalue &= ~fullperms;
|
||||||
|
if(lslperm != 0)
|
||||||
|
{
|
||||||
|
if ((lslperm & ScriptBaseClass.PERM_COPY) != 0)
|
||||||
|
oldvalue |= (uint)PermissionMask.Copy;
|
||||||
|
|
||||||
|
if ((lslperm & ScriptBaseClass.PERM_MODIFY) != 0)
|
||||||
|
oldvalue |= (uint)PermissionMask.Modify;
|
||||||
|
|
||||||
|
if ((lslperm & ScriptBaseClass.PERM_MOVE) != 0)
|
||||||
|
oldvalue |= (uint)PermissionMask.Move;
|
||||||
|
|
||||||
|
if ((lslperm & ScriptBaseClass.PERM_TRANSFER) != 0)
|
||||||
|
oldvalue |= (uint)PermissionMask.Transfer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return oldvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int fixedCopyTransfer(int value)
|
||||||
|
{
|
||||||
|
if ((value & (ScriptBaseClass.PERM_COPY | ScriptBaseClass.PERM_TRANSFER)) == 0)
|
||||||
|
value |= ScriptBaseClass.PERM_TRANSFER;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
public LSL_Integer llGetObjectPermMask(int mask)
|
public LSL_Integer llGetObjectPermMask(int mask)
|
||||||
{
|
{
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
|
|
||||||
int permmask = 0;
|
switch(mask)
|
||||||
|
|
||||||
if (mask == ScriptBaseClass.MASK_BASE)//0
|
|
||||||
{
|
{
|
||||||
permmask = (int)m_host.BaseMask;
|
case ScriptBaseClass.MASK_BASE:
|
||||||
}
|
return PermissionMaskToLSLPerm(m_host.BaseMask);
|
||||||
|
|
||||||
else if (mask == ScriptBaseClass.MASK_OWNER)//1
|
case ScriptBaseClass.MASK_OWNER:
|
||||||
{
|
return PermissionMaskToLSLPerm(m_host.OwnerMask);
|
||||||
permmask = (int)m_host.OwnerMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (mask == ScriptBaseClass.MASK_GROUP)//2
|
case ScriptBaseClass.MASK_GROUP:
|
||||||
{
|
return PermissionMaskToLSLPerm(m_host.GroupMask);
|
||||||
permmask = (int)m_host.GroupMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (mask == ScriptBaseClass.MASK_EVERYONE)//3
|
case ScriptBaseClass.MASK_EVERYONE:
|
||||||
{
|
return PermissionMaskToLSLPerm(m_host.EveryoneMask);
|
||||||
permmask = (int)m_host.EveryoneMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (mask == ScriptBaseClass.MASK_NEXT)//4
|
case ScriptBaseClass.MASK_NEXT:
|
||||||
{
|
return PermissionMaskToLSLPerm(m_host.NextOwnerMask);
|
||||||
permmask = (int)m_host.NextOwnerMask;
|
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
return permmask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void llSetObjectPermMask(int mask, int value)
|
public void llSetObjectPermMask(int mask, int value)
|
||||||
{
|
{
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
|
|
||||||
if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false))
|
if (!m_AllowGodFunctions || !World.Permissions.IsAdministrator(m_host.OwnerID))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// not even admins have right to violate basic rules
|
||||||
|
if (mask != ScriptBaseClass.MASK_BASE)
|
||||||
{
|
{
|
||||||
if (World.Permissions.IsAdministrator(m_host.OwnerID))
|
mask &= PermissionMaskToLSLPerm(m_host.BaseMask);
|
||||||
{
|
if (mask != ScriptBaseClass.MASK_OWNER)
|
||||||
if (mask == ScriptBaseClass.MASK_BASE)//0
|
mask &= PermissionMaskToLSLPerm(m_host.OwnerMask);
|
||||||
{
|
|
||||||
m_host.BaseMask = (uint)value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (mask == ScriptBaseClass.MASK_OWNER)//1
|
switch (mask)
|
||||||
{
|
{
|
||||||
m_host.OwnerMask = (uint)value;
|
case ScriptBaseClass.MASK_BASE:
|
||||||
}
|
value = fixedCopyTransfer(value);
|
||||||
|
m_host.BaseMask = LSLPermToPermissionMask(value, m_host.BaseMask);
|
||||||
|
break;
|
||||||
|
|
||||||
else if (mask == ScriptBaseClass.MASK_GROUP)//2
|
case ScriptBaseClass.MASK_OWNER:
|
||||||
{
|
value = fixedCopyTransfer(value);
|
||||||
m_host.GroupMask = (uint)value;
|
m_host.OwnerMask = LSLPermToPermissionMask(value, m_host.OwnerMask);
|
||||||
}
|
break;
|
||||||
|
|
||||||
else if (mask == ScriptBaseClass.MASK_EVERYONE)//3
|
case ScriptBaseClass.MASK_GROUP:
|
||||||
{
|
m_host.GroupMask = LSLPermToPermissionMask(value, m_host.GroupMask);
|
||||||
m_host.EveryoneMask = (uint)value;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
else if (mask == ScriptBaseClass.MASK_NEXT)//4
|
case ScriptBaseClass.MASK_EVERYONE:
|
||||||
{
|
m_host.EveryoneMask = LSLPermToPermissionMask(value, m_host.EveryoneMask);
|
||||||
m_host.NextOwnerMask = (uint)value;
|
break;
|
||||||
}
|
|
||||||
}
|
case ScriptBaseClass.MASK_NEXT:
|
||||||
|
value = fixedCopyTransfer(value);
|
||||||
|
m_host.NextOwnerMask = LSLPermToPermissionMask(value, m_host.NextOwnerMask);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
m_host.ParentGroup.AggregatePerms();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LSL_Integer llGetInventoryPermMask(string itemName, int mask)
|
public LSL_Integer llGetInventoryPermMask(string itemName, int mask)
|
||||||
|
@ -12748,53 +12804,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
|
|
||||||
switch (mask)
|
switch (mask)
|
||||||
{
|
{
|
||||||
case 0:
|
case ScriptBaseClass.MASK_BASE:
|
||||||
return (int)item.BasePermissions;
|
return PermissionMaskToLSLPerm(item.BasePermissions);
|
||||||
case 1:
|
case ScriptBaseClass.MASK_OWNER:
|
||||||
return (int)item.CurrentPermissions;
|
return PermissionMaskToLSLPerm(item.CurrentPermissions);
|
||||||
case 2:
|
case ScriptBaseClass.MASK_GROUP:
|
||||||
return (int)item.GroupPermissions;
|
return PermissionMaskToLSLPerm(item.GroupPermissions);
|
||||||
case 3:
|
case ScriptBaseClass.MASK_EVERYONE:
|
||||||
return (int)item.EveryonePermissions;
|
return PermissionMaskToLSLPerm(item.EveryonePermissions);
|
||||||
case 4:
|
case ScriptBaseClass.MASK_NEXT:
|
||||||
return (int)item.NextPermissions;
|
return PermissionMaskToLSLPerm(item.NextPermissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void llSetInventoryPermMask(string itemName, int mask, int value)
|
public void llSetInventoryPermMask(string itemName, int mask, int value)
|
||||||
{
|
{
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
|
if(!m_AllowGodFunctions || !World.Permissions.IsAdministrator(m_host.OwnerID))
|
||||||
|
return;
|
||||||
|
|
||||||
if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false))
|
|
||||||
{
|
|
||||||
if (World.Permissions.IsAdministrator(m_host.OwnerID))
|
|
||||||
{
|
|
||||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
|
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
|
if (mask != ScriptBaseClass.MASK_BASE)
|
||||||
|
{
|
||||||
|
mask &= PermissionMaskToLSLPerm(item.BasePermissions);
|
||||||
|
if (mask != ScriptBaseClass.MASK_OWNER)
|
||||||
|
mask &= PermissionMaskToLSLPerm(item.CurrentPermissions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(item.Type == (int)(AssetType.Settings))
|
||||||
|
value |= ScriptBaseClass.PERM_COPY;
|
||||||
|
*/
|
||||||
|
|
||||||
switch (mask)
|
switch (mask)
|
||||||
{
|
{
|
||||||
case 0:
|
case ScriptBaseClass.MASK_BASE:
|
||||||
item.BasePermissions = (uint)value;
|
value = fixedCopyTransfer(value);
|
||||||
|
item.BasePermissions = LSLPermToPermissionMask(value, item.BasePermissions);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case ScriptBaseClass.MASK_OWNER:
|
||||||
item.CurrentPermissions = (uint)value;
|
value = fixedCopyTransfer(value);
|
||||||
|
item.CurrentPermissions = LSLPermToPermissionMask(value, item.CurrentPermissions);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case ScriptBaseClass.MASK_GROUP:
|
||||||
item.GroupPermissions = (uint)value;
|
item.GroupPermissions = LSLPermToPermissionMask(value, item.GroupPermissions);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case ScriptBaseClass.MASK_EVERYONE:
|
||||||
item.EveryonePermissions = (uint)value;
|
item.EveryonePermissions = LSLPermToPermissionMask(value, item.EveryonePermissions);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case ScriptBaseClass.MASK_NEXT:
|
||||||
item.NextPermissions = (uint)value;
|
value = fixedCopyTransfer(value);
|
||||||
|
item.NextPermissions = LSLPermToPermissionMask(value, item.NextPermissions);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
m_host.ParentGroup.InvalidateDeepEffectivePerms();
|
||||||
|
m_host.ParentGroup.AggregatePerms();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue