add LinksetData support. Untested and still does not store in dbs. Not as spec. See mantis 9081 (runprebuild)

This commit is contained in:
UbitUmarov
2024-02-06 23:45:11 +00:00
parent 00e9e3c77a
commit 2e26b8a8bb
12 changed files with 621 additions and 95 deletions

View File

@@ -64,6 +64,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
/// Post event to an entire prim
/// </summary>
bool PostObjectEvent(uint localID, EventParams parms);
bool PostObjectLinksetDataEvent(uint localID, int action, ReadOnlySpan<char> name, ReadOnlySpan<char> value);
DetectParams GetDetectParams(UUID item, int number);
void SetMinEventDelay(UUID itemID, double delay);

View File

@@ -263,6 +263,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
private string m_lsl_shard = "OpenSim";
private string m_lsl_user_agent = string.Empty;
private int m_linksetDataLimit = 32 * 1024;
private static readonly Dictionary<string, string> MovementAnimationsForLSL = new(StringComparer.InvariantCultureIgnoreCase)
{
{"CROUCH", "Crouching"},
@@ -420,7 +422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
IConfig seConfig = m_ScriptEngine.Config;
if (seConfig != null)
if (seConfig is not null)
{
float scriptDistanceFactor = seConfig.GetFloat("ScriptDistanceLimitFactor", 1.0f);
m_Script10mDistance = 10.0f * scriptDistanceFactor;
@@ -438,6 +440,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_AllowGodFunctions = seConfig.GetBoolean("AllowGodFunctions", false);
m_disable_underground_movement = seConfig.GetBoolean("DisableUndergroundMovement", true);
m_linksetDataLimit = seConfig.GetInt("LinksetDataLimit", m_linksetDataLimit);
}
if (m_notecardLineReadCharsMax > 65535)
@@ -18559,6 +18563,184 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Vector(Util.sRGBtoLinear((float)src.x), Util.sRGBtoLinear((float)src.y), Util.sRGBtoLinear((float)src.z));
}
public LSL_Integer llLinksetDataAvailable()
{
if (m_host.ParentGroup.LinksetData is null)
return m_linksetDataLimit;
return new LSL_Integer(m_host.ParentGroup.LinksetData.Free());
}
public LSL_Integer llLinksetDataCountKeys()
{
if (m_host.ParentGroup.LinksetData is null)
return 0;
return new LSL_Integer(m_host.ParentGroup.LinksetData.Count());
}
public LSL_String llLinksetDataRead(LSL_String name)
{
if (m_host.ParentGroup.LinksetData is null || string.IsNullOrEmpty(name.m_string))
return new LSL_String(string.Empty);
return new LSL_String(m_host.ParentGroup.LinksetData.Get(name.m_string));
}
public LSL_String llLinksetDataReadProtected(LSL_String name, LSL_String pass)
{
if (m_host.ParentGroup.LinksetData is null || string.IsNullOrEmpty(name.m_string))
return new LSL_String(string.Empty);
return new LSL_String(m_host.ParentGroup.LinksetData.Get(name.m_string, pass.m_string));
}
public LSL_Integer llLinksetDataDelete(LSL_String name)
{
if (string.IsNullOrEmpty(name.m_string))
return ScriptBaseClass.LINKSETDATA_ENOKEY;
if (m_host.ParentGroup.LinksetData is null)
return ScriptBaseClass.LINKSETDATA_NOTFOUND;
int ret = m_host.ParentGroup.LinksetData.Remove(name.m_string);
if (ret == 0)
{
m_ScriptEngine.PostObjectLinksetDataEvent(m_host.LocalId, ScriptBaseClass.LINKSETDATA_DELETE, name.m_string, string.Empty);
m_host.ParentGroup.HasGroupChanged = true;
}
return ret;
}
public LSL_Integer llLinksetDataDeleteProtected(LSL_String name, LSL_String pass)
{
if (string.IsNullOrEmpty(name.m_string))
return ScriptBaseClass.LINKSETDATA_ENOKEY;
if (m_host.ParentGroup.LinksetData is null)
return ScriptBaseClass.LINKSETDATA_NOTFOUND;
int ret = m_host.ParentGroup.LinksetData.Remove(name.m_string, pass.m_string);
if (ret == 0)
{
m_ScriptEngine.PostObjectLinksetDataEvent(m_host.LocalId, ScriptBaseClass.LINKSETDATA_DELETE, name.m_string, string.Empty);
m_host.ParentGroup.HasGroupChanged = true;
}
return ret;
}
public void llLinksetDataReset()
{
if (m_host.ParentGroup.LinksetData is null)
return;
bool changed = m_host.ParentGroup.LinksetData.Count() > 0;
m_host.ParentGroup.LinksetData = null;
if(changed)
{
m_ScriptEngine.PostObjectLinksetDataEvent(m_host.LocalId, ScriptBaseClass.LINKSETDATA_RESET, string.Empty, string.Empty);
m_host.ParentGroup.HasGroupChanged = true;
}
}
public LSL_Integer llLinksetDataWrite(LSL_String name, LSL_String value)
{
if (string.IsNullOrEmpty(name.m_string))
return ScriptBaseClass.LINKSETDATA_ENOKEY;
int ret;
if (string.IsNullOrEmpty(value.m_string))
{
if (m_host.ParentGroup.LinksetData is null)
return ScriptBaseClass.LINKSETDATA_NOTFOUND;
ret = m_host.ParentGroup.LinksetData.Remove(name.m_string);
if (ret == 0)
{
m_ScriptEngine.PostObjectLinksetDataEvent(m_host.LocalId, ScriptBaseClass.LINKSETDATA_DELETE, name.m_string, string.Empty);
m_host.ParentGroup.HasGroupChanged = true;
}
return ret;
}
m_host.ParentGroup.LinksetData ??= new(m_linksetDataLimit);
ret = m_host.ParentGroup.LinksetData.AddOrUpdate(name.m_string, value.m_string);
if (ret == 0)
{
m_ScriptEngine.PostObjectLinksetDataEvent(m_host.LocalId, ScriptBaseClass.LINKSETDATA_UPDATE, name.m_string, value.m_string);
m_host.ParentGroup.HasGroupChanged = true;
}
return ret;
}
public LSL_Integer llLinksetDataWriteProtected(LSL_String name, LSL_String value, LSL_String pass)
{
if (string.IsNullOrEmpty(name.m_string))
return ScriptBaseClass.LINKSETDATA_ENOKEY;
int ret;
if (string.IsNullOrEmpty(value.m_string))
{
if (m_host.ParentGroup.LinksetData is null)
return ScriptBaseClass.LINKSETDATA_NOTFOUND;
ret = m_host.ParentGroup.LinksetData.Remove(name.m_string, pass.m_string);
if (ret == 0)
{
m_ScriptEngine.PostObjectLinksetDataEvent(m_host.LocalId, ScriptBaseClass.LINKSETDATA_DELETE, name.m_string, string.Empty);
m_host.ParentGroup.HasGroupChanged = true;
}
return ret;
}
m_host.ParentGroup.LinksetData ??= new(m_linksetDataLimit);
ret = m_host.ParentGroup.LinksetData.AddOrUpdate(name.m_string, value.m_string, pass.m_string);
if (ret == 0)
{
m_ScriptEngine.PostObjectLinksetDataEvent(m_host.LocalId, ScriptBaseClass.LINKSETDATA_UPDATE, name.m_string, string.Empty);
m_host.ParentGroup.HasGroupChanged = true;
}
return ret;
}
public LSL_List llLinksetDataDeleteFound(LSL_String pattern, LSL_String pass)
{
if (string.IsNullOrEmpty(pattern.m_string) || m_host.ParentGroup.LinksetData is null)
return new LSL_List(new object[] { new LSL_Integer(0), new LSL_Integer(0)});
string[] deleted = m_host.ParentGroup.LinksetData.RemoveByPattern(pattern.m_string, pass.m_string, out int notDeleted);
int deletedCount = deleted.Length;
if(deleted.Length > 0)
{
string deletedList = string.Join(",", deleted);
m_ScriptEngine.PostObjectLinksetDataEvent(m_host.LocalId, ScriptBaseClass.LINKSETDATA_MULTIDELETE, deletedList, string.Empty);
m_host.ParentGroup.HasGroupChanged = true;
}
return new LSL_List(new object[] { new LSL_Integer(deleted.Length), new LSL_Integer(notDeleted) });
}
public LSL_Integer llLinksetDataCountFound(LSL_String pattern)
{
if (string.IsNullOrEmpty(pattern.m_string) || m_host.ParentGroup.LinksetData is null)
return new LSL_Integer(0);
return m_host.ParentGroup.LinksetData.CountByPattern(pattern.m_string);
}
public LSL_List llLinksetDataListKeys(LSL_Integer start, LSL_Integer count)
{
if (m_host.ParentGroup.LinksetData is null)
return new LSL_List();
return new LSL_List(m_host.ParentGroup.LinksetData.ListKeys(start, count));
}
public LSL_List llLinksetDataFindKeys(LSL_String pattern, LSL_Integer start, LSL_Integer count)
{
if (string.IsNullOrEmpty(pattern.m_string) || m_host.ParentGroup.LinksetData is null)
return new LSL_List();
return new LSL_List(m_host.ParentGroup.LinksetData.ListKeysByPatttern(pattern.m_string, start, count));
}
}
public class NotecardCache

