diff options
author | Justin Clarke Casey | 2008-11-21 21:16:42 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-11-21 21:16:42 +0000 |
commit | 915593bfbc2f0d6729efe4dfe8d4c8a3f0fc9fbe (patch) | |
tree | 1f62bf777f73c4f3fffb2f5237cd7e5eaeddcb6f /OpenSim/Region/Environment/Scenes/SceneObjectPartInventory.cs | |
parent | * Extend sog delete to inventory test to crank the normally async sog deleter... (diff) | |
download | opensim-SC_OLD-915593bfbc2f0d6729efe4dfe8d4c8a3f0fc9fbe.zip opensim-SC_OLD-915593bfbc2f0d6729efe4dfe8d4c8a3f0fc9fbe.tar.gz opensim-SC_OLD-915593bfbc2f0d6729efe4dfe8d4c8a3f0fc9fbe.tar.bz2 opensim-SC_OLD-915593bfbc2f0d6729efe4dfe8d4c8a3f0fc9fbe.tar.xz |
* refactor: Rip out SOP inventory from the partial into a separate class
* SceneObjectPartInventory.cs isn't a particularly good name but it's probably not got a long life
* A proper inventory interface to follow
* Parallel changes for other inventory partial classes to follow at a later date
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPartInventory.cs (renamed from OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs) | 240 |
1 files changed, 133 insertions, 107 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPartInventory.cs index ba638e5..0a6f22c 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPartInventory.cs | |||
@@ -38,12 +38,17 @@ using OpenSim.Region.Environment.Scenes.Scripting; | |||
38 | 38 | ||
39 | namespace OpenSim.Region.Environment.Scenes | 39 | namespace OpenSim.Region.Environment.Scenes |
40 | { | 40 | { |
41 | public partial class SceneObjectPart : IScriptHost | 41 | public class SceneObjectPartInventory |
42 | { | 42 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 44 | ||
45 | private string m_inventoryFileName = String.Empty; | 45 | private string m_inventoryFileName = String.Empty; |
46 | private int m_inventoryFileNameSerial = 0; | 46 | private int m_inventoryFileNameSerial = 0; |
47 | |||
48 | /// <value> | ||
49 | /// The part to which the inventory belongs. | ||
50 | /// </value> | ||
51 | private SceneObjectPart m_part; | ||
47 | 52 | ||
48 | /// <summary> | 53 | /// <summary> |
49 | /// Serial count for inventory file , used to tell if inventory has changed | 54 | /// Serial count for inventory file , used to tell if inventory has changed |
@@ -54,12 +59,41 @@ namespace OpenSim.Region.Environment.Scenes | |||
54 | /// <summary> | 59 | /// <summary> |
55 | /// Holds in memory prim inventory | 60 | /// Holds in memory prim inventory |
56 | /// </summary> | 61 | /// </summary> |
57 | protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary(); | 62 | protected TaskInventoryDictionary m_items = new TaskInventoryDictionary(); |
58 | 63 | ||
59 | /// <summary> | 64 | /// <summary> |
60 | /// Tracks whether inventory has changed since the last persistent backup | 65 | /// Tracks whether inventory has changed since the last persistent backup |
61 | /// </summary> | 66 | /// </summary> |
62 | protected bool HasInventoryChanged; | 67 | protected bool HasInventoryChanged; |
68 | |||
69 | /// <value> | ||
70 | /// Inventory serial number | ||
71 | /// </value> | ||
72 | public uint Serial | ||
73 | { | ||
74 | get { return m_inventorySerial; } | ||
75 | set { m_inventorySerial = value; } | ||
76 | } | ||
77 | |||
78 | /// <value> | ||
79 | /// Raw inventory data | ||
80 | /// </value> | ||
81 | public TaskInventoryDictionary Items | ||
82 | { | ||
83 | get { return m_items; } | ||
84 | set { m_items = value; } | ||
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// Constructor | ||
89 | /// </summary> | ||
90 | /// <param name="part"> | ||
91 | /// A <see cref="SceneObjectPart"/> | ||
92 | /// </param> | ||
93 | public SceneObjectPartInventory(SceneObjectPart part) | ||
94 | { | ||
95 | m_part = part; | ||
96 | } | ||
63 | 97 | ||
64 | /// <summary> | 98 | /// <summary> |
65 | /// Force the task inventory of this prim to persist at the next update sweep | 99 | /// Force the task inventory of this prim to persist at the next update sweep |
@@ -67,7 +101,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
67 | public void ForceInventoryPersistence() | 101 | public void ForceInventoryPersistence() |
68 | { | 102 | { |
69 | HasInventoryChanged = true; | 103 | HasInventoryChanged = true; |
70 | } | 104 | } |
71 | 105 | ||
72 | /// <summary> | 106 | /// <summary> |
73 | /// Reset UUIDs for all the items in the prim's inventory. This involves either generating | 107 | /// Reset UUIDs for all the items in the prim's inventory. This involves either generating |
@@ -78,40 +112,40 @@ namespace OpenSim.Region.Environment.Scenes | |||
78 | /// <param name="linkNum">Link number for the part</param> | 112 | /// <param name="linkNum">Link number for the part</param> |
79 | public void ResetInventoryIDs() | 113 | public void ResetInventoryIDs() |
80 | { | 114 | { |
81 | lock (TaskInventory) | 115 | lock (Items) |
82 | { | 116 | { |
83 | if (0 == TaskInventory.Count) | 117 | if (0 == Items.Count) |
84 | return; | 118 | return; |
85 | 119 | ||
86 | HasInventoryChanged = true; | 120 | HasInventoryChanged = true; |
87 | ParentGroup.HasGroupChanged = true; | 121 | m_part.ParentGroup.HasGroupChanged = true; |
88 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values); | 122 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
89 | TaskInventory.Clear(); | 123 | Items.Clear(); |
90 | 124 | ||
91 | foreach (TaskInventoryItem item in items) | 125 | foreach (TaskInventoryItem item in items) |
92 | { | 126 | { |
93 | item.ResetIDs(UUID); | 127 | item.ResetIDs(m_part.UUID); |
94 | TaskInventory.Add(item.ItemID, item); | 128 | Items.Add(item.ItemID, item); |
95 | } | 129 | } |
96 | } | 130 | } |
97 | } | 131 | } |
98 | 132 | ||
99 | /// <summary> | 133 | /// <summary> |
100 | /// Change every item in this prim's inventory to a new owner. | 134 | /// Change every item in this inventory to a new owner. |
101 | /// </summary> | 135 | /// </summary> |
102 | /// <param name="ownerId"></param> | 136 | /// <param name="ownerId"></param> |
103 | public void ChangeInventoryOwner(UUID ownerId) | 137 | public void ChangeInventoryOwner(UUID ownerId) |
104 | { | 138 | { |
105 | lock (TaskInventory) | 139 | lock (Items) |
106 | { | 140 | { |
107 | if (0 == TaskInventory.Count) | 141 | if (0 == Items.Count) |
108 | { | 142 | { |
109 | return; | 143 | return; |
110 | } | 144 | } |
111 | 145 | ||
112 | HasInventoryChanged = true; | 146 | HasInventoryChanged = true; |
113 | ParentGroup.HasGroupChanged = true; | 147 | m_part.ParentGroup.HasGroupChanged = true; |
114 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values); | 148 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
115 | foreach (TaskInventoryItem item in items) | 149 | foreach (TaskInventoryItem item in items) |
116 | { | 150 | { |
117 | if (ownerId != item.OwnerID) | 151 | if (ownerId != item.OwnerID) |
@@ -123,18 +157,22 @@ namespace OpenSim.Region.Environment.Scenes | |||
123 | } | 157 | } |
124 | } | 158 | } |
125 | 159 | ||
160 | /// <summary> | ||
161 | /// Change every item in this inventory to a new group. | ||
162 | /// </summary> | ||
163 | /// <param name="groupID"></param> | ||
126 | public void ChangeInventoryGroup(UUID groupID) | 164 | public void ChangeInventoryGroup(UUID groupID) |
127 | { | 165 | { |
128 | lock (TaskInventory) | 166 | lock (Items) |
129 | { | 167 | { |
130 | if (0 == TaskInventory.Count) | 168 | if (0 == Items.Count) |
131 | { | 169 | { |
132 | return; | 170 | return; |
133 | } | 171 | } |
134 | 172 | ||
135 | HasInventoryChanged = true; | 173 | HasInventoryChanged = true; |
136 | ParentGroup.HasGroupChanged = true; | 174 | m_part.ParentGroup.HasGroupChanged = true; |
137 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values); | 175 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
138 | foreach (TaskInventoryItem item in items) | 176 | foreach (TaskInventoryItem item in items) |
139 | { | 177 | { |
140 | if (groupID != item.GroupID) | 178 | if (groupID != item.GroupID) |
@@ -150,9 +188,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
150 | /// </summary> | 188 | /// </summary> |
151 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 189 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
152 | { | 190 | { |
153 | lock (m_taskInventory) | 191 | lock (m_items) |
154 | { | 192 | { |
155 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 193 | foreach (TaskInventoryItem item in Items.Values) |
156 | { | 194 | { |
157 | if ((int)InventoryType.LSL == item.InvType) | 195 | if ((int)InventoryType.LSL == item.InvType) |
158 | { | 196 | { |
@@ -167,14 +205,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
167 | /// </summary> | 205 | /// </summary> |
168 | public void RemoveScriptInstances() | 206 | public void RemoveScriptInstances() |
169 | { | 207 | { |
170 | lock (m_taskInventory) | 208 | lock (Items) |
171 | { | 209 | { |
172 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 210 | foreach (TaskInventoryItem item in Items.Values) |
173 | { | 211 | { |
174 | if ((int)InventoryType.LSL == item.InvType) | 212 | if ((int)InventoryType.LSL == item.InvType) |
175 | { | 213 | { |
176 | RemoveScriptInstance(item.ItemID); | 214 | RemoveScriptInstance(item.ItemID); |
177 | RemoveScriptEvents(item.ItemID); | 215 | m_part.RemoveScriptEvents(item.ItemID); |
178 | } | 216 | } |
179 | } | 217 | } |
180 | } | 218 | } |
@@ -192,14 +230,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
192 | // "Starting script {0}, {1} in prim {2}, {3}", | 230 | // "Starting script {0}, {1} in prim {2}, {3}", |
193 | // item.Name, item.ItemID, Name, UUID); | 231 | // item.Name, item.ItemID, Name, UUID); |
194 | 232 | ||
195 | if (!m_parentGroup.Scene.ExternalChecks.ExternalChecksCanRunScript(item.ItemID, UUID, item.OwnerID)) | 233 | if (!m_part.ParentGroup.Scene.ExternalChecks.ExternalChecksCanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) |
196 | return; | 234 | return; |
197 | 235 | ||
198 | AddFlag(PrimFlags.Scripted); | 236 | m_part.AddFlag(PrimFlags.Scripted); |
199 | 237 | ||
200 | if (!m_parentGroup.Scene.RegionInfo.RegionSettings.DisableScripts) | 238 | if (!m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts) |
201 | { | 239 | { |
202 | AssetCache cache = m_parentGroup.Scene.AssetCache; | 240 | AssetCache cache = m_part.ParentGroup.Scene.AssetCache; |
203 | 241 | ||
204 | cache.GetAsset(item.AssetID, delegate(UUID assetID, AssetBase asset) | 242 | cache.GetAsset(item.AssetID, delegate(UUID assetID, AssetBase asset) |
205 | { | 243 | { |
@@ -212,13 +250,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
212 | } | 250 | } |
213 | else | 251 | else |
214 | { | 252 | { |
215 | m_taskInventory[item.ItemID].PermsMask = 0; | 253 | m_items[item.ItemID].PermsMask = 0; |
216 | m_taskInventory[item.ItemID].PermsGranter = UUID.Zero; | 254 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
217 | string script = Utils.BytesToString(asset.Data); | 255 | string script = Utils.BytesToString(asset.Data); |
218 | m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId, item.ItemID, script, | 256 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
219 | startParam, postOnRez, engine, stateSource); | 257 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
220 | m_parentGroup.AddActiveScriptCount(1); | 258 | m_part.ParentGroup.AddActiveScriptCount(1); |
221 | ScheduleFullUpdate(); | 259 | m_part.ScheduleFullUpdate(); |
222 | } | 260 | } |
223 | }, false); | 261 | }, false); |
224 | } | 262 | } |
@@ -232,18 +270,18 @@ namespace OpenSim.Region.Environment.Scenes | |||
232 | /// </param> | 270 | /// </param> |
233 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 271 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
234 | { | 272 | { |
235 | lock (m_taskInventory) | 273 | lock (m_items) |
236 | { | 274 | { |
237 | if (m_taskInventory.ContainsKey(itemId)) | 275 | if (m_items.ContainsKey(itemId)) |
238 | { | 276 | { |
239 | CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez, engine, stateSource); | 277 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); |
240 | } | 278 | } |
241 | else | 279 | else |
242 | { | 280 | { |
243 | m_log.ErrorFormat( | 281 | m_log.ErrorFormat( |
244 | "[PRIM INVENTORY]: " + | 282 | "[PRIM INVENTORY]: " + |
245 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", | 283 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", |
246 | itemId, Name, UUID); | 284 | itemId, m_part.Name, m_part.UUID); |
247 | } | 285 | } |
248 | } | 286 | } |
249 | } | 287 | } |
@@ -254,17 +292,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
254 | /// <param name="itemId"></param> | 292 | /// <param name="itemId"></param> |
255 | public void RemoveScriptInstance(UUID itemId) | 293 | public void RemoveScriptInstance(UUID itemId) |
256 | { | 294 | { |
257 | if (m_taskInventory.ContainsKey(itemId)) | 295 | if (m_items.ContainsKey(itemId)) |
258 | { | 296 | { |
259 | m_parentGroup.Scene.EventManager.TriggerRemoveScript(LocalId, itemId); | 297 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemId); |
260 | m_parentGroup.AddActiveScriptCount(-1); | 298 | m_part.ParentGroup.AddActiveScriptCount(-1); |
261 | } | 299 | } |
262 | else | 300 | else |
263 | { | 301 | { |
264 | m_log.ErrorFormat( | 302 | m_log.ErrorFormat( |
265 | "[PRIM INVENTORY]: " + | 303 | "[PRIM INVENTORY]: " + |
266 | "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2}", | 304 | "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2}", |
267 | itemId, Name, UUID); | 305 | itemId, m_part.Name, m_part.UUID); |
268 | } | 306 | } |
269 | } | 307 | } |
270 | 308 | ||
@@ -276,7 +314,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
276 | /// <returns></returns> | 314 | /// <returns></returns> |
277 | private bool InventoryContainsName(string name) | 315 | private bool InventoryContainsName(string name) |
278 | { | 316 | { |
279 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 317 | foreach (TaskInventoryItem item in Items.Values) |
280 | { | 318 | { |
281 | if (item.Name == name) | 319 | if (item.Name == name) |
282 | return true; | 320 | return true; |
@@ -322,7 +360,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
322 | /// <param name="item"></param> | 360 | /// <param name="item"></param> |
323 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 361 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
324 | { | 362 | { |
325 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_taskInventory.Values); | 363 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); |
326 | foreach (TaskInventoryItem i in il) | 364 | foreach (TaskInventoryItem i in il) |
327 | { | 365 | { |
328 | if (i.Name == item.Name) | 366 | if (i.Name == item.Name) |
@@ -355,24 +393,24 @@ namespace OpenSim.Region.Environment.Scenes | |||
355 | if (name == String.Empty) | 393 | if (name == String.Empty) |
356 | return; | 394 | return; |
357 | 395 | ||
358 | item.ParentID = UUID; | 396 | item.ParentID = m_part.UUID; |
359 | item.ParentPartID = UUID; | 397 | item.ParentPartID = m_part.UUID; |
360 | item.Name = name; | 398 | item.Name = name; |
361 | 399 | ||
362 | lock (m_taskInventory) | 400 | lock (m_items) |
363 | { | 401 | { |
364 | m_taskInventory.Add(item.ItemID, item); | 402 | m_items.Add(item.ItemID, item); |
365 | 403 | ||
366 | if (allowedDrop) | 404 | if (allowedDrop) |
367 | TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 405 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
368 | else | 406 | else |
369 | TriggerScriptChangedEvent(Changed.INVENTORY); | 407 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
370 | } | 408 | } |
371 | 409 | ||
372 | m_inventorySerial++; | 410 | m_inventorySerial++; |
373 | //m_inventorySerial += 2; | 411 | //m_inventorySerial += 2; |
374 | HasInventoryChanged = true; | 412 | HasInventoryChanged = true; |
375 | ParentGroup.HasGroupChanged = true; | 413 | m_part.ParentGroup.HasGroupChanged = true; |
376 | } | 414 | } |
377 | 415 | ||
378 | /// <summary> | 416 | /// <summary> |
@@ -384,12 +422,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
384 | /// <param name="items"></param> | 422 | /// <param name="items"></param> |
385 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 423 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
386 | { | 424 | { |
387 | lock (m_taskInventory) | 425 | lock (m_items) |
388 | { | 426 | { |
389 | foreach (TaskInventoryItem item in items) | 427 | foreach (TaskInventoryItem item in items) |
390 | { | 428 | { |
391 | m_taskInventory.Add(item.ItemID, item); | 429 | m_items.Add(item.ItemID, item); |
392 | TriggerScriptChangedEvent(Changed.INVENTORY); | 430 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
393 | } | 431 | } |
394 | } | 432 | } |
395 | 433 | ||
@@ -404,7 +442,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
404 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 442 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
405 | { | 443 | { |
406 | TaskInventoryItem item; | 444 | TaskInventoryItem item; |
407 | m_taskInventory.TryGetValue(itemId, out item); | 445 | m_items.TryGetValue(itemId, out item); |
408 | 446 | ||
409 | return item; | 447 | return item; |
410 | } | 448 | } |
@@ -417,22 +455,20 @@ namespace OpenSim.Region.Environment.Scenes | |||
417 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> | 455 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> |
418 | public bool UpdateInventoryItem(TaskInventoryItem item) | 456 | public bool UpdateInventoryItem(TaskInventoryItem item) |
419 | { | 457 | { |
420 | lock (m_taskInventory) | 458 | lock (m_items) |
421 | { | 459 | { |
422 | if (m_taskInventory.ContainsKey(item.ItemID)) | 460 | if (m_items.ContainsKey(item.ItemID)) |
423 | { | 461 | { |
424 | item.ParentID = UUID; | 462 | item.ParentID = m_part.UUID; |
425 | item.ParentPartID = UUID; | 463 | item.ParentPartID = m_part.UUID; |
426 | item.Flags=m_taskInventory[item.ItemID].Flags; | 464 | item.Flags = m_items[item.ItemID].Flags; |
427 | if (item.AssetID == UUID.Zero) | 465 | if (item.AssetID == UUID.Zero) |
428 | { | 466 | { |
429 | item.AssetID = m_taskInventory[item.ItemID].AssetID; | 467 | item.AssetID = m_items[item.ItemID].AssetID; |
430 | } | 468 | } |
431 | else if ((InventoryType)item.Type == InventoryType.Notecard) | 469 | else if ((InventoryType)item.Type == InventoryType.Notecard) |
432 | { | 470 | { |
433 | ScenePresence presence = | 471 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); |
434 | m_parentGroup.Scene.GetScenePresence( | ||
435 | item.OwnerID); | ||
436 | 472 | ||
437 | if (presence != null) | 473 | if (presence != null) |
438 | { | 474 | { |
@@ -441,12 +477,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
441 | } | 477 | } |
442 | } | 478 | } |
443 | 479 | ||
444 | m_taskInventory[item.ItemID] = item; | 480 | m_items[item.ItemID] = item; |
445 | m_inventorySerial++; | 481 | m_inventorySerial++; |
446 | TriggerScriptChangedEvent(Changed.INVENTORY); | 482 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
447 | 483 | ||
448 | HasInventoryChanged = true; | 484 | HasInventoryChanged = true; |
449 | ParentGroup.HasGroupChanged = true; | 485 | m_part.ParentGroup.HasGroupChanged = true; |
450 | 486 | ||
451 | return true; | 487 | return true; |
452 | } | 488 | } |
@@ -455,18 +491,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
455 | m_log.ErrorFormat( | 491 | m_log.ErrorFormat( |
456 | "[PRIM INVENTORY]: " + | 492 | "[PRIM INVENTORY]: " + |
457 | "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | 493 | "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", |
458 | item.ItemID, Name, UUID); | 494 | item.ItemID, m_part.Name, m_part.UUID); |
459 | } | 495 | } |
460 | } | 496 | } |
461 | 497 | ||
462 | return false; | 498 | return false; |
463 | } | 499 | } |
464 | 500 | ||
465 | public void AddScriptLPS(int count) | ||
466 | { | ||
467 | m_parentGroup.AddScriptLPS(count); | ||
468 | } | ||
469 | |||
470 | /// <summary> | 501 | /// <summary> |
471 | /// Remove an item from this prim's inventory | 502 | /// Remove an item from this prim's inventory |
472 | /// </summary> | 503 | /// </summary> |
@@ -475,37 +506,36 @@ namespace OpenSim.Region.Environment.Scenes | |||
475 | /// in this prim's inventory.</returns> | 506 | /// in this prim's inventory.</returns> |
476 | public int RemoveInventoryItem(UUID itemID) | 507 | public int RemoveInventoryItem(UUID itemID) |
477 | { | 508 | { |
478 | lock (m_taskInventory) | 509 | lock (m_items) |
479 | { | 510 | { |
480 | if (m_taskInventory.ContainsKey(itemID)) | 511 | if (m_items.ContainsKey(itemID)) |
481 | { | 512 | { |
482 | int type = m_taskInventory[itemID].InvType; | 513 | int type = m_items[itemID].InvType; |
483 | m_taskInventory.Remove(itemID); | 514 | m_items.Remove(itemID); |
484 | m_inventorySerial++; | 515 | m_inventorySerial++; |
485 | TriggerScriptChangedEvent(Changed.INVENTORY); | 516 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
486 | 517 | ||
487 | HasInventoryChanged = true; | 518 | HasInventoryChanged = true; |
488 | ParentGroup.HasGroupChanged = true; | 519 | m_part.ParentGroup.HasGroupChanged = true; |
489 | 520 | ||
490 | int scriptcount = 0; | 521 | int scriptcount = 0; |
491 | lock (m_taskInventory) | 522 | lock (m_items) |
492 | { | 523 | { |
493 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 524 | foreach (TaskInventoryItem item in m_items.Values) |
494 | { | 525 | { |
495 | if (item.Type == 10) | 526 | if (item.Type == 10) |
496 | { | 527 | { |
497 | scriptcount++; | 528 | scriptcount++; |
498 | } | 529 | } |
499 | } | 530 | } |
500 | |||
501 | } | 531 | } |
502 | 532 | ||
503 | if (scriptcount <= 0) | 533 | if (scriptcount <= 0) |
504 | { | 534 | { |
505 | RemFlag(PrimFlags.Scripted); | 535 | m_part.RemFlag(PrimFlags.Scripted); |
506 | } | 536 | } |
507 | 537 | ||
508 | ScheduleFullUpdate(); | 538 | m_part.ScheduleFullUpdate(); |
509 | 539 | ||
510 | return type; | 540 | return type; |
511 | } | 541 | } |
@@ -514,7 +544,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
514 | m_log.ErrorFormat( | 544 | m_log.ErrorFormat( |
515 | "[PRIM INVENTORY]: " + | 545 | "[PRIM INVENTORY]: " + |
516 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | 546 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", |
517 | itemID, Name, UUID); | 547 | itemID, m_part.Name, m_part.UUID); |
518 | } | 548 | } |
519 | } | 549 | } |
520 | 550 | ||
@@ -545,13 +575,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
545 | 575 | ||
546 | if (m_inventorySerial > 0) | 576 | if (m_inventorySerial > 0) |
547 | { | 577 | { |
548 | client.SendTaskInventory(m_uuid, (short)m_inventorySerial, | 578 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, |
549 | Utils.StringToBytes(GetInventoryFileName())); | 579 | Utils.StringToBytes(GetInventoryFileName())); |
550 | return true; | 580 | return true; |
551 | } | 581 | } |
552 | else | 582 | else |
553 | { | 583 | { |
554 | client.SendTaskInventory(m_uuid, 0, new byte[0]); | 584 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); |
555 | return false; | 585 | return false; |
556 | } | 586 | } |
557 | } | 587 | } |
@@ -567,11 +597,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
567 | // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches | 597 | // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches |
568 | // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality | 598 | // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality |
569 | // isn't available (such as drag from prim inventory to agent inventory) | 599 | // isn't available (such as drag from prim inventory to agent inventory) |
570 | InventoryStringBuilder invString = new InventoryStringBuilder(UUID, UUID.Zero); | 600 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
571 | 601 | ||
572 | lock (m_taskInventory) | 602 | lock (m_items) |
573 | { | 603 | { |
574 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 604 | foreach (TaskInventoryItem item in m_items.Values) |
575 | { | 605 | { |
576 | UUID ownerID = item.OwnerID; | 606 | UUID ownerID = item.OwnerID; |
577 | uint everyoneMask = 0; | 607 | uint everyoneMask = 0; |
@@ -580,7 +610,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
580 | 610 | ||
581 | invString.AddItemStart(); | 611 | invString.AddItemStart(); |
582 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 612 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
583 | invString.AddNameValueLine("parent_id", UUID.ToString()); | 613 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); |
584 | 614 | ||
585 | invString.AddPermissionsStart(); | 615 | invString.AddPermissionsStart(); |
586 | 616 | ||
@@ -635,9 +665,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
635 | { | 665 | { |
636 | if (HasInventoryChanged) | 666 | if (HasInventoryChanged) |
637 | { | 667 | { |
638 | lock (TaskInventory) | 668 | lock (Items) |
639 | { | 669 | { |
640 | datastore.StorePrimInventory(UUID, TaskInventory.Values); | 670 | datastore.StorePrimInventory(m_part.UUID, Items.Values); |
641 | } | 671 | } |
642 | 672 | ||
643 | HasInventoryChanged = false; | 673 | HasInventoryChanged = false; |
@@ -707,7 +737,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
707 | { | 737 | { |
708 | uint mask=0x7fffffff; | 738 | uint mask=0x7fffffff; |
709 | 739 | ||
710 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 740 | foreach (TaskInventoryItem item in m_items.Values) |
711 | { | 741 | { |
712 | if (item.InvType != 6) | 742 | if (item.InvType != 6) |
713 | { | 743 | { |
@@ -740,11 +770,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
740 | 770 | ||
741 | public void ApplyNextOwnerPermissions() | 771 | public void ApplyNextOwnerPermissions() |
742 | { | 772 | { |
743 | _baseMask &= _nextOwnerMask; | 773 | foreach (TaskInventoryItem item in m_items.Values) |
744 | _ownerMask &= _nextOwnerMask; | ||
745 | _everyoneMask &= _nextOwnerMask; | ||
746 | |||
747 | foreach (TaskInventoryItem item in m_taskInventory.Values) | ||
748 | { | 774 | { |
749 | if (item.InvType == 6 && (item.CurrentPermissions & 7) != 0) | 775 | if (item.InvType == 6 && (item.CurrentPermissions & 7) != 0) |
750 | { | 776 | { |
@@ -760,12 +786,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
760 | item.EveryonePermissions &= item.NextPermissions; | 786 | item.EveryonePermissions &= item.NextPermissions; |
761 | } | 787 | } |
762 | 788 | ||
763 | TriggerScriptChangedEvent(Changed.OWNER); | 789 | m_part.TriggerScriptChangedEvent(Changed.OWNER); |
764 | } | 790 | } |
765 | 791 | ||
766 | public void ApplyGodPermissions(uint perms) | 792 | public void ApplyGodPermissions(uint perms) |
767 | { | 793 | { |
768 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 794 | foreach (TaskInventoryItem item in m_items.Values) |
769 | { | 795 | { |
770 | item.CurrentPermissions = perms; | 796 | item.CurrentPermissions = perms; |
771 | item.BasePermissions = perms; | 797 | item.BasePermissions = perms; |
@@ -774,7 +800,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
774 | 800 | ||
775 | public bool ContainsScripts() | 801 | public bool ContainsScripts() |
776 | { | 802 | { |
777 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 803 | foreach (TaskInventoryItem item in m_items.Values) |
778 | { | 804 | { |
779 | if (item.InvType == 10) | 805 | if (item.InvType == 10) |
780 | { | 806 | { |
@@ -788,7 +814,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
788 | { | 814 | { |
789 | List<UUID> ret = new List<UUID>(); | 815 | List<UUID> ret = new List<UUID>(); |
790 | 816 | ||
791 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 817 | foreach (TaskInventoryItem item in m_items.Values) |
792 | ret.Add(item.ItemID); | 818 | ret.Add(item.ItemID); |
793 | 819 | ||
794 | return ret; | 820 | return ret; |
@@ -796,11 +822,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
796 | 822 | ||
797 | public string[] GetScriptAssemblies() | 823 | public string[] GetScriptAssemblies() |
798 | { | 824 | { |
799 | IScriptModule[] engines = m_parentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 825 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
800 | 826 | ||
801 | List<string> ret = new List<string>(); | 827 | List<string> ret = new List<string>(); |
802 | 828 | ||
803 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 829 | foreach (TaskInventoryItem item in m_items.Values) |
804 | { | 830 | { |
805 | if (item.InvType == 10) | 831 | if (item.InvType == 10) |
806 | { | 832 | { |
@@ -821,10 +847,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
821 | 847 | ||
822 | public Dictionary<UUID, string> GetScriptStates() | 848 | public Dictionary<UUID, string> GetScriptStates() |
823 | { | 849 | { |
824 | IScriptModule[] engines = m_parentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 850 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
825 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 851 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
826 | 852 | ||
827 | foreach (TaskInventoryItem item in m_taskInventory.Values) | 853 | foreach (TaskInventoryItem item in m_items.Values) |
828 | { | 854 | { |
829 | if (item.InvType == 10) | 855 | if (item.InvType == 10) |
830 | { | 856 | { |