mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
mantis 8972: avoid null ref plus cosmetics
This commit is contained in:
@@ -1482,9 +1482,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
string stateFileName = XMRInstance.GetStateFileName(m_ScriptBasePath, itemID);
|
||||
File.Delete(stateFileName);
|
||||
|
||||
ScriptRemoved handlerScriptRemoved = OnScriptRemoved;
|
||||
if(handlerScriptRemoved != null)
|
||||
handlerScriptRemoved(itemID);
|
||||
OnScriptRemoved?.Invoke(itemID);
|
||||
|
||||
m_LockedDict = "~~OnRemoveScript";
|
||||
}
|
||||
|
||||
@@ -135,10 +135,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
|
||||
// Initialize the API instance.
|
||||
scriptApi.Initialize(m_Engine, m_Part, m_Item);
|
||||
this.InitApi(api, scriptApi);
|
||||
InitApi(api, scriptApi);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get script object code loaded in memory and all ready to run,
|
||||
* ready to resume it from where the .state file says it was last
|
||||
@@ -250,7 +249,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
// If any error loading, decrement object code reference count.
|
||||
DecObjCodeRefCount();
|
||||
throw;
|
||||
@@ -326,16 +324,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
private void LoadObjCode()
|
||||
{
|
||||
// Script must leave this much stack remaining on calls to CheckRun().
|
||||
this.stackLimit = m_StackSize / 2;
|
||||
stackLimit = m_StackSize / 2;
|
||||
|
||||
// This is how many total heap bytes script is allowed to use.
|
||||
this.heapLimit = m_HeapSize;
|
||||
heapLimit = m_HeapSize;
|
||||
|
||||
// Allocate global variable arrays.
|
||||
this.glblVars.AllocVarArrays(m_ObjCode.glblSizes);
|
||||
glblVars.AllocVarArrays(m_ObjCode.glblSizes);
|
||||
|
||||
// Script can handle these event codes.
|
||||
m_HaveEventHandlers = new bool[m_ObjCode.scriptEventHandlerTable.GetLength(1)];
|
||||
for(int i = m_ObjCode.scriptEventHandlerTable.GetLength(0); --i >= 0;)
|
||||
{
|
||||
for(int j = m_ObjCode.scriptEventHandlerTable.GetLength(1); --j >= 0;)
|
||||
|
||||
@@ -30,29 +30,13 @@ using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Remoting.Lifetime;
|
||||
using System.Security.Policy;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
||||
using OpenSim.Region.ScriptEngine.Shared;
|
||||
using OpenSim.Region.ScriptEngine.Shared.Api;
|
||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
||||
using OpenSim.Region.ScriptEngine.Yengine;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using log4net;
|
||||
|
||||
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;
|
||||
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
|
||||
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;
|
||||
|
||||
// This class exists in the main app domain
|
||||
//
|
||||
namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
@@ -132,7 +116,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
public int m_StartParam = 0;
|
||||
public StateSource m_StateSource;
|
||||
public string m_DescName;
|
||||
private bool[] m_HaveEventHandlers;
|
||||
private bool[] m_HaveEventHandlers = new bool[(int)ScriptEventCode.Size];
|
||||
public int m_StackSize;
|
||||
public int m_HeapSize;
|
||||
private ArrayList m_CompilerErrors;
|
||||
|
||||
@@ -26,25 +26,12 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.Remoting.Lifetime;
|
||||
using System.Security.Policy;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
||||
using OpenSim.Region.ScriptEngine.Shared;
|
||||
using OpenSim.Region.ScriptEngine.Shared.Api;
|
||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
||||
using OpenSim.Region.ScriptEngine.Yengine;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using log4net;
|
||||
|
||||
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
|
||||
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
|
||||
|
||||
@@ -36,15 +36,6 @@ using OpenSim.Region.ScriptEngine.Shared;
|
||||
using OpenSim.Region.ScriptEngine.Shared.Api;
|
||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using log4net;
|
||||
|
||||
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;
|
||||
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
|
||||
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;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
{
|
||||
@@ -63,10 +54,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
*/
|
||||
public void PostEvent(EventParams evt)
|
||||
{
|
||||
if(!m_eventCodeMap.TryGetValue(evt.EventName, out ScriptEventCode evc))
|
||||
if (!m_eventCodeMap.TryGetValue(evt.EventName, out ScriptEventCode evc))
|
||||
return;
|
||||
|
||||
if (((uint)evc >= (uint)m_HaveEventHandlers.Length) || !m_HaveEventHandlers[(int)evc]) // don't bother if we don't have such a handler in any state
|
||||
if (!m_HaveEventHandlers[(int)evc]) // don't bother if we don't have such a handler in any state
|
||||
return;
|
||||
|
||||
// Put event on end of event queue.
|
||||
@@ -312,7 +303,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
Exception e = null;
|
||||
|
||||
// Do some more of the last event if it didn't finish.
|
||||
if (this.eventCode != ScriptEventCode.None)
|
||||
if (eventCode != ScriptEventCode.None)
|
||||
{
|
||||
lock(m_QueueLock)
|
||||
{
|
||||
@@ -492,7 +483,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
throw new Exception("still processing event " + this.eventCode.ToString());
|
||||
|
||||
// Silly to even try if there is no handler defined for this event.
|
||||
if (((int)newEventCode >= 0) && (m_ObjCode.scriptEventHandlerTable[this.stateCode, (int)newEventCode] == null))
|
||||
if ((newEventCode >= 0) && (m_ObjCode.scriptEventHandlerTable[stateCode, (int)newEventCode] == null))
|
||||
return null;
|
||||
|
||||
// Save eventCode so we know what event handler to run in the microthread.
|
||||
|
||||
Reference in New Issue
Block a user