View File

@@ -500,5 +500,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_Vector llLinear2sRGB(LSL_Vector src);
LSL_Vector llsRGB2Linear(LSL_Vector src);
LSL_Integer llLinksetDataAvailable();
LSL_Integer llLinksetDataCountFound(LSL_String pattern);
LSL_Integer llLinksetDataCountKeys();
LSL_Integer llLinksetDataDelete(LSL_String name);
LSL_List llLinksetDataDeleteFound(LSL_String pattern, LSL_String pass);
LSL_Integer llLinksetDataDeleteProtected(LSL_String name, LSL_String pass);
LSL_List llLinksetDataFindKeys(LSL_String pattern, LSL_Integer start, LSL_Integer count);
LSL_List llLinksetDataListKeys(LSL_Integer start, LSL_Integer count);
LSL_String llLinksetDataRead(LSL_String name);
LSL_String llLinksetDataReadProtected(LSL_String name, LSL_String pass);
void llLinksetDataReset();
LSL_Integer llLinksetDataWrite(LSL_String name, LSL_String value);
LSL_Integer llLinksetDataWriteProtected(LSL_String name, LSL_String value, LSL_String pass);
}
}

View File

@@ -537,8 +537,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int PRIM_PHYSICS_SHAPE_CONVEX = 2;
// PRIM_REFLECTION_PROBE flags
public const int PRIM_REFLECTION_PROBE_BOX = 1 << 0; // 1
public const int PRIM_REFLECTION_PROBE_DYNAMIC = 1 << 1; // 2
public const int PRIM_REFLECTION_PROBE_BOX = 1; // 1
public const int PRIM_REFLECTION_PROBE_DYNAMIC = 2; // 2
public const int PROFILE_NONE = 0;
public const int PROFILE_SCRIPT_MEMORY = 1;
@@ -1030,6 +1030,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int LINKSETDATA_RESET = 0;
public const int LINKSETDATA_UPDATE = 1;
public const int LINKSETDATA_DELETE = 2;
public const int LINKSETDATA_MULTIDELETE = 3;
public const int LINKSETDATA_OK = 0;
public const int LINKSETDATA_EMEMORY = 1;

