From 96abbbb6fbab56e29c8a8af6974ef1df90e45ddf Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 19 Sep 2013 12:14:21 -0700 Subject: VarRegion: change RegionInfo storage of region coordinates from region count number to integer world coordinates. Added new methods RegionWorldLoc[XY]. Refactored name of 'RegionLoc*' to 'LegacyRegionLoc*' throughout OpenSim. Kept old 'RegionLoc*' entrypoint to RegionInfo for downward compatability of external region management packages. --- .../LoadRegions/LoadRegionsPlugin.cs | 4 +- .../RemoteController/RemoteAdminPlugin.cs | 20 +++--- OpenSim/Data/Tests/RegionTests.cs | 8 +-- OpenSim/Framework/RegionInfo.cs | 82 ++++++++++++++++------ OpenSim/Region/Application/OpenSim.cs | 4 +- OpenSim/Region/Application/OpenSimBase.cs | 2 +- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 4 +- .../Region/CoreModules/Avatar/Chat/ChatModule.cs | 8 +-- .../Avatar/UserProfiles/UserProfileModule.cs | 4 +- .../EntityTransfer/EntityTransferModule.cs | 48 ++++++------- .../Scripting/EMailModules/EmailModule.cs | 4 +- .../MapImage/MapImageServiceModule.cs | 4 +- .../World/Archiver/ArchiveScenesGroup.cs | 8 +-- .../World/Archiver/DearchiveScenesGroup.cs | 2 +- .../World/Estate/EstateManagementCommands.cs | 12 ++-- .../CoreModules/World/Land/LandManagementModule.cs | 4 +- .../CoreModules/World/Terrain/TerrainModule.cs | 10 +-- .../CoreModules/World/WorldMap/WorldMapModule.cs | 22 +++--- OpenSim/Region/Framework/Scenes/Scene.cs | 24 +++---- OpenSim/Region/Framework/Scenes/SceneManager.cs | 4 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +- .../Region/Framework/Scenes/SimStatsReporter.cs | 2 +- .../OptionalModules/Avatar/Chat/RegionState.cs | 4 +- .../RegionCombinerIndividualEventForwarder.cs | 8 +-- .../RegionCombinerModule/RegionCombinerModule.cs | 28 ++++---- .../Shared/Api/Implementation/LSL_Api.cs | 12 ++-- .../SimianGrid/SimianGridMaptileModule.cs | 4 +- OpenSim/Services/Interfaces/IGridService.cs | 4 +- 28 files changed, 191 insertions(+), 155 deletions(-) diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index 1d63d26..74a7a50 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -184,11 +184,11 @@ namespace OpenSim.ApplicationPlugins.LoadRegions return false; } else if ( - regions[i].RegionLocX == regions[j].RegionLocX && regions[i].RegionLocY == regions[j].RegionLocY) + regions[i].LegacyRegionLocX == regions[j].LegacyRegionLocX && regions[i].LegacyRegionLocY == regions[j].LegacyRegionLocY) { m_log.ErrorFormat( "[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same grid location ({2}, {3})", - regions[i].RegionName, regions[j].RegionName, regions[i].RegionLocX, regions[i].RegionLocY); + regions[i].RegionName, regions[j].RegionName, regions[i].LegacyRegionLocX, regions[i].LegacyRegionLocY); return false; } else if (regions[i].InternalEndPoint.Port == regions[j].InternalEndPoint.Port) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index c78cf3b..7afdd34 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -542,7 +542,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController throw new Exception( String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, - scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); + scene.RegionInfo.LegacyRegionLocX, scene.RegionInfo.LegacyRegionLocY)); } else { @@ -556,8 +556,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController region.RegionID = regionID; region.originRegionID = regionID; region.RegionName = (string) requestData["region_name"]; - region.RegionLocX = Convert.ToUInt32(requestData["region_x"]); - region.RegionLocY = Convert.ToUInt32(requestData["region_y"]); + region.LegacyRegionLocX = Convert.ToUInt32(requestData["region_x"]); + region.LegacyRegionLocY = Convert.ToUInt32(requestData["region_y"]); // check for collisions: region name, region UUID, // region location @@ -565,14 +565,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController throw new Exception( String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>", scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, - scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); + scene.RegionInfo.LegacyRegionLocX, scene.RegionInfo.LegacyRegionLocY)); - if (m_application.SceneManager.TryGetScene(region.RegionLocX, region.RegionLocY, out scene)) + if (m_application.SceneManager.TryGetScene(region.LegacyRegionLocX, region.LegacyRegionLocY, out scene)) throw new Exception( String.Format("region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>", - region.RegionLocX, region.RegionLocY, + region.LegacyRegionLocX, region.LegacyRegionLocY, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, - scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); + scene.RegionInfo.LegacyRegionLocX, scene.RegionInfo.LegacyRegionLocY)); region.InternalEndPoint = new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0); @@ -586,7 +586,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController region.InternalEndPoint.Address, region.InternalEndPoint.Port, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, - scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); + scene.RegionInfo.LegacyRegionLocX, scene.RegionInfo.LegacyRegionLocY)); region.ExternalHostName = (string) requestData["external_address"]; @@ -625,8 +625,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController String.Format( m_config.GetString("region_file_template", "{0}x{1}-{2}.ini"), - region.RegionLocX.ToString(), - region.RegionLocY.ToString(), + region.LegacyRegionLocX.ToString(), + region.LegacyRegionLocY.ToString(), regionID.ToString(), region.InternalEndPoint.Port.ToString(), region.RegionName.Replace(" ", "_").Replace(":", "_"). diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs index dbed8f6..b4989d1 100644 --- a/OpenSim/Data/Tests/RegionTests.cs +++ b/OpenSim/Data/Tests/RegionTests.cs @@ -300,8 +300,8 @@ namespace OpenSim.Data.Tests RegionInfo regionInfo = new RegionInfo(); regionInfo.RegionID = region3; - regionInfo.RegionLocX = 0; - regionInfo.RegionLocY = 0; + regionInfo.LegacyRegionLocX = 0; + regionInfo.LegacyRegionLocY = 0; SceneObjectPart sop = new SceneObjectPart(); SceneObjectGroup sog = new SceneObjectGroup(sop); @@ -1066,8 +1066,8 @@ namespace OpenSim.Data.Tests { RegionInfo regionInfo = new RegionInfo(); regionInfo.RegionID = regionId; - regionInfo.RegionLocX = 0; - regionInfo.RegionLocY = 0; + regionInfo.LegacyRegionLocX = 0; + regionInfo.LegacyRegionLocY = 0; SceneObjectPart sop = new SceneObjectPart(); sop.Name = name; diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 24b9c89..255c8e0 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -137,8 +137,8 @@ namespace OpenSim.Framework public bool m_allow_alternate_ports; protected string m_externalHostName; protected IPEndPoint m_internalEndPoint; - protected uint? m_regionLocX; - protected uint? m_regionLocY; + public uint RegionWorldLocX { get; set; } + public uint RegionWorldLocY { get; set; } protected uint m_remotingPort; public UUID RegionID = UUID.Zero; public string RemotingAddress; @@ -147,6 +147,11 @@ namespace OpenSim.Framework private Dictionary m_otherSettings = new Dictionary(); + // Originally, regions were fixed size of 256 in X and Y. + // For downward compatability, 'RegionLocX' returns the region coordinates in the legacy region units. + // This is the constant used to convert world integer coordinates to legacy region units. + public const uint LegacyRegionSize = 256; + // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. @@ -229,10 +234,10 @@ namespace OpenSim.Framework m_serverURI = string.Empty; } - public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) + public RegionInfo(uint legacyRegionLocX, uint legacyRegionLocY, IPEndPoint internalEndPoint, string externalUri) { - m_regionLocX = regionLocX; - m_regionLocY = regionLocY; + RegionWorldLocX = legacyRegionLocX * LegacyRegionSize; + RegionWorldLocY = legacyRegionLocY * LegacyRegionSize; m_internalEndPoint = internalEndPoint; m_externalHostName = externalUri; @@ -447,25 +452,56 @@ namespace OpenSim.Framework /// /// The x co-ordinate of this region in map tiles (e.g. 1000). + /// Coordinate is scaled as world coordinates divided by the legacy region size + /// and is thus is the number of legacy regions. + /// + public uint LegacyRegionLocX + { + get { return RegionWorldLocX / LegacyRegionSize; } + set { RegionWorldLocX = value * LegacyRegionSize; } + } + + /// + /// The y co-ordinate of this region in map tiles (e.g. 1000). + /// Coordinate is scaled as world coordinates divided by the legacy region size + /// and is thus is the number of legacy regions. + /// + public uint LegacyRegionLocY + { + get { return RegionWorldLocY / LegacyRegionSize; } + set { RegionWorldLocY = value * LegacyRegionSize; } + } + + /// + /// The x co-ordinate of this region in map tiles (e.g. 1000). + /// Coordinate is scaled as world coordinates divided by the legacy region size + /// and is thus is the number of legacy regions. + /// This entrypoint exists for downward compatability for external modules. /// public uint RegionLocX { - get { return m_regionLocX.Value; } - set { m_regionLocX = value; } + get { return LegacyRegionLocX; } + set { LegacyRegionLocX = value; } } /// /// The y co-ordinate of this region in map tiles (e.g. 1000). + /// Coordinate is scaled as world coordinates divided by the legacy region size + /// and is thus is the number of legacy regions. + /// This entrypoint exists for downward compatability for external modules. /// public uint RegionLocY { - get { return m_regionLocY.Value; } - set { m_regionLocY = value; } + get { return LegacyRegionLocY; } + set { LegacyRegionLocY = value; } } + // A unique region handle is created from the region's world coordinates. + // This cannot be changed because some code expects to receive the region handle and then + // compute the region coordinates from it. public ulong RegionHandle { - get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); } + get { return Util.UIntsToLong(RegionWorldLocX, RegionWorldLocY); } } public void SetEndPoint(string ipaddr, int port) @@ -572,8 +608,8 @@ namespace OpenSim.Framework string[] locationElements = location.Split(new char[] {','}); - m_regionLocX = Convert.ToUInt32(locationElements[0]); - m_regionLocY = Convert.ToUInt32(locationElements[1]); + LegacyRegionLocX = Convert.ToUInt32(locationElements[0]); + LegacyRegionLocY = Convert.ToUInt32(locationElements[1]); // InternalAddress // @@ -704,7 +740,7 @@ namespace OpenSim.Framework config.Set("RegionUUID", RegionID.ToString()); - string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY); + string location = String.Format("{0},{1}", LegacyRegionLocX, LegacyRegionLocY); config.Set("Location", location); config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); @@ -790,9 +826,9 @@ namespace OpenSim.Framework configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Region Name", RegionName, true); configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - "Grid Location (X Axis)", m_regionLocX.ToString(), true); + "Grid Location (X Axis)", LegacyRegionLocX.ToString(), true); configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - "Grid Location (Y Axis)", m_regionLocY.ToString(), true); + "Grid Location (Y Axis)", LegacyRegionLocY.ToString(), true); //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); configMember.addConfigurationOption("internal_ip_address", ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, @@ -916,10 +952,10 @@ namespace OpenSim.Framework RegionName = (string) configuration_result; break; case "sim_location_x": - m_regionLocX = (uint) configuration_result; + LegacyRegionLocX = (uint) configuration_result; break; case "sim_location_y": - m_regionLocY = (uint) configuration_result; + LegacyRegionLocY = (uint) configuration_result; break; case "internal_ip_address": IPAddress address = (IPAddress) configuration_result; @@ -1000,8 +1036,8 @@ namespace OpenSim.Framework args["external_host_name"] = OSD.FromString(ExternalHostName); args["http_port"] = OSD.FromString(HttpPort.ToString()); args["server_uri"] = OSD.FromString(ServerURI); - args["region_xloc"] = OSD.FromString(RegionLocX.ToString()); - args["region_yloc"] = OSD.FromString(RegionLocY.ToString()); + args["region_xloc"] = OSD.FromString(LegacyRegionLocX.ToString()); + args["region_yloc"] = OSD.FromString(LegacyRegionLocY.ToString()); args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString()); args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString()); if ((RemotingAddress != null) && !RemotingAddress.Equals("")) @@ -1032,13 +1068,13 @@ namespace OpenSim.Framework { uint locx; UInt32.TryParse(args["region_xloc"].AsString(), out locx); - RegionLocX = locx; + LegacyRegionLocX = locx; } if (args["region_yloc"] != null) { uint locy; UInt32.TryParse(args["region_yloc"].AsString(), out locy); - RegionLocY = locy; + LegacyRegionLocY = locy; } IPAddress ip_addr = null; if (args["internal_ep_address"] != null) @@ -1081,8 +1117,8 @@ namespace OpenSim.Framework { Dictionary kvp = new Dictionary(); kvp["uuid"] = RegionID.ToString(); - kvp["locX"] = RegionLocX.ToString(); - kvp["locY"] = RegionLocY.ToString(); + kvp["locX"] = LegacyRegionLocX.ToString(); + kvp["locY"] = LegacyRegionLocY.ToString(); kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); kvp["external_port"] = ExternalEndPoint.Port.ToString(); kvp["external_host_name"] = ExternalHostName; diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 1cdd868..f16b40d 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -763,8 +763,8 @@ namespace OpenSim MainConsole.Instance.Output(String.Format( "Region Name: {0}, Region XLoc: {1}, Region YLoc: {2}, Region Port: {3}, Estate Name: {4}", scene.RegionInfo.RegionName, - scene.RegionInfo.RegionLocX, - scene.RegionInfo.RegionLocY, + scene.RegionInfo.LegacyRegionLocX, + scene.RegionInfo.LegacyRegionLocY, scene.RegionInfo.InternalEndPoint.Port, scene.RegionInfo.EstateSettings.EstateName)); }); diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index b032e7f..1e34a1e 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -742,7 +742,7 @@ namespace OpenSim { m_log.InfoFormat( "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})", - whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY); + whichRegion.RegionName, whichRegion.LegacyRegionLocX, whichRegion.LegacyRegionLocY); ShutdownClientServer(whichRegion); IScene scene; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 3609ec1..7b7daed 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -2910,8 +2910,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP { pos = (land.AABBMax + land.AABBMin) * 0.5f; } - reply.Data.GlobalX = info.RegionLocX + x; - reply.Data.GlobalY = info.RegionLocY + y; + reply.Data.GlobalX = info.LegacyRegionLocX + x; + reply.Data.GlobalY = info.LegacyRegionLocY + y; reply.Data.GlobalZ = pos.Z; reply.Data.SimName = Utils.StringToBytes(info.RegionName); reply.Data.SnapshotID = land.SnapshotID; diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 5229c08..4616170 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -180,8 +180,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat string message = c.Message; Scene scene = (Scene)c.Scene; Vector3 fromPos = c.Position; - Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, - scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); + Vector3 regionPos = new Vector3(scene.RegionInfo.LegacyRegionLocX * Constants.RegionSize, + scene.RegionInfo.LegacyRegionLocY * Constants.RegionSize, 0); if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; @@ -333,8 +333,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat { Vector3 fromRegionPos = fromPos + regionPos; Vector3 toRegionPos = presence.AbsolutePosition + - new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize, - presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); + new Vector3(presence.Scene.RegionInfo.LegacyRegionLocX * Constants.RegionSize, + presence.Scene.RegionInfo.LegacyRegionLocY * Constants.RegionSize, 0); int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 56ff2bd..7c60a40 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -663,8 +663,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles Vector3 avaPos = p.AbsolutePosition; // Getting the global position for the Avatar - Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.RegionLocX*Constants.RegionSize + avaPos.X, - remoteClient.Scene.RegionInfo.RegionLocY*Constants.RegionSize + avaPos.Y, + Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.LegacyRegionLocX*Constants.RegionSize + avaPos.X, + remoteClient.Scene.RegionInfo.LegacyRegionLocY*Constants.RegionSize + avaPos.Y, avaPos.Z); string landOwnerName = string.Empty; diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 8ae81ac..38c4d17 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -494,8 +494,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } // Check that these are not the same coordinates - if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX && - finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY) + if (finalDestination.RegionLocX == sp.Scene.RegionInfo.LegacyRegionLocX && + finalDestination.RegionLocY == sp.Scene.RegionInfo.LegacyRegionLocY) { // Can't do. Viewer crashes sp.ControllingClient.SendTeleportFailed("Space warp! You would crash. Move to a different region and try again."); @@ -567,8 +567,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // destRegionX, destRegionY, finalDestination.RegionID, finalDestination.ServerURI); // Insanely, RegionLoc on RegionInfo is the 256m map co-ord whilst GridRegion.RegionLoc is the raw meters position. - return Math.Abs(sourceRegion.RegionLocX - destRegion.RegionCoordX) <= MaxTransferDistance - && Math.Abs(sourceRegion.RegionLocY - destRegion.RegionCoordY) <= MaxTransferDistance; + return Math.Abs(sourceRegion.LegacyRegionLocX - destRegion.RegionCoordX) <= MaxTransferDistance + && Math.Abs(sourceRegion.LegacyRegionLocY - destRegion.RegionCoordY) <= MaxTransferDistance; } /// @@ -635,7 +635,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string.Format( "Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way", finalDestination.RegionName, finalDestination.RegionCoordX, finalDestination.RegionCoordY, - sourceRegion.RegionName, sourceRegion.RegionLocX, sourceRegion.RegionLocY, + sourceRegion.RegionName, sourceRegion.LegacyRegionLocX, sourceRegion.LegacyRegionLocY, MaxTransferDistance)); return; @@ -1374,8 +1374,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z); - uint neighbourx = scene.RegionInfo.RegionLocX; - uint neighboury = scene.RegionInfo.RegionLocY; + uint neighbourx = scene.RegionInfo.LegacyRegionLocX; + uint neighboury = scene.RegionInfo.LegacyRegionLocY; const float boundaryDistance = 1.7f; Vector3 northCross = new Vector3(0, boundaryDistance, 0); Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0); @@ -1408,8 +1408,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer neighbourx = b.TriggerRegionX; Vector3 newposition = pos; - newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; - newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + newposition.X += (scene.RegionInfo.LegacyRegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.LegacyRegionLocY - neighboury) * Constants.RegionSize; agent.ControllingClient.SendAgentAlertMessage( String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); @@ -1431,8 +1431,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer neighbourx = ba.TriggerRegionX; Vector3 newposition = pos; - newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; - newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + newposition.X += (scene.RegionInfo.LegacyRegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.LegacyRegionLocY - neighboury) * Constants.RegionSize; agent.ControllingClient.SendAgentAlertMessage( String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); @@ -1462,8 +1462,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer neighboury = ba.TriggerRegionY; neighbourx = ba.TriggerRegionX; Vector3 newposition = pos; - newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; - newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + newposition.X += (scene.RegionInfo.LegacyRegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.LegacyRegionLocY - neighboury) * Constants.RegionSize; agent.ControllingClient.SendAgentAlertMessage( String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); @@ -1492,8 +1492,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer neighboury = b.TriggerRegionY; neighbourx = b.TriggerRegionX; Vector3 newposition = pos; - newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; - newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + newposition.X += (scene.RegionInfo.LegacyRegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.LegacyRegionLocY - neighboury) * Constants.RegionSize; agent.ControllingClient.SendAgentAlertMessage( String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); @@ -1901,7 +1901,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (m_regionInfo != null) { - neighbours = RequestNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + neighbours = RequestNeighbours(sp, m_regionInfo.LegacyRegionLocX, m_regionInfo.LegacyRegionLocY); } else { @@ -2057,8 +2057,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour) { - int rRegionX = (int)sp.Scene.RegionInfo.RegionLocX; - int rRegionY = (int)sp.Scene.RegionInfo.RegionLocY; + int rRegionX = (int)sp.Scene.RegionInfo.LegacyRegionLocX; + int rRegionY = (int)sp.Scene.RegionInfo.LegacyRegionLocY; int tRegionX = neighbour.RegionLocX / (int)Constants.RegionSize; int tRegionY = neighbour.RegionLocY / (int)Constants.RegionSize; int shiftx = (rRegionX - tRegionX) * (int)Constants.RegionSize; @@ -2161,10 +2161,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer extent.X = ((int)extent.X / (int)Constants.RegionSize); extent.Y = ((int)extent.Y / (int)Constants.RegionSize); - swCorner.X = Scene.RegionInfo.RegionLocX - 1; - swCorner.Y = Scene.RegionInfo.RegionLocY - 1; - neCorner.X = Scene.RegionInfo.RegionLocX + extent.X; - neCorner.Y = Scene.RegionInfo.RegionLocY + extent.Y; + swCorner.X = Scene.RegionInfo.LegacyRegionLocX - 1; + swCorner.Y = Scene.RegionInfo.LegacyRegionLocY - 1; + neCorner.X = Scene.RegionInfo.LegacyRegionLocX + extent.X; + neCorner.Y = Scene.RegionInfo.LegacyRegionLocY + extent.Y; } /// @@ -2301,8 +2301,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } - int thisx = (int)scene.RegionInfo.RegionLocX; - int thisy = (int)scene.RegionInfo.RegionLocY; + int thisx = (int)scene.RegionInfo.LegacyRegionLocX; + int thisy = (int)scene.RegionInfo.LegacyRegionLocY; Vector3 EastCross = new Vector3(0.1f, 0, 0); Vector3 WestCross = new Vector3(-0.1f, 0, 0); Vector3 NorthCross = new Vector3(0, 0.1f, 0); diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index d943b20..769d662 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs @@ -213,8 +213,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules if (part != null) { ObjectRegionName = s.RegionInfo.RegionName; - uint localX = (s.RegionInfo.RegionLocX * (int)Constants.RegionSize); - uint localY = (s.RegionInfo.RegionLocY * (int)Constants.RegionSize); + uint localX = (s.RegionInfo.LegacyRegionLocX * (int)Constants.RegionSize); + uint localY = (s.RegionInfo.LegacyRegionLocY * (int)Constants.RegionSize); ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")"; return part; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 26d22b8..c1f2f04 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs @@ -224,10 +224,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage } string reason = string.Empty; - if (!m_MapService.AddMapTile((int)scene.RegionInfo.RegionLocX, (int)scene.RegionInfo.RegionLocY, jpgData, out reason)) + if (!m_MapService.AddMapTile((int)scene.RegionInfo.LegacyRegionLocX, (int)scene.RegionInfo.LegacyRegionLocY, jpgData, out reason)) { m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: Unable to upload tile image for {0} at {1}-{2}: {3}", - scene.RegionInfo.RegionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, reason); + scene.RegionInfo.RegionName, scene.RegionInfo.LegacyRegionLocX, scene.RegionInfo.LegacyRegionLocY, reason); } } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs index d8dace2..9aa4243 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs @@ -71,8 +71,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver public void AddScene(Scene scene) { - uint x = scene.RegionInfo.RegionLocX; - uint y = scene.RegionInfo.RegionLocY; + uint x = scene.RegionInfo.LegacyRegionLocX; + uint y = scene.RegionInfo.LegacyRegionLocY; SortedDictionary row; if (!Regions.TryGetValue(y, out row)) @@ -120,8 +120,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver { // We add the region's coordinates to ensure uniqueness even if multiple regions have the same name string path = string.Format("{0}_{1}_{2}", - scene.RegionInfo.RegionLocX - Rect.X + 1, - scene.RegionInfo.RegionLocY - Rect.Y + 1, + scene.RegionInfo.LegacyRegionLocX - Rect.X + 1, + scene.RegionInfo.LegacyRegionLocY - Rect.Y + 1, scene.RegionInfo.RegionName.Replace(' ', '_')); m_regionDirs[scene.RegionInfo.RegionID] = path; }); diff --git a/OpenSim/Region/CoreModules/World/Archiver/DearchiveScenesGroup.cs b/OpenSim/Region/CoreModules/World/Archiver/DearchiveScenesGroup.cs index 3dcc020..25f1e5c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/DearchiveScenesGroup.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/DearchiveScenesGroup.cs @@ -145,7 +145,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver { foreach (RegionInfo archivedRegion in m_directory2region.Values) { - Point location = new Point((int)rootScene.RegionInfo.RegionLocX, (int)rootScene.RegionInfo.RegionLocY); + Point location = new Point((int)rootScene.RegionInfo.LegacyRegionLocX, (int)rootScene.RegionInfo.LegacyRegionLocY); location.Offset(archivedRegion.Location); Scene scene; diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs index 173b603..bc172a4 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs @@ -96,9 +96,9 @@ namespace OpenSim.Region.CoreModules.World.Estate int x = (args.Length > 5 ? int.Parse(args[5]) : -1); int y = (args.Length > 6 ? int.Parse(args[6]) : -1); - if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x) + if (x == -1 || m_module.Scene.RegionInfo.LegacyRegionLocX == x) { - if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y) + if (y == -1 || m_module.Scene.RegionInfo.LegacyRegionLocY == y) { int corner = int.Parse(num); UUID texture = UUID.Parse(uuid); @@ -135,9 +135,9 @@ namespace OpenSim.Region.CoreModules.World.Estate int x = (args.Length > 4 ? int.Parse(args[4]) : -1); int y = (args.Length > 5 ? int.Parse(args[5]) : -1); - if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x) + if (x == -1 || m_module.Scene.RegionInfo.LegacyRegionLocX == x) { - if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y) + if (y == -1 || m_module.Scene.RegionInfo.LegacyRegionLocY == y) { double selectedheight = double.Parse(heightstring); @@ -159,9 +159,9 @@ namespace OpenSim.Region.CoreModules.World.Estate int x = (args.Length > 6 ? int.Parse(args[6]) : -1); int y = (args.Length > 7 ? int.Parse(args[7]) : -1); - if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x) + if (x == -1 || m_module.Scene.RegionInfo.LegacyRegionLocX == x) { - if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y) + if (y == -1 || m_module.Scene.RegionInfo.LegacyRegionLocY == y) { int corner = int.Parse(num); float lowValue = float.Parse(min, Culture.NumberFormatInfo); diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 1789d6d..51ed83f 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -1717,8 +1717,8 @@ namespace OpenSim.Region.CoreModules.World.Land // HACK for now RegionInfo r = new RegionInfo(); r.RegionName = info.RegionName; - r.RegionLocX = (uint)info.RegionLocX; - r.RegionLocY = (uint)info.RegionLocY; + r.LegacyRegionLocX = (uint)info.RegionLocX; + r.LegacyRegionLocY = (uint)info.RegionLocY; r.RegionSettings.Maturity = (int)Util.ConvertAccessLevelToMaturity(data.RegionAccess); remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y); } diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index fd30c46..c1ffd22 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -553,8 +553,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain /// Where to begin our slice public void LoadFromFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) { - int offsetX = (int) m_scene.RegionInfo.RegionLocX - fileStartX; - int offsetY = (int) m_scene.RegionInfo.RegionLocY - fileStartY; + int offsetX = (int) m_scene.RegionInfo.LegacyRegionLocX - fileStartX; + int offsetY = (int) m_scene.RegionInfo.LegacyRegionLocY - fileStartY; if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) { @@ -594,14 +594,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain /// The may y co-ordinate at which to begin the save. public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) { - int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX; - int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY; + int offsetX = (int)m_scene.RegionInfo.LegacyRegionLocX - fileStartX; + int offsetY = (int)m_scene.RegionInfo.LegacyRegionLocY - fileStartY; if (offsetX < 0 || offsetX >= fileWidth || offsetY < 0 || offsetY >= fileHeight) { MainConsole.Instance.OutputFormat( "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.", - m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, fileWidth, fileStartX, fileHeight, fileStartY); + m_scene.RegionInfo.LegacyRegionLocX, m_scene.RegionInfo.LegacyRegionLocY, fileWidth, fileStartX, fileHeight, fileStartY); return; } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index a26a5f0..c985ca2 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -240,7 +240,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. - if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) + if (m_scene.RegionInfo.LegacyRegionLocX >= 2048 || m_scene.RegionInfo.LegacyRegionLocY >= 2048) { ScenePresence avatarPresence = null; @@ -269,10 +269,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap List mapBlocks = new List(); ; List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, - (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, - (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, - (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, - (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); + (int)(m_scene.RegionInfo.LegacyRegionLocX - 8) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.LegacyRegionLocX + 8) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.LegacyRegionLocY - 8) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.LegacyRegionLocY + 8) * (int)Constants.RegionSize); foreach (GridRegion r in regions) { MapBlockData block = new MapBlockData(); @@ -1199,10 +1199,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap List mapBlocks = new List(); List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, - (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize, - (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize, - (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize, - (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize); + (int)(m_scene.RegionInfo.LegacyRegionLocX - 9) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.LegacyRegionLocX + 9) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.LegacyRegionLocY - 9) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.LegacyRegionLocY + 9) * (int)Constants.RegionSize); List textures = new List(); List bitImages = new List(); @@ -1243,8 +1243,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap for (int i = 0; i < mapBlocks.Count; i++) { - ushort x = (ushort)((mapBlocks[i].X - m_scene.RegionInfo.RegionLocX) + 10); - ushort y = (ushort)((mapBlocks[i].Y - m_scene.RegionInfo.RegionLocY) + 10); + ushort x = (ushort)((mapBlocks[i].X - m_scene.RegionInfo.LegacyRegionLocX) + 10); + ushort y = (ushort)((mapBlocks[i].Y - m_scene.RegionInfo.LegacyRegionLocY) + 10); g.DrawImage(bitImages[i], (x * 128), 2560 - (y * 128), 128, 128); // y origin is top } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3dc509b..e63963a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1107,8 +1107,8 @@ namespace OpenSim.Region.Framework.Scenes if (RegionInfo.RegionHandle != otherRegion.RegionHandle) { // If these are cast to INT because long + negative values + abs returns invalid data - int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX); - int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY); + int resultX = Math.Abs((int)xcell - (int)RegionInfo.LegacyRegionLocX); + int resultY = Math.Abs((int)ycell - (int)RegionInfo.LegacyRegionLocY); if (resultX <= 1 && resultY <= 1) { // Let the grid service module know, so this can be cached @@ -1183,8 +1183,8 @@ namespace OpenSim.Region.Framework.Scenes /// public int HaveNeighbor(Cardinals car, ref int[] fix) { - uint neighbourx = RegionInfo.RegionLocX; - uint neighboury = RegionInfo.RegionLocY; + uint neighbourx = RegionInfo.LegacyRegionLocX; + uint neighboury = RegionInfo.LegacyRegionLocY; int dir = (int)car; @@ -1204,8 +1204,8 @@ namespace OpenSim.Region.Framework.Scenes if (neighbourRegion == null) { - fix[0] = (int)(RegionInfo.RegionLocX - neighbourx); - fix[1] = (int)(RegionInfo.RegionLocY - neighboury); + fix[0] = (int)(RegionInfo.LegacyRegionLocX - neighbourx); + fix[1] = (int)(RegionInfo.LegacyRegionLocY - neighboury); return dir * (-1); } else @@ -4371,8 +4371,8 @@ namespace OpenSim.Region.Framework.Scenes { uint rRegionX = (uint)(cAgentData.RegionHandle >> 40); uint rRegionY = (((uint)(cAgentData.RegionHandle)) >> 8); - uint tRegionX = RegionInfo.RegionLocX; - uint tRegionY = RegionInfo.RegionLocY; + uint tRegionX = RegionInfo.LegacyRegionLocX; + uint tRegionY = RegionInfo.LegacyRegionLocY; //Send Data to ScenePresence childAgentUpdate.UpdateChildAgent(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); // Not Implemented: @@ -4600,13 +4600,13 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence sp = GetScenePresence(remoteClient.AgentId); if (sp != null) { - uint regionX = RegionInfo.RegionLocX; - uint regionY = RegionInfo.RegionLocY; + uint regionX = RegionInfo.LegacyRegionLocX; + uint regionY = RegionInfo.LegacyRegionLocY; Utils.LongToUInts(regionHandle, out regionX, out regionY); - int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize; - int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize; + int shiftx = (int) regionX - (int) RegionInfo.LegacyRegionLocX * (int)Constants.RegionSize; + int shifty = (int) regionY - (int) RegionInfo.LegacyRegionLocY * (int)Constants.RegionSize; position.X += shiftx; position.Y += shifty; diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 28f7896..2677989 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -445,8 +445,8 @@ namespace OpenSim.Region.Framework.Scenes { foreach (Scene mscene in m_localScenes) { - if (mscene.RegionInfo.RegionLocX == locX && - mscene.RegionInfo.RegionLocY == locY) + if (mscene.RegionInfo.LegacyRegionLocX == locX && + mscene.RegionInfo.LegacyRegionLocY == locY) { scene = mscene; return true; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7243db1..7ef144c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -710,7 +710,7 @@ namespace OpenSim.Region.Framework.Scenes Utils.LongToUInts(handle, out x, out y); x = x / Constants.RegionSize; y = y / Constants.RegionSize; - if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) + if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.LegacyRegionLocX, y, Scene.RegionInfo.LegacyRegionLocY)) { old.Add(handle); } @@ -2094,8 +2094,8 @@ namespace OpenSim.Region.Framework.Scenes // } // Get terrain height for sub-region in a megaregion if necessary - int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); - int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); + int X = (int)((m_scene.RegionInfo.LegacyRegionLocX * Constants.RegionSize) + pos.X); + int Y = (int)((m_scene.RegionInfo.LegacyRegionLocY * Constants.RegionSize) + pos.Y); GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); // If X and Y is NaN, target_region will be null if (target_region == null) diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 95f9caf..67998a0 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -437,7 +437,7 @@ namespace OpenSim.Region.Framework.Scenes SimStats simStats = new SimStats( - ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity, + ReportingRegion.LegacyRegionLocX, ReportingRegion.LegacyRegionLocY, regionFlags, (uint)m_objectCapacity, rb, sb, m_scene.RegionInfo.originRegionID); handlerSendStatResult = OnSendStatsResult; diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs index d4fe5e0..cbc538e 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs @@ -84,8 +84,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat Region = scene.RegionInfo.RegionName; Host = scene.RegionInfo.ExternalHostName; - LocX = Convert.ToString(scene.RegionInfo.RegionLocX); - LocY = Convert.ToString(scene.RegionInfo.RegionLocY); + LocX = Convert.ToString(scene.RegionInfo.LegacyRegionLocX); + LocY = Convert.ToString(scene.RegionInfo.LegacyRegionLocY); IDK = Convert.ToString(_idk_++); showAlert = config.GetBoolean("alert_show", false); diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs index 83732e2..7f616bb 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs @@ -100,8 +100,8 @@ namespace OpenSim.Region.RegionCombinerModule UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem, UUID fromtaskid) { - int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; - int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; + int differenceX = (int)m_virtScene.RegionInfo.LegacyRegionLocX - (int)m_rootScene.RegionInfo.LegacyRegionLocX; + int differenceY = (int)m_virtScene.RegionInfo.LegacyRegionLocY - (int)m_rootScene.RegionInfo.LegacyRegionLocY; rayend.X += differenceX * (int)Constants.RegionSize; rayend.Y += differenceY * (int)Constants.RegionSize; raystart.X += differenceX * (int)Constants.RegionSize; @@ -126,8 +126,8 @@ namespace OpenSim.Region.RegionCombinerModule PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid, byte rayendisintersection) { - int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; - int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; + int differenceX = (int)m_virtScene.RegionInfo.LegacyRegionLocX - (int)m_rootScene.RegionInfo.LegacyRegionLocX; + int differenceY = (int)m_virtScene.RegionInfo.LegacyRegionLocY - (int)m_rootScene.RegionInfo.LegacyRegionLocY; rayend.X += differenceX * (int)Constants.RegionSize; rayend.Y += differenceY * (int)Constants.RegionSize; raystart.X += differenceX * (int)Constants.RegionSize; diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 7127c73..3f835a4 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -246,8 +246,8 @@ namespace OpenSim.Region.RegionCombinerModule newConn.RegionScene = scene; newConn.RegionLandChannel = scene.LandChannel; newConn.RegionId = scene.RegionInfo.originRegionID; - newConn.X = scene.RegionInfo.RegionLocX; - newConn.Y = scene.RegionInfo.RegionLocY; + newConn.X = scene.RegionInfo.LegacyRegionLocX; + newConn.Y = scene.RegionInfo.LegacyRegionLocY; newConn.XEnd = (int)Constants.RegionSize; newConn.YEnd = (int)Constants.RegionSize; @@ -502,11 +502,11 @@ namespace OpenSim.Region.RegionCombinerModule lock (scene.WestBorders) { - scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West + scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.LegacyRegionLocX - rootConn.RegionScene.RegionInfo.LegacyRegionLocX) * (int)Constants.RegionSize); //auto teleport West // Trigger auto teleport to root region - scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; - scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; + scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.LegacyRegionLocX; + scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.LegacyRegionLocY; } // Reset Terrain.. since terrain loads before we get here, we need to load @@ -564,9 +564,9 @@ namespace OpenSim.Region.RegionCombinerModule lock (scene.SouthBorders) { - scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south - scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; - scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; + scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.LegacyRegionLocY - rootConn.RegionScene.RegionInfo.LegacyRegionLocY) * (int)Constants.RegionSize); //auto teleport south + scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.LegacyRegionLocX; + scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.LegacyRegionLocY; } // Reset Terrain.. since terrain normally loads first. @@ -636,9 +636,9 @@ namespace OpenSim.Region.RegionCombinerModule lock (scene.SouthBorders) { - scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south - scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; - scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; + scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.LegacyRegionLocY - rootConn.RegionScene.RegionInfo.LegacyRegionLocY) * (int)Constants.RegionSize); //auto teleport south + scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.LegacyRegionLocX; + scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.LegacyRegionLocY; } lock (rootConn.RegionScene.EastBorders) @@ -657,9 +657,9 @@ namespace OpenSim.Region.RegionCombinerModule lock (scene.WestBorders) { - scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West - scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; - scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; + scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.LegacyRegionLocX - rootConn.RegionScene.RegionInfo.LegacyRegionLocX) * (int)Constants.RegionSize); //auto teleport West + scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.LegacyRegionLocX; + scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.LegacyRegionLocY; } /* diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 975bf2d..c9c284f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4242,8 +4242,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_item.ItemID, item.AssetID.ToString()); Vector3 region = new Vector3( - World.RegionInfo.RegionLocX * Constants.RegionSize, - World.RegionInfo.RegionLocY * Constants.RegionSize, + World.RegionInfo.LegacyRegionLocX * Constants.RegionSize, + World.RegionInfo.LegacyRegionLocY * Constants.RegionSize, 0); World.AssetService.Get(item.AssetID.ToString(), this, @@ -5478,7 +5478,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetRegionCorner() { m_host.AddScriptLPS(1); - return new LSL_Vector(World.RegionInfo.RegionLocX * Constants.RegionSize, World.RegionInfo.RegionLocY * Constants.RegionSize, 0); + return new LSL_Vector(World.RegionInfo.LegacyRegionLocX * Constants.RegionSize, World.RegionInfo.LegacyRegionLocY * Constants.RegionSize, 0); } /// @@ -5651,8 +5651,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api List neighbors = World.GridService.GetNeighbours(World.RegionInfo.ScopeID, World.RegionInfo.RegionID); - uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x; - uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y; + uint neighborX = World.RegionInfo.LegacyRegionLocX + (uint)dir.x; + uint neighborY = World.RegionInfo.LegacyRegionLocY + (uint)dir.y; foreach (GridRegion sri in neighbors) { @@ -10737,7 +10737,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api httpHeaders["X-SecondLife-Shard"] = shard; httpHeaders["X-SecondLife-Object-Name"] = m_host.Name; httpHeaders["X-SecondLife-Object-Key"] = m_host.UUID.ToString(); - httpHeaders["X-SecondLife-Region"] = string.Format("{0} ({1}, {2})", regionInfo.RegionName, regionInfo.RegionLocX, regionInfo.RegionLocY); + httpHeaders["X-SecondLife-Region"] = string.Format("{0} ({1}, {2})", regionInfo.RegionName, regionInfo.LegacyRegionLocX, regionInfo.LegacyRegionLocY); httpHeaders["X-SecondLife-Local-Position"] = string.Format("({0:0.000000}, {1:0.000000}, {2:0.000000})", position.X, position.Y, position.Z); httpHeaders["X-SecondLife-Local-Velocity"] = string.Format("({0:0.000000}, {1:0.000000}, {2:0.000000})", velocity.X, velocity.Y, velocity.Z); httpHeaders["X-SecondLife-Local-Rotation"] = string.Format("({0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000})", rotation.X, rotation.Y, rotation.Z, rotation.W); diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs index b999509..71334ee 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs @@ -201,8 +201,8 @@ namespace OpenSim.Services.Connectors.SimianGrid NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "xAddMapTile" }, - { "X", scene.RegionInfo.RegionLocX.ToString() }, - { "Y", scene.RegionInfo.RegionLocY.ToString() }, + { "X", scene.RegionInfo.LegacyRegionLocX.ToString() }, + { "Y", scene.RegionInfo.LegacyRegionLocY.ToString() }, { "ContentType", "image/png" }, { "EncodedData", System.Convert.ToBase64String(pngData) } }; diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 88ac5b3..14b6d1a 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -246,8 +246,8 @@ namespace OpenSim.Services.Interfaces public GridRegion(RegionInfo ConvertFrom) { m_regionName = ConvertFrom.RegionName; - m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); - m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); + m_regionLocX = (int)(ConvertFrom.LegacyRegionLocX * Constants.RegionSize); + m_regionLocY = (int)(ConvertFrom.LegacyRegionLocY * Constants.RegionSize); m_internalEndPoint = ConvertFrom.InternalEndPoint; m_externalHostName = ConvertFrom.ExternalHostName; m_httpPort = ConvertFrom.HttpPort; -- cgit v1.1 From 0765a83a8c9bea84337bb9dcabffcb562153af50 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 19 Sep 2013 14:12:52 -0700 Subject: VarRegion: add RegionSize[XYZ] to RegionInfo.cs. Update RegionInfo parameter and serialization routines to serialize the region size if it is not the LegacyRegionSize. --- OpenSim/Framework/RegionInfo.cs | 101 +++++++++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 23 deletions(-) diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 255c8e0..437c7ff 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -137,14 +137,20 @@ namespace OpenSim.Framework public bool m_allow_alternate_ports; protected string m_externalHostName; protected IPEndPoint m_internalEndPoint; - public uint RegionWorldLocX { get; set; } - public uint RegionWorldLocY { get; set; } protected uint m_remotingPort; public UUID RegionID = UUID.Zero; public string RemotingAddress; public UUID ScopeID = UUID.Zero; private UUID m_maptileStaticUUID = UUID.Zero; + public uint RegionWorldLocX = 0; + public uint RegionWorldLocY = 0; + public uint RegionWorldLocZ = 0; + public uint RegionSizeX = LegacyRegionSize; + public uint RegionSizeY = LegacyRegionSize; + public uint RegionSizeZ = Constants.RegionHeight; + + private Dictionary m_otherSettings = new Dictionary(); // Originally, regions were fixed size of 256 in X and Y. @@ -236,9 +242,6 @@ namespace OpenSim.Framework public RegionInfo(uint legacyRegionLocX, uint legacyRegionLocY, IPEndPoint internalEndPoint, string externalUri) { - RegionWorldLocX = legacyRegionLocX * LegacyRegionSize; - RegionWorldLocY = legacyRegionLocY * LegacyRegionSize; - m_internalEndPoint = internalEndPoint; m_externalHostName = externalUri; m_serverURI = string.Empty; @@ -484,6 +487,17 @@ namespace OpenSim.Framework set { LegacyRegionLocX = value; } } + public void SetDefaultRegionSize() + { + RegionWorldLocX = 0; + RegionWorldLocY = 0; + RegionWorldLocZ = 0; + RegionSizeX = LegacyRegionSize; + RegionSizeY = LegacyRegionSize; + RegionSizeZ = Constants.RegionHeight; + } + + /// /// The y co-ordinate of this region in map tiles (e.g. 1000). /// Coordinate is scaled as world coordinates divided by the legacy region size @@ -611,6 +625,21 @@ namespace OpenSim.Framework LegacyRegionLocX = Convert.ToUInt32(locationElements[0]); LegacyRegionLocY = Convert.ToUInt32(locationElements[1]); + // Region size + // Default to legacy region size if not specified. + allKeys.Remove("SizeX"); + string configSizeX = config.GetString("SizeX", LegacyRegionSize.ToString()); + config.Set("SizeX", configSizeX); + RegionSizeX = Convert.ToUInt32(configSizeX); + allKeys.Remove("SizeY"); + string configSizeY = config.GetString("SizeY", LegacyRegionSize.ToString()); + config.Set("SizeY", configSizeX); + RegionSizeY = Convert.ToUInt32(configSizeY); + allKeys.Remove("SizeZ"); + string configSizeZ = config.GetString("SizeZ", Constants.RegionHeight.ToString()); + config.Set("SizeZ", configSizeX); + RegionSizeZ = Convert.ToUInt32(configSizeZ); + // InternalAddress // IPAddress address; @@ -743,6 +772,13 @@ namespace OpenSim.Framework string location = String.Format("{0},{1}", LegacyRegionLocX, LegacyRegionLocY); config.Set("Location", location); + if (RegionSizeX != LegacyRegionSize || RegionSizeY != LegacyRegionSize) + { + config.Set("SizeX", RegionSizeX); + config.Set("SizeY", RegionSizeY); + config.Set("SizeZ", RegionSizeZ); + } + config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); config.Set("InternalPort", m_internalEndPoint.Port); @@ -825,10 +861,18 @@ namespace OpenSim.Framework RegionID.ToString(), true); configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Region Name", RegionName, true); + configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (X Axis)", LegacyRegionLocX.ToString(), true); configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (Y Axis)", LegacyRegionLocY.ToString(), true); + configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "Size of region in X dimension", RegionSizeX.ToString(), true); + configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "Size of region in Y dimension", RegionSizeY.ToString(), true); + configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "Size of region in Z dimension", RegionSizeZ.ToString(), true); + //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); configMember.addConfigurationOption("internal_ip_address", ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, @@ -891,10 +935,18 @@ namespace OpenSim.Framework UUID.Random().ToString(), true); configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Region Name", "OpenSim Test", false); + configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (X Axis)", "1000", false); configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (Y Axis)", "1000", false); + configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "Size of region in X dimension", LegacyRegionSize.ToString(), false); + configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "Size of region in Y dimension", LegacyRegionSize.ToString(), false); + configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "Size of region in Z dimension", Constants.RegionHeight.ToString(), false); + //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); configMember.addConfigurationOption("internal_ip_address", ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, @@ -957,6 +1009,15 @@ namespace OpenSim.Framework case "sim_location_y": LegacyRegionLocY = (uint) configuration_result; break; + case "sim_size_x": + RegionSizeX = (uint) configuration_result; + break; + case "sim_size_y": + RegionSizeY = (uint) configuration_result; + break; + case "sim_size_z": + RegionSizeZ = (uint) configuration_result; + break; case "internal_ip_address": IPAddress address = (IPAddress) configuration_result; m_internalEndPoint = new IPEndPoint(address, 0); @@ -1036,8 +1097,13 @@ namespace OpenSim.Framework args["external_host_name"] = OSD.FromString(ExternalHostName); args["http_port"] = OSD.FromString(HttpPort.ToString()); args["server_uri"] = OSD.FromString(ServerURI); + args["region_xloc"] = OSD.FromString(LegacyRegionLocX.ToString()); args["region_yloc"] = OSD.FromString(LegacyRegionLocY.ToString()); + args["region_size_x"] = OSD.FromString(RegionSizeX.ToString()); + args["region_size_y"] = OSD.FromString(RegionSizeY.ToString()); + args["region_size_z"] = OSD.FromString(RegionSizeZ.ToString()); + args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString()); args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString()); if ((RemotingAddress != null) && !RemotingAddress.Equals("")) @@ -1076,6 +1142,13 @@ namespace OpenSim.Framework UInt32.TryParse(args["region_yloc"].AsString(), out locy); LegacyRegionLocY = locy; } + if (args.ContainsKey("region_size_x")) + RegionSizeX = (uint)args["region_size_x"].AsInteger(); + if (args.ContainsKey("region_size_y")) + RegionSizeY = (uint)args["region_size_y"].AsInteger(); + if (args.ContainsKey("region_size_z")) + RegionSizeZ = (uint)args["region_size_z"].AsInteger(); + IPAddress ip_addr = null; if (args["internal_ep_address"] != null) { @@ -1112,23 +1185,5 @@ namespace OpenSim.Framework regionInfo.ServerURI = serverURI; return regionInfo; } - - public Dictionary ToKeyValuePairs() - { - Dictionary kvp = new Dictionary(); - kvp["uuid"] = RegionID.ToString(); - kvp["locX"] = LegacyRegionLocX.ToString(); - kvp["locY"] = LegacyRegionLocY.ToString(); - kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); - kvp["external_port"] = ExternalEndPoint.Port.ToString(); - kvp["external_host_name"] = ExternalHostName; - kvp["http_port"] = HttpPort.ToString(); - kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); - kvp["internal_port"] = InternalEndPoint.Port.ToString(); - kvp["alternate_ports"] = m_allow_alternate_ports.ToString(); - kvp["server_uri"] = ServerURI; - - return kvp; - } } } -- cgit v1.1 From ab1474b5def9916f611a27db34dad56dada09c9c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 23 Sep 2013 10:38:38 -0700 Subject: varregion: go back to using Constants.RegionSize so as not to break external modules. People shouldn't use it but don't want to cause too much breakage of legacy modules. --- OpenSim/Framework/RegionInfo.cs | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 437c7ff..2d3c9ea 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -146,19 +146,12 @@ namespace OpenSim.Framework public uint RegionWorldLocX = 0; public uint RegionWorldLocY = 0; public uint RegionWorldLocZ = 0; - public uint RegionSizeX = LegacyRegionSize; - public uint RegionSizeY = LegacyRegionSize; + public uint RegionSizeX = Constants.RegionSize; + public uint RegionSizeY = Constants.RegionSize; public uint RegionSizeZ = Constants.RegionHeight; - private Dictionary m_otherSettings = new Dictionary(); - // Originally, regions were fixed size of 256 in X and Y. - // For downward compatability, 'RegionLocX' returns the region coordinates in the legacy region units. - // This is the constant used to convert world integer coordinates to legacy region units. - public const uint LegacyRegionSize = 256; - - // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. // MT: Yes. Estates can't span trust boundaries. Therefore, it can be @@ -460,8 +453,8 @@ namespace OpenSim.Framework /// public uint LegacyRegionLocX { - get { return RegionWorldLocX / LegacyRegionSize; } - set { RegionWorldLocX = value * LegacyRegionSize; } + get { return RegionWorldLocX / Constants.RegionSize; } + set { RegionWorldLocX = value * Constants.RegionSize; } } /// @@ -471,8 +464,8 @@ namespace OpenSim.Framework /// public uint LegacyRegionLocY { - get { return RegionWorldLocY / LegacyRegionSize; } - set { RegionWorldLocY = value * LegacyRegionSize; } + get { return RegionWorldLocY / Constants.RegionSize; } + set { RegionWorldLocY = value * Constants.RegionSize; } } /// @@ -492,8 +485,8 @@ namespace OpenSim.Framework RegionWorldLocX = 0; RegionWorldLocY = 0; RegionWorldLocZ = 0; - RegionSizeX = LegacyRegionSize; - RegionSizeY = LegacyRegionSize; + RegionSizeX = Constants.RegionSize; + RegionSizeY = Constants.RegionSize; RegionSizeZ = Constants.RegionHeight; } @@ -628,11 +621,11 @@ namespace OpenSim.Framework // Region size // Default to legacy region size if not specified. allKeys.Remove("SizeX"); - string configSizeX = config.GetString("SizeX", LegacyRegionSize.ToString()); + string configSizeX = config.GetString("SizeX", Constants.RegionSize.ToString()); config.Set("SizeX", configSizeX); RegionSizeX = Convert.ToUInt32(configSizeX); allKeys.Remove("SizeY"); - string configSizeY = config.GetString("SizeY", LegacyRegionSize.ToString()); + string configSizeY = config.GetString("SizeY", Constants.RegionSize.ToString()); config.Set("SizeY", configSizeX); RegionSizeY = Convert.ToUInt32(configSizeY); allKeys.Remove("SizeZ"); @@ -772,7 +765,7 @@ namespace OpenSim.Framework string location = String.Format("{0},{1}", LegacyRegionLocX, LegacyRegionLocY); config.Set("Location", location); - if (RegionSizeX != LegacyRegionSize || RegionSizeY != LegacyRegionSize) + if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize) { config.Set("SizeX", RegionSizeX); config.Set("SizeY", RegionSizeY); @@ -941,9 +934,9 @@ namespace OpenSim.Framework configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (Y Axis)", "1000", false); configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - "Size of region in X dimension", LegacyRegionSize.ToString(), false); + "Size of region in X dimension", Constants.RegionSize.ToString(), false); configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - "Size of region in Y dimension", LegacyRegionSize.ToString(), false); + "Size of region in Y dimension", Constants.RegionSize.ToString(), false); configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Size of region in Z dimension", Constants.RegionHeight.ToString(), false); -- cgit v1.1 From 7fa64cce7dbf19d8b5886afd58e42be790f12dea Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 24 Sep 2013 13:41:44 -0700 Subject: Remove time based terrain storage in SQLite so revision number can be used to denote terrain format revision. Add terrain DB format revision codes to ISimulationDataStore.cs. Setup so legacy compatible terrain storage and fetch is possible while allowing future format extensions. --- OpenSim/Data/MSSQL/MSSQLSimulationData.cs | 2 +- OpenSim/Data/MySQL/MySQLSimulationData.cs | 7 ++++--- OpenSim/Data/SQLite/SQLiteSimulationData.cs | 14 ++------------ .../Framework/Interfaces/ISimulationDataStore.cs | 21 +++++++++++++++++++++ 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs index f41f60c..8adddc9 100644 --- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs +++ b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs @@ -576,7 +576,7 @@ ELSE /// regionID. public void StoreTerrain(double[,] terrain, UUID regionID) { - int revision = Util.UnixTimeSinceEpoch(); + int revision = (int)DBTerrainRevision.Legacy256; //Delete old terrain map string sql = "delete from terrain where RegionUUID=@RegionUUID"; diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index b03a904..5751dc8 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -575,6 +575,7 @@ namespace OpenSim.Data.MySQL public void StoreTerrain(double[,] ter, UUID regionID) { m_log.Info("[REGION DB]: Storing terrain"); + int revision = (int)DBTerrainRevision.Legacy256; lock (m_dbLock) { @@ -589,10 +590,10 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); - cmd.CommandText = "insert into terrain (RegionUUID, " + - "Revision, Heightfield) values (?RegionUUID, " + - "1, ?Heightfield)"; + cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)" + + "values (?RegionUUID, ?Revision, ?Heightfield)"; + cmd.Parameters.AddWithValue("Revision", revision); cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); ExecuteNonQuery(cmd); diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index d938b6b..b70af6b 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs @@ -828,22 +828,12 @@ namespace OpenSim.Data.SQLite { lock (ds) { - int revision = Util.UnixTimeSinceEpoch(); - - // This is added to get rid of the infinitely growing - // terrain databases which negatively impact on SQLite - // over time. Before reenabling this feature there - // needs to be a limitter put on the number of - // revisions in the database, as this old - // implementation is a DOS attack waiting to happen. + int revision = (int)DBTerrainRevision.Legacy256; using ( - SqliteCommand cmd = - new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision <= :Revision", - m_conn)) + SqliteCommand cmd = new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID", m_conn)) { cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); cmd.ExecuteNonQuery(); } diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs index 3787ca0..c936a84 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs @@ -134,5 +134,26 @@ namespace OpenSim.Region.Framework.Interfaces Dictionary GetExtra(UUID regionID); void Shutdown(); + } + + // The terrain is stored as a blob in the database with a 'revision' field. + // Some implementations of terrain storage would fill the revision field with + // the time the terrain was stored. When real revisions were added and this + // feature removed, that left some old entries with the time in the revision + // field. + // Thus, if revision is greater than 'RevisionHigh' then terrain db entry is + // left over and it is presumed to be 'Legacy256'. + // Numbers are arbitrary and are chosen to to reduce possible mis-interpretation. + // If a revision does not match any of these, it is assumed to be Legacy256. + public enum DBTerrainRevision + { + // Terrain is 'double[256,256]' + Legacy256 = 11, + // Terrain is 'int32, int32, float[,]' where the shorts are X and Y dimensions + // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256. + Variable2D = 22, + // A revision that is not listed above or any revision greater than this value is 'Legacy256'. + RevisionHigh = 1234 } + } -- cgit v1.1 From fbc9072a5ca4ae3c8474964fbd4ef663eeed1377 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 25 Sep 2013 17:21:20 -0700 Subject: varregion: serious rework of TerrainChannel: -- addition of varaible region size in X and Y -- internal storage of heightmap changed from double[] to short[] -- helper routines for handling internal structure while keeping existing API -- to and from XML that adds region size information (for downward compatibility, output in the legacy XML format if X and Y are 256) Updated and commented Constants.RegionSize but didn't change the name for compatibility. --- OpenSim/Framework/Constants.cs | 9 + OpenSim/Framework/RegionInfo.cs | 25 +- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 4 +- .../Terrain/FileLoaders/GenericSystemDrawing.cs | 2 +- .../CoreModules/World/Terrain/TerrainModule.cs | 8 +- .../Framework/Interfaces/ISimulationDataStore.cs | 40 +-- .../Region/Framework/Interfaces/ITerrainChannel.cs | 10 +- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 280 ++++++++++++++------- 9 files changed, 247 insertions(+), 135 deletions(-) diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs index a2eb5ee..7979132 100644 --- a/OpenSim/Framework/Constants.cs +++ b/OpenSim/Framework/Constants.cs @@ -30,9 +30,18 @@ namespace OpenSim.Framework { public class Constants { + // 'RegionSize' captures the legacy region size. + // DO NOT USE THIS FOR ANY NEW CODE. Use Scene.RegionSize[XYZ] as a region might not + // be the legacy region size. public const uint RegionSize = 256; public const uint RegionHeight = 4096; + + // Terrain heightmap is kept as shorts that are the float value times this compression factor + public const float TerrainCompression = 100.0f; + // Since terrain is stored in 16x16 heights, regions must be a multiple of this number and that is the minimum + public const int MinRegionSize = 16; public const byte TerrainPatchSize = 16; + public const string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f"; public enum EstateAccessCodex : uint diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 2d3c9ea..882fe33 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -472,7 +472,7 @@ namespace OpenSim.Framework /// The x co-ordinate of this region in map tiles (e.g. 1000). /// Coordinate is scaled as world coordinates divided by the legacy region size /// and is thus is the number of legacy regions. - /// This entrypoint exists for downward compatability for external modules. + /// DO NOT USE FOR NEW CODE! This entrypoint exists for downward compatability with external modules. /// public uint RegionLocX { @@ -480,22 +480,11 @@ namespace OpenSim.Framework set { LegacyRegionLocX = value; } } - public void SetDefaultRegionSize() - { - RegionWorldLocX = 0; - RegionWorldLocY = 0; - RegionWorldLocZ = 0; - RegionSizeX = Constants.RegionSize; - RegionSizeY = Constants.RegionSize; - RegionSizeZ = Constants.RegionHeight; - } - - /// /// The y co-ordinate of this region in map tiles (e.g. 1000). /// Coordinate is scaled as world coordinates divided by the legacy region size /// and is thus is the number of legacy regions. - /// This entrypoint exists for downward compatability for external modules. + /// DO NOT USE FOR NEW CODE! This entrypoint exists for downward compatability with external modules. /// public uint RegionLocY { @@ -503,6 +492,16 @@ namespace OpenSim.Framework set { LegacyRegionLocY = value; } } + public void SetDefaultRegionSize() + { + RegionWorldLocX = 0; + RegionWorldLocY = 0; + RegionWorldLocZ = 0; + RegionSizeX = Constants.RegionSize; + RegionSizeY = Constants.RegionSize; + RegionSizeZ = Constants.RegionHeight; + } + // A unique region handle is created from the region's world coordinates. // This cannot be changed because some code expects to receive the region handle and then // compute the region coordinates from it. diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 7b7daed..3396c32 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -1240,9 +1240,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP try { int[] patches = new int[] { py * 16 + px }; - float[] heightmap = (map.Length == 65536) ? - map : - LLHeightFieldMoronize(map); + float[] heightmap = (map.Length == 65536) ? map : LLHeightFieldMoronize(map); LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches); diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index d78ade5..d5c77ec 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs @@ -67,7 +67,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders { using (Bitmap bitmap = new Bitmap(filename)) { - ITerrainChannel retval = new TerrainChannel(true); + ITerrainChannel retval = new TerrainChannel(w, h); for (int x = 0; x < retval.Width; x++) { diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index c1ffd22..2fff4c1 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -130,15 +130,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain { if (m_scene.Heightmap == null) { - m_channel = new TerrainChannel(m_InitialTerrain); + m_channel = new TerrainChannel(m_InitialTerrain, + m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY, m_scene.RegionInfo.RegionSizeZ); m_scene.Heightmap = m_channel; - m_revert = new TerrainChannel(); UpdateRevertMap(); } else { m_channel = m_scene.Heightmap; - m_revert = new TerrainChannel(); UpdateRevertMap(); } @@ -532,6 +531,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain /// public void UpdateRevertMap() { + /* int x; for (x = 0; x < m_channel.Width; x++) { @@ -541,6 +541,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain m_revert[x, y] = m_channel[x, y]; } } + */ + m_revert = m_channel.MakeCopy(); } /// diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs index c936a84..847d245 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs @@ -134,26 +134,26 @@ namespace OpenSim.Region.Framework.Interfaces Dictionary GetExtra(UUID regionID); void Shutdown(); - } - - // The terrain is stored as a blob in the database with a 'revision' field. - // Some implementations of terrain storage would fill the revision field with - // the time the terrain was stored. When real revisions were added and this - // feature removed, that left some old entries with the time in the revision - // field. - // Thus, if revision is greater than 'RevisionHigh' then terrain db entry is - // left over and it is presumed to be 'Legacy256'. - // Numbers are arbitrary and are chosen to to reduce possible mis-interpretation. - // If a revision does not match any of these, it is assumed to be Legacy256. - public enum DBTerrainRevision - { - // Terrain is 'double[256,256]' - Legacy256 = 11, - // Terrain is 'int32, int32, float[,]' where the shorts are X and Y dimensions - // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256. - Variable2D = 22, - // A revision that is not listed above or any revision greater than this value is 'Legacy256'. - RevisionHigh = 1234 + } + + // The terrain is stored as a blob in the database with a 'revision' field. + // Some implementations of terrain storage would fill the revision field with + // the time the terrain was stored. When real revisions were added and this + // feature removed, that left some old entries with the time in the revision + // field. + // Thus, if revision is greater than 'RevisionHigh' then terrain db entry is + // left over and it is presumed to be 'Legacy256'. + // Numbers are arbitrary and are chosen to to reduce possible mis-interpretation. + // If a revision does not match any of these, it is assumed to be Legacy256. + public enum DBTerrainRevision + { + // Terrain is 'double[256,256]' + Legacy256 = 11, + // Terrain is 'int32, int32, float[,]' where the shorts are X and Y dimensions + // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256. + Variable2D = 22, + // A revision that is not listed above or any revision greater than this value is 'Legacy256'. + RevisionHigh = 1234 } } diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs index e467701..3c060a4 100644 --- a/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs +++ b/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs @@ -29,15 +29,21 @@ namespace OpenSim.Region.Framework.Interfaces { public interface ITerrainChannel { - int Height { get; } + int Width { get;} // X dimension + int Height { get;} // Y dimension + int Altitude { get;} // Z dimension + double this[int x, int y] { get; set; } - int Width { get; } /// /// Squash the entire heightmap into a single dimensioned array /// /// float[] GetFloatsSerialised(); + // Get version of map as a single dimensioned array and each value compressed + // into an int (compressedHeight = (int)(floatHeight * Constants.TerrainCompression);) + // This is done to make the map smaller as it can get pretty larger for variable sized regions. + short[] GetCompressedMap(); double[,] GetDoubles(); bool Tainted(int x, int y); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e63963a..b714c7f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1905,13 +1905,13 @@ namespace OpenSim.Region.Framework.Scenes m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); - Heightmap = new TerrainChannel(m_InitialTerrain); + Heightmap = new TerrainChannel(m_InitialTerrain, RegionInfo.RegionSizeX, RegionInfo.RegionSizeY, RegionInfo.RegionSizeZ); SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); } else { - Heightmap = new TerrainChannel(map); + Heightmap = new TerrainChannel(map, RegionInfo.RegionSizeZ); } } catch (IOException e) diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index c0ca48e..fef93bf 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -40,132 +40,125 @@ namespace OpenSim.Region.Framework.Scenes /// public class TerrainChannel : ITerrainChannel { - private readonly bool[,] taint; - private double[,] map; + protected bool[,] m_taint; + protected short[] m_map; + public int Width { get; private set; } // X dimension + // Unfortunately, for historical reasons, in this module 'Width' is X and 'Height' is Y + public int Height { get; private set; } // Y dimension + public int Altitude { get; private set; } // Y dimension + + // Default, not-often-used builder public TerrainChannel() { - map = new double[Constants.RegionSize, Constants.RegionSize]; - taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; - - PinHeadIsland(); + InitializeStructures(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight, false); + FlatLand(); + // PinHeadIsland(); } - public TerrainChannel(String type) + // Create terrain of given size + public TerrainChannel(int pX, int pY) { - map = new double[Constants.RegionSize, Constants.RegionSize]; - taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; + InitializeStructures((uint)pX, (uint)pY, Constants.RegionHeight, true); + } + // Create terrain of specified size and initialize with specified terrain. + // TODO: join this with the terrain initializers. + public TerrainChannel(String type, uint pX, uint pY, uint pZ) + { + InitializeStructures(pX, pY, pZ, false); if (type.Equals("flat")) FlatLand(); else PinHeadIsland(); } - public TerrainChannel(double[,] import) - { - map = import; - taint = new bool[import.GetLength(0),import.GetLength(1)]; - } - - public TerrainChannel(bool createMap) - { - if (createMap) - { - map = new double[Constants.RegionSize,Constants.RegionSize]; - taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; - } - } - - public TerrainChannel(int w, int h) + public TerrainChannel(double[,] pM, uint pH) { - map = new double[w,h]; - taint = new bool[w / 16,h / 16]; + InitializeStructures((uint)pM.GetLength(0), (uint)pM.GetLength(1), pH, false); + int idx = 0; + for (int ii = 0; ii < Height; ii++) + for (int jj = 0; jj < Width; jj++) + m_map[idx++] = ToCompressedHeight(pM[ii, jj]); } #region ITerrainChannel Members - public int Width + // ITerrainChannel.MakeCopy() + public ITerrainChannel MakeCopy() { - get { return map.GetLength(0); } + return this.Copy(); } - public int Height + // ITerrainChannel.GetCompressedMap() + public short[] GetCompressedMap() { - get { return map.GetLength(1); } + return m_map; } - public ITerrainChannel MakeCopy() + // ITerrainChannel.GetFloatsSerialized() + public float[] GetFloatsSerialised() { - TerrainChannel copy = new TerrainChannel(false); - copy.map = (double[,]) map.Clone(); + int points = Width * Height; + float[] heights = new float[points]; - return copy; + for (int ii = 0; ii < points; ii++) + heights[ii] = FromCompressedHeight(m_map[ii]); + + return heights; } - public float[] GetFloatsSerialised() + // ITerrainChannel.GetDoubles() + public double[,] GetDoubles() { - // Move the member variables into local variables, calling - // member variables 256*256 times gets expensive int w = Width; - int h = Height; - float[] heights = new float[w * h]; + int l = Height; + double[,] heights = new double[w, l]; - int i, j; // map coordinates int idx = 0; // index into serialized array - for (i = 0; i < h; i++) + for (int ii = 0; ii < l; ii++) { - for (j = 0; j < w; j++) + for (int jj = 0; jj < w; jj++) { - heights[idx++] = (float)map[j, i]; + heights[ii, jj] = (double)FromCompressedHeight(m_map[idx]); + idx++; } } return heights; } - public double[,] GetDoubles() - { - return map; - } - + // ITerrainChannel.this[x,y] public double this[int x, int y] { - get { return map[x, y]; } + get { return m_map[x * Width + y]; } set { // Will "fix" terrain hole problems. Although not fantastically. if (Double.IsNaN(value) || Double.IsInfinity(value)) return; - if (map[x, y] != value) + int idx = x * Width + y; + if (m_map[idx] != value) { - taint[x / 16, y / 16] = true; - map[x, y] = value; + m_taint[x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize] = true; + m_map[idx] = ToCompressedHeight(value); } } } + // ITerrainChannel.Tainted() public bool Tainted(int x, int y) { - if (taint[x / 16, y / 16]) + if (m_taint[x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize]) { - taint[x / 16, y / 16] = false; + m_taint[x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize] = false; return true; } return false; } - #endregion - - public TerrainChannel Copy() - { - TerrainChannel copy = new TerrainChannel(false); - copy.map = (double[,]) map.Clone(); - - return copy; - } - + // ITerrainChannel.SaveToXmlString() public string SaveToXmlString() { XmlWriterSettings settings = new XmlWriterSettings(); @@ -181,13 +174,7 @@ namespace OpenSim.Region.Framework.Scenes } } - private void WriteXml(XmlWriter writer) - { - writer.WriteStartElement(String.Empty, "TerrainMap", String.Empty); - ToXml(writer); - writer.WriteEndElement(); - } - + // ITerrainChannel.LoadFromXmlString() public void LoadFromXmlString(string data) { StringReader sr = new StringReader(data); @@ -199,12 +186,89 @@ namespace OpenSim.Region.Framework.Scenes sr.Close(); } + #endregion + + private void InitializeStructures(uint pX, uint pY, uint pZ, bool shouldInitializeHeightmap) + { + Width = (int)pX; + Height = (int)pY; + Altitude = (int)pZ; + m_map = new short[Width * Height]; + m_taint = new bool[Width / Constants.TerrainPatchSize, Height / Constants.TerrainPatchSize]; + ClearTaint(); + if (shouldInitializeHeightmap) + { + FlatLand(); + } + } + + public void ClearTaint() + { + for (int ii = 0; ii < Width / Constants.TerrainPatchSize; ii++) + for (int jj = 0; jj < Height / Constants.TerrainPatchSize; jj++) + m_taint[ii, jj] = false; + } + + // To save space (especially for large regions), keep the height as a short integer + // that is coded as the float height times the compression factor (usually '100' + // to make for two decimal points). + public short ToCompressedHeight(double pHeight) + { + return (short)(pHeight * Constants.TerrainCompression); + } + + public float FromCompressedHeight(short pHeight) + { + return ((float)pHeight) / Constants.TerrainCompression; + } + + public TerrainChannel Copy() + { + TerrainChannel copy = new TerrainChannel(); + copy.m_map = (short[])m_map.Clone(); + copy.m_taint = (bool[,])m_taint.Clone(); + copy.Width = Width; + copy.Height = Height; + copy.Altitude = Altitude; + + return copy; + } + + private void WriteXml(XmlWriter writer) + { + if (Width == Constants.RegionSize && Height == Constants.RegionSize) + { + // Downward compatibility for legacy region terrain maps. + // If region is exactly legacy size, return the old format XML. + writer.WriteStartElement(String.Empty, "TerrainMap", String.Empty); + ToXml(writer); + writer.WriteEndElement(); + } + else + { + // New format XML that includes width and length. + writer.WriteStartElement(String.Empty, "TerrainMap2", String.Empty); + ToXml2(writer); + writer.WriteEndElement(); + } + } + private void ReadXml(XmlReader reader) { - reader.ReadStartElement("TerrainMap"); - FromXml(reader); + // Check the first element. If legacy element, use the legacy reader. + if (reader.IsStartElement("TerrainMap")) + { + reader.ReadStartElement("TerrainMap"); + FromXml(reader); + } + else + { + reader.ReadStartElement("TerrainMap2"); + FromXml2(reader); + } } + // Write legacy terrain map. Presumed to be 256x256 of data encoded as floats in a byte array. private void ToXml(XmlWriter xmlWriter) { float[] mapData = GetFloatsSerialised(); @@ -218,6 +282,7 @@ namespace OpenSim.Region.Framework.Scenes serializer.Serialize(xmlWriter, buffer); } + // Read legacy terrain map. Presumed to be 256x256 of data encoded as floats in a byte array. private void FromXml(XmlReader xmlReader) { XmlSerializer serializer = new XmlSerializer(typeof(byte[])); @@ -236,35 +301,68 @@ namespace OpenSim.Region.Framework.Scenes } } + private class TerrainChannelXMLPackage + { + public int Version; + public int SizeX; + public int SizeY; + public int SizeZ; + public short[] Map; + public TerrainChannelXMLPackage(int pX, int pY, int pZ, short[] pMap) + { + Version = 1; + SizeX = pX; + SizeY = pY; + SizeZ = pZ; + Map = pMap; + } + } + + // New terrain serialization format that includes the width and length. + private void ToXml2(XmlWriter xmlWriter) + { + TerrainChannelXMLPackage package = new TerrainChannelXMLPackage(Width, Height, Altitude, m_map); + XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage)); + serializer.Serialize(xmlWriter, package); + } + + // New terrain serialization format that includes the width and length. + private void FromXml2(XmlReader xmlReader) + { + XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage)); + TerrainChannelXMLPackage package = (TerrainChannelXMLPackage)serializer.Deserialize(xmlReader); + Width = package.SizeX; + Height = package.SizeY; + Altitude = package.SizeZ; + m_map = package.Map; + } + + // Fill the heightmap with the center bump terrain private void PinHeadIsland() { int x; - for (x = 0; x < Constants.RegionSize; x++) + for (x = 0; x < Width; x++) { int y; - for (y = 0; y < Constants.RegionSize; y++) + for (y = 0; y < Height; y++) { - map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; - double spherFacA = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01; - double spherFacB = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001; - if (map[x, y] < spherFacA) - map[x, y] = spherFacA; - if (map[x, y] < spherFacB) - map[x, y] = spherFacB; + int idx = x * (int)Width + y; + m_map[idx] = ToCompressedHeight(TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10); + short spherFacA = ToCompressedHeight(TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01); + short spherFacB = ToCompressedHeight(TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001); + if (m_map[idx] < spherFacA) + m_map[idx] = spherFacA; + if (m_map[idx] < spherFacB) + m_map[idx] = spherFacB; } } } private void FlatLand() { - int x; - for (x = 0; x < Constants.RegionSize; x++) - { - int y; - for (y = 0; y < Constants.RegionSize; y++) - map[x, y] = 21; - } + short flatHeight = ToCompressedHeight(21); + for (int ii = 0; ii < m_map.Length; ii++) + m_map[ii] = flatHeight; } - } } -- cgit v1.1