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. --- OpenSim/Framework/Communications/LoginResponse.cs | 10 +- OpenSim/Framework/Constants.cs | 11 ++ OpenSim/Framework/Data/RegionProfileData.cs | 4 +- OpenSim/Framework/RegionHandle.cs | 6 +- OpenSim/Framework/RegionInfo.cs | 2 +- OpenSim/Framework/SerializableRegionInfo.cs | 2 +- OpenSim/Framework/UserProfileData.cs | 2 +- OpenSim/Grid/GridServer/GridManager.cs | 28 ++--- OpenSim/Grid/MessagingServer/MessageService.cs | 2 +- OpenSim/Grid/UserServer/UserLoginService.cs | 10 +- .../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 ++++++---- 26 files changed, 276 insertions(+), 111 deletions(-) create mode 100644 OpenSim/Framework/Constants.cs create mode 100644 OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs create mode 100644 OpenSim/Region/Environment/Modules/TerrainModule.cs diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 9036884..00b691e 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -152,7 +152,7 @@ namespace OpenSim.Framework.UserManagement ErrorReason = "key"; welcomeMessage = "Welcome to OpenSim!"; seedCapability = String.Empty; - home = "{'region_handle':[r" + (1000*256).ToString() + ",r" + (1000*256).ToString() + "], 'position':[r" + + home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" + userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; @@ -347,8 +347,8 @@ namespace OpenSim.Framework.UserManagement responseData["home"] = home; responseData["look_at"] = lookAt; responseData["message"] = welcomeMessage; - responseData["region_x"] = (Int32) RegionX*256; - responseData["region_y"] = (Int32) RegionY*256; + responseData["region_x"] = (Int32)RegionX * Constants.RegionSize; + responseData["region_y"] = (Int32)RegionY * Constants.RegionSize; //responseData["inventory-lib-root"] = new ArrayList(); // todo @@ -447,8 +447,8 @@ namespace OpenSim.Framework.UserManagement map["home"] = LLSD.FromString(home); map["look_at"] = LLSD.FromString(lookAt); map["message"] = LLSD.FromString(welcomeMessage); - map["region_x"] = LLSD.FromInteger(RegionX * 256); - map["region_y"] = LLSD.FromInteger(RegionY * 256); + map["region_x"] = LLSD.FromInteger(RegionX * Constants.RegionSize); + map["region_y"] = LLSD.FromInteger(RegionY * Constants.RegionSize); if (m_buddyList != null) { diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs new file mode 100644 index 0000000..b308221 --- /dev/null +++ b/OpenSim/Framework/Constants.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework +{ + public class Constants + { + public const uint RegionSize = 256; + } +} diff --git a/OpenSim/Framework/Data/RegionProfileData.cs b/OpenSim/Framework/Data/RegionProfileData.cs index 48d3ebc..8119d01 100644 --- a/OpenSim/Framework/Data/RegionProfileData.cs +++ b/OpenSim/Framework/Data/RegionProfileData.cs @@ -169,7 +169,7 @@ namespace OpenSim.Framework.Data RegionProfileData simData = new RegionProfileData(); simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); - simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX*256), (simData.regionLocY*256)); + simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); simData.serverIP = (string) responseData["sim_ip"]; simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); @@ -203,7 +203,7 @@ namespace OpenSim.Framework.Data RegionProfileData simData = new RegionProfileData(); simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); - simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX*256), (simData.regionLocY*256)); + simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); simData.serverIP = (string) responseData["sim_ip"]; simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); diff --git a/OpenSim/Framework/RegionHandle.cs b/OpenSim/Framework/RegionHandle.cs index 440aaf6..9cfe53d 100644 --- a/OpenSim/Framework/RegionHandle.cs +++ b/OpenSim/Framework/RegionHandle.cs @@ -63,8 +63,8 @@ namespace OpenSim.Framework uint ny = (uint) y; // Multiply grid coords to get region coords - nx *= 256; - ny *= 256; + nx *= Constants.RegionSize; + ny *= Constants.RegionSize; // Stuff the IP address in too nx = (uint) a << 16; @@ -80,7 +80,7 @@ namespace OpenSim.Framework /// Grid Y Coordinate public RegionHandle(uint x, uint y) { - handle = ((x*256) << 32) | (y*256); + handle = ((x * Constants.RegionSize) << 32) | (y * Constants.RegionSize); } /// diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index e953182..f97db5c 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -156,7 +156,7 @@ namespace OpenSim.Framework public ulong RegionHandle { - get { return Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); } + get { return Util.UIntsToLong((RegionLocX * (uint)Constants.RegionSize), (RegionLocY * (uint)Constants.RegionSize)); } } } diff --git a/OpenSim/Framework/SerializableRegionInfo.cs b/OpenSim/Framework/SerializableRegionInfo.cs index 0097fe4..077ed8d 100644 --- a/OpenSim/Framework/SerializableRegionInfo.cs +++ b/OpenSim/Framework/SerializableRegionInfo.cs @@ -155,7 +155,7 @@ namespace OpenSim.Framework public ulong RegionHandle { - get { return Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); } + get { return Util.UIntsToLong((RegionLocX * (uint)Constants.RegionSize), (RegionLocY * (uint)Constants.RegionSize)); } } } } \ No newline at end of file diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs index de44a0d..9c02d78 100644 --- a/OpenSim/Framework/UserProfileData.cs +++ b/OpenSim/Framework/UserProfileData.cs @@ -70,7 +70,7 @@ namespace OpenSim.Framework /// public ulong homeRegion { - get { return Helpers.UIntsToLong((homeRegionX*256), (homeRegionY*256)); } + get { return Helpers.UIntsToLong((homeRegionX * (uint)Constants.RegionSize), (homeRegionY * (uint)Constants.RegionSize)); } set { homeRegionX = (uint) (value >> 40); diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index 0ccffd9..efab4fc 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs @@ -203,13 +203,13 @@ namespace OpenSim.Grid.GridServer { if ( getRegion( - Util.UIntsToLong((uint) ((central_region.regionLocX + x)*256), - (uint) (central_region.regionLocY + y)*256)) != null) + Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize), + (uint)(central_region.regionLocY + y) * Constants.RegionSize)) != null) { neighbour = getRegion( - Util.UIntsToLong((uint) ((central_region.regionLocX + x)*256), - (uint) (central_region.regionLocY + y)*256)); + Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize), + (uint)(central_region.regionLocY + y) * Constants.RegionSize)); response += ""; response += "" + neighbour.serverIP + ""; response += "" + neighbour.serverPort.ToString() + ""; @@ -303,7 +303,7 @@ namespace OpenSim.Grid.GridServer } catch (KeyNotFoundException) { } - TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256)); + TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * Constants.RegionSize), (TheSim.regionLocY * Constants.RegionSize)); TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/"; TheSim.httpServerURI = "http://" + TheSim.serverIP + ":" + TheSim.httpPort + "/"; @@ -416,13 +416,13 @@ namespace OpenSim.Grid.GridServer { if ( getRegion( - Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), - (uint)(TheSim.regionLocY + y) * 256)) != null) + Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * Constants.RegionSize), + (uint)(TheSim.regionLocY + y) * Constants.RegionSize)) != null) { neighbour = getRegion( - Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), - (uint)(TheSim.regionLocY + y) * 256)); + Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * Constants.RegionSize), + (uint)(TheSim.regionLocY + y) * Constants.RegionSize)); NeighbourBlock = new Hashtable(); NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString(); @@ -604,7 +604,7 @@ namespace OpenSim.Grid.GridServer { for (int y = ymin; y < ymax + 1; y++) { - ulong regHandle = Helpers.UIntsToLong((uint) (x*256), (uint) (y*256)); + ulong regHandle = Helpers.UIntsToLong((uint)(x * Constants.RegionSize), (uint)(y * Constants.RegionSize)); simProfile = getRegion(regHandle); if (simProfile != null) { @@ -764,12 +764,12 @@ namespace OpenSim.Grid.GridServer case "region_locx": TheSim.regionLocX = Convert.ToUInt32((string) simnode.ChildNodes[i].InnerText); - TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX*256), (TheSim.regionLocY*256)); + TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * Constants.RegionSize), (TheSim.regionLocY * Constants.RegionSize)); break; case "region_locy": TheSim.regionLocY = Convert.ToUInt32((string) simnode.ChildNodes[i].InnerText); - TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX*256), (TheSim.regionLocY*256)); + TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * Constants.RegionSize), (TheSim.regionLocY * Constants.RegionSize)); break; } } @@ -787,9 +787,9 @@ namespace OpenSim.Grid.GridServer return "ERROR! Servers must register with public addresses."; } - if (requireValid && (TheSim.serverIP.StartsWith("0."))) + if (requireValid && (TheSim.serverIP.StartsWith("0.") || TheSim.serverIP.StartsWith("255."))) { - return "ERROR! 0.*.*.* Addresses are invalid, please check your server config and try again"; + return "ERROR! 0.*.*.* / 255.*.*.* Addresses are invalid, please check your server config and try again"; } diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs index c2669b0..059a6b0 100644 --- a/OpenSim/Grid/MessagingServer/MessageService.cs +++ b/OpenSim/Grid/MessagingServer/MessageService.cs @@ -451,7 +451,7 @@ namespace OpenSim.Grid.MessagingServer regionProfile = new RegionProfileData(); regionProfile.httpPort = (uint)Convert.ToInt32((string)responseData["http_port"]); regionProfile.httpServerURI = "http://" + internalIpStr + ":" + regionProfile.httpPort + "/"; - regionProfile.regionHandle = Helpers.UIntsToLong((regX * 256), (regY * 256)); + regionProfile.regionHandle = Helpers.UIntsToLong((regX * Constants.RegionSize), (regY * Constants.RegionSize)); regionProfile.regionLocX = regX; regionProfile.regionLocY = regY; diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index af234e2..09cd9fd 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -82,8 +82,8 @@ namespace OpenSim.Grid.UserServer // Customise the response //CFK: This is redundant and the next message should always appear. //CFK: m_log.Info("[LOGIN]: Home Location"); - response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" + - (SimInfo.regionLocY*256).ToString() + "], " + + response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" + + (SimInfo.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" + @@ -144,7 +144,7 @@ namespace OpenSim.Grid.UserServer // Send him to default region instead // Load information from the gridserver - ulong defaultHandle = (((ulong) m_config.DefaultX*256) << 32) | ((ulong) m_config.DefaultY*256); + ulong defaultHandle = (((ulong)m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong)m_config.DefaultY * Constants.RegionSize); m_log.Warn( "[LOGIN]: Home region not available: sending to default " + defaultHandle.ToString()); @@ -158,8 +158,8 @@ namespace OpenSim.Grid.UserServer // Customise the response m_log.Info("[LOGIN]: Home Location"); - response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" + - (SimInfo.regionLocY*256).ToString() + "], " + + response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" + + (SimInfo.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/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