From f3afa68a2af6ad5999e6efe3e4725cb17293108d Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 14 Feb 2008 12:16:33 +0000 Subject: * Made new Framework.Constants class, added RegionSize member. * Converted all instances of "256" spotted to use RegionSize instead. Some approximations used for border crossings (ie 255.9f) are still using that value, but should be updated to use something based on RegionSize. * Moving Terrain to a RegionModule, implemented ITerrainChannel and TerrainModule - nonfunctional, but will be soon. --- .../Communications/Local/LocalLoginService.cs | 4 +- .../Environment/Interfaces/ITerrainChannel.cs | 10 ++ OpenSim/Region/Environment/LandManagement/Land.cs | 4 +- .../Environment/LandManagement/LandManager.cs | 4 +- OpenSim/Region/Environment/Modules/ChatModule.cs | 4 +- .../Region/Environment/Modules/TerrainModule.cs | 131 +++++++++++++++++++++ OpenSim/Region/Environment/Scenes/InnerScene.cs | 2 +- OpenSim/Region/Environment/Scenes/Scene.cs | 24 ++-- .../Region/Environment/Scenes/SceneObjectGroup.cs | 2 +- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 23 ++-- .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 8 +- .../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 2 +- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 8 +- OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 18 +-- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 2 +- .../DotNetEngine/Compiler/LSL/Compiler.cs | 64 ++++++---- 16 files changed, 232 insertions(+), 78 deletions(-) create mode 100644 OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs create mode 100644 OpenSim/Region/Environment/Modules/TerrainModule.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index f6dd379..53748ab 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -128,8 +128,8 @@ namespace OpenSim.Region.Communications.Local if (reg != null) { - response.Home = "{'region_handle':[r" + (reg.RegionLocX*256).ToString() + ",r" + - (reg.RegionLocY*256).ToString() + "], " + + response.Home = "{'region_handle':[r" + (reg.RegionLocX * Constants.RegionSize).ToString() + ",r" + + (reg.RegionLocY * Constants.RegionSize).ToString() + "], " + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + diff --git a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs new file mode 100644 index 0000000..9f70b98 --- /dev/null +++ b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs @@ -0,0 +1,10 @@ +using System; +namespace OpenSim.Region.Environment.Interfaces +{ + interface ITerrainChannel + { + int Height { get; } + double this[int x, int y] { get; set; } + int Width { get; } + } +} diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index 7cc8519..fec8899 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -78,7 +78,7 @@ namespace OpenSim.Region.Environment.LandManagement /// Returns true if the piece of land contains the specified point public bool containsPoint(int x, int y) { - if (x >= 0 && y >= 0 && x <= 256 && x <= 256) + if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) { return (landBitmap[x/4, y/4] == true); } @@ -545,7 +545,7 @@ namespace OpenSim.Region.Environment.LandManagement /// public static bool[,] basicFullRegionLandBitmap() { - return getSquareLandBitmap(0, 0, 256, 256); + return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize); } /// diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index a4d8868..f5e2a3e 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -281,7 +281,7 @@ namespace OpenSim.Region.Environment.LandManagement public Land getLandObject(int x, int y) { - if (x >= 256 || y >= 256 || x < 0 || y < 0) + if (x >= Constants.RegionSize || y >= Constants.RegionSize || x < 0 || y < 0) { // These exceptions here will cause a lot of complaints from the users specifically because // they happen every time at border crossings @@ -614,7 +614,7 @@ namespace OpenSim.Region.Environment.LandManagement Land fullSimParcel = new Land(LLUUID.Zero, false, m_scene); - fullSimParcel.setLandBitmap(Land.getSquareLandBitmap(0, 0, 256, 256)); + fullSimParcel.setLandBitmap(Land.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); fullSimParcel.landData.ownerID = m_regInfo.MasterAvatarAssignedUUID; addLandObject(fullSimParcel); diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 82bd2ec..a34bd96 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -223,7 +223,7 @@ namespace OpenSim.Region.Environment.Modules // Filled in since it's easier than rewriting right now. LLVector3 fromPos = e.Position; - LLVector3 regionPos = new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0); + LLVector3 regionPos = new LLVector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); string fromName = e.From; string message = e.Message; @@ -237,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules if (avatar != null) { fromPos = avatar.AbsolutePosition; - regionPos = new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0); + regionPos = new LLVector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); fromName = avatar.Firstname + " " + avatar.Lastname; fromAgentID = e.Sender.AgentId; } diff --git a/OpenSim/Region/Environment/Modules/TerrainModule.cs b/OpenSim/Region/Environment/Modules/TerrainModule.cs new file mode 100644 index 0000000..7e163a3 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/TerrainModule.cs @@ -0,0 +1,131 @@ +/* +* 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 Nini.Config; +using System; +using System.Collections; +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using libsecondlife; + +namespace OpenSim.Region.Environment.Modules +{ + /// + /// A new version of the old Channel class, simplified + /// + public class TerrainChannel : ITerrainChannel + { + private double[,] map; + + public int Width + { + get { return map.GetLength(0); } + } + + public int Height + { + get { return map.GetLength(1); } + } + + public TerrainChannel Copy() + { + TerrainChannel copy = new TerrainChannel(false); + copy.map = (double[,])this.map.Clone(); + + return copy; + } + + public double this[int x, int y] + { + get + { + return map[x, y]; + } + set + { + map[x, y] = value; + } + } + + public TerrainChannel() + { + map = new double[Constants.RegionSize, Constants.RegionSize]; + } + + public TerrainChannel(bool createMap) + { + if (createMap) + map = new double[Constants.RegionSize, Constants.RegionSize]; + } + + public TerrainChannel(int w, int h) + { + map = new double[w, h]; + } + } + + public class TerrainModule : IRegionModule + { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + Scene m_scene; + + private IConfigSource m_gConfig; + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + m_gConfig = config; + } + + public void Close() + { + + } + + public string Name + { + get { return "TerrainModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + public void PostInitialise() + { + + } + + } + +} diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 7698127..48fa3dc 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -81,7 +81,7 @@ namespace OpenSim.Region.Environment.Scenes m_parentScene = parent; m_regInfo = regInfo; PermissionsMngr = permissionsMngr; - QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, 256, 256); + QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, (short)Constants.RegionSize, (short)Constants.RegionSize); QuadTree.Subdivide(); QuadTree.Subdivide(); } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 5842932..eec51e6 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1232,31 +1232,31 @@ namespace OpenSim.Region.Environment.Scenes ulong newRegionHandle = 0; LLVector3 pos = position; - if (position.X > 257f) + if (position.X > Constants.RegionSize + 0.1f) { - pos.X = ((pos.X - 256)); - - newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * 256), (uint)(thisy * 256)); + pos.X = ((pos.X - Constants.RegionSize)); + + newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); // x + 1 } - else if (position.X < -1f) + else if (position.X < -0.1f) { - pos.X = ((pos.X + 256)); - newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * 256), (uint)(thisy * 256)); + pos.X = ((pos.X + Constants.RegionSize)); + newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); // x - 1 } - if (position.Y > 257f) + if (position.Y > Constants.RegionSize + 0.1f) { - pos.Y = ((pos.Y - 256)); - newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy + 1) * 256)); + pos.Y = ((pos.Y - Constants.RegionSize)); + newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); // y + 1 } else if (position.Y < -1f) { - pos.Y = ((pos.Y + 256)); - newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy - 1) * 256)); + pos.Y = ((pos.Y + Constants.RegionSize)); + newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize)); // y - 1 } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index aa2f2d0..e8d4766 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -387,7 +387,7 @@ namespace OpenSim.Region.Environment.Scenes // This may need to be updated to the maximum draw distance possible.. // We might (and probably will) be checking for prim creation from other sims // when the camera crosses the border. - float idist = 256f; + float idist = (float)Constants.RegionSize; if (inter.HitTF) diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 61fce39..2b02ab9 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -1514,12 +1514,12 @@ namespace OpenSim.Region.Environment.Scenes pos2.Y = pos2.Y + (vel.Y*timeStep); pos2.Z = pos2.Z + (vel.Z*timeStep); - if ((pos2.X < 0) || (pos2.X > 256)) + if ((pos2.X < 0) || (pos2.X > Constants.RegionSize)) { CrossToNewRegion(); } - if ((pos2.Y < 0) || (pos2.Y > 256)) + if ((pos2.Y < 0) || (pos2.Y > Constants.RegionSize)) { CrossToNewRegion(); } @@ -1544,17 +1544,12 @@ namespace OpenSim.Region.Environment.Scenes // distance into new region to place avatar const float enterDistance = 0.1f; - // region size - // TODO: this should be hard-coded in some common place - const float regionWidth = 256; - const float regionHeight = 256; - if (pos.X < boundaryDistance) { neighbourx--; - newpos.X = regionWidth - enterDistance; + newpos.X = Constants.RegionSize - enterDistance; } - else if (pos.X > regionWidth - boundaryDistance) + else if (pos.X > Constants.RegionSize - boundaryDistance) { neighbourx++; newpos.X = enterDistance; @@ -1563,16 +1558,16 @@ namespace OpenSim.Region.Environment.Scenes if (pos.Y < boundaryDistance) { neighboury--; - newpos.Y = regionHeight - enterDistance; + newpos.Y = Constants.RegionSize - enterDistance; } - else if (pos.Y > regionHeight - boundaryDistance) + else if (pos.Y > Constants.RegionSize - boundaryDistance) { neighboury++; newpos.Y = enterDistance; } LLVector3 vel = m_velocity; - ulong neighbourHandle = Helpers.UIntsToLong((uint) (neighbourx*256), (uint) (neighboury*256)); + ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); if (neighbourRegion != null) { @@ -1622,8 +1617,8 @@ namespace OpenSim.Region.Environment.Scenes public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) { // - int shiftx = ((int)rRegionX - (int)tRegionX) * 256; - int shifty = ((int)rRegionY - (int)tRegionY) * 256; + int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; + int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; m_DrawDistance = cAgentData.drawdistance; m_pos = new LLVector3(cAgentData.Position.x + shiftx, cAgentData.Position.y + shifty, cAgentData.Position.z); diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index a32bca5..d767eab 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -137,7 +137,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { actor.Position.Y = 0.1F; } - else if (actor.Position.Y >= 256) + else if (actor.Position.Y >= Constants.RegionSize) { actor.Position.Y = 255.9F; } @@ -146,16 +146,16 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { actor.Position.X = 0.1F; } - else if (actor.Position.X >= 256) + else if (actor.Position.X >= Constants.RegionSize) { actor.Position.X = 255.9F; } - float height = _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 1.0f; + float height = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + 1.0f; if (actor.Flying) { if (actor.Position.Z + (actor.Velocity.Z*timeStep) < - _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 2) + _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + 2) { actor.Position.Z = height; actor.Velocity.Z = 0; diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 5a8589c..314708f 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -336,7 +336,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin private const int minXY = 0; private const int minZ = 0; - private const int maxXY = 256; + private const int maxXY = (int)Constants.RegionSize; private const int maxZ = 4096; private const int maxHandles = 32766; //Why? I don't know private const float gravity = 9.8f; diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 4fbf653..3d70a3d 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -85,9 +85,9 @@ namespace OpenSim.Region.Physics.OdePlugin private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); CollisionLocker ode; - // TODO: this should be hard-coded in some common place - private const uint m_regionWidth = 256; - private const uint m_regionHeight = 256; + + private const uint m_regionWidth = Constants.RegionSize; + private const uint m_regionHeight = Constants.RegionSize; private static float ODE_STEPSIZE = 0.020f; private static bool RENDER_FLAG = false; @@ -585,7 +585,7 @@ namespace OpenSim.Region.Physics.OdePlugin } private float GetTerrainHeightAtXY(float x, float y) { - return (float)_origheightmap[(int) y*256 + (int) x]; + return (float)_origheightmap[(int)y * Constants.RegionSize + (int)x]; } diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index 7652934..3bd25f6 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs @@ -203,21 +203,21 @@ namespace OpenSim.Region.Physics.POSPlugin { character.Position.Y = 0.1F; } - else if (character.Position.Y >= 256) + else if (character.Position.Y >= Constants.RegionSize) { - character.Position.Y = 255.9F; + character.Position.Y = Constants.RegionSize - 0.1f; } if (character.Position.X < 0) { character.Position.X = 0.1F; } - else if (character.Position.X >= 256) + else if (character.Position.X >= Constants.RegionSize) { - character.Position.X = 255.9F; + character.Position.X = Constants.RegionSize - 0.1f; } - float terrainheight = _heightMap[(int) character.Position.Y*256 + (int) character.Position.X]; + float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X]; if (character.Position.Z + (character._target_velocity.Z*timeStep) < terrainheight + 2) { character.Position.Z = terrainheight + 1.0f; @@ -269,18 +269,18 @@ namespace OpenSim.Region.Physics.POSPlugin { character.Position.Y = 0.1F; } - else if (character.Position.Y >= 256) + else if (character.Position.Y >= Constants.RegionSize) { - character.Position.Y = 255.9F; + character.Position.Y = Constants.RegionSize - 0.1f; } if (character.Position.X < 0) { character.Position.X = 0.1F; } - else if (character.Position.X >= 256) + else if (character.Position.X >= Constants.RegionSize) { - character.Position.X = 255.9F; + character.Position.X = Constants.RegionSize - 0.1f; } character._velocity.X = (character.Position.X - oldposX)/timeStep; diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 2fc610a..c350301 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -2232,7 +2232,7 @@ namespace OpenSim.Region.ScriptEngine.Common public LSL_Types.Vector3 llGetRegionCorner() { m_host.AddScriptLPS(1); - return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * 256, World.RegionInfo.RegionLocY * 256, 0); + return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * Constants.RegionSize, World.RegionInfo.RegionLocY * Constants.RegionSize, 0); } public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start) diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index 5c8b4b5..58586c0 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -272,41 +272,59 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL switch (l) { case enumCompileType.cs: - compileScript = String.Empty + - "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" + - String.Empty + "namespace SecondLife { " + - String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { \r\n" + - @"public Script() { } " + - compileScript + - "} }\r\n"; + compileScript = CreateCSCompilerScript(compileScript); break; case enumCompileType.vb: - compileScript = String.Empty + - "Imports OpenSim.Region.ScriptEngine.Common: Imports System.Collections.Generic: " + - String.Empty + "NameSpace SecondLife:" + - String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.Common.LSL_BaseClass: " + - "\r\nPublic Sub New()\r\nEnd Sub: " + - compileScript + - ":End Class :End Namespace\r\n"; + compileScript = CreateVBCompilerScript(compileScript); break; case enumCompileType.js: - compileScript = String.Empty + - "import OpenSim.Region.ScriptEngine.Common; import System.Collections.Generic;\r\n" + - "package SecondLife {\r\n" + - "class Script extends OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { \r\n" + - compileScript + - "} }\r\n"; + compileScript = CreateJSCompilerScript(compileScript); break; } - return CompileFromCSorVBText(compileScript, l); + return CompileFromDotNetText(compileScript, l); + } + + private static string CreateJSCompilerScript(string compileScript) + { + compileScript = String.Empty + + "import OpenSim.Region.ScriptEngine.Common; import System.Collections.Generic;\r\n" + + "package SecondLife {\r\n" + + "class Script extends OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { \r\n" + + compileScript + + "} }\r\n"; + return compileScript; + } + + private static string CreateCSCompilerScript(string compileScript) + { + compileScript = String.Empty + + "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" + + String.Empty + "namespace SecondLife { " + + String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { \r\n" + + @"public Script() { } " + + compileScript + + "} }\r\n"; + return compileScript; + } + + private static string CreateVBCompilerScript(string compileScript) + { + compileScript = String.Empty + + "Imports OpenSim.Region.ScriptEngine.Common: Imports System.Collections.Generic: " + + String.Empty + "NameSpace SecondLife:" + + String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.Common.LSL_BaseClass: " + + "\r\nPublic Sub New()\r\nEnd Sub: " + + compileScript + + ":End Class :End Namespace\r\n"; + return compileScript; } /// - /// Compile CS script to .Net assembly (.dll) + /// Compile .NET script to .Net assembly (.dll) /// /// CS script /// Filename to .dll assembly - internal string CompileFromCSorVBText(string Script, enumCompileType lang) + internal string CompileFromDotNetText(string Script, enumCompileType lang) { string ext = "." + lang.ToString(); -- cgit v1.1