aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs9
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs38
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs9
-rw-r--r--OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs286
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs166
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs9
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs117
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs40
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs34
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs3
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs17
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs86
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs4
-rw-r--r--OpenSim/Region/DataSnapshot/DataSnapshotManager.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs20
-rw-r--r--OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs107
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs61
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs55
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/TerrainCompressor.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs146
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs15
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs78
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs6
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs1
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs4
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs4
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs34
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs65
43 files changed, 1096 insertions, 397 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
index 54cf285..bb932f2 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
@@ -63,7 +63,7 @@ namespace OpenSim.Region.ClientStack.Linden
63 private bool m_Enabled = false; 63 private bool m_Enabled = false;
64 64
65 // TODO: Change this to a config option 65 // TODO: Change this to a config option
66 const string REDIRECT_URL = null; 66 private string m_RedirectURL = null;
67 67
68 private string m_URL; 68 private string m_URL;
69 69
@@ -78,7 +78,10 @@ namespace OpenSim.Region.ClientStack.Linden
78 m_URL = config.GetString("Cap_GetTexture", string.Empty); 78 m_URL = config.GetString("Cap_GetTexture", string.Empty);
79 // Cap doesn't exist 79 // Cap doesn't exist
80 if (m_URL != string.Empty) 80 if (m_URL != string.Empty)
81 {
81 m_Enabled = true; 82 m_Enabled = true;
83 m_RedirectURL = config.GetString("GetTextureRedirectURL");
84 }
82 } 85 }
83 86
84 public void AddRegion(Scene s) 87 public void AddRegion(Scene s)
@@ -132,14 +135,14 @@ namespace OpenSim.Region.ClientStack.Linden
132// m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); 135// m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName);
133 caps.RegisterHandler( 136 caps.RegisterHandler(
134 "GetTexture", 137 "GetTexture",
135 new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString())); 138 new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString(), m_RedirectURL));
136 } 139 }
137 else 140 else
138 { 141 {
139// m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); 142// m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName);
140 IExternalCapsModule handler = m_scene.RequestModuleInterface<IExternalCapsModule>(); 143 IExternalCapsModule handler = m_scene.RequestModuleInterface<IExternalCapsModule>();
141 if (handler != null) 144 if (handler != null)
142 handler.RegisterExternalUserCapsHandler(agentID,caps,"GetTexture",m_URL); 145 handler.RegisterExternalUserCapsHandler(agentID,caps,"GetTexture", m_URL);
143 else 146 else
144 caps.RegisterHandler("GetTexture", m_URL); 147 caps.RegisterHandler("GetTexture", m_URL);
145 } 148 }
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs
index edc5016..ee1ea1a 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs
@@ -152,7 +152,7 @@ namespace OpenSim.Region.ClientStack.Linden.Caps.Tests
152 152
153 // A sanity check that the response has the expected number of descendents for a default inventory 153 // A sanity check that the response has the expected number of descendents for a default inventory
154 // TODO: Need a more thorough check. 154 // TODO: Need a more thorough check.
155 Assert.That((int)folderOsd["descendents"], Is.EqualTo(14)); 155 Assert.That((int)folderOsd["descendents"], Is.EqualTo(16));
156 } 156 }
157 } 157 }
158} \ No newline at end of file 158} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 53217a0..c28e58d 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -8949,7 +8949,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
8949 if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) 8949 if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
8950 { 8950 {
8951 string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString(); 8951 string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
8952 return ((Scene)Scene).AssetService.Get(assetServer + "/" + id); 8952 if (!string.IsNullOrEmpty(assetServer))
8953 return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
8953 } 8954 }
8954 8955
8955 return null; 8956 return null;
@@ -12658,16 +12659,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12658 12659
12659 if (asset == null) 12660 if (asset == null)
12660 { 12661 {
12661 req.AssetInf = null; 12662 // Try the user's asset server
12662 req.AssetRequestSource = source; 12663 IInventoryAccessModule inventoryAccessModule = Scene.RequestModuleInterface<IInventoryAccessModule>();
12663 req.IsTextureRequest = false; 12664
12664 req.NumPackets = 0; 12665 string assetServerURL = string.Empty;
12665 req.Params = transferRequest.TransferInfo.Params; 12666 if (inventoryAccessModule.IsForeignUser(AgentId, out assetServerURL) && !string.IsNullOrEmpty(assetServerURL))
12666 req.RequestAssetID = requestID; 12667 {
12667 req.TransferRequestID = transferRequest.TransferInfo.TransferID; 12668 if (!assetServerURL.EndsWith("/") && !assetServerURL.EndsWith("="))
12669 assetServerURL = assetServerURL + "/";
12670
12671 //m_log.DebugFormat("[LLCLIENTVIEW]: asset {0} not found in local storage. Trying user's storage.", assetServerURL + id);
12672 asset = m_scene.AssetService.Get(assetServerURL + id);
12673 }
12674
12675 if (asset == null)
12676 {
12677 req.AssetInf = null;
12678 req.AssetRequestSource = source;
12679 req.IsTextureRequest = false;
12680 req.NumPackets = 0;
12681 req.Params = transferRequest.TransferInfo.Params;
12682 req.RequestAssetID = requestID;
12683 req.TransferRequestID = transferRequest.TransferInfo.TransferID;
12684
12685 SendAssetNotFound(req);
12686 return;
12687 }
12668 12688
12669 SendAssetNotFound(req);
12670 return;
12671 } 12689 }
12672 12690
12673 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) 12691 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index e9b2f4f..7333769 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -774,15 +774,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
774 (sbyte)AssetType.Object, 774 (sbyte)AssetType.Object,
775 Utils.StringToBytes(sceneObjectXml), 775 Utils.StringToBytes(sceneObjectXml),
776 sp.UUID); 776 sp.UUID);
777 m_scene.AssetService.Store(asset);
778 777
779 item.AssetID = asset.FullID; 778 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
780 item.Description = asset.Description;
781 item.Name = asset.Name;
782 item.AssetType = asset.Type;
783 item.InvType = (int)InventoryType.Object;
784 779
785 m_scene.InventoryService.UpdateItem(item); 780 invAccess.UpdateInventoryItemAsset(sp.UUID, item, asset);
786 781
787 // If the name of the object has been changed whilst attached then we want to update the inventory 782 // If the name of the object has been changed whilst attached then we want to update the inventory
788 // item in the viewer. 783 // item in the viewer.
diff --git a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs
index af8a0c1..780d17b 100644
--- a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs
@@ -37,6 +37,7 @@ using System.Collections.Generic;
37using System.Reflection; 37using System.Reflection;
38using log4net; 38using log4net;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Framework.ServiceAuth;
40using OpenSim.Framework.Communications; 41using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
@@ -54,7 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
54 private string m_URL = String.Empty; 55 private string m_URL = String.Empty;
55 private static XmlSerializer m_serializer = new XmlSerializer(typeof(AssetBase)); 56 private static XmlSerializer m_serializer = new XmlSerializer(typeof(AssetBase));
56 57
57 58 private static IServiceAuth m_Auth;
58 59
59 public void Initialise(IConfigSource configSource) 60 public void Initialise(IConfigSource configSource)
60 { 61 {
@@ -63,6 +64,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
63 return; 64 return;
64 65
65 m_URL = config.GetString("URL", String.Empty); 66 m_URL = config.GetString("URL", String.Empty);
67 m_Auth = ServiceAuth.Create(configSource, "XBakes");
66 } 68 }
67 69
68 public void AddRegion(Scene scene) 70 public void AddRegion(Scene scene)
@@ -110,7 +112,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
110 112
111 try 113 try
112 { 114 {
113 Stream s = rc.Request(); 115 Stream s = rc.Request(m_Auth);
114 XmlTextReader sr = new XmlTextReader(s); 116 XmlTextReader sr = new XmlTextReader(s);
115 117
116 sr.ReadStartElement("BakedAppearance"); 118 sr.ReadStartElement("BakedAppearance");
@@ -183,7 +185,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
183 Util.FireAndForget( 185 Util.FireAndForget(
184 delegate 186 delegate
185 { 187 {
186 rc.Request(reqStream); 188 rc.Request(reqStream, m_Auth);
187 } 189 }
188 ); 190 );
189 } 191 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs
new file mode 100644
index 0000000..7b8c418
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs
@@ -0,0 +1,286 @@
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 log4net.Config;
31using Nini.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Region.CoreModules.Avatar.Chat;
38using OpenSim.Region.CoreModules.Framework;
39using OpenSim.Region.CoreModules.Framework.EntityTransfer;
40using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Services.Interfaces;
43using OpenSim.Tests.Common;
44using OpenSim.Tests.Common.Mock;
45
46namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
47{
48 [TestFixture]
49 public class ChatModuleTests : OpenSimTestCase
50 {
51 [TestFixtureSetUp]
52 public void FixtureInit()
53 {
54 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
55 // We must do this here so that child agent positions are updated in a predictable manner.
56 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
57 }
58
59 [TestFixtureTearDown]
60 public void TearDown()
61 {
62 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
63 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
64 // tests really shouldn't).
65 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
66 }
67
68 private void SetupNeighbourRegions(TestScene sceneA, TestScene sceneB)
69 {
70 // XXX: HTTP server is not (and should not be) necessary for this test, though it's absence makes the
71 // CapabilitiesModule complain when it can't set up HTTP endpoints.
72 // BaseHttpServer httpServer = new BaseHttpServer(99999);
73 // MainServer.AddHttpServer(httpServer);
74 // MainServer.Instance = httpServer;
75
76 // We need entity transfer modules so that when sp2 logs into the east region, the region calls
77 // EntityTransferModuleto set up a child agent on the west region.
78 // XXX: However, this is not an entity transfer so is misleading.
79 EntityTransferModule etmA = new EntityTransferModule();
80 EntityTransferModule etmB = new EntityTransferModule();
81 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
82
83 IConfigSource config = new IniConfigSource();
84 config.AddConfig("Chat");
85 IConfig modulesConfig = config.AddConfig("Modules");
86 modulesConfig.Set("EntityTransferModule", etmA.Name);
87 modulesConfig.Set("SimulationServices", lscm.Name);
88
89 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
90 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, new ChatModule());
91 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB, new ChatModule());
92 }
93
94 /// <summary>
95 /// Tests chat between neighbour regions on the east-west axis
96 /// </summary>
97 /// <remarks>
98 /// Really, this is a combination of a child agent position update test and a chat range test. These need
99 /// to be separated later on.
100 /// </remarks>
101 [Test]
102 public void TestInterRegionChatDistanceEastWest()
103 {
104 TestHelpers.InMethod();
105// TestHelpers.EnableLogging();
106
107 UUID sp1Uuid = TestHelpers.ParseTail(0x11);
108 UUID sp2Uuid = TestHelpers.ParseTail(0x12);
109
110 Vector3 sp1Position = new Vector3(6, 128, 20);
111 Vector3 sp2Position = new Vector3(250, 128, 20);
112
113 SceneHelpers sh = new SceneHelpers();
114 TestScene sceneWest = sh.SetupScene("sceneWest", TestHelpers.ParseTail(0x1), 1000, 1000);
115 TestScene sceneEast = sh.SetupScene("sceneEast", TestHelpers.ParseTail(0x2), 1001, 1000);
116
117 SetupNeighbourRegions(sceneWest, sceneEast);
118
119 ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneEast, sp1Uuid);
120 TestClient sp1Client = (TestClient)sp1.ControllingClient;
121
122 // If we don't set agents to flying, test will go wrong as they instantly fall to z = 0.
123 // TODO: May need to create special complete no-op test physics module rather than basic physics, since
124 // physics is irrelevant to this test.
125 sp1.Flying = true;
126
127 // When sp1 logs in to sceneEast, it sets up a child agent in sceneWest and informs the sp2 client to
128 // make the connection. For this test, will simplify this chain by making the connection directly.
129 ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneWest, sp1Uuid);
130 TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient;
131
132 sp1.AbsolutePosition = sp1Position;
133
134 ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneWest, sp2Uuid);
135 TestClient sp2Client = (TestClient)sp2.ControllingClient;
136 sp2.Flying = true;
137
138 ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneEast, sp2Uuid);
139 TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient;
140
141 sp2.AbsolutePosition = sp2Position;
142
143 // We must update the scenes in order to make the root new root agents trigger position updates in their
144 // children.
145 sceneWest.Update(1);
146 sceneEast.Update(1);
147
148 // Check child positions are correct.
149 Assert.AreEqual(
150 new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z),
151 sp1ChildClient.SceneAgent.AbsolutePosition);
152
153 Assert.AreEqual(
154 new Vector3(sp2Position.X - sceneWest.RegionInfo.RegionSizeX, sp2Position.Y, sp2Position.Z),
155 sp2ChildClient.SceneAgent.AbsolutePosition);
156
157 string receivedSp1ChatMessage = "";
158 string receivedSp2ChatMessage = "";
159
160 sp1ChildClient.OnReceivedChatMessage
161 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message;
162 sp2ChildClient.OnReceivedChatMessage
163 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message;
164
165 TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage);
166 TestUserInRange(sp2Client, "fantastic cats", ref receivedSp1ChatMessage);
167
168 sp1Position = new Vector3(30, 128, 20);
169 sp1.AbsolutePosition = sp1Position;
170 sceneEast.Update(1);
171
172 // Check child position is correct.
173 Assert.AreEqual(
174 new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z),
175 sp1ChildClient.SceneAgent.AbsolutePosition);
176
177 TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage);
178 TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage);
179 }
180
181 /// <summary>
182 /// Tests chat between neighbour regions on the north-south axis
183 /// </summary>
184 /// <remarks>
185 /// Really, this is a combination of a child agent position update test and a chat range test. These need
186 /// to be separated later on.
187 /// </remarks>
188 [Test]
189 public void TestInterRegionChatDistanceNorthSouth()
190 {
191 TestHelpers.InMethod();
192 // TestHelpers.EnableLogging();
193
194 UUID sp1Uuid = TestHelpers.ParseTail(0x11);
195 UUID sp2Uuid = TestHelpers.ParseTail(0x12);
196
197 Vector3 sp1Position = new Vector3(128, 250, 20);
198 Vector3 sp2Position = new Vector3(128, 6, 20);
199
200 SceneHelpers sh = new SceneHelpers();
201 TestScene sceneNorth = sh.SetupScene("sceneNorth", TestHelpers.ParseTail(0x1), 1000, 1000);
202 TestScene sceneSouth = sh.SetupScene("sceneSouth", TestHelpers.ParseTail(0x2), 1000, 1001);
203
204 SetupNeighbourRegions(sceneNorth, sceneSouth);
205
206 ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneNorth, sp1Uuid);
207 TestClient sp1Client = (TestClient)sp1.ControllingClient;
208
209 // If we don't set agents to flying, test will go wrong as they instantly fall to z = 0.
210 // TODO: May need to create special complete no-op test physics module rather than basic physics, since
211 // physics is irrelevant to this test.
212 sp1.Flying = true;
213
214 // When sp1 logs in to sceneEast, it sets up a child agent in sceneNorth and informs the sp2 client to
215 // make the connection. For this test, will simplify this chain by making the connection directly.
216 ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneSouth, sp1Uuid);
217 TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient;
218
219 sp1.AbsolutePosition = sp1Position;
220
221 ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneSouth, sp2Uuid);
222 TestClient sp2Client = (TestClient)sp2.ControllingClient;
223 sp2.Flying = true;
224
225 ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneNorth, sp2Uuid);
226 TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient;
227
228 sp2.AbsolutePosition = sp2Position;
229
230 // We must update the scenes in order to make the root new root agents trigger position updates in their
231 // children.
232 sceneNorth.Update(1);
233 sceneSouth.Update(1);
234
235 // Check child positions are correct.
236 Assert.AreEqual(
237 new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z),
238 sp1ChildClient.SceneAgent.AbsolutePosition);
239
240 Assert.AreEqual(
241 new Vector3(sp2Position.X, sp2Position.Y + sceneSouth.RegionInfo.RegionSizeY, sp2Position.Z),
242 sp2ChildClient.SceneAgent.AbsolutePosition);
243
244 string receivedSp1ChatMessage = "";
245 string receivedSp2ChatMessage = "";
246
247 sp1ChildClient.OnReceivedChatMessage
248 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message;
249 sp2ChildClient.OnReceivedChatMessage
250 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message;
251
252 TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage);
253 TestUserInRange(sp2Client, "fantastic cats", ref receivedSp1ChatMessage);
254
255 sp1Position = new Vector3(30, 128, 20);
256 sp1.AbsolutePosition = sp1Position;
257 sceneNorth.Update(1);
258
259 // Check child position is correct.
260 Assert.AreEqual(
261 new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z),
262 sp1ChildClient.SceneAgent.AbsolutePosition);
263
264 TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage);
265 TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage);
266 }
267
268 private void TestUserInRange(TestClient speakClient, string testMessage, ref string receivedMessage)
269 {
270 receivedMessage = "";
271
272 speakClient.Chat(0, ChatTypeEnum.Say, testMessage);
273
274 Assert.AreEqual(testMessage, receivedMessage);
275 }
276
277 private void TestUserOutOfRange(TestClient speakClient, string testMessage, ref string receivedMessage)
278 {
279 receivedMessage = "";
280
281 speakClient.Chat(0, ChatTypeEnum.Say, testMessage);
282
283 Assert.AreNotEqual(testMessage, receivedMessage);
284 }
285 }
286} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs
index c51b30f..6f3c80a 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs
@@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
210 success = m_IMService.OutgoingInstantMessage(im, url, foreigner); 210 success = m_IMService.OutgoingInstantMessage(im, url, foreigner);
211 211
212 if (!success && !foreigner) 212 if (!success && !foreigner)
213 HandleUndeliveredMessage(im, result); 213 HandleUndeliverableMessage(im, result);
214 else 214 else
215 result(success); 215 result(success);
216 }); 216 });
@@ -246,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
246 return successful; 246 return successful;
247 } 247 }
248 248
249 protected void HandleUndeliveredMessage(GridInstantMessage im, MessageResultNotification result) 249 public void HandleUndeliverableMessage(GridInstantMessage im, MessageResultNotification result)
250 { 250 {
251 UndeliveredMessage handlerUndeliveredMessage = OnUndeliveredMessage; 251 UndeliveredMessage handlerUndeliveredMessage = OnUndeliveredMessage;
252 252
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 40a400f..2462ff8 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
181 SendGridInstantMessageViaXMLRPC(im, result); 181 SendGridInstantMessageViaXMLRPC(im, result);
182 } 182 }
183 183
184 private void HandleUndeliveredMessage(GridInstantMessage im, MessageResultNotification result) 184 public void HandleUndeliverableMessage(GridInstantMessage im, MessageResultNotification result)
185 { 185 {
186 UndeliveredMessage handlerUndeliveredMessage = OnUndeliveredMessage; 186 UndeliveredMessage handlerUndeliveredMessage = OnUndeliveredMessage;
187 187
@@ -428,7 +428,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
428 /// <summary> 428 /// <summary>
429 /// delegate for sending a grid instant message asynchronously 429 /// delegate for sending a grid instant message asynchronously
430 /// </summary> 430 /// </summary>
431 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID); 431 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
432 432
433 protected virtual void GridInstantMessageCompleted(IAsyncResult iar) 433 protected virtual void GridInstantMessageCompleted(IAsyncResult iar)
434 { 434 {
@@ -442,138 +442,87 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
442 { 442 {
443 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; 443 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync;
444 444
445 d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); 445 d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
446 } 446 }
447 447
448 /// <summary> 448 /// <summary>
449 /// Recursive SendGridInstantMessage over XMLRPC method. 449 /// Internal SendGridInstantMessage over XMLRPC method.
450 /// This is called from within a dedicated thread.
451 /// The first time this is called, prevRegionHandle will be 0 Subsequent times this is called from
452 /// itself, prevRegionHandle will be the last region handle that we tried to send.
453 /// If the handles are the same, we look up the user's location using the grid.
454 /// If the handles are still the same, we end. The send failed.
455 /// </summary> 450 /// </summary>
456 /// <param name="prevRegionHandle"> 451 /// <remarks>
457 /// Pass in 0 the first time this method is called. It will be called recursively with the last 452 /// This is called from within a dedicated thread.
458 /// regionhandle tried 453 /// </remarks>
459 /// </param> 454 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result)
460 protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
461 { 455 {
462 UUID toAgentID = new UUID(im.toAgentID); 456 UUID toAgentID = new UUID(im.toAgentID);
463 457 UUID regionID;
464 PresenceInfo upd = null; 458 bool needToLookupAgent;
465
466 bool lookupAgent = false;
467 459
468 lock (m_UserRegionMap) 460 lock (m_UserRegionMap)
461 needToLookupAgent = !m_UserRegionMap.TryGetValue(toAgentID, out regionID);
462
463 while (true)
469 { 464 {
470 if (m_UserRegionMap.ContainsKey(toAgentID)) 465 if (needToLookupAgent)
471 { 466 {
472 upd = new PresenceInfo(); 467 PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() });
473 upd.RegionID = m_UserRegionMap[toAgentID];
474 468
475 // We need to compare the current regionhandle with the previous region handle 469 UUID foundRegionID = UUID.Zero;
476 // or the recursive loop will never end because it will never try to lookup the agent again
477 if (prevRegionID == upd.RegionID)
478 {
479 lookupAgent = true;
480 }
481 }
482 else
483 {
484 lookupAgent = true;
485 }
486 }
487
488 470
489 // Are we needing to look-up an agent? 471 if (presences != null)
490 if (lookupAgent)
491 {
492 // Non-cached user agent lookup.
493 PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() });
494 if (presences != null && presences.Length > 0)
495 {
496 foreach (PresenceInfo p in presences)
497 { 472 {
498 if (p.RegionID != UUID.Zero) 473 foreach (PresenceInfo p in presences)
499 { 474 {
500 upd = p; 475 if (p.RegionID != UUID.Zero)
501 break; 476 {
477 foundRegionID = p.RegionID;
478 break;
479 }
502 } 480 }
503 } 481 }
504 }
505 482
506 if (upd != null) 483 // If not found or the found region is the same as the last lookup, then message is undeliverable
507 { 484 if (foundRegionID == UUID.Zero || foundRegionID == regionID)
508 // check if we've tried this before.. 485 break;
509 // This is one way to end the recursive loop 486 else
510 // 487 regionID = foundRegionID;
511 if (upd.RegionID == prevRegionID)
512 {
513 // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
514 HandleUndeliveredMessage(im, result);
515 return;
516 }
517 } 488 }
518 else 489
490 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, regionID);
491 if (reginfo == null)
519 { 492 {
520 // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); 493 m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", regionID);
521 HandleUndeliveredMessage(im, result); 494 break;
522 return;
523 } 495 }
524 }
525 496
526 if (upd != null) 497 // Try to send the message to the agent via the retrieved region.
527 { 498 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
528 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, 499 msgdata["region_handle"] = 0;
529 upd.RegionID); 500 bool imresult = doIMSending(reginfo, msgdata);
530 if (reginfo != null) 501
502 // If the message delivery was successful, then cache the entry.
503 if (imresult)
531 { 504 {
532 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); 505 lock (m_UserRegionMap)
533 // Not actually used anymore, left in for compatibility
534 // Remove at next interface change
535 //
536 msgdata["region_handle"] = 0;
537 bool imresult = doIMSending(reginfo, msgdata);
538 if (imresult)
539 {
540 // IM delivery successful, so store the Agent's location in our local cache.
541 lock (m_UserRegionMap)
542 {
543 if (m_UserRegionMap.ContainsKey(toAgentID))
544 {
545 m_UserRegionMap[toAgentID] = upd.RegionID;
546 }
547 else
548 {
549 m_UserRegionMap.Add(toAgentID, upd.RegionID);
550 }
551 }
552 result(true);
553 }
554 else
555 { 506 {
556 // try again, but lookup user this time. 507 m_UserRegionMap[toAgentID] = regionID;
557 // Warning, this must call the Async version
558 // of this method or we'll be making thousands of threads
559 // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync
560 // The version that spawns the thread is SendGridInstantMessageViaXMLRPC
561
562 // This is recursive!!!!!
563 SendGridInstantMessageViaXMLRPCAsync(im, result,
564 upd.RegionID);
565 } 508 }
509 result(true);
510 return;
566 } 511 }
567 else 512
568 { 513 // If we reach this point in the first iteration of the while, then we may have unsuccessfully tried
569 m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); 514 // to use a locally cached region ID. All subsequent attempts need to lookup agent details from
570 HandleUndeliveredMessage(im, result); 515 // the presence service.
571 } 516 needToLookupAgent = true;
572 }
573 else
574 {
575 HandleUndeliveredMessage(im, result);
576 } 517 }
518
519 // If we reached this point then the message was not deliverable. Remove the bad cache entry and
520 // signal the delivery failure.
521 lock (m_UserRegionMap)
522 m_UserRegionMap.Remove(toAgentID);
523
524 // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
525 HandleUndeliverableMessage(im, result);
577 } 526 }
578 527
579 /// <summary> 528 /// <summary>
@@ -584,7 +533,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
584 /// <returns>Bool if the message was successfully delivered at the other side.</returns> 533 /// <returns>Bool if the message was successfully delivered at the other side.</returns>
585 protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata) 534 protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata)
586 { 535 {
587
588 ArrayList SendParams = new ArrayList(); 536 ArrayList SendParams = new ArrayList();
589 SendParams.Add(xmlrpcdata); 537 SendParams.Add(xmlrpcdata);
590 XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams); 538 XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams);
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index 7f3d0a2..c75920d 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -226,12 +226,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
226 return; 226 return;
227 } 227 }
228 228
229 Scene scene = FindScene(new UUID(im.fromAgentID));
230 if (scene == null)
231 scene = m_SceneList[0];
232
233 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( 229 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
234 "POST", m_RestURL+"/SaveMessage/", im); 230 "POST", m_RestURL+"/SaveMessage/", im, 10000);
235 231
236 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 232 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
237 { 233 {
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index 1ee2a7b..c4b5aac 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -484,6 +484,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
484 { 484 {
485 remoteClient.SendAgentAlertMessage( 485 remoteClient.SendAgentAlertMessage(
486 "Error updating classified", false); 486 "Error updating classified", false);
487 return;
487 } 488 }
488 } 489 }
489 490
@@ -510,6 +511,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
510 { 511 {
511 remoteClient.SendAgentAlertMessage( 512 remoteClient.SendAgentAlertMessage(
512 "Error classified delete", false); 513 "Error classified delete", false);
514 return;
513 } 515 }
514 516
515 parameters = (OSDMap)Params; 517 parameters = (OSDMap)Params;
@@ -612,6 +614,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
612 { 614 {
613 remoteClient.SendAgentAlertMessage( 615 remoteClient.SendAgentAlertMessage(
614 "Error selecting pick", false); 616 "Error selecting pick", false);
617 return;
615 } 618 }
616 pick = (UserProfilePick) Pick; 619 pick = (UserProfilePick) Pick;
617 620
@@ -714,6 +717,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
714 { 717 {
715 remoteClient.SendAgentAlertMessage( 718 remoteClient.SendAgentAlertMessage(
716 "Error updating pick", false); 719 "Error updating pick", false);
720 return;
717 } 721 }
718 722
719 m_log.DebugFormat("[PROFILES]: Finish PickInfoUpdate {0} {1}", pick.Name, pick.PickId.ToString()); 723 m_log.DebugFormat("[PROFILES]: Finish PickInfoUpdate {0} {1}", pick.Name, pick.PickId.ToString());
@@ -740,6 +744,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
740 { 744 {
741 remoteClient.SendAgentAlertMessage( 745 remoteClient.SendAgentAlertMessage(
742 "Error picks delete", false); 746 "Error picks delete", false);
747 return;
743 } 748 }
744 } 749 }
745 #endregion Picks 750 #endregion Picks
@@ -807,6 +812,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
807 object Note = note; 812 object Note = note;
808 if(!rpc.JsonRpcRequest(ref Note, "avatar_notes_update", serverURI, UUID.Random().ToString())) 813 if(!rpc.JsonRpcRequest(ref Note, "avatar_notes_update", serverURI, UUID.Random().ToString()))
809 { 814 {
815 remoteClient.SendAgentAlertMessage(
816 "Error updating note", false);
810 return; 817 return;
811 } 818 }
812 } 819 }
@@ -916,6 +923,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
916 { 923 {
917 remoteClient.SendAgentAlertMessage( 924 remoteClient.SendAgentAlertMessage(
918 "Error updating interests", false); 925 "Error updating interests", false);
926 return;
919 } 927 }
920 } 928 }
921 929
@@ -1044,6 +1052,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
1044 { 1052 {
1045 remoteClient.SendAgentAlertMessage( 1053 remoteClient.SendAgentAlertMessage(
1046 "Error updating properties", false); 1054 "Error updating properties", false);
1055 return;
1047 } 1056 }
1048 1057
1049 RequestAvatarProperties(remoteClient, newProfile.ID); 1058 RequestAvatarProperties(remoteClient, newProfile.ID);
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 539367d..e583590 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -761,12 +761,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
761 string reason; 761 string reason;
762 string version; 762 string version;
763 if (!Scene.SimulationService.QueryAccess( 763 if (!Scene.SimulationService.QueryAccess(
764 finalDestination, sp.ControllingClient.AgentId, homeURI, position, out version, out reason)) 764 finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, out version, out reason))
765 { 765 {
766 sp.ControllingClient.SendTeleportFailed(reason); 766 sp.ControllingClient.SendTeleportFailed(reason);
767 767
768 m_log.DebugFormat( 768 m_log.DebugFormat(
769 "[ENTITY TRANSFER MODULE]: {0} was stopped from teleporting from {1} to {2} because {3}", 769 "[ENTITY TRANSFER MODULE]: {0} was stopped from teleporting from {1} to {2} because: {3}",
770 sp.Name, sp.Scene.Name, finalDestination.RegionName, reason); 770 sp.Name, sp.Scene.Name, finalDestination.RegionName, reason);
771 771
772 return; 772 return;
@@ -1510,7 +1510,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1510 1510
1511 // Check to see if we have access to the target region. 1511 // Check to see if we have access to the target region.
1512 if (neighbourRegion != null 1512 if (neighbourRegion != null
1513 && !scene.SimulationService.QueryAccess(neighbourRegion, agentID, homeURI, newpos, out version, out failureReason)) 1513 && !scene.SimulationService.QueryAccess(neighbourRegion, agentID, homeURI, false, newpos, out version, out failureReason))
1514 { 1514 {
1515 // remember banned 1515 // remember banned
1516 m_bannedRegionCache.Add(neighbourRegion.RegionHandle, agentID); 1516 m_bannedRegionCache.Add(neighbourRegion.RegionHandle, agentID);
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index ce7ed26..5e831cc 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -64,6 +64,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
64 64
65 private bool m_bypassPermissions = true; 65 private bool m_bypassPermissions = true;
66 66
67 // This simple check makes it possible to support grids in which all the simulators
68 // share all central services of the Robust server EXCEPT assets. In other words,
69 // grids where the simulators' assets are kept in one DB and the users' inventory assets
70 // are kept on another. When users rez items from inventory or take objects from world,
71 // an HG-like asset copy takes place between the 2 servers, the world asset server and
72 // the user's asset server.
73 private bool m_CheckSeparateAssets = false;
74 private string m_LocalAssetsURL = string.Empty;
75
67// private bool m_Initialized = false; 76// private bool m_Initialized = false;
68 77
69 #region INonSharedRegionModule 78 #region INonSharedRegionModule
@@ -99,6 +108,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
99 108
100 m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); 109 m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true);
101 m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); 110 m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true);
111 m_CheckSeparateAssets = thisModuleConfig.GetBoolean("CheckSeparateAssets", false);
112 m_LocalAssetsURL = thisModuleConfig.GetString("RegionHGAssetServerURI", string.Empty);
113 m_LocalAssetsURL = m_LocalAssetsURL.Trim(new char[] { '/' });
114
102 } 115 }
103 else 116 else
104 m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); 117 m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!");
@@ -240,6 +253,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
240 return newAssetID; 253 return newAssetID;
241 } 254 }
242 255
256 ///
257 /// UpdateInventoryItemAsset
258 ///
259 public override bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset)
260 {
261 if (base.UpdateInventoryItemAsset(ownerID, item, asset))
262 {
263 UploadInventoryItem(ownerID, (AssetType)asset.Type, asset.FullID, asset.Name, 0);
264 return true;
265 }
266
267 return false;
268 }
269
243 /// 270 ///
244 /// Used in DeleteToInventory 271 /// Used in DeleteToInventory
245 /// 272 ///
@@ -284,50 +311,98 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
284 SceneObjectGroup sog = base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 311 SceneObjectGroup sog = base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
285 RezSelected, RemoveItem, fromTaskID, attachment); 312 RezSelected, RemoveItem, fromTaskID, attachment);
286 313
287 if (sog == null)
288 remoteClient.SendAgentAlertMessage("Unable to rez: problem accessing inventory or locating assets", false);
289
290 return sog; 314 return sog;
291 315
292 } 316 }
293 317
294 public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) 318 public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
295 { 319 {
296 string userAssetServer = string.Empty; 320 string senderAssetServer = string.Empty;
297 if (IsForeignUser(sender, out userAssetServer) && userAssetServer != string.Empty) 321 string receiverAssetServer = string.Empty;
298 m_assMapper.Get(item.AssetID, sender, userAssetServer); 322 bool isForeignSender, isForeignReceiver;
323 isForeignSender = IsForeignUser(sender, out senderAssetServer);
324 isForeignReceiver = IsForeignUser(receiver, out receiverAssetServer);
325
326 // They're both local. Nothing to do.
327 if (!isForeignSender && !isForeignReceiver)
328 return;
299 329
300 if (IsForeignUser(receiver, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) 330 // At least one of them is foreign.
301 m_assMapper.Post(item.AssetID, receiver, userAssetServer); 331 // If both users have the same asset server, no need to transfer the asset
332 if (senderAssetServer.Equals(receiverAssetServer))
333 {
334 m_log.DebugFormat("[HGScene]: Asset transfer between foreign users, but they have the same server. No transfer.");
335 return;
336 }
337
338 if (isForeignSender && senderAssetServer != string.Empty)
339 m_assMapper.Get(item.AssetID, sender, senderAssetServer);
340
341 if (isForeignReceiver && receiverAssetServer != string.Empty && m_OutboundPermission)
342 m_assMapper.Post(item.AssetID, receiver, receiverAssetServer);
302 } 343 }
303 344
304 public override bool IsForeignUser(UUID userID, out string assetServerURL) 345 public override bool IsForeignUser(UUID userID, out string assetServerURL)
305 { 346 {
306 assetServerURL = string.Empty; 347 assetServerURL = string.Empty;
307 348
308 if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID)) 349 if (UserManagementModule != null)
309 { // foreign 350 {
310 ScenePresence sp = null; 351 if (!m_CheckSeparateAssets)
311 if (m_Scene.TryGetScenePresence(userID, out sp))
312 { 352 {
313 AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 353 if (!UserManagementModule.IsLocalGridUser(userID))
314 if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) 354 { // foreign
315 { 355 ScenePresence sp = null;
316 assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); 356 if (m_Scene.TryGetScenePresence(userID, out sp))
317 assetServerURL = assetServerURL.Trim(new char[] { '/' }); 357 {
358 AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
359 if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
360 {
361 assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString();
362 assetServerURL = assetServerURL.Trim(new char[] { '/' });
363 }
364 }
365 else
366 {
367 assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI");
368 assetServerURL = assetServerURL.Trim(new char[] { '/' });
369 }
370 return true;
318 } 371 }
319 } 372 }
320 else 373 else
321 { 374 {
322 assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); 375 if (IsLocalInventoryAssetsUser(userID, out assetServerURL))
323 assetServerURL = assetServerURL.Trim(new char[] { '/' }); 376 {
377 m_log.DebugFormat("[HGScene]: user {0} has local assets {1}", userID, assetServerURL);
378 return false;
379 }
380 else
381 {
382 m_log.DebugFormat("[HGScene]: user {0} has foreign assets {1}", userID, assetServerURL);
383 return true;
384 }
324 } 385 }
325 return true;
326 } 386 }
327
328 return false; 387 return false;
329 } 388 }
330 389
390 private bool IsLocalInventoryAssetsUser(UUID uuid, out string assetsURL)
391 {
392 assetsURL = UserManagementModule.GetUserServerURL(uuid, "AssetServerURI");
393 if (assetsURL == string.Empty)
394 {
395 AgentCircuitData agent = m_Scene.AuthenticateHandler.GetAgentCircuitData(uuid);
396 if (agent != null)
397 {
398 assetsURL = agent.ServiceURLs["AssetServerURI"].ToString();
399 assetsURL = assetsURL.Trim(new char[] { '/' });
400 }
401 }
402 return m_LocalAssetsURL.Equals(assetsURL);
403 }
404
405
331 protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) 406 protected override InventoryItemBase GetItem(UUID agentID, UUID itemID)
332 { 407 {
333 InventoryItemBase item = base.GetItem(agentID, itemID); 408 InventoryItemBase item = base.GetItem(agentID, itemID);
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index d30ce72..b4771fd 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -203,7 +203,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
203 m_Scene.AssetService.Store(asset); 203 m_Scene.AssetService.Store(asset);
204 m_Scene.CreateNewInventoryItem( 204 m_Scene.CreateNewInventoryItem(
205 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, 205 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
206 name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate); 206 name, description, 0, callbackID, asset.FullID, asset.Type, invType, nextOwnerMask, creationDate);
207 } 207 }
208 else 208 else
209 { 209 {
@@ -292,7 +292,31 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
292 292
293 return UUID.Zero; 293 return UUID.Zero;
294 } 294 }
295 295
296 public virtual bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset)
297 {
298 if (item != null && item.Owner == ownerID && asset != null)
299 {
300 item.AssetID = asset.FullID;
301 item.Description = asset.Description;
302 item.Name = asset.Name;
303 item.AssetType = asset.Type;
304 item.InvType = (int)InventoryType.Object;
305
306 m_Scene.AssetService.Store(asset);
307 m_Scene.InventoryService.UpdateItem(item);
308
309 return true;
310 }
311 else
312 {
313 m_log.ErrorFormat("[INVENTORY ACCESS MODULE]: Given invalid item for inventory update: {0}",
314 (item == null || asset == null? "null item or asset" : "wrong owner"));
315 return false;
316 }
317
318 }
319
296 public virtual List<InventoryItemBase> CopyToInventory( 320 public virtual List<InventoryItemBase> CopyToInventory(
297 DeRezAction action, UUID folderID, 321 DeRezAction action, UUID folderID,
298 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient, bool asAttachment) 322 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient, bool asAttachment)
@@ -532,6 +556,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
532 556
533 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 557 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
534 { 558 {
559 // Changing ownership, so apply the "Next Owner" permissions to all of the
560 // inventory item's permissions.
561
535 uint perms = effectivePerms; 562 uint perms = effectivePerms;
536 PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms); 563 PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms);
537 564
@@ -546,6 +573,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
546 } 573 }
547 else 574 else
548 { 575 {
576 // Not changing ownership.
577 // In this case we apply the permissions in the object's items ONLY to the inventory
578 // item's "Next Owner" permissions, but NOT to its "Current", "Base", etc. permissions.
579 // E.g., if the object contains a No-Transfer item then the item's "Next Owner"
580 // permissions are also No-Transfer.
581 PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref allObjectsNextOwnerPerms);
582
549 item.BasePermissions = effectivePerms; 583 item.BasePermissions = effectivePerms;
550 item.CurrentPermissions = effectivePerms; 584 item.CurrentPermissions = effectivePerms;
551 item.NextPermissions = allObjectsNextOwnerPerms & effectivePerms; 585 item.NextPermissions = allObjectsNextOwnerPerms & effectivePerms;
@@ -773,12 +807,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
773 m_log.WarnFormat( 807 m_log.WarnFormat(
774 "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", 808 "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()",
775 assetID, item.Name, item.ID, remoteClient.Name); 809 assetID, item.Name, item.ID, remoteClient.Name);
810 remoteClient.SendAgentAlertMessage(string.Format("Unable to rez: could not find asset {0} for item {1}.", assetID, item.Name), false);
776 } 811 }
777 else 812 else
778 { 813 {
779 m_log.WarnFormat( 814 m_log.WarnFormat(
780 "[INVENTORY ACCESS MODULE]: Could not find asset {0} for {1} in RezObject()", 815 "[INVENTORY ACCESS MODULE]: Could not find asset {0} for {1} in RezObject()",
781 assetID, remoteClient.Name); 816 assetID, remoteClient.Name);
817 remoteClient.SendAgentAlertMessage(string.Format("Unable to rez: could not find asset {0}.", assetID), false);
782 } 818 }
783 819
784 return null; 820 return null;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
index 4470799..93dff1f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
@@ -89,35 +89,43 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
89 public bool IsAuthorizedForRegion( 89 public bool IsAuthorizedForRegion(
90 string user, string firstName, string lastName, string regionID, out string message) 90 string user, string firstName, string lastName, string regionID, out string message)
91 { 91 {
92 message = "authorized";
93
94 // This should not happen 92 // This should not happen
95 if (m_Scene.RegionInfo.RegionID.ToString() != regionID) 93 if (m_Scene.RegionInfo.RegionID.ToString() != regionID)
96 { 94 {
97 m_log.WarnFormat("[AuthorizationService]: Service for region {0} received request to authorize for region {1}", 95 m_log.WarnFormat("[AuthorizationService]: Service for region {0} received request to authorize for region {1}",
98 m_Scene.RegionInfo.RegionID, regionID); 96 m_Scene.RegionInfo.RegionID, regionID);
99 return true; 97 message = string.Format("Region {0} received request to authorize for region {1}", m_Scene.RegionInfo.RegionID, regionID);
98 return false;
100 } 99 }
101 100
102 if (m_accessValue == AccessFlags.None) 101 if (m_accessValue == AccessFlags.None)
102 {
103 message = "Authorized";
103 return true; 104 return true;
105 }
104 106
105 UUID userID = new UUID(user); 107 UUID userID = new UUID(user);
106 bool authorized = true; 108
107 if ((m_accessValue & AccessFlags.DisallowForeigners) == AccessFlags.DisallowForeigners) 109 if ((m_accessValue & AccessFlags.DisallowForeigners) != 0)
108 { 110 {
109 authorized = m_UserManagement.IsLocalGridUser(userID); 111 if (!m_UserManagement.IsLocalGridUser(userID))
110 if (!authorized) 112 {
111 message = "no foreigner users allowed in this region"; 113 message = "No foreign users allowed in this region";
114 return false;
115 }
112 } 116 }
113 if (authorized && (m_accessValue & AccessFlags.DisallowResidents) == AccessFlags.DisallowResidents) 117
118 if ((m_accessValue & AccessFlags.DisallowResidents) != 0)
114 { 119 {
115 authorized = m_Scene.Permissions.IsGod(userID) | m_Scene.Permissions.IsAdministrator(userID); 120 if (!(m_Scene.Permissions.IsGod(userID) || m_Scene.Permissions.IsAdministrator(userID)))
116 if (!authorized) 121 {
117 message = "only Admins and Managers allowed in this region"; 122 message = "Only Admins and Managers allowed in this region";
123 return false;
124 }
118 } 125 }
119 126
120 return authorized; 127 message = "Authorized";
128 return true;
121 } 129 }
122 130
123 } 131 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
index 516ad40..50c252c 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
@@ -69,7 +69,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
69 public void OnMakeRootAgent(ScenePresence sp) 69 public void OnMakeRootAgent(ScenePresence sp)
70 { 70 {
71// m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); 71// m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
72 m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID); 72 if (sp.PresenceType != PresenceType.Npc)
73 m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID);
73 } 74 }
74 75
75 public void OnNewClient(IClientAPI client) 76 public void OnNewClient(IClientAPI client)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 3348b42..926ef05 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -264,7 +264,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
264 return true; 264 return true;
265 } 265 }
266 266
267 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, out string version, out string reason) 267 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason)
268 { 268 {
269 reason = "Communications failure"; 269 reason = "Communications failure";
270 version = ServiceVersion; 270 version = ServiceVersion;
@@ -277,7 +277,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
277// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", 277// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
278// s.RegionInfo.RegionName, destination.RegionHandle); 278// s.RegionInfo.RegionName, destination.RegionHandle);
279 279
280 return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, position, out reason); 280 return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, viaTeleport, position, out reason);
281 } 281 }
282 282
283 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess"); 283 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index 8436488..0444e49 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -207,7 +207,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
207 return m_remoteConnector.UpdateAgent(destination, cAgentData); 207 return m_remoteConnector.UpdateAgent(destination, cAgentData);
208 } 208 }
209 209
210 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, out string version, out string reason) 210 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason)
211 { 211 {
212 reason = "Communications failure"; 212 reason = "Communications failure";
213 version = "Unknown"; 213 version = "Unknown";
@@ -216,12 +216,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
216 return false; 216 return false;
217 217
218 // Try local first 218 // Try local first
219 if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, position, out version, out reason)) 219 if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, out version, out reason))
220 return true; 220 return true;
221 221
222 // else do the remote thing 222 // else do the remote thing
223 if (!m_localBackend.IsLocalRegion(destination.RegionID)) 223 if (!m_localBackend.IsLocalRegion(destination.RegionID))
224 return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, position, out version, out reason); 224 return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, out version, out reason);
225 225
226 return false; 226 return false;
227 } 227 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index e08a42d..b31257d 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -585,7 +585,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
585 ld.GlobalID = landID; 585 ld.GlobalID = landID;
586 586
587 string ldPath = ArchiveConstants.CreateOarLandDataPath(ld); 587 string ldPath = ArchiveConstants.CreateOarLandDataPath(ld);
588 tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, null)); 588 Dictionary<string, object> options = new Dictionary<string, object>();
589 tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, options));
589 tar.Close(); 590 tar.Close();
590 591
591 oarStream = new MemoryStream(oarStream.ToArray()); 592 oarStream = new MemoryStream(oarStream.ToArray());
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index a032bc7..eecc478 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -1106,13 +1106,14 @@ namespace OpenSim.Region.CoreModules.World.Estate
1106 1106
1107 TerrainUploader = null; 1107 TerrainUploader = null;
1108 } 1108 }
1109
1110 m_log.DebugFormat("[CLIENT]: Terrain upload from {0} to {1} complete.", remoteClient.Name, Scene.Name);
1109 remoteClient.SendAlertMessage("Terrain Upload Complete. Loading...."); 1111 remoteClient.SendAlertMessage("Terrain Upload Complete. Loading....");
1112
1110 ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>(); 1113 ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
1111 1114
1112 if (terr != null) 1115 if (terr != null)
1113 { 1116 {
1114 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
1115
1116 try 1117 try
1117 { 1118 {
1118 MemoryStream terrainStream = new MemoryStream(terrainData); 1119 MemoryStream terrainStream = new MemoryStream(terrainData);
@@ -1161,7 +1162,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
1161 { 1162 {
1162 if (TerrainUploader == null) 1163 if (TerrainUploader == null)
1163 { 1164 {
1164 m_log.DebugFormat("Starting to receive uploaded terrain"); 1165 m_log.DebugFormat(
1166 "[TERRAIN]: Started receiving terrain upload for region {0} from {1}",
1167 Scene.Name, remote_client.Name);
1168
1165 TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName); 1169 TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
1166 remote_client.OnXferReceive += TerrainUploader.XferReceive; 1170 remote_client.OnXferReceive += TerrainUploader.XferReceive;
1167 remote_client.OnAbortXfer += AbortTerrainXferHandler; 1171 remote_client.OnAbortXfer += AbortTerrainXferHandler;
@@ -1182,7 +1186,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
1182 1186
1183 if (terr != null) 1187 if (terr != null)
1184 { 1188 {
1185 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName); 1189// m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
1186 if (File.Exists(Util.dataDir() + "/terrain.raw")) 1190 if (File.Exists(Util.dataDir() + "/terrain.raw"))
1187 { 1191 {
1188 File.Delete(Util.dataDir() + "/terrain.raw"); 1192 File.Delete(Util.dataDir() + "/terrain.raw");
@@ -1194,8 +1198,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
1194 input.Read(bdata, 0, (int)input.Length); 1198 input.Read(bdata, 0, (int)input.Length);
1195 remote_client.SendAlertMessage("Terrain file written, starting download..."); 1199 remote_client.SendAlertMessage("Terrain file written, starting download...");
1196 Scene.XferManager.AddNewFile("terrain.raw", bdata); 1200 Scene.XferManager.AddNewFile("terrain.raw", bdata);
1197 // Tell client about it 1201
1198 m_log.Warn("[CLIENT]: Sending Terrain to " + remote_client.Name); 1202 m_log.DebugFormat("[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name);
1203
1199 remote_client.SendInitiateDownload("terrain.raw", clientFileName); 1204 remote_client.SendInitiateDownload("terrain.raw", clientFileName);
1200 } 1205 }
1201 } 1206 }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index c35f6b7..de7ea6d 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -49,6 +49,18 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
49 List<Scene> m_scenes = new List<Scene>(); 49 List<Scene> m_scenes = new List<Scene>();
50 List<UUID> m_Clients; 50 List<UUID> m_Clients;
51 51
52 IWorldMapModule m_WorldMap;
53 IWorldMapModule WorldMap
54 {
55 get
56 {
57 if (m_WorldMap == null)
58 m_WorldMap = m_scene.RequestModuleInterface<IWorldMapModule>();
59 return m_WorldMap;
60 }
61
62 }
63
52 #region ISharedRegionModule Members 64 #region ISharedRegionModule Members
53 public void Initialise(IConfigSource source) 65 public void Initialise(IConfigSource source)
54 { 66 {
@@ -64,6 +76,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
64 m_scenes.Add(scene); 76 m_scenes.Add(scene);
65 scene.EventManager.OnNewClient += OnNewClient; 77 scene.EventManager.OnNewClient += OnNewClient;
66 m_Clients = new List<UUID>(); 78 m_Clients = new List<UUID>();
79
67 } 80 }
68 81
69 public void RemoveRegion(Scene scene) 82 public void RemoveRegion(Scene scene)
@@ -129,7 +142,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
129 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) 142 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags)
130 { 143 {
131 List<MapBlockData> blocks = new List<MapBlockData>(); 144 List<MapBlockData> blocks = new List<MapBlockData>();
132 MapBlockData data;
133 if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) 145 if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4))
134 { 146 {
135 // final block, closing the search result 147 // final block, closing the search result
@@ -143,50 +155,50 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
143 } 155 }
144 156
145 157
146 //m_log.DebugFormat("MAP NAME=({0})", mapName); 158 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
147 159
148 // Hack to get around the fact that ll V3 now drops the port from the
149 // map name. See https://jira.secondlife.com/browse/VWR-28570
150 //
151 // Caller, use this magic form instead:
152 // secondlife://http|!!mygrid.com|8002|Region+Name/128/128
153 // or url encode if possible.
154 // the hacks we do with this viewer...
155 //
156 string mapNameOrig = mapName; 160 string mapNameOrig = mapName;
157 if (mapName.Contains("|")) 161 if (regionInfos.Count == 0)
158 mapName = mapName.Replace('|', ':'); 162 {
159 if (mapName.Contains("+")) 163 // Hack to get around the fact that ll V3 now drops the port from the
160 mapName = mapName.Replace('+', ' '); 164 // map name. See https://jira.secondlife.com/browse/VWR-28570
161 if (mapName.Contains("!")) 165 //
162 mapName = mapName.Replace('!', '/'); 166 // Caller, use this magic form instead:
167 // secondlife://http|!!mygrid.com|8002|Region+Name/128/128
168 // or url encode if possible.
169 // the hacks we do with this viewer...
170 //
171 if (mapName.Contains("|"))
172 mapName = mapName.Replace('|', ':');
173 if (mapName.Contains("+"))
174 mapName = mapName.Replace('+', ' ');
175 if (mapName.Contains("!"))
176 mapName = mapName.Replace('!', '/');
177
178 if (mapName != mapNameOrig)
179 regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
180 }
163 181
164 // try to fetch from GridServer
165 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
166
167 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); 182 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags);
183
168 if (regionInfos.Count > 0) 184 if (regionInfos.Count > 0)
169 { 185 {
170 foreach (GridRegion info in regionInfos) 186 foreach (GridRegion info in regionInfos)
171 { 187 {
172 data = new MapBlockData(); 188 if ((flags & 2) == 2) // V2 sends this
173 data.Agents = 0; 189 {
174 data.Access = info.Access; 190 List<MapBlockData> datas = WorldMap.Map2BlockFromGridRegion(info, flags);
175 if (flags == 2) // V2 sends this 191 // ugh! V2-3 is very sensitive about the result being
176 data.MapImageId = UUID.Zero; 192 // exactly the same as the requested name
177 else 193 if (regionInfos.Count == 1 && (mapName != mapNameOrig))
178 data.MapImageId = info.TerrainImage; 194 datas.ForEach(d => d.Name = mapNameOrig);
179 // ugh! V2-3 is very sensitive about the result being 195
180 // exactly the same as the requested name 196 blocks.AddRange(datas);
181 if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+")) 197 }
182 data.Name = mapNameOrig;
183 else 198 else
184 data.Name = info.RegionName; 199 {
185 data.RegionFlags = 0; // TODO not used? 200 MapBlockData data = WorldMap.MapBlockFromGridRegion(info, flags);
186 data.WaterHeight = 0; // not used 201 }
187 data.X = (ushort)Util.WorldToRegionLoc((uint)info.RegionLocX);
188 data.Y = (ushort)Util.WorldToRegionLoc((uint)info.RegionLocY);
189 blocks.Add(data);
190 } 202 }
191 } 203 }
192 204
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index a3b0f39..b98afbc 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -1064,7 +1064,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1064 } 1064 }
1065 1065
1066 // Fill a passed MapBlockData from a GridRegion 1066 // Fill a passed MapBlockData from a GridRegion
1067 protected MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag) 1067 public MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag)
1068 { 1068 {
1069 MapBlockData block = new MapBlockData(); 1069 MapBlockData block = new MapBlockData();
1070 1070
@@ -1090,7 +1090,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1090 return block; 1090 return block;
1091 } 1091 }
1092 1092
1093 protected List<MapBlockData> Map2BlockFromGridRegion(GridRegion r, uint flag) 1093 public List<MapBlockData> Map2BlockFromGridRegion(GridRegion r, uint flag)
1094 { 1094 {
1095 List<MapBlockData> blocks = new List<MapBlockData>(); 1095 List<MapBlockData> blocks = new List<MapBlockData>();
1096 MapBlockData block = new MapBlockData(); 1096 MapBlockData block = new MapBlockData();
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
index 0c0a7aa..4a06f6e 100644
--- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
+++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
@@ -381,7 +381,7 @@ namespace OpenSim.Region.DataSnapshot
381 cli.RequestMethod = "GET"; 381 cli.RequestMethod = "GET";
382 try 382 try
383 { 383 {
384 reply = cli.Request(); 384 reply = cli.Request(null);
385 } 385 }
386 catch (WebException) 386 catch (WebException)
387 { 387 {
diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
index 3576e35..6bad018 100644
--- a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
@@ -38,7 +38,9 @@ namespace OpenSim.Region.Framework.Interfaces
38 public interface IInventoryAccessModule 38 public interface IInventoryAccessModule
39 { 39 {
40 UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data); 40 UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data);
41 41
42 bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset);
43
42 /// <summary> 44 /// <summary>
43 /// Copy objects to a user's inventory. 45 /// Copy objects to a user's inventory.
44 /// </summary> 46 /// </summary>
diff --git a/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs
index b0b47a7..290b826 100644
--- a/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs
@@ -36,6 +36,26 @@ namespace OpenSim.Region.Framework.Interfaces
36 { 36 {
37 event UndeliveredMessage OnUndeliveredMessage; 37 event UndeliveredMessage OnUndeliveredMessage;
38 38
39 /// <summary>
40 /// Attempt to send an instant message to a given destination.
41 /// </summary>
42 /// <remarks>
43 /// If the message cannot be delivered for any reason, this will be signalled on the OnUndeliveredMessage
44 /// event. result(false) will also be called if the message cannot be delievered unless the type is
45 /// InstantMessageDialog.MessageFromAgent. For successful message delivery, result(true) is called.
46 /// </remarks>
47 /// <param name="im"></param>
48 /// <param name="result"></param>
39 void SendInstantMessage(GridInstantMessage im, MessageResultNotification result); 49 void SendInstantMessage(GridInstantMessage im, MessageResultNotification result);
50
51 /// <summary>
52 /// Appropriately handle a known undeliverable message without attempting a send.
53 /// </summary>
54 /// <remarks>
55 /// Essentially, this invokes the OnUndeliveredMessage event.
56 /// </remarks>
57 /// <param name="im"></param>
58 /// <param name="result"></param>
59 void HandleUndeliverableMessage(GridInstantMessage im, MessageResultNotification result);
40 } 60 }
41} 61}
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs
index 65c57a6..9c781e1 100644
--- a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs
@@ -24,6 +24,9 @@
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 */
27using System.Collections.Generic;
28using OpenSim.Framework;
29using OpenSim.Services.Interfaces;
27 30
28namespace OpenSim.Region.Framework.Interfaces 31namespace OpenSim.Region.Framework.Interfaces
29{ 32{
@@ -33,5 +36,7 @@ namespace OpenSim.Region.Framework.Interfaces
33 /// Generate a map tile for the scene. a terrain texture for this scene 36 /// Generate a map tile for the scene. a terrain texture for this scene
34 /// </summary> 37 /// </summary>
35 void GenerateMaptile(); 38 void GenerateMaptile();
39 List<MapBlockData> Map2BlockFromGridRegion(GridRegion r, uint flag);
40 MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag);
36 } 41 }
37} 42}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 91f1b63..542d454 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -125,13 +125,18 @@ namespace OpenSim.Region.Framework.Scenes
125 125
126 return false; 126 return false;
127 } 127 }
128 }
129
130 public bool AddInventoryItem(InventoryItemBase item)
131 {
132 return AddInventoryItem(item, true);
128 } 133 }
129 134
130 /// <summary> 135 /// <summary>
131 /// Add the given inventory item to a user's inventory. 136 /// Add the given inventory item to a user's inventory.
132 /// </summary> 137 /// </summary>
133 /// <param name="item"></param> 138 /// <param name="item"></param>
134 public bool AddInventoryItem(InventoryItemBase item) 139 public bool AddInventoryItem(InventoryItemBase item, bool trigger)
135 { 140 {
136 if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) 141 if (item.Folder != UUID.Zero && InventoryService.AddItem(item))
137 { 142 {
@@ -140,7 +145,8 @@ namespace OpenSim.Region.Framework.Scenes
140 { 145 {
141 userlevel = 1; 146 userlevel = 1;
142 } 147 }
143 EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); 148 if (trigger)
149 EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel);
144 150
145 return true; 151 return true;
146 } 152 }
@@ -179,7 +185,8 @@ namespace OpenSim.Region.Framework.Scenes
179 { 185 {
180 userlevel = 1; 186 userlevel = 1;
181 } 187 }
182 EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); 188 if (trigger)
189 EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel);
183 190
184 if (originalFolder != UUID.Zero) 191 if (originalFolder != UUID.Zero)
185 { 192 {
@@ -764,7 +771,7 @@ namespace OpenSim.Region.Framework.Scenes
764 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); 771 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
765 if (invAccess != null) 772 if (invAccess != null)
766 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); 773 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
767 AddInventoryItem(itemCopy); 774 AddInventoryItem(itemCopy, false);
768 775
769 if (!Permissions.BypassPermissions()) 776 if (!Permissions.BypassPermissions())
770 { 777 {
@@ -872,51 +879,34 @@ namespace OpenSim.Region.Framework.Scenes
872 return; 879 return;
873 } 880 }
874 881
875 AssetBase asset = AssetService.Get(item.AssetID.ToString()); 882 if (newName == String.Empty)
883 newName = item.Name;
876 884
877 if (asset != null) 885 if (remoteClient.AgentId == oldAgentID
886 || (LibraryService != null
887 && LibraryService.LibraryRootFolder != null
888 && oldAgentID == LibraryService.LibraryRootFolder.Owner))
878 { 889 {
879 if (newName != String.Empty) 890 CreateNewInventoryItem(
880 { 891 remoteClient, item.CreatorId, item.CreatorData, newFolderID,
881 asset.Name = newName; 892 newName, item.Description, item.Flags, callbackID, item.AssetID, (sbyte)item.AssetType, (sbyte)item.InvType,
882 } 893 item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions,
883 else 894 item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false);
884 { 895 }
885 newName = item.Name; 896 else
886 } 897 {
887 898 // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item.
888 if (remoteClient.AgentId == oldAgentID 899 if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0)
889 || (LibraryService != null 900 && (m_permissions.BypassPermissions()
890 && LibraryService.LibraryRootFolder != null 901 || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID)))
891 && oldAgentID == LibraryService.LibraryRootFolder.Owner))
892 { 902 {
893 CreateNewInventoryItem( 903 CreateNewInventoryItem(
894 remoteClient, item.CreatorId, item.CreatorData, newFolderID, 904 remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID,
895 newName, item.Description, item.Flags, callbackID, asset, (sbyte)item.InvType, 905 item.AssetID, (sbyte)item.AssetType, (sbyte) item.InvType,
896 item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, 906 item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions,
897 item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); 907 item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false);
898 }
899 else
900 {
901 // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item.
902 if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0)
903 && (m_permissions.BypassPermissions()
904 || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID)))
905 {
906 CreateNewInventoryItem(
907 remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID,
908 asset, (sbyte) item.InvType,
909 item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions,
910 item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch());
911 }
912 } 908 }
913 } 909 }
914 else
915 {
916 m_log.ErrorFormat(
917 "[AGENT INVENTORY]: Could not copy item {0} since asset {1} could not be found",
918 item.Name, item.AssetID);
919 }
920 } 910 }
921 911
922 /// <summary> 912 /// <summary>
@@ -966,11 +956,12 @@ namespace OpenSim.Region.Framework.Scenes
966 public void CreateNewInventoryItem( 956 public void CreateNewInventoryItem(
967 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, 957 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID,
968 string name, string description, uint flags, uint callbackID, 958 string name, string description, uint flags, uint callbackID,
969 AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) 959 UUID assetID, sbyte assetType, sbyte invType, uint nextOwnerMask, int creationDate)
970 { 960 {
971 CreateNewInventoryItem( 961 CreateNewInventoryItem(
972 remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, 962 remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, assetID, assetType, invType,
973 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate); 963 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0,
964 creationDate, true);
974 } 965 }
975 966
976 /// <summary> 967 /// <summary>
@@ -994,19 +985,20 @@ namespace OpenSim.Region.Framework.Scenes
994 /// <param name="creationDate">Unix timestamp at which this item was created.</param> 985 /// <param name="creationDate">Unix timestamp at which this item was created.</param>
995 private void CreateNewInventoryItem( 986 private void CreateNewInventoryItem(
996 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, 987 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID,
997 string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, 988 string name, string description, uint flags, uint callbackID, UUID assetID, sbyte assetType, sbyte invType,
998 uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) 989 uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate,
990 bool assetUpload)
999 { 991 {
1000 InventoryItemBase item = new InventoryItemBase(); 992 InventoryItemBase item = new InventoryItemBase();
1001 item.Owner = remoteClient.AgentId; 993 item.Owner = remoteClient.AgentId;
1002 item.CreatorId = creatorID; 994 item.CreatorId = creatorID;
1003 item.CreatorData = creatorData; 995 item.CreatorData = creatorData;
1004 item.ID = UUID.Random(); 996 item.ID = UUID.Random();
1005 item.AssetID = asset.FullID; 997 item.AssetID = assetID;
1006 item.Name = name; 998 item.Name = name;
1007 item.Description = description; 999 item.Description = description;
1008 item.Flags = flags; 1000 item.Flags = flags;
1009 item.AssetType = asset.Type; 1001 item.AssetType = assetType;
1010 item.InvType = invType; 1002 item.InvType = invType;
1011 item.Folder = folderID; 1003 item.Folder = folderID;
1012 item.CurrentPermissions = currentMask; 1004 item.CurrentPermissions = currentMask;
@@ -1016,7 +1008,7 @@ namespace OpenSim.Region.Framework.Scenes
1016 item.BasePermissions = baseMask; 1008 item.BasePermissions = baseMask;
1017 item.CreationDate = creationDate; 1009 item.CreationDate = creationDate;
1018 1010
1019 if (AddInventoryItem(item)) 1011 if (AddInventoryItem(item, assetUpload))
1020 { 1012 {
1021 remoteClient.SendInventoryItemCreateUpdate(item, callbackID); 1013 remoteClient.SendInventoryItemCreateUpdate(item, callbackID);
1022 } 1014 }
@@ -1079,17 +1071,12 @@ namespace OpenSim.Region.Framework.Scenes
1079// return; 1071// return;
1080// } 1072// }
1081 1073
1082 AssetBase asset = new AssetBase();
1083 asset.FullID = olditemID;
1084 asset.Type = type;
1085 asset.Name = name;
1086 asset.Description = description;
1087
1088 CreateNewInventoryItem( 1074 CreateNewInventoryItem(
1089 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, 1075 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
1090 name, description, 0, callbackID, asset, invType, 1076 name, description, 0, callbackID, olditemID, type, invType,
1091 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All, 1077 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All,
1092 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch()); 1078 (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch(),
1079 false);
1093 } 1080 }
1094 else 1081 else
1095 { 1082 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e6887b4..eff24f8 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3751,6 +3751,13 @@ namespace OpenSim.Region.Framework.Scenes
3751 RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); 3751 RegionInfo.RegionSettings.TelehubObject, acd.Name, Name);
3752 } 3752 }
3753 3753
3754 // Final permissions check; this time we don't allow changing the position
3755 if (!IsPositionAllowed(acd.AgentID, acd.startpos, ref reason))
3756 {
3757 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3758 return false;
3759 }
3760
3754 return true; 3761 return true;
3755 } 3762 }
3756 3763
@@ -3760,6 +3767,13 @@ namespace OpenSim.Region.Framework.Scenes
3760 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3767 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
3761 { 3768 {
3762 acd.startpos = land.LandData.UserLocation; 3769 acd.startpos = land.LandData.UserLocation;
3770
3771 // Final permissions check; this time we don't allow changing the position
3772 if (!IsPositionAllowed(acd.AgentID, acd.startpos, ref reason))
3773 {
3774 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3775 return false;
3776 }
3763 } 3777 }
3764 } 3778 }
3765 } 3779 }
@@ -3767,6 +3781,21 @@ namespace OpenSim.Region.Framework.Scenes
3767 return true; 3781 return true;
3768 } 3782 }
3769 3783
3784 private bool IsPositionAllowed(UUID agentID, Vector3 pos, ref string reason)
3785 {
3786 ILandObject land = LandChannel.GetLandObject(pos);
3787 if (land == null)
3788 return true;
3789
3790 if (land.IsBannedFromLand(agentID) || land.IsRestrictedFromLand(agentID))
3791 {
3792 reason = "You are banned from the region.";
3793 return false;
3794 }
3795
3796 return true;
3797 }
3798
3770 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) 3799 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3771 { 3800 {
3772 if (posX < 0) 3801 if (posX < 0)
@@ -3865,7 +3894,7 @@ namespace OpenSim.Region.Framework.Scenes
3865 if (!AuthorizationService.IsAuthorizedForRegion( 3894 if (!AuthorizationService.IsAuthorizedForRegion(
3866 agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason)) 3895 agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason))
3867 { 3896 {
3868 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because {4}", 3897 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because: {4}",
3869 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName, reason); 3898 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName, reason);
3870 3899
3871 return false; 3900 return false;
@@ -4133,7 +4162,10 @@ namespace OpenSim.Region.Framework.Scenes
4133 /// <returns>true if we handled it.</returns> 4162 /// <returns>true if we handled it.</returns>
4134 public virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData) 4163 public virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData)
4135 { 4164 {
4136 //m_log.Debug(" XXX Scene IncomingChildAgentDataUpdate POSITION in " + RegionInfo.RegionName); 4165// m_log.DebugFormat(
4166// "[SCENE PRESENCE]: IncomingChildAgentDataUpdate POSITION for {0} in {1}, position {2}",
4167// cAgentData.AgentID, Name, cAgentData.Position);
4168
4137 ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID); 4169 ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID);
4138 if (childAgentUpdate != null) 4170 if (childAgentUpdate != null)
4139 { 4171 {
@@ -5150,7 +5182,7 @@ namespace OpenSim.Region.Framework.Scenes
5150 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5182 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5151 if (nearestPoint != null) 5183 if (nearestPoint != null)
5152 { 5184 {
5153 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); 5185 m_log.Debug("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
5154 return nearestPoint.Value; 5186 return nearestPoint.Value;
5155 } 5187 }
5156 5188
@@ -5160,7 +5192,7 @@ namespace OpenSim.Region.Framework.Scenes
5160 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5192 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5161 if (nearestPoint != null) 5193 if (nearestPoint != null)
5162 { 5194 {
5163 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); 5195 m_log.Debug("They had a zero velocity, sending them to: " + nearestPoint.ToString());
5164 return nearestPoint.Value; 5196 return nearestPoint.Value;
5165 } 5197 }
5166 5198
@@ -5169,7 +5201,7 @@ namespace OpenSim.Region.Framework.Scenes
5169 { 5201 {
5170 // Ultimate backup if we have no idea where they are and 5202 // Ultimate backup if we have no idea where they are and
5171 // the last allowed position was in another parcel 5203 // the last allowed position was in another parcel
5172 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); 5204 m_log.Debug("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5173 return avatar.lastKnownAllowedPosition; 5205 return avatar.lastKnownAllowedPosition;
5174 } 5206 }
5175 5207
@@ -5179,7 +5211,7 @@ namespace OpenSim.Region.Framework.Scenes
5179 //Go to the edge, this happens in teleporting to a region with no available parcels 5211 //Go to the edge, this happens in teleporting to a region with no available parcels
5180 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); 5212 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar);
5181 5213
5182 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); 5214 //m_log.Debug("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString());
5183 5215
5184 return nearestRegionEdgePoint; 5216 return nearestRegionEdgePoint;
5185 } 5217 }
@@ -5463,9 +5495,9 @@ namespace OpenSim.Region.Framework.Scenes
5463 /// <param name='position'></param> 5495 /// <param name='position'></param>
5464 /// <param name='reason'></param> 5496 /// <param name='reason'></param>
5465 /// <returns></returns> 5497 /// <returns></returns>
5466 public bool QueryAccess(UUID agentID, string agentHomeURI, Vector3 position, out string reason) 5498 public bool QueryAccess(UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string reason)
5467 { 5499 {
5468 reason = "You are banned from the region"; 5500 reason = string.Empty;
5469 5501
5470 if (Permissions.IsGod(agentID)) 5502 if (Permissions.IsGod(agentID))
5471 { 5503 {
@@ -5525,10 +5557,11 @@ namespace OpenSim.Region.Framework.Scenes
5525 catch (Exception e) 5557 catch (Exception e)
5526 { 5558 {
5527 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); 5559 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5560 reason = "Error authorizing agent: " + e.Message;
5528 return false; 5561 return false;
5529 } 5562 }
5530 5563
5531 if (position == Vector3.Zero) // Teleport 5564 if (viaTeleport)
5532 { 5565 {
5533 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5566 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
5534 { 5567 {
@@ -5568,6 +5601,7 @@ namespace OpenSim.Region.Framework.Scenes
5568 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) 5601 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5569 { 5602 {
5570 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); 5603 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5604 reason = "You are banned from the region on all parcels";
5571 return false; 5605 return false;
5572 } 5606 }
5573 } 5607 }
@@ -5575,13 +5609,22 @@ namespace OpenSim.Region.Framework.Scenes
5575 { 5609 {
5576 ILandObject land = LandChannel.GetLandObject(position.X, position.Y); 5610 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5577 if (land == null) 5611 if (land == null)
5612 {
5613 reason = "No parcel found";
5578 return false; 5614 return false;
5615 }
5579 5616
5580 bool banned = land.IsBannedFromLand(agentID); 5617 bool banned = land.IsBannedFromLand(agentID);
5581 bool restricted = land.IsRestrictedFromLand(agentID); 5618 bool restricted = land.IsRestrictedFromLand(agentID);
5582 5619
5583 if (banned || restricted) 5620 if (banned || restricted)
5621 {
5622 if (banned)
5623 reason = "You are banned from the parcel";
5624 else
5625 reason = "The parcel is restricted";
5584 return false; 5626 return false;
5627 }
5585 } 5628 }
5586 5629
5587 reason = String.Empty; 5630 reason = String.Empty;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index fb8ecd5..75e1cbb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -751,7 +751,7 @@ namespace OpenSim.Region.Framework.Scenes
751 Vector3 bbox; 751 Vector3 bbox;
752 float offsetHeight; 752 float offsetHeight;
753 753
754 bool single = m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight); 754 m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight);
755 755
756 for (int i = 0; i < objlist.Count; i++) 756 for (int i = 0; i < objlist.Count; i++)
757 { 757 {
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 8c56975..17f54c2 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -208,7 +208,6 @@ namespace OpenSim.Region.Framework.Scenes
208// private int m_lastColCount = -1; //KF: Look for Collision chnages 208// private int m_lastColCount = -1; //KF: Look for Collision chnages
209// private int m_updateCount = 0; //KF: Update Anims for a while 209// private int m_updateCount = 0; //KF: Update Anims for a while
210// private static readonly int UPDATE_COUNT = 10; // how many frames to update for 210// private static readonly int UPDATE_COUNT = 10; // how many frames to update for
211 private List<uint> m_lastColliders = new List<uint>();
212 211
213 private TeleportFlags m_teleportFlags; 212 private TeleportFlags m_teleportFlags;
214 public TeleportFlags TeleportFlags 213 public TeleportFlags TeleportFlags
@@ -271,8 +270,6 @@ namespace OpenSim.Region.Framework.Scenes
271 //private int m_moveToPositionStateStatus; 270 //private int m_moveToPositionStateStatus;
272 //***************************************************** 271 //*****************************************************
273 272
274 private object m_collisionEventLock = new Object();
275
276 private int m_movementAnimationUpdateCounter = 0; 273 private int m_movementAnimationUpdateCounter = 0;
277 274
278 public Vector3 PrevSitOffset { get; set; } 275 public Vector3 PrevSitOffset { get; set; }
@@ -1328,6 +1325,11 @@ namespace OpenSim.Region.Framework.Scenes
1328 1325
1329 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); 1326 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName);
1330 1327
1328 // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating
1329 // from the source simulator has completed on a V2 teleport.
1330 lock (m_originRegionIDAccessLock)
1331 m_originRegionID = UUID.Zero;
1332
1331 // Reset these so that teleporting in and walking out isn't seen 1333 // Reset these so that teleporting in and walking out isn't seen
1332 // as teleporting back 1334 // as teleporting back
1333 TeleportFlags = TeleportFlags.Default; 1335 TeleportFlags = TeleportFlags.Default;
@@ -2752,7 +2754,34 @@ namespace OpenSim.Region.Framework.Scenes
2752 part.AddSittingAvatar(this); 2754 part.AddSittingAvatar(this);
2753 2755
2754 cameraAtOffset = part.GetCameraAtOffset(); 2756 cameraAtOffset = part.GetCameraAtOffset();
2757
2758 if (!part.IsRoot && cameraAtOffset == Vector3.Zero)
2759 cameraAtOffset = part.ParentGroup.RootPart.GetCameraAtOffset();
2760
2761 bool cameraEyeOffsetFromRootForChild = false;
2755 cameraEyeOffset = part.GetCameraEyeOffset(); 2762 cameraEyeOffset = part.GetCameraEyeOffset();
2763
2764 if (!part.IsRoot && cameraEyeOffset == Vector3.Zero)
2765 {
2766 cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset();
2767 cameraEyeOffsetFromRootForChild = true;
2768 }
2769
2770 if ((cameraEyeOffset != Vector3.Zero && !cameraEyeOffsetFromRootForChild) || cameraAtOffset != Vector3.Zero)
2771 {
2772 if (!part.IsRoot)
2773 {
2774 cameraEyeOffset = cameraEyeOffset * part.RotationOffset;
2775 cameraAtOffset += part.OffsetPosition;
2776 }
2777
2778 cameraEyeOffset += part.OffsetPosition;
2779 }
2780
2781// m_log.DebugFormat(
2782// "[SCENE PRESENCE]: Using cameraAtOffset {0}, cameraEyeOffset {1} for sit on {2} by {3} in {4}",
2783// cameraAtOffset, cameraEyeOffset, part.Name, Name, Scene.Name);
2784
2756 forceMouselook = part.GetForceMouselook(); 2785 forceMouselook = part.GetForceMouselook();
2757 2786
2758 // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is 2787 // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is
@@ -3772,10 +3801,15 @@ namespace OpenSim.Region.Framework.Scenes
3772 if (!IsChildAgent) 3801 if (!IsChildAgent)
3773 return; 3802 return;
3774 3803
3775 //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); 3804// m_log.DebugFormat(
3805// "[SCENE PRESENCE]: ChildAgentPositionUpdate for {0} in {1}, tRegion {2},{3}, rRegion {4},{5}, pos {6}",
3806// Name, Scene.Name, tRegionX, tRegionY, rRegionX, rRegionY, cAgentData.Position);
3807
3776 // Find the distance (in meters) between the two regions 3808 // Find the distance (in meters) between the two regions
3777 uint shiftx = Util.RegionToWorldLoc(rRegionX - tRegionX); 3809 // XXX: We cannot use Util.RegionLocToHandle() here because a negative value will silently overflow the
3778 uint shifty = Util.RegionToWorldLoc(rRegionY - tRegionY); 3810 // uint
3811 int shiftx = (int)(((int)rRegionX - (int)tRegionX) * Constants.RegionSize);
3812 int shifty = (int)(((int)rRegionY - (int)tRegionY) * Constants.RegionSize);
3779 3813
3780 Vector3 offset = new Vector3(shiftx, shifty, 0f); 3814 Vector3 offset = new Vector3(shiftx, shifty, 0f);
3781 3815
@@ -3876,9 +3910,6 @@ namespace OpenSim.Region.Framework.Scenes
3876 3910
3877 private void CopyFrom(AgentData cAgent) 3911 private void CopyFrom(AgentData cAgent)
3878 { 3912 {
3879 lock (m_originRegionIDAccessLock)
3880 m_originRegionID = cAgent.RegionID;
3881
3882 m_callbackURI = cAgent.CallbackURI; 3913 m_callbackURI = cAgent.CallbackURI;
3883// m_log.DebugFormat( 3914// m_log.DebugFormat(
3884// "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()", 3915// "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()",
@@ -3951,6 +3982,12 @@ namespace OpenSim.Region.Framework.Scenes
3951 3982
3952 if (Scene.AttachmentsModule != null) 3983 if (Scene.AttachmentsModule != null)
3953 Scene.AttachmentsModule.CopyAttachments(cAgent, this); 3984 Scene.AttachmentsModule.CopyAttachments(cAgent, this);
3985
3986 // This must occur after attachments are copied, as it releases the CompleteMovement() calling thread
3987 // originating from the client completing a teleport. Otherwise, CompleteMovement() code to restart
3988 // script attachments can outrace this thread.
3989 lock (m_originRegionIDAccessLock)
3990 m_originRegionID = cAgent.RegionID;
3954 } 3991 }
3955 3992
3956 public bool CopyAgent(out IAgentData agent) 3993 public bool CopyAgent(out IAgentData agent)
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 85650d6..e68f954 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -1343,7 +1343,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1343 writer.WriteElementString("SalePrice", sop.SalePrice.ToString()); 1343 writer.WriteElementString("SalePrice", sop.SalePrice.ToString());
1344 writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString()); 1344 writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString());
1345 writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString()); 1345 writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString());
1346 WriteUUID(writer, "GroupID", sop.GroupID, options); 1346
1347 UUID groupID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.GroupID;
1348 WriteUUID(writer, "GroupID", groupID, options);
1347 1349
1348 UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.OwnerID; 1350 UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.OwnerID;
1349 WriteUUID(writer, "OwnerID", ownerID, options); 1351 WriteUUID(writer, "OwnerID", ownerID, options);
@@ -1469,7 +1471,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1469 writer.WriteElementString("Description", item.Description); 1471 writer.WriteElementString("Description", item.Description);
1470 writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString()); 1472 writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString());
1471 writer.WriteElementString("Flags", item.Flags.ToString()); 1473 writer.WriteElementString("Flags", item.Flags.ToString());
1472 WriteUUID(writer, "GroupID", item.GroupID, options); 1474
1475 UUID groupID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.GroupID;
1476 WriteUUID(writer, "GroupID", groupID, options);
1477
1473 writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString()); 1478 writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString());
1474 writer.WriteElementString("InvType", item.InvType.ToString()); 1479 writer.WriteElementString("InvType", item.InvType.ToString());
1475 WriteUUID(writer, "ItemID", item.ItemID, options); 1480 WriteUUID(writer, "ItemID", item.ItemID, options);
@@ -1490,7 +1495,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1490 WriteUUID(writer, "PermsGranter", item.PermsGranter, options); 1495 WriteUUID(writer, "PermsGranter", item.PermsGranter, options);
1491 writer.WriteElementString("PermsMask", item.PermsMask.ToString()); 1496 writer.WriteElementString("PermsMask", item.PermsMask.ToString());
1492 writer.WriteElementString("Type", item.Type.ToString()); 1497 writer.WriteElementString("Type", item.Type.ToString());
1493 writer.WriteElementString("OwnerChanged", item.OwnerChanged.ToString().ToLower()); 1498
1499 bool ownerChanged = options.ContainsKey("wipe-owners") ? false : item.OwnerChanged;
1500 writer.WriteElementString("OwnerChanged", ownerChanged.ToString().ToLower());
1494 1501
1495 writer.WriteEndElement(); // TaskInventoryItem 1502 writer.WriteEndElement(); // TaskInventoryItem
1496 } 1503 }
diff --git a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
index e797207..396f1e8 100644
--- a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
+++ b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
45{ 45{
46 public static class OpenSimTerrainCompressor 46 public static class OpenSimTerrainCompressor
47 { 47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50#pragma warning disable 414 50#pragma warning disable 414
51 private static string LogHeader = "[TERRAIN COMPRESSOR]"; 51 private static string LogHeader = "[TERRAIN COMPRESSOR]";
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
index fd804cd..e1b6abb 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
@@ -55,8 +55,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
55 private IGroupsServicesConnector m_groupData = null; 55 private IGroupsServicesConnector m_groupData = null;
56 56
57 // Config Options 57 // Config Options
58 private bool m_groupMessagingEnabled = false; 58 private bool m_groupMessagingEnabled;
59 private bool m_debugEnabled = true; 59 private bool m_debugEnabled;
60 60
61 /// <summary> 61 /// <summary>
62 /// If enabled, module only tries to send group IMs to online users by querying cached presence information. 62 /// If enabled, module only tries to send group IMs to online users by querying cached presence information.
@@ -113,7 +113,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
113 if (m_messageOnlineAgentsOnly) 113 if (m_messageOnlineAgentsOnly)
114 m_usersOnlineCache = new ExpiringCache<UUID, PresenceInfo[]>(); 114 m_usersOnlineCache = new ExpiringCache<UUID, PresenceInfo[]>();
115 115
116 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); 116 m_debugEnabled = groupsConfig.GetBoolean("MessagingDebugEnabled", m_debugEnabled);
117 } 117 }
118 118
119 m_log.InfoFormat( 119 m_log.InfoFormat(
@@ -127,6 +127,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
127 return; 127 return;
128 128
129 scene.RegisterModuleInterface<IGroupsMessagingModule>(this); 129 scene.RegisterModuleInterface<IGroupsMessagingModule>(this);
130
131 scene.AddCommand(
132 "Debug",
133 this,
134 "debug groups messaging verbose",
135 "debug groups messaging verbose <true|false>",
136 "This setting turns on very verbose groups messaging debugging",
137 HandleDebugGroupsMessagingVerbose);
130 } 138 }
131 139
132 public void RegionLoaded(Scene scene) 140 public void RegionLoaded(Scene scene)
@@ -218,6 +226,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
218 226
219 #endregion 227 #endregion
220 228
229 private void HandleDebugGroupsMessagingVerbose(object modules, string[] args)
230 {
231 if (args.Length < 5)
232 {
233 MainConsole.Instance.Output("Usage: debug groups messaging verbose <true|false>");
234 return;
235 }
236
237 bool verbose = false;
238 if (!bool.TryParse(args[4], out verbose))
239 {
240 MainConsole.Instance.Output("Usage: debug groups messaging verbose <true|false>");
241 return;
242 }
243
244 m_debugEnabled = verbose;
245
246 MainConsole.Instance.OutputFormat("{0} verbose logging set to {1}", Name, m_debugEnabled);
247 }
248
221 /// <summary> 249 /// <summary>
222 /// Not really needed, but does confirm that the group exists. 250 /// Not really needed, but does confirm that the group exists.
223 /// </summary> 251 /// </summary>
@@ -246,8 +274,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
246 public void SendMessageToGroup( 274 public void SendMessageToGroup(
247 GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func<GroupMembersData, bool> sendCondition) 275 GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func<GroupMembersData, bool> sendCondition)
248 { 276 {
277 int requestStartTick = Environment.TickCount;
278
249 List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(sendingAgentForGroupCalls, groupID); 279 List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(sendingAgentForGroupCalls, groupID);
250 int groupMembersCount = groupMembers.Count; 280 int groupMembersCount = groupMembers.Count;
281 HashSet<string> attemptDeliveryUuidSet = null;
251 282
252 if (m_messageOnlineAgentsOnly) 283 if (m_messageOnlineAgentsOnly)
253 { 284 {
@@ -263,10 +294,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
263 m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds); 294 m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds);
264 } 295 }
265 296
266 HashSet<string> onlineAgentsUuidSet = new HashSet<string>(); 297 attemptDeliveryUuidSet
267 Array.ForEach<PresenceInfo>(onlineAgents, pi => onlineAgentsUuidSet.Add(pi.UserID)); 298 = new HashSet<string>(Array.ConvertAll<PresenceInfo, string>(onlineAgents, pi => pi.UserID));
268 299
269 groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList(); 300 //Array.ForEach<PresenceInfo>(onlineAgents, pi => attemptDeliveryUuidSet.Add(pi.UserID));
301
302 //groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList();
270 303
271 // if (m_debugEnabled) 304 // if (m_debugEnabled)
272// m_log.DebugFormat( 305// m_log.DebugFormat(
@@ -275,13 +308,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
275 } 308 }
276 else 309 else
277 { 310 {
311 attemptDeliveryUuidSet
312 = new HashSet<string>(groupMembers.ConvertAll<string>(gmd => gmd.AgentID.ToString()));
313
278 if (m_debugEnabled) 314 if (m_debugEnabled)
279 m_log.DebugFormat( 315 m_log.DebugFormat(
280 "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members", 316 "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members",
281 groupID, groupMembers.Count); 317 groupID, groupMembers.Count);
282 } 318 }
283
284 int requestStartTick = Environment.TickCount;
285 319
286 foreach (GroupMembersData member in groupMembers) 320 foreach (GroupMembersData member in groupMembers)
287 { 321 {
@@ -309,7 +343,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
309 343
310 // Copy Message 344 // Copy Message
311 GridInstantMessage msg = new GridInstantMessage(); 345 GridInstantMessage msg = new GridInstantMessage();
312 msg.imSessionID = groupID.Guid; 346 msg.imSessionID = im.imSessionID;
313 msg.fromAgentName = im.fromAgentName; 347 msg.fromAgentName = im.fromAgentName;
314 msg.message = im.message; 348 msg.message = im.message;
315 msg.dialog = im.dialog; 349 msg.dialog = im.dialog;
@@ -325,26 +359,51 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
325 359
326 msg.toAgentID = member.AgentID.Guid; 360 msg.toAgentID = member.AgentID.Guid;
327 361
328 IClientAPI client = GetActiveClient(member.AgentID); 362 if (attemptDeliveryUuidSet.Contains(member.AgentID.ToString()))
329 if (client == null)
330 { 363 {
331 // If they're not local, forward across the grid 364 IClientAPI client = GetActiveClient(member.AgentID);
332 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID); 365 if (client == null)
333 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); 366 {
367 int startTick = Environment.TickCount;
368
369 // If they're not local, forward across the grid
370 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
371
372 if (m_debugEnabled)
373 m_log.DebugFormat(
374 "[GROUPS-MESSAGING]: Delivering to {0} via grid took {1} ms",
375 member.AgentID, Environment.TickCount - startTick);
376 }
377 else
378 {
379 int startTick = Environment.TickCount;
380
381 ProcessMessageFromGroupSession(msg, client);
382
383 // Deliver locally, directly
384 if (m_debugEnabled)
385 m_log.DebugFormat(
386 "[GROUPS-MESSAGING]: Delivering to {0} locally took {1} ms",
387 member.AgentID, Environment.TickCount - startTick);
388 }
334 } 389 }
335 else 390 else
336 { 391 {
337 // Deliver locally, directly 392 int startTick = Environment.TickCount;
338 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); 393
339 ProcessMessageFromGroupSession(msg, client); 394 m_msgTransferModule.HandleUndeliverableMessage(msg, delegate(bool success) { });
395
396 if (m_debugEnabled)
397 m_log.DebugFormat(
398 "[GROUPS-MESSAGING]: Handling undeliverable message for {0} took {1} ms",
399 member.AgentID, Environment.TickCount - startTick);
340 } 400 }
341 } 401 }
342 402
343 // Temporary for assessing how long it still takes to send messages to large online groups. 403 if (m_debugEnabled)
344 if (m_messageOnlineAgentsOnly)
345 m_log.DebugFormat( 404 m_log.DebugFormat(
346 "[GROUPS-MESSAGING]: SendMessageToGroup for group {0} with {1} visible members, {2} online took {3}ms", 405 "[GROUPS-MESSAGING]: Total SendMessageToGroup for group {0} with {1} members, {2} candidates for delivery took {3} ms",
347 groupID, groupMembersCount, groupMembers.Count(), Environment.TickCount - requestStartTick); 406 groupID, groupMembersCount, attemptDeliveryUuidSet.Count(), Environment.TickCount - requestStartTick);
348 } 407 }
349 408
350 #region SimGridEventHandlers 409 #region SimGridEventHandlers
@@ -407,7 +466,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
407 466
408 private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client) 467 private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client)
409 { 468 {
410 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); 469 if (m_debugEnabled)
470 m_log.DebugFormat(
471 "[GROUPS-MESSAGING]: Session message from {0} going to agent {1}, sessionID {2}, type {3}",
472 msg.fromAgentName, msg.toAgentID, msg.imSessionID, (InstantMessageDialog)msg.dialog);
411 473
412 UUID AgentID = new UUID(msg.fromAgentID); 474 UUID AgentID = new UUID(msg.fromAgentID);
413 UUID GroupID = new UUID(msg.imSessionID); 475 UUID GroupID = new UUID(msg.imSessionID);
@@ -431,8 +493,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
431 // Add them to the session for now, and Invite them 493 // Add them to the session for now, and Invite them
432 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); 494 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
433 495
434 UUID toAgentID = new UUID(msg.toAgentID);
435
436 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); 496 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
437 if (groupInfo != null) 497 if (groupInfo != null)
438 { 498 {
@@ -577,15 +637,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
577 // Don't log any normal IMs (privacy!) 637 // Don't log any normal IMs (privacy!)
578 if (m_debugEnabled && im.dialog != (byte)InstantMessageDialog.MessageFromAgent) 638 if (m_debugEnabled && im.dialog != (byte)InstantMessageDialog.MessageFromAgent)
579 { 639 {
580 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromGroup({0})", im.fromGroup ? "True" : "False"); 640 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromGroup({0})", im.fromGroup ? "True" : "False");
581 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", (InstantMessageDialog)im.dialog); 641 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", (InstantMessageDialog)im.dialog);
582 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID); 642 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID);
583 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName); 643 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName);
584 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID); 644 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID);
585 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message); 645 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message);
586 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline); 646 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline);
587 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID); 647 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID);
588 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket")); 648 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket"));
589 } 649 }
590 } 650 }
591 651
@@ -596,7 +656,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
596 /// </summary> 656 /// </summary>
597 private IClientAPI GetActiveClient(UUID agentID) 657 private IClientAPI GetActiveClient(UUID agentID)
598 { 658 {
599 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); 659 if (m_debugEnabled)
660 m_log.DebugFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID);
600 661
601 IClientAPI child = null; 662 IClientAPI child = null;
602 663
@@ -608,12 +669,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
608 { 669 {
609 if (!sp.IsChildAgent) 670 if (!sp.IsChildAgent)
610 { 671 {
611 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name); 672 if (m_debugEnabled)
673 m_log.DebugFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name);
674
612 return sp.ControllingClient; 675 return sp.ControllingClient;
613 } 676 }
614 else 677 else
615 { 678 {
616 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name); 679 if (m_debugEnabled)
680 m_log.DebugFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name);
681
617 child = sp.ControllingClient; 682 child = sp.ControllingClient;
618 } 683 }
619 } 684 }
@@ -622,12 +687,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
622 // If we didn't find a root, then just return whichever child we found, or null if none 687 // If we didn't find a root, then just return whichever child we found, or null if none
623 if (child == null) 688 if (child == null)
624 { 689 {
625 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); 690 if (m_debugEnabled)
691 m_log.DebugFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID);
626 } 692 }
627 else 693 else
628 { 694 {
629 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); 695 if (m_debugEnabled)
696 m_log.DebugFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name);
630 } 697 }
698
631 return child; 699 return child;
632 } 700 }
633 701
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index f34152c..8a9e4d2 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -357,7 +357,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
357 357
358 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 358 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
359 { 359 {
360 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 360 if (m_debugEnabled)
361 m_log.DebugFormat(
362 "[GROUPS]: {0} called for {1}, message type {2}",
363 System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name, (InstantMessageDialog)im.dialog);
361 364
362 // Group invitations 365 // Group invitations
363 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) 366 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
@@ -551,6 +554,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
551 554
552 UUID noticeID = new UUID(im.imSessionID); 555 UUID noticeID = new UUID(im.imSessionID);
553 556
557 if (m_debugEnabled)
558 m_log.DebugFormat("[GROUPS]: Requesting notice {0} for {1}", noticeID, remoteClient.AgentId);
559
554 GroupNoticeInfo notice = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), noticeID); 560 GroupNoticeInfo notice = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), noticeID);
555 if (notice != null) 561 if (notice != null)
556 { 562 {
@@ -572,6 +578,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
572 578
573 remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0); 579 remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0);
574 } 580 }
581 else
582 {
583 if (m_debugEnabled)
584 m_log.DebugFormat(
585 "[GROUPS]: Could not find notice {0} for {1} on GroupNoticeInventoryAccepted.",
586 noticeID, remoteClient.AgentId);
587 }
575 } 588 }
576 589
577 // Interop, received special 210 code for ejecting a group member 590 // Interop, received special 210 code for ejecting a group member
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
index 71f1098..d944087 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
@@ -132,6 +132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
132 MessageTransferModule mtm = new MessageTransferModule(); 132 MessageTransferModule mtm = new MessageTransferModule();
133 GroupsModule gm = new GroupsModule(); 133 GroupsModule gm = new GroupsModule();
134 GroupsMessagingModule gmm = new GroupsMessagingModule(); 134 GroupsMessagingModule gmm = new GroupsMessagingModule();
135 MockGroupsServicesConnector mgsc = new MockGroupsServicesConnector();
135 136
136 IConfigSource configSource = new IniConfigSource(); 137 IConfigSource configSource = new IniConfigSource();
137 138
@@ -149,6 +150,83 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
149 config.Set("MessagingEnabled", true); 150 config.Set("MessagingEnabled", true);
150 } 151 }
151 152
153 SceneHelpers.SetupSceneModules(scene, configSource, mgsc, mtm, gm, gmm);
154
155 UUID userId = TestHelpers.ParseTail(0x1);
156 string subjectText = "newman";
157 string messageText = "Hello";
158 string combinedSubjectMessage = string.Format("{0}|{1}", subjectText, messageText);
159
160 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
161 TestClient tc = (TestClient)sp.ControllingClient;
162
163 UUID groupID = gm.CreateGroup(tc, "group1", null, true, UUID.Zero, 0, true, true, true);
164 gm.JoinGroupRequest(tc, groupID);
165
166 // Create a second user who doesn't want to receive notices
167 ScenePresence sp2 = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x2));
168 TestClient tc2 = (TestClient)sp2.ControllingClient;
169 gm.JoinGroupRequest(tc2, groupID);
170 gm.SetGroupAcceptNotices(tc2, groupID, false, true);
171
172 List<GridInstantMessage> spReceivedMessages = new List<GridInstantMessage>();
173 tc.OnReceivedInstantMessage += im => spReceivedMessages.Add(im);
174
175 List<GridInstantMessage> sp2ReceivedMessages = new List<GridInstantMessage>();
176 tc2.OnReceivedInstantMessage += im => sp2ReceivedMessages.Add(im);
177
178 GridInstantMessage noticeIm = new GridInstantMessage();
179 noticeIm.fromAgentID = userId.Guid;
180 noticeIm.toAgentID = groupID.Guid;
181 noticeIm.message = combinedSubjectMessage;
182 noticeIm.dialog = (byte)InstantMessageDialog.GroupNotice;
183
184 tc.HandleImprovedInstantMessage(noticeIm);
185
186 Assert.That(spReceivedMessages.Count, Is.EqualTo(1));
187 Assert.That(spReceivedMessages[0].message, Is.EqualTo(combinedSubjectMessage));
188
189 List<GroupNoticeData> notices = mgsc.GetGroupNotices(UUID.Zero, groupID);
190 Assert.AreEqual(1, notices.Count);
191
192 // OpenSimulator (possibly also SL) transport the notice ID as the session ID!
193 Assert.AreEqual(notices[0].NoticeID.Guid, spReceivedMessages[0].imSessionID);
194
195 Assert.That(sp2ReceivedMessages.Count, Is.EqualTo(0));
196 }
197
198 /// <summary>
199 /// Run test with the MessageOnlineUsersOnly flag set.
200 /// </summary>
201 [Test]
202 public void TestSendGroupNoticeOnlineOnly()
203 {
204 TestHelpers.InMethod();
205 // TestHelpers.EnableLogging();
206
207 TestScene scene = new SceneHelpers().SetupScene();
208
209 MessageTransferModule mtm = new MessageTransferModule();
210 GroupsModule gm = new GroupsModule();
211 GroupsMessagingModule gmm = new GroupsMessagingModule();
212
213 IConfigSource configSource = new IniConfigSource();
214
215 {
216 IConfig config = configSource.AddConfig("Messaging");
217 config.Set("MessageTransferModule", mtm.Name);
218 }
219
220 {
221 IConfig config = configSource.AddConfig("Groups");
222 config.Set("Enabled", true);
223 config.Set("Module", gm.Name);
224 config.Set("DebugEnabled", true);
225 config.Set("MessagingModule", gmm.Name);
226 config.Set("MessagingEnabled", true);
227 config.Set("MessageOnlineUsersOnly", true);
228 }
229
152 SceneHelpers.SetupSceneModules(scene, configSource, new MockGroupsServicesConnector(), mtm, gm, gmm); 230 SceneHelpers.SetupSceneModules(scene, configSource, new MockGroupsServicesConnector(), mtm, gm, gmm);
153 231
154 UUID userId = TestHelpers.ParseTail(0x1); 232 UUID userId = TestHelpers.ParseTail(0x1);
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index d059b97..870c0bb 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -105,8 +105,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
105 m_scene.LoginLock = true; 105 m_scene.LoginLock = true;
106 m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; 106 m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
107 107
108 // Warn level because the region cannot be used while logins are disabled 108 // This should always show up to the user but should not trigger warn/errors as these messages are
109 m_log.WarnFormat("[RegionReady]: Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name); 109 // expected and are not simulator problems. Ideally, there would be a status level in log4net but
110 // failing that, we will print out to console instead.
111 MainConsole.Instance.OutputFormat("Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name);
110 112
111 if (m_uri != string.Empty) 113 if (m_uri != string.Empty)
112 { 114 {
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
index 8e40561..f53adcb 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
@@ -147,6 +147,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
147 terrainHeight = _heightMap[(int)actor.Position.Y * (int)m_regionExtent.Y + (int)actor.Position.X]; 147 terrainHeight = _heightMap[(int)actor.Position.Y * (int)m_regionExtent.Y + (int)actor.Position.X];
148 148
149 float height = terrainHeight + actor.Size.Z; 149 float height = terrainHeight + actor.Size.Z;
150// Console.WriteLine("height {0}, actorPosition {1}", height, actorPosition);
150 151
151 if (actor.Flying) 152 if (actor.Flying)
152 { 153 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs
index 1bcf879..1b8a454 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs
@@ -399,8 +399,8 @@ public class BSActorAvatarMove : BSActor
399 m_controllingPrim.ForcePosition = m_controllingPrim.RawPosition + displacement; 399 m_controllingPrim.ForcePosition = m_controllingPrim.RawPosition + displacement;
400 } 400 }
401 } 401 }
402 m_physicsScene.DetailLog("{0},BSCharacter.WalkUpStairs.ComputeStairCorrection,disp={1},force={2}", 402 m_physicsScene.DetailLog("{0},BSCharacter.WalkUpStairs.ComputeStairCorrection,stepUp={1},isp={2},force={3}",
403 m_controllingPrim.LocalID, displacement, ret); 403 m_controllingPrim.LocalID, stepUp, displacement, ret);
404 404
405 } 405 }
406 return ret; 406 return ret;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index 6683446..de42a4c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -598,9 +598,9 @@ public static class BSParam
598 new ParameterDefn<float>("AvatarStepForceFactor", "Controls the amount of force up applied to step up onto a step", 598 new ParameterDefn<float>("AvatarStepForceFactor", "Controls the amount of force up applied to step up onto a step",
599 1.0f ), 599 1.0f ),
600 new ParameterDefn<float>("AvatarStepUpCorrectionFactor", "Multiplied by height of step collision to create up movement at step", 600 new ParameterDefn<float>("AvatarStepUpCorrectionFactor", "Multiplied by height of step collision to create up movement at step",
601 1.0f ), 601 2.0f ),
602 new ParameterDefn<int>("AvatarStepSmoothingSteps", "Number of frames after a step collision that we continue walking up stairs", 602 new ParameterDefn<int>("AvatarStepSmoothingSteps", "Number of frames after a step collision that we continue walking up stairs",
603 2 ), 603 1 ),
604 604
605 new ParameterDefn<float>("VehicleMaxLinearVelocity", "Maximum velocity magnitude that can be assigned to a vehicle", 605 new ParameterDefn<float>("VehicleMaxLinearVelocity", "Maximum velocity magnitude that can be assigned to a vehicle",
606 1000.0f, 606 1000.0f,
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 9fa55ce..23bada9 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -639,15 +639,18 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
639 { 639 {
640 if (collidersCount > 0) 640 if (collidersCount > 0)
641 { 641 {
642 for (int ii = 0; ii < collidersCount; ii++) 642 lock (PhysObjects)
643 { 643 {
644 uint cA = m_collisionArray[ii].aID; 644 for (int ii = 0; ii < collidersCount; ii++)
645 uint cB = m_collisionArray[ii].bID; 645 {
646 Vector3 point = m_collisionArray[ii].point; 646 uint cA = m_collisionArray[ii].aID;
647 Vector3 normal = m_collisionArray[ii].normal; 647 uint cB = m_collisionArray[ii].bID;
648 float penetration = m_collisionArray[ii].penetration; 648 Vector3 point = m_collisionArray[ii].point;
649 SendCollision(cA, cB, point, normal, penetration); 649 Vector3 normal = m_collisionArray[ii].normal;
650 SendCollision(cB, cA, point, -normal, penetration); 650 float penetration = m_collisionArray[ii].penetration;
651 SendCollision(cA, cB, point, normal, penetration);
652 SendCollision(cB, cA, point, -normal, penetration);
653 }
651 } 654 }
652 } 655 }
653 } 656 }
@@ -658,14 +661,17 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
658 { 661 {
659 if (updatedEntityCount > 0) 662 if (updatedEntityCount > 0)
660 { 663 {
661 for (int ii = 0; ii < updatedEntityCount; ii++) 664 lock (PhysObjects)
662 { 665 {
663 EntityProperties entprop = m_updateArray[ii]; 666 for (int ii = 0; ii < updatedEntityCount; ii++)
664 BSPhysObject pobj;
665 if (PhysObjects.TryGetValue(entprop.ID, out pobj))
666 { 667 {
667 if (pobj.IsInitialized) 668 EntityProperties entprop = m_updateArray[ii];
668 pobj.UpdateProperties(entprop); 669 BSPhysObject pobj;
670 if (PhysObjects.TryGetValue(entprop.ID, out pobj))
671 {
672 if (pobj.IsInitialized)
673 pobj.UpdateProperties(entprop);
674 }
669 } 675 }
670 } 676 }
671 } 677 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 5590cd5..7d8821c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -6846,12 +6846,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6846 { 6846 {
6847 m_host.AddScriptLPS(1); 6847 m_host.AddScriptLPS(1);
6848 m_host.SetCameraEyeOffset(offset); 6848 m_host.SetCameraEyeOffset(offset);
6849
6850 if (m_host.ParentGroup.RootPart.GetCameraEyeOffset() == Vector3.Zero)
6851 m_host.ParentGroup.RootPart.SetCameraEyeOffset(offset);
6849 } 6852 }
6850 6853
6851 public void llSetCameraAtOffset(LSL_Vector offset) 6854 public void llSetCameraAtOffset(LSL_Vector offset)
6852 { 6855 {
6853 m_host.AddScriptLPS(1); 6856 m_host.AddScriptLPS(1);
6854 m_host.SetCameraAtOffset(offset); 6857 m_host.SetCameraAtOffset(offset);
6858
6859 if (m_host.ParentGroup.RootPart.GetCameraAtOffset() == Vector3.Zero)
6860 m_host.ParentGroup.RootPart.SetCameraAtOffset(offset);
6855 } 6861 }
6856 6862
6857 public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at) 6863 public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at)
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
index 6aa717d..8b8e038 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
@@ -162,7 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
162 m_braceCount++; 162 m_braceCount++;
163 163
164 // line number 164 // line number
165 m_CSharpLine += 3; 165 m_CSharpLine += 9;
166 166
167 // here's the payload 167 // here's the payload
168 retstr += GenerateLine(); 168 retstr += GenerateLine();
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index b4640ef..1efe798 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -444,7 +444,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
444// return compileScript; 444// return compileScript;
445// } 445// }
446 446
447 private static string CreateCSCompilerScript( 447 public static string CreateCSCompilerScript(
448 string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters) 448 string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters)
449 { 449 {
450 compileScript = string.Format( 450 compileScript = string.Format(
@@ -472,7 +472,7 @@ namespace SecondLife
472 return compileScript; 472 return compileScript;
473 } 473 }
474 474
475 private static string CreateVBCompilerScript(string compileScript, string className, string baseClassName) 475 public static string CreateVBCompilerScript(string compileScript, string className, string baseClassName)
476 { 476 {
477 compileScript = String.Empty + 477 compileScript = String.Empty +
478 "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " + 478 "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " +
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
index 05a8756..713b280 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
@@ -25,12 +25,14 @@
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 27
28using System;
28using System.IO; 29using System.IO;
29using System.CodeDom.Compiler; 30using System.CodeDom.Compiler;
30using System.Collections.Generic; 31using System.Collections.Generic;
31using Microsoft.CSharp; 32using Microsoft.CSharp;
32using NUnit.Framework; 33using NUnit.Framework;
33using OpenSim.Region.ScriptEngine.Shared.CodeTools; 34using OpenSim.Region.ScriptEngine.Shared.CodeTools;
35using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
34using OpenSim.Tests.Common; 36using OpenSim.Tests.Common;
35 37
36namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests 38namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
@@ -47,6 +49,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
47 private CSharpCodeProvider m_CSCodeProvider; 49 private CSharpCodeProvider m_CSCodeProvider;
48 private CompilerParameters m_compilerParameters; 50 private CompilerParameters m_compilerParameters;
49 private CompilerResults m_compilerResults; 51 private CompilerResults m_compilerResults;
52 private ResolveEventHandler m_resolveEventHandler;
50 53
51 /// <summary> 54 /// <summary>
52 /// Creates a temporary directory where build artifacts are stored. 55 /// Creates a temporary directory where build artifacts are stored.
@@ -66,9 +69,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
66 m_CSCodeProvider = new CSharpCodeProvider(); 69 m_CSCodeProvider = new CSharpCodeProvider();
67 m_compilerParameters = new CompilerParameters(); 70 m_compilerParameters = new CompilerParameters();
68 71
69 string rootPath = Path.Combine(Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory), "bin"); 72 string rootPath = System.AppDomain.CurrentDomain.BaseDirectory;
73
74 m_resolveEventHandler = new ResolveEventHandler(AssemblyResolver.OnAssemblyResolve);
75
76 System.AppDomain.CurrentDomain.AssemblyResolve += m_resolveEventHandler;
77
70 m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); 78 m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll"));
71 m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); 79 m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll"));
80 m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenMetaverseTypes.dll"));
72 m_compilerParameters.GenerateExecutable = false; 81 m_compilerParameters.GenerateExecutable = false;
73 } 82 }
74 83
@@ -79,6 +88,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
79 [TestFixtureTearDown] 88 [TestFixtureTearDown]
80 public void CleanUp() 89 public void CleanUp()
81 { 90 {
91 System.AppDomain.CurrentDomain.AssemblyResolve -= m_resolveEventHandler;
92
82 if (Directory.Exists(m_testDir)) 93 if (Directory.Exists(m_testDir))
83 { 94 {
84 // Blow away the temporary directory with artifacts. 95 // Blow away the temporary directory with artifacts.
@@ -90,7 +101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
90 /// Test the C# compiler error message can be mapped to the correct 101 /// Test the C# compiler error message can be mapped to the correct
91 /// line/column in the LSL source when an undeclared variable is used. 102 /// line/column in the LSL source when an undeclared variable is used.
92 /// </summary> 103 /// </summary>
93 //[Test] 104 [Test]
94 public void TestUseUndeclaredVariable() 105 public void TestUseUndeclaredVariable()
95 { 106 {
96 TestHelpers.InMethod(); 107 TestHelpers.InMethod();
@@ -106,25 +117,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
106}"; 117}";
107 118
108 CSCodeGenerator cg = new CSCodeGenerator(); 119 CSCodeGenerator cg = new CSCodeGenerator();
109 string output = "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\n" + 120 string output = cg.Convert(input);
110 "namespace SecondLife { " + 121
111 "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass {\n" + 122 output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null);
112 "public Script() { } " + 123// System.Console.WriteLine(output);
113 cg.Convert(input) + 124
114 "} }\n";
115 Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> positionMap = cg.PositionMap; 125 Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> positionMap = cg.PositionMap;
116 126
117 m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); 127 m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output);
118 128//
119 Assert.AreEqual(new KeyValuePair<int, int>(5, 21), 129// foreach (KeyValuePair<int, int> key in positionMap.Keys)
120 positionMap[new KeyValuePair<int, int>(m_compilerResults.Errors[0].Line, m_compilerResults.Errors[0].Column)]); 130// {
131// KeyValuePair<int, int> val = positionMap[key];
132//
133// System.Console.WriteLine("{0},{1} => {2},{3}", key.Key, key.Value, val.Key, val.Value);
134// }
135//
136// foreach (CompilerError compErr in m_compilerResults.Errors)
137// {
138// System.Console.WriteLine("Error: {0},{1} => {2}", compErr.Line, compErr.Column, compErr);
139// }
140
141 Assert.AreEqual(
142 new KeyValuePair<int, int>(5, 21),
143 positionMap[new KeyValuePair<int, int>(m_compilerResults.Errors[0].Line, m_compilerResults.Errors[0].Column)]);
121 } 144 }
122 145
123 /// <summary> 146 /// <summary>
124 /// Test that a string can be cast to string and another string 147 /// Test that a string can be cast to string and another string
125 /// concatenated. 148 /// concatenated.
126 /// </summary> 149 /// </summary>
127 //[Test] 150 [Test]
128 public void TestCastAndConcatString() 151 public void TestCastAndConcatString()
129 { 152 {
130 TestHelpers.InMethod(); 153 TestHelpers.InMethod();
@@ -143,15 +166,21 @@ default
143 } 166 }
144}"; 167}";
145 168
169// System.Console.WriteLine(input);
146 CSCodeGenerator cg = new CSCodeGenerator(); 170 CSCodeGenerator cg = new CSCodeGenerator();
147 string output = "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\n" + 171 string output = cg.Convert(input);
148 "namespace SecondLife { " + 172
149 "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass {\n" + 173 output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null);
150 "public Script() { } " + 174// System.Console.WriteLine(output);
151 cg.Convert(input) + 175
152 "} }\n";
153 m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); 176 m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output);
154 177
178 System.Console.WriteLine("ERRORS: {0}", m_compilerResults.Errors.Count);
179 foreach (CompilerError compErr in m_compilerResults.Errors)
180 {
181 System.Console.WriteLine("Error: {0}", compErr);
182 }
183
155 Assert.AreEqual(0, m_compilerResults.Errors.Count); 184 Assert.AreEqual(0, m_compilerResults.Errors.Count);
156 } 185 }
157 } 186 }