diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 114 |
1 files changed, 97 insertions, 17 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index bc26389..292e345 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Security; | ||
30 | using OpenMetaverse; | 31 | using OpenMetaverse; |
31 | using OpenMetaverse.Packets; | 32 | using OpenMetaverse.Packets; |
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
@@ -42,13 +43,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
42 | { | 43 | { |
43 | private readonly Scene m_rootScene; | 44 | private readonly Scene m_rootScene; |
44 | private readonly uint m_localID; | 45 | private readonly uint m_localID; |
46 | private readonly ISecurityCredential m_security; | ||
45 | 47 | ||
48 | [Obsolete("Replace with 'credential' constructor [security]")] | ||
46 | public SOPObject(Scene rootScene, uint localID) | 49 | public SOPObject(Scene rootScene, uint localID) |
47 | { | 50 | { |
48 | m_rootScene = rootScene; | 51 | m_rootScene = rootScene; |
49 | m_localID = localID; | 52 | m_localID = localID; |
50 | } | 53 | } |
51 | 54 | ||
55 | public SOPObject(Scene rootScene, uint localID, ISecurityCredential credential) | ||
56 | { | ||
57 | m_rootScene = rootScene; | ||
58 | m_localID = localID; | ||
59 | m_security = credential; | ||
60 | } | ||
61 | |||
52 | /// <summary> | 62 | /// <summary> |
53 | /// This needs to run very, very quickly. | 63 | /// This needs to run very, very quickly. |
54 | /// It is utilized in nearly every property and method. | 64 | /// It is utilized in nearly every property and method. |
@@ -59,6 +69,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
59 | return m_rootScene.GetSceneObjectPart(m_localID); | 69 | return m_rootScene.GetSceneObjectPart(m_localID); |
60 | } | 70 | } |
61 | 71 | ||
72 | private bool CanEdit() | ||
73 | { | ||
74 | if (!m_security.CanEditObject(this)) | ||
75 | { | ||
76 | throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]"); | ||
77 | } | ||
78 | return true; | ||
79 | } | ||
80 | |||
62 | #region OnTouch | 81 | #region OnTouch |
63 | 82 | ||
64 | private event OnTouchDelegate _OnTouch; | 83 | private event OnTouchDelegate _OnTouch; |
@@ -68,14 +87,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
68 | { | 87 | { |
69 | add | 88 | add |
70 | { | 89 | { |
71 | if (!_OnTouchActive) | 90 | if (CanEdit()) |
72 | { | 91 | { |
73 | GetSOP().Flags |= PrimFlags.Touch; | 92 | if (!_OnTouchActive) |
74 | _OnTouchActive = true; | 93 | { |
75 | m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab; | 94 | GetSOP().Flags |= PrimFlags.Touch; |
95 | _OnTouchActive = true; | ||
96 | m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab; | ||
97 | } | ||
98 | |||
99 | _OnTouch += value; | ||
76 | } | 100 | } |
77 | |||
78 | _OnTouch += value; | ||
79 | } | 101 | } |
80 | remove | 102 | remove |
81 | { | 103 | { |
@@ -95,7 +117,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
95 | if (_OnTouchActive && m_localID == localID) | 117 | if (_OnTouchActive && m_localID == localID) |
96 | { | 118 | { |
97 | TouchEventArgs e = new TouchEventArgs(); | 119 | TouchEventArgs e = new TouchEventArgs(); |
98 | e.Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId); | 120 | e.Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId, m_security); |
99 | e.TouchBiNormal = surfaceArgs.Binormal; | 121 | e.TouchBiNormal = surfaceArgs.Binormal; |
100 | e.TouchMaterialIndex = surfaceArgs.FaceIndex; | 122 | e.TouchMaterialIndex = surfaceArgs.FaceIndex; |
101 | e.TouchNormal = surfaceArgs.Normal; | 123 | e.TouchNormal = surfaceArgs.Normal; |
@@ -130,13 +152,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
130 | public string Name | 152 | public string Name |
131 | { | 153 | { |
132 | get { return GetSOP().Name; } | 154 | get { return GetSOP().Name; } |
133 | set { GetSOP().Name = value; } | 155 | set |
156 | { | ||
157 | if (CanEdit()) | ||
158 | GetSOP().Name = value; | ||
159 | } | ||
134 | } | 160 | } |
135 | 161 | ||
136 | public string Description | 162 | public string Description |
137 | { | 163 | { |
138 | get { return GetSOP().Description; } | 164 | get { return GetSOP().Description; } |
139 | set { GetSOP().Description = value; } | 165 | set |
166 | { | ||
167 | if (CanEdit()) | ||
168 | GetSOP().Description = value; | ||
169 | } | ||
140 | } | 170 | } |
141 | 171 | ||
142 | public IObject[] Children | 172 | public IObject[] Children |
@@ -151,7 +181,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
151 | int i = 0; | 181 | int i = 0; |
152 | foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children) | 182 | foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children) |
153 | { | 183 | { |
154 | rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId); | 184 | rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security); |
155 | } | 185 | } |
156 | 186 | ||
157 | return rets; | 187 | return rets; |
@@ -160,7 +190,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
160 | 190 | ||
161 | public IObject Root | 191 | public IObject Root |
162 | { | 192 | { |
163 | get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } | 193 | get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId, m_security); } |
164 | } | 194 | } |
165 | 195 | ||
166 | public IObjectMaterial[] Materials | 196 | public IObjectMaterial[] Materials |
@@ -182,7 +212,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
182 | public Vector3 Scale | 212 | public Vector3 Scale |
183 | { | 213 | { |
184 | get { return GetSOP().Scale; } | 214 | get { return GetSOP().Scale; } |
185 | set { GetSOP().Scale = value; } | 215 | set |
216 | { | ||
217 | if (CanEdit()) | ||
218 | GetSOP().Scale = value; | ||
219 | } | ||
186 | } | 220 | } |
187 | 221 | ||
188 | public Quaternion WorldRotation | 222 | public Quaternion WorldRotation |
@@ -202,15 +236,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
202 | get { return GetSOP().AbsolutePosition; } | 236 | get { return GetSOP().AbsolutePosition; } |
203 | set | 237 | set |
204 | { | 238 | { |
205 | SceneObjectPart pos = GetSOP(); | 239 | if (CanEdit()) |
206 | pos.UpdateOffSet(value - pos.AbsolutePosition); | 240 | { |
241 | SceneObjectPart pos = GetSOP(); | ||
242 | pos.UpdateOffSet(value - pos.AbsolutePosition); | ||
243 | } | ||
207 | } | 244 | } |
208 | } | 245 | } |
209 | 246 | ||
210 | public Vector3 OffsetPosition | 247 | public Vector3 OffsetPosition |
211 | { | 248 | { |
212 | get { return GetSOP().OffsetPosition; } | 249 | get { return GetSOP().OffsetPosition; } |
213 | set { GetSOP().OffsetPosition = value; } | 250 | set |
251 | { | ||
252 | if (CanEdit()) | ||
253 | { | ||
254 | GetSOP().OffsetPosition = value; | ||
255 | } | ||
256 | } | ||
214 | } | 257 | } |
215 | 258 | ||
216 | public Vector3 SitTarget | 259 | public Vector3 SitTarget |
@@ -310,8 +353,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
310 | 353 | ||
311 | public void Say(string msg) | 354 | public void Say(string msg) |
312 | { | 355 | { |
313 | SceneObjectPart sop = GetSOP(); | 356 | if (!CanEdit()) |
357 | return; | ||
314 | 358 | ||
359 | SceneObjectPart sop = GetSOP(); | ||
315 | m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false); | 360 | m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false); |
316 | } | 361 | } |
317 | 362 | ||
@@ -503,6 +548,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
503 | } | 548 | } |
504 | set | 549 | set |
505 | { | 550 | { |
551 | if (!CanEdit()) | ||
552 | return; | ||
553 | |||
506 | GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); | 554 | GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); |
507 | } | 555 | } |
508 | } | 556 | } |
@@ -516,6 +564,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
516 | } | 564 | } |
517 | set | 565 | set |
518 | { | 566 | { |
567 | if (!CanEdit()) | ||
568 | return; | ||
569 | |||
519 | GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); | 570 | GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); |
520 | } | 571 | } |
521 | } | 572 | } |
@@ -529,6 +580,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
529 | } | 580 | } |
530 | set | 581 | set |
531 | { | 582 | { |
583 | if (!CanEdit()) | ||
584 | return; | ||
585 | |||
532 | GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); | 586 | GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); |
533 | } | 587 | } |
534 | } | 588 | } |
@@ -551,27 +605,44 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
551 | } | 605 | } |
552 | set | 606 | set |
553 | { | 607 | { |
608 | if (!CanEdit()) | ||
609 | return; | ||
610 | |||
554 | GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); | 611 | GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); |
555 | } | 612 | } |
556 | } | 613 | } |
557 | 614 | ||
558 | public bool FloatOnWater | 615 | public bool FloatOnWater |
559 | { | 616 | { |
560 | set { GetSOP().PhysActor.FloatOnWater = value; } | 617 | set |
618 | { | ||
619 | if (!CanEdit()) | ||
620 | return; | ||
621 | GetSOP().PhysActor.FloatOnWater = value; | ||
622 | } | ||
561 | } | 623 | } |
562 | 624 | ||
563 | public void AddForce(Vector3 force, bool pushforce) | 625 | public void AddForce(Vector3 force, bool pushforce) |
564 | { | 626 | { |
627 | if (!CanEdit()) | ||
628 | return; | ||
629 | |||
565 | GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); | 630 | GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); |
566 | } | 631 | } |
567 | 632 | ||
568 | public void AddAngularForce(Vector3 force, bool pushforce) | 633 | public void AddAngularForce(Vector3 force, bool pushforce) |
569 | { | 634 | { |
635 | if (!CanEdit()) | ||
636 | return; | ||
637 | |||
570 | GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); | 638 | GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); |
571 | } | 639 | } |
572 | 640 | ||
573 | public void SetMomentum(Vector3 momentum) | 641 | public void SetMomentum(Vector3 momentum) |
574 | { | 642 | { |
643 | if (!CanEdit()) | ||
644 | return; | ||
645 | |||
575 | GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); | 646 | GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); |
576 | } | 647 | } |
577 | 648 | ||
@@ -586,6 +657,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
586 | get { return m_sculptMap; } | 657 | get { return m_sculptMap; } |
587 | set | 658 | set |
588 | { | 659 | { |
660 | if (!CanEdit()) | ||
661 | return; | ||
662 | |||
589 | m_sculptMap = value; | 663 | m_sculptMap = value; |
590 | SetPrimitiveSculpted(SculptMap, (byte) SculptType); | 664 | SetPrimitiveSculpted(SculptMap, (byte) SculptType); |
591 | } | 665 | } |
@@ -598,6 +672,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
598 | get { return m_sculptType; } | 672 | get { return m_sculptType; } |
599 | set | 673 | set |
600 | { | 674 | { |
675 | if (!CanEdit()) | ||
676 | return; | ||
677 | |||
601 | m_sculptType = value; | 678 | m_sculptType = value; |
602 | SetPrimitiveSculpted(SculptMap, (byte) SculptType); | 679 | SetPrimitiveSculpted(SculptMap, (byte) SculptType); |
603 | } | 680 | } |
@@ -654,6 +731,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
654 | 731 | ||
655 | public void Play(UUID asset, double volume) | 732 | public void Play(UUID asset, double volume) |
656 | { | 733 | { |
734 | if (!CanEdit()) | ||
735 | return; | ||
736 | |||
657 | GetSOP().SendSound(asset.ToString(), volume, true, 0); | 737 | GetSOP().SendSound(asset.ToString(), volume, true, 0); |
658 | } | 738 | } |
659 | 739 | ||