try simplify lsl listen code a bit

This commit is contained in:
UbitUmarov
2022-06-18 22:40:01 +01:00
parent ade2ceb098
commit c972c23d2e
8 changed files with 223 additions and 233 deletions

View File

@@ -454,16 +454,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
switch (type)
{
case "listener":
m_Listener[engine].CreateFromData(localID, itemID,
hostID, item);
m_Listener[engine].CreateFromData(itemID, hostID, item);
break;
case "timer":
m_ScriptTimer[engine].CreateFromData(localID, itemID,
hostID, item);
m_ScriptTimer[engine].CreateFromData(localID, itemID, hostID, item);
break;
case "sensor":
m_SensorRepeat[engine].CreateFromData(localID,
itemID, hostID, item);
m_SensorRepeat[engine].CreateFromData(localID, itemID, hostID, item);
break;
}
}

View File

@@ -1340,7 +1340,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return -1;
UUID.TryParse(ID, out UUID keyID);
return wComm.Listen(m_host.LocalId, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg);
return wComm.Listen(m_item.ItemID, m_host.UUID, channelID, name, keyID, msg);
}
public void llListenControl(int number, int active)

View File

@@ -3998,7 +3998,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(UUID.TryParse(prim, out UUID pID) && pID.IsNotZero())
{
SceneObjectPart obj = World.GetSceneObjectPart(pID);
SetProjectionParams(obj, llprojection, texture, fov, focus, amb);
if(obj != null)
{
if(obj.OwnerID.Equals(m_host.OwnerID))
SetProjectionParams(obj, llprojection, texture, fov, focus, amb);
}
}
else
SetProjectionParams(m_host, llprojection, texture, fov, focus, amb);
@@ -4598,9 +4602,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield)
{
CheckThreatLevel(ThreatLevel.Low, "osListenRegex");
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
if(wComm == null)
return -1;
UUID.TryParse(ID, out UUID keyID);
// if we want the name to be used as a regular expression, ensure it is valid first.
if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_NAME) == ScriptBaseClass.OS_LISTEN_REGEX_NAME)
{
@@ -4608,7 +4614,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
Regex.IsMatch("", name);
}
catch (Exception)
catch
{
OSSLShoutError("Name regex is invalid.");
return -1;
@@ -4622,24 +4628,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
Regex.IsMatch("", msg);
}
catch (Exception)
catch
{
OSSLShoutError("Message regex is invalid.");
return -1;
}
}
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
return (wComm == null) ? -1 : wComm.Listen(
m_host.LocalId,
m_item.ItemID,
m_host.UUID,
channelID,
name,
keyID,
msg,
regexBitfield
);
return wComm.Listen(m_item.ItemID, m_host.UUID,
channelID, name, keyID, msg, regexBitfield);
}
public LSL_Integer osRegexIsMatch(string input, string pattern)

View File

@@ -189,10 +189,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
catch { }
ds.action = null;
lock (DataserverRequests)
{
if (DataserverRequests.TryGetValue(id, out ds))
DataserverRequests.Remove(id);
DataserverRequests.Remove(id);
}
}
@@ -200,20 +200,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
public void DataserverReply(string identifier, string reply)
{
DataserverRequest ds;
lock (DataserverRequests)
{
if (!DataserverRequests.ContainsKey(identifier))
if (!DataserverRequests.TryGetValue(identifier, out ds))
return;
ds = DataserverRequests[identifier];
DataserverRequests.Remove(identifier);
}
m_CmdManager.m_ScriptEngine.PostObjectEvent(ds.localID,
new EventParams("dataserver", new Object[]
{ new LSL_Types.LSLString(ds.ID.ToString()),
new LSL_Types.LSLString(reply)},
{
new LSL_Types.LSLString(ds.ID.ToString()),
new LSL_Types.LSLString(reply)
},
new DetectParams[0]));
}

View File

@@ -62,25 +62,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
if (m_commsPlugin != null)
{
while (m_commsPlugin.HasMessages())
ListenerInfo lInfo;
while ((lInfo = (ListenerInfo)m_commsPlugin.GetNextMessage()) != null)
{
ListenerInfo lInfo = (ListenerInfo)m_commsPlugin.GetNextMessage();
//Deliver data to prim's listen handler
object[] resobj = new object[]
{
new LSL_Types.LSLInteger(lInfo.GetChannel()),
new LSL_Types.LSLString(lInfo.GetName()),
new LSL_Types.LSLString(lInfo.GetID().ToString()),
new LSL_Types.LSLString(lInfo.GetMessage())
new LSL_Types.LSLInteger(lInfo.Channel),
new LSL_Types.LSLString(lInfo.Name),
new LSL_Types.LSLString(lInfo.ID.ToString()),
new LSL_Types.LSLString(lInfo.Message)
};
foreach (IScriptEngine e in m_CmdManager.ScriptEngines)
{
e.PostScriptEvent(
lInfo.GetItemID(), new EventParams(
"listen", resobj,
new DetectParams[0]));
e.PostScriptEvent(lInfo.ItemID, new EventParams("listen", resobj, new DetectParams[0]));
}
}
}
@@ -94,11 +90,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
return new Object[]{};
}
public void CreateFromData(uint localID, UUID itemID, UUID hostID,
Object[] data)
public void CreateFromData( UUID itemID, UUID hostID, Object[] data)
{
if (m_commsPlugin != null)
m_commsPlugin.CreateFromData(localID, itemID, hostID, data);
m_commsPlugin.CreateFromData(itemID, hostID, data);
}
}
}

View File

@@ -253,10 +253,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public void Initialise(IConfigSource configSource)
{
if (configSource.Configs["XEngine"] == null)
m_ScriptConfig = configSource.Configs["XEngine"];
if (m_ScriptConfig == null)
return;
m_ScriptConfig = configSource.Configs["XEngine"];
if (!m_ScriptConfig.GetBoolean("Enabled", true))
return;
m_Enabled = true;
m_ConfigSource = configSource;
string rawScriptStopStrategy = m_ScriptConfig.GetString("ScriptStopStrategy", "co-op");
@@ -282,19 +287,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public void AddRegion(Scene scene)
{
if (m_ScriptConfig == null)
if (!m_Enabled)
return;
m_ScriptFailCount = 0;
m_ScriptErrorMessage = String.Empty;
m_Enabled = m_ScriptConfig.GetBoolean("Enabled", true);
if (!m_Enabled)
return;
AppDomain.CurrentDomain.AssemblyResolve +=
OnAssemblyResolve;
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
m_Scene = scene;
m_log.InfoFormat("[XEngine]: Initializing scripts in region {0}", m_Scene.RegionInfo.RegionName);