fail to find lsl api in ossl should be a global fatal error

This commit is contained in:
UbitUmarov
2023-06-02 22:37:10 +01:00
parent 2625eed5e4
commit 8b6b00d597

View File

@@ -268,7 +268,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// </remarks>
private void InitLSL()
{
m_LSL_Api ??= (LSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "LSL");
if (m_LSL_Api == null)
{
m_LSL_Api = (LSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "LSL");
if (m_LSL_Api == null)
throw new Exception("OSSL failed to load LSL API");
}
}
//
@@ -2811,7 +2816,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.VeryLow, "osForceCreateLink");
InitLSL();
m_LSL_Api?.CreateLink(target, parent);
m_LSL_Api.CreateLink(target, parent);
}
public void osForceBreakLink(int linknum)
@@ -2819,7 +2824,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.VeryLow, "osForceBreakLink");
InitLSL();
m_LSL_Api?.BreakLink(linknum);
m_LSL_Api.BreakLink(linknum);
}
public void osForceBreakAllLinks()
@@ -2827,7 +2832,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.VeryLow, "osForceBreakAllLinks");
InitLSL();
m_LSL_Api?.BreakAllLinks();
m_LSL_Api.BreakAllLinks();
}
public LSL_Integer osIsNpc(LSL_Key npc)
@@ -3258,7 +3263,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
InitLSL();
m_LSL_Api?.ThrottleSay(channel, 2000);
m_LSL_Api.ThrottleSay(channel, 2000);
module.Say(npcId, World, message, channel);
}
}
@@ -3291,7 +3296,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string npcNAME = NPCpresence.Name;
InitLSL();
m_LSL_Api?.ThrottleSay(channel, 2000);
m_LSL_Api.ThrottleSay(channel, 2000);
wComm.DeliverMessageTo(TargetID, channel, npcPOS, npcNAME, npcId, msg);
}
@@ -3308,7 +3313,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
InitLSL();
m_LSL_Api?.ThrottleSay(channel, 2000);
m_LSL_Api.ThrottleSay(channel, 2000);
module.Shout(npcId, World, message, channel);
}
}
@@ -3902,7 +3907,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel();
InitLSL();
m_LSL_Api?.SetPrimitiveParamsEx(prim, rules, "osSetPrimitiveParams");
m_LSL_Api.SetPrimitiveParamsEx(prim, rules, "osSetPrimitiveParams");
}
/// <summary>
@@ -4162,7 +4167,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
InitLSL();
m_LSL_Api?.AttachToAvatar(attachmentPoint);
m_LSL_Api.AttachToAvatar(attachmentPoint);
}
public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint)
@@ -4193,19 +4198,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
if (item is null)
{
m_LSL_Api?.llSay(0, $"Could not find object '{itemName}'");
m_LSL_Api.llSay(0, $"Could not find object '{itemName}'");
throw new Exception($"The inventory item '{itemName}' could not be found");
}
if (item.InvType != (int)InventoryType.Object)
{
m_LSL_Api?.llSay(0, $"Unable to attach, item '{itemName}' is not an object.");
m_LSL_Api.llSay(0, $"Unable to attach, item '{itemName}' is not an object.");
throw new Exception($"The inventory item '{itemName}' is not an object");
}
if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) != 0)
{
m_LSL_Api?.llSay(0, $"Unable to attach coalesced object, item '{itemName}'");
m_LSL_Api.llSay(0, $"Unable to attach coalesced object, item '{itemName}'");
throw new Exception($"The inventory item '{itemName}' is a coalesced object");
}
@@ -4220,7 +4225,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_log.ErrorFormat(
"[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}: {4}",
itemName, m_host.Name, attachmentPoint, World.Name, message);
m_LSL_Api?.llSay(0, message);
m_LSL_Api.llSay(0, message);
return;
}
@@ -4232,7 +4237,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
InitLSL();
m_LSL_Api?.DetachFromAvatar();
m_LSL_Api.DetachFromAvatar();
}
private static bool listObjToInt(object p, out int i)
@@ -5107,9 +5112,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
InitLSL();
if(m_LSL_Api is null)
return;
List<SceneObjectPart> sops = m_LSL_Api.GetLinkParts(linknum);
if(sops is null || sops.Count == 0)
return;
@@ -5622,9 +5624,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void osSetLinkSitActiveRange(LSL_Integer linkNumber, LSL_Float v)
{
InitLSL();
if(m_LSL_Api is null)
return;
float fv = (float)v.value;
if (fv > 128f)
fv = 128f;
@@ -5931,20 +5930,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void osParticleSystem(LSL_List rules)
{
InitLSL();
m_LSL_Api?.SetParticleSystem(m_host, rules, "osParticleSystem", true);
m_LSL_Api.SetParticleSystem(m_host, rules, "osParticleSystem", true);
}
public void osLinkParticleSystem(LSL_Integer linknumber, LSL_List rules)
{
InitLSL();
if (m_LSL_Api is not null)
{
List<SceneObjectPart> parts = m_LSL_Api.GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
{
m_LSL_Api.SetParticleSystem(part, rules, "osLinkParticleSystem", true);
}
List<SceneObjectPart> parts = m_LSL_Api.GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
{
m_LSL_Api.SetParticleSystem(part, rules, "osLinkParticleSystem", true);
}
}