aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorKitto Flora2011-03-22 20:33:24 +0000
committerKitto Flora2011-03-22 20:33:24 +0000
commit764e8c2a4371c24d1a0bd067c0bcbc806562064d (patch)
tree03dfb1bfe16c420fdbb6a1aa723c9203771d1beb /OpenSim/Region
parentMerge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/ca... (diff)
parentAdd some more fields to Estate settings and make them work. (diff)
downloadopensim-SC_OLD-764e8c2a4371c24d1a0bd067c0bcbc806562064d.zip
opensim-SC_OLD-764e8c2a4371c24d1a0bd067c0bcbc806562064d.tar.gz
opensim-SC_OLD-764e8c2a4371c24d1a0bd067c0bcbc806562064d.tar.bz2
opensim-SC_OLD-764e8c2a4371c24d1a0bd067c0bcbc806562064d.tar.xz
Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/OpenSim.cs77
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs12
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs16
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs171
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs26
-rw-r--r--OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs27
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs21
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs60
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs64
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs215
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs18
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs155
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs680
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs478
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs63
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/LightShare/LightShareModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml1
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs8
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs5
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs362
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs19
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs224
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs636
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs82
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs60
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs102
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs9
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISceneViewer.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs360
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs43
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs53
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneViewer.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs173
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs137
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs70
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs1
-rw-r--r--OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs58
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs14
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs19
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs66
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs1
-rw-r--r--OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs118
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs45
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs36
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs46
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs71
77 files changed, 2985 insertions, 2055 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 1c84e3f..313cdca 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -294,6 +294,18 @@ namespace OpenSim
294 "show connections", 294 "show connections",
295 "Show connection data", HandleShow); 295 "Show connection data", HandleShow);
296 296
297 m_console.Commands.AddCommand("region", false, "show circuits",
298 "show circuits",
299 "Show agent circuit data", HandleShow);
300
301 m_console.Commands.AddCommand("region", false, "show http-handlers",
302 "show http-handlers",
303 "Show all registered http handlers", HandleShow);
304
305 m_console.Commands.AddCommand("region", false, "show pending-objects",
306 "show pending-objects",
307 "Show # of objects on the pending queues of all scene viewers", HandleShow);
308
297 m_console.Commands.AddCommand("region", false, "show modules", 309 m_console.Commands.AddCommand("region", false, "show modules",
298 "show modules", 310 "show modules",
299 "Show module data", HandleShow); 311 "Show module data", HandleShow);
@@ -943,6 +955,66 @@ namespace OpenSim
943 MainConsole.Instance.Output(connections.ToString()); 955 MainConsole.Instance.Output(connections.ToString());
944 break; 956 break;
945 957
958 case "circuits":
959 System.Text.StringBuilder acd = new System.Text.StringBuilder("Agent Circuits:\n");
960 m_sceneManager.ForEachScene(
961 delegate(Scene scene)
962 {
963 //this.HttpServer.
964 acd.AppendFormat("{0}:\n", scene.RegionInfo.RegionName);
965 foreach (AgentCircuitData aCircuit in scene.AuthenticateHandler.AgentCircuits.Values)
966 acd.AppendFormat("\t{0} {1} ({2})\n", aCircuit.firstname, aCircuit.lastname, (aCircuit.child ? "Child" : "Root"));
967 }
968 );
969
970 MainConsole.Instance.Output(acd.ToString());
971 break;
972
973 case "http-handlers":
974 System.Text.StringBuilder handlers = new System.Text.StringBuilder("Registered HTTP Handlers:\n");
975
976 handlers.AppendFormat("* XMLRPC:\n");
977 foreach (String s in HttpServer.GetXmlRpcHandlerKeys())
978 handlers.AppendFormat("\t{0}\n", s);
979
980 handlers.AppendFormat("* HTTP:\n");
981 List<String> poll = HttpServer.GetPollServiceHandlerKeys();
982 foreach (String s in HttpServer.GetHTTPHandlerKeys())
983 handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty));
984
985 handlers.AppendFormat("* Agent:\n");
986 foreach (String s in HttpServer.GetAgentHandlerKeys())
987 handlers.AppendFormat("\t{0}\n", s);
988
989 handlers.AppendFormat("* LLSD:\n");
990 foreach (String s in HttpServer.GetLLSDHandlerKeys())
991 handlers.AppendFormat("\t{0}\n", s);
992
993 handlers.AppendFormat("* StreamHandlers ({0}):\n", HttpServer.GetStreamHandlerKeys().Count);
994 foreach (String s in HttpServer.GetStreamHandlerKeys())
995 handlers.AppendFormat("\t{0}\n", s);
996
997 MainConsole.Instance.Output(handlers.ToString());
998 break;
999
1000 case "pending-objects":
1001 System.Text.StringBuilder pending = new System.Text.StringBuilder("Pending objects:\n");
1002 m_sceneManager.ForEachScene(
1003 delegate(Scene scene)
1004 {
1005 scene.ForEachScenePresence(
1006 delegate(ScenePresence sp)
1007 {
1008 pending.AppendFormat("{0}: {1} {2} pending\n",
1009 scene.RegionInfo.RegionName, sp.Name, sp.SceneViewer.GetPendingObjectsCount());
1010 }
1011 );
1012 }
1013 );
1014
1015 MainConsole.Instance.Output(pending.ToString());
1016 break;
1017
946 case "modules": 1018 case "modules":
947 MainConsole.Instance.Output("The currently loaded shared modules are:"); 1019 MainConsole.Instance.Output("The currently loaded shared modules are:");
948 foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules) 1020 foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules)
@@ -958,11 +1030,12 @@ namespace OpenSim
958 delegate(Scene scene) 1030 delegate(Scene scene)
959 { 1031 {
960 MainConsole.Instance.Output(String.Format( 1032 MainConsole.Instance.Output(String.Format(
961 "Region Name: {0}, Region XLoc: {1}, Region YLoc: {2}, Region Port: {3}", 1033 "Region Name: {0}, Region XLoc: {1}, Region YLoc: {2}, Region Port: {3}, Estate Name: {4}",
962 scene.RegionInfo.RegionName, 1034 scene.RegionInfo.RegionName,
963 scene.RegionInfo.RegionLocX, 1035 scene.RegionInfo.RegionLocX,
964 scene.RegionInfo.RegionLocY, 1036 scene.RegionInfo.RegionLocY,
965 scene.RegionInfo.InternalEndPoint.Port)); 1037 scene.RegionInfo.InternalEndPoint.Port,
1038 scene.RegionInfo.EstateSettings.EstateName));
966 }); 1039 });
967 break; 1040 break;
968 1041
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index b74a392..9960a54 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -877,9 +877,7 @@ namespace OpenSim
877 /// <summary> 877 /// <summary>
878 /// Load the estate information for the provided RegionInfo object. 878 /// Load the estate information for the provided RegionInfo object.
879 /// </summary> 879 /// </summary>
880 /// <param name="regInfo"> 880 /// <param name="regInfo"></param>
881 /// A <see cref="RegionInfo"/>
882 /// </param>
883 public void PopulateRegionEstateInfo(RegionInfo regInfo) 881 public void PopulateRegionEstateInfo(RegionInfo regInfo)
884 { 882 {
885 IEstateDataService estateDataService = EstateDataService; 883 IEstateDataService estateDataService = EstateDataService;
@@ -901,7 +899,13 @@ namespace OpenSim
901 regInfo.EstateSettings = estateDataService.LoadEstateSettings(regInfo.RegionID, true); 899 regInfo.EstateSettings = estateDataService.LoadEstateSettings(regInfo.RegionID, true);
902 900
903 regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); 901 regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
904 //regInfo.EstateSettings.Save(); 902
903 // FIXME: Later on, the scene constructor will reload the estate settings no matter what.
904 // Therefore, we need to do an initial save here otherwise the new estate name will be reset
905 // back to the default. The reloading of estate settings by scene could be eliminated if it
906 // knows that the passed in settings in RegionInfo are already valid. Also, it might be
907 // possible to eliminate some additional later saves made by callers of this method.
908 regInfo.EstateSettings.Save();
905 break; 909 break;
906 } 910 }
907 else 911 else
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index f1fdbc5..d6159cd 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -122,6 +122,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
122 public int PacketsReceived; 122 public int PacketsReceived;
123 /// <summary>Number of packets sent to this client</summary> 123 /// <summary>Number of packets sent to this client</summary>
124 public int PacketsSent; 124 public int PacketsSent;
125 /// <summary>Number of packets resent to this client</summary>
126 public int PacketsResent;
125 /// <summary>Total byte count of unacked packets sent to this client</summary> 127 /// <summary>Total byte count of unacked packets sent to this client</summary>
126 public int UnackedBytes; 128 public int UnackedBytes;
127 129
@@ -257,9 +259,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
257 public string GetStats() 259 public string GetStats()
258 { 260 {
259 return string.Format( 261 return string.Format(
260 "{0,7} {1,7} {2,9} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7} {10,7}", 262 "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}",
263 PacketsReceived,
261 PacketsSent, 264 PacketsSent,
262 PacketsReceived, 265 PacketsResent,
263 UnackedBytes, 266 UnackedBytes,
264 m_packetOutboxes[(int)ThrottleOutPacketType.Resend].Count, 267 m_packetOutboxes[(int)ThrottleOutPacketType.Resend].Count,
265 m_packetOutboxes[(int)ThrottleOutPacketType.Land].Count, 268 m_packetOutboxes[(int)ThrottleOutPacketType.Land].Count,
@@ -449,13 +452,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
449 /// an outgoing packet from each, obeying the throttling bucket limits 452 /// an outgoing packet from each, obeying the throttling bucket limits
450 /// </summary> 453 /// </summary>
451 /// 454 ///
455 /// <remarks>
452 /// Packet queues are inspected in ascending numerical order starting from 0. Therefore, queues with a lower 456 /// Packet queues are inspected in ascending numerical order starting from 0. Therefore, queues with a lower
453 /// ThrottleOutPacketType number will see their packet get sent first (e.g. if both Land and Wind queues have 457 /// ThrottleOutPacketType number will see their packet get sent first (e.g. if both Land and Wind queues have
454 /// packets, then the packet at the front of the Land queue will be sent before the packet at the front of the 458 /// packets, then the packet at the front of the Land queue will be sent before the packet at the front of the
455 /// wind queue). 459 /// wind queue).
456 /// 460 ///
457 /// <remarks>This function is only called from a synchronous loop in the 461 /// This function is only called from a synchronous loop in the
458 /// UDPServer so we don't need to bother making this thread safe</remarks> 462 /// UDPServer so we don't need to bother making this thread safe
463 /// </remarks>
464 ///
459 /// <returns>True if any packets were sent, otherwise false</returns> 465 /// <returns>True if any packets were sent, otherwise false</returns>
460 public bool DequeueOutgoing() 466 public bool DequeueOutgoing()
461 { 467 {
@@ -486,7 +492,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
486 m_udpServer.SendPacketFinal(nextPacket); 492 m_udpServer.SendPacketFinal(nextPacket);
487 m_nextPackets[i] = null; 493 m_nextPackets[i] = null;
488 packetSent = true; 494 packetSent = true;
489 this.PacketsSent++;
490 } 495 }
491 } 496 }
492 else 497 else
@@ -503,7 +508,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
503 // Send the packet 508 // Send the packet
504 m_udpServer.SendPacketFinal(packet); 509 m_udpServer.SendPacketFinal(packet);
505 packetSent = true; 510 packetSent = true;
506 this.PacketsSent++;
507 } 511 }
508 else 512 else
509 { 513 {
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 703176c..c865c0f 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics;
30using System.IO; 31using System.IO;
31using System.Net; 32using System.Net;
32using System.Net.Sockets; 33using System.Net.Sockets;
@@ -506,7 +507,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
506 507
507 // Bump up the resend count on this packet 508 // Bump up the resend count on this packet
508 Interlocked.Increment(ref outgoingPacket.ResendCount); 509 Interlocked.Increment(ref outgoingPacket.ResendCount);
509 //Interlocked.Increment(ref Stats.ResentPackets);
510 510
511 // Requeue or resend the packet 511 // Requeue or resend the packet
512 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, false)) 512 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, false))
@@ -582,6 +582,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
582 udpClient.NeedAcks.Add(outgoingPacket); 582 udpClient.NeedAcks.Add(outgoingPacket);
583 } 583 }
584 } 584 }
585 else
586 {
587 Interlocked.Increment(ref udpClient.PacketsResent);
588 }
585 589
586 #endregion Sequence Number Assignment 590 #endregion Sequence Number Assignment
587 591
@@ -636,10 +640,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
636 { 640 {
637 object[] array = new object[] { buffer, packet }; 641 object[] array = new object[] { buffer, packet };
638 642
639 if (m_asyncPacketHandling) 643 Util.FireAndForget(HandleUseCircuitCode, array);
640 Util.FireAndForget(HandleUseCircuitCode, array);
641 else
642 HandleUseCircuitCode(array);
643 644
644 return; 645 return;
645 } 646 }
@@ -844,7 +845,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
844 845
845 private void HandleUseCircuitCode(object o) 846 private void HandleUseCircuitCode(object o)
846 { 847 {
847 DateTime startTime = DateTime.Now; 848// DateTime startTime = DateTime.Now;
848 object[] array = (object[])o; 849 object[] array = (object[])o;
849 UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; 850 UDPPacketBuffer buffer = (UDPPacketBuffer)array[0];
850 UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1]; 851 UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1];
@@ -856,10 +857,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
856 // Begin the process of adding the client to the simulator 857 // Begin the process of adding the client to the simulator
857 AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint); 858 AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint);
858 859
859 // Acknowledge the UseCircuitCode packet 860 // Send ack
860 SendAckImmediate(remoteEndPoint, packet.Header.Sequence); 861 SendAckImmediate(remoteEndPoint, packet.Header.Sequence);
861 862
862// m_log.DebugFormat( 863 // m_log.DebugFormat(
863// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms", 864// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms",
864// buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds); 865// buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds);
865 } 866 }
@@ -923,25 +924,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP
923 924
924 protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) 925 protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
925 { 926 {
926 // Create the LLUDPClient 927 // In priciple there shouldn't be more than one thread here, ever.
927 LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO); 928 // But in case that happens, we need to synchronize this piece of code
928 IClientAPI existingClient; 929 // because it's too important
929 930 lock (this)
930 if (!m_scene.TryGetClient(agentID, out existingClient))
931 { 931 {
932 // Create the LLClientView 932 IClientAPI existingClient;
933 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
934 client.OnLogout += LogoutHandler;
935 933
936 client.DisableFacelights = m_disableFacelights; 934 if (!m_scene.TryGetClient(agentID, out existingClient))
935 {
936 // Create the LLUDPClient
937 LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
938 // Create the LLClientView
939 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
940 client.OnLogout += LogoutHandler;
937 941
938 // Start the IClientAPI 942 client.DisableFacelights = m_disableFacelights;
939 client.Start(); 943
940 } 944 // Start the IClientAPI
941 else 945 client.Start();
942 { 946
943 m_log.WarnFormat("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode from {0} at {1} for circuit {2}", 947 }
944 udpClient.AgentID, remoteEndPoint, circuitCode); 948 else
949 {
950 m_log.WarnFormat("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode from {0} at {1} for circuit {2}",
951 existingClient.AgentId, remoteEndPoint, circuitCode);
952 }
945 } 953 }
946 } 954 }
947 955
@@ -1052,6 +1060,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1052 1060
1053 #endregion Update Timers 1061 #endregion Update Timers
1054 1062
1063 // Use this for emergency monitoring -- bug hunting
1064 //if (m_scene.EmergencyMonitoring)
1065 // clientPacketHandler = MonitoredClientOutgoingPacketHandler;
1066 //else
1067 // clientPacketHandler = ClientOutgoingPacketHandler;
1068
1055 // Handle outgoing packets, resends, acknowledgements, and pings for each 1069 // Handle outgoing packets, resends, acknowledgements, and pings for each
1056 // client. m_packetSent will be set to true if a packet is sent 1070 // client. m_packetSent will be set to true if a packet is sent
1057 m_scene.ForEachClient(clientPacketHandler); 1071 m_scene.ForEachClient(clientPacketHandler);
@@ -1067,6 +1081,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1067 { 1081 {
1068 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex); 1082 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex);
1069 } 1083 }
1084
1070 } 1085 }
1071 1086
1072 Watchdog.RemoveThread(); 1087 Watchdog.RemoveThread();
@@ -1104,6 +1119,112 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1104 } 1119 }
1105 } 1120 }
1106 1121
1122 #region Emergency Monitoring
1123 // Alternative packet handler fuull of instrumentation
1124 // Handy for hunting bugs
1125 private Stopwatch watch1 = new Stopwatch();
1126 private Stopwatch watch2 = new Stopwatch();
1127
1128 private float avgProcessingTicks = 0;
1129 private float avgResendUnackedTicks = 0;
1130 private float avgSendAcksTicks = 0;
1131 private float avgSendPingTicks = 0;
1132 private float avgDequeueTicks = 0;
1133 private long nticks = 0;
1134 private long nticksUnack = 0;
1135 private long nticksAck = 0;
1136 private long nticksPing = 0;
1137 private int npacksSent = 0;
1138 private int npackNotSent = 0;
1139
1140 private void MonitoredClientOutgoingPacketHandler(IClientAPI client)
1141 {
1142 nticks++;
1143 watch1.Start();
1144 try
1145 {
1146 if (client is LLClientView)
1147 {
1148 LLUDPClient udpClient = ((LLClientView)client).UDPClient;
1149
1150 if (udpClient.IsConnected)
1151 {
1152 if (m_resendUnacked)
1153 {
1154 nticksUnack++;
1155 watch2.Start();
1156
1157 ResendUnacked(udpClient);
1158
1159 watch2.Stop();
1160 avgResendUnackedTicks = (nticksUnack - 1)/(float)nticksUnack * avgResendUnackedTicks + (watch2.ElapsedTicks / (float)nticksUnack);
1161 watch2.Reset();
1162 }
1163
1164 if (m_sendAcks)
1165 {
1166 nticksAck++;
1167 watch2.Start();
1168
1169 SendAcks(udpClient);
1170
1171 watch2.Stop();
1172 avgSendAcksTicks = (nticksAck - 1) / (float)nticksAck * avgSendAcksTicks + (watch2.ElapsedTicks / (float)nticksAck);
1173 watch2.Reset();
1174 }
1175
1176 if (m_sendPing)
1177 {
1178 nticksPing++;
1179 watch2.Start();
1180
1181 SendPing(udpClient);
1182
1183 watch2.Stop();
1184 avgSendPingTicks = (nticksPing - 1) / (float)nticksPing * avgSendPingTicks + (watch2.ElapsedTicks / (float)nticksPing);
1185 watch2.Reset();
1186 }
1187
1188 watch2.Start();
1189 // Dequeue any outgoing packets that are within the throttle limits
1190 if (udpClient.DequeueOutgoing())
1191 {
1192 m_packetSent = true;
1193 npacksSent++;
1194 }
1195 else
1196 npackNotSent++;
1197
1198 watch2.Stop();
1199 avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks);
1200 watch2.Reset();
1201
1202 }
1203 else
1204 m_log.WarnFormat("[LLUDPSERVER]: Client is not connected");
1205 }
1206 }
1207 catch (Exception ex)
1208 {
1209 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler iteration for " + client.Name +
1210 " threw an exception: " + ex.Message, ex);
1211 }
1212 watch1.Stop();
1213 avgProcessingTicks = (nticks - 1) / (float)nticks * avgProcessingTicks + (watch1.ElapsedTicks / (float)nticks);
1214 watch1.Reset();
1215
1216 // reuse this -- it's every ~100ms
1217 if (m_scene.EmergencyMonitoring && nticks % 100 == 0)
1218 {
1219 m_log.InfoFormat("[LLUDPSERVER]: avg processing ticks: {0} avg unacked: {1} avg acks: {2} avg ping: {3} avg dequeue: {4} (TickCountRes: {5} sent: {6} notsent: {7})",
1220 avgProcessingTicks, avgResendUnackedTicks, avgSendAcksTicks, avgSendPingTicks, avgDequeueTicks, TickCountResolution, npacksSent, npackNotSent);
1221 npackNotSent = npacksSent = 0;
1222 }
1223
1224 }
1225
1226 #endregion
1227
1107 private void ProcessInPacket(object state) 1228 private void ProcessInPacket(object state)
1108 { 1229 {
1109 IncomingPacket incomingPacket = (IncomingPacket)state; 1230 IncomingPacket incomingPacket = (IncomingPacket)state;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
index 9d40688..d195110 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
@@ -143,7 +143,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
143 // Process all the pending adds 143 // Process all the pending adds
144 OutgoingPacket pendingAdd; 144 OutgoingPacket pendingAdd;
145 while (m_pendingAdds.TryDequeue(out pendingAdd)) 145 while (m_pendingAdds.TryDequeue(out pendingAdd))
146 m_packets[pendingAdd.SequenceNumber] = pendingAdd; 146 if (pendingAdd != null)
147 m_packets[pendingAdd.SequenceNumber] = pendingAdd;
147 148
148 // Process all the pending removes, including updating statistics and round-trip times 149 // Process all the pending removes, including updating statistics and round-trip times
149 PendingAck pendingRemove; 150 PendingAck pendingRemove;
@@ -152,17 +153,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
152 { 153 {
153 if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) 154 if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket))
154 { 155 {
155 m_packets.Remove(pendingRemove.SequenceNumber); 156 if (ackedPacket != null)
156
157 // Update stats
158 Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength);
159
160 if (!pendingRemove.FromResend)
161 { 157 {
162 // Calculate the round-trip time for this packet and its ACK 158 m_packets.Remove(pendingRemove.SequenceNumber);
163 int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount; 159
164 if (rtt > 0) 160 // Update stats
165 ackedPacket.Client.UpdateRoundTrip(rtt); 161 Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength);
162
163 if (!pendingRemove.FromResend)
164 {
165 // Calculate the round-trip time for this packet and its ACK
166 int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount;
167 if (rtt > 0)
168 ackedPacket.Client.UpdateRoundTrip(rtt);
169 }
166 } 170 }
167 } 171 }
168 } 172 }
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
index 5c5cb70..7526bd2 100644
--- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
@@ -26,12 +26,14 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Reflection; 31using System.Reflection;
31using log4net; 32using log4net;
32using Nini.Config; 33using Nini.Config;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Console;
35using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
37using Caps=OpenSim.Framework.Capabilities.Caps; 39using Caps=OpenSim.Framework.Capabilities.Caps;
@@ -61,6 +63,9 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
61 { 63 {
62 m_scene = scene; 64 m_scene = scene;
63 m_scene.RegisterModuleInterface<ICapabilitiesModule>(this); 65 m_scene.RegisterModuleInterface<ICapabilitiesModule>(this);
66 MainConsole.Instance.Commands.AddCommand("Capabilities", false, "show caps",
67 "show capabilities",
68 "Shows all registered capabilities", CapabilitiesCommand);
64 } 69 }
65 70
66 public void RegionLoaded(Scene scene) 71 public void RegionLoaded(Scene scene)
@@ -72,7 +77,9 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
72 m_scene.UnregisterModuleInterface<ICapabilitiesModule>(this); 77 m_scene.UnregisterModuleInterface<ICapabilitiesModule>(this);
73 } 78 }
74 79
75 public void PostInitialise() {} 80 public void PostInitialise()
81 {
82 }
76 83
77 public void Close() {} 84 public void Close() {}
78 85
@@ -227,5 +234,23 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
227 m_log.Info(" >> "+x+", "+y+": "+kvp.Value); 234 m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
228 } 235 }
229 } 236 }
237
238 private void CapabilitiesCommand(string module, string[] cmdparams)
239 {
240 System.Text.StringBuilder caps = new System.Text.StringBuilder();
241 caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
242
243 foreach (KeyValuePair<UUID, Caps> kvp in m_capsHandlers)
244 {
245 caps.AppendFormat("** User {0}:\n", kvp.Key);
246 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.CapsDetails.GetEnumerator(); kvp2.MoveNext(); )
247 {
248 Uri uri = new Uri(kvp2.Value.ToString());
249 caps.AppendFormat(" {0} = {1}\n", kvp2.Key, uri.PathAndQuery);
250 }
251 }
252
253 MainConsole.Instance.Output(caps.ToString());
254 }
230 } 255 }
231} 256}
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index e542d7d..7cba702 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -92,9 +92,9 @@ namespace Flotsam.RegionModules.AssetCache
92 // Expiration is expressed in hours. 92 // Expiration is expressed in hours.
93 private const double m_DefaultMemoryExpiration = 1.0; 93 private const double m_DefaultMemoryExpiration = 1.0;
94 private const double m_DefaultFileExpiration = 48; 94 private const double m_DefaultFileExpiration = 48;
95 private TimeSpan m_MemoryExpiration = TimeSpan.Zero; 95 private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration);
96 private TimeSpan m_FileExpiration = TimeSpan.Zero; 96 private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration);
97 private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.Zero; 97 private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(m_DefaultFileExpiration);
98 98
99 private static int m_CacheDirectoryTiers = 1; 99 private static int m_CacheDirectoryTiers = 1;
100 private static int m_CacheDirectoryTierLen = 3; 100 private static int m_CacheDirectoryTierLen = 3;
@@ -147,7 +147,7 @@ namespace Flotsam.RegionModules.AssetCache
147 } 147 }
148 148
149 m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); 149 m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory);
150 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); 150 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_CacheDirectory);
151 151
152 m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false); 152 m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false);
153 m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); 153 m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration));
@@ -245,16 +245,7 @@ namespace Flotsam.RegionModules.AssetCache
245 private void UpdateMemoryCache(string key, AssetBase asset) 245 private void UpdateMemoryCache(string key, AssetBase asset)
246 { 246 {
247 if (m_MemoryCacheEnabled) 247 if (m_MemoryCacheEnabled)
248 { 248 m_MemoryCache.AddOrUpdate(key, asset, m_MemoryExpiration);
249 if (m_MemoryExpiration > TimeSpan.Zero)
250 {
251 m_MemoryCache.AddOrUpdate(key, asset, m_MemoryExpiration);
252 }
253 else
254 {
255 m_MemoryCache.AddOrUpdate(key, asset, Double.MaxValue);
256 }
257 }
258 } 249 }
259 250
260 public void Cache(AssetBase asset) 251 public void Cache(AssetBase asset)
@@ -459,7 +450,7 @@ namespace Flotsam.RegionModules.AssetCache
459 private void CleanupExpiredFiles(object source, ElapsedEventArgs e) 450 private void CleanupExpiredFiles(object source, ElapsedEventArgs e)
460 { 451 {
461 if (m_LogLevel >= 2) 452 if (m_LogLevel >= 2)
462 m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration.ToString()); 453 m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration);
463 454
464 // Purge all files last accessed prior to this point 455 // Purge all files last accessed prior to this point
465 DateTime purgeLine = DateTime.Now - m_FileExpiration; 456 DateTime purgeLine = DateTime.Now - m_FileExpiration;
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
index 6fb8b46..df4d561 100644
--- a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
@@ -245,14 +245,12 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
245 WriteTextureData(httpRequest, httpResponse, texture, format); 245 WriteTextureData(httpRequest, httpResponse, texture, format);
246 return true; 246 return true;
247 } 247 }
248
249 } 248 }
250 249
251 // not found 250 // not found
252 m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found"); 251// m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found");
253 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; 252 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
254 return true; 253 return true;
255
256 } 254 }
257 255
258 private void WriteTextureData(OSHttpRequest request, OSHttpResponse response, AssetBase texture, string format) 256 private void WriteTextureData(OSHttpRequest request, OSHttpResponse response, AssetBase texture, string format)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 8c92588..dc33dbb 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -119,6 +119,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
119 return; 119 return;
120 } 120 }
121 121
122 if (part.OwnerID != remoteClient.AgentId) // Not ours
123 {
124 remoteClient.SendAgentAlertMessage(
125 "You don't have sufficient permissions to attach this object", false);
126 return;
127 }
128
122 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 129 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
123 // be removed when that functionality is implemented in opensim 130 // be removed when that functionality is implemented in opensim
124 AttachmentPt &= 0x7f; 131 AttachmentPt &= 0x7f;
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index f8ce444..08ac624 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -167,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
167 } 167 }
168 } 168 }
169 169
170 m_log.InfoFormat("[AVFACTORY]: complete texture check for {0}", client.AgentId); 170 m_log.DebugFormat("[AVFACTORY]: complete texture check for {0}", client.AgentId);
171 171
172 // If we only found default textures, then the appearance is not cached 172 // If we only found default textures, then the appearance is not cached
173 return (defonly ? false : true); 173 return (defonly ? false : true);
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index a514a83..ded8743 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -49,16 +49,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
49 { 49 {
50 m_scene = scene; 50 m_scene = scene;
51 m_scene.RegisterModuleInterface<IDialogModule>(this); 51 m_scene.RegisterModuleInterface<IDialogModule>(this);
52 52
53 m_scene.AddCommand( 53 m_scene.AddCommand(
54 this, "alert", "alert <first> <last> <message>", 54 this, "alert", "alert <message>",
55 "Send an alert to a user", 55 "Send an alert to everyone",
56 HandleAlertConsoleCommand); 56 HandleAlertConsoleCommand);
57 57
58 m_scene.AddCommand( 58 m_scene.AddCommand(
59 this, "alert general", "alert [general] <message>", 59 this, "alert-user", "alert-user <first> <last> <message>",
60 "Send an alert to everyone", 60 "Send an alert to a user",
61 "If keyword 'general' is omitted, then <message> must be surrounded by quotation marks.",
62 HandleAlertConsoleCommand); 61 HandleAlertConsoleCommand);
63 } 62 }
64 63
@@ -177,55 +176,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
177 { 176 {
178 if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) 177 if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene)
179 return; 178 return;
180 179
181 bool isGeneral = false;
182 string firstName = string.Empty;
183 string lastName = string.Empty;
184 string message = string.Empty; 180 string message = string.Empty;
185 181
186 if (cmdparams.Length > 1) 182 if (cmdparams[0].ToLower().Equals("alert"))
187 {
188 firstName = cmdparams[1];
189 isGeneral = firstName.ToLower().Equals("general");
190 }
191 if (cmdparams.Length == 2 && !isGeneral)
192 { 183 {
193 // alert "message" 184 message = CombineParams(cmdparams, 1);
194 message = cmdparams[1]; 185 m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}",
195 isGeneral = true; 186 m_scene.RegionInfo.RegionName, message);
196 } 187 SendGeneralAlert(message);
197 else if (cmdparams.Length > 2 && isGeneral)
198 {
199 // alert general <message>
200 message = CombineParams(cmdparams, 2);
201 } 188 }
202 else if (cmdparams.Length > 3) 189 else if (cmdparams.Length > 3)
203 { 190 {
204 // alert <first> <last> <message> 191 string firstName = cmdparams[1];
205 lastName = cmdparams[2]; 192 string lastName = cmdparams[2];
206 message = CombineParams(cmdparams, 3); 193 message = CombineParams(cmdparams, 3);
194 m_log.InfoFormat(
195 "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
196 m_scene.RegionInfo.RegionName, firstName, lastName, message);
197 SendAlertToUser(firstName, lastName, message, false);
207 } 198 }
208 else 199 else
209 { 200 {
210 OpenSim.Framework.Console.MainConsole.Instance.Output( 201 OpenSim.Framework.Console.MainConsole.Instance.Output(
211 "Usage: alert \"message\" | alert general <message> | alert <first> <last> <message>"); 202 "Usage: alert <message> | alert-user <first> <last> <message>");
212 return; 203 return;
213 } 204 }
214
215 if (isGeneral)
216 {
217 m_log.InfoFormat(
218 "[DIALOG]: Sending general alert in region {0} with message {1}",
219 m_scene.RegionInfo.RegionName, message);
220 SendGeneralAlert(message);
221 }
222 else
223 {
224 m_log.InfoFormat(
225 "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
226 m_scene.RegionInfo.RegionName, firstName, lastName, message);
227 SendAlertToUser(firstName, lastName, message, false);
228 }
229 } 205 }
230 206
231 private string CombineParams(string[] commandParams, int pos) 207 private string CombineParams(string[] commandParams, int pos)
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index dd9819a..a81ec7c 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -449,24 +449,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
449 return resp; 449 return resp;
450 } 450 }
451 451
452 /// <summary> 452 private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
453 /// delegate for sending a grid instant message asynchronously
454 /// </summary>
455 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID);
456 453
457 protected virtual void GridInstantMessageCompleted(IAsyncResult iar) 454 private class GIM {
458 { 455 public GridInstantMessage im;
459 GridInstantMessageDelegate icon = 456 public MessageResultNotification result;
460 (GridInstantMessageDelegate)iar.AsyncState; 457 };
461 icon.EndInvoke(iar);
462 }
463 458
459 private Queue<GIM> pendingInstantMessages = new Queue<GIM>();
460 private int numInstantMessageThreads = 0;
464 461
465 protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) 462 private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result)
466 { 463 {
467 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; 464 lock (pendingInstantMessages) {
465 if (numInstantMessageThreads >= 4) {
466 GIM gim = new GIM();
467 gim.im = im;
468 gim.result = result;
469 pendingInstantMessages.Enqueue(gim);
470 } else {
471 ++ numInstantMessageThreads;
472 m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads);
473 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain;
474 d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
475 }
476 }
477 }
468 478
469 d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); 479 private void GridInstantMessageCompleted(IAsyncResult iar)
480 {
481 GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState;
482 d.EndInvoke(iar);
470 } 483 }
471 484
472 /// <summary> 485 /// <summary>
@@ -481,8 +494,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
481 /// Pass in 0 the first time this method is called. It will be called recursively with the last 494 /// Pass in 0 the first time this method is called. It will be called recursively with the last
482 /// regionhandle tried 495 /// regionhandle tried
483 /// </param> 496 /// </param>
484 protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) 497 private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result)
485 { 498 {
499 GIM gim;
500 do {
501 try {
502 SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero);
503 } catch (Exception e) {
504 m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message);
505 }
506 lock (pendingInstantMessages) {
507 if (pendingInstantMessages.Count > 0) {
508 gim = pendingInstantMessages.Dequeue();
509 im = gim.im;
510 result = gim.result;
511 } else {
512 gim = null;
513 -- numInstantMessageThreads;
514 m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads);
515 }
516 }
517 } while (gim != null);
518 }
519 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
520 {
521
486 UUID toAgentID = new UUID(im.toAgentID); 522 UUID toAgentID = new UUID(im.toAgentID);
487 523
488 PresenceInfo upd = null; 524 PresenceInfo upd = null;
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 6030706..9b98de3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Serialization;
41using OpenSim.Framework.Serialization.External; 41using OpenSim.Framework.Serialization.External;
42using OpenSim.Region.CoreModules.World.Archiver; 42using OpenSim.Region.CoreModules.World.Archiver;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Region.Framework.Interfaces; 45using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Services.Interfaces; 46using OpenSim.Services.Interfaces;
46 47
@@ -75,6 +76,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
75 /// The stream from which the inventory archive will be loaded. 76 /// The stream from which the inventory archive will be loaded.
76 /// </value> 77 /// </value>
77 private Stream m_loadStream; 78 private Stream m_loadStream;
79
80 protected bool m_controlFileLoaded;
81 protected bool m_assetsLoaded;
82 protected bool m_inventoryNodesLoaded;
83
84 protected int m_successfulAssetRestores;
85 protected int m_failedAssetRestores;
86 protected int m_successfulItemRestores;
87
88 /// <summary>
89 /// Root destination folder for the IAR load.
90 /// </summary>
91 protected InventoryFolderBase m_rootDestinationFolder;
92
93 /// <summary>
94 /// Inventory nodes loaded from the iar.
95 /// </summary>
96 protected HashSet<InventoryNodeBase> m_loadedNodes = new HashSet<InventoryNodeBase>();
97
98 /// <summary>
99 /// In order to load identically named folders, we need to keep track of the folders that we have already
100 /// resolved.
101 /// </summary>
102 Dictionary <string, InventoryFolderBase> m_resolvedFolders = new Dictionary<string, InventoryFolderBase>();
103
104 /// <summary>
105 /// Record the creator id that should be associated with an asset. This is used to adjust asset creator ids
106 /// after OSP resolution (since OSP creators are only stored in the item
107 /// </summary>
108 protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>();
78 109
79 public InventoryArchiveReadRequest( 110 public InventoryArchiveReadRequest(
80 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) 111 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge)
@@ -100,20 +131,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
100 /// <summary> 131 /// <summary>
101 /// Execute the request 132 /// Execute the request
102 /// </summary> 133 /// </summary>
134 /// <remarks>
135 /// Only call this once. To load another IAR, construct another request object.
136 /// </remarks>
103 /// <returns> 137 /// <returns>
104 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are 138 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are
105 /// returned 139 /// returned
106 /// </returns> 140 /// </returns>
141 /// <exception cref="System.Exception">Thrown if load fails.</exception>
107 public HashSet<InventoryNodeBase> Execute() 142 public HashSet<InventoryNodeBase> Execute()
108 { 143 {
109 try 144 try
110 { 145 {
111 string filePath = "ERROR"; 146 string filePath = "ERROR";
112 int successfulAssetRestores = 0;
113 int failedAssetRestores = 0;
114 int successfulItemRestores = 0;
115
116 HashSet<InventoryNodeBase> loadedNodes = new HashSet<InventoryNodeBase>();
117 147
118 List<InventoryFolderBase> folderCandidates 148 List<InventoryFolderBase> folderCandidates
119 = InventoryArchiveUtils.FindFolderByPath( 149 = InventoryArchiveUtils.FindFolderByPath(
@@ -124,16 +154,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
124 // Possibly provide an option later on to automatically create this folder if it does not exist 154 // Possibly provide an option later on to automatically create this folder if it does not exist
125 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); 155 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
126 156
127 return loadedNodes; 157 return m_loadedNodes;
128 } 158 }
129 159
130 InventoryFolderBase rootDestinationFolder = folderCandidates[0]; 160 m_rootDestinationFolder = folderCandidates[0];
131 archive = new TarArchiveReader(m_loadStream); 161 archive = new TarArchiveReader(m_loadStream);
132
133 // In order to load identically named folders, we need to keep track of the folders that we have already
134 // resolved
135 Dictionary <string, InventoryFolderBase> resolvedFolders = new Dictionary<string, InventoryFolderBase>();
136
137 byte[] data; 162 byte[] data;
138 TarArchiveReader.TarEntryType entryType; 163 TarArchiveReader.TarEntryType entryType;
139 164
@@ -142,45 +167,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
142 if (filePath == ArchiveConstants.CONTROL_FILE_PATH) 167 if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
143 { 168 {
144 LoadControlFile(filePath, data); 169 LoadControlFile(filePath, data);
145 } 170 }
146 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 171 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
147 { 172 {
148 if (LoadAsset(filePath, data)) 173 LoadAssetFile(filePath, data);
149 successfulAssetRestores++;
150 else
151 failedAssetRestores++;
152
153 if ((successfulAssetRestores) % 50 == 0)
154 m_log.DebugFormat(
155 "[INVENTORY ARCHIVER]: Loaded {0} assets...",
156 successfulAssetRestores);
157 } 174 }
158 else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) 175 else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH))
159 { 176 {
160 filePath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); 177 LoadInventoryFile(filePath, entryType, data);
161
162 // Trim off the file portion if we aren't already dealing with a directory path
163 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
164 filePath = filePath.Remove(filePath.LastIndexOf("/") + 1);
165
166 InventoryFolderBase foundFolder
167 = ReplicateArchivePathToUserInventory(
168 filePath, rootDestinationFolder, resolvedFolders, loadedNodes);
169
170 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
171 {
172 InventoryItemBase item = LoadItem(data, foundFolder);
173
174 if (item != null)
175 {
176 successfulItemRestores++;
177
178 // If we aren't loading the folder containing the item then well need to update the
179 // viewer separately for that item.
180 if (!loadedNodes.Contains(foundFolder))
181 loadedNodes.Add(item);
182 }
183 }
184 } 178 }
185 } 179 }
186 180
@@ -188,10 +182,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
188 182
189 m_log.DebugFormat( 183 m_log.DebugFormat(
190 "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", 184 "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures",
191 successfulAssetRestores, failedAssetRestores); 185 m_successfulAssetRestores, m_failedAssetRestores);
192 m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores); 186 m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", m_successfulItemRestores);
193 187
194 return loadedNodes; 188 return m_loadedNodes;
195 } 189 }
196 finally 190 finally
197 { 191 {
@@ -400,9 +394,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
400 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); 394 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
401 if (UUID.Zero != ospResolvedId) // The user exists in this grid 395 if (UUID.Zero != ospResolvedId) // The user exists in this grid
402 { 396 {
397// m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId);
398
403 item.CreatorIdAsUuid = ospResolvedId; 399 item.CreatorIdAsUuid = ospResolvedId;
404 400
405 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the 401 // Don't preserve the OSPA in the creator id (which actually gets persisted to the
406 // database). Instead, replace with the UUID that we found. 402 // database). Instead, replace with the UUID that we found.
407 item.CreatorId = ospResolvedId.ToString(); 403 item.CreatorId = ospResolvedId.ToString();
408 404
@@ -410,7 +406,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
410 } 406 }
411 else if (item.CreatorData == null || item.CreatorData == String.Empty) 407 else if (item.CreatorData == null || item.CreatorData == String.Empty)
412 { 408 {
413 item.CreatorIdAsUuid = m_userInfo.PrincipalID; 409 item.CreatorId = m_userInfo.PrincipalID.ToString();
410 item.CreatorIdAsUuid = new UUID(item.CreatorId);
414 } 411 }
415 412
416 item.Owner = m_userInfo.PrincipalID; 413 item.Owner = m_userInfo.PrincipalID;
@@ -418,6 +415,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
418 // Reset folder ID to the one in which we want to load it 415 // Reset folder ID to the one in which we want to load it
419 item.Folder = loadFolder.ID; 416 item.Folder = loadFolder.ID;
420 417
418 // Record the creator id for the item's asset so that we can use it later, if necessary, when the asset
419 // is loaded.
420 // FIXME: This relies on the items coming before the assets in the TAR file. Need to create stronger
421 // checks for this, and maybe even an external tool for creating OARs which enforces this, rather than
422 // relying on native tar tools.
423 m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid;
424
421 m_scene.AddInventoryItem(item); 425 m_scene.AddInventoryItem(item);
422 426
423 return item; 427 return item;
@@ -446,18 +450,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
446 } 450 }
447 451
448 string extension = filename.Substring(i); 452 string extension = filename.Substring(i);
449 string uuid = filename.Remove(filename.Length - extension.Length); 453 string rawUuid = filename.Remove(filename.Length - extension.Length);
454 UUID assetId = new UUID(rawUuid);
450 455
451 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) 456 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
452 { 457 {
453 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; 458 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
454 459
455 if (assetType == (sbyte)AssetType.Unknown) 460 if (assetType == (sbyte)AssetType.Unknown)
456 m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); 461 {
462 m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, assetId);
463 }
464 else if (assetType == (sbyte)AssetType.Object)
465 {
466 if (m_creatorIdForAssetId.ContainsKey(assetId))
467 {
468 string xmlData = Utils.BytesToString(data);
469 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
470 foreach (SceneObjectPart sop in sog.Parts)
471 {
472 if (sop.CreatorData == null || sop.CreatorData == "")
473 {
474 sop.CreatorID = m_creatorIdForAssetId[assetId];
475 }
476 }
477
478 data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog));
479 }
480 }
457 481
458 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); 482 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
459 483
460 AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero.ToString()); 484 AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString());
461 asset.Data = data; 485 asset.Data = data;
462 486
463 m_scene.AssetService.Store(asset); 487 m_scene.AssetService.Store(asset);
@@ -495,7 +519,88 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
495 majorVersion, MAX_MAJOR_VERSION)); 519 majorVersion, MAX_MAJOR_VERSION));
496 } 520 }
497 521
498 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); 522 m_controlFileLoaded = true;
523 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version);
499 } 524 }
525
526 /// <summary>
527 /// Load inventory file
528 /// </summary>
529 /// <param name="path"></param>
530 /// <param name="entryType"></param>
531 /// <param name="data"></param>
532 protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data)
533 {
534 if (!m_controlFileLoaded)
535 throw new Exception(
536 string.Format(
537 "The IAR you are trying to load does not list {0} before {1}. Aborting load",
538 ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.INVENTORY_PATH));
539
540 if (m_assetsLoaded)
541 throw new Exception(
542 string.Format(
543 "The IAR you are trying to load does not list all {0} before {1}. Aborting load",
544 ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH));
545
546 path = path.Substring(ArchiveConstants.INVENTORY_PATH.Length);
547
548 // Trim off the file portion if we aren't already dealing with a directory path
549 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
550 path = path.Remove(path.LastIndexOf("/") + 1);
551
552 InventoryFolderBase foundFolder
553 = ReplicateArchivePathToUserInventory(
554 path, m_rootDestinationFolder, m_resolvedFolders, m_loadedNodes);
555
556 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
557 {
558 InventoryItemBase item = LoadItem(data, foundFolder);
559
560 if (item != null)
561 {
562 m_successfulItemRestores++;
563
564 // If we aren't loading the folder containing the item then well need to update the
565 // viewer separately for that item.
566 if (!m_loadedNodes.Contains(foundFolder))
567 m_loadedNodes.Add(item);
568 }
569 }
570
571 m_inventoryNodesLoaded = true;
572 }
573
574 /// <summary>
575 /// Load asset file
576 /// </summary>
577 /// <param name="path"></param>
578 /// <param name="data"></param>
579 protected void LoadAssetFile(string path, byte[] data)
580 {
581 if (!m_controlFileLoaded)
582 throw new Exception(
583 string.Format(
584 "The IAR you are trying to load does not list {0} before {1}. Aborting load",
585 ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.ASSETS_PATH));
586
587 if (!m_inventoryNodesLoaded)
588 throw new Exception(
589 string.Format(
590 "The IAR you are trying to load does not list all {0} before {1}. Aborting load",
591 ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH));
592
593 if (LoadAsset(path, data))
594 m_successfulAssetRestores++;
595 else
596 m_failedAssetRestores++;
597
598 if ((m_successfulAssetRestores) % 50 == 0)
599 m_log.DebugFormat(
600 "[INVENTORY ARCHIVER]: Loaded {0} assets...",
601 m_successfulAssetRestores);
602
603 m_assetsLoaded = true;
604 }
500 } 605 }
501} \ No newline at end of file 606} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index b1c2a3c..613f0ed 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -109,9 +109,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
109 109
110 scene.AddCommand( 110 scene.AddCommand(
111 this, "load iar", 111 this, "load iar",
112 "load iar [--merge] <first> <last> <inventory path> <password> [<IAR path>]", 112 "load iar [-m|--merge] <first> <last> <inventory path> <password> [<IAR path>]",
113 "Load user inventory archive (IAR).", 113 "Load user inventory archive (IAR).",
114 "--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" 114 "-m|--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones"
115 + "<first> is user's first name." + Environment.NewLine 115 + "<first> is user's first name." + Environment.NewLine
116 + "<last> is user's last name." + Environment.NewLine 116 + "<last> is user's last name." + Environment.NewLine
117 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine 117 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine
@@ -128,6 +128,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
128 + "<last> is the user's last name." + Environment.NewLine 128 + "<last> is the user's last name." + Environment.NewLine
129 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine 129 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine
130 + "-p|--profile=<url> adds the url of the profile service to the saved user information." + Environment.NewLine 130 + "-p|--profile=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
131 + "-c|--creators preserves information about foreign creators." + Environment.NewLine
132 + "-v|--verbose extra debug messages." + Environment.NewLine
131 + "<IAR path> is the filesystem path at which to save the IAR." 133 + "<IAR path> is the filesystem path at which to save the IAR."
132 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), 134 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME),
133 HandleSaveInvConsoleCommand); 135 HandleSaveInvConsoleCommand);
@@ -179,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
179 catch (EntryPointNotFoundException e) 181 catch (EntryPointNotFoundException e)
180 { 182 {
181 m_log.ErrorFormat( 183 m_log.ErrorFormat(
182 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 184 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
183 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 185 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
184 m_log.Error(e); 186 m_log.Error(e);
185 187
@@ -219,7 +221,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
219 catch (EntryPointNotFoundException e) 221 catch (EntryPointNotFoundException e)
220 { 222 {
221 m_log.ErrorFormat( 223 m_log.ErrorFormat(
222 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 224 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
223 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 225 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
224 m_log.Error(e); 226 m_log.Error(e);
225 227
@@ -267,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
267 catch (EntryPointNotFoundException e) 269 catch (EntryPointNotFoundException e)
268 { 270 {
269 m_log.ErrorFormat( 271 m_log.ErrorFormat(
270 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 272 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
271 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 273 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
272 m_log.Error(e); 274 m_log.Error(e);
273 275
@@ -315,7 +317,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
315 catch (EntryPointNotFoundException e) 317 catch (EntryPointNotFoundException e)
316 { 318 {
317 m_log.ErrorFormat( 319 m_log.ErrorFormat(
318 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 320 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
319 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 321 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
320 m_log.Error(e); 322 m_log.Error(e);
321 323
@@ -356,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
356 if (mainParams.Count < 6) 358 if (mainParams.Count < 6)
357 { 359 {
358 m_log.Error( 360 m_log.Error(
359 "[INVENTORY ARCHIVER]: usage is load iar [--merge] <first name> <last name> <inventory path> <user password> [<load file path>]"); 361 "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] <first name> <last name> <inventory path> <user password> [<load file path>]");
360 return; 362 return;
361 } 363 }
362 364
@@ -394,6 +396,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
394 OptionSet ops = new OptionSet(); 396 OptionSet ops = new OptionSet();
395 //ops.Add("v|version=", delegate(string v) { options["version"] = v; }); 397 //ops.Add("v|version=", delegate(string v) { options["version"] = v; });
396 ops.Add("p|profile=", delegate(string v) { options["profile"] = v; }); 398 ops.Add("p|profile=", delegate(string v) { options["profile"] = v; });
399 ops.Add("v|verbose", delegate(string v) { options["verbose"] = v; });
400 ops.Add("c|creators", delegate(string v) { options["creators"] = v; });
397 401
398 List<string> mainParams = ops.Parse(cmdparams); 402 List<string> mainParams = ops.Parse(cmdparams);
399 403
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
new file mode 100644
index 0000000..e5127a0
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
@@ -0,0 +1,155 @@
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.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using NUnit.Framework;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Serialization;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
41using OpenSim.Region.CoreModules.World.Serialiser;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup;
48
49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
50{
51 [TestFixture]
52 public class InventoryArchiveTestCase
53 {
54 protected ManualResetEvent mre = new ManualResetEvent(false);
55
56 /// <summary>
57 /// A raw array of bytes that we'll use to create an IAR memory stream suitable for isolated use in each test.
58 /// </summary>
59 protected byte[] m_iarStreamBytes;
60
61 /// <summary>
62 /// Stream of data representing a common IAR for load tests.
63 /// </summary>
64 protected MemoryStream m_iarStream;
65
66 protected UserAccount m_uaMT
67 = new UserAccount {
68 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
69 FirstName = "Mr",
70 LastName = "Tiddles" };
71 protected UserAccount m_uaLL1
72 = new UserAccount {
73 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
74 FirstName = "Lord",
75 LastName = "Lucan" };
76 protected UserAccount m_uaLL2
77 = new UserAccount {
78 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"),
79 FirstName = "Lord",
80 LastName = "Lucan" };
81 protected string m_item1Name = "Ray Gun Item";
82
83 [SetUp]
84 public virtual void SetUp()
85 {
86 m_iarStream = new MemoryStream(m_iarStreamBytes);
87 }
88
89 [TestFixtureSetUp]
90 public void FixtureSetup()
91 {
92 ConstructDefaultIarBytesForTestLoad();
93 }
94
95 protected void ConstructDefaultIarBytesForTestLoad()
96 {
97// log4net.Config.XmlConfigurator.Configure();
98
99 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
100 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
101 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
102
103 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
104
105 MemoryStream archiveWriteStream = new MemoryStream();
106
107 // Create asset
108 SceneObjectGroup object1;
109 SceneObjectPart part1;
110 {
111 string partName = "Ray Gun Object";
112 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
113 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
114 Vector3 groupPosition = new Vector3(10, 20, 30);
115 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
116 Vector3 offsetPosition = new Vector3(5, 10, 15);
117
118 part1
119 = new SceneObjectPart(
120 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
121 part1.Name = partName;
122
123 object1 = new SceneObjectGroup(part1);
124 scene.AddNewSceneObject(object1, false);
125 }
126
127 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
128 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
129 scene.AssetService.Store(asset1);
130
131 // Create item
132 InventoryItemBase item1 = new InventoryItemBase();
133 item1.Name = m_item1Name;
134 item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020");
135 item1.AssetID = asset1.FullID;
136 item1.GroupID = UUID.Random();
137 item1.CreatorIdAsUuid = m_uaLL1.PrincipalID;
138 item1.Owner = m_uaLL1.PrincipalID;
139 item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
140 scene.AddInventoryItem(item1);
141
142 archiverModule.ArchiveInventory(
143 Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, m_item1Name, "hampshire", archiveWriteStream);
144
145 m_iarStreamBytes = archiveWriteStream.ToArray();
146 }
147
148 protected void SaveCompleted(
149 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
150 Exception reportedException)
151 {
152 mre.Set();
153 }
154 }
155} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 76d0b85..7f156f8 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -31,7 +31,6 @@ using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Threading; 32using System.Threading;
33using NUnit.Framework; 33using NUnit.Framework;
34using NUnit.Framework.SyntaxHelpers;
35using OpenMetaverse; 34using OpenMetaverse;
36using OpenSim.Data; 35using OpenSim.Data;
37using OpenSim.Framework; 36using OpenSim.Framework;
@@ -50,182 +49,21 @@ using OpenSim.Tests.Common.Setup;
50namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests 49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
51{ 50{
52 [TestFixture] 51 [TestFixture]
53 public class InventoryArchiverTests 52 public class InventoryArchiverTests : InventoryArchiveTestCase
54 { 53 {
55 protected ManualResetEvent mre = new ManualResetEvent(false); 54 protected TestScene m_scene;
56 55 protected InventoryArchiverModule m_archiverModule;
57 /// <summary> 56
58 /// Stream of data representing a common IAR that can be reused in load tests.
59 /// </summary>
60 protected MemoryStream m_iarStream;
61
62 protected UserAccount m_ua1
63 = new UserAccount {
64 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
65 FirstName = "Mr",
66 LastName = "Tiddles" };
67 protected UserAccount m_ua2
68 = new UserAccount {
69 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
70 FirstName = "Lord",
71 LastName = "Lucan" };
72 string m_item1Name = "b.lsl";
73
74 private void SaveCompleted(
75 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
76 Exception reportedException)
77 {
78 mre.Set();
79 }
80
81 [SetUp] 57 [SetUp]
82 public void Init() 58 public override void SetUp()
83 {
84 ConstructDefaultIarForTestLoad();
85 }
86
87 protected void ConstructDefaultIarForTestLoad()
88 {
89 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random());
90
91 MemoryStream archiveWriteStream = new MemoryStream();
92 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
93
94 InventoryItemBase item1 = new InventoryItemBase();
95 item1.Name = m_item1Name;
96 item1.AssetID = UUID.Random();
97 item1.GroupID = UUID.Random();
98 //item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName);
99 //item1.CreatorId = userUuid.ToString();
100 item1.CreatorId = m_ua2.PrincipalID.ToString();
101 item1.Owner = UUID.Zero;
102
103 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
104 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
105
106 string item1FileName
107 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
108 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService));
109 tar.Close();
110 m_iarStream = new MemoryStream(archiveWriteStream.ToArray());
111 }
112
113 /// <summary>
114 /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive
115 /// (subject to change since there is no fixed format yet).
116 /// </summary>
117 [Test]
118 public void TestSavePathToIarV0_1()
119 { 59 {
120 TestHelper.InMethod(); 60 base.SetUp();
121// log4net.Config.XmlConfigurator.Configure();
122
123 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
124
125 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
126 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
127
128 // Create user
129 string userFirstName = "Jock";
130 string userLastName = "Stirrup";
131 string userPassword = "troll";
132 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
133 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
134 61
135 // Create asset 62 SerialiserModule serialiserModule = new SerialiserModule();
136 SceneObjectGroup object1; 63 m_archiverModule = new InventoryArchiverModule();
137 SceneObjectPart part1;
138 {
139 string partName = "My Little Dog Object";
140 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
141 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
142 Vector3 groupPosition = new Vector3(10, 20, 30);
143 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
144 Vector3 offsetPosition = new Vector3(5, 10, 15);
145
146 part1
147 = new SceneObjectPart(
148 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
149 part1.Name = partName;
150
151 object1 = new SceneObjectGroup(part1);
152 scene.AddNewSceneObject(object1, false);
153 }
154
155 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
156 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
157 scene.AssetService.Store(asset1);
158
159 // Create item
160 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
161 InventoryItemBase item1 = new InventoryItemBase();
162 item1.Name = "My Little Dog";
163 item1.AssetID = asset1.FullID;
164 item1.ID = item1Id;
165 InventoryFolderBase objsFolder
166 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
167 item1.Folder = objsFolder.ID;
168 scene.AddInventoryItem(item1);
169
170 MemoryStream archiveWriteStream = new MemoryStream();
171 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
172
173 // Test saving a particular path
174 mre.Reset();
175 archiverModule.ArchiveInventory(
176 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
177 mre.WaitOne(60000, false);
178
179 byte[] archive = archiveWriteStream.ToArray();
180 MemoryStream archiveReadStream = new MemoryStream(archive);
181 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
182
183 //bool gotControlFile = false;
184 bool gotObject1File = false;
185 //bool gotObject2File = false;
186 string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
187 string expectedObject1FilePath = string.Format(
188 "{0}{1}{2}",
189 ArchiveConstants.INVENTORY_PATH,
190 InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
191 expectedObject1FileName);
192
193 string filePath;
194 TarArchiveReader.TarEntryType tarEntryType;
195
196// Console.WriteLine("Reading archive");
197
198 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
199 {
200// Console.WriteLine("Got {0}", filePath);
201
202// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
203// {
204// gotControlFile = true;
205// }
206
207 if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
208 {
209// string fileName = filePath.Remove(0, "Objects/".Length);
210//
211// if (fileName.StartsWith(part1.Name))
212// {
213 Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
214 gotObject1File = true;
215// }
216// else if (fileName.StartsWith(part2.Name))
217// {
218// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
219// gotObject2File = true;
220// }
221 }
222 }
223
224// Assert.That(gotControlFile, Is.True, "No control file in archive");
225 Assert.That(gotObject1File, Is.True, "No item1 file in archive");
226// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
227 64
228 // TODO: Test presence of more files and contents of files. 65 m_scene = SceneSetupHelpers.SetupScene("Inventory");
66 SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule);
229 } 67 }
230 68
231 /// <summary> 69 /// <summary>
@@ -238,17 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
238 TestHelper.InMethod(); 76 TestHelper.InMethod();
239// log4net.Config.XmlConfigurator.Configure(); 77// log4net.Config.XmlConfigurator.Configure();
240 78
241 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
242
243 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
244 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
245
246 // Create user 79 // Create user
247 string userFirstName = "Jock"; 80 string userFirstName = "Jock";
248 string userLastName = "Stirrup"; 81 string userLastName = "Stirrup";
249 string userPassword = "troll"; 82 string userPassword = "troll";
250 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); 83 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
251 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); 84 UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);
252 85
253 // Create asset 86 // Create asset
254 SceneObjectGroup object1; 87 SceneObjectGroup object1;
@@ -267,12 +100,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
267 part1.Name = partName; 100 part1.Name = partName;
268 101
269 object1 = new SceneObjectGroup(part1); 102 object1 = new SceneObjectGroup(part1);
270 scene.AddNewSceneObject(object1, false); 103 m_scene.AddNewSceneObject(object1, false);
271 } 104 }
272 105
273 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 106 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
274 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); 107 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
275 scene.AssetService.Store(asset1); 108 m_scene.AssetService.Store(asset1);
276 109
277 // Create item 110 // Create item
278 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); 111 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
@@ -282,15 +115,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
282 item1.AssetID = asset1.FullID; 115 item1.AssetID = asset1.FullID;
283 item1.ID = item1Id; 116 item1.ID = item1Id;
284 InventoryFolderBase objsFolder 117 InventoryFolderBase objsFolder
285 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; 118 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0];
286 item1.Folder = objsFolder.ID; 119 item1.Folder = objsFolder.ID;
287 scene.AddInventoryItem(item1); 120 m_scene.AddInventoryItem(item1);
288 121
289 MemoryStream archiveWriteStream = new MemoryStream(); 122 MemoryStream archiveWriteStream = new MemoryStream();
290 archiverModule.OnInventoryArchiveSaved += SaveCompleted; 123 m_archiverModule.OnInventoryArchiveSaved += SaveCompleted;
291 124
292 mre.Reset(); 125 mre.Reset();
293 archiverModule.ArchiveInventory( 126 m_archiverModule.ArchiveInventory(
294 Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream); 127 Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream);
295 mre.WaitOne(60000, false); 128 mre.WaitOne(60000, false);
296 129
@@ -346,474 +179,99 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
346 } 179 }
347 180
348 /// <summary> 181 /// <summary>
349 /// Test that things work when the load path specified starts with a slash 182 /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized
350 /// </summary> 183 /// objects.
184 /// </summary>
351 [Test] 185 [Test]
352 public void TestLoadIarPathStartsWithSlash() 186 public void TestLoadIarCreatorAccountPresent()
353 { 187 {
354 TestHelper.InMethod(); 188 TestHelper.InMethod();
355// log4net.Config.XmlConfigurator.Configure(); 189// log4net.Config.XmlConfigurator.Configure();
356
357 SerialiserModule serialiserModule = new SerialiserModule();
358 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
359 Scene scene = SceneSetupHelpers.SetupScene("inventory");
360 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
361
362 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password");
363 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/Objects", "password", m_iarStream);
364 190
191 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood");
192
193 m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream);
365 InventoryItemBase foundItem1 194 InventoryItemBase foundItem1
366 = InventoryArchiveUtils.FindItemByPath( 195 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name);
367 scene.InventoryService, m_ua1.PrincipalID, "/Objects/" + m_item1Name); 196
197 Assert.That(
198 foundItem1.CreatorId, Is.EqualTo(m_uaLL1.PrincipalID.ToString()),
199 "Loaded item non-uuid creator doesn't match original");
200 Assert.That(
201 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL1.PrincipalID),
202 "Loaded item uuid creator doesn't match original");
203 Assert.That(foundItem1.Owner, Is.EqualTo(m_uaLL1.PrincipalID),
204 "Loaded item owner doesn't match inventory reciever");
368 205
369 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()"); 206 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
207 string xmlData = Utils.BytesToString(asset1.Data);
208 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
209
210 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID));
370 } 211 }
371 212
372 /// <summary> 213 /// <summary>
373 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 214 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
374 /// an account exists with the creator name. 215 /// an account exists with the same name as the creator, though not the same id.
375 /// </summary> 216 /// </summary>
376 ///
377 /// This test also does some deeper probing of loading into nested inventory structures
378 [Test] 217 [Test]
379 public void TestLoadIarV0_1ExistingUsers() 218 public void TestLoadIarV0_1SameNameCreator()
380 { 219 {
381 TestHelper.InMethod(); 220 TestHelper.InMethod();
382 //log4net.Config.XmlConfigurator.Configure(); 221// log4net.Config.XmlConfigurator.Configure();
383
384 SerialiserModule serialiserModule = new SerialiserModule();
385 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
386
387 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
388 Scene scene = SceneSetupHelpers.SetupScene("inventory");
389
390 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
391 222
392 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); 223 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "meowfood");
393 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); 224 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire");
394 225
395 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); 226 m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
396
397 InventoryItemBase foundItem1 227 InventoryItemBase foundItem1
398 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); 228 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
399
400 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
401 229
402// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
403// UUID, not the OSPA itself.
404// Assert.That(
405// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
406// "Loaded item non-uuid creator doesn't match original");
407 Assert.That( 230 Assert.That(
408 foundItem1.CreatorId, Is.EqualTo(m_ua2.PrincipalID.ToString()), 231 foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()),
409 "Loaded item non-uuid creator doesn't match original"); 232 "Loaded item non-uuid creator doesn't match original");
410
411 Assert.That( 233 Assert.That(
412 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua2.PrincipalID), 234 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID),
413 "Loaded item uuid creator doesn't match original"); 235 "Loaded item uuid creator doesn't match original");
414 Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID), 236 Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID),
415 "Loaded item owner doesn't match inventory reciever"); 237 "Loaded item owner doesn't match inventory reciever");
416
417 // Now try loading to a root child folder
418 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xA");
419 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
420 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream);
421
422 InventoryItemBase foundItem2
423 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name);
424 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
425
426 // Now try loading to a more deeply nested folder
427 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xB/xC");
428 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
429 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream);
430
431 InventoryItemBase foundItem3
432 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name);
433 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
434 }
435
436 [Test]
437 public void TestIarV0_1WithEscapedChars()
438 {
439 TestHelper.InMethod();
440// log4net.Config.XmlConfigurator.Configure();
441
442 string itemName = "You & you are a mean/man/";
443 string humanEscapedItemName = @"You & you are a mean\/man\/";
444 string userPassword = "meowfood";
445
446 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
447
448 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
449 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
450
451 // Create user
452 string userFirstName = "Jock";
453 string userLastName = "Stirrup";
454 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
455 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood");
456
457 // Create asset
458 SceneObjectGroup object1;
459 SceneObjectPart part1;
460 {
461 string partName = "part name";
462 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
463 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
464 Vector3 groupPosition = new Vector3(10, 20, 30);
465 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
466 Vector3 offsetPosition = new Vector3(5, 10, 15);
467
468 part1
469 = new SceneObjectPart(
470 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
471 part1.Name = partName;
472
473 object1 = new SceneObjectGroup(part1);
474 scene.AddNewSceneObject(object1, false);
475 }
476
477 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
478 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
479 scene.AssetService.Store(asset1);
480
481 // Create item
482 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
483 InventoryItemBase item1 = new InventoryItemBase();
484 item1.Name = itemName;
485 item1.AssetID = asset1.FullID;
486 item1.ID = item1Id;
487 InventoryFolderBase objsFolder
488 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
489 item1.Folder = objsFolder.ID;
490 scene.AddInventoryItem(item1);
491
492 MemoryStream archiveWriteStream = new MemoryStream();
493 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
494
495 mre.Reset();
496 archiverModule.ArchiveInventory(
497 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
498 mre.WaitOne(60000, false);
499
500 // LOAD ITEM
501 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
502 238
503 archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); 239 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
504 240 string xmlData = Utils.BytesToString(asset1.Data);
505 InventoryItemBase foundItem1 241 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
506 = InventoryArchiveUtils.FindItemByPath(
507 scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
508 242
509 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 243 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID));
510// Assert.That(
511// foundItem1.CreatorId, Is.EqualTo(userUuid),
512// "Loaded item non-uuid creator doesn't match that of the loading user");
513 Assert.That(
514 foundItem1.Name, Is.EqualTo(itemName),
515 "Loaded item name doesn't match saved name");
516 } 244 }
517 245
518 /// <summary> 246 /// <summary>
519 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 247 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
520 /// embedded creators do not exist in the system 248 /// the creator or an account with the creator's name does not exist within the system.
521 /// </summary> 249 /// </summary>
522 ///
523 /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature
524 /// (as tested in the a later commented out test)
525 /// This test is currently disabled
526 [Test] 250 [Test]
527 public void TestLoadIarV0_1AbsentUsers() 251 public void TestLoadIarV0_1AbsentCreator()
528 { 252 {
529 TestHelper.InMethod(); 253 TestHelper.InMethod();
530 //log4net.Config.XmlConfigurator.Configure(); 254// log4net.Config.XmlConfigurator.Configure();
531
532 string userFirstName = "Charlie";
533 string userLastName = "Chan";
534 UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999");
535 string userItemCreatorFirstName = "Bat";
536 string userItemCreatorLastName = "Man";
537 //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888");
538
539 string itemName = "b.lsl";
540 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
541
542 MemoryStream archiveWriteStream = new MemoryStream();
543 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
544
545 InventoryItemBase item1 = new InventoryItemBase();
546 item1.Name = itemName;
547 item1.AssetID = UUID.Random();
548 item1.GroupID = UUID.Random();
549 item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
550 //item1.CreatorId = userUuid.ToString();
551 //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
552 item1.Owner = UUID.Zero;
553
554 string item1FileName
555 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
556 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string,object>(), null));
557 tar.Close();
558
559 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
560 SerialiserModule serialiserModule = new SerialiserModule();
561 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
562
563 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
564 Scene scene = SceneSetupHelpers.SetupScene("inventory");
565
566 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
567 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userUuid, "meowfood");
568 255
569 archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); 256 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "password");
257 m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream);
570 258
571 InventoryItemBase foundItem1 259 InventoryItemBase foundItem1
572 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, itemName); 260 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
573 261
574 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 262 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
575// Assert.That(
576// foundItem1.CreatorId, Is.EqualTo(userUuid),
577// "Loaded item non-uuid creator doesn't match that of the loading user");
578 Assert.That( 263 Assert.That(
579 foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), 264 foundItem1.CreatorId, Is.EqualTo(m_uaMT.PrincipalID.ToString()),
265 "Loaded item non-uuid creator doesn't match that of the loading user");
266 Assert.That(
267 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaMT.PrincipalID),
580 "Loaded item uuid creator doesn't match that of the loading user"); 268 "Loaded item uuid creator doesn't match that of the loading user");
581 }
582
583 /// <summary>
584 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
585 /// no account exists with the creator name
586 /// </summary>
587 /// Disabled since temporary profiles have not yet been implemented.
588 ///
589 //[Test]
590 //public void TestLoadIarV0_1TempProfiles()
591 //{
592 // TestHelper.InMethod();
593
594 // //log4net.Config.XmlConfigurator.Configure();
595 269
596 // string userFirstName = "Dennis"; 270 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
597 // string userLastName = "Menace"; 271 string xmlData = Utils.BytesToString(asset1.Data);
598 // UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa"); 272 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
599 // string user2FirstName = "Walter";
600 // string user2LastName = "Mitty";
601 273
602 // string itemName = "b.lsl"; 274 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID));
603 // string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
604
605 // MemoryStream archiveWriteStream = new MemoryStream();
606 // TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
607
608 // InventoryItemBase item1 = new InventoryItemBase();
609 // item1.Name = itemName;
610 // item1.AssetID = UUID.Random();
611 // item1.GroupID = UUID.Random();
612 // item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName);
613 // item1.Owner = UUID.Zero;
614
615 // string item1FileName
616 // = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
617 // tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
618 // tar.Close();
619
620 // MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
621 // SerialiserModule serialiserModule = new SerialiserModule();
622 // InventoryArchiverModule archiverModule = new InventoryArchiverModule();
623
624 // // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
625 // Scene scene = SceneSetupHelpers.SetupScene();
626 // IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
627
628 // SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
629 // userAdminService.AddUser(
630 // userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
631
632 // archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream);
633
634 // // Check that a suitable temporary user profile has been created.
635 // UserProfileData user2Profile
636 // = scene.CommsManager.UserService.GetUserProfile(
637 // OspResolver.HashName(user2FirstName + " " + user2LastName));
638 // Assert.That(user2Profile, Is.Not.Null);
639 // Assert.That(user2Profile.FirstName == user2FirstName);
640 // Assert.That(user2Profile.SurName == user2LastName);
641
642 // CachedUserInfo userInfo
643 // = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
644 // userInfo.OnInventoryReceived += InventoryReceived;
645
646 // lock (this)
647 // {
648 // userInfo.FetchInventory();
649 // Monitor.Wait(this, 60000);
650 // }
651
652 // InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
653
654 // Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId));
655 // Assert.That(
656 // foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName)));
657 // Assert.That(foundItem.Owner, Is.EqualTo(userUuid));
658
659 // Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod());
660 //}
661
662 /// <summary>
663 /// Test replication of an archive path to the user's inventory.
664 /// </summary>
665 [Test]
666 public void TestNewIarPath()
667 {
668 TestHelper.InMethod();
669// log4net.Config.XmlConfigurator.Configure();
670
671 Scene scene = SceneSetupHelpers.SetupScene("inventory");
672 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
673
674 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
675 HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>();
676
677 string folder1Name = "1";
678 string folder2aName = "2a";
679 string folder2bName = "2b";
680
681 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
682 string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
683 string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());
684
685 string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName });
686 string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName });
687
688 {
689 // Test replication of path1
690 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
691 .ReplicateArchivePathToUserInventory(
692 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
693 foldersCreated, nodesLoaded);
694
695 List<InventoryFolderBase> folder1Candidates
696 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
697 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
698
699 InventoryFolderBase folder1 = folder1Candidates[0];
700 List<InventoryFolderBase> folder2aCandidates
701 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
702 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
703 }
704
705 {
706 // Test replication of path2
707 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
708 .ReplicateArchivePathToUserInventory(
709 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
710 foldersCreated, nodesLoaded);
711
712 List<InventoryFolderBase> folder1Candidates
713 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
714 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
715
716 InventoryFolderBase folder1 = folder1Candidates[0];
717
718 List<InventoryFolderBase> folder2aCandidates
719 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
720 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
721
722 List<InventoryFolderBase> folder2bCandidates
723 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName);
724 Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
725 }
726 }
727
728 /// <summary>
729 /// Test replication of a partly existing archive path to the user's inventory. This should create
730 /// a duplicate path without the merge option.
731 /// </summary>
732 [Test]
733 public void TestPartExistingIarPath()
734 {
735 TestHelper.InMethod();
736 //log4net.Config.XmlConfigurator.Configure();
737
738 Scene scene = SceneSetupHelpers.SetupScene("inventory");
739 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
740
741 string folder1ExistingName = "a";
742 string folder2Name = "b";
743
744 InventoryFolderBase folder1
745 = UserInventoryTestUtils.CreateInventoryFolder(
746 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
747
748 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
749 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
750
751 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
752
753 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
754 .ReplicateArchivePathToUserInventory(
755 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
756 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
757
758 List<InventoryFolderBase> folder1PostCandidates
759 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
760 Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
761
762 // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder.
763 InventoryFolderBase folder1Post = null;
764 foreach (InventoryFolderBase folder in folder1PostCandidates)
765 {
766 if (folder.ID != folder1.ID)
767 {
768 folder1Post = folder;
769 break;
770 }
771 }
772// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
773
774 List<InventoryFolderBase> folder2PostCandidates
775 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
776 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
777 }
778
779 /// <summary>
780 /// Test replication of a partly existing archive path to the user's inventory. This should create
781 /// a merged path.
782 /// </summary>
783 [Test]
784 public void TestMergeIarPath()
785 {
786 TestHelper.InMethod();
787// log4net.Config.XmlConfigurator.Configure();
788
789 Scene scene = SceneSetupHelpers.SetupScene("inventory");
790 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
791
792 string folder1ExistingName = "a";
793 string folder2Name = "b";
794
795 InventoryFolderBase folder1
796 = UserInventoryTestUtils.CreateInventoryFolder(
797 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
798
799 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
800 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
801
802 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
803
804 new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true)
805 .ReplicateArchivePathToUserInventory(
806 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
807 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
808
809 List<InventoryFolderBase> folder1PostCandidates
810 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
811 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
812 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
813
814 List<InventoryFolderBase> folder2PostCandidates
815 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b");
816 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
817 } 275 }
818 } 276 }
819} \ No newline at end of file 277} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
new file mode 100644
index 0000000..0e8f647
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
@@ -0,0 +1,478 @@
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.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using NUnit.Framework;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Serialization;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
41using OpenSim.Region.CoreModules.World.Serialiser;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup;
48
49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
50{
51 [TestFixture]
52 public class PathTests : InventoryArchiveTestCase
53 {
54 /// <summary>
55 /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive
56 /// (subject to change since there is no fixed format yet).
57 /// </summary>
58 [Test]
59 public void TestSavePathToIarV0_1()
60 {
61 TestHelper.InMethod();
62// log4net.Config.XmlConfigurator.Configure();
63
64 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
65
66 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
67 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
68
69 // Create user
70 string userFirstName = "Jock";
71 string userLastName = "Stirrup";
72 string userPassword = "troll";
73 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
74 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
75
76 // Create asset
77 SceneObjectGroup object1;
78 SceneObjectPart part1;
79 {
80 string partName = "My Little Dog Object";
81 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
82 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
83 Vector3 groupPosition = new Vector3(10, 20, 30);
84 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
85 Vector3 offsetPosition = new Vector3(5, 10, 15);
86
87 part1 = new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition);
88 part1.Name = partName;
89
90 object1 = new SceneObjectGroup(part1);
91 scene.AddNewSceneObject(object1, false);
92 }
93
94 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
95 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
96 scene.AssetService.Store(asset1);
97
98 // Create item
99 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
100 InventoryItemBase item1 = new InventoryItemBase();
101 item1.Name = "My Little Dog";
102 item1.AssetID = asset1.FullID;
103 item1.ID = item1Id;
104 InventoryFolderBase objsFolder
105 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
106 item1.Folder = objsFolder.ID;
107 scene.AddInventoryItem(item1);
108
109 MemoryStream archiveWriteStream = new MemoryStream();
110 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
111
112 // Test saving a particular path
113 mre.Reset();
114 archiverModule.ArchiveInventory(
115 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
116 mre.WaitOne(60000, false);
117
118 byte[] archive = archiveWriteStream.ToArray();
119 MemoryStream archiveReadStream = new MemoryStream(archive);
120 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
121
122 //bool gotControlFile = false;
123 bool gotObject1File = false;
124 //bool gotObject2File = false;
125 string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
126 string expectedObject1FilePath = string.Format(
127 "{0}{1}{2}",
128 ArchiveConstants.INVENTORY_PATH,
129 InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
130 expectedObject1FileName);
131
132 string filePath;
133 TarArchiveReader.TarEntryType tarEntryType;
134
135// Console.WriteLine("Reading archive");
136
137 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
138 {
139// Console.WriteLine("Got {0}", filePath);
140
141// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
142// {
143// gotControlFile = true;
144// }
145
146 if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
147 {
148// string fileName = filePath.Remove(0, "Objects/".Length);
149//
150// if (fileName.StartsWith(part1.Name))
151// {
152 Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
153 gotObject1File = true;
154// }
155// else if (fileName.StartsWith(part2.Name))
156// {
157// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
158// gotObject2File = true;
159// }
160 }
161 }
162
163// Assert.That(gotControlFile, Is.True, "No control file in archive");
164 Assert.That(gotObject1File, Is.True, "No item1 file in archive");
165// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
166
167 // TODO: Test presence of more files and contents of files.
168 }
169
170 /// <summary>
171 /// Test loading an IAR to various different inventory paths.
172 /// </summary>
173 [Test]
174 public void TestLoadIarToInventoryPaths()
175 {
176 TestHelper.InMethod();
177// log4net.Config.XmlConfigurator.Configure();
178
179 SerialiserModule serialiserModule = new SerialiserModule();
180 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
181
182 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
183 Scene scene = SceneSetupHelpers.SetupScene("inventory");
184
185 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
186
187 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "meowfood");
188 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
189
190 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
191 InventoryItemBase foundItem1
192 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
193
194 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
195
196 // Now try loading to a root child folder
197 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA");
198 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
199 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream);
200
201 InventoryItemBase foundItem2
202 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xA/" + m_item1Name);
203 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
204
205 // Now try loading to a more deeply nested folder
206 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC");
207 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
208 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream);
209
210 InventoryItemBase foundItem3
211 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC/" + m_item1Name);
212 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
213 }
214
215 /// <summary>
216 /// Test that things work when the load path specified starts with a slash
217 /// </summary>
218 [Test]
219 public void TestLoadIarPathStartsWithSlash()
220 {
221 TestHelper.InMethod();
222// log4net.Config.XmlConfigurator.Configure();
223
224 SerialiserModule serialiserModule = new SerialiserModule();
225 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
226 Scene scene = SceneSetupHelpers.SetupScene("inventory");
227 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
228
229 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password");
230 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream);
231
232 InventoryItemBase foundItem1
233 = InventoryArchiveUtils.FindItemByPath(
234 scene.InventoryService, m_uaMT.PrincipalID, "/Objects/" + m_item1Name);
235
236 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()");
237 }
238
239 [Test]
240 public void TestLoadIarPathWithEscapedChars()
241 {
242 TestHelper.InMethod();
243// log4net.Config.XmlConfigurator.Configure();
244
245 string itemName = "You & you are a mean/man/";
246 string humanEscapedItemName = @"You & you are a mean\/man\/";
247 string userPassword = "meowfood";
248
249 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
250
251 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
252 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
253
254 // Create user
255 string userFirstName = "Jock";
256 string userLastName = "Stirrup";
257 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
258 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood");
259
260 // Create asset
261 SceneObjectGroup object1;
262 SceneObjectPart part1;
263 {
264 string partName = "part name";
265 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
266 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
267 Vector3 groupPosition = new Vector3(10, 20, 30);
268 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
269 Vector3 offsetPosition = new Vector3(5, 10, 15);
270
271 part1
272 = new SceneObjectPart(
273 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
274 part1.Name = partName;
275
276 object1 = new SceneObjectGroup(part1);
277 scene.AddNewSceneObject(object1, false);
278 }
279
280 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
281 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
282 scene.AssetService.Store(asset1);
283
284 // Create item
285 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
286 InventoryItemBase item1 = new InventoryItemBase();
287 item1.Name = itemName;
288 item1.AssetID = asset1.FullID;
289 item1.ID = item1Id;
290 InventoryFolderBase objsFolder
291 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
292 item1.Folder = objsFolder.ID;
293 scene.AddInventoryItem(item1);
294
295 MemoryStream archiveWriteStream = new MemoryStream();
296 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
297
298 mre.Reset();
299 archiverModule.ArchiveInventory(
300 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
301 mre.WaitOne(60000, false);
302
303 // LOAD ITEM
304 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
305
306 archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream);
307
308 InventoryItemBase foundItem1
309 = InventoryArchiveUtils.FindItemByPath(
310 scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
311
312 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
313// Assert.That(
314// foundItem1.CreatorId, Is.EqualTo(userUuid),
315// "Loaded item non-uuid creator doesn't match that of the loading user");
316 Assert.That(
317 foundItem1.Name, Is.EqualTo(itemName),
318 "Loaded item name doesn't match saved name");
319 }
320
321 /// <summary>
322 /// Test replication of an archive path to the user's inventory.
323 /// </summary>
324 [Test]
325 public void TestNewIarPath()
326 {
327 TestHelper.InMethod();
328// log4net.Config.XmlConfigurator.Configure();
329
330 Scene scene = SceneSetupHelpers.SetupScene("inventory");
331 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
332
333 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
334 HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>();
335
336 string folder1Name = "1";
337 string folder2aName = "2a";
338 string folder2bName = "2b";
339
340 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
341 string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
342 string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());
343
344 string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName });
345 string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName });
346
347 {
348 // Test replication of path1
349 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
350 .ReplicateArchivePathToUserInventory(
351 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
352 foldersCreated, nodesLoaded);
353
354 List<InventoryFolderBase> folder1Candidates
355 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
356 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
357
358 InventoryFolderBase folder1 = folder1Candidates[0];
359 List<InventoryFolderBase> folder2aCandidates
360 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
361 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
362 }
363
364 {
365 // Test replication of path2
366 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
367 .ReplicateArchivePathToUserInventory(
368 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
369 foldersCreated, nodesLoaded);
370
371 List<InventoryFolderBase> folder1Candidates
372 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
373 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
374
375 InventoryFolderBase folder1 = folder1Candidates[0];
376
377 List<InventoryFolderBase> folder2aCandidates
378 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
379 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
380
381 List<InventoryFolderBase> folder2bCandidates
382 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName);
383 Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
384 }
385 }
386
387 /// <summary>
388 /// Test replication of a partly existing archive path to the user's inventory. This should create
389 /// a duplicate path without the merge option.
390 /// </summary>
391 [Test]
392 public void TestPartExistingIarPath()
393 {
394 TestHelper.InMethod();
395 //log4net.Config.XmlConfigurator.Configure();
396
397 Scene scene = SceneSetupHelpers.SetupScene("inventory");
398 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
399
400 string folder1ExistingName = "a";
401 string folder2Name = "b";
402
403 InventoryFolderBase folder1
404 = UserInventoryTestUtils.CreateInventoryFolder(
405 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
406
407 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
408 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
409
410 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
411
412 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
413 .ReplicateArchivePathToUserInventory(
414 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
415 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
416
417 List<InventoryFolderBase> folder1PostCandidates
418 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
419 Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
420
421 // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder.
422 InventoryFolderBase folder1Post = null;
423 foreach (InventoryFolderBase folder in folder1PostCandidates)
424 {
425 if (folder.ID != folder1.ID)
426 {
427 folder1Post = folder;
428 break;
429 }
430 }
431// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
432
433 List<InventoryFolderBase> folder2PostCandidates
434 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
435 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
436 }
437
438 /// <summary>
439 /// Test replication of a partly existing archive path to the user's inventory. This should create
440 /// a merged path.
441 /// </summary>
442 [Test]
443 public void TestMergeIarPath()
444 {
445 TestHelper.InMethod();
446// log4net.Config.XmlConfigurator.Configure();
447
448 Scene scene = SceneSetupHelpers.SetupScene("inventory");
449 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
450
451 string folder1ExistingName = "a";
452 string folder2Name = "b";
453
454 InventoryFolderBase folder1
455 = UserInventoryTestUtils.CreateInventoryFolder(
456 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
457
458 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
459 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
460
461 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
462
463 new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true)
464 .ReplicateArchivePathToUserInventory(
465 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
466 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
467
468 List<InventoryFolderBase> folder1PostCandidates
469 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
470 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
471 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
472
473 List<InventoryFolderBase> folder2PostCandidates
474 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b");
475 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
476 }
477 }
478} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 9e1d414..138556f 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -244,7 +244,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
244 } 244 }
245 catch (Exception e) 245 catch (Exception e)
246 { 246 {
247 m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message, e.StackTrace); 247 m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0} {1}", e.Message, e.StackTrace);
248 sp.ControllingClient.SendTeleportFailed("Internal error"); 248 sp.ControllingClient.SendTeleportFailed("Internal error");
249 } 249 }
250 } 250 }
@@ -285,9 +285,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
285 return; 285 return;
286 } 286 }
287 287
288 if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero)) 288 string reason;
289 if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out reason))
289 { 290 {
290 sp.ControllingClient.SendTeleportFailed("The destination region has refused access"); 291 sp.ControllingClient.SendTeleportFailed("Teleport failed: " + reason);
291 return; 292 return;
292 } 293 }
293 294
@@ -318,14 +319,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
318 agentCircuit.Id0 = currentAgentCircuit.Id0; 319 agentCircuit.Id0 = currentAgentCircuit.Id0;
319 } 320 }
320 321
321 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) 322 if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
322 { 323 {
323 // brand new agent, let's create a new caps seed 324 // brand new agent, let's create a new caps seed
324 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); 325 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
325 } 326 }
326 327
327 string reason = String.Empty;
328
329 // Let's create an agent there if one doesn't exist yet. 328 // Let's create an agent there if one doesn't exist yet.
330 bool logout = false; 329 bool logout = false;
331 if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) 330 if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout))
@@ -338,7 +337,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
338 // OK, it got this agent. Let's close some child agents 337 // OK, it got this agent. Let's close some child agents
339 sp.CloseChildAgents(newRegionX, newRegionY); 338 sp.CloseChildAgents(newRegionX, newRegionY);
340 IClientIPEndpoint ipepClient; 339 IClientIPEndpoint ipepClient;
341 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) 340 if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
342 { 341 {
343 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); 342 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
344 #region IP Translation for NAT 343 #region IP Translation for NAT
@@ -401,6 +400,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
401 if (!UpdateAgent(reg, finalDestination, agent)) 400 if (!UpdateAgent(reg, finalDestination, agent))
402 { 401 {
403 // Region doesn't take it 402 // Region doesn't take it
403 m_log.WarnFormat(
404 "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Returning avatar to source region.",
405 sp.Name, finalDestination.RegionName);
406
404 Fail(sp, finalDestination); 407 Fail(sp, finalDestination);
405 return; 408 return;
406 } 409 }
@@ -427,16 +430,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
427 // that the client contacted the destination before we send the attachments and close things here. 430 // that the client contacted the destination before we send the attachments and close things here.
428 if (!WaitForCallback(sp.UUID)) 431 if (!WaitForCallback(sp.UUID))
429 { 432 {
430 Fail(sp, finalDestination); 433 m_log.WarnFormat(
434 "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} failed due to no callback from destination region. Returning avatar to source region.",
435 sp.Name, finalDestination.RegionName);
436
437 Fail(sp, finalDestination);
431 return; 438 return;
432 } 439 }
433 440
434
435 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it 441 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
436 CrossAttachmentsIntoNewRegion(finalDestination, sp, true); 442 CrossAttachmentsIntoNewRegion(finalDestination, sp, true);
437 443
438 // Well, this is it. The agent is over there. 444 // Well, this is it. The agent is over there.
439
440 KillEntity(sp.Scene, sp.LocalId); 445 KillEntity(sp.Scene, sp.LocalId);
441 446
442 // May need to logout or other cleanup 447 // May need to logout or other cleanup
@@ -449,7 +454,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
449 454
450 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone 455 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
451 456
452 if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 457 if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
453 { 458 {
454 Thread.Sleep(5000); 459 Thread.Sleep(5000);
455 sp.Close(); 460 sp.Close();
@@ -523,14 +528,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
523 return region; 528 return region;
524 } 529 }
525 530
526 protected virtual bool NeedsNewAgent(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) 531 protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY)
527 { 532 {
528 return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); 533 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
529 } 534 }
530 535
531 protected virtual bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) 536 protected virtual bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
532 { 537 {
533 return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); 538 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
534 } 539 }
535 540
536 protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) 541 protected virtual bool IsOutsideRegion(Scene s, Vector3 pos)
@@ -797,7 +802,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
797 802
798 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); 803 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y);
799 804
800 if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos)) 805 string reason;
806 if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos, out reason))
801 { 807 {
802 agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); 808 agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel");
803 if (r == null) 809 if (r == null)
@@ -1006,7 +1012,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1006 /// </summary> 1012 /// </summary>
1007 public void EnableChildAgent(ScenePresence sp, GridRegion region) 1013 public void EnableChildAgent(ScenePresence sp, GridRegion region)
1008 { 1014 {
1009 m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighour {0}", region.RegionName); 1015 m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName);
1010 1016
1011 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 1017 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
1012 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); 1018 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo();
@@ -1072,7 +1078,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1072 1078
1073 if (m_regionInfo != null) 1079 if (m_regionInfo != null)
1074 { 1080 {
1075 neighbours = RequestNeighbours(sp.Scene, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 1081 neighbours = RequestNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
1076 } 1082 }
1077 else 1083 else
1078 { 1084 {
@@ -1298,8 +1304,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1298 /// <param name="pRegionLocX"></param> 1304 /// <param name="pRegionLocX"></param>
1299 /// <param name="pRegionLocY"></param> 1305 /// <param name="pRegionLocY"></param>
1300 /// <returns></returns> 1306 /// <returns></returns>
1301 protected List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) 1307 protected List<GridRegion> RequestNeighbours(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY)
1302 { 1308 {
1309 Scene pScene = avatar.Scene;
1303 RegionInfo m_regionInfo = pScene.RegionInfo; 1310 RegionInfo m_regionInfo = pScene.RegionInfo;
1304 1311
1305 Border[] northBorders = pScene.NorthBorders.ToArray(); 1312 Border[] northBorders = pScene.NorthBorders.ToArray();
@@ -1307,10 +1314,24 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1307 Border[] eastBorders = pScene.EastBorders.ToArray(); 1314 Border[] eastBorders = pScene.EastBorders.ToArray();
1308 Border[] westBorders = pScene.WestBorders.ToArray(); 1315 Border[] westBorders = pScene.WestBorders.ToArray();
1309 1316
1310 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. 1317 // Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't
1318 // clear what should be done with a "far view" given that megaregions already extended the
1319 // view to include everything in the megaregion
1311 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) 1320 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
1312 { 1321 {
1313 return pScene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); 1322 int dd = avatar.DrawDistance < Constants.RegionSize ? (int)Constants.RegionSize : (int)avatar.DrawDistance;
1323
1324 int startX = (int)pRegionLocX * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2);
1325 int startY = (int)pRegionLocY * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2);
1326
1327 int endX = (int)pRegionLocX * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2);
1328 int endY = (int)pRegionLocY * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2);
1329
1330 List<GridRegion> neighbours =
1331 avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
1332
1333 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
1334 return neighbours;
1314 } 1335 }
1315 else 1336 else
1316 { 1337 {
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index c75bc0a..5a80100 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -130,9 +130,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
130 return region; 130 return region;
131 } 131 }
132 132
133 protected override bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) 133 protected override bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
134 { 134 {
135 if (base.NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 135 if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
136 return true; 136 return true;
137 137
138 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); 138 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID);
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 34b8114..4565d10 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -55,6 +55,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
55 } 55 }
56 56
57 private string m_ProfileServerURI; 57 private string m_ProfileServerURI;
58 private bool m_OutboundPermission;
58 59
59// private bool m_Initialized = false; 60// private bool m_Initialized = false;
60 61
@@ -78,7 +79,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
78 79
79 IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; 80 IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"];
80 if (thisModuleConfig != null) 81 if (thisModuleConfig != null)
82 {
81 m_ProfileServerURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty); 83 m_ProfileServerURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty);
84 m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true);
85 }
82 else 86 else
83 m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); 87 m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!");
84 } 88 }
@@ -103,7 +107,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
103 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) 107 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
104 { 108 {
105 string userAssetServer = string.Empty; 109 string userAssetServer = string.Empty;
106 if (IsForeignUser(avatarID, out userAssetServer)) 110 if (IsForeignUser(avatarID, out userAssetServer) && m_OutboundPermission)
107 { 111 {
108 Util.FireAndForget(delegate { m_assMapper.Post(assetID, avatarID, userAssetServer); }); 112 Util.FireAndForget(delegate { m_assMapper.Post(assetID, avatarID, userAssetServer); });
109 } 113 }
@@ -197,7 +201,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
197 if (IsForeignUser(sender, out userAssetServer)) 201 if (IsForeignUser(sender, out userAssetServer))
198 m_assMapper.Get(item.AssetID, sender, userAssetServer); 202 m_assMapper.Get(item.AssetID, sender, userAssetServer);
199 203
200 if (IsForeignUser(receiver, out userAssetServer)) 204 if (IsForeignUser(receiver, out userAssetServer) && m_OutboundPermission)
201 m_assMapper.Post(item.AssetID, receiver, userAssetServer); 205 m_assMapper.Post(item.AssetID, receiver, userAssetServer);
202 } 206 }
203 207
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 0163060..108c9a0 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -149,6 +149,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
149 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 149 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
150 item = m_Scene.InventoryService.GetItem(item); 150 item = m_Scene.InventoryService.GetItem(item);
151 151
152 if (item.Owner != remoteClient.AgentId)
153 return UUID.Zero;
154
152 if (item != null) 155 if (item != null)
153 { 156 {
154 if ((InventoryType)item.InvType == InventoryType.Notecard) 157 if ((InventoryType)item.InvType == InventoryType.Notecard)
@@ -604,6 +607,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
604 { 607 {
605 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 1"); 608 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 1");
606 } 609 }
610 item.Owner = remoteClient.AgentId;
607 611
608 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); 612 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
609 613
diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
index 88f392d..2de8d7a 100644
--- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
+++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
75 m_scene = scene; 75 m_scene = scene;
76 m_scene.RegisterModuleInterface<IRegionModule>(this); 76 m_scene.RegisterModuleInterface<IRegionModule>(this);
77 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; 77 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
78 78
79 // ini file settings 79 // ini file settings
80 try 80 try
81 { 81 {
@@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
148 public void SendProfileToClient(ScenePresence presence) 148 public void SendProfileToClient(ScenePresence presence)
149 { 149 {
150 IClientAPI client = presence.ControllingClient; 150 IClientAPI client = presence.ControllingClient;
151 if (m_enableWindlight) 151 if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
152 { 152 {
153 if (presence.IsChildAgent == false) 153 if (presence.IsChildAgent == false)
154 { 154 {
@@ -165,7 +165,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
165 public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl) 165 public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl)
166 { 166 {
167 IClientAPI client = presence.ControllingClient; 167 IClientAPI client = presence.ControllingClient;
168 if (m_enableWindlight) 168 if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
169 { 169 {
170 if (presence.IsChildAgent == false) 170 if (presence.IsChildAgent == false)
171 { 171 {
@@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
229 { 229 {
230 Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast"); 230 Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast");
231 Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin"); 231 Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin");
232 Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Enable the windlight plugin"); 232 Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Disable the windlight plugin");
233 233
234 m_commander.RegisterCommand("load", wlload); 234 m_commander.RegisterCommand("load", wlload);
235 m_commander.RegisterCommand("enable", wlenable); 235 m_commander.RegisterCommand("enable", wlenable);
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index 43de2ab..a9d247a 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -47,7 +47,6 @@
47 <RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" /> 47 <RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" />
48 <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" /> 48 <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" />
49 <RegionModule id="LocalInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.LocalInventoryServicesConnector" /> 49 <RegionModule id="LocalInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.LocalInventoryServicesConnector" />
50 <RegionModule id="RemoteInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.RemoteInventoryServicesConnector" />
51 <RegionModule id="RemoteXInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.RemoteXInventoryServicesConnector" /> 50 <RegionModule id="RemoteXInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.RemoteXInventoryServicesConnector" />
52 <RegionModule id="HGInventoryBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.HGInventoryBroker" /> 51 <RegionModule id="HGInventoryBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.HGInventoryBroker" />
53 <RegionModule id="LocalNeighbourServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour.LocalNeighbourServicesConnector" /> 52 <RegionModule id="LocalNeighbourServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour.LocalNeighbourServicesConnector" />
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 66eb747..bdbd0c2 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -77,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
77 new Dictionary<string, UrlData>(); 77 new Dictionary<string, UrlData>();
78 78
79 79
80 private int m_TotalUrls = 1000; 80 private int m_TotalUrls = 5000;
81 81
82 private IHttpServer m_HttpServer = null; 82 private IHttpServer m_HttpServer = null;
83 83
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
index 01a2615..66994fa 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
@@ -139,7 +139,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
139 139
140 if (scene != null) 140 if (scene != null)
141 { 141 {
142 UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, userID); 142 UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID));
143 isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName, 143 isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName,
144 account.Email, scene.RegionInfo.RegionName, regionID, out message); 144 account.Email, scene.RegionInfo.RegionName, regionID, out message);
145 } 145 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 023a44c..3c36799 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -247,13 +247,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
247 247
248 public void NeighboursCommand(string module, string[] cmdparams) 248 public void NeighboursCommand(string module, string[] cmdparams)
249 { 249 {
250 System.Text.StringBuilder caps = new System.Text.StringBuilder();
251
250 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache) 252 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
251 { 253 {
252 m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName); 254 caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key);
253 List<GridRegion> regions = kvp.Value.GetNeighbours(); 255 List<GridRegion> regions = kvp.Value.GetNeighbours();
254 foreach (GridRegion r in regions) 256 foreach (GridRegion r in regions)
255 m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); 257 caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
256 } 258 }
259
260 MainConsole.Instance.Output(caps.ToString());
257 } 261 }
258 262
259 } 263 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
index ebfba2b..7128d2b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using Nini.Config; 37using Nini.Config;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 39410b5..3f63db3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -200,6 +200,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
200 return; 200 return;
201 } 201 }
202 } 202 }
203 else
204 {
205 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: User {0} does not have InventoryServerURI. OH NOES!", userID);
206 return;
207 }
203 } 208 }
204 } 209 }
205 } 210 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
deleted file mode 100644
index 9213132..0000000
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
+++ /dev/null
@@ -1,362 +0,0 @@
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 log4net;
29using System;
30using System.Collections.Generic;
31using System.Reflection;
32using Nini.Config;
33using OpenSim.Framework;
34using OpenSim.Framework.Statistics;
35using OpenSim.Services.Connectors;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces;
39using OpenMetaverse;
40
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
42{
43 public class RemoteInventoryServicesConnector : BaseInventoryConnector, ISharedRegionModule, IInventoryService
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private bool m_Enabled = false;
49 private bool m_Initialized = false;
50 private Scene m_Scene;
51 private InventoryServicesConnector m_RemoteConnector;
52
53 private IUserManagement m_UserManager;
54 private IUserManagement UserManager
55 {
56 get
57 {
58 if (m_UserManager == null)
59 {
60 m_UserManager = m_Scene.RequestModuleInterface<IUserManagement>();
61 }
62 return m_UserManager;
63 }
64 }
65
66
67 public Type ReplaceableInterface
68 {
69 get { return null; }
70 }
71
72 public string Name
73 {
74 get { return "RemoteInventoryServicesConnector"; }
75 }
76
77 public RemoteInventoryServicesConnector()
78 {
79 }
80
81 public RemoteInventoryServicesConnector(IConfigSource source)
82 {
83 Init(source);
84 }
85
86 protected override void Init(IConfigSource source)
87 {
88 m_RemoteConnector = new InventoryServicesConnector(source);
89 base.Init(source);
90 }
91
92 #region ISharedRegionModule
93
94 public void Initialise(IConfigSource source)
95 {
96 IConfig moduleConfig = source.Configs["Modules"];
97 if (moduleConfig != null)
98 {
99 string name = moduleConfig.GetString("InventoryServices", "");
100 if (name == Name)
101 {
102 Init(source);
103 m_Enabled = true;
104
105 m_log.Info("[INVENTORY CONNECTOR]: Remote inventory enabled");
106 }
107 }
108 }
109
110 public void PostInitialise()
111 {
112 }
113
114 public void Close()
115 {
116 }
117
118 public void AddRegion(Scene scene)
119 {
120// m_Scene = scene;
121 //m_log.Debug("[XXXX] Adding scene " + m_Scene.RegionInfo.RegionName);
122
123 if (!m_Enabled)
124 return;
125
126 if (!m_Initialized)
127 {
128 m_Initialized = true;
129 }
130
131 scene.RegisterModuleInterface<IInventoryService>(this);
132 m_cache.AddRegion(scene);
133
134 if (m_Scene == null)
135 m_Scene = scene;
136 }
137
138 public void RemoveRegion(Scene scene)
139 {
140 if (!m_Enabled)
141 return;
142
143 m_cache.RemoveRegion(scene);
144 }
145
146 public void RegionLoaded(Scene scene)
147 {
148 if (!m_Enabled)
149 return;
150
151 m_log.InfoFormat("[INVENTORY CONNECTOR]: Enabled remote inventory for region {0}", scene.RegionInfo.RegionName);
152
153 }
154
155 #endregion ISharedRegionModule
156
157 #region IInventoryService
158
159 public override bool CreateUserInventory(UUID user)
160 {
161 return false;
162 }
163
164 public override List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
165 {
166 return new List<InventoryFolderBase>();
167 }
168
169 public override InventoryCollection GetUserInventory(UUID userID)
170 {
171 return null;
172 }
173
174 public override void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
175 {
176 UUID sessionID = GetSessionID(userID);
177 try
178 {
179 m_RemoteConnector.GetUserInventory(userID.ToString(), sessionID, callback);
180 }
181 catch (Exception e)
182 {
183 if (StatsManager.SimExtraStats != null)
184 StatsManager.SimExtraStats.AddInventoryServiceRetrievalFailure();
185
186 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Request inventory operation failed, {0} {1}",
187 e.Source, e.Message);
188 }
189
190 }
191
192 // inherited. See base class
193 // public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
194
195 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
196 {
197 UUID sessionID = GetSessionID(userID);
198 return m_RemoteConnector.GetSystemFolders(userID.ToString(), sessionID);
199 }
200
201 public override InventoryCollection GetFolderContent(UUID userID, UUID folderID)
202 {
203 UUID sessionID = GetSessionID(userID);
204 try
205 {
206 InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID.ToString(), folderID, sessionID);
207 foreach (InventoryItemBase item in invCol.Items)
208 UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
209 return invCol;
210 }
211 catch (Exception e)
212 {
213 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1}",
214 e.Source, e.Message);
215 }
216 InventoryCollection nullCollection = new InventoryCollection();
217 nullCollection.Folders = new List<InventoryFolderBase>();
218 nullCollection.Items = new List<InventoryItemBase>();
219 nullCollection.UserID = userID;
220 return nullCollection;
221 }
222
223 public override List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
224 {
225 UUID sessionID = GetSessionID(userID);
226 return m_RemoteConnector.GetFolderItems(userID.ToString(), folderID, sessionID);
227 }
228
229 public override bool AddFolder(InventoryFolderBase folder)
230 {
231 if (folder == null)
232 return false;
233
234 UUID sessionID = GetSessionID(folder.Owner);
235 return m_RemoteConnector.AddFolder(folder.Owner.ToString(), folder, sessionID);
236 }
237
238 public override bool UpdateFolder(InventoryFolderBase folder)
239 {
240 if (folder == null)
241 return false;
242
243 UUID sessionID = GetSessionID(folder.Owner);
244 return m_RemoteConnector.UpdateFolder(folder.Owner.ToString(), folder, sessionID);
245 }
246
247 public override bool MoveFolder(InventoryFolderBase folder)
248 {
249 if (folder == null)
250 return false;
251
252 UUID sessionID = GetSessionID(folder.Owner);
253 return m_RemoteConnector.MoveFolder(folder.Owner.ToString(), folder, sessionID);
254 }
255
256 public override bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
257 {
258 if (folderIDs == null)
259 return false;
260 if (folderIDs.Count == 0)
261 return false;
262
263 UUID sessionID = GetSessionID(ownerID);
264 return m_RemoteConnector.DeleteFolders(ownerID.ToString(), folderIDs, sessionID);
265 }
266
267
268 public override bool PurgeFolder(InventoryFolderBase folder)
269 {
270 if (folder == null)
271 return false;
272
273 UUID sessionID = GetSessionID(folder.Owner);
274 return m_RemoteConnector.PurgeFolder(folder.Owner.ToString(), folder, sessionID);
275 }
276
277 // public bool AddItem(InventoryItemBase item) inherited
278 // Uses AddItemPlain
279
280 protected override bool AddItemPlain(InventoryItemBase item)
281 {
282 if (item == null)
283 return false;
284
285 UUID sessionID = GetSessionID(item.Owner);
286 return m_RemoteConnector.AddItem(item.Owner.ToString(), item, sessionID);
287 }
288
289 public override bool UpdateItem(InventoryItemBase item)
290 {
291 if (item == null)
292 return false;
293
294 UUID sessionID = GetSessionID(item.Owner);
295 return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID);
296 }
297
298 public override bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
299 {
300 if (items == null)
301 return false;
302
303 UUID sessionID = GetSessionID(ownerID);
304 return m_RemoteConnector.MoveItems(ownerID.ToString(), items, sessionID);
305 }
306
307
308 public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
309 {
310 if (itemIDs == null)
311 return false;
312 if (itemIDs.Count == 0)
313 return true;
314
315 UUID sessionID = GetSessionID(ownerID);
316 return m_RemoteConnector.DeleteItems(ownerID.ToString(), itemIDs, sessionID);
317 }
318
319 public override InventoryItemBase GetItem(InventoryItemBase item)
320 {
321 if (item == null)
322 return null;
323
324 UUID sessionID = GetSessionID(item.Owner);
325 return m_RemoteConnector.QueryItem(item.Owner.ToString(), item, sessionID);
326 }
327
328 public override InventoryFolderBase GetFolder(InventoryFolderBase folder)
329 {
330 if (folder == null)
331 return null;
332
333 UUID sessionID = GetSessionID(folder.Owner);
334 return m_RemoteConnector.QueryFolder(folder.Owner.ToString(), folder, sessionID);
335 }
336
337 public override bool HasInventoryForUser(UUID userID)
338 {
339 return false;
340 }
341
342 public override List<InventoryItemBase> GetActiveGestures(UUID userId)
343 {
344 return new List<InventoryItemBase>();
345 }
346
347 public override int GetAssetPermissions(UUID userID, UUID assetID)
348 {
349 UUID sessionID = GetSessionID(userID);
350 return m_RemoteConnector.GetAssetPermissions(userID.ToString(), assetID, sessionID);
351 }
352
353
354 #endregion
355
356 private UUID GetSessionID(UUID userID)
357 {
358 return UUID.Zero;
359 }
360
361 }
362}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
index ef910f4..e471f75 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using Nini.Config; 37using Nini.Config;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 971a56f..41dbffb 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -225,17 +225,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
225 if (destination == null) 225 if (destination == null)
226 return false; 226 return false;
227 227
228 // We limit the number of messages sent for a position change to just one per
229 // simulator so when we receive the update we need to hand it to each of the
230 // scenes; scenes each check to see if the is a scene presence for the avatar
231 // note that we really don't need the GridRegion for this call
228 foreach (Scene s in m_sceneList) 232 foreach (Scene s in m_sceneList)
229 { 233 {
230 if (s.RegionInfo.RegionHandle == destination.RegionHandle) 234 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
231 { 235 s.IncomingChildAgentDataUpdate(cAgentData);
232 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
233 s.IncomingChildAgentDataUpdate(cAgentData);
234 return true;
235 }
236 } 236 }
237 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); 237 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate");
238 return false; 238 return true;
239 } 239 }
240 240
241 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) 241 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
@@ -257,15 +257,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
257 return false; 257 return false;
258 } 258 }
259 259
260 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) 260 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason)
261 { 261 {
262 reason = "Communications failure";
262 if (destination == null) 263 if (destination == null)
263 return false; 264 return false;
264 265
265 foreach (Scene s in m_sceneList) 266 foreach (Scene s in m_sceneList)
266 { 267 {
267 if (s.RegionInfo.RegionID == destination.RegionID) 268 if (s.RegionInfo.RegionID == destination.RegionID)
268 return s.QueryAccess(id, position); 269 return s.QueryAccess(id, position, out reason);
269 } 270 }
270 return false; 271 return false;
271 } 272 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index e8a6629..97833f3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -192,15 +192,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
192 return false; 192 return false;
193 193
194 // Try local first 194 // Try local first
195 if (m_localBackend.UpdateAgent(destination, cAgentData)) 195 if (m_localBackend.IsLocalRegion(destination.RegionHandle))
196 return true; 196 return m_localBackend.UpdateAgent(destination, cAgentData);
197
198 // else do the remote thing
199 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
200 return m_remoteConnector.UpdateAgent(destination, cAgentData);
201
202 return false;
203 197
198 return m_remoteConnector.UpdateAgent(destination, cAgentData);
204 } 199 }
205 200
206 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) 201 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData)
@@ -209,15 +204,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
209 return false; 204 return false;
210 205
211 // Try local first 206 // Try local first
212 if (m_localBackend.UpdateAgent(destination, cAgentData)) 207 if (m_localBackend.IsLocalRegion(destination.RegionHandle))
213 return true; 208 return m_localBackend.UpdateAgent(destination, cAgentData);
214
215 // else do the remote thing
216 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
217 return m_remoteConnector.UpdateAgent(destination, cAgentData);
218
219 return false;
220 209
210 return m_remoteConnector.UpdateAgent(destination, cAgentData);
221 } 211 }
222 212
223 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) 213 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
@@ -239,18 +229,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
239 229
240 } 230 }
241 231
242 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) 232 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason)
243 { 233 {
234 reason = "Communications failure";
244 if (destination == null) 235 if (destination == null)
245 return false; 236 return false;
246 237
247 // Try local first 238 // Try local first
248 if (m_localBackend.QueryAccess(destination, id, position)) 239 if (m_localBackend.QueryAccess(destination, id, position, out reason))
249 return true; 240 return true;
250 241
251 // else do the remote thing 242 // else do the remote thing
252 if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) 243 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
253 return m_remoteConnector.QueryAccess(destination, id, position); 244 return m_remoteConnector.QueryAccess(destination, id, position, out reason);
254 245
255 return false; 246 return false;
256 247
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 04b6e3d..e2760a2 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenMetaverse.Assets; 36using OpenMetaverse.Assets;
38using OpenSim.Framework; 37using OpenSim.Framework;
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs
new file mode 100644
index 0000000..f6d1a82
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs
@@ -0,0 +1,224 @@
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.Generic;
30using System.IO;
31using System.Reflection;
32using System.Security;
33using System.Text;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Console;
39using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes;
42
43namespace OpenSim.Region.CoreModules.World.Estate
44{
45 /// <summary>
46 /// Estate management console commands.
47 /// </summary>
48 public class EstateManagementCommands
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 protected EstateManagementModule m_module;
53
54 protected Commander m_commander = new Commander("estate");
55
56 public EstateManagementCommands(EstateManagementModule module)
57 {
58 m_module = module;
59 }
60
61 public void Initialise()
62 {
63 m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName);
64
65 m_module.Scene.AddCommand(m_module, "set terrain texture",
66 "set terrain texture <number> <uuid> [<x>] [<y>]",
67 "Sets the terrain <number> to <uuid>, if <x> or <y> are specified, it will only " +
68 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
69 " that coordinate.",
70 consoleSetTerrainTexture);
71
72 m_module.Scene.AddCommand(m_module, "set terrain heights",
73 "set terrain heights <corner> <min> <max> [<x>] [<y>]",
74 "Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
75 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
76 " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.",
77 consoleSetTerrainHeights);
78
79 Command showCommand
80 = new Command("show", CommandIntentions.COMMAND_STATISTICAL, ShowEstatesCommand, "Shows all estates on the simulator.");
81
82 m_commander.RegisterCommand("show", showCommand);
83
84 m_module.Scene.RegisterModuleCommander(m_commander);
85
86 m_module.Scene.EventManager.OnPluginConsole += EventManagerOnPluginConsole;
87 }
88
89 public void Close()
90 {
91 m_module.Scene.EventManager.OnPluginConsole -= EventManagerOnPluginConsole;
92 m_module.Scene.UnregisterModuleCommander(m_commander.Name);
93 }
94
95 /// <summary>
96 /// Processes commandline input. Do not call directly.
97 /// </summary>
98 /// <param name="args">Commandline arguments</param>
99 protected void EventManagerOnPluginConsole(string[] args)
100 {
101 if (args[0] == "estate")
102 {
103 if (args.Length == 1)
104 {
105 m_commander.ProcessConsoleCommand("help", new string[0]);
106 return;
107 }
108
109 string[] tmpArgs = new string[args.Length - 2];
110 int i;
111 for (i = 2; i < args.Length; i++)
112 tmpArgs[i - 2] = args[i];
113
114 m_commander.ProcessConsoleCommand(args[1], tmpArgs);
115 }
116 }
117
118 protected void consoleSetTerrainTexture(string module, string[] args)
119 {
120 string num = args[3];
121 string uuid = args[4];
122 int x = (args.Length > 5 ? int.Parse(args[5]) : -1);
123 int y = (args.Length > 6 ? int.Parse(args[6]) : -1);
124
125 if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
126 {
127 if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
128 {
129 int corner = int.Parse(num);
130 UUID texture = UUID.Parse(uuid);
131
132 m_log.Debug("[ESTATEMODULE]: Setting terrain textures for " + m_module.Scene.RegionInfo.RegionName +
133 string.Format(" (C#{0} = {1})", corner, texture));
134
135 switch (corner)
136 {
137 case 0:
138 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
139 break;
140 case 1:
141 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
142 break;
143 case 2:
144 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
145 break;
146 case 3:
147 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
148 break;
149 }
150
151 m_module.Scene.RegionInfo.RegionSettings.Save();
152 m_module.TriggerRegionInfoChange();
153 m_module.sendRegionInfoPacketToAll();
154 }
155 }
156 }
157
158 protected void consoleSetTerrainHeights(string module, string[] args)
159 {
160 string num = args[3];
161 string min = args[4];
162 string max = args[5];
163 int x = (args.Length > 6 ? int.Parse(args[6]) : -1);
164 int y = (args.Length > 7 ? int.Parse(args[7]) : -1);
165
166 if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
167 {
168 if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
169 {
170 int corner = int.Parse(num);
171 float lowValue = float.Parse(min, Culture.NumberFormatInfo);
172 float highValue = float.Parse(max, Culture.NumberFormatInfo);
173
174 m_log.Debug("[ESTATEMODULE]: Setting terrain heights " + m_module.Scene.RegionInfo.RegionName +
175 string.Format(" (C{0}, {1}-{2}", corner, lowValue, highValue));
176
177 switch (corner)
178 {
179 case 0:
180 m_module.Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
181 m_module.Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
182 break;
183 case 1:
184 m_module.Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
185 m_module.Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
186 break;
187 case 2:
188 m_module.Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
189 m_module.Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
190 break;
191 case 3:
192 m_module.Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
193 m_module.Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
194 break;
195 }
196
197 m_module.Scene.RegionInfo.RegionSettings.Save();
198 m_module.TriggerRegionInfoChange();
199 m_module.sendRegionHandshakeToAll();
200 }
201 }
202 }
203
204 protected void ShowEstatesCommand(Object[] args)
205 {
206 StringBuilder report = new StringBuilder();
207 RegionInfo ri = m_module.Scene.RegionInfo;
208 EstateSettings es = ri.EstateSettings;
209
210 report.AppendFormat("Estate information for region {0}\n", ri.RegionName);
211 report.AppendFormat(
212 "{0,-20} {1,-7} {2,-20}\n",
213 "Estate Name",
214 "ID",
215 "Owner");
216
217 report.AppendFormat(
218 "{0,-20} {1,-7} {2,-20}\n",
219 es.EstateName, es.EstateID, m_module.UserManager.GetUserName(es.EstateOwner));
220
221 MainConsole.Instance.Output(report.ToString());
222 }
223 }
224} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 3653842..c146b72 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -24,6 +24,7 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27
27using System; 28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.IO; 30using System.IO;
@@ -31,6 +32,7 @@ using System.Reflection;
31using System.Security; 32using System.Security;
32using System.Timers; 33using System.Timers;
33using log4net; 34using log4net;
35using Mono.Addins;
34using Nini.Config; 36using Nini.Config;
35using OpenMetaverse; 37using OpenMetaverse;
36using OpenSim.Framework; 38using OpenSim.Framework;
@@ -39,14 +41,18 @@ using OpenSim.Region.Framework.Scenes;
39 41
40namespace OpenSim.Region.CoreModules.World.Estate 42namespace OpenSim.Region.CoreModules.World.Estate
41{ 43{
42 public class EstateManagementModule : IEstateModule 44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EstateManagementModule")]
45 public class EstateManagementModule : IEstateModule, INonSharedRegionModule
43 { 46 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 48
46 private delegate void LookupUUIDS(List<UUID> uuidLst); 49 private delegate void LookupUUIDS(List<UUID> uuidLst);
47 50
48 private Scene m_scene;
49 private Timer m_regionChangeTimer = new Timer(); 51 private Timer m_regionChangeTimer = new Timer();
52 public Scene Scene { get; private set; }
53 public IUserManagement UserManager { get; private set; }
54
55 protected EstateManagementCommands m_commands;
50 56
51 private EstateTerrainXferHandler TerrainUploader; 57 private EstateTerrainXferHandler TerrainUploader;
52 58
@@ -60,89 +66,89 @@ namespace OpenSim.Region.CoreModules.World.Estate
60 { 66 {
61 uint sun = 0; 67 uint sun = 0;
62 68
63 if (!m_scene.RegionInfo.EstateSettings.UseGlobalTime) 69 if (!Scene.RegionInfo.EstateSettings.UseGlobalTime)
64 sun=(uint)(m_scene.RegionInfo.EstateSettings.SunPosition*1024.0) + 0x1800; 70 sun = (uint)(Scene.RegionInfo.EstateSettings.SunPosition * 1024.0) + 0x1800;
65 UUID estateOwner; 71 UUID estateOwner;
66 estateOwner = m_scene.RegionInfo.EstateSettings.EstateOwner; 72 estateOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
67 73
68 if (m_scene.Permissions.IsGod(remote_client.AgentId)) 74 if (Scene.Permissions.IsGod(remote_client.AgentId))
69 estateOwner = remote_client.AgentId; 75 estateOwner = remote_client.AgentId;
70 76
71 remote_client.SendDetailedEstateData(invoice, 77 remote_client.SendDetailedEstateData(invoice,
72 m_scene.RegionInfo.EstateSettings.EstateName, 78 Scene.RegionInfo.EstateSettings.EstateName,
73 m_scene.RegionInfo.EstateSettings.EstateID, 79 Scene.RegionInfo.EstateSettings.EstateID,
74 m_scene.RegionInfo.EstateSettings.ParentEstateID, 80 Scene.RegionInfo.EstateSettings.ParentEstateID,
75 GetEstateFlags(), 81 GetEstateFlags(),
76 sun, 82 sun,
77 m_scene.RegionInfo.RegionSettings.Covenant, 83 Scene.RegionInfo.RegionSettings.Covenant,
78 m_scene.RegionInfo.EstateSettings.AbuseEmail, 84 Scene.RegionInfo.EstateSettings.AbuseEmail,
79 estateOwner); 85 estateOwner);
80 86
81 remote_client.SendEstateList(invoice, 87 remote_client.SendEstateList(invoice,
82 (int)Constants.EstateAccessCodex.EstateManagers, 88 (int)Constants.EstateAccessCodex.EstateManagers,
83 m_scene.RegionInfo.EstateSettings.EstateManagers, 89 Scene.RegionInfo.EstateSettings.EstateManagers,
84 m_scene.RegionInfo.EstateSettings.EstateID); 90 Scene.RegionInfo.EstateSettings.EstateID);
85 91
86 remote_client.SendEstateList(invoice, 92 remote_client.SendEstateList(invoice,
87 (int)Constants.EstateAccessCodex.AccessOptions, 93 (int)Constants.EstateAccessCodex.AccessOptions,
88 m_scene.RegionInfo.EstateSettings.EstateAccess, 94 Scene.RegionInfo.EstateSettings.EstateAccess,
89 m_scene.RegionInfo.EstateSettings.EstateID); 95 Scene.RegionInfo.EstateSettings.EstateID);
90 96
91 remote_client.SendEstateList(invoice, 97 remote_client.SendEstateList(invoice,
92 (int)Constants.EstateAccessCodex.AllowedGroups, 98 (int)Constants.EstateAccessCodex.AllowedGroups,
93 m_scene.RegionInfo.EstateSettings.EstateGroups, 99 Scene.RegionInfo.EstateSettings.EstateGroups,
94 m_scene.RegionInfo.EstateSettings.EstateID); 100 Scene.RegionInfo.EstateSettings.EstateID);
95 101
96 remote_client.SendBannedUserList(invoice, 102 remote_client.SendBannedUserList(invoice,
97 m_scene.RegionInfo.EstateSettings.EstateBans, 103 Scene.RegionInfo.EstateSettings.EstateBans,
98 m_scene.RegionInfo.EstateSettings.EstateID); 104 Scene.RegionInfo.EstateSettings.EstateID);
99 } 105 }
100 106
101 private void estateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor, 107 private void estateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor,
102 int matureLevel, bool restrictPushObject, bool allowParcelChanges) 108 int matureLevel, bool restrictPushObject, bool allowParcelChanges)
103 { 109 {
104 if (blockTerraform) 110 if (blockTerraform)
105 m_scene.RegionInfo.RegionSettings.BlockTerraform = true; 111 Scene.RegionInfo.RegionSettings.BlockTerraform = true;
106 else 112 else
107 m_scene.RegionInfo.RegionSettings.BlockTerraform = false; 113 Scene.RegionInfo.RegionSettings.BlockTerraform = false;
108 114
109 if (noFly) 115 if (noFly)
110 m_scene.RegionInfo.RegionSettings.BlockFly = true; 116 Scene.RegionInfo.RegionSettings.BlockFly = true;
111 else 117 else
112 m_scene.RegionInfo.RegionSettings.BlockFly = false; 118 Scene.RegionInfo.RegionSettings.BlockFly = false;
113 119
114 if (allowDamage) 120 if (allowDamage)
115 m_scene.RegionInfo.RegionSettings.AllowDamage = true; 121 Scene.RegionInfo.RegionSettings.AllowDamage = true;
116 else 122 else
117 m_scene.RegionInfo.RegionSettings.AllowDamage = false; 123 Scene.RegionInfo.RegionSettings.AllowDamage = false;
118 124
119 if (blockLandResell) 125 if (blockLandResell)
120 m_scene.RegionInfo.RegionSettings.AllowLandResell = false; 126 Scene.RegionInfo.RegionSettings.AllowLandResell = false;
121 else 127 else
122 m_scene.RegionInfo.RegionSettings.AllowLandResell = true; 128 Scene.RegionInfo.RegionSettings.AllowLandResell = true;
123 129
124 m_scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents; 130 Scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents;
125 131
126 m_scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor; 132 Scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor;
127 133
128 if (matureLevel <= 13) 134 if (matureLevel <= 13)
129 m_scene.RegionInfo.RegionSettings.Maturity = 0; 135 Scene.RegionInfo.RegionSettings.Maturity = 0;
130 else if (matureLevel <= 21) 136 else if (matureLevel <= 21)
131 m_scene.RegionInfo.RegionSettings.Maturity = 1; 137 Scene.RegionInfo.RegionSettings.Maturity = 1;
132 else 138 else
133 m_scene.RegionInfo.RegionSettings.Maturity = 2; 139 Scene.RegionInfo.RegionSettings.Maturity = 2;
134 140
135 if (restrictPushObject) 141 if (restrictPushObject)
136 m_scene.RegionInfo.RegionSettings.RestrictPushing = true; 142 Scene.RegionInfo.RegionSettings.RestrictPushing = true;
137 else 143 else
138 m_scene.RegionInfo.RegionSettings.RestrictPushing = false; 144 Scene.RegionInfo.RegionSettings.RestrictPushing = false;
139 145
140 if (allowParcelChanges) 146 if (allowParcelChanges)
141 m_scene.RegionInfo.RegionSettings.AllowLandJoinDivide = true; 147 Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = true;
142 else 148 else
143 m_scene.RegionInfo.RegionSettings.AllowLandJoinDivide = false; 149 Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = false;
144 150
145 m_scene.RegionInfo.RegionSettings.Save(); 151 Scene.RegionInfo.RegionSettings.Save();
146 TriggerRegionInfoChange(); 152 TriggerRegionInfoChange();
147 153
148 sendRegionInfoPacketToAll(); 154 sendRegionInfoPacketToAll();
@@ -156,19 +162,19 @@ namespace OpenSim.Region.CoreModules.World.Estate
156 switch (corner) 162 switch (corner)
157 { 163 {
158 case 0: 164 case 0:
159 m_scene.RegionInfo.RegionSettings.TerrainTexture1 = texture; 165 Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
160 break; 166 break;
161 case 1: 167 case 1:
162 m_scene.RegionInfo.RegionSettings.TerrainTexture2 = texture; 168 Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
163 break; 169 break;
164 case 2: 170 case 2:
165 m_scene.RegionInfo.RegionSettings.TerrainTexture3 = texture; 171 Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
166 break; 172 break;
167 case 3: 173 case 3:
168 m_scene.RegionInfo.RegionSettings.TerrainTexture4 = texture; 174 Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
169 break; 175 break;
170 } 176 }
171 m_scene.RegionInfo.RegionSettings.Save(); 177 Scene.RegionInfo.RegionSettings.Save();
172 TriggerRegionInfoChange(); 178 TriggerRegionInfoChange();
173 sendRegionInfoPacketToAll(); 179 sendRegionInfoPacketToAll();
174 } 180 }
@@ -178,23 +184,23 @@ namespace OpenSim.Region.CoreModules.World.Estate
178 switch (corner) 184 switch (corner)
179 { 185 {
180 case 0: 186 case 0:
181 m_scene.RegionInfo.RegionSettings.Elevation1SW = lowValue; 187 Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
182 m_scene.RegionInfo.RegionSettings.Elevation2SW = highValue; 188 Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
183 break; 189 break;
184 case 1: 190 case 1:
185 m_scene.RegionInfo.RegionSettings.Elevation1NW = lowValue; 191 Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
186 m_scene.RegionInfo.RegionSettings.Elevation2NW = highValue; 192 Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
187 break; 193 break;
188 case 2: 194 case 2:
189 m_scene.RegionInfo.RegionSettings.Elevation1SE = lowValue; 195 Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
190 m_scene.RegionInfo.RegionSettings.Elevation2SE = highValue; 196 Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
191 break; 197 break;
192 case 3: 198 case 3:
193 m_scene.RegionInfo.RegionSettings.Elevation1NE = lowValue; 199 Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
194 m_scene.RegionInfo.RegionSettings.Elevation2NE = highValue; 200 Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
195 break; 201 break;
196 } 202 }
197 m_scene.RegionInfo.RegionSettings.Save(); 203 Scene.RegionInfo.RegionSettings.Save();
198 TriggerRegionInfoChange(); 204 TriggerRegionInfoChange();
199 sendRegionInfoPacketToAll(); 205 sendRegionInfoPacketToAll();
200 } 206 }
@@ -210,30 +216,30 @@ namespace OpenSim.Region.CoreModules.World.Estate
210 bool UseGlobal, bool EstateFixedSun, float EstateSunHour) 216 bool UseGlobal, bool EstateFixedSun, float EstateSunHour)
211 { 217 {
212 // Water Height 218 // Water Height
213 m_scene.RegionInfo.RegionSettings.WaterHeight = WaterHeight; 219 Scene.RegionInfo.RegionSettings.WaterHeight = WaterHeight;
214 220
215 // Terraforming limits 221 // Terraforming limits
216 m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit = TerrainRaiseLimit; 222 Scene.RegionInfo.RegionSettings.TerrainRaiseLimit = TerrainRaiseLimit;
217 m_scene.RegionInfo.RegionSettings.TerrainLowerLimit = TerrainLowerLimit; 223 Scene.RegionInfo.RegionSettings.TerrainLowerLimit = TerrainLowerLimit;
218 224
219 // Time of day / fixed sun 225 // Time of day / fixed sun
220 m_scene.RegionInfo.RegionSettings.UseEstateSun = UseEstateSun; 226 Scene.RegionInfo.RegionSettings.UseEstateSun = UseEstateSun;
221 m_scene.RegionInfo.RegionSettings.FixedSun = UseFixedSun; 227 Scene.RegionInfo.RegionSettings.FixedSun = UseFixedSun;
222 m_scene.RegionInfo.RegionSettings.SunPosition = SunHour; 228 Scene.RegionInfo.RegionSettings.SunPosition = SunHour;
223 229
224 m_scene.TriggerEstateSunUpdate(); 230 Scene.TriggerEstateSunUpdate();
225 231
226 //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString()); 232 //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString());
227 //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString()); 233 //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString());
228 234
229 sendRegionInfoPacketToAll(); 235 sendRegionInfoPacketToAll();
230 m_scene.RegionInfo.RegionSettings.Save(); 236 Scene.RegionInfo.RegionSettings.Save();
231 TriggerRegionInfoChange(); 237 TriggerRegionInfoChange();
232 } 238 }
233 239
234 private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds) 240 private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
235 { 241 {
236 IRestartModule restartModule = m_scene.RequestModuleInterface<IRestartModule>(); 242 IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>();
237 if (restartModule != null) 243 if (restartModule != null)
238 { 244 {
239 List<int> times = new List<int>(); 245 List<int> times = new List<int>();
@@ -254,8 +260,8 @@ namespace OpenSim.Region.CoreModules.World.Estate
254 260
255 private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID) 261 private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)
256 { 262 {
257 m_scene.RegionInfo.RegionSettings.Covenant = estateCovenantID; 263 Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID;
258 m_scene.RegionInfo.RegionSettings.Save(); 264 Scene.RegionInfo.RegionSettings.Save();
259 TriggerRegionInfoChange(); 265 TriggerRegionInfoChange();
260 } 266 }
261 267
@@ -263,17 +269,17 @@ namespace OpenSim.Region.CoreModules.World.Estate
263 { 269 {
264 // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc. 270 // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
265 271
266 if (user == m_scene.RegionInfo.EstateSettings.EstateOwner) 272 if (user == Scene.RegionInfo.EstateSettings.EstateOwner)
267 return; // never process EO 273 return; // never process EO
268 274
269 if ((estateAccessType & 4) != 0) // User add 275 if ((estateAccessType & 4) != 0) // User add
270 { 276 {
271 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 277 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
272 { 278 {
273 m_scene.RegionInfo.EstateSettings.AddEstateUser(user); 279 Scene.RegionInfo.EstateSettings.AddEstateUser(user);
274 m_scene.RegionInfo.EstateSettings.Save(); 280 Scene.RegionInfo.EstateSettings.Save();
275 TriggerEstateInfoChange(); 281 TriggerEstateInfoChange();
276 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, m_scene.RegionInfo.EstateSettings.EstateAccess, m_scene.RegionInfo.EstateSettings.EstateID); 282 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
277 } 283 }
278 else 284 else
279 { 285 {
@@ -283,13 +289,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
283 } 289 }
284 if ((estateAccessType & 8) != 0) // User remove 290 if ((estateAccessType & 8) != 0) // User remove
285 { 291 {
286 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 292 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
287 { 293 {
288 m_scene.RegionInfo.EstateSettings.RemoveEstateUser(user); 294 Scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
289 m_scene.RegionInfo.EstateSettings.Save(); 295 Scene.RegionInfo.EstateSettings.Save();
290 TriggerEstateInfoChange(); 296 TriggerEstateInfoChange();
291 297
292 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, m_scene.RegionInfo.EstateSettings.EstateAccess, m_scene.RegionInfo.EstateSettings.EstateID); 298 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
293 } 299 }
294 else 300 else
295 { 301 {
@@ -298,12 +304,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
298 } 304 }
299 if ((estateAccessType & 16) != 0) // Group add 305 if ((estateAccessType & 16) != 0) // Group add
300 { 306 {
301 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 307 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
302 { 308 {
303 m_scene.RegionInfo.EstateSettings.AddEstateGroup(user); 309 Scene.RegionInfo.EstateSettings.AddEstateGroup(user);
304 m_scene.RegionInfo.EstateSettings.Save(); 310 Scene.RegionInfo.EstateSettings.Save();
305 TriggerEstateInfoChange(); 311 TriggerEstateInfoChange();
306 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, m_scene.RegionInfo.EstateSettings.EstateGroups, m_scene.RegionInfo.EstateSettings.EstateID); 312 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
307 } 313 }
308 else 314 else
309 { 315 {
@@ -312,13 +318,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
312 } 318 }
313 if ((estateAccessType & 32) != 0) // Group remove 319 if ((estateAccessType & 32) != 0) // Group remove
314 { 320 {
315 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 321 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
316 { 322 {
317 m_scene.RegionInfo.EstateSettings.RemoveEstateGroup(user); 323 Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
318 m_scene.RegionInfo.EstateSettings.Save(); 324 Scene.RegionInfo.EstateSettings.Save();
319 TriggerEstateInfoChange(); 325 TriggerEstateInfoChange();
320 326
321 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, m_scene.RegionInfo.EstateSettings.EstateGroups, m_scene.RegionInfo.EstateSettings.EstateID); 327 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
322 } 328 }
323 else 329 else
324 { 330 {
@@ -327,9 +333,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
327 } 333 }
328 if ((estateAccessType & 64) != 0) // Ban add 334 if ((estateAccessType & 64) != 0) // Ban add
329 { 335 {
330 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 336 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || Scene.Permissions.BypassPermissions())
331 { 337 {
332 EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans; 338 EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
333 339
334 bool alreadyInList = false; 340 bool alreadyInList = false;
335 341
@@ -348,20 +354,20 @@ namespace OpenSim.Region.CoreModules.World.Estate
348 EstateBan item = new EstateBan(); 354 EstateBan item = new EstateBan();
349 355
350 item.BannedUserID = user; 356 item.BannedUserID = user;
351 item.EstateID = m_scene.RegionInfo.EstateSettings.EstateID; 357 item.EstateID = Scene.RegionInfo.EstateSettings.EstateID;
352 item.BannedHostAddress = "0.0.0.0"; 358 item.BannedHostAddress = "0.0.0.0";
353 item.BannedHostIPMask = "0.0.0.0"; 359 item.BannedHostIPMask = "0.0.0.0";
354 360
355 m_scene.RegionInfo.EstateSettings.AddBan(item); 361 Scene.RegionInfo.EstateSettings.AddBan(item);
356 m_scene.RegionInfo.EstateSettings.Save(); 362 Scene.RegionInfo.EstateSettings.Save();
357 TriggerEstateInfoChange(); 363 TriggerEstateInfoChange();
358 364
359 ScenePresence s = m_scene.GetScenePresence(user); 365 ScenePresence s = Scene.GetScenePresence(user);
360 if (s != null) 366 if (s != null)
361 { 367 {
362 if (!s.IsChildAgent) 368 if (!s.IsChildAgent)
363 { 369 {
364 if (!m_scene.TeleportClientHome(user, s.ControllingClient)) 370 if (!Scene.TeleportClientHome(user, s.ControllingClient))
365 { 371 {
366 s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out."); 372 s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
367 s.ControllingClient.Close(); 373 s.ControllingClient.Close();
@@ -374,8 +380,8 @@ namespace OpenSim.Region.CoreModules.World.Estate
374 { 380 {
375 remote_client.SendAlertMessage("User is already on the region ban list"); 381 remote_client.SendAlertMessage("User is already on the region ban list");
376 } 382 }
377 //m_scene.RegionInfo.regionBanlist.Add(Manager(user); 383 //Scene.RegionInfo.regionBanlist.Add(Manager(user);
378 remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID); 384 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
379 } 385 }
380 else 386 else
381 { 387 {
@@ -384,9 +390,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
384 } 390 }
385 if ((estateAccessType & 128) != 0) // Ban remove 391 if ((estateAccessType & 128) != 0) // Ban remove
386 { 392 {
387 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 393 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || Scene.Permissions.BypassPermissions())
388 { 394 {
389 EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans; 395 EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
390 396
391 bool alreadyInList = false; 397 bool alreadyInList = false;
392 EstateBan listitem = null; 398 EstateBan listitem = null;
@@ -399,20 +405,21 @@ namespace OpenSim.Region.CoreModules.World.Estate
399 listitem = banlistcheck[i]; 405 listitem = banlistcheck[i];
400 break; 406 break;
401 } 407 }
402
403 } 408 }
409
404 if (alreadyInList && listitem != null) 410 if (alreadyInList && listitem != null)
405 { 411 {
406 m_scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID); 412 Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
407 m_scene.RegionInfo.EstateSettings.Save(); 413 Scene.RegionInfo.EstateSettings.Save();
408 TriggerEstateInfoChange(); 414 TriggerEstateInfoChange();
409 } 415 }
410 else 416 else
411 { 417 {
412 remote_client.SendAlertMessage("User is not on the region ban list"); 418 remote_client.SendAlertMessage("User is not on the region ban list");
413 } 419 }
414 //m_scene.RegionInfo.regionBanlist.Add(Manager(user); 420
415 remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID); 421 //Scene.RegionInfo.regionBanlist.Add(Manager(user);
422 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
416 } 423 }
417 else 424 else
418 { 425 {
@@ -421,12 +428,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
421 } 428 }
422 if ((estateAccessType & 256) != 0) // Manager add 429 if ((estateAccessType & 256) != 0) // Manager add
423 { 430 {
424 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 431 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
425 { 432 {
426 m_scene.RegionInfo.EstateSettings.AddEstateManager(user); 433 Scene.RegionInfo.EstateSettings.AddEstateManager(user);
427 m_scene.RegionInfo.EstateSettings.Save(); 434 Scene.RegionInfo.EstateSettings.Save();
428 TriggerEstateInfoChange(); 435 TriggerEstateInfoChange();
429 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID); 436 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
430 } 437 }
431 else 438 else
432 { 439 {
@@ -435,13 +442,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
435 } 442 }
436 if ((estateAccessType & 512) != 0) // Manager remove 443 if ((estateAccessType & 512) != 0) // Manager remove
437 { 444 {
438 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 445 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
439 { 446 {
440 m_scene.RegionInfo.EstateSettings.RemoveEstateManager(user); 447 Scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
441 m_scene.RegionInfo.EstateSettings.Save(); 448 Scene.RegionInfo.EstateSettings.Save();
442 TriggerEstateInfoChange(); 449 TriggerEstateInfoChange();
443 450
444 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID); 451 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
445 } 452 }
446 else 453 else
447 { 454 {
@@ -453,7 +460,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
453 private void SendSimulatorBlueBoxMessage( 460 private void SendSimulatorBlueBoxMessage(
454 IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message) 461 IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
455 { 462 {
456 IDialogModule dm = m_scene.RequestModuleInterface<IDialogModule>(); 463 IDialogModule dm = Scene.RequestModuleInterface<IDialogModule>();
457 464
458 if (dm != null) 465 if (dm != null)
459 dm.SendNotificationToUsersInRegion(senderID, senderName, message); 466 dm.SendNotificationToUsersInRegion(senderID, senderName, message);
@@ -468,38 +475,38 @@ namespace OpenSim.Region.CoreModules.World.Estate
468 private void handleEstateDebugRegionRequest(IClientAPI remote_client, UUID invoice, UUID senderID, bool scripted, bool collisionEvents, bool physics) 475 private void handleEstateDebugRegionRequest(IClientAPI remote_client, UUID invoice, UUID senderID, bool scripted, bool collisionEvents, bool physics)
469 { 476 {
470 if (physics) 477 if (physics)
471 m_scene.RegionInfo.RegionSettings.DisablePhysics = true; 478 Scene.RegionInfo.RegionSettings.DisablePhysics = true;
472 else 479 else
473 m_scene.RegionInfo.RegionSettings.DisablePhysics = false; 480 Scene.RegionInfo.RegionSettings.DisablePhysics = false;
474 481
475 if (scripted) 482 if (scripted)
476 m_scene.RegionInfo.RegionSettings.DisableScripts = true; 483 Scene.RegionInfo.RegionSettings.DisableScripts = true;
477 else 484 else
478 m_scene.RegionInfo.RegionSettings.DisableScripts = false; 485 Scene.RegionInfo.RegionSettings.DisableScripts = false;
479 486
480 if (collisionEvents) 487 if (collisionEvents)
481 m_scene.RegionInfo.RegionSettings.DisableCollisions = true; 488 Scene.RegionInfo.RegionSettings.DisableCollisions = true;
482 else 489 else
483 m_scene.RegionInfo.RegionSettings.DisableCollisions = false; 490 Scene.RegionInfo.RegionSettings.DisableCollisions = false;
484 491
485 492
486 m_scene.RegionInfo.RegionSettings.Save(); 493 Scene.RegionInfo.RegionSettings.Save();
487 TriggerRegionInfoChange(); 494 TriggerRegionInfoChange();
488 495
489 m_scene.SetSceneCoreDebug(scripted, collisionEvents, physics); 496 Scene.SetSceneCoreDebug(scripted, collisionEvents, physics);
490 } 497 }
491 498
492 private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey) 499 private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey)
493 { 500 {
494 if (!m_scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false)) 501 if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
495 return; 502 return;
496 503
497 if (prey != UUID.Zero) 504 if (prey != UUID.Zero)
498 { 505 {
499 ScenePresence s = m_scene.GetScenePresence(prey); 506 ScenePresence s = Scene.GetScenePresence(prey);
500 if (s != null) 507 if (s != null)
501 { 508 {
502 if (!m_scene.TeleportClientHome(prey, s.ControllingClient)) 509 if (!Scene.TeleportClientHome(prey, s.ControllingClient))
503 { 510 {
504 s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); 511 s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
505 s.ControllingClient.Close(); 512 s.ControllingClient.Close();
@@ -510,19 +517,19 @@ namespace OpenSim.Region.CoreModules.World.Estate
510 517
511 private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID) 518 private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
512 { 519 {
513 if (!m_scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false)) 520 if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
514 return; 521 return;
515 522
516 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 523 Scene.ForEachScenePresence(delegate(ScenePresence sp)
517 { 524 {
518 if (sp.UUID != senderID) 525 if (sp.UUID != senderID)
519 { 526 {
520 ScenePresence p = m_scene.GetScenePresence(sp.UUID); 527 ScenePresence p = Scene.GetScenePresence(sp.UUID);
521 // make sure they are still there, we could be working down a long list 528 // make sure they are still there, we could be working down a long list
522 // Also make sure they are actually in the region 529 // Also make sure they are actually in the region
523 if (p != null && !p.IsChildAgent) 530 if (p != null && !p.IsChildAgent)
524 { 531 {
525 if (!m_scene.TeleportClientHome(p.UUID, p.ControllingClient)) 532 if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient))
526 { 533 {
527 p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); 534 p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
528 p.ControllingClient.Close(); 535 p.ControllingClient.Close();
@@ -531,6 +538,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
531 } 538 }
532 }); 539 });
533 } 540 }
541
534 private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) 542 private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
535 { 543 {
536 if (TerrainUploader != null) 544 if (TerrainUploader != null)
@@ -561,11 +569,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
561 TerrainUploader = null; 569 TerrainUploader = null;
562 } 570 }
563 remoteClient.SendAlertMessage("Terrain Upload Complete. Loading...."); 571 remoteClient.SendAlertMessage("Terrain Upload Complete. Loading....");
564 ITerrainModule terr = m_scene.RequestModuleInterface<ITerrainModule>(); 572 ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
565 573
566 if (terr != null) 574 if (terr != null)
567 { 575 {
568 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName); 576 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
569 577
570 try 578 try
571 { 579 {
@@ -611,7 +619,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
611 619
612 private void handleUploadTerrain(IClientAPI remote_client, string clientFileName) 620 private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
613 { 621 {
614
615 if (TerrainUploader == null) 622 if (TerrainUploader == null)
616 { 623 {
617 624
@@ -629,16 +636,16 @@ namespace OpenSim.Region.CoreModules.World.Estate
629 { 636 {
630 remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!"); 637 remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
631 } 638 }
632
633 } 639 }
640
634 private void handleTerrainRequest(IClientAPI remote_client, string clientFileName) 641 private void handleTerrainRequest(IClientAPI remote_client, string clientFileName)
635 { 642 {
636 // Save terrain here 643 // Save terrain here
637 ITerrainModule terr = m_scene.RequestModuleInterface<ITerrainModule>(); 644 ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
638 645
639 if (terr != null) 646 if (terr != null)
640 { 647 {
641 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName); 648 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
642 if (File.Exists(Util.dataDir() + "/terrain.raw")) 649 if (File.Exists(Util.dataDir() + "/terrain.raw"))
643 { 650 {
644 File.Delete(Util.dataDir() + "/terrain.raw"); 651 File.Delete(Util.dataDir() + "/terrain.raw");
@@ -649,7 +656,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
649 byte[] bdata = new byte[input.Length]; 656 byte[] bdata = new byte[input.Length];
650 input.Read(bdata, 0, (int)input.Length); 657 input.Read(bdata, 0, (int)input.Length);
651 remote_client.SendAlertMessage("Terrain file written, starting download..."); 658 remote_client.SendAlertMessage("Terrain file written, starting download...");
652 m_scene.XferManager.AddNewFile("terrain.raw", bdata); 659 Scene.XferManager.AddNewFile("terrain.raw", bdata);
653 // Tell client about it 660 // Tell client about it
654 m_log.Warn("[CLIENT]: Sending Terrain to " + remote_client.Name); 661 m_log.Warn("[CLIENT]: Sending Terrain to " + remote_client.Name);
655 remote_client.SendInitiateDownload("terrain.raw", clientFileName); 662 remote_client.SendInitiateDownload("terrain.raw", clientFileName);
@@ -659,35 +666,35 @@ namespace OpenSim.Region.CoreModules.World.Estate
659 private void HandleRegionInfoRequest(IClientAPI remote_client) 666 private void HandleRegionInfoRequest(IClientAPI remote_client)
660 { 667 {
661 RegionInfoForEstateMenuArgs args = new RegionInfoForEstateMenuArgs(); 668 RegionInfoForEstateMenuArgs args = new RegionInfoForEstateMenuArgs();
662 args.billableFactor = m_scene.RegionInfo.EstateSettings.BillableFactor; 669 args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
663 args.estateID = m_scene.RegionInfo.EstateSettings.EstateID; 670 args.estateID = Scene.RegionInfo.EstateSettings.EstateID;
664 args.maxAgents = (byte)m_scene.RegionInfo.RegionSettings.AgentLimit; 671 args.maxAgents = (byte)Scene.RegionInfo.RegionSettings.AgentLimit;
665 args.objectBonusFactor = (float)m_scene.RegionInfo.RegionSettings.ObjectBonus; 672 args.objectBonusFactor = (float)Scene.RegionInfo.RegionSettings.ObjectBonus;
666 args.parentEstateID = m_scene.RegionInfo.EstateSettings.ParentEstateID; 673 args.parentEstateID = Scene.RegionInfo.EstateSettings.ParentEstateID;
667 args.pricePerMeter = m_scene.RegionInfo.EstateSettings.PricePerMeter; 674 args.pricePerMeter = Scene.RegionInfo.EstateSettings.PricePerMeter;
668 args.redirectGridX = m_scene.RegionInfo.EstateSettings.RedirectGridX; 675 args.redirectGridX = Scene.RegionInfo.EstateSettings.RedirectGridX;
669 args.redirectGridY = m_scene.RegionInfo.EstateSettings.RedirectGridY; 676 args.redirectGridY = Scene.RegionInfo.EstateSettings.RedirectGridY;
670 args.regionFlags = GetRegionFlags(); 677 args.regionFlags = GetRegionFlags();
671 args.simAccess = m_scene.RegionInfo.AccessLevel; 678 args.simAccess = Scene.RegionInfo.AccessLevel;
672 args.sunHour = (float)m_scene.RegionInfo.RegionSettings.SunPosition; 679 args.sunHour = (float)Scene.RegionInfo.RegionSettings.SunPosition;
673 args.terrainLowerLimit = (float)m_scene.RegionInfo.RegionSettings.TerrainLowerLimit; 680 args.terrainLowerLimit = (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit;
674 args.terrainRaiseLimit = (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit; 681 args.terrainRaiseLimit = (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit;
675 args.useEstateSun = m_scene.RegionInfo.RegionSettings.UseEstateSun; 682 args.useEstateSun = Scene.RegionInfo.RegionSettings.UseEstateSun;
676 args.waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; 683 args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
677 args.simName = m_scene.RegionInfo.RegionName; 684 args.simName = Scene.RegionInfo.RegionName;
678 args.regionType = m_scene.RegionInfo.RegionType; 685 args.regionType = Scene.RegionInfo.RegionType;
679 686
680 remote_client.SendRegionInfoToEstateMenu(args); 687 remote_client.SendRegionInfoToEstateMenu(args);
681 } 688 }
682 689
683 private void HandleEstateCovenantRequest(IClientAPI remote_client) 690 private void HandleEstateCovenantRequest(IClientAPI remote_client)
684 { 691 {
685 remote_client.SendEstateCovenantInformation(m_scene.RegionInfo.RegionSettings.Covenant); 692 remote_client.SendEstateCovenantInformation(Scene.RegionInfo.RegionSettings.Covenant);
686 } 693 }
687 694
688 private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient) 695 private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient)
689 { 696 {
690 if (!m_scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false)) 697 if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false))
691 return; 698 return;
692 699
693 Dictionary<uint, float> SceneData = new Dictionary<uint,float>(); 700 Dictionary<uint, float> SceneData = new Dictionary<uint,float>();
@@ -695,11 +702,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
695 702
696 if (reportType == 1) 703 if (reportType == 1)
697 { 704 {
698 SceneData = m_scene.PhysicsScene.GetTopColliders(); 705 SceneData = Scene.PhysicsScene.GetTopColliders();
699 } 706 }
700 else if (reportType == 0) 707 else if (reportType == 0)
701 { 708 {
702 SceneData = m_scene.SceneGraph.GetTopScripts(); 709 SceneData = Scene.SceneGraph.GetTopScripts();
703 } 710 }
704 711
705 List<LandStatReportItem> SceneReport = new List<LandStatReportItem>(); 712 List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
@@ -707,7 +714,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
707 { 714 {
708 foreach (uint obj in SceneData.Keys) 715 foreach (uint obj in SceneData.Keys)
709 { 716 {
710 SceneObjectPart prt = m_scene.GetSceneObjectPart(obj); 717 SceneObjectPart prt = Scene.GetSceneObjectPart(obj);
711 if (prt != null) 718 if (prt != null)
712 { 719 {
713 if (prt.ParentGroup != null) 720 if (prt.ParentGroup != null)
@@ -777,9 +784,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
777 784
778 for (int i = 0; i < uuidarr.Length; i++) 785 for (int i = 0; i < uuidarr.Length; i++)
779 { 786 {
780 // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]); 787 // string lookupname = Scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
781 788
782 IUserManagement userManager = m_scene.RequestModuleInterface<IUserManagement>(); 789 IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>();
783 if (userManager != null) 790 if (userManager != null)
784 userManager.GetUserName(uuidarr[i]); 791 userManager.GetUserName(uuidarr[i]);
785 792
@@ -794,7 +801,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
794 801
795 public void sendRegionInfoPacketToAll() 802 public void sendRegionInfoPacketToAll()
796 { 803 {
797 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 804 Scene.ForEachScenePresence(delegate(ScenePresence sp)
798 { 805 {
799 if (!sp.IsChildAgent) 806 if (!sp.IsChildAgent)
800 HandleRegionInfoRequest(sp.ControllingClient); 807 HandleRegionInfoRequest(sp.ControllingClient);
@@ -805,99 +812,99 @@ namespace OpenSim.Region.CoreModules.World.Estate
805 { 812 {
806 RegionHandshakeArgs args = new RegionHandshakeArgs(); 813 RegionHandshakeArgs args = new RegionHandshakeArgs();
807 814
808 args.isEstateManager = m_scene.RegionInfo.EstateSettings.IsEstateManager(remoteClient.AgentId); 815 args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManager(remoteClient.AgentId);
809 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && m_scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId) 816 if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId)
810 args.isEstateManager = true; 817 args.isEstateManager = true;
811 818
812 args.billableFactor = m_scene.RegionInfo.EstateSettings.BillableFactor; 819 args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
813 args.terrainStartHeight0 = (float)m_scene.RegionInfo.RegionSettings.Elevation1SW; 820 args.terrainStartHeight0 = (float)Scene.RegionInfo.RegionSettings.Elevation1SW;
814 args.terrainHeightRange0 = (float)m_scene.RegionInfo.RegionSettings.Elevation2SW; 821 args.terrainHeightRange0 = (float)Scene.RegionInfo.RegionSettings.Elevation2SW;
815 args.terrainStartHeight1 = (float)m_scene.RegionInfo.RegionSettings.Elevation1NW; 822 args.terrainStartHeight1 = (float)Scene.RegionInfo.RegionSettings.Elevation1NW;
816 args.terrainHeightRange1 = (float)m_scene.RegionInfo.RegionSettings.Elevation2NW; 823 args.terrainHeightRange1 = (float)Scene.RegionInfo.RegionSettings.Elevation2NW;
817 args.terrainStartHeight2 = (float)m_scene.RegionInfo.RegionSettings.Elevation1SE; 824 args.terrainStartHeight2 = (float)Scene.RegionInfo.RegionSettings.Elevation1SE;
818 args.terrainHeightRange2 = (float)m_scene.RegionInfo.RegionSettings.Elevation2SE; 825 args.terrainHeightRange2 = (float)Scene.RegionInfo.RegionSettings.Elevation2SE;
819 args.terrainStartHeight3 = (float)m_scene.RegionInfo.RegionSettings.Elevation1NE; 826 args.terrainStartHeight3 = (float)Scene.RegionInfo.RegionSettings.Elevation1NE;
820 args.terrainHeightRange3 = (float)m_scene.RegionInfo.RegionSettings.Elevation2NE; 827 args.terrainHeightRange3 = (float)Scene.RegionInfo.RegionSettings.Elevation2NE;
821 args.simAccess = m_scene.RegionInfo.AccessLevel; 828 args.simAccess = Scene.RegionInfo.AccessLevel;
822 args.waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; 829 args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
823 args.regionFlags = GetRegionFlags(); 830 args.regionFlags = GetRegionFlags();
824 args.regionName = m_scene.RegionInfo.RegionName; 831 args.regionName = Scene.RegionInfo.RegionName;
825 args.SimOwner = m_scene.RegionInfo.EstateSettings.EstateOwner; 832 args.SimOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
826 833
827 args.terrainBase0 = UUID.Zero; 834 args.terrainBase0 = UUID.Zero;
828 args.terrainBase1 = UUID.Zero; 835 args.terrainBase1 = UUID.Zero;
829 args.terrainBase2 = UUID.Zero; 836 args.terrainBase2 = UUID.Zero;
830 args.terrainBase3 = UUID.Zero; 837 args.terrainBase3 = UUID.Zero;
831 args.terrainDetail0 = m_scene.RegionInfo.RegionSettings.TerrainTexture1; 838 args.terrainDetail0 = Scene.RegionInfo.RegionSettings.TerrainTexture1;
832 args.terrainDetail1 = m_scene.RegionInfo.RegionSettings.TerrainTexture2; 839 args.terrainDetail1 = Scene.RegionInfo.RegionSettings.TerrainTexture2;
833 args.terrainDetail2 = m_scene.RegionInfo.RegionSettings.TerrainTexture3; 840 args.terrainDetail2 = Scene.RegionInfo.RegionSettings.TerrainTexture3;
834 args.terrainDetail3 = m_scene.RegionInfo.RegionSettings.TerrainTexture4; 841 args.terrainDetail3 = Scene.RegionInfo.RegionSettings.TerrainTexture4;
835 842
836 remoteClient.SendRegionHandshake(m_scene.RegionInfo,args); 843 remoteClient.SendRegionHandshake(Scene.RegionInfo,args);
837 } 844 }
838 845
839 public void sendRegionHandshakeToAll() 846 public void sendRegionHandshakeToAll()
840 { 847 {
841 m_scene.ForEachClient(sendRegionHandshake); 848 Scene.ForEachClient(sendRegionHandshake);
842 } 849 }
843 850
844 public void handleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2) 851 public void handleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2)
845 { 852 {
846 if (parms2 == 0) 853 if (parms2 == 0)
847 { 854 {
848 m_scene.RegionInfo.EstateSettings.UseGlobalTime = true; 855 Scene.RegionInfo.EstateSettings.UseGlobalTime = true;
849 m_scene.RegionInfo.EstateSettings.SunPosition = 0.0; 856 Scene.RegionInfo.EstateSettings.SunPosition = 0.0;
850 } 857 }
851 else 858 else
852 { 859 {
853 m_scene.RegionInfo.EstateSettings.UseGlobalTime = false; 860 Scene.RegionInfo.EstateSettings.UseGlobalTime = false;
854 m_scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0; 861 Scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
855 } 862 }
856 863
857 if ((parms1 & 0x00000010) != 0) 864 if ((parms1 & 0x00000010) != 0)
858 m_scene.RegionInfo.EstateSettings.FixedSun = true; 865 Scene.RegionInfo.EstateSettings.FixedSun = true;
859 else 866 else
860 m_scene.RegionInfo.EstateSettings.FixedSun = false; 867 Scene.RegionInfo.EstateSettings.FixedSun = false;
861 868
862 if ((parms1 & 0x00008000) != 0) 869 if ((parms1 & 0x00008000) != 0)
863 m_scene.RegionInfo.EstateSettings.PublicAccess = true; 870 Scene.RegionInfo.EstateSettings.PublicAccess = true;
864 else 871 else
865 m_scene.RegionInfo.EstateSettings.PublicAccess = false; 872 Scene.RegionInfo.EstateSettings.PublicAccess = false;
866 873
867 if ((parms1 & 0x10000000) != 0) 874 if ((parms1 & 0x10000000) != 0)
868 m_scene.RegionInfo.EstateSettings.AllowVoice = true; 875 Scene.RegionInfo.EstateSettings.AllowVoice = true;
869 else 876 else
870 m_scene.RegionInfo.EstateSettings.AllowVoice = false; 877 Scene.RegionInfo.EstateSettings.AllowVoice = false;
871 878
872 if ((parms1 & 0x00100000) != 0) 879 if ((parms1 & 0x00100000) != 0)
873 m_scene.RegionInfo.EstateSettings.AllowDirectTeleport = true; 880 Scene.RegionInfo.EstateSettings.AllowDirectTeleport = true;
874 else 881 else
875 m_scene.RegionInfo.EstateSettings.AllowDirectTeleport = false; 882 Scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
876 883
877 if ((parms1 & 0x00800000) != 0) 884 if ((parms1 & 0x00800000) != 0)
878 m_scene.RegionInfo.EstateSettings.DenyAnonymous = true; 885 Scene.RegionInfo.EstateSettings.DenyAnonymous = true;
879 else 886 else
880 m_scene.RegionInfo.EstateSettings.DenyAnonymous = false; 887 Scene.RegionInfo.EstateSettings.DenyAnonymous = false;
881 888
882 if ((parms1 & 0x01000000) != 0) 889 if ((parms1 & 0x01000000) != 0)
883 m_scene.RegionInfo.EstateSettings.DenyIdentified = true; 890 Scene.RegionInfo.EstateSettings.DenyIdentified = true;
884 else 891 else
885 m_scene.RegionInfo.EstateSettings.DenyIdentified = false; 892 Scene.RegionInfo.EstateSettings.DenyIdentified = false;
886 893
887 if ((parms1 & 0x02000000) != 0) 894 if ((parms1 & 0x02000000) != 0)
888 m_scene.RegionInfo.EstateSettings.DenyTransacted = true; 895 Scene.RegionInfo.EstateSettings.DenyTransacted = true;
889 else 896 else
890 m_scene.RegionInfo.EstateSettings.DenyTransacted = false; 897 Scene.RegionInfo.EstateSettings.DenyTransacted = false;
891 898
892 if ((parms1 & 0x40000000) != 0) 899 if ((parms1 & 0x40000000) != 0)
893 m_scene.RegionInfo.EstateSettings.DenyMinors = true; 900 Scene.RegionInfo.EstateSettings.DenyMinors = true;
894 else 901 else
895 m_scene.RegionInfo.EstateSettings.DenyMinors = false; 902 Scene.RegionInfo.EstateSettings.DenyMinors = false;
896 903
897 m_scene.RegionInfo.EstateSettings.Save(); 904 Scene.RegionInfo.EstateSettings.Save();
898 TriggerEstateInfoChange(); 905 TriggerEstateInfoChange();
899 906
900 m_scene.TriggerEstateSunUpdate(); 907 Scene.TriggerEstateSunUpdate();
901 908
902 sendDetailedEstateData(remoteClient, invoice); 909 sendDetailedEstateData(remoteClient, invoice);
903 } 910 }
@@ -905,140 +912,42 @@ namespace OpenSim.Region.CoreModules.World.Estate
905 #endregion 912 #endregion
906 913
907 #region IRegionModule Members 914 #region IRegionModule Members
915
916 public string Name { get { return "EstateManagementModule"; } }
917
918 public Type ReplaceableInterface { get { return null; } }
908 919
909 public void Initialise(Scene scene, IConfigSource source) 920 public void Initialise(IConfigSource source) {}
921
922 public void AddRegion(Scene scene)
910 { 923 {
911 m_scene = scene;
912 m_scene.RegisterModuleInterface<IEstateModule>(this);
913 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
914 m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
915 m_regionChangeTimer.AutoReset = false; 924 m_regionChangeTimer.AutoReset = false;
916 m_regionChangeTimer.Interval = 2000; 925 m_regionChangeTimer.Interval = 2000;
917 m_regionChangeTimer.Elapsed += RaiseRegionInfoChange; 926 m_regionChangeTimer.Elapsed += RaiseRegionInfoChange;
918 927
919 m_scene.AddCommand(this, "set terrain texture", 928 Scene = scene;
920 "set terrain texture <number> <uuid> [<x>] [<y>]", 929 Scene.RegisterModuleInterface<IEstateModule>(this);
921 "Sets the terrain <number> to <uuid>, if <x> or <y> are specified, it will only " + 930 Scene.EventManager.OnNewClient += EventManager_OnNewClient;
922 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" + 931 Scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
923 " that coordinate.", 932
924 consoleSetTerrainTexture); 933 m_commands = new EstateManagementCommands(this);
925 934 m_commands.Initialise();
926 m_scene.AddCommand(this, "set terrain heights",
927 "set terrain heights <corner> <min> <max> [<x>] [<y>]",
928 "Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
929 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
930 " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.",
931 consoleSetTerrainHeights);
932 }
933
934 #region Console Commands
935
936 public void consoleSetTerrainTexture(string module, string[] args)
937 {
938 string num = args[3];
939 string uuid = args[4];
940 int x = (args.Length > 5 ? int.Parse(args[5]) : -1);
941 int y = (args.Length > 6 ? int.Parse(args[6]) : -1);
942
943 if (x == -1 || m_scene.RegionInfo.RegionLocX == x)
944 {
945 if (y == -1 || m_scene.RegionInfo.RegionLocY == y)
946 {
947 int corner = int.Parse(num);
948 UUID texture = UUID.Parse(uuid);
949
950 m_log.Debug("[ESTATEMODULE] Setting terrain textures for " + m_scene.RegionInfo.RegionName +
951 string.Format(" (C#{0} = {1})", corner, texture));
952
953 switch (corner)
954 {
955 case 0:
956 m_scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
957 break;
958 case 1:
959 m_scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
960 break;
961 case 2:
962 m_scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
963 break;
964 case 3:
965 m_scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
966 break;
967 }
968 m_scene.RegionInfo.RegionSettings.Save();
969 TriggerRegionInfoChange();
970 sendRegionInfoPacketToAll();
971
972 }
973 }
974 }
975
976 public void consoleSetTerrainHeights(string module, string[] args)
977 {
978 string num = args[3];
979 string min = args[4];
980 string max = args[5];
981 int x = (args.Length > 6 ? int.Parse(args[6]) : -1);
982 int y = (args.Length > 7 ? int.Parse(args[7]) : -1);
983
984 if (x == -1 || m_scene.RegionInfo.RegionLocX == x)
985 {
986 if (y == -1 || m_scene.RegionInfo.RegionLocY == y)
987 {
988 int corner = int.Parse(num);
989 float lowValue = float.Parse(min, Culture.NumberFormatInfo);
990 float highValue = float.Parse(max, Culture.NumberFormatInfo);
991
992 m_log.Debug("[ESTATEMODULE] Setting terrain heights " + m_scene.RegionInfo.RegionName +
993 string.Format(" (C{0}, {1}-{2}", corner, lowValue, highValue));
994
995 switch (corner)
996 {
997 case 0:
998 m_scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
999 m_scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
1000 break;
1001 case 1:
1002 m_scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
1003 m_scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
1004 break;
1005 case 2:
1006 m_scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
1007 m_scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
1008 break;
1009 case 3:
1010 m_scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
1011 m_scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
1012 break;
1013 }
1014 m_scene.RegionInfo.RegionSettings.Save();
1015 TriggerRegionInfoChange();
1016 sendRegionHandshakeToAll();
1017 }
1018 }
1019 } 935 }
1020 936
1021 #endregion 937 public void RemoveRegion(Scene scene) {}
1022 938
1023 public void PostInitialise() 939 public void RegionLoaded(Scene scene)
1024 { 940 {
1025 // Sets up the sun module based no the saved Estate and Region Settings 941 // Sets up the sun module based no the saved Estate and Region Settings
1026 // DO NOT REMOVE or the sun will stop working 942 // DO NOT REMOVE or the sun will stop working
1027 m_scene.TriggerEstateSunUpdate(); 943 scene.TriggerEstateSunUpdate();
1028 } 944
1029 945 UserManager = scene.RequestModuleInterface<IUserManagement>();
1030 public void Close()
1031 {
1032 }
1033
1034 public string Name
1035 {
1036 get { return "EstateManagementModule"; }
1037 } 946 }
1038 947
1039 public bool IsSharedModule 948 public void Close()
1040 { 949 {
1041 get { return false; } 950 m_commands.Close();
1042 } 951 }
1043 952
1044 #endregion 953 #endregion
@@ -1048,14 +957,14 @@ namespace OpenSim.Region.CoreModules.World.Estate
1048 public void changeWaterHeight(float height) 957 public void changeWaterHeight(float height)
1049 { 958 {
1050 setRegionTerrainSettings(height, 959 setRegionTerrainSettings(height,
1051 (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit, 960 (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit,
1052 (float)m_scene.RegionInfo.RegionSettings.TerrainLowerLimit, 961 (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit,
1053 m_scene.RegionInfo.RegionSettings.UseEstateSun, 962 Scene.RegionInfo.RegionSettings.UseEstateSun,
1054 m_scene.RegionInfo.RegionSettings.FixedSun, 963 Scene.RegionInfo.RegionSettings.FixedSun,
1055 (float)m_scene.RegionInfo.RegionSettings.SunPosition, 964 (float)Scene.RegionInfo.RegionSettings.SunPosition,
1056 m_scene.RegionInfo.EstateSettings.UseGlobalTime, 965 Scene.RegionInfo.EstateSettings.UseGlobalTime,
1057 m_scene.RegionInfo.EstateSettings.FixedSun, 966 Scene.RegionInfo.EstateSettings.FixedSun,
1058 (float)m_scene.RegionInfo.EstateSettings.SunPosition); 967 (float)Scene.RegionInfo.EstateSettings.SunPosition);
1059 968
1060 sendRegionInfoPacketToAll(); 969 sendRegionInfoPacketToAll();
1061 } 970 }
@@ -1095,33 +1004,42 @@ namespace OpenSim.Region.CoreModules.World.Estate
1095 1004
1096 // Fully implemented 1005 // Fully implemented
1097 // 1006 //
1098 if (m_scene.RegionInfo.RegionSettings.AllowDamage) 1007 if (Scene.RegionInfo.RegionSettings.AllowDamage)
1099 flags |= RegionFlags.AllowDamage; 1008 flags |= RegionFlags.AllowDamage;
1100 if (m_scene.RegionInfo.RegionSettings.BlockTerraform) 1009 if (Scene.RegionInfo.RegionSettings.BlockTerraform)
1101 flags |= RegionFlags.BlockTerraform; 1010 flags |= RegionFlags.BlockTerraform;
1102 if (!m_scene.RegionInfo.RegionSettings.AllowLandResell) 1011 if (!Scene.RegionInfo.RegionSettings.AllowLandResell)
1103 flags |= RegionFlags.BlockLandResell; 1012 flags |= RegionFlags.BlockLandResell;
1104 if (m_scene.RegionInfo.RegionSettings.DisableCollisions) 1013 if (Scene.RegionInfo.RegionSettings.DisableCollisions)
1105 flags |= RegionFlags.SkipCollisions; 1014 flags |= RegionFlags.SkipCollisions;
1106 if (m_scene.RegionInfo.RegionSettings.DisableScripts) 1015 if (Scene.RegionInfo.RegionSettings.DisableScripts)
1107 flags |= RegionFlags.SkipScripts; 1016 flags |= RegionFlags.SkipScripts;
1108 if (m_scene.RegionInfo.RegionSettings.DisablePhysics) 1017 if (Scene.RegionInfo.RegionSettings.DisablePhysics)
1109 flags |= RegionFlags.SkipPhysics; 1018 flags |= RegionFlags.SkipPhysics;
1110 if (m_scene.RegionInfo.RegionSettings.BlockFly) 1019 if (Scene.RegionInfo.RegionSettings.BlockFly)
1111 flags |= RegionFlags.NoFly; 1020 flags |= RegionFlags.NoFly;
1112 if (m_scene.RegionInfo.RegionSettings.RestrictPushing) 1021 if (Scene.RegionInfo.RegionSettings.RestrictPushing)
1113 flags |= RegionFlags.RestrictPushObject; 1022 flags |= RegionFlags.RestrictPushObject;
1114 if (m_scene.RegionInfo.RegionSettings.AllowLandJoinDivide) 1023 if (Scene.RegionInfo.RegionSettings.AllowLandJoinDivide)
1115 flags |= RegionFlags.AllowParcelChanges; 1024 flags |= RegionFlags.AllowParcelChanges;
1116 if (m_scene.RegionInfo.RegionSettings.BlockShowInSearch) 1025 if (Scene.RegionInfo.RegionSettings.BlockShowInSearch)
1117 flags |= RegionFlags.BlockParcelSearch; 1026 flags |= RegionFlags.BlockParcelSearch;
1118 1027
1119 if (m_scene.RegionInfo.RegionSettings.FixedSun) 1028 if (Scene.RegionInfo.RegionSettings.FixedSun)
1120 flags |= RegionFlags.SunFixed; 1029 flags |= RegionFlags.SunFixed;
1121 if (m_scene.RegionInfo.RegionSettings.Sandbox) 1030 if (Scene.RegionInfo.RegionSettings.Sandbox)
1122 flags |= RegionFlags.Sandbox; 1031 flags |= RegionFlags.Sandbox;
1123 if (m_scene.RegionInfo.EstateSettings.AllowVoice) 1032 if (Scene.RegionInfo.EstateSettings.AllowVoice)
1124 flags |= RegionFlags.AllowVoice; 1033 flags |= RegionFlags.AllowVoice;
1034 if (Scene.RegionInfo.EstateSettings.AllowLandmark)
1035 flags |= RegionFlags.AllowLandmark;
1036 if (Scene.RegionInfo.EstateSettings.AllowSetHome)
1037 flags |= RegionFlags.AllowSetHome;
1038 if (Scene.RegionInfo.EstateSettings.BlockDwell)
1039 flags |= RegionFlags.BlockDwell;
1040 if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
1041 flags |= RegionFlags.ResetHomeOnTeleport;
1042
1125 1043
1126 // Fudge these to always on, so the menu options activate 1044 // Fudge these to always on, so the menu options activate
1127 // 1045 //
@@ -1142,32 +1060,38 @@ namespace OpenSim.Region.CoreModules.World.Estate
1142 { 1060 {
1143 RegionFlags flags = RegionFlags.None; 1061 RegionFlags flags = RegionFlags.None;
1144 1062
1145 if (m_scene.RegionInfo.EstateSettings.FixedSun) 1063 if (Scene.RegionInfo.EstateSettings.FixedSun)
1146 flags |= RegionFlags.SunFixed; 1064 flags |= RegionFlags.SunFixed;
1147 if (m_scene.RegionInfo.EstateSettings.PublicAccess) 1065 if (Scene.RegionInfo.EstateSettings.PublicAccess)
1148 flags |= (RegionFlags.PublicAllowed | 1066 flags |= (RegionFlags.PublicAllowed |
1149 RegionFlags.ExternallyVisible); 1067 RegionFlags.ExternallyVisible);
1150 if (m_scene.RegionInfo.EstateSettings.AllowVoice) 1068 if (Scene.RegionInfo.EstateSettings.AllowVoice)
1151 flags |= RegionFlags.AllowVoice; 1069 flags |= RegionFlags.AllowVoice;
1152 if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) 1070 if (Scene.RegionInfo.EstateSettings.AllowDirectTeleport)
1153 flags |= RegionFlags.AllowDirectTeleport; 1071 flags |= RegionFlags.AllowDirectTeleport;
1154 if (m_scene.RegionInfo.EstateSettings.DenyAnonymous) 1072 if (Scene.RegionInfo.EstateSettings.DenyAnonymous)
1155 flags |= RegionFlags.DenyAnonymous; 1073 flags |= RegionFlags.DenyAnonymous;
1156 if (m_scene.RegionInfo.EstateSettings.DenyIdentified) 1074 if (Scene.RegionInfo.EstateSettings.DenyIdentified)
1157 flags |= RegionFlags.DenyIdentified; 1075 flags |= RegionFlags.DenyIdentified;
1158 if (m_scene.RegionInfo.EstateSettings.DenyTransacted) 1076 if (Scene.RegionInfo.EstateSettings.DenyTransacted)
1159 flags |= RegionFlags.DenyTransacted; 1077 flags |= RegionFlags.DenyTransacted;
1160 if (m_scene.RegionInfo.EstateSettings.AbuseEmailToEstateOwner) 1078 if (Scene.RegionInfo.EstateSettings.AbuseEmailToEstateOwner)
1161 flags |= RegionFlags.AbuseEmailToEstateOwner; 1079 flags |= RegionFlags.AbuseEmailToEstateOwner;
1162 if (m_scene.RegionInfo.EstateSettings.BlockDwell) 1080 if (Scene.RegionInfo.EstateSettings.BlockDwell)
1163 flags |= RegionFlags.BlockDwell; 1081 flags |= RegionFlags.BlockDwell;
1164 if (m_scene.RegionInfo.EstateSettings.EstateSkipScripts) 1082 if (Scene.RegionInfo.EstateSettings.EstateSkipScripts)
1165 flags |= RegionFlags.EstateSkipScripts; 1083 flags |= RegionFlags.EstateSkipScripts;
1166 if (m_scene.RegionInfo.EstateSettings.ResetHomeOnTeleport) 1084 if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
1167 flags |= RegionFlags.ResetHomeOnTeleport; 1085 flags |= RegionFlags.ResetHomeOnTeleport;
1168 if (m_scene.RegionInfo.EstateSettings.TaxFree) 1086 if (Scene.RegionInfo.EstateSettings.TaxFree)
1169 flags |= RegionFlags.TaxFree; 1087 flags |= RegionFlags.TaxFree;
1170 if (m_scene.RegionInfo.EstateSettings.DenyMinors) 1088 if (Scene.RegionInfo.EstateSettings.AllowLandmark)
1089 flags |= RegionFlags.AllowLandmark;
1090 if (Scene.RegionInfo.EstateSettings.AllowParcelChanges)
1091 flags |= RegionFlags.AllowParcelChanges;
1092 if (Scene.RegionInfo.EstateSettings.AllowSetHome)
1093 flags |= RegionFlags.AllowSetHome;
1094 if (Scene.RegionInfo.EstateSettings.DenyMinors)
1171 flags |= (RegionFlags)(1 << 30); 1095 flags |= (RegionFlags)(1 << 30);
1172 1096
1173 return (uint)flags; 1097 return (uint)flags;
@@ -1175,17 +1099,17 @@ namespace OpenSim.Region.CoreModules.World.Estate
1175 1099
1176 public bool IsManager(UUID avatarID) 1100 public bool IsManager(UUID avatarID)
1177 { 1101 {
1178 if (avatarID == m_scene.RegionInfo.EstateSettings.EstateOwner) 1102 if (avatarID == Scene.RegionInfo.EstateSettings.EstateOwner)
1179 return true; 1103 return true;
1180 1104
1181 List<UUID> ems = new List<UUID>(m_scene.RegionInfo.EstateSettings.EstateManagers); 1105 List<UUID> ems = new List<UUID>(Scene.RegionInfo.EstateSettings.EstateManagers);
1182 if (ems.Contains(avatarID)) 1106 if (ems.Contains(avatarID))
1183 return true; 1107 return true;
1184 1108
1185 return false; 1109 return false;
1186 } 1110 }
1187 1111
1188 protected void TriggerRegionInfoChange() 1112 public void TriggerRegionInfoChange()
1189 { 1113 {
1190 m_regionChangeTimer.Stop(); 1114 m_regionChangeTimer.Stop();
1191 m_regionChangeTimer.Start(); 1115 m_regionChangeTimer.Start();
@@ -1196,23 +1120,23 @@ namespace OpenSim.Region.CoreModules.World.Estate
1196 ChangeDelegate change = OnRegionInfoChange; 1120 ChangeDelegate change = OnRegionInfoChange;
1197 1121
1198 if (change != null) 1122 if (change != null)
1199 change(m_scene.RegionInfo.RegionID); 1123 change(Scene.RegionInfo.RegionID);
1200 } 1124 }
1201 1125
1202 protected void TriggerEstateInfoChange() 1126 public void TriggerEstateInfoChange()
1203 { 1127 {
1204 ChangeDelegate change = OnEstateInfoChange; 1128 ChangeDelegate change = OnEstateInfoChange;
1205 1129
1206 if (change != null) 1130 if (change != null)
1207 change(m_scene.RegionInfo.RegionID); 1131 change(Scene.RegionInfo.RegionID);
1208 } 1132 }
1209 1133
1210 protected void TriggerEstateMessage(UUID fromID, string fromName, string message) 1134 public void TriggerEstateMessage(UUID fromID, string fromName, string message)
1211 { 1135 {
1212 MessageDelegate onmessage = OnEstateMessage; 1136 MessageDelegate onmessage = OnEstateMessage;
1213 1137
1214 if (onmessage != null) 1138 if (onmessage != null)
1215 onmessage(m_scene.RegionInfo.RegionID, fromID, fromName, message); 1139 onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message);
1216 } 1140 }
1217 } 1141 }
1218} 1142}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index b671aec..ad75ea5 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -163,13 +163,6 @@ namespace OpenSim.Region.CoreModules.World.Land
163 m_scene.UnregisterModuleCommander(m_commander.Name); 163 m_scene.UnregisterModuleCommander(m_commander.Name);
164 } 164 }
165 165
166// private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
167// {
168// ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
169// reason = "You are not allowed to enter this sim.";
170// return nearestParcel != null;
171// }
172
173 /// <summary> 166 /// <summary>
174 /// Processes commandline input. Do not call directly. 167 /// Processes commandline input. Do not call directly.
175 /// </summary> 168 /// </summary>
@@ -364,31 +357,7 @@ namespace OpenSim.Region.CoreModules.World.Land
364 } 357 }
365 358
366 if (parcelAvatarIsEntering != null) 359 if (parcelAvatarIsEntering != null)
367 { 360 EnforceBans(parcelAvatarIsEntering, avatar);
368 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
369 {
370 if (parcelAvatarIsEntering.IsEitherBannedOrRestricted(avatar.UUID))
371 {
372 SendYouAreBannedNotice(avatar);
373 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
374 //ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
375 }
376 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
377 {
378 SendYouAreRestrictedNotice(avatar);
379 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
380 //ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
381 }
382 else
383 {
384 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
385 }
386 }
387 else
388 {
389 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
390 }
391 }
392 } 361 }
393 } 362 }
394 363
@@ -460,32 +429,7 @@ namespace OpenSim.Region.CoreModules.World.Land
460 SendOutNearestBanLine(remote_client); 429 SendOutNearestBanLine(remote_client);
461 ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); 430 ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
462 if (parcel != null) 431 if (parcel != null)
463 { 432 EnforceBans(parcel, clientAvatar);
464 if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
465 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown)
466 {
467 EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID,
468 m_scene.RegionInfo.RegionID);
469 //They are going under the safety line!
470 if (!parcel.IsBannedFromLand(clientAvatar.UUID))
471 {
472 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false;
473 }
474 }
475 else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
476 parcel.IsBannedFromLand(clientAvatar.UUID))
477 {
478 // SendYouAreBannedNotice(clientAvatar);
479 //ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
480 ForceAvatarToPosition(clientAvatar, clientAvatar.lastKnownAllowedPosition);
481 }
482 else if (parcel.IsRestrictedFromLand(clientAvatar.UUID))
483 {
484 // SendYouAreRestrictedNotice(clientAvatar);
485 //ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
486 ForceAvatarToPosition(clientAvatar, clientAvatar.lastKnownAllowedPosition);
487 }
488 }
489 } 433 }
490 } 434 }
491 435
@@ -2005,5 +1949,27 @@ namespace OpenSim.Region.CoreModules.World.Land
2005 1949
2006 MainConsole.Instance.Output(report.ToString()); 1950 MainConsole.Instance.Output(report.ToString());
2007 } 1951 }
1952
1953 public void EnforceBans(ILandObject land, ScenePresence avatar)
1954 {
1955 if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
1956 return;
1957
1958 if (land.IsEitherBannedOrRestricted(avatar.UUID))
1959 {
1960 if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
1961 {
1962 Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
1963 if (pos == null)
1964 m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
1965 else
1966 ForceAvatarToPosition(avatar, (Vector3)pos);
1967 }
1968 else
1969 {
1970 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
1971 }
1972 }
1973 }
2008 } 1974 }
2009} 1975}
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
index 071314a..aa14054 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
@@ -188,17 +188,17 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
188 } 188 }
189 catch (DllNotFoundException) 189 catch (DllNotFoundException)
190 { 190 {
191 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is emtpy for {0}", id); 191 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id);
192 192
193 } 193 }
194 catch (IndexOutOfRangeException) 194 catch (IndexOutOfRangeException)
195 { 195 {
196 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id); 196 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
197 197
198 } 198 }
199 catch (Exception) 199 catch (Exception)
200 { 200 {
201 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id); 201 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
202 202
203 } 203 }
204 return null; 204 return null;
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index 7c5d044..898ca4a 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -50,7 +50,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
50using OSDArray = OpenMetaverse.StructuredData.OSDArray; 50using OSDArray = OpenMetaverse.StructuredData.OSDArray;
51using OSDMap = OpenMetaverse.StructuredData.OSDMap; 51using OSDMap = OpenMetaverse.StructuredData.OSDMap;
52 52
53namespace OpenSim.Region.CoreModules.Media.Moap 53namespace OpenSim.Region.CoreModules.World.Media.Moap
54{ 54{
55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")] 55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")]
56 public class MoapModule : INonSharedRegionModule, IMoapModule 56 public class MoapModule : INonSharedRegionModule, IMoapModule
@@ -225,24 +225,62 @@ namespace OpenSim.Region.CoreModules.Media.Moap
225 return me; 225 return me;
226 } 226 }
227 227
228 /// <summary>
229 /// Set the media entry on the face of the given part.
230 /// </summary>
231 /// <param name="part">/param>
232 /// <param name="face"></param>
233 /// <param name="me">If null, then the media entry is cleared.</param>
228 public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) 234 public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
229 { 235 {
236// m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face);
237
230 CheckFaceParam(part, face); 238 CheckFaceParam(part, face);
231 239
232 if (null == part.Shape.Media) 240 if (null == part.Shape.Media)
233 part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); 241 {
234 242 if (me == null)
243 return;
244 else
245 part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
246 }
247
235 lock (part.Shape.Media) 248 lock (part.Shape.Media)
236 part.Shape.Media[face] = me; 249 part.Shape.Media[face] = me;
237 250
238 UpdateMediaUrl(part, UUID.Zero); 251 UpdateMediaUrl(part, UUID.Zero);
252
253 SetPartMediaFlags(part, face, me != null);
254
239 part.ScheduleFullUpdate(); 255 part.ScheduleFullUpdate();
240 part.TriggerScriptChangedEvent(Changed.MEDIA); 256 part.TriggerScriptChangedEvent(Changed.MEDIA);
241 } 257 }
242 258
259 /// <summary>
260 /// Clear the media entry from the face of the given part.
261 /// </summary>
262 /// <param name="part"></param>
263 /// <param name="face"></param>
243 public void ClearMediaEntry(SceneObjectPart part, int face) 264 public void ClearMediaEntry(SceneObjectPart part, int face)
244 { 265 {
245 SetMediaEntry(part, face, null); 266 SetMediaEntry(part, face, null);
267 }
268
269 /// <summary>
270 /// Set the media flags on the texture face of the given part.
271 /// </summary>
272 /// <remarks>
273 /// The fact that we need a separate function to do what should be a simple one line operation is BUTT UGLY.
274 /// </remarks>
275 /// <param name="part"></param>
276 /// <param name="face"></param>
277 /// <param name="flag"></param>
278 protected void SetPartMediaFlags(SceneObjectPart part, int face, bool flag)
279 {
280 Primitive.TextureEntry te = part.Shape.Textures;
281 Primitive.TextureEntryFace teFace = te.CreateFace((uint)face);
282 teFace.MediaFlags = flag;
283 part.Shape.Textures = te;
246 } 284 }
247 285
248 /// <summary> 286 /// <summary>
@@ -333,7 +371,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
333 } 371 }
334 372
335// m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId); 373// m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId);
336 374//
337// for (int i = 0; i < omu.FaceMedia.Length; i++) 375// for (int i = 0; i < omu.FaceMedia.Length; i++)
338// { 376// {
339// MediaEntry me = omu.FaceMedia[i]; 377// MediaEntry me = omu.FaceMedia[i];
@@ -368,10 +406,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
368 // FIXME: Race condition here since some other texture entry manipulator may overwrite/get 406 // FIXME: Race condition here since some other texture entry manipulator may overwrite/get
369 // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry 407 // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry
370 // directly. 408 // directly.
371 Primitive.TextureEntry te = part.Shape.Textures; 409 SetPartMediaFlags(part, i, true);
372 Primitive.TextureEntryFace face = te.CreateFace((uint)i);
373 face.MediaFlags = true;
374 part.Shape.Textures = te;
375// m_log.DebugFormat( 410// m_log.DebugFormat(
376// "[MOAP]: Media flags for face {0} is {1}", 411// "[MOAP]: Media flags for face {0} is {1}",
377// i, part.Shape.Textures.FaceTextures[i].MediaFlags); 412// i, part.Shape.Textures.FaceTextures[i].MediaFlags);
@@ -380,6 +415,8 @@ namespace OpenSim.Region.CoreModules.Media.Moap
380 } 415 }
381 else 416 else
382 { 417 {
418// m_log.DebugFormat("[MOAP]: Setting existing media list for {0}", part.Name);
419
383 // We need to go through the media textures one at a time to make sure that we have permission 420 // We need to go through the media textures one at a time to make sure that we have permission
384 // to change them 421 // to change them
385 422
@@ -401,8 +438,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
401 if (null == media[i]) 438 if (null == media[i])
402 continue; 439 continue;
403 440
404 Primitive.TextureEntryFace face = te.CreateFace((uint)i); 441 SetPartMediaFlags(part, i, true);
405 face.MediaFlags = true;
406 442
407 // m_log.DebugFormat( 443 // m_log.DebugFormat(
408 // "[MOAP]: Media flags for face {0} is {1}", 444 // "[MOAP]: Media flags for face {0} is {1}",
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
new file mode 100644
index 0000000..5b85830
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
@@ -0,0 +1,102 @@
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.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using log4net.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Assets;
37using OpenSim.Framework;
38using OpenSim.Region.CoreModules.World.Media.Moap;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.Framework.Scenes.Serialization;
41using OpenSim.Tests.Common;
42using OpenSim.Tests.Common.Mock;
43using OpenSim.Tests.Common.Setup;
44
45namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
46{
47 [TestFixture]
48 public class MoapTests
49 {
50 protected TestScene m_scene;
51 protected MoapModule m_module;
52
53 [SetUp]
54 public void SetUp()
55 {
56 m_module = new MoapModule();
57 m_scene = SceneSetupHelpers.SetupScene();
58 SceneSetupHelpers.SetupSceneModules(m_scene, m_module);
59 }
60
61 [Test]
62 public void TestClearMediaUrl()
63 {
64 TestHelper.InMethod();
65// log4net.Config.XmlConfigurator.Configure();
66
67 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
68 MediaEntry me = new MediaEntry();
69
70 m_module.SetMediaEntry(part, 1, me);
71 m_module.ClearMediaEntry(part, 1);
72
73 Assert.That(part.Shape.Media[1], Is.EqualTo(null));
74
75 // Although we've cleared one face, other faces may still be present. So we need to check for an
76 // update media url version
77 Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000001/" + UUID.Zero));
78
79 // By changing media flag to false, the face texture once again becomes identical to the DefaultTexture.
80 // Therefore, when libOMV reserializes it, it disappears and we are left with no face texture in this slot.
81 // Not at all confusing, eh?
82 Assert.That(part.Shape.Textures.FaceTextures[1], Is.Null);
83 }
84
85 [Test]
86 public void TestSetMediaUrl()
87 {
88 TestHelper.InMethod();
89
90 string homeUrl = "opensimulator.org";
91
92 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
93 MediaEntry me = new MediaEntry() { HomeURL = homeUrl };
94
95 m_module.SetMediaEntry(part, 1, me);
96
97 Assert.That(part.Shape.Media[1].HomeURL, Is.EqualTo(homeUrl));
98 Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero));
99 Assert.That(part.Shape.Textures.FaceTextures[1].MediaFlags, Is.True);
100 }
101 }
102} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index f9b2384..a098ff6 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -642,7 +642,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
642 /// implemented by callers. 642 /// implemented by callers.
643 /// </summary> 643 /// </summary>
644 /// <param name="currentUser"></param> 644 /// <param name="currentUser"></param>
645 /// <param name="objId"></param> 645 /// <param name="objId">This is a scene object group UUID</param>
646 /// <param name="denyOnLocked"></param> 646 /// <param name="denyOnLocked"></param>
647 /// <returns></returns> 647 /// <returns></returns>
648 protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked) 648 protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked)
@@ -1896,7 +1896,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1896// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}", 1896// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}",
1897// agentID, primID, face, me.ControlPermissions); 1897// agentID, primID, face, me.ControlPermissions);
1898 1898
1899 return GenericPrimMediaPermission(part, agentID, me.ControlPermissions); 1899 return GenericObjectPermission(agentID, part.ParentGroup.UUID, true);
1900 } 1900 }
1901 1901
1902 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) 1902 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face)
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
index f10e848..dafaa0c 100644
--- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
+++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
@@ -30,7 +30,6 @@ using System.IO;
30using System.Xml; 30using System.Xml;
31using log4net.Config; 31using log4net.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using OpenSim.Framework; 34using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 334dcb0..282e4f1 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
113 data = new MapBlockData(); 113 data = new MapBlockData();
114 data.Agents = 0; 114 data.Agents = 0;
115 data.Access = info.Access; 115 data.Access = info.Access;
116 data.MapImageId = info.TerrainImage; 116 data.MapImageId = UUID.Zero; // could use info.TerrainImage but it seems to break viewer2
117 data.Name = info.RegionName; 117 data.Name = info.RegionName;
118 data.RegionFlags = 0; // TODO not used? 118 data.RegionFlags = 0; // TODO not used?
119 data.WaterHeight = 0; // not used 119 data.WaterHeight = 0; // not used
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index e0f36a2..b05aef8 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -764,10 +764,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
764 764
765 if (!responseMap.ContainsKey(itemtype.ToString())) // remote sim doesnt have the stated region handle 765 if (!responseMap.ContainsKey(itemtype.ToString())) // remote sim doesnt have the stated region handle
766 { 766 {
767 if (!m_blacklistedregions.ContainsKey(regionhandle)) 767 m_log.DebugFormat("[WORLD MAP]: Remote sim does not have the stated region. Blacklisting.");
768 lock (m_blacklistedregions)
768 { 769 {
769 m_log.DebugFormat("[WORLD MAP]: Remote sim does not have the stated region. Blacklisting."); 770 if (!m_blacklistedregions.ContainsKey(regionhandle))
770 m_blacklistedregions.Add(regionhandle, Environment.TickCount); 771 m_blacklistedregions.Add(regionhandle, Environment.TickCount);
771 } 772 }
772 } 773 }
773 774
@@ -1055,7 +1056,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1055 } 1056 }
1056 else 1057 else
1057 { 1058 {
1058 OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); 1059 OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount());
1059 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 1060 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
1060 { 1061 {
1061 OSDMap responsemapdata = new OSDMap(); 1062 OSDMap responsemapdata = new OSDMap();
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
index c850f7f..72e79ed 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
@@ -32,7 +32,7 @@ namespace OpenSim.Region.Framework.Interfaces
32 public delegate void ChangeDelegate(UUID regionID); 32 public delegate void ChangeDelegate(UUID regionID);
33 public delegate void MessageDelegate(UUID regionID, UUID fromID, string fromName, string message); 33 public delegate void MessageDelegate(UUID regionID, UUID fromID, string fromName, string message);
34 34
35 public interface IEstateModule : IRegionModule 35 public interface IEstateModule
36 { 36 {
37 event ChangeDelegate OnRegionInfoChange; 37 event ChangeDelegate OnRegionInfoChange;
38 event ChangeDelegate OnEstateInfoChange; 38 event ChangeDelegate OnEstateInfoChange;
@@ -45,5 +45,7 @@ namespace OpenSim.Region.Framework.Interfaces
45 /// Tell all clients about the current state of the region (terrain textures, water height, etc.). 45 /// Tell all clients about the current state of the region (terrain textures, water height, etc.).
46 /// </summary> 46 /// </summary>
47 void sendRegionHandshakeToAll(); 47 void sendRegionHandshakeToAll();
48 void TriggerEstateInfoChange();
49 void TriggerRegionInfoChange();
48 } 50 }
49} 51}
diff --git a/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs b/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs
index 7251d57..2397f22 100644
--- a/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs
@@ -36,5 +36,6 @@ namespace OpenSim.Region.Framework.Interfaces
36 void Close(); 36 void Close();
37 void QueuePartForUpdate(SceneObjectPart part); 37 void QueuePartForUpdate(SceneObjectPart part);
38 void SendPrimUpdates(); 38 void SendPrimUpdates();
39 int GetPendingObjectsCount();
39 } 40 }
40} 41}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 9a93a26..bc892e0 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -303,6 +303,8 @@ namespace OpenSim.Region.Framework.Scenes
303 // Passing something to another avatar or a an object will already 303 // Passing something to another avatar or a an object will already
304 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 304 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
305 item = InventoryService.GetItem(item); 305 item = InventoryService.GetItem(item);
306 if (item.Owner != remoteClient.AgentId)
307 return;
306 308
307 if (item != null) 309 if (item != null)
308 { 310 {
@@ -1227,6 +1229,10 @@ namespace OpenSim.Region.Framework.Scenes
1227 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) 1229 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0))
1228 return; 1230 return;
1229 1231
1232 bool overrideNoMod = false;
1233 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1234 overrideNoMod = true;
1235
1230 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) 1236 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1231 { 1237 {
1232 // object cannot copy items to an object owned by a different owner 1238 // object cannot copy items to an object owned by a different owner
@@ -1236,7 +1242,7 @@ namespace OpenSim.Region.Framework.Scenes
1236 } 1242 }
1237 1243
1238 // must have both move and modify permission to put an item in an object 1244 // must have both move and modify permission to put an item in an object
1239 if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) 1245 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1240 { 1246 {
1241 return; 1247 return;
1242 } 1248 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2424194..e5c0f38 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -64,6 +64,8 @@ namespace OpenSim.Region.Framework.Scenes
64 64
65 #region Fields 65 #region Fields
66 66
67 public bool EmergencyMonitoring = false;
68
67 public SynchronizeSceneHandler SynchronizeScene; 69 public SynchronizeSceneHandler SynchronizeScene;
68 public SimStatsReporter StatsReporter; 70 public SimStatsReporter StatsReporter;
69 public List<Border> NorthBorders = new List<Border>(); 71 public List<Border> NorthBorders = new List<Border>();
@@ -81,6 +83,13 @@ namespace OpenSim.Region.Framework.Scenes
81 public bool m_useFlySlow; 83 public bool m_useFlySlow;
82 public bool m_usePreJump; 84 public bool m_usePreJump;
83 public bool m_seeIntoRegionFromNeighbor; 85 public bool m_seeIntoRegionFromNeighbor;
86
87 protected float m_defaultDrawDistance = 255.0f;
88 public float DefaultDrawDistance
89 {
90 get { return m_defaultDrawDistance; }
91 }
92
84 // TODO: need to figure out how allow client agents but deny 93 // TODO: need to figure out how allow client agents but deny
85 // root agents when ACL denies access to root agent 94 // root agents when ACL denies access to root agent
86 public bool m_strictAccessControl = true; 95 public bool m_strictAccessControl = true;
@@ -129,7 +138,16 @@ namespace OpenSim.Region.Framework.Scenes
129 protected ICapabilitiesModule m_capsModule; 138 protected ICapabilitiesModule m_capsModule;
130 // Central Update Loop 139 // Central Update Loop
131 protected int m_fps = 10; 140 protected int m_fps = 10;
132 protected uint m_frame; 141
142 /// <summary>
143 /// Current scene frame number
144 /// </summary>
145 public uint Frame
146 {
147 get;
148 protected set;
149 }
150
133 protected float m_timespan = 0.089f; 151 protected float m_timespan = 0.089f;
134 protected DateTime m_lastupdate = DateTime.UtcNow; 152 protected DateTime m_lastupdate = DateTime.UtcNow;
135 153
@@ -638,6 +656,8 @@ namespace OpenSim.Region.Framework.Scenes
638 // 656 //
639 IConfig startupConfig = m_config.Configs["Startup"]; 657 IConfig startupConfig = m_config.Configs["Startup"];
640 658
659 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
660
641 //Animation states 661 //Animation states
642 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 662 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
643 // TODO: Change default to true once the feature is supported 663 // TODO: Change default to true once the feature is supported
@@ -1209,7 +1229,8 @@ namespace OpenSim.Region.Framework.Scenes
1209 1229
1210 try 1230 try
1211 { 1231 {
1212 Update(); 1232 while (!shuttingdown)
1233 Update();
1213 } 1234 }
1214 catch (ThreadAbortException) 1235 catch (ThreadAbortException)
1215 { 1236 {
@@ -1223,190 +1244,180 @@ namespace OpenSim.Region.Framework.Scenes
1223 Watchdog.RemoveThread(); 1244 Watchdog.RemoveThread();
1224 } 1245 }
1225 1246
1226 /// <summary>
1227 /// Performs per-frame updates on the scene, this should be the central scene loop
1228 /// </summary>
1229 public override void Update() 1247 public override void Update()
1230 { 1248 {
1231 float physicsFPS; 1249 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
1232 int maintc; 1250 float physicsFPS = 0f;
1233 1251
1234 while (!shuttingdown) 1252 int maintc = Util.EnvironmentTickCount();
1253 int tmpFrameMS = maintc;
1254 tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1255
1256 // Increment the frame counter
1257 ++Frame;
1258
1259 try
1235 { 1260 {
1236 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; 1261 // Check if any objects have reached their targets
1237 physicsFPS = 0f; 1262 CheckAtTargets();
1238 1263
1239 maintc = Util.EnvironmentTickCount(); 1264 // Update SceneObjectGroups that have scheduled themselves for updates
1240 int tmpFrameMS = maintc; 1265 // Objects queue their updates onto all scene presences
1241 tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; 1266 if (Frame % m_update_objects == 0)
1267 m_sceneGraph.UpdateObjectGroups();
1242 1268
1243 // Increment the frame counter 1269 // Run through all ScenePresences looking for updates
1244 ++m_frame; 1270 // Presence updates and queued object updates for each presence are sent to clients
1271 if (Frame % m_update_presences == 0)
1272 m_sceneGraph.UpdatePresences();
1245 1273
1246 try 1274 // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
1275 if (Frame % m_update_coarse_locations == 0)
1247 { 1276 {
1248 // Check if any objects have reached their targets 1277 List<Vector3> coarseLocations;
1249 CheckAtTargets(); 1278 List<UUID> avatarUUIDs;
1250 1279 SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
1251 // Update SceneObjectGroups that have scheduled themselves for updates 1280 // Send coarse locations to clients
1252 // Objects queue their updates onto all scene presences 1281 ForEachScenePresence(delegate(ScenePresence presence)
1253 if (m_frame % m_update_objects == 0) 1282 {
1254 m_sceneGraph.UpdateObjectGroups(); 1283 presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
1284 });
1285 }
1255 1286
1256 // Run through all ScenePresences looking for updates 1287 int tmpPhysicsMS2 = Util.EnvironmentTickCount();
1257 // Presence updates and queued object updates for each presence are sent to clients 1288 if ((Frame % m_update_physics == 0) && m_physics_enabled)
1258 if (m_frame % m_update_presences == 0) 1289 m_sceneGraph.UpdatePreparePhysics();
1259 m_sceneGraph.UpdatePresences(); 1290 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2);
1260 1291
1261 // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client) 1292 // Apply any pending avatar force input to the avatar's velocity
1262 if (m_frame % m_update_coarse_locations == 0) 1293 if (Frame % m_update_entitymovement == 0)
1263 { 1294 m_sceneGraph.UpdateScenePresenceMovement();
1264 List<Vector3> coarseLocations;
1265 List<UUID> avatarUUIDs;
1266 SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
1267 // Send coarse locations to clients
1268 ForEachScenePresence(delegate(ScenePresence presence)
1269 {
1270 presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
1271 });
1272 }
1273 1295
1274 int tmpPhysicsMS2 = Util.EnvironmentTickCount(); 1296 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1275 if ((m_frame % m_update_physics == 0) && m_physics_enabled) 1297 // velocity
1276 m_sceneGraph.UpdatePreparePhysics(); 1298 int tmpPhysicsMS = Util.EnvironmentTickCount();
1277 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); 1299 if (Frame % m_update_physics == 0)
1300 {
1301 if (m_physics_enabled)
1302 physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan));
1303 if (SynchronizeScene != null)
1304 SynchronizeScene(this);
1305 }
1306 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
1278 1307
1279 // Apply any pending avatar force input to the avatar's velocity 1308 // Delete temp-on-rez stuff
1280 if (m_frame % m_update_entitymovement == 0) 1309 if (Frame % 1000 == 0 && !m_cleaningTemps)
1281 m_sceneGraph.UpdateScenePresenceMovement(); 1310 {
1311 int tmpTempOnRezMS = Util.EnvironmentTickCount();
1312 m_cleaningTemps = true;
1313 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
1314 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
1315 }
1282 1316
1283 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1317 if (RegionStatus != RegionStatus.SlaveScene)
1284 // velocity 1318 {
1285 int tmpPhysicsMS = Util.EnvironmentTickCount(); 1319 if (Frame % m_update_events == 0)
1286 if (m_frame % m_update_physics == 0)
1287 { 1320 {
1288 if (m_physics_enabled) 1321 int evMS = Util.EnvironmentTickCount();
1289 physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); 1322 UpdateEvents();
1290 if (SynchronizeScene != null) 1323 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1291 SynchronizeScene(this);
1292 } 1324 }
1293 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
1294 1325
1295 // Delete temp-on-rez stuff 1326 if (Frame % m_update_backup == 0)
1296 if (m_frame % 1000 == 0 && !m_cleaningTemps)
1297 { 1327 {
1298 int tmpTempOnRezMS = Util.EnvironmentTickCount(); 1328 int backMS = Util.EnvironmentTickCount();
1299 m_cleaningTemps = true; 1329 UpdateStorageBackup();
1300 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1330 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1301 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
1302 } 1331 }
1303 1332
1304 if (RegionStatus != RegionStatus.SlaveScene) 1333 if (Frame % m_update_terrain == 0)
1305 { 1334 {
1306 if (m_frame % m_update_events == 0) 1335 int terMS = Util.EnvironmentTickCount();
1307 { 1336 UpdateTerrain();
1308 int evMS = Util.EnvironmentTickCount(); 1337 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1309 UpdateEvents();
1310 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1311 }
1312
1313 if (m_frame % m_update_backup == 0)
1314 {
1315 int backMS = Util.EnvironmentTickCount();
1316 UpdateStorageBackup();
1317 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1318 }
1319
1320 if (m_frame % m_update_terrain == 0)
1321 {
1322 int terMS = Util.EnvironmentTickCount();
1323 UpdateTerrain();
1324 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1325 }
1326
1327 if (m_frame % m_update_land == 0)
1328 {
1329 int ldMS = Util.EnvironmentTickCount();
1330 UpdateLand();
1331 landMS = Util.EnvironmentTickCountSubtract(ldMS);
1332 }
1333
1334 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1335 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1336 lastCompletedFrame = Util.EnvironmentTickCount();
1337
1338 // if (m_frame%m_update_avatars == 0)
1339 // UpdateInWorldTime();
1340 StatsReporter.AddPhysicsFPS(physicsFPS);
1341 StatsReporter.AddTimeDilation(TimeDilation);
1342 StatsReporter.AddFPS(1);
1343 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1344 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1345 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1346 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1347 StatsReporter.addFrameMS(frameMS);
1348 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1349 StatsReporter.addOtherMS(otherMS);
1350 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1351 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1352 } 1338 }
1353 1339
1354 if (LoginsDisabled && m_frame == 20) 1340 if (Frame % m_update_land == 0)
1355 { 1341 {
1356 // In 99.9% of cases it is a bad idea to manually force garbage collection. However, 1342 int ldMS = Util.EnvironmentTickCount();
1357 // this is a rare case where we know we have just went through a long cycle of heap 1343 UpdateLand();
1358 // allocations, and there is no more work to be done until someone logs in 1344 landMS = Util.EnvironmentTickCountSubtract(ldMS);
1359 GC.Collect(); 1345 }
1360 1346
1361 IConfig startupConfig = m_config.Configs["Startup"]; 1347 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1362 if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) 1348 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1363 { 1349 lastCompletedFrame = Util.EnvironmentTickCount();
1364 m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); 1350
1365 LoginsDisabled = false; 1351 // if (Frame%m_update_avatars == 0)
1366 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1352 // UpdateInWorldTime();
1367 } 1353 StatsReporter.AddPhysicsFPS(physicsFPS);
1354 StatsReporter.AddTimeDilation(TimeDilation);
1355 StatsReporter.AddFPS(1);
1356 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1357 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1358 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1359 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1360 StatsReporter.addFrameMS(frameMS);
1361 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1362 StatsReporter.addOtherMS(otherMS);
1363 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1364 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1365 }
1366
1367 if (LoginsDisabled && Frame == 20)
1368 {
1369 // In 99.9% of cases it is a bad idea to manually force garbage collection. However,
1370 // this is a rare case where we know we have just went through a long cycle of heap
1371 // allocations, and there is no more work to be done until someone logs in
1372 GC.Collect();
1373
1374 IConfig startupConfig = m_config.Configs["Startup"];
1375 if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false))
1376 {
1377 m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
1378 LoginsDisabled = false;
1379 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
1368 } 1380 }
1369 } 1381 }
1370 catch (NotImplementedException) 1382 }
1371 { 1383 catch (NotImplementedException)
1372 throw; 1384 {
1373 } 1385 throw;
1374 catch (AccessViolationException e) 1386 }
1375 { 1387 catch (AccessViolationException e)
1376 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1388 {
1377 } 1389 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1378 //catch (NullReferenceException e) 1390 }
1379 //{ 1391 //catch (NullReferenceException e)
1380 // m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1392 //{
1381 //} 1393 // m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1382 catch (InvalidOperationException e) 1394 //}
1383 { 1395 catch (InvalidOperationException e)
1384 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1396 {
1385 } 1397 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1386 catch (Exception e) 1398 }
1387 { 1399 catch (Exception e)
1388 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1400 {
1389 } 1401 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1390 finally 1402 }
1391 { 1403 finally
1392 m_lastupdate = DateTime.UtcNow; 1404 {
1393 } 1405 m_lastupdate = DateTime.UtcNow;
1406 }
1394 1407
1395 maintc = Util.EnvironmentTickCountSubtract(maintc); 1408 maintc = Util.EnvironmentTickCountSubtract(maintc);
1396 maintc = (int)(m_timespan * 1000) - maintc; 1409 maintc = (int)(m_timespan * 1000) - maintc;
1397 1410
1398 if (maintc > 0)
1399 Thread.Sleep(maintc);
1400 1411
1401 // Tell the watchdog that this thread is still alive 1412 m_lastUpdate = Util.EnvironmentTickCount();
1402 Watchdog.UpdateThread(); 1413 m_firstHeartbeat = false;
1403 1414
1404 m_lastUpdate = Util.EnvironmentTickCount(); 1415 if (maintc > 0)
1405 m_firstHeartbeat = false; 1416 Thread.Sleep(maintc);
1406 }
1407 }
1408 1417
1409 1418 // Tell the watchdog that this thread is still alive
1419 Watchdog.UpdateThread();
1420 }
1410 1421
1411 public void AddGroupTarget(SceneObjectGroup grp) 1422 public void AddGroupTarget(SceneObjectGroup grp)
1412 { 1423 {
@@ -3125,7 +3136,9 @@ namespace OpenSim.Region.Framework.Scenes
3125 (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); 3136 (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName);
3126 3137
3127 m_sceneGraph.removeUserCount(!childagentYN); 3138 m_sceneGraph.removeUserCount(!childagentYN);
3128 CapsModule.RemoveCapsHandler(agentID); 3139
3140 if (CapsModule != null)
3141 CapsModule.RemoveCapsHandler(agentID);
3129 3142
3130 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever 3143 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3131 // this method is doing is HORRIBLE!!! 3144 // this method is doing is HORRIBLE!!!
@@ -3329,7 +3342,7 @@ namespace OpenSim.Region.Framework.Scenes
3329 // TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport 3342 // TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport
3330 3343
3331 // Don't disable this log message - it's too helpful 3344 // Don't disable this log message - it's too helpful
3332 m_log.InfoFormat( 3345 m_log.DebugFormat(
3333 "[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6})", 3346 "[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6})",
3334 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3347 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
3335 agent.AgentID, agent.circuitcode, teleportFlags); 3348 agent.AgentID, agent.circuitcode, teleportFlags);
@@ -3403,8 +3416,11 @@ namespace OpenSim.Region.Framework.Scenes
3403 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3416 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
3404 agent.AgentID, agent.circuitcode); 3417 agent.AgentID, agent.circuitcode);
3405 3418
3406 CapsModule.NewUserConnection(agent); 3419 if (CapsModule != null)
3407 CapsModule.AddCapsHandler(agent.AgentID); 3420 {
3421 CapsModule.NewUserConnection(agent);
3422 CapsModule.AddCapsHandler(agent.AgentID);
3423 }
3408 } 3424 }
3409 else 3425 else
3410 { 3426 {
@@ -3419,7 +3435,9 @@ namespace OpenSim.Region.Framework.Scenes
3419 agent.AgentID, RegionInfo.RegionName); 3435 agent.AgentID, RegionInfo.RegionName);
3420 3436
3421 sp.AdjustKnownSeeds(); 3437 sp.AdjustKnownSeeds();
3422 CapsModule.NewUserConnection(agent); 3438
3439 if (CapsModule != null)
3440 CapsModule.NewUserConnection(agent);
3423 } 3441 }
3424 } 3442 }
3425 3443
@@ -3506,6 +3524,8 @@ namespace OpenSim.Region.Framework.Scenes
3506 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) 3524 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3507 { 3525 {
3508 reason = String.Empty; 3526 reason = String.Empty;
3527 if (Permissions.IsGod(agentID))
3528 return true;
3509 3529
3510 ILandObject land = LandChannel.GetLandObject(posX, posY); 3530 ILandObject land = LandChannel.GetLandObject(posX, posY);
3511 if (land == null) 3531 if (land == null)
@@ -3931,15 +3951,15 @@ namespace OpenSim.Region.Framework.Scenes
3931 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, 3951 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
3932 Vector3 lookat, uint teleportFlags) 3952 Vector3 lookat, uint teleportFlags)
3933 { 3953 {
3934 GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName); 3954 List<GridRegion> regions = GridService.GetRegionsByName(RegionInfo.ScopeID, regionName, 1);
3935 if (regionInfo == null) 3955 if (regions == null || regions.Count == 0)
3936 { 3956 {
3937 // can't find the region: Tell viewer and abort 3957 // can't find the region: Tell viewer and abort
3938 remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found."); 3958 remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found.");
3939 return; 3959 return;
3940 } 3960 }
3941 3961
3942 RequestTeleportLocation(remoteClient, regionInfo.RegionHandle, position, lookat, teleportFlags); 3962 RequestTeleportLocation(remoteClient, regions[0].RegionHandle, position, lookat, teleportFlags);
3943 } 3963 }
3944 3964
3945 /// <summary> 3965 /// <summary>
@@ -5143,9 +5163,15 @@ namespace OpenSim.Region.Framework.Scenes
5143 // from logging into the region, teleporting into the region 5163 // from logging into the region, teleporting into the region
5144 // or corssing the broder walking, but will NOT prevent 5164 // or corssing the broder walking, but will NOT prevent
5145 // child agent creation, thereby emulating the SL behavior. 5165 // child agent creation, thereby emulating the SL behavior.
5146 public bool QueryAccess(UUID agentID, Vector3 position) 5166 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5147 { 5167 {
5148 string reason; 5168 reason = "You are banned from the region";
5169
5170 if (Permissions.IsGod(agentID))
5171 {
5172 reason = String.Empty;
5173 return true;
5174 }
5149 5175
5150 if (!AuthorizeUser(agentID, out reason)) 5176 if (!AuthorizeUser(agentID, out reason))
5151 { 5177 {
@@ -5176,6 +5202,8 @@ namespace OpenSim.Region.Framework.Scenes
5176 if (banned || restricted) 5202 if (banned || restricted)
5177 return false; 5203 return false;
5178 } 5204 }
5205
5206 reason = String.Empty;
5179 return true; 5207 return true;
5180 } 5208 }
5181 } 5209 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index c8af4c3..19cb0c1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -189,7 +189,8 @@ namespace OpenSim.Region.Framework.Scenes
189 } 189 }
190 } 190 }
191 191
192 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, UUID scopeID, ulong regionHandle); 192 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, UUID scopeID, GridRegion dest);
193
193 194
194 /// <summary> 195 /// <summary>
195 /// This informs all neighboring regions about the settings of it's child agent. 196 /// This informs all neighboring regions about the settings of it's child agent.
@@ -198,31 +199,17 @@ namespace OpenSim.Region.Framework.Scenes
198 /// This contains information, such as, Draw Distance, Camera location, Current Position, Current throttle settings, etc. 199 /// This contains information, such as, Draw Distance, Camera location, Current Position, Current throttle settings, etc.
199 /// 200 ///
200 /// </summary> 201 /// </summary>
201 private void SendChildAgentDataUpdateAsync(AgentPosition cAgentData, UUID scopeID, ulong regionHandle) 202 private void SendChildAgentDataUpdateAsync(AgentPosition cAgentData, UUID scopeID, GridRegion dest)
202 { 203 {
203 //m_log.Info("[INTERGRID]: Informing neighbors about my agent in " + m_regionInfo.RegionName); 204 //m_log.Info("[INTERGRID]: Informing neighbors about my agent in " + m_regionInfo.RegionName);
204 try 205 try
205 { 206 {
206 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); 207 m_scene.SimulationService.UpdateAgent(dest, cAgentData);
207 uint x = 0, y = 0;
208 Utils.LongToUInts(regionHandle, out x, out y);
209 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
210 m_scene.SimulationService.UpdateAgent(destination, cAgentData);
211 } 208 }
212 catch 209 catch
213 { 210 {
214 // Ignore; we did our best 211 // Ignore; we did our best
215 } 212 }
216
217 //if (regionAccepted)
218 //{
219 // //m_log.Info("[INTERGRID]: Completed sending a neighbor an update about my agent");
220 //}
221 //else
222 //{
223 // //m_log.Info("[INTERGRID]: Failed sending a neighbor an update about my agent");
224 //}
225
226 } 213 }
227 214
228 private void SendChildAgentDataUpdateCompleted(IAsyncResult iar) 215 private void SendChildAgentDataUpdateCompleted(IAsyncResult iar)
@@ -236,14 +223,28 @@ namespace OpenSim.Region.Framework.Scenes
236 // This assumes that we know what our neighbors are. 223 // This assumes that we know what our neighbors are.
237 try 224 try
238 { 225 {
226 uint x = 0, y = 0;
227 List<string> simulatorList = new List<string>();
239 foreach (ulong regionHandle in presence.KnownChildRegionHandles) 228 foreach (ulong regionHandle in presence.KnownChildRegionHandles)
240 { 229 {
241 if (regionHandle != m_regionInfo.RegionHandle) 230 if (regionHandle != m_regionInfo.RegionHandle)
242 { 231 {
243 SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync; 232 // we only want to send one update to each simulator; the simulator will
244 d.BeginInvoke(cAgentData, m_regionInfo.ScopeID, regionHandle, 233 // hand it off to the regions where a child agent exists, this does assume
245 SendChildAgentDataUpdateCompleted, 234 // that the region position is cached or performance will degrade
246 d); 235 Utils.LongToUInts(regionHandle, out x, out y);
236 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
237 if (! simulatorList.Contains(dest.ServerURI))
238 {
239 // we havent seen this simulator before, add it to the list
240 // and send it an update
241 simulatorList.Add(dest.ServerURI);
242
243 SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync;
244 d.BeginInvoke(cAgentData, m_regionInfo.ScopeID, dest,
245 SendChildAgentDataUpdateCompleted,
246 d);
247 }
247 } 248 }
248 } 249 }
249 } 250 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 92fe2ab..e8cf4f4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -218,9 +218,10 @@ namespace OpenSim.Region.Framework.Scenes
218 for (int i = 0; i < Math.Min(presences.Count, maxLocations); ++i) 218 for (int i = 0; i < Math.Min(presences.Count, maxLocations); ++i)
219 { 219 {
220 ScenePresence sp = presences[i]; 220 ScenePresence sp = presences[i];
221
221 // If this presence is a child agent, we don't want its coarse locations 222 // If this presence is a child agent, we don't want its coarse locations
222 if (sp.IsChildAgent) 223 if (sp.IsChildAgent)
223 return; 224 continue;
224 225
225 if (sp.ParentID != 0) 226 if (sp.ParentID != 0)
226 { 227 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 6496a25..9b9f280 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2093,8 +2093,9 @@ namespace OpenSim.Region.Framework.Scenes
2093 2093
2094 public void GetProperties(IClientAPI client) 2094 public void GetProperties(IClientAPI client)
2095 { 2095 {
2096 //Viewer wants date in microseconds so multiply it by 1,000,000.
2096 client.SendObjectPropertiesReply( 2097 client.SendObjectPropertiesReply(
2097 m_fromUserInventoryItemID, (ulong)_creationDate, _creatorID, UUID.Zero, UUID.Zero, 2098 m_fromUserInventoryItemID, (ulong)_creationDate*(ulong)1e6, _creatorID, UUID.Zero, UUID.Zero,
2098 _groupID, (short)InventorySerial, _lastOwnerID, UUID, _ownerID, 2099 _groupID, (short)InventorySerial, _lastOwnerID, UUID, _ownerID,
2099 ParentGroup.RootPart.TouchName, new byte[0], ParentGroup.RootPart.SitName, Name, Description, 2100 ParentGroup.RootPart.TouchName, new byte[0], ParentGroup.RootPart.SitName, Name, Description,
2100 ParentGroup.RootPart._ownerMask, ParentGroup.RootPart._nextOwnerMask, ParentGroup.RootPart._groupMask, ParentGroup.RootPart._everyoneMask, 2101 ParentGroup.RootPart._ownerMask, ParentGroup.RootPart._nextOwnerMask, ParentGroup.RootPart._groupMask, ParentGroup.RootPart._everyoneMask,
@@ -2141,7 +2142,7 @@ namespace OpenSim.Region.Framework.Scenes
2141 { 2142 {
2142 Quaternion newRot; 2143 Quaternion newRot;
2143 2144
2144 if (this.LinkNum < 2) //KF Single or root prim 2145 if (this.LinkNum == 0 || this.LinkNum == 1)
2145 { 2146 {
2146 newRot = RotationOffset; 2147 newRot = RotationOffset;
2147 } 2148 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 7e59b10..854f1dc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1287,9 +1287,13 @@ namespace OpenSim.Region.Framework.Scenes
1287 1287
1288 public Dictionary<UUID, string> GetScriptStates(bool oldIDs) 1288 public Dictionary<UUID, string> GetScriptStates(bool oldIDs)
1289 { 1289 {
1290 Dictionary<UUID, string> ret = new Dictionary<UUID, string>();
1291
1292 if (m_part.ParentGroup.Scene == null) // Group not in a scene
1293 return ret;
1294
1290 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 1295 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1291 1296
1292 Dictionary<UUID, string> ret = new Dictionary<UUID, string>();
1293 if (engines == null) // No engine at all 1297 if (engines == null) // No engine at all
1294 return ret; 1298 return ret;
1295 1299
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index b87275c..3a5b05d 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -123,7 +123,6 @@ namespace OpenSim.Region.Framework.Scenes
123 private SceneObjectGroup proxyObjectGroup; 123 private SceneObjectGroup proxyObjectGroup;
124 //private SceneObjectPart proxyObjectPart = null; 124 //private SceneObjectPart proxyObjectPart = null;
125 public Vector3 lastKnownAllowedPosition; 125 public Vector3 lastKnownAllowedPosition;
126 public bool sentMessageAboutRestrictedParcelFlyingDown;
127 public Vector4 CollisionPlane = Vector4.UnitW; 126 public Vector4 CollisionPlane = Vector4.UnitW;
128 127
129 private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation 128 private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation
@@ -691,7 +690,7 @@ namespace OpenSim.Region.Framework.Scenes
691 Utils.LongToUInts(handle, out x, out y); 690 Utils.LongToUInts(handle, out x, out y);
692 x = x / Constants.RegionSize; 691 x = x / Constants.RegionSize;
693 y = y / Constants.RegionSize; 692 y = y / Constants.RegionSize;
694 if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) 693 if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY))
695 { 694 {
696 old.Add(handle); 695 old.Add(handle);
697 } 696 }
@@ -765,6 +764,7 @@ namespace OpenSim.Region.Framework.Scenes
765 764
766 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() 765 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this()
767 { 766 {
767 m_DrawDistance = world.DefaultDrawDistance;
768 m_rootRegionHandle = reginfo.RegionHandle; 768 m_rootRegionHandle = reginfo.RegionHandle;
769 m_controllingClient = client; 769 m_controllingClient = client;
770 m_firstname = m_controllingClient.FirstName; 770 m_firstname = m_controllingClient.FirstName;
@@ -1311,7 +1311,9 @@ namespace OpenSim.Region.Framework.Scenes
1311 if (m_agentTransfer != null) 1311 if (m_agentTransfer != null)
1312 m_agentTransfer.EnableChildAgents(this); 1312 m_agentTransfer.EnableChildAgents(this);
1313 else 1313 else
1314 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); 1314 m_log.DebugFormat(
1315 "[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active for region {0}",
1316 m_scene.RegionInfo.RegionName);
1315 1317
1316 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); 1318 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1317 if (friendsModule != null) 1319 if (friendsModule != null)
@@ -1428,7 +1430,11 @@ namespace OpenSim.Region.Framework.Scenes
1428 m_CameraUpAxis = agentData.CameraUpAxis; 1430 m_CameraUpAxis = agentData.CameraUpAxis;
1429 1431
1430 // The Agent's Draw distance setting 1432 // The Agent's Draw distance setting
1431 m_DrawDistance = agentData.Far; 1433 // When we get to the point of re-computing neighbors everytime this
1434 // changes, then start using the agent's drawdistance rather than the
1435 // region's draw distance.
1436 // m_DrawDistance = agentData.Far;
1437 m_DrawDistance = Scene.DefaultDrawDistance;
1432 1438
1433 // Check if Client has camera in 'follow cam' or 'build' mode. 1439 // Check if Client has camera in 'follow cam' or 'build' mode.
1434 Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); 1440 Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation);
@@ -2853,7 +2859,7 @@ namespace OpenSim.Region.Framework.Scenes
2853 // If we are using the the cached appearance then send it out to everyone 2859 // If we are using the the cached appearance then send it out to everyone
2854 if (cachedappearance) 2860 if (cachedappearance)
2855 { 2861 {
2856 m_log.InfoFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); 2862 m_log.DebugFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name);
2857 2863
2858 // If the avatars baked textures are all in the cache, then we have a 2864 // If the avatars baked textures are all in the cache, then we have a
2859 // complete appearance... send it out, if not, then we'll send it when 2865 // complete appearance... send it out, if not, then we'll send it when
@@ -3070,8 +3076,11 @@ namespace OpenSim.Region.Framework.Scenes
3070 #region Border Crossing Methods 3076 #region Border Crossing Methods
3071 3077
3072 /// <summary> 3078 /// <summary>
3073 /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion 3079 /// Starts the process of moving an avatar into another region if they are crossing the border.
3074 /// </summary> 3080 /// </summary>
3081 /// <remarks>
3082 /// Also removes the avatar from the physical scene if transit has started.
3083 /// </remarks>
3075 protected void CheckForBorderCrossing() 3084 protected void CheckForBorderCrossing()
3076 { 3085 {
3077 if (IsChildAgent) 3086 if (IsChildAgent)
@@ -3139,7 +3148,6 @@ namespace OpenSim.Region.Framework.Scenes
3139 neighbor = HaveNeighbor(Cardinals.N, ref fix); 3148 neighbor = HaveNeighbor(Cardinals.N, ref fix);
3140 } 3149 }
3141 3150
3142
3143 // Makes sure avatar does not end up outside region 3151 // Makes sure avatar does not end up outside region
3144 if (neighbor <= 0) 3152 if (neighbor <= 0)
3145 { 3153 {
@@ -3194,6 +3202,13 @@ namespace OpenSim.Region.Framework.Scenes
3194 } 3202 }
3195 else 3203 else
3196 { 3204 {
3205 // We must remove the agent from the physical scene if it has been placed in transit. If we don't,
3206 // then this method continues to be called from ScenePresence.Update() until the handover of the client between
3207 // regions is completed. Since this handover can take more than 1000ms (due to the 1000ms
3208 // event queue polling response from the server), this results in the avatar pausing on the border
3209 // for the handover period.
3210 RemoveFromPhysicalScene();
3211
3197 // This constant has been inferred from experimentation 3212 // This constant has been inferred from experimentation
3198 // I'm not sure what this value should be, so I tried a few values. 3213 // I'm not sure what this value should be, so I tried a few values.
3199 timeStep = 0.04f; 3214 timeStep = 0.04f;
@@ -3205,6 +3220,15 @@ namespace OpenSim.Region.Framework.Scenes
3205 } 3220 }
3206 } 3221 }
3207 3222
3223 /// <summary>
3224 /// Checks whether this region has a neighbour in the given direction.
3225 /// </summary>
3226 /// <param name="car"></param>
3227 /// <param name="fix"></param>
3228 /// <returns>
3229 /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8.
3230 /// Returns a positive integer if there is a region in that direction, a negative integer if not.
3231 /// </returns>
3208 protected int HaveNeighbor(Cardinals car, ref int[] fix) 3232 protected int HaveNeighbor(Cardinals car, ref int[] fix)
3209 { 3233 {
3210 uint neighbourx = m_regionInfo.RegionLocX; 3234 uint neighbourx = m_regionInfo.RegionLocX;
@@ -3311,7 +3335,7 @@ namespace OpenSim.Region.Framework.Scenes
3311 3335
3312 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 3336 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
3313 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 3337 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
3314 if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) 3338 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY))
3315 { 3339 {
3316 byebyeRegions.Add(handle); 3340 byebyeRegions.Add(handle);
3317 } 3341 }
@@ -3387,7 +3411,12 @@ namespace OpenSim.Region.Framework.Scenes
3387 3411
3388 Vector3 offset = new Vector3(shiftx, shifty, 0f); 3412 Vector3 offset = new Vector3(shiftx, shifty, 0f);
3389 3413
3390 m_DrawDistance = cAgentData.Far; 3414 // When we get to the point of re-computing neighbors everytime this
3415 // changes, then start using the agent's drawdistance rather than the
3416 // region's draw distance.
3417 // m_DrawDistance = cAgentData.Far;
3418 m_DrawDistance = Scene.DefaultDrawDistance;
3419
3391 if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! 3420 if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!!
3392 m_pos = cAgentData.Position + offset; 3421 m_pos = cAgentData.Position + offset;
3393 3422
@@ -3538,7 +3567,11 @@ namespace OpenSim.Region.Framework.Scenes
3538 m_CameraLeftAxis = cAgent.LeftAxis; 3567 m_CameraLeftAxis = cAgent.LeftAxis;
3539 m_CameraUpAxis = cAgent.UpAxis; 3568 m_CameraUpAxis = cAgent.UpAxis;
3540 3569
3541 m_DrawDistance = cAgent.Far; 3570 // When we get to the point of re-computing neighbors everytime this
3571 // changes, then start using the agent's drawdistance rather than the
3572 // region's draw distance.
3573 // m_DrawDistance = cAgent.Far;
3574 m_DrawDistance = Scene.DefaultDrawDistance;
3542 3575
3543 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) 3576 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0)
3544 ControllingClient.SetChildAgentThrottle(cAgent.Throttles); 3577 ControllingClient.SetChildAgentThrottle(cAgent.Throttles);
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
index 40a73a9..1f4ec96 100644
--- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
@@ -205,6 +205,14 @@ namespace OpenSim.Region.Framework.Scenes
205 Reset(); 205 Reset();
206 } 206 }
207 207
208 public int GetPendingObjectsCount()
209 {
210 if (m_pendingObjects != null)
211 return m_pendingObjects.Count;
212
213 return 0;
214 }
215
208 public class ScenePartUpdate 216 public class ScenePartUpdate
209 { 217 {
210 public UUID FullID; 218 public UUID FullID;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs
new file mode 100644
index 0000000..855b589
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs
@@ -0,0 +1,173 @@
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.Generic;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
44using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock;
46using OpenSim.Tests.Common.Setup;
47
48namespace OpenSim.Region.Framework.Scenes.Tests
49{
50 /// <summary>
51 /// Attachment tests
52 /// </summary>
53 [TestFixture]
54 public class AttachmentTests
55 {
56 public Scene scene, scene2;
57 public UUID agent1;
58 public static Random random;
59 public ulong region1, region2;
60 public AgentCircuitData acd1;
61 public SceneObjectGroup sog1, sog2, sog3;
62
63 [TestFixtureSetUp]
64 public void Init()
65 {
66 TestHelper.InMethod();
67
68 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
69 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
70
71 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
72 interregionComms.Initialise(new IniConfigSource());
73 interregionComms.PostInitialise();
74 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
75 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
76
77 agent1 = UUID.Random();
78 random = new Random();
79 sog1 = NewSOG(UUID.Random(), scene, agent1);
80 sog2 = NewSOG(UUID.Random(), scene, agent1);
81 sog3 = NewSOG(UUID.Random(), scene, agent1);
82
83 //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
84 region1 = scene.RegionInfo.RegionHandle;
85 region2 = scene2.RegionInfo.RegionHandle;
86
87 SceneSetupHelpers.AddRootAgent(scene, agent1);
88 }
89
90 [Test]
91 public void T030_TestAddAttachments()
92 {
93 TestHelper.InMethod();
94
95 ScenePresence presence = scene.GetScenePresence(agent1);
96
97 presence.AddAttachment(sog1);
98 presence.AddAttachment(sog2);
99 presence.AddAttachment(sog3);
100
101 Assert.That(presence.HasAttachments(), Is.True);
102 Assert.That(presence.ValidateAttachments(), Is.True);
103 }
104
105 [Test]
106 public void T031_RemoveAttachments()
107 {
108 TestHelper.InMethod();
109
110 ScenePresence presence = scene.GetScenePresence(agent1);
111 presence.RemoveAttachment(sog1);
112 presence.RemoveAttachment(sog2);
113 presence.RemoveAttachment(sog3);
114 Assert.That(presence.HasAttachments(), Is.False);
115 }
116
117 // I'm commenting this test because scene setup NEEDS InventoryService to
118 // be non-null
119 //[Test]
120 public void T032_CrossAttachments()
121 {
122 TestHelper.InMethod();
123
124 ScenePresence presence = scene.GetScenePresence(agent1);
125 ScenePresence presence2 = scene2.GetScenePresence(agent1);
126 presence2.AddAttachment(sog1);
127 presence2.AddAttachment(sog2);
128
129 ISharedRegionModule serialiser = new SerialiserModule();
130 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
131 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
132
133 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
134
135 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
136 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
137 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
138 }
139
140 private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent)
141 {
142 SceneObjectPart sop = new SceneObjectPart();
143 sop.Name = RandomName();
144 sop.Description = RandomName();
145 sop.Text = RandomName();
146 sop.SitName = RandomName();
147 sop.TouchName = RandomName();
148 sop.UUID = uuid;
149 sop.Shape = PrimitiveBaseShape.Default;
150 sop.Shape.State = 1;
151 sop.OwnerID = agent;
152
153 SceneObjectGroup sog = new SceneObjectGroup(sop);
154 sog.SetScene(scene);
155
156 return sog;
157 }
158
159 private static string RandomName()
160 {
161 StringBuilder name = new StringBuilder();
162 int size = random.Next(5,12);
163 char ch;
164 for (int i = 0; i < size; i++)
165 {
166 ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
167 name.Append(ch);
168 }
169
170 return name.ToString();
171 }
172 }
173} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
index b3c3e22..667b74e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
@@ -32,7 +32,6 @@ using System.Text;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using Nini.Config; 33using Nini.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
index 9244bc3..ca635d7 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
@@ -28,7 +28,6 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 4969b09..a6a95ef 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -28,7 +28,6 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
index 39116b6..0d26026 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
@@ -30,7 +30,6 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using Nini.Config; 31using Nini.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using OpenSim.Framework; 34using OpenSim.Framework;
36using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index b84298f..bdfcd1d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -29,7 +29,6 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using NUnit.Framework; 31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse; 32using OpenMetaverse;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
index c78038f..8876a43 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
@@ -30,7 +30,6 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using Nini.Config; 31using Nini.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using OpenSim.Framework; 34using OpenSim.Framework;
36using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index ef52363..efb757f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -34,12 +34,12 @@ using System.Timers;
34using Timer=System.Timers.Timer; 34using Timer=System.Timers.Timer;
35using Nini.Config; 35using Nini.Config;
36using NUnit.Framework; 36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse; 37using OpenMetaverse;
39using OpenSim.Framework; 38using OpenSim.Framework;
40using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.CoreModules.Framework.EntityTransfer;
43using OpenSim.Region.CoreModules.World.Serialiser; 43using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
@@ -116,9 +116,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
116 agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); 116 agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
117 agent.child = true; 117 agent.child = true;
118 118
119 if (scene.PresenceService == null)
120 Console.WriteLine("Presence Service is null");
121
122 scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); 119 scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
123 120
124 string reason; 121 string reason;
@@ -175,25 +172,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
175 172
176 Assert.That(neighbours.Count, Is.EqualTo(2)); 173 Assert.That(neighbours.Count, Is.EqualTo(2));
177 } 174 }
178
179 public void fixNullPresence()
180 {
181 string firstName = "testfirstname";
182
183 AgentCircuitData agent = new AgentCircuitData();
184 agent.AgentID = agent1;
185 agent.firstname = firstName;
186 agent.lastname = "testlastname";
187 agent.SessionID = UUID.Zero;
188 agent.SecureSessionID = UUID.Zero;
189 agent.circuitcode = 123;
190 agent.BaseFolder = UUID.Zero;
191 agent.InventoryFolder = UUID.Zero;
192 agent.startpos = Vector3.Zero;
193 agent.CapsPath = GetRandomCapsObjectPath();
194
195 acd1 = agent;
196 }
197 175
198 [Test] 176 [Test]
199 public void T013_TestRemoveNeighbourRegion() 177 public void T013_TestRemoveNeighbourRegion()
@@ -211,24 +189,36 @@ namespace OpenSim.Region.Framework.Scenes.Tests
211 CompleteAvatarMovement 189 CompleteAvatarMovement
212 */ 190 */
213 } 191 }
214 192
215 // I'm commenting this test, because this is not supposed to happen here 193 /// <summary>
216 //[Test] 194 /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region
217 public void T020_TestMakeRootAgent() 195 /// </summary>
196 /// <remarks>
197 /// Please note that unlike the other tests here, this doesn't rely on structures
198 /// </remarks>
199 [Test]
200 public void TestChildAgentEstablished()
218 { 201 {
219 TestHelper.InMethod(); 202 TestHelper.InMethod();
220 203// log4net.Config.XmlConfigurator.Configure();
221 ScenePresence presence = scene.GetScenePresence(agent1); 204
222 Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent"); 205 UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
223 206
224 presence.MakeChildAgent(); 207 TestScene myScene1 = SceneSetupHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
225 Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); 208 TestScene myScene2 = SceneSetupHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
226 209
227 // Accepts 0 but rejects Constants.RegionSize 210 IConfigSource configSource = new IniConfigSource();
228 Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0); 211 configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule");
229 presence.MakeRootAgent(pos,true); 212 EntityTransferModule etm = new EntityTransferModule();
230 Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); 213
231 Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); 214 SceneSetupHelpers.SetupSceneModules(myScene1, configSource, etm);
215
216 SceneSetupHelpers.AddRootAgent(myScene1, agent1Id);
217 ScenePresence childPresence = myScene2.GetScenePresence(agent1);
218
219 // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents
220// Assert.That(childPresence, Is.Not.Null);
221// Assert.That(childPresence.IsChildAgent, Is.True);
232 } 222 }
233 223
234 // I'm commenting this test because it does not represent 224 // I'm commenting this test because it does not represent
@@ -333,63 +323,26 @@ namespace OpenSim.Region.Framework.Scenes.Tests
333 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); 323 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
334 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); 324 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
335 } 325 }
336 326
337 [Test] 327 public void fixNullPresence()
338 public void T030_TestAddAttachments()
339 {
340 TestHelper.InMethod();
341
342 ScenePresence presence = scene.GetScenePresence(agent1);
343
344 presence.AddAttachment(sog1);
345 presence.AddAttachment(sog2);
346 presence.AddAttachment(sog3);
347
348 Assert.That(presence.HasAttachments(), Is.True);
349 Assert.That(presence.ValidateAttachments(), Is.True);
350 }
351
352 [Test]
353 public void T031_RemoveAttachments()
354 {
355 TestHelper.InMethod();
356
357 ScenePresence presence = scene.GetScenePresence(agent1);
358 presence.RemoveAttachment(sog1);
359 presence.RemoveAttachment(sog2);
360 presence.RemoveAttachment(sog3);
361 Assert.That(presence.HasAttachments(), Is.False);
362 }
363
364 // I'm commenting this test because scene setup NEEDS InventoryService to
365 // be non-null
366 //[Test]
367 public void T032_CrossAttachments()
368 { 328 {
369 TestHelper.InMethod(); 329 string firstName = "testfirstname";
370
371 ScenePresence presence = scene.GetScenePresence(agent1);
372 ScenePresence presence2 = scene2.GetScenePresence(agent1);
373 presence2.AddAttachment(sog1);
374 presence2.AddAttachment(sog2);
375
376 ISharedRegionModule serialiser = new SerialiserModule();
377 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
378 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
379
380 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
381 330
382 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); 331 AgentCircuitData agent = new AgentCircuitData();
383 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); 332 agent.AgentID = agent1;
384 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); 333 agent.firstname = firstName;
385 } 334 agent.lastname = "testlastname";
335 agent.SessionID = UUID.Zero;
336 agent.SecureSessionID = UUID.Zero;
337 agent.circuitcode = 123;
338 agent.BaseFolder = UUID.Zero;
339 agent.InventoryFolder = UUID.Zero;
340 agent.startpos = Vector3.Zero;
341 agent.CapsPath = GetRandomCapsObjectPath();
386 342
387 [TearDown] 343 acd1 = agent;
388 public void TearDown()
389 {
390 if (MainServer.Instance != null) MainServer.Instance.Stop();
391 } 344 }
392 345
393 public static string GetRandomCapsObjectPath() 346 public static string GetRandomCapsObjectPath()
394 { 347 {
395 UUID caps = UUID.Random(); 348 UUID caps = UUID.Random();
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
new file mode 100644
index 0000000..abcce66
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -0,0 +1,70 @@
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.Generic;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
44using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock;
46using OpenSim.Tests.Common.Setup;
47
48namespace OpenSim.Region.Framework.Scenes.Tests
49{
50 /// <summary>
51 /// Scene presence tests
52 /// </summary>
53 [TestFixture]
54 public class SceneTests
55 {
56 /// <summary>
57 /// Very basic scene update test. Should become more elaborate with time.
58 /// </summary>
59 [Test]
60 public void TestUpdateScene()
61 {
62 TestHelper.InMethod();
63
64 Scene scene = SceneSetupHelpers.SetupScene();
65 scene.Update();
66
67 Assert.That(scene.Frame, Is.EqualTo(1));
68 }
69 }
70} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
index cafe48a..8588f7f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
@@ -29,7 +29,6 @@ using System;
29using System.Reflection; 29using System.Reflection;
30using Nini.Config; 30using Nini.Config;
31using NUnit.Framework; 31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse; 32using OpenMetaverse;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
index fe59d4f..8138bcc 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
@@ -34,7 +34,6 @@ using System.Timers;
34using Timer=System.Timers.Timer; 34using Timer=System.Timers.Timer;
35using Nini.Config; 35using Nini.Config;
36using NUnit.Framework; 36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse; 37using OpenMetaverse;
39using OpenMetaverse.Assets; 38using OpenMetaverse.Assets;
40using OpenSim.Framework; 39using OpenSim.Framework;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index 5e6124b..6b70865 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -28,7 +28,6 @@
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
index 87d067c..6a24cc1 100644
--- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
51 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")] 51 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")]
52 public class LindenUDPInfoModule : ISharedRegionModule 52 public class LindenUDPInfoModule : ISharedRegionModule
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); 56 protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
57 57
@@ -95,7 +95,15 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
95 "Show throttle settings for each client and for the server overall", 95 "Show throttle settings for each client and for the server overall",
96 "Without the 'full' option, only root agents are shown." 96 "Without the 'full' option, only root agents are shown."
97 + " With the 'full' option child agents are also shown.", 97 + " With the 'full' option child agents are also shown.",
98 ShowThrottlesReport); 98 ShowThrottlesReport);
99
100 scene.AddCommand(
101 this, "emergency-monitoring",
102 "Go on/off emergency monitoring mode",
103 "Go on/off emergency monitoring mode",
104 "Go on/off emergency monitoring mode",
105 EmergencyMonitoring);
106
99 } 107 }
100 108
101 public void RemoveRegion(Scene scene) 109 public void RemoveRegion(Scene scene)
@@ -120,7 +128,25 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
120 { 128 {
121 MainConsole.Instance.Output(GetThrottlesReport(cmd)); 129 MainConsole.Instance.Output(GetThrottlesReport(cmd));
122 } 130 }
123 131
132 protected void EmergencyMonitoring(string module, string[] cmd)
133 {
134 bool mode = true;
135 if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on"))
136 {
137 mode = true;
138 MainConsole.Instance.Output("Emergency Monitoring ON");
139 }
140 else
141 {
142 mode = false;
143 MainConsole.Instance.Output("Emergency Monitoring OFF");
144 }
145
146 foreach (Scene s in m_scenes.Values)
147 s.EmergencyMonitoring = mode;
148 }
149
124 protected string GetColumnEntry(string entry, int maxLength, int columnPadding) 150 protected string GetColumnEntry(string entry, int maxLength, int columnPadding)
125 { 151 {
126 return string.Format( 152 return string.Format(
@@ -154,24 +180,26 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
154 report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); 180 report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding));
155 181
156 report.AppendFormat( 182 report.AppendFormat(
157 "{0,7} {1,7} {2,9} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7} {10,7}\n", 183 "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}\n",
158 "Pkts", 184 "Pkts",
159 "Pkts", 185 "Pkts",
186 "Pkts",
160 "Bytes", 187 "Bytes",
161 "Pkts", 188 "Q Pkts",
162 "Pkts", 189 "Q Pkts",
163 "Pkts", 190 "Q Pkts",
164 "Pkts", 191 "Q Pkts",
165 "Pkts", 192 "Q Pkts",
166 "Pkts", 193 "Q Pkts",
167 "Pkts", 194 "Q Pkts",
168 "Pkts"); 195 "Q Pkts");
169 196
170 report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); 197 report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", "");
171 report.AppendFormat( 198 report.AppendFormat(
172 "{0,7} {1,7} {2,9} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7} {10,7}\n", 199 "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}\n",
173 "Out",
174 "In", 200 "In",
201 "Out",
202 "Resent",
175 "Unacked", 203 "Unacked",
176 "Resend", 204 "Resend",
177 "Land", 205 "Land",
@@ -333,7 +361,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
333 ThrottleRates throttleRates = udpServer.ThrottleRates; 361 ThrottleRates throttleRates = udpServer.ThrottleRates;
334 report.AppendFormat( 362 report.AppendFormat(
335 "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}", 363 "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}",
336 "n/a", 364 (throttleRates.Total * 8) / 1000,
337 (throttleRates.ResendLimit * 8) / 1000, 365 (throttleRates.ResendLimit * 8) / 1000,
338 (throttleRates.LandLimit * 8) / 1000, 366 (throttleRates.LandLimit * 8) / 1000,
339 (throttleRates.WindLimit * 8) / 1000, 367 (throttleRates.WindLimit * 8) / 1000,
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index d75e25d..7deb32f 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -92,7 +92,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
92 private static string m_freeSwitchUrlResetPassword; 92 private static string m_freeSwitchUrlResetPassword;
93 private uint m_freeSwitchServicePort; 93 private uint m_freeSwitchServicePort;
94 private string m_openSimWellKnownHTTPAddress; 94 private string m_openSimWellKnownHTTPAddress;
95 private string m_freeSwitchContext; 95// private string m_freeSwitchContext;
96 96
97 private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>(); 97 private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>();
98 private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>(); 98 private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>();
@@ -144,7 +144,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
144 m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString(); 144 m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString();
145 m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger(); 145 m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger();
146 m_freeSwitchUrlResetPassword = String.Empty; 146 m_freeSwitchUrlResetPassword = String.Empty;
147 m_freeSwitchContext = map["Context"].AsString(); 147// m_freeSwitchContext = map["Context"].AsString();
148 148
149 if (String.IsNullOrEmpty(m_freeSwitchRealm) || 149 if (String.IsNullOrEmpty(m_freeSwitchRealm) ||
150 String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) 150 String.IsNullOrEmpty(m_freeSwitchAPIPrefix))
@@ -662,7 +662,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
662 resp.Append("</buddies><groups></groups></body></level0></response>"); 662 resp.Append("</buddies><groups></groups></body></level0></response>");
663 663
664 response["str_response_string"] = resp.ToString(); 664 response["str_response_string"] = resp.ToString();
665 Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); 665// Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline);
666 666
667 //m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],"")); 667 //m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],""));
668 return response; 668 return response;
@@ -670,10 +670,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
670 670
671 public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request) 671 public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request)
672 { 672 {
673// m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called"); 673 //m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called");
674 string requestbody = (string)request["body"]; 674// string requestbody = (string)request["body"];
675 string uri = (string)request["uri"]; 675// string uri = (string)request["uri"];
676 string contenttype = (string)request["content-type"]; 676// string contenttype = (string)request["content-type"];
677 677
678 Hashtable requestBody = ParseRequestBody((string)request["body"]); 678 Hashtable requestBody = ParseRequestBody((string)request["body"]);
679 679
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
index 5c779de..6d26075 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
@@ -63,7 +63,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
63 void SetAgentActiveGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); 63 void SetAgentActiveGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
64 void SetAgentGroupInfo(UUID RequestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile); 64 void SetAgentGroupInfo(UUID RequestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile);
65 65
66 /// <summary>
67 /// Get information about a specific group to which the user belongs.
68 /// </summary>
69 /// <param name="RequestingAgentID">The agent requesting the information.</param>
70 /// <param name="AgentID">The agent requested.</param>
71 /// <param name="GroupID">The group requested.</param>
72 /// <returns>
73 /// If the user is a member of the group then the data structure is returned. If not, then null is returned.
74 /// </returns>
66 GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID); 75 GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
76
77 /// <summary>
78 /// Get information about the groups to which a user belongs.
79 /// </summary>
80 /// <param name="RequestingAgentID">The agent requesting the information.</param>
81 /// <param name="AgentID">The agent requested.</param>
82 /// <returns>
83 /// Information about the groups to which the user belongs. If the user belongs to no groups then an empty
84 /// list is returned.
85 /// </returns>
67 List<GroupMembershipData> GetAgentGroupMemberships(UUID RequestingAgentID, UUID AgentID); 86 List<GroupMembershipData> GetAgentGroupMemberships(UUID RequestingAgentID, UUID AgentID);
68 87
69 void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); 88 void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket);
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
index 0d265f2..02751ea 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
@@ -704,7 +704,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
704 } 704 }
705 } 705 }
706 706
707
708 return findings; 707 return findings;
709 } 708 }
710 709
@@ -712,54 +711,55 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
712 { 711 {
713 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 712 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
714 713
715 GroupMembershipData data = new GroupMembershipData(); 714 GroupMembershipData data = null;
716 715// bool foundData = false;
717 ///////////////////////////////
718 // Agent Specific Information:
719 //
720 OSDMap UserActiveGroup;
721 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
722 {
723 data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID);
724 }
725 716
726 OSDMap UserGroupMemberInfo; 717 OSDMap UserGroupMemberInfo;
727 if (SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo)) 718 if (SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo))
728 { 719 {
720 data = new GroupMembershipData();
729 data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean(); 721 data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean();
730 data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger(); 722 data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger();
731 data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean(); 723 data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean();
732 data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID(); 724 data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID();
725
726 ///////////////////////////////
727 // Agent Specific Information:
728 //
729 OSDMap UserActiveGroup;
730 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
731 {
732 data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID);
733 }
733 734
734 /////////////////////////////// 735 ///////////////////////////////
735 // Role Specific Information: 736 // Role Specific Information:
736 // 737 //
737
738 OSDMap GroupRoleInfo; 738 OSDMap GroupRoleInfo;
739 if (SimianGetGenericEntry(groupID, "GroupRole", data.ActiveRole.ToString(), out GroupRoleInfo)) 739 if (SimianGetGenericEntry(groupID, "GroupRole", data.ActiveRole.ToString(), out GroupRoleInfo))
740 { 740 {
741 data.GroupTitle = GroupRoleInfo["Title"].AsString(); 741 data.GroupTitle = GroupRoleInfo["Title"].AsString();
742 data.GroupPowers = GroupRoleInfo["Powers"].AsULong(); 742 data.GroupPowers = GroupRoleInfo["Powers"].AsULong();
743 } 743 }
744 } 744
745 745 ///////////////////////////////
746 /////////////////////////////// 746 // Group Specific Information:
747 // Group Specific Information: 747 //
748 // 748 OSDMap GroupInfo;
749 OSDMap GroupInfo; 749 string GroupName;
750 string GroupName; 750 if (SimianGetFirstGenericEntry(groupID, "Group", out GroupName, out GroupInfo))
751 if (SimianGetFirstGenericEntry(groupID, "Group", out GroupName, out GroupInfo)) 751 {
752 { 752 data.GroupID = groupID;
753 data.GroupID = groupID; 753 data.AllowPublish = GroupInfo["AllowPublish"].AsBoolean();
754 data.AllowPublish = GroupInfo["AllowPublish"].AsBoolean(); 754 data.Charter = GroupInfo["Charter"].AsString();
755 data.Charter = GroupInfo["Charter"].AsString(); 755 data.FounderID = GroupInfo["FounderID"].AsUUID();
756 data.FounderID = GroupInfo["FounderID"].AsUUID(); 756 data.GroupName = GroupName;
757 data.GroupName = GroupName; 757 data.GroupPicture = GroupInfo["InsigniaID"].AsUUID();
758 data.GroupPicture = GroupInfo["InsigniaID"].AsUUID(); 758 data.MaturePublish = GroupInfo["MaturePublish"].AsBoolean();
759 data.MaturePublish = GroupInfo["MaturePublish"].AsBoolean(); 759 data.MembershipFee = GroupInfo["MembershipFee"].AsInteger();
760 data.MembershipFee = GroupInfo["MembershipFee"].AsInteger(); 760 data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean();
761 data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean(); 761 data.ShowInList = GroupInfo["ShowInList"].AsBoolean();
762 data.ShowInList = GroupInfo["ShowInList"].AsBoolean(); 762 }
763 } 763 }
764 764
765 return data; 765 return data;
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
index bc55b04..6de97b7 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
@@ -29,7 +29,6 @@ using System;
29using System.Reflection; 29using System.Reflection;
30using Nini.Config; 30using Nini.Config;
31using NUnit.Framework; 31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse; 32using OpenMetaverse;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
index b84a34d..d469548 100644
--- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
+++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
@@ -838,6 +838,10 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
838 if (module != null) 838 if (module != null)
839 module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice); 839 module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice);
840 } 840 }
841
842 public void MoveMoney(UUID fromAgentID, UUID toAgentID, int amount, string text)
843 {
844 }
841 } 845 }
842 846
843 public enum TransactionType : int 847 public enum TransactionType : int
diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
index d4b7020..cee8851 100644
--- a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
+++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
@@ -71,6 +71,9 @@ namespace OpenSim.Region.OptionalModules.World.WorldView
71 71
72 public void RegionLoaded(Scene scene) 72 public void RegionLoaded(Scene scene)
73 { 73 {
74 if (!m_Enabled)
75 return;
76
74 m_Generator = scene.RequestModuleInterface<IMapImageGenerator>(); 77 m_Generator = scene.RequestModuleInterface<IMapImageGenerator>();
75 if (m_Generator == null) 78 if (m_Generator == null)
76 { 79 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
new file mode 100644
index 0000000..489c1c6
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -0,0 +1,118 @@
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.Reflection;
30using System.Collections;
31using System.Collections.Generic;
32using System.Runtime.Remoting.Lifetime;
33using OpenMetaverse;
34using Nini.Config;
35using OpenSim;
36using OpenSim.Framework;
37using OpenSim.Region.CoreModules.World.LightShare;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.ScriptEngine.Shared;
41using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
42using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
43using OpenSim.Region.ScriptEngine.Interfaces;
44using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
45using OpenSim.Services.Interfaces;
46
47using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
48using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
49using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
50using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
51using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
52using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
53using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
54
55namespace OpenSim.Region.ScriptEngine.Shared.Api
56{
57 [Serializable]
58 public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi
59 {
60 internal IScriptEngine m_ScriptEngine;
61 internal SceneObjectPart m_host;
62 internal uint m_localID;
63 internal UUID m_itemID;
64 internal bool m_CMFunctionsEnabled = false;
65
66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
67 {
68 m_ScriptEngine = ScriptEngine;
69 m_host = host;
70 m_localID = localID;
71 m_itemID = itemID;
72
73 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
74 m_CMFunctionsEnabled = true;
75 }
76
77 public override Object InitializeLifetimeService()
78 {
79 ILease lease = (ILease)base.InitializeLifetimeService();
80
81 if (lease.CurrentState == LeaseState.Initial)
82 {
83 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
84 // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
85 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
86 }
87 return lease;
88 }
89
90 public Scene World
91 {
92 get { return m_ScriptEngine.World; }
93 }
94
95 public string cmDetectedCountry(int number)
96 {
97 m_host.AddScriptLPS(1);
98 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number);
99 if (detectedParams == null)
100 return String.Empty;
101 return detectedParams.Country;
102 }
103
104 public string cmGetAgentCountry(LSL_Key key)
105 {
106 if (!World.Permissions.IsGod(m_host.OwnerID))
107 return String.Empty;
108
109 UUID uuid;
110
111 if (!UUID.TryParse(key, out uuid))
112 return String.Empty;
113
114 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
115 return account.UserCountry;
116 }
117 }
118}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 59e905e..559523b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1920,15 +1920,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1920 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 1920 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1921 return; 1921 return;
1922 1922
1923 UUID textureID=new UUID(); 1923 UUID textureID = new UUID();
1924 1924
1925 if (!UUID.TryParse(texture, out textureID)) 1925 textureID = InventoryKey(texture, (int)AssetType.Texture);
1926 { 1926 if (textureID == UUID.Zero)
1927 textureID=InventoryKey(texture, (int)AssetType.Texture); 1927 {
1928 } 1928 if (!UUID.TryParse(texture, out textureID))
1929 1929 return;
1930 if (textureID == UUID.Zero) 1930 }
1931 return;
1932 1931
1933 Primitive.TextureEntry tex = part.Shape.Textures; 1932 Primitive.TextureEntry tex = part.Shape.Textures;
1934 1933
@@ -3346,12 +3345,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3346 msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; 3345 msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID;
3347 msg.Position = new Vector3(m_host.AbsolutePosition); 3346 msg.Position = new Vector3(m_host.AbsolutePosition);
3348 msg.RegionID = World.RegionInfo.RegionID.Guid; 3347 msg.RegionID = World.RegionInfo.RegionID.Guid;
3349 msg.binaryBucket = Util.StringToBytes256(m_host.OwnerID.ToString()); 3348 msg.binaryBucket
3349 = Util.StringToBytes256(
3350 "{0}/{1}/{2}/{3}",
3351 World.RegionInfo.RegionName,
3352 (int)Math.Floor(m_host.AbsolutePosition.X),
3353 (int)Math.Floor(m_host.AbsolutePosition.Y),
3354 (int)Math.Floor(m_host.AbsolutePosition.Z));
3350 3355
3351 if (m_TransferModule != null) 3356 if (m_TransferModule != null)
3352 { 3357 {
3353 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); 3358 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
3354 } 3359 }
3360
3355 ScriptSleep(2000); 3361 ScriptSleep(2000);
3356 } 3362 }
3357 3363
@@ -4195,7 +4201,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4195 if (!found) 4201 if (!found)
4196 { 4202 {
4197 llSay(0, String.Format("Could not find object '{0}'", inventory)); 4203 llSay(0, String.Format("Could not find object '{0}'", inventory));
4198 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 4204 return;
4205// throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
4199 } 4206 }
4200 4207
4201 // check if destination is an object 4208 // check if destination is an object
@@ -4479,7 +4486,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4479 if (presence != null) 4486 if (presence != null)
4480 { 4487 {
4481 // agent must not be a god 4488 // agent must not be a god
4482 if (presence.GodLevel >= 200) return; 4489 if (presence.UserLevel >= 200) return;
4483 4490
4484 // agent must be over the owners land 4491 // agent must be over the owners land
4485 if (m_host.OwnerID == World.LandChannel.GetLandObject( 4492 if (m_host.OwnerID == World.LandChannel.GetLandObject(
@@ -6860,6 +6867,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6860 } 6867 }
6861 6868
6862 // copy the first script found with this inventory name 6869 // copy the first script found with this inventory name
6870 TaskInventoryItem scriptItem = null;
6863 m_host.TaskInventory.LockItemsForRead(true); 6871 m_host.TaskInventory.LockItemsForRead(true);
6864 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6872 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6865 { 6873 {
@@ -6870,6 +6878,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6870 { 6878 {
6871 found = true; 6879 found = true;
6872 srcId = inv.Key; 6880 srcId = inv.Key;
6881 scriptItem = inv.Value;
6873 break; 6882 break;
6874 } 6883 }
6875 } 6884 }
@@ -6882,8 +6891,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6882 return; 6891 return;
6883 } 6892 }
6884 6893
6885 // the rest of the permission checks are done in RezScript, so check the pin there as well 6894 SceneObjectPart dest = World.GetSceneObjectPart(destId);
6886 World.RezScript(srcId, m_host, destId, pin, running, start_param); 6895 if (dest != null)
6896 {
6897 if ((scriptItem.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID)
6898 {
6899 // the rest of the permission checks are done in RezScript, so check the pin there as well
6900 World.RezScript(srcId, m_host, destId, pin, running, start_param);
6901
6902 if ((scriptItem.BasePermissions & (uint)PermissionMask.Copy) == 0)
6903 m_host.Inventory.RemoveInventoryItem(srcId);
6904 }
6905 }
6887 // this will cause the delay even if the script pin or permissions were wrong - seems ok 6906 // this will cause the delay even if the script pin or permissions were wrong - seems ok
6888 ScriptSleep(3000); 6907 ScriptSleep(3000);
6889 } 6908 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index cf059b3..39e1a27 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -690,10 +690,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
690 // 690 //
691 CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); 691 CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
692 692
693 TeleportAgent(agent, regionName, position, lookat); 693 TeleportAgent(agent, regionName, position, lookat, false);
694 } 694 }
695 695
696 private void TeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) 696 private void TeleportAgent(string agent, string regionName,
697 LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions)
697 { 698 {
698 m_host.AddScriptLPS(1); 699 m_host.AddScriptLPS(1);
699 UUID agentId = new UUID(); 700 UUID agentId = new UUID();
@@ -702,21 +703,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
702 ScenePresence presence = World.GetScenePresence(agentId); 703 ScenePresence presence = World.GetScenePresence(agentId);
703 if (presence != null) 704 if (presence != null)
704 { 705 {
705 // agent must be over owners land to avoid abuse 706 // For osTeleportAgent, agent must be over owners land to avoid abuse
706 if (m_host.OwnerID 707 // For osTeleportOwner, this restriction isn't necessary
708 if (relaxRestrictions ||
709 m_host.OwnerID
707 == World.LandChannel.GetLandObject( 710 == World.LandChannel.GetLandObject(
708 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) 711 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
709 { 712 {
710 // Check for hostname, attempt to make a HG link,
711 // and convert the regionName to the target region
712 if (regionName.Contains(".") && regionName.Contains(":"))
713 {
714// List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.ScopeID, regionName, 1);
715 string[] parts = regionName.Split(new char[] { ':' });
716 if (parts.Length > 2)
717 regionName = parts[0] + ':' + parts[1] + "/ " + parts[2];
718 regionName = "http://" + regionName;
719 }
720 World.RequestTeleportLocation(presence.ControllingClient, regionName, 713 World.RequestTeleportLocation(presence.ControllingClient, regionName,
721 new Vector3((float)position.x, (float)position.y, (float)position.z), 714 new Vector3((float)position.x, (float)position.y, (float)position.z),
722 new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation); 715 new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation);
@@ -733,10 +726,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
733 // 726 //
734 CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); 727 CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
735 728
736 TeleportAgent(agent, regionX, regionY, position, lookat); 729 TeleportAgent(agent, regionX, regionY, position, lookat, false);
737 } 730 }
738 731
739 private void TeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) 732 private void TeleportAgent(string agent, int regionX, int regionY,
733 LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions)
740 { 734 {
741 ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); 735 ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
742 736
@@ -747,8 +741,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
747 ScenePresence presence = World.GetScenePresence(agentId); 741 ScenePresence presence = World.GetScenePresence(agentId);
748 if (presence != null) 742 if (presence != null)
749 { 743 {
750 // agent must be over owners land to avoid abuse 744 // For osTeleportAgent, agent must be over owners land to avoid abuse
751 if (m_host.OwnerID 745 // For osTeleportOwner, this restriction isn't necessary
746 if (relaxRestrictions ||
747 m_host.OwnerID
752 == World.LandChannel.GetLandObject( 748 == World.LandChannel.GetLandObject(
753 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) 749 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
754 { 750 {
@@ -771,7 +767,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
771 // Threat level None because this is what can already be done with the World Map in the viewer 767 // Threat level None because this is what can already be done with the World Map in the viewer
772 CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); 768 CheckThreatLevel(ThreatLevel.None, "osTeleportOwner");
773 769
774 TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat); 770 TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat, true);
775 } 771 }
776 772
777 public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) 773 public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
@@ -783,7 +779,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
783 { 779 {
784 CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); 780 CheckThreatLevel(ThreatLevel.None, "osTeleportOwner");
785 781
786 TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat); 782 TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat, true);
787 } 783 }
788 784
789 // Functions that get information from the agent itself. 785 // Functions that get information from the agent itself.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
new file mode 100644
index 0000000..ab215f3
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -0,0 +1,46 @@
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.Collections;
29using OpenSim.Region.ScriptEngine.Interfaces;
30
31using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
32using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
33using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
34using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
35using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
36using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
37using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
38
39namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
40{
41 public interface ICM_Api
42 {
43 string cmDetectedCountry(int num);
44 string cmGetAgentCountry(key key);
45 }
46}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
new file mode 100644
index 0000000..4132dfa
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -0,0 +1,71 @@
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.Runtime.Remoting.Lifetime;
30using System.Threading;
31using System.Reflection;
32using System.Collections;
33using System.Collections.Generic;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
38using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
39using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
40using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
41using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
42using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
43using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
44using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
45using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
46
47namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
48{
49 public partial class ScriptBaseClass : MarshalByRefObject
50 {
51 public ICM_Api m_CM_Functions;
52
53 public void ApiTypeCM(IScriptApi api)
54 {
55 if (!(api is ICM_Api))
56 return;
57
58 m_CM_Functions = (ICM_Api)api;
59 }
60
61 public string cmDetectedCountry(int num)
62 {
63 return m_CM_Functions.cmDetectedCountry(num);
64 }
65
66 public string cmGetAgentCountry(key key)
67 {
68 return m_CM_Functions.cmGetAgentCountry(key);
69 }
70 }
71}