View File

@@ -2706,5 +2706,83 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_LSL_Functions.llsRGB2Linear(src);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_Integer llLinksetDataAvailable()
{
return m_LSL_Functions.llLinksetDataAvailable();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_Integer llLinksetDataCountKeys()
{
return m_LSL_Functions.llLinksetDataCountKeys();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_String llLinksetDataRead(LSL_String name)
{
return m_LSL_Functions.llLinksetDataRead(name);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_String llLinksetDataReadProtected(LSL_String name, LSL_String pass)
{
return m_LSL_Functions.llLinksetDataReadProtected(name, pass);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_Integer llLinksetDataDelete(LSL_String name)
{
return m_LSL_Functions.llLinksetDataDelete(name);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_Integer llLinksetDataDeleteProtected(LSL_String name, LSL_String pass)
{
return m_LSL_Functions.llLinksetDataDeleteProtected(name, pass);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void llLinksetDataReset()
{
m_LSL_Functions.llLinksetDataReset();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_Integer llLinksetDataWrite(LSL_String name, LSL_String value)
{
return m_LSL_Functions.llLinksetDataWrite(name, value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_Integer llLinksetDataWriteProtected(LSL_String name, LSL_String value, LSL_String pass)
{
return m_LSL_Functions.llLinksetDataWriteProtected(name, value, pass);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_List llLinksetDataDeleteFound(LSL_String pattern, LSL_String pass)
{
return m_LSL_Functions.llLinksetDataDeleteFound(pattern, pass);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_Integer llLinksetDataCountFound(LSL_String pattern)
{
return m_LSL_Functions.llLinksetDataCountFound(pattern);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_List llLinksetDataListKeys(LSL_Integer start, LSL_Integer count)
{
return m_LSL_Functions.llLinksetDataListKeys(start, count);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_List llLinksetDataFindKeys(LSL_String pattern, LSL_Integer start, LSL_Integer count)
{
return m_LSL_Functions.llLinksetDataFindKeys(pattern, start, count);
}
}
}

View File

@@ -361,7 +361,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
{
Name = "XMRInstanceSuperAssembly"
};
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
//AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndCollect);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("XMRInstanceSuperModule");
TypeBuilder typeBuilder = moduleBuilder.DefineType("XMRInstanceSuperType", TypeAttributes.Public | TypeAttributes.Class);
typeBuilder.SetParent(typeof(XMRInstance));
@@ -904,8 +905,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
TraceCalls("[YEngine]: YEngine.PostScriptEvent({0},{1})", itemID.ToString(), parms.EventName);
instance.PostEvent(parms);
return true;
return instance.PostEvent(parms);
}
public void CancelScriptEvent(UUID itemID, string eventName)
@@ -952,6 +952,32 @@ namespace OpenSim.Region.ScriptEngine.Yengine
return PostPrimEvent(part, parms);
}
public bool PostObjectLinksetDataEvent(uint localID, int action, ReadOnlySpan<char> name, ReadOnlySpan<char> value)
{
if (m_Exiting)
return false;
if (m_HeapSize < name.Length + value.Length)
return false;
SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
if (part is null || part.ParentGroup is null)
return false;
EventParams parms = new("linkset_data", new object[] {
new LSL_Integer(action),
new LSL_String(name.ToString()),
value.Length == 0 ? LSL_String.Empty : new LSL_String(value.ToString())
},
Array.Empty<DetectParams>());;
bool posted = false;
foreach (SceneObjectPart primpart in part.ParentGroup.Parts)
posted |= PostPrimEvent(primpart, parms);
return posted;
}
private bool PostPrimEvent(SceneObjectPart part, EventParams parms)
{
UUID partUUID = part.UUID;
@@ -974,10 +1000,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine
if(objInstArray.Length <= 0)
return false;
bool posted = false;
foreach (XMRInstance inst in objInstArray)
inst.PostEvent(parms);
posted |= inst.PostEvent(parms);
return true;
return posted;
}
public DetectParams GetDetectParams(UUID itemID, int number)

View File

@@ -26,16 +26,11 @@
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Interfaces;
using log4net;
//using log4net;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;

View File

@@ -52,13 +52,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine
* @brief This can be called in any thread (including the script thread itself)
* to queue event to script for processing.
*/
public void PostEvent(EventParams evt)
public bool PostEvent(EventParams evt)
{
if (!m_eventCodeMap.TryGetValue(evt.EventName, out ScriptEventCode evc))
return;
return false;
if (!m_HaveEventHandlers[(int)evc]) // don't bother if we don't have such a handler in any state
return;
return false;
// Put event on end of event queue.
bool startIt = false;
@@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
m_EventQueue.AddFirst(llns);
}
}
return;
return true;
}
}
@@ -101,7 +101,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
{
double now = Util.GetTimeStamp();
if (now < m_nextEventTime)
return;
return false;
m_nextEventTime = now + m_minEventDelay;
break;
}
@@ -110,12 +110,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine
const int canignore = ~(CHANGED_SCALE | CHANGED_POSITION);
int change = (int)evt.Params[0];
if(change == 0) // what?
return;
return false;
if((change & canignore) == 0)
{
double now = Util.GetTimeStamp();
if (now < m_nextEventTime)
return;
return false;
m_nextEventTime = now + m_minEventDelay;
}
break;
@@ -128,14 +128,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine
if(evc == ScriptEventCode.timer)
{
if (m_EventCounts[(int)evc] >= 1)
return;
return false;
m_EventCounts[(int)evc]++;
m_EventQueue.AddLast(new LinkedListNode<EventParams>(evt));
}
else
{
if (m_EventCounts[(int)evc] >= MAXEVENTQUEUE)
return;
return false;
m_EventCounts[(int)evc]++;
@@ -221,6 +221,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
m_SleepUntil = DateTime.MinValue;
m_Engine.WakeFromSleep(this);
}
return true;
}
public void CancelEvent(string eventName)