From abaf8e7a370f0ba932412232504d906507b2d745 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 31 May 2008 21:20:04 +0000 Subject: [PATCH] * Put in preparatory code to restore whole prim textures on archive load * No user functionality yet --- .../World/Archiver/ArchiveConstants.cs | 7 ++++- .../World/Archiver/ArchiveReadRequest.cs | 27 ++++++++++++++++++- .../World/Archiver/ArchiveWriteRequest.cs | 4 ++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs index 7df6033e5c..d98814bc8b 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs @@ -35,7 +35,12 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver /// /// Path for the assets held in an archive /// - public static readonly string ASSETS_PATH = "assets/"; + public static readonly string ASSETS_PATH = "assets/"; + + /// + /// Extension used for texture assets in archive + /// + public static readonly string TEXTURE_EXTENSION = ".jp2"; /// /// Path for the prims file diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index d3f0cbc6de..6ad9fb8301 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs @@ -25,11 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Modules.World.Serialiser; using System; using System.IO; using System.Reflection; +using libsecondlife; using log4net; namespace OpenSim.Region.Environment.Modules.World.Archiver @@ -66,12 +68,35 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver byte[] data; while ((data = archive.ReadEntry(out filePath)) != null) { - m_log.DebugFormat("[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath); + m_log.DebugFormat( + "[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath); if (filePath.Equals(ArchiveConstants.PRIMS_PATH)) { serializedPrims = m_asciiEncoding.GetString(data); } + /* + else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) + { + // Right now we're nastily obtaining the lluuid from the filename + string rawId = filePath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); + rawId = rawId.Remove(rawId.Length - ArchiveConstants.TEXTURE_EXTENSION.Length); + + m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", rawId); + + // Not preserving asset name or description as of yet + AssetBase asset = new AssetBase(new LLUUID(rawId), "imported name"); + asset.Description = "imported description"; + + // Only importing textures right now + asset.Type = (sbyte)AssetType.Texture; + asset.InvType = (sbyte)InventoryType.Texture; + + asset.Data = data; + + m_scene.AssetCache.AddAsset(asset); + } + */ } m_log.DebugFormat("[ARCHIVER]: Reached end of archive"); diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs index d936df5642..c9a7f07376 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs @@ -112,7 +112,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver { if (assets[uuid] != null) { - archive.AddFile(ArchiveConstants.ASSETS_PATH + uuid.ToString() + ".jp2", assets[uuid].Data); + archive.AddFile( + ArchiveConstants.ASSETS_PATH + uuid.ToString() + ArchiveConstants.TEXTURE_EXTENSION, + assets[uuid].Data); } else {