aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs73
2 files changed, 46 insertions, 29 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 9b94e05..53681f8 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -1408,7 +1408,7 @@ namespace OpenSim.Region.Environment.Scenes
1408 1408
1409 destPart.AddInventoryItemExclusive(destTaskItem); 1409 destPart.AddInventoryItemExclusive(destTaskItem);
1410 1410
1411 if ( running > 0 ) 1411 if (running > 0)
1412 { 1412 {
1413 if (ExternalChecks.ExternalChecksCanRunScript(destTaskItem.AssetID, destPart.UUID, destPart.OwnerID)) 1413 if (ExternalChecks.ExternalChecksCanRunScript(destTaskItem.AssetID, destPart.UUID, destPart.OwnerID))
1414 { 1414 {
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index 27b00ee..fea131e 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -90,6 +90,10 @@ namespace OpenSim.Region.Environment.Scenes
90 } 90 }
91 } 91 }
92 92
93 /// <summary>
94 /// Change every item in this prim's inventory to a new owner.
95 /// </summary>
96 /// <param name="ownerId"></param>
93 public void ChangeInventoryOwner(LLUUID ownerId) 97 public void ChangeInventoryOwner(LLUUID ownerId)
94 { 98 {
95 lock (TaskInventory) 99 lock (TaskInventory)
@@ -122,8 +126,7 @@ namespace OpenSim.Region.Environment.Scenes
122 { 126 {
123 foreach (TaskInventoryItem item in m_taskInventory.Values) 127 foreach (TaskInventoryItem item in m_taskInventory.Values)
124 { 128 {
125 // XXX more hardcoding badness. Should be an enum in TaskInventoryItem 129 if ((int)InventoryType.LSL == item.InvType)
126 if (10 == item.Type)
127 { 130 {
128 CreateScriptInstance(item, startParam, postOnRez); 131 CreateScriptInstance(item, startParam, postOnRez);
129 } 132 }
@@ -140,7 +143,7 @@ namespace OpenSim.Region.Environment.Scenes
140 { 143 {
141 foreach (TaskInventoryItem item in m_taskInventory.Values) 144 foreach (TaskInventoryItem item in m_taskInventory.Values)
142 { 145 {
143 if (10 == item.Type) 146 if ((int)InventoryType.LSL == item.InvType)
144 { 147 {
145 RemoveScriptInstance(item.ItemID); 148 RemoveScriptInstance(item.ItemID);
146 RemoveScriptEvents(item.ItemID); 149 RemoveScriptEvents(item.ItemID);
@@ -154,7 +157,6 @@ namespace OpenSim.Region.Environment.Scenes
154 /// </summary> 157 /// </summary>
155 /// <param name="item"></param> 158 /// <param name="item"></param>
156 /// <returns></returns> 159 /// <returns></returns>
157
158 public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez) 160 public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez)
159 { 161 {
160 // m_log.InfoFormat( 162 // m_log.InfoFormat(
@@ -200,7 +202,6 @@ namespace OpenSim.Region.Environment.Scenes
200 if (m_taskInventory.ContainsKey(itemId)) 202 if (m_taskInventory.ContainsKey(itemId))
201 { 203 {
202 CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez); 204 CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez);
203
204 } 205 }
205 else 206 else
206 { 207 {
@@ -232,7 +233,12 @@ namespace OpenSim.Region.Environment.Scenes
232 } 233 }
233 } 234 }
234 235
235 // Assumes a lock is held on the inventory 236 /// <summary>
237 /// Check if the inventory holds an item with a given name.
238 /// This method assumes that the task inventory is already locked.
239 /// </summary>
240 /// <param name="name"></param>
241 /// <returns></returns>
236 private bool InventoryContainsName(string name) 242 private bool InventoryContainsName(string name)
237 { 243 {
238 foreach (TaskInventoryItem item in m_taskInventory.Values) 244 foreach (TaskInventoryItem item in m_taskInventory.Values)
@@ -243,6 +249,12 @@ namespace OpenSim.Region.Environment.Scenes
243 return false; 249 return false;
244 } 250 }
245 251
252 /// <summary>
253 /// For a given item name, return that name if it is available. Otherwise, return the next available
254 /// similar name (which is currently the original name with the next available numeric suffix).
255 /// </summary>
256 /// <param name="name"></param>
257 /// <returns></returns>
246 private string FindAvailableInventoryName(string name) 258 private string FindAvailableInventoryName(string name)
247 { 259 {
248 if (!InventoryContainsName(name)) 260 if (!InventoryContainsName(name))
@@ -260,49 +272,54 @@ namespace OpenSim.Region.Environment.Scenes
260 } 272 }
261 273
262 /// <summary> 274 /// <summary>
263 /// Add an item to this prim's inventory. 275 /// Add an item to this prim's inventory. If an item with the same name already exists, then an alternative
276 /// name is chosen.
264 /// </summary> 277 /// </summary>
265 /// <param name="item"></param> 278 /// <param name="item"></param>
266 public void AddInventoryItem(TaskInventoryItem item) 279 public void AddInventoryItem(TaskInventoryItem item)
267 { 280 {
268 item.ParentID = UUID;
269 item.ParentPartID = UUID;
270
271 string name = FindAvailableInventoryName(item.Name); 281 string name = FindAvailableInventoryName(item.Name);
272 if (name == String.Empty) 282 if (name == String.Empty)
273 return; 283 return;
274 284
275 item.Name=name; 285 AddInventoryItem(name, item);
276
277 lock (m_taskInventory)
278 {
279 m_taskInventory.Add(item.ItemID, item);
280 TriggerScriptChangedEvent(Changed.INVENTORY);
281 }
282
283 m_inventorySerial++;
284 //m_inventorySerial += 2;
285 HasInventoryChanged = true;
286 ParentGroup.HasGroupChanged = true;
287 } 286 }
288 287
288 /// <summary>
289 /// Add an item to this prim's inventory. If an item with the same name already exists, it is replaced.
290 /// </summary>
291 /// <param name="item"></param>
289 public void AddInventoryItemExclusive(TaskInventoryItem item) 292 public void AddInventoryItemExclusive(TaskInventoryItem item)
290 { 293 {
291 item.ParentID = UUID;
292 item.ParentPartID = UUID;
293
294 List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_taskInventory.Values); 294 List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_taskInventory.Values);
295 foreach(TaskInventoryItem i in il) 295 foreach(TaskInventoryItem i in il)
296 { 296 {
297 if(i.Name == item.Name) 297 if (i.Name == item.Name)
298 { 298 {
299 if(i.Type == 10) 299 if (i.InvType == (int)InventoryType.LSL)
300 RemoveScriptInstance(i.ItemID); 300 RemoveScriptInstance(i.ItemID);
301
301 RemoveInventoryItem(i.ItemID); 302 RemoveInventoryItem(i.ItemID);
302 break; 303 break;
303 } 304 }
304 } 305 }
305 306
307 AddInventoryItem(item.Name, item);
308 }
309
310 /// <summary>
311 /// Add an item to this prim's inventory.
312 /// </summary>
313 /// <param name="name">The name that the new item should have.</param>
314 /// <param name="item">
315 /// The item itself. The name within this structure is ignored in favour of the name
316 /// given in this method's arguments
317 /// </param>
318 protected void AddInventoryItem(string name, TaskInventoryItem item)
319 {
320 item.ParentID = UUID;
321 item.ParentPartID = UUID;
322
306 lock (m_taskInventory) 323 lock (m_taskInventory)
307 { 324 {
308 m_taskInventory.Add(item.ItemID, item); 325 m_taskInventory.Add(item.ItemID, item);
@@ -312,7 +329,7 @@ namespace OpenSim.Region.Environment.Scenes
312 m_inventorySerial++; 329 m_inventorySerial++;
313 //m_inventorySerial += 2; 330 //m_inventorySerial += 2;
314 HasInventoryChanged = true; 331 HasInventoryChanged = true;
315 ParentGroup.HasGroupChanged = true; 332 ParentGroup.HasGroupChanged = true;
316 } 333 }
317 334
318 /// <summary> 335 /// <summary>