aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorlbsa712008-02-20 13:11:19 +0000
committerlbsa712008-02-20 13:11:19 +0000
commit4c6e5a5090f847aa8944bd06168b45af8fcec3bf (patch)
tree2a2dddd48c11c635b9181170ae506f5b8d4a5a73 /OpenSim/Region/Environment
parentFixed big bug in AgentAssetTransactions, now don't seem to be getting any Abo... (diff)
downloadopensim-SC-4c6e5a5090f847aa8944bd06168b45af8fcec3bf.zip
opensim-SC-4c6e5a5090f847aa8944bd06168b45af8fcec3bf.tar.gz
opensim-SC-4c6e5a5090f847aa8944bd06168b45af8fcec3bf.tar.bz2
opensim-SC-4c6e5a5090f847aa8944bd06168b45af8fcec3bf.tar.xz
* re-enabled AssetNotFound code
* turned script asset fetching asynchronous
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs157
1 files changed, 80 insertions, 77 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index a27432d..17c4d6d 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -33,6 +33,7 @@ using System.Xml.Serialization;
33using libsecondlife; 33using libsecondlife;
34 34
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
37using OpenSim.Region.Environment.Interfaces; 38using OpenSim.Region.Environment.Interfaces;
38using OpenSim.Region.Environment.Scenes.Scripting; 39using OpenSim.Region.Environment.Scenes.Scripting;
@@ -44,12 +45,12 @@ namespace OpenSim.Region.Environment.Scenes
44 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
45 46
46 private string m_inventoryFileName = String.Empty; 47 private string m_inventoryFileName = String.Empty;
47 48
48 /// <summary> 49 /// <summary>
49 /// The inventory folder for this prim 50 /// The inventory folder for this prim
50 /// </summary> 51 /// </summary>
51 private LLUUID m_folderID = LLUUID.Zero; 52 private LLUUID m_folderID = LLUUID.Zero;
52 53
53 /// <summary> 54 /// <summary>
54 /// Exposing this is not particularly good, but it's one of the least evils at the moment to see 55 /// Exposing this is not particularly good, but it's one of the least evils at the moment to see
55 /// folder id from prim inventory item data, since it's not (yet) actually stored with the prim. 56 /// folder id from prim inventory item data, since it's not (yet) actually stored with the prim.
@@ -58,8 +59,8 @@ namespace OpenSim.Region.Environment.Scenes
58 { 59 {
59 get { return m_folderID; } 60 get { return m_folderID; }
60 set { m_folderID = value; } 61 set { m_folderID = value; }
61 } 62 }
62 63
63 /// <summary> 64 /// <summary>
64 /// Serial count for inventory file , used to tell if inventory has changed 65 /// Serial count for inventory file , used to tell if inventory has changed
65 /// no need for this to be part of Database backup 66 /// no need for this to be part of Database backup
@@ -70,24 +71,24 @@ namespace OpenSim.Region.Environment.Scenes
70 { 71 {
71 get { return m_inventorySerial; } 72 get { return m_inventorySerial; }
72 set { m_inventorySerial = value; } 73 set { m_inventorySerial = value; }
73 } 74 }
74 75
75 /// <summary> 76 /// <summary>
76 /// Holds in memory prim inventory 77 /// Holds in memory prim inventory
77 /// </summary> 78 /// </summary>
78 protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary(); 79 protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary();
79 80
80 public TaskInventoryDictionary TaskInventory 81 public TaskInventoryDictionary TaskInventory
81 { 82 {
82 get { return m_taskInventory; } 83 get { return m_taskInventory; }
83 set { m_taskInventory = value; } 84 set { m_taskInventory = value; }
84 } 85 }
85 86
86 /// <summary> 87 /// <summary>
87 /// Tracks whether inventory has changed since the last persistent backup 88 /// Tracks whether inventory has changed since the last persistent backup
88 /// </summary> 89 /// </summary>
89 private bool HasInventoryChanged; 90 private bool HasInventoryChanged;
90 91
91 /// <summary> 92 /// <summary>
92 /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating 93 /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating
93 /// new ones or setting existing UUIDs to the correct parent UUIDs 94 /// new ones or setting existing UUIDs to the correct parent UUIDs
@@ -96,18 +97,18 @@ namespace OpenSim.Region.Environment.Scenes
96 public void ResetInventoryIDs() 97 public void ResetInventoryIDs()
97 { 98 {
98 lock (TaskInventory) 99 lock (TaskInventory)
99 { 100 {
100 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values); 101 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values);
101 TaskInventory.Clear(); 102 TaskInventory.Clear();
102 103
103 foreach (TaskInventoryItem item in items) 104 foreach (TaskInventoryItem item in items)
104 { 105 {
105 item.ResetIDs(UUID); 106 item.ResetIDs(UUID);
106 TaskInventory.Add(item.ItemID, item); 107 TaskInventory.Add(item.ItemID, item);
107 } 108 }
108 } 109 }
109 } 110 }
110 111
111 /// <summary> 112 /// <summary>
112 /// Start all the scripts contained in this prim's inventory 113 /// Start all the scripts contained in this prim's inventory
113 /// </summary> 114 /// </summary>
@@ -139,7 +140,7 @@ namespace OpenSim.Region.Environment.Scenes
139 } 140 }
140 } 141 }
141 } 142 }
142 143
143 /// <summary> 144 /// <summary>
144 /// Start a script which is in this prim's inventory. 145 /// Start a script which is in this prim's inventory.
145 /// </summary> 146 /// </summary>
@@ -147,34 +148,36 @@ namespace OpenSim.Region.Environment.Scenes
147 /// <returns></returns> 148 /// <returns></returns>
148 public void StartScript(TaskInventoryItem item) 149 public void StartScript(TaskInventoryItem item)
149 { 150 {
150// m_log.InfoFormat( 151 // m_log.InfoFormat(
151// "[PRIMINVENTORY]: " + 152 // "[PRIMINVENTORY]: " +
152// "Starting script {0}, {1} in prim {2}, {3}", 153 // "Starting script {0}, {1} in prim {2}, {3}",
153// item.Name, item.ItemID, Name, UUID); 154 // item.Name, item.ItemID, Name, UUID);
154 AddFlag(LLObject.ObjectFlags.Scripted); 155 AddFlag(LLObject.ObjectFlags.Scripted);
155 156
156 if (!((m_parentGroup.Scene.RegionInfo.EstateSettings.regionFlags & Simulator.RegionFlags.SkipScripts) == Simulator.RegionFlags.SkipScripts)) 157 if (!((m_parentGroup.Scene.RegionInfo.EstateSettings.regionFlags & Simulator.RegionFlags.SkipScripts) == Simulator.RegionFlags.SkipScripts))
157 { 158 {
158 AssetBase rezAsset = m_parentGroup.Scene.AssetCache.GetAsset(item.AssetID, false); 159 AssetCache cache = m_parentGroup.Scene.AssetCache;
159 160
160 if (rezAsset != null) 161 cache.GetAsset(item.AssetID, delegate(LLUUID assetID, AssetBase asset)
161 { 162 {
162 163 if (asset.FullID == LLUUID.Zero)
163 string script = Helpers.FieldToUTF8String(rezAsset.Data); 164 {
164 m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID, item.ItemID, script); 165 m_log.ErrorFormat(
165 m_parentGroup.AddActiveScriptCount(1); 166 "[PRIMINVENTORY]: " +
166 } 167 "Couldn't start script {0}, {1} since asset ID {2} could not be found",
167 else 168 item.Name, item.ItemID, item.AssetID);
168 { 169 }
169 m_log.ErrorFormat( 170 else
170 "[PRIMINVENTORY]: " + 171 {
171 "Couldn't start script {0}, {1} since asset ID {2} could not be found", 172 string script = Helpers.FieldToUTF8String(asset.Data);
172 item.Name, item.ItemID, item.AssetID); 173 m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID,item.ItemID,script);
173 } 174 m_parentGroup.AddActiveScriptCount(1);
175 ScheduleFullUpdate();
176 }
177 });
174 } 178 }
175 ScheduleFullUpdate(); 179 }
176 } 180
177
178 /// <summary> 181 /// <summary>
179 /// Start a script which is in this prim's inventory. 182 /// Start a script which is in this prim's inventory.
180 /// </summary> 183 /// </summary>
@@ -184,22 +187,22 @@ namespace OpenSim.Region.Environment.Scenes
184 public void StartScript(LLUUID itemId) 187 public void StartScript(LLUUID itemId)
185 { 188 {
186 lock (m_taskInventory) 189 lock (m_taskInventory)
187 { 190 {
188 if (m_taskInventory.ContainsKey(itemId)) 191 if (m_taskInventory.ContainsKey(itemId))
189 { 192 {
190 StartScript(m_taskInventory[itemId]); 193 StartScript(m_taskInventory[itemId]);
191 194
192 } 195 }
193 else 196 else
194 { 197 {
195 m_log.ErrorFormat( 198 m_log.ErrorFormat(
196 "[PRIMINVENTORY]: " + 199 "[PRIMINVENTORY]: " +
197 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", 200 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}",
198 itemId, Name, UUID); 201 itemId, Name, UUID);
199 } 202 }
200 } 203 }
201 } 204 }
202 205
203 /// <summary> 206 /// <summary>
204 /// Stop a script which is in this prim's inventory. 207 /// Stop a script which is in this prim's inventory.
205 /// </summary> 208 /// </summary>
@@ -210,15 +213,15 @@ namespace OpenSim.Region.Environment.Scenes
210 { 213 {
211 m_parentGroup.Scene.EventManager.TriggerRemoveScript(LocalID, itemId); 214 m_parentGroup.Scene.EventManager.TriggerRemoveScript(LocalID, itemId);
212 m_parentGroup.AddActiveScriptCount(-1); 215 m_parentGroup.AddActiveScriptCount(-1);
213 } 216 }
214 else 217 else
215 { 218 {
216 m_log.ErrorFormat( 219 m_log.ErrorFormat(
217 "[PRIMINVENTORY]: " + 220 "[PRIMINVENTORY]: " +
218 "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2}", 221 "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2}",
219 itemId, Name, UUID); 222 itemId, Name, UUID);
220 } 223 }
221 } 224 }
222 225
223 /// <summary> 226 /// <summary>
224 /// Add an item to this prim's inventory. 227 /// Add an item to this prim's inventory.
@@ -229,17 +232,17 @@ namespace OpenSim.Region.Environment.Scenes
229 item.ParentID = m_folderID; 232 item.ParentID = m_folderID;
230 item.CreationDate = 1000; 233 item.CreationDate = 1000;
231 item.ParentPartID = UUID; 234 item.ParentPartID = UUID;
232 235
233 lock (m_taskInventory) 236 lock (m_taskInventory)
234 { 237 {
235 m_taskInventory.Add(item.ItemID, item); 238 m_taskInventory.Add(item.ItemID, item);
236 TriggerScriptChangedEvent(Changed.INVENTORY); 239 TriggerScriptChangedEvent(Changed.INVENTORY);
237 } 240 }
238 241
239 m_inventorySerial++; 242 m_inventorySerial++;
240 HasInventoryChanged = true; 243 HasInventoryChanged = true;
241 } 244 }
242 245
243 /// <summary> 246 /// <summary>
244 /// Restore a whole collection of items to the prim's inventory at once. 247 /// Restore a whole collection of items to the prim's inventory at once.
245 /// We assume that the items already have all their fields correctly filled out. 248 /// We assume that the items already have all their fields correctly filled out.
@@ -250,17 +253,17 @@ namespace OpenSim.Region.Environment.Scenes
250 public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) 253 public void RestoreInventoryItems(ICollection<TaskInventoryItem> items)
251 { 254 {
252 lock (m_taskInventory) 255 lock (m_taskInventory)
253 { 256 {
254 foreach (TaskInventoryItem item in items) 257 foreach (TaskInventoryItem item in items)
255 { 258 {
256 m_taskInventory.Add(item.ItemID, item); 259 m_taskInventory.Add(item.ItemID, item);
257 TriggerScriptChangedEvent(Changed.INVENTORY); 260 TriggerScriptChangedEvent(Changed.INVENTORY);
258 } 261 }
259 } 262 }
260 263
261 m_inventorySerial++; 264 m_inventorySerial++;
262 } 265 }
263 266
264 /// <summary> 267 /// <summary>
265 /// Returns an existing inventory item. Returns the original, so any changes will be live. 268 /// Returns an existing inventory item. Returns the original, so any changes will be live.
266 /// </summary> 269 /// </summary>
@@ -269,7 +272,7 @@ namespace OpenSim.Region.Environment.Scenes
269 public TaskInventoryItem GetInventoryItem(LLUUID itemID) 272 public TaskInventoryItem GetInventoryItem(LLUUID itemID)
270 { 273 {
271 lock (m_taskInventory) 274 lock (m_taskInventory)
272 { 275 {
273 if (m_taskInventory.ContainsKey(itemID)) 276 if (m_taskInventory.ContainsKey(itemID))
274 { 277 {
275 return m_taskInventory[itemID]; 278 return m_taskInventory[itemID];
@@ -295,15 +298,15 @@ namespace OpenSim.Region.Environment.Scenes
295 public bool UpdateInventoryItem(TaskInventoryItem item) 298 public bool UpdateInventoryItem(TaskInventoryItem item)
296 { 299 {
297 lock (m_taskInventory) 300 lock (m_taskInventory)
298 { 301 {
299 if (m_taskInventory.ContainsKey(item.ItemID)) 302 if (m_taskInventory.ContainsKey(item.ItemID))
300 { 303 {
301 m_taskInventory[item.ItemID] = item; 304 m_taskInventory[item.ItemID] = item;
302 m_inventorySerial++; 305 m_inventorySerial++;
303 TriggerScriptChangedEvent(Changed.INVENTORY); 306 TriggerScriptChangedEvent(Changed.INVENTORY);
304 307
305 HasInventoryChanged = true; 308 HasInventoryChanged = true;
306 309
307 return true; 310 return true;
308 } 311 }
309 else 312 else
@@ -312,9 +315,9 @@ namespace OpenSim.Region.Environment.Scenes
312 "[PRIMINVENTORY]: " + 315 "[PRIMINVENTORY]: " +
313 "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", 316 "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
314 item.ItemID, Name, UUID); 317 item.ItemID, Name, UUID);
315 } 318 }
316 } 319 }
317 320
318 return false; 321 return false;
319 } 322 }
320 323
@@ -332,14 +335,14 @@ namespace OpenSim.Region.Environment.Scenes
332 public int RemoveInventoryItem(LLUUID itemID) 335 public int RemoveInventoryItem(LLUUID itemID)
333 { 336 {
334 lock (m_taskInventory) 337 lock (m_taskInventory)
335 { 338 {
336 if (m_taskInventory.ContainsKey(itemID)) 339 if (m_taskInventory.ContainsKey(itemID))
337 { 340 {
338 int type = m_taskInventory[itemID].InvType; 341 int type = m_taskInventory[itemID].InvType;
339 m_taskInventory.Remove(itemID); 342 m_taskInventory.Remove(itemID);
340 m_inventorySerial++; 343 m_inventorySerial++;
341 TriggerScriptChangedEvent(Changed.INVENTORY); 344 TriggerScriptChangedEvent(Changed.INVENTORY);
342 345
343 HasInventoryChanged = true; 346 HasInventoryChanged = true;
344 347
345 int scriptcount = 0; 348 int scriptcount = 0;
@@ -359,7 +362,7 @@ namespace OpenSim.Region.Environment.Scenes
359 RemFlag(LLObject.ObjectFlags.Scripted); 362 RemFlag(LLObject.ObjectFlags.Scripted);
360 ScheduleFullUpdate(); 363 ScheduleFullUpdate();
361 } 364 }
362 ScheduleFullUpdate(); 365 ScheduleFullUpdate();
363 366
364 return type; 367 return type;
365 } 368 }
@@ -369,7 +372,7 @@ namespace OpenSim.Region.Environment.Scenes
369 "[PRIMINVENTORY]: " + 372 "[PRIMINVENTORY]: " +
370 "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", 373 "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
371 itemID, Name, UUID); 374 itemID, Name, UUID);
372 } 375 }
373 } 376 }
374 377
375 return -1; 378 return -1;
@@ -384,7 +387,7 @@ namespace OpenSim.Region.Environment.Scenes
384 { 387 {
385 if (m_inventorySerial > 0) 388 if (m_inventorySerial > 0)
386 { 389 {
387 client.SendTaskInventory(m_uuid, (short) m_inventorySerial, 390 client.SendTaskInventory(m_uuid, (short)m_inventorySerial,
388 Helpers.StringToField(m_inventoryFileName)); 391 Helpers.StringToField(m_inventoryFileName));
389 return true; 392 return true;
390 } 393 }
@@ -399,15 +402,15 @@ namespace OpenSim.Region.Environment.Scenes
399 { 402 {
400 byte[] fileData = new byte[0]; 403 byte[] fileData = new byte[0];
401 InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID); 404 InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID);
402 405
403 lock (m_taskInventory) 406 lock (m_taskInventory)
404 { 407 {
405 foreach (TaskInventoryItem item in m_taskInventory.Values) 408 foreach (TaskInventoryItem item in m_taskInventory.Values)
406 { 409 {
407 invString.AddItemStart(); 410 invString.AddItemStart();
408 invString.AddNameValueLine("item_id", item.ItemID.ToString()); 411 invString.AddNameValueLine("item_id", item.ItemID.ToString());
409 invString.AddNameValueLine("parent_id", item.ParentID.ToString()); 412 invString.AddNameValueLine("parent_id", item.ParentID.ToString());
410 413
411 invString.AddPermissionsStart(); 414 invString.AddPermissionsStart();
412 invString.AddNameValueLine("base_mask", "0x7FFFFFFF"); 415 invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
413 invString.AddNameValueLine("owner_mask", "0x7FFFFFFF"); 416 invString.AddNameValueLine("owner_mask", "0x7FFFFFFF");
@@ -419,7 +422,7 @@ namespace OpenSim.Region.Environment.Scenes
419 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); 422 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
420 invString.AddNameValueLine("group_id", item.GroupID.ToString()); 423 invString.AddNameValueLine("group_id", item.GroupID.ToString());
421 invString.AddSectionEnd(); 424 invString.AddSectionEnd();
422 425
423 invString.AddNameValueLine("asset_id", item.AssetID.ToString()); 426 invString.AddNameValueLine("asset_id", item.AssetID.ToString());
424 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); 427 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
425 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); 428 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
@@ -430,18 +433,18 @@ namespace OpenSim.Region.Environment.Scenes
430 invString.AddSectionEnd(); 433 invString.AddSectionEnd();
431 } 434 }
432 } 435 }
433 436
434 fileData = Helpers.StringToField(invString.BuildString); 437 fileData = Helpers.StringToField(invString.BuildString);
435 438
436// m_log.InfoFormat( 439 // m_log.InfoFormat(
437// "[PRIMINVENTORY]: RequestInventoryFile fileData: {0}", Helpers.FieldToUTF8String(fileData)); 440 // "[PRIMINVENTORY]: RequestInventoryFile fileData: {0}", Helpers.FieldToUTF8String(fileData));
438 441
439 if (fileData.Length > 2) 442 if (fileData.Length > 2)
440 { 443 {
441 xferManager.AddNewFile(m_inventoryFileName, fileData); 444 xferManager.AddNewFile(m_inventoryFileName, fileData);
442 } 445 }
443 } 446 }
444 447
445 /// <summary> 448 /// <summary>
446 /// Process inventory backup 449 /// Process inventory backup
447 /// </summary> 450 /// </summary>
@@ -454,10 +457,10 @@ namespace OpenSim.Region.Environment.Scenes
454 { 457 {
455 datastore.StorePrimInventory(UUID, TaskInventory.Values); 458 datastore.StorePrimInventory(UUID, TaskInventory.Values);
456 } 459 }
457 460
458 HasInventoryChanged = false; 461 HasInventoryChanged = false;
459 } 462 }
460 } 463 }
461 464
462 public class InventoryStringBuilder 465 public class InventoryStringBuilder
463 { 466 {
@@ -505,6 +508,6 @@ namespace OpenSim.Region.Environment.Scenes
505 public void Close() 508 public void Close()
506 { 509 {
507 } 510 }
508 } 511 }
509 } 512 }
510} 513}