diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 106 |
1 files changed, 83 insertions, 23 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2eba2b1..525c3c3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -8173,23 +8173,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8173 | { | 8173 | { |
8174 | m_host.AddScriptLPS(1); | 8174 | m_host.AddScriptLPS(1); |
8175 | ScriptSleep(1000); | 8175 | ScriptSleep(1000); |
8176 | return GetPrimMediaParams(m_host, face, rules); | ||
8177 | } | ||
8178 | |||
8179 | public LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules) | ||
8180 | { | ||
8181 | m_host.AddScriptLPS(1); | ||
8182 | ScriptSleep(1000); | ||
8183 | if (link == ScriptBaseClass.LINK_ROOT) | ||
8184 | return GetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules); | ||
8185 | else if (link == ScriptBaseClass.LINK_THIS) | ||
8186 | return GetPrimMediaParams(m_host, face, rules); | ||
8187 | else | ||
8188 | { | ||
8189 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link); | ||
8190 | if (null != part) | ||
8191 | return GetPrimMediaParams(part, face, rules); | ||
8192 | } | ||
8193 | |||
8194 | return new LSL_List(); | ||
8195 | } | ||
8176 | 8196 | ||
8197 | private LSL_List GetPrimMediaParams(SceneObjectPart part, int face, LSL_List rules) | ||
8198 | { | ||
8177 | // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid | 8199 | // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid |
8178 | // TODO: Need to correctly handle case where a face has no media (which gives back an empty list). | 8200 | // TODO: Need to correctly handle case where a face has no media (which gives back an empty list). |
8179 | // Assuming silently fail means give back an empty list. Ideally, need to check this. | 8201 | // Assuming silently fail means give back an empty list. Ideally, need to check this. |
8180 | if (face < 0 || face > m_host.GetNumberOfSides() - 1) | 8202 | if (face < 0 || face > part.GetNumberOfSides() - 1) |
8181 | return new LSL_List(); | 8203 | return new LSL_List(); |
8182 | 8204 | ||
8183 | return GetPrimMediaParams(face, rules); | ||
8184 | } | ||
8185 | |||
8186 | private LSL_List GetPrimMediaParams(int face, LSL_List rules) | ||
8187 | { | ||
8188 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); | 8205 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); |
8189 | if (null == module) | 8206 | if (null == module) |
8190 | throw new Exception("Media on a prim functions not available"); | 8207 | return new LSL_List(); |
8191 | 8208 | ||
8192 | MediaEntry me = module.GetMediaEntry(m_host, face); | 8209 | MediaEntry me = module.GetMediaEntry(part, face); |
8193 | 8210 | ||
8194 | // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams | 8211 | // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams |
8195 | if (null == me) | 8212 | if (null == me) |
@@ -8271,33 +8288,52 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8271 | case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: | 8288 | case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: |
8272 | res.Add(new LSL_Integer((int)me.ControlPermissions)); | 8289 | res.Add(new LSL_Integer((int)me.ControlPermissions)); |
8273 | break; | 8290 | break; |
8291 | |||
8292 | default: return ScriptBaseClass.LSL_STATUS_MALFORMED_PARAMS; | ||
8274 | } | 8293 | } |
8275 | } | 8294 | } |
8276 | 8295 | ||
8277 | return res; | 8296 | return res; |
8278 | } | 8297 | } |
8279 | 8298 | ||
8280 | public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules) | 8299 | public LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules) |
8281 | { | 8300 | { |
8282 | m_host.AddScriptLPS(1); | 8301 | m_host.AddScriptLPS(1); |
8283 | ScriptSleep(1000); | 8302 | ScriptSleep(1000); |
8303 | return SetPrimMediaParams(m_host, face, rules); | ||
8304 | } | ||
8284 | 8305 | ||
8285 | // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid | 8306 | public LSL_Integer llSetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules) |
8286 | // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. | 8307 | { |
8287 | // Don't perform the media check directly | 8308 | m_host.AddScriptLPS(1); |
8288 | if (face < 0 || face > m_host.GetNumberOfSides() - 1) | 8309 | ScriptSleep(1000); |
8289 | return ScriptBaseClass.LSL_STATUS_OK; | 8310 | if (link == ScriptBaseClass.LINK_ROOT) |
8311 | return SetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules); | ||
8312 | else if (link == ScriptBaseClass.LINK_THIS) | ||
8313 | return SetPrimMediaParams(m_host, face, rules); | ||
8314 | else | ||
8315 | { | ||
8316 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link); | ||
8317 | if (null != part) | ||
8318 | return SetPrimMediaParams(part, face, rules); | ||
8319 | } | ||
8290 | 8320 | ||
8291 | return SetPrimMediaParams(face, rules); | 8321 | return ScriptBaseClass.LSL_STATUS_NOT_FOUND; |
8292 | } | 8322 | } |
8293 | 8323 | ||
8294 | private LSL_Integer SetPrimMediaParams(int face, LSL_List rules) | 8324 | private LSL_Integer SetPrimMediaParams(SceneObjectPart part, LSL_Integer face, LSL_List rules) |
8295 | { | 8325 | { |
8326 | // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid | ||
8327 | // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. | ||
8328 | // Don't perform the media check directly | ||
8329 | if (face < 0 || face > part.GetNumberOfSides() - 1) | ||
8330 | return ScriptBaseClass.LSL_STATUS_NOT_FOUND; | ||
8331 | |||
8296 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); | 8332 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); |
8297 | if (null == module) | 8333 | if (null == module) |
8298 | throw new Exception("Media on a prim functions not available"); | 8334 | return ScriptBaseClass.LSL_STATUS_NOT_SUPPORTED; |
8299 | 8335 | ||
8300 | MediaEntry me = module.GetMediaEntry(m_host, face); | 8336 | MediaEntry me = module.GetMediaEntry(part, face); |
8301 | if (null == me) | 8337 | if (null == me) |
8302 | me = new MediaEntry(); | 8338 | me = new MediaEntry(); |
8303 | 8339 | ||
@@ -8376,10 +8412,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8376 | case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: | 8412 | case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: |
8377 | me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++); | 8413 | me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++); |
8378 | break; | 8414 | break; |
8415 | |||
8416 | default: return ScriptBaseClass.LSL_STATUS_MALFORMED_PARAMS; | ||
8379 | } | 8417 | } |
8380 | } | 8418 | } |
8381 | 8419 | ||
8382 | module.SetMediaEntry(m_host, face, me); | 8420 | module.SetMediaEntry(part, face, me); |
8383 | 8421 | ||
8384 | return ScriptBaseClass.LSL_STATUS_OK; | 8422 | return ScriptBaseClass.LSL_STATUS_OK; |
8385 | } | 8423 | } |
@@ -8388,18 +8426,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8388 | { | 8426 | { |
8389 | m_host.AddScriptLPS(1); | 8427 | m_host.AddScriptLPS(1); |
8390 | ScriptSleep(1000); | 8428 | ScriptSleep(1000); |
8429 | return ClearPrimMedia(m_host, face); | ||
8430 | } | ||
8391 | 8431 | ||
8432 | public LSL_Integer llClearLinkMedia(LSL_Integer link, LSL_Integer face) | ||
8433 | { | ||
8434 | m_host.AddScriptLPS(1); | ||
8435 | ScriptSleep(1000); | ||
8436 | if (link == ScriptBaseClass.LINK_ROOT) | ||
8437 | return ClearPrimMedia(m_host.ParentGroup.RootPart, face); | ||
8438 | else if (link == ScriptBaseClass.LINK_THIS) | ||
8439 | return ClearPrimMedia(m_host, face); | ||
8440 | else | ||
8441 | { | ||
8442 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link); | ||
8443 | if (null != part) | ||
8444 | return ClearPrimMedia(part, face); | ||
8445 | } | ||
8446 | |||
8447 | return ScriptBaseClass.LSL_STATUS_NOT_FOUND; | ||
8448 | } | ||
8449 | |||
8450 | private LSL_Integer ClearPrimMedia(SceneObjectPart part, LSL_Integer face) | ||
8451 | { | ||
8392 | // LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid | 8452 | // LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid |
8393 | // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. | 8453 | // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. |
8394 | // FIXME: Don't perform the media check directly | 8454 | // FIXME: Don't perform the media check directly |
8395 | if (face < 0 || face > m_host.GetNumberOfSides() - 1) | 8455 | if (face < 0 || face > part.GetNumberOfSides() - 1) |
8396 | return ScriptBaseClass.LSL_STATUS_OK; | 8456 | return ScriptBaseClass.LSL_STATUS_NOT_FOUND; |
8397 | 8457 | ||
8398 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); | 8458 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); |
8399 | if (null == module) | 8459 | if (null == module) |
8400 | throw new Exception("Media on a prim functions not available"); | 8460 | return ScriptBaseClass.LSL_STATUS_NOT_SUPPORTED; |
8401 | 8461 | ||
8402 | module.ClearMediaEntry(m_host, face); | 8462 | module.ClearMediaEntry(part, face); |
8403 | 8463 | ||
8404 | return ScriptBaseClass.LSL_STATUS_OK; | 8464 | return ScriptBaseClass.LSL_STATUS_OK; |
8405 | } | 8465 | } |