diff --git a/BUILDING.md b/BUILDING.md index a05a33cdaac..4eb287a38a9 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -15,7 +15,7 @@ get or update source from git dotnet 8.0 is the LTS version and is recommended. To building under Windows, the following is required: - * [dotnet 6.0 SDK, Runtime and Desktop Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) + * [dotnet 8.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) optionally also @@ -47,9 +47,7 @@ The resulting build will be generated to ./build/{Debug|Release}/ ## Requirements - * [Microsoft DotNet 6.0 or later](https://dotnet.microsoft.com/en-us/download). - dotnet 8.0 is the LTS version and is recommended. - * [dotnet 6.0 SDK and Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) + * [dotnet 8.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) * libgdiplus if you have mono 6.x complete, you already have libgdiplus, otherwise you need to install it diff --git a/OpenSim/Data/MySQL/MySQLAvatarData.cs b/OpenSim/Data/MySQL/MySQLAvatarData.cs index 32461fcf04d..9c512258f15 100644 --- a/OpenSim/Data/MySQL/MySQLAvatarData.cs +++ b/OpenSim/Data/MySQL/MySQLAvatarData.cs @@ -26,14 +26,8 @@ */ using System; -using System.Collections.Generic; -using System.Data; -using System.Reflection; -using System.Threading; -using log4net; using MySqlConnector; using OpenMetaverse; -using OpenSim.Framework; namespace OpenSim.Data.MySQL { diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index e6febd0e55e..9c670b094a1 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -44,8 +44,7 @@ public class MySQLEstateStore : IEstateDataStore private string m_connectionString; private FieldInfo[] m_Fields; - private Dictionary m_FieldMap = - new Dictionary(); + private Dictionary m_FieldMap = new(); protected virtual Assembly Assembly { diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index 4cdbe2a532d..646e28c71fd 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -35,9 +35,7 @@ namespace OpenSim.Data.MySQL /// public class MySqlFramework { - private static readonly log4net.ILog m_log = - log4net.LogManager.GetLogger( - System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); protected string m_connectionString = String.Empty; protected MySqlTransaction m_trans = null; diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index ac1e0843f84..b145f733d2f 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -906,11 +906,11 @@ public virtual void StoreRegionSettings(RegionSettings rs) "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + "?WaterHeight, ?TerrainRaiseLimit, " + "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + - "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + + "?SunPosition, ?Covenant, ?covenant_datetime, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID, ?block_search, ?casino, " + - "?TelehubObject, ?ParcelImageID, ?cacheID)"; + "?loaded_creation_datetime, ?loaded_creation_id, " + + "?map_tile_ID, ?block_search, ?casino, " + + "?TelehubObject, ?parcel_tile_ID, ?cacheID)"; FillRegionSettingsCommand(cmd, rs); ExecuteNonQuery(cmd); @@ -1691,14 +1691,14 @@ private static void FillRegionSettingsCommand(MySqlCommand cmd, RegionSettings s cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun); cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition); cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); - cmd.Parameters.AddWithValue("CovenantChangedDateTime", settings.CovenantChangedDateTime); - cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); - cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); - cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID.ToString()); + cmd.Parameters.AddWithValue("covenant_datetime", settings.CovenantChangedDateTime); + cmd.Parameters.AddWithValue("loaded_creation_datetime", settings.LoadedCreationDateTime); + cmd.Parameters.AddWithValue("loaded_creation_id", settings.LoadedCreationID); + cmd.Parameters.AddWithValue("map_tile_ID", settings.TerrainImageID.ToString()); cmd.Parameters.AddWithValue("block_search", settings.GodBlockSearch); cmd.Parameters.AddWithValue("casino", settings.Casino); - cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID.ToString()); + cmd.Parameters.AddWithValue("parcel_tile_ID", settings.ParcelImageID.ToString()); cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject.ToString()); cmd.Parameters.AddWithValue("cacheID", settings.CacheID.ToString()); } diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 05f33368a8b..bbf42a3af6f 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -281,9 +281,9 @@ public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) { if(reader.Read ()) { - ad.CreatorId = new UUID(reader.GetGuid("creatoruuid")); - ad.ParcelId = new UUID(reader.GetGuid("parceluuid")); - ad.SnapshotId = new UUID(reader.GetGuid("snapshotuuid")); + ad.CreatorId = DBGuid.FromDB(reader["creatoruuid"]); + ad.ParcelId = DBGuid.FromDB(reader["parceluuid"]); + ad.SnapshotId = DBGuid.FromDB(reader["snapshotuuid"]); ad.CreationDate = Convert.ToInt32(reader["creationdate"]); ad.ExpirationDate = Convert.ToInt32(reader["expirationdate"]); ad.ParentEstate = Convert.ToInt32(reader["parentestate"]); @@ -803,7 +803,7 @@ public OSDArray GetUserImageAssets(UUID avatarId) { while (reader.Read()) { - data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); + data.Add(new OSDString(reader["snapshotuuid"].ToString ())); } } } @@ -822,7 +822,7 @@ public OSDArray GetUserImageAssets(UUID avatarId) { while (reader.Read()) { - data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); + data.Add(new OSDString(reader["snapshotuuid"].ToString ())); } } } @@ -843,8 +843,8 @@ public OSDArray GetUserImageAssets(UUID avatarId) { while (reader.Read()) { - data.Add(new OSDString((string)reader["profileImage"].ToString ())); - data.Add(new OSDString((string)reader["profileFirstImage"].ToString ())); + data.Add(new OSDString(reader["profileImage"].ToString ())); + data.Add(new OSDString(reader["profileFirstImage"].ToString ())); } } } diff --git a/OpenSim/Framework/Animation.cs b/OpenSim/Framework/Animation.cs index 7d53d82f4ed..8e3b54d026a 100644 --- a/OpenSim/Framework/Animation.cs +++ b/OpenSim/Framework/Animation.cs @@ -140,9 +140,7 @@ public override int GetHashCode() public override string ToString() { - return "AnimID=" + AnimID.ToString() - + "/seq=" + SequenceNum.ToString() - + "/objID=" + ObjectID.ToString(); + return $"AnimID= {AnimID}/seq={SequenceNum}/objID={ObjectID}"; } } diff --git a/OpenSim/Framework/Monitoring/JobEngine.cs b/OpenSim/Framework/Monitoring/JobEngine.cs index 3f71811d36a..f1eb75748e8 100644 --- a/OpenSim/Framework/Monitoring/JobEngine.cs +++ b/OpenSim/Framework/Monitoring/JobEngine.cs @@ -257,7 +257,6 @@ private void ProcessRequests(object o) m_log.DebugFormat("[{0}]: Processed job {1}",LoggingName,currentJob.Name); currentJob.Action = null; - currentJob = null; } lock (JobLock) --m_numberThreads; diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index a36790fd4f1..d824bbdf2f9 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/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); /// /// Asset types used only in OpenSim. /// To avoid clashing with the code numbers used in Second Life, use only negative numbers here. /// - public enum OpenSimAssetType : sbyte - { - Material = -2 - } #region SL / file extension / content-type conversions @@ -56,81 +53,48 @@ public static object AssetTypeFromCode(sbyte assetType) { 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 @@ public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, stri /// AssetType "AssetType.Texture" -> Content-Type "image-xj2c" /// Content-Type "image/x-j2c" -> InventoryType "InventoryType.Texture" /// - 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 @@ public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, stri 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 asset2Content; - private static Dictionary asset2Extension; - private static Dictionary inventory2Content; - private static Dictionary content2Asset; - private static Dictionary content2Inventory; - private static Dictionary name2Asset = new Dictionary() + new TypeMapping(AssetType.OSMaterial, InventoryType.Unknown, "application/llsd+xml", "material") + ]; + + private static readonly FrozenDictionary asset2Content; + private static readonly FrozenDictionary asset2Extension; + private static readonly FrozenDictionary inventory2Content; + private static readonly FrozenDictionary content2Asset; + private static readonly FrozenDictionary content2Inventory; + private static readonly FrozenDictionary name2Asset = new Dictionary() { {"texture", AssetType.Texture }, {"sound", AssetType.Sound}, @@ -216,8 +180,9 @@ public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, stri {"mesh", AssetType.Mesh}, {"settings", AssetType.Settings}, {"material", AssetType.Material} - }; - private static Dictionary name2Inventory = new Dictionary() + }.ToFrozenDictionary(); + + private static readonly FrozenDictionary name2Inventory = new Dictionary() { {"texture", FolderType.Texture}, {"sound", FolderType.Sound}, @@ -243,34 +208,39 @@ public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, stri {"settings", FolderType.Settings}, {"material", FolderType.Material}, {"suitcase", FolderType.Suitcase} - }; + }.ToFrozenDictionary(); static SLUtil() { - asset2Content = new Dictionary(); - asset2Extension = new Dictionary(); - inventory2Content = new Dictionary(); - content2Asset = new Dictionary(); - content2Inventory = new Dictionary(); + Dictionary asset2Contentd = []; + Dictionary asset2Extensiond = []; + Dictionary inventory2Contentd = []; + Dictionary content2Assetd = []; + Dictionary 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)] diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs index 63d8bd14fb8..245bc0bf286 100644 --- a/OpenSim/Framework/Serialization/ArchiveConstants.cs +++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs @@ -29,7 +29,6 @@ using System.Collections.Generic; using System.Text; using OpenMetaverse; -using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType; namespace OpenSim.Framework.Serialization { @@ -125,7 +124,7 @@ static ArchiveConstants() 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 @@ static ArchiveConstants() 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; } diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs index de54dd5e03e..7510e04469a 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs @@ -263,7 +263,7 @@ private void BuildQueryDictionary() NameValueCollection q = m_request.QueryString; _queryAsDictionay = new Dictionary(); m_queryFlags = new HashSet(); - for(int i = 0; i - /// Holds a reference to a and a - /// for incoming packets - /// - public sealed class IncomingPacket - { - /// Client this packet came from - public LLClientView Client; - - /// Packet data that has been received - public Packet Packet; - - /// - /// No arg constructor. - /// - public IncomingPacket() {} - - /// - /// Constructor - /// - /// Reference to the client this packet came from - /// Packet data - public IncomingPacket(LLClientView client, Packet packet) - { - Client = client; - Packet = packet; - } - } -} diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index d347fdcdc00..507dfe394b4 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Collections.Frozen; using System.Net; using System.Reflection; using System.Runtime; @@ -66,6 +67,8 @@ public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, ICl /// public int DebugPacketLevel { get; set; } + private delegate void StaticPacketMethod(LLClientView cli, Packet packet); + #region Events public event BinaryGenericMessage OnBinaryGenericMessage; @@ -324,9 +327,9 @@ public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, ICl public JobEngine m_asyncPacketProcess; private readonly LLUDPServer m_udpServer; private readonly LLUDPClient m_udpClient; - private readonly UUID m_sessionId; + internal readonly UUID m_sessionId; private readonly UUID m_secureSessionId; - protected readonly UUID m_agentId; + internal readonly UUID m_agentId; protected readonly UUID m_scopeId; private readonly uint m_circuitCode; private readonly byte[] m_regionChannelVersion = Utils.EmptyBytes; @@ -478,7 +481,7 @@ public int NextAnimationSequenceNumber /// /// Used to synchronise threads when client is being closed. /// - public object CloseSyncLock { get;} = new object(); + public readonly object CloseSyncLock = new object(); public bool IsLoggingOut { get; set; } @@ -549,7 +552,7 @@ public LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, A var myself = userAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_agentId); RegisterLocalPacketHandlers(); - string name = string.Format("AsyncInUDP-{0}",m_agentId.ToString()); + string name = $"AsyncInUDP-{m_agentId}"; m_asyncPacketProcess = new JobEngine(name, name, 5000); IsActive = true; @@ -691,6 +694,7 @@ public void PopulateStats(int inPackets, int outPackets, int unAckedBytes) /// /// /// true if the handler was added. This is currently always the case. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler) { return AddLocalPacketHandler(packetType, handler, true); @@ -707,12 +711,14 @@ public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler) /// synchronously. /// /// true if the handler was added. This is currently always the case. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync) { lock (m_packetHandlers) - return m_packetHandlers.TryAdd(packetType, new PacketProcessor() { method = handler, Async = doAsync}); + return m_packetHandlers.TryAdd(packetType, new PacketProcessor(handler, doAsync)); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool AddGenericPacketHandler(string MethodName, GenericMessage handler) { MethodName = MethodName.ToLower().Trim(); @@ -727,24 +733,29 @@ public bool AddGenericPacketHandler(string MethodName, GenericMessage handler) /// True if a handler was found which successfully processed the packet. protected bool ProcessPacketMethod(Packet packet) { - if(m_packetHandlers.TryGetValue(packet.Type, out PacketProcessor pprocessor)) + if (m_staticHandlers.TryGetValue(packet.Type, out StaticPacketProcessor spp)) + { + if (spp.Async) + { + Packet lp = packet; + StaticPacketMethod m = spp.method; + LLClientView c = this; + _ = m_asyncPacketProcess.QueueJob(packet.Type.ToString(), () => { m(c,lp); }); + } + else + { + spp.method(this, packet); + } + return true; + } + + if (m_packetHandlers.TryGetValue(packet.Type, out PacketProcessor pprocessor)) { if (pprocessor.Async) { Packet lp = packet; - _ = m_asyncPacketProcess.QueueJob(packet.Type.ToString(), () => - { - try - { - pprocessor.method(lp); - } - catch (Exception e) - { - // Make sure that we see any exception caused by the asynchronous operation. - m_log.Error( - $"[LLCLIENTVIEW]: Caught exception while processing {packet.Type} for {Name}: {e.Message}"); - } - }); + PacketMethod m = pprocessor.method; + _ = m_asyncPacketProcess.QueueJob(packet.Type.ToString(), () => { m(lp); }); } else { @@ -873,7 +884,7 @@ public void SendRegionHandshake() bool isEstateManager = m_scene.Permissions.IsEstateManager(m_agentId); // go by oficial path uint regionFlags = GetRegionFlags(); - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(RegionHandshakeHeader, 0, buf.Data, 0, 11); // inline zeroencode @@ -976,7 +987,7 @@ public unsafe void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 m_thisAgentUpdateArgs.lastUpdateTS = 0; m_thisAgentUpdateArgs.ControlFlags = 0; - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] bdata = buf.Data; //setup header @@ -1027,7 +1038,7 @@ public unsafe void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 public void SendChatMessage(string message, byte chattype, Vector3 fromPos, string fromName, UUID sourceID, UUID ownerID, byte sourcetype, byte audible) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header @@ -1084,7 +1095,7 @@ public void SendInstantMessage(GridInstantMessage im) if (!m_scene.Permissions.CanInstantMessage(fromAgentID, toAgentID)) return; - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header @@ -1176,7 +1187,7 @@ public void SendInstantMessage(GridInstantMessage im) public void SendGenericMessage(string method, UUID invoice, List message) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header @@ -1225,7 +1236,7 @@ public void SendGenericMessage(string method, UUID invoice, List message //m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task, null, false, true); m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task); - UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer newbuf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(data, 0, newbuf.Data, 0, countpos); buf = newbuf; data = buf.Data; @@ -1246,7 +1257,7 @@ public void SendGenericMessage(string method, UUID invoice, List message public void SendGenericMessage(string method, UUID invoice, List message) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header @@ -1296,7 +1307,7 @@ public void SendGenericMessage(string method, UUID invoice, List message //m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task, null, false, true); m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task); - UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer newbuf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(data, 0, newbuf.Data, 0, countpos); buf = newbuf; data = buf.Data; @@ -1628,7 +1639,7 @@ public void SendLayerData(int[] map) int numberPatchs = map.Length / 2; - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; Buffer.BlockCopy(TerrainPacketHeader, 0, data, 0, 7); @@ -1664,7 +1675,7 @@ public void SendLayerData(int[] map) m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Land); // start another - buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); data = buf.Data; Buffer.BlockCopy(TerrainPacketHeader, 0, data, 0, 7); @@ -1855,7 +1866,7 @@ public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 look public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header and agentinfo block @@ -1896,7 +1907,7 @@ public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flag else { // prepare next packet - UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer newbuf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(data, 0, newbuf.Data, 0, 34); // copy the block we already did @@ -1959,7 +1970,7 @@ public void SendMapBlock(List mapBlocks, uint flags) needSizes = true; } - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header and agentinfo block @@ -2002,7 +2013,7 @@ public void SendMapBlock(List mapBlocks, uint flags) else { // prepare next packet - UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer newbuf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(data, 0, newbuf.Data, 0, 30); // copy the block we already did @@ -2786,7 +2797,7 @@ public void SendTakeControls(int controls, bool passToAgent, bool TakeControls) public void SendTaskInventory(UUID taskID, short serial, byte[] fileName) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header @@ -2814,7 +2825,7 @@ public void SendTaskInventory(UUID taskID, short serial, byte[] fileName) public void SendXferPacket(ulong xferID, uint packet, byte[] XferData, int XferDataOffset, int XferDatapktLen, bool isTaskInventory) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header @@ -2862,7 +2873,7 @@ public void SendXferPacket(ulong xferID, uint packet, public void SendAbortXferPacket(ulong xferID) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header @@ -2911,7 +2922,7 @@ public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int Obje public void SendAvatarPickerReply(UUID QueryID, List users) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header @@ -2957,7 +2968,7 @@ public void SendAvatarPickerReply(UUID QueryID, List users) m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task); if (u < users.Count - 1) { - UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer newbuf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] newdata = newbuf.Data; Buffer.BlockCopy(data, 0, newdata, 0, 42); buf = newbuf; @@ -4372,7 +4383,7 @@ public void SendWearables(AvatarWearable[] wearables, int serial) public void SendAppearance(UUID targetID, byte[] visualParams, byte[] textureEntry, float hover) { // doing post zero encode, because odds of beeing bad are not that low - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(AvatarAppearanceHeader, 0, buf.Data, 0, 10); byte[] data = buf.Data; int pos = 10; @@ -4424,7 +4435,7 @@ public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UU { // m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name); - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header Buffer.BlockCopy(AvatarAnimationHeader, 0, data, 0, 7); @@ -4525,7 +4536,7 @@ public void SendEntityFullUpdateImmediate(ISceneEntity ent) if (ent is not ScenePresence && ent is not SceneObjectPart) return; - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(objectUpdateHeader, 0, buf.Data, 0, 7); LLUDPZeroEncoder zc = new(buf.Data); @@ -4550,7 +4561,7 @@ public unsafe void SendEntityTerseUpdateImmediate(ISceneEntity ent) if (ent is null) return; - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); //setup header and regioninfo block Buffer.BlockCopy(terseUpdateHeader, 0, buf.Data, 0, 7); @@ -4610,7 +4621,7 @@ public void SendCoarseLocationUpdate(List users, List CoarseLocat //bool doprey = m_courseLocationPrey != UUID.Zero; - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(CoarseLocationUpdateHeader, 0, buf.Data, 0, 8); byte[] data = buf.Data; @@ -5100,7 +5111,7 @@ private void ProcessEntityUpdates(int maxUpdatesBytes) { //List tau = new List(30); - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(objectUpdateHeader, 0, buf.Data, 0, 7); LLUDPZeroEncoder zc = new(buf.Data); @@ -5141,7 +5152,7 @@ private void ProcessEntityUpdates(int maxUpdatesBytes) else { // we need more packets - UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer newbuf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(buf.Data, 0, newbuf.Data, 0, countposition); // start is the same buf.Data[countposition] = (byte)count; @@ -5192,7 +5203,7 @@ private void ProcessEntityUpdates(int maxUpdatesBytes) { //List tau = new List(30); - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; Buffer.BlockCopy(CompressedObjectHeader, 0, data, 0, 7); @@ -5236,7 +5247,7 @@ private void ProcessEntityUpdates(int maxUpdatesBytes) else { // we need more packets - UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer newbuf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(buf.Data, 0, newbuf.Data, 0, countposition); // start is the same buf.Data[countposition] = (byte)count; @@ -5284,7 +5295,7 @@ private void ProcessEntityUpdates(int maxUpdatesBytes) if (objectUpdateProbes is not null) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; Buffer.BlockCopy(ObjectUpdateCachedHeader, 0, data, 0, 7); @@ -5333,7 +5344,7 @@ private void ProcessEntityUpdates(int maxUpdatesBytes) if (pos > (LLUDPServer.MAXPAYLOAD - 13)) { // we need more packets - UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer newbuf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(data, 0, newbuf.Data, 0, countposition); // start is the same data[countposition] = (byte)count; @@ -5364,7 +5375,7 @@ private void ProcessEntityUpdates(int maxUpdatesBytes) int blocks = terseUpdates.Count; //List tau = new List(30); - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); //setup header and regioninfo block Buffer.BlockCopy(terseUpdateHeader, 0, buf.Data, 0, 7); @@ -5402,7 +5413,7 @@ private void ProcessEntityUpdates(int maxUpdatesBytes) else if (blocks > 0) { // we need more packets - UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer newbuf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(buf.Data, 0, newbuf.Data, 0, COUNTINDEX); // start is the same // copy what we done in excess int extralen = pos - lastpos; @@ -5458,7 +5469,7 @@ private void ProcessEntityUpdates(int maxUpdatesBytes) int count = sop.GetAnimations(out UUID[] ids, out int[] seqs); - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header @@ -5526,7 +5537,7 @@ private void ProcessEntityUpdates(int maxUpdatesBytes) continue; } - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] dataptr = buf.Data; //setup header @@ -5882,7 +5893,7 @@ public void SendShutdownConnectionNotice() public void SendSimStats(SimStats stats) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); byte[] data = buf.Data; //setup header @@ -6036,7 +6047,7 @@ private void ProcessEntityPropertyRequests(int maxUpdateBytes) int blocks = objectPropertiesUpdates.Count; //List tau = new List(30); - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(ObjectPropertyUpdateHeader, 0, buf.Data, 0, 8); LLUDPZeroEncoder zc = new(buf.Data); @@ -6064,7 +6075,7 @@ private void ProcessEntityPropertyRequests(int maxUpdateBytes) else if (blocks > 0) { // we need more packets - UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer newbuf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(buf.Data, 0, newbuf.Data, 0, countposition); // start is the same buf.Data[countposition] = (byte)count; @@ -6107,7 +6118,7 @@ private void ProcessEntityPropertyRequests(int maxUpdateBytes) { foreach (EntityUpdate eu in objectPropertiesFamilyUpdates) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); Buffer.BlockCopy(ObjectFamilyUpdateHeader, 0, buf.Data, 0, 8); LLUDPZeroEncoder zc = new(buf.Data); @@ -8182,238 +8193,278 @@ public ulong GetGroupPowers(UUID groupID) #endregion + private static readonly FrozenDictionary m_staticHandlers = new SortedDictionary() + //private static readonly Dictionary m_staticHandlers = new() + { + { PacketType.AgentUpdate, new(HandleAgentUpdate, false) }, + { PacketType.ViewerEffect, new(HandleViewerEffect , false) }, + { PacketType.VelocityInterpolateOn, new(HandleVelocityInterpolateOn, false) }, + { PacketType.VelocityInterpolateOff, new(HandleVelocityInterpolateOff, false) }, + { PacketType.AgentCachedTexture, new(HandleAgentTextureCached, false) }, + { PacketType.MultipleObjectUpdate, new(HandleMultipleObjUpdate, false) }, + { PacketType.MoneyTransferRequest, new(HandleMoneyTransferRequest, false) }, + { PacketType.ParcelBuy, new(HandleParcelBuyRequest, false) }, + { PacketType.RegionHandshakeReply, new(HandlerRegionHandshakeReply, false) }, + { PacketType.SetAlwaysRun, new(HandleSetAlwaysRun, false) }, + { PacketType.AgentAnimation, new(HandleAgentAnimation, false) }, + { PacketType.AgentThrottle, new(HandleAgentThrottle, false) }, + { PacketType.AgentPause, new(HandleAgentPause, false) }, + { PacketType.AgentResume, new(HandleAgentResume, false) }, + { PacketType.ObjectImage, new(HandleObjectImage, false) }, + { PacketType.ObjectGrab, new(HandleObjectGrab, false) }, + { PacketType.ObjectGrabUpdate, new(HandleObjectGrabUpdate, false) }, + { PacketType.ObjectSpinStart, new(HandleObjectSpinStart, false) }, + { PacketType.ObjectSpinUpdate, new(HandleObjectSpinUpdate, false) }, + { PacketType.ObjectSpinStop, new(HandleObjectSpinStop, false) }, + { PacketType.ObjectDescription, new(HandleObjectDescription, false) }, + { PacketType.ObjectName, new(HandleObjectName, false) }, + { PacketType.ObjectPermissions, new(HandleObjectPermissions, false) }, + { PacketType.Undo, new(HandleUndo, false) }, + { PacketType.UndoLand, new(HandleLandUndo, false) }, + { PacketType.Redo, new(HandleRedo, false) }, + { PacketType.RequestObjectPropertiesFamily, new(HandleRequestObjectPropertiesFamily, false) }, + { PacketType.ScriptAnswerYes, new(HandleScriptAnswerYes, false) }, + { PacketType.ObjectClickAction, new(HandleObjectClickAction, false) }, + { PacketType.ObjectMaterial, new(HandleObjectMaterial, false) }, + { PacketType.RequestImage, new(HandleRequestImage, false) }, + { PacketType.TransferRequest, new(HandleTransferRequest, false) }, + { PacketType.ConfirmXferPacket, new(HandleConfirmXferPacket, false) }, + { PacketType.UUIDNameRequest, new(HandleUUIDNameRequest, false) }, + { PacketType.RegionHandleRequest, new(HandleRegionHandleRequest, false) }, + { PacketType.ParcelAccessListRequest, new(HandleParcelAccessListRequest, false) }, + { PacketType.ParcelAccessListUpdate, new(HandleParcelAccessListUpdate, false) }, + { PacketType.ParcelPropertiesRequest, new(HandleParcelPropertiesRequest, false) }, + { PacketType.RequestRegionInfo, new(HandleRequestRegionInfo, false) }, + { PacketType.AgentFOV, new(HandleAgentFOV, false) }, + { PacketType.MapItemRequest, new(HandleMapItemRequest, false) }, + { PacketType.TransferAbort, new(HandleTransferAbort, false) }, + { PacketType.AgentHeightWidth, new(HandleAgentHeightWidth, false) }, + + { PacketType.LogoutRequest, new(HandleLogout, true) }, + { PacketType.UUIDGroupNameRequest, new(HandleUUIDGroupNameRequest, true) }, + { PacketType.ObjectGroup, new(HandleObjectGroupRequest, true) }, + { PacketType.GenericMessage, new(HandleGenericMessage, true) }, + + { PacketType.MuteListRequest, new(HandleMuteListRequest, false) }, + { PacketType.UpdateMuteListEntry, new(HandleUpdateMuteListEntry, true) }, + { PacketType.RemoveMuteListEntry, new(HandleRemoveMuteListEntry, true) }, + + { PacketType.AvatarPropertiesRequest, new(HandleAvatarPropertiesRequest, true) }, + { PacketType.ChatFromViewer, new(HandleChatFromViewer, true) }, + { PacketType.AvatarPropertiesUpdate, new(HandlerAvatarPropertiesUpdate, true) }, + { PacketType.ScriptDialogReply, new(HandlerScriptDialogReply, true) }, + { PacketType.ImprovedInstantMessage, new(HandlerImprovedInstantMessage, true) }, + { PacketType.AcceptFriendship, new(HandlerAcceptFriendship, true) }, + { PacketType.DeclineFriendship, new(HandlerDeclineFriendship, true) }, + { PacketType.TerminateFriendship, new(HandlerTerminateFriendship, true) }, + { PacketType.RezObject, new(HandlerRezObject, true) }, + { PacketType.DeRezObject, new(HandlerDeRezObject, true) }, + { PacketType.RezRestoreToWorld, new(HandlerRezRestoreToWorld, true) }, + { PacketType.ModifyLand, new(HandlerModifyLand, true) }, + { PacketType.AgentWearablesRequest, new(HandlerAgentWearablesRequest, true) }, + { PacketType.AgentSetAppearance, new(HandlerAgentSetAppearance, true) }, + { PacketType.AgentIsNowWearing, new(HandlerAgentIsNowWearing, true) }, + { PacketType.RezSingleAttachmentFromInv, new(HandlerRezSingleAttachmentFromInv, true) }, + { PacketType.RezMultipleAttachmentsFromInv, new(HandleRezMultipleAttachmentsFromInv, true) }, + { PacketType.DetachAttachmentIntoInv, new(HandleDetachAttachmentIntoInv, true) }, + { PacketType.ObjectAttach, new(HandleObjectAttach, true) }, + { PacketType.ObjectDetach, new(HandleObjectDetach, true) }, + { PacketType.ObjectDrop, new(HandleObjectDrop, true) }, + { PacketType.CompleteAgentMovement, new(HandleCompleteAgentMovement, true) }, + { PacketType.AgentRequestSit, new(HandleAgentRequestSit, true) }, + { PacketType.AgentSit, new(HandleAgentSit, true) }, + { PacketType.SoundTrigger, new(HandleSoundTrigger, true) }, + { PacketType.AvatarPickerRequest, new(HandleAvatarPickerRequest, true) }, + { PacketType.AgentDataUpdateRequest, new(HandleAgentDataUpdateRequest, true) }, + { PacketType.UserInfoRequest, new(HandleUserInfoRequest, true) }, + { PacketType.UpdateUserInfo, new(HandleUpdateUserInfo, true) }, + { PacketType.SetStartLocationRequest, new(HandleSetStartLocationRequest, true) }, + { PacketType.ForceScriptControlRelease, new(HandleForceScriptControlRelease, true) }, + { PacketType.ObjectLink, new(HandleObjectLink, true) }, + { PacketType.ObjectDelink, new(HandleObjectDelink, true) }, + { PacketType.ObjectAdd, new(HandleObjectAdd, true) }, + { PacketType.ObjectShape, new(HandleObjectShape, true) }, + { PacketType.ObjectExtraParams, new(HandleObjectExtraParams, true) }, + { PacketType.ObjectDuplicate, new(HandleObjectDuplicate, true) }, + { PacketType.RequestMultipleObjects, new(HandleRequestMultipleObjects, true) }, + { PacketType.ObjectSelect, new(HandleObjectSelect, true) }, + { PacketType.ObjectDeselect, new(HandleObjectDeselect, true) }, + { PacketType.ObjectPosition, new(HandleObjectPosition, true) }, + { PacketType.ObjectScale, new(HandleObjectScale, true) }, + { PacketType.ObjectRotation, new(HandleObjectRotation, true) }, + { PacketType.ObjectFlagUpdate, new(HandleObjectFlagUpdate, true) }, + { PacketType.ObjectDeGrab, new(HandleObjectDeGrab, true) }, + { PacketType.ObjectDuplicateOnRay, new(HandleObjectDuplicateOnRay, true) }, + { PacketType.ObjectIncludeInSearch, new(HandleObjectIncludeInSearch, true) }, + { PacketType.AssetUploadRequest, new(HandleAssetUploadRequest, true) }, + { PacketType.RequestXfer, new(HandleRequestXfer, true) }, + { PacketType.SendXferPacket, new(HandleSendXferPacket, true) }, + { PacketType.AbortXfer, new(HandleAbortXfer, true) }, + + { PacketType.CreateInventoryFolder, new (HandleCreateInventoryFolder, true) }, + { PacketType.UpdateInventoryFolder, new(HandleUpdateInventoryFolder, true) }, + { PacketType.MoveInventoryFolder, new(HandleMoveInventoryFolder, true) }, + { PacketType.CreateInventoryItem, new(HandleCreateInventoryItem, true) }, + { PacketType.LinkInventoryItem, new(HandleLinkInventoryItem, true) }, + { PacketType.FetchInventory, new(HandleFetchInventory, true) }, + { PacketType.FetchInventoryDescendents, new(HandleFetchInventoryDescendents, true) }, + { PacketType.InventoryDescendents, new (HandleInventoryDescendents, true) }, + { PacketType.PurgeInventoryDescendents, new(HandlePurgeInventoryDescendents, true) }, + { PacketType.UpdateInventoryItem, new(HandleUpdateInventoryItem, true) }, + { PacketType.CopyInventoryItem, new(HandleCopyInventoryItem, true) }, + { PacketType.MoveInventoryItem, new(HandleMoveInventoryItem, true) }, + { PacketType.RemoveInventoryItem, new(HandleRemoveInventoryItem, true) }, + { PacketType.RemoveInventoryFolder, new(HandleRemoveInventoryFolder, true) }, + { PacketType.RemoveInventoryObjects, new(HandleRemoveInventoryObjects, true) }, + + { PacketType.RequestTaskInventory, new(HandleRequestTaskInventory, true) }, + { PacketType.UpdateTaskInventory, new(HandleUpdateTaskInventory, true) }, + { PacketType.RemoveTaskInventory, new(HandleRemoveTaskInventory, true) }, + { PacketType.MoveTaskInventory, new(HandleMoveTaskInventory, true) }, + + { PacketType.RezScript, new(HandleRezScript, true) }, + + { PacketType.MapLayerRequest, new(HandleMapLayerRequest, true) }, + { PacketType.MapBlockRequest, new(HandleMapBlockRequest, true) }, + { PacketType.MapNameRequest, new(HandleMapNameRequest, true) }, + + { PacketType.TeleportLandmarkRequest, new(HandleTeleportLandmarkRequest, true) }, + { PacketType.TeleportCancel, new(HandleTeleportCancel, true) }, + { PacketType.TeleportLocationRequest, new(HandleTeleportLocationRequest, true) }, + + { PacketType.ParcelInfoRequest, new (HandleParcelInfoRequest, true) }, + { PacketType.ParcelDivide, new(HandleParcelDivide, true) }, + { PacketType.ParcelJoin, new(HandleParcelJoin, true) }, + { PacketType.ParcelPropertiesUpdate, new(HandleParcelPropertiesUpdate, true) }, + { PacketType.ParcelSelectObjects, new(HandleParcelSelectObjects, true) }, + { PacketType.ParcelObjectOwnersRequest, new(HandleParcelObjectOwnersRequest, true) }, + { PacketType.ParcelGodForceOwner, new(HandleParcelGodForceOwner, true) }, + { PacketType.ParcelRelease, new(HandleParcelRelease, true) }, + { PacketType.ParcelReclaim, new(HandleParcelReclaim, true) }, + { PacketType.ParcelReturnObjects, new(HandleParcelReturnObjects, true) }, + { PacketType.ParcelSetOtherCleanTime, new(HandleParcelSetOtherCleanTime, true) }, + { PacketType.ParcelDeedToGroup, new (HandleParcelDeedToGroup, true) }, + + { PacketType.LandStatRequest, new(HandleLandStatRequest, true) }, + { PacketType.ParcelDwellRequest, new(HandleParcelDwellRequest, true) }, + + { PacketType.EstateOwnerMessage, new(HandleEstateOwnerMessage, true) }, + { PacketType.EstateCovenantRequest, new(HandleEstateCovenantRequest, true) }, + + { PacketType.RequestGodlikePowers, new(HandleRequestGodlikePowers, true) }, + { PacketType.GodKickUser, new(HandleGodKickUser, true) }, + + { PacketType.MoneyBalanceRequest, new(HandleMoneyBalanceRequest, true) }, + { PacketType.EconomyDataRequest, new(HandleEconomyDataRequest, true) }, + { PacketType.RequestPayPrice, new(HandleRequestPayPrice, true) }, + { PacketType.ObjectSaleInfo, new(HandleObjectSaleInfo, true) }, + { PacketType.ObjectBuy, new(HandleObjectBuy, true) }, + + { PacketType.GetScriptRunning, new(HandleGetScriptRunning, true) }, + { PacketType.SetScriptRunning, new(HandleSetScriptRunning, true) }, + { PacketType.ScriptReset, new(HandleScriptReset, true) }, + + { PacketType.ActivateGestures, new(HandleActivateGestures, true) }, + { PacketType.DeactivateGestures, new(HandleDeactivateGestures, true) }, + + { PacketType.ObjectOwner, new(HandleObjectOwner, true) }, + + { PacketType.ViewerStats, new(HandleViewerStats, true) }, + + { PacketType.UseCircuitCode, new(HandleUseCircuitCode, true) }, + + { PacketType.CreateNewOutfitAttachments, new(HandleCreateNewOutfitAttachments, true) }, + + { PacketType.DirFindQuery, new(HandleDirFindQuery, true) }, + { PacketType.DirPlacesQuery, new(HandleDirPlacesQuery, true) }, + { PacketType.DirClassifiedQuery, new(HandleDirClassifiedQuery, true) }, + { PacketType.DirLandQuery, new(HandleDirLandQuery, true) }, + { PacketType.DirPopularQuery, new(HandleDirPopularQuery, true) }, + + { PacketType.EventInfoRequest, new(HandleEventInfoRequest, true) }, + + { PacketType.OfferCallingCard, new(HandleOfferCallingCard, true) }, + { PacketType.AcceptCallingCard, new(HandleAcceptCallingCard, true) }, + { PacketType.DeclineCallingCard, new(HandleDeclineCallingCard, true) }, + + { PacketType.ActivateGroup, new(HandleActivateGroup, true) }, + { PacketType.GroupTitlesRequest, new(HandleGroupTitlesRequest, true) }, + { PacketType.GroupProfileRequest, new(HandleGroupProfileRequest, true) }, + { PacketType.GroupMembersRequest, new(HandleGroupMembersRequest, true) }, + { PacketType.GroupRoleDataRequest, new(HandleGroupRoleDataRequest, true) }, + { PacketType.GroupRoleMembersRequest, new(HandleGroupRoleMembersRequest, true) }, + { PacketType.CreateGroupRequest, new(HandleCreateGroupRequest, true) }, + { PacketType.UpdateGroupInfo, new(HandleUpdateGroupInfo, true) }, + { PacketType.SetGroupAcceptNotices, new(HandleSetGroupAcceptNotices, true) }, + { PacketType.GroupTitleUpdate, new(HandleGroupTitleUpdate, true) }, + + { PacketType.GroupNoticesListRequest, new(HandleGroupNoticesListRequest, true) }, + { PacketType.GroupNoticeRequest, new(HandleGroupNoticeRequest, true) }, + + { PacketType.GroupRoleChanges, new(HandleGroupRoleChanges, true) }, + + { PacketType.JoinGroupRequest, new(HandleJoinGroupRequest, true) }, + { PacketType.LeaveGroupRequest, new(HandleLeaveGroupRequest, true) }, + { PacketType.EjectGroupMemberRequest, new(HandleEjectGroupMemberRequest, true) }, + { PacketType.InviteGroupRequest, new(HandleInviteGroupRequest, true) }, + + { PacketType.GroupAccountDetailsRequest, new(HandleGroupAccountDetailsRequest, true) }, + { PacketType.GroupAccountSummaryRequest, new(HandleGroupAccountSummaryRequest, true) }, + { PacketType.GroupAccountTransactionsRequest, new(HandleGroupTransactionsDetailsRequest, true) }, + + { PacketType.GroupActiveProposalsRequest, new(HandleGroupActiveProposalsRequest, true) }, + { PacketType.GroupVoteHistoryRequest, new(HandleGroupVoteHistoryRequest, true) }, + + { PacketType.StartLure, new(HandleStartLure, true) }, + { PacketType.TeleportLureRequest, new(HandleTeleportLureRequest, true) }, + + { PacketType.ClassifiedInfoRequest, new(HandleClassifiedInfoRequest, true) }, + { PacketType.ClassifiedInfoUpdate, new(HandleClassifiedInfoUpdate, true) }, + { PacketType.ClassifiedDelete, new(HandleClassifiedDelete, true) }, + { PacketType.ClassifiedGodDelete, new(HandleClassifiedGodDelete, true) }, + + { PacketType.EventGodDelete, new(HandleEventGodDelete, true) }, + { PacketType.EventNotificationAddRequest, new(HandleEventNotificationAddRequest, true) }, + { PacketType.EventNotificationRemoveRequest, new(HandleEventNotificationRemoveRequest, true) }, + + { PacketType.RetrieveInstantMessages, new(HandleRetrieveInstantMessages, true) }, + + { PacketType.PickDelete, new(HandlePickDelete, true) }, + { PacketType.PickGodDelete, new(HandlePickGodDelete, true) }, + { PacketType.PickInfoUpdate, new(HandlePickInfoUpdate, true) }, + + { PacketType.AvatarNotesUpdate, new(HandleAvatarNotesUpdate, true) }, + { PacketType.AvatarInterestsUpdate, new(HandleAvatarInterestsUpdate, true) }, + + { PacketType.GrantUserRights, new(HandleGrantUserRights, true) }, + + { PacketType.PlacesQuery, new(HandlePlacesQuery, true) }, + + { PacketType.UserReport, new(HandleUserReport, true) }, + { PacketType.FindAgent, new(HandleFindAgent, true) }, + { PacketType.TrackAgent, new(HandleTrackAgent, true) }, + + { PacketType.GodUpdateRegionInfo, new(HandleGodUpdateRegionInfoUpdate, true) }, + { PacketType.GodlikeMessage, new(HandleGodlikeMessage, true) }, + + { PacketType.StateSave, new(HandleSaveStatePacket, true) }, + + { PacketType.RevokePermissions, new(HandleRevokePermissions, true) }, + + { PacketType.FreezeUser, new(HandleFreezeUser, true) }, + { PacketType.EjectUser, new(HandleEjectUser, true) }, + + { PacketType.ParcelBuyPass, new(HandleParcelBuyPass, true) }, + { PacketType.ParcelGodMarkAsContent, new(HandleParcelGodMarkAsContent, true) }, + { PacketType.SimWideDeletes, new(HandleSimWideDeletes, true) }, + { PacketType.SendPostcard, new(HandleSendPostcard, true) }, + { PacketType.ChangeInventoryItemFlags, new(HandleChangeInventoryItemFlags, true) }, + + }.ToFrozenDictionary(); + //}; + protected virtual void RegisterLocalPacketHandlers() { - AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout); - - // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs - // for each AgentUpdate packet. - AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false); - - AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false); - AddLocalPacketHandler(PacketType.VelocityInterpolateOff, HandleVelocityInterpolateOff, false); - AddLocalPacketHandler(PacketType.VelocityInterpolateOn, HandleVelocityInterpolateOn, false); - AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false); - AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false); - AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false); - AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false); - AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest); - AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest); - AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage); - AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest); - AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); - AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate); - AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply); - AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage); - AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship); - AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship); - AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship); - AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject); - AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject); - AddLocalPacketHandler(PacketType.RezRestoreToWorld, HandlerRezRestoreToWorld); - AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand); - AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply, false); - AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest); - AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance); - AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing); - AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv); - AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv); - AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv); - AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach); - AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach); - AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop); - AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false); - AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement); - AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false); - AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit); - AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit); - AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger); - AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest); - AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest); - AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest); - AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo); - AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest); - AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false); - AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false); - AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false); - AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease); - AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink); - AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink); - AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd); - AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape); - AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams); - AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate); - AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects); - AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect); - AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect); - AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition); - AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale); - AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation); - AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate); - - // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once, - // some clients will send out a separate ObjectImage packet for each face - AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false); - - AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false); - AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false); - AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab); - AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false); - AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false); - AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false); - AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false); - AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false); - AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false); - AddLocalPacketHandler(PacketType.Undo, HandleUndo, false); - AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false); - AddLocalPacketHandler(PacketType.Redo, HandleRedo, false); - AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay); - AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false); - AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch); - AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false); - AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false); - AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false); - AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage, false); - AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest, false); - AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest); - AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer); - AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket); - AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket, false); - AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer); - AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder); - AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder); - AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder); - AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem); - AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem); - AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory); - AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents); - AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents); - AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem); - AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem); - AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem); - AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem); - AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder); - AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects); - AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory); - AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory); - AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory); - AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory); - AddLocalPacketHandler(PacketType.RezScript, HandleRezScript); - AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest); - AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest); - AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest); - AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest); - AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel); - AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest); - AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false); - AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest, false); - AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest); - AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false); - AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false); - AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false); - AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide); - AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin); - AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate); - AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects); - AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest); - AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner); - AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease); - AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim); - AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects); - AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime); - AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest); - AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest); - AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage); - AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false); - AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest); - AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers); - AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser); - AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest); - AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest); - AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice); - AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo); - AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy); - AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning); - AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning); - AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset); - AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures); - AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures); - AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner); - AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false); - AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats); - AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false); - AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false); - AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false); - AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode); - AddLocalPacketHandler(PacketType.CreateNewOutfitAttachments, HandleCreateNewOutfitAttachments); - AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false); - AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents); - AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery); - AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery); - AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery); - AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery); - AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery); - AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest); - AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard); - AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard); - AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard); - AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup); - AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest); - AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest); - AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest); - AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest); - AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest); - AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest); - AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo); - AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices); - AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate); - AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup); - AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest); - AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest); - AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate); - AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges); - AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest); - AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest); - AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest); - AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest); - AddLocalPacketHandler(PacketType.StartLure, HandleStartLure); - AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest); - AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest); - AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate); - AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete); - AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete); - AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete); - AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest); - AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest); - AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages); - AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete); - AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete); - AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate); - AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate); - AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate); - AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights); - AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery); - AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry); - AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry); - AddLocalPacketHandler(PacketType.UserReport, HandleUserReport); - AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent); - AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent); - AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate); - AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage); - AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket); - AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest); - AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest); - AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest); - AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser); - AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser); - AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass); - AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent); - AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest); - AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest); - AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes); - AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard); - AddLocalPacketHandler(PacketType.ChangeInventoryItemFlags, HandleChangeInventoryItemFlags); - AddLocalPacketHandler(PacketType.RevokePermissions, HandleRevokePermissions); AddGenericPacketHandler("autopilot", HandleAutopilot); } @@ -8482,23 +8533,20 @@ private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock ); } - private void HandleAgentUpdate(Packet packet) + private static void HandleAgentUpdate(LLClientView c, Packet packet) { - if(OnAgentUpdate is null) + if(c.OnAgentUpdate is null) return; AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; - if (x.AgentID.NotEqual(m_agentId) || x.SessionID.NotEqual(m_sessionId)) - return; - uint seq = packet.Header.Sequence; - TotalAgentUpdates++; + c.TotalAgentUpdates++; // dont let ignored updates pollute this throttles - if(SceneAgent is null || SceneAgent.IsChildAgent || - SceneAgent.IsInTransit || seq <= m_thisAgentUpdateArgs.lastpacketSequence ) + if(c.SceneAgent is null || c.SceneAgent.IsChildAgent || + c.SceneAgent.IsInTransit || seq <= c.m_thisAgentUpdateArgs.lastpacketSequence ) { // throttle reset is done at MoveAgentIntoRegion() // called by scenepresence on completemovement @@ -8506,172 +8554,150 @@ private void HandleAgentUpdate(Packet packet) return; } - m_thisAgentUpdateArgs.lastpacketSequence = seq; + c.m_thisAgentUpdateArgs.lastpacketSequence = seq; - OnPreAgentUpdate?.Invoke(this, m_thisAgentUpdateArgs); + c.OnPreAgentUpdate?.Invoke(c, c.m_thisAgentUpdateArgs); bool movement; bool camera; double now = Util.GetTimeStampMS(); - if(now - m_thisAgentUpdateArgs.lastUpdateTS > 500.0) // at least 2 per sec + if(now - c.m_thisAgentUpdateArgs.lastUpdateTS > 500.0) // at least 2 per sec { movement = true; camera = true; } else { - movement = CheckAgentMovementUpdateSignificance(x); - camera = CheckAgentCameraUpdateSignificance(x); + movement = c.CheckAgentMovementUpdateSignificance(x); + camera = c.CheckAgentCameraUpdateSignificance(x); } // Was there a significant movement/state change? if (movement) { - m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation; - m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags; - m_thisAgentUpdateArgs.Far = x.Far; - m_thisAgentUpdateArgs.Flags = x.Flags; - m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; - m_thisAgentUpdateArgs.State = x.State; + c.m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation; + c.m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags; + c.m_thisAgentUpdateArgs.Far = x.Far; + c.m_thisAgentUpdateArgs.Flags = x.Flags; + c.m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; + c.m_thisAgentUpdateArgs.State = x.State; - m_thisAgentUpdateArgs.NeedsCameraCollision = !camera; + c.m_thisAgentUpdateArgs.NeedsCameraCollision = !camera; - OnAgentUpdate?.Invoke(this, m_thisAgentUpdateArgs); + c.OnAgentUpdate?.Invoke(c, c.m_thisAgentUpdateArgs); } // Was there a significant camera(s) change? if (camera) { - m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; - m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter; - m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; - m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; + c.m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; + c.m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter; + c.m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; + c.m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; - m_thisAgentUpdateArgs.NeedsCameraCollision = true; + c.m_thisAgentUpdateArgs.NeedsCameraCollision = true; - OnAgentCameraUpdate?.Invoke(this, m_thisAgentUpdateArgs); + c.OnAgentCameraUpdate?.Invoke(c, c.m_thisAgentUpdateArgs); } if(movement && camera) - m_thisAgentUpdateArgs.lastUpdateTS = now; + c.m_thisAgentUpdateArgs.lastUpdateTS = now; } - private void HandleMoneyTransferRequest(Packet Pack) + + private static void HandleMoneyTransferRequest(LLClientView c, Packet Pack) { - if(OnMoneyTransferRequest is null) + if(c.OnMoneyTransferRequest is null) return; MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack; - // validate the agent owns the agentID and sessionID - if (money.MoneyData.SourceID.Equals(m_agentId) && money.AgentData.AgentID.Equals(m_agentId) && - money.AgentData.SessionID.Equals(m_sessionId)) - { - OnMoneyTransferRequest?.Invoke(money.MoneyData.SourceID, money.MoneyData.DestID, + c.OnMoneyTransferRequest?.Invoke(money.MoneyData.SourceID, money.MoneyData.DestID, money.MoneyData.Amount, money.MoneyData.TransactionType, Util.FieldToString(money.MoneyData.Description)); - } } - private void HandleParcelGodMarkAsContent(Packet packet) + private static void HandleParcelGodMarkAsContent(LLClientView c, Packet packet) { - if(OnParcelGodMark is null) + if(c.OnParcelGodMark is null) return; ParcelGodMarkAsContentPacket ParcelGodMarkAsContent = (ParcelGodMarkAsContentPacket)packet; - if(m_sessionId != ParcelGodMarkAsContent.AgentData.SessionID || m_agentId != ParcelGodMarkAsContent.AgentData.AgentID) - return; - - OnParcelGodMark?.Invoke(this, - m_agentId, + c.OnParcelGodMark?.Invoke(c, + c.m_agentId, ParcelGodMarkAsContent.ParcelData.LocalID); } - private void HandleFreezeUser(Packet packet) + private static void HandleFreezeUser(LLClientView c, Packet packet) { - if(OnParcelFreezeUser is null) + if(c.OnParcelFreezeUser is null) return; FreezeUserPacket FreezeUser = (FreezeUserPacket)packet; - if(m_sessionId != FreezeUser.AgentData.SessionID || m_agentId != FreezeUser.AgentData.AgentID) - return; - - OnParcelFreezeUser?.Invoke(this, - m_agentId, + c.OnParcelFreezeUser?.Invoke(c, + c.m_agentId, FreezeUser.Data.Flags, FreezeUser.Data.TargetID); } - private void HandleEjectUser(Packet packet) + private static void HandleEjectUser(LLClientView c, Packet packet) { - if(OnParcelEjectUser is null) + if(c.OnParcelEjectUser is null) return; EjectUserPacket EjectUser = (EjectUserPacket)packet; - if(m_sessionId != EjectUser.AgentData.SessionID || m_agentId != EjectUser.AgentData.AgentID) - return; - - OnParcelEjectUser?.Invoke(this, - m_agentId, + c.OnParcelEjectUser?.Invoke(c, + c.m_agentId, EjectUser.Data.Flags, EjectUser.Data.TargetID); } - private void HandleParcelBuyPass(Packet packet) + private static void HandleParcelBuyPass(LLClientView c, Packet packet) { - if(OnParcelBuyPass is null) + if(c.OnParcelBuyPass is null) return; ParcelBuyPassPacket ParcelBuyPass = (ParcelBuyPassPacket)packet; - - if(m_sessionId != ParcelBuyPass.AgentData.SessionID || m_agentId != ParcelBuyPass.AgentData.AgentID) - return; - - OnParcelBuyPass?.Invoke(this, - m_agentId, + c.OnParcelBuyPass?.Invoke(c, + c.m_agentId, ParcelBuyPass.ParcelData.LocalID); } - private void HandleParcelBuyRequest(Packet Pack) + private static void HandleParcelBuyRequest(LLClientView c, Packet Pack) { ParcelBuyPacket parcel = (ParcelBuyPacket)Pack; - if (parcel.AgentData.AgentID.Equals(m_agentId) && parcel.AgentData.SessionID.Equals(m_sessionId)) - { - OnParcelBuy?.Invoke(m_agentId, parcel.Data.GroupID, parcel.Data.Final, + c.OnParcelBuy?.Invoke(c.m_agentId, parcel.Data.GroupID, parcel.Data.Final, parcel.Data.IsGroupOwned, parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area, parcel.ParcelData.Price, false); - } } - private void HandleUUIDGroupNameRequest(Packet Pack) + private static void HandleUUIDGroupNameRequest(LLClientView c, Packet Pack) { - if(OnUUIDGroupNameRequest is null) + if(c.OnUUIDGroupNameRequest is null) return; - ScenePresence sp = (ScenePresence)SceneAgent; + ScenePresence sp = (ScenePresence)c.SceneAgent; if(sp is null || sp.IsDeleted || (sp.IsInTransit && !sp.IsInLocalTransit)) return; UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack; for (int i = 0; i < upack.UUIDNameBlock.Length; i++) { - OnUUIDGroupNameRequest?.Invoke(upack.UUIDNameBlock[i].ID, this); + c.OnUUIDGroupNameRequest?.Invoke(upack.UUIDNameBlock[i].ID, c); } } - public void HandleGenericMessage(Packet pack) + public static void HandleGenericMessage(LLClientView c, Packet pack) { - if (m_genericPacketHandlers.Count == 0) + if (c.m_genericPacketHandlers.Count == 0) return; GenericMessagePacket gmpack = (GenericMessagePacket)pack; - if (gmpack.AgentData.SessionID.NotEqual(m_sessionId) || gmpack.AgentData.AgentID.NotEqual(m_agentId)) - return; string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim(); - if (m_genericPacketHandlers.TryGetValue(method, out GenericMessage handlerGenericMessage)) + if (c.m_genericPacketHandlers.TryGetValue(method, out GenericMessage handlerGenericMessage)) { List msg = new(); List msgBytes = new(); @@ -8684,8 +8710,8 @@ public void HandleGenericMessage(Packet pack) try { - OnBinaryGenericMessage?.Invoke(this, method, msgBytes.ToArray()); - handlerGenericMessage?.Invoke(this, method, msg); + c.OnBinaryGenericMessage?.Invoke(c, method, msgBytes.ToArray()); + handlerGenericMessage?.Invoke(c, method, msg); } catch (Exception e) { @@ -8695,33 +8721,24 @@ public void HandleGenericMessage(Packet pack) } } - public void HandleObjectGroupRequest(Packet Pack) + public static void HandleObjectGroupRequest(LLClientView c, Packet Pack) { - if(OnObjectGroupRequest is null) + if(c.OnObjectGroupRequest is null) return; ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack; - if (ogpack.AgentData.SessionID.NotEqual(m_sessionId)) - return; - for (int i = 0; i < ogpack.ObjectData.Length; i++) - { - OnObjectGroupRequest?.Invoke(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero); - } + c.OnObjectGroupRequest?.Invoke(c, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero); } - private void HandleViewerEffect(Packet Pack) + private static void HandleViewerEffect(LLClientView c, Packet Pack) { - if(OnViewerEffect is null) + if(c.OnViewerEffect is null) return; ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; - if (viewer.AgentData.SessionID.NotEqual(m_sessionId) || m_agentId != viewer.AgentData.AgentID) - return; - - int length = viewer.Effect.Length; - List args = new(length); - for (int i = 0; i < length; i++) + List args = new(viewer.Effect.Length); + for (int i = 0; i < viewer.Effect.Length; i++) { //copy the effects block arguments into the event handler arg. ViewerEffectEventHandlerArg argument = new() @@ -8735,75 +8752,55 @@ private void HandleViewerEffect(Packet Pack) }; args.Add(argument); } - OnViewerEffect?.Invoke(this, args); + c.OnViewerEffect?.Invoke(c, args); } - private void HandleVelocityInterpolateOff(Packet Pack) + private static void HandleVelocityInterpolateOff(LLClientView c, Packet Pack) { - VelocityInterpolateOffPacket p = (VelocityInterpolateOffPacket)Pack; - if (p.AgentData.SessionID.NotEqual(m_sessionId) || p.AgentData.AgentID.NotEqual(m_agentId)) - return ; - - m_VelocityInterpolate = false; + c.m_VelocityInterpolate = false; } - private void HandleVelocityInterpolateOn(Packet Pack) + private static void HandleVelocityInterpolateOn(LLClientView c, Packet Pack) { - VelocityInterpolateOnPacket p = (VelocityInterpolateOnPacket)Pack; - if (p.AgentData.SessionID.NotEqual(m_sessionId) || p.AgentData.AgentID.NotEqual(m_agentId)) - return; - - m_VelocityInterpolate = true; + c.m_VelocityInterpolate = true; } - private void HandleAvatarPropertiesRequest(Packet Pack) + private static void HandleAvatarPropertiesRequest(LLClientView c, Packet Pack) { AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack; - - if (avatarProperties.AgentData.SessionID.NotEqual(m_sessionId) || avatarProperties.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnRequestAvatarProperties?.Invoke(this, avatarProperties.AgentData.AvatarID); + c.OnRequestAvatarProperties?.Invoke(c, avatarProperties.AgentData.AvatarID); } - private void HandleChatFromViewer(Packet Pack) + private static void HandleChatFromViewer(LLClientView c, Packet Pack) { - if (OnChatFromClient is null) + if (c.OnChatFromClient is null) return; ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; - - if (inchatpack.AgentData.SessionID.NotEqual(m_sessionId) || inchatpack.AgentData.AgentID.NotEqual(m_agentId)) - return; - ChatFromViewerPacket.ChatDataBlock packdata = inchatpack.ChatData; OSChatMessage args = new() { Channel = packdata.Channel, Message = Utils.BytesToString(packdata.Message), Type = (ChatTypeEnum)packdata.Type, - Position = SceneAgent.AbsolutePosition, + Position = c.SceneAgent.AbsolutePosition, - Scene = Scene, - Sender = this + Scene = c.Scene, + Sender = c }; - OnChatFromClient?.Invoke(this, args); + c.OnChatFromClient?.Invoke(c, args); } - private void HandlerAvatarPropertiesUpdate(Packet Pack) + private static void HandlerAvatarPropertiesUpdate(LLClientView c, Packet Pack) { - if (OnUpdateAvatarProperties is null) + if (c.OnUpdateAvatarProperties is null) return; AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack; - - if (avatarProps.AgentData.SessionID.NotEqual(m_sessionId) || avatarProps.AgentData.AgentID.NotEqual(m_agentId)) - return; - AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData; UserProfileProperties UserProfile = new() { - UserId = AgentId, + UserId = c.AgentId, WebUrl = Utils.BytesToString(Properties.ProfileURL), ImageId = Properties.ImageID, FirstLifeImageId = Properties.FLImageID, @@ -8812,44 +8809,38 @@ private void HandlerAvatarPropertiesUpdate(Packet Pack) PublishProfile = Properties.AllowPublish, PublishMature = Properties.MaturePublish }; - OnUpdateAvatarProperties?.Invoke(this, UserProfile); + c.OnUpdateAvatarProperties?.Invoke(c, UserProfile); } - private void HandlerScriptDialogReply(Packet Pack) + private static void HandlerScriptDialogReply(LLClientView c, Packet Pack) { - if (OnChatFromClient is null) + if (c.OnChatFromClient is null) return; ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack; //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID); - if (rdialog.AgentData.SessionID.NotEqual(m_sessionId) || rdialog.AgentData.AgentID.NotEqual(m_agentId)) - return; - ScriptDialogReplyPacket.DataBlock rdialogData = rdialog.Data; OSChatMessage args = new() { Channel = rdialogData.ChatChannel, Message = Utils.BytesToString(rdialogData.ButtonLabel), Type = ChatTypeEnum.Region, //Behaviour in SL is that the response can be heard from any distance - Scene = Scene, - Sender = this + Scene = c.Scene, + Sender = c }; - OnChatFromClient?.Invoke(this, args); + c.OnChatFromClient?.Invoke(c, args); } - private void HandlerImprovedInstantMessage(Packet Pack) + private static void HandlerImprovedInstantMessage(LLClientView c, Packet Pack) { - if(OnInstantMessage is null) + if(c.OnInstantMessage is null) return; ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack; - if (msgpack.AgentData.SessionID.NotEqual(m_sessionId) || msgpack.AgentData.AgentID.NotEqual(m_agentId)) - return; - string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message); - GridInstantMessage im = new(Scene, + GridInstantMessage im = new(c.Scene, msgpack.AgentData.AgentID, IMfromName, msgpack.MessageBlock.ToAgentID, @@ -8862,18 +8853,15 @@ private void HandlerImprovedInstantMessage(Packet Pack) msgpack.MessageBlock.BinaryBucket, true); - OnInstantMessage?.Invoke(this, im); + c.OnInstantMessage?.Invoke(c, im); } - private void HandlerAcceptFriendship(Packet Pack) + private static void HandlerAcceptFriendship(LLClientView c, Packet Pack) { - if(OnApproveFriendRequest is null) + if(c.OnApproveFriendRequest is null) return; AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack; - if (afriendpack.AgentData.SessionID.NotEqual(m_sessionId) || afriendpack.AgentData.AgentID.NotEqual(m_agentId)) - return; - // My guess is this is the folder to stick the calling card into List callingCardFolders = new(); UUID transactionID = afriendpack.TransactionBlock.TransactionID; @@ -8883,62 +8871,44 @@ private void HandlerAcceptFriendship(Packet Pack) callingCardFolders.Add(afriendpack.FolderData[fi].FolderID); } - OnApproveFriendRequest?.Invoke(this, transactionID, callingCardFolders); + c.OnApproveFriendRequest?.Invoke(c, transactionID, callingCardFolders); } - private void HandlerDeclineFriendship(Packet Pack) + private static void HandlerDeclineFriendship(LLClientView c, Packet Pack) { DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack; - - if (dfriendpack.AgentData.SessionID.NotEqual(m_sessionId) || dfriendpack.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnDenyFriendRequest?.Invoke(this, - dfriendpack.TransactionBlock.TransactionID, - null); + c.OnDenyFriendRequest?.Invoke(c, dfriendpack.TransactionBlock.TransactionID, null); } - private void HandlerTerminateFriendship(Packet Pack) + private static void HandlerTerminateFriendship(LLClientView c, Packet Pack) { TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack; - - if (tfriendpack.AgentData.SessionID.NotEqual(m_sessionId) || tfriendpack.AgentData.AgentID.NotEqual(m_agentId)) - return; - UUID exFriendID = tfriendpack.ExBlock.OtherID; - FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship; - TerminateFriendshipHandler?.Invoke(this, exFriendID); + FriendshipTermination TerminateFriendshipHandler = c.OnTerminateFriendship; + TerminateFriendshipHandler?.Invoke(c, exFriendID); } - private void HandleFindAgent(Packet packet) + private static void HandleFindAgent(LLClientView c, Packet packet) { FindAgentPacket FindAgent = (FindAgentPacket)packet; - OnFindAgent?.Invoke(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey); + c.OnFindAgent?.Invoke(c, FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey); } - private void HandleTrackAgent(Packet packet) + private static void HandleTrackAgent(LLClientView c, Packet packet) { TrackAgentPacket TrackAgent = (TrackAgentPacket)packet; - - if(TrackAgent.AgentData.AgentID.NotEqual(m_agentId) || TrackAgent.AgentData.SessionID.NotEqual(m_sessionId)) - return; - - OnTrackAgent?.Invoke(this, + c.OnTrackAgent?.Invoke(c, TrackAgent.AgentData.AgentID, TrackAgent.TargetData.PreyID); } - private void HandlerRezObject(Packet Pack) + private static void HandlerRezObject(LLClientView c, Packet Pack) { RezObjectPacket rezPacket = (RezObjectPacket)Pack; - - if (rezPacket.AgentData.SessionID.NotEqual(m_sessionId) || rezPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - UUID rezGroupID = rezPacket.AgentData.GroupID; - if(!IsGroupMember(rezGroupID)) + if(!c.IsGroupMember(rezGroupID)) rezGroupID = UUID.Zero; - OnRezObject?.Invoke(this, rezPacket.InventoryData.ItemID, rezGroupID, rezPacket.RezData.RayEnd, + c.OnRezObject?.Invoke(c, rezPacket.InventoryData.ItemID, rezGroupID, rezPacket.RezData.RayEnd, rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID, rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection, rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem, @@ -8952,16 +8922,12 @@ private class DeRezObjectInfo } private Dictionary m_DeRezObjectDelayed; - private void HandlerDeRezObject(Packet Pack) + private static void HandlerDeRezObject(LLClientView c, Packet Pack) { - if (OnDeRezObject is null) + if (c.OnDeRezObject is null) return; DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack; - DeRezObjectPacket.AgentDataBlock DeRezPacketAgentData = DeRezPacket.AgentData; - if (DeRezPacketAgentData.AgentID.NotEqual(m_agentId) || DeRezPacketAgentData.SessionID.NotEqual(m_sessionId)) - return; - List deRezIDs; DeRezObjectPacket.AgentBlockBlock DeRezPacketAgentBlock = DeRezPacket.AgentBlock; DeRezAction action = (DeRezAction)DeRezPacketAgentBlock.Destination; @@ -8971,9 +8937,9 @@ private void HandlerDeRezObject(Packet Pack) if (numberPackets > 1) { - m_DeRezObjectDelayed ??= new Dictionary(); + c.m_DeRezObjectDelayed ??= new Dictionary(); - if (!m_DeRezObjectDelayed.TryGetValue(id, out DeRezObjectInfo info)) + if (!c.m_DeRezObjectDelayed.TryGetValue(id, out DeRezObjectInfo info)) { deRezIDs = new List(DeRezPacket.ObjectData.Length); info = new DeRezObjectInfo @@ -8981,7 +8947,7 @@ private void HandlerDeRezObject(Packet Pack) rcvedpackets = new HashSet() { curPacket }, objectids = deRezIDs }; - m_DeRezObjectDelayed[id] = info; + c.m_DeRezObjectDelayed[id] = info; } else { @@ -8999,7 +8965,7 @@ private void HandlerDeRezObject(Packet Pack) if (info.rcvedpackets.Count < numberPackets) return; - m_DeRezObjectDelayed.Remove(id); + c.m_DeRezObjectDelayed.Remove(id); info.objectids = null; info.rcvedpackets = null; } @@ -9012,23 +8978,19 @@ private void HandlerDeRezObject(Packet Pack) } } - OnDeRezObject?.Invoke(this, deRezIDs, DeRezPacketAgentBlock.GroupID, + c.OnDeRezObject?.Invoke(c, deRezIDs, DeRezPacketAgentBlock.GroupID, action, DeRezPacketAgentBlock.DestinationID); } - private void HandlerRezRestoreToWorld(Packet Pack) + private static void HandlerRezRestoreToWorld(LLClientView c, Packet Pack) { RezRestoreToWorldPacket restore = (RezRestoreToWorldPacket)Pack; - - if (restore.AgentData.SessionID.NotEqual(m_sessionId) || restore.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnRezRestoreToWorld?.Invoke(this, restore.InventoryData.ItemID); + c.OnRezRestoreToWorld?.Invoke(c, restore.InventoryData.ItemID); } - private void HandlerModifyLand(Packet Pack) + private static void HandlerModifyLand(LLClientView c, Packet Pack) { - if (OnModifyTerrain is null) + if (c.OnModifyTerrain is null) return; ModifyLandPacket modify = (ModifyLandPacket)Pack; @@ -9036,13 +8998,10 @@ private void HandlerModifyLand(Packet Pack) if (modify.ParcelData.Length == 0) return; - if (modify.AgentData.SessionID.NotEqual(m_sessionId) || modify.AgentData.AgentID.NotEqual(m_agentId)) - return; - //m_log.Info("[LAND]: LAND:" + modify.ToString()); for (int i = 0; i < modify.ParcelData.Length; i++) { - OnModifyTerrain?.Invoke(m_agentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, + c.OnModifyTerrain?.Invoke(c.m_agentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlockExtended[i].BrushSize, modify.ModifyBlock.Action, modify.ParcelData[i].North, modify.ParcelData[i].West, modify.ParcelData[i].South, modify.ParcelData[i].East, @@ -9052,38 +9011,32 @@ private void HandlerModifyLand(Packet Pack) public uint m_viewerHandShakeFlags = 0; - private void HandlerRegionHandshakeReply(Packet Pack) + private static void HandlerRegionHandshakeReply(LLClientView c, Packet Pack) { - if (OnRegionHandShakeReply is null) + if (c.OnRegionHandShakeReply is null) return; // silence the warning RegionHandshakeReplyPacket rsrpkt = (RegionHandshakeReplyPacket)Pack; - if(rsrpkt.AgentData.AgentID.NotEqual(m_agentId) || rsrpkt.AgentData.SessionID.NotEqual(m_sessionId)) - return; - - if(m_supportViewerCache) - m_viewerHandShakeFlags = rsrpkt.RegionInfo.Flags; + if(c.m_supportViewerCache) + c.m_viewerHandShakeFlags = rsrpkt.RegionInfo.Flags; else - m_viewerHandShakeFlags = 0; + c.m_viewerHandShakeFlags = 0; - OnRegionHandShakeReply?.Invoke(this); + c.OnRegionHandShakeReply?.Invoke(c); } - private void HandlerAgentWearablesRequest(Packet Pack) + private static void HandlerAgentWearablesRequest(LLClientView c, Packet Pack) { - OnRequestWearables?.Invoke(this); - OnRequestAvatarsData?.Invoke(this); + c.OnRequestWearables?.Invoke(c); + c.OnRequestAvatarsData?.Invoke(c); } - private void HandlerAgentSetAppearance(Packet Pack) + private static void HandlerAgentSetAppearance(LLClientView c, Packet Pack) { - if(OnSetAppearance is null) + if(c.OnSetAppearance is null) return; AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; - if (appear.AgentData.SessionID.NotEqual(m_sessionId) || appear.AgentData.AgentID.NotEqual(m_agentId)) - return; - try { Vector3 avSize = appear.AgentData.Size; @@ -9103,26 +9056,20 @@ private void HandlerAgentSetAppearance(Packet Pack) TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex) }; - OnSetAppearance?.Invoke(this, te, visualparams,avSize, cacheitems); + c.OnSetAppearance?.Invoke(c, te, visualparams,avSize, cacheitems); } catch (Exception e) { - m_log.ErrorFormat( - "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}", - e); + m_log.Error($"[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {e.Message}"); } } - private void HandlerAgentIsNowWearing(Packet Pack) + private static void HandlerAgentIsNowWearing(LLClientView c, Packet Pack) { - if (OnAvatarNowWearing is null) + if (c.OnAvatarNowWearing is null) return; AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack; - - if (nowWearing.AgentData.SessionID.NotEqual(m_sessionId) || nowWearing.AgentData.AgentID.NotEqual(m_agentId)) - return; - AvatarWearingArgs wearingArgs = new(); for (int i = 0; i < nowWearing.WearableData.Length; i++) { @@ -9132,166 +9079,133 @@ private void HandlerAgentIsNowWearing(Packet Pack) wearingArgs.NowWearing.Add(wearable); } - OnAvatarNowWearing?.Invoke(this, wearingArgs); + c.OnAvatarNowWearing?.Invoke(c, wearingArgs); } - private void HandlerRezSingleAttachmentFromInv(Packet Pack) + private static void HandlerRezSingleAttachmentFromInv(LLClientView c, Packet Pack) { RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack; - if (rez.AgentData.SessionID.NotEqual(m_sessionId) || rez.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnRezSingleAttachmentFromInv?.Invoke(this, rez.ObjectData.ItemID, + c.OnRezSingleAttachmentFromInv?.Invoke(c, rez.ObjectData.ItemID, rez.ObjectData.AttachmentPt); } - private void HandleRezMultipleAttachmentsFromInv(Packet Pack) + private static void HandleRezMultipleAttachmentsFromInv(LLClientView c, Packet Pack) { - if(OnRezMultipleAttachmentsFromInv is null) + if(c.OnRezMultipleAttachmentsFromInv is null) return; RezMultipleAttachmentsFromInvPacket rez = (RezMultipleAttachmentsFromInvPacket)Pack; - RezMultipleAttachmentsFromInvPacket.AgentDataBlock rezAgentData = rez.AgentData; - if (rezAgentData.SessionID.NotEqual(m_sessionId) || rezAgentData.AgentID.NotEqual(m_agentId)) - return; - List> rezlist = new(); foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in rez.ObjectData) rezlist.Add(new KeyValuePair(obj.ItemID, obj.AttachmentPt)); - OnRezMultipleAttachmentsFromInv?.Invoke(this, rezlist); + c.OnRezMultipleAttachmentsFromInv?.Invoke(c, rezlist); } - private void HandleDetachAttachmentIntoInv(Packet Pack) + private static void HandleDetachAttachmentIntoInv(LLClientView c, Packet Pack) { - if (OnDetachAttachmentIntoInv is null) + if (c.OnDetachAttachmentIntoInv is null) return; - DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack; - if(detachtoInv.ObjectData.AgentID.NotEqual(m_agentId)) - return; + DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack; + if(detachtoInv.ObjectData.AgentID.NotEqual(c.m_agentId)) + return; - OnDetachAttachmentIntoInv?.Invoke(detachtoInv.ObjectData.ItemID, this); + c.OnDetachAttachmentIntoInv?.Invoke(detachtoInv.ObjectData.ItemID, c); } - private void HandleObjectAttach(Packet Pack) + private static void HandleObjectAttach(LLClientView c, Packet Pack) { - if (OnObjectAttach is null) + if (c.OnObjectAttach is null) return; ObjectAttachPacket att = (ObjectAttachPacket)Pack; - if (att.AgentData.SessionID.NotEqual(m_sessionId) || att.AgentData.AgentID.NotEqual(m_agentId)) - return; - if (att.ObjectData.Length > 0) - OnObjectAttach?.Invoke(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false); + c.OnObjectAttach?.Invoke(c, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false); } - private void HandleObjectDetach(Packet Pack) + private static void HandleObjectDetach(LLClientView c, Packet Pack) { - if(OnObjectDetach is null) + if(c.OnObjectDetach is null) return; ObjectDetachPacket dett = (ObjectDetachPacket)Pack; - if (dett.AgentData.SessionID.NotEqual(m_sessionId) || dett.AgentData.AgentID.NotEqual(m_agentId)) - return; - for (int j = 0; j < dett.ObjectData.Length; j++) { uint obj = dett.ObjectData[j].ObjectLocalID; - OnObjectDetach?.Invoke(obj, this); + c.OnObjectDetach?.Invoke(obj, c); } } - private void HandleObjectDrop(Packet Pack) + private static void HandleObjectDrop(LLClientView c, Packet Pack) { - if(OnObjectDrop is null) + if(c.OnObjectDrop is null) return; ObjectDropPacket dropp = (ObjectDropPacket)Pack; - - if (dropp.AgentData.SessionID.NotEqual(m_sessionId) || dropp.AgentData.AgentID.NotEqual(m_agentId)) - return; - for (int j = 0; j < dropp.ObjectData.Length; j++) { uint obj = dropp.ObjectData[j].ObjectLocalID; - OnObjectDrop?.Invoke(obj, this); + c.OnObjectDrop?.Invoke(obj, c); } } - private void HandleSetAlwaysRun(Packet Pack) + private static void HandleSetAlwaysRun(LLClientView c, Packet Pack) { SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; - - if (run.AgentData.SessionID.NotEqual(m_sessionId) || run.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnSetAlwaysRun?.Invoke(this, run.AgentData.AlwaysRun); + c.OnSetAlwaysRun?.Invoke(c, run.AgentData.AlwaysRun); } - private void HandleCompleteAgentMovement(Packet Pack) + private static void HandleCompleteAgentMovement(LLClientView c, Packet Pack) { //m_log.DebugFormat("[LLClientView] HandleCompleteAgentMovement"); CompleteAgentMovementPacket cmp = (CompleteAgentMovementPacket)Pack; - if(cmp.AgentData.AgentID.NotEqual(m_agentId) || cmp.AgentData.SessionID.NotEqual(m_sessionId) || cmp.AgentData.CircuitCode != m_circuitCode) - return; - - OnCompleteMovementToRegion?.Invoke(this, true); + if(cmp.AgentData.CircuitCode == c.m_circuitCode) + c.OnCompleteMovementToRegion?.Invoke(c, true); } - private void HandleAgentAnimation(Packet Pack) + private static void HandleAgentAnimation(LLClientView c, Packet Pack) { - if(OnChangeAnim is null) + if(c.OnChangeAnim is null) return; AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; - if (AgentAni.AgentData.SessionID.NotEqual(m_sessionId) || AgentAni.AgentData.AgentID.NotEqual(m_agentId)) - return; - for (int i = 0; i < AgentAni.AnimationList.Length; i++) - OnChangeAnim?.Invoke(AgentAni.AnimationList[i].AnimID, AgentAni.AnimationList[i].StartAnim, false); + c.OnChangeAnim?.Invoke(AgentAni.AnimationList[i].AnimID, AgentAni.AnimationList[i].StartAnim, false); - OnChangeAnim?.Invoke(UUID.Zero, false, true); + c.OnChangeAnim?.Invoke(UUID.Zero, false, true); } - private void HandleAgentRequestSit(Packet Pack) + private static void HandleAgentRequestSit(LLClientView c, Packet Pack) { - if (OnAgentRequestSit is null) - return; - - AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack; - - if (agentRequestSit.AgentData.SessionID.NotEqual(m_sessionId) || agentRequestSit.AgentData.AgentID.NotEqual(m_agentId)) + if (c.OnAgentRequestSit is null) return; - if (SceneAgent.IsChildAgent) + if (c.SceneAgent.IsChildAgent) { - SendCantSitBecauseChildAgentResponse(); + c.SendCantSitBecauseChildAgentResponse(); return; } - OnAgentRequestSit?.Invoke(this, agentRequestSit.AgentData.AgentID, + AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack; + c.OnAgentRequestSit?.Invoke(c, agentRequestSit.AgentData.AgentID, agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); } - private void HandleAgentSit(Packet Pack) + private static void HandleAgentSit(LLClientView c, Packet Pack) { - if (OnAgentSit is null) + if (c.OnAgentSit is null) return; - AgentSitPacket agentSit = (AgentSitPacket)Pack; - if (agentSit.AgentData.SessionID.NotEqual(m_sessionId) || agentSit.AgentData.AgentID.NotEqual(m_agentId)) - return; - - if (SceneAgent.IsChildAgent) + if (c.SceneAgent.IsChildAgent) { - SendCantSitBecauseChildAgentResponse(); + c.SendCantSitBecauseChildAgentResponse(); return; } - OnAgentSit?.Invoke(this, agentSit.AgentData.AgentID); + AgentSitPacket agentSit = (AgentSitPacket)Pack; + c.OnAgentSit?.Invoke(c, agentSit.AgentData.AgentID); } /// @@ -9299,88 +9213,73 @@ private void HandleAgentSit(Packet Pack) /// private void SendCantSitBecauseChildAgentResponse() { - SendAlertMessage("Try moving closer. Can't sit on object because it is not in the same region as you."); + SendAlertMessage("Can't sit on object because it is not in the same region as you."); } - private void HandleSoundTrigger(Packet Pack) + private static void HandleSoundTrigger(LLClientView c, Packet Pack) { SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack; - // UUIDS are sent as zeroes by the client, substitute agent's id - OnSoundTrigger?.Invoke(soundTriggerPacket.SoundData.SoundID, m_agentId, - m_agentId, m_agentId, + // UUIDS are sent as zeroes by the client, substitute agent's id + c.OnSoundTrigger?.Invoke(soundTriggerPacket.SoundData.SoundID, c.m_agentId, + c.m_agentId, c.m_agentId, soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position, soundTriggerPacket.SoundData.Handle); } - private void HandleAvatarPickerRequest(Packet Pack) + private static void HandleAvatarPickerRequest(LLClientView c, Packet Pack) { AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack; - - if (avRequestQuery.AgentData.SessionID.NotEqual(m_sessionId) || avRequestQuery.AgentData.AgentID.NotEqual(m_agentId)) - return; - AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name)); - OnAvatarPickerRequest?.Invoke(this, Requestdata.AgentID, Requestdata.QueryID, + c.OnAvatarPickerRequest?.Invoke(c, Requestdata.AgentID, Requestdata.QueryID, Utils.BytesToString(querydata.Name)); } - private void HandleAgentDataUpdateRequest(Packet Pack) + private static void HandleAgentDataUpdateRequest(LLClientView c, Packet Pack) { AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack; - - if (avRequestDataUpdatePacket.AgentData.SessionID.NotEqual(m_sessionId) || avRequestDataUpdatePacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnAgentDataUpdateRequest?.Invoke(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID); + c.OnAgentDataUpdateRequest?.Invoke(c, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID); } - private void HandleUserInfoRequest(Packet Pack) + private static void HandleUserInfoRequest(LLClientView c, Packet _) { - if (OnUserInfoRequest != null) + if (c.OnUserInfoRequest != null) { - OnUserInfoRequest(this); + c.OnUserInfoRequest(c); } else { - SendUserInfoReply(false, true, ""); + c.SendUserInfoReply(false, true, ""); } } - private void HandleUpdateUserInfo(Packet Pack) + private static void HandleUpdateUserInfo(LLClientView c, Packet Pack) { - if(OnUpdateUserInfo is null) + if(c.OnUpdateUserInfo is null) return; UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack; - if (updateUserInfo.AgentData.SessionID.NotEqual(m_sessionId) || updateUserInfo.AgentData.AgentID.NotEqual(m_agentId)) - return; - bool visible = true; string DirectoryVisibility = Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility); if (DirectoryVisibility == "hidden") visible = false; - OnUpdateUserInfo?.Invoke( updateUserInfo.UserData.IMViaEMail, visible, this); + c.OnUpdateUserInfo?.Invoke( updateUserInfo.UserData.IMViaEMail, visible, c); } - private void HandleSetStartLocationRequest(Packet Pack) + private static void HandleSetStartLocationRequest(LLClientView c, Packet Pack) { SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack; - if (avSetStartLocationRequestPacket.AgentData.SessionID.NotEqual(m_sessionId) || - avSetStartLocationRequestPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - float packX = avSetStartLocationRequestPacket.StartLocationData.LocationPos.X; float packY = avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y; // Linden Client limitation.. if (packX == 255.5f || packY == 255.5f) { - if (((Scene)m_scene).TryGetScenePresence(m_agentId, out ScenePresence avatar)) + if (c.m_scene.TryGetScenePresence(c.m_agentId, out ScenePresence avatar)) { if (packX == 255.5f) { @@ -9393,49 +9292,42 @@ private void HandleSetStartLocationRequest(Packet Pack) } } - OnSetStartLocationRequest?.Invoke(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos, + c.OnSetStartLocationRequest?.Invoke(c, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos, avSetStartLocationRequestPacket.StartLocationData.LocationLookAt, avSetStartLocationRequestPacket.StartLocationData.LocationID); } - private void HandleAgentThrottle(Packet Pack) + private static void HandleAgentThrottle(LLClientView c, Packet Pack) { AgentThrottlePacket atpack = (AgentThrottlePacket)Pack; - - if (atpack.AgentData.SessionID.NotEqual(m_sessionId) || atpack.AgentData.AgentID.NotEqual(m_agentId)) - return; - - m_udpClient.SetThrottles(atpack.Throttle.Throttles); - OnUpdateThrottles?.Invoke(); + c.m_udpClient.SetThrottles(atpack.Throttle.Throttles); + c.OnUpdateThrottles?.Invoke(); } - private void HandleAgentPause(Packet Pack) + private static void HandleAgentPause(LLClientView c, Packet Pack) { - m_udpClient.IsPaused = true; + c.m_udpClient.IsPaused = true; } - private void HandleAgentResume(Packet Pack) + private static void HandleAgentResume(LLClientView c, Packet Pack) { - m_udpClient.IsPaused = false; - m_udpServer.SendPing(m_udpClient); + c.m_udpClient.IsPaused = false; + c.m_udpServer.SendPing(c.m_udpClient); } - private void HandleForceScriptControlRelease(Packet Pack) + private static void HandleForceScriptControlRelease(LLClientView c, Packet _) { - OnForceReleaseControls?.Invoke(this, m_agentId); + c.OnForceReleaseControls?.Invoke(c, c.m_agentId); } #endregion Scene/Avatar #region Objects/m_sceneObjects - private void HandleObjectLink(Packet Pack) + private static void HandleObjectLink(LLClientView c, Packet Pack) { ObjectLinkPacket link = (ObjectLinkPacket)Pack; - if (link.AgentData.SessionID.NotEqual(m_sessionId) || link.AgentData.AgentID.NotEqual(m_agentId)) - return; - uint parentprimid = 0; List childrenprims = new(); if (link.ObjectData.Length > 1) @@ -9447,16 +9339,13 @@ private void HandleObjectLink(Packet Pack) childrenprims.Add(link.ObjectData[i].ObjectLocalID); } } - OnLinkObjects?.Invoke(this, parentprimid, childrenprims); + c.OnLinkObjects?.Invoke(c, parentprimid, childrenprims); } - private void HandleObjectDelink(Packet Pack) + private static void HandleObjectDelink(LLClientView c, Packet Pack) { ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack; - if (delink.AgentData.SessionID.NotEqual(m_sessionId) || delink.AgentData.AgentID.NotEqual(m_agentId)) - return; - // It appears the prim at index 0 is not always the root prim (for // instance, when one prim of a link set has been edited independently // of the others). Therefore, we'll pass all the ids onto the delink @@ -9467,32 +9356,30 @@ private void HandleObjectDelink(Packet Pack) prims.Add(delink.ObjectData[i].ObjectLocalID); } - OnDelinkObjects?.Invoke(prims, this); + c.OnDelinkObjects?.Invoke(prims, c); } - private void HandleObjectAdd(Packet Pack) + private static void HandleObjectAdd(LLClientView c, Packet Pack) { ObjectAddPacket addPacket = (ObjectAddPacket)Pack; - if (addPacket.AgentData.SessionID.NotEqual(m_sessionId) || addPacket.AgentData.AgentID.NotEqual(m_agentId)) + if (addPacket.AgentData.SessionID.NotEqual(c.m_sessionId) || addPacket.AgentData.AgentID.NotEqual(c.m_agentId)) return; ObjectAddPacket.ObjectDataBlock datablk = addPacket.ObjectData; PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket); - OnAddPrim?.Invoke(m_agentId, addPacket.AgentData.GroupID, datablk.RayEnd, + c.OnAddPrim?.Invoke(c.m_agentId, addPacket.AgentData.GroupID, datablk.RayEnd, datablk.Rotation, shape, datablk.BypassRaycast, datablk.RayStart, datablk.RayTargetID, datablk.RayEndIsIntersection, datablk.AddFlags); } - private void HandleObjectShape(Packet Pack) + private static void HandleObjectShape(LLClientView c, Packet Pack) { - if(OnUpdatePrimShape is null) + if(c.OnUpdatePrimShape is null) return; ObjectShapePacket shapePacket = (ObjectShapePacket)Pack; - if (shapePacket.AgentData.SessionID.NotEqual(m_sessionId) || shapePacket.AgentData.AgentID.NotEqual(m_agentId)) - return; for (int i = 0; i < shapePacket.ObjectData.Length; i++) { @@ -9520,145 +9407,123 @@ private void HandleObjectShape(Packet Pack) ProfileHollow = shapePacket.ObjectData[i].ProfileHollow }; - OnUpdatePrimShape?.Invoke(m_agentId, id, shapeData); + c.OnUpdatePrimShape?.Invoke(c.m_agentId, id, shapeData); } } - private void HandleObjectExtraParams(Packet Pack) + private static void HandleObjectExtraParams(LLClientView c, Packet Pack) { ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack; - if (extraPar.AgentData.SessionID.NotEqual(m_sessionId) || extraPar.AgentData.AgentID.NotEqual(m_agentId)) - return; - ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams; - if (handlerUpdateExtraParams != null) + if (c.OnUpdateExtraParams != null) { for (int i = 0; i < extraPar.ObjectData.Length; i++) { - OnUpdateExtraParams?.Invoke(m_agentId, extraPar.ObjectData[i].ObjectLocalID, + c.OnUpdateExtraParams?.Invoke(c.m_agentId, extraPar.ObjectData[i].ObjectLocalID, extraPar.ObjectData[i].ParamType, extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData); } } } - private void HandleObjectDuplicate(Packet Pack) + private static void HandleObjectDuplicate(LLClientView c, Packet Pack) { - if(OnObjectDuplicate is null) + if(c.OnObjectDuplicate is null) return; ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack; - if (dupe.AgentData.SessionID.NotEqual(m_sessionId) || dupe.AgentData.AgentID.NotEqual(m_agentId)) - return; -// ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData; + UUID rezGroupID = c.IsGroupMember(dupe.AgentData.GroupID) ? dupe.AgentData.GroupID : UUID.Zero; + //ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData; for (int i = 0; i < dupe.ObjectData.Length; i++) { - UUID rezGroupID = dupe.AgentData.GroupID; - if(!IsGroupMember(rezGroupID)) - rezGroupID = UUID.Zero; - OnObjectDuplicate?.Invoke(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, - dupe.SharedData.DuplicateFlags, m_agentId, + c.OnObjectDuplicate?.Invoke(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, + dupe.SharedData.DuplicateFlags, c.m_agentId, rezGroupID); } } - private void HandleRequestMultipleObjects(Packet Pack) + private static void HandleRequestMultipleObjects(LLClientView c, Packet Pack) { - if (OnObjectRequest is null) + if (c.OnObjectRequest is null) return; RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack; - if (incomingRequest.AgentData.SessionID.NotEqual(m_sessionId) || incomingRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; for (int i = 0; i < incomingRequest.ObjectData.Length; i++) - OnObjectRequest?.Invoke(incomingRequest.ObjectData[i].ID, this); + c.OnObjectRequest?.Invoke(incomingRequest.ObjectData[i].ID, c); } - private void HandleObjectSelect(Packet Pack) + private static void HandleObjectSelect(LLClientView c, Packet Pack) { - if(OnObjectSelect is null) + if(c.OnObjectSelect is null) return; ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; - if (incomingselect.AgentData.SessionID.NotEqual(m_sessionId) || incomingselect.AgentData.AgentID.NotEqual(m_agentId)) - return; List thisSelection = new(); for (int i = 0; i < incomingselect.ObjectData.Length; i++) thisSelection.Add(incomingselect.ObjectData[i].ObjectLocalID); - OnObjectSelect?.Invoke(thisSelection, this); + c.OnObjectSelect?.Invoke(thisSelection, c); } - private void HandleObjectDeselect(Packet Pack) + private static void HandleObjectDeselect(LLClientView c, Packet Pack) { - if(OnObjectDeselect is null) + if(c.OnObjectDeselect is null) return; ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack; - if (incomingdeselect.AgentData.SessionID.NotEqual(m_sessionId) || incomingdeselect.AgentData.AgentID.NotEqual(m_agentId)) - return; for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) { - OnObjectDeselect?.Invoke(incomingdeselect.ObjectData[i].ObjectLocalID, this); + c.OnObjectDeselect?.Invoke(incomingdeselect.ObjectData[i].ObjectLocalID, c); } } - private void HandleObjectPosition(Packet Pack) + private static void HandleObjectPosition(LLClientView c, Packet Pack) { - if (OnUpdatePrimGroupPosition is null) + if (c.OnUpdatePrimGroupPosition is null) return; // DEPRECATED: but till libsecondlife removes it, people will use it ObjectPositionPacket position = (ObjectPositionPacket)Pack; - if (position.AgentData.SessionID.NotEqual(m_sessionId) || position.AgentData.AgentID.NotEqual(m_agentId)) - return; for (int i = 0; i < position.ObjectData.Length; i++) - OnUpdatePrimGroupPosition?.Invoke(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this); + c.OnUpdatePrimGroupPosition?.Invoke(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, c); } - private void HandleObjectScale(Packet Pack) + private static void HandleObjectScale(LLClientView c, Packet Pack) { - if (OnUpdatePrimGroupScale is null) + if (c.OnUpdatePrimGroupScale is null) return; // DEPRECATED: but till libsecondlife removes it, people will use it ObjectScalePacket scale = (ObjectScalePacket)Pack; - if (scale.AgentData.SessionID.NotEqual(m_sessionId) || scale.AgentData.AgentID.NotEqual(m_agentId)) - return; for (int i = 0; i < scale.ObjectData.Length; i++) - OnUpdatePrimGroupScale?.Invoke(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this); + c.OnUpdatePrimGroupScale?.Invoke(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, c); } - private void HandleObjectRotation(Packet Pack) + private static void HandleObjectRotation(LLClientView c, Packet Pack) { - if (OnUpdatePrimGroupRotation is null) + if (c.OnUpdatePrimGroupRotation is null) return; // DEPRECATED: but till libsecondlife removes it, people will use it ObjectRotationPacket rotation = (ObjectRotationPacket)Pack; - if (rotation.AgentData.SessionID.NotEqual(m_sessionId) || rotation.AgentData.AgentID.NotEqual(m_agentId)) - return; - for (int i = 0; i < rotation.ObjectData.Length; i++) - OnUpdatePrimGroupRotation?.Invoke(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this); + c.OnUpdatePrimGroupRotation?.Invoke(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, c); } - private void HandleObjectFlagUpdate(Packet Pack) + private static void HandleObjectFlagUpdate(LLClientView c, Packet Pack) { - if(OnUpdatePrimFlags is null) + if(c.OnUpdatePrimFlags is null) return; ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; - if (flags.AgentData.SessionID.NotEqual(m_sessionId) || flags.AgentData.AgentID.NotEqual(m_agentId)) - return; // byte[] data = Pack.ToBytes(); // 46,47,48 are special positions within the packet @@ -9670,7 +9535,7 @@ private void HandleObjectFlagUpdate(Packet Pack) bool IsPhantom = (data[48] != 0) ? true : false; handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this); */ - bool UsePhysics = flags.AgentData.UsePhysics; + bool UsePhysics = flags.AgentData.UsePhysics; bool IsPhantom = flags.AgentData.IsPhantom; bool IsTemporary = flags.AgentData.IsTemporary; ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = flags.ExtraPhysics; @@ -9690,29 +9555,24 @@ private void HandleObjectFlagUpdate(Packet Pack) physdata.GravitationModifier = phsblock.GravityMultiplier; } - OnUpdatePrimFlags?.Invoke(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this); + c.OnUpdatePrimFlags?.Invoke(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, c); } Dictionary objImageSeqs = null; double lastobjImageSeqsMS = 0.0; - private void HandleObjectImage(Packet Pack) + private static void HandleObjectImage(LLClientView c, Packet Pack) { - if (OnUpdatePrimTexture is null) + if (c.OnUpdatePrimTexture is null) return; ObjectImagePacket imagePack = (ObjectImagePacket)Pack; - if (imagePack.AgentData.SessionID.NotEqual(m_sessionId) || imagePack.AgentData.AgentID.NotEqual(m_agentId)) - return; double now = Util.GetTimeStampMS(); - if(objImageSeqs is null || ( now - lastobjImageSeqsMS > 30000.0)) - { - objImageSeqs = null; // yeah i know superstition... - objImageSeqs = new Dictionary(16); - } + if(c.objImageSeqs is null || ( now - c.lastobjImageSeqsMS > 30000.0)) + c.objImageSeqs = new Dictionary(16); - lastobjImageSeqsMS = now; + c.lastobjImageSeqsMS = now; uint seq = Pack.Header.Sequence; uint id; @@ -9721,24 +9581,22 @@ private void HandleObjectImage(Packet Pack) { o = imagePack.ObjectData[i]; id = o.ObjectLocalID; - if(objImageSeqs.TryGetValue(id, out uint lastseq)) + if(c.objImageSeqs.TryGetValue(id, out uint lastseq)) { if(seq <= lastseq) continue; } - objImageSeqs[id] = seq; - OnUpdatePrimTexture?.Invoke(id, o.TextureEntry, this); + c.objImageSeqs[id] = seq; + c.OnUpdatePrimTexture?.Invoke(id, o.TextureEntry, c); } } - private void HandleObjectGrab(Packet Pack) + private static void HandleObjectGrab(LLClientView c, Packet Pack) { - if(OnGrabObject is null) + if(c.OnGrabObject is null) return; ObjectGrabPacket grab = (ObjectGrabPacket)Pack; - if (grab.AgentData.SessionID.NotEqual(m_sessionId) || grab.AgentData.AgentID.NotEqual(m_agentId)) - return; List touchArgs = new(); if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0)) @@ -9757,17 +9615,15 @@ private void HandleObjectGrab(Packet Pack) touchArgs.Add(arg); } } - OnGrabObject?.Invoke(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs); + c.OnGrabObject?.Invoke(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, c, touchArgs); } - private void HandleObjectGrabUpdate(Packet Pack) + private static void HandleObjectGrabUpdate(LLClientView c, Packet Pack) { - if (OnGrabUpdate is null) + if (c.OnGrabUpdate is null) return; ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack; - if (grabUpdate.AgentData.SessionID.NotEqual(m_sessionId) || grabUpdate.AgentData.AgentID.NotEqual(m_agentId)) - return; List touchArgs = new(); if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0)) @@ -9787,20 +9643,17 @@ private void HandleObjectGrabUpdate(Packet Pack) } } - OnGrabUpdate?.Invoke(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial, - grabUpdate.ObjectData.GrabPosition, this, touchArgs); + c.OnGrabUpdate?.Invoke(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial, + grabUpdate.ObjectData.GrabPosition, c, touchArgs); } - private void HandleObjectDeGrab(Packet Pack) + private static void HandleObjectDeGrab(LLClientView c, Packet Pack) { - if (OnDeGrabObject is null) + if (c.OnDeGrabObject is null) return; ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack; - if (deGrab.AgentData.SessionID.NotEqual(m_sessionId) || deGrab.AgentData.AgentID.NotEqual(m_agentId)) - return; - List touchArgs = new(); if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0)) { @@ -9818,83 +9671,64 @@ private void HandleObjectDeGrab(Packet Pack) touchArgs.Add(arg); } } - OnDeGrabObject?.Invoke(deGrab.ObjectData.LocalID, this, touchArgs); + c.OnDeGrabObject?.Invoke(deGrab.ObjectData.LocalID, c, touchArgs); } - private void HandleObjectSpinStart(Packet Pack) + private static void HandleObjectSpinStart(LLClientView c, Packet Pack) { //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet"); ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack; - if (spinStart.AgentData.SessionID.NotEqual(m_sessionId) || spinStart.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnSpinStart?.Invoke(spinStart.ObjectData.ObjectID, this); + if (spinStart.AgentData.SessionID.Equals(c.m_sessionId) && spinStart.AgentData.AgentID.Equals(c.m_agentId)) + c.OnSpinStart?.Invoke(spinStart.ObjectData.ObjectID, c); } - private void HandleObjectSpinUpdate(Packet Pack) + private static void HandleObjectSpinUpdate(LLClientView c, Packet Pack) { //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet"); ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack; - if (spinUpdate.AgentData.SessionID.NotEqual(m_sessionId) || spinUpdate.AgentData.AgentID.NotEqual(m_agentId)) - return; spinUpdate.ObjectData.Rotation.GetAxisAngle(out Vector3 axis, out float angle); //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle); - OnSpinUpdate?.Invoke(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this); + c.OnSpinUpdate?.Invoke(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, c); } - private void HandleObjectSpinStop(Packet Pack) + private static void HandleObjectSpinStop(LLClientView c, Packet Pack) { //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet"); ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack; - if (spinStop.AgentData.SessionID.NotEqual(m_sessionId) || spinStop.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnSpinStop?.Invoke(spinStop.ObjectData.ObjectID, this); + if (spinStop.AgentData.SessionID.Equals(c.m_sessionId) && spinStop.AgentData.AgentID.Equals(c.m_agentId)) + c.OnSpinStop?.Invoke(spinStop.ObjectData.ObjectID, c); } - private void HandleObjectDescription(Packet Pack) + private static void HandleObjectDescription(LLClientView c, Packet Pack) { - if(OnObjectDescription is null) + if(c.OnObjectDescription is null) return; ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack; - if (objDes.AgentData.SessionID.NotEqual(m_sessionId) || objDes.AgentData.AgentID.NotEqual(m_agentId)) - return; - for (int i = 0; i < objDes.ObjectData.Length; i++) - OnObjectDescription?.Invoke(this, objDes.ObjectData[i].LocalID, + c.OnObjectDescription?.Invoke(c, objDes.ObjectData[i].LocalID, Util.FieldToString(objDes.ObjectData[i].Description)); } - private void HandleObjectName(Packet Pack) + private static void HandleObjectName(LLClientView c, Packet Pack) { - if(OnObjectName is null) + if(c.OnObjectName is null) return; ObjectNamePacket objName = (ObjectNamePacket)Pack; - if (objName.AgentData.SessionID.NotEqual(m_sessionId) || objName.AgentData.AgentID.NotEqual(m_agentId)) - return; - for (int i = 0; i < objName.ObjectData.Length; i++) - OnObjectName?.Invoke(this, objName.ObjectData[i].LocalID, + c.OnObjectName?.Invoke(c, objName.ObjectData[i].LocalID, Util.FieldToString(objName.ObjectData[i].Name)); } - private void HandleObjectPermissions(Packet Pack) + private static void HandleObjectPermissions(LLClientView c, Packet Pack) { - if (OnObjectPermissions is null) + if (c.OnObjectPermissions is null) return; ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack; - UUID SessionID = newobjPerms.AgentData.SessionID; - if (SessionID.NotEqual(m_sessionId)) - return; - UUID AgentID = newobjPerms.AgentData.AgentID; - if(AgentID.NotEqual(m_agentId)) - return; - for (int i = 0; i < newobjPerms.ObjectData.Length; i++) { ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i]; @@ -9904,7 +9738,7 @@ private void HandleObjectPermissions(Packet Pack) uint mask = permChanges.Mask; byte set = permChanges.Set; - OnObjectPermissions?.Invoke(this, AgentID, SessionID, field, localID, mask, set); + c.OnObjectPermissions?.Invoke(c, newobjPerms.AgentData.AgentID, newobjPerms.AgentData.SessionID, field, localID, mask, set); } // Here's our data, @@ -9920,58 +9754,46 @@ private void HandleObjectPermissions(Packet Pack) // That means multiple object perms may be updated in a single packet. } - private void HandleUndo(Packet Pack) + private static void HandleUndo(LLClientView c, Packet Pack) { - if(OnUndo is null) + if(c.OnUndo is null) return; UndoPacket undoitem = (UndoPacket)Pack; - if (undoitem.AgentData.SessionID.NotEqual(m_sessionId) || undoitem.AgentData.AgentID.NotEqual(m_agentId)) - return; - for (int i = 0; i < undoitem.ObjectData.Length; i++) - OnUndo?.Invoke(this, undoitem.ObjectData[i].ObjectID); + c.OnUndo?.Invoke(c, undoitem.ObjectData[i].ObjectID); } - private void HandleLandUndo(Packet Pack) + private static void HandleLandUndo(LLClientView c, Packet Pack) { UndoLandPacket undolanditem = (UndoLandPacket)Pack; - if (undolanditem.AgentData.SessionID.NotEqual(m_sessionId) || undolanditem.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnLandUndo?.Invoke(this); + c.OnLandUndo?.Invoke(c); } - private void HandleRedo(Packet Pack) + private static void HandleRedo(LLClientView c, Packet Pack) { - if(OnRedo is null) + if(c.OnRedo is null) return; RedoPacket redoitem = (RedoPacket)Pack; - if (redoitem.AgentData.SessionID.NotEqual(m_sessionId) || redoitem.AgentData.AgentID.NotEqual(m_agentId)) - return; - for (int i = 0; i < redoitem.ObjectData.Length; i++) - OnRedo?.Invoke(this, redoitem.ObjectData[i].ObjectID); + c.OnRedo?.Invoke(c, redoitem.ObjectData[i].ObjectID); } - private void HandleObjectDuplicateOnRay(Packet Pack) + private static void HandleObjectDuplicateOnRay(LLClientView c, Packet Pack) { - if(OnObjectDuplicateOnRay is null) + if(c.OnObjectDuplicateOnRay is null) return; ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack; - if (dupeOnRay.AgentData.SessionID.NotEqual(m_sessionId) || dupeOnRay.AgentData.AgentID.NotEqual(m_agentId)) - return; + UUID rezGroupID = dupeOnRay.AgentData.GroupID; + if (!c.IsGroupMember(rezGroupID)) + rezGroupID = UUID.Zero; for (int i = 0; i < dupeOnRay.ObjectData.Length; i++) { - UUID rezGroupID = dupeOnRay.AgentData.GroupID; - if(!IsGroupMember(rezGroupID)) - rezGroupID = UUID.Zero; - - OnObjectDuplicateOnRay?.Invoke(dupeOnRay.ObjectData[i].ObjectLocalID, - dupeOnRay.AgentData.DuplicateFlags, m_agentId, rezGroupID, + c.OnObjectDuplicateOnRay?.Invoke(dupeOnRay.ObjectData[i].ObjectLocalID, + dupeOnRay.AgentData.DuplicateFlags, c.m_agentId, rezGroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd, dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection, @@ -9979,77 +9801,58 @@ private void HandleObjectDuplicateOnRay(Packet Pack) } } - private void HandleRequestObjectPropertiesFamily(Packet Pack) + private static void HandleRequestObjectPropertiesFamily(LLClientView c, Packet Pack) { //This powers the little tooltip that appears when you move your mouse over an object RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack; - if (packToolTip.AgentData.SessionID.NotEqual(m_sessionId) || packToolTip.AgentData.AgentID.NotEqual(m_agentId)) - return; - RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; - OnRequestObjectPropertiesFamily?.Invoke(this, m_agentId, packObjBlock.RequestFlags, + c.OnRequestObjectPropertiesFamily?.Invoke(c, c.m_agentId, packObjBlock.RequestFlags, packObjBlock.ObjectID); } - private void HandleObjectIncludeInSearch(Packet Pack) + private static void HandleObjectIncludeInSearch(LLClientView c, Packet Pack) { - if(OnObjectIncludeInSearch is null) + if(c.OnObjectIncludeInSearch is null) return; //This lets us set objects to appear in search (stuff like DataSnapshot, etc) ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack; - if (packInSearch.AgentData.SessionID.NotEqual(m_sessionId) || packInSearch.AgentData.AgentID.NotEqual(m_agentId)) - return; - foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData) - { - bool inSearch = objData.IncludeInSearch; - uint localID = objData.ObjectLocalID; - OnObjectIncludeInSearch?.Invoke(this, inSearch, localID); - } + c.OnObjectIncludeInSearch?.Invoke(c, objData.IncludeInSearch, objData.ObjectLocalID); } - private void HandleScriptAnswerYes(Packet Pack) + private static void HandleScriptAnswerYes(LLClientView c, Packet Pack) { ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack; - if (scriptAnswer.AgentData.SessionID.NotEqual(m_sessionId) || scriptAnswer.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnScriptAnswer?.Invoke(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions); + c.OnScriptAnswer?.Invoke(c, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions); } - private void HandleObjectClickAction(Packet Pack) + private static void HandleObjectClickAction(LLClientView c, Packet Pack) { - if(OnObjectClickAction is null) + if(c.OnObjectClickAction is null) return; ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack; - if (ocpacket.AgentData.SessionID.NotEqual(m_sessionId) || ocpacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData) { byte action = odata.ClickAction; uint localID = odata.ObjectLocalID; - OnObjectClickAction?.Invoke(this, localID, action.ToString()); + c.OnObjectClickAction?.Invoke(c, localID, action.ToString()); } } - private void HandleObjectMaterial(Packet Pack) + private static void HandleObjectMaterial(LLClientView c, Packet Pack) { - if(OnObjectMaterial is null) + if(c.OnObjectMaterial is null) return; ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack; - if (ompacket.AgentData.SessionID.NotEqual(m_sessionId) || ompacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData) { byte material = odata.Material; uint localID = odata.ObjectLocalID; - OnObjectMaterial?.Invoke(this, localID, material.ToString()); + c.OnObjectMaterial?.Invoke(c, localID, material.ToString()); } } @@ -10057,12 +9860,9 @@ private void HandleObjectMaterial(Packet Pack) #region Inventory/Asset/Other related packets - private void HandleRequestImage(Packet Pack) + private static void HandleRequestImage(LLClientView c, Packet Pack) { RequestImagePacket imageRequest = (RequestImagePacket)Pack; - if (imageRequest.AgentData.SessionID.NotEqual(m_sessionId) || imageRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - //handlerTextureRequest = null; for (int i = 0; i < imageRequest.RequestImage.Length; i++) { @@ -10082,7 +9882,7 @@ private void HandleRequestImage(Packet Pack) if ((ImageType)block.Type == ImageType.Baked) args.Priority *= 2.0f; - ImageManager.EnqueueReq(args); + c.ImageManager.EnqueueReq(args); } } @@ -10093,7 +9893,7 @@ private void HandleRequestImage(Packet Pack) /// /// /// This parameter may be ignored since we appear to return true whatever happens - private void HandleTransferRequest(Packet Pack) + private static void HandleTransferRequest(LLClientView c, Packet Pack) { //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); @@ -10101,13 +9901,13 @@ private void HandleTransferRequest(Packet Pack) UUID taskID = UUID.Zero; if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) { - if (!(((Scene)m_scene).Permissions.BypassPermissions())) + if (!c.m_scene.Permissions.BypassPermissions()) { // We're spawning a thread because the permissions check can block this thread Util.FireAndForget(delegate { // This requests the asset if needed - HandleSimInventoryTransferRequestWithPermsCheck(this, transfer); + c.HandleSimInventoryTransferRequestWithPermsCheck(c, transfer); }, null, "LLClientView.HandleTransferRequest"); return; @@ -10117,11 +9917,11 @@ private void HandleTransferRequest(Packet Pack) { //TransferRequestPacket does not include covenant uuid? //get scene covenant uuid - taskID = m_scene.RegionInfo.RegionSettings.Covenant; + taskID = c.m_scene.RegionInfo.RegionSettings.Covenant; } // This is non-blocking - MakeAssetRequest(transfer, taskID); + c.MakeAssetRequest(transfer, taskID); } private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, TransferRequestPacket transfer) @@ -10235,97 +10035,90 @@ private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, } - - private void HandleAssetUploadRequest(Packet Pack) + private static void HandleAssetUploadRequest(LLClientView c, Packet Pack) { AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; // m_log.Debug("upload request " + request.ToString()); // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); - UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); + UUID temp = UUID.Combine(request.AssetBlock.TransactionID, c.SecureSessionId); - OnAssetUploadRequest?.Invoke(this, temp, + c.OnAssetUploadRequest?.Invoke(c, temp, request.AssetBlock.TransactionID, request.AssetBlock.Type, request.AssetBlock.AssetData, request.AssetBlock.StoreLocal, request.AssetBlock.Tempfile); } - private void HandleRequestXfer(Packet Pack) + private static void HandleRequestXfer(LLClientView c, Packet Pack) { RequestXferPacket xferReq = (RequestXferPacket)Pack; - OnRequestXfer?.Invoke(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename)); + c.OnRequestXfer?.Invoke(c, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename)); } - private void HandleSendXferPacket(Packet Pack) + private static void HandleSendXferPacket(LLClientView c, Packet Pack) { SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack; - OnXferReceive?.Invoke(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); + c.OnXferReceive?.Invoke(c, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); } - private void HandleConfirmXferPacket(Packet Pack) + private static void HandleConfirmXferPacket(LLClientView c, Packet Pack) { ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack; - OnConfirmXfer?.Invoke(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); + c.OnConfirmXfer?.Invoke(c, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); } - private void HandleAbortXfer(Packet Pack) + private static void HandleAbortXfer(LLClientView c, Packet Pack) { AbortXferPacket abortXfer = (AbortXferPacket)Pack; - OnAbortXfer?.Invoke(this, abortXfer.XferID.ID); + c.OnAbortXfer?.Invoke(c, abortXfer.XferID.ID); } - private void HandleCreateInventoryFolder(Packet Pack) + private static void HandleCreateInventoryFolder(LLClientView c, Packet Pack) { CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; - if (invFolder.AgentData.SessionID.NotEqual(m_sessionId) || invFolder.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnCreateNewInventoryFolder?.Invoke(this, invFolder.FolderData.FolderID, + c.OnCreateNewInventoryFolder?.Invoke(c, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); } - private void HandleUpdateInventoryFolder(Packet Pack) + private static void HandleUpdateInventoryFolder(LLClientView c, Packet Pack) { - if (OnUpdateInventoryFolder is null) + if (c.OnUpdateInventoryFolder is null) return; UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack; - if (invFolderx.AgentData.SessionID.NotEqual(m_sessionId) || invFolderx.AgentData.AgentID.NotEqual(m_agentId)) + if (invFolderx.AgentData.SessionID.NotEqual(c.m_sessionId) || invFolderx.AgentData.AgentID.NotEqual(c.m_agentId)) return; for (int i = 0; i < invFolderx.FolderData.Length; i++) { - OnUpdateInventoryFolder?.Invoke(this, invFolderx.FolderData[i].FolderID, + c.OnUpdateInventoryFolder?.Invoke(c, invFolderx.FolderData[i].FolderID, (ushort)invFolderx.FolderData[i].Type, Util.FieldToString(invFolderx.FolderData[i].Name), invFolderx.FolderData[i].ParentID); } } - private void HandleMoveInventoryFolder(Packet Pack) + private static void HandleMoveInventoryFolder(LLClientView c, Packet Pack) { - if (OnMoveInventoryFolder is null) + if (c.OnMoveInventoryFolder is null) return; MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack; - if (invFoldery.AgentData.SessionID.NotEqual(m_sessionId) || invFoldery.AgentData.AgentID.NotEqual(m_agentId)) - return; - for (int i = 0; i < invFoldery.InventoryData.Length; i++) { - OnMoveInventoryFolder?.Invoke(this, invFoldery.InventoryData[i].FolderID, + c.OnMoveInventoryFolder?.Invoke(c, invFoldery.InventoryData[i].FolderID, invFoldery.InventoryData[i].ParentID); } } - private void HandleCreateInventoryItem(Packet Pack) + private static void HandleCreateInventoryItem(LLClientView c, Packet Pack) { CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; - if (createItem.AgentData.SessionID.NotEqual(m_sessionId) || createItem.AgentData.AgentID.NotEqual(m_agentId)) + if (createItem.AgentData.SessionID.NotEqual(c.m_sessionId) || createItem.AgentData.AgentID.NotEqual(c.m_agentId)) return; - OnCreateNewInventoryItem?.Invoke(this, createItem.InventoryBlock.TransactionID, + c.OnCreateNewInventoryItem?.Invoke(c, createItem.InventoryBlock.TransactionID, createItem.InventoryBlock.FolderID, createItem.InventoryBlock.CallbackID, Util.FieldToString(createItem.InventoryBlock.Description), @@ -10337,14 +10130,11 @@ private void HandleCreateInventoryItem(Packet Pack) Util.UnixTimeSinceEpoch()); } - private void HandleLinkInventoryItem(Packet Pack) + private static void HandleLinkInventoryItem(LLClientView c, Packet Pack) { LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack; - if (createLink.AgentData.SessionID.NotEqual(m_sessionId) || createLink.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnLinkInventoryItem?.Invoke( - this, + c.OnLinkInventoryItem?.Invoke( + c, createLink.InventoryBlock.TransactionID, createLink.InventoryBlock.FolderID, createLink.InventoryBlock.CallbackID, @@ -10355,15 +10145,12 @@ private void HandleLinkInventoryItem(Packet Pack) createLink.InventoryBlock.OldItemID); } - private void HandleFetchInventory(Packet Pack) + private static void HandleFetchInventory(LLClientView c, Packet Pack) { - if (OnFetchInventory is null) + if (c.OnFetchInventory is null) return; FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack; - if (FetchInventoryx.AgentData.SessionID.NotEqual(m_sessionId) || FetchInventoryx.AgentData.AgentID.NotEqual(m_agentId)) - return; - FetchInventoryPacket.InventoryDataBlock[] data = FetchInventoryx.InventoryData; UUID[] items = new UUID[data.Length]; @@ -10375,39 +10162,30 @@ private void HandleFetchInventory(Packet Pack) owners[i] = data[i].OwnerID; } - OnFetchInventory?.Invoke(this, items, owners); + c.OnFetchInventory?.Invoke(c, items, owners); } - private void HandleFetchInventoryDescendents(Packet Pack) + private static void HandleFetchInventoryDescendents(LLClientView c, Packet Pack) { FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; - if (Fetch.AgentData.SessionID.NotEqual(m_sessionId) || Fetch.AgentData.AgentID.NotEqual(m_agentId)) - return; - FetchInventoryDescendentsPacket.InventoryDataBlock data = Fetch.InventoryData; - OnFetchInventoryDescendents?.Invoke(this, data.FolderID, data.OwnerID, + c.OnFetchInventoryDescendents?.Invoke(c, data.FolderID, data.OwnerID, data.FetchFolders, data.FetchItems, data.SortOrder); } - private void HandlePurgeInventoryDescendents(Packet Pack) + private static void HandlePurgeInventoryDescendents(LLClientView c, Packet Pack) { PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack; - if (Purge.AgentData.SessionID.NotEqual(m_sessionId) || Purge.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnPurgeInventoryDescendents?.Invoke(this, Purge.InventoryData.FolderID); + c.OnPurgeInventoryDescendents?.Invoke(c, Purge.InventoryData.FolderID); } - private void HandleUpdateInventoryItem(Packet Pack) + private static void HandleUpdateInventoryItem(LLClientView c, Packet Pack) { - if (OnUpdateInventoryItem is null) + if (c.OnUpdateInventoryItem is null) return; UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack; - if (inventoryItemUpdate.AgentData.SessionID.NotEqual(m_sessionId) || inventoryItemUpdate.AgentData.AgentID.NotEqual(m_agentId)) - return; - for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++) { InventoryItemBase itemUpd = new() @@ -10428,43 +10206,37 @@ private void HandleUpdateInventoryItem(Packet Pack) Flags = inventoryItemUpdate.InventoryData[i].Flags }; - OnUpdateInventoryItem?.Invoke(this, inventoryItemUpdate.InventoryData[i].TransactionID, + c.OnUpdateInventoryItem?.Invoke(c, inventoryItemUpdate.InventoryData[i].TransactionID, inventoryItemUpdate.InventoryData[i].ItemID, itemUpd); } } - private void HandleCopyInventoryItem(Packet Pack) + private static void HandleCopyInventoryItem(LLClientView c, Packet Pack) { - if(OnCopyInventoryItem is null) + if(c.OnCopyInventoryItem is null) return; CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack; - if (copyitem.AgentData.SessionID.NotEqual(m_sessionId) || copyitem.AgentData.AgentID.NotEqual(m_agentId)) - return; - foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) { - OnCopyInventoryItem?.Invoke(this, datablock.CallbackID, datablock.OldAgentID, + c.OnCopyInventoryItem?.Invoke(c, datablock.CallbackID, datablock.OldAgentID, datablock.OldItemID, datablock.NewFolderID, Util.FieldToString(datablock.NewName)); } } - private void HandleMoveInventoryItem(Packet Pack) + private static void HandleMoveInventoryItem(LLClientView c, Packet Pack) { - if (OnMoveInventoryItem is null) + if (c.OnMoveInventoryItem is null) return; MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack; - if (moveitem.AgentData.SessionID.NotEqual(m_sessionId) || moveitem.AgentData.AgentID.NotEqual(m_agentId)) - return; - InventoryItemBase itm = null; List items = new(); foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) { - itm = new InventoryItemBase(datablock.ItemID, m_agentId) + itm = new InventoryItemBase(datablock.ItemID, c.m_agentId) { Folder = datablock.FolderID, Name = Util.FieldToString(datablock.NewName) @@ -10473,84 +10245,69 @@ private void HandleMoveInventoryItem(Packet Pack) //m_log.DebugFormat("[XXX] new name: {0}", itm.Name); items.Add(itm); } - OnMoveInventoryItem?.Invoke(this, items); + c.OnMoveInventoryItem?.Invoke(c, items); } - private void HandleRemoveInventoryItem(Packet Pack) + private static void HandleRemoveInventoryItem(LLClientView c, Packet Pack) { - if(OnRemoveInventoryItem is null) + if(c.OnRemoveInventoryItem is null) return; RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack; - if (removeItem.AgentData.SessionID.NotEqual(m_sessionId) || removeItem.AgentData.AgentID.NotEqual(m_agentId)) - return; - List uuids = new(removeItem.InventoryData.Length); foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData) { uuids.Add(datablock.ItemID); } - OnRemoveInventoryItem?.Invoke(this, uuids); + c.OnRemoveInventoryItem?.Invoke(c, uuids); } - private void HandleRemoveInventoryFolder(Packet Pack) + private static void HandleRemoveInventoryFolder(LLClientView c, Packet Pack) { - if (OnRemoveInventoryFolder is null) + if (c.OnRemoveInventoryFolder is null) return; RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack; - if (removeFolder.AgentData.SessionID.NotEqual(m_sessionId) || removeFolder.AgentData.AgentID.NotEqual(m_agentId)) - return; - List uuids = new(removeFolder.FolderData.Length); foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData) { uuids.Add(datablock.FolderID); } - OnRemoveInventoryFolder?.Invoke(this, uuids); + c.OnRemoveInventoryFolder?.Invoke(c, uuids); } - private void HandleRemoveInventoryObjects(Packet Pack) + private static void HandleRemoveInventoryObjects(LLClientView c, Packet Pack) { - if (OnRemoveInventoryFolder is null || OnRemoveInventoryItem is null) + if (c.OnRemoveInventoryFolder is null || c.OnRemoveInventoryItem is null) return; RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack; - if (removeObject.AgentData.SessionID.NotEqual(m_sessionId) || removeObject.AgentData.AgentID.NotEqual(m_agentId)) - return; - List uuids = new(removeObject.FolderData.Length); foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData) uuids.Add(datablock.FolderID); - OnRemoveInventoryFolder?.Invoke(this, uuids); + c.OnRemoveInventoryFolder?.Invoke(c, uuids); uuids.Clear(); foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData) uuids.Add(datablock.ItemID); - OnRemoveInventoryItem?.Invoke(this, uuids); + c.OnRemoveInventoryItem?.Invoke(c, uuids); } - private void HandleRequestTaskInventory(Packet Pack) + private static void HandleRequestTaskInventory(LLClientView c, Packet Pack) { RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; - if (requesttask.AgentData.SessionID.NotEqual(m_sessionId) || requesttask.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnRequestTaskInventory?.Invoke(this, requesttask.InventoryData.LocalID); + c.OnRequestTaskInventory?.Invoke(c, requesttask.InventoryData.LocalID); } - private void HandleUpdateTaskInventory(Packet Pack) + private static void HandleUpdateTaskInventory(LLClientView c, Packet Pack) { - if (OnUpdateTaskInventory is null) + if (c.OnUpdateTaskInventory is null) return; UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; if (updatetask.UpdateData.Key != 0) return; // only do inventory not assets - if (updatetask.AgentData.SessionID.NotEqual(m_sessionId) || updatetask.AgentData.AgentID.NotEqual(m_agentId)) - return; - TaskInventoryItem newTaskItem = new() { ItemID = updatetask.InventoryData.ItemID, @@ -10577,39 +10334,33 @@ private void HandleUpdateTaskInventory(Packet Pack) CreationDate = (uint)updatetask.InventoryData.CreationDate }; - OnUpdateTaskInventory?.Invoke(this, updatetask.InventoryData.TransactionID, + c.OnUpdateTaskInventory?.Invoke(c, updatetask.InventoryData.TransactionID, newTaskItem, updatetask.UpdateData.LocalID); } - private void HandleRemoveTaskInventory(Packet Pack) + private static void HandleRemoveTaskInventory(LLClientView c, Packet Pack) { RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack; - if (removeTask.AgentData.SessionID.NotEqual(m_sessionId) || removeTask.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnRemoveTaskItem?.Invoke(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID); + c.OnRemoveTaskItem?.Invoke(c, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID); } - private void HandleMoveTaskInventory(Packet Pack) + private static void HandleMoveTaskInventory(LLClientView c, Packet Pack) { MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack; - if (moveTaskInventoryPacket.AgentData.SessionID.NotEqual(m_sessionId) || moveTaskInventoryPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnMoveTaskItem?.Invoke( - this, moveTaskInventoryPacket.AgentData.FolderID, + c.OnMoveTaskItem?.Invoke( + c, moveTaskInventoryPacket.AgentData.FolderID, moveTaskInventoryPacket.InventoryData.LocalID, moveTaskInventoryPacket.InventoryData.ItemID); } - private void HandleRezScript(Packet Pack) + private static void HandleRezScript(LLClientView c, Packet Pack) { - if(OnRezScript is null) + if(c.OnRezScript is null) return; //m_log.Debug(Pack.ToString()); RezScriptPacket rezScriptx = (RezScriptPacket)Pack; - if (rezScriptx.AgentData.SessionID.NotEqual(m_sessionId) || rezScriptx.AgentData.AgentID.NotEqual(m_agentId)) + if (rezScriptx.AgentData.SessionID.NotEqual(c.m_sessionId) || rezScriptx.AgentData.AgentID.NotEqual(c.m_agentId)) return; InventoryItemBase item = new() @@ -10635,61 +10386,52 @@ private void HandleRezScript(Packet Pack) CreationDate = rezScriptx.InventoryBlock.CreationDate }; - OnRezScript?.Invoke(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID); + c.OnRezScript?.Invoke(c, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID); } - private void HandleMapLayerRequest(Packet Pack) + private static void HandleMapLayerRequest(LLClientView c, Packet Pack) { - RequestMapLayer(); + c.RequestMapLayer(); } - private void HandleMapBlockRequest(Packet Pack) + private static void HandleMapBlockRequest(LLClientView c, Packet Pack) { MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; - if (MapRequest.AgentData.SessionID.NotEqual(m_sessionId) || MapRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnRequestMapBlocks?.Invoke(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, + c.OnRequestMapBlocks?.Invoke(c, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags); } - private void HandleMapNameRequest(Packet Pack) + private static void HandleMapNameRequest(LLClientView c, Packet Pack) { MapNameRequestPacket map = (MapNameRequestPacket)Pack; - if (map.AgentData.SessionID.NotEqual(m_sessionId) || map.AgentData.AgentID.NotEqual(m_agentId)) - return; - - string mapName = (map.NameData.Name.Length == 0) ? m_scene.RegionInfo.RegionName : + string mapName = map.NameData.Name.Length == 0 ? c.m_scene.RegionInfo.RegionName : Util.UTF8.GetString(map.NameData.Name, 0, map.NameData.Name.Length - 1); - OnMapNameRequest?.Invoke(this, mapName, map.AgentData.Flags); + c.OnMapNameRequest?.Invoke(c, mapName, map.AgentData.Flags); } - private void HandleTeleportLandmarkRequest(Packet Pack) + private static void HandleTeleportLandmarkRequest(LLClientView c, Packet Pack) { TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; - if (tpReq.Info.SessionID.NotEqual(m_sessionId) || tpReq.Info.AgentID.NotEqual(m_agentId)) - return; - UUID lmid = tpReq.Info.LandmarkID; AssetLandmark lm; if (!lmid.IsZero()) { //AssetBase lma = m_assetCache.GetAsset(lmid, false); - AssetBase lma = m_assetService.Get(lmid.ToString()); + AssetBase lma = c.m_assetService.Get(lmid.ToString()); if (lma is null) { // Failed to find landmark // Let's try to search in the user's home asset server - lma = FindAssetInUserAssetServer(lmid.ToString()); + lma = c.FindAssetInUserAssetServer(lmid.ToString()); if (lma is null) { // Really doesn't exist m_log.WarnFormat("[llClient]: landmark asset {0} not found",lmid.ToString()); - SendTeleportFailed("Could not find the landmark asset data"); + c.SendTeleportFailed("Could not find the landmark asset data"); return; } } @@ -10701,27 +10443,24 @@ private void HandleTeleportLandmarkRequest(Packet Pack) catch (NullReferenceException) { // asset not found generates null ref inside the assetlandmark constructor. - SendTeleportFailed("Could not find the landmark asset data"); + c.SendTeleportFailed("Could not find the landmark asset data"); return; } } else { // Teleport home request - OnTeleportHomeRequest?.Invoke(m_agentId, this); + c.OnTeleportHomeRequest?.Invoke(c.m_agentId, c); return; } - OnTeleportLandmarkRequest?.Invoke(this, lm); + c.OnTeleportLandmarkRequest?.Invoke(c, lm); } - private void HandleTeleportCancel(Packet Pack) + private static void HandleTeleportCancel(LLClientView c, Packet Pack) { TeleportCancelPacket pkt = (TeleportCancelPacket) Pack; - if(pkt.Info.AgentID.NotEqual(m_agentId) || pkt.Info.SessionID.NotEqual(m_sessionId)) - return; - - OnTeleportCancel?.Invoke(this); + c.OnTeleportCancel?.Invoke(c); } private AssetBase FindAssetInUserAssetServer(string id) @@ -10737,90 +10476,82 @@ private AssetBase FindAssetInUserAssetServer(string id) return null; } - private void HandleTeleportLocationRequest(Packet Pack) + private static void HandleTeleportLocationRequest(LLClientView c, Packet Pack) { - if(OnTeleportLocationRequest is null) + if(c.OnTeleportLocationRequest is null) { - SendTeleportFailed("Could not process the teleport"); + c.SendTeleportFailed("Could not process the teleport"); return; } TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; - if (tpLocReq.AgentData.SessionID.NotEqual(m_sessionId) || tpLocReq.AgentData.AgentID.NotEqual(m_agentId)) - return; // Adjust teleport location to base of a larger region if requested to teleport to a sub-region Util.RegionHandleToWorldLoc(tpLocReq.Info.RegionHandle, out uint locX, out uint locY); - if ((locX >= m_scene.RegionInfo.WorldLocX) - && (locX < (m_scene.RegionInfo.WorldLocX + m_scene.RegionInfo.RegionSizeX)) - && (locY >= m_scene.RegionInfo.WorldLocY) - && (locY < (m_scene.RegionInfo.WorldLocY + m_scene.RegionInfo.RegionSizeY))) + RegionInfo ri = c.m_scene.RegionInfo; + if ((locX >= ri.WorldLocX) + && (locX < (ri.WorldLocX + ri.RegionSizeX)) + && (locY >= ri.WorldLocY) + && (locY < (ri.WorldLocY + ri.RegionSizeY))) { - tpLocReq.Info.RegionHandle = m_scene.RegionInfo.RegionHandle; - tpLocReq.Info.Position.X += locX - m_scene.RegionInfo.WorldLocX; - tpLocReq.Info.Position.Y += locY - m_scene.RegionInfo.WorldLocY; + tpLocReq.Info.RegionHandle = ri.RegionHandle; + tpLocReq.Info.Position.X += locX - ri.WorldLocX; + tpLocReq.Info.Position.Y += locY - ri.WorldLocY; } - OnTeleportLocationRequest?.Invoke(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, + c.OnTeleportLocationRequest?.Invoke(c, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, tpLocReq.Info.LookAt, 16); } #endregion Inventory/Asset/Other related packets - private void HandleUUIDNameRequest(Packet Pack) + private static void HandleUUIDNameRequest(LLClientView c, Packet Pack) { - if(OnNameFromUUIDRequest is null) + if(c.OnNameFromUUIDRequest is null) return; - ScenePresence sp = (ScenePresence)SceneAgent; + ScenePresence sp = (ScenePresence)c.SceneAgent; if(sp is null || sp.IsDeleted || (sp.IsInTransit && !sp.IsInLocalTransit)) return; UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) - OnNameFromUUIDRequest?.Invoke(UUIDBlock.ID, this); + c.OnNameFromUUIDRequest?.Invoke(UUIDBlock.ID, c); } #region Parcel related packets - private void HandleRegionHandleRequest(Packet Pack) + private static void HandleRegionHandleRequest(LLClientView c, Packet Pack) { RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack; - OnRegionHandleRequest?.Invoke(this, rhrPack.RequestBlock.RegionID); + c.OnRegionHandleRequest?.Invoke(c, rhrPack.RequestBlock.RegionID); } - private void HandleParcelInfoRequest(Packet Pack) + private static void HandleParcelInfoRequest(LLClientView c, Packet Pack) { - if(OnParcelInfoRequest is null) + if(c.OnParcelInfoRequest is null) return; ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack; - if (pirPack.AgentData.SessionID.NotEqual(m_sessionId) || pirPack.AgentData.AgentID.NotEqual(m_agentId)) - return; - OnParcelInfoRequest?.Invoke(this, pirPack.Data.ParcelID); + c.OnParcelInfoRequest?.Invoke(c, pirPack.Data.ParcelID); } - private void HandleParcelAccessListRequest(Packet Pack) + private static void HandleParcelAccessListRequest(LLClientView c, Packet Pack) { ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack; - if (requestPacket.AgentData.SessionID.NotEqual(m_sessionId) || requestPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnParcelAccessListRequest?.Invoke(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID, + c.OnParcelAccessListRequest?.Invoke(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID, requestPacket.Data.Flags, requestPacket.Data.SequenceID, - requestPacket.Data.LocalID, this); + requestPacket.Data.LocalID, c); } - private void HandleParcelAccessListUpdate(Packet Pack) + private static void HandleParcelAccessListUpdate(LLClientView c, Packet Pack) { - if(OnParcelAccessListUpdateRequest is null) + if(c.OnParcelAccessListUpdateRequest is null) return; ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack; - if (updatePacket.AgentData.SessionID.NotEqual(m_sessionId) || updatePacket.AgentData.AgentID.NotEqual(m_agentId)) - return; // viewers do send estimated number of packets and sequenceID, but don't seem reliable. List entries = new(updatePacket.List.Length); @@ -10835,56 +10566,48 @@ private void HandleParcelAccessListUpdate(Packet Pack) entries.Add(entry); } - OnParcelAccessListUpdateRequest?.Invoke(updatePacket.AgentData.AgentID, + c.OnParcelAccessListUpdateRequest?.Invoke(updatePacket.AgentData.AgentID, updatePacket.Data.Flags, updatePacket.Data.TransactionID, updatePacket.Data.LocalID, - entries, this); + entries, c); } - private void HandleParcelPropertiesRequest(Packet Pack) + private static void HandleParcelPropertiesRequest(LLClientView c, Packet Pack) { ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; - if (propertiesRequest.AgentData.SessionID.NotEqual(m_sessionId) || propertiesRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; ParcelPropertiesRequestPacket.ParcelDataBlock pdb = propertiesRequest.ParcelData; - OnParcelPropertiesRequest?.Invoke((int)MathF.Round(pdb.West), (int)MathF.Round(pdb.South), + c.OnParcelPropertiesRequest?.Invoke((int)MathF.Round(pdb.West), (int)MathF.Round(pdb.South), (int)MathF.Round(pdb.East), (int)MathF.Round(pdb.North), - pdb.SequenceID, pdb.SnapSelection, this); + pdb.SequenceID, pdb.SnapSelection, c); } - private void HandleParcelDivide(Packet Pack) + private static void HandleParcelDivide(LLClientView c, Packet Pack) { ParcelDividePacket landDivide = (ParcelDividePacket)Pack; - if (landDivide.AgentData.SessionID.NotEqual(m_sessionId) || landDivide.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnParcelDivideRequest?.Invoke((int)MathF.Round(landDivide.ParcelData.West), + c.OnParcelDivideRequest?.Invoke((int)MathF.Round(landDivide.ParcelData.West), (int)MathF.Round(landDivide.ParcelData.South), (int)Math.Round(landDivide.ParcelData.East), - (int)MathF.Round(landDivide.ParcelData.North), this); + (int)MathF.Round(landDivide.ParcelData.North), c); } - private void HandleParcelJoin(Packet Pack) + private static void HandleParcelJoin(LLClientView c, Packet Pack) { ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack; - if (landJoin.AgentData.SessionID.NotEqual(m_sessionId) || landJoin.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnParcelJoinRequest?.Invoke((int)MathF.Round(landJoin.ParcelData.West), + c.OnParcelJoinRequest?.Invoke((int)MathF.Round(landJoin.ParcelData.West), (int)MathF.Round(landJoin.ParcelData.South), (int)MathF.Round(landJoin.ParcelData.East), - (int)MathF.Round(landJoin.ParcelData.North), this); + (int)MathF.Round(landJoin.ParcelData.North), c); } - private void HandleParcelPropertiesUpdate(Packet Pack) + private static void HandleParcelPropertiesUpdate(LLClientView c, Packet Pack) { - if (OnParcelPropertiesUpdateRequest is null) + if (c.OnParcelPropertiesUpdateRequest is null) return; ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack; - if (parcelPropertiesPacket.AgentData.SessionID.NotEqual(m_sessionId) || parcelPropertiesPacket.AgentData.AgentID.NotEqual(m_agentId)) + if (parcelPropertiesPacket.AgentData.SessionID.NotEqual(c.m_sessionId) || parcelPropertiesPacket.AgentData.AgentID.NotEqual(c.m_agentId)) return; LandUpdateArgs args = new() @@ -10908,73 +10631,55 @@ private void HandleParcelPropertiesUpdate(Packet Pack) UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt }; - OnParcelPropertiesUpdateRequest?.Invoke(args, parcelPropertiesPacket.ParcelData.LocalID, this); + c.OnParcelPropertiesUpdateRequest?.Invoke(args, parcelPropertiesPacket.ParcelData.LocalID, c); } - private void HandleParcelSelectObjects(Packet Pack) + private static void HandleParcelSelectObjects(LLClientView c, Packet Pack) { - if(OnParcelSelectObjects is null) + if(c.OnParcelSelectObjects is null) return; ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack; - if (selectPacket.AgentData.SessionID.NotEqual(m_sessionId) || selectPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - List returnIDs = new(selectPacket.ReturnIDs.Length); foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in selectPacket.ReturnIDs) { returnIDs.Add(rb.ReturnID); } - OnParcelSelectObjects?.Invoke(selectPacket.ParcelData.LocalID, - Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this); + c.OnParcelSelectObjects?.Invoke(selectPacket.ParcelData.LocalID, + Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, c); } - private void HandleParcelObjectOwnersRequest(Packet Pack) + private static void HandleParcelObjectOwnersRequest(LLClientView c, Packet Pack) { ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack; - if (reqPacket.AgentData.SessionID.NotEqual(m_sessionId) || reqPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnParcelObjectOwnerRequest?.Invoke(reqPacket.ParcelData.LocalID, this); + c.OnParcelObjectOwnerRequest?.Invoke(reqPacket.ParcelData.LocalID, c); } - private void HandleParcelGodForceOwner(Packet Pack) + private static void HandleParcelGodForceOwner(LLClientView c, Packet Pack) { ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack; - if (godForceOwnerPacket.AgentData.SessionID.NotEqual(m_sessionId) || godForceOwnerPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnParcelGodForceOwner?.Invoke(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this); + c.OnParcelGodForceOwner?.Invoke(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, c); } - private void HandleParcelRelease(Packet Pack) + private static void HandleParcelRelease(LLClientView c, Packet Pack) { ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack; - if (releasePacket.AgentData.SessionID.NotEqual(m_sessionId) || releasePacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnParcelAbandonRequest?.Invoke(releasePacket.Data.LocalID, this); + c.OnParcelAbandonRequest?.Invoke(releasePacket.Data.LocalID, c); } - private void HandleParcelReclaim(Packet Pack) + private static void HandleParcelReclaim(LLClientView c, Packet Pack) { ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack; - if (reclaimPacket.AgentData.SessionID.NotEqual(m_sessionId) || reclaimPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnParcelReclaim?.Invoke(reclaimPacket.Data.LocalID, this); + c.OnParcelReclaim?.Invoke(reclaimPacket.Data.LocalID, c); } - private void HandleParcelReturnObjects(Packet Pack) + private static void HandleParcelReturnObjects(LLClientView c, Packet Pack) { - if(OnParcelReturnObjectsRequest is null) + if(c.OnParcelReturnObjectsRequest is null) return; ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack; - if (parcelReturnObjects.AgentData.SessionID.NotEqual(m_sessionId) || parcelReturnObjects.AgentData.AgentID.NotEqual(m_agentId)) - return; - UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length]; for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++) puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID; @@ -10983,36 +10688,27 @@ private void HandleParcelReturnObjects(Packet Pack) for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++) puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID; - OnParcelReturnObjectsRequest?.Invoke(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this); + c.OnParcelReturnObjectsRequest?.Invoke(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, c); } - private void HandleParcelSetOtherCleanTime(Packet Pack) + private static void HandleParcelSetOtherCleanTime(LLClientView c, Packet Pack) { ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack; - if (parcelSetOtherCleanTimePacket.AgentData.SessionID.NotEqual(m_sessionId) || parcelSetOtherCleanTimePacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnParcelSetOtherCleanTime?.Invoke(this, + c.OnParcelSetOtherCleanTime?.Invoke(c, parcelSetOtherCleanTimePacket.ParcelData.LocalID, parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime); } - private void HandleLandStatRequest(Packet Pack) + private static void HandleLandStatRequest(LLClientView c, Packet Pack) { LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack; - if (lsrp.AgentData.SessionID.NotEqual(m_sessionId) || lsrp.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnLandStatRequest?.Invoke(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this); + c.OnLandStatRequest?.Invoke(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), c); } - private void HandleParcelDwellRequest(Packet Pack) + private static void HandleParcelDwellRequest(LLClientView c, Packet Pack) { ParcelDwellRequestPacket dwellrq = (ParcelDwellRequestPacket)Pack; - if (dwellrq.AgentData.SessionID.NotEqual(m_sessionId) || dwellrq.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnParcelDwellRequest?.Invoke(dwellrq.Data.LocalID, this); + c.OnParcelDwellRequest?.Invoke(dwellrq.Data.LocalID, c); } #endregion Parcel related packets @@ -11020,25 +10716,23 @@ private void HandleParcelDwellRequest(Packet Pack) #region Estate Packets private static double m_lastMapRegenTime = Double.MinValue; - private void HandleEstateOwnerMessage(Packet Pack) + private static void HandleEstateOwnerMessage(LLClientView c, Packet Pack) { EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; - if (messagePacket.AgentData.SessionID.NotEqual(m_sessionId) || messagePacket.AgentData.AgentID.NotEqual(m_agentId)) - return; string method = Utils.BytesToString(messagePacket.MethodData.Method); switch (method) { case "getinfo": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { - OnDetailedEstateDataRequest?.Invoke(this, messagePacket.MethodData.Invoice); + c.OnDetailedEstateDataRequest?.Invoke(c, messagePacket.MethodData.Invoice); } return; case "setregioninfo": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { - OnSetEstateFlagsRequest?.Invoke(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter), + c.OnSetEstateFlagsRequest?.Invoke(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter), convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter), Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)), (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo), @@ -11062,7 +10756,7 @@ private void HandleEstateOwnerMessage(Packet Pack) // } // break; case "texturedetail": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) { @@ -11073,14 +10767,14 @@ private void HandleEstateOwnerMessage(Packet Pack) Int16 corner = Convert.ToInt16(splitField[0]); UUID textureUUID = new(splitField[1]); - OnSetEstateTerrainDetailTexture?.Invoke(this, corner, textureUUID); + c.OnSetEstateTerrainDetailTexture?.Invoke(c, corner, textureUUID); } } } return; case "textureheights": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) { @@ -11092,16 +10786,16 @@ private void HandleEstateOwnerMessage(Packet Pack) float lowValue = Convert.ToSingle(splitField[1], Culture.NumberFormatInfo); float highValue = Convert.ToSingle(splitField[2], Culture.NumberFormatInfo); - OnSetEstateTerrainTextureHeights?.Invoke(this, corner, lowValue, highValue); + c.OnSetEstateTerrainTextureHeights?.Invoke(c, corner, lowValue, highValue); } } } return; case "texturecommit": - OnCommitEstateTerrainTextureRequest?.Invoke(this); + c.OnCommitEstateTerrainTextureRequest?.Invoke(c); return; case "setregionterrain": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { if (messagePacket.ParamList.Length != 9) { @@ -11121,7 +10815,7 @@ private void HandleEstateOwnerMessage(Packet Pack) bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter); float EstateSunHour = Convert.ToSingle(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo); - OnSetRegionTerrainSettings?.Invoke(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour); + c.OnSetRegionTerrainSettings?.Invoke(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour); } catch (Exception ex) { @@ -11132,47 +10826,47 @@ private void HandleEstateOwnerMessage(Packet Pack) return; case "restart": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) { if(Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out float timeSeconds)) - OnEstateRestartSimRequest?.Invoke(this, (int)timeSeconds); + c.OnEstateRestartSimRequest?.Invoke(c, (int)timeSeconds); } } return; case "estatechangecovenantid": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) { UUID newCovenantID = new(Utils.BytesToString(block.Parameter)); - OnEstateChangeCovenantRequest?.Invoke(this, newCovenantID); + c.OnEstateChangeCovenantRequest?.Invoke(c, newCovenantID); } } return; case "estateaccessdelta": // Estate access delta manages the banlist and allow list too. - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); - OnUpdateEstateAccessDeltaRequest?.Invoke(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter))); + c.OnUpdateEstateAccessDeltaRequest?.Invoke(c, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter))); } return; case "simulatormessage": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { UUID SenderID = new(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter); string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter); - OnSimulatorBlueBoxMessageRequest?.Invoke(this, messagePacket.MethodData.Invoice, + c.OnSimulatorBlueBoxMessageRequest?.Invoke(c, messagePacket.MethodData.Invoice, SenderID, messagePacket.AgentData.SessionID, SenderName, Message); } return; case "instantmessage": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { if (messagePacket.ParamList.Length < 2) return; @@ -11183,7 +10877,7 @@ private void HandleEstateOwnerMessage(Packet Pack) if (messagePacket.ParamList.Length < 5) { - SenderID = m_agentId; + SenderID = c.m_agentId; SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter); Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter); } @@ -11194,45 +10888,45 @@ private void HandleEstateOwnerMessage(Packet Pack) Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter); } - OnEstateBlueBoxMessageRequest?.Invoke(this, messagePacket.MethodData.Invoice, - SenderID, m_sessionId, SenderName, Message); + c.OnEstateBlueBoxMessageRequest?.Invoke(c, messagePacket.MethodData.Invoice, + SenderID, c.m_sessionId, SenderName, Message); } return; case "setregiondebug": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { - if(OnEstateDebugRegionRequest is not null) + if(c.OnEstateDebugRegionRequest is not null) { bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter); bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter); bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter); - OnEstateDebugRegionRequest?.Invoke(this, messagePacket.MethodData.Invoice, - m_agentId, scripted, collisionEvents, physics); + c.OnEstateDebugRegionRequest?.Invoke(c, messagePacket.MethodData.Invoice, + c.m_agentId, scripted, collisionEvents, physics); } } return; case "teleporthomeuser": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { if(UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out UUID Prey)) - OnEstateTeleportOneUserHomeRequest?.Invoke(this, messagePacket.MethodData.Invoice, m_agentId, Prey, false); + c.OnEstateTeleportOneUserHomeRequest?.Invoke(c, messagePacket.MethodData.Invoice, c.m_agentId, Prey, false); } return; case "teleporthomeallusers": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { - OnEstateTeleportAllUsersHomeRequest?.Invoke(this, messagePacket.MethodData.Invoice, m_agentId); + c.OnEstateTeleportAllUsersHomeRequest?.Invoke(c, messagePacket.MethodData.Invoice, c.m_agentId); } return; case "colliders": - OnLandStatRequest?.Invoke(0, 1, 0, "", this); + c.OnLandStatRequest?.Invoke(0, 1, 0, "", c); return; case "scripts": - OnLandStatRequest?.Invoke(0, 0, 0, "", this); + c.OnLandStatRequest?.Invoke(0, 0, 0, "", c); return; case "terrain": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { if (messagePacket.ParamList.Length > 0) { @@ -11240,17 +10934,17 @@ private void HandleEstateOwnerMessage(Packet Pack) switch(p0) { case "bake": - OnBakeTerrain?.Invoke(this); + c.OnBakeTerrain?.Invoke(c); break; case "download filename": if (messagePacket.ParamList.Length > 1) - OnRequestTerrain?.Invoke(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); + c.OnRequestTerrain?.Invoke(c, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); break; case "upload filename": if (messagePacket.ParamList.Length > 1) - OnUploadTerrain?.Invoke(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); + c.OnUploadTerrain?.Invoke(c, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); break; default: @@ -11261,16 +10955,16 @@ private void HandleEstateOwnerMessage(Packet Pack) return; case "estatechangeinfo": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); - OnEstateChangeInfo?.Invoke(this, messagePacket.MethodData.Invoice, m_agentId, param1, param2); + c.OnEstateChangeInfo?.Invoke(c, messagePacket.MethodData.Invoice, c.m_agentId, param1, param2); } return; case "telehub": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { UInt32 param1 = 0u; string command = Utils.BytesToString(messagePacket.ParamList[0].Parameter); @@ -11282,53 +10976,53 @@ private void HandleEstateOwnerMessage(Packet Pack) } catch {} } - OnEstateManageTelehub?.Invoke(this, messagePacket.MethodData.Invoice, messagePacket.AgentData.AgentID, command, param1); + c.OnEstateManageTelehub?.Invoke(c, messagePacket.MethodData.Invoice, messagePacket.AgentData.AgentID, command, param1); } return; case "refreshmapvisibility": - if (m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if (c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { - IWorldMapModule mapModule = Scene.RequestModuleInterface(); + IWorldMapModule mapModule = c.m_scene.RequestModuleInterface(); if (mapModule is null) { - SendAlertMessage("Terrain map generator not avaiable"); + c.SendAlertMessage("Terrain map generator not avaiable"); return; } if (m_lastMapRegenTime == Double.MaxValue) { - SendAlertMessage("Terrain map generation still in progress"); + c.SendAlertMessage("Terrain map generation still in progress"); return; } double now = Util.GetTimeStamp(); if (now - m_lastMapRegenTime < 120) // 2 minutes global cool down { - SendAlertMessage("Please wait at least 2 minutes between map generation commands"); + c.SendAlertMessage("Please wait at least 2 minutes between map generation commands"); return; } m_lastMapRegenTime = Double.MaxValue; - m_scene.RegenerateMaptileAndReregister(this, null); - SendAlertMessage("Terrain map generated"); + c.m_scene.RegenerateMaptileAndReregister(c, null); + c.SendAlertMessage("Terrain map generated"); m_lastMapRegenTime = now; } return; case "kickestate": - if(m_scene.Permissions.CanIssueEstateCommand(m_agentId, false)) + if(c.m_scene.Permissions.CanIssueEstateCommand(c.m_agentId, false)) { if(UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[0].Parameter), out UUID Prey)) - OnEstateTeleportOneUserHomeRequest?.Invoke(this, messagePacket.MethodData.Invoice, - m_agentId, Prey, true); + c.OnEstateTeleportOneUserHomeRequest?.Invoke(c, messagePacket.MethodData.Invoice, + c.m_agentId, Prey, true); } return; default: m_log.WarnFormat( "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}", - method, Name, Scene.Name); + method, c.Name, c.m_scene.Name); for (int i = 0; i < messagePacket.ParamList.Length; i++) { @@ -11348,47 +11042,41 @@ private void HandleEstateOwnerMessage(Packet Pack) //lsrp.RequestData.Filter; } - private void HandleRequestRegionInfo(Packet Pack) + private static void HandleRequestRegionInfo(LLClientView c, Packet Pack) { RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData; - if (mPacket.SessionID.NotEqual(m_sessionId) || mPacket.AgentID.NotEqual(m_agentId)) - return; - - OnRegionInfoRequest?.Invoke(this); + c.OnRegionInfoRequest?.Invoke(c); } - private void HandleEstateCovenantRequest(Packet Pack) + private static void HandleEstateCovenantRequest(LLClientView c, Packet Pack) { EstateCovenantRequestPacket.AgentDataBlock epack = ((EstateCovenantRequestPacket)Pack).AgentData; - if (epack.SessionID.NotEqual(m_sessionId) || epack.AgentID.NotEqual(m_agentId)) - return; - - OnEstateCovenantRequest?.Invoke(this); + c.OnEstateCovenantRequest?.Invoke(c); } #endregion Estate Packets #region GodPackets - private void HandleRequestGodlikePowers(Packet Pack) + private static void HandleRequestGodlikePowers(LLClientView c, Packet Pack) { RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack; RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; - if (ablock.SessionID.NotEqual(m_sessionId) || ablock.AgentID.NotEqual(m_agentId)) + if (ablock.SessionID.NotEqual(c.m_sessionId) || ablock.AgentID.NotEqual(c.m_agentId)) return; RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock; UUID token = rblock.Token; - OnRequestGodlikePowers?.Invoke(ablock.AgentID, ablock.SessionID, token, rblock.Godlike); + c.OnRequestGodlikePowers?.Invoke(ablock.AgentID, ablock.SessionID, token, rblock.Godlike); } - private void HandleGodUpdateRegionInfoUpdate(Packet packet) + private static void HandleGodUpdateRegionInfoUpdate(LLClientView c, Packet packet) { GodUpdateRegionInfoPacket GodUpdateRegionInfo = (GodUpdateRegionInfoPacket)packet; - if (GodUpdateRegionInfo.AgentData.SessionID.NotEqual(m_sessionId) || GodUpdateRegionInfo.AgentData.AgentID.NotEqual(m_agentId)) + if (GodUpdateRegionInfo.AgentData.SessionID.NotEqual(c.m_sessionId) || GodUpdateRegionInfo.AgentData.AgentID.NotEqual(c.m_agentId)) return; - OnGodUpdateRegionInfoUpdate?.Invoke(this, + c.OnGodUpdateRegionInfoUpdate?.Invoke(c, GodUpdateRegionInfo.RegionInfo.BillableFactor, GodUpdateRegionInfo.RegionInfo.EstateID, GodUpdateRegionInfo.RegionInfo.RegionFlags, @@ -11397,102 +11085,80 @@ private void HandleGodUpdateRegionInfoUpdate(Packet packet) GodUpdateRegionInfo.RegionInfo.RedirectGridY); } - private void HandleSimWideDeletes(Packet packet) + private static void HandleSimWideDeletes(LLClientView c, Packet packet) { SimWideDeletesPacket SimWideDeletesRequest = (SimWideDeletesPacket)packet; - if(SimWideDeletesRequest.AgentData.AgentID.NotEqual(m_agentId) || SimWideDeletesRequest.AgentData.SessionID.NotEqual(m_sessionId)) - return; - - OnSimWideDeletes?.Invoke(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID); + c.OnSimWideDeletes?.Invoke(c, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags, + SimWideDeletesRequest.DataBlock.TargetID); } - private void HandleGodlikeMessage(Packet packet) + private static void HandleGodlikeMessage(LLClientView c, Packet packet) { GodlikeMessagePacket GodlikeMessage = (GodlikeMessagePacket)packet; - - if (GodlikeMessage.AgentData.SessionID.NotEqual(m_sessionId) || GodlikeMessage.AgentData.AgentID.NotEqual(m_agentId)) - return; - - onGodlikeMessage?.Invoke(this, + c.onGodlikeMessage?.Invoke(c, GodlikeMessage.MethodData.Invoice, GodlikeMessage.MethodData.Method, GodlikeMessage.ParamList[0].Parameter); } - private void HandleSaveStatePacket(Packet packet) + private static void HandleSaveStatePacket(LLClientView c, Packet packet) { StateSavePacket SaveStateMessage = (StateSavePacket)packet; - - if (SaveStateMessage.AgentData.SessionID.NotEqual(m_sessionId) || SaveStateMessage.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnSaveState?.Invoke(this,SaveStateMessage.AgentData.AgentID); + c.OnSaveState?.Invoke(c, SaveStateMessage.AgentData.AgentID); } - private void HandleGodKickUser(Packet Pack) + private static void HandleGodKickUser(LLClientView c, Packet Pack) { GodKickUserPacket gkupack = (GodKickUserPacket)Pack; - if (gkupack.UserInfo.GodSessionID.NotEqual(m_sessionId) || gkupack.UserInfo.GodID.NotEqual(m_agentId)) - return; - - OnGodKickUser?.Invoke(gkupack.UserInfo.GodID, gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason); + c.OnGodKickUser?.Invoke(gkupack.UserInfo.GodID, gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason); } #endregion GodPackets #region Economy/Transaction Packets - private void HandleMoneyBalanceRequest(Packet Pack) + private static void HandleMoneyBalanceRequest(LLClientView c, Packet Pack) { MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack; - if (moneybalancerequestpacket.AgentData.SessionID.NotEqual(m_sessionId) || moneybalancerequestpacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnMoneyBalanceRequest?.Invoke(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID); + c.OnMoneyBalanceRequest?.Invoke(c, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID); } - private void HandleEconomyDataRequest(Packet Pack) + private static void HandleEconomyDataRequest(LLClientView c, Packet _) { - OnEconomyDataRequest?.Invoke(this); + c.OnEconomyDataRequest?.Invoke(c); } - private void HandleRequestPayPrice(Packet Pack) + private static void HandleRequestPayPrice(LLClientView c, Packet Pack) { RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack; - OnRequestPayPrice?.Invoke(this, requestPayPricePacket.ObjectData.ObjectID); + c.OnRequestPayPrice?.Invoke(c, requestPayPricePacket.ObjectData.ObjectID); } - private void HandleObjectSaleInfo(Packet Pack) + private static void HandleObjectSaleInfo(LLClientView c, Packet Pack) { - if(OnObjectSaleInfo is null) + if(c.OnObjectSaleInfo is null) return; ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack; - if (objectSaleInfoPacket.AgentData.SessionID.NotEqual(m_sessionId) || objectSaleInfoPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - foreach (ObjectSaleInfoPacket.ObjectDataBlock d in objectSaleInfoPacket.ObjectData) { - OnObjectSaleInfo?.Invoke(this, - m_agentId, - SessionId, + c.OnObjectSaleInfo?.Invoke(c, + c.m_agentId, + c.SessionId, d.LocalID, d.SaleType, d.SalePrice); } } - private void HandleObjectBuy(Packet Pack) + private static void HandleObjectBuy(LLClientView c, Packet Pack) { - if(OnObjectBuy is null) + if(c.OnObjectBuy is null) return; ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack; - if (objectBuyPacket.AgentData.SessionID.NotEqual(m_sessionId) || objectBuyPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - foreach (ObjectBuyPacket.ObjectDataBlock d in objectBuyPacket.ObjectData) { - OnObjectBuy?.Invoke(this, + c.OnObjectBuy?.Invoke(c, objectBuyPacket.AgentData.AgentID, objectBuyPacket.AgentData.SessionID, objectBuyPacket.AgentData.GroupID, @@ -11506,122 +11172,102 @@ private void HandleObjectBuy(Packet Pack) #endregion Economy/Transaction Packets #region Script Packets - private void HandleGetScriptRunning(Packet Pack) + private static void HandleGetScriptRunning(LLClientView c, Packet Pack) { GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack; - OnGetScriptRunning?.Invoke(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID); + c.OnGetScriptRunning?.Invoke(c, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID); } - private void HandleSetScriptRunning(Packet Pack) + private static void HandleSetScriptRunning(LLClientView c, Packet Pack) { SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack; - if (setScriptRunning.AgentData.SessionID.NotEqual(m_sessionId) || setScriptRunning.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnSetScriptRunning?.Invoke(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running); + c.OnSetScriptRunning?.Invoke(c, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running); } - private void HandleScriptReset(Packet Pack) + private static void HandleScriptReset(LLClientView c, Packet Pack) { ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack; - if (scriptResetPacket.AgentData.SessionID.NotEqual(m_sessionId) || scriptResetPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnScriptReset?.Invoke(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID); + c.OnScriptReset?.Invoke(c, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID); } #endregion Script Packets #region Gesture Managment - private void HandleActivateGestures(Packet Pack) + private static void HandleActivateGestures(LLClientView c, Packet Pack) { - if(OnActivateGesture is null) + if(c.OnActivateGesture is null) return; ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack; - if (activateGesturePacket.AgentData.SessionID.NotEqual(m_sessionId) || activateGesturePacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - ActivateGesturesPacket.DataBlock[] data = activateGesturePacket.Data; for (int i= 0; i < data.Length; ++i) { - OnActivateGesture?.Invoke(this, + c.OnActivateGesture?.Invoke(c, data[i].AssetID, data[i].ItemID); } } - private void HandleDeactivateGestures(Packet Pack) + private static void HandleDeactivateGestures(LLClientView c, Packet Pack) { - if(OnDeactivateGesture is null) + if(c.OnDeactivateGesture is null) return; DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack; - if (deactivateGesturePacket.AgentData.SessionID.NotEqual(m_sessionId) || deactivateGesturePacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - DeactivateGesturesPacket.DataBlock[] data = deactivateGesturePacket.Data; for (int i = 0; i < data.Length; ++i) { - OnDeactivateGesture?.Invoke(this, data[i].ItemID); + c.OnDeactivateGesture?.Invoke(c, data[i].ItemID); } } #endregion Gesture Managment - private void HandleObjectOwner(Packet Pack) + private static void HandleObjectOwner(LLClientView c, Packet Pack) { - if (OnObjectOwner is null) + if (c.OnObjectOwner is null) return; ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack; - if (objectOwnerPacket.AgentData.SessionID.NotEqual(m_sessionId) || objectOwnerPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - List localIDs = new(); foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData) localIDs.Add(d.ObjectLocalID); - OnObjectOwner?.Invoke(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs); + c.OnObjectOwner?.Invoke(c, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs); } - private void HandleAgentFOV(Packet Pack) + private static void HandleAgentFOV(LLClientView c, Packet Pack) { AgentFOVPacket fovPacket = (AgentFOVPacket)Pack; - if(fovPacket.AgentData.AgentID.NotEqual(m_agentId) || fovPacket.AgentData.SessionID.NotEqual(m_sessionId)) - return; - uint genCounter = fovPacket.FOVBlock.GenCounter; - if (genCounter == 0 || genCounter > m_agentFOVCounter) + if (genCounter == 0 || genCounter > c.m_agentFOVCounter) { - m_agentFOVCounter = genCounter; - FOV = fovPacket.FOVBlock.VerticalAngle; - OnAgentFOV?.Invoke(this, FOV); + c.m_agentFOVCounter = genCounter; + c.FOV = fovPacket.FOVBlock.VerticalAngle; + c.OnAgentFOV?.Invoke(c, c.FOV); } } #region unimplemented handlers - private void HandleViewerStats(Packet Pack) + private static void HandleViewerStats(LLClientView c, Packet Pack) { // TODO: handle this packet //m_log.Warn("[CLIENT]: unhandled ViewerStats packet"); } - private void HandleMapItemRequest(Packet Pack) + private static void HandleMapItemRequest(LLClientView c, Packet Pack) { MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack; - if (mirpk.AgentData.SessionID.NotEqual(m_sessionId) || mirpk.AgentData.AgentID.NotEqual(m_agentId)) - return; //m_log.Debug(mirpk.ToString()); try { - OnMapItemRequest?.Invoke(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID, + c.OnMapItemRequest?.Invoke(c, mirpk.AgentData.Flags, mirpk.AgentData.EstateID, mirpk.AgentData.Godlike, mirpk.RequestData.ItemType, mirpk.RequestData.RegionHandle); } @@ -11631,59 +11277,47 @@ private void HandleMapItemRequest(Packet Pack) } } - private void HandleTransferAbort(Packet Pack) + private static void HandleTransferAbort(LLClientView c, Packet Pack) { } - private void HandleMuteListRequest(Packet Pack) + private static void HandleMuteListRequest(LLClientView c, Packet Pack) { MuteListRequestPacket muteListRequest = (MuteListRequestPacket)Pack; - if (muteListRequest.AgentData.SessionID.NotEqual(m_sessionId) || muteListRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - if (OnMuteListRequest != null) + if (c.OnMuteListRequest != null) { - OnMuteListRequest?.Invoke(this, muteListRequest.MuteData.MuteCRC); + c.OnMuteListRequest?.Invoke(c, muteListRequest.MuteData.MuteCRC); } else { if(muteListRequest.MuteData.MuteCRC == 0) - SendEmpytMuteList(); + c.SendEmpytMuteList(); else - SendUseCachedMuteList(); + c.SendUseCachedMuteList(); } } - private void HandleUpdateMuteListEntry(Packet packet) + private static void HandleUpdateMuteListEntry(LLClientView c, Packet packet) { UpdateMuteListEntryPacket UpdateMuteListEntry = (UpdateMuteListEntryPacket)packet; - if (UpdateMuteListEntry.AgentData.SessionID.NotEqual(m_sessionId) || UpdateMuteListEntry.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnUpdateMuteListEntry?.Invoke(this, UpdateMuteListEntry.MuteData.MuteID, + c.OnUpdateMuteListEntry?.Invoke(c, UpdateMuteListEntry.MuteData.MuteID, Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName), UpdateMuteListEntry.MuteData.MuteType, UpdateMuteListEntry.MuteData.MuteFlags); } - private void HandleRemoveMuteListEntry(Packet packet) + private static void HandleRemoveMuteListEntry(LLClientView c, Packet packet) { RemoveMuteListEntryPacket RemoveMuteListEntry = (RemoveMuteListEntryPacket)packet; - if (RemoveMuteListEntry.AgentData.SessionID.NotEqual(m_sessionId) || RemoveMuteListEntry.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnRemoveMuteListEntry?.Invoke(this, + c.OnRemoveMuteListEntry?.Invoke(c, RemoveMuteListEntry.MuteData.MuteID, Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName)); } - private void HandleUserReport(Packet packet) + private static void HandleUserReport(LLClientView c, Packet packet) { UserReportPacket UserReport = (UserReportPacket)packet; - if (UserReport.AgentData.SessionID.NotEqual(m_sessionId) || UserReport.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnUserReport?.Invoke(this, + c.OnUserReport?.Invoke(c, Utils.BytesToString(UserReport.ReportData.AbuseRegionName), UserReport.ReportData.AbuserID, UserReport.ReportData.Category, @@ -11697,27 +11331,24 @@ private void HandleUserReport(Packet packet) UserReport.AgentData.AgentID); } - private void HandleSendPostcard(Packet packet) + private static void HandleSendPostcard(LLClientView c, Packet packet) { // SendPostcardPacket SendPostcard = // (SendPostcardPacket)packet; - OnSendPostcard?.Invoke(this); + c.OnSendPostcard?.Invoke(c); } - private void HandleChangeInventoryItemFlags(Packet packet) + private static void HandleChangeInventoryItemFlags(LLClientView c, Packet packet) { - if(OnChangeInventoryItemFlags is null) + if(c.OnChangeInventoryItemFlags is null) return; ChangeInventoryItemFlagsPacket ChangeInventoryItemFlags = (ChangeInventoryItemFlagsPacket)packet; - if (ChangeInventoryItemFlags.AgentData.SessionID.NotEqual(m_sessionId) || ChangeInventoryItemFlags.AgentData.AgentID.NotEqual(m_agentId)) - return; - foreach(ChangeInventoryItemFlagsPacket.InventoryDataBlock b in ChangeInventoryItemFlags.InventoryData) - OnChangeInventoryItemFlags?.Invoke(this, b.ItemID, b.Flags); + c.OnChangeInventoryItemFlags?.Invoke(c, b.ItemID, b.Flags); } - private void HandleUseCircuitCode(Packet Pack) + private static void HandleUseCircuitCode(LLClientView c, Packet Pack) { /* UseCircuitCodePacket uccp = (UseCircuitCodePacket)Pack; @@ -11731,15 +11362,12 @@ private void HandleUseCircuitCode(Packet Pack) */ } - private void HandleCreateNewOutfitAttachments(Packet Pack) + private static void HandleCreateNewOutfitAttachments(LLClientView c, Packet Pack) { - if(OnMoveItemsAndLeaveCopy is null) + if(c.OnMoveItemsAndLeaveCopy is null) return; CreateNewOutfitAttachmentsPacket packet = (CreateNewOutfitAttachmentsPacket)Pack; - if (packet.AgentData.SessionID.NotEqual(m_sessionId) || packet.AgentData.AgentID.NotEqual(m_agentId)) - return; - List items = new(); foreach (CreateNewOutfitAttachmentsPacket.ObjectDataBlock n in packet.ObjectData) { @@ -11751,21 +11379,17 @@ private void HandleCreateNewOutfitAttachments(Packet Pack) items.Add(b); } - OnMoveItemsAndLeaveCopy?.Invoke(this, items, packet.HeaderData.NewFolderID); + c.OnMoveItemsAndLeaveCopy?.Invoke(c, items, packet.HeaderData.NewFolderID); } - private void HandleAgentHeightWidth(Packet Pack) + private static void HandleAgentHeightWidth(LLClientView c, Packet Pack) { AgentHeightWidthPacket hwPacket = (AgentHeightWidthPacket)Pack; - if (hwPacket.AgentData.AgentID.NotEqual(m_agentId) || hwPacket.AgentData.SessionID.NotEqual(m_sessionId)) - return; - - viewHeight = hwPacket.HeightWidthBlock.Height; - viewWidth = hwPacket.HeightWidthBlock.Width; + c.viewHeight = hwPacket.HeightWidthBlock.Height; + c.viewWidth = hwPacket.HeightWidthBlock.Width; } - - private void HandleInventoryDescendents(Packet Pack) + private static void HandleInventoryDescendents(LLClientView c, Packet Pack) { } @@ -11773,13 +11397,10 @@ private void HandleInventoryDescendents(Packet Pack) #region Dir handlers - private void HandleDirPlacesQuery(Packet Pack) + private static void HandleDirPlacesQuery(LLClientView c, Packet Pack) { DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack; - if (dirPlacesQueryPacket.AgentData.SessionID.NotEqual(m_sessionId) || dirPlacesQueryPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnDirPlacesQuery?.Invoke(this, + c.OnDirPlacesQuery?.Invoke(c, dirPlacesQueryPacket.QueryData.QueryID, Utils.BytesToString( dirPlacesQueryPacket.QueryData.QueryText), @@ -11790,13 +11411,10 @@ private void HandleDirPlacesQuery(Packet Pack) dirPlacesQueryPacket.QueryData.QueryStart); } - private void HandleDirFindQuery(Packet Pack) + private static void HandleDirFindQuery(LLClientView c, Packet Pack) { DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack; - if (dirFindQueryPacket.AgentData.SessionID.NotEqual(m_sessionId) || dirFindQueryPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnDirFindQuery?.Invoke(this, + c.OnDirFindQuery?.Invoke(c, dirFindQueryPacket.QueryData.QueryID, Utils.BytesToString( dirFindQueryPacket.QueryData.QueryText).Trim(), @@ -11804,13 +11422,10 @@ private void HandleDirFindQuery(Packet Pack) dirFindQueryPacket.QueryData.QueryStart); } - private void HandleDirLandQuery(Packet Pack) + private static void HandleDirLandQuery(LLClientView c, Packet Pack) { DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack; - if (dirLandQueryPacket.AgentData.SessionID.NotEqual(m_sessionId) || dirLandQueryPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnDirLandQuery?.Invoke(this, + c.OnDirLandQuery?.Invoke(c, dirLandQueryPacket.QueryData.QueryID, dirLandQueryPacket.QueryData.QueryFlags, dirLandQueryPacket.QueryData.SearchType, @@ -11819,24 +11434,18 @@ private void HandleDirLandQuery(Packet Pack) dirLandQueryPacket.QueryData.QueryStart); } - private void HandleDirPopularQuery(Packet Pack) + private static void HandleDirPopularQuery(LLClientView c, Packet Pack) { DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack; - if (dirPopularQueryPacket.AgentData.SessionID.NotEqual(m_sessionId) || dirPopularQueryPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnDirPopularQuery?.Invoke(this, + c.OnDirPopularQuery?.Invoke(c, dirPopularQueryPacket.QueryData.QueryID, dirPopularQueryPacket.QueryData.QueryFlags); } - private void HandleDirClassifiedQuery(Packet Pack) + private static void HandleDirClassifiedQuery(LLClientView c, Packet Pack) { DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack; - if (dirClassifiedQueryPacket.AgentData.SessionID.NotEqual(m_sessionId) || dirClassifiedQueryPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnDirClassifiedQuery?.Invoke(this, + c.OnDirClassifiedQuery?.Invoke(c, dirClassifiedQueryPacket.QueryData.QueryID, Utils.BytesToString( dirClassifiedQueryPacket.QueryData.QueryText), @@ -11845,53 +11454,42 @@ private void HandleDirClassifiedQuery(Packet Pack) dirClassifiedQueryPacket.QueryData.QueryStart); } - private void HandleEventInfoRequest(Packet Pack) + private static void HandleEventInfoRequest(LLClientView c, Packet Pack) { EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack; - if (eventInfoRequestPacket.AgentData.SessionID.NotEqual(m_sessionId) || eventInfoRequestPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnEventInfoRequest?.Invoke(this, eventInfoRequestPacket.EventData.EventID); + c.OnEventInfoRequest?.Invoke(c, eventInfoRequestPacket.EventData.EventID); } #endregion #region Calling Card - private void HandleOfferCallingCard(Packet Pack) + private static void HandleOfferCallingCard(LLClientView c, Packet Pack) { OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack; - if (offerCallingCardPacket.AgentData.SessionID.NotEqual(m_sessionId) || offerCallingCardPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnOfferCallingCard?.Invoke(this, + c.OnOfferCallingCard?.Invoke(c, offerCallingCardPacket.AgentBlock.DestID, offerCallingCardPacket.AgentBlock.TransactionID); } - private void HandleAcceptCallingCard(Packet Pack) + private static void HandleAcceptCallingCard(LLClientView c, Packet Pack) { AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack; - if (acceptCallingCardPacket.AgentData.SessionID.NotEqual(m_sessionId) || acceptCallingCardPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should // contain exactly one entry if (acceptCallingCardPacket.FolderData.Length > 0) { - OnAcceptCallingCard?.Invoke(this, + c.OnAcceptCallingCard?.Invoke(c, acceptCallingCardPacket.TransactionBlock.TransactionID, acceptCallingCardPacket.FolderData[0].FolderID); } } - private void HandleDeclineCallingCard(Packet Pack) + private static void HandleDeclineCallingCard(LLClientView c, Packet Pack) { DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack; - if (declineCallingCardPacket.AgentData.SessionID.NotEqual(m_sessionId) || declineCallingCardPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnDeclineCallingCard?.Invoke(this, + c.OnDeclineCallingCard?.Invoke(c, declineCallingCardPacket.TransactionBlock.TransactionID); } @@ -11899,81 +11497,61 @@ private void HandleDeclineCallingCard(Packet Pack) #region Groups - private void HandleActivateGroup(Packet Pack) + private static void HandleActivateGroup(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack; - if (activateGroupPacket.AgentData.SessionID.NotEqual(m_sessionId) || activateGroupPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID); + c.m_GroupsModule.ActivateGroup(c, activateGroupPacket.AgentData.GroupID); } - private void HandleGroupVoteHistoryRequest(Packet packet) + private static void HandleGroupVoteHistoryRequest(LLClientView c, Packet packet) { GroupVoteHistoryRequestPacket GroupVoteHistoryRequest = (GroupVoteHistoryRequestPacket)packet; - if (GroupVoteHistoryRequest.AgentData.SessionID.NotEqual(m_sessionId) || GroupVoteHistoryRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnGroupVoteHistoryRequest?.Invoke(this, m_agentId, SessionId, GroupVoteHistoryRequest.GroupData.GroupID, GroupVoteHistoryRequest.TransactionData.TransactionID); + c.OnGroupVoteHistoryRequest?.Invoke(c, c.m_agentId, c.SessionId, GroupVoteHistoryRequest.GroupData.GroupID, GroupVoteHistoryRequest.TransactionData.TransactionID); } - private void HandleGroupActiveProposalsRequest(Packet packet) + private static void HandleGroupActiveProposalsRequest(LLClientView c, Packet packet) { GroupActiveProposalsRequestPacket GroupActiveProposalsRequest = (GroupActiveProposalsRequestPacket)packet; - if (GroupActiveProposalsRequest.AgentData.SessionID.NotEqual(m_sessionId) || GroupActiveProposalsRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnGroupActiveProposalsRequest?.Invoke(this, m_agentId, SessionId, GroupActiveProposalsRequest.GroupData.GroupID, GroupActiveProposalsRequest.TransactionData.TransactionID); + c.OnGroupActiveProposalsRequest?.Invoke(c, c.m_agentId, c.SessionId, GroupActiveProposalsRequest.GroupData.GroupID, GroupActiveProposalsRequest.TransactionData.TransactionID); } - private void HandleGroupAccountDetailsRequest(Packet packet) + private static void HandleGroupAccountDetailsRequest(LLClientView c, Packet packet) { GroupAccountDetailsRequestPacket GroupAccountDetailsRequest = (GroupAccountDetailsRequestPacket)packet; - if (GroupAccountDetailsRequest.AgentData.SessionID.NotEqual(m_sessionId) || GroupAccountDetailsRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnGroupAccountDetailsRequest?.Invoke(this, m_agentId, GroupAccountDetailsRequest.AgentData.GroupID, GroupAccountDetailsRequest.MoneyData.RequestID, SessionId); + c.OnGroupAccountDetailsRequest?.Invoke(c, c.m_agentId, GroupAccountDetailsRequest.AgentData.GroupID, GroupAccountDetailsRequest.MoneyData.RequestID, c.SessionId); } - private void HandleGroupAccountSummaryRequest(Packet packet) + private static void HandleGroupAccountSummaryRequest(LLClientView c, Packet packet) { GroupAccountSummaryRequestPacket GroupAccountSummaryRequest = (GroupAccountSummaryRequestPacket)packet; - if (GroupAccountSummaryRequest.AgentData.SessionID.NotEqual(m_sessionId) || GroupAccountSummaryRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnGroupAccountSummaryRequest?.Invoke(this, m_agentId, GroupAccountSummaryRequest.AgentData.GroupID); + c.OnGroupAccountSummaryRequest?.Invoke(c, c.m_agentId, GroupAccountSummaryRequest.AgentData.GroupID); } - private void HandleGroupTransactionsDetailsRequest(Packet packet) + private static void HandleGroupTransactionsDetailsRequest(LLClientView c, Packet packet) { GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest = (GroupAccountTransactionsRequestPacket)packet; - if (GroupAccountTransactionsRequest.AgentData.SessionID.NotEqual(m_sessionId) || GroupAccountTransactionsRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnGroupAccountTransactionsRequest?.Invoke(this, m_agentId, GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID, SessionId); + c.OnGroupAccountTransactionsRequest?.Invoke(c, c.m_agentId, GroupAccountTransactionsRequest.AgentData.GroupID, + GroupAccountTransactionsRequest.MoneyData.RequestID, c.SessionId); } - private void HandleGroupTitlesRequest(Packet Pack) + private static void HandleGroupTitlesRequest(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; GroupTitlesRequestPacket groupTitlesRequest = (GroupTitlesRequestPacket)Pack; - if (groupTitlesRequest.AgentData.SessionID.NotEqual(m_sessionId) || groupTitlesRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply); groupTitlesReply.AgentData = new GroupTitlesReplyPacket.AgentDataBlock { - AgentID = m_agentId, + AgentID = c.m_agentId, GroupID = groupTitlesRequest.AgentData.GroupID, RequestID = groupTitlesRequest.AgentData.RequestID }; - List titles = m_GroupsModule.GroupTitlesRequest(this, + List titles = c.m_GroupsModule.GroupTitlesRequest(c, groupTitlesRequest.AgentData.GroupID); groupTitlesReply.GroupData = new GroupTitlesReplyPacket.GroupDataBlock[titles.Count]; @@ -11988,36 +11566,33 @@ private void HandleGroupTitlesRequest(Packet Pack) }; } - OutPacket(groupTitlesReply, ThrottleOutPacketType.Task); + c.OutPacket(groupTitlesReply, ThrottleOutPacketType.Task); } UUID lastGroupProfileRequestID = UUID.Zero; double lastGroupProfileRequestTS = Util.GetTimeStampMS(); - private void HandleGroupProfileRequest(Packet Pack) + private static void HandleGroupProfileRequest(LLClientView c, Packet Pack) { - if(m_GroupsModule is null) + if(c.m_GroupsModule is null) return; GroupProfileRequestPacket groupProfileRequest = (GroupProfileRequestPacket)Pack; - if (groupProfileRequest.AgentData.SessionID.NotEqual(m_sessionId) || groupProfileRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - UUID grpID = groupProfileRequest.GroupData.GroupID; double ts = Util.GetTimeStampMS(); - if(grpID == lastGroupProfileRequestID && ts - lastGroupProfileRequestTS < 10000) + if(grpID == c.lastGroupProfileRequestID && ts - c.lastGroupProfileRequestTS < 10000) return; - lastGroupProfileRequestID = grpID; - lastGroupProfileRequestTS = ts; + c.lastGroupProfileRequestID = grpID; + c.lastGroupProfileRequestTS = ts; GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply); groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock(); groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock(); - groupProfileReply.AgentData.AgentID = m_agentId; + groupProfileReply.AgentData.AgentID = c.m_agentId; - GroupProfileData d = m_GroupsModule.GroupProfileRequest(this, groupProfileRequest.GroupData.GroupID); + GroupProfileData d = c.m_GroupsModule.GroupProfileRequest(c, groupProfileRequest.GroupData.GroupID); if(d.GroupID.IsZero()) // don't send broken data return; @@ -12039,9 +11614,9 @@ private void HandleGroupProfileRequest(Packet Pack) groupProfileReply.GroupData.MaturePublish = d.MaturePublish; groupProfileReply.GroupData.OwnerRole = d.OwnerRole; - if (m_scene.Permissions.IsGod(m_agentId) && (!IsGroupMember(groupProfileRequest.GroupData.GroupID))) + if (c.m_scene.Permissions.IsGod(c.m_agentId) && (!c.IsGroupMember(groupProfileRequest.GroupData.GroupID))) { - if (m_scene.TryGetScenePresence(m_agentId, out ScenePresence p)) + if (c.m_scene.TryGetScenePresence(c.m_agentId, out ScenePresence p)) { if (p.IsViewerUIGod) { @@ -12051,24 +11626,20 @@ private void HandleGroupProfileRequest(Packet Pack) } } - OutPacket(groupProfileReply, ThrottleOutPacketType.Task); + c.OutPacket(groupProfileReply, ThrottleOutPacketType.Task); - if(grpID == lastGroupProfileRequestID) - lastGroupProfileRequestTS = Util.GetTimeStampMS() - 7000; + if(grpID.Equals(c.lastGroupProfileRequestID)) + c.lastGroupProfileRequestTS = Util.GetTimeStampMS() - 7000; } - private void HandleGroupMembersRequest(Packet Pack) + private static void HandleGroupMembersRequest(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) - return; - - GroupMembersRequestPacket groupMembersRequestPacket = - (GroupMembersRequestPacket)Pack; - if (groupMembersRequestPacket.AgentData.SessionID.NotEqual(m_sessionId) || groupMembersRequestPacket.AgentData.AgentID.NotEqual(m_agentId)) + if (c.m_GroupsModule is null) return; + GroupMembersRequestPacket groupMembersRequestPacket = (GroupMembersRequestPacket)Pack; List members = - m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID); + c.m_GroupsModule.GroupMembersRequest(c, groupMembersRequestPacket.GroupData.GroupID); int memberCount = members.Count; int indx = 0; @@ -12084,7 +11655,7 @@ private void HandleGroupMembersRequest(Packet Pack) groupMembersReply.GroupData = new GroupMembersReplyPacket.GroupDataBlock(); groupMembersReply.MemberData = new GroupMembersReplyPacket.MemberDataBlock[blockCount]; - groupMembersReply.AgentData.AgentID = m_agentId; + groupMembersReply.AgentData.AgentID = c.m_agentId; groupMembersReply.GroupData.GroupID = groupMembersRequestPacket.GroupData.GroupID; groupMembersReply.GroupData.RequestID = groupMembersRequestPacket.GroupData.RequestID; groupMembersReply.GroupData.MemberCount = memberCount; @@ -12102,28 +11673,25 @@ private void HandleGroupMembersRequest(Packet Pack) IsOwner = m.IsOwner }; } - OutPacket(groupMembersReply, ThrottleOutPacketType.Task); + c.OutPacket(groupMembersReply, ThrottleOutPacketType.Task); } } - private void HandleGroupRoleDataRequest(Packet Pack) + private static void HandleGroupRoleDataRequest(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; GroupRoleDataRequestPacket groupRolesRequest = (GroupRoleDataRequestPacket)Pack; - if (groupRolesRequest.AgentData.SessionID.NotEqual(m_sessionId) || groupRolesRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply); - groupRolesReply.AgentData = new GroupRoleDataReplyPacket.AgentDataBlock { AgentID = m_agentId }; + groupRolesReply.AgentData = new GroupRoleDataReplyPacket.AgentDataBlock { AgentID = c.m_agentId }; groupRolesReply.GroupData = new GroupRoleDataReplyPacket.GroupDataBlock { GroupID = groupRolesRequest.GroupData.GroupID, RequestID = groupRolesRequest.GroupData.RequestID }; - List titles = m_GroupsModule.GroupRoleDataRequest(this, + List titles = c.m_GroupsModule.GroupRoleDataRequest(c, groupRolesRequest.GroupData.GroupID); groupRolesReply.GroupData.RoleCount = titles.Count; groupRolesReply.RoleData = new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count]; @@ -12143,19 +11711,17 @@ private void HandleGroupRoleDataRequest(Packet Pack) i++; } - OutPacket(groupRolesReply, ThrottleOutPacketType.Task); + c.OutPacket(groupRolesReply, ThrottleOutPacketType.Task); } - private void HandleGroupRoleMembersRequest(Packet Pack) + private static void HandleGroupRoleMembersRequest(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; GroupRoleMembersRequestPacket groupRoleMembersRequest = (GroupRoleMembersRequestPacket)Pack; - if (groupRoleMembersRequest.AgentData.SessionID.NotEqual(m_sessionId) || groupRoleMembersRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - List mappings = m_GroupsModule.GroupRoleMembersRequest(this, + List mappings = c.m_GroupsModule.GroupRoleMembersRequest(c, groupRoleMembersRequest.GroupData.GroupID); int mappingsCount = mappings.Count; @@ -12169,7 +11735,7 @@ private void HandleGroupRoleMembersRequest(Packet Pack) GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply); groupRoleMembersReply.AgentData = new GroupRoleMembersReplyPacket.AgentDataBlock { - AgentID = m_agentId, + AgentID = c.m_agentId, GroupID = groupRoleMembersRequest.GroupData.GroupID, RequestID = groupRoleMembersRequest.GroupData.RequestID, @@ -12190,20 +11756,18 @@ private void HandleGroupRoleMembersRequest(Packet Pack) }; } - OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task); + c.OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task); } } - private void HandleCreateGroupRequest(Packet Pack) + private static void HandleCreateGroupRequest(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; CreateGroupRequestPacket createGroupRequest = (CreateGroupRequestPacket)Pack; - if (createGroupRequest.AgentData.SessionID.NotEqual(m_sessionId) || createGroupRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - m_GroupsModule.CreateGroup(this, + c.m_GroupsModule.CreateGroup(c, Utils.BytesToString(createGroupRequest.GroupData.Name), Utils.BytesToString(createGroupRequest.GroupData.Charter), createGroupRequest.GroupData.ShowInList, @@ -12214,16 +11778,13 @@ private void HandleCreateGroupRequest(Packet Pack) createGroupRequest.GroupData.MaturePublish); } - private void HandleUpdateGroupInfo(Packet Pack) + private static void HandleUpdateGroupInfo(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; UpdateGroupInfoPacket updateGroupInfo = (UpdateGroupInfoPacket)Pack; - if (updateGroupInfo.AgentData.SessionID.NotEqual(m_sessionId) || updateGroupInfo.AgentData.AgentID.NotEqual(m_agentId)) - return; - - m_GroupsModule.UpdateGroupInfo(this, + c.m_GroupsModule.UpdateGroupInfo(c, updateGroupInfo.GroupData.GroupID, Utils.BytesToString(updateGroupInfo.GroupData.Charter), updateGroupInfo.GroupData.ShowInList, @@ -12234,60 +11795,48 @@ private void HandleUpdateGroupInfo(Packet Pack) updateGroupInfo.GroupData.MaturePublish); } - private void HandleSetGroupAcceptNotices(Packet Pack) + private static void HandleSetGroupAcceptNotices(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; SetGroupAcceptNoticesPacket setGroupAcceptNotices = (SetGroupAcceptNoticesPacket)Pack; - if (setGroupAcceptNotices.AgentData.SessionID.NotEqual(m_sessionId) || setGroupAcceptNotices.AgentData.AgentID.NotEqual(m_agentId)) - return; - - m_GroupsModule.SetGroupAcceptNotices(this, + c.m_GroupsModule.SetGroupAcceptNotices(c, setGroupAcceptNotices.Data.GroupID, setGroupAcceptNotices.Data.AcceptNotices, setGroupAcceptNotices.NewData.ListInProfile); } - private void HandleGroupTitleUpdate(Packet Pack) + private static void HandleGroupTitleUpdate(LLClientView c, Packet Pack) { GroupTitleUpdatePacket groupTitleUpdate = (GroupTitleUpdatePacket)Pack; - if (groupTitleUpdate.AgentData.SessionID.NotEqual(m_sessionId) || groupTitleUpdate.AgentData.AgentID.NotEqual(m_agentId)) - return; - - m_GroupsModule.GroupTitleUpdate(this, + c.m_GroupsModule.GroupTitleUpdate(c, groupTitleUpdate.AgentData.GroupID, groupTitleUpdate.AgentData.TitleRoleID); } - private void HandleParcelDeedToGroup(Packet Pack) + private static void HandleParcelDeedToGroup(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack; - if (parcelDeedToGroup.AgentData.SessionID.NotEqual(m_sessionId) || parcelDeedToGroup.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnParcelDeedToGroup?.Invoke(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this); + c.OnParcelDeedToGroup?.Invoke(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, c); } - private void HandleGroupNoticesListRequest(Packet Pack) + private static void HandleGroupNoticesListRequest(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; GroupNoticesListRequestPacket groupNoticesListRequest = (GroupNoticesListRequestPacket)Pack; - if (groupNoticesListRequest.AgentData.SessionID.NotEqual(m_sessionId) || groupNoticesListRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - GroupNoticeData[] gn = m_GroupsModule.GroupNoticesListRequest(this, groupNoticesListRequest.Data.GroupID); + GroupNoticeData[] gn = c.m_GroupsModule.GroupNoticesListRequest(c, groupNoticesListRequest.Data.GroupID); GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply); groupNoticesListReply.AgentData = new GroupNoticesListReplyPacket.AgentDataBlock { - AgentID = m_agentId, + AgentID = c.m_agentId, GroupID = groupNoticesListRequest.Data.GroupID }; @@ -12307,33 +11856,27 @@ private void HandleGroupNoticesListRequest(Packet Pack) }; } - OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task); + c.OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task); } - private void HandleGroupNoticeRequest(Packet Pack) + private static void HandleGroupNoticeRequest(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; GroupNoticeRequestPacket groupNoticeRequest = (GroupNoticeRequestPacket)Pack; - if (groupNoticeRequest.AgentData.SessionID.NotEqual(m_sessionId) || groupNoticeRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - m_GroupsModule.GroupNoticeRequest(this, groupNoticeRequest.Data.GroupNoticeID); + c.m_GroupsModule.GroupNoticeRequest(c, groupNoticeRequest.Data.GroupNoticeID); } - private void HandleGroupRoleUpdate(Packet Pack) + private static void HandleGroupRoleUpdate(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; GroupRoleUpdatePacket groupRoleUpdate = (GroupRoleUpdatePacket)Pack; - if (groupRoleUpdate.AgentData.SessionID.NotEqual(m_sessionId) || groupRoleUpdate.AgentData.AgentID.NotEqual(m_agentId)) - return; - foreach (GroupRoleUpdatePacket.RoleDataBlock d in groupRoleUpdate.RoleData) { - m_GroupsModule.GroupRoleUpdate(this, + c.m_GroupsModule.GroupRoleUpdate(c, groupRoleUpdate.AgentData.GroupID, d.RoleID, Utils.BytesToString(d.Name), @@ -12342,82 +11885,67 @@ private void HandleGroupRoleUpdate(Packet Pack) d.Powers, d.UpdateType); } - m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID); + c.m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID); } - private void HandleGroupRoleChanges(Packet Pack) + private static void HandleGroupRoleChanges(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; GroupRoleChangesPacket groupRoleChanges = (GroupRoleChangesPacket)Pack; - if (groupRoleChanges.AgentData.SessionID.NotEqual(m_sessionId) || groupRoleChanges.AgentData.AgentID.NotEqual(m_agentId)) - return; - foreach (GroupRoleChangesPacket.RoleChangeBlock d in groupRoleChanges.RoleChange) { - m_GroupsModule.GroupRoleChanges(this, + c.m_GroupsModule.GroupRoleChanges(c, groupRoleChanges.AgentData.GroupID, d.RoleID, d.MemberID, d.Change); } - m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID); + c.m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID); } - private void HandleJoinGroupRequest(Packet Pack) + private static void HandleJoinGroupRequest(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; JoinGroupRequestPacket joinGroupRequest = (JoinGroupRequestPacket)Pack; - if (joinGroupRequest.AgentData.SessionID.NotEqual(m_sessionId) || joinGroupRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - m_GroupsModule.JoinGroupRequest(this, joinGroupRequest.GroupData.GroupID); + c.m_GroupsModule.JoinGroupRequest(c, joinGroupRequest.GroupData.GroupID); } - private void HandleLeaveGroupRequest(Packet Pack) + private static void HandleLeaveGroupRequest(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; LeaveGroupRequestPacket leaveGroupRequest = (LeaveGroupRequestPacket)Pack; - if (leaveGroupRequest.AgentData.SessionID.NotEqual(m_sessionId) || leaveGroupRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - m_GroupsModule.LeaveGroupRequest(this, leaveGroupRequest.GroupData.GroupID); + c.m_GroupsModule.LeaveGroupRequest(c, leaveGroupRequest.GroupData.GroupID); } - private void HandleEjectGroupMemberRequest(Packet Pack) + private static void HandleEjectGroupMemberRequest(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; EjectGroupMemberRequestPacket ejectGroupMemberRequest = (EjectGroupMemberRequestPacket)Pack; - if (ejectGroupMemberRequest.AgentData.SessionID.NotEqual(m_sessionId) || ejectGroupMemberRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - foreach (EjectGroupMemberRequestPacket.EjectDataBlock e in ejectGroupMemberRequest.EjectData) { - m_GroupsModule.EjectGroupMemberRequest(this, + c.m_GroupsModule.EjectGroupMemberRequest(c, ejectGroupMemberRequest.GroupData.GroupID, e.EjecteeID); } } - private void HandleInviteGroupRequest(Packet Pack) + private static void HandleInviteGroupRequest(LLClientView c, Packet Pack) { - if (m_GroupsModule is null) + if (c.m_GroupsModule is null) return; InviteGroupRequestPacket inviteGroupRequest = (InviteGroupRequestPacket)Pack; - if (inviteGroupRequest.AgentData.SessionID.NotEqual(m_sessionId) || inviteGroupRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - foreach (InviteGroupRequestPacket.InviteDataBlock b in inviteGroupRequest.InviteData) { - m_GroupsModule.InviteGroupRequest(this, + c.m_GroupsModule.InviteGroupRequest(c, inviteGroupRequest.GroupData.GroupID, b.InviteeID, b.RoleID); @@ -12426,60 +11954,49 @@ private void HandleInviteGroupRequest(Packet Pack) #endregion Groups - private void HandleStartLure(Packet Pack) + private static void HandleStartLure(LLClientView c, Packet Pack) { - if(OnStartLure is null) + if(c.OnStartLure is null) return; StartLurePacket startLureRequest = (StartLurePacket)Pack; - if (startLureRequest.AgentData.SessionID.NotEqual(m_sessionId) || startLureRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - for (int i = 0 ; i < startLureRequest.TargetData.Length ; i++) { - OnStartLure?.Invoke(startLureRequest.Info.LureType, + c.OnStartLure?.Invoke(startLureRequest.Info.LureType, Utils.BytesToString( startLureRequest.Info.Message), startLureRequest.TargetData[i].TargetID, - this); + c); } } - private void HandleTeleportLureRequest(Packet Pack) + private static void HandleTeleportLureRequest(LLClientView c, Packet Pack) { TeleportLureRequestPacket teleportLureRequest = (TeleportLureRequestPacket)Pack; - if (teleportLureRequest.Info.SessionID.NotEqual(m_sessionId) || teleportLureRequest.Info.AgentID.NotEqual(m_agentId)) - return; - - OnTeleportLureRequest?.Invoke( + c.OnTeleportLureRequest?.Invoke( teleportLureRequest.Info.LureID, teleportLureRequest.Info.TeleportFlags, - this); + c); } - private void HandleClassifiedInfoRequest(Packet Pack) + private static void HandleClassifiedInfoRequest(LLClientView c, Packet Pack) { ClassifiedInfoRequestPacket classifiedInfoRequest = (ClassifiedInfoRequestPacket)Pack; - if (classifiedInfoRequest.AgentData.SessionID.NotEqual(m_sessionId) || classifiedInfoRequest.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnClassifiedInfoRequest?.Invoke( + c.OnClassifiedInfoRequest?.Invoke( classifiedInfoRequest.Data.ClassifiedID, - this); + c); } - private void HandleClassifiedInfoUpdate(Packet Pack) + private static void HandleClassifiedInfoUpdate(LLClientView c, Packet Pack) { ClassifiedInfoUpdatePacket classifiedInfoUpdate = (ClassifiedInfoUpdatePacket)Pack; - if (classifiedInfoUpdate.AgentData.SessionID.NotEqual(m_sessionId) || classifiedInfoUpdate.AgentData.AgentID.NotEqual(m_agentId)) - return; // fix classifiedFlags maturity byte classifiedFlags = classifiedInfoUpdate.Data.ClassifiedFlags; if ((classifiedFlags & 0x4e) == 0) // if none classifiedFlags |= 0x4; // pg - OnClassifiedInfoUpdate?.Invoke( + c.OnClassifiedInfoUpdate?.Invoke( classifiedInfoUpdate.Data.ClassifiedID, classifiedInfoUpdate.Data.Category, Utils.BytesToString( @@ -12493,103 +12010,76 @@ private void HandleClassifiedInfoUpdate(Packet Pack) classifiedInfoUpdate.Data.PosGlobal), classifiedFlags, classifiedInfoUpdate.Data.PriceForListing, - this); + c); } - private void HandleClassifiedDelete(Packet Pack) + private static void HandleClassifiedDelete(LLClientView c, Packet Pack) { ClassifiedDeletePacket classifiedDelete = (ClassifiedDeletePacket)Pack; - if (classifiedDelete.AgentData.SessionID.NotEqual(m_sessionId) || classifiedDelete.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnClassifiedDelete?.Invoke( + c.OnClassifiedDelete?.Invoke( classifiedDelete.Data.ClassifiedID, - this); + c); } - private void HandleClassifiedGodDelete(Packet Pack) + private static void HandleClassifiedGodDelete(LLClientView c, Packet Pack) { ClassifiedGodDeletePacket classifiedGodDelete = (ClassifiedGodDeletePacket)Pack; - if (classifiedGodDelete.AgentData.SessionID.NotEqual(m_sessionId) || classifiedGodDelete.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnClassifiedGodDelete?.Invoke( + c.OnClassifiedGodDelete?.Invoke( classifiedGodDelete.Data.ClassifiedID, classifiedGodDelete.Data.QueryID, - this); + c); } - private void HandleEventGodDelete(Packet Pack) + private static void HandleEventGodDelete(LLClientView c, Packet Pack) { EventGodDeletePacket eventGodDelete = (EventGodDeletePacket)Pack; - if (eventGodDelete.AgentData.SessionID.NotEqual(m_sessionId) || eventGodDelete.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnEventGodDelete?.Invoke( + c.OnEventGodDelete?.Invoke( eventGodDelete.EventData.EventID, eventGodDelete.QueryData.QueryID, Utils.BytesToString( eventGodDelete.QueryData.QueryText), eventGodDelete.QueryData.QueryFlags, eventGodDelete.QueryData.QueryStart, - this); + c); } - private void HandleEventNotificationAddRequest(Packet Pack) + private static void HandleEventNotificationAddRequest(LLClientView c, Packet Pack) { EventNotificationAddRequestPacket eventNotificationAdd = (EventNotificationAddRequestPacket)Pack; - if (eventNotificationAdd.AgentData.SessionID.NotEqual(m_sessionId) || eventNotificationAdd.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnEventNotificationAddRequest?.Invoke(eventNotificationAdd.EventData.EventID, this); + c.OnEventNotificationAddRequest?.Invoke(eventNotificationAdd.EventData.EventID, c); } - private void HandleEventNotificationRemoveRequest(Packet Pack) + private static void HandleEventNotificationRemoveRequest(LLClientView c, Packet Pack) { EventNotificationRemoveRequestPacket eventNotificationRemove = (EventNotificationRemoveRequestPacket)Pack; - if (eventNotificationRemove.AgentData.SessionID.NotEqual(m_sessionId) || eventNotificationRemove.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnEventNotificationRemoveRequest?.Invoke(eventNotificationRemove.EventData.EventID, this); + c.OnEventNotificationRemoveRequest?.Invoke(eventNotificationRemove.EventData.EventID, c); } - private void HandleRetrieveInstantMessages(Packet Pack) + private static void HandleRetrieveInstantMessages(LLClientView c, Packet Pack) { RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack; - if (rimpInstantMessagePack.AgentData.SessionID.NotEqual(m_sessionId) || rimpInstantMessagePack.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnRetrieveInstantMessages?.Invoke(this); + c.OnRetrieveInstantMessages?.Invoke(c); } - private void HandlePickDelete(Packet Pack) + private static void HandlePickDelete(LLClientView c, Packet Pack) { PickDeletePacket pickDelete = (PickDeletePacket)Pack; - if (pickDelete.AgentData.SessionID.NotEqual(m_sessionId) || pickDelete.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnPickDelete?.Invoke(this, pickDelete.Data.PickID); + c.OnPickDelete?.Invoke(c, pickDelete.Data.PickID); } - private void HandlePickGodDelete(Packet Pack) + private static void HandlePickGodDelete(LLClientView c, Packet Pack) { PickGodDeletePacket pickGodDelete = (PickGodDeletePacket)Pack; - if (pickGodDelete.AgentData.SessionID.NotEqual(m_sessionId) || pickGodDelete.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnPickGodDelete?.Invoke(this, + c.OnPickGodDelete?.Invoke(c, pickGodDelete.AgentData.AgentID, pickGodDelete.Data.PickID, pickGodDelete.Data.QueryID); } - private void HandlePickInfoUpdate(Packet Pack) + private static void HandlePickInfoUpdate(LLClientView c, Packet Pack) { PickInfoUpdatePacket pickInfoUpdate = (PickInfoUpdatePacket)Pack; - if (pickInfoUpdate.AgentData.SessionID.NotEqual(m_sessionId) || pickInfoUpdate.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnPickInfoUpdate?.Invoke(this, + c.OnPickInfoUpdate?.Invoke(c, pickInfoUpdate.Data.PickID, pickInfoUpdate.Data.CreatorID, pickInfoUpdate.Data.TopPick, @@ -12600,24 +12090,18 @@ private void HandlePickInfoUpdate(Packet Pack) pickInfoUpdate.Data.Enabled); } - private void HandleAvatarNotesUpdate(Packet Pack) + private static void HandleAvatarNotesUpdate(LLClientView c, Packet Pack) { AvatarNotesUpdatePacket avatarNotesUpdate = (AvatarNotesUpdatePacket)Pack; - if (avatarNotesUpdate.AgentData.SessionID.NotEqual(m_sessionId) || avatarNotesUpdate.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnAvatarNotesUpdate?.Invoke(this, + c.OnAvatarNotesUpdate?.Invoke(c, avatarNotesUpdate.Data.TargetID, Utils.BytesToString(avatarNotesUpdate.Data.Notes)); } - private void HandleAvatarInterestsUpdate(Packet Pack) + private static void HandleAvatarInterestsUpdate(LLClientView c, Packet Pack) { AvatarInterestsUpdatePacket avatarInterestUpdate = (AvatarInterestsUpdatePacket)Pack; - if (avatarInterestUpdate.AgentData.SessionID.NotEqual(m_sessionId) || avatarInterestUpdate.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnAvatarInterestUpdate?.Invoke(this, + c.OnAvatarInterestUpdate?.Invoke(c, avatarInterestUpdate.PropertiesData.WantToMask, Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText), avatarInterestUpdate.PropertiesData.SkillsMask, @@ -12625,13 +12109,10 @@ private void HandleAvatarInterestsUpdate(Packet Pack) Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText)); } - private void HandleGrantUserRights(Packet Pack) + private static void HandleGrantUserRights(LLClientView c, Packet Pack) { GrantUserRightsPacket GrantUserRights = (GrantUserRightsPacket)Pack; - if (GrantUserRights.AgentData.SessionID.NotEqual(m_sessionId) || GrantUserRights.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnGrantUserRights?.Invoke(this, + c.OnGrantUserRights?.Invoke(c, GrantUserRights.Rights[0].AgentRelated, GrantUserRights.Rights[0].RelatedRights); } @@ -12639,43 +12120,37 @@ private void HandleGrantUserRights(Packet Pack) private double m_nextRevokePermissionsTime = Double.MinValue; private uint m_lastRevokePermissionsSeq = uint.MinValue; - private void HandleRevokePermissions(Packet Pack) + private static void HandleRevokePermissions(LLClientView c, Packet Pack) { RevokePermissionsPacket pkt = (RevokePermissionsPacket)Pack; - if (pkt.AgentData.SessionID.NotEqual(m_sessionId) || pkt .AgentData.AgentID.NotEqual(m_agentId)) - return; - uint thisSeq = pkt.Header.Sequence; - if (thisSeq == m_lastRevokePermissionsSeq) + if (thisSeq == c.m_lastRevokePermissionsSeq) return; - m_lastRevokePermissionsSeq = thisSeq; + c.m_lastRevokePermissionsSeq = thisSeq; - ScenePresence sp = (ScenePresence)SceneAgent; + ScenePresence sp = (ScenePresence)c.SceneAgent; if(sp != null && !sp.IsDeleted && !sp.IsInTransit) { UUID objectID = pkt.Data.ObjectID; double now = Util.GetTimeStampMS(); - if (now < m_nextRevokePermissionsTime) + if (now < c.m_nextRevokePermissionsTime) return; - if (objectID == m_scene.RegionInfo.RegionID) - m_nextRevokePermissionsTime = now + 2000; + if (objectID == c.m_scene.RegionInfo.RegionID) + c.m_nextRevokePermissionsTime = now + 2000; else - m_nextRevokePermissionsTime = now + 50; + c.m_nextRevokePermissionsTime = now + 50; uint permissions = pkt.Data.ObjectPermissions; sp.HandleRevokePermissions(objectID , permissions); } } - private void HandlePlacesQuery(Packet Pack) + private static void HandlePlacesQuery(LLClientView c, Packet Pack) { PlacesQueryPacket placesQueryPacket = (PlacesQueryPacket)Pack; - if (placesQueryPacket.AgentData.SessionID.NotEqual(m_sessionId) || placesQueryPacket.AgentData.AgentID.NotEqual(m_agentId)) - return; - - OnPlacesQuery?.Invoke(placesQueryPacket.AgentData.QueryID, + c.OnPlacesQuery?.Invoke(placesQueryPacket.AgentData.QueryID, placesQueryPacket.TransactionData.TransactionID, Utils.BytesToString( placesQueryPacket.QueryData.QueryText), @@ -12683,7 +12158,7 @@ private void HandlePlacesQuery(Packet Pack) (byte)placesQueryPacket.QueryData.Category, Utils.BytesToString( placesQueryPacket.QueryData.SimName), - this); + c); } #endregion Packet Handlers @@ -12699,20 +12174,11 @@ public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, U OutPacket(scriptQuestion, ThrottleOutPacketType.Task); } - /// - /// Handler called when we receive a logout packet. - /// - /// - /// - /// - protected virtual void HandleLogout(Packet packet) + protected static void HandleLogout(LLClientView c, Packet packet) { - if (packet.Type == PacketType.LogoutRequest) - { - if (((LogoutRequestPacket)packet).AgentData.SessionID.NotEqual(m_sessionId)) - return; - } - Logout(this); + var lrp = (LogoutRequestPacket)packet; + m_log.Info($"[CLIENT]: Got a logout request for {c.Name} in {c.Scene.Name}"); + c.OnLogout?.Invoke(c); } /// @@ -12729,30 +12195,25 @@ protected virtual void Logout(IClientAPI client) /// /// /// - /// At the moment, we always reply that there is no cached texture. /// /// /// /// - - protected void HandleAgentTextureCached(Packet packet) + protected static void HandleAgentTextureCached(LLClientView c, Packet packet) { //m_log.Debug("texture cached: " + packet.ToString()); AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet; AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse); - if (cachedtex.AgentData.SessionID.NotEqual(m_sessionId) || cachedtex.AgentData.AgentID.NotEqual(m_agentId)) - return; - - ScenePresence p = m_scene.GetScenePresence(m_agentId); - if(p is null) + ScenePresence p = c.m_scene.GetScenePresence(c.m_agentId); + if (p is null) return; WearableCacheItem[] cacheItems = p.Appearance?.WearableCacheItems; - cachedresp.AgentData.AgentID = m_agentId; - cachedresp.AgentData.SessionID = m_sessionId; + cachedresp.AgentData.AgentID = c.m_agentId; + cachedresp.AgentData.SessionID = c.m_sessionId; cachedresp.AgentData.SerialNum = cachedtex.AgentData.SerialNum; cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length]; @@ -12796,7 +12257,7 @@ protected void HandleAgentTextureCached(Packet packet) } } cachedresp.Header.Zerocoded = true; - OutPacket(cachedresp, ThrottleOutPacketType.Task); + c.OutPacket(cachedresp, ThrottleOutPacketType.Task); } /// @@ -12834,17 +12295,14 @@ public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List { localId }); + c.SendKillObject([localId]); } else { - ClientChangeObject updatehandler = onClientChangeObject; + ClientChangeObject updatehandler = c.onClientChangeObject; if (updatehandler != null) { @@ -12887,14 +12345,14 @@ protected void HandleMultipleObjUpdate(Packet packet) udata.position = new Vector3(block.Data, 0); udata.change = ObjectChangeType.primP; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; case 2: // rotation sp udata.rotation = new Quaternion(block.Data, 0, true); udata.change = ObjectChangeType.primR; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; case 3: // position plus rotation @@ -12902,21 +12360,21 @@ protected void HandleMultipleObjUpdate(Packet packet) udata.rotation = new Quaternion(block.Data, 12, true); udata.change = ObjectChangeType.primPR; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; case 4: // scale sp udata.scale = new Vector3(block.Data, 0); udata.change = ObjectChangeType.primS; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; case 0x14: // uniform scale sp udata.scale = new Vector3(block.Data, 0); udata.change = ObjectChangeType.primUS; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; case 5: // scale and position sp @@ -12924,7 +12382,7 @@ protected void HandleMultipleObjUpdate(Packet packet) udata.scale = new Vector3(block.Data, 12); udata.change = ObjectChangeType.primPS; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; case 0x15: //uniform scale and position @@ -12932,7 +12390,7 @@ protected void HandleMultipleObjUpdate(Packet packet) udata.scale = new Vector3(block.Data, 12); udata.change = ObjectChangeType.primPUS; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; // now group related (bit 4) @@ -12940,14 +12398,14 @@ protected void HandleMultipleObjUpdate(Packet packet) udata.position = new Vector3(block.Data, 0); udata.change = ObjectChangeType.groupP; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; case 0x0A: // (8 + 2) group rotation udata.rotation = new Quaternion(block.Data, 0, true); udata.change = ObjectChangeType.groupR; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; case 0x0B: //( 8 + 2 + 1) group rotation and position @@ -12955,7 +12413,7 @@ protected void HandleMultipleObjUpdate(Packet packet) udata.rotation = new Quaternion(block.Data, 12, true); udata.change = ObjectChangeType.groupPR; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; case 0x0C: // (8 + 4) group scale @@ -12966,7 +12424,7 @@ protected void HandleMultipleObjUpdate(Packet packet) udata.scale = new Vector3(block.Data, 0); udata.change = ObjectChangeType.groupS; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; @@ -12977,14 +12435,14 @@ protected void HandleMultipleObjUpdate(Packet packet) udata.scale = new Vector3(block.Data, 12); udata.change = ObjectChangeType.groupPS; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; case 0x1C: // (0x10 + 8 + 4 ) group scale UNIFORM udata.scale = new Vector3(block.Data, 0); udata.change = ObjectChangeType.groupUS; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; case 0x1D: // (UNIFORM + GROUP + SCALE + POS) @@ -12992,7 +12450,7 @@ protected void HandleMultipleObjUpdate(Packet packet) udata.scale = new Vector3(block.Data, 12); udata.change = ObjectChangeType.groupPUS; - updatehandler(localId, udata, this); + updatehandler(localId, udata, c); break; default: @@ -13228,15 +12686,12 @@ public void ProcessInPacket(Packet packet) logPacket = false; if (logPacket) - m_log.DebugFormat( - "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}", - Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name, packet.Type); + m_log.Debug( + $"[CLIENT]: PACKET IN from {Name} ({(SceneAgent.IsChildAgent ? "child" : "root")}) in {Scene.Name} - {packet.Type}"); } if (!ProcessPacketMethod(packet)) - m_log.WarnFormat( - "[CLIENT]: Unhandled packet {0} from {1} ({2}) in {3}. Ignoring.", - packet.Type, Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name); + m_log.Warn($"[CLIENT]: ignoring unhandled packet {packet.Type} from {Name} ({(SceneAgent.IsChildAgent ? "child" : "root")}) in {m_scene.Name}"); } private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) @@ -13382,10 +12837,7 @@ protected void RegisterInterface(T iface) { lock (m_clientInterfaces) { - if (!m_clientInterfaces.ContainsKey(typeof(T))) - { - m_clientInterfaces.Add(typeof(T), iface); - } + m_clientInterfaces.TryAdd(typeof(T), iface); } } @@ -13631,18 +13083,16 @@ public void SendRebakeAvatarTextures(UUID textureID) OutPacket(pack, ThrottleOutPacketType.Task); } - public struct PacketProcessor + public readonly struct PacketProcessor(PacketMethod m, bool doasync ) { - /// - /// Packet handling method. - /// - public PacketMethod method; - - /// - /// Should this packet be handled asynchronously? - /// - public bool Async; + public readonly PacketMethod method = m; + public readonly bool Async = doasync; + } + private readonly struct StaticPacketProcessor(StaticPacketMethod m, bool doasync) + { + public readonly StaticPacketMethod method = m; + public readonly bool Async = doasync; } public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) @@ -13713,7 +13163,7 @@ public void SendAgentTerseUpdate(ISceneEntity p) { if (p is ScenePresence sp) { - UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); //setup header and regioninfo block Buffer.BlockCopy(terseUpdateHeader, 0, buf.Data, 0, 7); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index 58399476fbc..01206c771db 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -779,11 +779,6 @@ internal int GetThrottleSetting(int throttle) return 0; } - public void FreeUDPBuffer(UDPPacketBuffer buf) - { - m_udpServer.FreeUDPBuffer(buf); - } - /// /// Converts a integer to a /// flag value diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index d097f7a6247..04bfe5b482c 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -31,7 +31,6 @@ using System.Diagnostics; using System.IO; using System.Net; -using System.Net.Sockets; using System.Reflection; using System.Threading; using log4net; @@ -43,7 +42,6 @@ using OpenSim.Region.Framework.Interfaces; using OpenMetaverse; using Mono.Addins; -using TokenBucket = OpenSim.Region.ClientStack.LindenUDP.TokenBucket; namespace OpenSim.Region.ClientStack.LindenUDP @@ -326,8 +324,6 @@ public class LLUDPServer : OpenSimUDPBase protected int m_pausedAckTimeout = 0; protected bool m_disableFacelights = false; - public Socket Server { get { return null; } } - /// /// Record how many packets have been resent /// @@ -1194,9 +1190,9 @@ public override void PacketReceived(UDPPacketBuffer buffer) headerLen += buffer.Data[5]; if (bufferLen < headerLen) { -// m_log.WarnFormat( -// "[LLUDPSERVER]: Dropping packet with malformed header received from {0} in {1}", -// buffer.RemoteEndPoint, m_scene.RegionInfo.RegionName); + //m_log.WarnFormat( + // "[LLUDPSERVER]: Dropping packet with malformed header received from {0} in {1}", + // buffer.RemoteEndPoint, m_scene.RegionInfo.RegionName); RecordMalformedInboundPacket(endPoint); FreeUDPBuffer(buffer); return; // Malformed header @@ -1221,7 +1217,7 @@ public override void PacketReceived(UDPPacketBuffer buffer) catch (Exception e) { if (IncomingMalformedPacketCount < 100) - m_log.DebugFormat("[LLUDPSERVER]: Dropped malformed packet: " + e.ToString()); + m_log.Debug("[LLUDPSERVER]: Dropped malformed packet: " + e.ToString()); } // Fail-safe check @@ -1289,7 +1285,7 @@ public override void PacketReceived(UDPPacketBuffer buffer) FreeUDPBuffer(buffer); // Determine which agent this packet came from - if (client == null || client is not LLClientView) + if (client == null || client is not LLClientView lclient) { //m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); @@ -1302,7 +1298,7 @@ public override void PacketReceived(UDPPacketBuffer buffer) return; } - LLUDPClient udpClient = ((LLClientView)client).UDPClient; + LLUDPClient udpClient = lclient.UDPClient; if (!udpClient.IsConnected) { @@ -1318,6 +1314,12 @@ public override void PacketReceived(UDPPacketBuffer buffer) int now = Environment.TickCount & Int32.MaxValue; udpClient.TickLastPacketReceived = now; + if(packet.NeedValidateIDs) + { + if(!packet.ValidIDs(lclient.m_sessionId, lclient.m_agentId)) + return; + } + #region ACK Receiving // Handle appended ACKs @@ -1432,10 +1434,7 @@ public override void PacketReceived(UDPPacketBuffer buffer) #endregion Ping Check Handling - IncomingPacket incomingPacket; - - incomingPacket = new IncomingPacket((LLClientView)client, packet); - packetInbox.Add(incomingPacket); + packetInbox.Add(new IncomingPacket((LLClientView)client, packet)); } #region BinaryStats @@ -1778,26 +1777,28 @@ protected void IncomingPacketHandler() Scene.ThreadAlive(1); try { - packetInbox.TryTake(out IncomingPacket incomingPacket, 4500); - - if (incomingPacket != null && IsRunningInbound) + if (packetInbox.TryTake(out IncomingPacket incomingPacket, 4500) && IsRunningInbound) { - ProcessInPacket(incomingPacket); - incomingPacket = null; + if (incomingPacket.Client.IsActive) + { + incomingPacket.Client.ProcessInPacket(incomingPacket.Packet); + IncomingPacketsProcessed++; + } } } - /* catch (ThreadAbortException) { - Thread.ResetAbort(); + // If something is trying to abort the packet processing thread, take that as a hint that it's time to shut down + m_log.Info("[LLUDPSERVER]: Caught a thread abort, shutting down the LLUDP server"); + Stop(); } - */ - catch (Exception ex) + catch (Exception e) { - m_log.Error("[LLUDPSERVER]: Error in the incoming packet handler loop: " + ex.Message, ex); + // Don't let a failure in an individual client thread crash the whole sim. + m_log.Error($"[LLUDPSERVER]: IncomingPacketHandler threw ", e); } - Watchdog.UpdateThread(); + Watchdog.UpdateThread(); } if (packetInbox.Count > 0) @@ -1947,38 +1948,6 @@ protected void ClientOutgoingPacketHandler(IClientAPI client) #endregion - protected void ProcessInPacket(IncomingPacket incomingPacket) - { - Packet packet = incomingPacket.Packet; - LLClientView client = incomingPacket.Client; - - if(!client.IsActive) - return; - - try - { - // Process this packet - client.ProcessInPacket(packet); - } - catch(ThreadAbortException) - { - // If something is trying to abort the packet processing thread, take that as a hint that it's time to shut down - m_log.Info("[LLUDPSERVER]: Caught a thread abort, shutting down the LLUDP server"); - Stop(); - } - catch(Exception e) - { - // Don't let a failure in an individual client thread crash the whole sim. - m_log.Error( - string.Format( - "[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw ", - client.Name,packet.Type), - e); - } - - IncomingPacketsProcessed++; - } - protected void LogoutHandler(IClientAPI client) { client.SendLogoutPacket(); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index b1a37b971a0..74593d9a527 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs @@ -26,16 +26,24 @@ */ using System; -using System.Collections.Concurrent; using System.Net; using System.Net.Sockets; -using System.Threading; using log4net; using OpenSim.Framework; -using OpenSim.Framework.Monitoring; +using OpenMetaverse; +using OpenMetaverse.Packets; -namespace OpenMetaverse +namespace OpenSim.Region.ClientStack.LindenUDP { + public readonly struct IncomingPacket(LLClientView client, Packet packet) + { + /// Client this packet came from + public readonly LLClientView Client = client; + + /// Packet data that has been received + public readonly Packet Packet = packet; + } + /// /// Base UDP server /// @@ -126,7 +134,7 @@ public OpenSimUDPBase(IPAddress bindAddress, int port) try { m_udpSocket.Close(); } catch { } } - public UDPPacketBuffer GetNewUDPBuffer(IPEndPoint remoteEndpoint) + public static UDPPacketBuffer GetNewUDPBuffer(IPEndPoint remoteEndpoint) { lock (m_udpBuffersPoolLock) { @@ -143,7 +151,7 @@ public UDPPacketBuffer GetNewUDPBuffer(IPEndPoint remoteEndpoint) return new UDPPacketBuffer(remoteEndpoint); } - public void FreeUDPBuffer(UDPPacketBuffer buf) + public static void FreeUDPBuffer(UDPPacketBuffer buf) { lock (m_udpBuffersPoolLock) { @@ -257,6 +265,7 @@ public virtual void StopInbound() IsRunningInbound = false; m_udpSocket.Close(); + m_udpSocket = null; } } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/Linden/UDP/UnackedPacketCollection.cs index db937021df6..9681981b558 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/UnackedPacketCollection.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/UnackedPacketCollection.cs @@ -219,8 +219,7 @@ private void ProcessQueues() { // Update stats Interlocked.Add(ref removedPacket.Client.UnackedBytes, -removedPacket.Buffer.DataLength); - - removedPacket.Client.FreeUDPBuffer(removedPacket.Buffer); + OpenSimUDPBase.FreeUDPBuffer(removedPacket.Buffer); removedPacket.Buffer = null; } } @@ -247,7 +246,7 @@ private void ProcessQueues() { Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength); - ackedPacket.Client.FreeUDPBuffer(ackedPacket.Buffer); + OpenSimUDPBase.FreeUDPBuffer(ackedPacket.Buffer); ackedPacket.Buffer = null; } // As with other network applications, assume that an acknowledged packet is an diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index 45dd6717204..027d43243dc 100755 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs @@ -160,7 +160,7 @@ public void AddRegion(Scene scene) // 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; } diff --git a/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs b/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs index 604068079d2..8d5badffbe8 100644 --- a/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs +++ b/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs @@ -25,8 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; @@ -64,7 +62,7 @@ public static UUID GetAssetIdFromItemName(SceneObjectPart part, string name, int /// public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier) { - if(string.IsNullOrEmpty(identifier)) + if(string.IsNullOrEmpty(identifier) || part.Inventory is null) return UUID.Zero; // if we can parse the string as a key, use it. @@ -73,14 +71,8 @@ public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string iden if (UUID.TryParse(identifier, out UUID key)) return key; - if (part.Inventory != null) - { - TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier); - if (item != null) - return item.AssetID; - } - - return UUID.Zero; + TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier); + return item is not null ? item.AssetID : UUID.Zero; } /// @@ -93,17 +85,11 @@ public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string iden /// public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier, AssetType type) { - if (UUID.TryParse(identifier, out UUID key)) + if (UUID.TryParse(identifier, out UUID key) || part.Inventory is null) return key; - if (part.Inventory is not null) - { - TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier, (int)type); - if (item is not null) - return item.AssetID; - } - - return UUID.Zero; + TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier, (int)type); + return item is not null ? item.AssetID : UUID.Zero; } public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, SceneObjectPart host, string identifier, AssetType type) diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index a59e1e071b0..7442f16b713 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -35,7 +35,6 @@ 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 @@ private void GetAssetUuids(UUID assetUuid) case AssetType.LSLText: RecordEmbeddedAssetDataUuids(assetBase); break; - case (AssetType)OpenSimAssetType.Material: + case (AssetType)AssetType.OSMaterial: RecordMaterialAssetUuids(assetBase); break; case AssetType.Object: @@ -668,7 +667,7 @@ private void AddForInspection(UUID assetUuid, sbyte assetType) 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: diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index 603f18af2fd..69e6d708059 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -44,7 +44,6 @@ 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 @@ public void RenderMaterialsPutCap(IOSHttpRequest request, IOSHttpResponse respon 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 diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 068e28530c7..53cf030585b 100755 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -639,7 +639,7 @@ public string Born public bool IsGroupMember(UUID groupID) { - return (m_hostGroupID == groupID); + return m_hostGroupID.Equals(groupID); } public Dictionary GetGroupPowers() diff --git a/README.md b/README.md index 4799481e409..53d94e7a219 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Please see BUILDING.md # Running OpenSim on Windows -You will need dotnet 6.0 runtime (https://dotnet.microsoft.com/en-us/download/dotnet/6.0) +You will need dotnet 8.0 runtime (https://dotnet.microsoft.com/en-us/download/dotnet/8.0) To run OpenSim from a command prompt @@ -30,7 +30,7 @@ To run OpenSim from a command prompt You will need - * [dotnet 6.0 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) + * [dotnet 8.0 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) * libgdiplus if you have mono 6.x complete, you already have libgdiplus, otherwise you need to install it diff --git a/bin/BouncyCastle.Cryptography.dll b/bin/BouncyCastle.Cryptography.dll new file mode 100644 index 00000000000..80581a40a9b Binary files /dev/null and b/bin/BouncyCastle.Cryptography.dll differ diff --git a/bin/CSJ2K.dll b/bin/CSJ2K.dll index 896e874001d..3da9675dc1b 100755 Binary files a/bin/CSJ2K.dll and b/bin/CSJ2K.dll differ diff --git a/bin/OpenMetaverse.Rendering.Meshmerizer.dll b/bin/OpenMetaverse.Rendering.Meshmerizer.dll index dee4601730d..e691bac9106 100755 Binary files a/bin/OpenMetaverse.Rendering.Meshmerizer.dll and b/bin/OpenMetaverse.Rendering.Meshmerizer.dll differ diff --git a/bin/OpenMetaverse.StructuredData.dll b/bin/OpenMetaverse.StructuredData.dll index 64163d7746f..4577b0d8309 100755 Binary files a/bin/OpenMetaverse.StructuredData.dll and b/bin/OpenMetaverse.StructuredData.dll differ diff --git a/bin/OpenMetaverse.dll b/bin/OpenMetaverse.dll index f8c2b0a6250..009e97c09d4 100755 Binary files a/bin/OpenMetaverse.dll and b/bin/OpenMetaverse.dll differ diff --git a/bin/OpenMetaverseTypes.dll b/bin/OpenMetaverseTypes.dll index 92be2a4c5df..93c91e35990 100755 Binary files a/bin/OpenMetaverseTypes.dll and b/bin/OpenMetaverseTypes.dll differ diff --git a/bin/Warp3D.dll b/bin/Warp3D.dll index 8e6817e0296..4a025ecc8bb 100755 Binary files a/bin/Warp3D.dll and b/bin/Warp3D.dll differ diff --git a/bin/XMLRPC.dll b/bin/XMLRPC.dll index 1800342e51d..3655956c31e 100755 Binary files a/bin/XMLRPC.dll and b/bin/XMLRPC.dll differ diff --git a/bin/prebuild.runtimeconfig.json b/bin/prebuild.runtimeconfig.json index 418df653a1d..b0a83d62c1f 100644 --- a/bin/prebuild.runtimeconfig.json +++ b/bin/prebuild.runtimeconfig.json @@ -1,11 +1,13 @@ { "runtimeOptions": { - "tfm": "net6.0", + "tfm": "net8.0", "framework": { "name": "Microsoft.NETCore.App", - "version": "6.0.0" + "version": "8.0.0" }, "configProperties": { + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false, + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false, "System.Runtime.TieredCompilation": false } }