Browse Source

libomv now knows old opensim material asset type + dotnet8 usless changes

UbitUmarov 6 months ago
parent
commit
257a9ad398

+ 53 - 83
OpenSim/Framework/SLUtil.cs

@@ -27,6 +27,7 @@
 
 using OpenMetaverse;
 using System;
+using System.Collections.Frozen;
 using System.Collections.Generic;
 using System.Globalization;
 using System.Runtime.CompilerServices;
@@ -35,16 +36,12 @@ namespace OpenSim.Framework
 {
     public static class SLUtil
     {
-//        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+        //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
         /// <summary>
         /// Asset types used only in OpenSim.
         /// To avoid clashing with the code numbers used in Second Life, use only negative numbers here.
         /// </summary>
-        public enum OpenSimAssetType : sbyte
-        {
-            Material = -2
-        }
 
         #region SL / file extension / content-type conversions
 
@@ -56,81 +53,48 @@ namespace OpenSim.Framework
         {
             if (Enum.IsDefined(typeof(OpenMetaverse.AssetType), assetType))
                 return (OpenMetaverse.AssetType)assetType;
-            else if (Enum.IsDefined(typeof(OpenSimAssetType), assetType))
-                return (OpenSimAssetType)assetType;
             else
                 return OpenMetaverse.AssetType.Unknown;
         }
 
-        private class TypeMapping
+        private struct TypeMapping
         {
-            private sbyte assetType;
-            private sbyte inventoryType;
-            private string contentType;
-            private string contentType2;
-            private string extension;
-
-            public sbyte AssetTypeCode
-            {
-                get { return assetType; }
-            }
-
-            public object AssetType
-            {
-                get { return AssetTypeFromCode(assetType); }
-            }
-
-            public sbyte InventoryType
-            {
-                get { return inventoryType; }
-            }
-
-            public string ContentType
-            {
-                get { return contentType; }
-            }
-
-            public string ContentType2
-            {
-                get { return contentType2; }
-            }
-
-            public string Extension
-            {
-                get { return extension; }
-            }
+            public readonly sbyte AssetType;
+            public readonly sbyte InventoryType;
+            public readonly string ContentType;
+            public readonly string ContentType2;
+            public readonly string Extension;
 
             private TypeMapping(sbyte assetType, sbyte inventoryType, string contentType, string contentType2, string extension)
             {
-                this.assetType = assetType;
-                this.inventoryType = inventoryType;
-                this.contentType = contentType;
-                this.contentType2 = contentType2;
-                this.extension = extension;
+                AssetType = assetType;
+                InventoryType = inventoryType;
+                ContentType = contentType;
+                ContentType2 = contentType2;
+                Extension = extension;
             }
 
             public TypeMapping(AssetType assetType, sbyte inventoryType, string contentType, string contentType2, string extension)
-                : this((sbyte)assetType, inventoryType, contentType, contentType2, extension)
             {
+                AssetType = (sbyte)assetType;
+                InventoryType = inventoryType;
+                ContentType = contentType;
+                ContentType2 = contentType2;
+                Extension = extension;
             }
 
             public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string contentType2, string extension)
-                : this((sbyte)assetType, (sbyte)inventoryType, contentType, contentType2, extension)
+                : this(assetType, (sbyte)inventoryType, contentType, contentType2, extension)
             {
             }
 
             public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string extension)
-                : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
+                : this(assetType, (sbyte)inventoryType, contentType, null, extension)
             {
             }
 
             public TypeMapping(AssetType assetType, FolderType inventoryType, string contentType, string extension)
-                : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
-            {
-            }
-
-            public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, string contentType, string extension)
-                : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
+                : this(assetType, (sbyte)inventoryType, contentType, null, extension)
             {
             }
         }
@@ -141,7 +105,7 @@ namespace OpenSim.Framework
         ///   AssetType "AssetType.Texture" -> Content-Type "image-xj2c"
         ///   Content-Type "image/x-j2c" -> InventoryType "InventoryType.Texture"
         /// </summary>
