mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 22:26:09 +08:00
Merge branch 'master' into careminster-presence-refactor
This commit is contained in:
@@ -2111,7 +2111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return;
|
||||
|
||||
// Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
|
||||
LSL_Vector currentPos = llGetLocalPos();
|
||||
LSL_Vector currentPos = GetPartLocalPos(part);
|
||||
|
||||
float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y);
|
||||
bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true);
|
||||
@@ -2144,33 +2144,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public LSL_Vector llGetLocalPos()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
if (m_host.IsAttachment == true) {
|
||||
if (m_host.IsRoot == true)
|
||||
{
|
||||
return new LSL_Vector(m_host.AbsolutePosition.X,
|
||||
m_host.AbsolutePosition.Y,
|
||||
m_host.AbsolutePosition.Z);
|
||||
return GetPartLocalPos(m_host);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return new LSL_Vector(m_host.OffsetPosition.X,
|
||||
m_host.OffsetPosition.Y,
|
||||
m_host.OffsetPosition.Z);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_host.ParentID != 0)
|
||||
protected LSL_Vector GetPartLocalPos(SceneObjectPart part)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
if (part.ParentID != 0)
|
||||
{
|
||||
return new LSL_Vector(m_host.OffsetPosition.X,
|
||||
m_host.OffsetPosition.Y,
|
||||
m_host.OffsetPosition.Z);
|
||||
return new LSL_Vector(part.OffsetPosition.X,
|
||||
part.OffsetPosition.Y,
|
||||
part.OffsetPosition.Z);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new LSL_Vector(m_host.AbsolutePosition.X,
|
||||
m_host.AbsolutePosition.Y,
|
||||
m_host.AbsolutePosition.Z);
|
||||
return new LSL_Vector(part.AbsolutePosition.X,
|
||||
part.AbsolutePosition.Y,
|
||||
part.AbsolutePosition.Z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8300,6 +8290,241 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return res;
|
||||
}
|
||||
|
||||
public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
ScriptSleep(1000);
|
||||
|
||||
// LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid
|
||||
// TODO: Need to correctly handle case where a face has no media (which gives back an empty list).
|
||||
// Assuming silently fail means give back an empty list. Ideally, need to check this.
|
||||
if (face < 0 || face > m_host.GetNumberOfSides() - 1)
|
||||
return new LSL_List();
|
||||
|
||||
return GetPrimMediaParams(face, rules);
|
||||
}
|
||||
|
||||
private LSL_List GetPrimMediaParams(int face, LSL_List rules)
|
||||
{
|
||||
IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
|
||||
if (null == module)
|
||||
throw new Exception("Media on a prim functions not available");
|
||||
|
||||
MediaEntry me = module.GetMediaEntry(m_host, face);
|
||||
|
||||
// As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams
|
||||
if (null == me)
|
||||
return new LSL_List();
|
||||
|
||||
LSL_List res = new LSL_List();
|
||||
|
||||
for (int i = 0; i < rules.Length; i++)
|
||||
{
|
||||
int code = (int)rules.GetLSLIntegerItem(i);
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
|
||||
// Not implemented
|
||||
res.Add(new LSL_Integer(0));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
|
||||
if (me.Controls == MediaControls.Standard)
|
||||
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD));
|
||||
else
|
||||
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_MINI));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
|
||||
res.Add(new LSL_String(me.CurrentURL));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
|
||||
res.Add(new LSL_String(me.HomeURL));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
|
||||
res.Add(me.AutoLoop ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
|
||||
res.Add(me.AutoPlay ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
|
||||
res.Add(me.AutoScale ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
|
||||
res.Add(me.AutoZoom ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
|
||||
res.Add(me.InteractOnFirstClick ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
|
||||
res.Add(new LSL_Integer(me.Width));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS:
|
||||
res.Add(new LSL_Integer(me.Height));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE:
|
||||
res.Add(me.EnableWhiteList ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_WHITELIST:
|
||||
string[] urls = (string[])me.WhiteList.Clone();
|
||||
|
||||
for (int j = 0; j < urls.Length; j++)
|
||||
urls[j] = Uri.EscapeDataString(urls[j]);
|
||||
|
||||
res.Add(new LSL_String(string.Join(", ", urls)));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT:
|
||||
res.Add(new LSL_Integer((int)me.InteractPermissions));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
|
||||
res.Add(new LSL_Integer((int)me.ControlPermissions));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
ScriptSleep(1000);
|
||||
|
||||
// LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid
|
||||
// Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this.
|
||||
// Don't perform the media check directly
|
||||
if (face < 0 || face > m_host.GetNumberOfSides() - 1)
|
||||
return ScriptBaseClass.LSL_STATUS_OK;
|
||||
|
||||
return SetPrimMediaParams(face, rules);
|
||||
}
|
||||
|
||||
private LSL_Integer SetPrimMediaParams(int face, LSL_List rules)
|
||||
{
|
||||
IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
|
||||
if (null == module)
|
||||
throw new Exception("Media on a prim functions not available");
|
||||
|
||||
MediaEntry me = module.GetMediaEntry(m_host, face);
|
||||
if (null == me)
|
||||
me = new MediaEntry();
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (i < rules.Length - 1)
|
||||
{
|
||||
int code = rules.GetLSLIntegerItem(i++);
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
|
||||
me.EnableAlterntiveImage = (rules.GetLSLIntegerItem(i++) != 0 ? true : false);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
|
||||
int v = rules.GetLSLIntegerItem(i++);
|
||||
if (ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD == v)
|
||||
me.Controls = MediaControls.Standard;
|
||||
else
|
||||
me.Controls = MediaControls.Mini;
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
|
||||
me.CurrentURL = rules.GetLSLStringItem(i++);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
|
||||
me.HomeURL = rules.GetLSLStringItem(i++);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
|
||||
me.AutoLoop = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
|
||||
me.AutoPlay = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
|
||||
me.AutoScale = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
|
||||
me.AutoZoom = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
|
||||
me.InteractOnFirstClick = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
|
||||
me.Width = (int)rules.GetLSLIntegerItem(i++);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS:
|
||||
me.Height = (int)rules.GetLSLIntegerItem(i++);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE:
|
||||
me.EnableWhiteList = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_WHITELIST:
|
||||
string[] rawWhiteListUrls = rules.GetLSLStringItem(i++).ToString().Split(new char[] { ',' });
|
||||
List<string> whiteListUrls = new List<string>();
|
||||
Array.ForEach(
|
||||
rawWhiteListUrls, delegate(string rawUrl) { whiteListUrls.Add(rawUrl.Trim()); });
|
||||
me.WhiteList = whiteListUrls.ToArray();
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT:
|
||||
me.InteractPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
|
||||
me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
module.SetMediaEntry(m_host, face, me);
|
||||
|
||||
return ScriptBaseClass.LSL_STATUS_OK;
|
||||
}
|
||||
|
||||
public LSL_Integer llClearPrimMedia(LSL_Integer face)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
ScriptSleep(1000);
|
||||
|
||||
// LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid
|
||||
// Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this.
|
||||
// FIXME: Don't perform the media check directly
|
||||
if (face < 0 || face > m_host.GetNumberOfSides() - 1)
|
||||
return ScriptBaseClass.LSL_STATUS_OK;
|
||||
|
||||
IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
|
||||
if (null == module)
|
||||
throw new Exception("Media on a prim functions not available");
|
||||
|
||||
module.ClearMediaEntry(m_host, face);
|
||||
|
||||
return ScriptBaseClass.LSL_STATUS_OK;
|
||||
}
|
||||
|
||||
// <remarks>
|
||||
// <para>
|
||||
// The .NET definition of base 64 is:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
void llBreakLink(int linknum);
|
||||
LSL_Integer llCeil(double f);
|
||||
void llClearCameraParams();
|
||||
LSL_Integer llClearPrimMedia(LSL_Integer face);
|
||||
void llCloseRemoteDataChannel(string channel);
|
||||
LSL_Float llCloud(LSL_Vector offset);
|
||||
void llCollisionFilter(string name, string id, int accept);
|
||||
@@ -162,6 +163,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
LSL_List llGetParcelPrimOwners(LSL_Vector pos);
|
||||
LSL_Integer llGetPermissions();
|
||||
LSL_Key llGetPermissionsKey();
|
||||
LSL_List llGetPrimMediaParams(int face, LSL_List rules);
|
||||
LSL_Vector llGetPos();
|
||||
LSL_List llGetPrimitiveParams(LSL_List rules);
|
||||
LSL_Integer llGetRegionAgentCount();
|
||||
@@ -332,6 +334,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
void llSetParcelMusicURL(string url);
|
||||
void llSetPayPrice(int price, LSL_List quick_pay_buttons);
|
||||
void llSetPos(LSL_Vector pos);
|
||||
LSL_Integer llSetPrimMediaParams(int face, LSL_List rules);
|
||||
void llSetPrimitiveParams(LSL_List rules);
|
||||
void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules);
|
||||
void llSetPrimURL(string url);
|
||||
|
||||
@@ -277,6 +277,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const int CHANGED_TELEPORT = 512;
|
||||
public const int CHANGED_REGION_RESTART = 1024;
|
||||
public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART
|
||||
public const int CHANGED_MEDIA = 2048;
|
||||
public const int CHANGED_ANIMATION = 16384;
|
||||
public const int TYPE_INVALID = 0;
|
||||
public const int TYPE_INTEGER = 1;
|
||||
@@ -518,6 +519,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const int TOUCH_INVALID_FACE = -1;
|
||||
public static readonly vector TOUCH_INVALID_TEXCOORD = new vector(-1.0, -1.0, 0.0);
|
||||
public static readonly vector TOUCH_INVALID_VECTOR = ZERO_VECTOR;
|
||||
|
||||
// constants for llGetPrimMediaParams/llSetPrimMediaParams
|
||||
public const int PRIM_MEDIA_ALT_IMAGE_ENABLE = 0;
|
||||
public const int PRIM_MEDIA_CONTROLS = 1;
|
||||
public const int PRIM_MEDIA_CURRENT_URL = 2;
|
||||
public const int PRIM_MEDIA_HOME_URL = 3;
|
||||
public const int PRIM_MEDIA_AUTO_LOOP = 4;
|
||||
public const int PRIM_MEDIA_AUTO_PLAY = 5;
|
||||
public const int PRIM_MEDIA_AUTO_SCALE = 6;
|
||||
public const int PRIM_MEDIA_AUTO_ZOOM = 7;
|
||||
public const int PRIM_MEDIA_FIRST_CLICK_INTERACT = 8;
|
||||
public const int PRIM_MEDIA_WIDTH_PIXELS = 9;
|
||||
public const int PRIM_MEDIA_HEIGHT_PIXELS = 10;
|
||||
public const int PRIM_MEDIA_WHITELIST_ENABLE = 11;
|
||||
public const int PRIM_MEDIA_WHITELIST = 12;
|
||||
public const int PRIM_MEDIA_PERMS_INTERACT = 13;
|
||||
public const int PRIM_MEDIA_PERMS_CONTROL = 14;
|
||||
|
||||
public const int PRIM_MEDIA_CONTROLS_STANDARD = 0;
|
||||
public const int PRIM_MEDIA_CONTROLS_MINI = 1;
|
||||
|
||||
public const int PRIM_MEDIA_PERM_NONE = 0;
|
||||
public const int PRIM_MEDIA_PERM_OWNER = 1;
|
||||
public const int PRIM_MEDIA_PERM_GROUP = 2;
|
||||
public const int PRIM_MEDIA_PERM_ANYONE = 4;
|
||||
|
||||
// extra constants for llSetPrimMediaParams
|
||||
public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0);
|
||||
public static readonly LSLInteger LSL_STATUS_MALFORMED_PARAMS = new LSLInteger(1000);
|
||||
public static readonly LSLInteger LSL_STATUS_TYPE_MISMATCH = new LSLInteger(1001);
|
||||
public static readonly LSLInteger LSL_STATUS_BOUNDS_ERROR = new LSLInteger(1002);
|
||||
public static readonly LSLInteger LSL_STATUS_NOT_FOUND = new LSLInteger(1003);
|
||||
public static readonly LSLInteger LSL_STATUS_NOT_SUPPORTED = new LSLInteger(1004);
|
||||
public static readonly LSLInteger LSL_STATUS_INTERNAL_ERROR = new LSLInteger(1999);
|
||||
public static readonly LSLInteger LSL_STATUS_WHITELIST_FAILED = new LSLInteger(2001);
|
||||
|
||||
// Constants for default textures
|
||||
public const string TEXTURE_BLANK = "5748decc-f629-461c-9a36-a35a221fe21f";
|
||||
|
||||
@@ -1834,5 +1834,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
{
|
||||
return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2);
|
||||
}
|
||||
|
||||
public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
|
||||
{
|
||||
return m_LSL_Functions.llGetPrimMediaParams(face, rules);
|
||||
}
|
||||
|
||||
public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules)
|
||||
{
|
||||
return m_LSL_Functions.llSetPrimMediaParams(face, rules);
|
||||
}
|
||||
|
||||
public LSL_Integer llClearPrimMedia(LSL_Integer face)
|
||||
{
|
||||
return m_LSL_Functions.llClearPrimMedia(face);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user