aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs16
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs127
-rw-r--r--OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs66
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs115
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs17
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs204
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs26
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs102
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs62
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs7
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs63
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs32
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs60
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs19
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs780
-rw-r--r--OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs16
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs34
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs74
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs23
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs15
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs6
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs12
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs18
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs56
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs496
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs37
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Region/RestartModule.cs35
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs2
39 files changed, 1860 insertions, 728 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index 771038e..4255c79 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -167,6 +167,19 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
167 { 167 {
168 if (XferUploaders.ContainsKey(transactionID)) 168 if (XferUploaders.ContainsKey(transactionID))
169 { 169 {
170// m_log.DebugFormat("[XFER]: Asked to update item {0} ({1})",
171// item.Name, item.ID);
172
173 // Here we need to get the old asset to extract the
174 // texture UUIDs if it's a wearable.
175 if (item.AssetType == (int)AssetType.Bodypart ||
176 item.AssetType == (int)AssetType.Clothing)
177 {
178 AssetBase oldAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
179 if (oldAsset != null)
180 XferUploaders[transactionID].SetOldData(oldAsset.Data);
181 }
182
170 AssetBase asset = GetTransactionAsset(transactionID); 183 AssetBase asset = GetTransactionAsset(transactionID);
171 184
172 if (asset != null) 185 if (asset != null)
@@ -181,6 +194,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
181 194
182 IInventoryService invService = m_Scene.InventoryService; 195 IInventoryService invService = m_Scene.InventoryService;
183 invService.UpdateItem(item); 196 invService.UpdateItem(item);
197
198// m_log.DebugFormat("[XFER]: Updated item {0} ({1}) with asset {2}",
199// item.Name, item.ID, asset.FullID);
184 } 200 }
185 } 201 }
186 } 202 }
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
index a7929ba..a5dcdcc 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Reflection; 30using System.Reflection;
31using System.Collections.Generic;
31using log4net; 32using log4net;
32using OpenMetaverse; 33using OpenMetaverse;
33using OpenSim.Framework; 34using OpenSim.Framework;
@@ -38,6 +39,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
38{ 39{
39 public class AssetXferUploader 40 public class AssetXferUploader
40 { 41 {
42 // Viewer's notion of the default texture
43 private List<UUID> defaultIDs = new List<UUID> {
44 new UUID("5748decc-f629-461c-9a36-a35a221fe21f"),
45 new UUID("7ca39b4c-bd19-4699-aff7-f93fd03d3e7b"),
46 new UUID("6522e74d-1660-4e7f-b601-6f48c1659a77"),
47 new UUID("c228d1cf-4b5d-4ba8-84f4-899a0796aa97")
48 };
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 50
43 private AssetBase m_asset; 51 private AssetBase m_asset;
@@ -55,6 +63,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
55 private UUID TransactionID = UUID.Zero; 63 private UUID TransactionID = UUID.Zero;
56 private sbyte type = 0; 64 private sbyte type = 0;
57 private byte wearableType = 0; 65 private byte wearableType = 0;
66 private byte[] m_oldData = null;
58 public ulong XferID; 67 public ulong XferID;
59 private Scene m_Scene; 68 private Scene m_Scene;
60 69
@@ -219,6 +228,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
219 228
220 private void DoCreateItem(uint callbackID) 229 private void DoCreateItem(uint callbackID)
221 { 230 {
231 ValidateAssets();
222 m_Scene.AssetService.Store(m_asset); 232 m_Scene.AssetService.Store(m_asset);
223 233
224 InventoryItemBase item = new InventoryItemBase(); 234 InventoryItemBase item = new InventoryItemBase();
@@ -239,12 +249,84 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
239 item.Flags = (uint) wearableType; 249 item.Flags = (uint) wearableType;
240 item.CreationDate = Util.UnixTimeSinceEpoch(); 250 item.CreationDate = Util.UnixTimeSinceEpoch();
241 251
252 m_log.DebugFormat("[XFER]: Created item {0} with asset {1}",
253 item.ID, item.AssetID);
254
242 if (m_Scene.AddInventoryItem(item)) 255 if (m_Scene.AddInventoryItem(item))
243 ourClient.SendInventoryItemCreateUpdate(item, callbackID); 256 ourClient.SendInventoryItemCreateUpdate(item, callbackID);
244 else 257 else
245 ourClient.SendAlertMessage("Unable to create inventory item"); 258 ourClient.SendAlertMessage("Unable to create inventory item");
246 } 259 }
247 260
261 private void ValidateAssets()
262 {
263 if (m_asset.Type == (sbyte)AssetType.Clothing ||
264 m_asset.Type == (sbyte)AssetType.Bodypart)
265 {
266 string content = System.Text.Encoding.ASCII.GetString(m_asset.Data);
267 string[] lines = content.Split(new char[] {'\n'});
268
269 List<string> validated = new List<string>();
270
271 Dictionary<int, UUID> allowed = ExtractTexturesFromOldData();
272
273 int textures = 0;
274
275 foreach (string line in lines)
276 {
277 try
278 {
279 if (line.StartsWith("textures "))
280 {
281 textures = Convert.ToInt32(line.Substring(9));
282 validated.Add(line);
283 }
284 else if (textures > 0)
285 {
286 string[] parts = line.Split(new char[] {' '});
287
288 UUID tx = new UUID(parts[1]);
289 int id = Convert.ToInt32(parts[0]);
290
291 if (defaultIDs.Contains(tx) || tx == UUID.Zero ||
292 (allowed.ContainsKey(id) && allowed[id] == tx))
293 {
294 validated.Add(parts[0] + " " + tx.ToString());
295 }
296 else
297 {
298 int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, tx);
299 int full = (int)(PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Copy);
300
301 if ((perms & full) != full)
302 {
303 m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId);
304 validated.Add(parts[0] + " " + UUID.Zero.ToString());
305 }
306 else
307 {
308 validated.Add(line);
309 }
310 }
311 textures--;
312 }
313 else
314 {
315 validated.Add(line);
316 }
317 }
318 catch
319 {
320 // If it's malformed, skip it
321 }
322 }
323
324 string final = String.Join("\n", validated.ToArray());
325
326 m_asset.Data = System.Text.Encoding.ASCII.GetBytes(final);
327 }
328 }
329
248 /// <summary> 330 /// <summary>
249 /// Get the asset data uploaded in this transfer. 331 /// Get the asset data uploaded in this transfer.
250 /// </summary> 332 /// </summary>
@@ -253,10 +335,55 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
253 { 335 {
254 if (m_finished) 336 if (m_finished)
255 { 337 {
338 ValidateAssets();
256 return m_asset; 339 return m_asset;
257 } 340 }
258 341
259 return null; 342 return null;
260 } 343 }
344
345 public void SetOldData(byte[] d)
346 {
347 m_oldData = d;
348 }
349
350 private Dictionary<int,UUID> ExtractTexturesFromOldData()
351 {
352 Dictionary<int,UUID> result = new Dictionary<int,UUID>();
353 if (m_oldData == null)
354 return result;
355
356 string content = System.Text.Encoding.ASCII.GetString(m_oldData);
357 string[] lines = content.Split(new char[] {'\n'});
358
359 int textures = 0;
360
361 foreach (string line in lines)
362 {
363 try
364 {
365 if (line.StartsWith("textures "))
366 {
367 textures = Convert.ToInt32(line.Substring(9));
368 }
369 else if (textures > 0)
370 {
371 string[] parts = line.Split(new char[] {' '});
372
373 UUID tx = new UUID(parts[1]);
374 int id = Convert.ToInt32(parts[0]);
375 result[id] = tx;
376 textures--;
377 }
378 }
379 catch
380 {
381 // If it's malformed, skip it
382 }
383 }
384
385 return result;
386 }
261 } 387 }
262} 388}
389
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
index 1d8e70e..7526bd2 100644
--- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
@@ -95,7 +95,8 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
95 95
96 public void AddCapsHandler(UUID agentId) 96 public void AddCapsHandler(UUID agentId)
97 { 97 {
98 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) 98 int flags = m_scene.GetUserFlags(agentId);
99 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
99 return; 100 return;
100 101
101 String capsObjectPath = GetCapsPath(agentId); 102 String capsObjectPath = GetCapsPath(agentId);
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 9adb68b..7cba702 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -262,7 +262,16 @@ namespace Flotsam.RegionModules.AssetCache
262 // If the file is already cached, don't cache it, just touch it so access time is updated 262 // If the file is already cached, don't cache it, just touch it so access time is updated
263 if (File.Exists(filename)) 263 if (File.Exists(filename))
264 { 264 {
265 File.SetLastAccessTime(filename, DateTime.Now); 265 // We don't really want to know about sharing
266 // violations here. If the file is locked, then
267 // the other thread has updated the time for us.
268 try
269 {
270 File.SetLastAccessTime(filename, DateTime.Now);
271 }
272 catch
273 {
274 }
266 } else { 275 } else {
267 276
268 // Once we start writing, make sure we flag that we're writing 277 // Once we start writing, make sure we flag that we're writing
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index ff26264..dc33dbb 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Xml;
31using log4net; 32using log4net;
32using Mono.Addins; 33using Mono.Addins;
33using Nini.Config; 34using Nini.Config;
@@ -118,6 +119,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
118 return; 119 return;
119 } 120 }
120 121
122 if (part.OwnerID != remoteClient.AgentId) // Not ours
123 {
124 remoteClient.SendAgentAlertMessage(
125 "You don't have sufficient permissions to attach this object", false);
126 return;
127 }
128
121 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 129 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
122 // be removed when that functionality is implemented in opensim 130 // be removed when that functionality is implemented in opensim
123 AttachmentPt &= 0x7f; 131 AttachmentPt &= 0x7f;
@@ -226,15 +234,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
226 public UUID RezSingleAttachmentFromInventory( 234 public UUID RezSingleAttachmentFromInventory(
227 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) 235 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus)
228 { 236 {
229 m_log.DebugFormat( 237 return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true, null);
230 "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", 238 }
231 (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); 239
232 240 public UUID RezSingleAttachmentFromInventory(
241 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc)
242 {
233 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 243 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
234 // be removed when that functionality is implemented in opensim 244 // be removed when that functionality is implemented in opensim
235 AttachmentPt &= 0x7f; 245 AttachmentPt &= 0x7f;
236 246
237 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); 247 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt, doc);
238 248
239 if (updateInventoryStatus) 249 if (updateInventoryStatus)
240 { 250 {
@@ -251,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
251 } 261 }
252 262
253 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 263 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
254 IClientAPI remoteClient, UUID itemID, uint AttachmentPt) 264 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, XmlDocument doc)
255 { 265 {
256 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 266 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
257 if (invAccess != null) 267 if (invAccess != null)
@@ -289,13 +299,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
289 if (tainted) 299 if (tainted)
290 objatt.HasGroupChanged = true; 300 objatt.HasGroupChanged = true;
291 301
302 if (doc != null)
303 {
304 objatt.LoadScriptState(doc);
305 objatt.ResetOwnerChangeFlag();
306 }
307
292 // Fire after attach, so we don't get messy perms dialogs 308 // Fire after attach, so we don't get messy perms dialogs
293 // 4 == AttachedRez 309 // 4 == AttachedRez
294 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); 310 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
295 objatt.ResumeScripts(); 311 objatt.ResumeScripts();
296 312
297 // Do this last so that event listeners have access to all the effects of the attachment 313 // Do this last so that event listeners have access to all the effects of the attachment
298 m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); 314 //m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
299 } 315 }
300 else 316 else
301 { 317 {
@@ -332,7 +348,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
332 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) 348 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
333 { 349 {
334 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 350 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
335 item = m_scene.InventoryService.GetItem(item); 351 if (m_scene.InventoryService != null)
352 item = m_scene.InventoryService.GetItem(item);
336 353
337 bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); 354 bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
338 if (changed && m_scene.AvatarFactory != null) 355 if (changed && m_scene.AvatarFactory != null)
@@ -379,6 +396,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
379 { 396 {
380 // XXYY!! 397 // XXYY!!
381 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 398 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
399 if (item == null)
400 m_log.Error("[ATTACHMENT]: item == null");
401 if (m_scene == null)
402 m_log.Error("[ATTACHMENT]: m_scene == null");
403 if (m_scene.InventoryService == null)
404 m_log.Error("[ATTACHMENT]: m_scene.InventoryService == null");
382 item = m_scene.InventoryService.GetItem(item); 405 item = m_scene.InventoryService.GetItem(item);
383 bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); 406 bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
384 if (changed && m_scene.AvatarFactory != null) 407 if (changed && m_scene.AvatarFactory != null)
@@ -465,6 +488,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
465 if (group.GetFromItemID() == itemID) 488 if (group.GetFromItemID() == itemID)
466 { 489 {
467 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); 490 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
491 // CM / XMREngine!!!! Needed to conclude attach event
492 //SceneObjectSerializer.ToOriginalXmlFormat(group);
468 group.DetachToInventoryPrep(); 493 group.DetachToInventoryPrep();
469 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); 494 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
470 495
@@ -482,22 +507,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
482 } 507 }
483 } 508 }
484 509
485 public void UpdateAttachmentPosition(SceneObjectGroup sog, Vector3 pos)
486 {
487 // First we save the
488 // attachment point information, then we update the relative
489 // positioning. Then we have to mark the object as NOT an
490 // attachment. This is necessary in order to correctly save
491 // and retrieve GroupPosition information for the attachment.
492 // Finally, we restore the object's attachment status.
493 byte attachmentPoint = sog.GetAttachmentPoint();
494 sog.UpdateGroupPosition(pos);
495 sog.RootPart.IsAttachment = false;
496 sog.AbsolutePosition = sog.RootPart.AttachedPos;
497 sog.SetAttachmentPoint(attachmentPoint);
498 sog.HasGroupChanged = true;
499 }
500
501 /// <summary> 510 /// <summary>
502 /// Update the attachment asset for the new sog details if they have changed. 511 /// Update the attachment asset for the new sog details if they have changed.
503 /// </summary> 512 /// </summary>
@@ -601,15 +610,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
601 610
602 if (!silent) 611 if (!silent)
603 { 612 {
604 // Killing it here will cause the client to deselect it
605 // It then reappears on the avatar, deselected
606 // through the full update below
607 //
608 if (so.IsSelected)
609 {
610 m_scene.SendKillObject(so.RootPart.LocalId);
611 }
612
613 so.IsSelected = false; // fudge.... 613 so.IsSelected = false; // fudge....
614 so.ScheduleGroupForFullUpdate(); 614 so.ScheduleGroupForFullUpdate();
615 } 615 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index 4359c01..35a3f43 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -49,7 +49,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
49 private int m_shoutdistance = 100; 49 private int m_shoutdistance = 100;
50 private int m_whisperdistance = 10; 50 private int m_whisperdistance = 10;
51 private List<Scene> m_scenes = new List<Scene>(); 51 private List<Scene> m_scenes = new List<Scene>();
52 52 private List<string> FreezeCache = new List<string>();
53 private string m_adminPrefix = "";
53 internal object m_syncy = new object(); 54 internal object m_syncy = new object();
54 55
55 internal IConfig m_config; 56 internal IConfig m_config;
@@ -76,6 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
76 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 77 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
77 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 78 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
78 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 79 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
80 m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", "");
79 } 81 }
80 82
81 public virtual void AddRegion(Scene scene) 83 public virtual void AddRegion(Scene scene)
@@ -171,7 +173,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
171 return; 173 return;
172 } 174 }
173 175
174 DeliverChatToAvatars(ChatSourceType.Agent, c); 176 if (FreezeCache.Contains(c.Sender.AgentId.ToString()))
177 {
178 if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping)
179 c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false);
180 }
181 else
182 {
183 DeliverChatToAvatars(ChatSourceType.Agent, c);
184 }
175 } 185 }
176 186
177 public virtual void OnChatFromWorld(Object sender, OSChatMessage c) 187 public virtual void OnChatFromWorld(Object sender, OSChatMessage c)
@@ -185,6 +195,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
185 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) 195 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
186 { 196 {
187 string fromName = c.From; 197 string fromName = c.From;
198 string fromNamePrefix = "";
188 UUID fromID = UUID.Zero; 199 UUID fromID = UUID.Zero;
189 string message = c.Message; 200 string message = c.Message;
190 IScene scene = c.Scene; 201 IScene scene = c.Scene;
@@ -207,7 +218,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
207 fromPos = avatar.AbsolutePosition; 218 fromPos = avatar.AbsolutePosition;
208 fromName = avatar.Name; 219 fromName = avatar.Name;
209 fromID = c.Sender.AgentId; 220 fromID = c.Sender.AgentId;
210 221 if (avatar.GodLevel >= 200)
222 {
223 fromNamePrefix = m_adminPrefix;
224 }
211 break; 225 break;
212 226
213 case ChatSourceType.Object: 227 case ChatSourceType.Object:
@@ -231,8 +245,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
231 s.ForEachScenePresence( 245 s.ForEachScenePresence(
232 delegate(ScenePresence presence) 246 delegate(ScenePresence presence)
233 { 247 {
234 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) 248 ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
235 receiverIDs.Add(presence.UUID); 249 if (Presencecheck != null)
250 {
251 // This will pass all chat from objects. Not
252 // perfect, but it will do. For now. Better
253 // than the prior behavior of muting all
254 // objects on a parcel with access restrictions
255 if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
256 {
257 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType))
258 receiverIDs.Add(presence.UUID);
259 }
260 }
261
236 } 262 }
237 ); 263 );
238 } 264 }
@@ -276,31 +302,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
276 } 302 }
277 303
278 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); 304 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
279
280 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 305 HashSet<UUID> receiverIDs = new HashSet<UUID>();
281 306
282 ((Scene)c.Scene).ForEachScenePresence( 307 if (c.Scene != null)
283 delegate(ScenePresence presence) 308 {
284 { 309 ((Scene)c.Scene).ForEachScenePresence
285 // ignore chat from child agents 310 (
286 if (presence.IsChildAgent) return; 311 delegate(ScenePresence presence)
287 312 {
288 IClientAPI client = presence.ControllingClient; 313 // ignore chat from child agents
289 314 if (presence.IsChildAgent) return;
290 // don't forward SayOwner chat from objects to 315
291 // non-owner agents 316 IClientAPI client = presence.ControllingClient;
292 if ((c.Type == ChatTypeEnum.Owner) && 317
293 (null != c.SenderObject) && 318 // don't forward SayOwner chat from objects to
294 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) 319 // non-owner agents
295 return; 320 if ((c.Type == ChatTypeEnum.Owner) &&
296 321 (null != c.SenderObject) &&
297 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, 322 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
298 (byte)sourceType, (byte)ChatAudibleLevel.Fully); 323 return;
299 receiverIDs.Add(presence.UUID); 324
300 }); 325 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
301 326 (byte)sourceType, (byte)ChatAudibleLevel.Fully);
302 (c.Scene as Scene).EventManager.TriggerOnChatToClients( 327 receiverIDs.Add(presence.UUID);
303 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); 328 }
329 );
330 (c.Scene as Scene).EventManager.TriggerOnChatToClients(
331 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
332 }
304 } 333 }
305 334
306 /// <summary> 335 /// <summary>
@@ -343,5 +372,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
343 372
344 return true; 373 return true;
345 } 374 }
375
376 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
377 public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
378 {
379 System.Threading.Timer Timer;
380 if (flags == 0)
381 {
382 FreezeCache.Add(target.ToString());
383 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
384 Timer = new System.Threading.Timer(timeCB, target, 30000, 0);
385 Timers.Add(target, Timer);
386 }
387 else
388 {
389 FreezeCache.Remove(target.ToString());
390 Timers.TryGetValue(target, out Timer);
391 Timers.Remove(target);
392 Timer.Dispose();
393 }
394 }
395
396 private void OnEndParcelFrozen(object avatar)
397 {
398 UUID target = (UUID)avatar;
399 FreezeCache.Remove(target.ToString());
400 System.Threading.Timer Timer;
401 Timers.TryGetValue(target, out Timer);
402 Timers.Remove(target);
403 Timer.Dispose();
404 }
346 } 405 }
347} 406}
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index 8a977c9..ded8743 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -215,4 +215,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
215 return result; 215 return result;
216 } 216 }
217 } 217 }
218} \ No newline at end of file 218}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 4d74b2a..3148871 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -273,7 +273,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
273 273
274 // Inform the friends that this user is online 274 // Inform the friends that this user is online
275 StatusChange(agentID, true); 275 StatusChange(agentID, true);
276 276
277 // Register that we need to send the list of online friends to this user 277 // Register that we need to send the list of online friends to this user
278 lock (m_NeedsListOfFriends) 278 lock (m_NeedsListOfFriends)
279 m_NeedsListOfFriends.Add(agentID); 279 m_NeedsListOfFriends.Add(agentID);
@@ -516,6 +516,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
516 FriendsService.StoreFriend(agentID, friendID.ToString(), 1); 516 FriendsService.StoreFriend(agentID, friendID.ToString(), 1);
517 FriendsService.StoreFriend(friendID, agentID.ToString(), 1); 517 FriendsService.StoreFriend(friendID, agentID.ToString(), 1);
518 518
519 ICallingCardModule ccm = client.Scene.RequestModuleInterface<ICallingCardModule>();
520 if (ccm != null)
521 {
522 ccm.CreateCallingCard(agentID, friendID, UUID.Zero);
523 }
524
519 // Update the local cache 525 // Update the local cache
520 UpdateFriendsCache(agentID); 526 UpdateFriendsCache(agentID);
521 527
@@ -679,6 +685,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
679 (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero); 685 (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero);
680 friendClient.SendInstantMessage(im); 686 friendClient.SendInstantMessage(im);
681 687
688 ICallingCardModule ccm = friendClient.Scene.RequestModuleInterface<ICallingCardModule>();
689 if (ccm != null)
690 {
691 ccm.CreateCallingCard(friendID, userID, UUID.Zero);
692 }
693
694
682 // Update the local cache 695 // Update the local cache
683 UpdateFriendsCache(friendID); 696 UpdateFriendsCache(friendID);
684 697
@@ -701,7 +714,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
701 // we're done 714 // we're done
702 return true; 715 return true;
703 } 716 }
704 717
705 return false; 718 return false;
706 } 719 }
707 720
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index 5ec64d5..a83b3df 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -31,16 +31,40 @@ using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes; 32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using System;
35using System.Reflection;
36using System.Collections;
37using System.Collections.Specialized;
38using System.Reflection;
39using System.IO;
40using System.Web;
41using System.Xml;
42using log4net;
43using Mono.Addins;
44using OpenMetaverse.Messages.Linden;
45using OpenMetaverse.StructuredData;
46using OpenSim.Framework.Capabilities;
47using OpenSim.Framework.Servers;
48using OpenSim.Framework.Servers.HttpServer;
49using Caps = OpenSim.Framework.Capabilities.Caps;
50using OSDArray = OpenMetaverse.StructuredData.OSDArray;
51using OSDMap = OpenMetaverse.StructuredData.OSDMap;
34 52
35namespace OpenSim.Region.CoreModules.Avatar.Gods 53namespace OpenSim.Region.CoreModules.Avatar.Gods
36{ 54{
37 public class GodsModule : IRegionModule, IGodsModule 55 public class GodsModule : IRegionModule, IGodsModule
38 { 56 {
57 private static readonly ILog m_log =
58 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59
39 /// <summary>Special UUID for actions that apply to all agents</summary> 60 /// <summary>Special UUID for actions that apply to all agents</summary>
40 private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); 61 private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb");
41 62
42 protected Scene m_scene; 63 protected Scene m_scene;
43 protected IDialogModule m_dialogModule; 64 protected IDialogModule m_dialogModule;
65
66 protected Dictionary<UUID, string> m_capsDict =
67 new Dictionary<UUID, string>();
44 68
45 public void Initialise(Scene scene, IConfigSource source) 69 public void Initialise(Scene scene, IConfigSource source)
46 { 70 {
@@ -48,6 +72,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
48 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); 72 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
49 m_scene.RegisterModuleInterface<IGodsModule>(this); 73 m_scene.RegisterModuleInterface<IGodsModule>(this);
50 m_scene.EventManager.OnNewClient += SubscribeToClientEvents; 74 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
75 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
76 m_scene.EventManager.OnClientClosed += OnClientClosed;
77 scene.EventManager.OnIncomingInstantMessage +=
78 OnIncomingInstantMessage;
51 } 79 }
52 80
53 public void PostInitialise() {} 81 public void PostInitialise() {}
@@ -67,6 +95,54 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
67 client.OnRequestGodlikePowers -= RequestGodlikePowers; 95 client.OnRequestGodlikePowers -= RequestGodlikePowers;
68 } 96 }
69 97
98 private void OnClientClosed(UUID agentID, Scene scene)
99 {
100 m_capsDict.Remove(agentID);
101 }
102
103 private void OnRegisterCaps(UUID agentID, Caps caps)
104 {
105 string uri = "/CAPS/" + UUID.Random();
106 m_capsDict[agentID] = uri;
107
108 caps.RegisterHandler("UntrustedSimulatorMessage",
109 new RestStreamHandler("POST", uri,
110 HandleUntrustedSimulatorMessage));
111 }
112
113 private string HandleUntrustedSimulatorMessage(string request,
114 string path, string param, OSHttpRequest httpRequest,
115 OSHttpResponse httpResponse)
116 {
117 OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(request);
118
119 string message = osd["message"].AsString();
120
121 if (message == "GodKickUser")
122 {
123 OSDMap body = (OSDMap)osd["body"];
124 OSDArray userInfo = (OSDArray)body["UserInfo"];
125 OSDMap userData = (OSDMap)userInfo[0];
126
127 UUID agentID = userData["AgentID"].AsUUID();
128 UUID godID = userData["GodID"].AsUUID();
129 UUID godSessionID = userData["GodSessionID"].AsUUID();
130 uint kickFlags = userData["KickFlags"].AsUInteger();
131 string reason = userData["Reason"].AsString();
132
133 ScenePresence god = m_scene.GetScenePresence(godID);
134 if (god == null || god.ControllingClient.SessionId != godSessionID)
135 return String.Empty;
136
137 KickUser(godID, godSessionID, agentID, kickFlags, Util.StringToBytes1024(reason));
138 }
139 else
140 {
141 m_log.ErrorFormat("[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message);
142 }
143 return String.Empty;
144 }
145
70 public void RequestGodlikePowers( 146 public void RequestGodlikePowers(
71 UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) 147 UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient)
72 { 148 {
@@ -115,71 +191,85 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
115 /// <param name="reason">The message to send to the user after it's been turned into a field</param> 191 /// <param name="reason">The message to send to the user after it's been turned into a field</param>
116 public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) 192 public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason)
117 { 193 {
118 UUID kickUserID = ALL_AGENTS; 194 if (!m_scene.Permissions.IsGod(godID))
119 195 return;
196
120 ScenePresence sp = m_scene.GetScenePresence(agentID); 197 ScenePresence sp = m_scene.GetScenePresence(agentID);
121 198
122 if (sp != null || agentID == kickUserID) 199 if (sp == null && agentID != ALL_AGENTS)
123 { 200 {
124 if (m_scene.Permissions.IsGod(godID)) 201 IMessageTransferModule transferModule =
202 m_scene.RequestModuleInterface<IMessageTransferModule>();
203 if (transferModule != null)
125 { 204 {
126 if (kickflags == 0) 205 m_log.DebugFormat("[GODS]: Sending nonlocal kill for agent {0}", agentID);
127 { 206 transferModule.SendInstantMessage(new GridInstantMessage(
128 if (agentID == kickUserID) 207 m_scene, godID, "God", agentID, (byte)250, false,
129 { 208 Utils.BytesToString(reason), UUID.Zero, true,
130 string reasonStr = Utils.BytesToString(reason); 209 new Vector3(), new byte[] {(byte)kickflags}),
131 210 delegate(bool success) {} );
132 m_scene.ForEachClient( 211 }
133 delegate(IClientAPI controller) 212 return;
134 { 213 }
135 if (controller.AgentId != godID)
136 controller.Kick(reasonStr);
137 }
138 );
139
140 // This is a bit crude. It seems the client will be null before it actually stops the thread
141 // The thread will kill itself eventually :/
142 // Is there another way to make sure *all* clients get this 'inter region' message?
143 m_scene.ForEachScenePresence(
144 delegate(ScenePresence p)
145 {
146 if (p.UUID != godID && !p.IsChildAgent)
147 {
148 // Possibly this should really be p.Close() though that method doesn't send a close
149 // to the client
150 p.ControllingClient.Close();
151 }
152 }
153 );
154 }
155 else
156 {
157 m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent);
158 214
159 sp.ControllingClient.Kick(Utils.BytesToString(reason)); 215 switch (kickflags)
160 sp.ControllingClient.Close(); 216 {
161 } 217 case 0:
162 } 218 if (sp != null)
163 219 {
164 if (kickflags == 1) 220 KickPresence(sp, Utils.BytesToString(reason));
165 {
166 sp.AllowMovement = false;
167 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
168 m_dialogModule.SendAlertToUser(godID, "User Frozen");
169 }
170
171 if (kickflags == 2)
172 {
173 sp.AllowMovement = true;
174 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
175 m_dialogModule.SendAlertToUser(godID, "User Unfrozen");
176 }
177 } 221 }
178 else 222 else if (agentID == ALL_AGENTS)
179 { 223 {
180 m_dialogModule.SendAlertToUser(godID, "Kick request denied"); 224 m_scene.ForEachScenePresence(
225 delegate(ScenePresence p)
226 {
227 if (p.UUID != godID && (!m_scene.Permissions.IsGod(p.UUID)))
228 KickPresence(p, Utils.BytesToString(reason));
229 }
230 );
181 } 231 }
232 break;
233 case 1:
234 if (sp != null)
235 {
236 sp.AllowMovement = false;
237 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
238 m_dialogModule.SendAlertToUser(godID, "User Frozen");
239 }
240 break;
241 case 2:
242 if (sp != null)
243 {
244 sp.AllowMovement = true;
245 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
246 m_dialogModule.SendAlertToUser(godID, "User Unfrozen");
247 }
248 break;
249 default:
250 break;
251 }
252 }
253
254 private void KickPresence(ScenePresence sp, string reason)
255 {
256 if (sp.IsChildAgent)
257 return;
258 sp.ControllingClient.Kick(reason);
259 sp.Scene.IncomingCloseAgent(sp.UUID);
260 }
261
262 private void OnIncomingInstantMessage(GridInstantMessage msg)
263 {
264 if (msg.dialog == (uint)250) // Nonlocal kick
265 {
266 UUID agentID = new UUID(msg.toAgentID);
267 string reason = msg.message;
268 UUID godID = new UUID(msg.fromAgentID);
269 uint kickMode = (uint)msg.binaryBucket[0];
270
271 KickUser(godID, UUID.Zero, agentID, kickMode, Util.StringToBytes1024(reason));
182 } 272 }
183 } 273 }
184 } 274 }
185} \ No newline at end of file 275}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index af39565..feb5fb8 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -156,6 +156,32 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
156 return; 156 return;
157 } 157 }
158 158
159 //DateTime dt = DateTime.UtcNow;
160
161 // Ticks from UtcNow, but make it look like local. Evil, huh?
162 //dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
163
164 //try
165 //{
166 // // Convert that to the PST timezone
167 // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
168 // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
169 //}
170 //catch
171 //{
172 // //m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp.");
173 //}
174
175 //// And make it look local again to fool the unix time util
176 //dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
177
178 // If client is null, this message comes from storage and IS offline
179 if (client != null)
180 im.offline = 0;
181
182 if (im.offline == 0)
183 im.timestamp = (uint)Util.UnixTimeSinceEpoch();
184
159 if (m_TransferModule != null) 185 if (m_TransferModule != null)
160 { 186 {
161 if (client != null) 187 if (client != null)
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 77c7147..c1caf44 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -47,6 +47,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private bool m_Enabled = false; 49 private bool m_Enabled = false;
50 protected string m_MessageKey = String.Empty;
50 protected List<Scene> m_Scenes = new List<Scene>(); 51 protected List<Scene> m_Scenes = new List<Scene>();
51 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); 52 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>();
52 53
@@ -66,14 +67,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
66 public virtual void Initialise(IConfigSource config) 67 public virtual void Initialise(IConfigSource config)
67 { 68 {
68 IConfig cnf = config.Configs["Messaging"]; 69 IConfig cnf = config.Configs["Messaging"];
69 if (cnf != null && cnf.GetString( 70 if (cnf != null)
70 "MessageTransferModule", "MessageTransferModule") !=
71 "MessageTransferModule")
72 { 71 {
73 m_log.Debug("[MESSAGE TRANSFER]: Disabled by configuration"); 72 if (cnf.GetString("MessageTransferModule",
74 return; 73 "MessageTransferModule") != "MessageTransferModule")
75 } 74 {
75 return;
76 }
76 77
78 m_MessageKey = cnf.GetString("MessageKey", String.Empty);
79 }
80 m_log.Debug("[MESSAGE TRANSFER]: Module enabled");
77 m_Enabled = true; 81 m_Enabled = true;
78 } 82 }
79 83
@@ -145,8 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
145 ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; 149 ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
146 if (!user.IsChildAgent) 150 if (!user.IsChildAgent)
147 { 151 {
148 // Local message 152 // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering to client");
149// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID);
150 user.ControllingClient.SendInstantMessage(im); 153 user.ControllingClient.SendInstantMessage(im);
151 154
152 // Message sent 155 // Message sent
@@ -168,7 +171,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
168 // Local message 171 // Local message
169 ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; 172 ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
170 173
171// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); 174 // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering to client");
172 user.ControllingClient.SendInstantMessage(im); 175 user.ControllingClient.SendInstantMessage(im);
173 176
174 // Message sent 177 // Message sent
@@ -251,6 +254,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
251 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") 254 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id")
252 && requestData.ContainsKey("binary_bucket")) 255 && requestData.ContainsKey("binary_bucket"))
253 { 256 {
257 if (m_MessageKey != String.Empty)
258 {
259 XmlRpcResponse error_resp = new XmlRpcResponse();
260 Hashtable error_respdata = new Hashtable();
261 error_respdata["success"] = "FALSE";
262 error_resp.Value = error_respdata;
263
264 if (!requestData.Contains("message_key"))
265 return error_resp;
266 if (m_MessageKey != (string)requestData["message_key"])
267 return error_resp;
268 }
269
254 // Do the easy way of validating the UUIDs 270 // Do the easy way of validating the UUIDs
255 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); 271 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID);
256 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); 272 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID);
@@ -433,24 +449,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
433 return resp; 449 return resp;
434 } 450 }
435 451
436 /// <summary> 452 private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
437 /// delegate for sending a grid instant message asynchronously
438 /// </summary>
439 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID);
440 453
441 protected virtual void GridInstantMessageCompleted(IAsyncResult iar) 454 private class GIM {
442 { 455 public GridInstantMessage im;
443 GridInstantMessageDelegate icon = 456 public MessageResultNotification result;
444 (GridInstantMessageDelegate)iar.AsyncState; 457 };
445 icon.EndInvoke(iar);
446 }
447 458
459 private Queue<GIM> pendingInstantMessages = new Queue<GIM>();
460 private int numInstantMessageThreads = 0;
448 461
449 protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) 462 private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result)
450 { 463 {
451 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; 464 lock (pendingInstantMessages) {
465 if (numInstantMessageThreads >= 4) {
466 GIM gim = new GIM();
467 gim.im = im;
468 gim.result = result;
469 pendingInstantMessages.Enqueue(gim);
470 } else {
471 ++ numInstantMessageThreads;
472 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads);
473 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain;
474 d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
475 }
476 }
477 }
452 478
453 d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); 479 private void GridInstantMessageCompleted(IAsyncResult iar)
480 {
481 GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState;
482 d.EndInvoke(iar);
454 } 483 }
455 484
456 /// <summary> 485 /// <summary>
@@ -465,8 +494,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
465 /// Pass in 0 the first time this method is called. It will be called recursively with the last 494 /// Pass in 0 the first time this method is called. It will be called recursively with the last
466 /// regionhandle tried 495 /// regionhandle tried
467 /// </param> 496 /// </param>
468 protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) 497 private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result)
469 { 498 {
499 GIM gim;
500 do {
501 try {
502 SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero);
503 } catch (Exception e) {
504 m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message);
505 }
506 lock (pendingInstantMessages) {
507 if (pendingInstantMessages.Count > 0) {
508 gim = pendingInstantMessages.Dequeue();
509 im = gim.im;
510 result = gim.result;
511 } else {
512 gim = null;
513 -- numInstantMessageThreads;
514 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads);
515 }
516 }
517 } while (gim != null);
518 }
519 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
520 {
521
470 UUID toAgentID = new UUID(im.toAgentID); 522 UUID toAgentID = new UUID(im.toAgentID);
471 523
472 PresenceInfo upd = null; 524 PresenceInfo upd = null;
@@ -533,7 +585,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
533 585
534 if (upd != null) 586 if (upd != null)
535 { 587 {
536 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, 588 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(UUID.Zero,
537 upd.RegionID); 589 upd.RegionID);
538 if (reginfo != null) 590 if (reginfo != null)
539 { 591 {
@@ -682,6 +734,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
682 gim["position_z"] = msg.Position.Z.ToString(); 734 gim["position_z"] = msg.Position.Z.ToString();
683 gim["region_id"] = msg.RegionID.ToString(); 735 gim["region_id"] = msg.RegionID.ToString();
684 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); 736 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None);
737 if (m_MessageKey != String.Empty)
738 gim["message_key"] = m_MessageKey;
685 return gim; 739 return gim;
686 } 740 }
687 741
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index fdfcd10..164ae50 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -172,13 +172,16 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
172 172
173 private void RetrieveInstantMessages(IClientAPI client) 173 private void RetrieveInstantMessages(IClientAPI client)
174 { 174 {
175 if (m_RestURL != "") 175 if (m_RestURL == String.Empty)
176 { 176 return;
177 m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId);
178 177
179 List<GridInstantMessage> msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>( 178 m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId);
179
180 List<GridInstantMessage> msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>(
180 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); 181 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
181 182
183 if (msglist != null)
184 {
182 foreach (GridInstantMessage im in msglist) 185 foreach (GridInstantMessage im in msglist)
183 { 186 {
184 // client.SendInstantMessage(im); 187 // client.SendInstantMessage(im);
@@ -189,6 +192,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
189 // Needed for proper state management for stored group 192 // Needed for proper state management for stored group
190 // invitations 193 // invitations
191 // 194 //
195
196 im.offline = 1;
197
192 Scene s = FindScene(client.AgentId); 198 Scene s = FindScene(client.AgentId);
193 if (s != null) 199 if (s != null)
194 s.EventManager.TriggerIncomingInstantMessage(im); 200 s.EventManager.TriggerIncomingInstantMessage(im);
@@ -198,26 +204,38 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
198 204
199 private void UndeliveredMessage(GridInstantMessage im) 205 private void UndeliveredMessage(GridInstantMessage im)
200 { 206 {
201 if ((im.offline != 0) 207 if (im.dialog != (byte)InstantMessageDialog.MessageFromObject &&
202 && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages))) 208 im.dialog != (byte)InstantMessageDialog.MessageFromAgent &&
209 im.dialog != (byte)InstantMessageDialog.GroupNotice &&
210 im.dialog != (byte)InstantMessageDialog.GroupInvitation &&
211 im.dialog != (byte)InstantMessageDialog.InventoryOffered)
203 { 212 {
204 bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>( 213 return;
205 "POST", m_RestURL+"/SaveMessage/", im); 214 }
206 215
207 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 216 // It's not delivered. Make sure the scope id is saved
208 { 217 // We don't need the imSessionID here anymore, overwrite it
209 IClientAPI client = FindClient(new UUID(im.fromAgentID)); 218 Scene scene = FindScene(new UUID(im.fromAgentID));
210 if (client == null) 219 if (scene == null)
211 return; 220 scene = m_SceneList[0];
212 221
213 client.SendInstantMessage(new GridInstantMessage( 222 bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>(
214 null, new UUID(im.toAgentID), 223 "POST", m_RestURL+"/SaveMessage/?scope=" +
215 "System", new UUID(im.fromAgentID), 224 scene.RegionInfo.ScopeID.ToString(), im);
216 (byte)InstantMessageDialog.MessageFromAgent, 225
217 "User is not logged in. "+ 226 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
218 (success ? "Message saved." : "Message not saved"), 227 {
219 false, new Vector3())); 228 IClientAPI client = FindClient(new UUID(im.fromAgentID));
220 } 229 if (client == null)
230 return;
231
232 client.SendInstantMessage(new GridInstantMessage(
233 null, new UUID(im.toAgentID),
234 "System", new UUID(im.fromAgentID),
235 (byte)InstantMessageDialog.MessageFromAgent,
236 "User is not logged in. "+
237 (success ? "Message saved." : "Message not saved"),
238 false, new Vector3()));
221 } 239 }
222 } 240 }
223 } 241 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 01170aa..9b98de3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -77,12 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
77 /// </value> 77 /// </value>
78 private Stream m_loadStream; 78 private Stream m_loadStream;
79 79
80 /// <summary> 80 protected bool m_controlFileLoaded;
81 /// FIXME: Do not perform this check since older versions of OpenSim do save the control file after other things
82 /// (I thought they weren't). We will need to bump the version number and perform this check on all
83 /// subsequent IAR versions only
84 /// </summary>
85 protected bool m_controlFileLoaded = true;
86 protected bool m_assetsLoaded; 81 protected bool m_assetsLoaded;
87 protected bool m_inventoryNodesLoaded; 82 protected bool m_inventoryNodesLoaded;
88 83
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index dc4900f..5e5f6c0 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -139,9 +139,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
139 139
140 protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService) 140 protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService)
141 { 141 {
142 if (options.ContainsKey("verbose"))
143 m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving item {0} with asset {1}", inventoryItem.ID, inventoryItem.AssetID);
144
145 string filename = path + CreateArchiveItemName(inventoryItem); 142 string filename = path + CreateArchiveItemName(inventoryItem);
146 143
147 // Record the creator of this item for user record purposes (which might go away soon) 144 // Record the creator of this item for user record purposes (which might go away soon)
@@ -165,9 +162,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
165 InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, 162 InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself,
166 Dictionary<string, object> options, IUserAccountService userAccountService) 163 Dictionary<string, object> options, IUserAccountService userAccountService)
167 { 164 {
168 if (options.ContainsKey("verbose"))
169 m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving folder {0}", inventoryFolder.Name);
170
171 if (saveThisFolderItself) 165 if (saveThisFolderItself)
172 { 166 {
173 path += CreateArchiveFolderName(inventoryFolder); 167 path += CreateArchiveFolderName(inventoryFolder);
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 576a154..613f0ed 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -122,7 +122,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
122 122
123 scene.AddCommand( 123 scene.AddCommand(
124 this, "save iar", 124 this, "save iar",
125 "save iar [--p|-profile=<url>] <first> <last> <inventory path> <password> [<IAR path>] [--v|-verbose]", 125 "save iar [--p|-profile=<url>] <first> <last> <inventory path> <password> [<IAR path>]",
126 "Save user inventory archive (IAR).", 126 "Save user inventory archive (IAR).",
127 "<first> is the user's first name." + Environment.NewLine 127 "<first> is the user's first name." + Environment.NewLine
128 + "<last> is the user's last name." + Environment.NewLine 128 + "<last> is the user's last name." + Environment.NewLine
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index e3d4969..528bc8d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -175,8 +175,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
175 if (im.binaryBucket.Length < 17) // Invalid 175 if (im.binaryBucket.Length < 17) // Invalid
176 return; 176 return;
177 177
178 UUID receipientID = new UUID(im.toAgentID); 178 UUID recipientID = new UUID(im.toAgentID);
179 ScenePresence user = scene.GetScenePresence(receipientID); 179 ScenePresence user = scene.GetScenePresence(recipientID);
180 UUID copyID; 180 UUID copyID;
181 181
182 // First byte is the asset type 182 // First byte is the asset type
@@ -191,7 +191,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
191 folderID, new UUID(im.toAgentID)); 191 folderID, new UUID(im.toAgentID));
192 192
193 InventoryFolderBase folderCopy 193 InventoryFolderBase folderCopy
194 = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); 194 = scene.GiveInventoryFolder(recipientID, client.AgentId, folderID, UUID.Zero);
195 195
196 if (folderCopy == null) 196 if (folderCopy == null)
197 { 197 {
@@ -248,6 +248,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
248 im.imSessionID = itemID.Guid; 248 im.imSessionID = itemID.Guid;
249 } 249 }
250 250
251 im.offline = 1; // Remember these
252
251 // Send the IM to the recipient. The item is already 253 // Send the IM to the recipient. The item is already
252 // in their inventory, so it will not be lost if 254 // in their inventory, so it will not be lost if
253 // they are offline. 255 // they are offline.
@@ -417,22 +419,67 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
417 /// 419 ///
418 /// </summary> 420 /// </summary>
419 /// <param name="msg"></param> 421 /// <param name="msg"></param>
420 private void OnGridInstantMessage(GridInstantMessage msg) 422 private void OnGridInstantMessage(GridInstantMessage im)
421 { 423 {
422 // Check if this is ours to handle 424 // Check if this is ours to handle
423 // 425 //
424 Scene scene = FindClientScene(new UUID(msg.toAgentID)); 426 Scene scene = FindClientScene(new UUID(im.toAgentID));
425 427
426 if (scene == null) 428 if (scene == null)
427 return; 429 return;
428 430
429 // Find agent to deliver to 431 // Find agent to deliver to
430 // 432 //
431 ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); 433 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
434 if (user == null)
435 return;
436
437 // This requires a little bit of processing because we have to make the
438 // new item visible in the recipient's inventory here
439 //
440 if (im.dialog == (byte) InstantMessageDialog.InventoryOffered)
441 {
442 if (im.binaryBucket.Length < 17) // Invalid
443 return;
444
445 UUID recipientID = new UUID(im.toAgentID);
446
447 // First byte is the asset type
448 AssetType assetType = (AssetType)im.binaryBucket[0];
449
450 if (AssetType.Folder == assetType)
451 {
452 UUID folderID = new UUID(im.binaryBucket, 1);
453
454 InventoryFolderBase given =
455 new InventoryFolderBase(folderID, recipientID);
456 InventoryFolderBase folder =
457 scene.InventoryService.GetFolder(given);
458
459 if (folder != null)
460 user.ControllingClient.SendBulkUpdateInventory(folder);
461 }
462 else
463 {
464 UUID itemID = new UUID(im.binaryBucket, 1);
432 465
433 // Just forward to local handling 466 InventoryItemBase given =
434 OnInstantMessage(user.ControllingClient, msg); 467 new InventoryItemBase(itemID, recipientID);
468 InventoryItemBase item =
469 scene.InventoryService.GetItem(given);
435 470
471 if (item != null)
472 {
473 user.ControllingClient.SendBulkUpdateInventory(item);
474 }
475 }
476 user.ControllingClient.SendInstantMessage(im);
477 }
478 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted ||
479 im.dialog == (byte) InstantMessageDialog.InventoryDeclined)
480 {
481 user.ControllingClient.SendInstantMessage(im);
482 }
436 } 483 }
437 } 484 }
438} 485}
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
index d1d7df2..a12b57a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
@@ -146,16 +146,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
146 scene.RegionInfo.RegionHandle, 146 scene.RegionInfo.RegionHandle,
147 (uint)presence.AbsolutePosition.X, 147 (uint)presence.AbsolutePosition.X,
148 (uint)presence.AbsolutePosition.Y, 148 (uint)presence.AbsolutePosition.Y,
149 (uint)presence.AbsolutePosition.Z); 149 (uint)presence.AbsolutePosition.Z + 2);
150 150
151 m_log.DebugFormat("TP invite with message {0}", message); 151 m_log.DebugFormat("[LURE]: TP invite with message {0}", message);
152
153 GridInstantMessage m;
154
155 if (scene.Permissions.IsAdministrator(client.AgentId) && presence.GodLevel >= 200 && (!scene.Permissions.IsAdministrator(targetid)))
156 {
157 m = new GridInstantMessage(scene, client.AgentId,
158 client.FirstName+" "+client.LastName, targetid,
159 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
160 message, dest, false, presence.AbsolutePosition,
161 new Byte[0]);
162 }
163 else
164 {
165 m = new GridInstantMessage(scene, client.AgentId,
166 client.FirstName+" "+client.LastName, targetid,
167 (byte)InstantMessageDialog.RequestTeleport, false,
168 message, dest, false, presence.AbsolutePosition,
169 new Byte[0]);
170 }
152 171
153 GridInstantMessage m = new GridInstantMessage(scene, client.AgentId,
154 client.FirstName+" "+client.LastName, targetid,
155 (byte)InstantMessageDialog.RequestTeleport, false,
156 message, dest, false, presence.AbsolutePosition,
157 new Byte[0]);
158
159 if (m_TransferModule != null) 172 if (m_TransferModule != null)
160 { 173 {
161 m_TransferModule.SendInstantMessage(m, 174 m_TransferModule.SendInstantMessage(m,
@@ -190,7 +203,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
190 { 203 {
191 // Forward remote teleport requests 204 // Forward remote teleport requests
192 // 205 //
193 if (msg.dialog != 22) 206 if (msg.dialog != (byte)InstantMessageDialog.RequestTeleport &&
207 msg.dialog != (byte)InstantMessageDialog.GodLikeRequestTeleport)
194 return; 208 return;
195 209
196 if (m_TransferModule != null) 210 if (m_TransferModule != null)
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index c88be7d..138556f 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -102,7 +102,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
102 102
103 protected virtual void OnNewClient(IClientAPI client) 103 protected virtual void OnNewClient(IClientAPI client)
104 { 104 {
105 client.OnTeleportHomeRequest += TeleportHome; 105 client.OnTeleportHomeRequest += TeleportHomeFired;
106 } 106 }
107 107
108 public virtual void Close() 108 public virtual void Close()
@@ -180,6 +180,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
180 sp.ControllingClient.SendTeleportStart(teleportFlags); 180 sp.ControllingClient.SendTeleportStart(teleportFlags);
181 181
182 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); 182 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
183 sp.TeleportFlags = (TeleportFlags)teleportFlags;
183 sp.Teleport(position); 184 sp.Teleport(position);
184 185
185 foreach (SceneObjectGroup grp in sp.Attachments) 186 foreach (SceneObjectGroup grp in sp.Attachments)
@@ -271,7 +272,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
271 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, 272 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
272 // it's actually doing a lot of work. 273 // it's actually doing a lot of work.
273 IPEndPoint endPoint = finalDestination.ExternalEndPoint; 274 IPEndPoint endPoint = finalDestination.ExternalEndPoint;
274 if (endPoint.Address != null) 275 if (endPoint != null && endPoint.Address != null)
275 { 276 {
276 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from 277 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
277 // both regions 278 // both regions
@@ -519,7 +520,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
519 520
520 protected void KillEntity(Scene scene, uint localID) 521 protected void KillEntity(Scene scene, uint localID)
521 { 522 {
522 scene.SendKillObject(localID); 523 scene.SendKillObject(new List<uint>() { localID });
523 } 524 }
524 525
525 protected virtual GridRegion GetFinalDestination(GridRegion region) 526 protected virtual GridRegion GetFinalDestination(GridRegion region)
@@ -557,7 +558,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
557 558
558 #region Teleport Home 559 #region Teleport Home
559 560
560 public virtual void TeleportHome(UUID id, IClientAPI client) 561 public void TeleportHomeFired(UUID id, IClientAPI client)
562 {
563 TeleportHome(id, client);
564 }
565
566 public virtual bool TeleportHome(UUID id, IClientAPI client)
561 { 567 {
562 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); 568 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
563 569
@@ -566,12 +572,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
566 572
567 if (uinfo != null) 573 if (uinfo != null)
568 { 574 {
575 if (uinfo.HomeRegionID == UUID.Zero)
576 {
577 // can't find the Home region: Tell viewer and abort
578 client.SendTeleportFailed("You don't have a home position set.");
579 return false;
580 }
569 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); 581 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
570 if (regionInfo == null) 582 if (regionInfo == null)
571 { 583 {
572 // can't find the Home region: Tell viewer and abort 584 // can't find the Home region: Tell viewer and abort
573 client.SendTeleportFailed("Your home region could not be found."); 585 client.SendTeleportFailed("Your home region could not be found.");
574 return; 586 return false;
575 } 587 }
576 588
577 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})", 589 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})",
@@ -582,6 +594,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
582 client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt, 594 client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt,
583 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); 595 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
584 } 596 }
597 else
598 {
599 // can't find the Home region: Tell viewer and abort
600 client.SendTeleportFailed("Your home region could not be found.");
601 return false;
602 }
603 return true;
585 } 604 }
586 605
587 #endregion 606 #endregion
@@ -916,15 +935,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
916 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); 935 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
917 936
918 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>(); 937 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
919 if (eq != null) 938 IPEndPoint neighbourExternal = neighbourRegion.ExternalEndPoint;
920 { 939 if (neighbourExternal != null)
921 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
922 capsPath, agent.UUID, agent.ControllingClient.SessionId);
923 }
924 else
925 { 940 {
926 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, 941 if (eq != null)
927 capsPath); 942 {
943 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal,
944 capsPath, agent.UUID, agent.ControllingClient.SessionId);
945 }
946 else
947 {
948 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal,
949 capsPath);
950 }
928 } 951 }
929 952
930 if (!WaitForCallback(agent.UUID)) 953 if (!WaitForCallback(agent.UUID))
@@ -1028,10 +1051,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1028 agent.Id0 = currentAgentCircuit.Id0; 1051 agent.Id0 = currentAgentCircuit.Id0;
1029 } 1052 }
1030 1053
1031 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 1054 IPEndPoint external = region.ExternalEndPoint;
1032 d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, 1055 if (external != null)
1056 {
1057 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1058 d.BeginInvoke(sp, agent, region, external, true,
1033 InformClientOfNeighbourCompleted, 1059 InformClientOfNeighbourCompleted,
1034 d); 1060 d);
1061 }
1035 } 1062 }
1036 #endregion 1063 #endregion
1037 1064
@@ -1164,6 +1191,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1164 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 1191 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1165 try 1192 try
1166 { 1193 {
1194 //neighbour.ExternalEndPoint may return null, which will be caught
1167 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, 1195 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
1168 InformClientOfNeighbourCompleted, 1196 InformClientOfNeighbourCompleted,
1169 d); 1197 d);
@@ -1267,8 +1295,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1267 1295
1268 m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); 1296 m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString());
1269 } 1297 }
1270 if (!regionAccepted)
1271 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Region {0} did not accept agent: {1}", reg.RegionName, reason);
1272 } 1298 }
1273 1299
1274 /// <summary> 1300 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 79e76b4..5a80100 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
86 86
87 protected override void OnNewClient(IClientAPI client) 87 protected override void OnNewClient(IClientAPI client)
88 { 88 {
89 client.OnTeleportHomeRequest += TeleportHome; 89 client.OnTeleportHomeRequest += TeleportHomeFired;
90 client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed); 90 client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed);
91 } 91 }
92 92
@@ -177,7 +177,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
177 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); 177 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
178 } 178 }
179 179
180 public override void TeleportHome(UUID id, IClientAPI client) 180 public void TeleportHomeFired(UUID id, IClientAPI client)
181 {
182 TeleportHome(id, client);
183 }
184
185 public override bool TeleportHome(UUID id, IClientAPI client)
181 { 186 {
182 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); 187 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
183 188
@@ -187,8 +192,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
187 { 192 {
188 // local grid user 193 // local grid user
189 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); 194 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local");
190 base.TeleportHome(id, client); 195 return base.TeleportHome(id, client);
191 return;
192 } 196 }
193 197
194 // Foreign user wants to go home 198 // Foreign user wants to go home
@@ -198,7 +202,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
198 { 202 {
199 client.SendTeleportFailed("Your information has been lost"); 203 client.SendTeleportFailed("Your information has been lost");
200 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); 204 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information");
201 return; 205 return false;
202 } 206 }
203 207
204 IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); 208 IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString());
@@ -208,7 +212,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
208 { 212 {
209 client.SendTeleportFailed("Your home region could not be found"); 213 client.SendTeleportFailed("Your home region could not be found");
210 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); 214 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found");
211 return; 215 return false;
212 } 216 }
213 217
214 ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId); 218 ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId);
@@ -216,7 +220,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
216 { 220 {
217 client.SendTeleportFailed("Internal error"); 221 client.SendTeleportFailed("Internal error");
218 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be"); 222 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be");
219 return; 223 return false;
220 } 224 }
221 225
222 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); 226 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
@@ -226,6 +230,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
226 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName); 230 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName);
227 231
228 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq); 232 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq);
233 return true;
229 } 234 }
230 #endregion 235 #endregion
231 236
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 8d0c35a..0fbd5e7 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Xml;
31using System.Reflection; 32using System.Reflection;
32using System.Threading; 33using System.Threading;
33 34
@@ -205,11 +206,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
205 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, 206 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
206 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient) 207 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient)
207 { 208 {
208 // HACK: This is only working for lists containing a single item!
209 // It's just a hack to make this WIP compile and run. Nothing
210 // currently calls this with multiple items.
211 UUID ret = UUID.Zero; 209 UUID ret = UUID.Zero;
212 210
211 // The following code groups the SOG's by owner. No objects
212 // belonging to different people can be coalesced, for obvious
213 // reasons.
213 Dictionary<UUID, List<SceneObjectGroup>> deletes = 214 Dictionary<UUID, List<SceneObjectGroup>> deletes =
214 new Dictionary<UUID, List<SceneObjectGroup>>(); 215 new Dictionary<UUID, List<SceneObjectGroup>>();
215 216
@@ -221,262 +222,337 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
221 deletes[g.OwnerID].Add(g); 222 deletes[g.OwnerID].Add(g);
222 } 223 }
223 224
225 // This is pethod scoped and will be returned. It will be the
226 // last created asset id
227 UUID assetID = UUID.Zero;
228
229 // Each iteration is really a separate asset being created,
230 // with distinct destinations as well.
224 foreach (List<SceneObjectGroup> objlist in deletes.Values) 231 foreach (List<SceneObjectGroup> objlist in deletes.Values)
225 { 232 {
226 foreach (SceneObjectGroup g in objlist) 233 Dictionary<UUID, string> xmlStrings =
227 ret = DeleteToInventory(action, folderID, g, remoteClient); 234 new Dictionary<UUID, string>();
228 }
229 235
230 return ret; 236 foreach (SceneObjectGroup objectGroup in objlist)
231 } 237 {
238 Vector3 inventoryStoredPosition = new Vector3
239 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
240 ? 250
241 : objectGroup.AbsolutePosition.X)
242 ,
243 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
244 ? 250
245 : objectGroup.AbsolutePosition.X,
246 objectGroup.AbsolutePosition.Z);
232 247
233 private UUID DeleteToInventory(DeRezAction action, UUID folderID, 248 Vector3 originalPosition = objectGroup.AbsolutePosition;
234 SceneObjectGroup objectGroup, IClientAPI remoteClient)
235 {
236 UUID assetID = UUID.Zero;
237 249
238 Vector3 inventoryStoredPosition = new Vector3 250 // Restore attachment data after trip through the sim
239 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) 251 if (objectGroup.RootPart.AttachPoint > 0)
240 ? 250 252 inventoryStoredPosition = objectGroup.RootPart.AttachOffset;
241 : objectGroup.AbsolutePosition.X) 253 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
242 ,
243 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
244 ? 250
245 : objectGroup.AbsolutePosition.X,
246 objectGroup.AbsolutePosition.Z);
247 254
248 Vector3 originalPosition = objectGroup.AbsolutePosition; 255 objectGroup.AbsolutePosition = inventoryStoredPosition;
249 256
250 objectGroup.AbsolutePosition = inventoryStoredPosition; 257 // Make sure all bits but the ones we want are clear
258 // on take.
259 // This will be applied to the current perms, so
260 // it will do what we want.
261 objectGroup.RootPart.NextOwnerMask &=
262 ((uint)PermissionMask.Copy |
263 (uint)PermissionMask.Transfer |
264 (uint)PermissionMask.Modify);
265 objectGroup.RootPart.NextOwnerMask |=
266 (uint)PermissionMask.Move;
251 267
252 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); 268 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
253 269
254 objectGroup.AbsolutePosition = originalPosition; 270 objectGroup.AbsolutePosition = originalPosition;
255 271
256 // Get the user info of the item destination 272 xmlStrings[objectGroup.UUID] = sceneObjectXml;
257 // 273 }
258 UUID userID = UUID.Zero;
259 274
260 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || 275 string itemXml;
261 action == DeRezAction.SaveToExistingUserInventoryItem)
262 {
263 // Take or take copy require a taker
264 // Saving changes requires a local user
265 //
266 if (remoteClient == null)
267 return UUID.Zero;
268 276
269 userID = remoteClient.AgentId; 277 if (objlist.Count > 1)
270 } 278 {
271 else 279 float minX, minY, minZ;
272 { 280 float maxX, maxY, maxZ;
273 // All returns / deletes go to the object owner
274 //
275 281
276 userID = objectGroup.RootPart.OwnerID; 282 Vector3[] offsets = m_Scene.GetCombinedBoundingBox(objlist,
277 } 283 out minX, out maxX, out minY, out maxY,
284 out minZ, out maxZ);
278 285
279 if (userID == UUID.Zero) // Can't proceed 286 // CreateWrapper
280 { 287 XmlDocument itemDoc = new XmlDocument();
281 return UUID.Zero; 288 XmlElement root = itemDoc.CreateElement("", "CoalescedObject", "");
282 } 289 itemDoc.AppendChild(root);
283 290
284 // If we're returning someone's item, it goes back to the 291 // Embed the offsets into the group XML
285 // owner's Lost And Found folder. 292 for ( int i = 0 ; i < objlist.Count ; i++ )
286 // Delete is treated like return in this case 293 {
287 // Deleting your own items makes them go to trash 294 XmlDocument doc = new XmlDocument();
288 // 295 SceneObjectGroup g = objlist[i];
289 296 doc.LoadXml(xmlStrings[g.UUID]);
290 InventoryFolderBase folder = null; 297 XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup");
291 InventoryItemBase item = null; 298 e.SetAttribute("offsetx", offsets[i].X.ToString());
299 e.SetAttribute("offsety", offsets[i].Y.ToString());
300 e.SetAttribute("offsetz", offsets[i].Z.ToString());
301
302 XmlNode objectNode = itemDoc.ImportNode(e, true);
303 root.AppendChild(objectNode);
304 }
292 305
293 if (DeRezAction.SaveToExistingUserInventoryItem == action) 306 float sizeX = maxX - minX;
294 { 307 float sizeY = maxY - minY;
295 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); 308 float sizeZ = maxZ - minZ;
296 item = m_Scene.InventoryService.GetItem(item);
297 309
298 //item = userInfo.RootFolder.FindItem( 310 root.SetAttribute("x", sizeX.ToString());
299 // objectGroup.RootPart.FromUserInventoryItemID); 311 root.SetAttribute("y", sizeY.ToString());
312 root.SetAttribute("z", sizeZ.ToString());
300 313
301 if (null == item) 314 itemXml = itemDoc.InnerXml;
315 }
316 else
302 { 317 {
303 m_log.DebugFormat( 318 itemXml = xmlStrings[objlist[0].UUID];
304 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
305 objectGroup.Name, objectGroup.UUID);
306 return UUID.Zero;
307 } 319 }
308 } 320
309 else 321 // Get the user info of the item destination
310 {
311 // Folder magic
312 // 322 //
313 if (action == DeRezAction.Delete) 323 UUID userID = UUID.Zero;
324
325 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
326 action == DeRezAction.SaveToExistingUserInventoryItem)
314 { 327 {
315 // Deleting someone else's item 328 // Take or take copy require a taker
329 // Saving changes requires a local user
316 // 330 //
317 if (remoteClient == null || 331 if (remoteClient == null)
318 objectGroup.OwnerID != remoteClient.AgentId) 332 return UUID.Zero;
319 {
320 333
321 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 334 userID = remoteClient.AgentId;
322 }
323 else
324 {
325 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
326 }
327 } 335 }
328 else if (action == DeRezAction.Return) 336 else
329 { 337 {
330 338 // All returns / deletes go to the object owner
331 // Dump to lost + found unconditionally
332 // 339 //
333 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 340
341 userID = objlist[0].RootPart.OwnerID;
334 } 342 }
335 343
336 if (folderID == UUID.Zero && folder == null) 344 if (userID == UUID.Zero) // Can't proceed
337 { 345 {
338 if (action == DeRezAction.Delete) 346 return UUID.Zero;
347 }
348
349 // If we're returning someone's item, it goes back to the
350 // owner's Lost And Found folder.
351 // Delete is treated like return in this case
352 // Deleting your own items makes them go to trash
353 //
354
355 InventoryFolderBase folder = null;
356 InventoryItemBase item = null;
357
358 if (DeRezAction.SaveToExistingUserInventoryItem == action)
359 {
360 item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID);
361 item = m_Scene.InventoryService.GetItem(item);
362
363 //item = userInfo.RootFolder.FindItem(
364 // objectGroup.RootPart.FromUserInventoryItemID);
365
366 if (null == item)
339 { 367 {
340 // Deletes go to trash by default 368 m_log.DebugFormat(
341 // 369 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
342 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); 370 objlist[0].Name, objlist[0].UUID);
371 return UUID.Zero;
343 } 372 }
344 else 373 }
374 else
375 {
376 // Folder magic
377 //
378 if (action == DeRezAction.Delete)
345 { 379 {
380 // Deleting someone else's item
381 //
346 if (remoteClient == null || 382 if (remoteClient == null ||
347 objectGroup.OwnerID != remoteClient.AgentId) 383 objlist[0].OwnerID != remoteClient.AgentId)
348 { 384 {
349 // Taking copy of another person's item. Take to 385
350 // Objects folder. 386 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
351 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
352 } 387 }
353 else 388 else
354 { 389 {
355 // Catch all. Use lost & found 390 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
391 }
392 }
393 else if (action == DeRezAction.Return)
394 {
395
396 // Dump to lost + found unconditionally
397 //
398 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
399 }
400
401 if (folderID == UUID.Zero && folder == null)
402 {
403 if (action == DeRezAction.Delete)
404 {
405 // Deletes go to trash by default
356 // 406 //
407 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
408 }
409 else
410 {
411 if (remoteClient == null ||
412 objlist[0].OwnerID != remoteClient.AgentId)
413 {
414 // Taking copy of another person's item. Take to
415 // Objects folder.
416 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
417 }
418 else
419 {
420 // Catch all. Use lost & found
421 //
357 422
358 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 423 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
424 }
359 } 425 }
360 } 426 }
361 }
362 427
363 // Override and put into where it came from, if it came 428 // Override and put into where it came from, if it came
364 // from anywhere in inventory 429 // from anywhere in inventory
365 // 430 //
366 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) 431 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
367 {
368 if (objectGroup.RootPart.FromFolderID != UUID.Zero)
369 { 432 {
370 InventoryFolderBase f = new InventoryFolderBase(objectGroup.RootPart.FromFolderID, userID); 433 if (objlist[0].RootPart.FromFolderID != UUID.Zero && objlist[0].OwnerID == remoteClient.AgentId)
371 folder = m_Scene.InventoryService.GetFolder(f); 434 {
435 InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID);
436 folder = m_Scene.InventoryService.GetFolder(f);
437 }
372 } 438 }
373 }
374 439
375 if (folder == null) // None of the above 440 if (folder == null) // None of the above
376 { 441 {
377 folder = new InventoryFolderBase(folderID); 442 folder = new InventoryFolderBase(folderID);
378 443
379 if (folder == null) // Nowhere to put it 444 if (folder == null) // Nowhere to put it
445 {
446 return UUID.Zero;
447 }
448 }
449
450 item = new InventoryItemBase();
451 // Can't know creator is the same, so null it in inventory
452 if (objlist.Count > 1)
380 { 453 {
381 return UUID.Zero; 454 item.CreatorId = UUID.Zero.ToString();
455 item.CreatorData = String.Empty;
456 }
457 else
458 {
459 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
460 item.CreatorData = objlist[0].RootPart.CreatorData;
461 }
462 item.ID = UUID.Random();
463 item.InvType = (int)InventoryType.Object;
464 item.Folder = folder.ID;
465 item.Owner = userID;
466 if (objlist.Count > 1)
467 {
468 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
469 }
470 else
471 {
472 item.SaleType = objlist[0].RootPart.ObjectSaleType;
473 item.SalePrice = objlist[0].RootPart.SalePrice;
382 } 474 }
383 } 475 }
384 476
385 item = new InventoryItemBase(); 477 AssetBase asset = CreateAsset(
386 item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); 478 objlist[0].GetPartName(objlist[0].RootPart.LocalId),
387 item.CreatorData = objectGroup.RootPart.CreatorData; 479 objlist[0].GetPartDescription(objlist[0].RootPart.LocalId),
388 item.ID = UUID.Random(); 480 (sbyte)AssetType.Object,
389 item.InvType = (int)InventoryType.Object; 481 Utils.StringToBytes(itemXml),
390 item.Folder = folder.ID; 482 objlist[0].OwnerID.ToString());
391 item.Owner = userID; 483 m_Scene.AssetService.Store(asset);
392 } 484 assetID = asset.FullID;
393
394 AssetBase asset = CreateAsset(
395 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
396 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
397 (sbyte)AssetType.Object,
398 Utils.StringToBytes(sceneObjectXml),
399 objectGroup.OwnerID.ToString());
400 m_Scene.AssetService.Store(asset);
401 assetID = asset.FullID;
402
403 if (DeRezAction.SaveToExistingUserInventoryItem == action)
404 {
405 item.AssetID = asset.FullID;
406 m_Scene.InventoryService.UpdateItem(item);
407 }
408 else
409 {
410 item.AssetID = asset.FullID;
411 485
412 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 486 if (DeRezAction.SaveToExistingUserInventoryItem == action)
413 { 487 {
414 uint perms = objectGroup.GetEffectivePermissions(); 488 item.AssetID = asset.FullID;
415 uint nextPerms = (perms & 7) << 13; 489 m_Scene.InventoryService.UpdateItem(item);
416 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
417 perms &= ~(uint)PermissionMask.Copy;
418 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
419 perms &= ~(uint)PermissionMask.Transfer;
420 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
421 perms &= ~(uint)PermissionMask.Modify;
422
423 // Make sure all bits but the ones we want are clear
424 // on take.
425 // This will be applied to the current perms, so
426 // it will do what we want.
427 objectGroup.RootPart.NextOwnerMask &=
428 ((uint)PermissionMask.Copy |
429 (uint)PermissionMask.Transfer |
430 (uint)PermissionMask.Modify);
431 objectGroup.RootPart.NextOwnerMask |=
432 (uint)PermissionMask.Move;
433
434 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
435 item.CurrentPermissions = item.BasePermissions;
436 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
437 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
438 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
439
440 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
441 } 490 }
442 else 491 else
443 { 492 {
444 item.BasePermissions = objectGroup.GetEffectivePermissions(); 493 item.AssetID = asset.FullID;
445 item.CurrentPermissions = objectGroup.GetEffectivePermissions();
446 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
447 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
448 item.GroupPermissions = objectGroup.RootPart.GroupMask;
449 494
450 item.CurrentPermissions &= 495 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7;
451 ((uint)PermissionMask.Copy | 496 foreach (SceneObjectGroup grp in objlist)
452 (uint)PermissionMask.Transfer | 497 effectivePerms &= grp.GetEffectivePermissions();
453 (uint)PermissionMask.Modify | 498 effectivePerms |= (uint)PermissionMask.Move;
454 (uint)PermissionMask.Move |
455 7); // Preserve folded permissions
456 }
457 499
458 // TODO: add the new fields (Flags, Sale info, etc) 500 if (remoteClient != null && (remoteClient.AgentId != objlist[0].RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
459 item.CreationDate = Util.UnixTimeSinceEpoch(); 501 {
460 item.Description = asset.Description; 502 uint perms = effectivePerms;
461 item.Name = asset.Name; 503 uint nextPerms = (perms & 7) << 13;
462 item.AssetType = asset.Type; 504 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
505 perms &= ~(uint)PermissionMask.Copy;
506 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
507 perms &= ~(uint)PermissionMask.Transfer;
508 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
509 perms &= ~(uint)PermissionMask.Modify;
510
511 item.BasePermissions = perms & objlist[0].RootPart.NextOwnerMask;
512 item.CurrentPermissions = item.BasePermissions;
513 item.NextPermissions = perms & objlist[0].RootPart.NextOwnerMask;
514 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & objlist[0].RootPart.NextOwnerMask;
515 item.GroupPermissions = objlist[0].RootPart.GroupMask & objlist[0].RootPart.NextOwnerMask;
516
517 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
518 }
519 else
520 {
521 item.BasePermissions = effectivePerms;
522 item.CurrentPermissions = effectivePerms;
523 item.NextPermissions = objlist[0].RootPart.NextOwnerMask & effectivePerms;
524 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & effectivePerms;
525 item.GroupPermissions = objlist[0].RootPart.GroupMask & effectivePerms;
526
527 item.CurrentPermissions &=
528 ((uint)PermissionMask.Copy |
529 (uint)PermissionMask.Transfer |
530 (uint)PermissionMask.Modify |
531 (uint)PermissionMask.Move |
532 7); // Preserve folded permissions
533 }
463 534
464 m_Scene.AddInventoryItem(item); 535 item.CreationDate = Util.UnixTimeSinceEpoch();
536 item.Description = asset.Description;
537 item.Name = asset.Name;
538 item.AssetType = asset.Type;
465 539
466 if (remoteClient != null && item.Owner == remoteClient.AgentId) 540 m_Scene.AddInventoryItem(item);
467 { 541
468 remoteClient.SendInventoryItemCreateUpdate(item, 0); 542 if (remoteClient != null && item.Owner == remoteClient.AgentId)
469 }
470 else
471 {
472 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner);
473 if (notifyUser != null)
474 { 543 {
475 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); 544 remoteClient.SendInventoryItemCreateUpdate(item, 0);
545 }
546 else
547 {
548 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner);
549 if (notifyUser != null)
550 {
551 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
552 }
476 } 553 }
477 } 554 }
478 } 555 }
479
480 return assetID; 556 return assetID;
481 } 557 }
482 558
@@ -527,10 +603,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
527 603
528 if (item != null) 604 if (item != null)
529 { 605 {
606 if (item.ID == UUID.Zero)
607 {
608 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 1");
609 }
530 item.Owner = remoteClient.AgentId; 610 item.Owner = remoteClient.AgentId;
531 611
532 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); 612 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
533 613
614 SceneObjectGroup group = null;
615
534 if (rezAsset != null) 616 if (rezAsset != null)
535 { 617 {
536 UUID itemId = UUID.Zero; 618 UUID itemId = UUID.Zero;
@@ -539,34 +621,83 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
539 // item that it came from. This allows us to enable 'save object to inventory' 621 // item that it came from. This allows us to enable 'save object to inventory'
540 if (!m_Scene.Permissions.BypassPermissions()) 622 if (!m_Scene.Permissions.BypassPermissions())
541 { 623 {
542 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) 624 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
543 { 625 {
544 itemId = item.ID; 626 itemId = item.ID;
545 } 627 }
546 } 628 }
547 else 629 else
548 { 630 {
549 // Brave new fullperm world 631 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
550 // 632 {
551 itemId = item.ID; 633 // Brave new fullperm world
634 itemId = item.ID;
635 }
636 }
637
638 if (item.ID == UUID.Zero)
639 {
640 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 2");
552 } 641 }
553 642
554 string xmlData = Utils.BytesToString(rezAsset.Data); 643 string xmlData = Utils.BytesToString(rezAsset.Data);
555 SceneObjectGroup group 644 List<SceneObjectGroup> objlist =
556 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); 645 new List<SceneObjectGroup>();
646 List<Vector3> veclist = new List<Vector3>();
647
648 XmlDocument doc = new XmlDocument();
649 doc.LoadXml(xmlData);
650 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject");
651 if (e == null || attachment) // Single
652 {
653 SceneObjectGroup g =
654 SceneObjectSerializer.FromOriginalXmlFormat(
655 itemId, xmlData);
656 objlist.Add(g);
657 veclist.Add(new Vector3(0, 0, 0));
557 658
558 Util.FireAndForget(delegate { AddUserData(group); }); 659 float offsetHeight = 0;
559 660 pos = m_Scene.GetNewRezLocation(
560 group.RootPart.FromFolderID = item.Folder; 661 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
662 BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false);
663 pos.Z += offsetHeight;
664 }
665 else
666 {
667 XmlElement coll = (XmlElement)e;
668 float bx = Convert.ToSingle(coll.GetAttribute("x"));
669 float by = Convert.ToSingle(coll.GetAttribute("y"));
670 float bz = Convert.ToSingle(coll.GetAttribute("z"));
671 Vector3 bbox = new Vector3(bx, by, bz);
561 672
562 // If it's rezzed in world, select it. Much easier to 673 pos = m_Scene.GetNewRezLocation(RayStart, RayEnd,
563 // find small items. 674 RayTargetID, Quaternion.Identity,
564 // 675 BypassRayCast, bRayEndIsIntersection, true,
565 if (!attachment) 676 bbox, false);
566 group.RootPart.CreateSelected = true; 677
678 pos -= bbox / 2;
679
680 XmlNodeList groups = e.SelectNodes("SceneObjectGroup");
681 foreach (XmlNode n in groups)
682 {
683 SceneObjectGroup g =
684 SceneObjectSerializer.FromOriginalXmlFormat(
685 itemId, n.OuterXml);
686 objlist.Add(g);
687 XmlElement el = (XmlElement)n;
688 float x = Convert.ToSingle(el.GetAttribute("offsetx"));
689 float y = Convert.ToSingle(el.GetAttribute("offsety"));
690 float z = Convert.ToSingle(el.GetAttribute("offsetz"));
691 veclist.Add(new Vector3(x, y, z));
692 }
693 }
694
695 int primcount = 0;
696 foreach (SceneObjectGroup g in objlist)
697 primcount += g.PrimCount;
567 698
568 if (!m_Scene.Permissions.CanRezObject( 699 if (!m_Scene.Permissions.CanRezObject(
569 group.PrimCount, remoteClient.AgentId, pos) 700 primcount, remoteClient.AgentId, pos)
570 && !attachment) 701 && !attachment)
571 { 702 {
572 // The client operates in no fail mode. It will 703 // The client operates in no fail mode. It will
@@ -579,121 +710,159 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
579 return null; 710 return null;
580 } 711 }
581 712
582 group.ResetIDs(); 713 for (int i = 0 ; i < objlist.Count ; i++ )
583
584 if (attachment)
585 { 714 {
586 group.RootPart.Flags |= PrimFlags.Phantom; 715 group = objlist[i];
587 group.RootPart.IsAttachment = true;
588
589 // If we're rezzing an attachment then don't ask
590 // AddNewSceneObject() to update the client since
591 // we'll be doing that later on. Scheduling more
592 // than one full update during the attachment
593 // process causes some clients to fail to display
594 // the attachment properly.
595 // Also, don't persist attachments.
596 m_Scene.AddNewSceneObject(group, false, false);
597 }
598 else
599 {
600 m_Scene.AddNewSceneObject(group, true, false);
601 }
602 716
603 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); 717 Vector3 storedPosition = group.AbsolutePosition;
604 // if attachment we set it's asset id so object updates can reflect that 718 if (group.UUID == UUID.Zero)
605 // if not, we set it's position in world. 719 {
606 if (!attachment) 720 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3");
607 { 721 }
608 group.ScheduleGroupForFullUpdate(); 722 group.RootPart.FromFolderID = item.Folder;
609
610 float offsetHeight = 0;
611 pos = m_Scene.GetNewRezLocation(
612 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
613 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
614 pos.Z += offsetHeight;
615 group.AbsolutePosition = pos;
616 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
617 723
618 } 724 // If it's rezzed in world, select it. Much easier to
619 else 725 // find small items.
620 { 726 //
621 group.SetFromItemID(itemID); 727 if (!attachment)
622 } 728 {
729 group.RootPart.CreateSelected = true;
730 foreach (SceneObjectPart child in group.Parts)
731 child.CreateSelected = true;
732 }
623 733
624 SceneObjectPart rootPart = null; 734 group.ResetIDs();
625 try
626 {
627 rootPart = group.GetChildPart(group.UUID);
628 }
629 catch (NullReferenceException)
630 {
631 string isAttachment = "";
632 735
633 if (attachment) 736 if (attachment)
634 isAttachment = " Object was an attachment"; 737 {
738 group.RootPart.Flags |= PrimFlags.Phantom;
739 group.RootPart.IsAttachment = true;
740
741 // If we're rezzing an attachment then don't ask
742 // AddNewSceneObject() to update the client since
743 // we'll be doing that later on. Scheduling more
744 // than one full update during the attachment
745 // process causes some clients to fail to display
746 // the attachment properly.
747 // Also, don't persist attachments.
748 m_Scene.AddNewSceneObject(group, false, false);
749 }
750 else
751 {
752 m_Scene.AddNewSceneObject(group, true, false);
753 }
635 754
636 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); 755 // if attachment we set it's asset id so object updates
637 } 756 // can reflect that, if not, we set it's position in world.
757 if (!attachment)
758 {
759 group.ScheduleGroupForFullUpdate();
760
761 group.AbsolutePosition = pos + veclist[i];
762 }
763 else
764 {
765 group.SetFromItemID(itemID);
766 }
638 767
639 // Since renaming the item in the inventory does not affect the name stored 768 SceneObjectPart rootPart = null;
640 // in the serialization, transfer the correct name from the inventory to the
641 // object itself before we rez.
642 rootPart.Name = item.Name;
643 rootPart.Description = item.Description;
644 769
645 if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0) 770 try
646 { 771 {
647 rootPart.ObjectSaleType = item.SaleType; 772 rootPart = group.GetChildPart(group.UUID);
648 rootPart.SalePrice = item.SalePrice; 773 }
649 } 774 catch (NullReferenceException)
775 {
776 string isAttachment = "";
777
778 if (attachment)
779 isAttachment = " Object was an attachment";
780
781 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
782 }
783
784 // Since renaming the item in the inventory does not
785 // affect the name stored in the serialization, transfer
786 // the correct name from the inventory to the
787 // object itself before we rez.
788 // On coalesced objects, this has no effect.
789 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
790 {
791 rootPart.Name = item.Name;
792 rootPart.Description = item.Description;
793 }
794 if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0)
795 {
796 rootPart.ObjectSaleType = item.SaleType;
797 rootPart.SalePrice = item.SalePrice;
798 }
650 799
651 group.SetGroup(remoteClient.ActiveGroupId, remoteClient); 800 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
652 if ((rootPart.OwnerID != item.Owner) || 801 // TODO: Remove the magic number badness
802
803 if ((rootPart.OwnerID != item.Owner) ||
653 (item.CurrentPermissions & 16) != 0 || // Magic number 804 (item.CurrentPermissions & 16) != 0 || // Magic number
654 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) 805 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
655 {
656 //Need to kill the for sale here
657 rootPart.ObjectSaleType = 0;
658 rootPart.SalePrice = 10;
659
660 if (m_Scene.Permissions.PropagatePermissions())
661 { 806 {
662 foreach (SceneObjectPart part in group.Parts) 807 //Need to kill the for sale here
663 { 808 rootPart.ObjectSaleType = 0;
664 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) 809 rootPart.SalePrice = 10;
665 part.EveryoneMask = item.EveryOnePermissions;
666 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
667 part.NextOwnerMask = item.NextPermissions;
668 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
669 part.GroupMask = item.GroupPermissions;
670 }
671 810
672 foreach (SceneObjectPart part in group.Parts) 811 if (m_Scene.Permissions.PropagatePermissions())
673 { 812 {
674 part.LastOwnerID = part.OwnerID; 813 foreach (SceneObjectPart part in group.Parts)
675 part.OwnerID = item.Owner; 814 {
676 part.Inventory.ChangeInventoryOwner(item.Owner); 815 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
816 {
817 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
818 part.EveryoneMask = item.EveryOnePermissions;
819 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
820 part.NextOwnerMask = item.NextPermissions;
821 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
822 part.GroupMask = item.GroupPermissions;
823 }
824 }
825
826 foreach (SceneObjectPart part in group.Parts)
827 {
828 part.LastOwnerID = part.OwnerID;
829 part.OwnerID = item.Owner;
830 part.Inventory.ChangeInventoryOwner(item.Owner);
831 }
832
833 group.ApplyNextOwnerPermissions();
677 } 834 }
678
679 group.ApplyNextOwnerPermissions();
680 } 835 }
681 }
682
683 rootPart.TrimPermissions();
684 836
685 if (!attachment) 837 foreach (SceneObjectPart part in group.Parts)
686 {
687 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
688 { 838 {
689 group.ClearPartAttachmentData(); 839 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
840 part.EveryoneMask = item.EveryOnePermissions;
841 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
842 part.NextOwnerMask = item.NextPermissions;
843 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
844 part.GroupMask = item.GroupPermissions;
690 } 845 }
691
692 // Fire on_rez
693 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1);
694 rootPart.ParentGroup.ResumeScripts();
695 846
696 rootPart.ScheduleFullUpdate(); 847 rootPart.TrimPermissions();
848
849 if (!attachment)
850 {
851 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
852 {
853 // Save attachment data
854 group.RootPart.AttachPoint = group.RootPart.Shape.State;
855 group.RootPart.AttachOffset = storedPosition;
856
857 group.ClearPartAttachmentData();
858 }
859
860 // Fire on_rez
861 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1);
862 rootPart.ParentGroup.ResumeScripts();
863
864 rootPart.ScheduleFullUpdate();
865 }
697 } 866 }
698 867
699 if (!m_Scene.Permissions.BypassPermissions()) 868 if (!m_Scene.Permissions.BypassPermissions())
@@ -711,9 +880,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
711 } 880 }
712 } 881 }
713 } 882 }
714
715 return rootPart.ParentGroup;
716 } 883 }
884 return group;
717 } 885 }
718 886
719 return null; 887 return null;
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index d78931a..51742ff 100644
--- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -341,6 +341,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
341 try 341 try
342 { 342 {
343 Request = (HttpWebRequest) WebRequest.Create(Url); 343 Request = (HttpWebRequest) WebRequest.Create(Url);
344
345 //This works around some buggy HTTP Servers like Lighttpd
346 Request.ServicePoint.Expect100Continue = false;
347
344 Request.Method = HttpMethod; 348 Request.Method = HttpMethod;
345 Request.ContentType = HttpMIMEType; 349 Request.ContentType = HttpMIMEType;
346 350
@@ -404,7 +408,17 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
404 { 408 {
405 HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response; 409 HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response;
406 Status = (int)webRsp.StatusCode; 410 Status = (int)webRsp.StatusCode;
407 ResponseBody = webRsp.StatusDescription; 411 try
412 {
413 using (Stream responseStream = webRsp.GetResponseStream())
414 {
415 ResponseBody = responseStream.GetStreamString();
416 }
417 }
418 catch
419 {
420 ResponseBody = webRsp.StatusDescription;
421 }
408 } 422 }
409 else 423 else
410 { 424 {
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 9b565ed..bdbd0c2 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -60,6 +60,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
60 //public ManualResetEvent ev; 60 //public ManualResetEvent ev;
61 public bool requestDone; 61 public bool requestDone;
62 public int startTime; 62 public int startTime;
63 public bool responseSent;
63 public string uri; 64 public string uri;
64 } 65 }
65 66
@@ -76,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
76 new Dictionary<string, UrlData>(); 77 new Dictionary<string, UrlData>();
77 78
78 79
79 private int m_TotalUrls = 100; 80 private int m_TotalUrls = 5000;
80 81
81 private IHttpServer m_HttpServer = null; 82 private IHttpServer m_HttpServer = null;
82 83
@@ -142,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
142 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 143 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
143 return urlcode; 144 return urlcode;
144 } 145 }
145 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; 146 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString();
146 147
147 UrlData urlData = new UrlData(); 148 UrlData urlData = new UrlData();
148 urlData.hostID = host.UUID; 149 urlData.hostID = host.UUID;
@@ -152,10 +153,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
152 urlData.urlcode = urlcode; 153 urlData.urlcode = urlcode;
153 urlData.requests = new Dictionary<UUID, RequestData>(); 154 urlData.requests = new Dictionary<UUID, RequestData>();
154 155
155
156 m_UrlMap[url] = urlData; 156 m_UrlMap[url] = urlData;
157 157
158 string uri = "/lslhttp/" + urlcode.ToString() + "/"; 158 string uri = "/lslhttp/" + urlcode.ToString();
159 159
160 m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, 160 m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll,
161 new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, 161 new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents,
@@ -200,10 +200,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
200 if (m_RequestMap.ContainsKey(request)) 200 if (m_RequestMap.ContainsKey(request))
201 { 201 {
202 UrlData urlData = m_RequestMap[request]; 202 UrlData urlData = m_RequestMap[request];
203 urlData.requests[request].responseCode = status; 203 if (!urlData.requests[request].responseSent)
204 urlData.requests[request].responseBody = body; 204 {
205 //urlData.requests[request].ev.Set(); 205 urlData.requests[request].responseCode = status;
206 urlData.requests[request].requestDone =true; 206 urlData.requests[request].responseBody = body;
207 //urlData.requests[request].ev.Set();
208 urlData.requests[request].requestDone = true;
209 urlData.requests[request].responseSent = true;
210 }
207 } 211 }
208 else 212 else
209 { 213 {
@@ -386,6 +390,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
386 390
387 return response; 391 return response;
388 } 392 }
393
389 public void HttpRequestHandler(UUID requestID, Hashtable request) 394 public void HttpRequestHandler(UUID requestID, Hashtable request)
390 { 395 {
391 lock (request) 396 lock (request)
@@ -400,8 +405,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
400 405
401 int pos1 = uri.IndexOf("/");// /lslhttp 406 int pos1 = uri.IndexOf("/");// /lslhttp
402 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ 407 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/
403 int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/ 408 int pos3 = pos2 + 37; // /lslhttp/urlcode
404 string uri_tmp = uri.Substring(0, pos3 + 1); 409 string uri_tmp = uri.Substring(0, pos3);
405 //HTTP server code doesn't provide us with QueryStrings 410 //HTTP server code doesn't provide us with QueryStrings
406 string pathInfo; 411 string pathInfo;
407 string queryString; 412 string queryString;
@@ -439,7 +444,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
439 if (request.ContainsKey(key)) 444 if (request.ContainsKey(key))
440 { 445 {
441 string val = (String)request[key]; 446 string val = (String)request[key];
442 queryString = queryString + key + "=" + val + "&"; 447 if (key != "")
448 {
449 queryString = queryString + key + "=" + val + "&";
450 }
451 else
452 {
453 queryString = queryString + val + "&";
454 }
443 } 455 }
444 } 456 }
445 if (queryString.Length > 1) 457 if (queryString.Length > 1)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
index 18db9fa..7128d2b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -56,9 +56,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
56 config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); 56 config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
57 config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); 57 config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
58 config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); 58 config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
59 config.Configs["GridService"].Set("Region_Test_Region_1", "DefaultRegion"); 59 config.Configs["GridService"].Set("Region_Test_Region_1", "DefaultRegion");
60 config.Configs["GridService"].Set("Region_Test_Region_2", "FallbackRegion"); 60 config.Configs["GridService"].Set("Region_Test_Region_2", "FallbackRegion");
61 config.Configs["GridService"].Set("Region_Test_Region_3", "FallbackRegion"); 61 config.Configs["GridService"].Set("Region_Test_Region_3", "FallbackRegion");
62 config.Configs["GridService"].Set("Region_Other_Region_4", "FallbackRegion"); 62 config.Configs["GridService"].Set("Region_Other_Region_4", "FallbackRegion");
63 63
64 m_LocalConnector = new LocalGridServicesConnector(config); 64 m_LocalConnector = new LocalGridServicesConnector(config);
@@ -127,8 +127,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
127 Assert.IsNotNull(result, "Retrieved GetRegionByName is null"); 127 Assert.IsNotNull(result, "Retrieved GetRegionByName is null");
128 Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match"); 128 Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match");
129 129
130 m_LocalConnector.RegisterRegion(UUID.Zero, r2); 130 m_LocalConnector.RegisterRegion(UUID.Zero, r2);
131 m_LocalConnector.RegisterRegion(UUID.Zero, r3); 131 m_LocalConnector.RegisterRegion(UUID.Zero, r3);
132 m_LocalConnector.RegisterRegion(UUID.Zero, r4); 132 m_LocalConnector.RegisterRegion(UUID.Zero, r4);
133 133
134 result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1)); 134 result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1));
@@ -153,38 +153,38 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
153 Assert.IsNotNull(results, "Retrieved GetRegionRange collection is null"); 153 Assert.IsNotNull(results, "Retrieved GetRegionRange collection is null");
154 Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected"); 154 Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected");
155 155
156 results = m_LocalConnector.GetDefaultRegions(UUID.Zero); 156 results = m_LocalConnector.GetDefaultRegions(UUID.Zero);
157 Assert.IsNotNull(results, "Retrieved GetDefaultRegions collection is null"); 157 Assert.IsNotNull(results, "Retrieved GetDefaultRegions collection is null");
158 Assert.That(results.Count, Is.EqualTo(1), "Retrieved default regions collection has not the expected size"); 158 Assert.That(results.Count, Is.EqualTo(1), "Retrieved default regions collection has not the expected size");
159 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(1)), "Retrieved default region's UUID does not match"); 159 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(1)), "Retrieved default region's UUID does not match");
160 160
161 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r1.RegionLocX, r1.RegionLocY); 161 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r1.RegionLocX, r1.RegionLocY);
162 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 1 is null"); 162 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 1 is null");
163 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 1 has not the expected size"); 163 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 1 has not the expected size");
164 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions for default region are not in the expected order 2-4-3"); 164 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions for default region are not in the expected order 2-4-3");
165 Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions for default region are not in the expected order 2-4-3"); 165 Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions for default region are not in the expected order 2-4-3");
166 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions for default region are not in the expected order 2-4-3"); 166 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions for default region are not in the expected order 2-4-3");
167 167
168 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r2.RegionLocX, r2.RegionLocY); 168 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r2.RegionLocX, r2.RegionLocY);
169 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 2 is null"); 169 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 2 is null");
170 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 2 has not the expected size"); 170 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 2 has not the expected size");
171 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 2-4-3"); 171 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 2-4-3");
172 Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 2-4-3"); 172 Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 2-4-3");
173 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 2-4-3"); 173 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 2-4-3");
174 174
175 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r3.RegionLocX, r3.RegionLocY); 175 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r3.RegionLocX, r3.RegionLocY);
176 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 3 is null"); 176 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 3 is null");
177 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 3 has not the expected size"); 177 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 3 has not the expected size");
178 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 3-4-2"); 178 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 3-4-2");
179 Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 3-4-2"); 179 Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 3-4-2");
180 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 3-4-2"); 180 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 3-4-2");
181 181
182 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r4.RegionLocX, r4.RegionLocY); 182 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r4.RegionLocX, r4.RegionLocY);
183 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 4 is null"); 183 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 4 is null");
184 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 4 has not the expected size"); 184 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 4 has not the expected size");
185 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 4-3-2"); 185 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 4-3-2");
186 Assert.That(results[1].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 4-3-2"); 186 Assert.That(results[1].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 4-3-2");
187 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 4-3-2"); 187 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 4-3-2");
188 188
189 results = m_LocalConnector.GetHyperlinks(UUID.Zero); 189 results = m_LocalConnector.GetHyperlinks(UUID.Zero);
190 Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null"); 190 Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null");
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index a298b65..41dbffb 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -268,7 +268,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
268 if (s.RegionInfo.RegionID == destination.RegionID) 268 if (s.RegionInfo.RegionID == destination.RegionID)
269 return s.QueryAccess(id, position, out reason); 269 return s.QueryAccess(id, position, out reason);
270 } 270 }
271 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
272 return false; 271 return false;
273 } 272 }
274 273
@@ -298,10 +297,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
298 if (s.RegionInfo.RegionID == destination.RegionID) 297 if (s.RegionInfo.RegionID == destination.RegionID)
299 { 298 {
300 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); 299 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
301 // Let's spawn a threadlet right here, because this may take 300 return s.IncomingCloseAgent(id);
302 // a while 301 }
303 Util.FireAndForget(delegate { s.IncomingCloseAgent(id); }); 302 }
304 return true; 303 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
304 return false;
305 }
306
307 public bool CloseChildAgent(GridRegion destination, UUID id)
308 {
309 if (destination == null)
310 return false;
311
312 foreach (Scene s in m_sceneList)
313 {
314 if (s.RegionInfo.RegionID == destination.RegionID)
315 {
316 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
317 return s.IncomingCloseChildAgent(id);
305 } 318 }
306 } 319 }
307 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); 320 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index 67f4d60..97833f3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -260,6 +260,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
260 return false; 260 return false;
261 } 261 }
262 262
263 public bool CloseChildAgent(GridRegion destination, UUID id)
264 {
265 if (destination == null)
266 return false;
267
268 // Try local first
269 if (m_localBackend.CloseChildAgent(destination, id))
270 return true;
271
272 // else do the remote thing
273 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
274 return m_remoteConnector.CloseChildAgent(destination, id);
275
276 return false;
277 }
263 278
264 public bool CloseAgent(GridRegion destination, UUID id) 279 public bool CloseAgent(GridRegion destination, UUID id)
265 { 280 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
index 30ebb21..535a637 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
@@ -120,6 +120,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
120 return; 120 return;
121 121
122 scene.RegisterModuleInterface<IUserAccountService>(m_UserService); 122 scene.RegisterModuleInterface<IUserAccountService>(m_UserService);
123 scene.RegisterModuleInterface<IUserAccountCacheModule>(m_Cache);
123 } 124 }
124 125
125 public void RemoveRegion(Scene scene) 126 public void RemoveRegion(Scene scene)
@@ -172,6 +173,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
172 return m_UserService.GetUserAccount(scopeID, Email); 173 return m_UserService.GetUserAccount(scopeID, Email);
173 } 174 }
174 175
176 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
177 {
178 return null;
179 }
180
175 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 181 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
176 { 182 {
177 return m_UserService.GetUserAccounts(scopeID, query); 183 return m_UserService.GetUserAccounts(scopeID, query);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
index 3321b38..f6b6aeb 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
@@ -33,6 +33,7 @@ using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Connectors; 35using OpenSim.Services.Connectors;
36using OpenSim.Framework;
36 37
37using OpenMetaverse; 38using OpenMetaverse;
38 39
@@ -101,6 +102,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
101 return; 102 return;
102 103
103 scene.RegisterModuleInterface<IUserAccountService>(this); 104 scene.RegisterModuleInterface<IUserAccountService>(this);
105 scene.RegisterModuleInterface<IUserAccountCacheModule>(m_Cache);
106
107 scene.EventManager.OnNewClient += OnNewClient;
104 } 108 }
105 109
106 public void RemoveRegion(Scene scene) 110 public void RemoveRegion(Scene scene)
@@ -115,6 +119,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
115 return; 119 return;
116 } 120 }
117 121
122 // When a user actually enters the sim, clear them from
123 // cache so the sim will have the current values for
124 // flags, title, etc. And country, don't forget country!
125 private void OnNewClient(IClientAPI client)
126 {
127 m_Cache.Remove(client.Name);
128 }
129
118 #region Overwritten methods from IUserAccountService 130 #region Overwritten methods from IUserAccountService
119 131
120 public override UserAccount GetUserAccount(UUID scopeID, UUID userID) 132 public override UserAccount GetUserAccount(UUID scopeID, UUID userID)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
index ddef75f..cbe2eaa 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
@@ -34,7 +34,7 @@ using log4net;
34 34
35namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts 35namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
36{ 36{
37 public class UserAccountCache 37 public class UserAccountCache : IUserAccountCacheModule
38 { 38 {
39 private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! 39 private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours!
40 40
@@ -92,5 +92,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
92 92
93 return null; 93 return null;
94 } 94 }
95
96 public void Remove(string name)
97 {
98 if (!m_NameCache.Contains(name))
99 return;
100
101 UUID uuid = UUID.Zero;
102 if (m_NameCache.TryGetValue(name, out uuid))
103 {
104 m_NameCache.Remove(name);
105 m_UUIDCache.Remove(uuid);
106 }
107 }
95 } 108 }
96} 109}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index fd8f546..b1dec4c 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -287,6 +287,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver
287 // being no copy/no mod for everyone 287 // being no copy/no mod for everyone
288 lock (part.TaskInventory) 288 lock (part.TaskInventory)
289 { 289 {
290 if (!ResolveUserUuid(part.CreatorID))
291 part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
292
293 if (!ResolveUserUuid(part.OwnerID))
294 part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
295
296 if (!ResolveUserUuid(part.LastOwnerID))
297 part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
298
299 // And zap any troublesome sit target information
300 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
301 part.SitTargetPosition = new Vector3(0, 0, 0);
302
303 // Fix ownership/creator of inventory items
304 // Not doing so results in inventory items
305 // being no copy/no mod for everyone
306 part.TaskInventory.LockItemsForRead(true);
290 TaskInventoryDictionary inv = part.TaskInventory; 307 TaskInventoryDictionary inv = part.TaskInventory;
291 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) 308 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
292 { 309 {
@@ -302,6 +319,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
302 if (UserManager != null) 319 if (UserManager != null)
303 UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData); 320 UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData);
304 } 321 }
322 part.TaskInventory.LockItemsForRead(false);
305 } 323 }
306 } 324 }
307 325
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index b888698..5da1656 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -249,18 +249,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver
249 249
250 if (asset != null) 250 if (asset != null)
251 { 251 {
252 if (m_options.ContainsKey("verbose")) 252// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
253 m_log.InfoFormat("[ARCHIVER]: Writing asset {0}", id);
254
255 m_foundAssetUuids.Add(asset.FullID); 253 m_foundAssetUuids.Add(asset.FullID);
256 254
257 m_assetsArchiver.WriteAsset(PostProcess(asset)); 255 m_assetsArchiver.WriteAsset(PostProcess(asset));
258 } 256 }
259 else 257 else
260 { 258 {
261 if (m_options.ContainsKey("verbose")) 259// m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id);
262 m_log.InfoFormat("[ARCHIVER]: Recording asset {0} as not found", id);
263
264 m_notFoundAssetUuids.Add(new UUID(id)); 260 m_notFoundAssetUuids.Add(new UUID(id));
265 } 261 }
266 262
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 57ab135..e8b5af0 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Security; 32using System.Security;
33using System.Timers;
33using log4net; 34using log4net;
34using Mono.Addins; 35using Mono.Addins;
35using Nini.Config; 36using Nini.Config;
@@ -47,6 +48,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
47 48
48 private delegate void LookupUUIDS(List<UUID> uuidLst); 49 private delegate void LookupUUIDS(List<UUID> uuidLst);
49 50
51 private Timer m_regionChangeTimer = new Timer();
50 public Scene Scene { get; private set; } 52 public Scene Scene { get; private set; }
51 public IUserManagement UserManager { get; private set; } 53 public IUserManagement UserManager { get; private set; }
52 54
@@ -252,7 +254,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
252 timeInSeconds -= 15; 254 timeInSeconds -= 15;
253 } 255 }
254 256
255 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); 257 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), false);
256 } 258 }
257 } 259 }
258 260
@@ -365,7 +367,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
365 { 367 {
366 if (!s.IsChildAgent) 368 if (!s.IsChildAgent)
367 { 369 {
368 Scene.TeleportClientHome(user, s.ControllingClient); 370 if (!Scene.TeleportClientHome(user, s.ControllingClient))
371 {
372 s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
373 s.ControllingClient.Close();
374 }
369 } 375 }
370 } 376 }
371 377
@@ -374,7 +380,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
374 { 380 {
375 remote_client.SendAlertMessage("User is already on the region ban list"); 381 remote_client.SendAlertMessage("User is already on the region ban list");
376 } 382 }
377 //m_scene.RegionInfo.regionBanlist.Add(Manager(user); 383 //Scene.RegionInfo.regionBanlist.Add(Manager(user);
378 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); 384 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
379 } 385 }
380 else 386 else
@@ -412,7 +418,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
412 remote_client.SendAlertMessage("User is not on the region ban list"); 418 remote_client.SendAlertMessage("User is not on the region ban list");
413 } 419 }
414 420
415 //m_scene.RegionInfo.regionBanlist.Add(Manager(user); 421 //Scene.RegionInfo.regionBanlist.Add(Manager(user);
416 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); 422 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
417 } 423 }
418 else 424 else
@@ -500,7 +506,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
500 ScenePresence s = Scene.GetScenePresence(prey); 506 ScenePresence s = Scene.GetScenePresence(prey);
501 if (s != null) 507 if (s != null)
502 { 508 {
503 Scene.TeleportClientHome(prey, s.ControllingClient); 509 if (!Scene.TeleportClientHome(prey, s.ControllingClient))
510 {
511 s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
512 s.ControllingClient.Close();
513 }
504 } 514 }
505 } 515 }
506 } 516 }
@@ -519,7 +529,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
519 // Also make sure they are actually in the region 529 // Also make sure they are actually in the region
520 if (p != null && !p.IsChildAgent) 530 if (p != null && !p.IsChildAgent)
521 { 531 {
522 Scene.TeleportClientHome(p.UUID, p.ControllingClient); 532 if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient))
533 {
534 p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
535 p.ControllingClient.Close();
536 }
523 } 537 }
524 } 538 }
525 }); 539 });
@@ -770,7 +784,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
770 784
771 for (int i = 0; i < uuidarr.Length; i++) 785 for (int i = 0; i < uuidarr.Length; i++)
772 { 786 {
773 // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]); 787 // string lookupname = Scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
774 788
775 IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>(); 789 IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>();
776 if (userManager != null) 790 if (userManager != null)
@@ -907,6 +921,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
907 921
908 public void AddRegion(Scene scene) 922 public void AddRegion(Scene scene)
909 { 923 {
924 m_regionChangeTimer.AutoReset = false;
925 m_regionChangeTimer.Interval = 2000;
926 m_regionChangeTimer.Elapsed += RaiseRegionInfoChange;
927
910 Scene = scene; 928 Scene = scene;
911 Scene.RegisterModuleInterface<IEstateModule>(this); 929 Scene.RegisterModuleInterface<IEstateModule>(this);
912 Scene.EventManager.OnNewClient += EventManager_OnNewClient; 930 Scene.EventManager.OnNewClient += EventManager_OnNewClient;
@@ -1013,11 +1031,15 @@ namespace OpenSim.Region.CoreModules.World.Estate
1013 flags |= RegionFlags.Sandbox; 1031 flags |= RegionFlags.Sandbox;
1014 if (Scene.RegionInfo.EstateSettings.AllowVoice) 1032 if (Scene.RegionInfo.EstateSettings.AllowVoice)
1015 flags |= RegionFlags.AllowVoice; 1033 flags |= RegionFlags.AllowVoice;
1034 if (Scene.RegionInfo.EstateSettings.AllowLandmark)
1035 flags |= RegionFlags.AllowLandmark;
1036 if (Scene.RegionInfo.EstateSettings.AllowSetHome)
1037 flags |= RegionFlags.AllowSetHome;
1038 if (Scene.RegionInfo.EstateSettings.BlockDwell)
1039 flags |= RegionFlags.BlockDwell;
1040 if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
1041 flags |= RegionFlags.ResetHomeOnTeleport;
1016 1042
1017 // Fudge these to always on, so the menu options activate
1018 //
1019 flags |= RegionFlags.AllowLandmark;
1020 flags |= RegionFlags.AllowSetHome;
1021 1043
1022 // TODO: SkipUpdateInterestList 1044 // TODO: SkipUpdateInterestList
1023 1045
@@ -1058,6 +1080,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
1058 flags |= RegionFlags.ResetHomeOnTeleport; 1080 flags |= RegionFlags.ResetHomeOnTeleport;
1059 if (Scene.RegionInfo.EstateSettings.TaxFree) 1081 if (Scene.RegionInfo.EstateSettings.TaxFree)
1060 flags |= RegionFlags.TaxFree; 1082 flags |= RegionFlags.TaxFree;
1083 if (Scene.RegionInfo.EstateSettings.AllowLandmark)
1084 flags |= RegionFlags.AllowLandmark;
1085 if (Scene.RegionInfo.EstateSettings.AllowParcelChanges)
1086 flags |= RegionFlags.AllowParcelChanges;
1087 if (Scene.RegionInfo.EstateSettings.AllowSetHome)
1088 flags |= RegionFlags.AllowSetHome;
1061 if (Scene.RegionInfo.EstateSettings.DenyMinors) 1089 if (Scene.RegionInfo.EstateSettings.DenyMinors)
1062 flags |= (RegionFlags)(1 << 30); 1090 flags |= (RegionFlags)(1 << 30);
1063 1091
@@ -1078,6 +1106,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
1078 1106
1079 public void TriggerRegionInfoChange() 1107 public void TriggerRegionInfoChange()
1080 { 1108 {
1109 m_regionChangeTimer.Stop();
1110 m_regionChangeTimer.Start();
1111 }
1112
1113 protected void RaiseRegionInfoChange(object sender, ElapsedEventArgs e)
1114 {
1081 ChangeDelegate change = OnRegionInfoChange; 1115 ChangeDelegate change = OnRegionInfoChange;
1082 1116
1083 if (change != null) 1117 if (change != null)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 2b5f7a0..b5517a1 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -93,11 +93,11 @@ namespace OpenSim.Region.CoreModules.World.Land
93 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 93 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
94 94
95 private bool m_allowedForcefulBans = true; 95 private bool m_allowedForcefulBans = true;
96 private UUID DefaultGodParcelGroup;
97 private string DefaultGodParcelName;
96 98
97 // caches ExtendedLandData 99 // caches ExtendedLandData
98 private Cache parcelInfoCache; 100 private Cache parcelInfoCache;
99 private Dictionary<UUID, Vector3> forcedPosition =
100 new Dictionary<UUID, Vector3>();
101 101
102 #region INonSharedRegionModule Members 102 #region INonSharedRegionModule Members
103 103
@@ -108,6 +108,12 @@ namespace OpenSim.Region.CoreModules.World.Land
108 108
109 public void Initialise(IConfigSource source) 109 public void Initialise(IConfigSource source)
110 { 110 {
111 IConfig cnf = source.Configs["LandManagement"];
112 if (cnf != null)
113 {
114 DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
115 DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
116 }
111 } 117 }
112 118
113 public void AddRegion(Scene scene) 119 public void AddRegion(Scene scene)
@@ -159,13 +165,6 @@ namespace OpenSim.Region.CoreModules.World.Land
159 m_scene.UnregisterModuleCommander(m_commander.Name); 165 m_scene.UnregisterModuleCommander(m_commander.Name);
160 } 166 }
161 167
162// private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
163// {
164// ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
165// reason = "You are not allowed to enter this sim.";
166// return nearestParcel != null;
167// }
168
169 /// <summary> 168 /// <summary>
170 /// Processes commandline input. Do not call directly. 169 /// Processes commandline input. Do not call directly.
171 /// </summary> 170 /// </summary>
@@ -217,36 +216,6 @@ namespace OpenSim.Region.CoreModules.World.Land
217 216
218 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 217 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
219 { 218 {
220 //If we are forcing a position for them to go
221 if (forcedPosition.ContainsKey(remoteClient.AgentId))
222 {
223 ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
224
225 //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
226 //When the avatar walks into a ban line on the ground, it prevents getting stuck
227 agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
228
229
230 //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
231 if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2)
232 {
233 Debug.WriteLine(string.Format("Stopping force position because {0} is close enough to position {1}", forcedPosition[remoteClient.AgentId], clientAvatar.AbsolutePosition));
234 forcedPosition.Remove(remoteClient.AgentId);
235 }
236 //if we are far away, teleport
237 else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3)
238 {
239 Debug.WriteLine(string.Format("Teleporting out because {0} is too far from avatar position {1}", forcedPosition[remoteClient.AgentId], clientAvatar.AbsolutePosition));
240 clientAvatar.Teleport(forcedPosition[remoteClient.AgentId]);
241 forcedPosition.Remove(remoteClient.AgentId);
242 }
243 else
244 {
245 //Forces them toward the forced position we want if they aren't there yet
246 agentData.UseClientAgentPosition = true;
247 agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId];
248 }
249 }
250 } 219 }
251 220
252 public void Close() 221 public void Close()
@@ -365,10 +334,16 @@ namespace OpenSim.Region.CoreModules.World.Land
365 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) 334 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
366 { 335 {
367 if (m_scene.Permissions.IsGod(avatar.UUID)) return; 336 if (m_scene.Permissions.IsGod(avatar.UUID)) return;
368 if (position.HasValue) 337
369 { 338 if (!position.HasValue)
370 forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; 339 return;
371 } 340
341 bool isFlying = avatar.PhysicsActor.Flying;
342 avatar.RemoveFromPhysicalScene();
343
344 avatar.AbsolutePosition = (Vector3)position;
345
346 avatar.AddToPhysicalScene(isFlying);
372 } 347 }
373 348
374 public void SendYouAreRestrictedNotice(ScenePresence avatar) 349 public void SendYouAreRestrictedNotice(ScenePresence avatar)
@@ -388,29 +363,7 @@ namespace OpenSim.Region.CoreModules.World.Land
388 } 363 }
389 364
390 if (parcelAvatarIsEntering != null) 365 if (parcelAvatarIsEntering != null)
391 { 366 EnforceBans(parcelAvatarIsEntering, avatar);
392 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
393 {
394 if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
395 {
396 SendYouAreBannedNotice(avatar);
397 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
398 }
399 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
400 {
401 SendYouAreRestrictedNotice(avatar);
402 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
403 }
404 else
405 {
406 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
407 }
408 }
409 else
410 {
411 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
412 }
413 }
414 } 367 }
415 } 368 }
416 369
@@ -482,43 +435,7 @@ namespace OpenSim.Region.CoreModules.World.Land
482 SendOutNearestBanLine(remote_client); 435 SendOutNearestBanLine(remote_client);
483 ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); 436 ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
484 if (parcel != null) 437 if (parcel != null)
485 { 438 EnforceBans(parcel, clientAvatar);
486 if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
487 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown)
488 {
489 EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID,
490 m_scene.RegionInfo.RegionID);
491 //They are going under the safety line!
492 if (!parcel.IsBannedFromLand(clientAvatar.UUID))
493 {
494 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false;
495 }
496 }
497 else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
498 parcel.IsBannedFromLand(clientAvatar.UUID))
499 {
500 //once we've sent the message once, keep going toward the target until we are done
501 if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId))
502 {
503 SendYouAreBannedNotice(clientAvatar);
504 ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
505 }
506 }
507 else if (parcel.IsRestrictedFromLand(clientAvatar.UUID))
508 {
509 //once we've sent the message once, keep going toward the target until we are done
510 if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId))
511 {
512 SendYouAreRestrictedNotice(clientAvatar);
513 ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
514 }
515 }
516 else
517 {
518 //when we are finally in a safe place, lets release the forced position lock
519 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
520 }
521 }
522 } 439 }
523 } 440 }
524 441
@@ -720,7 +637,7 @@ namespace OpenSim.Region.CoreModules.World.Land
720 int x; 637 int x;
721 int y; 638 int y;
722 639
723 if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) 640 if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0)
724 return null; 641 return null;
725 642
726 try 643 try
@@ -762,14 +679,13 @@ namespace OpenSim.Region.CoreModules.World.Land
762 { 679 {
763 try 680 try
764 { 681 {
765 return m_landList[m_landIDList[x / 4, y / 4]]; 682 //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4]))
683 return m_landList[m_landIDList[x / 4, y / 4]];
684 //else
685 // return null;
766 } 686 }
767 catch (IndexOutOfRangeException) 687 catch (IndexOutOfRangeException)
768 { 688 {
769// m_log.WarnFormat(
770// "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}",
771// x, y, m_scene.RegionInfo.RegionName);
772
773 return null; 689 return null;
774 } 690 }
775 } 691 }
@@ -1068,6 +984,10 @@ namespace OpenSim.Region.CoreModules.World.Land
1068 //Owner Flag 984 //Owner Flag
1069 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); 985 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER);
1070 } 986 }
987 else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID))
988 {
989 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP);
990 }
1071 else if (currentParcelBlock.LandData.SalePrice > 0 && 991 else if (currentParcelBlock.LandData.SalePrice > 0 &&
1072 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || 992 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
1073 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) 993 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
@@ -1361,24 +1281,38 @@ namespace OpenSim.Region.CoreModules.World.Land
1361 { 1281 {
1362 land.DeedToGroup(groupID); 1282 land.DeedToGroup(groupID);
1363 } 1283 }
1284 EventManagerOnParcelPrimCountTainted();
1364 } 1285 }
1365 1286
1366 #region Land Object From Storage Functions 1287 #region Land Object From Storage Functions
1367 1288
1368 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1289 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
1369 { 1290 {
1370 for (int i = 0; i < data.Count; i++) 1291 lock (m_landList)
1371 { 1292 {
1372 IncomingLandObjectFromStorage(data[i]); 1293 //Remove all the land objects in the sim and then process our new data
1294 foreach (int n in m_landList.Keys)
1295 {
1296 m_scene.EventManager.TriggerLandObjectRemoved(m_landList[n].LandData.GlobalID);
1297 }
1298 m_landIDList.Initialize();
1299 m_landList.Clear();
1300
1301 for (int i = 0; i < data.Count; i++)
1302 {
1303 IncomingLandObjectFromStorage(data[i]);
1304 }
1373 } 1305 }
1374 } 1306 }
1375 1307
1376 public void IncomingLandObjectFromStorage(LandData data) 1308 public void IncomingLandObjectFromStorage(LandData data)
1377 { 1309 {
1310
1378 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); 1311 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1379 new_land.LandData = data.Copy(); 1312 new_land.LandData = data.Copy();
1380 new_land.SetLandBitmapFromByteArray(); 1313 new_land.SetLandBitmapFromByteArray();
1381 AddLandObject(new_land); 1314 AddLandObject(new_land);
1315 new_land.SendLandUpdateToAvatarsOverMe();
1382 } 1316 }
1383 1317
1384 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) 1318 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
@@ -1652,6 +1586,322 @@ namespace OpenSim.Region.CoreModules.World.Land
1652 1586
1653 UpdateLandObject(localID, land.LandData); 1587 UpdateLandObject(localID, land.LandData);
1654 } 1588 }
1589
1590 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
1591 {
1592 ILandObject land = null;
1593 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
1594 foreach (ILandObject landObject in Land)
1595 {
1596 if (landObject.LandData.LocalID == landID)
1597 {
1598 land = landObject;
1599 }
1600 }
1601 land.DeedToGroup(DefaultGodParcelGroup);
1602 land.LandData.Name = DefaultGodParcelName;
1603 land.SendLandUpdateToAvatarsOverMe();
1604 }
1605
1606 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
1607 {
1608 ScenePresence SP;
1609 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP);
1610 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
1611 if (SP.UserLevel != 0)
1612 {
1613 if (flags == 0) //All parcels, scripted or not
1614 {
1615 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1616 {
1617 if (e.OwnerID == targetID)
1618 {
1619 returns.Add(e);
1620 }
1621 }
1622 );
1623 }
1624 if (flags == 4) //All parcels, scripted object
1625 {
1626 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1627 {
1628 if (e.OwnerID == targetID)
1629 {
1630 if (e.scriptScore >= 0.01)
1631 {
1632 returns.Add(e);
1633 }
1634 }
1635 }
1636 );
1637 }
1638 if (flags == 4) //not target parcel, scripted object
1639 {
1640 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1641 {
1642 if (e.OwnerID == targetID)
1643 {
1644 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1645 if (landobject.LandData.OwnerID != e.OwnerID)
1646 {
1647 if (e.scriptScore >= 0.01)
1648 {
1649 returns.Add(e);
1650 }
1651 }
1652 }
1653 }
1654 );
1655 }
1656 foreach (SceneObjectGroup ol in returns)
1657 {
1658 ReturnObject(ol, client);
1659 }
1660 }
1661 }
1662 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
1663 {
1664 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1665 objs[0] = obj;
1666 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
1667 }
1668
1669 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1670
1671 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1672 {
1673 ScenePresence targetAvatar = null;
1674 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1675 ScenePresence parcelManager = null;
1676 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1677 System.Threading.Timer Timer;
1678
1679 if (targetAvatar.UserLevel == 0)
1680 {
1681 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1682 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1683 return;
1684 if (flags == 0)
1685 {
1686 targetAvatar.AllowMovement = false;
1687 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
1688 parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
1689 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
1690 Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
1691 Timers.Add(targetAvatar.UUID, Timer);
1692 }
1693 else
1694 {
1695 targetAvatar.AllowMovement = true;
1696 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
1697 parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
1698 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1699 Timers.Remove(targetAvatar.UUID);
1700 Timer.Dispose();
1701 }
1702 }
1703 }
1704 private void OnEndParcelFrozen(object avatar)
1705 {
1706 ScenePresence targetAvatar = (ScenePresence)avatar;
1707 targetAvatar.AllowMovement = true;
1708 System.Threading.Timer Timer;
1709 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1710 Timers.Remove(targetAvatar.UUID);
1711 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1712 }
1713
1714
1715 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1716 {
1717 ScenePresence targetAvatar = null;
1718 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1719 ScenePresence parcelManager = null;
1720 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1721 //Just eject
1722 if (flags == 0)
1723 {
1724 if (targetAvatar.UserLevel == 0)
1725 {
1726 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1727 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1728 return;
1729
1730 Vector3 position = new Vector3(0, 0, 0);
1731 List<ILandObject> allParcels = new List<ILandObject>();
1732 allParcels = AllParcels();
1733 if (allParcels.Count != 1)
1734 {
1735 foreach (ILandObject parcel in allParcels)
1736 {
1737 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1738 {
1739 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1740 {
1741 for (int x = 1; x <= Constants.RegionSize; x += 2)
1742 {
1743 for (int y = 1; y <= Constants.RegionSize; y += 2)
1744 {
1745 if (parcel.ContainsPoint(x, y))
1746 {
1747 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1748 targetAvatar.TeleportWithMomentum(position);
1749 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1750 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1751 return;
1752 }
1753 }
1754 }
1755 }
1756 }
1757 }
1758 }
1759 Vector3 targetVector;
1760 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1761 {
1762 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1763 {
1764 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1765 targetAvatar.TeleportWithMomentum(targetVector);
1766 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1767 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1768 return;
1769 }
1770 else
1771 {
1772 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1773 targetAvatar.TeleportWithMomentum(targetVector);
1774 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1775 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1776 return;
1777 }
1778 }
1779 else
1780 {
1781 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1782 {
1783 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1784 targetAvatar.TeleportWithMomentum(targetVector);
1785 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1786 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1787 return;
1788 }
1789 else
1790 {
1791 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1792 targetAvatar.TeleportWithMomentum(targetVector);
1793 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1794 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1795 return;
1796 }
1797 }
1798 }
1799 }
1800 //Eject and ban
1801 if (flags == 1)
1802 {
1803 if (targetAvatar.UserLevel == 0)
1804 {
1805 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1806 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1807 return;
1808
1809 Vector3 position = new Vector3(0, 0, 0);
1810 List<ILandObject> allParcels = new List<ILandObject>();
1811 allParcels = AllParcels();
1812 if (allParcels.Count != 1)
1813 {
1814 foreach (ILandObject parcel in allParcels)
1815 {
1816 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1817 {
1818 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1819 {
1820 for (int x = 1; x <= Constants.RegionSize; x += 2)
1821 {
1822 for (int y = 1; y <= Constants.RegionSize; y += 2)
1823 {
1824 if (parcel.ContainsPoint(x, y))
1825 {
1826 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1827 targetAvatar.TeleportWithMomentum(position);
1828 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1829 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1830 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1831 entry.AgentID = targetAvatar.UUID;
1832 entry.Flags = AccessList.Ban;
1833 entry.Time = new DateTime();
1834 land.LandData.ParcelAccessList.Add(entry);
1835 return;
1836 }
1837 }
1838 }
1839 }
1840 }
1841 }
1842 }
1843 Vector3 targetVector;
1844 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1845 {
1846 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1847 {
1848 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1849 targetAvatar.TeleportWithMomentum(targetVector);
1850 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1851 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1852 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1853 entry.AgentID = targetAvatar.UUID;
1854 entry.Flags = AccessList.Ban;
1855 entry.Time = new DateTime();
1856 land.LandData.ParcelAccessList.Add(entry);
1857 return;
1858 }
1859 else
1860 {
1861 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1862 targetAvatar.TeleportWithMomentum(targetVector);
1863 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1864 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1865 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1866 entry.AgentID = targetAvatar.UUID;
1867 entry.Flags = AccessList.Ban;
1868 entry.Time = new DateTime();
1869 land.LandData.ParcelAccessList.Add(entry);
1870 return;
1871 }
1872 }
1873 else
1874 {
1875 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1876 {
1877 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1878 targetAvatar.TeleportWithMomentum(targetVector);
1879 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1880 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1881 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1882 entry.AgentID = targetAvatar.UUID;
1883 entry.Flags = AccessList.Ban;
1884 entry.Time = new DateTime();
1885 land.LandData.ParcelAccessList.Add(entry);
1886 return;
1887 }
1888 else
1889 {
1890 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1891 targetAvatar.TeleportWithMomentum(targetVector);
1892 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1893 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1894 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1895 entry.AgentID = targetAvatar.UUID;
1896 entry.Flags = AccessList.Ban;
1897 entry.Time = new DateTime();
1898 land.LandData.ParcelAccessList.Add(entry);
1899 return;
1900 }
1901 }
1902 }
1903 }
1904 }
1655 1905
1656 protected void InstallInterfaces() 1906 protected void InstallInterfaces()
1657 { 1907 {
@@ -1714,5 +1964,27 @@ namespace OpenSim.Region.CoreModules.World.Land
1714 1964
1715 MainConsole.Instance.Output(report.ToString()); 1965 MainConsole.Instance.Output(report.ToString());
1716 } 1966 }
1967
1968 public void EnforceBans(ILandObject land, ScenePresence avatar)
1969 {
1970 if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
1971 return;
1972
1973 if (land.IsEitherBannedOrRestricted(avatar.UUID))
1974 {
1975 if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
1976 {
1977 Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
1978 if (pos == null)
1979 m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
1980 else
1981 ForceAvatarToPosition(avatar, (Vector3)pos);
1982 }
1983 else
1984 {
1985 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
1986 }
1987 }
1988 }
1717 } 1989 }
1718} \ No newline at end of file 1990}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index e7bdb19..e87153b 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -416,6 +416,37 @@ namespace OpenSim.Region.CoreModules.World.Land
416 return false; 416 return false;
417 } 417 }
418 418
419 public bool HasGroupAccess(UUID avatar)
420 {
421 if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup)
422 {
423 ScenePresence sp;
424 if (!m_scene.TryGetScenePresence(avatar, out sp))
425 {
426 IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
427 if (groupsModule == null)
428 return false;
429
430 GroupMembershipData[] membership = groupsModule.GetMembershipData(avatar);
431 if (membership == null || membership.Length == 0)
432 return false;
433
434 foreach (GroupMembershipData d in membership)
435 {
436 if (d.GroupID == LandData.GroupID)
437 return true;
438 }
439 return false;
440 }
441
442 if (!sp.ControllingClient.IsGroupMember(LandData.GroupID))
443 return false;
444
445 return true;
446 }
447 return false;
448 }
449
419 public bool IsBannedFromLand(UUID avatar) 450 public bool IsBannedFromLand(UUID avatar)
420 { 451 {
421 if (m_scene.Permissions.IsAdministrator(avatar)) 452 if (m_scene.Permissions.IsAdministrator(avatar))
@@ -452,9 +483,13 @@ namespace OpenSim.Region.CoreModules.World.Land
452 return false; 483 return false;
453 }) == -1 && LandData.OwnerID != avatar) 484 }) == -1 && LandData.OwnerID != avatar)
454 { 485 {
455 return true; 486 if (!HasGroupAccess(avatar))
487 {
488 return true;
489 }
456 } 490 }
457 } 491 }
492
458 return false; 493 return false;
459 } 494 }
460 495
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index bc140ae..2a9036d 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -183,11 +183,6 @@ namespace OpenSim.Region.CoreModules.World.Land
183 183
184 Vector3 pos = obj.AbsolutePosition; 184 Vector3 pos = obj.AbsolutePosition;
185 ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); 185 ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
186
187 // If for some reason there is no land object (perhaps the object is out of bounds) then we can't count it
188 if (landObject == null)
189 return;
190
191 LandData landData = landObject.LandData; 186 LandData landData = landObject.LandData;
192 187
193// m_log.DebugFormat( 188// m_log.DebugFormat(
@@ -198,7 +193,7 @@ namespace OpenSim.Region.CoreModules.World.Land
198 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) 193 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
199 { 194 {
200 UUID landOwner = landData.OwnerID; 195 UUID landOwner = landData.OwnerID;
201 int partCount = obj.Parts.Length; 196 int partCount = obj.GetPartCount();
202 197
203 m_SimwideCounts[landOwner] += partCount; 198 m_SimwideCounts[landOwner] += partCount;
204 if (parcelCounts.Users.ContainsKey(obj.OwnerID)) 199 if (parcelCounts.Users.ContainsKey(obj.OwnerID))
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 170c35f..a098ff6 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -362,7 +362,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
362 362
363 public string Name 363 public string Name
364 { 364 {
365 get { return "PermissionsModule"; } 365 get { return "DefaultPermissionsModule"; }
366 } 366 }
367 367
368 public bool IsSharedModule 368 public bool IsSharedModule
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
index ab6a598..19ee7f5 100644
--- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
+++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
@@ -28,6 +28,8 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Timers; 30using System.Timers;
31using System.IO;
32using System.Diagnostics;
31using System.Threading; 33using System.Threading;
32using System.Collections.Generic; 34using System.Collections.Generic;
33using log4net; 35using log4net;
@@ -56,13 +58,23 @@ namespace OpenSim.Region.CoreModules.World.Region
56 protected UUID m_Initiator; 58 protected UUID m_Initiator;
57 protected bool m_Notice = false; 59 protected bool m_Notice = false;
58 protected IDialogModule m_DialogModule = null; 60 protected IDialogModule m_DialogModule = null;
61 protected string m_MarkerPath = String.Empty;
59 62
60 public void Initialise(IConfigSource config) 63 public void Initialise(IConfigSource config)
61 { 64 {
65 IConfig restartConfig = config.Configs["RestartModule"];
66 if (restartConfig != null)
67 {
68 m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty);
69 }
62 } 70 }
63 71
64 public void AddRegion(Scene scene) 72 public void AddRegion(Scene scene)
65 { 73 {
74 if (m_MarkerPath != String.Empty)
75 File.Delete(Path.Combine(m_MarkerPath,
76 scene.RegionInfo.RegionID.ToString()));
77
66 m_Scene = scene; 78 m_Scene = scene;
67 scene.RegisterModuleInterface<IRestartModule>(this); 79 scene.RegisterModuleInterface<IRestartModule>(this);
68 MainConsole.Instance.Commands.AddCommand("RestartModule", 80 MainConsole.Instance.Commands.AddCommand("RestartModule",
@@ -114,6 +126,7 @@ namespace OpenSim.Region.CoreModules.World.Region
114 126
115 if (alerts == null) 127 if (alerts == null)
116 { 128 {
129 CreateMarkerFile();
117 m_Scene.RestartNow(); 130 m_Scene.RestartNow();
118 return; 131 return;
119 } 132 }
@@ -127,6 +140,7 @@ namespace OpenSim.Region.CoreModules.World.Region
127 140
128 if (m_Alerts[0] == 0) 141 if (m_Alerts[0] == 0)
129 { 142 {
143 CreateMarkerFile();
130 m_Scene.RestartNow(); 144 m_Scene.RestartNow();
131 return; 145 return;
132 } 146 }
@@ -140,6 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Region
140 { 154 {
141 if (m_Alerts.Count == 0 || m_Alerts[0] == 0) 155 if (m_Alerts.Count == 0 || m_Alerts[0] == 0)
142 { 156 {
157 CreateMarkerFile();
143 m_Scene.RestartNow(); 158 m_Scene.RestartNow();
144 return 0; 159 return 0;
145 } 160 }
@@ -259,5 +274,25 @@ namespace OpenSim.Region.CoreModules.World.Region
259 274
260 ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); 275 ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice);
261 } 276 }
277
278 protected void CreateMarkerFile()
279 {
280 if (m_MarkerPath == String.Empty)
281 return;
282
283 string path = Path.Combine(m_MarkerPath, m_Scene.RegionInfo.RegionID.ToString());
284 try
285 {
286 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
287 FileStream fs = File.Create(path);
288 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
289 Byte[] buf = enc.GetBytes(pidstring);
290 fs.Write(buf, 0, buf.Length);
291 fs.Close();
292 }
293 catch (Exception)
294 {
295 }
296 }
262 } 297 }
263} 298}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 8a79d78..9d968e7 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -551,6 +551,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
551 m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); 551 m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised());
552 m_scene.SaveTerrain(); 552 m_scene.SaveTerrain();
553 553
554 m_scene.EventManager.TriggerTerrainUpdate();
555
554 // Clients who look at the map will never see changes after they looked at the map, so i've commented this out. 556 // Clients who look at the map will never see changes after they looked at the map, so i've commented this out.
555 //m_scene.CreateTerrainTexture(true); 557 //m_scene.CreateTerrainTexture(true);
556 } 558 }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index f9ef286..d0aa53e 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -86,9 +86,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
86 86
87 private void OnMapNameRequest(IClientAPI remoteClient, string mapName) 87 private void OnMapNameRequest(IClientAPI remoteClient, string mapName)
88 { 88 {
89 if (mapName.Length < 3) 89 if (mapName.Length < 2)
90 { 90 {
91 remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); 91 remoteClient.SendAlertMessage("Use a search string with at least 2 characters");
92 return; 92 return;
93 } 93 }
94 94
@@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
106 else if (regionInfos.Count == 0 && mapName.StartsWith("http://")) 106 else if (regionInfos.Count == 0 && mapName.StartsWith("http://"))
107 remoteClient.SendAlertMessage("Hyperlink could not be established."); 107 remoteClient.SendAlertMessage("Hyperlink could not be established.");
108 108
109 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); 109 //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count);
110 List<MapBlockData> blocks = new List<MapBlockData>(); 110 List<MapBlockData> blocks = new List<MapBlockData>();
111 111
112 MapBlockData data; 112 MapBlockData data;
@@ -132,15 +132,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
132 data.Agents = 0; 132 data.Agents = 0;
133 data.Access = 255; 133 data.Access = 255;
134 data.MapImageId = UUID.Zero; 134 data.MapImageId = UUID.Zero;
135 data.Name = ""; // mapName; 135 data.Name = mapName;
136 data.RegionFlags = 0; 136 data.RegionFlags = 0;
137 data.WaterHeight = 0; // not used 137 data.WaterHeight = 0; // not used
138 data.X = 0; 138 data.X = 0;
139 data.Y = 0; 139 data.Y = 0;
140 blocks.Add(data); 140 blocks.Add(data);
141 141
142 // not sure what the flags do here, but seems to be necessary
143 // to set to "2" for viewer 2
144 remoteClient.SendMapBlock(blocks, 2); 142 remoteClient.SendMapBlock(blocks, 2);
145 } 143 }
146 144
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 1094970..b05aef8 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -1056,7 +1056,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1056 } 1056 }
1057 else 1057 else
1058 { 1058 {
1059 OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); 1059 OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount());
1060 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 1060 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
1061 { 1061 {
1062 OSDMap responsemapdata = new OSDMap(); 1062 OSDMap responsemapdata = new OSDMap();