diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 124 |
1 files changed, 116 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 4dc6cb8..2fc2ea1 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1328,6 +1328,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1328 | } | 1328 | } |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | string map = String.Empty; | ||
1332 | |||
1333 | if (File.Exists(fn + ".map")) | ||
1334 | { | ||
1335 | FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read); | ||
1336 | StreamReader msr = new StreamReader(mfs); | ||
1337 | |||
1338 | map = msr.ReadToEnd(); | ||
1339 | |||
1340 | msr.Close(); | ||
1341 | mfs.Close(); | ||
1342 | } | ||
1343 | |||
1331 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); | 1344 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); |
1332 | XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); | 1345 | XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); |
1333 | 1346 | ||
@@ -1338,21 +1351,116 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1338 | 1351 | ||
1339 | stateData.AppendChild(assemblyData); | 1352 | stateData.AppendChild(assemblyData); |
1340 | 1353 | ||
1341 | return doc.InnerXml; | 1354 | XmlElement mapData = doc.CreateElement("", "LineMap", ""); |
1342 | } | 1355 | XmlAttribute mapName = doc.CreateAttribute("", "Filename", ""); |
1343 | 1356 | ||
1344 | public bool CanBeDeleted(UUID itemID) | 1357 | mapName.Value = fn + ".map"; |
1345 | { | 1358 | mapData.Attributes.Append(mapName); |
1346 | IScriptInstance instance = GetInstance(itemID); | ||
1347 | if (instance == null) | ||
1348 | return true; | ||
1349 | 1359 | ||
1350 | return instance.CanBeDeleted(); | 1360 | mapData.InnerText = map; |
1361 | |||
1362 | stateData.AppendChild(mapData); | ||
1363 | return doc.InnerXml; | ||
1351 | } | 1364 | } |
1352 | 1365 | ||
1353 | private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled) | 1366 | private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled) |
1354 | { | 1367 | { |
1355 | return false; | 1368 | return false; |
1356 | } | 1369 | } |
1370 | |||
1371 | public void SetXMLState(UUID itemID, string xml) | ||
1372 | { | ||
1373 | if (xml == String.Empty) | ||
1374 | return; | ||
1375 | |||
1376 | XmlDocument doc = new XmlDocument(); | ||
1377 | |||
1378 | try | ||
1379 | { | ||
1380 | doc.LoadXml(xml); | ||
1381 | } | ||
1382 | catch (Exception) | ||
1383 | { | ||
1384 | m_log.Error("[XEngine]: Exception decoding XML data from region transfer"); | ||
1385 | return; | ||
1386 | } | ||
1387 | |||
1388 | XmlNodeList rootL = doc.GetElementsByTagName("State"); | ||
1389 | if (rootL.Count < 1) | ||
1390 | return; | ||
1391 | |||
1392 | XmlElement rootE = (XmlElement)rootL[0]; | ||
1393 | |||
1394 | if (rootE.GetAttribute("UUID") != itemID.ToString()) | ||
1395 | return; | ||
1396 | |||
1397 | string assetID = rootE.GetAttribute("Asset"); | ||
1398 | |||
1399 | XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState"); | ||
1400 | |||
1401 | if (stateL.Count != 1) | ||
1402 | return; | ||
1403 | |||
1404 | XmlElement stateE = (XmlElement)stateL[0]; | ||
1405 | |||
1406 | if (World.m_trustBinaries) | ||
1407 | { | ||
1408 | XmlNodeList assemL = rootE.GetElementsByTagName("Assembly"); | ||
1409 | |||
1410 | if (assemL.Count != 1) | ||
1411 | return; | ||
1412 | |||
1413 | XmlElement assemE = (XmlElement)assemL[0]; | ||
1414 | |||
1415 | string fn = assemE.GetAttribute("Filename"); | ||
1416 | string base64 = assemE.InnerText; | ||
1417 | |||
1418 | string path = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | ||
1419 | path = Path.Combine(path, fn); | ||
1420 | |||
1421 | if (!File.Exists(path)) | ||
1422 | { | ||
1423 | Byte[] filedata = Convert.FromBase64String(base64); | ||
1424 | |||
1425 | FileStream fs = File.Create(path); | ||
1426 | fs.Write(filedata, 0, filedata.Length); | ||
1427 | fs.Close(); | ||
1428 | |||
1429 | fs = File.Create(path + ".text"); | ||
1430 | StreamWriter sw = new StreamWriter(fs); | ||
1431 | |||
1432 | sw.Write(base64); | ||
1433 | |||
1434 | sw.Close(); | ||
1435 | fs.Close(); | ||
1436 | } | ||
1437 | } | ||
1438 | |||
1439 | string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | ||
1440 | statepath = Path.Combine(statepath, itemID.ToString() + ".state"); | ||
1441 | |||
1442 | FileStream sfs = File.Create(statepath); | ||
1443 | StreamWriter ssw = new StreamWriter(sfs); | ||
1444 | |||
1445 | ssw.Write(stateE.OuterXml); | ||
1446 | |||
1447 | ssw.Close(); | ||
1448 | sfs.Close(); | ||
1449 | |||
1450 | XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); | ||
1451 | |||
1452 | XmlElement mapE = (XmlElement)mapL[0]; | ||
1453 | |||
1454 | string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | ||
1455 | mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); | ||
1456 | |||
1457 | FileStream mfs = File.Create(mappath); | ||
1458 | StreamWriter msw = new StreamWriter(mfs); | ||
1459 | |||
1460 | msw.Write(mapE.InnerText); | ||
1461 | |||
1462 | msw.Close(); | ||
1463 | mfs.Close(); | ||
1464 | } | ||
1357 | } | 1465 | } |
1358 | } | 1466 | } |