Skip to content

Commit

Permalink
For YEngine when posting events for linkset_data, deliver the event t…
Browse files Browse the repository at this point in the history
…o all scripts in all prims. Similar to attach which is currently handled here. Clean up some of the special case handling in LinksetData Write. Writing a key with no value is translated to a delete. We weren't handling that case. Also returned key value on a write, we were previously returning a null string.
  • Loading branch information
mdickson committed Nov 21, 2023
1 parent ad6defe commit 04668d6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 38 deletions.
87 changes: 51 additions & 36 deletions OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18801,25 +18801,32 @@ public LSL_String llReplaceSubString(LSL_String src, LSL_String pattern, LSL_Str

public LSL_Integer llLinksetDataWrite(LSL_String name, LSL_String value)
{
return llLinksetDataWriteProtected(name, value, string.Empty);
return llLinksetDataWriteProtected(name, value, new LSL_String(string.Empty));
}

public LSL_Integer llLinksetDataWriteProtected(LSL_String name, LSL_String value, LSL_String pass)
{
if (name == "")
if (string.IsNullOrEmpty(name))
return ScriptBaseClass.LINKSETDATA_ENOKEY;

// If value is empty this becomes a key delete operation
if (string.IsNullOrEmpty(value))
{
return llLinksetDataDeleteProtected(name, pass);
}

var rootPrim = m_host.ParentGroup.RootPart;

int ret = rootPrim.AddOrUpdateLinksetDataKey(name, value, pass);

object[] parameters = new object[]
{
new LSL_Integer(ScriptBaseClass.LINKSETDATA_UPDATE), name, string.Empty
new LSL_Integer(ScriptBaseClass.LINKSETDATA_UPDATE), name, value
};

if (ret == 0)
{
m_ScriptEngine.PostObjectEvent(rootPrim.LocalId,
m_ScriptEngine.PostObjectEvent(
rootPrim.LocalId,
new EventParams("linkset_data", parameters, Array.Empty<DetectParams>()));

return ScriptBaseClass.LINKSETDATA_OK;
Expand Down Expand Up @@ -18852,8 +18859,9 @@ public void llLinksetDataReset()
new LSL_Integer(ScriptBaseClass.LINKSETDATA_RESET), new LSL_String(string.Empty), new LSL_String(string.Empty)
};

EventParams linksetdata_params = new EventParams("linkset_data", parameters, Array.Empty<DetectParams>());
m_ScriptEngine.PostObjectEvent(rootPrim.LocalId, linksetdata_params);
m_ScriptEngine.PostObjectEvent(
rootPrim.LocalId,
new EventParams("linkset_data", parameters, Array.Empty<DetectParams>()));
}

public LSL_Integer llLinksetDataAvailable()
Expand All @@ -18870,7 +18878,36 @@ public LSL_Integer llLinksetDataCountKeys()

public LSL_Integer llLinksetDataDelete(LSL_String name)
{
return llLinksetDataDeleteProtected(name, string.Empty);
return llLinksetDataDeleteProtected(name, new LSL_String(string.Empty));
}

public LSL_Integer llLinksetDataDeleteProtected(LSL_String name, LSL_String pass)
{
var rootPrim = m_host.ParentGroup.RootPart;
int ret = rootPrim.DeleteLinksetDataKey(name, pass);
object[] parameters;

if (ret == 0)
{
parameters = new object[]
{
new LSL_Integer(ScriptBaseClass.LINKSETDATA_DELETE), name, new LSL_String(string.Empty)
};

m_ScriptEngine.PostObjectEvent(
rootPrim.LocalId,
new EventParams("linkset_data", parameters, Array.Empty<DetectParams>()));

return new LSL_Integer(ScriptBaseClass.LINKSETDATA_OK);
}
else if (ret == 1)
{
return new LSL_Integer(ScriptBaseClass.LINKSETDATA_EPROTECTED);
}
else
{
return new LSL_Integer(ScriptBaseClass.LINKSETDATA_NOTFOUND);
}
}

public LSL_List llLinksetDataDeleteFound(LSL_String pattern, LSL_String pass)
Expand All @@ -18884,12 +18921,16 @@ public LSL_List llLinksetDataDeleteFound(LSL_String pattern, LSL_String pass)

object[] parameters = new object[]
{
new LSL_Integer(ScriptBaseClass.LINKSETDATA_MULTIDELETE), new LSL_String(removed_keys), new LSL_String(string.Empty)
new LSL_Integer(ScriptBaseClass.LINKSETDATA_MULTIDELETE),
new LSL_String(removed_keys),
new LSL_String(string.Empty)
};

if (deleted > 0)
{
m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams("linkset_data", parameters, Array.Empty<DetectParams>()));
m_ScriptEngine.PostObjectEvent(
m_host.LocalId,
new EventParams("linkset_data", parameters, Array.Empty<DetectParams>()));
}

return new LSL_List(new object[]
Expand All @@ -18904,32 +18945,6 @@ public LSL_Integer llLinksetDataCountFound(LSL_String pattern)
return root.LinksetDataCountMatches(pattern);
}

public LSL_Integer llLinksetDataDeleteProtected(LSL_String name, LSL_String pass)
{
var rootPrim = m_host.ParentGroup.RootPart;
int ret = rootPrim.DeleteLinksetDataKey(name, pass);
object[] parameters;

if (ret == 0)
{
parameters = new object[]
{
new LSL_Integer(ScriptBaseClass.LINKSETDATA_OK), name, new LSL_String(string.Empty)
};
}
else if (ret == 1)
{
return new LSL_Integer(ScriptBaseClass.LINKSETDATA_EPROTECTED);
}
else
{
return new LSL_Integer(ScriptBaseClass.LINKSETDATA_NOTFOUND);
}

m_ScriptEngine.PostObjectEvent(rootPrim.LocalId, new EventParams("linkset_data", parameters, Array.Empty<DetectParams>()));
return new LSL_Integer(ScriptBaseClass.LINKSETDATA_OK);
}

public LSL_List llLinksetDataFindKeys(LSL_String pattern, LSL_Integer start, LSL_Integer count)
{
var rootPrim = m_host.ParentGroup.RootPart;
Expand Down
4 changes: 2 additions & 2 deletions OpenSim/Region/ScriptEngine/YEngine/XMREngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -935,11 +935,11 @@ public bool PostObjectEvent(uint localID, EventParams parms)

TraceCalls("[YEngine]: YEngine.PostObjectEvent({0},{1})", localID.ToString(), parms.EventName);

// In SecondLife, attach events go to all scripts of all prims
// In SecondLife, attach and linkset_data events go to all scripts of all prims
// in a linked object. So here we duplicate that functionality,
// as all we ever get is a single attach event for the whole
// object.
if(parms.EventName == "attach")
if ((parms.EventName == "attach") || (parms.EventName == "linkset_data"))
{
bool posted = false;
foreach(SceneObjectPart primpart in part.ParentGroup.Parts)
Expand Down

0 comments on commit 04668d6

Please sign in to comment.