aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
diff options
context:
space:
mode:
authorUbitUmarov2017-06-10 02:48:51 +0100
committerUbitUmarov2017-06-10 02:48:51 +0100
commitb5910cfdb7461d523e2dc34dc9f33fe096766525 (patch)
treec8fa1bfd77c9b77f636117b953422f2cf66c0c07 /OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
parentMerge branch 'master' into httptests (diff)
parentadd a adicional in transit flag to signal HG tps, and use it to ignore userna... (diff)
downloadopensim-SC-b5910cfdb7461d523e2dc34dc9f33fe096766525.zip
opensim-SC-b5910cfdb7461d523e2dc34dc9f33fe096766525.tar.gz
opensim-SC-b5910cfdb7461d523e2dc34dc9f33fe096766525.tar.bz2
opensim-SC-b5910cfdb7461d523e2dc34dc9f33fe096766525.tar.xz
merge
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs121
1 files changed, 65 insertions, 56 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 60efc04..d8f2b80 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -91,7 +91,8 @@ namespace OpenSim.Region.Framework.Scenes
91 /// </value> 91 /// </value>
92 protected internal TaskInventoryDictionary Items 92 protected internal TaskInventoryDictionary Items
93 { 93 {
94 get { 94 get
95 {
95 return m_items; 96 return m_items;
96 } 97 }
97 set 98 set
@@ -141,45 +142,53 @@ namespace OpenSim.Region.Framework.Scenes
141 /// </remarks> 142 /// </remarks>
142 public void ResetInventoryIDs() 143 public void ResetInventoryIDs()
143 { 144 {
144 if (null == m_part) 145 if (m_part == null)
145 m_items.LockItemsForWrite(true); 146 return;
146 147
147 if (Items.Count == 0) 148 m_items.LockItemsForWrite(true);
149 if (m_items.Count == 0)
148 { 150 {
149 m_items.LockItemsForWrite(false); 151 m_items.LockItemsForWrite(false);
150 return; 152 return;
151 } 153 }
152 154
153 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 155 UUID partID = m_part.UUID;
154 Items.Clear(); 156 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(m_items.Values);
157 m_items.Clear();
155 158
156 foreach (TaskInventoryItem item in items) 159 foreach (TaskInventoryItem item in items)
157 { 160 {
158 item.ResetIDs(m_part.UUID); 161 item.ResetIDs(partID);
159 Items.Add(item.ItemID, item); 162 m_items.Add(item.ItemID, item);
160 } 163 }
164 m_inventorySerial++;
161 m_items.LockItemsForWrite(false); 165 m_items.LockItemsForWrite(false);
162 } 166 }
163 167
164 public void ResetObjectID() 168 public void ResetObjectID()
165 { 169 {
170 if (m_part == null)
171 return;
172
166 m_items.LockItemsForWrite(true); 173 m_items.LockItemsForWrite(true);
167 174
168 if (Items.Count == 0) 175 if (m_items.Count == 0)
169 { 176 {
170 m_items.LockItemsForWrite(false); 177 m_items.LockItemsForWrite(false);
171 return; 178 return;
172 } 179 }
173 180
174 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 181 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(m_items.Values);
175 Items.Clear(); 182 m_items.Clear();
176 183
184 UUID partID = m_part.UUID;
177 foreach (TaskInventoryItem item in items) 185 foreach (TaskInventoryItem item in items)
178 { 186 {
179 item.ParentPartID = m_part.UUID; 187 item.ParentPartID = partID;
180 item.ParentID = m_part.UUID; 188 item.ParentID = partID;
181 Items.Add(item.ItemID, item); 189 m_items.Add(item.ItemID, item);
182 } 190 }
191 m_inventorySerial++;
183 m_items.LockItemsForWrite(false); 192 m_items.LockItemsForWrite(false);
184 } 193 }
185 194
@@ -189,15 +198,17 @@ namespace OpenSim.Region.Framework.Scenes
189 /// <param name="ownerId"></param> 198 /// <param name="ownerId"></param>
190 public void ChangeInventoryOwner(UUID ownerId) 199 public void ChangeInventoryOwner(UUID ownerId)
191 { 200 {
192 List<TaskInventoryItem> items = GetInventoryItems(); 201 if(m_part == null)
193
194 if (items.Count == 0)
195 return; 202 return;
196 203
197 m_items.LockItemsForWrite(true); 204 m_items.LockItemsForWrite(true);
198 HasInventoryChanged = true; 205 if (m_items.Count == 0)
199 m_part.ParentGroup.HasGroupChanged = true; 206 {
200 foreach (TaskInventoryItem item in items) 207 m_items.LockItemsForWrite(false);
208 return;
209 }
210
211 foreach (TaskInventoryItem item in m_items.Values)
201 { 212 {
202 if (ownerId != item.OwnerID) 213 if (ownerId != item.OwnerID)
203 item.LastOwnerID = item.OwnerID; 214 item.LastOwnerID = item.OwnerID;
@@ -207,6 +218,8 @@ namespace OpenSim.Region.Framework.Scenes
207 item.PermsGranter = UUID.Zero; 218 item.PermsGranter = UUID.Zero;
208 item.OwnerChanged = true; 219 item.OwnerChanged = true;
209 } 220 }
221 HasInventoryChanged = true;
222 m_part.ParentGroup.HasGroupChanged = true;
210 m_inventorySerial++; 223 m_inventorySerial++;
211 m_items.LockItemsForWrite(false); 224 m_items.LockItemsForWrite(false);
212 } 225 }
@@ -217,8 +230,11 @@ namespace OpenSim.Region.Framework.Scenes
217 /// <param name="groupID"></param> 230 /// <param name="groupID"></param>
218 public void ChangeInventoryGroup(UUID groupID) 231 public void ChangeInventoryGroup(UUID groupID)
219 { 232 {
233 if(m_part == null)
234 return;
235
220 m_items.LockItemsForWrite(true); 236 m_items.LockItemsForWrite(true);
221 if (0 == Items.Count) 237 if (m_items.Count == 0)
222 { 238 {
223 m_items.LockItemsForWrite(false); 239 m_items.LockItemsForWrite(false);
224 return; 240 return;
@@ -233,11 +249,9 @@ namespace OpenSim.Region.Framework.Scenes
233 m_part.ParentGroup.HasGroupChanged = true; 249 m_part.ParentGroup.HasGroupChanged = true;
234 } 250 }
235 251
236 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 252 foreach (TaskInventoryItem item in m_items.Values)
237 foreach (TaskInventoryItem item in items)
238 {
239 item.GroupID = groupID; 253 item.GroupID = groupID;
240 } 254
241 m_items.LockItemsForWrite(false); 255 m_items.LockItemsForWrite(false);
242 } 256 }
243 257
@@ -246,8 +260,8 @@ namespace OpenSim.Region.Framework.Scenes
246 if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) 260 if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null)
247 return; 261 return;
248 262
249 Items.LockItemsForRead(true); 263 m_items.LockItemsForRead(true);
250 foreach (TaskInventoryItem item in Items.Values) 264 foreach (TaskInventoryItem item in m_items.Values)
251 { 265 {
252 if (item.InvType == (int)InventoryType.LSL) 266 if (item.InvType == (int)InventoryType.LSL)
253 { 267 {
@@ -257,7 +271,7 @@ namespace OpenSim.Region.Framework.Scenes
257 } 271 }
258 } 272 }
259 273
260 Items.LockItemsForRead(false); 274 m_items.LockItemsForRead(false);
261 } 275 }
262 276
263 public bool TryGetScriptInstanceRunning(UUID itemId, out bool running) 277 public bool TryGetScriptInstanceRunning(UUID itemId, out bool running)
@@ -345,7 +359,9 @@ namespace OpenSim.Region.Framework.Scenes
345 /// </summary> 359 /// </summary>
346 public void StopScriptInstances() 360 public void StopScriptInstances()
347 { 361 {
348 GetInventoryItems(InventoryType.LSL).ForEach(i => StopScriptInstance(i)); 362 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
363 foreach (TaskInventoryItem item in scripts)
364 StopScriptInstance(item);
349 } 365 }
350 366
351 /// <summary> 367 /// <summary>
@@ -807,7 +823,6 @@ namespace OpenSim.Region.Framework.Scenes
807 823
808 m_part.AggregateInnerPerms(); 824 m_part.AggregateInnerPerms();
809 m_inventorySerial++; 825 m_inventorySerial++;
810 //m_inventorySerial += 2;
811 HasInventoryChanged = true; 826 HasInventoryChanged = true;
812 m_part.ParentGroup.HasGroupChanged = true; 827 m_part.ParentGroup.HasGroupChanged = true;
813 } 828 }
@@ -1126,18 +1141,18 @@ namespace OpenSim.Region.Framework.Scenes
1126 { 1141 {
1127 bool changed = false; 1142 bool changed = false;
1128 1143
1129 Items.LockItemsForRead(true); 1144 m_items.LockItemsForRead(true);
1130 1145
1131 if (m_inventorySerial == 0) // No inventory 1146 if (m_inventorySerial == 0) // No inventory
1132 { 1147 {
1133 Items.LockItemsForRead(false); 1148 m_items.LockItemsForRead(false);
1134 client.SendTaskInventory(m_part.UUID, 0, new byte[0]); 1149 client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
1135 return; 1150 return;
1136 } 1151 }
1137 1152
1138 if (m_items.Count == 0) // No inventory 1153 if (m_items.Count == 0) // No inventory
1139 { 1154 {
1140 Items.LockItemsForRead(false); 1155 m_items.LockItemsForRead(false);
1141 client.SendTaskInventory(m_part.UUID, 0, new byte[0]); 1156 client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
1142 return; 1157 return;
1143 } 1158 }
@@ -1148,7 +1163,7 @@ namespace OpenSim.Region.Framework.Scenes
1148 changed = true; 1163 changed = true;
1149 } 1164 }
1150 1165
1151 Items.LockItemsForRead(false); 1166 m_items.LockItemsForRead(false);
1152 1167
1153 if (m_inventoryFileData.Length < 2) 1168 if (m_inventoryFileData.Length < 2)
1154 changed = true; 1169 changed = true;
@@ -1173,7 +1188,7 @@ namespace OpenSim.Region.Framework.Scenes
1173 1188
1174 InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); 1189 InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
1175 1190
1176 Items.LockItemsForRead(true); 1191 m_items.LockItemsForRead(true);
1177 1192
1178 foreach (TaskInventoryItem item in m_items.Values) 1193 foreach (TaskInventoryItem item in m_items.Values)
1179 { 1194 {
@@ -1234,7 +1249,7 @@ namespace OpenSim.Region.Framework.Scenes
1234 invString.AddSectionEnd(); 1249 invString.AddSectionEnd();
1235 } 1250 }
1236 1251
1237 Items.LockItemsForRead(false); 1252 m_items.LockItemsForRead(false);
1238 1253
1239 m_inventoryFileData = Utils.StringToBytes(invString.GetString()); 1254 m_inventoryFileData = Utils.StringToBytes(invString.GetString());
1240 1255
@@ -1264,10 +1279,10 @@ namespace OpenSim.Region.Framework.Scenes
1264// of prim inventory loss. 1279// of prim inventory loss.
1265// if (HasInventoryChanged) 1280// if (HasInventoryChanged)
1266// { 1281// {
1267 Items.LockItemsForRead(true); 1282 m_items.LockItemsForRead(true);
1268 ICollection<TaskInventoryItem> itemsvalues = Items.Values; 1283 ICollection<TaskInventoryItem> itemsvalues = m_items.Values;
1269 HasInventoryChanged = false; 1284 HasInventoryChanged = false;
1270 Items.LockItemsForRead(false); 1285 m_items.LockItemsForRead(false);
1271 try 1286 try
1272 { 1287 {
1273 datastore.StorePrimInventory(m_part.UUID, itemsvalues); 1288 datastore.StorePrimInventory(m_part.UUID, itemsvalues);
@@ -1434,15 +1449,13 @@ namespace OpenSim.Region.Framework.Scenes
1434 public int ScriptCount() 1449 public int ScriptCount()
1435 { 1450 {
1436 int count = 0; 1451 int count = 0;
1437 Items.LockItemsForRead(true); 1452 m_items.LockItemsForRead(true);
1438 foreach (TaskInventoryItem item in m_items.Values) 1453 foreach (TaskInventoryItem item in m_items.Values)
1439 { 1454 {
1440 if (item.InvType == (int)InventoryType.LSL) 1455 if (item.InvType == (int)InventoryType.LSL)
1441 {
1442 count++; 1456 count++;
1443 } 1457 }
1444 } 1458 m_items.LockItemsForRead(false);
1445 Items.LockItemsForRead(false);
1446 return count; 1459 return count;
1447 } 1460 }
1448 /// <summary> 1461 /// <summary>
@@ -1465,48 +1478,44 @@ namespace OpenSim.Region.Framework.Scenes
1465 if (engine != null) 1478 if (engine != null)
1466 { 1479 {
1467 if (engine.GetScriptState(item.ItemID)) 1480 if (engine.GetScriptState(item.ItemID))
1468 {
1469 count++; 1481 count++;
1470 } 1482 }
1471 } 1483 }
1472 } 1484 }
1473 }
1474 return count; 1485 return count;
1475 } 1486 }
1476 1487
1477 public List<UUID> GetInventoryList() 1488 public List<UUID> GetInventoryList()
1478 { 1489 {
1479 List<UUID> ret = new List<UUID>(); 1490 m_items.LockItemsForRead(true);
1480 1491
1492 List<UUID> ret = new List<UUID>(m_items.Count);
1481 foreach (TaskInventoryItem item in m_items.Values) 1493 foreach (TaskInventoryItem item in m_items.Values)
1482 ret.Add(item.ItemID); 1494 ret.Add(item.ItemID);
1483 1495
1496 m_items.LockItemsForRead(false);
1484 return ret; 1497 return ret;
1485 } 1498 }
1486 1499
1487 public List<TaskInventoryItem> GetInventoryItems() 1500 public List<TaskInventoryItem> GetInventoryItems()
1488 { 1501 {
1489 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1502 m_items.LockItemsForRead(true);
1490 1503 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(m_items.Values);
1491 Items.LockItemsForRead(true); 1504 m_items.LockItemsForRead(false);
1492 ret = new List<TaskInventoryItem>(m_items.Values);
1493 Items.LockItemsForRead(false);
1494 1505
1495 return ret; 1506 return ret;
1496 } 1507 }
1497 1508
1498 public List<TaskInventoryItem> GetInventoryItems(InventoryType type) 1509 public List<TaskInventoryItem> GetInventoryItems(InventoryType type)
1499 { 1510 {
1500 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1511 m_items.LockItemsForRead(true);
1501
1502 Items.LockItemsForRead(true);
1503 1512
1513 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(m_items.Count);
1504 foreach (TaskInventoryItem item in m_items.Values) 1514 foreach (TaskInventoryItem item in m_items.Values)
1505 if (item.InvType == (int)type) 1515 if (item.InvType == (int)type)
1506 ret.Add(item); 1516 ret.Add(item);
1507 1517
1508 Items.LockItemsForRead(false); 1518 m_items.LockItemsForRead(false);
1509
1510 return ret; 1519 return ret;
1511 } 1520 }
1512 1521