aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-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
18 files changed, 591 insertions, 217 deletions
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();