aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-01-16 18:35:34 +0000
committerJustin Clarke Casey2008-01-16 18:35:34 +0000
commit57519b6dba97d7e7a2de71af9d58c93b4750bde8 (patch)
tree9597647ee1e70e50215b90bb116fede1ca7f8e27 /OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
parentFirst part of changing prim's permission flags to use the correct enum (libsl... (diff)
downloadopensim-SC_OLD-57519b6dba97d7e7a2de71af9d58c93b4750bde8.zip
opensim-SC_OLD-57519b6dba97d7e7a2de71af9d58c93b4750bde8.tar.gz
opensim-SC_OLD-57519b6dba97d7e7a2de71af9d58c93b4750bde8.tar.bz2
opensim-SC_OLD-57519b6dba97d7e7a2de71af9d58c93b4750bde8.tar.xz
* Store task inventory when an object is taken into agent inventory
* This means that you can take an object from a region and rez it somewhere else, with its inventory intact. * As for earlier, at this stage only scripts can be placed in inventory * This isn't an efficient implementation, a better one will probably need to come along soonish
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs90
1 files changed, 53 insertions, 37 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index fc74c4e..5132a6c 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -57,30 +57,46 @@ namespace OpenSim.Region.Environment.Scenes
57 get { return m_folderID; } 57 get { return m_folderID; }
58 set { m_folderID = value; } 58 set { m_folderID = value; }
59 } 59 }
60
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
68 {
69 get { return m_inventorySerial; }
70 set { m_inventorySerial = value; }
71 }
60 72
61 /// <summary> 73 /// <summary>
62 /// Holds in memory prim inventory 74 /// Holds in memory prim inventory
63 /// </summary> 75 /// </summary>
64 protected IDictionary<LLUUID, TaskInventoryItem> m_taskInventory 76 protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary();
65 = new Dictionary<LLUUID, TaskInventoryItem>();
66 77
67 [XmlIgnore] 78 public TaskInventoryDictionary TaskInventory
68 public IDictionary<LLUUID, TaskInventoryItem> TaskInventory
69 { 79 {
70 get { return m_taskInventory; } 80 get { return m_taskInventory; }
81 set { m_taskInventory = value; }
71 } 82 }
72 83
73 /// <summary> 84 /// <summary>
74 /// Serial count for inventory file , used to tell if inventory has changed 85 /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating
75 /// no need for this to be part of Database backup 86 /// new ones or setting existing UUIDs to the correct parent UUIDs
76 /// </summary> 87 /// </summary>
77 protected uint m_inventorySerial = 0; 88 /// <param name="linkNum'>Link number for the part</param>
78 89 public void ResetInventoryIDs()
79 public uint InventorySerial
80 { 90 {
81 get { return m_inventorySerial; } 91 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values);
82 } 92 TaskInventory.Clear();
83 93
94 foreach (TaskInventoryItem item in items)
95 {
96 item.ResetIDs(UUID);
97 TaskInventory.Add(item.ItemID, item);
98 }
99 }
84 100
85 /// <summary> 101 /// <summary>
86 /// Start all the scripts contained in this prim's inventory 102 /// Start all the scripts contained in this prim's inventory
@@ -90,7 +106,7 @@ namespace OpenSim.Region.Environment.Scenes
90 foreach (TaskInventoryItem item in m_taskInventory.Values) 106 foreach (TaskInventoryItem item in m_taskInventory.Values)
91 { 107 {
92 // XXX more hardcoding badness. Should be an enum in TaskInventoryItem 108 // XXX more hardcoding badness. Should be an enum in TaskInventoryItem
93 if (10 == item.type) 109 if (10 == item.Type)
94 { 110 {
95 StartScript(item); 111 StartScript(item);
96 } 112 }
@@ -107,21 +123,21 @@ namespace OpenSim.Region.Environment.Scenes
107// MainLog.Instance.Verbose( 123// MainLog.Instance.Verbose(
108// "PRIMINVENTORY", 124// "PRIMINVENTORY",
109// "Starting script {0}, {1} in prim {2}, {3}", 125// "Starting script {0}, {1} in prim {2}, {3}",
110// item.name, item.item_id, Name, UUID); 126// item.Name, item.ItemID, Name, UUID);
111 127
112 AssetBase rezAsset = m_parentGroup.Scene.AssetCache.GetAsset(item.asset_id, false); 128 AssetBase rezAsset = m_parentGroup.Scene.AssetCache.GetAsset(item.AssetID, false);
113 129
114 if (rezAsset != null) 130 if (rezAsset != null)
115 { 131 {
116 string script = Helpers.FieldToUTF8String(rezAsset.Data); 132 string script = Helpers.FieldToUTF8String(rezAsset.Data);
117 m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID, item.item_id, script); 133 m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID, item.ItemID, script);
118 } 134 }
119 else 135 else
120 { 136 {
121 MainLog.Instance.Error( 137 MainLog.Instance.Error(
122 "PRIMINVENTORY", 138 "PRIMINVENTORY",
123 "Couldn't start script {0}, {1} since asset ID {2} could not be found", 139 "Couldn't start script {0}, {1} since asset ID {2} could not be found",
124 item.name, item.item_id, item.asset_id); 140 item.Name, item.ItemID, item.AssetID);
125 } 141 }
126 } 142 }
127 143
@@ -172,10 +188,10 @@ namespace OpenSim.Region.Environment.Scenes
172 /// <param name="item"></param> 188 /// <param name="item"></param>
173 public void AddInventoryItem(TaskInventoryItem item) 189 public void AddInventoryItem(TaskInventoryItem item)
174 { 190 {
175 item.parent_id = m_folderID; 191 item.ParentID = m_folderID;
176 item.creation_date = 1000; 192 item.CreationDate = 1000;
177 item.ParentPartID = UUID; 193 item.ParentPartID = UUID;
178 m_taskInventory.Add(item.item_id, item); 194 m_taskInventory.Add(item.ItemID, item);
179 m_inventorySerial++; 195 m_inventorySerial++;
180 } 196 }
181 197
@@ -188,7 +204,7 @@ namespace OpenSim.Region.Environment.Scenes
188 { 204 {
189 foreach (TaskInventoryItem item in items) 205 foreach (TaskInventoryItem item in items)
190 { 206 {
191 m_taskInventory.Add(item.item_id, item); 207 m_taskInventory.Add(item.ItemID, item);
192 } 208 }
193 209
194 m_inventorySerial++; 210 m_inventorySerial++;
@@ -224,9 +240,9 @@ namespace OpenSim.Region.Environment.Scenes
224 /// <returns>false if the item did not exist, true if the update occurred succesfully</returns> 240 /// <returns>false if the item did not exist, true if the update occurred succesfully</returns>
225 public bool UpdateInventoryItem(TaskInventoryItem item) 241 public bool UpdateInventoryItem(TaskInventoryItem item)
226 { 242 {
227 if (m_taskInventory.ContainsKey(item.item_id)) 243 if (m_taskInventory.ContainsKey(item.ItemID))
228 { 244 {
229 m_taskInventory[item.item_id] = item; 245 m_taskInventory[item.ItemID] = item;
230 m_inventorySerial++; 246 m_inventorySerial++;
231 247
232 return true; 248 return true;
@@ -236,7 +252,7 @@ namespace OpenSim.Region.Environment.Scenes
236 MainLog.Instance.Error( 252 MainLog.Instance.Error(
237 "PRIMINVENTORY", 253 "PRIMINVENTORY",
238 "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", 254 "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
239 item.item_id, Name, UUID); 255 item.ItemID, Name, UUID);
240 } 256 }
241 257
242 return false; 258 return false;
@@ -252,7 +268,7 @@ namespace OpenSim.Region.Environment.Scenes
252 { 268 {
253 if (m_taskInventory.ContainsKey(itemID)) 269 if (m_taskInventory.ContainsKey(itemID))
254 { 270 {
255 int type = m_taskInventory[itemID].inv_type; 271 int type = m_taskInventory[itemID].InvType;
256 m_taskInventory.Remove(itemID); 272 m_taskInventory.Remove(itemID);
257 m_inventorySerial++; 273 m_inventorySerial++;
258 274
@@ -296,8 +312,8 @@ namespace OpenSim.Region.Environment.Scenes
296 foreach (TaskInventoryItem item in m_taskInventory.Values) 312 foreach (TaskInventoryItem item in m_taskInventory.Values)
297 { 313 {
298 invString.AddItemStart(); 314 invString.AddItemStart();
299 invString.AddNameValueLine("item_id", item.item_id.ToString()); 315 invString.AddNameValueLine("item_id", item.ItemID.ToString());
300 invString.AddNameValueLine("parent_id", item.parent_id.ToString()); 316 invString.AddNameValueLine("parent_id", item.ParentID.ToString());
301 317
302 invString.AddPermissionsStart(); 318 invString.AddPermissionsStart();
303 invString.AddNameValueLine("base_mask", "0x7FFFFFFF"); 319 invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
@@ -305,19 +321,19 @@ namespace OpenSim.Region.Environment.Scenes
305 invString.AddNameValueLine("group_mask", "0x7FFFFFFF"); 321 invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
306 invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF"); 322 invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
307 invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF"); 323 invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
308 invString.AddNameValueLine("creator_id", item.creator_id.ToString()); 324 invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
309 invString.AddNameValueLine("owner_id", item.owner_id.ToString()); 325 invString.AddNameValueLine("owner_id", item.OwnerID.ToString());
310 invString.AddNameValueLine("last_owner_id", item.last_owner_id.ToString()); 326 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
311 invString.AddNameValueLine("group_id", item.group_id.ToString()); 327 invString.AddNameValueLine("group_id", item.GroupID.ToString());
312 invString.AddSectionEnd(); 328 invString.AddSectionEnd();
313 329
314 invString.AddNameValueLine("asset_id", item.asset_id.ToString()); 330 invString.AddNameValueLine("asset_id", item.AssetID.ToString());
315 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.type]); 331 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
316 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.inv_type]); 332 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
317 invString.AddNameValueLine("flags", "0x00"); 333 invString.AddNameValueLine("flags", "0x00");
318 invString.AddNameValueLine("name", item.name + "|"); 334 invString.AddNameValueLine("name", item.Name + "|");
319 invString.AddNameValueLine("desc", item.desc + "|"); 335 invString.AddNameValueLine("desc", item.Description + "|");
320 invString.AddNameValueLine("creation_date", item.creation_date.ToString()); 336 invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
321 invString.AddSectionEnd(); 337 invString.AddSectionEnd();
322 } 338 }
323 339