diff options
author | Melanie | 2012-07-05 22:17:39 +0100 |
---|---|---|
committer | Melanie | 2012-07-05 22:17:39 +0100 |
commit | 5776351f6abd4ca8cca7344b26ab989425c67687 (patch) | |
tree | fe0c0355ceb25db47125525b9b72d2077cc3c29f /OpenSim/Region/ScriptEngine/Shared | |
parent | Merge branch 'master' into careminster (diff) | |
parent | minor: add client name to various login service log messages to disambiguate ... (diff) | |
download | opensim-SC-5776351f6abd4ca8cca7344b26ab989425c67687.zip opensim-SC-5776351f6abd4ca8cca7344b26ab989425c67687.tar.gz opensim-SC-5776351f6abd4ca8cca7344b26ab989425c67687.tar.bz2 opensim-SC-5776351f6abd4ca8cca7344b26ab989425c67687.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/Framework/Scenes/Scene.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
8 files changed, 416 insertions, 274 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 04c4c00..14dd2ad 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -231,7 +231,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
231 | 231 | ||
232 | m_host.AddScriptLPS(1); | 232 | m_host.AddScriptLPS(1); |
233 | 233 | ||
234 | if ((item = ScriptByName(name)) != UUID.Zero) | 234 | if ((item = GetScriptByName(name)) != UUID.Zero) |
235 | m_ScriptEngine.ResetScript(item); | 235 | m_ScriptEngine.ResetScript(item); |
236 | else | 236 | else |
237 | ShoutError("llResetOtherScript: script "+name+" not found"); | 237 | ShoutError("llResetOtherScript: script "+name+" not found"); |
@@ -243,7 +243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
243 | 243 | ||
244 | m_host.AddScriptLPS(1); | 244 | m_host.AddScriptLPS(1); |
245 | 245 | ||
246 | if ((item = ScriptByName(name)) != UUID.Zero) | 246 | if ((item = GetScriptByName(name)) != UUID.Zero) |
247 | { | 247 | { |
248 | return m_ScriptEngine.GetScriptState(item) ?1:0; | 248 | return m_ScriptEngine.GetScriptState(item) ?1:0; |
249 | } | 249 | } |
@@ -265,7 +265,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
265 | // These functions are supposed to be robust, | 265 | // These functions are supposed to be robust, |
266 | // so get the state one step at a time. | 266 | // so get the state one step at a time. |
267 | 267 | ||
268 | if ((item = ScriptByName(name)) != UUID.Zero) | 268 | if ((item = GetScriptByName(name)) != UUID.Zero) |
269 | { | 269 | { |
270 | m_ScriptEngine.SetScriptState(item, run == 0 ? false : true); | 270 | m_ScriptEngine.SetScriptState(item, run == 0 ? false : true); |
271 | } | 271 | } |
@@ -3003,68 +3003,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3003 | { | 3003 | { |
3004 | m_host.AddScriptLPS(1); | 3004 | m_host.AddScriptLPS(1); |
3005 | 3005 | ||
3006 | Util.FireAndForget(delegate (object x) | 3006 | Util.FireAndForget(x => |
3007 | { | 3007 | { |
3008 | if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) | 3008 | if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) |
3009 | return; | 3009 | return; |
3010 | |||
3010 | float dist = (float)llVecDist(llGetPos(), pos); | 3011 | float dist = (float)llVecDist(llGetPos(), pos); |
3011 | 3012 | ||
3012 | if (dist > m_ScriptDistanceFactor * 10.0f) | 3013 | if (dist > m_ScriptDistanceFactor * 10.0f) |
3013 | return; | 3014 | return; |
3014 | 3015 | ||
3015 | //Clone is thread-safe | 3016 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory); |
3016 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | ||
3017 | 3017 | ||
3018 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 3018 | if (item == null) |
3019 | { | 3019 | { |
3020 | if (inv.Value.Name == inventory) | 3020 | llSay(0, "Could not find object " + inventory); |
3021 | { | 3021 | return; |
3022 | // make sure we're an object. | 3022 | } |
3023 | if (inv.Value.InvType != (int)InventoryType.Object) | ||
3024 | { | ||
3025 | llSay(0, "Unable to create requested object. Object is missing from database."); | ||
3026 | return; | ||
3027 | } | ||
3028 | 3023 | ||
3029 | Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | 3024 | if (item.InvType != (int)InventoryType.Object) |
3030 | Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); | 3025 | { |
3026 | llSay(0, "Unable to create requested object. Object is missing from database."); | ||
3027 | return; | ||
3028 | } | ||
3031 | 3029 | ||
3032 | // need the magnitude later | 3030 | Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); |
3033 | // float velmag = (float)Util.GetMagnitude(llvel); | 3031 | Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); |
3034 | 3032 | ||
3035 | SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); | 3033 | // need the magnitude later |
3034 | // float velmag = (float)Util.GetMagnitude(llvel); | ||
3036 | 3035 | ||
3037 | // If either of these are null, then there was an unknown error. | 3036 | SceneObjectGroup new_group = World.RezObject(m_host, item, llpos, Rot2Quaternion(rot), llvel, param); |
3038 | if (new_group == null) | ||
3039 | continue; | ||
3040 | 3037 | ||
3041 | // objects rezzed with this method are die_at_edge by default. | 3038 | // If either of these are null, then there was an unknown error. |
3042 | new_group.RootPart.SetDieAtEdge(true); | 3039 | if (new_group == null) |
3040 | return; | ||
3043 | 3041 | ||
3044 | new_group.ResumeScripts(); | 3042 | // objects rezzed with this method are die_at_edge by default. |
3043 | new_group.RootPart.SetDieAtEdge(true); | ||
3045 | 3044 | ||
3046 | m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( | 3045 | new_group.ResumeScripts(); |
3047 | "object_rez", new Object[] { | ||
3048 | new LSL_String( | ||
3049 | new_group.RootPart.UUID.ToString()) }, | ||
3050 | new DetectParams[0])); | ||
3051 | 3046 | ||
3052 | float groupmass = new_group.GetMass(); | 3047 | m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( |
3048 | "object_rez", new Object[] { | ||
3049 | new LSL_String( | ||
3050 | new_group.RootPart.UUID.ToString()) }, | ||
3051 | new DetectParams[0])); | ||
3053 | 3052 | ||
3054 | PhysicsActor pa = new_group.RootPart.PhysActor; | 3053 | // do recoil |
3054 | SceneObjectGroup hostgrp = m_host.ParentGroup; | ||
3055 | if (hostgrp == null) | ||
3056 | return; | ||
3055 | 3057 | ||
3056 | if (pa != null && pa.IsPhysical && llvel != Vector3.Zero) | 3058 | if (hostgrp.IsAttachment) // don't recoil avatars |
3057 | { | 3059 | return; |
3058 | // recoil | 3060 | |
3059 | llvel *= -groupmass; | 3061 | PhysicsActor pa = new_group.RootPart.PhysActor; |
3060 | llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0); | 3062 | |
3061 | } | 3063 | if (pa != null && pa.IsPhysical && llvel != Vector3.Zero) |
3062 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) | 3064 | { |
3063 | return; | 3065 | float groupmass = new_group.GetMass(); |
3064 | } | 3066 | llvel *= -groupmass; |
3067 | llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0); | ||
3065 | } | 3068 | } |
3069 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) | ||
3070 | return; | ||
3066 | 3071 | ||
3067 | llSay(0, "Could not find object " + inventory); | ||
3068 | }); | 3072 | }); |
3069 | 3073 | ||
3070 | //ScriptSleep((int)((groupmass * velmag) / 10)); | 3074 | //ScriptSleep((int)((groupmass * velmag) / 10)); |
@@ -4213,11 +4217,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4213 | public void llGiveInventory(string destination, string inventory) | 4217 | public void llGiveInventory(string destination, string inventory) |
4214 | { | 4218 | { |
4215 | m_host.AddScriptLPS(1); | 4219 | m_host.AddScriptLPS(1); |
4216 | bool found = false; | 4220 | |
4217 | UUID destId = UUID.Zero; | 4221 | UUID destId = UUID.Zero; |
4218 | UUID objId = UUID.Zero; | ||
4219 | int assetType = 0; | ||
4220 | string objName = String.Empty; | ||
4221 | 4222 | ||
4222 | if (!UUID.TryParse(destination, out destId)) | 4223 | if (!UUID.TryParse(destination, out destId)) |
4223 | { | 4224 | { |
@@ -4225,28 +4226,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4225 | return; | 4226 | return; |
4226 | } | 4227 | } |
4227 | 4228 | ||
4228 | // move the first object found with this inventory name | 4229 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory); |
4229 | m_host.TaskInventory.LockItemsForRead(true); | ||
4230 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4231 | { | ||
4232 | if (inv.Value.Name == inventory) | ||
4233 | { | ||
4234 | found = true; | ||
4235 | objId = inv.Key; | ||
4236 | assetType = inv.Value.Type; | ||
4237 | objName = inv.Value.Name; | ||
4238 | break; | ||
4239 | } | ||
4240 | } | ||
4241 | m_host.TaskInventory.LockItemsForRead(false); | ||
4242 | 4230 | ||
4243 | if (!found) | 4231 | if (item == null) |
4244 | { | 4232 | { |
4245 | llSay(0, String.Format("Could not find object '{0}'", inventory)); | 4233 | llSay(0, String.Format("Could not find object '{0}'", inventory)); |
4246 | return; | 4234 | return; |
4247 | // throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 4235 | // throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); |
4248 | } | 4236 | } |
4249 | 4237 | ||
4238 | UUID objId = item.ItemID; | ||
4239 | |||
4250 | // check if destination is an object | 4240 | // check if destination is an object |
4251 | if (World.GetSceneObjectPart(destId) != null) | 4241 | if (World.GetSceneObjectPart(destId) != null) |
4252 | { | 4242 | { |
@@ -4278,14 +4268,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4278 | return; | 4268 | return; |
4279 | 4269 | ||
4280 | byte[] bucket = new byte[1]; | 4270 | byte[] bucket = new byte[1]; |
4281 | bucket[0] = (byte)assetType; | 4271 | bucket[0] = (byte)item.Type; |
4282 | //byte[] objBytes = agentItem.ID.GetBytes(); | 4272 | //byte[] objBytes = agentItem.ID.GetBytes(); |
4283 | //Array.Copy(objBytes, 0, bucket, 1, 16); | 4273 | //Array.Copy(objBytes, 0, bucket, 1, 16); |
4284 | 4274 | ||
4285 | GridInstantMessage msg = new GridInstantMessage(World, | 4275 | GridInstantMessage msg = new GridInstantMessage(World, |
4286 | m_host.OwnerID, m_host.Name, destId, | 4276 | m_host.OwnerID, m_host.Name, destId, |
4287 | (byte)InstantMessageDialog.TaskInventoryOffered, | 4277 | (byte)InstantMessageDialog.TaskInventoryOffered, |
4288 | false, objName+". "+m_host.Name+" is located at "+ | 4278 | false, item.Name+". "+m_host.Name+" is located at "+ |
4289 | World.RegionInfo.RegionName+" "+ | 4279 | World.RegionInfo.RegionName+" "+ |
4290 | m_host.AbsolutePosition.ToString(), | 4280 | m_host.AbsolutePosition.ToString(), |
4291 | agentItem.ID, true, m_host.AbsolutePosition, | 4281 | agentItem.ID, true, m_host.AbsolutePosition, |
@@ -4313,27 +4303,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4313 | { | 4303 | { |
4314 | m_host.AddScriptLPS(1); | 4304 | m_host.AddScriptLPS(1); |
4315 | 4305 | ||
4316 | List<TaskInventoryItem> inv; | 4306 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); |
4317 | try | 4307 | |
4318 | { | 4308 | if (item == null) |
4319 | m_host.TaskInventory.LockItemsForRead(true); | 4309 | return; |
4320 | inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values); | 4310 | |
4321 | } | 4311 | if (item.ItemID == m_item.ItemID) |
4322 | finally | 4312 | throw new ScriptDeleteException(); |
4323 | { | 4313 | else |
4324 | m_host.TaskInventory.LockItemsForRead(false); | 4314 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
4325 | } | ||
4326 | foreach (TaskInventoryItem item in inv) | ||
4327 | { | ||
4328 | if (item.Name == name) | ||
4329 | { | ||
4330 | if (item.ItemID == m_item.ItemID) | ||
4331 | throw new ScriptDeleteException(); | ||
4332 | else | ||
4333 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | ||
4334 | return; | ||
4335 | } | ||
4336 | } | ||
4337 | } | 4315 | } |
4338 | 4316 | ||
4339 | public void llSetText(string text, LSL_Vector color, double alpha) | 4317 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -4481,10 +4459,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4481 | { | 4459 | { |
4482 | m_host.AddScriptLPS(1); | 4460 | m_host.AddScriptLPS(1); |
4483 | 4461 | ||
4484 | //Clone is thread safe | 4462 | foreach (TaskInventoryItem item in m_host.Inventory.GetInventoryItems()) |
4485 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | ||
4486 | |||
4487 | foreach (TaskInventoryItem item in itemDictionary.Values) | ||
4488 | { | 4463 | { |
4489 | if (item.Type == 3 && item.Name == name) | 4464 | if (item.Type == 3 && item.Name == name) |
4490 | { | 4465 | { |
@@ -4516,6 +4491,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4516 | return tid.ToString(); | 4491 | return tid.ToString(); |
4517 | } | 4492 | } |
4518 | } | 4493 | } |
4494 | |||
4519 | ScriptSleep(1000); | 4495 | ScriptSleep(1000); |
4520 | return String.Empty; | 4496 | return String.Empty; |
4521 | } | 4497 | } |
@@ -4708,19 +4684,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4708 | UUID soundId = UUID.Zero; | 4684 | UUID soundId = UUID.Zero; |
4709 | if (!UUID.TryParse(impact_sound, out soundId)) | 4685 | if (!UUID.TryParse(impact_sound, out soundId)) |
4710 | { | 4686 | { |
4711 | m_host.TaskInventory.LockItemsForRead(true); | 4687 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(impact_sound); |
4712 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4688 | |
4713 | { | 4689 | if (item != null && item.Type == (int)AssetType.Sound) |
4714 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4690 | soundId = item.AssetID; |
4715 | { | ||
4716 | soundId = item.AssetID; | ||
4717 | break; | ||
4718 | } | ||
4719 | } | ||
4720 | m_host.TaskInventory.LockItemsForRead(false); | ||
4721 | } | 4691 | } |
4722 | m_host.CollisionSoundVolume = (float)impact_volume; | 4692 | |
4723 | m_host.CollisionSound = soundId; | 4693 | m_host.CollisionSound = soundId; |
4694 | m_host.CollisionSoundVolume = (float)impact_volume; | ||
4724 | m_host.CollisionSoundType = 1; | 4695 | m_host.CollisionSoundType = 1; |
4725 | } | 4696 | } |
4726 | 4697 | ||
@@ -4762,10 +4733,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4762 | UUID partItemID; | 4733 | UUID partItemID; |
4763 | foreach (SceneObjectPart part in parts) | 4734 | foreach (SceneObjectPart part in parts) |
4764 | { | 4735 | { |
4765 | //Clone is thread safe | 4736 | foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems()) |
4766 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | ||
4767 | |||
4768 | foreach (TaskInventoryItem item in itemsDictionary.Values) | ||
4769 | { | 4737 | { |
4770 | if (item.Type == ScriptBaseClass.INVENTORY_SCRIPT) | 4738 | if (item.Type == ScriptBaseClass.INVENTORY_SCRIPT) |
4771 | { | 4739 | { |
@@ -5136,22 +5104,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5136 | { | 5104 | { |
5137 | m_host.AddScriptLPS(1); | 5105 | m_host.AddScriptLPS(1); |
5138 | 5106 | ||
5139 | m_host.TaskInventory.LockItemsForRead(true); | 5107 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); |
5140 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 5108 | |
5109 | if (item == null) | ||
5110 | return UUID.Zero.ToString(); | ||
5111 | |||
5112 | if ((item.CurrentPermissions | ||
5113 | & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | ||
5114 | == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | ||
5141 | { | 5115 | { |
5142 | if (inv.Value.Name == name) | 5116 | return item.AssetID.ToString(); |
5143 | { | ||
5144 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | ||
5145 | { | ||
5146 | m_host.TaskInventory.LockItemsForRead(false); | ||
5147 | return inv.Value.AssetID.ToString(); | ||
5148 | } | ||
5149 | else | ||
5150 | { | ||
5151 | m_host.TaskInventory.LockItemsForRead(false); | ||
5152 | return UUID.Zero.ToString(); | ||
5153 | } | ||
5154 | } | ||
5155 | } | 5117 | } |
5156 | m_host.TaskInventory.LockItemsForRead(false); | 5118 | m_host.TaskInventory.LockItemsForRead(false); |
5157 | 5119 | ||
@@ -6774,22 +6736,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6774 | } | 6736 | } |
6775 | } | 6737 | } |
6776 | 6738 | ||
6777 | protected UUID GetTaskInventoryItem(string name) | ||
6778 | { | ||
6779 | m_host.TaskInventory.LockItemsForRead(true); | ||
6780 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6781 | { | ||
6782 | if (inv.Value.Name == name) | ||
6783 | { | ||
6784 | m_host.TaskInventory.LockItemsForRead(false); | ||
6785 | return inv.Key; | ||
6786 | } | ||
6787 | } | ||
6788 | m_host.TaskInventory.LockItemsForRead(false); | ||
6789 | |||
6790 | return UUID.Zero; | ||
6791 | } | ||
6792 | |||
6793 | public void llGiveInventoryList(string destination, string category, LSL_List inventory) | 6739 | public void llGiveInventoryList(string destination, string category, LSL_List inventory) |
6794 | { | 6740 | { |
6795 | m_host.AddScriptLPS(1); | 6741 | m_host.AddScriptLPS(1); |
@@ -6802,16 +6748,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6802 | 6748 | ||
6803 | foreach (Object item in inventory.Data) | 6749 | foreach (Object item in inventory.Data) |
6804 | { | 6750 | { |
6751 | string rawItemString = item.ToString(); | ||
6752 | |||
6805 | UUID itemID; | 6753 | UUID itemID; |
6806 | if (UUID.TryParse(item.ToString(), out itemID)) | 6754 | if (UUID.TryParse(rawItemString, out itemID)) |
6807 | { | 6755 | { |
6808 | itemList.Add(itemID); | 6756 | itemList.Add(itemID); |
6809 | } | 6757 | } |
6810 | else | 6758 | else |
6811 | { | 6759 | { |
6812 | itemID = GetTaskInventoryItem(item.ToString()); | 6760 | TaskInventoryItem taskItem = m_host.Inventory.GetInventoryItem(rawItemString); |
6813 | if (itemID != UUID.Zero) | 6761 | |
6814 | itemList.Add(itemID); | 6762 | if (taskItem != null) |
6763 | itemList.Add(taskItem.ItemID); | ||
6815 | } | 6764 | } |
6816 | } | 6765 | } |
6817 | 6766 | ||
@@ -7133,9 +7082,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7133 | public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) | 7082 | public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) |
7134 | { | 7083 | { |
7135 | m_host.AddScriptLPS(1); | 7084 | m_host.AddScriptLPS(1); |
7136 | bool found = false; | 7085 | |
7137 | UUID destId = UUID.Zero; | 7086 | UUID destId = UUID.Zero; |
7138 | UUID srcId = UUID.Zero; | ||
7139 | 7087 | ||
7140 | if (!UUID.TryParse(target, out destId)) | 7088 | if (!UUID.TryParse(target, out destId)) |
7141 | { | 7089 | { |
@@ -7150,25 +7098,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7150 | } | 7098 | } |
7151 | 7099 | ||
7152 | // copy the first script found with this inventory name | 7100 | // copy the first script found with this inventory name |
7153 | TaskInventoryItem scriptItem = null; | 7101 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); |
7154 | m_host.TaskInventory.LockItemsForRead(true); | ||
7155 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
7156 | { | ||
7157 | if (inv.Value.Name == name) | ||
7158 | { | ||
7159 | // make sure the object is a script | ||
7160 | if (10 == inv.Value.Type) | ||
7161 | { | ||
7162 | found = true; | ||
7163 | srcId = inv.Key; | ||
7164 | scriptItem = inv.Value; | ||
7165 | break; | ||
7166 | } | ||
7167 | } | ||
7168 | } | ||
7169 | m_host.TaskInventory.LockItemsForRead(false); | ||
7170 | 7102 | ||
7171 | if (!found) | 7103 | // make sure the object is a script |
7104 | if (item == null || item.Type != 10) | ||
7172 | { | 7105 | { |
7173 | llSay(0, "Could not find script " + name); | 7106 | llSay(0, "Could not find script " + name); |
7174 | return; | 7107 | return; |
@@ -7177,13 +7110,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7177 | SceneObjectPart dest = World.GetSceneObjectPart(destId); | 7110 | SceneObjectPart dest = World.GetSceneObjectPart(destId); |
7178 | if (dest != null) | 7111 | if (dest != null) |
7179 | { | 7112 | { |
7180 | if ((scriptItem.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID) | 7113 | if ((item.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID) |
7181 | { | 7114 | { |
7182 | // the rest of the permission checks are done in RezScript, so check the pin there as well | 7115 | // the rest of the permission checks are done in RezScript, so check the pin there as well |
7183 | World.RezScriptFromPrim(srcId, m_host, destId, pin, running, start_param); | 7116 | World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param); |
7184 | 7117 | ||
7185 | if ((scriptItem.BasePermissions & (uint)PermissionMask.Copy) == 0) | 7118 | if ((item.BasePermissions & (uint)PermissionMask.Copy) == 0) |
7186 | m_host.Inventory.RemoveInventoryItem(srcId); | 7119 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
7187 | } | 7120 | } |
7188 | } | 7121 | } |
7189 | // this will cause the delay even if the script pin or permissions were wrong - seems ok | 7122 | // this will cause the delay even if the script pin or permissions were wrong - seems ok |
@@ -10224,92 +10157,82 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10224 | } | 10157 | } |
10225 | } | 10158 | } |
10226 | 10159 | ||
10227 | public LSL_Integer llGetInventoryPermMask(string item, int mask) | 10160 | public LSL_Integer llGetInventoryPermMask(string itemName, int mask) |
10228 | { | 10161 | { |
10229 | m_host.AddScriptLPS(1); | 10162 | m_host.AddScriptLPS(1); |
10230 | 10163 | ||
10231 | m_host.TaskInventory.LockItemsForRead(true); | 10164 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); |
10232 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 10165 | |
10166 | if (item == null) | ||
10167 | return -1; | ||
10168 | |||
10169 | switch (mask) | ||
10233 | { | 10170 | { |
10234 | if (inv.Value.Name == item) | 10171 | case 0: |
10235 | { | 10172 | return (int)item.BasePermissions; |
10236 | m_host.TaskInventory.LockItemsForRead(false); | 10173 | case 1: |
10237 | switch (mask) | 10174 | return (int)item.CurrentPermissions; |
10238 | { | 10175 | case 2: |
10239 | case 0: | 10176 | return (int)item.GroupPermissions; |
10240 | return (int)inv.Value.BasePermissions; | 10177 | case 3: |
10241 | case 1: | 10178 | return (int)item.EveryonePermissions; |
10242 | return (int)inv.Value.CurrentPermissions; | 10179 | case 4: |
10243 | case 2: | 10180 | return (int)item.NextPermissions; |
10244 | return (int)inv.Value.GroupPermissions; | ||
10245 | case 3: | ||
10246 | return (int)inv.Value.EveryonePermissions; | ||
10247 | case 4: | ||
10248 | return (int)inv.Value.NextPermissions; | ||
10249 | } | ||
10250 | } | ||
10251 | } | 10181 | } |
10252 | m_host.TaskInventory.LockItemsForRead(false); | 10182 | m_host.TaskInventory.LockItemsForRead(false); |
10253 | 10183 | ||
10254 | return -1; | 10184 | return -1; |
10255 | } | 10185 | } |
10256 | 10186 | ||
10257 | public void llSetInventoryPermMask(string item, int mask, int value) | 10187 | public void llSetInventoryPermMask(string itemName, int mask, int value) |
10258 | { | 10188 | { |
10259 | m_host.AddScriptLPS(1); | 10189 | m_host.AddScriptLPS(1); |
10190 | |||
10260 | if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false)) | 10191 | if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false)) |
10261 | { | 10192 | { |
10262 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) | 10193 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) |
10263 | { | 10194 | { |
10264 | lock (m_host.TaskInventory) | 10195 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); |
10196 | |||
10197 | if (item != null) | ||
10265 | { | 10198 | { |
10266 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 10199 | switch (mask) |
10267 | { | 10200 | { |
10268 | if (inv.Value.Name == item) | 10201 | case 0: |
10269 | { | 10202 | item.BasePermissions = (uint)value; |
10270 | switch (mask) | 10203 | break; |
10271 | { | 10204 | case 1: |
10272 | case 0: | 10205 | item.CurrentPermissions = (uint)value; |
10273 | inv.Value.BasePermissions = (uint)value; | 10206 | break; |
10274 | break; | 10207 | case 2: |
10275 | case 1: | 10208 | item.GroupPermissions = (uint)value; |
10276 | inv.Value.CurrentPermissions = (uint)value; | 10209 | break; |
10277 | break; | 10210 | case 3: |
10278 | case 2: | 10211 | item.EveryonePermissions = (uint)value; |
10279 | inv.Value.GroupPermissions = (uint)value; | 10212 | break; |
10280 | break; | 10213 | case 4: |
10281 | case 3: | 10214 | item.NextPermissions = (uint)value; |
10282 | inv.Value.EveryonePermissions = (uint)value; | 10215 | break; |
10283 | break; | ||
10284 | case 4: | ||
10285 | inv.Value.NextPermissions = (uint)value; | ||
10286 | break; | ||
10287 | } | ||
10288 | } | ||
10289 | } | 10216 | } |
10290 | } | 10217 | } |
10291 | } | 10218 | } |
10292 | } | 10219 | } |
10293 | } | 10220 | } |
10294 | 10221 | ||
10295 | public LSL_String llGetInventoryCreator(string item) | 10222 | public LSL_String llGetInventoryCreator(string itemName) |
10296 | { | 10223 | { |
10297 | m_host.AddScriptLPS(1); | 10224 | m_host.AddScriptLPS(1); |
10298 | 10225 | ||
10299 | m_host.TaskInventory.LockItemsForRead(true); | 10226 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); |
10300 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 10227 | |
10228 | if (item == null) | ||
10301 | { | 10229 | { |
10302 | if (inv.Value.Name == item) | 10230 | llSay(0, "No item name '" + item + "'"); |
10303 | { | ||
10304 | m_host.TaskInventory.LockItemsForRead(false); | ||
10305 | return inv.Value.CreatorID.ToString(); | ||
10306 | } | ||
10307 | } | ||
10308 | m_host.TaskInventory.LockItemsForRead(false); | ||
10309 | 10231 | ||
10310 | llSay(0, "No item name '" + item + "'"); | 10232 | return String.Empty; |
10233 | } | ||
10311 | 10234 | ||
10312 | return String.Empty; | 10235 | return item.CreatorID.ToString(); |
10313 | } | 10236 | } |
10314 | 10237 | ||
10315 | public void llOwnerSay(string msg) | 10238 | public void llOwnerSay(string msg) |
@@ -10869,18 +10792,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10869 | { | 10792 | { |
10870 | m_host.AddScriptLPS(1); | 10793 | m_host.AddScriptLPS(1); |
10871 | 10794 | ||
10872 | m_host.TaskInventory.LockItemsForRead(true); | 10795 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); |
10873 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
10874 | { | ||
10875 | if (inv.Value.Name == name) | ||
10876 | { | ||
10877 | m_host.TaskInventory.LockItemsForRead(false); | ||
10878 | return inv.Value.Type; | ||
10879 | } | ||
10880 | } | ||
10881 | m_host.TaskInventory.LockItemsForRead(false); | ||
10882 | 10796 | ||
10883 | return -1; | 10797 | if (item == null) |
10798 | return -1; | ||
10799 | |||
10800 | return item.Type; | ||
10884 | } | 10801 | } |
10885 | 10802 | ||
10886 | public void llSetPayPrice(int price, LSL_List quick_pay_buttons) | 10803 | public void llSetPayPrice(int price, LSL_List quick_pay_buttons) |
@@ -11766,22 +11683,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11766 | return new LSL_List(); | 11683 | return new LSL_List(); |
11767 | } | 11684 | } |
11768 | 11685 | ||
11769 | internal UUID ScriptByName(string name) | 11686 | internal UUID GetScriptByName(string name) |
11770 | { | 11687 | { |
11771 | m_host.TaskInventory.LockItemsForRead(true); | 11688 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); |
11772 | |||
11773 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
11774 | { | ||
11775 | if (item.Type == 10 && item.Name == name) | ||
11776 | { | ||
11777 | m_host.TaskInventory.LockItemsForRead(false); | ||
11778 | return item.ItemID; | ||
11779 | } | ||
11780 | } | ||
11781 | 11689 | ||
11782 | m_host.TaskInventory.LockItemsForRead(false); | 11690 | if (item == null || item.Type != 10) |
11691 | return UUID.Zero; | ||
11783 | 11692 | ||
11784 | return UUID.Zero; | 11693 | return item.ItemID; |
11785 | } | 11694 | } |
11786 | 11695 | ||
11787 | internal void ShoutError(string msg) | 11696 | internal void ShoutError(string msg) |
@@ -11821,21 +11730,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11821 | { | 11730 | { |
11822 | m_host.AddScriptLPS(1); | 11731 | m_host.AddScriptLPS(1); |
11823 | 11732 | ||
11824 | //Clone is thread safe | ||
11825 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | ||
11826 | |||
11827 | UUID assetID = UUID.Zero; | 11733 | UUID assetID = UUID.Zero; |
11828 | 11734 | ||
11829 | if (!UUID.TryParse(name, out assetID)) | 11735 | if (!UUID.TryParse(name, out assetID)) |
11830 | { | 11736 | { |
11831 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 11737 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); |
11832 | { | 11738 | |
11833 | if (item.Type == 7 && item.Name == name) | 11739 | if (item != null && item.Type == 7) |
11834 | { | 11740 | assetID = item.AssetID; |
11835 | assetID = item.AssetID; | ||
11836 | break; | ||
11837 | } | ||
11838 | } | ||
11839 | } | 11741 | } |
11840 | 11742 | ||
11841 | if (assetID == UUID.Zero) | 11743 | if (assetID == UUID.Zero) |
@@ -11884,21 +11786,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11884 | { | 11786 | { |
11885 | m_host.AddScriptLPS(1); | 11787 | m_host.AddScriptLPS(1); |
11886 | 11788 | ||
11887 | //Clone is thread safe | ||
11888 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | ||
11889 | |||
11890 | UUID assetID = UUID.Zero; | 11789 | UUID assetID = UUID.Zero; |
11891 | 11790 | ||
11892 | if (!UUID.TryParse(name, out assetID)) | 11791 | if (!UUID.TryParse(name, out assetID)) |
11893 | { | 11792 | { |
11894 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 11793 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); |
11895 | { | 11794 | |
11896 | if (item.Type == 7 && item.Name == name) | 11795 | if (item != null && item.Type == 7) |
11897 | { | 11796 | assetID = item.AssetID; |
11898 | assetID = item.AssetID; | ||
11899 | break; | ||
11900 | } | ||
11901 | } | ||
11902 | } | 11797 | } |
11903 | 11798 | ||
11904 | if (assetID == UUID.Zero) | 11799 | if (assetID == UUID.Zero) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 795376b..77b659b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -126,7 +126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
126 | [Serializable] | 126 | [Serializable] |
127 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi | 127 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi |
128 | { | 128 | { |
129 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 129 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
130 | 130 | ||
131 | public const string GridInfoServiceConfigSectionName = "GridInfoService"; | 131 | public const string GridInfoServiceConfigSectionName = "GridInfoService"; |
132 | 132 | ||
@@ -2136,7 +2136,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2136 | 2136 | ||
2137 | public LSL_String osFormatString(string str, LSL_List strings) | 2137 | public LSL_String osFormatString(string str, LSL_List strings) |
2138 | { | 2138 | { |
2139 | CheckThreatLevel(ThreatLevel.Low, "osFormatString"); | 2139 | CheckThreatLevel(ThreatLevel.VeryLow, "osFormatString"); |
2140 | m_host.AddScriptLPS(1); | 2140 | m_host.AddScriptLPS(1); |
2141 | 2141 | ||
2142 | return String.Format(str, strings.Data); | 2142 | return String.Format(str, strings.Data); |
@@ -2144,7 +2144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2144 | 2144 | ||
2145 | public LSL_List osMatchString(string src, string pattern, int start) | 2145 | public LSL_List osMatchString(string src, string pattern, int start) |
2146 | { | 2146 | { |
2147 | CheckThreatLevel(ThreatLevel.High, "osMatchString"); | 2147 | CheckThreatLevel(ThreatLevel.VeryLow, "osMatchString"); |
2148 | m_host.AddScriptLPS(1); | 2148 | m_host.AddScriptLPS(1); |
2149 | 2149 | ||
2150 | LSL_List result = new LSL_List(); | 2150 | LSL_List result = new LSL_List(); |
@@ -2186,7 +2186,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2186 | 2186 | ||
2187 | public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start) | 2187 | public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start) |
2188 | { | 2188 | { |
2189 | CheckThreatLevel(ThreatLevel.High, "osReplaceString"); | 2189 | CheckThreatLevel(ThreatLevel.VeryLow, "osReplaceString"); |
2190 | m_host.AddScriptLPS(1); | 2190 | m_host.AddScriptLPS(1); |
2191 | 2191 | ||
2192 | // Normalize indices (if negative). | 2192 | // Normalize indices (if negative). |
@@ -3199,6 +3199,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3199 | ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); | 3199 | ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); |
3200 | } | 3200 | } |
3201 | 3201 | ||
3202 | public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint) | ||
3203 | { | ||
3204 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory"); | ||
3205 | |||
3206 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | ||
3207 | |||
3208 | if (attachmentsModule == null) | ||
3209 | return; | ||
3210 | |||
3211 | m_host.AddScriptLPS(1); | ||
3212 | |||
3213 | InitLSL(); | ||
3214 | |||
3215 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); | ||
3216 | |||
3217 | if (item == null) | ||
3218 | { | ||
3219 | ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Could not find object '{0}'", itemName)); | ||
3220 | throw new Exception(String.Format("The inventory item '{0}' could not be found", itemName)); | ||
3221 | } | ||
3222 | |||
3223 | if (item.InvType != (int)InventoryType.Object) | ||
3224 | { | ||
3225 | // FIXME: Temporary null check for regression tests since they dont' have the infrastructure to set | ||
3226 | // up the api reference. | ||
3227 | if (m_LSL_Api != null) | ||
3228 | ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName)); | ||
3229 | |||
3230 | throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName)); | ||
3231 | |||
3232 | return; | ||
3233 | } | ||
3234 | |||
3235 | ScenePresence sp = World.GetScenePresence(m_host.OwnerID); | ||
3236 | |||
3237 | if (sp == null) | ||
3238 | return; | ||
3239 | |||
3240 | InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID); | ||
3241 | |||
3242 | if (newItem == null) | ||
3243 | { | ||
3244 | m_log.ErrorFormat( | ||
3245 | "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}", | ||
3246 | itemName, m_host.Name, attachmentPoint, World.Name); | ||
3247 | |||
3248 | return; | ||
3249 | } | ||
3250 | |||
3251 | attachmentsModule.RezSingleAttachmentFromInventory(sp, newItem.ID, (uint)attachmentPoint); | ||
3252 | } | ||
3253 | |||
3202 | public void osForceDetachFromAvatar() | 3254 | public void osForceDetachFromAvatar() |
3203 | { | 3255 | { |
3204 | CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); | 3256 | CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 7382495..a790cdc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -107,6 +107,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
107 | void osForceAttachToAvatar(int attachment); | 107 | void osForceAttachToAvatar(int attachment); |
108 | 108 | ||
109 | /// <summary> | 109 | /// <summary> |
110 | /// Attach the inventory item in the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH | ||
111 | /// </summary> | ||
112 | /// <param name='itemName'>Tha name of the item. If this is not found then a warning is said to the owner</param> | ||
113 | /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param> | ||
114 | void osForceAttachToAvatarFromInventory(string itemName, int attachment); | ||
115 | |||
116 | /// <summary> | ||
110 | /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH | 117 | /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH |
111 | /// </summary> | 118 | /// </summary> |
112 | /// <remarks>Nothing happens if the object is not attached.</remarks> | 119 | /// <remarks>Nothing happens if the object is not attached.</remarks> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index d230662..500ed96 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -296,6 +296,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
296 | m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint); | 296 | m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint); |
297 | } | 297 | } |
298 | 298 | ||
299 | public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint) | ||
300 | { | ||
301 | m_OSSL_Functions.osForceAttachToAvatarFromInventory(itemName, attachmentPoint); | ||
302 | } | ||
303 | |||
299 | public void osForceDetachFromAvatar() | 304 | public void osForceDetachFromAvatar() |
300 | { | 305 | { |
301 | m_OSSL_Functions.osForceDetachFromAvatar(); | 306 | m_OSSL_Functions.osForceDetachFromAvatar(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs index bc3b790..2565ae7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs | |||
@@ -89,7 +89,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
89 | 89 | ||
90 | // FIXME: This should really be a script item (with accompanying script) | 90 | // FIXME: This should really be a script item (with accompanying script) |
91 | TaskInventoryItem grp1Item | 91 | TaskInventoryItem grp1Item |
92 | = TaskInventoryHelpers.AddNotecard(m_scene, grp1.RootPart); | 92 | = TaskInventoryHelpers.AddNotecard( |
93 | m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); | ||
93 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 94 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
94 | 95 | ||
95 | SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); | 96 | SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); |
@@ -122,7 +123,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
122 | 123 | ||
123 | // FIXME: This should really be a script item (with accompanying script) | 124 | // FIXME: This should really be a script item (with accompanying script) |
124 | TaskInventoryItem grp1Item | 125 | TaskInventoryItem grp1Item |
125 | = TaskInventoryHelpers.AddNotecard(m_scene, grp1.RootPart); | 126 | = TaskInventoryHelpers.AddNotecard( |
127 | m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); | ||
128 | |||
126 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 129 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
127 | 130 | ||
128 | LSL_Api apiGrp1 = new LSL_Api(); | 131 | LSL_Api apiGrp1 = new LSL_Api(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index f96a156..c41d1e7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
59 | config.Set("Enabled", "true"); | 59 | config.Set("Enabled", "true"); |
60 | 60 | ||
61 | Scene scene = new SceneHelpers().SetupScene(); | 61 | Scene scene = new SceneHelpers().SetupScene(); |
62 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 62 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene).RootPart; |
63 | 63 | ||
64 | XEngine.XEngine engine = new XEngine.XEngine(); | 64 | XEngine.XEngine engine = new XEngine.XEngine(); |
65 | engine.Initialise(initConfigSource); | 65 | engine.Initialise(initConfigSource); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs new file mode 100644 index 0000000..537b8aa --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs | |||
@@ -0,0 +1,178 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.Assets; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.CoreModules.Avatar.Attachments; | ||
40 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Region.ScriptEngine.Shared; | ||
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
44 | using OpenSim.Services.Interfaces; | ||
45 | using OpenSim.Tests.Common; | ||
46 | using OpenSim.Tests.Common.Mock; | ||
47 | |||
48 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | ||
49 | { | ||
50 | /// <summary> | ||
51 | /// Tests for OSSL attachment functions | ||
52 | /// </summary> | ||
53 | /// <remarks> | ||
54 | /// TODO: Add tests for all functions | ||
55 | /// </remarks> | ||
56 | [TestFixture] | ||
57 | public class OSSL_ApiAttachmentTests : OpenSimTestCase | ||
58 | { | ||
59 | protected Scene m_scene; | ||
60 | protected XEngine.XEngine m_engine; | ||
61 | |||
62 | [SetUp] | ||
63 | public override void SetUp() | ||
64 | { | ||
65 | base.SetUp(); | ||
66 | |||
67 | IConfigSource initConfigSource = new IniConfigSource(); | ||
68 | |||
69 | IConfig xengineConfig = initConfigSource.AddConfig("XEngine"); | ||
70 | xengineConfig.Set("Enabled", "true"); | ||
71 | xengineConfig.Set("AllowOSFunctions", "true"); | ||
72 | xengineConfig.Set("OSFunctionThreatLevel", "Severe"); | ||
73 | |||
74 | IConfig modulesConfig = initConfigSource.AddConfig("Modules"); | ||
75 | modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
76 | |||
77 | m_scene = new SceneHelpers().SetupScene(); | ||
78 | SceneHelpers.SetupSceneModules( | ||
79 | m_scene, initConfigSource, new AttachmentsModule(), new BasicInventoryAccessModule()); | ||
80 | |||
81 | m_engine = new XEngine.XEngine(); | ||
82 | m_engine.Initialise(initConfigSource); | ||
83 | m_engine.AddRegion(m_scene); | ||
84 | } | ||
85 | |||
86 | [Test] | ||
87 | public void TestOsForceAttachToAvatarFromInventory() | ||
88 | { | ||
89 | TestHelpers.InMethod(); | ||
90 | // TestHelpers.EnableLogging(); | ||
91 | |||
92 | string taskInvObjItemName = "sphere"; | ||
93 | UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); | ||
94 | AttachmentPoint attachPoint = AttachmentPoint.Chin; | ||
95 | |||
96 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1); | ||
97 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID); | ||
98 | SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); | ||
99 | TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); | ||
100 | |||
101 | new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); | ||
102 | OSSL_Api osslApi = new OSSL_Api(); | ||
103 | osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); | ||
104 | |||
105 | // SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ua1.PrincipalID); | ||
106 | |||
107 | // Create an object embedded inside the first | ||
108 | TaskInventoryHelpers.AddSceneObject(m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); | ||
109 | |||
110 | osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint); | ||
111 | |||
112 | // Check scene presence status | ||
113 | Assert.That(sp.HasAttachments(), Is.True); | ||
114 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
115 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
116 | SceneObjectGroup attSo = attachments[0]; | ||
117 | Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName)); | ||
118 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint)); | ||
119 | Assert.That(attSo.IsAttachment); | ||
120 | Assert.That(attSo.UsesPhysics, Is.False); | ||
121 | Assert.That(attSo.IsTemporary, Is.False); | ||
122 | |||
123 | // Check appearance status | ||
124 | List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments(); | ||
125 | Assert.That(attachmentsInAppearance.Count, Is.EqualTo(1)); | ||
126 | Assert.That(sp.Appearance.GetAttachpoint(attachmentsInAppearance[0].ItemID), Is.EqualTo((uint)attachPoint)); | ||
127 | } | ||
128 | |||
129 | /// <summary> | ||
130 | /// Make sure we can't force attach anything other than objects. | ||
131 | /// </summary> | ||
132 | [Test] | ||
133 | public void TestOsForceAttachToAvatarFromInventoryNotObject() | ||
134 | { | ||
135 | TestHelpers.InMethod(); | ||
136 | // TestHelpers.EnableLogging(); | ||
137 | |||
138 | string taskInvObjItemName = "sphere"; | ||
139 | UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); | ||
140 | AttachmentPoint attachPoint = AttachmentPoint.Chin; | ||
141 | |||
142 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1); | ||
143 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID); | ||
144 | SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); | ||
145 | TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); | ||
146 | |||
147 | new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); | ||
148 | OSSL_Api osslApi = new OSSL_Api(); | ||
149 | osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); | ||
150 | |||
151 | // Create an object embedded inside the first | ||
152 | TaskInventoryHelpers.AddNotecard( | ||
153 | m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900)); | ||
154 | |||
155 | bool exceptionCaught = false; | ||
156 | |||
157 | try | ||
158 | { | ||
159 | osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint); | ||
160 | } | ||
161 | catch (Exception e) | ||
162 | { | ||
163 | exceptionCaught = true; | ||
164 | } | ||
165 | |||
166 | Assert.That(exceptionCaught, Is.True); | ||
167 | |||
168 | // Check scene presence status | ||
169 | Assert.That(sp.HasAttachments(), Is.False); | ||
170 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
171 | Assert.That(attachments.Count, Is.EqualTo(0)); | ||
172 | |||
173 | // Check appearance status | ||
174 | List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments(); | ||
175 | Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0)); | ||
176 | } | ||
177 | } | ||
178 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index 0ccd889..813e53b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | |||
@@ -52,14 +52,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
52 | /// Tests for OSSL NPC API | 52 | /// Tests for OSSL NPC API |
53 | /// </summary> | 53 | /// </summary> |
54 | [TestFixture] | 54 | [TestFixture] |
55 | public class OSSL_NpcApiAppearanceTest | 55 | public class OSSL_NpcApiAppearanceTest : OpenSimTestCase |
56 | { | 56 | { |
57 | protected Scene m_scene; | 57 | protected Scene m_scene; |
58 | protected XEngine.XEngine m_engine; | 58 | protected XEngine.XEngine m_engine; |
59 | 59 | ||
60 | [SetUp] | 60 | [SetUp] |
61 | public void SetUp() | 61 | public override void SetUp() |
62 | { | 62 | { |
63 | base.SetUp(); | ||
64 | |||
63 | IConfigSource initConfigSource = new IniConfigSource(); | 65 | IConfigSource initConfigSource = new IniConfigSource(); |
64 | IConfig config = initConfigSource.AddConfig("XEngine"); | 66 | IConfig config = initConfigSource.AddConfig("XEngine"); |
65 | config.Set("Enabled", "true"); | 67 | config.Set("Enabled", "true"); |