diff options
author | Diva Canto | 2009-12-21 06:59:36 -0800 |
---|---|---|
committer | Diva Canto | 2009-12-21 06:59:36 -0800 |
commit | 86104cd45c17f4112493ae1e095e44e18b3ac0be (patch) | |
tree | 0653f44e969c9620dde01e6e8248559e06acfe65 | |
parent | Making the library read the item's flag, so that clothing items can have the ... (diff) | |
parent | Script State Fix: Part 2 (diff) | |
download | opensim-SC-86104cd45c17f4112493ae1e095e44e18b3ac0be.zip opensim-SC-86104cd45c17f4112493ae1e095e44e18b3ac0be.tar.gz opensim-SC-86104cd45c17f4112493ae1e095e44e18b3ac0be.tar.bz2 opensim-SC-86104cd45c17f4112493ae1e095e44e18b3ac0be.tar.xz |
Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim
Diffstat (limited to '')
4 files changed, 79 insertions, 27 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index f11e571..98efcbe 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs | |||
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
35 | string ScriptEngineName { get; } | 35 | string ScriptEngineName { get; } |
36 | 36 | ||
37 | string GetXMLState(UUID itemID); | 37 | string GetXMLState(UUID itemID); |
38 | void SetXMLState(UUID itemID, string xml); | 38 | bool SetXMLState(UUID itemID, string xml); |
39 | 39 | ||
40 | bool PostScriptEvent(UUID itemID, string name, Object[] args); | 40 | bool PostScriptEvent(UUID itemID, string name, Object[] args); |
41 | bool PostObjectEvent(UUID itemID, string name, Object[] args); | 41 | bool PostObjectEvent(UUID itemID, string name, Object[] args); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index eb284c1..f79eb5d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1314,7 +1314,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1314 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1314 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1315 | maintc = (int)(m_timespan * 1000) - maintc; | 1315 | maintc = (int)(m_timespan * 1000) - maintc; |
1316 | 1316 | ||
1317 | if ((maintc < (m_timespan * 1000)) && maintc > 0) | 1317 | if (maintc > 0) |
1318 | Thread.Sleep(maintc); | 1318 | Thread.Sleep(maintc); |
1319 | 1319 | ||
1320 | // Tell the watchdog that this thread is still alive | 1320 | // Tell the watchdog that this thread is still alive |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 22eedba..47e4ad0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml; | ||
29 | using System.IO; | 30 | using System.IO; |
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -283,15 +284,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
283 | 284 | ||
284 | private void RestoreSavedScriptState(UUID oldID, UUID newID) | 285 | private void RestoreSavedScriptState(UUID oldID, UUID newID) |
285 | { | 286 | { |
287 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
288 | if (engines == null) // No engine at all | ||
289 | return; | ||
290 | |||
286 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) | 291 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) |
287 | { | 292 | { |
288 | string fpath = Path.Combine("ScriptEngines/"+m_part.ParentGroup.Scene.RegionInfo.RegionID.ToString(), | 293 | XmlDocument doc = new XmlDocument(); |
289 | newID.ToString()+".state"); | 294 | |
290 | FileStream fs = File.Create(fpath); | 295 | doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]); |
291 | Byte[] buffer = enc.GetBytes(m_part.ParentGroup.m_savedScriptState[oldID]); | 296 | |
292 | fs.Write(buffer,0,buffer.Length); | 297 | ////////// CRUFT WARNING /////////////////////////////////// |
293 | fs.Close(); | 298 | // |
294 | m_part.ParentGroup.m_savedScriptState.Remove(oldID); | 299 | // Old objects will have <ScriptState><State> ... |
300 | // This format is XEngine ONLY | ||
301 | // | ||
302 | // New objects have <State Engine="...." ...><ScriptState>... | ||
303 | // This can be passed to any engine | ||
304 | // | ||
305 | XmlNode n = doc.SelectSingleNode("ScriptState"); | ||
306 | if (n != null) // Old format data | ||
307 | { | ||
308 | XmlDocument newDoc = new XmlDocument(); | ||
309 | |||
310 | XmlElement rootN = newDoc.CreateElement("", "State", ""); | ||
311 | XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", ""); | ||
312 | uuidA.Value = oldID.ToString(); | ||
313 | rootN.Attributes.Append(uuidA); | ||
314 | XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", ""); | ||
315 | engineA.Value = "XEngine"; | ||
316 | rootN.Attributes.Append(engineA); | ||
317 | |||
318 | newDoc.AppendChild(rootN); | ||
319 | |||
320 | XmlNode stateN = newDoc.ImportNode(n, true); | ||
321 | rootN.AppendChild(stateN); | ||
322 | |||
323 | // This created document has only the minimun data | ||
324 | // necessary for XEngine to parse it successfully | ||
325 | |||
326 | m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; | ||
327 | } | ||
328 | foreach (IScriptModule e in engines) | ||
329 | { | ||
330 | if (e != null) | ||
331 | { | ||
332 | if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) | ||
333 | break; | ||
334 | } | ||
335 | } | ||
295 | } | 336 | } |
296 | } | 337 | } |
297 | 338 | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 9030a5c..25a4cd6 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1266,6 +1266,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1266 | XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); | 1266 | XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); |
1267 | assetID.Value = instance.AssetID.ToString(); | 1267 | assetID.Value = instance.AssetID.ToString(); |
1268 | stateData.Attributes.Append(assetID); | 1268 | stateData.Attributes.Append(assetID); |
1269 | XmlAttribute engineName = doc.CreateAttribute("", "Engine", ""); | ||
1270 | engineName.Value = ScriptEngineName; | ||
1271 | stateData.Attributes.Append(engineName); | ||
1269 | doc.AppendChild(stateData); | 1272 | doc.AppendChild(stateData); |
1270 | 1273 | ||
1271 | // Add <ScriptState>...</ScriptState> | 1274 | // Add <ScriptState>...</ScriptState> |
@@ -1365,10 +1368,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1365 | return false; | 1368 | return false; |
1366 | } | 1369 | } |
1367 | 1370 | ||
1368 | public void SetXMLState(UUID itemID, string xml) | 1371 | public bool SetXMLState(UUID itemID, string xml) |
1369 | { | 1372 | { |
1370 | if (xml == String.Empty) | 1373 | if (xml == String.Empty) |
1371 | return; | 1374 | return false; |
1372 | 1375 | ||
1373 | XmlDocument doc = new XmlDocument(); | 1376 | XmlDocument doc = new XmlDocument(); |
1374 | 1377 | ||
@@ -1379,24 +1382,28 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1379 | catch (Exception) | 1382 | catch (Exception) |
1380 | { | 1383 | { |
1381 | m_log.Error("[XEngine]: Exception decoding XML data from region transfer"); | 1384 | m_log.Error("[XEngine]: Exception decoding XML data from region transfer"); |
1382 | return; | 1385 | return false; |
1383 | } | 1386 | } |
1384 | 1387 | ||
1385 | XmlNodeList rootL = doc.GetElementsByTagName("State"); | 1388 | XmlNodeList rootL = doc.GetElementsByTagName("State"); |
1386 | if (rootL.Count < 1) | 1389 | if (rootL.Count < 1) |
1387 | return; | 1390 | return false; |
1388 | 1391 | ||
1389 | XmlElement rootE = (XmlElement)rootL[0]; | 1392 | XmlElement rootE = (XmlElement)rootL[0]; |
1390 | 1393 | ||
1391 | if (rootE.GetAttribute("UUID") != itemID.ToString()) | 1394 | if (rootE.GetAttribute("Engine") != ScriptEngineName) |
1392 | return; | 1395 | return false; |
1393 | 1396 | ||
1394 | // string assetID = rootE.GetAttribute("Asset"); | 1397 | // On rez from inventory, that ID will have changed. It was only |
1398 | // advisory anyway. So we don't check it anymore. | ||
1399 | // | ||
1400 | // if (rootE.GetAttribute("UUID") != itemID.ToString()) | ||
1401 | // return; | ||
1395 | 1402 | ||
1396 | XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState"); | 1403 | XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState"); |
1397 | 1404 | ||
1398 | if (stateL.Count != 1) | 1405 | if (stateL.Count != 1) |
1399 | return; | 1406 | return false; |
1400 | 1407 | ||
1401 | XmlElement stateE = (XmlElement)stateL[0]; | 1408 | XmlElement stateE = (XmlElement)stateL[0]; |
1402 | 1409 | ||
@@ -1405,7 +1412,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1405 | XmlNodeList assemL = rootE.GetElementsByTagName("Assembly"); | 1412 | XmlNodeList assemL = rootE.GetElementsByTagName("Assembly"); |
1406 | 1413 | ||
1407 | if (assemL.Count != 1) | 1414 | if (assemL.Count != 1) |
1408 | return; | 1415 | return false; |
1409 | 1416 | ||
1410 | XmlElement assemE = (XmlElement)assemL[0]; | 1417 | XmlElement assemE = (XmlElement)assemL[0]; |
1411 | 1418 | ||
@@ -1445,19 +1452,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1445 | sfs.Close(); | 1452 | sfs.Close(); |
1446 | 1453 | ||
1447 | XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); | 1454 | XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); |
1448 | 1455 | if (mapL.Count > 0) | |
1449 | XmlElement mapE = (XmlElement)mapL[0]; | 1456 | { |
1457 | XmlElement mapE = (XmlElement)mapL[0]; | ||
1450 | 1458 | ||
1451 | string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | 1459 | string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); |
1452 | mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); | 1460 | mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); |
1453 | 1461 | ||
1454 | FileStream mfs = File.Create(mappath); | 1462 | FileStream mfs = File.Create(mappath); |
1455 | StreamWriter msw = new StreamWriter(mfs); | 1463 | StreamWriter msw = new StreamWriter(mfs); |
1456 | 1464 | ||
1457 | msw.Write(mapE.InnerText); | 1465 | msw.Write(mapE.InnerText); |
1458 | 1466 | ||
1459 | msw.Close(); | 1467 | msw.Close(); |
1460 | mfs.Close(); | 1468 | mfs.Close(); |
1469 | } | ||
1470 | |||
1471 | return true; | ||
1461 | } | 1472 | } |
1462 | } | 1473 | } |
1463 | } | 1474 | } |