From 09297af80ed2359abfd0fb447637b438a5ed2d43 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 4 Jan 2021 05:48:33 +0100 Subject: [PATCH] read config --- prebuild.xml | 17 ++-- src/GetRegionTextures.cs | 40 +++++++++- src/IDTools.cs | 168 --------------------------------------- src/SceneObjectGroup.cs | 85 -------------------- 4 files changed, 44 insertions(+), 266 deletions(-) delete mode 100644 src/IDTools.cs delete mode 100644 src/SceneObjectGroup.cs diff --git a/prebuild.xml b/prebuild.xml index 4b291a6..305b6a6 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -2,18 +2,18 @@ - ../../bin/ + ../../../bin/ true - ../../bin/ + ../../../bin/ true - ../../bin/ + ../../../bin/ @@ -21,12 +21,11 @@ - - - - - - + + + + + diff --git a/src/GetRegionTextures.cs b/src/GetRegionTextures.cs index afb6666..01ca567 100644 --- a/src/GetRegionTextures.cs +++ b/src/GetRegionTextures.cs @@ -2,7 +2,6 @@ using Nini.Config; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Services.Connectors; using OpenSim.Services.Interfaces; using System; using System.Collections.Generic; @@ -19,7 +18,7 @@ namespace GetRegionTextures class GetRegionTextures { private static MySqlConnection m_mySQLConnection = null; - private static String m_assetURL = "http://172.21.0.150:5738/assets/"; + private static String m_assetURL = "http://127.0.0.1:8002/assets/"; private static List m_assets = new List(); @@ -60,20 +59,53 @@ namespace GetRegionTextures return returnData; } + public static Stream GenerateStreamFromString(string s) + { + var stream = new MemoryStream(); + var writer = new StreamWriter(stream); + writer.Write(s); + writer.Flush(); + stream.Position = 0; + return stream; + } static void Main(string[] args) { - if (!File.Exists("config-include/GridCommon.ini")) + if(File.Exists("ffmpeg.exe")) + { + Console.WriteLine("Cant find ffmpeg.exe"); + Console.ReadLine(); return; + } - IConfigSource source = new IniConfigSource("config-include/GridCommon.ini"); + String config = ""; + + if (File.Exists("OpenSim.ini")) + config += File.ReadAllText("OpenSim.ini") + "\n"; + + if (File.Exists("config-include/GridCommon.ini")) + config += File.ReadAllText("config-include/GridCommon.ini") + "\n"; + + IConfigSource source = new IniConfigSource(GenerateStreamFromString(config)); + source.ExpandKeyValues(); if (source.Configs["DatabaseService"] == null) return; + if (source.Configs["HGAssetService"] == null) + return; + + if (source.Configs["DatabaseService"].GetString("ConnectionString", null) == null) return; + if (source.Configs["HGAssetService"].GetString("HomeURI", "http://127.0.0.1:8002") == null) + return; + + m_assetURL = source.Configs["HGAssetService"].GetString("HomeURI", "http://127.0.0.1:8002") + "/assets/"; + + Console.WriteLine("AssetServer URL: " + m_assetURL); + m_mySQLConnection = new MySqlConnection(source.Configs["DatabaseService"].GetString("ConnectionString", null)); m_mySQLConnection.Open(); diff --git a/src/IDTools.cs b/src/IDTools.cs deleted file mode 100644 index 2a62152..0000000 --- a/src/IDTools.cs +++ /dev/null @@ -1,168 +0,0 @@ -using OpenMetaverse; -using OpenMetaverse.Assets; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; - -namespace GetRegionTextures -{ - class IDTools - { - public static void addToList(ref List _list, List _input) - { - foreach (String _entry in _input) - { - addToList(ref _list, _entry); - } - } - - public static void addToList(ref List _list, List _input) - { - foreach (TaskInventoryItemElement _entry in _input) - { - addToList(ref _list, _entry.AssetID.UUID); - } - } - - public static void addToList(ref List _list, String _input) - { - if (_input == "00000000-0000-0000-0000-000000000000") - return; - - if (_input == null) - return; - - if (!_list.Contains(_input)) - _list.Add(_input); - } - - public static List getUUIDListFromTexturEntry(String _base64) - { - List _ausgabe = new List(); - try - { - PrimObject obj = new PrimObject(); - - byte[] teData = Convert.FromBase64String(_base64); - obj.Textures = new Primitive.TextureEntry(teData, 0, teData.Length); - - foreach (Primitive.TextureEntryFace _face in obj.Textures.FaceTextures) - { - if (_face != null) - { - _ausgabe.Add(_face.TextureID.ToString()); - } - } - } - catch(Exception error) - { - Console.WriteLine("Cant decode textur data: " + error.Message); - } - return _ausgabe; - } - - public static List getUUIDListFromString(String _xml) - { - AppDomain.CurrentDomain.SetData("REGEX_DEFAULT_MATCH_TIMEOUT", TimeSpan.FromSeconds(10)); - List _ausgabe = new List(); - String _regex = @"[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}"; - - try - { - Regex _suche = new Regex(_regex); - MatchCollection _funde = _suche.Matches(_xml); - - foreach (Match _f in _funde) - { - String _value = _f.Value.ToUpper().Trim(); - if (_value.Length < 75 && _value.Length > 10) - { - if (!_ausgabe.Contains(_value)) - { - _ausgabe.Add(_value); - } - } - } - } - catch (Exception _e) - { - Console.WriteLine(_e.ToString()); - Thread.Sleep(1000); - } - - return _ausgabe; - } - - - public static List getIDListFromSceneObjectGroup(SceneObjectGroup _group) - { - List _returnList = new List(); - - if (_group.RootPart.SceneObjectPart.CollisionSound != null) - { - if (_group.RootPart.SceneObjectPart.CollisionSound.UUID != null) - addToList(ref _returnList, _group.RootPart.SceneObjectPart.CollisionSound.UUID); - } - - if (_group.RootPart.SceneObjectPart.SoundID != null) - { - if (_group.RootPart.SceneObjectPart.SoundID.UUID != null) - addToList(ref _returnList, _group.RootPart.SceneObjectPart.SoundID.UUID); - } - - if (_group.RootPart.SceneObjectPart.Shape.SculptTexture != null) - { - if (_group.RootPart.SceneObjectPart.Shape.SculptTexture.UUID != null) - addToList(ref _returnList, _group.RootPart.SceneObjectPart.Shape.SculptTexture.UUID); - } - - if (_group.RootPart.SceneObjectPart.Shape != null) - { - if (_group.RootPart.SceneObjectPart.Shape.TextureEntry != null) - addToList(ref _returnList, getUUIDListFromTexturEntry(_group.RootPart.SceneObjectPart.Shape.TextureEntry)); - } - - if (_group.RootPart.SceneObjectPart.TaskInventory != null) - addToList(ref _returnList, _group.RootPart.SceneObjectPart.TaskInventory); - - if (_group.OtherParts != null) - { - foreach (PartElement _sope in _group.OtherParts) - { - if (_sope.SceneObjectPart.CollisionSound != null) - { - if (_sope.SceneObjectPart.CollisionSound.UUID != null) - addToList(ref _returnList, _sope.SceneObjectPart.CollisionSound.UUID); - } - - if (_sope.SceneObjectPart.SoundID != null) - { - if (_sope.SceneObjectPart.SoundID.UUID != null) - addToList(ref _returnList, _sope.SceneObjectPart.SoundID.UUID); - } - - if (_sope.SceneObjectPart.Shape.SculptTexture != null) - { - if (_sope.SceneObjectPart.Shape.SculptTexture.UUID != null) - addToList(ref _returnList, _sope.SceneObjectPart.Shape.SculptTexture.UUID); - } - - if (_sope.SceneObjectPart.Shape != null) - { - if (_sope.SceneObjectPart.Shape.TextureEntry != null) - addToList(ref _returnList, getUUIDListFromTexturEntry(_sope.SceneObjectPart.Shape.TextureEntry)); - } - - if (_sope.SceneObjectPart.TaskInventory != null) - addToList(ref _returnList, (_sope.SceneObjectPart.TaskInventory)); - } - } - - return _returnList; - } - } -} diff --git a/src/SceneObjectGroup.cs b/src/SceneObjectGroup.cs deleted file mode 100644 index 215892a..0000000 --- a/src/SceneObjectGroup.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Serialization; - -namespace GetRegionTextures -{ - [Serializable()] - [XmlRoot] - public class SceneObjectGroup - { - [XmlElement("RootPart", typeof(RootPartElement))] - public RootPartElement RootPart { get; set; } - - [XmlArray("OtherParts")] - [XmlArrayItem("Part")] - public PartElement[] OtherParts { get; set; } - } - - [XmlRoot] - public class RootPartElement - { - [XmlElement("SceneObjectPart", typeof(SceneObjectPartElement))] - public SceneObjectPartElement SceneObjectPart { get; set; } - } - - [XmlRoot] - public class PartElement - { - [XmlElement("SceneObjectPart", typeof(SceneObjectPartElement))] - public SceneObjectPartElement SceneObjectPart { get; set; } - } - - [XmlRoot] - public class SceneObjectPartElement - { - [XmlElement("Name", typeof(String))] - public String Name { get; set; } - - [XmlElement("Shape", typeof(ShapeElement))] - public ShapeElement Shape { get; set; } - - [XmlElement("CollisionSound", typeof(UUIDEntry))] - public UUIDEntry CollisionSound { get; set; } - - [XmlElement("SoundID", typeof(UUIDEntry))] - public UUIDEntry SoundID { get; set; } - - [XmlArray("TaskInventory")] - [XmlArrayItem("TaskInventoryItem")] - public List TaskInventory { get; set; } - } - - [XmlRoot] - public class TaskInventoryItemElement - { - [XmlElement("Name", typeof(String))] - public String Name { get; set; } - - [XmlElement("AssetID", typeof(UUIDEntry))] - public UUIDEntry AssetID { get; set; } - } - - [XmlRoot] - public class ShapeElement - { - [XmlElement("TextureEntry", typeof(String))] - public String TextureEntry { get; set; } - - [XmlElement("ExtraParams", typeof(String))] - public String ExtraParams { get; set; } - - [XmlElement("SculptTexture", typeof(UUIDEntry))] - public UUIDEntry SculptTexture { get; set; } - } - - [XmlRoot] - public class UUIDEntry - { - [XmlElement("UUID", typeof(String))] - public String UUID { get; set; } - } -}