save/load environments to/from oars
parent
7b77609537
commit
8fe2cd6c46
|
@ -29,17 +29,13 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using MySql.Data.MySqlClient;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Data;
|
||||
|
||||
namespace OpenSim.Data.MySQL
|
||||
{
|
||||
|
@ -1510,9 +1506,7 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
try
|
||||
{
|
||||
OSD oenv = OSDParser.Deserialize(env);
|
||||
ViewerEnvironment VEnv = new ViewerEnvironment();
|
||||
VEnv.FromOSD(oenv);
|
||||
ViewerEnvironment VEnv = ViewerEnvironment.FromOSDString(env);
|
||||
newData.Environment = VEnv;
|
||||
newData.EnvironmentVersion = VEnv.version;
|
||||
}
|
||||
|
@ -1875,9 +1869,7 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
try
|
||||
{
|
||||
OSD oenv = land.Environment.ToOSD();
|
||||
string env = OSDParser.SerializeLLSDNotationFull(oenv);
|
||||
cmd.Parameters.AddWithValue("environment", env);
|
||||
cmd.Parameters.AddWithValue("environment", ViewerEnvironment.ToOSDString(land.Environment));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace OpenSim.Framework.Serialization
|
|||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ASSET_EXTENSION_SEPARATOR + "texture.jp2";
|
||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ASSET_EXTENSION_SEPARATOR + "texture.tga";
|
||||
ASSET_TYPE_TO_EXTENSION[(sbyte)OpenSimAssetType.Material] = ASSET_EXTENSION_SEPARATOR + "material.xml";
|
||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Settings] = ASSET_EXTENSION_SEPARATOR + "settings.bin";
|
||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Settings] = ASSET_EXTENSION_SEPARATOR + "settings.dat";
|
||||
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "animation.bvh"] = (sbyte)AssetType.Animation;
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bodypart.txt"] = (sbyte)AssetType.Bodypart;
|
||||
|
@ -148,7 +148,7 @@ namespace OpenSim.Framework.Serialization
|
|||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.jp2"] = (sbyte)AssetType.Texture;
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.tga"] = (sbyte)AssetType.TextureTGA;
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "material.xml"] = (sbyte)OpenSimAssetType.Material;
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "settings.bin"] = (sbyte)AssetType.Settings;
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "settings.dat"] = (sbyte)AssetType.Settings;
|
||||
}
|
||||
|
||||
public static string CreateOarLandDataPath(LandData ld)
|
||||
|
|
|
@ -28,12 +28,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Framework.Serialization.External
|
||||
{
|
||||
|
@ -99,6 +97,9 @@ namespace OpenSim.Framework.Serialization.External
|
|||
m_ldProcessors.Add(
|
||||
"ParcelAccessList", ProcessParcelAccessList);
|
||||
|
||||
m_ldProcessors.Add(
|
||||
"Environment", ProcessParcelEnvironment);
|
||||
|
||||
m_ldProcessors.Add(
|
||||
"PassHours", (ld, xtr) => ld.PassHours = Convert.ToSingle(xtr.ReadElementString("PassHours")));
|
||||
m_ldProcessors.Add(
|
||||
|
@ -132,6 +133,13 @@ namespace OpenSim.Framework.Serialization.External
|
|||
);
|
||||
m_laeProcessors.Add(
|
||||
"AccessList", (lae, xtr) => lae.Flags = (AccessList)Convert.ToUInt32(xtr.ReadElementString("AccessList")));
|
||||
|
||||
}
|
||||
|
||||
public static void ProcessParcelEnvironment(LandData ld, XmlReader xtr)
|
||||
{
|
||||
string senv = xtr.ReadElementString("Environment");
|
||||
ld.Environment = ViewerEnvironment.FromOSDString(senv);
|
||||
}
|
||||
|
||||
public static void ProcessParcelAccessList(LandData ld, XmlReader xtr)
|
||||
|
@ -255,6 +263,15 @@ namespace OpenSim.Framework.Serialization.External
|
|||
xtw.WriteElementString("Dwell", "0");
|
||||
xtw.WriteElementString("OtherCleanTime", Convert.ToString(landData.OtherCleanTime));
|
||||
|
||||
if(landData.Environment != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string senv = ViewerEnvironment.ToOSDString(landData.Environment);
|
||||
xtw.WriteElementString("Environment", senv);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
|
||||
xtw.Close();
|
||||
|
|
|
@ -46,9 +46,10 @@ namespace OpenSim.Framework.Serialization.External
|
|||
/// <param name="serializedSettings"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.Xml.XmlException"></exception>
|
||||
public static RegionSettings Deserialize(byte[] serializedSettings)
|
||||
public static RegionSettings Deserialize(byte[] serializedSettings, out ViewerEnvironment regionEnv)
|
||||
{
|
||||
return Deserialize(Encoding.ASCII.GetString(serializedSettings, 0, serializedSettings.Length));
|
||||
// encoding is wrong. old oars seem to be on utf-16
|
||||
return Deserialize(Encoding.ASCII.GetString(serializedSettings, 0, serializedSettings.Length), out regionEnv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -57,9 +58,10 @@ namespace OpenSim.Framework.Serialization.External
|
|||
/// <param name="serializedSettings"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.Xml.XmlException"></exception>
|
||||
public static RegionSettings Deserialize(string serializedSettings)
|
||||
public static RegionSettings Deserialize(string serializedSettings, out ViewerEnvironment regionEnv)
|
||||
{
|
||||
RegionSettings settings = new RegionSettings();
|
||||
regionEnv = null;
|
||||
|
||||
StringReader sr = new StringReader(serializedSettings);
|
||||
XmlTextReader xtr = new XmlTextReader(sr);
|
||||
|
@ -210,13 +212,28 @@ namespace OpenSim.Framework.Serialization.External
|
|||
}
|
||||
}
|
||||
|
||||
if (xtr.IsStartElement("Environment"))
|
||||
{
|
||||
xtr.ReadStartElement("Environment");
|
||||
|
||||
while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
|
||||
{
|
||||
switch (xtr.Name)
|
||||
{
|
||||
case "data":
|
||||
regionEnv = ViewerEnvironment.FromOSDString(xtr.ReadElementContentAsString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xtr.Close();
|
||||
sr.Close();
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static string Serialize(RegionSettings settings)
|
||||
public static string Serialize(RegionSettings settings, ViewerEnvironment RegionEnv)
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
XmlTextWriter xtw = new XmlTextWriter(sw);
|
||||
|
@ -263,8 +280,6 @@ namespace OpenSim.Framework.Serialization.External
|
|||
xtw.WriteElementString("UseEstateSun", settings.UseEstateSun.ToString());
|
||||
xtw.WriteElementString("FixedSun", settings.FixedSun.ToString());
|
||||
xtw.WriteElementString("SunPosition", settings.SunPosition.ToString());
|
||||
// Note: 'SunVector' isn't saved because this value is owned by the Sun Module, which
|
||||
// calculates it automatically according to the date and other factors.
|
||||
xtw.WriteEndElement();
|
||||
|
||||
xtw.WriteStartElement("Telehub");
|
||||
|
@ -276,6 +291,13 @@ namespace OpenSim.Framework.Serialization.External
|
|||
}
|
||||
xtw.WriteEndElement();
|
||||
|
||||
if (RegionEnv != null)
|
||||
{
|
||||
xtw.WriteStartElement("Environment");
|
||||
xtw.WriteElementString("data", ViewerEnvironment.ToOSDString(RegionEnv));
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
|
||||
xtw.WriteEndElement();
|
||||
|
||||
xtw.Close();
|
||||
|
|
|
@ -130,7 +130,7 @@ namespace OpenSim.Framework.Serialization.Tests
|
|||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
RegionSettings deserRs = RegionSettingsSerializer.Deserialize(m_serializedRs);
|
||||
RegionSettings deserRs = RegionSettingsSerializer.Deserialize(m_serializedRs, out ViewerEnvironment dummy);
|
||||
Assert.That(deserRs, Is.Not.Null);
|
||||
Assert.That(deserRs.TerrainTexture2, Is.EqualTo(m_rs.TerrainTexture2));
|
||||
Assert.That(deserRs.DisablePhysics, Is.EqualTo(m_rs.DisablePhysics));
|
||||
|
|
|
@ -3381,6 +3381,14 @@ namespace OpenSim.Framework
|
|||
return ticks * TimeStampClockPeriodMS;
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
public static void AddToGatheredIds(Dictionary<UUID, sbyte> uuids, UUID id, sbyte type)
|
||||
{
|
||||
if (id == UUID.Zero)
|
||||
return;
|
||||
uuids[id] = type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formats a duration (given in milliseconds).
|
||||
/// </summary>
|
||||
|
@ -3976,7 +3984,5 @@ namespace OpenSim.Framework
|
|||
{
|
||||
rng.GetBytes(buff);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -484,6 +484,16 @@ namespace OpenSim.Framework
|
|||
sunlight_color = otmp;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public void GatherAssets(Dictionary<UUID, sbyte> uuids)
|
||||
{
|
||||
Util.AddToGatheredIds(uuids, bloom_id, (sbyte)AssetType.Texture);
|
||||
Util.AddToGatheredIds(uuids, cloud_id, (sbyte)AssetType.Texture);
|
||||
Util.AddToGatheredIds(uuids, halo_id, (sbyte)AssetType.Texture);
|
||||
Util.AddToGatheredIds(uuids, moon_id, (sbyte)AssetType.Texture);
|
||||
Util.AddToGatheredIds(uuids, rainbow_id, (sbyte)AssetType.Texture);
|
||||
Util.AddToGatheredIds(uuids, sun_id, (sbyte)AssetType.Texture);
|
||||
}
|
||||
}
|
||||
|
||||
public class WaterData
|
||||
|
@ -599,6 +609,12 @@ namespace OpenSim.Framework
|
|||
|
||||
return map;
|
||||
}
|
||||
|
||||
public void GatherAssets(Dictionary<UUID, sbyte> uuids)
|
||||
{
|
||||
Util.AddToGatheredIds(uuids, normalMap, (sbyte)AssetType.Texture);
|
||||
Util.AddToGatheredIds(uuids, transpTexture, (sbyte)AssetType.Texture);
|
||||
}
|
||||
}
|
||||
|
||||
public class DayCycle
|
||||
|
@ -889,6 +905,18 @@ namespace OpenSim.Framework
|
|||
|
||||
return cycle;
|
||||
}
|
||||
|
||||
public void GatherAssets(Dictionary<UUID, sbyte> uuids)
|
||||
{
|
||||
foreach (WaterData wd in waterframes.Values)
|
||||
{
|
||||
wd.GatherAssets(uuids);
|
||||
}
|
||||
foreach (SkyData sd in skyframes.Values)
|
||||
{
|
||||
sd.GatherAssets(uuids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ViewerEnvironment
|
||||
|
@ -1216,6 +1244,35 @@ namespace OpenSim.Framework
|
|||
return env;
|
||||
}
|
||||
|
||||
public static ViewerEnvironment FromOSDString(string s)
|
||||
{
|
||||
try
|
||||
{
|
||||
OSD eosd = OSDParser.Deserialize(s);
|
||||
ViewerEnvironment VEnv = new ViewerEnvironment();
|
||||
VEnv.FromOSD(eosd);
|
||||
return VEnv;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string ToOSDString(ViewerEnvironment VEnv, bool xml = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
OSD eosd= VEnv.ToOSD();
|
||||
if(xml)
|
||||
return OSDParser.SerializeLLSDXmlString(eosd);
|
||||
else
|
||||
return OSDParser.SerializeLLSDNotationFull(eosd);
|
||||
}
|
||||
catch {}
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
public ViewerEnvironment Clone()
|
||||
{
|
||||
// im lazy need to proper clone later
|
||||
|
@ -1398,5 +1455,11 @@ namespace OpenSim.Framework
|
|||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
public void GatherAssets(Dictionary<UUID, sbyte> uuids)
|
||||
{
|
||||
if (Cycle != null)
|
||||
Cycle.GatherAssets(uuids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,14 +285,13 @@ namespace OpenSim.Framework
|
|||
if (tickdiff > LongCallTime)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {7} bytes ({8} uncomp): {9}",
|
||||
"[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4} bytes ({5} uncomp): {6}",
|
||||
reqnum,
|
||||
method,
|
||||
url,
|
||||
tickdiff,
|
||||
compsize,
|
||||
strBuffer != null ? strBuffer.Length : 0,
|
||||
|
||||
strBuffer != null
|
||||
? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer)
|
||||
: "");
|
||||
|
|
|
@ -1039,10 +1039,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
private bool LoadRegionSettings(Scene scene, string settingsPath, byte[] data, DearchiveScenesInfo dearchivedScenes)
|
||||
{
|
||||
RegionSettings loadedRegionSettings;
|
||||
|
||||
ViewerEnvironment regionEnv = null;
|
||||
try
|
||||
{
|
||||
loadedRegionSettings = RegionSettingsSerializer.Deserialize(data);
|
||||
loadedRegionSettings = RegionSettingsSerializer.Deserialize(data, out regionEnv);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -1051,7 +1051,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
settingsPath, e);
|
||||
return false;
|
||||
}
|
||||
|
||||
scene.RegionEnvironment = regionEnv;
|
||||
RegionSettings currentRegionSettings = scene.RegionInfo.RegionSettings;
|
||||
|
||||
currentRegionSettings.AgentLimit = loadedRegionSettings.AgentLimit;
|
||||
|
|
|
@ -321,6 +321,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
|
||||
assetUuids[regionSettings.TerrainTexture4] = (sbyte)AssetType.Texture;
|
||||
|
||||
if(scene.RegionEnvironment != null)
|
||||
scene.RegionEnvironment.GatherAssets(assetUuids);
|
||||
|
||||
List<ILandObject> landObjects = scene.LandChannel.AllParcels();
|
||||
foreach (ILandObject lo in landObjects)
|
||||
{
|
||||
if(lo.LandData != null && lo.LandData.Environment != null)
|
||||
lo.LandData.Environment.GatherAssets(assetUuids);
|
||||
}
|
||||
|
||||
Save(scene, sceneObjects, regionDir);
|
||||
GC.Collect();
|
||||
}
|
||||
|
@ -572,7 +582,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
// Write out region settings
|
||||
string settingsPath = String.Format("{0}{1}{2}.xml",
|
||||
regionDir, ArchiveConstants.SETTINGS_PATH, scene.RegionInfo.RegionName);
|
||||
m_archiveWriter.WriteFile(settingsPath, RegionSettingsSerializer.Serialize(scene.RegionInfo.RegionSettings));
|
||||
m_archiveWriter.WriteFile(settingsPath, RegionSettingsSerializer.Serialize(scene.RegionInfo.RegionSettings, scene.RegionEnvironment));
|
||||
|
||||
m_log.InfoFormat("[ARCHIVER]: Adding parcel settings to archive.");
|
||||
|
||||
|
|
|
@ -657,7 +657,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
|
|||
rs.TelehubObject = UUID.Parse("00000000-0000-0000-0000-111111111111");
|
||||
rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33"));
|
||||
|
||||
tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs));
|
||||
tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs, null));
|
||||
|
||||
tar.Close();
|
||||
|
||||
|
|
|
@ -837,6 +837,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
|
|||
return OSDParser.SerializeLLSDNotationToBytes(osddata,true);
|
||||
}
|
||||
|
||||
|
||||
public List<byte[]> MakeLightShareData()
|
||||
{
|
||||
if(m_scene.RegionEnvironment == null)
|
||||
|
|
|
@ -66,10 +66,10 @@ namespace OpenSim.Server.Handlers.Authentication
|
|||
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userService, args);
|
||||
|
||||
// Handler for OpenID user identity pages
|
||||
server.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", m_UserAccountService, m_AuthenticationService));
|
||||
server.AddStreamHandler(new OpenIdStreamHandler("GET", "/users", m_UserAccountService, m_AuthenticationService));
|
||||
// Handlers for the OpenID endpoint server
|
||||
server.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server/", m_UserAccountService, m_AuthenticationService));
|
||||
server.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", m_UserAccountService, m_AuthenticationService));
|
||||
server.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server", m_UserAccountService, m_AuthenticationService));
|
||||
server.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server", m_UserAccountService, m_AuthenticationService));
|
||||
|
||||
m_log.Info("[OPENID]: OpenId service enabled");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue