add LSL_Integer osIsNotValidNumber(LSL_Float v)

This commit is contained in:
UbitUmarov
2019-10-17 23:33:11 +01:00
parent d6abf2a2fe
commit 2a90f78fe1
6 changed files with 77 additions and 56 deletions

View File

@@ -25,38 +25,29 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.IO;
using System.Reflection;
using System.Runtime.Remoting.Lifetime;
using System.Text;
using System.Net;
using System.Threading;
using System.Xml;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using Nini.Config;
using OpenSim;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Scripting;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using OpenSim.Services.Connectors.Hypergrid;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Remoting.Lifetime;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
@@ -65,7 +56,7 @@ using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
using PermissionMask = OpenSim.Framework.PermissionMask;
using OpenSim.Services.Connectors.Hypergrid;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
namespace OpenSim.Region.ScriptEngine.Shared.Api
{
@@ -187,10 +178,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(m_osslconfig == null)
m_osslconfig = m_ScriptEngine.Config;
if (m_osslconfig.GetBoolean("AllowOSFunctions", false))
if (m_osslconfig.GetBoolean("AllowOSFunctions", true))
{
m_OSFunctionsEnabled = true;
// m_log.Warn("[OSSL] OSSL FUNCTIONS ENABLED");
m_OSFunctionsEnabled = true;
// m_log.Warn("[OSSL] OSSL FUNCTIONS ENABLED");
}
m_PermissionErrortoOwner = m_osslconfig.GetBoolean("PermissionErrorToOwner", m_PermissionErrortoOwner);
@@ -5674,5 +5665,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_ScriptEngine.ApiResetScript(me);
}
public LSL_Integer osIsNotValidNumber(LSL_Float v)
{
double d = v;
if (double.IsNaN(d))
return 1;
if (double.IsNegativeInfinity(d))
return 2;
if (double.IsPositiveInfinity(d))
return 3;
return 0;
}
}
}

View File

@@ -558,5 +558,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_Rotation osSlerp(LSL_Rotation a, LSL_Rotation b, LSL_Float amount);
void osResetAllScripts(LSL_Integer AllLinkset);
LSL_Integer osIsNotValidNumber(LSL_Float v);
}
}

View File

@@ -35,7 +35,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public partial class ScriptBaseClass
{
// SCRIPTS CONSTANTS
public static readonly LSLInteger OS_APIVERSION = 9;
public static readonly LSLInteger OS_APIVERSION = 10;
public static readonly LSLInteger TRUE = 1;
public static readonly LSLInteger FALSE = 0;

View File

@@ -1416,5 +1416,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
m_OSSL_Functions.osResetAllScripts(allLinkSet);
}
public LSL_Integer osIsNotValidNumber(LSL_Float v)
{
return m_OSSL_Functions.osIsNotValidNumber(v);
}
}
}

View File

@@ -106,6 +106,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
// has an effect - without it tests will fail due to a 120 second wait for the event to finish.
xEngineConfig.Set("WaitForEventCompletionOnScriptStop", 120000);
IConfig config = configSource.AddConfig("OSSL");
config.Set("DebuggerSafe", false);
config.Set("AllowOSFunctions", "true");
config.Set("OSFunctionThreatLevel", "Severe");
m_scene = new SceneHelpers().SetupScene("My Test", TestHelpers.ParseTail(0x9999), 1000, 1000, configSource);
SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine);
m_scene.StartScripts();