diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 172 |
1 files changed, 123 insertions, 49 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0cc8829..e2d17a7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -4213,7 +4213,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4213 | List<String> nametable = new List<String>(); | 4213 | List<String> nametable = new List<String>(); |
4214 | World.ForEachRootScenePresence(delegate(ScenePresence presence) | 4214 | World.ForEachRootScenePresence(delegate(ScenePresence presence) |
4215 | { | 4215 | { |
4216 | if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) | 4216 | SceneObjectPart sitPart = presence.ParentPart; |
4217 | if (sitPart != null && m_host.ParentGroup.HasChildPrim(sitPart.LocalId)) | ||
4217 | nametable.Add(presence.ControllingClient.Name); | 4218 | nametable.Add(presence.ControllingClient.Name); |
4218 | }); | 4219 | }); |
4219 | 4220 | ||
@@ -4450,7 +4451,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4450 | Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f), | 4451 | Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f), |
4451 | Util.Clip((float)color.y, 0.0f, 1.0f), | 4452 | Util.Clip((float)color.y, 0.0f, 1.0f), |
4452 | Util.Clip((float)color.z, 0.0f, 1.0f)); | 4453 | Util.Clip((float)color.z, 0.0f, 1.0f)); |
4453 | m_host.SetText(text.Length > 254 ? text.Remove(255) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); | 4454 | m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); |
4454 | //m_host.ParentGroup.HasGroupChanged = true; | 4455 | //m_host.ParentGroup.HasGroupChanged = true; |
4455 | //m_host.ParentGroup.ScheduleGroupForFullUpdate(); | 4456 | //m_host.ParentGroup.ScheduleGroupForFullUpdate(); |
4456 | } | 4457 | } |
@@ -4844,22 +4845,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4844 | 4845 | ||
4845 | // Find pushee position | 4846 | // Find pushee position |
4846 | // Pushee Linked? | 4847 | // Pushee Linked? |
4847 | if (pusheeav.ParentID != 0) | 4848 | SceneObjectPart sitPart = pusheeav.ParentPart; |
4848 | { | 4849 | if (sitPart != null) |
4849 | SceneObjectPart parentobj = World.GetSceneObjectPart(pusheeav.ParentID); | 4850 | PusheePos = sitPart.AbsolutePosition; |
4850 | if (parentobj != null) | ||
4851 | { | ||
4852 | PusheePos = parentobj.AbsolutePosition; | ||
4853 | } | ||
4854 | else | ||
4855 | { | ||
4856 | PusheePos = pusheeav.AbsolutePosition; | ||
4857 | } | ||
4858 | } | ||
4859 | else | 4851 | else |
4860 | { | ||
4861 | PusheePos = pusheeav.AbsolutePosition; | 4852 | PusheePos = pusheeav.AbsolutePosition; |
4862 | } | ||
4863 | } | 4853 | } |
4864 | 4854 | ||
4865 | if (!pusheeIsAvatar) | 4855 | if (!pusheeIsAvatar) |
@@ -6067,7 +6057,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6067 | flags |= ScriptBaseClass.AGENT_IN_AIR; | 6057 | flags |= ScriptBaseClass.AGENT_IN_AIR; |
6068 | } | 6058 | } |
6069 | 6059 | ||
6070 | if (agent.ParentID != 0) | 6060 | if (agent.ParentPart != null) |
6071 | { | 6061 | { |
6072 | flags |= ScriptBaseClass.AGENT_ON_OBJECT; | 6062 | flags |= ScriptBaseClass.AGENT_ON_OBJECT; |
6073 | flags |= ScriptBaseClass.AGENT_SITTING; | 6063 | flags |= ScriptBaseClass.AGENT_SITTING; |
@@ -6866,16 +6856,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6866 | } | 6856 | } |
6867 | } | 6857 | } |
6868 | 6858 | ||
6869 | public void llSitTarget(LSL_Vector offset, LSL_Rotation rot) | 6859 | protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot) |
6870 | { | 6860 | { |
6871 | m_host.AddScriptLPS(1); | ||
6872 | // LSL quaternions can normalize to 0, normal Quaternions can't. | 6861 | // LSL quaternions can normalize to 0, normal Quaternions can't. |
6873 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) | 6862 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) |
6874 | rot.z = 1; // ZERO_ROTATION = 0,0,0,1 | 6863 | rot.z = 1; // ZERO_ROTATION = 0,0,0,1 |
6875 | 6864 | ||
6876 | m_host.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); | 6865 | part.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); |
6877 | m_host.SitTargetOrientation = Rot2Quaternion(rot); | 6866 | part.SitTargetOrientation = Rot2Quaternion(rot); |
6878 | m_host.ParentGroup.HasGroupChanged = true; | 6867 | part.ParentGroup.HasGroupChanged = true; |
6868 | } | ||
6869 | |||
6870 | public void llSitTarget(LSL_Vector offset, LSL_Rotation rot) | ||
6871 | { | ||
6872 | m_host.AddScriptLPS(1); | ||
6873 | SitTarget(m_host, offset, rot); | ||
6874 | } | ||
6875 | |||
6876 | public void llLinkSitTarget(LSL_Integer link, LSL_Vector offset, LSL_Rotation rot) | ||
6877 | { | ||
6878 | m_host.AddScriptLPS(1); | ||
6879 | if (link == ScriptBaseClass.LINK_ROOT) | ||
6880 | SitTarget(m_host.ParentGroup.RootPart, offset, rot); | ||
6881 | else if (link == ScriptBaseClass.LINK_THIS) | ||
6882 | SitTarget(m_host, offset, rot); | ||
6883 | else | ||
6884 | { | ||
6885 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link); | ||
6886 | if (null != part) | ||
6887 | { | ||
6888 | SitTarget(part, offset, rot); | ||
6889 | } | ||
6890 | } | ||
6879 | } | 6891 | } |
6880 | 6892 | ||
6881 | public LSL_String llAvatarOnSitTarget() | 6893 | public LSL_String llAvatarOnSitTarget() |
@@ -7560,10 +7572,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7560 | shapeBlock.PathScaleX = 100; | 7572 | shapeBlock.PathScaleX = 100; |
7561 | shapeBlock.PathScaleY = 150; | 7573 | shapeBlock.PathScaleY = 150; |
7562 | 7574 | ||
7563 | if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 && | 7575 | int flag = type & (ScriptBaseClass.PRIM_SCULPT_FLAG_INVERT | ScriptBaseClass.PRIM_SCULPT_FLAG_MIRROR); |
7564 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 && | 7576 | |
7565 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 && | 7577 | if (type != (ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER | flag) && |
7566 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0) | 7578 | type != (ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE | flag) && |
7579 | type != (ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE | flag) && | ||
7580 | type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) | ||
7567 | { | 7581 | { |
7568 | // default | 7582 | // default |
7569 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7583 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
@@ -8851,23 +8865,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8851 | { | 8865 | { |
8852 | m_host.AddScriptLPS(1); | 8866 | m_host.AddScriptLPS(1); |
8853 | ScriptSleep(1000); | 8867 | ScriptSleep(1000); |
8868 | return GetPrimMediaParams(m_host, face, rules); | ||
8869 | } | ||
8870 | |||
8871 | public LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules) | ||
8872 | { | ||
8873 | m_host.AddScriptLPS(1); | ||
8874 | ScriptSleep(1000); | ||
8875 | if (link == ScriptBaseClass.LINK_ROOT) | ||
8876 | return GetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules); | ||
8877 | else if (link == ScriptBaseClass.LINK_THIS) | ||
8878 | return GetPrimMediaParams(m_host, face, rules); | ||
8879 | else | ||
8880 | { | ||
8881 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link); | ||
8882 | if (null != part) | ||
8883 | return GetPrimMediaParams(part, face, rules); | ||
8884 | } | ||
8854 | 8885 | ||
8886 | return new LSL_List(); | ||
8887 | } | ||
8888 | |||
8889 | private LSL_List GetPrimMediaParams(SceneObjectPart part, int face, LSL_List rules) | ||
8890 | { | ||
8855 | // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid | 8891 | // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid |
8856 | // TODO: Need to correctly handle case where a face has no media (which gives back an empty list). | 8892 | // TODO: Need to correctly handle case where a face has no media (which gives back an empty list). |
8857 | // Assuming silently fail means give back an empty list. Ideally, need to check this. | 8893 | // Assuming silently fail means give back an empty list. Ideally, need to check this. |
8858 | if (face < 0 || face > m_host.GetNumberOfSides() - 1) | 8894 | if (face < 0 || face > part.GetNumberOfSides() - 1) |
8859 | return new LSL_List(); | 8895 | return new LSL_List(); |
8860 | 8896 | ||
8861 | return GetPrimMediaParams(face, rules); | ||
8862 | } | ||
8863 | |||
8864 | private LSL_List GetPrimMediaParams(int face, LSL_List rules) | ||
8865 | { | ||
8866 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); | 8897 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); |
8867 | if (null == module) | 8898 | if (null == module) |
8868 | throw new Exception("Media on a prim functions not available"); | 8899 | return new LSL_List(); |
8869 | 8900 | ||
8870 | MediaEntry me = module.GetMediaEntry(m_host, face); | 8901 | MediaEntry me = module.GetMediaEntry(part, face); |
8871 | 8902 | ||
8872 | // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams | 8903 | // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams |
8873 | if (null == me) | 8904 | if (null == me) |
@@ -8949,33 +8980,52 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8949 | case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: | 8980 | case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: |
8950 | res.Add(new LSL_Integer((int)me.ControlPermissions)); | 8981 | res.Add(new LSL_Integer((int)me.ControlPermissions)); |
8951 | break; | 8982 | break; |
8983 | |||
8984 | default: return ScriptBaseClass.LSL_STATUS_MALFORMED_PARAMS; | ||
8952 | } | 8985 | } |
8953 | } | 8986 | } |
8954 | 8987 | ||
8955 | return res; | 8988 | return res; |
8956 | } | 8989 | } |
8957 | 8990 | ||
8958 | public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules) | 8991 | public LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules) |
8959 | { | 8992 | { |
8960 | m_host.AddScriptLPS(1); | 8993 | m_host.AddScriptLPS(1); |
8961 | ScriptSleep(1000); | 8994 | ScriptSleep(1000); |
8995 | return SetPrimMediaParams(m_host, face, rules); | ||
8996 | } | ||
8962 | 8997 | ||
8963 | // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid | 8998 | public LSL_Integer llSetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules) |
8964 | // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. | 8999 | { |
8965 | // Don't perform the media check directly | 9000 | m_host.AddScriptLPS(1); |
8966 | if (face < 0 || face > m_host.GetNumberOfSides() - 1) | 9001 | ScriptSleep(1000); |
8967 | return ScriptBaseClass.LSL_STATUS_OK; | 9002 | if (link == ScriptBaseClass.LINK_ROOT) |
9003 | return SetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules); | ||
9004 | else if (link == ScriptBaseClass.LINK_THIS) | ||
9005 | return SetPrimMediaParams(m_host, face, rules); | ||
9006 | else | ||
9007 | { | ||
9008 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link); | ||
9009 | if (null != part) | ||
9010 | return SetPrimMediaParams(part, face, rules); | ||
9011 | } | ||
8968 | 9012 | ||
8969 | return SetPrimMediaParams(face, rules); | 9013 | return ScriptBaseClass.LSL_STATUS_NOT_FOUND; |
8970 | } | 9014 | } |
8971 | 9015 | ||
8972 | private LSL_Integer SetPrimMediaParams(int face, LSL_List rules) | 9016 | private LSL_Integer SetPrimMediaParams(SceneObjectPart part, LSL_Integer face, LSL_List rules) |
8973 | { | 9017 | { |
9018 | // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid | ||
9019 | // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. | ||
9020 | // Don't perform the media check directly | ||
9021 | if (face < 0 || face > part.GetNumberOfSides() - 1) | ||
9022 | return ScriptBaseClass.LSL_STATUS_NOT_FOUND; | ||
9023 | |||
8974 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); | 9024 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); |
8975 | if (null == module) | 9025 | if (null == module) |
8976 | throw new Exception("Media on a prim functions not available"); | 9026 | return ScriptBaseClass.LSL_STATUS_NOT_SUPPORTED; |
8977 | 9027 | ||
8978 | MediaEntry me = module.GetMediaEntry(m_host, face); | 9028 | MediaEntry me = module.GetMediaEntry(part, face); |
8979 | if (null == me) | 9029 | if (null == me) |
8980 | me = new MediaEntry(); | 9030 | me = new MediaEntry(); |
8981 | 9031 | ||
@@ -9054,10 +9104,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9054 | case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: | 9104 | case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: |
9055 | me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++); | 9105 | me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++); |
9056 | break; | 9106 | break; |
9107 | |||
9108 | default: return ScriptBaseClass.LSL_STATUS_MALFORMED_PARAMS; | ||
9057 | } | 9109 | } |
9058 | } | 9110 | } |
9059 | 9111 | ||
9060 | module.SetMediaEntry(m_host, face, me); | 9112 | module.SetMediaEntry(part, face, me); |
9061 | 9113 | ||
9062 | return ScriptBaseClass.LSL_STATUS_OK; | 9114 | return ScriptBaseClass.LSL_STATUS_OK; |
9063 | } | 9115 | } |
@@ -9066,18 +9118,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9066 | { | 9118 | { |
9067 | m_host.AddScriptLPS(1); | 9119 | m_host.AddScriptLPS(1); |
9068 | ScriptSleep(1000); | 9120 | ScriptSleep(1000); |
9121 | return ClearPrimMedia(m_host, face); | ||
9122 | } | ||
9069 | 9123 | ||
9124 | public LSL_Integer llClearLinkMedia(LSL_Integer link, LSL_Integer face) | ||
9125 | { | ||
9126 | m_host.AddScriptLPS(1); | ||
9127 | ScriptSleep(1000); | ||
9128 | if (link == ScriptBaseClass.LINK_ROOT) | ||
9129 | return ClearPrimMedia(m_host.ParentGroup.RootPart, face); | ||
9130 | else if (link == ScriptBaseClass.LINK_THIS) | ||
9131 | return ClearPrimMedia(m_host, face); | ||
9132 | else | ||
9133 | { | ||
9134 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link); | ||
9135 | if (null != part) | ||
9136 | return ClearPrimMedia(part, face); | ||
9137 | } | ||
9138 | |||
9139 | return ScriptBaseClass.LSL_STATUS_NOT_FOUND; | ||
9140 | } | ||
9141 | |||
9142 | private LSL_Integer ClearPrimMedia(SceneObjectPart part, LSL_Integer face) | ||
9143 | { | ||
9070 | // LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid | 9144 | // LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid |
9071 | // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. | 9145 | // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. |
9072 | // FIXME: Don't perform the media check directly | 9146 | // FIXME: Don't perform the media check directly |
9073 | if (face < 0 || face > m_host.GetNumberOfSides() - 1) | 9147 | if (face < 0 || face > part.GetNumberOfSides() - 1) |
9074 | return ScriptBaseClass.LSL_STATUS_OK; | 9148 | return ScriptBaseClass.LSL_STATUS_NOT_FOUND; |
9075 | 9149 | ||
9076 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); | 9150 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); |
9077 | if (null == module) | 9151 | if (null == module) |
9078 | throw new Exception("Media on a prim functions not available"); | 9152 | return ScriptBaseClass.LSL_STATUS_NOT_SUPPORTED; |
9079 | 9153 | ||
9080 | module.ClearMediaEntry(m_host, face); | 9154 | module.ClearMediaEntry(part, face); |
9081 | 9155 | ||
9082 | return ScriptBaseClass.LSL_STATUS_OK; | 9156 | return ScriptBaseClass.LSL_STATUS_OK; |
9083 | } | 9157 | } |