* 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.
ThreadPoolClientBranch
Adam Frisby 2008-02-14 12:16:33 +00:00
parent c0d411f427
commit f3afa68a2a
26 changed files with 276 additions and 111 deletions

View File

@ -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)
{

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework
{
public class Constants
{
public const uint RegionSize = 256;
}
}

View File

@ -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"]);

View File

@ -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
/// <param name="y">Grid Y Coordinate</param>
public RegionHandle(uint x, uint y)
{
handle = ((x*256) << 32) | (y*256);
handle = ((x * Constants.RegionSize) << 32) | (y * Constants.RegionSize);
}
/// <summary>

View File

@ -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)); }
}
}

View File

@ -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)); }
}
}
}

View File

@ -70,7 +70,7 @@ namespace OpenSim.Framework
/// </summary>
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);

View File

@ -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 += "<neighbour>";
response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>";
response += "<sim_port>" + neighbour.serverPort.ToString() + "</sim_port>";
@ -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";
}

View File

@ -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;

View File

@ -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" +

View File

@ -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" +

View File

@ -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; }
}
}

View File

@ -78,7 +78,7 @@ namespace OpenSim.Region.Environment.LandManagement
/// <returns>Returns true if the piece of land contains the specified point</returns>
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
/// <returns></returns>
public static bool[,] basicFullRegionLandBitmap()
{
return getSquareLandBitmap(0, 0, 256, 256);
return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize);
}
/// <summary>

View File

@ -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);

View File

@ -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;
}

View File

@ -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
{
/// <summary>
/// A new version of the old Channel class, simplified
/// </summary>
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()
{
}
}
}

View File

@ -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();
}

View File

@ -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
}

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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];
}

View File

@ -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;

View File

@ -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)

View File

@ -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;
}
/// <summary>
/// Compile CS script to .Net assembly (.dll)
/// Compile .NET script to .Net assembly (.dll)
/// </summary>
/// <param name="Script">CS script</param>
/// <returns>Filename to .dll assembly</returns>
internal string CompileFromCSorVBText(string Script, enumCompileType lang)
internal string CompileFromDotNetText(string Script, enumCompileType lang)
{
string ext = "." + lang.ToString();