diff options
author | SignpostMarv | 2012-09-01 02:44:11 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-09-04 00:03:44 +0100 |
commit | ff867b59cf59fdab19413cd46f3dd04058fbf3c7 (patch) | |
tree | 36d6ac570be77c61245be64a8403fc296be76d3f | |
parent | refactoring the grunt work of MessageObject into a private method with a UUID... (diff) | |
download | opensim-SC-ff867b59cf59fdab19413cd46f3dd04058fbf3c7.zip opensim-SC-ff867b59cf59fdab19413cd46f3dd04058fbf3c7.tar.gz opensim-SC-ff867b59cf59fdab19413cd46f3dd04058fbf3c7.tar.bz2 opensim-SC-ff867b59cf59fdab19413cd46f3dd04058fbf3c7.tar.xz |
Implementing functing to send messages directly to attachments
4 files changed, 201 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 82114b3..8e80b4c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -3354,6 +3354,137 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3354 | return resp; | 3354 | return resp; |
3355 | } | 3355 | } |
3356 | 3356 | ||
3357 | public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options) | ||
3358 | { | ||
3359 | CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments"); | ||
3360 | m_host.AddScriptLPS(1); | ||
3361 | |||
3362 | UUID targetUUID; | ||
3363 | ScenePresence target; | ||
3364 | |||
3365 | if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target)) | ||
3366 | { | ||
3367 | List<int> aps = new List<int>(); | ||
3368 | foreach (object point in attachmentPoints.Data) | ||
3369 | { | ||
3370 | int ipoint; | ||
3371 | if (int.TryParse(point.ToString(), out ipoint)) | ||
3372 | { | ||
3373 | aps.Add(ipoint); | ||
3374 | } | ||
3375 | } | ||
3376 | |||
3377 | List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(); | ||
3378 | |||
3379 | bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL); | ||
3380 | bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0; | ||
3381 | |||
3382 | if (msgAll && invertPoints) | ||
3383 | { | ||
3384 | return; | ||
3385 | } | ||
3386 | else if (msgAll || invertPoints) | ||
3387 | { | ||
3388 | attachments = target.GetAttachments(); | ||
3389 | } | ||
3390 | else | ||
3391 | { | ||
3392 | foreach (int point in aps) | ||
3393 | { | ||
3394 | if (point > 0) | ||
3395 | { | ||
3396 | attachments.AddRange(target.GetAttachments((uint)point)); | ||
3397 | } | ||
3398 | } | ||
3399 | } | ||
3400 | |||
3401 | // if we have no attachments at this point, exit now | ||
3402 | if (attachments.Count == 0) | ||
3403 | { | ||
3404 | return; | ||
3405 | } | ||
3406 | |||
3407 | List<SceneObjectGroup> ignoreThese = new List<SceneObjectGroup>(); | ||
3408 | |||
3409 | if (invertPoints) | ||
3410 | { | ||
3411 | foreach (SceneObjectGroup attachment in attachments) | ||
3412 | { | ||
3413 | if (aps.Contains((int)attachment.AttachmentPoint)) | ||
3414 | { | ||
3415 | ignoreThese.Add(attachment); | ||
3416 | } | ||
3417 | } | ||
3418 | } | ||
3419 | |||
3420 | foreach (SceneObjectGroup attachment in ignoreThese) | ||
3421 | { | ||
3422 | attachments.Remove(attachment); | ||
3423 | } | ||
3424 | ignoreThese.Clear(); | ||
3425 | |||
3426 | // if inverting removed all attachments to check, exit now | ||
3427 | if (attachments.Count < 1) | ||
3428 | { | ||
3429 | return; | ||
3430 | } | ||
3431 | |||
3432 | if ((options & ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0) | ||
3433 | { | ||
3434 | foreach (SceneObjectGroup attachment in attachments) | ||
3435 | { | ||
3436 | if (attachment.RootPart.CreatorID != m_host.CreatorID) | ||
3437 | { | ||
3438 | ignoreThese.Add(attachment); | ||
3439 | } | ||
3440 | } | ||
3441 | |||
3442 | foreach (SceneObjectGroup attachment in ignoreThese) | ||
3443 | { | ||
3444 | attachments.Remove(attachment); | ||
3445 | } | ||
3446 | ignoreThese.Clear(); | ||
3447 | |||
3448 | // if filtering by same object creator removed all | ||
3449 | // attachments to check, exit now | ||
3450 | if (attachments.Count == 0) | ||
3451 | { | ||
3452 | return; | ||
3453 | } | ||
3454 | } | ||
3455 | |||
3456 | if ((options & ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0) | ||
3457 | { | ||
3458 | foreach (SceneObjectGroup attachment in attachments) | ||
3459 | { | ||
3460 | if (attachment.RootPart.CreatorID != m_item.CreatorID) | ||
3461 | { | ||
3462 | ignoreThese.Add(attachment); | ||
3463 | } | ||
3464 | } | ||
3465 | |||
3466 | foreach (SceneObjectGroup attachment in ignoreThese) | ||
3467 | { | ||
3468 | attachments.Remove(attachment); | ||
3469 | } | ||
3470 | ignoreThese.Clear(); | ||
3471 | |||
3472 | // if filtering by object creator must match originating | ||
3473 | // script creator removed all attachments to check, | ||
3474 | // exit now | ||
3475 | if (attachments.Count == 0) | ||
3476 | { | ||
3477 | return; | ||
3478 | } | ||
3479 | } | ||
3480 | |||
3481 | foreach (SceneObjectGroup attachment in attachments) | ||
3482 | { | ||
3483 | MessageObject(attachment.RootPart.UUID, message); | ||
3484 | } | ||
3485 | } | ||
3486 | } | ||
3487 | |||
3357 | #endregion | 3488 | #endregion |
3358 | 3489 | ||
3359 | /// <summary> | 3490 | /// <summary> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 6db6443..bde7a8e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -200,6 +200,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
200 | /// <returns></returns> | 200 | /// <returns></returns> |
201 | LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints); | 201 | LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints); |
202 | 202 | ||
203 | /// <summary> | ||
204 | /// Sends a specified message to the specified avatar's attachments on | ||
205 | /// the specified attachment points. | ||
206 | /// </summary> | ||
207 | /// <remarks> | ||
208 | /// Behaves as osMessageObject(), without the sending script needing to know the attachment keys in advance. | ||
209 | /// </remarks> | ||
210 | /// <param name="avatar">avatar UUID</param> | ||
211 | /// <param name="message">message string</param> | ||
212 | /// <param name="attachmentPoints">list of ATTACH_* constants, or -1 for all attachments. If -1 is specified and OS_ATTACH_MSG_INVERT_POINTS is present in flags, no action is taken.</param> | ||
213 | /// <param name="flags">flags further constraining the attachments to deliver the message to.</param> | ||
214 | void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags); | ||
215 | |||
203 | #endregion | 216 | #endregion |
204 | 217 | ||
205 | //texture draw functions | 218 | //texture draw functions |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index cad8518..60a7e14 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -237,6 +237,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
237 | public const int ATTACH_HUD_BOTTOM = 37; | 237 | public const int ATTACH_HUD_BOTTOM = 37; |
238 | public const int ATTACH_HUD_BOTTOM_RIGHT = 38; | 238 | public const int ATTACH_HUD_BOTTOM_RIGHT = 38; |
239 | 239 | ||
240 | #region osMessageAttachments constants | ||
241 | |||
242 | /// <summary> | ||
243 | /// Instructs osMessageAttachements to send the message to attachments | ||
244 | /// on every point. | ||
245 | /// </summary> | ||
246 | /// <remarks> | ||
247 | /// One might expect this to be named OS_ATTACH_ALL, but then one might | ||
248 | /// also expect functions designed to attach or detach or get | ||
249 | /// attachments to work with it too. Attaching a no-copy item to | ||
250 | /// many attachments could be dangerous. | ||
251 | /// when combined with OS_ATTACH_MSG_INVERT_POINTS, will prevent the | ||
252 | /// message from being sent. | ||
253 | /// if combined with OS_ATTACH_MSG_OBJECT_CREATOR or | ||
254 | /// OS_ATTACH_MSG_SCRIPT_CREATOR, could result in no message being | ||
255 | /// sent- this is expected behaviour. | ||
256 | /// </remarks> | ||
257 | public const int OS_ATTACH_MSG_ALL = -65535; | ||
258 | |||
259 | /// <summary> | ||
260 | /// Instructs osMessageAttachements to invert how the attachment points | ||
261 | /// list should be treated (e.g. go from inclusive operation to | ||
262 | /// exclusive operation). | ||
263 | /// </summary> | ||
264 | /// <remarks> | ||
265 | /// This might be used if you want to deliver a message to one set of | ||
266 | /// attachments and a different message to everything else. With | ||
267 | /// this flag, you only need to build one explicit list for both calls. | ||
268 | /// </remarks> | ||
269 | public const int OS_ATTACH_MSG_INVERT_POINTS = 1; | ||
270 | |||
271 | /// <summary> | ||
272 | /// Instructs osMessageAttachments to only send the message to | ||
273 | /// attachments with a CreatorID that matches the host object CreatorID | ||
274 | /// </summary> | ||
275 | /// <remarks> | ||
276 | /// This would be used if distributed in an object vendor/updater server. | ||
277 | /// </remarks> | ||
278 | public const int OS_ATTACH_MSG_OBJECT_CREATOR = 2; | ||
279 | |||
280 | /// <summary> | ||
281 | /// Instructs osMessageAttachments to only send the message to | ||
282 | /// attachments with a CreatorID that matches the sending script CreatorID | ||
283 | /// </summary> | ||
284 | /// <remarks> | ||
285 | /// This might be used if the script is distributed independently of a | ||
286 | /// containing object. | ||
287 | /// </remarks> | ||
288 | public const int OS_ATTACH_MSG_SCRIPT_CREATOR = 4; | ||
289 | |||
290 | #endregion | ||
291 | |||
240 | public const int LAND_LEVEL = 0; | 292 | public const int LAND_LEVEL = 0; |
241 | public const int LAND_RAISE = 1; | 293 | public const int LAND_RAISE = 1; |
242 | public const int LAND_LOWER = 2; | 294 | public const int LAND_LOWER = 2; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 230c378..08ebfd6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -316,6 +316,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
316 | return m_OSSL_Functions.osGetNumberOfAttachments(avatar, attachmentPoints); | 316 | return m_OSSL_Functions.osGetNumberOfAttachments(avatar, attachmentPoints); |
317 | } | 317 | } |
318 | 318 | ||
319 | public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags) | ||
320 | { | ||
321 | m_OSSL_Functions.osMessageAttachments(avatar, message, attachmentPoints, flags); | ||
322 | } | ||
323 | |||
319 | #endregion | 324 | #endregion |
320 | 325 | ||
321 | // Texture Draw functions | 326 | // Texture Draw functions |