**Big ass update warning**

* Renamed plugin console message, to send a message to a plugin, use either "plugin <message>", or any unrecognised message will be sent ("plugin" sends explicitly) This replaces the old "script <message>".
* Terrain commands - "terrain <command>" now works again. "Script terrain <command>" does not. Many of the commands have now been reimplemented, eg load-tile. However some have new syntax.
* New console command handler, you can now use things like "terrain help" or "terrain save help". See TerrainModule.cs for an example of how to use the new "Commander" class.
* Commander class - advanced processing of console input and also enables a script API to be generated from registered console commands.
0.6.0-stable
Adam Frisby 2008-03-30 09:03:38 +00:00
parent fd2caf5f16
commit fadd19f314
18 changed files with 691 additions and 63 deletions

View File

@ -890,17 +890,8 @@ namespace OpenSim
}
break;
case "terrain":
string result = String.Empty;
if (!m_sceneManager.RunTerrainCmdOnCurrentScene(cmdparams, ref result))
{
m_console.Error(result);
}
break;
case "script":
m_sceneManager.SendCommandToCurrentSceneScripts(cmdparams);
case "plugin":
m_sceneManager.SendCommandToPluginModules(cmdparams);
break;
case "command-script":
@ -1081,14 +1072,15 @@ namespace OpenSim
}
}
break;
/*
* Temporarily disabled but it would be good to have this - needs to be levered
* in to BaseOpenSimServer (which requires a RunCmd method restrcuture probably)
break;
default:
m_console.Error("Unknown command");
string[] tmpPluginArgs = new string[cmdparams.Length + 1];
cmdparams.CopyTo(tmpPluginArgs, 1);
tmpPluginArgs[0] = command;
m_sceneManager.SendCommandToPluginModules(tmpPluginArgs);
break;
*/
}
}

View File

