Change the scirpt engine loading mechanism. Script engines are now
ordinary region modules and are able to coexist in one instance. See http://opensimulator.org/wiki/ScriptEngines for details. There were changes to OpenSim.ini.example, please note DefaultScriptEngine. Also see the User docs and FAQ on the Wiki. Default is DotNetEngine.0.6.0-stable
parent
451bd5a0ca
commit
94aaf67dfa
|
@ -78,7 +78,6 @@ namespace OpenSim
|
||||||
|
|
||||||
public string m_physicsEngine;
|
public string m_physicsEngine;
|
||||||
public string m_meshEngineName;
|
public string m_meshEngineName;
|
||||||
public string m_scriptEngine;
|
|
||||||
public bool m_sandbox;
|
public bool m_sandbox;
|
||||||
public bool user_accounts;
|
public bool user_accounts;
|
||||||
public bool m_gridLocalAsset;
|
public bool m_gridLocalAsset;
|
||||||
|
@ -222,6 +221,8 @@ namespace OpenSim
|
||||||
config.Set("startup_console_commands_file", String.Empty);
|
config.Set("startup_console_commands_file", String.Empty);
|
||||||
config.Set("shutdown_console_commands_file", String.Empty);
|
config.Set("shutdown_console_commands_file", String.Empty);
|
||||||
config.Set("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
|
config.Set("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
|
||||||
|
config.Set("DefaultScriptEngine", "DotNetEngine");
|
||||||
|
|
||||||
config.Set("asset_database", "sqlite");
|
config.Set("asset_database", "sqlite");
|
||||||
config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
|
config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
|
||||||
}
|
}
|
||||||
|
@ -321,7 +322,6 @@ namespace OpenSim
|
||||||
= startupConfig.GetString("storage_connection_string", "URI=file:OpenSim.db,version=3");
|
= startupConfig.GetString("storage_connection_string", "URI=file:OpenSim.db,version=3");
|
||||||
m_estateConnectionString
|
m_estateConnectionString
|
||||||
= startupConfig.GetString("estate_connection_string", m_storageConnectionString);
|
= startupConfig.GetString("estate_connection_string", m_storageConnectionString);
|
||||||
m_scriptEngine = startupConfig.GetString("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
|
|
||||||
m_assetStorage = startupConfig.GetString("asset_database", "local");
|
m_assetStorage = startupConfig.GetString("asset_database", "local");
|
||||||
m_clientstackDll = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
|
m_clientstackDll = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
|
||||||
}
|
}
|
||||||
|
@ -522,31 +522,6 @@ namespace OpenSim
|
||||||
// script module can pick up events exposed by a module
|
// script module can pick up events exposed by a module
|
||||||
m_moduleLoader.InitialiseSharedModules(scene);
|
m_moduleLoader.InitialiseSharedModules(scene);
|
||||||
|
|
||||||
//m_moduleLoader.PickupModules(scene, "ScriptEngines");
|
|
||||||
//m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", m_scriptEngine), scene);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(m_scriptEngine))
|
|
||||||
{
|
|
||||||
m_log.Info("[MODULES]: No script engine module specified");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.Info("[MODULES]: Loading scripting engine modules");
|
|
||||||
foreach (string module in m_scriptEngine.Split(','))
|
|
||||||
{
|
|
||||||
string mod = module.Trim(" \t".ToCharArray()); // Clean up name
|
|
||||||
m_log.Info("[MODULES]: Loading scripting engine: " + mod);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
modules.AddRange(m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", mod), scene));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
m_log.Error("[MODULES]: Failed to load script engine: " + ex.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scene.SetModuleInterfaces();
|
scene.SetModuleInterfaces();
|
||||||
|
|
||||||
// Prims have to be loaded after module configuration since some modules may be invoked during the load
|
// Prims have to be loaded after module configuration since some modules may be invoked during the load
|
||||||
|
|
|
@ -174,7 +174,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
|
|
||||||
foreach (SceneObjectGroup sceneObject in sceneObjects)
|
foreach (SceneObjectGroup sceneObject in sceneObjects)
|
||||||
{
|
{
|
||||||
sceneObject.CreateScriptInstances(0, true);
|
sceneObject.CreateScriptInstances(0, true, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
foreach (SceneObjectGroup sceneObject in sceneObjects)
|
foreach (SceneObjectGroup sceneObject in sceneObjects)
|
||||||
{
|
{
|
||||||
sceneObject.CreateScriptInstances(0, true);
|
sceneObject.CreateScriptInstances(0, true, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
public event OnPermissionErrorDelegate OnPermissionError;
|
public event OnPermissionErrorDelegate OnPermissionError;
|
||||||
|
|
||||||
public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez);
|
public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine);
|
||||||
|
|
||||||
public event NewRezScript OnRezScript;
|
public event NewRezScript OnRezScript;
|
||||||
|
|
||||||
|
@ -519,12 +519,13 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez)
|
public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
|
||||||
{
|
{
|
||||||
handlerRezScript = OnRezScript;
|
handlerRezScript = OnRezScript;
|
||||||
if (handlerRezScript != null)
|
if (handlerRezScript != null)
|
||||||
{
|
{
|
||||||
handlerRezScript(localID, itemID, script, startParam, postOnRez);
|
handlerRezScript(localID, itemID, script, startParam,
|
||||||
|
postOnRez, engine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1604,7 +1604,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
copy.UpdateGroupRotation(rot);
|
copy.UpdateGroupRotation(rot);
|
||||||
}
|
}
|
||||||
|
|
||||||
copy.CreateScriptInstances(0, false);
|
copy.CreateScriptInstances(0, false, "");
|
||||||
copy.HasGroupChanged = true;
|
copy.HasGroupChanged = true;
|
||||||
copy.ScheduleGroupForFullUpdate();
|
copy.ScheduleGroupForFullUpdate();
|
||||||
return copy;
|
return copy;
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
if (group is SceneObjectGroup)
|
if (group is SceneObjectGroup)
|
||||||
{
|
{
|
||||||
((SceneObjectGroup) group).CreateScriptInstances(0, false);
|
((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
// Trigger rerunning of script (use TriggerRezScript event, see RezScript)
|
// Trigger rerunning of script (use TriggerRezScript event, see RezScript)
|
||||||
if (isScriptRunning)
|
if (isScriptRunning)
|
||||||
{
|
{
|
||||||
part.CreateScriptInstance(item.ItemID, 0, false);
|
// Needs to determine which engine was running it and use that
|
||||||
|
//
|
||||||
|
part.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1289,7 +1291,7 @@ System.Console.WriteLine("Item asset {0}, request asset {1}", prevItem.AssetID.T
|
||||||
|
|
||||||
part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID);
|
part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID);
|
||||||
// TODO: set this to "true" when scripts in inventory have persistent state to fire on_rez
|
// TODO: set this to "true" when scripts in inventory have persistent state to fire on_rez
|
||||||
part.CreateScriptInstance(copyID, 0, false);
|
part.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine);
|
||||||
|
|
||||||
// m_log.InfoFormat("[PRIMINVENTORY]: " +
|
// m_log.InfoFormat("[PRIMINVENTORY]: " +
|
||||||
// "Rezzed script {0} into prim local ID {1} for user {2}",
|
// "Rezzed script {0} into prim local ID {1} for user {2}",
|
||||||
|
@ -1353,7 +1355,7 @@ System.Console.WriteLine("Item asset {0}, request asset {1}", prevItem.AssetID.T
|
||||||
part.AddInventoryItem(taskItem);
|
part.AddInventoryItem(taskItem);
|
||||||
part.GetProperties(remoteClient);
|
part.GetProperties(remoteClient);
|
||||||
|
|
||||||
part.CreateScriptInstance(taskItem, 0, false);
|
part.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1449,7 +1451,7 @@ System.Console.WriteLine("Item asset {0}, request asset {1}", prevItem.AssetID.T
|
||||||
|
|
||||||
if (running > 0)
|
if (running > 0)
|
||||||
{
|
{
|
||||||
destPart.CreateScriptInstance(destTaskItem, 0, false);
|
destPart.CreateScriptInstance(destTaskItem, 0, false, DefaultScriptEngine);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScenePresence avatar;
|
ScenePresence avatar;
|
||||||
|
@ -2037,7 +2039,7 @@ System.Console.WriteLine("Item asset {0}, request asset {1}", prevItem.AssetID.T
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make this true to fire on_rez when scripts have state while in inventory
|
// TODO: make this true to fire on_rez when scripts have state while in inventory
|
||||||
group.CreateScriptInstances(0, false);
|
group.CreateScriptInstances(0, false, DefaultScriptEngine);
|
||||||
|
|
||||||
if (!attachment)
|
if (!attachment)
|
||||||
rootPart.ScheduleFullUpdate();
|
rootPart.ScheduleFullUpdate();
|
||||||
|
@ -2141,7 +2143,7 @@ System.Console.WriteLine("Item asset {0}, request asset {1}", prevItem.AssetID.T
|
||||||
group.UpdateGroupRotation(rot);
|
group.UpdateGroupRotation(rot);
|
||||||
//group.ApplyPhysics(m_physicalPrim);
|
//group.ApplyPhysics(m_physicalPrim);
|
||||||
group.Velocity = vel;
|
group.Velocity = vel;
|
||||||
group.CreateScriptInstances(param, true);
|
group.CreateScriptInstances(param, true, DefaultScriptEngine);
|
||||||
rootPart.ScheduleFullUpdate();
|
rootPart.ScheduleFullUpdate();
|
||||||
|
|
||||||
if (!ExternalChecks.ExternalChecksBypassPermissions())
|
if (!ExternalChecks.ExternalChecksBypassPermissions())
|
||||||
|
|
|
@ -166,6 +166,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
private bool m_physics_enabled = true;
|
private bool m_physics_enabled = true;
|
||||||
private bool m_scripts_enabled = true;
|
private bool m_scripts_enabled = true;
|
||||||
|
private string m_defaultScriptEngine;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -199,6 +200,11 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
get { return m_timePhase; }
|
get { return m_timePhase; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string DefaultScriptEngine
|
||||||
|
{
|
||||||
|
get { return m_defaultScriptEngine; }
|
||||||
|
}
|
||||||
|
|
||||||
// Local reference to the objects in the scene (which are held in innerScene)
|
// Local reference to the objects in the scene (which are held in innerScene)
|
||||||
// public Dictionary<UUID, SceneObjectGroup> Objects
|
// public Dictionary<UUID, SceneObjectGroup> Objects
|
||||||
// {
|
// {
|
||||||
|
@ -314,6 +320,8 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
IConfig startupConfig = m_config.Configs["Startup"];
|
IConfig startupConfig = m_config.Configs["Startup"];
|
||||||
m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", 65536.0f);
|
m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", 65536.0f);
|
||||||
m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", 10.0f);
|
m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", 10.0f);
|
||||||
|
|
||||||
|
m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "DotNetEngine");
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
@ -574,7 +582,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
if (ent is SceneObjectGroup)
|
if (ent is SceneObjectGroup)
|
||||||
{
|
{
|
||||||
((SceneObjectGroup)ent).CreateScriptInstances(0, false);
|
((SceneObjectGroup)ent).CreateScriptInstances(0, false, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,14 +55,15 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start the scripts contained in all the prims in this group.
|
/// Start the scripts contained in all the prims in this group.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CreateScriptInstances(int startParam, bool postOnRez)
|
public void CreateScriptInstances(int startParam, bool postOnRez,
|
||||||
|
string engine)
|
||||||
{
|
{
|
||||||
// Don't start scripts if they're turned off in the region!
|
// Don't start scripts if they're turned off in the region!
|
||||||
if (!m_scene.RegionInfo.RegionSettings.DisableScripts)
|
if (!m_scene.RegionInfo.RegionSettings.DisableScripts)
|
||||||
{
|
{
|
||||||
foreach (SceneObjectPart part in m_parts.Values)
|
foreach (SceneObjectPart part in m_parts.Values)
|
||||||
{
|
{
|
||||||
part.CreateScriptInstances(startParam, postOnRez);
|
part.CreateScriptInstances(startParam, postOnRez, engine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start all the scripts contained in this prim's inventory
|
/// Start all the scripts contained in this prim's inventory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CreateScriptInstances(int startParam, bool postOnRez)
|
public void CreateScriptInstances(int startParam, bool postOnRez, string engine)
|
||||||
{
|
{
|
||||||
lock (m_taskInventory)
|
lock (m_taskInventory)
|
||||||
{
|
{
|
||||||
|
@ -133,7 +133,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
if ((int)InventoryType.LSL == item.InvType)
|
if ((int)InventoryType.LSL == item.InvType)
|
||||||
{
|
{
|
||||||
CreateScriptInstance(item, startParam, postOnRez);
|
CreateScriptInstance(item, startParam, postOnRez, engine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez)
|
public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine)
|
||||||
{
|
{
|
||||||
// m_log.InfoFormat(
|
// m_log.InfoFormat(
|
||||||
// "[PRIM INVENTORY]: " +
|
// "[PRIM INVENTORY]: " +
|
||||||
|
@ -193,7 +193,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
m_taskInventory[item.ItemID].PermsGranter = UUID.Zero;
|
m_taskInventory[item.ItemID].PermsGranter = UUID.Zero;
|
||||||
string script = Utils.BytesToString(asset.Data);
|
string script = Utils.BytesToString(asset.Data);
|
||||||
m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId, item.ItemID, script,
|
m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId, item.ItemID, script,
|
||||||
startParam, postOnRez);
|
startParam, postOnRez, engine);
|
||||||
m_parentGroup.AddActiveScriptCount(1);
|
m_parentGroup.AddActiveScriptCount(1);
|
||||||
ScheduleFullUpdate();
|
ScheduleFullUpdate();
|
||||||
}
|
}
|
||||||
|
@ -207,13 +207,13 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <param name="itemId">
|
/// <param name="itemId">
|
||||||
/// A <see cref="UUID"/>
|
/// A <see cref="UUID"/>
|
||||||
/// </param>
|
/// </param>
|
||||||
public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez)
|
public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine)
|
||||||
{
|
{
|
||||||
lock (m_taskInventory)
|
lock (m_taskInventory)
|
||||||
{
|
{
|
||||||
if (m_taskInventory.ContainsKey(itemId))
|
if (m_taskInventory.ContainsKey(itemId))
|
||||||
{
|
{
|
||||||
CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez);
|
CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez, engine);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,14 +65,20 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
myScriptEngine = _ScriptEngine;
|
myScriptEngine = _ScriptEngine;
|
||||||
ReadConfig();
|
ReadConfig();
|
||||||
|
|
||||||
// Hook up to events from OpenSim
|
|
||||||
// We may not want to do it because someone is controlling us and will deliver events to us
|
|
||||||
if (performHookUp)
|
if (performHookUp)
|
||||||
{
|
{
|
||||||
|
myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HookUpEvents()
|
||||||
|
{
|
||||||
|
// Hook up to events from OpenSim
|
||||||
|
// We may not want to do it because someone is controlling us and will deliver events to us
|
||||||
|
|
||||||
myScriptEngine.Log.Info("[" + myScriptEngine.ScriptEngineName + "]: Hooking up to server events");
|
myScriptEngine.Log.Info("[" + myScriptEngine.ScriptEngineName + "]: Hooking up to server events");
|
||||||
myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
|
myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
|
||||||
myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end;
|
myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end;
|
||||||
myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
|
|
||||||
myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
|
myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
|
||||||
myScriptEngine.World.EventManager.OnScriptChangedEvent += changed;
|
myScriptEngine.World.EventManager.OnScriptChangedEvent += changed;
|
||||||
myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target;
|
myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target;
|
||||||
|
@ -90,7 +96,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void ReadConfig()
|
public void ReadConfig()
|
||||||
{
|
{
|
||||||
|
@ -187,8 +192,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) });
|
myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez)
|
public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
|
||||||
{
|
{
|
||||||
|
if (engine != "DotNetEngine")
|
||||||
|
return;
|
||||||
|
|
||||||
myScriptEngine.Log.Debug("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +
|
myScriptEngine.Log.Debug("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +
|
||||||
script.Length);
|
script.Length);
|
||||||
myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script, startParam, postOnRez);
|
myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script, startParam, postOnRez);
|
||||||
|
|
|
@ -353,6 +353,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
/// <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, UUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
|
public void AddToScriptQueue(uint localID, UUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
|
||||||
{
|
{
|
||||||
|
List<UUID> keylist = new List<UUID>(m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID));
|
||||||
|
|
||||||
|
if (!keylist.Contains(itemID)) // We don't manage that script
|
||||||
|
return;
|
||||||
|
|
||||||
lock (eventQueue)
|
lock (eventQueue)
|
||||||
{
|
{
|
||||||
if (eventQueue.Count >= EventExecutionMaxQueueSize)
|
if (eventQueue.Count >= EventExecutionMaxQueueSize)
|
||||||
|
|
|
@ -56,6 +56,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
public IConfigSource ConfigSource;
|
public IConfigSource ConfigSource;
|
||||||
public IConfig ScriptConfigSource;
|
public IConfig ScriptConfigSource;
|
||||||
public abstract string ScriptEngineName { get; }
|
public abstract string ScriptEngineName { get; }
|
||||||
|
private bool m_enabled = true;
|
||||||
|
private bool m_hookUpToServer = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How many seconds between re-reading config-file. 0 = never. ScriptEngine will try to adjust to new config changes.
|
/// How many seconds between re-reading config-file. 0 = never. ScriptEngine will try to adjust to new config changes.
|
||||||
|
@ -91,6 +93,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
{
|
{
|
||||||
World = Sceneworld;
|
World = Sceneworld;
|
||||||
ConfigSource = config;
|
ConfigSource = config;
|
||||||
|
m_hookUpToServer = HookUpToServer;
|
||||||
|
|
||||||
m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing");
|
m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing");
|
||||||
|
|
||||||
// Make sure we have config
|
// Make sure we have config
|
||||||
|
@ -98,13 +102,16 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
ConfigSource.AddConfig(ScriptEngineName);
|
ConfigSource.AddConfig(ScriptEngineName);
|
||||||
ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
|
ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
|
||||||
|
|
||||||
|
m_enabled = ScriptConfigSource.GetBoolean("Enabled", true);
|
||||||
|
if (!m_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
//m_log.Info("[" + ScriptEngineName + "]: InitializeEngine");
|
//m_log.Info("[" + ScriptEngineName + "]: InitializeEngine");
|
||||||
|
|
||||||
// Create all objects we'll be using
|
// Create all objects we'll be using
|
||||||
m_EventQueueManager = new EventQueueManager(this);
|
m_EventQueueManager = new EventQueueManager(this);
|
||||||
m_EventManager = new EventManager(this, HookUpToServer);
|
m_EventManager = new EventManager(this, HookUpToServer);
|
||||||
// We need to start it
|
// We need to start it
|
||||||
newScriptManager.Start();
|
|
||||||
m_ScriptManager = newScriptManager;
|
m_ScriptManager = newScriptManager;
|
||||||
m_AppDomainManager = new AppDomainManager(this);
|
m_AppDomainManager = new AppDomainManager(this);
|
||||||
m_ASYNCLSLCommandManager = new AsyncCommandManager(this);
|
m_ASYNCLSLCommandManager = new AsyncCommandManager(this);
|
||||||
|
@ -118,6 +125,17 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
// 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?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PostInitialise()
|
||||||
|
{
|
||||||
|
if (!m_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_hookUpToServer)
|
||||||
|
m_EventManager.HookUpEvents();
|
||||||
|
|
||||||
|
m_ScriptManager.Start();
|
||||||
|
}
|
||||||
|
|
||||||
public void Shutdown()
|
public void Shutdown()
|
||||||
{
|
{
|
||||||
// We are shutting down
|
// We are shutting down
|
||||||
|
@ -155,10 +173,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
|
|
||||||
public abstract void Initialise(Scene scene, IConfigSource config);
|
public abstract void Initialise(Scene scene, IConfigSource config);
|
||||||
|
|
||||||
public void PostInitialise()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
private static bool PrivateThread;
|
private static bool PrivateThread;
|
||||||
private int LoadUnloadMaxQueueSize;
|
private int LoadUnloadMaxQueueSize;
|
||||||
private Object scriptLock = new Object();
|
private Object scriptLock = new Object();
|
||||||
|
private bool m_started = false;
|
||||||
|
|
||||||
// Load/Unload structure
|
// Load/Unload structure
|
||||||
private struct LUStruct
|
private struct LUStruct
|
||||||
|
@ -119,6 +120,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
public abstract void Initialize();
|
public abstract void Initialize();
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
|
m_started = true;
|
||||||
|
|
||||||
ReadConfig();
|
ReadConfig();
|
||||||
Initialize();
|
Initialize();
|
||||||
|
|
||||||
|
@ -213,6 +216,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
|
|
||||||
public void DoScriptLoadUnload()
|
public void DoScriptLoadUnload()
|
||||||
{
|
{
|
||||||
|
if (!m_started)
|
||||||
|
return;
|
||||||
|
|
||||||
lock (LUQueue)
|
lock (LUQueue)
|
||||||
{
|
{
|
||||||
if (LUQueue.Count > 0)
|
if (LUQueue.Count > 0)
|
||||||
|
@ -258,7 +264,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
{
|
{
|
||||||
lock (LUQueue)
|
lock (LUQueue)
|
||||||
{
|
{
|
||||||
if (LUQueue.Count >= LoadUnloadMaxQueueSize)
|
if ((LUQueue.Count >= LoadUnloadMaxQueueSize) && m_started)
|
||||||
{
|
{
|
||||||
m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: ERROR: Load/unload queue item count is at " + LUQueue.Count + ". Config variable \"LoadUnloadMaxQueueSize\" is set to " + LoadUnloadMaxQueueSize + ", so ignoring new script.");
|
m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: ERROR: Load/unload queue item count is at " + LUQueue.Count + ". Config variable \"LoadUnloadMaxQueueSize\" is set to " + LoadUnloadMaxQueueSize + ", so ignoring new script.");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||||
public interface RemoteEvents
|
public interface RemoteEvents
|
||||||
{
|
{
|
||||||
void touch_start(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient);
|
void touch_start(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient);
|
||||||
void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez);
|
void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine);
|
||||||
void OnRemoveScript(uint localID, UUID itemID);
|
void OnRemoveScript(uint localID, UUID itemID);
|
||||||
void state_exit(uint localID);
|
void state_exit(uint localID);
|
||||||
void touch(uint localID, uint originalID, UUID itemID);
|
void touch(uint localID, uint originalID, UUID itemID);
|
||||||
|
|
|
@ -82,7 +82,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||||
|
|
||||||
// private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files
|
// private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files
|
||||||
private static UInt64 scriptCompileCounter = 0; // And a counter
|
private static UInt64 scriptCompileCounter = 0; // And a counter
|
||||||
private bool m_UseCompiler = true;
|
|
||||||
|
|
||||||
public IScriptEngine m_scriptEngine;
|
public IScriptEngine m_scriptEngine;
|
||||||
public Compiler(IScriptEngine scriptEngine)
|
public Compiler(IScriptEngine scriptEngine)
|
||||||
|
@ -93,8 +92,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||||
public bool in_startup = true;
|
public bool in_startup = true;
|
||||||
public void ReadConfig()
|
public void ReadConfig()
|
||||||
{
|
{
|
||||||
m_UseCompiler = m_scriptEngine.Config.GetBoolean("UseNewCompiler", true);
|
|
||||||
|
|
||||||
// Get some config
|
// Get some config
|
||||||
WriteScriptSourceToDebugFile = m_scriptEngine.Config.GetBoolean("WriteScriptSourceToDebugFile", true);
|
WriteScriptSourceToDebugFile = m_scriptEngine.Config.GetBoolean("WriteScriptSourceToDebugFile", true);
|
||||||
CompileWithDebugInformation = m_scriptEngine.Config.GetBoolean("CompileWithDebugInformation", true);
|
CompileWithDebugInformation = m_scriptEngine.Config.GetBoolean("CompileWithDebugInformation", true);
|
||||||
|
@ -327,13 +324,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||||
{
|
{
|
||||||
// Its LSL, convert it to C#
|
// Its LSL, convert it to C#
|
||||||
//compileScript = LSL_Converter.Convert(Script);
|
//compileScript = LSL_Converter.Convert(Script);
|
||||||
if (m_UseCompiler)
|
|
||||||
LSL_Converter = (ICodeConverter)new CSCodeGenerator();
|
LSL_Converter = (ICodeConverter)new CSCodeGenerator();
|
||||||
else
|
|
||||||
LSL_Converter = (ICodeConverter)new LSL2CSConverter();
|
|
||||||
compileScript = LSL_Converter.Convert(Script);
|
compileScript = LSL_Converter.Convert(Script);
|
||||||
|
|
||||||
if (m_UseCompiler)
|
|
||||||
m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap;
|
m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap;
|
||||||
|
|
||||||
l = enumCompileType.cs;
|
l = enumCompileType.cs;
|
||||||
|
@ -549,8 +542,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||||
severity = "Warning";
|
severity = "Warning";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_UseCompiler)
|
|
||||||
{
|
|
||||||
KeyValuePair<int, int> lslPos;
|
KeyValuePair<int, int> lslPos;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -566,14 +557,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||||
// The Second Life viewer's script editor begins
|
// The Second Life viewer's script editor begins
|
||||||
// countingn lines and columns at 0, so we subtract 1.
|
// countingn lines and columns at 0, so we subtract 1.
|
||||||
errtext += String.Format("Line {0}, column {1}, {4} Number: {2}, '{3}'\r\n", lslPos.Key - 1, lslPos.Value - 1, CompErr.ErrorNumber, CompErr.ErrorText, severity);
|
errtext += String.Format("Line {0}, column {1}, {4} Number: {2}, '{3}'\r\n", lslPos.Key - 1, lslPos.Value - 1, CompErr.ErrorNumber, CompErr.ErrorText, severity);
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) +
|
|
||||||
", " + severity + " Number: " + CompErr.ErrorNumber +
|
|
||||||
", '" + CompErr.ErrorText + "'\r\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("[COMPILER MESSAGES]: " + errtext);
|
Console.WriteLine("[COMPILER MESSAGES]: " + errtext);
|
||||||
|
|
|
@ -1,374 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSim Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|
||||||
{
|
|
||||||
public class LSL2CSConverter : ICodeConverter
|
|
||||||
{
|
|
||||||
// Uses regex to convert LSL code to C# code.
|
|
||||||
|
|
||||||
//private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled);
|
|
||||||
private Dictionary<string, string> dataTypes = new Dictionary<string, string>();
|
|
||||||
private Dictionary<string, string> quotes = new Dictionary<string, string>();
|
|
||||||
// c Style
|
|
||||||
private Regex cstylecomments = new Regex(@"/\*(.|[\r\n])*?\*/", RegexOptions.Compiled | RegexOptions.Multiline);
|
|
||||||
// c# one liners
|
|
||||||
private Regex nonCommentFwsl = new Regex("\"[a-zA-Z0-9.,:/\\n ]+//[^\"+]+([\\\\\\\"+]+)?(\\s+)?[\"+](\\s+)?(;)?", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
private Regex conelinecomments = new Regex(@"[^:].?([\/]{2}[^\n]*)|([\n]{1,}[\/]{2}[^\n]*)", RegexOptions.Compiled | RegexOptions.Multiline);
|
|
||||||
// ([^\"])((?:[a-zA-Z])\.[a-zA-Z].?)([^\"])
|
|
||||||
|
|
||||||
// value we're looking for: (?:[a-zA-Z])\.[a-zA-Z]
|
|
||||||
public LSL2CSConverter()
|
|
||||||
{
|
|
||||||
// Only the types we need to convert
|
|
||||||
dataTypes.Add("void", "void");
|
|
||||||
dataTypes.Add("integer", "LSL_Types.LSLInteger");
|
|
||||||
dataTypes.Add("float", "LSL_Types.LSLFloat");
|
|
||||||
dataTypes.Add("string", "LSL_Types.LSLString");
|
|
||||||
dataTypes.Add("key", "LSL_Types.LSLString");
|
|
||||||
dataTypes.Add("vector", "LSL_Types.Vector3");
|
|
||||||
dataTypes.Add("rotation", "LSL_Types.Quaternion");
|
|
||||||
dataTypes.Add("list", "LSL_Types.list");
|
|
||||||
dataTypes.Add("null", "null");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Convert(string Script)
|
|
||||||
{
|
|
||||||
quotes.Clear();
|
|
||||||
string Return = String.Empty;
|
|
||||||
Script = " \r\n" + Script;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Prepare script for processing
|
|
||||||
//
|
|
||||||
|
|
||||||
// Clean up linebreaks
|
|
||||||
Script = Regex.Replace(Script, @"\r\n", "\n");
|
|
||||||
Script = Regex.Replace(Script, @"\n", "\r\n");
|
|
||||||
|
|
||||||
// QUOTE REPLACEMENT
|
|
||||||
// temporarily replace quotes so we can work our magic on the script without
|
|
||||||
// always considering if we are inside our outside quotes's
|
|
||||||
// TODO: Does this work on half-quotes in strings? ;)
|
|
||||||
string _Script = String.Empty;
|
|
||||||
string C;
|
|
||||||
bool in_quote = false;
|
|
||||||
bool quote_replaced = false;
|
|
||||||
string quote_replacement_string = "Q_U_O_T_E_REPLACEMENT_";
|
|
||||||
string quote = String.Empty;
|
|
||||||
bool last_was_escape = false;
|
|
||||||
int quote_replaced_count = 0;
|
|
||||||
|
|
||||||
string removefwnoncomments = nonCommentFwsl.Replace(Script, "\"\";");
|
|
||||||
|
|
||||||
string removecomments = conelinecomments.Replace(removefwnoncomments, "");
|
|
||||||
removecomments = cstylecomments.Replace(removecomments, "");
|
|
||||||
string[] localscript = removecomments.Split('"');
|
|
||||||
string checkscript = String.Empty;
|
|
||||||
bool flip = true;
|
|
||||||
|
|
||||||
for (int p = 0; p < localscript.Length; p++)
|
|
||||||
{
|
|
||||||
//if (localscript[p].Length >= 1)
|
|
||||||
//{
|
|
||||||
if (!localscript[p].EndsWith(@"\"))
|
|
||||||
{
|
|
||||||
flip = !flip;
|
|
||||||
//System.Console.WriteLine("Flip:" + flip.ToString() + " - " + localscript[p] + " ! " + localscript[p].EndsWith(@"\").ToString());
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// flip = !flip;
|
|
||||||
// System.Console.WriteLine("Flip:" + flip.ToString() + " - " + localscript[p]);
|
|
||||||
//}
|
|
||||||
if (!flip)
|
|
||||||
checkscript += localscript[p];
|
|
||||||
}
|
|
||||||
|
|
||||||
//System.Console.WriteLine("SCRIPT:" + checkscript);
|
|
||||||
|
|
||||||
// checks for alpha.alpha way of referring to objects in C#
|
|
||||||
// ignores alpha.X alpha.Y, alpha.Z for refering to vector components
|
|
||||||
Match SecurityM;
|
|
||||||
|
|
||||||
// BROKEN: this check is very wrong. It block's any url in strings.
|
|
||||||
SecurityM = Regex.Match(checkscript, @"(?:[a-zA-Z])\.(?:[a-rt-wA-Z]|[a-zA-Z][a-zA-Z])", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
|
|
||||||
if (SecurityM.Success)
|
|
||||||
throw new Exception("CS0103: 'The . symbol cannot be used in LSL except in float values or vector components'. Detected around: " + SecurityM.Captures[0].Value);
|
|
||||||
|
|
||||||
SecurityM = Regex.Match(checkscript, @"typeof\s", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
if (SecurityM.Success)
|
|
||||||
throw new Exception("CS0103: 'The object.typeof method isn't allowed in LSL'");
|
|
||||||
|
|
||||||
SecurityM = Regex.Match(checkscript, @"GetType\(", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
if (SecurityM.Success)
|
|
||||||
throw new Exception("CS0103: 'The object.GetType method isn't allowed in LSL'");
|
|
||||||
|
|
||||||
for (int p = 0; p < Script.Length; p++)
|
|
||||||
{
|
|
||||||
C = Script.Substring(p, 1);
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
// found " and last was not \ so this is not an escaped \"
|
|
||||||
if (C == "\"" && last_was_escape == false)
|
|
||||||
{
|
|
||||||
// Toggle inside/outside quote
|
|
||||||
in_quote = !in_quote;
|
|
||||||
if (in_quote)
|
|
||||||
{
|
|
||||||
quote_replaced_count++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (quote == String.Empty)
|
|
||||||
{
|
|
||||||
// We didn't replace quote, probably because of empty string?
|
|
||||||
_Script += quote_replacement_string +
|
|
||||||
quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]);
|
|
||||||
}
|
|
||||||
// We just left a quote
|
|
||||||
quotes.Add(
|
|
||||||
quote_replacement_string +
|
|
||||||
quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote);
|
|
||||||
quote = String.Empty;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!in_quote)
|
|
||||||
{
|
|
||||||
// We are not inside a quote
|
|
||||||
quote_replaced = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// We are inside a quote
|
|
||||||
if (!quote_replaced)
|
|
||||||
{
|
|
||||||
// Replace quote
|
|
||||||
_Script += quote_replacement_string +
|
|
||||||
quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]);
|
|
||||||
quote_replaced = true;
|
|
||||||
}
|
|
||||||
quote += C;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
_Script += C;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
last_was_escape = false;
|
|
||||||
if (C == @"\")
|
|
||||||
{
|
|
||||||
last_was_escape = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Script = _Script;
|
|
||||||
//
|
|
||||||
// END OF QUOTE REPLACEMENT
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// PROCESS STATES
|
|
||||||
// Remove state definitions and add state names to start of each event within state
|
|
||||||
//
|
|
||||||
int ilevel = 0;
|
|
||||||
int lastlevel = 0;
|
|
||||||
string ret = String.Empty;
|
|
||||||
string cache = String.Empty;
|
|
||||||
bool in_state = false;
|
|
||||||
string current_statename = String.Empty;
|
|
||||||
for (int p = 0; p < Script.Length; p++)
|
|
||||||
{
|
|
||||||
C = Script.Substring(p, 1);
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
// inc / dec level
|
|
||||||
if (C == @"{")
|
|
||||||
ilevel++;
|
|
||||||
if (C == @"}")
|
|
||||||
ilevel--;
|
|
||||||
if (ilevel < 0)
|
|
||||||
ilevel = 0;
|
|
||||||
cache += C;
|
|
||||||
|
|
||||||
// if level == 0, add to return
|
|
||||||
if (ilevel == 1 && lastlevel == 0)
|
|
||||||
{
|
|
||||||
// 0 => 1: Get last
|
|
||||||
Match m =
|
|
||||||
//Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{",
|
|
||||||
Regex.Match(cache, @"(?![a-zA-Z_]+)\s*(state\s+)?(?<statename>[a-zA-Z_][a-zA-Z_0-9]*)[^a-zA-Z_0-9\(\)]*{",
|
|
||||||
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
|
|
||||||
in_state = false;
|
|
||||||
if (m.Success)
|
|
||||||
{
|
|
||||||
// Go back to level 0, this is not a state
|
|
||||||
in_state = true;
|
|
||||||
current_statename = m.Groups["statename"].Captures[0].Value;
|
|
||||||
//Console.WriteLine("Current statename: " + current_statename);
|
|
||||||
cache =
|
|
||||||
//@"(?<s1>(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?<s2>[^a-zA-Z_\(\)]*){",
|
|
||||||
Regex.Replace(cache,
|
|
||||||
@"(?<s1>(?![a-zA-Z_]+)\s*)" + @"(state\s+)?([a-zA-Z_][a-zA-Z_0-9]*)(?<s2>[^a-zA-Z_0-9\(\)]*){",
|
|
||||||
"${s1}${s2}",
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
|
|
||||||
}
|
|
||||||
ret += cache;
|
|
||||||
cache = String.Empty;
|
|
||||||
}
|
|
||||||
if (ilevel == 0 && lastlevel == 1)
|
|
||||||
{
|
|
||||||
// 1 => 0: Remove last }
|
|
||||||
if (in_state == true)
|
|
||||||
{
|
|
||||||
cache = cache.Remove(cache.Length - 1, 1);
|
|
||||||
//cache = Regex.Replace(cache, "}$", String.Empty, RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
|
|
||||||
//Replace function names
|
|
||||||
// void dataserver(key query_id, string data) {
|
|
||||||
//cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "<STATE>" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
//Console.WriteLine("Replacing using statename: " + current_statename);
|
|
||||||
cache =
|
|
||||||
Regex.Replace(cache,
|
|
||||||
@"^(\s*)((?!(if|switch|for|while)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)",
|
|
||||||
@"$1public " + current_statename + "_event_$2",
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret += cache;
|
|
||||||
cache = String.Empty;
|
|
||||||
in_state = true;
|
|
||||||
current_statename = String.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
lastlevel = ilevel;
|
|
||||||
}
|
|
||||||
ret += cache;
|
|
||||||
cache = String.Empty;
|
|
||||||
|
|
||||||
Script = ret;
|
|
||||||
ret = String.Empty;
|
|
||||||
|
|
||||||
foreach (string key in dataTypes.Keys)
|
|
||||||
{
|
|
||||||
string val;
|
|
||||||
dataTypes.TryGetValue(key, out val);
|
|
||||||
|
|
||||||
// Replace CAST - (integer) with (int)
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script, @"\(" + key + @"\)", @"(" + val + ")",
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline);
|
|
||||||
// Replace return types and function variables - integer a() and f(integer a, integer a)
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s+)", @"$1$2" + val + "$3",
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline);
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s*)[,]", @"$1$2" + val + "$3,",
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change jumps into goto's and prefix its label
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script,
|
|
||||||
@"(\W)jump\s+([a-zA-Z_][a-zA-Z_0-9]*)\s*;",
|
|
||||||
@"$1goto label_$2;", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
// and prefix labels so the do not clash with C#'s reserved words
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script,
|
|
||||||
@"@([a-zA-Z_][a-zA-Z_0-9]*)\s*;",
|
|
||||||
@"label_$1: ;", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
|
|
||||||
// Add "void" in front of functions that needs it
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script,
|
|
||||||
@"^(\s*public\s+)?((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)",
|
|
||||||
@"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
|
|
||||||
// Replace <x,y,z> and <x,y,z,r>
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script, @"<([^,>;]*,[^,>;]*,[^,>;]*,[^,>;]*)>", @"new LSL_Types.Quaternion($1)",
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script, @"<([^,>;)]*,[^,>;]*,[^,>;]*)>", @"new LSL_Types.Vector3($1)",
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
|
|
||||||
// Replace List []'s
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script, @"\[([^\]]*)\]", @"new LSL_Types.list($1)",
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
|
|
||||||
// Replace (string) to .ToString() //
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.ToString()",
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.Parse($2)",
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
|
||||||
|
|
||||||
// Replace "state STATENAME" with "state("statename")"
|
|
||||||
Script =
|
|
||||||
Regex.Replace(Script, @"(state)\s+([^;\n\r]+)(;[\r\n\s])", "$1(\"$2\")$3",
|
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
|
|
||||||
|
|
||||||
// REPLACE BACK QUOTES
|
|
||||||
foreach (string key in quotes.Keys)
|
|
||||||
{
|
|
||||||
string val;
|
|
||||||
quotes.TryGetValue(key, out val);
|
|
||||||
Script = Script.Replace(key, "\"" + val + "\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
//System.Console.WriteLine(Script);
|
|
||||||
Return = String.Empty;// +
|
|
||||||
//"using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;";
|
|
||||||
|
|
||||||
//Return += String.Empty +
|
|
||||||
// "namespace SecondLife { ";
|
|
||||||
//Return += String.Empty +
|
|
||||||
// //"[Serializable] " +
|
|
||||||
// "public class Script : OpenSim.Region.ScriptEngine.Shared.LSL_BaseClass { ";
|
|
||||||
//Return += @"public Script() { } ";
|
|
||||||
Return += Script;
|
|
||||||
//Return += "} }\r\n";
|
|
||||||
|
|
||||||
quotes.Clear();
|
|
||||||
|
|
||||||
return Return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -67,6 +67,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
private int m_SleepTime;
|
private int m_SleepTime;
|
||||||
private int m_SaveTime;
|
private int m_SaveTime;
|
||||||
private ThreadPriority m_Prio;
|
private ThreadPriority m_Prio;
|
||||||
|
private bool m_Enabled = true;
|
||||||
|
|
||||||
// disable warning: need to keep a reference to XEngine.EventManager
|
// disable warning: need to keep a reference to XEngine.EventManager
|
||||||
// alive to avoid it being garbage collected
|
// alive to avoid it being garbage collected
|
||||||
|
@ -151,6 +152,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
//
|
//
|
||||||
public void Initialise(Scene scene, IConfigSource configSource)
|
public void Initialise(Scene scene, IConfigSource configSource)
|
||||||
{
|
{
|
||||||
|
m_ScriptConfig = configSource.Configs["XEngine"];
|
||||||
|
|
||||||
|
if (m_ScriptConfig == null)
|
||||||
|
{
|
||||||
|
// m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Enabled = m_ScriptConfig.GetBoolean("Enabled", true);
|
||||||
|
|
||||||
|
if (!m_Enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
AppDomain.CurrentDomain.AssemblyResolve +=
|
AppDomain.CurrentDomain.AssemblyResolve +=
|
||||||
OnAssemblyResolve;
|
OnAssemblyResolve;
|
||||||
|
|
||||||
|
@ -158,14 +172,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
scene.RegionInfo.RegionName);
|
scene.RegionInfo.RegionName);
|
||||||
m_Scene = scene;
|
m_Scene = scene;
|
||||||
|
|
||||||
m_ScriptConfig = configSource.Configs["XEngine"];
|
|
||||||
|
|
||||||
if (m_ScriptConfig == null)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_MinThreads = m_ScriptConfig.GetInt("MinThreads", 2);
|
m_MinThreads = m_ScriptConfig.GetInt("MinThreads", 2);
|
||||||
m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100);
|
m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100);
|
||||||
m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60);
|
m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60);
|
||||||
|
@ -220,6 +226,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
|
|
||||||
public void PostInitialise()
|
public void PostInitialise()
|
||||||
{
|
{
|
||||||
|
if (!m_Enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
m_EventManager = new EventManager(this);
|
m_EventManager = new EventManager(this);
|
||||||
|
|
||||||
m_Compiler = new Compiler(this);
|
m_Compiler = new Compiler(this);
|
||||||
|
@ -330,8 +339,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
get { return false; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez)
|
public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
|
||||||
{
|
{
|
||||||
|
if (engine != "XEngine")
|
||||||
|
return;
|
||||||
|
|
||||||
Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez};
|
Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez};
|
||||||
|
|
||||||
lock (m_CompileQueue)
|
lock (m_CompileQueue)
|
||||||
|
|
|
@ -107,22 +107,8 @@ physical_prim = true
|
||||||
; ## ScriptEngine
|
; ## ScriptEngine
|
||||||
; ##
|
; ##
|
||||||
|
|
||||||
; These are region modules loaded into each region to provide script support
|
DefaultScriptEngine = "DotNetEngine"
|
||||||
; Scripts may be everything from LSL or C# scripts put in prims to whole game systems that controls the whole grid.
|
;DefaultScriptEngine = "XEngine"
|
||||||
; You can load multiple modules by separating them with a coma.
|
|
||||||
;
|
|
||||||
; Example:
|
|
||||||
;script_engine = OpenSim.Region.ScriptEngine.DotNetEngine.dll,OpenSim.Region.ScriptEngine.RemoteServer.dll
|
|
||||||
;
|
|
||||||
; This is the current ScriptEngine:
|
|
||||||
script_engine = "OpenSim.Region.ScriptEngine.DotNetEngine.dll"
|
|
||||||
|
|
||||||
; This is the new XEngine
|
|
||||||
;script_engine = "OpenSim.Region.ScriptEngine.XEngine.dll"
|
|
||||||
|
|
||||||
;Experimental remote ScriptServer plugin (does not currently work):
|
|
||||||
;script_engine = "OpenSim.Region.ScriptEngine.RemoteServer.dll"
|
|
||||||
|
|
||||||
|
|
||||||
[StandAlone]
|
[StandAlone]
|
||||||
accounts_authenticate = true
|
accounts_authenticate = true
|
||||||
|
@ -447,6 +433,7 @@ asterisk_salt = paluempalum
|
||||||
|
|
||||||
|
|
||||||
[ScriptEngine.DotNetEngine]
|
[ScriptEngine.DotNetEngine]
|
||||||
|
Enabled = true
|
||||||
;
|
;
|
||||||
; These settings are specific to DotNetEngine script engine
|
; These settings are specific to DotNetEngine script engine
|
||||||
; Other script engines based on OpenSim.Region.ScriptEngine.Common.dll will have almost identical settings, but in another section of this config file.
|
; Other script engines based on OpenSim.Region.ScriptEngine.Common.dll will have almost identical settings, but in another section of this config file.
|
||||||
|
@ -651,8 +638,8 @@ AutoSavePeriod = 15 ; Number of minutes between autosave backups
|
||||||
|
|
||||||
|
|
||||||
[XEngine]
|
[XEngine]
|
||||||
; Use the newer LSL to CS compiler (under test)
|
; Enable this engine in this OpenSim instance
|
||||||
UseNewCompiler = true
|
Enabled = true
|
||||||
; How many threads to keep alive even if nothing is happening
|
; How many threads to keep alive even if nothing is happening
|
||||||
MinThreads = 2
|
MinThreads = 2
|
||||||
; How many threads to start at maximum load
|
; How many threads to start at maximum load
|
||||||
|
|
10
prebuild.xml
10
prebuild.xml
|
@ -1847,12 +1847,12 @@
|
||||||
<Project name="OpenSim.Region.ScriptEngine.XEngine" path="OpenSim/Region/ScriptEngine/XEngine" type="Library">
|
<Project name="OpenSim.Region.ScriptEngine.XEngine" path="OpenSim/Region/ScriptEngine/XEngine" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
<OutputPath>../../../../bin/ScriptEngines/</OutputPath>
|
<OutputPath>../../../../bin/</OutputPath>
|
||||||
</Options>
|
</Options>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration name="Release">
|
<Configuration name="Release">
|
||||||
<Options>
|
<Options>
|
||||||
<OutputPath>../../../../bin/ScriptEngines/</OutputPath>
|
<OutputPath>../../../../bin/</OutputPath>
|
||||||
</Options>
|
</Options>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
|
|
||||||
|
@ -2424,17 +2424,17 @@
|
||||||
<Project name="OpenSim.Region.ScriptEngine.DotNetEngine" path="OpenSim/Region/ScriptEngine/DotNetEngine" type="Library">
|
<Project name="OpenSim.Region.ScriptEngine.DotNetEngine" path="OpenSim/Region/ScriptEngine/DotNetEngine" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
<OutputPath>../../../../bin/ScriptEngines/</OutputPath>
|
<OutputPath>../../../../bin/</OutputPath>
|
||||||
</Options>
|
</Options>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration name="Release">
|
<Configuration name="Release">
|
||||||
<Options>
|
<Options>
|
||||||
<OutputPath>../../../../bin/ScriptEngines/</OutputPath>
|
<OutputPath>../../../../bin/</OutputPath>
|
||||||
</Options>
|
</Options>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
|
|
||||||
<ReferencePath>../../../../bin/</ReferencePath>
|
<ReferencePath>../../../../bin/</ReferencePath>
|
||||||
<ReferencePath>../../../../bin/ScriptEngines/</ReferencePath>
|
<ReferencePath>../../../../bin/</ReferencePath>
|
||||||
<Reference name="System" localCopy="false"/>
|
<Reference name="System" localCopy="false"/>
|
||||||
<Reference name="System.Data" localCopy="false"/>
|
<Reference name="System.Data" localCopy="false"/>
|
||||||
<Reference name="System.Xml" localCopy="false"/>
|
<Reference name="System.Xml" localCopy="false"/>
|
||||||
|
|
Loading…
Reference in New Issue