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/Api/Implementation | |
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/Api/Implementation')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 425 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 60 |
2 files changed, 216 insertions, 269 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"); |