Hiding evidence that I once was a VB coder (thanks to refactoring). Renamed member names to smallcapsy.

afrisby
Tedd Hansen 2007-09-13 11:11:08 +00:00
parent 615487a756
commit cef8c5e9d7
13 changed files with 140 additions and 140 deletions

View File

@ -164,7 +164,6 @@ namespace OpenSim.Framework.Data
ArrayList SendParams = new ArrayList(); ArrayList SendParams = new ArrayList();
SendParams.Add(requestData); SendParams.Add(requestData);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
Console.WriteLine("Requesting response from GridServer URL: " + gridserver_url);
XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
Hashtable responseData = (Hashtable)GridResp.Value; Hashtable responseData = (Hashtable)GridResp.Value;

View File

@ -173,6 +173,7 @@ namespace OpenSim.Framework.UserManagement
/// <returns>Authenticated?</returns> /// <returns>Authenticated?</returns>
public virtual bool AuthenticateUser(UserProfileData profile, string password) public virtual bool AuthenticateUser(UserProfileData profile, string password)
{ {
MainLog.Instance.Verbose( MainLog.Instance.Verbose(
"Authenticating " + profile.username + " " + profile.surname); "Authenticating " + profile.username + " " + profile.surname);

View File

@ -15,11 +15,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
public class AppDomainManager public class AppDomainManager
{ {
private int MaxScriptsPerAppDomain = 1; private int maxScriptsPerAppDomain = 1;
/// <summary> /// <summary>
/// Internal list of all AppDomains /// Internal list of all AppDomains
/// </summary> /// </summary>
private List<AppDomainStructure> AppDomains = new List<AppDomainStructure>(); private List<AppDomainStructure> appDomains = new List<AppDomainStructure>();
/// <summary> /// <summary>
/// Structure to keep track of data around AppDomain /// Structure to keep track of data around AppDomain
/// </summary> /// </summary>
@ -41,9 +41,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// <summary> /// <summary>
/// Current AppDomain /// Current AppDomain
/// </summary> /// </summary>
private AppDomainStructure CurrentAD; private AppDomainStructure currentAD;
private object GetLock = new object(); // Mutex private object getLock = new object(); // Mutex
private object FreeLock = new object(); // Mutex private object freeLock = new object(); // Mutex
//private ScriptEngine m_scriptEngine; //private ScriptEngine m_scriptEngine;
//public AppDomainManager(ScriptEngine scriptEngine) //public AppDomainManager(ScriptEngine scriptEngine)
@ -59,25 +59,25 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
private AppDomainStructure GetFreeAppDomain() private AppDomainStructure GetFreeAppDomain()
{ {
Console.WriteLine("Finding free AppDomain"); Console.WriteLine("Finding free AppDomain");
lock (GetLock) lock (getLock)
{ {
// Current full? // Current full?
if (CurrentAD != null && CurrentAD.ScriptsLoaded >= MaxScriptsPerAppDomain) if (currentAD != null && currentAD.ScriptsLoaded >= maxScriptsPerAppDomain)
{ {
// Add it to AppDomains list and empty current // Add it to AppDomains list and empty current
AppDomains.Add(CurrentAD); appDomains.Add(currentAD);
CurrentAD = null; currentAD = null;
} }
// No current // No current
if (CurrentAD == null) if (currentAD == null)
{ {
// Create a new current AppDomain // Create a new current AppDomain
CurrentAD = new AppDomainStructure(); currentAD = new AppDomainStructure();
CurrentAD.CurrentAppDomain = PrepareNewAppDomain(); currentAD.CurrentAppDomain = PrepareNewAppDomain();
} }
Console.WriteLine("Scripts loaded in this Appdomain: " + CurrentAD.ScriptsLoaded); Console.WriteLine("Scripts loaded in this Appdomain: " + currentAD.ScriptsLoaded);
return CurrentAD; return currentAD;
} // lock } // lock
} }
@ -112,13 +112,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// </summary> /// </summary>
private void UnloadAppDomains() private void UnloadAppDomains()
{ {
lock (FreeLock) lock (freeLock)
{ {
// Go through all // Go through all
foreach (AppDomainStructure ads in new System.Collections.ArrayList(AppDomains)) foreach (AppDomainStructure ads in new System.Collections.ArrayList(appDomains))
{ {
// Don't process current AppDomain // Don't process current AppDomain
if (ads.CurrentAppDomain != CurrentAD.CurrentAppDomain) if (ads.CurrentAppDomain != currentAD.CurrentAppDomain)
{ {
// Not current AppDomain // Not current AppDomain
// Is number of unloaded bigger or equal to number of loaded? // Is number of unloaded bigger or equal to number of loaded?
@ -126,7 +126,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
Console.WriteLine("Found empty AppDomain, unloading"); Console.WriteLine("Found empty AppDomain, unloading");
// Remove from internal list // Remove from internal list
AppDomains.Remove(ads); appDomains.Remove(ads);
#if DEBUG #if DEBUG
long m = GC.GetTotalMemory(true); long m = GC.GetTotalMemory(true);
#endif #endif
@ -164,19 +164,19 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
//[Obsolete("Needs fixing, needs a real purpose in life!!!")] //[Obsolete("Needs fixing, needs a real purpose in life!!!")]
public void StopScript(AppDomain ad) public void StopScript(AppDomain ad)
{ {
lock (FreeLock) lock (freeLock)
{ {
Console.WriteLine("Stopping script in AppDomain"); Console.WriteLine("Stopping script in AppDomain");
// Check if it is current AppDomain // Check if it is current AppDomain
if (CurrentAD.CurrentAppDomain == ad) if (currentAD.CurrentAppDomain == ad)
{ {
// Yes - increase // Yes - increase
CurrentAD.ScriptsWaitingUnload++; currentAD.ScriptsWaitingUnload++;
return; return;
} }
// Lopp through all AppDomains // Lopp through all AppDomains
foreach (AppDomainStructure ads in new System.Collections.ArrayList(AppDomains)) foreach (AppDomainStructure ads in new System.Collections.ArrayList(appDomains))
{ {
if (ads.CurrentAppDomain == ad) if (ads.CurrentAppDomain == ad)
{ {

View File

@ -34,7 +34,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
public static class Common public static class Common
{ {
static public bool Debug = true; static public bool debug = true;
static public ScriptEngine mySE; static public ScriptEngine mySE;
//public delegate void SendToDebugEventDelegate(string Message); //public delegate void SendToDebugEventDelegate(string Message);

View File

@ -13,7 +13,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
{ {
private LSL2CSConverter LSL_Converter = new LSL2CSConverter(); private LSL2CSConverter LSL_Converter = new LSL2CSConverter();
private CSharpCodeProvider codeProvider = new CSharpCodeProvider(); private CSharpCodeProvider codeProvider = new CSharpCodeProvider();
private static UInt64 ScriptCompileCounter = 0; private static UInt64 scriptCompileCounter = 0;
//private ICodeCompiler icc = codeProvider.CreateCompiler(); //private ICodeCompiler icc = codeProvider.CreateCompiler();
public string CompileFromFile(string LSOFileName) public string CompileFromFile(string LSOFileName)
{ {
@ -49,8 +49,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
// Output assembly name // Output assembly name
ScriptCompileCounter++; scriptCompileCounter++;
string OutFile = Path.Combine("ScriptEngines", "Script_" + ScriptCompileCounter + ".dll"); string OutFile = Path.Combine("ScriptEngines", "Script_" + scriptCompileCounter + ".dll");
try try
{ {
System.IO.File.Delete(OutFile); System.IO.File.Delete(OutFile);

View File

@ -8,21 +8,21 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
public class LSL2CSConverter public class LSL2CSConverter
{ {
//private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled); //private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled);
private Dictionary<string, string> DataTypes = new Dictionary<string, string>(); private Dictionary<string, string> dataTypes = new Dictionary<string, string>();
private Dictionary<string, string> QUOTES = new Dictionary<string, string>(); private Dictionary<string, string> quotes = new Dictionary<string, string>();
public LSL2CSConverter() public LSL2CSConverter()
{ {
// Only the types we need to convert // Only the types we need to convert
DataTypes.Add("void", "void"); dataTypes.Add("void", "void");
DataTypes.Add("integer", "int"); dataTypes.Add("integer", "int");
DataTypes.Add("float", "double"); dataTypes.Add("float", "double");
DataTypes.Add("string", "string"); dataTypes.Add("string", "string");
DataTypes.Add("key", "string"); dataTypes.Add("key", "string");
DataTypes.Add("vector", "LSL_Types.Vector3"); dataTypes.Add("vector", "LSL_Types.Vector3");
DataTypes.Add("rotation", "LSL_Types.Quaternion"); dataTypes.Add("rotation", "LSL_Types.Quaternion");
DataTypes.Add("list", "list"); dataTypes.Add("list", "list");
DataTypes.Add("null", "null"); dataTypes.Add("null", "null");
} }
@ -74,7 +74,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
_Script += quote_replacement_string + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]); _Script += quote_replacement_string + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]);
} }
// We just left a quote // We just left a quote
QUOTES.Add(quote_replacement_string + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote); quotes.Add(quote_replacement_string + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote);
quote = ""; quote = "";
} }
break; break;
@ -189,10 +189,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
foreach (string key in DataTypes.Keys) foreach (string key in dataTypes.Keys)
{ {
string val; string val;
DataTypes.TryGetValue(key, out val); dataTypes.TryGetValue(key, out val);
// Replace CAST - (integer) with (int) // Replace CAST - (integer) with (int)
Script = Regex.Replace(Script, @"\(" + key + @"\)", @"(" + val + ")", RegexOptions.Compiled | RegexOptions.Multiline); Script = Regex.Replace(Script, @"\(" + key + @"\)", @"(" + val + ")", RegexOptions.Compiled | RegexOptions.Multiline);
@ -217,10 +217,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
// REPLACE BACK QUOTES // REPLACE BACK QUOTES
foreach (string key in QUOTES.Keys) foreach (string key in quotes.Keys)
{ {
string val; string val;
QUOTES.TryGetValue(key, out val); quotes.TryGetValue(key, out val);
Script = Script.Replace(key, "\"" + val + "\""); Script = Script.Replace(key, "\"" + val + "\"");
} }

View File

@ -302,7 +302,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
public void llSetTimerEvent(double sec) public void llSetTimerEvent(double sec)
{ {
// Setting timer repeat // Setting timer repeat
m_ScriptEngine.myLSLLongCmdHandler.SetTimerEvent(m_localID, m_itemID, sec); m_ScriptEngine.m_LSLLongCmdHandler.SetTimerEvent(m_localID, m_itemID, sec);
} }
public void llSleep(double sec) public void llSleep(double sec)

View File

@ -63,7 +63,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Add to queue for all scripts in ObjectID object // Add to queue for all scripts in ObjectID object
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Event: touch_start"); //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Event: touch_start");
//Console.WriteLine("touch_start localID: " + localID); //Console.WriteLine("touch_start localID: " + localID);
myScriptEngine.myEventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] { (int)1 }); myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] { (int)1 });
} }
public void OnRezScript(uint localID, LLUUID itemID, string script) public void OnRezScript(uint localID, LLUUID itemID, string script)
{ {
@ -72,7 +72,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost() // new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()
//); //);
Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + script.Length); Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + script.Length);
myScriptEngine.myScriptManager.StartScript(localID, itemID, script); myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script);
} }
public void OnRemoveScript(uint localID, LLUUID itemID) public void OnRemoveScript(uint localID, LLUUID itemID)
{ {
@ -81,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost() // new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()
//); //);
Console.WriteLine("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString()); Console.WriteLine("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
myScriptEngine.myScriptManager.StopScript( myScriptEngine.m_ScriptManager.StopScript(
localID, localID,
itemID itemID
); );

View File

@ -47,20 +47,20 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// <summary> /// <summary>
/// List of threads processing event queue /// List of threads processing event queue
/// </summary> /// </summary>
private List<Thread> EventQueueThreads = new List<Thread>(); private List<Thread> eventQueueThreads = new List<Thread>();
private object QueueLock = new object(); // Mutex lock object private object queueLock = new object(); // Mutex lock object
/// <summary> /// <summary>
/// How many ms to sleep if queue is empty /// How many ms to sleep if queue is empty
/// </summary> /// </summary>
private int NothingToDoSleepms = 50; private int nothingToDoSleepms = 50;
/// <summary> /// <summary>
/// How many threads to process queue with /// How many threads to process queue with
/// </summary> /// </summary>
private int NumberOfThreads = 2; private int numberOfThreads = 2;
/// <summary> /// <summary>
/// Queue containing events waiting to be executed /// Queue containing events waiting to be executed
/// </summary> /// </summary>
private Queue<QueueItemStruct> EventQueue = new Queue<QueueItemStruct>(); private Queue<QueueItemStruct> eventQueue = new Queue<QueueItemStruct>();
/// <summary> /// <summary>
/// Queue item structure /// Queue item structure
/// </summary> /// </summary>
@ -68,28 +68,28 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
public uint localID; public uint localID;
public LLUUID itemID; public LLUUID itemID;
public string FunctionName; public string functionName;
public object[] param; public object[] param;
} }
/// <summary> /// <summary>
/// List of localID locks for mutex processing of script events /// List of localID locks for mutex processing of script events
/// </summary> /// </summary>
private List<uint> ObjectLocks = new List<uint>(); private List<uint> objectLocks = new List<uint>();
private object TryLockLock = new object(); // Mutex lock object private object tryLockLock = new object(); // Mutex lock object
private ScriptEngine myScriptEngine; private ScriptEngine m_ScriptEngine;
public EventQueueManager(ScriptEngine _ScriptEngine) public EventQueueManager(ScriptEngine _ScriptEngine)
{ {
myScriptEngine = _ScriptEngine; m_ScriptEngine = _ScriptEngine;
// //
// Start event queue processing threads (worker threads) // Start event queue processing threads (worker threads)
// //
for (int ThreadCount = 0; ThreadCount <= NumberOfThreads; ThreadCount++) for (int ThreadCount = 0; ThreadCount <= numberOfThreads; ThreadCount++)
{ {
Thread EventQueueThread = new Thread(EventQueueThreadLoop); Thread EventQueueThread = new Thread(EventQueueThreadLoop);
EventQueueThreads.Add(EventQueueThread); eventQueueThreads.Add(EventQueueThread);
EventQueueThread.IsBackground = true; EventQueueThread.IsBackground = true;
EventQueueThread.Priority = ThreadPriority.BelowNormal; EventQueueThread.Priority = ThreadPriority.BelowNormal;
EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount; EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount;
@ -100,7 +100,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
// Kill worker threads // Kill worker threads
foreach (Thread EventQueueThread in new System.Collections.ArrayList(EventQueueThreads)) foreach (Thread EventQueueThread in new System.Collections.ArrayList(eventQueueThreads))
{ {
if (EventQueueThread != null && EventQueueThread.IsAlive == true) if (EventQueueThread != null && EventQueueThread.IsAlive == true)
{ {
@ -115,9 +115,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
} }
} }
EventQueueThreads.Clear(); eventQueueThreads.Clear();
// Todo: Clean up our queues // Todo: Clean up our queues
EventQueue.Clear(); eventQueue.Clear();
} }
@ -137,10 +137,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
QueueItemStruct QIS = BlankQIS; QueueItemStruct QIS = BlankQIS;
bool GotItem = false; bool GotItem = false;
if (EventQueue.Count == 0) if (eventQueue.Count == 0)
{ {
// Nothing to do? Sleep a bit waiting for something to do // Nothing to do? Sleep a bit waiting for something to do
Thread.Sleep(NothingToDoSleepms); Thread.Sleep(nothingToDoSleepms);
} }
else else
{ {
@ -148,19 +148,19 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
//myScriptEngine.m_logger.Verbose("ScriptEngine", "Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName); //myScriptEngine.m_logger.Verbose("ScriptEngine", "Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
// OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD // OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
lock (QueueLock) lock (queueLock)
{ {
GotItem = false; GotItem = false;
for (int qc = 0; qc < EventQueue.Count; qc++) for (int qc = 0; qc < eventQueue.Count; qc++)
{ {
// Get queue item // Get queue item
QIS = EventQueue.Dequeue(); QIS = eventQueue.Dequeue();
// Check if object is being processed by someone else // Check if object is being processed by someone else
if (TryLock(QIS.localID) == false) if (TryLock(QIS.localID) == false)
{ {
// Object is already being processed, requeue it // Object is already being processed, requeue it
EventQueue.Enqueue(QIS); eventQueue.Enqueue(QIS);
} }
else else
{ {
@ -176,12 +176,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Execute function // Execute function
try try
{ {
myScriptEngine.myScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.FunctionName, QIS.param); m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.functionName, QIS.param);
} }
catch (Exception e) catch (Exception e)
{ {
// DISPLAY ERROR INWORLD // DISPLAY ERROR INWORLD
string text = "Error executing script function \"" + QIS.FunctionName + "\":\r\n"; string text = "Error executing script function \"" + QIS.functionName + "\":\r\n";
if (e.InnerException != null) if (e.InnerException != null)
{ // Send inner exception { // Send inner exception
text += e.InnerException.Message.ToString(); text += e.InnerException.Message.ToString();
@ -194,10 +194,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
if (text.Length > 1500) if (text.Length > 1500)
text = text.Substring(0, 1500); text = text.Substring(0, 1500);
IScriptHost m_host = myScriptEngine.World.GetSceneObjectPart(QIS.localID); IScriptHost m_host = m_ScriptEngine.World.GetSceneObjectPart(QIS.localID);
//if (m_host != null) //if (m_host != null)
//{ //{
myScriptEngine.World.SimChat(Helpers.StringToField(text), 1, m_host.AbsolutePosition, m_host.Name, m_host.UUID); m_ScriptEngine.World.SimChat(Helpers.StringToField(text), 1, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
} catch { } catch {
//} //}
//else //else
@ -234,15 +234,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// <returns></returns> /// <returns></returns>
private bool TryLock(uint localID) private bool TryLock(uint localID)
{ {
lock (TryLockLock) lock (tryLockLock)
{ {
if (ObjectLocks.Contains(localID) == true) if (objectLocks.Contains(localID) == true)
{ {
return false; return false;
} }
else else
{ {
ObjectLocks.Add(localID); objectLocks.Add(localID);
return true; return true;
} }
} }
@ -254,11 +254,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// <param name="localID"></param> /// <param name="localID"></param>
private void ReleaseLock(uint localID) private void ReleaseLock(uint localID)
{ {
lock (TryLockLock) lock (tryLockLock)
{ {
if (ObjectLocks.Contains(localID) == true) if (objectLocks.Contains(localID) == true)
{ {
ObjectLocks.Remove(localID); objectLocks.Remove(localID);
} }
} }
} }
@ -277,13 +277,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Do we have any scripts in this object at all? If not, return // Do we have any scripts in this object at all? If not, return
if (myScriptEngine.myScriptManager.Scripts.ContainsKey(localID) == false) if (m_ScriptEngine.m_ScriptManager.Scripts.ContainsKey(localID) == false)
{ {
//Console.WriteLine("Event \"" + FunctionName + "\" for localID: " + localID + ". No scripts found on this localID."); //Console.WriteLine("Event \"" + FunctionName + "\" for localID: " + localID + ". No scripts found on this localID.");
return; return;
} }
Dictionary<LLUUID, LSL_BaseClass>.KeyCollection scriptKeys = myScriptEngine.myScriptManager.GetScriptKeys(localID); Dictionary<LLUUID, LSL_BaseClass>.KeyCollection scriptKeys = m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
foreach ( LLUUID itemID in scriptKeys ) foreach ( LLUUID itemID in scriptKeys )
{ {
@ -303,17 +303,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// <param name="param">Array of parameters to match event mask</param> /// <param name="param">Array of parameters to match event mask</param>
public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, object[] param) public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, object[] param)
{ {
lock (QueueLock) lock (queueLock)
{ {
// Create a structure and add data // Create a structure and add data
QueueItemStruct QIS = new QueueItemStruct(); QueueItemStruct QIS = new QueueItemStruct();
QIS.localID = localID; QIS.localID = localID;
QIS.itemID = itemID; QIS.itemID = itemID;
QIS.FunctionName = FunctionName; QIS.functionName = FunctionName;
QIS.param = param; QIS.param = param;
// Add it to queue // Add it to queue
EventQueue.Enqueue(QIS); eventQueue.Enqueue(QIS);
} }
} }

View File

@ -11,32 +11,32 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// </summary> /// </summary>
class LSLLongCmdHandler class LSLLongCmdHandler
{ {
private Thread CmdHandlerThread; private Thread cmdHandlerThread;
private int CmdHandlerThreadCycleSleepms = 100; private int cmdHandlerThreadCycleSleepms = 100;
private ScriptEngine myScriptEngine; private ScriptEngine m_ScriptEngine;
public LSLLongCmdHandler(ScriptEngine _ScriptEngine) public LSLLongCmdHandler(ScriptEngine _ScriptEngine)
{ {
myScriptEngine = _ScriptEngine; m_ScriptEngine = _ScriptEngine;
// Start the thread that will be doing the work // Start the thread that will be doing the work
CmdHandlerThread = new Thread(CmdHandlerThreadLoop); cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
CmdHandlerThread.Name = "CmdHandlerThread"; cmdHandlerThread.Name = "CmdHandlerThread";
CmdHandlerThread.Priority = ThreadPriority.BelowNormal; cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
CmdHandlerThread.IsBackground = true; cmdHandlerThread.IsBackground = true;
CmdHandlerThread.Start(); cmdHandlerThread.Start();
} }
~LSLLongCmdHandler() ~LSLLongCmdHandler()
{ {
// Shut down thread // Shut down thread
try try
{ {
if (CmdHandlerThread != null) if (cmdHandlerThread != null)
{ {
if (CmdHandlerThread.IsAlive == true) if (cmdHandlerThread.IsAlive == true)
{ {
CmdHandlerThread.Abort(); cmdHandlerThread.Abort();
CmdHandlerThread.Join(); cmdHandlerThread.Join();
} }
} }
} }
@ -51,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
CheckTimerEvents(); CheckTimerEvents();
// Sleep before next cycle // Sleep before next cycle
Thread.Sleep(CmdHandlerThreadCycleSleepms); Thread.Sleep(cmdHandlerThreadCycleSleepms);
} }
} }
@ -134,7 +134,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
{ {
// Add it to queue // Add it to queue
myScriptEngine.myEventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { }); m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { });
// set next interval // set next interval

View File

@ -45,11 +45,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
internal OpenSim.Region.Environment.Scenes.Scene World; internal OpenSim.Region.Environment.Scenes.Scene World;
internal EventManager myEventManager; // Handles and queues incoming events from OpenSim internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim
internal EventQueueManager myEventQueueManager; // Executes events internal EventQueueManager m_EventQueueManager; // Executes events
internal ScriptManager myScriptManager; // Load, unload and execute scripts internal ScriptManager m_ScriptManager; // Load, unload and execute scripts
internal AppDomainManager myAppDomainManager; internal AppDomainManager m_AppDomainManager;
internal LSLLongCmdHandler myLSLLongCmdHandler; internal LSLLongCmdHandler m_LSLLongCmdHandler;
private OpenSim.Framework.Console.LogBase m_log; private OpenSim.Framework.Console.LogBase m_log;
@ -75,11 +75,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
//m_logger.Status("ScriptEngine", "InitializeEngine"); //m_logger.Status("ScriptEngine", "InitializeEngine");
// Create all objects we'll be using // Create all objects we'll be using
myEventQueueManager = new EventQueueManager(this); m_EventQueueManager = new EventQueueManager(this);
myEventManager = new EventManager(this); m_EventManager = new EventManager(this);
myScriptManager = new ScriptManager(this); m_ScriptManager = new ScriptManager(this);
myAppDomainManager = new AppDomainManager(); m_AppDomainManager = new AppDomainManager();
myLSLLongCmdHandler = new LSLLongCmdHandler(this); m_LSLLongCmdHandler = new LSLLongCmdHandler(this);
// Should we iterate the region for scripts that needs starting? // Should we iterate the region for scripts that needs starting?
// Or can we assume we are loaded before anything else so we can use proper events? // Or can we assume we are loaded before anything else so we can use proper events?

View File

@ -53,15 +53,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public class ScriptManager public class ScriptManager
{ {
#region Declares #region Declares
private Thread ScriptLoadUnloadThread; private Thread scriptLoadUnloadThread;
private int ScriptLoadUnloadThread_IdleSleepms = 100; private int scriptLoadUnloadThread_IdleSleepms = 100;
private Queue<LoadStruct> LoadQueue = new Queue<LoadStruct>(); private Queue<LoadStruct> loadQueue = new Queue<LoadStruct>();
private Queue<UnloadStruct> UnloadQueue = new Queue<UnloadStruct>(); private Queue<UnloadStruct> unloadQueue = new Queue<UnloadStruct>();
private struct LoadStruct private struct LoadStruct
{ {
public uint localID; public uint localID;
public LLUUID itemID; public LLUUID itemID;
public string Script; public string script;
} }
private struct UnloadStruct private struct UnloadStruct
{ {
@ -87,11 +87,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
m_scriptEngine = scriptEngine; m_scriptEngine = scriptEngine;
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
ScriptLoadUnloadThread = new Thread(ScriptLoadUnloadThreadLoop); scriptLoadUnloadThread = new Thread(ScriptLoadUnloadThreadLoop);
ScriptLoadUnloadThread.Name = "ScriptLoadUnloadThread"; scriptLoadUnloadThread.Name = "ScriptLoadUnloadThread";
ScriptLoadUnloadThread.IsBackground = true; scriptLoadUnloadThread.IsBackground = true;
ScriptLoadUnloadThread.Priority = ThreadPriority.BelowNormal; scriptLoadUnloadThread.Priority = ThreadPriority.BelowNormal;
ScriptLoadUnloadThread.Start(); scriptLoadUnloadThread.Start();
} }
~ScriptManager () ~ScriptManager ()
@ -99,12 +99,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Abort load/unload thread // Abort load/unload thread
try try
{ {
if (ScriptLoadUnloadThread != null) if (scriptLoadUnloadThread != null)
{ {
if (ScriptLoadUnloadThread.IsAlive == true) if (scriptLoadUnloadThread.IsAlive == true)
{ {
ScriptLoadUnloadThread.Abort(); scriptLoadUnloadThread.Abort();
ScriptLoadUnloadThread.Join(); scriptLoadUnloadThread.Join();
} }
} }
} }
@ -120,18 +120,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
while (true) while (true)
{ {
if (LoadQueue.Count == 0 && UnloadQueue.Count == 0) if (loadQueue.Count == 0 && unloadQueue.Count == 0)
Thread.Sleep(ScriptLoadUnloadThread_IdleSleepms); Thread.Sleep(scriptLoadUnloadThread_IdleSleepms);
if (LoadQueue.Count > 0) if (loadQueue.Count > 0)
{ {
LoadStruct item = LoadQueue.Dequeue(); LoadStruct item = loadQueue.Dequeue();
_StartScript(item.localID, item.itemID, item.Script); _StartScript(item.localID, item.itemID, item.script);
} }
if (UnloadQueue.Count > 0) if (unloadQueue.Count > 0)
{ {
UnloadStruct item = UnloadQueue.Dequeue(); UnloadStruct item = unloadQueue.Dequeue();
_StopScript(item.localID, item.itemID); _StopScript(item.localID, item.itemID);
} }
@ -232,8 +232,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
LoadStruct ls = new LoadStruct(); LoadStruct ls = new LoadStruct();
ls.localID = localID; ls.localID = localID;
ls.itemID = itemID; ls.itemID = itemID;
ls.Script = Script; ls.script = Script;
LoadQueue.Enqueue(ls); loadQueue.Enqueue(ls);
} }
/// <summary> /// <summary>
/// Disables and unloads a script /// Disables and unloads a script
@ -245,7 +245,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
UnloadStruct ls = new UnloadStruct(); UnloadStruct ls = new UnloadStruct();
ls.localID = localID; ls.localID = localID;
ls.itemID = itemID; ls.itemID = itemID;
UnloadQueue.Enqueue(ls); unloadQueue.Enqueue(ls);
} }
private void _StartScript(uint localID, LLUUID itemID, string Script) private void _StartScript(uint localID, LLUUID itemID, string Script)
@ -279,7 +279,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
before = GC.GetTotalMemory(true); before = GC.GetTotalMemory(true);
#endif #endif
LSL_BaseClass CompiledScript; LSL_BaseClass CompiledScript;
CompiledScript = m_scriptEngine.myAppDomainManager.LoadScript(FileName); CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(FileName);
#if DEBUG #if DEBUG
Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before);
#endif #endif
@ -297,7 +297,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
CompiledScript.Start(LSLB); CompiledScript.Start(LSLB);
// Fire the first start-event // Fire the first start-event
m_scriptEngine.myEventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] { }); m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] { });
} }
@ -329,7 +329,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Stop long command on script // Stop long command on script
m_scriptEngine.myLSLLongCmdHandler.RemoveScript(localID, itemID); m_scriptEngine.m_LSLLongCmdHandler.RemoveScript(localID, itemID);
LSL_BaseClass LSLBC = GetScript(localID, itemID); LSL_BaseClass LSLBC = GetScript(localID, itemID);
if (LSLBC == null) if (LSLBC == null)
@ -348,7 +348,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Remove from internal structure // Remove from internal structure
RemoveScript(localID, itemID); RemoveScript(localID, itemID);
// Tell AppDomain that we have stopped script // Tell AppDomain that we have stopped script
m_scriptEngine.myAppDomainManager.StopScript(ad); m_scriptEngine.m_AppDomainManager.StopScript(ad);
} }
catch(Exception e) catch(Exception e)
{ {
@ -375,7 +375,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Execute a function in the script // Execute a function in the script
//m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName); //m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(localID, itemID); LSL_BaseClass Script = m_scriptEngine.m_ScriptManager.GetScript(localID, itemID);
if (Script == null) if (Script == null)
return; return;

View File

@ -112,7 +112,7 @@ namespace OpenSim.GUI
proc_UserServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_UserServer_DataReceived); proc_UserServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_UserServer_DataReceived);
proc_UserServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_UserServer_DataReceived); proc_UserServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_UserServer_DataReceived);
proc_UserServer.StartProcess(); proc_UserServer.StartProcess();
System.Threading.Thread.Sleep(2000); System.Threading.Thread.Sleep(3000);
// Start GridServer // Start GridServer
proc_GridServer = new ProcessManager("OpenSim.Grid.GridServer.exe", ""); proc_GridServer = new ProcessManager("OpenSim.Grid.GridServer.exe", "");
@ -120,7 +120,7 @@ namespace OpenSim.GUI
proc_GridServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_GridServer_DataReceived); proc_GridServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_GridServer_DataReceived);
proc_GridServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_GridServer_DataReceived); proc_GridServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_GridServer_DataReceived);
proc_GridServer.StartProcess(); proc_GridServer.StartProcess();
System.Threading.Thread.Sleep(2000); System.Threading.Thread.Sleep(3000);
// Start AssetServer // Start AssetServer
proc_AssetServer = new ProcessManager("OpenSim.Grid.AssetServer.exe", ""); proc_AssetServer = new ProcessManager("OpenSim.Grid.AssetServer.exe", "");
@ -128,7 +128,7 @@ namespace OpenSim.GUI
proc_AssetServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_AssetServer_DataReceived); proc_AssetServer.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_AssetServer_DataReceived);
proc_AssetServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_AssetServer_DataReceived); proc_AssetServer.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_AssetServer_DataReceived);
proc_AssetServer.StartProcess(); proc_AssetServer.StartProcess();
System.Threading.Thread.Sleep(2000); System.Threading.Thread.Sleep(3000);
} }
// Start OpenSim // Start OpenSim