@ -0,0 +1,16 @@
using System;
using OpenSim.Region.Environment.Modules.ModuleFramework;
namespace OpenSim.Region.Environment.Interfaces
{
public interface ICommand
{
void AddArgument(string name, string helptext, string type);
System.Collections.Generic.Dictionary<string, string> Arguments { get; }
string Help { get; }
string Name { get; }
void Run(object[] args);
void ShowConsoleHelp();
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Environment.Modules.ModuleFramework;
namespace OpenSim.Region.Environment.Interfaces
{
public interface ICommandableModule
{
ICommander CommandInterface
{
get;
}
}
}

View File

@ -0,0 +1,14 @@
using System;
using OpenSim.Region.Environment.Modules.ModuleFramework;
namespace OpenSim.Region.Environment.Interfaces
{
public interface ICommander
{
void ProcessConsoleCommand(string function, string[] args);
void RegisterCommand(string commandName, ICommand command);
void Run(string function, object[] args);
string GenerateRuntimeAPI();
}
}

View File

@ -0,0 +1,92 @@
/*
* 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 libsecondlife;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Modules.ModuleFramework;
namespace OpenSim.Region.Environment.Modules
{
public class CommanderTestModule : IRegionModule, ICommandableModule
{
Commander m_commander = new Commander("CommanderTest");
Scene m_scene;
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource source)
{
m_scene = scene;
}
private void InterfaceHelloWorld(Object[] args)
{
Console.WriteLine("Hello World");
}
public void PostInitialise()
{
Command testCommand = new Command("hello", InterfaceHelloWorld, "Says a simple debugging test string");
testCommand.AddArgument("world", "Write world here", "string");
m_commander.RegisterCommand("hello", testCommand);
// Register me
m_scene.RegisterModuleCommander("commandertest", m_commander);
}
public void Close()
{
}
public string Name
{
get { return "CommanderTestModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
#endregion
#region ICommandableModule Members
public ICommander CommandInterface
{
get { throw new NotImplementedException(); }
}
#endregion
}
}

View File

@ -0,0 +1,271 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.ModuleFramework
{
/// <summary>
/// A single function call encapsulated in a class which enforces arguments when passing around as Object[]'s.
/// Used for console commands and script API generation
/// </summary>
public class Command : ICommand
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Action<Object[]> m_command;
private string m_name;
private string m_help;
private List<CommandArgument> m_args = new List<CommandArgument>();
public Command(string name, Action<Object[]> command, string help)
{
m_name = name;
m_command = command;
m_help = help;
}
public void AddArgument(string name, string helptext, string type)
{
m_args.Add(new CommandArgument(name, helptext, type));
}
public string Name
{
get { return m_name; }
}
public string Help
{
get { return m_help; }
}
public Dictionary<string, string> Arguments
{
get
{
Dictionary<string, string> tmp = new Dictionary<string, string>();
foreach (CommandArgument arg in m_args)
{
tmp.Add(arg.Name, arg.ArgumentType);
}
return tmp;
}
}
public void ShowConsoleHelp()
{
m_log.Info("== " + Name + " ==");
m_log.Info(m_help);
m_log.Info("= Parameters =");
foreach (CommandArgument arg in m_args)
{
m_log.Info("* " + arg.Name + " (" + arg.ArgumentType + ")");
m_log.Info("\t" + arg.HelpText);
}
}
public void Run(Object[] args)
{
Object[] cleanArgs = new Object[m_args.Count];
if (args.Length < cleanArgs.Length)
{
m_log.Error("Missing " + (cleanArgs.Length - args.Length) + " argument(s)");
ShowConsoleHelp();
return;
}
if (args.Length > cleanArgs.Length)
{
m_log.Error("Too many arguments for this command. Type '<module> <command> help' for help.");
return;
}
int i = 0;
foreach (Object arg in args)
{
if (string.IsNullOrEmpty(arg.ToString()))
{
m_log.Error("Empty arguments are not allowed");
return;
}
try
{
switch (m_args[i].ArgumentType)
{
case "String":
m_args[i].ArgumentValue = arg.ToString();
break;
case "Integer":
m_args[i].ArgumentValue = Int32.Parse(arg.ToString());
break;
case "Double":
m_args[i].ArgumentValue = Double.Parse(arg.ToString());
break;
case "Boolean":
m_args[i].ArgumentValue = Boolean.Parse(arg.ToString());
break;
default:
m_log.Error("Unknown desired type for argument " + m_args[i].Name + " on command " + m_name);
break;
}
}
catch (FormatException)
{
m_log.Error("Argument number " + (i + 1) +
" (" + m_args[i].Name + ") must be a valid " +
m_args[i].ArgumentType.ToLower() + ".");
}
cleanArgs[i] = m_args[i].ArgumentValue;
i++;
}
m_command.Invoke(cleanArgs);
}
}
/// <summary>
/// A single command argument, contains name, type and at runtime, value.
/// </summary>
public class CommandArgument
{
private string m_name;
private string m_help;
private string m_type;
private Object m_val;
public CommandArgument(string name, string help, string type)
{
m_name = name;
m_help = help;
m_type = type;
}
public string Name
{
get { return m_name; }
}
public string HelpText
{
get { return m_help; }
}
public string ArgumentType
{
get { return m_type; }
}
public Object ArgumentValue
{
get { return m_val; }
set { m_val = value; }
}
}
/// <summary>
/// A class to enable modules to register console and script commands, which enforces typing and valid input.
/// </summary>
public class Commander : ICommander
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>();
private string m_name;
public Commander(string name)
{
m_name = name;
}
public void RegisterCommand(string commandName, ICommand command)
{
m_commands[commandName] = command;
}
void ShowConsoleHelp()
{
m_log.Info("===" + m_name + "===");
foreach (ICommand com in m_commands.Values)
{
m_log.Info("* " + com.Name + " - " + com.Help);
}
}
string EscapeRuntimeAPICommand(string command)
{
command = command.Replace('-', '_');
StringBuilder tmp = new StringBuilder(command);
tmp[0] = tmp[0].ToString().ToUpper().ToCharArray()[0];
return tmp.ToString();
}
/// <summary>
/// Generates a runtime C# class which can be compiled and inserted via reflection to enable modules to register new script commands
/// </summary>
/// <returns>Returns C# source code to create a binding</returns>
public string GenerateRuntimeAPI()
{
string classSrc = "\n\tpublic class " + m_name + " {\n";
foreach (ICommand com in m_commands.Values)
{
classSrc += "\tpublic void " + EscapeRuntimeAPICommand(com.Name) + "( ";
foreach (KeyValuePair<string, string> arg in com.Arguments)
{
classSrc += arg.Value + " " + Framework.Util.Md5Hash(arg.Key) + ",";
}
classSrc = classSrc.Remove(classSrc.Length - 1); // Delete the last comma
classSrc += " )\n\t{\n";
classSrc += "\t\tObject[] args = new Object[" + com.Arguments.Count.ToString() + "];\n";
int i = 0;
foreach (KeyValuePair<string, string> arg in com.Arguments)
{
classSrc += "\t\targs[" + i.ToString() + "] = " + Framework.Util.Md5Hash(arg.Key) + " " + ";\n";
i++;
}
classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n";
classSrc += "\t}\n";
}
classSrc += "}\n";
return classSrc;
}
/// <summary>
/// Runs a specified function with attached arguments
/// *** <b>DO NOT CALL DIRECTLY.</b> ***
/// Call ProcessConsoleCommand instead if handling human input.
/// </summary>
/// <param name="function">The function name to call</param>
/// <param name="args">The function parameters</param>
public void Run(string function, object[] args)
{
m_commands[function].Run(args);
}
public void ProcessConsoleCommand(string function, string[] args)
{
if (m_commands.ContainsKey(function))
{
if (args[0] == "help")
{
m_commands[function].ShowConsoleHelp();
}
else
{
m_commands[function].Run(args);
}
}
else
{
if (function != "help")
m_log.Error("Invalid command - No such command exists");
if (function == "api")
m_log.Info(GenerateRuntimeAPI());
ShowConsoleHelp();
}
}
}
}

View File

@ -41,6 +41,16 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
throw new NotImplementedException();
}
public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
{
throw new NotImplementedException();
}
public override string ToString()
{
return "JPEG";
}
private Bitmap CreateBitmapFromMap(ITerrainChannel map)
{
Bitmap gradientmapLd = new Bitmap("defaultstripe.png");

View File

@ -58,6 +58,16 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
return retval;
}
public override string ToString()
{
return "LL/SL RAW";
}
public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
{
throw new NotImplementedException();
}
public void SaveFile(string filename, ITerrainChannel map)
{
FileInfo file = new FileInfo(filename);

View File

@ -57,6 +57,43 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
return retval;
}
public override string ToString()
{
return "RAW32";
}
public ITerrainChannel LoadFile(string filename, int fileStartX, int fileStartY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight)
{
TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight);
FileInfo file = new FileInfo(filename);
FileStream s = file.Open(FileMode.Open, FileAccess.Read);
BinaryReader bs = new BinaryReader(s);
// Advance to our section of the file
if (fileStartY * sectionHeight > 0)
bs.ReadBytes(fileStartY * sectionHeight);
int x, y;
for (y = 0; y < retval.Height; y++)
{
// Advance the stream if we aren't at the start of the section in the file
if (fileStartX * sectionWidth > 0)
bs.ReadBytes(fileStartX * sectionHeight);
for (x = 0; x < retval.Width; x++)
{
// Read a strip and continue
retval[x, y] = bs.ReadSingle();
}
}
bs.Close();
s.Close();
return retval;
}
public void SaveFile(string filename, ITerrainChannel map)
{
FileInfo file = new FileInfo(filename);

View File

@ -107,6 +107,16 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
throw new NotImplementedException();
}
public override string ToString()
{
return "Terragen";
}
public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
{
throw new NotImplementedException();
}
#endregion
}
}

View File

@ -32,6 +32,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
public interface ITerrainLoader
{
ITerrainChannel LoadFile(string filename);
ITerrainChannel LoadFile(string filename, int fileStartX, int fileStartY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight);
void SaveFile(string filename, ITerrainChannel map);
}
}

View File

@ -33,11 +33,12 @@ using Nini.Config;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Modules.ModuleFramework;
namespace OpenSim.Region.Environment.Modules.Terrain
{
public class TerrainModule : IRegionModule , ITerrainTemp
public class TerrainModule : IRegionModule , ITerrainTemp, ICommandableModule
{
public enum StandardTerrainEffects : byte
{
@ -51,6 +52,8 @@ namespace OpenSim.Region.Environment.Modules.Terrain
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Commander m_commander = new Commander("Terrain");
private Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects =
new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>();
private Dictionary<StandardTerrainEffects, ITerrainFloodEffect> m_floodeffects =
@ -109,7 +112,44 @@ namespace OpenSim.Region.Environment.Modules.Terrain
{
lock (m_scene)
{
ITerrainChannel channel = loader.Value.LoadFile(filename);
try
{
ITerrainChannel channel = loader.Value.LoadFile(filename);
m_scene.Heightmap = channel;
m_channel = channel;
UpdateRevertMap();
}
catch (NotImplementedException)
{
m_log.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value.ToString() + " parser does not support file loading. (May be save only)");
return;
}
catch (System.IO.FileNotFoundException)
{
m_log.Error("[TERRAIN]: Unable to load heightmap, file not found. (A directory permissions error may also cause this)");
return;
}
}
m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully");
return;
}
}
m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader availible for that format.");
}
public void LoadFromFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY)
{
fileStartX -= (int)m_scene.RegionInfo.RegionLocX;
fileStartY -= (int)m_scene.RegionInfo.RegionLocY;
foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
{
if (filename.EndsWith(loader.Key))
{
lock (m_scene)
{
ITerrainChannel channel = loader.Value.LoadFile(filename, fileStartX, fileStartY,
fileWidth, fileHeight, (int)Constants.RegionSize, (int)Constants.RegionSize);
m_scene.Heightmap = channel;
m_channel = channel;
UpdateRevertMap();
@ -177,46 +217,101 @@ namespace OpenSim.Region.Environment.Modules.Terrain
}
}
#region Console Commands
private void InterfaceLoadFile(Object[] args)
{
LoadFromFile((string)args[0]);
}
private void InterfaceLoadTileFile(Object[] args)
{
LoadFromFile((string)args[0],
(int)args[1],
(int)args[2],
(int)args[3],
(int)args[4]);
}
private void InterfaceSaveFile(Object[] args)
{
SaveToFile((string)args[0]);
}
private void InterfaceFillTerrain(Object[] args)
{
int x, y;
for (x = 0; x < m_channel.Width; x++)
for (y = 0; y < m_channel.Height; y++)
m_channel[x, y] = (double)args[0];
SendUpdatedLayerData();
}
private void InterfaceEnableExperimentalBrushes(Object[] args)
{
if ((bool)args[0])
{
m_painteffects[StandardTerrainEffects.Revert] = new PaintBrushes.WeatherSphere();
m_painteffects[StandardTerrainEffects.Flatten] = new PaintBrushes.OlsenSphere();
m_painteffects[StandardTerrainEffects.Smooth] = new PaintBrushes.ErodeSphere();
}
else
{
InstallDefaultEffects();
}
}
private void InstallInterfaces()
{
// Load / Save
string supportedFileExtensions = "";
foreach (KeyValuePair<string,ITerrainLoader> loader in m_loaders)
supportedFileExtensions += " " + loader.Key + " (" + loader.Value.ToString() + ")";
Command loadFromFileCommand = new Command("load", InterfaceLoadFile, "Loads a terrain from a specified file.");
loadFromFileCommand.AddArgument("filename", "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + supportedFileExtensions, "String");
Command saveToFileCommand = new Command("save", InterfaceSaveFile, "Saves the current heightmap to a specified file.");
saveToFileCommand.AddArgument("filename", "The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " + supportedFileExtensions, "String");
Command loadFromTileCommand = new Command("load-tile", InterfaceLoadTileFile, "Loads a terrain from a section of a larger file.");
loadFromTileCommand.AddArgument("filename", "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + supportedFileExtensions, "String");
loadFromTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer");
loadFromTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer");
loadFromTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file", "Integer");
loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", "Integer");
// Terrain adjustments
Command fillRegionCommand = new Command("fill", InterfaceFillTerrain, "Fills the current heightmap with a specified value.");
fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.", "Double");
// Brushes
Command experimentalBrushesCommand = new Command("newbrushes", InterfaceEnableExperimentalBrushes, "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time.");
experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean");
m_commander.RegisterCommand("load", loadFromFileCommand);
m_commander.RegisterCommand("load-tile", loadFromTileCommand);
m_commander.RegisterCommand("save", saveToFileCommand);
m_commander.RegisterCommand("fill", fillRegionCommand);
m_commander.RegisterCommand("newbrushes", experimentalBrushesCommand);
// Add this to our scene so scripts can call these functions
//TMPm_scene.RegisterModuleCommander("Terrain", m_commander);
}
#endregion
void EventManager_OnPluginConsole(string[] args)
{
if (args[0] == "terrain")
{
string command = args[1];
string param = args[2];
int x, y;
switch (command)
{
case "load":
LoadFromFile(param);
SendUpdatedLayerData();
break;
case "save":
SaveToFile(param);
break;
case "fill":
for (x = 0; x < m_channel.Width; x++)
for (y = 0; y < m_channel.Height; y++)
m_channel[x, y] = Double.Parse(param);
SendUpdatedLayerData();
break;
case "newbrushes":
if (Boolean.Parse(param))
{
m_painteffects[StandardTerrainEffects.Revert] = new PaintBrushes.WeatherSphere();
m_painteffects[StandardTerrainEffects.Flatten] = new PaintBrushes.OlsenSphere();
m_painteffects[StandardTerrainEffects.Smooth] = new PaintBrushes.ErodeSphere();
}
else
{
InstallDefaultEffects();
}
break;
default:
m_log.Warn("Unknown terrain command.");
break;
}
string[] tmpArgs = new string[args.Length - 2];
int i = 0;
for (i = 2; i < args.Length; i++)
tmpArgs[i - 2] = args[i];
m_commander.ProcessConsoleCommand(args[1], tmpArgs);
}
}
@ -363,6 +458,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
public void PostInitialise()
{
InstallDefaultEffects();
InstallInterfaces();
}
public void Close()
@ -378,5 +474,14 @@ namespace OpenSim.Region.Environment.Modules.Terrain
{
get { return false; }
}
#region ICommandable Members
public ICommander CommandInterface
{
get { return m_commander; }
}
#endregion
}
}

View File

@ -40,10 +40,8 @@ using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Servers;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules;
using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Region.Physics.Manager;
using OpenSim.Region.Terrain;
using Caps = OpenSim.Region.Capabilities.Caps;
using Image = System.Drawing.Image;
using Timer = System.Timers.Timer;
@ -75,7 +73,6 @@ namespace OpenSim.Region.Environment.Scenes
private readonly Mutex _primAllocateMutex = new Mutex(false);
private int m_timePhase = 24;
private int m_timeUpdateCount;
private readonly Mutex updateLock;
public bool m_physicalPrim;
@ -104,6 +101,7 @@ namespace OpenSim.Region.Environment.Scenes
protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>();
public Dictionary<Type, object> ModuleInterfaces = new Dictionary<Type, object>();
protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>();
public Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>();
//API module interfaces
@ -1949,6 +1947,27 @@ namespace OpenSim.Region.Environment.Scenes
}
}
public void RegisterModuleCommander(string name, ICommander commander)
{
lock (m_moduleCommanders)
{
m_moduleCommanders.Add(name, commander);
}
}
public ICommander GetCommander(string name)
{
lock (m_moduleCommanders)
{
return m_moduleCommanders[name];
}
}
public Dictionary<string, ICommander> GetCommanders()
{
return m_moduleCommanders;
}
/// <summary>
///
/// </summary>

View File

@ -175,16 +175,14 @@ namespace OpenSim.Region.Environment.Scenes
CurrentOrFirstScene.LoadPrimsFromXml2(filename);
}
[Obsolete("TODO: Remove this warning by 0.7")]
public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
{
m_log.Warn("Old terrain commands format has been deprecated.");
m_log.Warn("Please enter 'script terrain' rather than 'terrain'.");
m_log.Warn("FOR EXAMPLE: script terrain fill 25");
m_log.Warn("DEPRECIATED: The terrain engine has been replaced with a new terrain plugin module. Please type 'plugin terrain help' for new commands.");
return false;
}
public void SendCommandToCurrentSceneScripts(string[] cmdparams)
public void SendCommandToPluginModules(string[] cmdparams)
{
ForEachCurrentScene(delegate(Scene scene) { scene.SendCommandToPlugins(cmdparams); });
}

View File

@ -146,6 +146,12 @@ namespace OpenSim.Region.ScriptEngine.Common
//
// They are only forwarders to LSL_BuiltIn_Commands.cs
//
public OpenSim.Region.Environment.Interfaces.ICommander GetCommander(string name)
{
return m_LSL_Functions.GetCommander(name);
}
public double llSin(double f)
{
return m_LSL_Functions.llSin(f);

View File

@ -105,6 +105,12 @@ namespace OpenSim.Region.ScriptEngine.Common
get { return m_ScriptEngine.World; }
}
// Extension commands use this:
public ICommander GetCommander(string name)
{
return World.GetCommander(name);
}
//These are the implementations of the various ll-functions used by the LSL scripts.
//starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07
public double llSin(double f)

View File

@ -35,6 +35,8 @@ namespace OpenSim.Region.ScriptEngine.Common
string State { get; set; }
OpenSim.Region.Environment.Interfaces.ICommander GetCommander(string name);
double llSin(double f);
double llCos(double f);
double llTan(double f);

View File

@ -268,6 +268,24 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
l = enumCompileType.cs;
}
// Insert additional assemblies here
//ADAM: Disabled for the moment until it's working right.
bool enableCommanderLSL = false;
if (enableCommanderLSL == true && l == enumCompileType.cs)
{
foreach (KeyValuePair<string,
OpenSim.Region.Environment.Interfaces.ICommander> com
in m_scriptEngine.World.GetCommanders())
{
compileScript = com.Value.GenerateRuntimeAPI() + compileScript;
}
}
// End of insert
switch (l)
{
case enumCompileType.cs:
@ -280,6 +298,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
compileScript = CreateJSCompilerScript(compileScript);
break;
}
Console.WriteLine("\n\n\n");
Console.WriteLine(compileScript);
Console.WriteLine("\n\n\n");
return CompileFromDotNetText(compileScript, l);
}