diff options
author | Adam Frisby | 2008-05-01 16:35:00 +0000 |
---|---|---|
committer | Adam Frisby | 2008-05-01 16:35:00 +0000 |
commit | 13526097f24b7a8ad63b1d482c44b44397fa055f (patch) | |
tree | 7a82c20ed7c63e2aea5ad3863325e37f64e1cbea /OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs | |
parent | * Breaking all the code, breaking all the code..! (diff) | |
download | opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.zip opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.gz opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.bz2 opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.xz |
* Spring cleaning on Region.Environment.
* Converted a large number of read-only fields to be actually, readonly.
* Reformatted code sections.
* Removed redundant code.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs | 150 |
1 files changed, 76 insertions, 74 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs index 0215cec..c8a8f95 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs | |||
@@ -41,7 +41,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
41 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | private string m_inventoryFileName = String.Empty; | 44 | private readonly string m_inventoryFileName = String.Empty; |
45 | |||
46 | /// <summary> | ||
47 | /// Tracks whether inventory has changed since the last persistent backup | ||
48 | /// </summary> | ||
49 | private bool HasInventoryChanged; | ||
45 | 50 | ||
46 | /// <summary> | 51 | /// <summary> |
47 | /// The inventory folder for this prim | 52 | /// The inventory folder for this prim |
@@ -49,6 +54,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
49 | private LLUUID m_folderID = LLUUID.Zero; | 54 | private LLUUID m_folderID = LLUUID.Zero; |
50 | 55 | ||
51 | /// <summary> | 56 | /// <summary> |
57 | /// Serial count for inventory file , used to tell if inventory has changed | ||
58 | /// no need for this to be part of Database backup | ||
59 | /// </summary> | ||
60 | protected uint m_inventorySerial; | ||
61 | |||
62 | /// <summary> | ||
63 | /// Holds in memory prim inventory | ||
64 | /// </summary> | ||
65 | protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary(); | ||
66 | |||
67 | /// <summary> | ||
52 | /// Exposing this is not particularly good, but it's one of the least evils at the moment to see | 68 | /// Exposing this is not particularly good, but it's one of the least evils at the moment to see |
53 | /// folder id from prim inventory item data, since it's not (yet) actually stored with the prim. | 69 | /// folder id from prim inventory item data, since it's not (yet) actually stored with the prim. |
54 | /// </summary> | 70 | /// </summary> |
@@ -58,23 +74,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
58 | set { m_folderID = value; } | 74 | set { m_folderID = value; } |
59 | } | 75 | } |
60 | 76 | ||
61 | /// <summary> | ||
62 | /// Serial count for inventory file , used to tell if inventory has changed | ||
63 | /// no need for this to be part of Database backup | ||
64 | /// </summary> | ||
65 | protected uint m_inventorySerial = 0; | ||
66 | |||
67 | public uint InventorySerial | 77 | public uint InventorySerial |
68 | { | 78 | { |
69 | get { return m_inventorySerial; } | 79 | get { return m_inventorySerial; } |
70 | set { m_inventorySerial = value; } | 80 | set { m_inventorySerial = value; } |
71 | } | 81 | } |
72 | 82 | ||
73 | /// <summary> | ||
74 | /// Holds in memory prim inventory | ||
75 | /// </summary> | ||
76 | protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary(); | ||
77 | |||
78 | public TaskInventoryDictionary TaskInventory | 83 | public TaskInventoryDictionary TaskInventory |
79 | { | 84 | { |
80 | get { return m_taskInventory; } | 85 | get { return m_taskInventory; } |
@@ -82,11 +87,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
82 | } | 87 | } |
83 | 88 | ||
84 | /// <summary> | 89 | /// <summary> |
85 | /// Tracks whether inventory has changed since the last persistent backup | ||
86 | /// </summary> | ||
87 | private bool HasInventoryChanged; | ||
88 | |||
89 | /// <summary> | ||
90 | /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating | 90 | /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating |
91 | /// new ones or setting existing UUIDs to the correct parent UUIDs. | 91 | /// new ones or setting existing UUIDs to the correct parent UUIDs. |
92 | /// | 92 | /// |
@@ -96,14 +96,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
96 | public void ResetInventoryIDs() | 96 | public void ResetInventoryIDs() |
97 | { | 97 | { |
98 | lock (TaskInventory) | 98 | lock (TaskInventory) |
99 | { | 99 | { |
100 | if (0 == TaskInventory.Count) | 100 | if (0 == TaskInventory.Count) |
101 | { | 101 | { |
102 | return; | 102 | return; |
103 | } | 103 | } |
104 | 104 | ||
105 | HasInventoryChanged = true; | 105 | HasInventoryChanged = true; |
106 | 106 | ||
107 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values); | 107 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values); |
108 | TaskInventory.Clear(); | 108 | TaskInventory.Clear(); |
109 | 109 | ||
@@ -132,9 +132,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
132 | if (ownerId != item.OwnerID) | 132 | if (ownerId != item.OwnerID) |
133 | { | 133 | { |
134 | item.LastOwnerID = item.OwnerID; | 134 | item.LastOwnerID = item.OwnerID; |
135 | item.OwnerID = ownerId; | 135 | item.OwnerID = ownerId; |
136 | item.BaseMask = item.NextOwnerMask & (uint)PermissionMask.All; | 136 | item.BaseMask = item.NextOwnerMask & (uint) PermissionMask.All; |
137 | item.OwnerMask = item.NextOwnerMask & (uint)PermissionMask.All; | 137 | item.OwnerMask = item.NextOwnerMask & (uint) PermissionMask.All; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | } | 140 | } |
@@ -194,22 +194,22 @@ namespace OpenSim.Region.Environment.Scenes | |||
194 | AssetCache cache = m_parentGroup.Scene.AssetCache; | 194 | AssetCache cache = m_parentGroup.Scene.AssetCache; |
195 | 195 | ||
196 | cache.GetAsset(item.AssetID, delegate(LLUUID assetID, AssetBase asset) | 196 | cache.GetAsset(item.AssetID, delegate(LLUUID assetID, AssetBase asset) |
197 | { | 197 | { |
198 | if (null == asset) | 198 | if (null == asset) |
199 | { | 199 | { |
200 | m_log.ErrorFormat( | 200 | m_log.ErrorFormat( |
201 | "[PRIMINVENTORY]: " + | 201 | "[PRIMINVENTORY]: " + |
202 | "Couldn't start script {0}, {1} since asset ID {2} could not be found", | 202 | "Couldn't start script {0}, {1} since asset ID {2} could not be found", |
203 | item.Name, item.ItemID, item.AssetID); | 203 | item.Name, item.ItemID, item.AssetID); |
204 | } | 204 | } |
205 | else | 205 | else |
206 | { | 206 | { |
207 | string script = Helpers.FieldToUTF8String(asset.Data); | 207 | string script = Helpers.FieldToUTF8String(asset.Data); |
208 | m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId,item.ItemID,script); | 208 | m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId, item.ItemID, script); |
209 | m_parentGroup.AddActiveScriptCount(1); | 209 | m_parentGroup.AddActiveScriptCount(1); |
210 | ScheduleFullUpdate(); | 210 | ScheduleFullUpdate(); |
211 | } | 211 | } |
212 | }, false); | 212 | }, false); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
@@ -226,7 +226,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
226 | if (m_taskInventory.ContainsKey(itemId)) | 226 | if (m_taskInventory.ContainsKey(itemId)) |
227 | { | 227 | { |
228 | StartScript(m_taskInventory[itemId]); | 228 | StartScript(m_taskInventory[itemId]); |
229 | |||
230 | } | 229 | } |
231 | else | 230 | else |
232 | { | 231 | { |
@@ -263,7 +262,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
263 | { | 262 | { |
264 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 263 | foreach (TaskInventoryItem item in m_taskInventory.Values) |
265 | { | 264 | { |
266 | if(item.Name == name) | 265 | if (item.Name == name) |
267 | return true; | 266 | return true; |
268 | } | 267 | } |
269 | return false; | 268 | return false; |
@@ -271,14 +270,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
271 | 270 | ||
272 | private string FindAvailableInventoryName(string name) | 271 | private string FindAvailableInventoryName(string name) |
273 | { | 272 | { |
274 | if(!InventoryContainsName(name)) | 273 | if (!InventoryContainsName(name)) |
275 | return name; | 274 | return name; |
276 | 275 | ||
277 | int suffix=1; | 276 | int suffix = 1; |
278 | while(suffix < 256) | 277 | while (suffix < 256) |
279 | { | 278 | { |
280 | string tryName=String.Format("{0} {1}", name, suffix); | 279 | string tryName = String.Format("{0} {1}", name, suffix); |
281 | if(!InventoryContainsName(tryName)) | 280 | if (!InventoryContainsName(tryName)) |
282 | return tryName; | 281 | return tryName; |
283 | suffix++; | 282 | suffix++; |
284 | } | 283 | } |
@@ -295,11 +294,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
295 | item.CreationDate = 1000; | 294 | item.CreationDate = 1000; |
296 | item.ParentPartID = UUID; | 295 | item.ParentPartID = UUID; |
297 | 296 | ||
298 | string name=FindAvailableInventoryName(item.Name); | 297 | string name = FindAvailableInventoryName(item.Name); |
299 | if(name == String.Empty) | 298 | if (name == String.Empty) |
300 | return; | 299 | return; |
301 | 300 | ||
302 | item.Name=name; | 301 | item.Name = name; |
303 | 302 | ||
304 | lock (m_taskInventory) | 303 | lock (m_taskInventory) |
305 | { | 304 | { |
@@ -347,7 +346,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
347 | // m_log.DebugFormat( | 346 | // m_log.DebugFormat( |
348 | // "[PRIM INVENTORY]: Retrieved task inventory item {0}, {1} from prim {2}, {3}", | 347 | // "[PRIM INVENTORY]: Retrieved task inventory item {0}, {1} from prim {2}, {3}", |
349 | // m_taskInventory[itemID].Name, itemID, Name, UUID); | 348 | // m_taskInventory[itemID].Name, itemID, Name, UUID); |
350 | 349 | ||
351 | return m_taskInventory[itemID]; | 350 | return m_taskInventory[itemID]; |
352 | } | 351 | } |
353 | else | 352 | else |
@@ -428,7 +427,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
428 | scriptcount++; | 427 | scriptcount++; |
429 | } | 428 | } |
430 | } | 429 | } |
431 | |||
432 | } | 430 | } |
433 | if (scriptcount <= 0) | 431 | if (scriptcount <= 0) |
434 | { | 432 | { |
@@ -457,14 +455,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
457 | /// <param name="client"></param> | 455 | /// <param name="client"></param> |
458 | /// <param name="localID"></param> | 456 | /// <param name="localID"></param> |
459 | public bool GetInventoryFileName(IClientAPI client, uint localID) | 457 | public bool GetInventoryFileName(IClientAPI client, uint localID) |
460 | { | 458 | { |
461 | // m_log.DebugFormat( | 459 | // m_log.DebugFormat( |
462 | // "[PRIM INVENTORY]: Received request from client {0} for inventory file name of {1}, {2}", | 460 | // "[PRIM INVENTORY]: Received request from client {0} for inventory file name of {1}, {2}", |
463 | // client.AgentId, Name, UUID); | 461 | // client.AgentId, Name, UUID); |
464 | 462 | ||
465 | if (m_inventorySerial > 0) | 463 | if (m_inventorySerial > 0) |
466 | { | 464 | { |
467 | client.SendTaskInventory(m_uuid, (short)m_inventorySerial, | 465 | client.SendTaskInventory(m_uuid, (short) m_inventorySerial, |
468 | Helpers.StringToField(m_inventoryFileName)); | 466 | Helpers.StringToField(m_inventoryFileName)); |
469 | return true; | 467 | return true; |
470 | } | 468 | } |
@@ -480,9 +478,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
480 | /// </summary> | 478 | /// </summary> |
481 | /// <param name="xferManager"></param> | 479 | /// <param name="xferManager"></param> |
482 | public void RequestInventoryFile(IXfer xferManager) | 480 | public void RequestInventoryFile(IXfer xferManager) |
483 | { | 481 | { |
484 | byte[] fileData = new byte[0]; | 482 | byte[] fileData = new byte[0]; |
485 | 483 | ||
486 | // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches | 484 | // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches |
487 | // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality | 485 | // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality |
488 | // isn't available (such as drag from prim inventory to agent inventory) | 486 | // isn't available (such as drag from prim inventory to agent inventory) |
@@ -493,53 +491,53 @@ namespace OpenSim.Region.Environment.Scenes | |||
493 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 491 | foreach (TaskInventoryItem item in m_taskInventory.Values) |
494 | { | 492 | { |
495 | invString.AddItemStart(); | 493 | invString.AddItemStart(); |
496 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 494 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
497 | invString.AddNameValueLine("parent_id", m_folderID.ToString()); | 495 | invString.AddNameValueLine("parent_id", m_folderID.ToString()); |
498 | 496 | ||
499 | invString.AddPermissionsStart(); | 497 | invString.AddPermissionsStart(); |
500 | 498 | ||
501 | // FIXME: Temporary until permissions are properly sorted. | 499 | // FIXME: Temporary until permissions are properly sorted. |
502 | invString.AddNameValueLine("base_mask", "7fffffff"); | 500 | invString.AddNameValueLine("base_mask", "7fffffff"); |
503 | invString.AddNameValueLine("owner_mask", "7fffffff"); | 501 | invString.AddNameValueLine("owner_mask", "7fffffff"); |
504 | invString.AddNameValueLine("group_mask", "7fffffff"); | 502 | invString.AddNameValueLine("group_mask", "7fffffff"); |
505 | invString.AddNameValueLine("everyone_mask", "7fffffff"); | 503 | invString.AddNameValueLine("everyone_mask", "7fffffff"); |
506 | invString.AddNameValueLine("next_owner_mask", "7fffffff"); | 504 | invString.AddNameValueLine("next_owner_mask", "7fffffff"); |
507 | 505 | ||
508 | // invString.AddNameValueLine("group_mask", "00000000"); | 506 | // invString.AddNameValueLine("group_mask", "00000000"); |
509 | // invString.AddNameValueLine("everyone_mask", "00000000"); | 507 | // invString.AddNameValueLine("everyone_mask", "00000000"); |
510 | // invString.AddNameValueLine("next_owner_mask", "00086000"); | 508 | // invString.AddNameValueLine("next_owner_mask", "00086000"); |
511 | 509 | ||
512 | // invString.AddNameValueLine("base_mask", Helpers.UIntToHexString(item.BaseMask)); | 510 | // invString.AddNameValueLine("base_mask", Helpers.UIntToHexString(item.BaseMask)); |
513 | // invString.AddNameValueLine("owner_mask", Helpers.UIntToHexString(item.OwnerMask)); | 511 | // invString.AddNameValueLine("owner_mask", Helpers.UIntToHexString(item.OwnerMask)); |
514 | // invString.AddNameValueLine("group_mask", Helpers.UIntToHexString(item.GroupMask)); | 512 | // invString.AddNameValueLine("group_mask", Helpers.UIntToHexString(item.GroupMask)); |
515 | // invString.AddNameValueLine("everyone_mask", Helpers.UIntToHexString(item.EveryoneMask)); | 513 | // invString.AddNameValueLine("everyone_mask", Helpers.UIntToHexString(item.EveryoneMask)); |
516 | // invString.AddNameValueLine("next_owner_mask", Helpers.UIntToHexString(item.NextOwnerMask)); | 514 | // invString.AddNameValueLine("next_owner_mask", Helpers.UIntToHexString(item.NextOwnerMask)); |
517 | 515 | ||
518 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | 516 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); |
519 | invString.AddNameValueLine("owner_id", item.OwnerID.ToString()); | 517 | invString.AddNameValueLine("owner_id", item.OwnerID.ToString()); |
520 | 518 | ||
521 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | 519 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); |
522 | // invString.AddNameValueLine("last_owner_id", item.OwnerID.ToString()); | 520 | // invString.AddNameValueLine("last_owner_id", item.OwnerID.ToString()); |
523 | 521 | ||
524 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | 522 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); |
525 | invString.AddSectionEnd(); | 523 | invString.AddSectionEnd(); |
526 | 524 | ||
527 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | 525 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); |
528 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); | 526 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); |
529 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); | 527 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); |
530 | invString.AddNameValueLine("flags", "00000000"); | 528 | invString.AddNameValueLine("flags", "00000000"); |
531 | 529 | ||
532 | invString.AddSaleStart(); | 530 | invString.AddSaleStart(); |
533 | invString.AddNameValueLine("sale_type", "not"); | 531 | invString.AddNameValueLine("sale_type", "not"); |
534 | invString.AddNameValueLine("sale_price", "0"); | 532 | invString.AddNameValueLine("sale_price", "0"); |
535 | invString.AddSectionEnd(); | 533 | invString.AddSectionEnd(); |
536 | 534 | ||
537 | invString.AddNameValueLine("name", item.Name + "|"); | 535 | invString.AddNameValueLine("name", item.Name + "|"); |
538 | invString.AddNameValueLine("desc", item.Description + "|"); | 536 | invString.AddNameValueLine("desc", item.Description + "|"); |
539 | 537 | ||
540 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | 538 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); |
541 | // invString.AddNameValueLine("creation_date", "1209151453"); | 539 | // invString.AddNameValueLine("creation_date", "1209151453"); |
542 | 540 | ||
543 | invString.AddSectionEnd(); | 541 | invString.AddSectionEnd(); |
544 | } | 542 | } |
545 | } | 543 | } |
@@ -571,6 +569,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
571 | } | 569 | } |
572 | } | 570 | } |
573 | 571 | ||
572 | #region Nested type: InventoryStringBuilder | ||
573 | |||
574 | public class InventoryStringBuilder | 574 | public class InventoryStringBuilder |
575 | { | 575 | { |
576 | public string BuildString = String.Empty; | 576 | public string BuildString = String.Empty; |
@@ -596,13 +596,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
596 | BuildString += "\tpermissions 0\n"; | 596 | BuildString += "\tpermissions 0\n"; |
597 | AddSectionStart(); | 597 | AddSectionStart(); |
598 | } | 598 | } |
599 | 599 | ||
600 | public void AddSaleStart() | 600 | public void AddSaleStart() |
601 | { | 601 | { |
602 | BuildString += "\tsale_info\t0\n"; | 602 | BuildString += "\tsale_info\t0\n"; |
603 | AddSectionStart(); | 603 | AddSectionStart(); |
604 | } | 604 | } |
605 | 605 | ||
606 | protected void AddSectionStart() | 606 | protected void AddSectionStart() |
607 | { | 607 | { |
608 | BuildString += "\t{\n"; | 608 | BuildString += "\t{\n"; |
@@ -629,5 +629,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
629 | { | 629 | { |
630 | } | 630 | } |
631 | } | 631 | } |
632 | |||
633 | #endregion | ||
632 | } | 634 | } |
633 | } | 635 | } \ No newline at end of file |