diff options
12 files changed, 347 insertions, 130 deletions
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 2bb7de1..c5d6b78 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs | |||
@@ -188,19 +188,21 @@ namespace OpenSim.Framework.Console | |||
188 | { | 188 | { |
189 | lock (m_modulesCommands) | 189 | lock (m_modulesCommands) |
190 | { | 190 | { |
191 | if (m_modulesCommands.ContainsKey(moduleName)) | 191 | foreach (string key in m_modulesCommands.Keys) |
192 | { | 192 | { |
193 | List<CommandInfo> commands = m_modulesCommands[moduleName]; | 193 | // Allow topic help requests to succeed whether they are upper or lowercase. |
194 | var ourHelpText = commands.ConvertAll(c => string.Format("{0} - {1}", c.help_text, c.long_help)); | 194 | if (moduleName.ToLower() == key.ToLower()) |
195 | ourHelpText.Sort(); | 195 | { |
196 | helpText.AddRange(ourHelpText); | 196 | List<CommandInfo> commands = m_modulesCommands[key]; |
197 | var ourHelpText = commands.ConvertAll(c => string.Format("{0} - {1}", c.help_text, c.long_help)); | ||
198 | ourHelpText.Sort(); | ||
199 | helpText.AddRange(ourHelpText); | ||
197 | 200 | ||
198 | return true; | 201 | return true; |
199 | } | 202 | } |
200 | else | ||
201 | { | ||
202 | return false; | ||
203 | } | 203 | } |
204 | |||
205 | return false; | ||
204 | } | 206 | } |
205 | } | 207 | } |
206 | 208 | ||
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 7a3e67f..1b2f681 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -423,12 +423,18 @@ namespace OpenSim.Framework | |||
423 | set { m_internalEndPoint = value; } | 423 | set { m_internalEndPoint = value; } |
424 | } | 424 | } |
425 | 425 | ||
426 | /// <summary> | ||
427 | /// The x co-ordinate of this region in map tiles (e.g. 1000). | ||
428 | /// </summary> | ||
426 | public uint RegionLocX | 429 | public uint RegionLocX |
427 | { | 430 | { |
428 | get { return m_regionLocX.Value; } | 431 | get { return m_regionLocX.Value; } |
429 | set { m_regionLocX = value; } | 432 | set { m_regionLocX = value; } |
430 | } | 433 | } |
431 | 434 | ||
435 | /// <summary> | ||
436 | /// The y co-ordinate of this region in map tiles (e.g. 1000). | ||
437 | /// </summary> | ||
432 | public uint RegionLocY | 438 | public uint RegionLocY |
433 | { | 439 | { |
434 | get { return m_regionLocY.Value; } | 440 | get { return m_regionLocY.Value; } |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index c1d0727..ddc7f10 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -263,15 +263,16 @@ namespace OpenSim | |||
263 | { | 263 | { |
264 | string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1); | 264 | string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1); |
265 | 265 | ||
266 | // This is a hack to allow the user to enter the help command in upper or lowercase. This will go | ||
267 | // away at some point. | ||
268 | m_console.Commands.AddCommand(capitalizedTopic, false, "help " + topic, | ||
269 | "help " + capitalizedTopic, | ||
270 | "Get help on plugin command '" + topic + "'", | ||
271 | HandleCommanderHelp); | ||
266 | m_console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic, | 272 | m_console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic, |
267 | "help " + capitalizedTopic, | 273 | "help " + capitalizedTopic, |
268 | "Get help on plugin command '" + topic + "'", | 274 | "Get help on plugin command '" + topic + "'", |
269 | HandleCommanderHelp); | 275 | HandleCommanderHelp); |
270 | // | ||
271 | // m_console.Commands.AddCommand("General", false, topic, | ||
272 | // topic, | ||
273 | // "Execute subcommand for plugin '" + topic + "'", | ||
274 | // null); | ||
275 | 276 | ||
276 | ICommander commander = null; | 277 | ICommander commander = null; |
277 | 278 | ||
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index 21a9999..58925fd 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -132,13 +132,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
132 | { | 132 | { |
133 | // We need to do this because: | 133 | // We need to do this because: |
134 | // "Saving the image to the same file it was constructed from is not allowed and throws an exception." | 134 | // "Saving the image to the same file it was constructed from is not allowed and throws an exception." |
135 | string tempName = offsetX + "_ " + offsetY + "_" + filename; | 135 | string tempName = Path.GetTempFileName(); |
136 | 136 | ||
137 | Bitmap entireBitmap = null; | 137 | Bitmap entireBitmap = null; |
138 | Bitmap thisBitmap = null; | 138 | Bitmap thisBitmap = null; |
139 | if (File.Exists(filename)) | 139 | if (File.Exists(filename)) |
140 | { | 140 | { |
141 | File.Copy(filename, tempName); | 141 | File.Copy(filename, tempName, true); |
142 | entireBitmap = new Bitmap(tempName); | 142 | entireBitmap = new Bitmap(tempName); |
143 | if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY) | 143 | if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY) |
144 | { | 144 | { |
@@ -152,7 +152,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
152 | } | 152 | } |
153 | 153 | ||
154 | thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); | 154 | thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); |
155 | Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); | 155 | // Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); |
156 | for (int x = 0; x < regionSizeX; x++) | 156 | for (int x = 0; x < regionSizeX; x++) |
157 | for (int y = 0; y < regionSizeY; y++) | 157 | for (int y = 0; y < regionSizeY; y++) |
158 | entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); | 158 | entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs index 7237f90..d407617 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs | |||
@@ -38,6 +38,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
38 | ITerrainChannel LoadStream(Stream stream); | 38 | ITerrainChannel LoadStream(Stream stream); |
39 | void SaveFile(string filename, ITerrainChannel map); | 39 | void SaveFile(string filename, ITerrainChannel map); |
40 | void SaveStream(Stream stream, ITerrainChannel map); | 40 | void SaveStream(Stream stream, ITerrainChannel map); |
41 | |||
42 | /// <summary> | ||
43 | /// Save a number of map tiles to a single big image file. | ||
44 | /// </summary> | ||
45 | /// <remarks> | ||
46 | /// If the image file already exists then the tiles saved will replace those already in the file - other tiles | ||
47 | /// will be untouched. | ||
48 | /// </remarks> | ||
49 | /// <param name="filename">The terrain file to save</param> | ||
50 | /// <param name="offsetX">The map x co-ordinate at which to begin the save.</param> | ||
51 | /// <param name="offsetY">The may y co-ordinate at which to begin the save.</param> | ||
52 | /// <param name="fileWidth">The number of tiles to save along the X axis.</param> | ||
53 | /// <param name="fileHeight">The number of tiles to save along the Y axis.</param> | ||
54 | /// <param name="regionSizeX">The width of a map tile.</param> | ||
55 | /// <param name="regionSizeY">The height of a map tile.</param> | ||
41 | void SaveFile(ITerrainChannel map, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY); | 56 | void SaveFile(ITerrainChannel map, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY); |
42 | } | 57 | } |
43 | } \ No newline at end of file | 58 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 7c6df03..9159f0c 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -561,49 +561,56 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
561 | } | 561 | } |
562 | 562 | ||
563 | /// <summary> | 563 | /// <summary> |
564 | /// Saves the terrain to a larger terrain file. | 564 | /// Save a number of map tiles to a single big image file. |
565 | /// </summary> | 565 | /// </summary> |
566 | /// <remarks> | ||
567 | /// If the image file already exists then the tiles saved will replace those already in the file - other tiles | ||
568 | /// will be untouched. | ||
569 | /// </remarks> | ||
566 | /// <param name="filename">The terrain file to save</param> | 570 | /// <param name="filename">The terrain file to save</param> |
567 | /// <param name="fileWidth">The width of the file in units</param> | 571 | /// <param name="fileWidth">The number of tiles to save along the X axis.</param> |
568 | /// <param name="fileHeight">The height of the file in units</param> | 572 | /// <param name="fileHeight">The number of tiles to save along the Y axis.</param> |
569 | /// <param name="fileStartX">Where to begin our slice</param> | 573 | /// <param name="fileStartX">The map x co-ordinate at which to begin the save.</param> |
570 | /// <param name="fileStartY">Where to begin our slice</param> | 574 | /// <param name="fileStartY">The may y co-ordinate at which to begin the save.</param> |
571 | public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) | 575 | public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) |
572 | { | 576 | { |
573 | int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX; | 577 | int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX; |
574 | int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY; | 578 | int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY; |
575 | 579 | ||
576 | if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) | 580 | if (offsetX < 0 || offsetX >= fileWidth || offsetY < 0 || offsetY >= fileHeight) |
577 | { | 581 | { |
578 | // this region is included in the tile request | 582 | MainConsole.Instance.OutputFormat( |
579 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 583 | "ERROR: file width + minimum X tile and file height + minimum Y tile must incorporate the current region at ({0},{1}). File width {2} from {3} and file height {4} from {5} does not.", |
584 | m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, fileWidth, fileStartX, fileHeight, fileStartY); | ||
585 | |||
586 | return; | ||
587 | } | ||
588 | |||
589 | // this region is included in the tile request | ||
590 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | ||
591 | { | ||
592 | if (filename.EndsWith(loader.Key)) | ||
580 | { | 593 | { |
581 | if (filename.EndsWith(loader.Key)) | 594 | lock (m_scene) |
582 | { | 595 | { |
583 | lock (m_scene) | 596 | loader.Value.SaveFile(m_channel, filename, offsetX, offsetY, |
584 | { | 597 | fileWidth, fileHeight, |
585 | loader.Value.SaveFile(m_channel, filename, offsetX, offsetY, | 598 | (int)Constants.RegionSize, |
586 | fileWidth, fileHeight, | 599 | (int)Constants.RegionSize); |
587 | (int)Constants.RegionSize, | 600 | |
588 | (int)Constants.RegionSize); | 601 | MainConsole.Instance.OutputFormat( |
589 | 602 | "Saved terrain from ({0},{1}) to ({2},{3}) from {4} to {5}", | |
590 | m_log.InfoFormat("[TERRAIN]: Saved terrain from {0} to {1}", m_scene.RegionInfo.RegionName, filename); | 603 | fileStartX, fileStartY, fileStartX + fileWidth - 1, fileStartY + fileHeight - 1, |
591 | } | 604 | m_scene.RegionInfo.RegionName, filename); |
592 | |||
593 | return; | ||
594 | } | 605 | } |
606 | |||
607 | return; | ||
595 | } | 608 | } |
596 | |||
597 | m_log.ErrorFormat( | ||
598 | "[TERRAIN]: Could not save terrain from {0} to {1}. Valid file extensions are {2}", | ||
599 | m_scene.RegionInfo.RegionName, filename, m_supportedFileExtensions); | ||
600 | } | 609 | } |
601 | // else | 610 | |
602 | // { | 611 | MainConsole.Instance.OutputFormat( |
603 | // m_log.ErrorFormat( | 612 | "ERROR: Could not save terrain from {0} to {1}. Valid file extensions are {2}", |
604 | // "[TERRAIN]: Could not save terrain from {0} to {1}. {2} {3} {4} {5} {6} {7}", | 613 | m_scene.RegionInfo.RegionName, filename, m_supportedFileExtensions); |
605 | // m_scene.RegionInfo.RegionName, filename, fileWidth, fileHeight, fileStartX, fileStartY, offsetX, offsetY); | ||
606 | // } | ||
607 | } | 614 | } |
608 | 615 | ||
609 | /// <summary> | 616 | /// <summary> |
@@ -1194,6 +1201,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1194 | "Integer"); | 1201 | "Integer"); |
1195 | saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", | 1202 | saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", |
1196 | "Integer"); | 1203 | "Integer"); |
1204 | saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first tile on the file\n" | ||
1205 | + "= Example =\n" | ||
1206 | + "To save a PNG file for a set of map tiles 2 regions wide and 3 regions high from map co-ordinate (9910,10234)\n" | ||
1207 | + " # terrain save-tile ST06.png 2 3 9910 10234\n", | ||
1208 | "Integer"); | ||
1209 | |||
1197 | // Terrain adjustments | 1210 | // Terrain adjustments |
1198 | Command fillRegionCommand = | 1211 | Command fillRegionCommand = |
1199 | new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); | 1212 | new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); |
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index bb4c788..8bfbbf8 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs | |||
@@ -46,7 +46,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
46 | /// </summary> | 46 | /// </summary> |
47 | event ScriptCommand OnScriptCommand; | 47 | event ScriptCommand OnScriptCommand; |
48 | 48 | ||
49 | void RegisterScriptInvocation(string name, ScriptInvocation fn, Type[] csig, Type rsig); | 49 | void RegisterScriptInvocation(ScriptInvocation fn); |
50 | ScriptInvocation[] GetScriptInvocationList(); | ||
50 | 51 | ||
51 | ScriptInvocation LookupScriptInvocation(string fname); | 52 | ScriptInvocation LookupScriptInvocation(string fname); |
52 | string LookupModInvocation(string fname); | 53 | string LookupModInvocation(string fname); |
diff --git a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs index a3f68e5..e452124 100755 --- a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs +++ b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs | |||
@@ -264,14 +264,14 @@ namespace OpenSim.Region.OptionalModules.PhysicsParameters | |||
264 | 264 | ||
265 | private void WriteOut(string msg, params object[] args) | 265 | private void WriteOut(string msg, params object[] args) |
266 | { | 266 | { |
267 | m_log.InfoFormat(msg, args); | 267 | // m_log.InfoFormat(msg, args); |
268 | // MainConsole.Instance.OutputFormat(msg, args); | 268 | MainConsole.Instance.OutputFormat(msg, args); |
269 | } | 269 | } |
270 | 270 | ||
271 | private void WriteError(string msg, params object[] args) | 271 | private void WriteError(string msg, params object[] args) |
272 | { | 272 | { |
273 | m_log.ErrorFormat(msg, args); | 273 | // m_log.ErrorFormat(msg, args); |
274 | // MainConsole.Instance.OutputFormat(msg, args); | 274 | MainConsole.Instance.OutputFormat(msg, args); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | } \ No newline at end of file | 277 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index a90362e..8e8a0b6 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | |||
@@ -126,14 +126,30 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms | |||
126 | m_scriptModule.PostScriptEvent(script, "link_message", args); | 126 | m_scriptModule.PostScriptEvent(script, "link_message", args); |
127 | } | 127 | } |
128 | 128 | ||
129 | public void RegisterScriptInvocation(string fname, ScriptInvocation fcall, Type[] csig, Type rsig) | 129 | public void RegisterScriptInvocation(ScriptInvocation fcall) |
130 | { | 130 | { |
131 | lock (m_scriptInvocation) | 131 | lock (m_scriptInvocation) |
132 | { | 132 | { |
133 | m_scriptInvocation[fname] = new ScriptInvocationData(fname,fcall,csig,rsig); | 133 | ParameterInfo[] parameters = fcall.Method.GetParameters (); |
134 | Type[] parmTypes = new Type[parameters.Length]; | ||
135 | for (int i = 0 ; i < parameters.Length ; i++) | ||
136 | parmTypes[i] = parameters[i].ParameterType; | ||
137 | m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType); | ||
134 | } | 138 | } |
135 | } | 139 | } |
136 | 140 | ||
141 | public ScriptInvocation[] GetScriptInvocationList() | ||
142 | { | ||
143 | List<ScriptInvocation> ret = new List<ScriptInvocation>(); | ||
144 | |||
145 | lock (m_scriptInvocation) | ||
146 | { | ||
147 | foreach (ScriptInvocationData d in m_scriptInvocation.Values) | ||
148 | ret.Add(d.ScriptInvocationFn); | ||
149 | } | ||
150 | return ret.ToArray(); | ||
151 | } | ||
152 | |||
137 | public string LookupModInvocation(string fname) | 153 | public string LookupModInvocation(string fname) |
138 | { | 154 | { |
139 | lock (m_scriptInvocation) | 155 | lock (m_scriptInvocation) |
@@ -147,6 +163,14 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms | |||
147 | return "modInvokeI"; | 163 | return "modInvokeI"; |
148 | else if (sid.ReturnType == typeof(float)) | 164 | else if (sid.ReturnType == typeof(float)) |
149 | return "modInvokeF"; | 165 | return "modInvokeF"; |
166 | else if (sid.ReturnType == typeof(UUID)) | ||
167 | return "modInvokeK"; | ||
168 | else if (sid.ReturnType == typeof(OpenMetaverse.Vector3)) | ||
169 | return "modInvokeV"; | ||
170 | else if (sid.ReturnType == typeof(OpenMetaverse.Quaternion)) | ||
171 | return "modInvokeR"; | ||
172 | else if (sid.ReturnType == typeof(object[])) | ||
173 | return "modInvokeL"; | ||
150 | } | 174 | } |
151 | } | 175 | } |
152 | 176 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 2942104..1bcbcd3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -120,33 +120,101 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
120 | /// | 120 | /// |
121 | /// </summary> | 121 | /// </summary> |
122 | /// <param name="fname">The name of the function to invoke</param> | 122 | /// <param name="fname">The name of the function to invoke</param> |
123 | /// <param name="fname">List of parameters</param> | 123 | /// <param name="parms">List of parameters</param> |
124 | /// <returns>string result of the invocation</returns> | 124 | /// <returns>string result of the invocation</returns> |
125 | public string modInvokeS(string fname, params object[] parms) | 125 | public LSL_String modInvokeS(string fname, params object[] parms) |
126 | { | 126 | { |
127 | Type returntype = m_comms.LookupReturnType(fname); | 127 | Type returntype = m_comms.LookupReturnType(fname); |
128 | if (returntype != typeof(string)) | 128 | if (returntype != typeof(string)) |
129 | MODError(String.Format("return type mismatch for {0}",fname)); | 129 | MODError(String.Format("return type mismatch for {0}",fname)); |
130 | 130 | ||
131 | return (string)modInvoke(fname,parms); | 131 | string result = (string)modInvoke(fname,parms); |
132 | return new LSL_String(result); | ||
132 | } | 133 | } |
133 | 134 | ||
134 | public int modInvokeI(string fname, params object[] parms) | 135 | public LSL_Integer modInvokeI(string fname, params object[] parms) |
135 | { | 136 | { |
136 | Type returntype = m_comms.LookupReturnType(fname); | 137 | Type returntype = m_comms.LookupReturnType(fname); |
137 | if (returntype != typeof(int)) | 138 | if (returntype != typeof(int)) |
138 | MODError(String.Format("return type mismatch for {0}",fname)); | 139 | MODError(String.Format("return type mismatch for {0}",fname)); |
139 | 140 | ||
140 | return (int)modInvoke(fname,parms); | 141 | int result = (int)modInvoke(fname,parms); |
142 | return new LSL_Integer(result); | ||
141 | } | 143 | } |
142 | 144 | ||
143 | public float modInvokeF(string fname, params object[] parms) | 145 | public LSL_Float modInvokeF(string fname, params object[] parms) |
144 | { | 146 | { |
145 | Type returntype = m_comms.LookupReturnType(fname); | 147 | Type returntype = m_comms.LookupReturnType(fname); |
146 | if (returntype != typeof(float)) | 148 | if (returntype != typeof(float)) |
147 | MODError(String.Format("return type mismatch for {0}",fname)); | 149 | MODError(String.Format("return type mismatch for {0}",fname)); |
148 | 150 | ||
149 | return (float)modInvoke(fname,parms); | 151 | float result = (float)modInvoke(fname,parms); |
152 | return new LSL_Float(result); | ||
153 | } | ||
154 | |||
155 | public LSL_Key modInvokeK(string fname, params object[] parms) | ||
156 | { | ||
157 | Type returntype = m_comms.LookupReturnType(fname); | ||
158 | if (returntype != typeof(UUID)) | ||
159 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
160 | |||
161 | UUID result = (UUID)modInvoke(fname,parms); | ||
162 | return new LSL_Key(result.ToString()); | ||
163 | } | ||
164 | |||
165 | public LSL_Vector modInvokeV(string fname, params object[] parms) | ||
166 | { | ||
167 | Type returntype = m_comms.LookupReturnType(fname); | ||
168 | if (returntype != typeof(OpenMetaverse.Vector3)) | ||
169 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
170 | |||
171 | OpenMetaverse.Vector3 result = (OpenMetaverse.Vector3)modInvoke(fname,parms); | ||
172 | return new LSL_Vector(result.X,result.Y,result.Z); | ||
173 | } | ||
174 | |||
175 | public LSL_Rotation modInvokeR(string fname, params object[] parms) | ||
176 | { | ||
177 | Type returntype = m_comms.LookupReturnType(fname); | ||
178 | if (returntype != typeof(OpenMetaverse.Quaternion)) | ||
179 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
180 | |||
181 | OpenMetaverse.Quaternion result = (OpenMetaverse.Quaternion)modInvoke(fname,parms); | ||
182 | return new LSL_Rotation(result.X,result.Y,result.Z,result.W); | ||
183 | } | ||
184 | |||
185 | public LSL_List modInvokeL(string fname, params object[] parms) | ||
186 | { | ||
187 | Type returntype = m_comms.LookupReturnType(fname); | ||
188 | if (returntype != typeof(object[])) | ||
189 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
190 | |||
191 | object[] result = (object[])modInvoke(fname,parms); | ||
192 | object[] llist = new object[result.Length]; | ||
193 | for (int i = 0; i < result.Length; i++) | ||
194 | { | ||
195 | if (result[i] is string) | ||
196 | llist[i] = new LSL_String((string)result[i]); | ||
197 | else if (result[i] is int) | ||
198 | llist[i] = new LSL_Integer((int)result[i]); | ||
199 | else if (result[i] is float) | ||
200 | llist[i] = new LSL_Float((float)result[i]); | ||
201 | else if (result[i] is OpenMetaverse.Vector3) | ||
202 | { | ||
203 | OpenMetaverse.Vector3 vresult = (OpenMetaverse.Vector3)result[i]; | ||
204 | llist[i] = new LSL_Vector(vresult.X,vresult.Y,vresult.Z); | ||
205 | } | ||
206 | else if (result[i] is OpenMetaverse.Quaternion) | ||
207 | { | ||
208 | OpenMetaverse.Quaternion qresult = (OpenMetaverse.Quaternion)result[i]; | ||
209 | llist[i] = new LSL_Rotation(qresult.X,qresult.Y,qresult.Z,qresult.W); | ||
210 | } | ||
211 | else | ||
212 | { | ||
213 | MODError(String.Format("unknown list element returned by {0}",fname)); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | return new LSL_List(llist); | ||
150 | } | 218 | } |
151 | 219 | ||
152 | /// <summary> | 220 | /// <summary> |
@@ -168,63 +236,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
168 | MODError(String.Format("wrong number of parameters to function {0}",fname)); | 236 | MODError(String.Format("wrong number of parameters to function {0}",fname)); |
169 | 237 | ||
170 | object[] convertedParms = new object[parms.Length]; | 238 | object[] convertedParms = new object[parms.Length]; |
171 | |||
172 | for (int i = 0; i < parms.Length; i++) | 239 | for (int i = 0; i < parms.Length; i++) |
173 | { | 240 | convertedParms[i] = ConvertFromLSL(parms[i],signature[i]); |
174 | if (parms[i] is LSL_String) | ||
175 | { | ||
176 | if (signature[i] != typeof(string)) | ||
177 | MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); | ||
178 | |||
179 | convertedParms[i] = (string)(LSL_String)parms[i]; | ||
180 | } | ||
181 | else if (parms[i] is LSL_Integer) | ||
182 | { | ||
183 | if (signature[i] != typeof(int)) | ||
184 | MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); | ||
185 | |||
186 | convertedParms[i] = (int)(LSL_Integer)parms[i]; | ||
187 | } | ||
188 | else if (parms[i] is LSL_Float) | ||
189 | { | ||
190 | if (signature[i] != typeof(float)) | ||
191 | MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); | ||
192 | |||
193 | convertedParms[i] = (float)(LSL_Float)parms[i]; | ||
194 | } | ||
195 | else if (parms[i] is LSL_Key) | ||
196 | { | ||
197 | if (signature[i] != typeof(string)) | ||
198 | MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); | ||
199 | |||
200 | convertedParms[i] = (string)(LSL_Key)parms[i]; | ||
201 | } | ||
202 | else if (parms[i] is LSL_Rotation) | ||
203 | { | ||
204 | if (signature[i] != typeof(string)) | ||
205 | MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); | ||
206 | |||
207 | convertedParms[i] = (string)(LSL_Rotation)parms[i]; | ||
208 | } | ||
209 | else if (parms[i] is LSL_Vector) | ||
210 | { | ||
211 | if (signature[i] != typeof(string)) | ||
212 | MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); | ||
213 | 241 | ||
214 | convertedParms[i] = (string)(LSL_Vector)parms[i]; | 242 | // now call the function, the contract with the function is that it will always return |
215 | } | 243 | // non-null but don't trust it completely |
216 | else | 244 | try |
217 | { | 245 | { |
218 | if (signature[i] != parms[i].GetType()) | 246 | object result = m_comms.InvokeOperation(m_itemID,fname,convertedParms); |
219 | MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); | 247 | if (result != null) |
248 | return result; | ||
220 | 249 | ||
221 | convertedParms[i] = parms[i]; | 250 | MODError(String.Format("Invocation of {0} failed; null return value",fname)); |
222 | } | 251 | } |
252 | catch (Exception e) | ||
253 | { | ||
254 | MODError(String.Format("Invocation of {0} failed; {1}",fname,e.Message)); | ||
223 | } | 255 | } |
224 | 256 | ||
225 | return m_comms.InvokeOperation(m_itemID,fname,convertedParms); | 257 | return null; |
226 | } | 258 | } |
227 | 259 | ||
260 | /// <summary> | ||
261 | /// Send a command to functions registered on an event | ||
262 | /// </summary> | ||
228 | public string modSendCommand(string module, string command, string k) | 263 | public string modSendCommand(string module, string command, string k) |
229 | { | 264 | { |
230 | if (!m_MODFunctionsEnabled) | 265 | if (!m_MODFunctionsEnabled) |
@@ -239,5 +274,101 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
239 | 274 | ||
240 | return req.ToString(); | 275 | return req.ToString(); |
241 | } | 276 | } |
277 | |||
278 | /// <summary> | ||
279 | /// </summary> | ||
280 | protected object ConvertFromLSL(object lslparm, Type type) | ||
281 | { | ||
282 | // ---------- String ---------- | ||
283 | if (lslparm is LSL_String) | ||
284 | { | ||
285 | if (type == typeof(string)) | ||
286 | return (string)(LSL_String)lslparm; | ||
287 | |||
288 | // Need to check for UUID since keys are often treated as strings | ||
289 | if (type == typeof(UUID)) | ||
290 | return new UUID((string)(LSL_String)lslparm); | ||
291 | } | ||
292 | |||
293 | // ---------- Integer ---------- | ||
294 | else if (lslparm is LSL_Integer) | ||
295 | { | ||
296 | if (type == typeof(int)) | ||
297 | return (int)(LSL_Integer)lslparm; | ||
298 | } | ||
299 | |||
300 | // ---------- Float ---------- | ||
301 | else if (lslparm is LSL_Float) | ||
302 | { | ||
303 | if (type == typeof(float)) | ||
304 | return (float)(LSL_Float)lslparm; | ||
305 | } | ||
306 | |||
307 | // ---------- Key ---------- | ||
308 | else if (lslparm is LSL_Key) | ||
309 | { | ||
310 | if (type == typeof(UUID)) | ||
311 | return new UUID((LSL_Key)lslparm); | ||
312 | } | ||
313 | |||
314 | // ---------- Rotation ---------- | ||
315 | else if (lslparm is LSL_Rotation) | ||
316 | { | ||
317 | if (type == typeof(OpenMetaverse.Quaternion)) | ||
318 | { | ||
319 | LSL_Rotation rot = (LSL_Rotation)lslparm; | ||
320 | return new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); | ||
321 | } | ||
322 | } | ||
323 | |||
324 | // ---------- Vector ---------- | ||
325 | else if (lslparm is LSL_Vector) | ||
326 | { | ||
327 | if (type == typeof(OpenMetaverse.Vector3)) | ||
328 | { | ||
329 | LSL_Vector vect = (LSL_Vector)lslparm; | ||
330 | return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); | ||
331 | } | ||
332 | } | ||
333 | |||
334 | // ---------- List ---------- | ||
335 | else if (lslparm is LSL_List) | ||
336 | { | ||
337 | if (type == typeof(object[])) | ||
338 | { | ||
339 | object[] plist = (lslparm as LSL_List).Data; | ||
340 | object[] result = new object[plist.Length]; | ||
341 | for (int i = 0; i < plist.Length; i++) | ||
342 | { | ||
343 | if (plist[i] is LSL_String) | ||
344 | result[i] = (string)(LSL_String)plist[i]; | ||
345 | else if (plist[i] is LSL_Integer) | ||
346 | result[i] = (int)(LSL_Integer)plist[i]; | ||
347 | else if (plist[i] is LSL_Float) | ||
348 | result[i] = (float)(LSL_Float)plist[i]; | ||
349 | else if (plist[i] is LSL_Key) | ||
350 | result[i] = new UUID((LSL_Key)plist[i]); | ||
351 | else if (plist[i] is LSL_Rotation) | ||
352 | { | ||
353 | LSL_Rotation rot = (LSL_Rotation)plist[i]; | ||
354 | result[i] = new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); | ||
355 | } | ||
356 | else if (plist[i] is LSL_Vector) | ||
357 | { | ||
358 | LSL_Vector vect = (LSL_Vector)plist[i]; | ||
359 | result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); | ||
360 | } | ||
361 | else | ||
362 | MODError("unknown LSL list element type"); | ||
363 | } | ||
364 | |||
365 | return result; | ||
366 | } | ||
367 | } | ||
368 | |||
369 | MODError(String.Format("parameter type mismatch; expecting {0}",type.Name)); | ||
370 | return null; | ||
371 | } | ||
372 | |||
242 | } | 373 | } |
243 | } | 374 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs index 756a59f..d258f76 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs | |||
@@ -28,26 +28,26 @@ | |||
28 | using System.Collections; | 28 | using System.Collections; |
29 | using OpenSim.Region.ScriptEngine.Interfaces; | 29 | using OpenSim.Region.ScriptEngine.Interfaces; |
30 | 30 | ||
31 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 31 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
32 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | 32 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; |
33 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | 33 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
34 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | 34 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; |
35 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
35 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 36 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
36 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | 37 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; |
37 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
38 | 38 | ||
39 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | 39 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces |
40 | { | 40 | { |
41 | public interface IMOD_Api | 41 | public interface IMOD_Api |
42 | { | 42 | { |
43 | // Invocation functions | 43 | // Invocation functions |
44 | string modInvokeS(string fname, params object[] parms); | 44 | LSL_String modInvokeS(string fname, params object[] parms); |
45 | int modInvokeI(string fname, params object[] parms); | 45 | LSL_Integer modInvokeI(string fname, params object[] parms); |
46 | float modInvokeF(string fname, params object[] parms); | 46 | LSL_Float modInvokeF(string fname, params object[] parms); |
47 | // vector modInvokeV(string fname, params object[] parms); | 47 | LSL_Key modInvokeK(string fname, params object[] parms); |
48 | // rotation modInvokeV(string fname, params object[] parms); | 48 | LSL_Vector modInvokeV(string fname, params object[] parms); |
49 | // key modInvokeK(string fname, params object[] parms); | 49 | LSL_Rotation modInvokeR(string fname, params object[] parms); |
50 | // list modInvokeL(string fname, params object[] parms); | 50 | LSL_List modInvokeL(string fname, params object[] parms); |
51 | 51 | ||
52 | //Module functions | 52 | //Module functions |
53 | string modSendCommand(string modules, string command, string k); | 53 | string modSendCommand(string modules, string command, string k); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs index 04b7f14..e7a4b2b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs | |||
@@ -39,10 +39,14 @@ using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | |||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | 39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; |
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | 40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; |
41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
42 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | 42 | |
43 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
44 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | 43 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
45 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | 44 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; |
45 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
46 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
47 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
48 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
49 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
46 | 50 | ||
47 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | 51 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase |
48 | { | 52 | { |
@@ -58,21 +62,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
58 | m_MOD_Functions = (IMOD_Api)api; | 62 | m_MOD_Functions = (IMOD_Api)api; |
59 | } | 63 | } |
60 | 64 | ||
61 | public string modInvokeS(string fname, params object[] parms) | 65 | public LSL_String modInvokeS(string fname, params object[] parms) |
62 | { | 66 | { |
63 | return m_MOD_Functions.modInvokeS(fname, parms); | 67 | return m_MOD_Functions.modInvokeS(fname, parms); |
64 | } | 68 | } |
65 | 69 | ||
66 | public int modInvokeI(string fname, params object[] parms) | 70 | public LSL_Integer modInvokeI(string fname, params object[] parms) |
67 | { | 71 | { |
68 | return m_MOD_Functions.modInvokeI(fname, parms); | 72 | return m_MOD_Functions.modInvokeI(fname, parms); |
69 | } | 73 | } |
70 | 74 | ||
71 | public float modInvokeF(string fname, params object[] parms) | 75 | public LSL_Float modInvokeF(string fname, params object[] parms) |
72 | { | 76 | { |
73 | return m_MOD_Functions.modInvokeF(fname, parms); | 77 | return m_MOD_Functions.modInvokeF(fname, parms); |
74 | } | 78 | } |
75 | 79 | ||
80 | public LSL_Key modInvokeK(string fname, params object[] parms) | ||
81 | { | ||
82 | return m_MOD_Functions.modInvokeK(fname, parms); | ||
83 | } | ||
84 | |||
85 | public LSL_Vector modInvokeV(string fname, params object[] parms) | ||
86 | { | ||
87 | return m_MOD_Functions.modInvokeV(fname, parms); | ||
88 | } | ||
89 | |||
90 | public LSL_Rotation modInvokeR(string fname, params object[] parms) | ||
91 | { | ||
92 | return m_MOD_Functions.modInvokeR(fname, parms); | ||
93 | } | ||
94 | |||
95 | public LSL_List modInvokeL(string fname, params object[] parms) | ||
96 | { | ||
97 | return m_MOD_Functions.modInvokeL(fname, parms); | ||
98 | } | ||
99 | |||
76 | public string modSendCommand(string module, string command, string k) | 100 | public string modSendCommand(string module, string command, string k) |
77 | { | 101 | { |
78 | return m_MOD_Functions.modSendCommand(module, command, k); | 102 | return m_MOD_Functions.modSendCommand(module, command, k); |