diff options
author | Melanie | 2012-02-02 01:52:17 +0000 |
---|---|---|
committer | Melanie | 2012-02-02 01:52:17 +0000 |
commit | 567f4c51f85e61205c8b1caaab207bc6f979f04f (patch) | |
tree | 1b56fcc63de25d7c6c8fc0739843381bd1a7662e /OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |
parent | Small optimization to last commit (diff) | |
download | opensim-SC_OLD-567f4c51f85e61205c8b1caaab207bc6f979f04f.zip opensim-SC_OLD-567f4c51f85e61205c8b1caaab207bc6f979f04f.tar.gz opensim-SC_OLD-567f4c51f85e61205c8b1caaab207bc6f979f04f.tar.bz2 opensim-SC_OLD-567f4c51f85e61205c8b1caaab207bc6f979f04f.tar.xz |
Improve reliability of script state saving by covering various saving
and loading scenarios which resulted in loss of continuity on item ids
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index daddb90..0c36dcd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -307,14 +307,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
307 | else | 307 | else |
308 | { | 308 | { |
309 | if (m_part.ParentGroup.m_savedScriptState != null) | 309 | if (m_part.ParentGroup.m_savedScriptState != null) |
310 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 310 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); |
311 | 311 | ||
312 | lock (m_items) | 312 | lock (m_items) |
313 | { | 313 | { |
314 | m_items[item.ItemID].OldItemID = item.OldItemID; | ||
314 | m_items[item.ItemID].PermsMask = 0; | 315 | m_items[item.ItemID].PermsMask = 0; |
315 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 316 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
316 | } | 317 | } |
317 | 318 | ||
318 | string script = Utils.BytesToString(asset.Data); | 319 | string script = Utils.BytesToString(asset.Data); |
319 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 320 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
320 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 321 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
@@ -324,17 +325,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
324 | } | 325 | } |
325 | } | 326 | } |
326 | 327 | ||
327 | private void RestoreSavedScriptState(UUID oldID, UUID newID) | 328 | private UUID RestoreSavedScriptState(UUID loadedID, UUID oldID, UUID newID) |
328 | { | 329 | { |
329 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 330 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
330 | if (engines.Length == 0) // No engine at all | 331 | if (engines.Length == 0) // No engine at all |
331 | return; | 332 | return oldID; |
332 | 333 | ||
333 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) | 334 | UUID stateID = oldID; |
335 | if (!m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) | ||
336 | stateID = loadedID; | ||
337 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(stateID)) | ||
334 | { | 338 | { |
335 | XmlDocument doc = new XmlDocument(); | 339 | XmlDocument doc = new XmlDocument(); |
336 | 340 | ||
337 | doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]); | 341 | doc.LoadXml(m_part.ParentGroup.m_savedScriptState[stateID]); |
338 | 342 | ||
339 | ////////// CRUFT WARNING /////////////////////////////////// | 343 | ////////// CRUFT WARNING /////////////////////////////////// |
340 | // | 344 | // |
@@ -351,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
351 | 355 | ||
352 | XmlElement rootN = newDoc.CreateElement("", "State", ""); | 356 | XmlElement rootN = newDoc.CreateElement("", "State", ""); |
353 | XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", ""); | 357 | XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", ""); |
354 | uuidA.Value = oldID.ToString(); | 358 | uuidA.Value = stateID.ToString(); |
355 | rootN.Attributes.Append(uuidA); | 359 | rootN.Attributes.Append(uuidA); |
356 | XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", ""); | 360 | XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", ""); |
357 | engineA.Value = "XEngine"; | 361 | engineA.Value = "XEngine"; |
@@ -365,20 +369,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
365 | // This created document has only the minimun data | 369 | // This created document has only the minimun data |
366 | // necessary for XEngine to parse it successfully | 370 | // necessary for XEngine to parse it successfully |
367 | 371 | ||
368 | m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; | 372 | m_part.ParentGroup.m_savedScriptState[stateID] = newDoc.OuterXml; |
369 | } | 373 | } |
370 | 374 | ||
371 | foreach (IScriptModule e in engines) | 375 | foreach (IScriptModule e in engines) |
372 | { | 376 | { |
373 | if (e != null) | 377 | if (e != null) |
374 | { | 378 | { |
375 | if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) | 379 | if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[stateID])) |
376 | break; | 380 | break; |
377 | } | 381 | } |
378 | } | 382 | } |
379 | 383 | ||
380 | m_part.ParentGroup.m_savedScriptState.Remove(oldID); | 384 | m_part.ParentGroup.m_savedScriptState.Remove(stateID); |
381 | } | 385 | } |
386 | |||
387 | return stateID; | ||
382 | } | 388 | } |
383 | 389 | ||
384 | /// <summary> | 390 | /// <summary> |