-        private static TypeMapping[] MAPPINGS = new TypeMapping[] {
+        private static TypeMapping[] MAPPINGS = [
             new TypeMapping(AssetType.Unknown, InventoryType.Unknown, "application/octet-stream", "bin"),
             new TypeMapping(AssetType.Texture, InventoryType.Texture, "image/x-j2c", "image/jp2", "j2c"),
             new TypeMapping(AssetType.Texture, InventoryType.Snapshot, "image/x-j2c", "image/jp2", "j2c"),
@@ -184,15 +148,15 @@ namespace OpenSim.Framework
             new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"),
 
             // OpenSim specific
-            new TypeMapping(OpenSimAssetType.Material, InventoryType.Unknown, "application/llsd+xml", "material")
-        };
-
-        private static Dictionary<sbyte, string> asset2Content;
-        private static Dictionary<sbyte, string> asset2Extension;
-        private static Dictionary<sbyte, string> inventory2Content;
-        private static Dictionary<string, sbyte> content2Asset;
-        private static Dictionary<string, sbyte> content2Inventory;
-        private static Dictionary<string, AssetType> name2Asset = new Dictionary<string, AssetType>()
+            new TypeMapping(AssetType.OSMaterial, InventoryType.Unknown, "application/llsd+xml", "material")
+        ];
+
+        private static readonly FrozenDictionary<sbyte, string> asset2Content;
+        private static readonly FrozenDictionary<sbyte, string> asset2Extension;
+        private static readonly FrozenDictionary<sbyte, string> inventory2Content;
+        private static readonly FrozenDictionary<string, sbyte> content2Asset;
+        private static readonly FrozenDictionary<string, sbyte> content2Inventory;
+        private static readonly FrozenDictionary<string, AssetType> name2Asset = new Dictionary<string, AssetType>()
         {
             {"texture", AssetType.Texture },
             {"sound", AssetType.Sound},
@@ -216,8 +180,9 @@ namespace OpenSim.Framework
             {"mesh", AssetType.Mesh},
             {"settings", AssetType.Settings},
             {"material", AssetType.Material}
-        };
-        private static Dictionary<string, FolderType> name2Inventory = new Dictionary<string, FolderType>()
+        }.ToFrozenDictionary();
+
+        private static readonly FrozenDictionary<string, FolderType> name2Inventory = new Dictionary<string, FolderType>()
         {
             {"texture", FolderType.Texture},
             {"sound", FolderType.Sound},
@@ -243,34 +208,39 @@ namespace OpenSim.Framework
             {"settings", FolderType.Settings},
             {"material", FolderType.Material},
             {"suitcase", FolderType.Suitcase}
-        };
+        }.ToFrozenDictionary();
 
         static SLUtil()
         {
-            asset2Content = new Dictionary<sbyte, string>();
-            asset2Extension = new Dictionary<sbyte, string>();
-            inventory2Content = new Dictionary<sbyte, string>();
-            content2Asset = new Dictionary<string, sbyte>();
-            content2Inventory = new Dictionary<string, sbyte>();
+            Dictionary<sbyte, string> asset2Contentd = [];
+            Dictionary<sbyte, string> asset2Extensiond = [];
+            Dictionary<sbyte, string> inventory2Contentd = [];
+            Dictionary<string, sbyte> content2Assetd = [];
+            Dictionary<string, sbyte> content2Inventoryd = [];
 
             foreach (TypeMapping mapping in MAPPINGS)
             {
-                sbyte assetType = mapping.AssetTypeCode;
-                asset2Content.TryAdd(assetType, mapping.ContentType);
-                asset2Extension.TryAdd(assetType, mapping.Extension);
+                sbyte assetType = mapping.AssetType;
+                asset2Contentd.TryAdd(assetType, mapping.ContentType);
+                asset2Extensiond.TryAdd(assetType, mapping.Extension);
 
-                inventory2Content.TryAdd(mapping.InventoryType, mapping.ContentType);
+                inventory2Contentd.TryAdd(mapping.InventoryType, mapping.ContentType);
 
-                content2Asset.TryAdd(mapping.ContentType, assetType);
+                content2Assetd.TryAdd(mapping.ContentType, assetType);
 
-                content2Inventory.TryAdd(mapping.ContentType, mapping.InventoryType);
+                content2Inventoryd.TryAdd(mapping.ContentType, mapping.InventoryType);
 
                 if (mapping.ContentType2 != null)
                 {
-                    content2Asset.TryAdd(mapping.ContentType2, assetType);
-                    content2Inventory.TryAdd(mapping.ContentType2, mapping.InventoryType);
+                    content2Assetd.TryAdd(mapping.ContentType2, assetType);
+                    content2Inventoryd.TryAdd(mapping.ContentType2, mapping.InventoryType);
                 }
             }
+            asset2Content = asset2Contentd.ToFrozenDictionary();
+            asset2Extension = asset2Extensiond.ToFrozenDictionary();
+            inventory2Content = inventory2Contentd.ToFrozenDictionary();
+            content2Asset = content2Assetd.ToFrozenDictionary();
+            content2Inventory = content2Inventoryd.ToFrozenDictionary();
         }
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]

