aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/LandData.cs2
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs19
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs94
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs9
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs6
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs63
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs35
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandChannel.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs92
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs24
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs406
-rw-r--r--OpenSim/Region/CoreModules/World/Region/RestartModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs239
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/ILandChannel.cs8
-rw-r--r--OpenSim/Region/Framework/Interfaces/ILandObject.cs1
-rw-r--r--OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs55
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs49
-rw-r--r--OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs2
-rw-r--r--OpenSim/Server/Handlers/Simulation/AgentHandlers.cs9
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs25
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestLandChannel.cs5
30 files changed, 1032 insertions, 163 deletions
diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs
index accf52e..a9a493d 100644
--- a/OpenSim/Framework/LandData.cs
+++ b/OpenSim/Framework/LandData.cs
@@ -697,6 +697,8 @@ namespace OpenSim.Framework
697 landData._mediaLoop = _mediaLoop; 697 landData._mediaLoop = _mediaLoop;
698 landData._obscureMusic = _obscureMusic; 698 landData._obscureMusic = _obscureMusic;
699 landData._obscureMedia = _obscureMedia; 699 landData._obscureMedia = _obscureMedia;
700 landData._simwideArea = _simwideArea;
701 landData._simwidePrims = _simwidePrims;
700 702
701 landData._parcelAccessList.Clear(); 703 landData._parcelAccessList.Clear();
702 foreach (ParcelManager.ParcelAccessEntry entry in _parcelAccessList) 704 foreach (ParcelManager.ParcelAccessEntry entry in _parcelAccessList)
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index 6e3d6af..40ab765 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -179,8 +179,10 @@ namespace OpenSim
179 for (int i = 0 ; i < sources.Count ; i++) 179 for (int i = 0 ; i < sources.Count ; i++)
180 { 180 {
181 if (ReadConfig(sources[i])) 181 if (ReadConfig(sources[i]))
182 {
182 iniFileExists = true; 183 iniFileExists = true;
183 AddIncludes(sources); 184 AddIncludes(sources);
185 }
184 } 186 }
185 187
186 if (!iniFileExists) 188 if (!iniFileExists)
@@ -235,10 +237,19 @@ namespace OpenSim
235 string path = Path.Combine(basepath, chunkWithoutWildcards); 237 string path = Path.Combine(basepath, chunkWithoutWildcards);
236 path = Path.GetFullPath(path) + chunkWithWildcards; 238 path = Path.GetFullPath(path) + chunkWithWildcards;
237 string[] paths = Util.Glob(path); 239 string[] paths = Util.Glob(path);
238 foreach (string p in paths) 240
241 // If the include path contains no wildcards, then warn the user that it wasn't found.
242 if (wildcardIndex == -1 && paths.Length == 0)
239 { 243 {
240 if (!sources.Contains(p)) 244 m_log.WarnFormat("[CONFIG]: Could not find include file {0}", path);
241 sources.Add(p); 245 }
246 else
247 {
248 foreach (string p in paths)
249 {
250 if (!sources.Contains(p))
251 sources.Add(p);
252 }
242 } 253 }
243 } 254 }
244 } 255 }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 5dab1bc..2c6795f 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -4333,7 +4333,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4333 updateMessage.SequenceID = sequence_id; 4333 updateMessage.SequenceID = sequence_id;
4334 if (landData.SimwideArea > 0) 4334 if (landData.SimwideArea > 0)
4335 { 4335 {
4336 updateMessage.SimWideMaxPrims = parcelObjectCapacity; 4336 int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
4337 updateMessage.SimWideMaxPrims = simulatorCapacity;
4337 } 4338 }
4338 else 4339 else
4339 { 4340 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs
index 542af25..4a42c93 100644
--- a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets
54// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 private Scene m_scene; 56 private Scene m_scene;
57 private IAssetService m_assetService; 57// private IAssetService m_assetService;
58 private bool m_dumpAssetsToFile = false; 58 private bool m_dumpAssetsToFile = false;
59 59
60 #region IRegionModuleBase Members 60 #region IRegionModuleBase Members
@@ -85,7 +85,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets
85 public void RegionLoaded(Scene scene) 85 public void RegionLoaded(Scene scene)
86 { 86 {
87 87
88 m_assetService = m_scene.RequestModuleInterface<IAssetService>(); 88// m_assetService = m_scene.RequestModuleInterface<IAssetService>();
89 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 89 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
90 } 90 }
91 91
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 8bf2bf8..54b95f7 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -53,6 +53,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
53 protected bool m_Enabled = false; 53 protected bool m_Enabled = false;
54 protected Scene m_aScene; 54 protected Scene m_aScene;
55 protected List<UUID> m_agentsInTransit; 55 protected List<UUID> m_agentsInTransit;
56 private ExpiringCache<UUID, ExpiringCache<ulong, DateTime>> m_bannedRegions =
57 new ExpiringCache<UUID, ExpiringCache<ulong, DateTime>>();
58
56 59
57 #region ISharedRegionModule 60 #region ISharedRegionModule
58 61
@@ -281,6 +284,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
281 return; 284 return;
282 } 285 }
283 286
287 if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero))
288 {
289 sp.ControllingClient.SendTeleportFailed("The destination region has refused access");
290 return;
291 }
292
284 sp.ControllingClient.SendTeleportStart(teleportFlags); 293 sp.ControllingClient.SendTeleportStart(teleportFlags);
285 294
286 // the avatar.Close below will clear the child region list. We need this below for (possibly) 295 // the avatar.Close below will clear the child region list. We need this below for (possibly)
@@ -575,7 +584,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
575 584
576 #region Agent Crossings 585 #region Agent Crossings
577 586
578 public void Cross(ScenePresence agent, bool isFlying) 587 public bool Cross(ScenePresence agent, bool isFlying)
579 { 588 {
580 Scene scene = agent.Scene; 589 Scene scene = agent.Scene;
581 Vector3 pos = agent.AbsolutePosition; 590 Vector3 pos = agent.AbsolutePosition;
@@ -611,6 +620,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
611 } 620 }
612 else 621 else
613 { 622 {
623 agent.InTransit();
624
614 neighboury = b.TriggerRegionY; 625 neighboury = b.TriggerRegionY;
615 neighbourx = b.TriggerRegionX; 626 neighbourx = b.TriggerRegionX;
616 627
@@ -620,7 +631,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
620 agent.ControllingClient.SendAgentAlertMessage( 631 agent.ControllingClient.SendAgentAlertMessage(
621 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); 632 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
622 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 633 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
623 return; 634 return true;
624 } 635 }
625 } 636 }
626 637
@@ -632,6 +643,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
632 } 643 }
633 else 644 else
634 { 645 {
646 agent.InTransit();
647
635 neighboury = ba.TriggerRegionY; 648 neighboury = ba.TriggerRegionY;
636 neighbourx = ba.TriggerRegionX; 649 neighbourx = ba.TriggerRegionX;
637 650
@@ -644,7 +657,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
644 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 657 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
645 658
646 659
647 return; 660 return true;
648 } 661 }
649 662
650 } 663 }
@@ -664,6 +677,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
664 } 677 }
665 else 678 else
666 { 679 {
680 agent.InTransit();
681
667 neighboury = ba.TriggerRegionY; 682 neighboury = ba.TriggerRegionY;
668 neighbourx = ba.TriggerRegionX; 683 neighbourx = ba.TriggerRegionX;
669 Vector3 newposition = pos; 684 Vector3 newposition = pos;
@@ -672,7 +687,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
672 agent.ControllingClient.SendAgentAlertMessage( 687 agent.ControllingClient.SendAgentAlertMessage(
673 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); 688 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
674 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 689 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
675 return; 690 return true;
676 } 691 }
677 } 692 }
678 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 693 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
@@ -694,6 +709,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
694 } 709 }
695 else 710 else
696 { 711 {
712 agent.InTransit();
713
697 neighboury = b.TriggerRegionY; 714 neighboury = b.TriggerRegionY;
698 neighbourx = b.TriggerRegionX; 715 neighbourx = b.TriggerRegionX;
699 Vector3 newposition = pos; 716 Vector3 newposition = pos;
@@ -702,7 +719,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
702 agent.ControllingClient.SendAgentAlertMessage( 719 agent.ControllingClient.SendAgentAlertMessage(
703 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); 720 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
704 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 721 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
705 return; 722 return true;
706 } 723 }
707 } 724 }
708 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 725 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
@@ -738,9 +755,52 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
738 } 755 }
739 */ 756 */
740 757
758 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
759
760 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
761
762 ExpiringCache<ulong, DateTime> r;
763 DateTime banUntil;
764
765 if (m_bannedRegions.TryGetValue(agent.ControllingClient.AgentId, out r))
766 {
767 if (r.TryGetValue(neighbourHandle, out banUntil))
768 {
769 if (DateTime.Now < banUntil)
770 return false;
771 r.Remove(neighbourHandle);
772 }
773 }
774 else
775 {
776 r = null;
777 }
778
779 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y);
780
781 if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos))
782 {
783 agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel");
784 if (r == null)
785 {
786 r = new ExpiringCache<ulong, DateTime>();
787 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
788
789 m_bannedRegions.Add(agent.ControllingClient.AgentId, r, TimeSpan.FromSeconds(45));
790 }
791 else
792 {
793 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
794 }
795 return false;
796 }
797
798 agent.InTransit();
799
741 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; 800 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
742 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); 801 d.BeginInvoke(agent, newpos, neighbourx, neighboury, neighbourRegion, isFlying, CrossAgentToNewRegionCompleted, d);
743 802
803 return true;
744 } 804 }
745 805
746 806
@@ -751,7 +811,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
751 private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene) 811 private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene)
752 { 812 {
753 813
754 // This assumes that we know what our neighbors are. 814 // This assumes that we know what our neighbours are.
755 815
756 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync; 816 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync;
757 d.BeginInvoke(agent, regionX, regionY, position, initiatingScene, 817 d.BeginInvoke(agent, regionX, regionY, position, initiatingScene,
@@ -795,21 +855,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
795 icon.EndInvoke(iar); 855 icon.EndInvoke(iar);
796 } 856 }
797 857
798 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying); 858 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying);
799 859
800 /// <summary> 860 /// <summary>
801 /// This Closes child agents on neighboring regions 861 /// This Closes child agents on neighbouring regions
802 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 862 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
803 /// </summary> 863 /// </summary>
804 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying) 864 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying)
805 { 865 {
866 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
867
806 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); 868 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
807 869
808 Scene m_scene = agent.Scene; 870 Scene m_scene = agent.Scene;
809 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
810
811 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
812 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
813 871
814 if (neighbourRegion != null && agent.ValidateAttachments()) 872 if (neighbourRegion != null && agent.ValidateAttachments())
815 { 873 {
@@ -920,7 +978,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
920 978
921 #region Enable Child Agent 979 #region Enable Child Agent
922 /// <summary> 980 /// <summary>
923 /// This informs a single neighboring region about agent "avatar". 981 /// This informs a single neighbouring region about agent "avatar".
924 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 982 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
925 /// </summary> 983 /// </summary>
926 public void EnableChildAgent(ScenePresence sp, GridRegion region) 984 public void EnableChildAgent(ScenePresence sp, GridRegion region)
@@ -977,7 +1035,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
977 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); 1035 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
978 1036
979 /// <summary> 1037 /// <summary>
980 /// This informs all neighboring regions about agent "avatar". 1038 /// This informs all neighbouring regions about agent "avatar".
981 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 1039 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
982 /// </summary> 1040 /// </summary>
983 public void EnableChildAgents(ScenePresence sp) 1041 public void EnableChildAgents(ScenePresence sp)
@@ -1108,7 +1166,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1108 catch (ArgumentOutOfRangeException) 1166 catch (ArgumentOutOfRangeException)
1109 { 1167 {
1110 m_log.ErrorFormat( 1168 m_log.ErrorFormat(
1111 "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", 1169 "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbour list. The following region will not display to the client: {0} for region {1} ({2}, {3}).",
1112 neighbour.ExternalHostName, 1170 neighbour.ExternalHostName,
1113 neighbour.RegionHandle, 1171 neighbour.RegionHandle,
1114 neighbour.RegionLocX, 1172 neighbour.RegionLocX,
@@ -1188,7 +1246,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1188 } 1246 }
1189 #endregion 1247 #endregion
1190 1248
1191 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbor region {2} @ {3} " + 1249 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbour region {2} @ {3} " +
1192 "and EstablishAgentCommunication with seed cap {4}", 1250 "and EstablishAgentCommunication with seed cap {4}",
1193 m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath); 1251 m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath);
1194 1252
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index cfa4109..43de2ab 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -14,6 +14,7 @@
14 <RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.BasicInventoryAccessModule" /> 14 <RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.BasicInventoryAccessModule" />
15 <RegionModule id="HGInventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.HGInventoryAccessModule" /> 15 <RegionModule id="HGInventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.HGInventoryAccessModule" />
16 <RegionModule id="LandManagementModule" type="OpenSim.Region.CoreModules.World.Land.LandManagementModule" /> 16 <RegionModule id="LandManagementModule" type="OpenSim.Region.CoreModules.World.Land.LandManagementModule" />
17 <RegionModule id="PrimCountModule" type="OpenSim.Region.CoreModules.World.Land.PrimCountModule" />
17 <RegionModule id="ExportSerialisationModule" type="OpenSim.Region.CoreModules.World.Serialiser.SerialiserModule" /> 18 <RegionModule id="ExportSerialisationModule" type="OpenSim.Region.CoreModules.World.Serialiser.SerialiserModule" />
18 <RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" /> 19 <RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" />
19 <RegionModule id="CapabilitiesModule" type="OpenSim.Region.CoreModules.Agent.Capabilities.CapabilitiesModule" /> 20 <RegionModule id="CapabilitiesModule" type="OpenSim.Region.CoreModules.Agent.Capabilities.CapabilitiesModule" />
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 2dd0099..c5972dd 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -257,18 +257,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
257 return false; 257 return false;
258 } 258 }
259 259
260 public bool QueryAccess(GridRegion destination, UUID id) 260 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position)
261 { 261 {
262 if (destination == null) 262 if (destination == null)
263 return false; 263 return false;
264 264
265 foreach (Scene s in m_sceneList) 265 foreach (Scene s in m_sceneList)
266 { 266 {
267 if (s.RegionInfo.RegionHandle == destination.RegionHandle) 267 if (s.RegionInfo.RegionID == destination.RegionID)
268 { 268 return s.QueryAccess(id, position);
269 //m_log.Debug("[LOCAL COMMS]: Found region to send QueryAccess");
270 return s.QueryAccess(id);
271 }
272 } 269 }
273 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess"); 270 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
274 return false; 271 return false;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index 387a9b8..c4919b3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -239,18 +239,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
239 239
240 } 240 }
241 241
242 public bool QueryAccess(GridRegion destination, UUID id) 242 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position)
243 { 243 {
244 if (destination == null) 244 if (destination == null)
245 return false; 245 return false;
246 246
247 // Try local first 247 // Try local first
248 if (m_localBackend.QueryAccess(destination, id)) 248 if (m_localBackend.QueryAccess(destination, id, position))
249 return true; 249 return true;
250 250
251 // else do the remote thing 251 // else do the remote thing
252 if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) 252 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
253 return m_remoteConnector.QueryAccess(destination, id); 253 return m_remoteConnector.QueryAccess(destination, id, position);
254 254
255 return false; 255 return false;
256 256
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
index 155335b..ddef75f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
@@ -38,9 +38,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
38 { 38 {
39 private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! 39 private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours!
40 40
41 private static readonly ILog m_log = 41// private static readonly ILog m_log =
42 LogManager.GetLogger( 42// LogManager.GetLogger(
43 MethodBase.GetCurrentMethod().DeclaringType); 43// MethodBase.GetCurrentMethod().DeclaringType);
44
44 private ExpiringCache<UUID, UserAccount> m_UUIDCache; 45 private ExpiringCache<UUID, UserAccount> m_UUIDCache;
45 private ExpiringCache<string, UUID> m_NameCache; 46 private ExpiringCache<string, UUID> m_NameCache;
46 47
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 3238a81..fd8f546 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -217,22 +217,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver
217 m_scene.DeleteAllSceneObjects(); 217 m_scene.DeleteAllSceneObjects();
218 } 218 }
219 219
220 // Try to retain the original creator/owner/lastowner if their uuid is present on this grid 220 LoadParcels(serialisedParcels);
221 // otherwise, use the master avatar uuid instead 221 LoadObjects(serialisedSceneObjects);
222 222
223 // Reload serialized parcels 223 m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive");
224 m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count);
225 List<LandData> landData = new List<LandData>();
226 foreach (string serialisedParcel in serialisedParcels)
227 {
228 LandData parcel = LandDataSerializer.Deserialize(serialisedParcel);
229 if (!ResolveUserUuid(parcel.OwnerID))
230 parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
231 landData.Add(parcel);
232 }
233 m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData);
234 m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count);
235 224
225 m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
226 }
227
228 /// <summary>
229 /// Load serialized scene objects.
230 /// </summary>
231 /// <param name="serialisedSceneObjects"></param>
232 protected void LoadObjects(List<string> serialisedSceneObjects)
233 {
236 // Reload serialized prims 234 // Reload serialized prims
237 m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); 235 m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count);
238 236
@@ -262,6 +260,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
262 // to the same scene (when this is possible). 260 // to the same scene (when this is possible).
263 sceneObject.ResetIDs(); 261 sceneObject.ResetIDs();
264 262
263 // Try to retain the original creator/owner/lastowner if their uuid is present on this grid
264 // or creator data is present. Otherwise, use the estate owner instead.
265 foreach (SceneObjectPart part in sceneObject.Parts) 265 foreach (SceneObjectPart part in sceneObject.Parts)
266 { 266 {
267 if (part.CreatorData == null || part.CreatorData == string.Empty) 267 if (part.CreatorData == null || part.CreatorData == string.Empty)
@@ -318,11 +318,36 @@ namespace OpenSim.Region.CoreModules.World.Archiver
318 int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount; 318 int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount;
319 319
320 if (ignoredObjects > 0) 320 if (ignoredObjects > 0)
321 m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects); 321 m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects);
322 322 }
323 m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); 323
324 324 /// <summary>
325 m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage); 325 /// Load serialized parcels.
326 /// </summary>
327 /// <param name="serialisedParcels"></param>
328 protected void LoadParcels(List<string> serialisedParcels)
329 {
330 // Reload serialized parcels
331 m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count);
332 List<LandData> landData = new List<LandData>();
333 foreach (string serialisedParcel in serialisedParcels)
334 {
335 LandData parcel = LandDataSerializer.Deserialize(serialisedParcel);
336 if (!ResolveUserUuid(parcel.OwnerID))
337 parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
338
339// m_log.DebugFormat(
340// "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}",
341// parcel.Name, parcel.LocalID, parcel.Area);
342
343 landData.Add(parcel);
344 }
345
346 if (!m_merge)
347 m_scene.LandChannel.Clear(false);
348
349 m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData);
350 m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count);
326 } 351 }
327 352
328 /// <summary> 353 /// <summary>
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index b0563c5..01f04d9 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -555,37 +555,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
555 555
556 try 556 try
557 { 557 {
558 MemoryStream terrainStream = new MemoryStream(terrainData);
559 terr.LoadFromStream(filename, terrainStream);
560 terrainStream.Close();
558 561
559 string localfilename = "terrain.raw"; 562 FileInfo x = new FileInfo(filename);
560 563 remoteClient.SendAlertMessage("Your terrain was loaded as a " + x.Extension + " file. It may take a few moments to appear.");
561 if (terrainData.Length == 851968)
562 {
563 localfilename = Path.Combine(Util.dataDir(),"terrain.raw"); // It's a .LLRAW
564 }
565
566 if (terrainData.Length == 196662) // 24-bit 256x256 Bitmap
567 localfilename = Path.Combine(Util.dataDir(), "terrain.bmp");
568
569 if (terrainData.Length == 256 * 256 * 4) // It's a .R32
570 localfilename = Path.Combine(Util.dataDir(), "terrain.r32");
571
572 if (terrainData.Length == 256 * 256 * 8) // It's a .R64
573 localfilename = Path.Combine(Util.dataDir(), "terrain.r64");
574
575 if (File.Exists(localfilename))
576 {
577 File.Delete(localfilename);
578 }
579
580 FileStream input = new FileStream(localfilename, FileMode.CreateNew);
581 input.Write(terrainData, 0, terrainData.Length);
582 input.Close();
583
584 FileInfo x = new FileInfo(localfilename);
585
586 terr.LoadFromFile(localfilename);
587 remoteClient.SendAlertMessage("Your terrain was loaded as a ." + x.Extension + " file. It may take a few moments to appear.");
588
589 } 564 }
590 catch (IOException e) 565 catch (IOException e)
591 { 566 {
diff --git a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
index 9e27ef0..7d990c2 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
@@ -116,6 +116,12 @@ namespace OpenSim.Region.CoreModules.World.Land
116 116
117 return new List<ILandObject>(); 117 return new List<ILandObject>();
118 } 118 }
119
120 public void Clear(bool setupDefaultParcel)
121 {
122 if (m_landManagementModule != null)
123 m_landManagementModule.Clear(setupDefaultParcel);
124 }
119 125
120 public List<ILandObject> ParcelsNearPoint(Vector3 position) 126 public List<ILandObject> ParcelsNearPoint(Vector3 position)
121 { 127 {
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 70767f7..98ba8c3 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -298,13 +298,19 @@ namespace OpenSim.Region.CoreModules.World.Land
298 m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 298 m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
299 m_landIDList.Initialize(); 299 m_landIDList.Initialize();
300 } 300 }
301 301 }
302
303 /// <summary>
304 /// Create a default parcel that spans the entire region and is owned by the estate owner.
305 /// </summary>
306 /// <returns>The parcel created.</returns>
307 protected ILandObject CreateDefaultParcel()
308 {
302 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); 309 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
303
304 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); 310 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
305 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 311 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
306 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 312 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
307 AddLandObject(fullSimParcel); 313 return AddLandObject(fullSimParcel);
308 } 314 }
309 315
310 public List<ILandObject> AllParcels() 316 public List<ILandObject> AllParcels()
@@ -578,15 +584,6 @@ namespace OpenSim.Region.CoreModules.World.Land
578 } 584 }
579 585
580 /// <summary> 586 /// <summary>
581 /// Creates a basic Parcel object without an owner (a zeroed key)
582 /// </summary>
583 /// <returns></returns>
584 public ILandObject CreateBaseLand()
585 {
586 return new LandObject(UUID.Zero, false, m_scene);
587 }
588
589 /// <summary>
590 /// Adds a land object to the stored list and adds them to the landIDList to what they own 587 /// Adds a land object to the stored list and adds them to the landIDList to what they own
591 /// </summary> 588 /// </summary>
592 /// <param name="new_land">The land object being added</param> 589 /// <param name="new_land">The land object being added</param>
@@ -645,6 +642,28 @@ namespace OpenSim.Region.CoreModules.World.Land
645 m_landList.Remove(local_id); 642 m_landList.Remove(local_id);
646 } 643 }
647 } 644 }
645
646 /// <summary>
647 /// Clear the scene of all parcels
648 /// </summary>
649 public void Clear(bool setupDefaultParcel)
650 {
651 lock (m_landList)
652 {
653 foreach (ILandObject lo in m_landList.Values)
654 {
655 //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID);
656 m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
657 }
658
659 m_landList.Clear();
660 }
661
662 ResetSimLandObjects();
663
664 if (setupDefaultParcel)
665 CreateDefaultParcel();
666 }
648 667
649 private void performFinalLandJoin(ILandObject master, ILandObject slave) 668 private void performFinalLandJoin(ILandObject master, ILandObject slave)
650 { 669 {
@@ -690,7 +709,7 @@ namespace OpenSim.Region.CoreModules.World.Land
690 int x; 709 int x;
691 int y; 710 int y;
692 711
693 if (x_float > Constants.RegionSize || x_float <= 0 || y_float > Constants.RegionSize || y_float <= 0) 712 if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0)
694 return null; 713 return null;
695 714
696 try 715 try
@@ -732,10 +751,10 @@ namespace OpenSim.Region.CoreModules.World.Land
732 { 751 {
733 try 752 try
734 { 753 {
735 if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) 754 //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4]))
736 return m_landList[m_landIDList[x / 4, y / 4]]; 755 return m_landList[m_landIDList[x / 4, y / 4]];
737 else 756 //else
738 return null; 757 // return null;
739 } 758 }
740 catch (IndexOutOfRangeException) 759 catch (IndexOutOfRangeException)
741 { 760 {
@@ -1311,7 +1330,6 @@ namespace OpenSim.Region.CoreModules.World.Land
1311 } 1330 }
1312 } 1331 }
1313 1332
1314
1315 void ClientOnParcelDeedToGroup(int parcelLocalID, UUID groupID, IClientAPI remote_client) 1333 void ClientOnParcelDeedToGroup(int parcelLocalID, UUID groupID, IClientAPI remote_client)
1316 { 1334 {
1317 ILandObject land; 1335 ILandObject land;
@@ -1327,10 +1345,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1327 { 1345 {
1328 land.DeedToGroup(groupID); 1346 land.DeedToGroup(groupID);
1329 } 1347 }
1330
1331 } 1348 }
1332 1349
1333
1334 #region Land Object From Storage Functions 1350 #region Land Object From Storage Functions
1335 1351
1336 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1352 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
@@ -1365,6 +1381,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1365 public void EventManagerOnNoLandDataFromStorage() 1381 public void EventManagerOnNoLandDataFromStorage()
1366 { 1382 {
1367 ResetSimLandObjects(); 1383 ResetSimLandObjects();
1384 CreateDefaultParcel();
1368 } 1385 }
1369 1386
1370 #endregion 1387 #endregion
@@ -1622,14 +1639,36 @@ namespace OpenSim.Region.CoreModules.World.Land
1622 1639
1623 protected void InstallInterfaces() 1640 protected void InstallInterfaces()
1624 { 1641 {
1625 Command showCommand = 1642 Command clearCommand
1626 new Command("show", CommandIntentions.COMMAND_STATISTICAL, ShowParcelsCommand, "Shows all parcels on the current region."); 1643 = new Command("clear", CommandIntentions.COMMAND_HAZARDOUS, ClearCommand, "Clears all the parcels from the region.");
1644 Command showCommand
1645 = new Command("show", CommandIntentions.COMMAND_STATISTICAL, ShowParcelsCommand, "Shows all parcels on the region.");
1627 1646
1647 m_commander.RegisterCommand("clear", clearCommand);
1628 m_commander.RegisterCommand("show", showCommand); 1648 m_commander.RegisterCommand("show", showCommand);
1629 1649
1630 // Add this to our scene so scripts can call these functions 1650 // Add this to our scene so scripts can call these functions
1631 m_scene.RegisterModuleCommander(m_commander); 1651 m_scene.RegisterModuleCommander(m_commander);
1632 } 1652 }
1653
1654 protected void ClearCommand(Object[] args)
1655 {
1656 string response = MainConsole.Instance.CmdPrompt(
1657 string.Format(
1658 "Are you sure that you want to clear all land parcels from {0} (y or n)",
1659 m_scene.RegionInfo.RegionName),
1660 "n");
1661
1662 if (response.ToLower() == "y")
1663 {
1664 Clear(true);
1665 MainConsole.Instance.OutputFormat("Cleared all parcels from {0}", m_scene.RegionInfo.RegionName);
1666 }
1667 else
1668 {
1669 MainConsole.Instance.OutputFormat("Aborting clear of all parcels from {0}", m_scene.RegionInfo.RegionName);
1670 }
1671 }
1633 1672
1634 protected void ShowParcelsCommand(Object[] args) 1673 protected void ShowParcelsCommand(Object[] args)
1635 { 1674 {
@@ -1637,8 +1676,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1637 1676
1638 report.AppendFormat("Land information for {0}\n", m_scene.RegionInfo.RegionName); 1677 report.AppendFormat("Land information for {0}\n", m_scene.RegionInfo.RegionName);
1639 report.AppendFormat( 1678 report.AppendFormat(
1640 "{0,-20} {1,-9} {2,-18} {3,-18} {4,-20}\n", 1679 "{0,-20} {1,-10} {2,-9} {3,-18} {4,-18} {5,-20}\n",
1641 "Parcel Name", 1680 "Parcel Name",
1681 "Local ID",
1642 "Area", 1682 "Area",
1643 "Starts", 1683 "Starts",
1644 "Ends", 1684 "Ends",
@@ -1651,12 +1691,12 @@ namespace OpenSim.Region.CoreModules.World.Land
1651 LandData ld = lo.LandData; 1691 LandData ld = lo.LandData;
1652 1692
1653 report.AppendFormat( 1693 report.AppendFormat(
1654 "{0,-20} {1,-9} {2,-18} {3,-18} {4,-20}\n", 1694 "{0,-20} {1,-10} {2,-9} {3,-18} {4,-18} {5,-20}\n",
1655 ld.Name, ld.Area, lo.StartPoint, lo.EndPoint, m_userManager.GetUserName(ld.OwnerID)); 1695 ld.Name, ld.LocalID, ld.Area, lo.StartPoint, lo.EndPoint, m_userManager.GetUserName(ld.OwnerID));
1656 } 1696 }
1657 } 1697 }
1658 1698
1659 MainConsole.Instance.Output(report.ToString()); 1699 MainConsole.Instance.Output(report.ToString());
1660 } 1700 }
1661 } 1701 }
1662} \ No newline at end of file 1702} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index b90e307..46c15ed 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -66,6 +66,13 @@ namespace OpenSim.Region.CoreModules.World.Land
66 66
67 #region ILandObject Members 67 #region ILandObject Members
68 68
69 public int GetPrimsFree()
70 {
71 m_scene.EventManager.TriggerParcelPrimCountUpdate();
72 int free = GetSimulatorMaxPrimCount(this) - m_landData.SimwidePrims;
73 return free;
74 }
75
69 public LandData LandData 76 public LandData LandData
70 { 77 {
71 get { return m_landData; } 78 get { return m_landData; }
@@ -141,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Land
141 /// <returns>Returns true if the piece of land contains the specified point</returns> 148 /// <returns>Returns true if the piece of land contains the specified point</returns>
142 public bool ContainsPoint(int x, int y) 149 public bool ContainsPoint(int x, int y)
143 { 150 {
144 if (x >= 0 && y >= 0 && x <= Constants.RegionSize && y <= Constants.RegionSize) 151 if (x >= 0 && y >= 0 && x < Constants.RegionSize && y < Constants.RegionSize)
145 { 152 {
146 return (LandBitmap[x / 4, y / 4] == true); 153 return (LandBitmap[x / 4, y / 4] == true);
147 } 154 }
@@ -183,7 +190,11 @@ namespace OpenSim.Region.CoreModules.World.Land
183 else 190 else
184 { 191 {
185 // Normal Calculations 192 // Normal Calculations
186 return (int)Math.Round(((float)LandData.Area / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); 193 int parcelMax = (int)(((float)LandData.Area / 65536.0f)
194 * (float)m_scene.RegionInfo.ObjectCapacity
195 * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
196 // TODO: The calculation of ObjectBonus should be refactored. It does still not work in the same manner as SL!
197 return parcelMax;
187 } 198 }
188 } 199 }
189 public int GetSimulatorMaxPrimCount(ILandObject thisObject) 200 public int GetSimulatorMaxPrimCount(ILandObject thisObject)
@@ -195,7 +206,9 @@ namespace OpenSim.Region.CoreModules.World.Land
195 else 206 else
196 { 207 {
197 //Normal Calculations 208 //Normal Calculations
198 return m_scene.RegionInfo.ObjectCapacity; 209 int simMax = (int)(((float)LandData.SimwideArea / 65536.0f)
210 * (float)m_scene.RegionInfo.ObjectCapacity);
211 return simMax;
199 } 212 }
200 } 213 }
201 #endregion 214 #endregion
@@ -369,7 +382,7 @@ namespace OpenSim.Region.CoreModules.World.Land
369 newData.AuthBuyerID = UUID.Zero; 382 newData.AuthBuyerID = UUID.Zero;
370 newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory); 383 newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
371 m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); 384 m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData);
372 385 m_scene.EventManager.TriggerParcelPrimCountUpdate();
373 SendLandUpdateToAvatarsOverMe(true); 386 SendLandUpdateToAvatarsOverMe(true);
374 } 387 }
375 388
@@ -384,7 +397,7 @@ namespace OpenSim.Region.CoreModules.World.Land
384 newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory); 397 newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
385 398
386 m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); 399 m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData);
387 400 m_scene.EventManager.TriggerParcelPrimCountUpdate();
388 SendLandUpdateToAvatarsOverMe(true); 401 SendLandUpdateToAvatarsOverMe(true);
389 } 402 }
390 403
@@ -450,6 +463,7 @@ namespace OpenSim.Region.CoreModules.World.Land
450 463
451 public void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client) 464 public void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client)
452 { 465 {
466 m_scene.EventManager.TriggerParcelPrimCountUpdate();
453 SendLandProperties(0, snap_selection, 0, remote_client); 467 SendLandProperties(0, snap_selection, 0, remote_client);
454 } 468 }
455 469
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
new file mode 100644
index 0000000..34ef67f
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -0,0 +1,406 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Diagnostics;
32using System.Reflection;
33using log4net;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces;
40
41namespace OpenSim.Region.CoreModules.World.Land
42{
43 public class ParcelCounts
44 {
45 public int Owner = 0;
46 public int Group = 0;
47 public int Others = 0;
48 public Dictionary <UUID, int> Users =
49 new Dictionary <UUID, int>();
50 }
51
52 public class PrimCountModule : IPrimCountModule, INonSharedRegionModule
53 {
54 private static readonly ILog m_log =
55 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 private Scene m_Scene;
58 private Dictionary<UUID, PrimCounts> m_PrimCounts =
59 new Dictionary<UUID, PrimCounts>();
60 private Dictionary<UUID, UUID> m_OwnerMap =
61 new Dictionary<UUID, UUID>();
62 private Dictionary<UUID, int> m_SimwideCounts =
63 new Dictionary<UUID, int>();
64 private Dictionary<UUID, ParcelCounts> m_ParcelCounts =
65 new Dictionary<UUID, ParcelCounts>();
66
67 // For now, a simple simwide taint to get this up. Later parcel based
68 // taint to allow recounting a parcel if only ownership has changed
69 // without recounting the whole sim.
70 private bool m_Tainted = true;
71 private Object m_TaintLock = new Object();
72
73 public Type ReplaceableInterface
74 {
75 get { return null; }
76 }
77
78 public void Initialise(IConfigSource source)
79 {
80 }
81
82 public void AddRegion(Scene scene)
83 {
84 m_Scene = scene;
85
86 m_Scene.EventManager.OnParcelPrimCountAdd +=
87 OnParcelPrimCountAdd;
88 m_Scene.EventManager.OnObjectBeingRemovedFromScene +=
89 OnObjectBeingRemovedFromScene;
90 m_Scene.EventManager.OnParcelPrimCountTainted +=
91 OnParcelPrimCountTainted;
92 }
93
94 public void RegionLoaded(Scene scene)
95 {
96 }
97
98 public void RemoveRegion(Scene scene)
99 {
100 }
101
102 public void Close()
103 {
104 }
105
106 public string Name
107 {
108 get { return "PrimCountModule"; }
109 }
110
111 private void OnParcelPrimCountAdd(SceneObjectGroup obj)
112 {
113 // If we're tainted already, don't bother to add. The next
114 // access will cause a recount anyway
115 lock (m_TaintLock)
116 {
117 if (!m_Tainted)
118 AddObject(obj);
119 }
120 }
121
122 private void OnObjectBeingRemovedFromScene(SceneObjectGroup obj)
123 {
124 // Don't bother to update tainted counts
125 lock (m_TaintLock)
126 {
127 if (!m_Tainted)
128 RemoveObject(obj);
129 }
130 }
131
132 private void OnParcelPrimCountTainted()
133 {
134 lock (m_TaintLock)
135 m_Tainted = true;
136 }
137
138 public void TaintPrimCount(ILandObject land)
139 {
140 lock (m_TaintLock)
141 m_Tainted = true;
142 }
143
144 public void TaintPrimCount(int x, int y)
145 {
146 lock (m_TaintLock)
147 m_Tainted = true;
148 }
149
150 public void TaintPrimCount()
151 {
152 lock (m_TaintLock)
153 m_Tainted = true;
154 }
155
156 // NOTE: Call under Taint Lock
157 private void AddObject(SceneObjectGroup obj)
158 {
159 if (obj.IsAttachment)
160 return;
161 if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0))
162 return;
163
164 Vector3 pos = obj.AbsolutePosition;
165 ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
166 LandData landData = landObject.LandData;
167
168 ParcelCounts parcelCounts;
169 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
170 {
171 UUID landOwner = landData.OwnerID;
172 int partCount = obj.Parts.Length;
173
174 m_SimwideCounts[landOwner] += partCount;
175 if (parcelCounts.Users.ContainsKey(obj.OwnerID))
176 parcelCounts.Users[obj.OwnerID] += partCount;
177 else
178 parcelCounts.Users[obj.OwnerID] = partCount;
179
180 if (landData.IsGroupOwned)
181 {
182 if (obj.OwnerID == landData.GroupID)
183 parcelCounts.Owner += partCount;
184 else if (obj.GroupID == landData.GroupID)
185 parcelCounts.Group += partCount;
186 else
187 parcelCounts.Others += partCount;
188 }
189 else
190 {
191 if (obj.OwnerID == landData.OwnerID)
192 parcelCounts.Owner += partCount;
193 else if (obj.GroupID == landData.GroupID)
194 parcelCounts.Group += partCount;
195 else
196 parcelCounts.Others += partCount;
197 }
198 }
199 }
200
201 // NOTE: Call under Taint Lock
202 private void RemoveObject(SceneObjectGroup obj)
203 {
204 }
205
206 public IPrimCounts GetPrimCounts(UUID parcelID)
207 {
208 PrimCounts primCounts;
209
210 lock (m_PrimCounts)
211 {
212 if (m_PrimCounts.TryGetValue(parcelID, out primCounts))
213 return primCounts;
214
215 primCounts = new PrimCounts(parcelID, this);
216 m_PrimCounts[parcelID] = primCounts;
217 }
218 return primCounts;
219 }
220
221 public int GetOwnerCount(UUID parcelID)
222 {
223 lock (m_TaintLock)
224 {
225 if (m_Tainted)
226 Recount();
227
228 ParcelCounts counts;
229 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
230 return counts.Owner;
231 }
232 return 0;
233 }
234
235 public int GetGroupCount(UUID parcelID)
236 {
237 lock (m_TaintLock)
238 {
239 if (m_Tainted)
240 Recount();
241
242 ParcelCounts counts;
243 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
244 return counts.Group;
245 }
246 return 0;
247 }
248
249 public int GetOthersCount(UUID parcelID)
250 {
251 lock (m_TaintLock)
252 {
253 if (m_Tainted)
254 Recount();
255
256 ParcelCounts counts;
257 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
258 return counts.Others;
259 }
260 return 0;
261 }
262
263 public int GetSimulatorCount(UUID parcelID)
264 {
265 lock (m_TaintLock)
266 {
267 if (m_Tainted)
268 Recount();
269
270 UUID owner;
271 if (m_OwnerMap.TryGetValue(parcelID, out owner))
272 {
273 int val;
274 if (m_SimwideCounts.TryGetValue(owner, out val))
275 return val;
276 }
277 }
278 return 0;
279 }
280
281 public int GetUserCount(UUID parcelID, UUID userID)
282 {
283 lock (m_TaintLock)
284 {
285 if (m_Tainted)
286 Recount();
287
288 ParcelCounts counts;
289 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
290 {
291 int val;
292 if (counts.Users.TryGetValue(userID, out val))
293 return val;
294 }
295 }
296 return 0;
297 }
298
299 // NOTE: This method MUST be called while holding the taint lock!
300 private void Recount()
301 {
302 m_OwnerMap.Clear();
303 m_SimwideCounts.Clear();
304 m_ParcelCounts.Clear();
305
306 List<ILandObject> land = m_Scene.LandChannel.AllParcels();
307
308 foreach (ILandObject l in land)
309 {
310 LandData landData = l.LandData;
311
312 m_OwnerMap[landData.GlobalID] = landData.OwnerID;
313 m_SimwideCounts[landData.OwnerID] = 0;
314 m_ParcelCounts[landData.GlobalID] = new ParcelCounts();
315 }
316
317 m_Scene.ForEachSOG(AddObject);
318
319 List<UUID> primcountKeys = new List<UUID>(m_PrimCounts.Keys);
320 foreach (UUID k in primcountKeys)
321 {
322 if (!m_OwnerMap.ContainsKey(k))
323 m_PrimCounts.Remove(k);
324 }
325 m_Tainted = false;
326 }
327 }
328
329 public class PrimCounts : IPrimCounts
330 {
331 private PrimCountModule m_Parent;
332 private UUID m_ParcelID;
333 private UserPrimCounts m_UserPrimCounts;
334
335 public PrimCounts (UUID parcelID, PrimCountModule parent)
336 {
337 m_ParcelID = parcelID;
338 m_Parent = parent;
339
340 m_UserPrimCounts = new UserPrimCounts(this);
341 }
342
343 public int Owner
344 {
345 get
346 {
347 return m_Parent.GetOwnerCount(m_ParcelID);
348 }
349 }
350
351 public int Group
352 {
353 get
354 {
355 return m_Parent.GetGroupCount(m_ParcelID);
356 }
357 }
358
359 public int Others
360 {
361 get
362 {
363 return m_Parent.GetOthersCount(m_ParcelID);
364 }
365 }
366
367 public int Simulator
368 {
369 get
370 {
371 return m_Parent.GetSimulatorCount(m_ParcelID);
372 }
373 }
374
375 public IUserPrimCounts Users
376 {
377 get
378 {
379 return m_UserPrimCounts;
380 }
381 }
382
383 public int GetUserCount(UUID userID)
384 {
385 return m_Parent.GetUserCount(m_ParcelID, userID);
386 }
387 }
388
389 public class UserPrimCounts : IUserPrimCounts
390 {
391 private PrimCounts m_Parent;
392
393 public UserPrimCounts(PrimCounts parent)
394 {
395 m_Parent = parent;
396 }
397
398 public int this[UUID userID]
399 {
400 get
401 {
402 return m_Parent.GetUserCount(userID);
403 }
404 }
405 }
406}
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
index c65aa6a..ab6a598 100644
--- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
+++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
@@ -45,8 +45,8 @@ namespace OpenSim.Region.CoreModules.World.Region
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RestartModule")] 45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RestartModule")]
46 public class RestartModule : INonSharedRegionModule, IRestartModule 46 public class RestartModule : INonSharedRegionModule, IRestartModule
47 { 47 {
48 private static readonly ILog m_log = 48// private static readonly ILog m_log =
49 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 protected Scene m_Scene; 51 protected Scene m_Scene;
52 protected Timer m_CountdownTimer = null; 52 protected Timer m_CountdownTimer = null;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
index 3ee20ae..2919897 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
@@ -30,6 +30,7 @@ using System.IO;
30using System.Text; 30using System.Text;
31using OpenSim.Region.Framework.Interfaces; 31using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes; 32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Framework;
33 34
34namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders 35namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
35{ 36{
@@ -53,17 +54,120 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
53 return retval; 54 return retval;
54 } 55 }
55 56
57 public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight)
58 {
59 TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight);
60
61 FileInfo file = new FileInfo(filename);
62 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
63 BinaryReader bs = new BinaryReader(s);
64
65 bool eof = false;
66
67 int fileXPoints = 0;
68 int fileYPoints = 0;
69
70 // Terragen file
71 while (eof == false)
72 {
73 string tmp = Encoding.ASCII.GetString(bs.ReadBytes(4));
74 switch (tmp)
75 {
76 case "SIZE":
77 fileXPoints = bs.ReadInt16() + 1;
78 fileYPoints = fileXPoints;
79 bs.ReadInt16();
80 break;
81 case "XPTS":
82 fileXPoints = bs.ReadInt16();
83 bs.ReadInt16();
84 break;
85 case "YPTS":
86 fileYPoints = bs.ReadInt16();
87 bs.ReadInt16();
88 break;
89 case "ALTW":
90 eof = true;
91 Int16 heightScale = bs.ReadInt16();
92 Int16 baseHeight = bs.ReadInt16();
93
94 int currFileYOffset = 0;
95
96 // if our region isn't on the first X section of the areas to be landscaped, then
97 // advance to our section of the file
98 while (currFileYOffset < offsetY)
99 {
100 // read a whole strip of regions
101 int heightsToRead = sectionHeight * fileXPoints;
102 bs.ReadBytes(heightsToRead * 2); // because the shorts are 2 bytes in the file
103 currFileYOffset++;
104 }
105
106 for (int y = 0; y < sectionHeight; y++)
107 {
108 int currFileXOffset = 0;
109
110 // if our region isn't the first X section of the areas to be landscaped, then
111 // advance the stream to the X start pos of our section in the file
112 // i.e. eat X upto where we start
113 while (currFileXOffset < offsetX)
114 {
115 bs.ReadBytes(sectionWidth * 2); // 2 bytes = short
116 currFileXOffset++;
117 }
118
119 // got to our X offset, so write our regions X line
120 for (int x = 0; x < sectionWidth; x++)
121 {
122 // Read a strip and continue
123 retval[x, y] = baseHeight + bs.ReadInt16() * (double)heightScale / 65536.0;
124 }
125 // record that we wrote it
126 currFileXOffset++;
127
128 // if our region isn't the last X section of the areas to be landscaped, then
129 // advance the stream to the end of this Y column
130 while (currFileXOffset < fileWidth)
131 {
132 // eat the next regions x line
133 bs.ReadBytes(sectionWidth * 2); // 2 bytes = short
134 currFileXOffset++;
135 }
136 //eat the last additional point
137 bs.ReadInt16();
138 }
139
140
141 break;
142 default:
143 bs.ReadInt32();
144 break;
145 }
146 }
147
148 bs.Close();
149 s.Close();
150
151 return retval;
152 }
153
56 public ITerrainChannel LoadStream(Stream s) 154 public ITerrainChannel LoadStream(Stream s)
57 { 155 {
58 TerrainChannel retval = new TerrainChannel(); 156
157 int w = (int)Constants.RegionSize;
158 int h = (int)Constants.RegionSize;
159
160 TerrainChannel retval = new TerrainChannel(w, h);
59 161
60 BinaryReader bs = new BinaryReader(s); 162 BinaryReader bs = new BinaryReader(s);
61 163
62 bool eof = false; 164 bool eof = false;
63 if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") 165 if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ")
64 { 166 {
65 int w = 256; 167
66 int h = 256; 168 int fileWidth = w;
169 int fileHeight = h;
170
67 171
68 // Terragen file 172 // Terragen file
69 while (eof == false) 173 while (eof == false)
@@ -73,30 +177,27 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
73 { 177 {
74 case "SIZE": 178 case "SIZE":
75 int sztmp = bs.ReadInt16() + 1; 179 int sztmp = bs.ReadInt16() + 1;
76 w = sztmp; 180 fileWidth = sztmp;
77 h = sztmp; 181 fileHeight = sztmp;
78 bs.ReadInt16(); 182 bs.ReadInt16();
79 break; 183 break;
80 case "XPTS": 184 case "XPTS":
81 w = bs.ReadInt16(); 185 fileWidth = bs.ReadInt16();
82 bs.ReadInt16(); 186 bs.ReadInt16();
83 break; 187 break;
84 case "YPTS": 188 case "YPTS":
85 h = bs.ReadInt16(); 189 fileHeight = bs.ReadInt16();
86 bs.ReadInt16(); 190 bs.ReadInt16();
87 break; 191 break;
88 case "ALTW": 192 case "ALTW":
89 eof = true; 193 eof = true;
90 Int16 heightScale = bs.ReadInt16(); 194 Int16 heightScale = bs.ReadInt16();
91 Int16 baseHeight = bs.ReadInt16(); 195 Int16 baseHeight = bs.ReadInt16();
92 retval = new TerrainChannel(w, h); 196 for (int y = 0; y < h; y++)
93 int x;
94 for (x = 0; x < w; x++)
95 { 197 {
96 int y; 198 for (int x = 0; x < w; x++)
97 for (y = 0; y < h; y++)
98 { 199 {
99 retval[x, y] = baseHeight + bs.ReadInt16() * (double) heightScale / 65536.0; 200 retval[x, y] = baseHeight + bs.ReadInt16() * (double)heightScale / 65536.0;
100 } 201 }
101 } 202 }
102 break; 203 break;
@@ -114,12 +215,92 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
114 215
115 public void SaveFile(string filename, ITerrainChannel map) 216 public void SaveFile(string filename, ITerrainChannel map)
116 { 217 {
117 throw new NotImplementedException(); 218 FileInfo file = new FileInfo(filename);
219 FileStream s = file.Open(FileMode.Create, FileAccess.Write);
220 SaveStream(s, map);
221
222 s.Close();
118 } 223 }
119 224
120 public void SaveStream(Stream stream, ITerrainChannel map) 225 public void SaveStream(Stream stream, ITerrainChannel map)
121 { 226 {
122 throw new NotImplementedException(); 227 BinaryWriter bs = new BinaryWriter(stream);
228
229 //find the max and min heights on the map
230 double heightMax = map[0,0];
231 double heightMin = map[0,0];
232
233 for (int y = 0; y < map.Height; y++)
234 {
235 for (int x = 0; x < map.Width; x++)
236 {
237 double current = map[x,y];
238 if (heightMax < current)
239 heightMax = current;
240 if (heightMin > current)
241 heightMin = current;
242 }
243 }
244
245 double baseHeight = Math.Floor( (heightMax + heightMin) / 2d );
246
247 double horizontalScale = Math.Ceiling((heightMax - heightMin));
248
249 // if we are completely flat add 1cm range to avoid NaN divisions
250 if (horizontalScale < 0.01d)
251 horizontalScale = 0.01d;
252
253 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
254
255 bs.Write(enc.GetBytes("TERRAGENTERRAIN "));
256
257 bs.Write(enc.GetBytes("SIZE"));
258 bs.Write(Convert.ToInt16(Constants.RegionSize));
259 bs.Write(Convert.ToInt16(0)); // necessary padding
260
261 //The XPTS and YPTS chunks are not needed for square regions
262 //but L3DT won't load the terrain file properly without them.
263 bs.Write(enc.GetBytes("XPTS"));
264 bs.Write(Convert.ToInt16(Constants.RegionSize));
265 bs.Write(Convert.ToInt16(0)); // necessary padding
266
267 bs.Write(enc.GetBytes("YPTS"));
268 bs.Write(Convert.ToInt16(Constants.RegionSize));
269 bs.Write(Convert.ToInt16(0)); // necessary padding
270
271 bs.Write(enc.GetBytes("SCAL"));
272 bs.Write(ToLittleEndian(1f)); //we're going to say that 1 terrain unit is 1 metre
273 bs.Write(ToLittleEndian(1f));
274 bs.Write(ToLittleEndian(1f));
275
276 // as we are square and not projected on a sphere then the other
277 // header blocks are not required
278
279 // now write the elevation data
280 bs.Write(enc.GetBytes("ALTW"));
281 bs.Write(Convert.ToInt16(horizontalScale)); // range between max and min
282 bs.Write(Convert.ToInt16(baseHeight)); // base height or mid point
283
284 for (int y = 0; y < map.Height; y++)
285 {
286 for (int x = 0; x < map.Width; x++)
287 {
288 float elevation = (float)((map[x,y] - baseHeight) * 65536 ) / (float)horizontalScale; // see LoadStream for inverse
289
290 // clamp rounding issues
291 if (elevation > Int16.MaxValue)
292 elevation = Int16.MaxValue;
293 else if (elevation < Int16.MinValue)
294 elevation = Int16.MinValue;
295
296 bs.Write(Convert.ToInt16(elevation));
297 }
298 }
299
300 //This is only necessary for older versions of Terragen.
301 bs.Write(enc.GetBytes("EOF "));
302
303 bs.Close();
123 } 304 }
124 305
125 public string FileExtension 306 public string FileExtension
@@ -127,16 +308,34 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
127 get { return ".ter"; } 308 get { return ".ter"; }
128 } 309 }
129 310
130 public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
131 {
132 throw new NotImplementedException();
133 }
134
135 #endregion 311 #endregion
136 312
137 public override string ToString() 313 public override string ToString()
138 { 314 {
139 return "Terragen"; 315 return "Terragen";
140 } 316 }
317
318 /// <summary>
319 /// terragen SCAL floats need to be written intel ordered regardless of
320 /// big or little endian system
321 /// </summary>
322 /// <param name="number"></param>
323 /// <returns></returns>
324 private byte[] ToLittleEndian( float number)
325 {
326 byte[] retVal = BitConverter.GetBytes(number);
327 if (BitConverter.IsLittleEndian == false)
328 {
329 byte[] tmp = new byte[4];
330 for (int i = 0; i < 4; i++)
331 {
332 tmp[i] = retVal[3 - i];
333 }
334 retVal = tmp;
335
336 }
337 return retVal ;
338 }
339
141 } 340 }
142} 341}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 25d73c2..8a79d78 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -131,7 +131,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
131 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 131 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
132 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; 132 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
133 m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick; 133 m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
134 InstallInterfaces();
135 } 134 }
136 135
137 InstallDefaultEffects(); 136 InstallDefaultEffects();
@@ -140,6 +139,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain
140 139
141 public void RegionLoaded(Scene scene) 140 public void RegionLoaded(Scene scene)
142 { 141 {
142 //Do this here to give file loaders time to initialize and
143 //register their supported file extensions and file formats.
144 InstallInterfaces();
143 } 145 }
144 146
145 public void RemoveRegion(Scene scene) 147 public void RemoveRegion(Scene scene)
@@ -1082,8 +1084,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1082 { 1084 {
1083 // Load / Save 1085 // Load / Save
1084 string supportedFileExtensions = ""; 1086 string supportedFileExtensions = "";
1087 string supportedFilesSeparator = "";
1085 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) 1088 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
1086 supportedFileExtensions += " " + loader.Key + " (" + loader.Value + ")"; 1089 {
1090 supportedFileExtensions += supportedFilesSeparator + loader.Key + " (" + loader.Value + ")";
1091 supportedFilesSeparator = ", ";
1092 }
1087 1093
1088 Command loadFromFileCommand = 1094 Command loadFromFileCommand =
1089 new Command("load", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadFile, "Loads a terrain from a specified file."); 1095 new Command("load", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadFile, "Loads a terrain from a specified file.");
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index e8738c4..8b96de4 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Region.Framework.Interfaces
42 42
43 void TeleportHome(UUID id, IClientAPI client); 43 void TeleportHome(UUID id, IClientAPI client);
44 44
45 void Cross(ScenePresence agent, bool isFlying); 45 bool Cross(ScenePresence agent, bool isFlying);
46 46
47 void AgentArrivedAtDestination(UUID agent); 47 void AgentArrivedAtDestination(UUID agent);
48 48
diff --git a/OpenSim/Region/Framework/Interfaces/ILandChannel.cs b/OpenSim/Region/Framework/Interfaces/ILandChannel.cs
index 20b8ab6..30bae16 100644
--- a/OpenSim/Region/Framework/Interfaces/ILandChannel.cs
+++ b/OpenSim/Region/Framework/Interfaces/ILandChannel.cs
@@ -69,6 +69,14 @@ namespace OpenSim.Region.Framework.Interfaces
69 /// <returns></returns> 69 /// <returns></returns>
70 ILandObject GetLandObject(int localID); 70 ILandObject GetLandObject(int localID);
71 71
72 /// <summary>
73 /// Clear the land channel of all parcels.
74 /// </summary>
75 /// <param name="setupDefaultParcel">
76 /// If true, set up a default parcel covering the whole region owned by the estate owner.
77 /// </param>
78 void Clear(bool setupDefaultParcel);
79
72 bool IsLandPrimCountTainted(); 80 bool IsLandPrimCountTainted();
73 bool IsForcefulBansAllowed(); 81 bool IsForcefulBansAllowed();
74 void UpdateLandObject(int localID, LandData data); 82 void UpdateLandObject(int localID, LandData data);
diff --git a/OpenSim/Region/Framework/Interfaces/ILandObject.cs b/OpenSim/Region/Framework/Interfaces/ILandObject.cs
index 576b645..eeb9d3a 100644
--- a/OpenSim/Region/Framework/Interfaces/ILandObject.cs
+++ b/OpenSim/Region/Framework/Interfaces/ILandObject.cs
@@ -39,6 +39,7 @@ namespace OpenSim.Region.Framework.Interfaces
39 { 39 {
40 int GetParcelMaxPrimCount(ILandObject thisObject); 40 int GetParcelMaxPrimCount(ILandObject thisObject);
41 int GetSimulatorMaxPrimCount(ILandObject thisObject); 41 int GetSimulatorMaxPrimCount(ILandObject thisObject);
42 int GetPrimsFree();
42 43
43 LandData LandData { get; set; } 44 LandData LandData { get; set; }
44 bool[,] LandBitmap { get; set; } 45 bool[,] LandBitmap { get; set; }
diff --git a/OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs b/OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs
new file mode 100644
index 0000000..65158e1
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs
@@ -0,0 +1,55 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenMetaverse;
29using OpenSim.Framework;
30
31namespace OpenSim.Region.Framework.Interfaces
32{
33 public interface IPrimCountModule
34 {
35 void TaintPrimCount(ILandObject land);
36 void TaintPrimCount(int x, int y);
37 void TaintPrimCount();
38
39 IPrimCounts GetPrimCounts(UUID parcelID);
40 }
41
42 public interface IPrimCounts
43 {
44 int Owner { get; }
45 int Group { get; }
46 int Others { get; }
47 int Simulator { get; }
48 IUserPrimCounts Users { get; }
49 }
50
51 public interface IUserPrimCounts
52 {
53 int this[UUID agentID] { get; }
54 }
55}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index dc08b49..4fca261 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3861,14 +3861,16 @@ namespace OpenSim.Region.Framework.Scenes
3861 RequestTeleportLocation(remoteClient, info.RegionHandle, position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark)); 3861 RequestTeleportLocation(remoteClient, info.RegionHandle, position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark));
3862 } 3862 }
3863 3863
3864 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 3864 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
3865 { 3865 {
3866 if (m_teleportModule != null) 3866 if (m_teleportModule != null)
3867 m_teleportModule.Cross(agent, isFlying); 3867 return m_teleportModule.Cross(agent, isFlying);
3868 else 3868 else
3869 { 3869 {
3870 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); 3870 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
3871 } 3871 }
3872
3873 return false;
3872 } 3874 }
3873 3875
3874 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) 3876 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence)
@@ -4919,7 +4921,7 @@ namespace OpenSim.Region.Framework.Scenes
4919 // from logging into the region, teleporting into the region 4921 // from logging into the region, teleporting into the region
4920 // or corssing the broder walking, but will NOT prevent 4922 // or corssing the broder walking, but will NOT prevent
4921 // child agent creation, thereby emulating the SL behavior. 4923 // child agent creation, thereby emulating the SL behavior.
4922 public bool QueryAccess(UUID agentID) 4924 public bool QueryAccess(UUID agentID, Vector3 position)
4923 { 4925 {
4924 return true; 4926 return true;
4925 } 4927 }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 1c276fa..cd70de8 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2725,29 +2725,57 @@ namespace OpenSim.Region.Framework.Scenes
2725 // Makes sure avatar does not end up outside region 2725 // Makes sure avatar does not end up outside region
2726 if (neighbor <= 0) 2726 if (neighbor <= 0)
2727 { 2727 {
2728 if (!needsTransit) 2728 if (needsTransit)
2729 { 2729 {
2730 if (m_requestedSitTargetUUID == UUID.Zero) 2730 if (m_requestedSitTargetUUID == UUID.Zero)
2731 { 2731 {
2732 bool isFlying = m_physicsActor.Flying;
2733 RemoveFromPhysicalScene();
2734
2732 Vector3 pos = AbsolutePosition; 2735 Vector3 pos = AbsolutePosition;
2733 if (AbsolutePosition.X < 0) 2736 if (AbsolutePosition.X < 0)
2734 pos.X += Velocity.X; 2737 pos.X += Velocity.X * 2;
2735 else if (AbsolutePosition.X > Constants.RegionSize) 2738 else if (AbsolutePosition.X > Constants.RegionSize)
2736 pos.X -= Velocity.X; 2739 pos.X -= Velocity.X * 2;
2737 if (AbsolutePosition.Y < 0) 2740 if (AbsolutePosition.Y < 0)
2738 pos.Y += Velocity.Y; 2741 pos.Y += Velocity.Y * 2;
2739 else if (AbsolutePosition.Y > Constants.RegionSize) 2742 else if (AbsolutePosition.Y > Constants.RegionSize)
2740 pos.Y -= Velocity.Y; 2743 pos.Y -= Velocity.Y * 2;
2744 Velocity = Vector3.Zero;
2741 AbsolutePosition = pos; 2745 AbsolutePosition = pos;
2746
2747 AddToPhysicalScene(isFlying);
2742 } 2748 }
2743 } 2749 }
2744 } 2750 }
2745 else if (neighbor > 0) 2751 else if (neighbor > 0)
2746 CrossToNewRegion(); 2752 {
2753 if (!CrossToNewRegion())
2754 {
2755 if (m_requestedSitTargetUUID == UUID.Zero)
2756 {
2757 bool isFlying = m_physicsActor.Flying;
2758 RemoveFromPhysicalScene();
2759
2760 Vector3 pos = AbsolutePosition;
2761 if (AbsolutePosition.X < 0)
2762 pos.X += Velocity.X * 2;
2763 else if (AbsolutePosition.X > Constants.RegionSize)
2764 pos.X -= Velocity.X * 2;
2765 if (AbsolutePosition.Y < 0)
2766 pos.Y += Velocity.Y * 2;
2767 else if (AbsolutePosition.Y > Constants.RegionSize)
2768 pos.Y -= Velocity.Y * 2;
2769 Velocity = Vector3.Zero;
2770 AbsolutePosition = pos;
2771
2772 AddToPhysicalScene(isFlying);
2773 }
2774 }
2775 }
2747 } 2776 }
2748 else 2777 else
2749 { 2778 {
2750 RemoveFromPhysicalScene();
2751 // This constant has been inferred from experimentation 2779 // This constant has been inferred from experimentation
2752 // I'm not sure what this value should be, so I tried a few values. 2780 // I'm not sure what this value should be, so I tried a few values.
2753 timeStep = 0.04f; 2781 timeStep = 0.04f;
@@ -2796,16 +2824,15 @@ namespace OpenSim.Region.Framework.Scenes
2796 /// If the neighbor accepts, remove the agent's viewable avatar from this scene 2824 /// If the neighbor accepts, remove the agent's viewable avatar from this scene
2797 /// set them to a child agent. 2825 /// set them to a child agent.
2798 /// </summary> 2826 /// </summary>
2799 protected void CrossToNewRegion() 2827 protected bool CrossToNewRegion()
2800 { 2828 {
2801 InTransit();
2802 try 2829 try
2803 { 2830 {
2804 m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); 2831 return m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying);
2805 } 2832 }
2806 catch 2833 catch
2807 { 2834 {
2808 m_scene.CrossAgentToNewRegion(this, false); 2835 return m_scene.CrossAgentToNewRegion(this, false);
2809 } 2836 }
2810 } 2837 }
2811 2838
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs
index be5411a..98e5453 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs
@@ -62,6 +62,11 @@ public class RegionCombinerLargeLandChannel : ILandChannel
62 { 62 {
63 return RootRegionLandChannel.AllParcels(); 63 return RootRegionLandChannel.AllParcels();
64 } 64 }
65
66 public void Clear(bool setupDefaultParcel)
67 {
68 RootRegionLandChannel.Clear(setupDefaultParcel);
69 }
65 70
66 public ILandObject GetLandObject(int x, int y) 71 public ILandObject GetLandObject(int x, int y)
67 { 72 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index bca08fb..c0c790d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -702,7 +702,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
702 // and convert the regionName to the target region 702 // and convert the regionName to the target region
703 if (regionName.Contains(".") && regionName.Contains(":")) 703 if (regionName.Contains(".") && regionName.Contains(":"))
704 { 704 {
705 List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.ScopeID, regionName, 1); 705// List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.ScopeID, regionName, 1);
706 string[] parts = regionName.Split(new char[] { ':' }); 706 string[] parts = regionName.Split(new char[] { ':' });
707 if (parts.Length > 2) 707 if (parts.Length > 2)
708 regionName = parts[0] + ':' + parts[1] + "/ " + parts[2]; 708 regionName = parts[0] + ':' + parts[1] + "/ " + parts[2];
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index 57672a8..2601d2a 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -326,10 +326,17 @@ namespace OpenSim.Server.Handlers.Simulation
326 return; 326 return;
327 } 327 }
328 328
329 // m_log.DebugFormat("[AGENT HANDLER]: Received QUERYACCESS with {0}", (string)request["body"]);
330 OSDMap args = Utils.GetOSDMap((string)request["body"]);
331
332 Vector3 position = Vector3.Zero;
333 if (args.ContainsKey("position"))
334 position = Vector3.Parse(args["position"].AsString());
335
329 GridRegion destination = new GridRegion(); 336 GridRegion destination = new GridRegion();
330 destination.RegionID = regionID; 337 destination.RegionID = regionID;
331 338
332 bool result = m_SimulationService.QueryAccess(destination, id); 339 bool result = m_SimulationService.QueryAccess(destination, id, position);
333 340
334 responsedata["int_response_code"] = HttpStatusCode.OK; 341 responsedata["int_response_code"] = HttpStatusCode.OK;
335 responsedata["str_response_string"] = result.ToString(); 342 responsedata["str_response_string"] = result.ToString();
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 143c296..c5313fc 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -31,6 +31,7 @@ using System.IO;
31using System.Net; 31using System.Net;
32using System.Reflection; 32using System.Reflection;
33using System.Text; 33using System.Text;
34using System.Collections;
34 35
35using OpenSim.Framework; 36using OpenSim.Framework;
36using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
@@ -206,9 +207,9 @@ namespace OpenSim.Services.Connectors.Simulation
206 207
207 /// <summary> 208 /// <summary>
208 /// </summary> 209 /// </summary>
209 public bool QueryAccess(GridRegion destination, UUID id) 210 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position)
210 { 211 {
211 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start"); 212 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position);
212 213
213 IPEndPoint ext = destination.ExternalEndPoint; 214 IPEndPoint ext = destination.ExternalEndPoint;
214 if (ext == null) return false; 215 if (ext == null) return false;
@@ -216,10 +217,26 @@ namespace OpenSim.Services.Connectors.Simulation
216 // Eventually, we want to use a caps url instead of the agentID 217 // Eventually, we want to use a caps url instead of the agentID
217 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; 218 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/";
218 219
220 OSDMap request = new OSDMap();
221 request.Add("position", OSD.FromString(position.ToString()));
222
219 try 223 try
220 { 224 {
221 OSDMap result = WebUtil.ServiceOSDRequest(uri,null,"QUERYACCESS",10000); 225 OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 10000);
222 return result["Success"].AsBoolean(); 226 bool success = result["Success"].AsBoolean();
227 if (!success)
228 {
229 if (result.ContainsKey("Message"))
230 {
231 string message = result["Message"].AsString();
232 if (message == "Service request failed: [MethodNotAllowed] MethodNotAllowed") // Old style region
233 {
234 m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored");
235 return true;
236 }
237 }
238 }
239 return success;
223 } 240 }
224 catch (Exception e) 241 catch (Exception e)
225 { 242 {
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index 12e8982..48a2185 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Services.Interfaces
60 60
61 bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent); 61 bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent);
62 62
63 bool QueryAccess(GridRegion destination, UUID id); 63 bool QueryAccess(GridRegion destination, UUID id, Vector3 position);
64 64
65 /// <summary> 65 /// <summary>
66 /// Message from receiving region to departing region, telling it got contacted by the client. 66 /// Message from receiving region to departing region, telling it got contacted by the client.
diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
index 159764c..c3134b3 100644
--- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs
+++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
@@ -55,6 +55,11 @@ namespace OpenSim.Tests.Common.Mock
55 { 55 {
56 return new List<ILandObject>(); 56 return new List<ILandObject>();
57 } 57 }
58
59 public void Clear(bool setupDefaultParcel)
60 {
61 // Intentionally blank since we don't save any parcel data in the test channel
62 }
58 63
59 protected ILandObject GetNoLand() 64 protected ILandObject GetNoLand()
60 { 65 {