From 92e3f424cfb2429b9163e805670f94ce524d66a7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 30 Aug 2020 16:05:02 +0100 Subject: [PATCH] cosmetics --- .../Framework/Interfaces/IScenePresence.cs | 1 + .../DataSnapshot/DataSnapshotManager.cs | 17 ++--- .../Shared/Api/Runtime/Executor.cs | 62 ++++++++++--------- .../YEngine/MMRScriptEventCode.cs | 2 +- .../Region/ScriptEngine/YEngine/XMREngine.cs | 39 +++++------- .../Region/ScriptEngine/YEngine/XMREvents.cs | 3 +- 6 files changed, 57 insertions(+), 67 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs index 10d429dd17..661aac605e 100644 --- a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs +++ b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs @@ -53,6 +53,7 @@ namespace OpenSim.Region.Framework.Interfaces /// All add and remove attachment operations must synchronize on this for the lifetime of their operations. /// Object AttachmentsSyncLock { get; } + int GetAttachmentsCount(); /// /// The scene objects attached to this avatar. diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs index d7e9114ffc..eb810f08c3 100644 --- a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs @@ -420,7 +420,11 @@ namespace OpenSim.Region.DataSnapshot cli.RequestMethod = "GET"; try { - reply = cli.Request(null); + using(reply = cli.Request(null)) + { + byte[] response = new byte[1024]; + reply.Read(response, 0, 1024); + } } catch (WebException) { @@ -431,17 +435,6 @@ namespace OpenSim.Region.DataSnapshot m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString()); } - byte[] response = new byte[1024]; - // int n = 0; - try - { - // n = reply.Read(response, 0, 1024); - reply.Read(response, 0, 1024); - } - catch (Exception e) - { - m_log.WarnFormat("[DATASNAPSHOT]: Unable to decode reply from data service. Ignoring. {0}", e.StackTrace); - } // This is not quite working, so... // string responseStr = Util.UTF8.GetString(response); m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 1cc2cfb06c..11f8cb9360 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs @@ -50,36 +50,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase [Flags] public enum scriptEvents : int { - None = 0, - attach = 1, - collision = 16, - collision_end = 32, - collision_start = 64, - control = 128, - dataserver = 256, - email = 512, - http_response = 1024, - land_collision = 2048, - land_collision_end = 4096, - land_collision_start = 8192, - at_target = 16384, - at_rot_target = 16777216, - listen = 32768, - money = 65536, - moving_end = 131072, - moving_start = 262144, - not_at_rot_target = 524288, - not_at_target = 1048576, - remote_data = 8388608, - run_time_permissions = 268435456, - state_entry = 1073741824, - state_exit = 2, - timer = 4, - touch = 8, - touch_end = 536870912, - touch_start = 2097152, - transaction_result = 33554432, - object_rez = 4194304 + None = 0, + attach = 1, + state_exit = 1 << 1, + timer = 1 << 2, + touch = 1 << 3, + collision = 1 << 4, + collision_end = 1 << 5, + collision_start = 1 << 6, + control = 1 << 7, + dataserver = 1 << 8, + email = 1 << 9, + http_response = 1 << 10, + land_collision = 1 << 11, + land_collision_end = 1 << 12, + land_collision_start = 1 << 13, + at_target = 1 << 14, + listen = 1 << 15, + money = 1 << 16, + moving_end = 1 << 17, + moving_start = 1 << 18, + not_at_rot_target = 1 << 19, + not_at_target = 1 << 20, + touch_start = 1 << 21, + object_rez = 1 << 22, + remote_data = 1 << 23, + at_rot_target = 1 << 24, + transaction_result = 1 << 25, + // + // + run_time_permissions = 1 << 28, + touch_end = 1 << 29, + state_entry = 1 << 30, } // Cache functions by keeping a reference to them in a dictionary diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptEventCode.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptEventCode.cs index 3539fa13b9..23d6c6d8dd 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptEventCode.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptEventCode.cs @@ -39,9 +39,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine * in range 0..63 that begin with a lower-case letter for scripts to * reference. */ + public enum ScriptEventCode: int { - // used by XMRInstance to indicate no event being processed None = -1, diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMREngine.cs b/OpenSim/Region/ScriptEngine/YEngine/XMREngine.cs index daf3ed11e3..56cba3094a 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMREngine.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMREngine.cs @@ -87,14 +87,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine private string m_ScriptBasePath; private bool m_Enabled = false; public bool m_StartProcessing = false; - private Dictionary m_ScriptErrors = - new Dictionary(); - private Dictionary> m_ObjectItemList = - new Dictionary>(); - private Dictionary m_ObjectInstArray = - new Dictionary(); - public Dictionary m_XMRInstanceApiCtxFieldInfos = - new Dictionary(); + private Dictionary m_ScriptErrors = new Dictionary(); + private Dictionary> m_ObjectItemList = new Dictionary>(); + private Dictionary m_ObjectInstArray = new Dictionary(); + public Dictionary m_XMRInstanceApiCtxFieldInfos = new Dictionary(); public int m_StackSize; private int m_HeapSize; private Thread m_SleepThread = null; @@ -941,7 +937,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(!m_ObjectInstArray.TryGetValue(partUUID, out objInstArray)) return false; - if(objInstArray == null) + if (objInstArray == null) { objInstArray = RebuildObjectInstArray(partUUID); m_ObjectInstArray[partUUID] = objInstArray; @@ -951,7 +947,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine // Post event to all script instances in the object. if(objInstArray.Length <= 0) return false; - foreach(XMRInstance inst in objInstArray) + + foreach (XMRInstance inst in objInstArray) inst.PostEvent(parms); return true; @@ -1991,19 +1988,17 @@ namespace OpenSim.Region.ScriptEngine.Yengine private XMRInstance[] RebuildObjectInstArray(UUID partUUID) { List itemIDList = m_ObjectItemList[partUUID]; - int n = 0; - foreach(UUID itemID in itemIDList) + XMRInstance[] a = new XMRInstance[itemIDList.Count]; + if(itemIDList.Count > 0) { - if(m_InstancesDict.ContainsKey(itemID)) - n++; - } - - XMRInstance[] a = new XMRInstance[n]; - n = 0; - foreach(UUID itemID in itemIDList) - { - if(m_InstancesDict.TryGetValue(itemID, out a[n])) - n++; + int n = 0; + foreach (UUID itemID in itemIDList) + { + if (m_InstancesDict.TryGetValue(itemID, out a[n])) + n++; + } + if(n < itemIDList.Count) + Array.Resize(ref a, n); } m_ObjectInstArray[partUUID] = a; return a; diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMREvents.cs b/OpenSim/Region/ScriptEngine/YEngine/XMREvents.cs index 80d5f3767f..de21d809db 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMREvents.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMREvents.cs @@ -103,8 +103,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine // get it. But only one has the object in question. The others // just ignore it. // - SceneObjectPart part = - this.World.GetSceneObjectPart(objectID); + SceneObjectPart part = World.GetSceneObjectPart(objectID); if(part == null) return;