+ 2 - 3
OpenSim/Framework/Serialization/ArchiveConstants.cs

@@ -29,7 +29,6 @@ using System;
 using System.Collections.Generic;
 using System.Text;
 using OpenMetaverse;
-using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType;
 
 namespace OpenSim.Framework.Serialization
 {
@@ -125,7 +124,7 @@ namespace OpenSim.Framework.Serialization
             ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV]            = ASSET_EXTENSION_SEPARATOR + "sound.wav";
             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.OSMaterial]          = ASSET_EXTENSION_SEPARATOR + "material.xml";
             ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Settings]            = ASSET_EXTENSION_SEPARATOR + "settings.bin";
             ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Material]            = ASSET_EXTENSION_SEPARATOR + "prmat.dat";
 
@@ -148,7 +147,7 @@ namespace OpenSim.Framework.Serialization
             EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "sound.wav"]                = (sbyte)AssetType.SoundWAV;
             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 + "material.xml"]             = (sbyte)AssetType.OSMaterial;
             EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "settings.bin"]             = (sbyte)AssetType.Settings;
             EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "prmat.dat"]                = (sbyte)AssetType.Material;
         }

+ 1 - 1
OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs

@@ -263,7 +263,7 @@ namespace OpenSim.Framework.Servers.HttpServer
             NameValueCollection q = m_request.QueryString;
             _queryAsDictionay = new Dictionary<string, string>();
             m_queryFlags = new HashSet<string>();
-            for(int i = 0; i <q.Count; ++i)
+            for(int i = 0; i < q.Count; ++i)
             {
                 try
                 {

+ 1 - 1
OpenSim/Region/CoreModules/World/Wind/WindModule.cs

@@ -160,7 +160,7 @@ namespace OpenSim.Region.CoreModules
             // Generate initial wind values
             GenWind();
             // hopefully this will not be the same for all regions on same instance
-            m_dataVersion = m_scene.AllocateIntId();
+            m_dataVersion = 1;
             // Mark Module Ready for duty
             m_ready = true;
         }

+ 2 - 3
OpenSim/Region/Framework/Scenes/UuidGatherer.cs

@@ -35,7 +35,6 @@ using OpenMetaverse;
 using OpenMetaverse.StructuredData;
 using OpenSim.Framework;
 using OpenSim.Services.Interfaces;
-using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType;
 
 namespace OpenSim.Region.Framework.Scenes
 {
@@ -616,7 +615,7 @@ namespace OpenSim.Region.Framework.Scenes
                     case AssetType.LSLText:
                         RecordEmbeddedAssetDataUuids(assetBase);
                         break;
-                    case (AssetType)OpenSimAssetType.Material:
+                    case (AssetType)AssetType.OSMaterial:
                         RecordMaterialAssetUuids(assetBase);
                         break;
                     case AssetType.Object:
@@ -668,7 +667,7 @@ namespace OpenSim.Region.Framework.Scenes
                     case (sbyte)AssetType.Gesture:
                     case (sbyte)AssetType.Notecard:
                     case (sbyte)AssetType.LSLText:
-                    case (sbyte)OpenSimAssetType.Material:
+                    case (sbyte)AssetType.OSMaterial:
                     case (sbyte)AssetType.Object:
                     case (sbyte)AssetType.Settings:
                     case (sbyte)AssetType.Material:

+ 1 - 2
OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs

@@ -44,7 +44,6 @@ using OpenSim.Framework;
 using OpenSim.Framework.Servers.HttpServer;
 using OpenSim.Region.Framework.Interfaces;
 using OpenSim.Region.Framework.Scenes;
-using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType;
 
 using Ionic.Zlib;
 
@@ -742,7 +741,7 @@ namespace OpenSim.Region.OptionalModules.Materials
         private AssetBase MakeAsset(FaceMaterial fm, bool local)
         {
             byte[] data = fm.toLLSDxml();
-            AssetBase asset = new(fm.ID, "llmaterial", (sbyte)OpenSimAssetType.Material, "00000000-0000-0000-0000-000000000000")
+            AssetBase asset = new(fm.ID, "osmaterial", (sbyte)AssetType.OSMaterial, "00000000-0000-0000-0000-000000000000")
             {
                 Data = data,
                 Local = local