From 332692a07648a4fa801ddfea21681f2708f8cf66 Mon Sep 17 00:00:00 2001 From: Robin Cornelius Date: Thu, 28 Jul 2011 10:55:02 +0000 Subject: [PATCH] Add some helper code for decoding the static VFS and generating a set of asset files that can be directly used in the static asset cache (openmetaverse_data) git-svn-id: https://radegast.googlecode.com/svn/trunk@1017 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- Radegast/GUI/Rendering/RenderingHelpers.cs | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/Radegast/GUI/Rendering/RenderingHelpers.cs b/Radegast/GUI/Rendering/RenderingHelpers.cs index a22f7fd..7db6943 100644 --- a/Radegast/GUI/Rendering/RenderingHelpers.cs +++ b/Radegast/GUI/Rendering/RenderingHelpers.cs @@ -2888,4 +2888,71 @@ namespace Radegast.Rendering return Quaternion.CreateFromEulers((float)(float.Parse(rotparts[0]) * Math.PI / 180f), (float)(float.Parse(rotparts[1]) * Math.PI / 180f), (float)(float.Parse(rotparts[2]) * Math.PI / 180f)); } } + + /* + * Helper classs for reading the static VFS file, call + * staticVFS.readVFSheaders() with the path to the static_data.db2 and static_index.db2 files + * and it will pass and dump in to openmetaverse_data for you + * This should only be needed to be used if LL update the static VFS in order to refresh our data + */ + + class VFSblock + { + public int mLocation; + public int mLength; + public int mAccessTime; + public UUID mFileID; + public int mSize; + public AssetType mAssetType; + + public int readblock(byte[] blockdata, int offset) + { + + BitPack input = new BitPack(blockdata, offset); + mLocation = input.UnpackInt(); + mLength = input.UnpackInt(); + mAccessTime = input.UnpackInt(); + mFileID = input.UnpackUUID(); + int filetype = input.UnpackShort(); + mAssetType = (AssetType)filetype; + mSize = input.UnpackInt(); + offset += 34; + + Logger.Log(String.Format("Found header for {0} type {1} length {2} at {3}", mFileID, mAssetType, mSize, mLocation),Helpers.LogLevel.Info); + + return offset; + } + + } + + public class staticVFS + { + public static void readVFSheaders(string datafile, string indexfile) + { + FileStream datastream; + FileStream indexstream; + + datastream = File.Open(datafile, FileMode.Open); + indexstream = File.Open(indexfile, FileMode.Open); + + int offset=0; + + byte[] blockdata = new byte[indexstream.Length]; + indexstream.Read(blockdata, 0, (int)indexstream.Length); + + while (offset < indexstream.Length) + { + VFSblock block = new VFSblock(); + offset = block.readblock(blockdata, offset); + + FileStream writer = File.Open(OpenMetaverse.Settings.RESOURCE_DIR+System.IO.Path.DirectorySeparatorChar+block.mFileID.ToString(),FileMode.Create); + byte[] data = new byte[block.mSize]; + datastream.Seek(block.mLocation, SeekOrigin.Begin); + datastream.Read(data, 0, block.mSize); + writer.Write(data, 0, block.mSize); + writer.Close(); + } + + } + } } \ No newline at end of file -- 2.11.0