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/AssetXferUploader.cs127
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs85
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs56
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs105
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs19
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs202
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs26
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs122
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs49
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs5
-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/Caps/CapabilitiesModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs58
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs19
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs54
-rw-r--r--OpenSim/Region/CoreModules/LightShare/LightShareModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs16
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs152
-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.cs8
-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.cs74
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs456
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs79
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.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.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs2
39 files changed, 1556 insertions, 416 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
index ec4dfd0..4cedfe6 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 /// <summary> 51 /// <summary>
@@ -65,6 +73,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
65 private UUID TransactionID = UUID.Zero; 73 private UUID TransactionID = UUID.Zero;
66 private sbyte type = 0; 74 private sbyte type = 0;
67 private byte wearableType = 0; 75 private byte wearableType = 0;
76 private byte[] m_oldData = null;
68 public ulong XferID; 77 public ulong XferID;
69 private Scene m_Scene; 78 private Scene m_Scene;
70 79
@@ -302,6 +311,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
302 311
303 private void DoCreateItem(uint callbackID) 312 private void DoCreateItem(uint callbackID)
304 { 313 {
314 ValidateAssets();
305 m_Scene.AssetService.Store(m_asset); 315 m_Scene.AssetService.Store(m_asset);
306 316
307 InventoryItemBase item = new InventoryItemBase(); 317 InventoryItemBase item = new InventoryItemBase();
@@ -322,12 +332,84 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
322 item.Flags = (uint) wearableType; 332 item.Flags = (uint) wearableType;
323 item.CreationDate = Util.UnixTimeSinceEpoch(); 333 item.CreationDate = Util.UnixTimeSinceEpoch();
324 334
335 m_log.DebugFormat("[XFER]: Created item {0} with asset {1}",
336 item.ID, item.AssetID);
337
325 if (m_Scene.AddInventoryItem(item)) 338 if (m_Scene.AddInventoryItem(item))
326 ourClient.SendInventoryItemCreateUpdate(item, callbackID); 339 ourClient.SendInventoryItemCreateUpdate(item, callbackID);
327 else 340 else
328 ourClient.SendAlertMessage("Unable to create inventory item"); 341 ourClient.SendAlertMessage("Unable to create inventory item");
329 } 342 }
330 343
344 private void ValidateAssets()
345 {
346 if (m_asset.Type == (sbyte)AssetType.Clothing ||
347 m_asset.Type == (sbyte)AssetType.Bodypart)
348 {
349 string content = System.Text.Encoding.ASCII.GetString(m_asset.Data);
350 string[] lines = content.Split(new char[] {'\n'});
351
352 List<string> validated = new List<string>();
353
354 Dictionary<int, UUID> allowed = ExtractTexturesFromOldData();
355
356 int textures = 0;
357
358 foreach (string line in lines)
359 {
360 try
361 {
362 if (line.StartsWith("textures "))
363 {
364 textures = Convert.ToInt32(line.Substring(9));
365 validated.Add(line);
366 }
367 else if (textures > 0)
368 {
369 string[] parts = line.Split(new char[] {' '});
370
371 UUID tx = new UUID(parts[1]);
372 int id = Convert.ToInt32(parts[0]);
373
374 if (defaultIDs.Contains(tx) || tx == UUID.Zero ||
375 (allowed.ContainsKey(id) && allowed[id] == tx))
376 {
377 validated.Add(parts[0] + " " + tx.ToString());
378 }
379 else
380 {
381 int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, tx);
382 int full = (int)(PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Copy);
383
384 if ((perms & full) != full)
385 {
386 m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId);
387 validated.Add(parts[0] + " " + UUID.Zero.ToString());
388 }
389 else
390 {
391 validated.Add(line);
392 }
393 }
394 textures--;
395 }
396 else
397 {
398 validated.Add(line);
399 }
400 }
401 catch
402 {
403 // If it's malformed, skip it
404 }
405 }
406
407 string final = String.Join("\n", validated.ToArray());
408
409 m_asset.Data = System.Text.Encoding.ASCII.GetBytes(final);
410 }
411 }
412
331 /// <summary> 413 /// <summary>
332 /// Get the asset data uploaded in this transfer. 414 /// Get the asset data uploaded in this transfer.
333 /// </summary> 415 /// </summary>
@@ -336,10 +418,55 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
336 { 418 {
337 if (m_finished) 419 if (m_finished)
338 { 420 {
421 ValidateAssets();
339 return m_asset; 422 return m_asset;
340 } 423 }
341 424
342 return null; 425 return null;
343 } 426 }
427
428 public void SetOldData(byte[] d)
429 {
430 m_oldData = d;
431 }
432
433 private Dictionary<int,UUID> ExtractTexturesFromOldData()
434 {
435 Dictionary<int,UUID> result = new Dictionary<int,UUID>();
436 if (m_oldData == null)
437 return result;
438
439 string content = System.Text.Encoding.ASCII.GetString(m_oldData);
440 string[] lines = content.Split(new char[] {'\n'});
441
442 int textures = 0;
443
444 foreach (string line in lines)
445 {
446 try
447 {
448 if (line.StartsWith("textures "))
449 {
450 textures = Convert.ToInt32(line.Substring(9));
451 }
452 else if (textures > 0)
453 {
454 string[] parts = line.Split(new char[] {' '});
455
456 UUID tx = new UUID(parts[1]);
457 int id = Convert.ToInt32(parts[0]);
458 result[id] = tx;
459 textures--;
460 }
461 }
462 catch
463 {
464 // If it's malformed, skip it
465 }
466 }
467
468 return result;
469 }
344 } 470 }
345} 471}
472
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 22c301b..8e2dba4 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -257,53 +257,66 @@ namespace Flotsam.RegionModules.AssetCache
257 257
258 private void UpdateFileCache(string key, AssetBase asset) 258 private void UpdateFileCache(string key, AssetBase asset)
259 { 259 {
260 string filename = GetFileName(asset.ID); 260 // TODO: Spawn this off to some seperate thread to do the actual writing
261 261 if (asset != null)
262 try
263 { 262 {
264 // If the file is already cached, don't cache it, just touch it so access time is updated 263 string filename = GetFileName(key);
265 if (File.Exists(filename)) 264
266 { 265 try
267 File.SetLastAccessTime(filename, DateTime.Now);
268 }
269 else
270 { 266 {
271 // Once we start writing, make sure we flag that we're writing 267 // If the file is already cached, don't cache it, just touch it so access time is updated
272 // that object to the cache so that we don't try to write the 268 if (File.Exists(filename))
273 // same file multiple times.
274 lock (m_CurrentlyWriting)
275 { 269 {
276#if WAIT_ON_INPROGRESS_REQUESTS 270 // We don't really want to know about sharing
277 if (m_CurrentlyWriting.ContainsKey(filename)) 271 // violations here. If the file is locked, then
272 // the other thread has updated the time for us.
273 try
278 { 274 {
279 return; 275 File.SetLastAccessTime(filename, DateTime.Now);
280 } 276 }
281 else 277 catch
282 {
283 m_CurrentlyWriting.Add(filename, new ManualResetEvent(false));
284 }
285
286#else
287 if (m_CurrentlyWriting.Contains(filename))
288 { 278 {
289 return;
290 } 279 }
291 else 280 } else {
281
282 // Once we start writing, make sure we flag that we're writing
283 // that object to the cache so that we don't try to write the
284 // same file multiple times.
285 lock (m_CurrentlyWriting)
292 { 286 {
293 m_CurrentlyWriting.Add(filename); 287#if WAIT_ON_INPROGRESS_REQUESTS
294 } 288 if (m_CurrentlyWriting.ContainsKey(filename))
289 {
290 return;
291 }
292 else
293 {
294 m_CurrentlyWriting.Add(filename, new ManualResetEvent(false));
295 }
296
297#else
298 if (m_CurrentlyWriting.Contains(filename))
299 {
300 return;
301 }
302 else
303 {
304 m_CurrentlyWriting.Add(filename);
305 }
295#endif 306#endif
296 }
297 307
298 Util.FireAndForget( 308 }
299 delegate { WriteFileCache(filename, asset); }); 309
310 Util.FireAndForget(
311 delegate { WriteFileCache(filename, asset); });
312 }
313 }
314 catch (Exception e)
315 {
316 m_log.ErrorFormat(
317 "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}",
318 asset.ID, e.Message, e.StackTrace);
300 } 319 }
301 }
302 catch (Exception e)
303 {
304 m_log.ErrorFormat(
305 "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}",
306 asset.ID, e.Message, e.StackTrace);
307 } 320 }
308 } 321 }
309 322
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2349e40..3881dcd 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;
@@ -135,7 +136,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
135 // If we're an NPC then skip all the item checks and manipulations since we don't have an 136 // If we're an NPC then skip all the item checks and manipulations since we don't have an
136 // inventory right now. 137 // inventory right now.
137 if (sp.PresenceType == PresenceType.Npc) 138 if (sp.PresenceType == PresenceType.Npc)
138 RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p); 139 RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null);
139 else 140 else
140 RezSingleAttachmentFromInventory(sp, attach.ItemID, p); 141 RezSingleAttachmentFromInventory(sp, attach.ItemID, p);
141 } 142 }
@@ -265,6 +266,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
265 } 266 }
266 267
267 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) 268 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
269 {
270 return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, true, null);
271 }
272
273 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc)
268 { 274 {
269 if (!Enabled) 275 if (!Enabled)
270 return null; 276 return null;
@@ -303,7 +309,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
303 return null; 309 return null;
304 } 310 }
305 311
306 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt); 312 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc);
307 313
308 if (att == null) 314 if (att == null)
309 DetachSingleAttachmentToInv(sp, itemID); 315 DetachSingleAttachmentToInv(sp, itemID);
@@ -574,11 +580,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
574 580
575 Vector3 inventoryStoredPosition = new Vector3 581 Vector3 inventoryStoredPosition = new Vector3
576 (((grp.AbsolutePosition.X > (int)Constants.RegionSize) 582 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
577 ? Constants.RegionSize - 6 583 ? (float)Constants.RegionSize - 6
578 : grp.AbsolutePosition.X) 584 : grp.AbsolutePosition.X)
579 , 585 ,
580 (grp.AbsolutePosition.Y > (int)Constants.RegionSize) 586 (grp.AbsolutePosition.Y > (int)Constants.RegionSize)
581 ? Constants.RegionSize - 6 587 ? (float)Constants.RegionSize - 6
582 : grp.AbsolutePosition.Y, 588 : grp.AbsolutePosition.Y,
583 grp.AbsolutePosition.Z); 589 grp.AbsolutePosition.Z);
584 590
@@ -696,8 +702,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
696 } 702 }
697 } 703 }
698 704
699 private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 705 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
700 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt) 706 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc)
701 { 707 {
702 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 708 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
703 if (invAccess != null) 709 if (invAccess != null)
@@ -705,7 +711,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
705 lock (sp.AttachmentsSyncLock) 711 lock (sp.AttachmentsSyncLock)
706 { 712 {
707 SceneObjectGroup objatt; 713 SceneObjectGroup objatt;
708 714
709 if (itemID != UUID.Zero) 715 if (itemID != UUID.Zero)
710 objatt = invAccess.RezObject(sp.ControllingClient, 716 objatt = invAccess.RezObject(sp.ControllingClient,
711 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, 717 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
@@ -714,11 +720,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
714 objatt = invAccess.RezObject(sp.ControllingClient, 720 objatt = invAccess.RezObject(sp.ControllingClient,
715 null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, 721 null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
716 false, false, sp.UUID, true); 722 false, false, sp.UUID, true);
717 723
718 // m_log.DebugFormat( 724 // m_log.DebugFormat(
719 // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", 725 // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
720 // objatt.Name, remoteClient.Name, AttachmentPt); 726 // objatt.Name, remoteClient.Name, AttachmentPt);
721 727
722 if (objatt != null) 728 if (objatt != null)
723 { 729 {
724 // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. 730 // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
@@ -726,7 +732,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
726 bool tainted = false; 732 bool tainted = false;
727 if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) 733 if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
728 tainted = true; 734 tainted = true;
729 735
730 // This will throw if the attachment fails 736 // This will throw if the attachment fails
731 try 737 try
732 { 738 {
@@ -737,21 +743,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
737 m_log.ErrorFormat( 743 m_log.ErrorFormat(
738 "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", 744 "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}",
739 objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); 745 objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace);
740 746
741 // Make sure the object doesn't stick around and bail 747 // Make sure the object doesn't stick around and bail
742 sp.RemoveAttachment(objatt); 748 sp.RemoveAttachment(objatt);
743 m_scene.DeleteSceneObject(objatt, false); 749 m_scene.DeleteSceneObject(objatt, false);
744 return null; 750 return null;
745 } 751 }
746 752
747 if (tainted) 753 if (tainted)
748 objatt.HasGroupChanged = true; 754 objatt.HasGroupChanged = true;
749 755
750 // Fire after attach, so we don't get messy perms dialogs 756 // Fire after attach, so we don't get messy perms dialogs
751 // 4 == AttachedRez 757 // 4 == AttachedRez
752 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); 758 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
753 objatt.ResumeScripts(); 759 objatt.ResumeScripts();
754 760
755 // Do this last so that event listeners have access to all the effects of the attachment 761 // Do this last so that event listeners have access to all the effects of the attachment
756 m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); 762 m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID);
757 763
@@ -763,9 +769,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
763 "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", 769 "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
764 itemID, sp.Name, attachmentPt); 770 itemID, sp.Name, attachmentPt);
765 } 771 }
772
773 if (doc != null)
774 {
775 objatt.LoadScriptState(doc);
776 objatt.ResetOwnerChangeFlag();
777 }
778
779 // Fire after attach, so we don't get messy perms dialogs
780 // 4 == AttachedRez
781 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
782 objatt.ResumeScripts();
783
784 // Do this last so that event listeners have access to all the effects of the attachment
785 m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID);
766 } 786 }
767 } 787 }
768 788
769 return null; 789 return null;
770 } 790 }
771 791
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 07d1cb3..d866636 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -327,8 +327,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
327 if (checkonly) 327 if (checkonly)
328 return false; 328 return false;
329 329
330 m_log.InfoFormat("[AVFACTORY]: missing baked texture {0}, requesting rebake", face.TextureID);
331
332 sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID); 330 sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID);
333 } 331 }
334 } 332 }
@@ -350,7 +348,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
350 { 348 {
351 if (m_scene.AssetService.Get(textureID.ToString()) == null) 349 if (m_scene.AssetService.Get(textureID.ToString()) == null)
352 { 350 {
353 m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}", 351 m_log.InfoFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}",
354 textureID, idx, sp.Name); 352 textureID, idx, sp.Name);
355 return false; 353 return false;
356 } 354 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index 10b4c37..4d8fb90 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:
@@ -233,8 +247,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
233 s.ForEachRootScenePresence( 247 s.ForEachRootScenePresence(
234 delegate(ScenePresence presence) 248 delegate(ScenePresence presence)
235 { 249 {
236 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) 250 ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
237 receiverIDs.Add(presence.UUID); 251 if (Presencecheck != null)
252 {
253 // This will pass all chat from objects. Not
254 // perfect, but it will do. For now. Better
255 // than the prior behavior of muting all
256 // objects on a parcel with access restrictions
257 if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
258 {
259 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType))
260 receiverIDs.Add(presence.UUID);
261 }
262 }
263
238 } 264 }
239 ); 265 );
240 } 266 }
@@ -278,26 +304,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
278 } 304 }
279 305
280 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); 306 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
281
282 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 307 HashSet<UUID> receiverIDs = new HashSet<UUID>();
283 308
284 ((Scene)c.Scene).ForEachRootClient( 309 if (c.Scene != null)
285 delegate(IClientAPI client) 310 {
286 { 311 ((Scene)c.Scene).ForEachRootClient
287 // don't forward SayOwner chat from objects to 312 (
288 // non-owner agents 313 delegate(IClientAPI client)
289 if ((c.Type == ChatTypeEnum.Owner) && 314 {
290 (null != c.SenderObject) && 315 // don't forward SayOwner chat from objects to
291 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) 316 // non-owner agents
292 return; 317 if ((c.Type == ChatTypeEnum.Owner) &&
293 318 (null != c.SenderObject) &&
294 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, 319 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
295 (byte)sourceType, (byte)ChatAudibleLevel.Fully); 320 return;
296 receiverIDs.Add(client.AgentId); 321
297 }); 322 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
298 323 (byte)sourceType, (byte)ChatAudibleLevel.Fully);
299 (c.Scene as Scene).EventManager.TriggerOnChatToClients( 324 receiverIDs.Add(client.AgentId);
300 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); 325 }
326 );
327 (c.Scene as Scene).EventManager.TriggerOnChatToClients(
328 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
329 }
301 } 330 }
302 331
303 /// <summary> 332 /// <summary>
@@ -340,5 +369,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
340 369
341 return true; 370 return true;
342 } 371 }
372
373 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
374 public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
375 {
376 System.Threading.Timer Timer;
377 if (flags == 0)
378 {
379 FreezeCache.Add(target.ToString());
380 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
381 Timer = new System.Threading.Timer(timeCB, target, 30000, 0);
382 Timers.Add(target, Timer);
383 }
384 else
385 {
386 FreezeCache.Remove(target.ToString());
387 Timers.TryGetValue(target, out Timer);
388 Timers.Remove(target);
389 Timer.Dispose();
390 }
391 }
392
393 private void OnEndParcelFrozen(object avatar)
394 {
395 UUID target = (UUID)avatar;
396 FreezeCache.Remove(target.ToString());
397 System.Threading.Timer Timer;
398 Timers.TryGetValue(target, out Timer);
399 Timers.Remove(target);
400 Timer.Dispose();
401 }
343 } 402 }
344} 403}
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index ffe7718..bb2cd1f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -216,4 +216,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
216 return result; 216 return result;
217 } 217 }
218 } 218 }
219} \ No newline at end of file 219}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index c266fe5..5d94ff7 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -328,7 +328,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
328 //m_log.DebugFormat("[XXX]: OnClientLogin!"); 328 //m_log.DebugFormat("[XXX]: OnClientLogin!");
329 // Inform the friends that this user is online 329 // Inform the friends that this user is online
330 StatusChange(agentID, true); 330 StatusChange(agentID, true);
331 331
332 // Register that we need to send the list of online friends to this user 332 // Register that we need to send the list of online friends to this user
333 lock (m_NeedsListOfOnlineFriends) 333 lock (m_NeedsListOfOnlineFriends)
334 m_NeedsListOfOnlineFriends.Add(agentID); 334 m_NeedsListOfOnlineFriends.Add(agentID);
@@ -603,6 +603,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
603 { 603 {
604 StoreFriendships(client.AgentId, friendID); 604 StoreFriendships(client.AgentId, friendID);
605 605
606 ICallingCardModule ccm = client.Scene.RequestModuleInterface<ICallingCardModule>();
607 if (ccm != null)
608 {
609 ccm.CreateCallingCard(client.AgentId, friendID, UUID.Zero);
610 }
611
606 // Update the local cache 612 // Update the local cache
607 RecacheFriends(client); 613 RecacheFriends(client);
608 614
@@ -779,6 +785,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
779 (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero); 785 (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero);
780 friendClient.SendInstantMessage(im); 786 friendClient.SendInstantMessage(im);
781 787
788 ICallingCardModule ccm = friendClient.Scene.RequestModuleInterface<ICallingCardModule>();
789 if (ccm != null)
790 {
791 ccm.CreateCallingCard(friendID, userID, UUID.Zero);
792 }
793
794
782 // Update the local cache 795 // Update the local cache
783 RecacheFriends(friendClient); 796 RecacheFriends(friendClient);
784 797
@@ -801,7 +814,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
801 // we're done 814 // we're done
802 return true; 815 return true;
803 } 816 }
804 817
805 return false; 818 return false;
806 } 819 }
807 820
@@ -853,7 +866,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
853 866
854 public bool LocalStatusNotification(UUID userID, UUID friendID, bool online) 867 public bool LocalStatusNotification(UUID userID, UUID friendID, bool online)
855 { 868 {
856// m_log.DebugFormat("[FRIENDS]: Local Status Notify {0} that user {1} is {2}", friendID, userID, online); 869 //m_log.DebugFormat("[FRIENDS]: Local Status Notify {0} that user {1} is {2}", friendID, userID, online);
857 IClientAPI friendClient = LocateClientObject(friendID); 870 IClientAPI friendClient = LocateClientObject(friendID);
858 if (friendClient != null) 871 if (friendClient != null)
859 { 872 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index 2e3312f..f73f9c1 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,69 +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.ForEachRootClient(
144 delegate(IClientAPI client)
145 {
146 if (client.AgentId != godID)
147 {
148 client.Close();
149 }
150 }
151 );
152 }
153 else
154 {
155 m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent);
156 214
157 sp.ControllingClient.Kick(Utils.BytesToString(reason)); 215 switch (kickflags)
158 sp.ControllingClient.Close(); 216 {
159 } 217 case 0:
160 } 218 if (sp != null)
161 219 {
162 if (kickflags == 1) 220 KickPresence(sp, Utils.BytesToString(reason));
163 {
164 sp.AllowMovement = false;
165 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
166 m_dialogModule.SendAlertToUser(godID, "User Frozen");
167 }
168
169 if (kickflags == 2)
170 {
171 sp.AllowMovement = true;
172 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
173 m_dialogModule.SendAlertToUser(godID, "User Unfrozen");
174 }
175 } 221 }
176 else 222 else if (agentID == ALL_AGENTS)
177 { 223 {
178 m_dialogModule.SendAlertToUser(godID, "Kick request denied"); 224 m_scene.ForEachRootScenePresence(
225 delegate(ScenePresence p)
226 {
227 if (p.UUID != godID && (!m_scene.Permissions.IsGod(p.UUID)))
228 KickPresence(p, Utils.BytesToString(reason));
229 }
230 );
179 } 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));
180 } 272 }
181 } 273 }
182 } 274 }
183} \ 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 ca5d485..1af4d68 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -157,6 +157,32 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
157 return; 157 return;
158 } 158 }
159 159
160 //DateTime dt = DateTime.UtcNow;
161
162 // Ticks from UtcNow, but make it look like local. Evil, huh?
163 //dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
164
165 //try
166 //{
167 // // Convert that to the PST timezone
168 // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
169 // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
170 //}
171 //catch
172 //{
173 // //m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp.");
174 //}
175
176 //// And make it look local again to fool the unix time util
177 //dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
178
179 // If client is null, this message comes from storage and IS offline
180 if (client != null)
181 im.offline = 0;
182
183 if (im.offline == 0)
184 im.timestamp = (uint)Util.UnixTimeSinceEpoch();
185
160 if (m_TransferModule != null) 186 if (m_TransferModule != null)
161 { 187 {
162 if (client != null) 188 if (client != null)
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 0dad3c4..712632b 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -48,6 +48,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 private bool m_Enabled = false; 50 private bool m_Enabled = false;
51 protected string m_MessageKey = String.Empty;
51 protected List<Scene> m_Scenes = new List<Scene>(); 52 protected List<Scene> m_Scenes = new List<Scene>();
52 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); 53 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>();
53 54
@@ -67,14 +68,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
67 public virtual void Initialise(IConfigSource config) 68 public virtual void Initialise(IConfigSource config)
68 { 69 {
69 IConfig cnf = config.Configs["Messaging"]; 70 IConfig cnf = config.Configs["Messaging"];
70 if (cnf != null && cnf.GetString( 71 if (cnf != null)
71 "MessageTransferModule", "MessageTransferModule") !=
72 "MessageTransferModule")
73 { 72 {
74 m_log.Debug("[MESSAGE TRANSFER]: Disabled by configuration"); 73 if (cnf.GetString("MessageTransferModule",
75 return; 74 "MessageTransferModule") != "MessageTransferModule")
76 } 75 {
76 return;
77 }
77 78
79 m_MessageKey = cnf.GetString("MessageKey", String.Empty);
80 }
81 m_log.Debug("[MESSAGE TRANSFER]: Module enabled");
78 m_Enabled = true; 82 m_Enabled = true;
79 } 83 }
80 84
@@ -142,13 +146,20 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
142 ScenePresence sp = scene.GetScenePresence(toAgentID); 146 ScenePresence sp = scene.GetScenePresence(toAgentID);
143 if (sp != null && !sp.IsChildAgent) 147 if (sp != null && !sp.IsChildAgent)
144 { 148 {
145 // Local message 149// m_log.DebugFormat(
146// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); 150// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}",
147 sp.ControllingClient.SendInstantMessage(im); 151// toAgentID.ToString(), scene.RegionInfo.RegionName);
152
153 ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
154 if (!user.IsChildAgent)
155 {
156 // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering to client");
157 user.ControllingClient.SendInstantMessage(im);
148 158
149 // Message sent 159 // Message sent
150 result(true); 160 result(true);
151 return; 161 return;
162 }
152 } 163 }
153 } 164 }
154 165
@@ -161,8 +172,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
161 if (sp != null) 172 if (sp != null)
162 { 173 {
163 // Local message 174 // Local message
164// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); 175 ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
165 sp.ControllingClient.SendInstantMessage(im); 176
177 // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering to client");
178 user.ControllingClient.SendInstantMessage(im);
166 179
167 // Message sent 180 // Message sent
168 result(true); 181 result(true);
@@ -244,6 +257,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
244 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") 257 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id")
245 && requestData.ContainsKey("binary_bucket")) 258 && requestData.ContainsKey("binary_bucket"))
246 { 259 {
260 if (m_MessageKey != String.Empty)
261 {
262 XmlRpcResponse error_resp = new XmlRpcResponse();
263 Hashtable error_respdata = new Hashtable();
264 error_respdata["success"] = "FALSE";
265 error_resp.Value = error_respdata;
266
267 if (!requestData.Contains("message_key"))
268 return error_resp;
269 if (m_MessageKey != (string)requestData["message_key"])
270 return error_resp;
271 }
272
247 // Do the easy way of validating the UUIDs 273 // Do the easy way of validating the UUIDs
248 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); 274 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID);
249 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); 275 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID);
@@ -420,24 +446,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
420 return resp; 446 return resp;
421 } 447 }
422 448
423 /// <summary> 449 private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
424 /// delegate for sending a grid instant message asynchronously
425 /// </summary>
426 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID);
427 450
428 protected virtual void GridInstantMessageCompleted(IAsyncResult iar) 451 private class GIM {
429 { 452 public GridInstantMessage im;
430 GridInstantMessageDelegate icon = 453 public MessageResultNotification result;
431 (GridInstantMessageDelegate)iar.AsyncState; 454 };
432 icon.EndInvoke(iar);
433 }
434 455
456 private Queue<GIM> pendingInstantMessages = new Queue<GIM>();
457 private int numInstantMessageThreads = 0;
435 458
436 protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) 459 private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result)
437 { 460 {
438 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; 461 lock (pendingInstantMessages) {
462 if (numInstantMessageThreads >= 4) {
463 GIM gim = new GIM();
464 gim.im = im;
465 gim.result = result;
466 pendingInstantMessages.Enqueue(gim);
467 } else {
468 ++ numInstantMessageThreads;
469 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads);
470 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain;
471 d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
472 }
473 }
474 }
439 475
440 d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); 476 private void GridInstantMessageCompleted(IAsyncResult iar)
477 {
478 GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState;
479 d.EndInvoke(iar);
441 } 480 }
442 481
443 /// <summary> 482 /// <summary>
@@ -452,8 +491,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
452 /// Pass in 0 the first time this method is called. It will be called recursively with the last 491 /// Pass in 0 the first time this method is called. It will be called recursively with the last
453 /// regionhandle tried 492 /// regionhandle tried
454 /// </param> 493 /// </param>
455 protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) 494 private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result)
495 {
496 GIM gim;
497 do {
498 try {
499 SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero);
500 } catch (Exception e) {
501 m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message);
502 }
503 lock (pendingInstantMessages) {
504 if (pendingInstantMessages.Count > 0) {
505 gim = pendingInstantMessages.Dequeue();
506 im = gim.im;
507 result = gim.result;
508 } else {
509 gim = null;
510 -- numInstantMessageThreads;
511 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads);
512 }
513 }
514 } while (gim != null);
515 }
516 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
456 { 517 {
518
457 UUID toAgentID = new UUID(im.toAgentID); 519 UUID toAgentID = new UUID(im.toAgentID);
458 520
459 PresenceInfo upd = null; 521 PresenceInfo upd = null;
@@ -520,7 +582,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
520 582
521 if (upd != null) 583 if (upd != null)
522 { 584 {
523 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, 585 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(UUID.Zero,
524 upd.RegionID); 586 upd.RegionID);
525 if (reginfo != null) 587 if (reginfo != null)
526 { 588 {
@@ -669,6 +731,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
669 gim["position_z"] = msg.Position.Z.ToString(); 731 gim["position_z"] = msg.Position.Z.ToString();
670 gim["region_id"] = msg.RegionID.ToString(); 732 gim["region_id"] = msg.RegionID.ToString();
671 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); 733 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None);
734 if (m_MessageKey != String.Empty)
735 gim["message_key"] = m_MessageKey;
672 return gim; 736 return gim;
673 } 737 }
674 738
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index de25048..5ab604f 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -171,7 +171,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
171 171
172 private void RetrieveInstantMessages(IClientAPI client) 172 private void RetrieveInstantMessages(IClientAPI client)
173 { 173 {
174 if (m_RestURL != "") 174 if (m_RestURL == String.Empty)
175 {
176 return;
177 }
178 else
175 { 179 {
176 m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); 180 m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId);
177 181
@@ -179,22 +183,25 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
179 = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( 183 = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>(
180 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); 184 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
181 185
182 if (msglist == null) 186 if (msglist != null)
183 m_log.WarnFormat("[OFFLINE MESSAGING]: WARNING null message list.");
184
185 foreach (GridInstantMessage im in msglist)
186 { 187 {
187 // client.SendInstantMessage(im); 188 foreach (GridInstantMessage im in msglist)
188 189 {
189 // Send through scene event manager so all modules get a chance 190 // client.SendInstantMessage(im);
190 // to look at this message before it gets delivered. 191
191 // 192 // Send through scene event manager so all modules get a chance
192 // Needed for proper state management for stored group 193 // to look at this message before it gets delivered.
193 // invitations 194 //
194 // 195 // Needed for proper state management for stored group
195 Scene s = FindScene(client.AgentId); 196 // invitations
196 if (s != null) 197 //
197 s.EventManager.TriggerIncomingInstantMessage(im); 198
199 im.offline = 1;
200
201 Scene s = FindScene(client.AgentId);
202 if (s != null)
203 s.EventManager.TriggerIncomingInstantMessage(im);
204 }
198 } 205 }
199 } 206 }
200 } 207 }
@@ -210,19 +217,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
210 return; 217 return;
211 } 218 }
212 219
213 if (!m_ForwardOfflineGroupMessages)
214 {
215 if (im.dialog == (byte)InstantMessageDialog.GroupNotice ||
216 im.dialog != (byte)InstantMessageDialog.GroupInvitation)
217 return;
218 }
219
220 Scene scene = FindScene(new UUID(im.fromAgentID)); 220 Scene scene = FindScene(new UUID(im.fromAgentID));
221 if (scene == null) 221 if (scene == null)
222 scene = m_SceneList[0]; 222 scene = m_SceneList[0];
223 223
224 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( 224 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
225 "POST", m_RestURL+"/SaveMessage/", im); 225 "POST", m_RestURL+"/SaveMessage/?scope=" +
226 scene.RegionInfo.ScopeID.ToString(), im);
226 227
227 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 228 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
228 { 229 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 6b24718..a19bbfd 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -632,4 +632,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
632 m_assetsLoaded = true; 632 m_assetsLoaded = true;
633 } 633 }
634 } 634 }
635} \ No newline at end of file 635}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 36ecb3b..63fde07 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -178,9 +178,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
178 InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, 178 InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself,
179 Dictionary<string, object> options, IUserAccountService userAccountService) 179 Dictionary<string, object> options, IUserAccountService userAccountService)
180 { 180 {
181 if (options.ContainsKey("verbose"))
182 m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving folder {0}", inventoryFolder.Name);
183
184 if (saveThisFolderItself) 181 if (saveThisFolderItself)
185 { 182 {
186 path += CreateArchiveFolderName(inventoryFolder); 183 path += CreateArchiveFolderName(inventoryFolder);
@@ -449,4 +446,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
449 return s; 446 return s;
450 } 447 }
451 } 448 }
452} \ No newline at end of file 449}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 19c774f..b33342f 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 {
@@ -244,6 +244,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
244 im.imSessionID = itemID.Guid; 244 im.imSessionID = itemID.Guid;
245 } 245 }
246 246
247 im.offline = 1; // Remember these
248
247 // Send the IM to the recipient. The item is already 249 // Send the IM to the recipient. The item is already
248 // in their inventory, so it will not be lost if 250 // in their inventory, so it will not be lost if
249 // they are offline. 251 // they are offline.
@@ -433,22 +435,67 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
433 /// 435 ///
434 /// </summary> 436 /// </summary>
435 /// <param name="msg"></param> 437 /// <param name="msg"></param>
436 private void OnGridInstantMessage(GridInstantMessage msg) 438 private void OnGridInstantMessage(GridInstantMessage im)
437 { 439 {
438 // Check if this is ours to handle 440 // Check if this is ours to handle
439 // 441 //
440 Scene scene = FindClientScene(new UUID(msg.toAgentID)); 442 Scene scene = FindClientScene(new UUID(im.toAgentID));
441 443
442 if (scene == null) 444 if (scene == null)
443 return; 445 return;
444 446
445 // Find agent to deliver to 447 // Find agent to deliver to
446 // 448 //
447 ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); 449 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
450 if (user == null)
451 return;
452
453 // This requires a little bit of processing because we have to make the
454 // new item visible in the recipient's inventory here
455 //
456 if (im.dialog == (byte) InstantMessageDialog.InventoryOffered)
457 {
458 if (im.binaryBucket.Length < 17) // Invalid
459 return;
460
461 UUID recipientID = new UUID(im.toAgentID);
462
463 // First byte is the asset type
464 AssetType assetType = (AssetType)im.binaryBucket[0];
465
466 if (AssetType.Folder == assetType)
467 {
468 UUID folderID = new UUID(im.binaryBucket, 1);
469
470 InventoryFolderBase given =
471 new InventoryFolderBase(folderID, recipientID);
472 InventoryFolderBase folder =
473 scene.InventoryService.GetFolder(given);
474
475 if (folder != null)
476 user.ControllingClient.SendBulkUpdateInventory(folder);
477 }
478 else
479 {
480 UUID itemID = new UUID(im.binaryBucket, 1);
448 481
449 // Just forward to local handling 482 InventoryItemBase given =
450 OnInstantMessage(user.ControllingClient, msg); 483 new InventoryItemBase(itemID, recipientID);
484 InventoryItemBase item =
485 scene.InventoryService.GetItem(given);
451 486
487 if (item != null)
488 {
489 user.ControllingClient.SendBulkUpdateInventory(item);
490 }
491 }
492 user.ControllingClient.SendInstantMessage(im);
493 }
494 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted ||
495 im.dialog == (byte) InstantMessageDialog.InventoryDeclined)
496 {
497 user.ControllingClient.SendInstantMessage(im);
498 }
452 } 499 }
453 } 500 }
454} 501}
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
index d295384..dcfdf8f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
@@ -155,16 +155,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
155 scene.RegionInfo.RegionHandle, 155 scene.RegionInfo.RegionHandle,
156 (uint)presence.AbsolutePosition.X, 156 (uint)presence.AbsolutePosition.X,
157 (uint)presence.AbsolutePosition.Y, 157 (uint)presence.AbsolutePosition.Y,
158 (uint)presence.AbsolutePosition.Z); 158 (uint)presence.AbsolutePosition.Z + 2);
159 159
160 m_log.DebugFormat("TP invite with message {0}", message); 160 m_log.DebugFormat("[LURE]: TP invite with message {0}", message);
161
162 GridInstantMessage m;
163
164 if (scene.Permissions.IsAdministrator(client.AgentId) && presence.GodLevel >= 200 && (!scene.Permissions.IsAdministrator(targetid)))
165 {
166 m = new GridInstantMessage(scene, client.AgentId,
167 client.FirstName+" "+client.LastName, targetid,
168 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
169 message, dest, false, presence.AbsolutePosition,
170 new Byte[0]);
171 }
172 else
173 {
174 m = new GridInstantMessage(scene, client.AgentId,
175 client.FirstName+" "+client.LastName, targetid,
176 (byte)InstantMessageDialog.RequestTeleport, false,
177 message, dest, false, presence.AbsolutePosition,
178 new Byte[0]);
179 }
161 180
162 GridInstantMessage m = new GridInstantMessage(scene, client.AgentId,
163 client.FirstName+" "+client.LastName, targetid,
164 (byte)InstantMessageDialog.RequestTeleport, false,
165 message, dest, false, presence.AbsolutePosition,
166 new Byte[0]);
167
168 if (m_TransferModule != null) 181 if (m_TransferModule != null)
169 { 182 {
170 m_TransferModule.SendInstantMessage(m, 183 m_TransferModule.SendInstantMessage(m,
@@ -199,7 +212,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
199 { 212 {
200 // Forward remote teleport requests 213 // Forward remote teleport requests
201 // 214 //
202 if (msg.dialog != 22) 215 if (msg.dialog != (byte)InstantMessageDialog.RequestTeleport &&
216 msg.dialog != (byte)InstantMessageDialog.GodLikeRequestTeleport)
203 return; 217 return;
204 218
205 if (m_TransferModule != null) 219 if (m_TransferModule != null)
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
index afbd902..babeaab 100644
--- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
@@ -98,7 +98,8 @@ namespace OpenSim.Region.CoreModules.Framework
98 98
99 public void CreateCaps(UUID agentId) 99 public void CreateCaps(UUID agentId)
100 { 100 {
101 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) 101 int flags = m_scene.GetUserFlags(agentId);
102 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
102 return; 103 return;
103 104
104 String capsObjectPath = GetCapsPath(agentId); 105 String capsObjectPath = GetCapsPath(agentId);
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index d01f89b..5431841 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -126,7 +126,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
126 126
127 protected virtual void OnNewClient(IClientAPI client) 127 protected virtual void OnNewClient(IClientAPI client)
128 { 128 {
129 client.OnTeleportHomeRequest += TeleportHome; 129 client.OnTeleportHomeRequest += TriggerTeleportHome;
130 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 130 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
131 } 131 }
132 132
@@ -204,6 +204,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
204 sp.ControllingClient.SendTeleportStart(teleportFlags); 204 sp.ControllingClient.SendTeleportStart(teleportFlags);
205 205
206 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); 206 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
207 sp.TeleportFlags = (TeleportFlags)teleportFlags;
207 sp.Teleport(position); 208 sp.Teleport(position);
208 209
209 foreach (SceneObjectGroup grp in sp.GetAttachments()) 210 foreach (SceneObjectGroup grp in sp.GetAttachments())
@@ -320,7 +321,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
320 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, 321 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
321 // it's actually doing a lot of work. 322 // it's actually doing a lot of work.
322 IPEndPoint endPoint = finalDestination.ExternalEndPoint; 323 IPEndPoint endPoint = finalDestination.ExternalEndPoint;
323 if (endPoint.Address != null) 324 if (endPoint != null && endPoint.Address != null)
324 { 325 {
325 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from 326 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
326 // both regions 327 // both regions
@@ -631,7 +632,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
631 632
632 #region Teleport Home 633 #region Teleport Home
633 634
634 public virtual void TeleportHome(UUID id, IClientAPI client) 635 public virtual void TriggerTeleportHome(UUID id, IClientAPI client)
636 {
637 TeleportHome(id, client);
638 }
639
640 public virtual bool TeleportHome(UUID id, IClientAPI client)
635 { 641 {
636 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); 642 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
637 643
@@ -640,12 +646,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
640 646
641 if (uinfo != null) 647 if (uinfo != null)
642 { 648 {
649 if (uinfo.HomeRegionID == UUID.Zero)
650 {
651 // can't find the Home region: Tell viewer and abort
652 client.SendTeleportFailed("You don't have a home position set.");
653 return false;
654 }
643 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); 655 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
644 if (regionInfo == null) 656 if (regionInfo == null)
645 { 657 {
646 // can't find the Home region: Tell viewer and abort 658 // can't find the Home region: Tell viewer and abort
647 client.SendTeleportFailed("Your home region could not be found."); 659 client.SendTeleportFailed("Your home region could not be found.");
648 return; 660 return false;
649 } 661 }
650 662
651 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})", 663 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})",
@@ -656,6 +668,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
656 client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt, 668 client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt,
657 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); 669 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
658 } 670 }
671 else
672 {
673 // can't find the Home region: Tell viewer and abort
674 client.SendTeleportFailed("Your home region could not be found.");
675 return false;
676 }
677 return true;
659 } 678 }
660 679
661 #endregion 680 #endregion
@@ -999,15 +1018,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
999 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); 1018 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
1000 1019
1001 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>(); 1020 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
1002 if (eq != null) 1021 IPEndPoint neighbourExternal = neighbourRegion.ExternalEndPoint;
1003 { 1022 if (neighbourExternal != null)
1004 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1005 capsPath, agent.UUID, agent.ControllingClient.SessionId);
1006 }
1007 else
1008 { 1023 {
1009 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, 1024 if (eq != null)
1010 capsPath); 1025 {
1026 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal,
1027 capsPath, agent.UUID, agent.ControllingClient.SessionId);
1028 }
1029 else
1030 {
1031 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal,
1032 capsPath);
1033 }
1011 } 1034 }
1012 1035
1013 if (!WaitForCallback(agent.UUID)) 1036 if (!WaitForCallback(agent.UUID))
@@ -1122,10 +1145,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1122 agent.Id0 = currentAgentCircuit.Id0; 1145 agent.Id0 = currentAgentCircuit.Id0;
1123 } 1146 }
1124 1147
1125 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 1148 IPEndPoint external = region.ExternalEndPoint;
1126 d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, 1149 if (external != null)
1150 {
1151 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1152 d.BeginInvoke(sp, agent, region, external, true,
1127 InformClientOfNeighbourCompleted, 1153 InformClientOfNeighbourCompleted,
1128 d); 1154 d);
1155 }
1129 } 1156 }
1130 #endregion 1157 #endregion
1131 1158
@@ -1259,6 +1286,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1259 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 1286 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1260 try 1287 try
1261 { 1288 {
1289 //neighbour.ExternalEndPoint may return null, which will be caught
1262 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, 1290 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
1263 InformClientOfNeighbourCompleted, 1291 InformClientOfNeighbourCompleted,
1264 d); 1292 d);
@@ -1362,8 +1390,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1362 1390
1363 m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); 1391 m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString());
1364 } 1392 }
1365 if (!regionAccepted)
1366 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Region {0} did not accept agent: {1}", reg.RegionName, reason);
1367 } 1393 }
1368 1394
1369 /// <summary> 1395 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index a87279a..6daae62 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
84 84
85 protected override void OnNewClient(IClientAPI client) 85 protected override void OnNewClient(IClientAPI client)
86 { 86 {
87 client.OnTeleportHomeRequest += TeleportHome; 87 client.OnTeleportHomeRequest += TriggerTeleportHome;
88 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 88 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
89 client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed); 89 client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed);
90 } 90 }
@@ -179,7 +179,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
179 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); 179 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
180 } 180 }
181 181
182 public override void TeleportHome(UUID id, IClientAPI client) 182 public void TriggerTeleportHome(UUID id, IClientAPI client)
183 {
184 TeleportHome(id, client);
185 }
186
187 public override bool TeleportHome(UUID id, IClientAPI client)
183 { 188 {
184 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); 189 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
185 190
@@ -189,8 +194,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
189 { 194 {
190 // local grid user 195 // local grid user
191 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); 196 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local");
192 base.TeleportHome(id, client); 197 return base.TeleportHome(id, client);
193 return;
194 } 198 }
195 199
196 // Foreign user wants to go home 200 // Foreign user wants to go home
@@ -200,7 +204,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
200 { 204 {
201 client.SendTeleportFailed("Your information has been lost"); 205 client.SendTeleportFailed("Your information has been lost");
202 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); 206 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information");
203 return; 207 return false;
204 } 208 }
205 209
206 IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); 210 IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString());
@@ -210,7 +214,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
210 { 214 {
211 client.SendTeleportFailed("Your home region could not be found"); 215 client.SendTeleportFailed("Your home region could not be found");
212 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); 216 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found");
213 return; 217 return false;
214 } 218 }
215 219
216 ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId); 220 ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId);
@@ -218,7 +222,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
218 { 222 {
219 client.SendTeleportFailed("Internal error"); 223 client.SendTeleportFailed("Internal error");
220 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be"); 224 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be");
221 return; 225 return false;
222 } 226 }
223 227
224 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); 228 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
@@ -228,6 +232,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
228 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName); 232 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName);
229 233
230 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq); 234 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq);
235 return true;
231 } 236 }
232 237
233 /// <summary> 238 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 54b422b..12555b7 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -477,7 +477,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
477 { 477 {
478 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; 478 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7;
479 foreach (SceneObjectGroup grp in objsForEffectivePermissions) 479 foreach (SceneObjectGroup grp in objsForEffectivePermissions)
480 effectivePerms &= grp.GetEffectivePermissions(); 480 effectivePerms &= grp.GetEffectivePermissions(true);
481 effectivePerms |= (uint)PermissionMask.Move; 481 effectivePerms |= (uint)PermissionMask.Move;
482 482
483 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 483 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
@@ -674,19 +674,21 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
674 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) 674 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
675 { 675 {
676// m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); 676// m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID);
677
678 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 677 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
679 item = m_Scene.InventoryService.GetItem(item); 678 item = m_Scene.InventoryService.GetItem(item);
680 679
681 if (item == null) 680 if (item == null)
682 { 681 {
683 m_log.WarnFormat(
684 "[InventoryAccessModule]: Could not find item {0} for {1} in RezObject()",
685 itemID, remoteClient.Name);
686 682
687 return null; 683 return null;
688 } 684 }
689 685
686
687
688
689
690
691
690 item.Owner = remoteClient.AgentId; 692 item.Owner = remoteClient.AgentId;
691 693
692 return RezObject( 694 return RezObject(
@@ -784,10 +786,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
784 786
785 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, attachment)) 787 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, attachment))
786 return null; 788 return null;
787
788 for (int i = 0; i < objlist.Count; i++) 789 for (int i = 0; i < objlist.Count; i++)
789 { 790 {
790 group = objlist[i]; 791 group = objlist[i];
792 SceneObjectPart rootPart = group.RootPart;
791 793
792// Vector3 storedPosition = group.AbsolutePosition; 794// Vector3 storedPosition = group.AbsolutePosition;
793 if (group.UUID == UUID.Zero) 795 if (group.UUID == UUID.Zero)
@@ -842,8 +844,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
842 844
843 if (!attachment) 845 if (!attachment)
844 { 846 {
845 SceneObjectPart rootPart = group.RootPart;
846
847 if (rootPart.Shape.PCode == (byte)PCode.Prim) 847 if (rootPart.Shape.PCode == (byte)PCode.Prim)
848 group.ClearPartAttachmentData(); 848 group.ClearPartAttachmentData();
849 849
@@ -854,11 +854,47 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
854 rootPart.ScheduleFullUpdate(); 854 rootPart.ScheduleFullUpdate();
855 } 855 }
856 856
857 if ((rootPart.OwnerID != item.Owner) ||
858 (item.CurrentPermissions & 16) != 0 || // Magic number
859 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
860 {
861 //Need to kill the for sale here
862 rootPart.ObjectSaleType = 0;
863 rootPart.SalePrice = 10;
864
865 if (m_Scene.Permissions.PropagatePermissions())
866 {
867 foreach (SceneObjectPart part in group.Parts)
868 {
869 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
870 {
871 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
872 part.EveryoneMask = item.EveryOnePermissions;
873 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
874 part.NextOwnerMask = item.NextPermissions;
875 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
876 part.GroupMask = item.GroupPermissions;
877 }
878 }
879
880 foreach (SceneObjectPart part in group.Parts)
881 {
882 part.LastOwnerID = part.OwnerID;
883 part.OwnerID = item.Owner;
884 part.Inventory.ChangeInventoryOwner(item.Owner);
885 }
886
887 group.ApplyNextOwnerPermissions();
888 }
889 }
890
857// m_log.DebugFormat( 891// m_log.DebugFormat(
858// "[InventoryAccessModule]: Rezzed {0} {1} {2} for {3}", 892// "[InventoryAccessModule]: Rezzed {0} {1} {2} for {3}",
859// group.Name, group.LocalId, group.UUID, remoteClient.Name); 893// group.Name, group.LocalId, group.UUID, remoteClient.Name);
860 } 894 }
861 895
896 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
897 // TODO: Remove the magic number badness
862 if (item != null) 898 if (item != null)
863 DoPostRezWhenFromItem(item, attachment); 899 DoPostRezWhenFromItem(item, attachment);
864 900
@@ -1111,4 +1147,4 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1111 1147
1112 #endregion 1148 #endregion
1113 } 1149 }
1114} \ No newline at end of file 1150}
diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
index cabbd31..41a80ce 100644
--- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
+++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
@@ -162,7 +162,8 @@ namespace OpenSim.Region.CoreModules.World.LightShare
162 162
163 private void EventManager_OnMakeRootAgent(ScenePresence presence) 163 private void EventManager_OnMakeRootAgent(ScenePresence presence)
164 { 164 {
165 m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); 165 if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
166 m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
166 SendProfileToClient(presence.ControllingClient); 167 SendProfileToClient(presence.ControllingClient);
167 } 168 }
168 169
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index 43672d1..5e28ee1 100644
--- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -366,6 +366,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
366 try 366 try
367 { 367 {
368 Request = (HttpWebRequest) WebRequest.Create(Url); 368 Request = (HttpWebRequest) WebRequest.Create(Url);
369
370 //This works around some buggy HTTP Servers like Lighttpd
371 Request.ServicePoint.Expect100Continue = false;
372
369 Request.Method = HttpMethod; 373 Request.Method = HttpMethod;
370 Request.ContentType = HttpMIMEType; 374 Request.ContentType = HttpMIMEType;
371 375
@@ -440,7 +444,17 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
440 { 444 {
441 HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response; 445 HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response;
442 Status = (int)webRsp.StatusCode; 446 Status = (int)webRsp.StatusCode;
443 ResponseBody = webRsp.StatusDescription; 447 try
448 {
449 using (Stream responseStream = webRsp.GetResponseStream())
450 {
451 ResponseBody = responseStream.GetStreamString();
452 }
453 }
454 catch
455 {
456 ResponseBody = webRsp.StatusDescription;
457 }
444 } 458 }
445 else 459 else
446 { 460 {
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 7377ceb..458426b 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -61,6 +61,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
61 //public ManualResetEvent ev; 61 //public ManualResetEvent ev;
62 public bool requestDone; 62 public bool requestDone;
63 public int startTime; 63 public int startTime;
64 public bool responseSent;
64 public string uri; 65 public string uri;
65 } 66 }
66 67
@@ -77,7 +78,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
77 new Dictionary<string, UrlData>(); 78 new Dictionary<string, UrlData>();
78 79
79 80
80 private int m_TotalUrls = 100; 81 private int m_TotalUrls = 5000;
81 82
82 private uint https_port = 0; 83 private uint https_port = 0;
83 private IHttpServer m_HttpServer = null; 84 private IHttpServer m_HttpServer = null;
@@ -156,7 +157,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
156 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 157 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
157 return urlcode; 158 return urlcode;
158 } 159 }
159 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; 160 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString();
160 161
161 UrlData urlData = new UrlData(); 162 UrlData urlData = new UrlData();
162 urlData.hostID = host.UUID; 163 urlData.hostID = host.UUID;
@@ -166,10 +167,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
166 urlData.urlcode = urlcode; 167 urlData.urlcode = urlcode;
167 urlData.requests = new Dictionary<UUID, RequestData>(); 168 urlData.requests = new Dictionary<UUID, RequestData>();
168 169
169
170 m_UrlMap[url] = urlData; 170 m_UrlMap[url] = urlData;
171 171
172 string uri = "/lslhttp/" + urlcode.ToString() + "/"; 172 string uri = "/lslhttp/" + urlcode.ToString();
173 173
174 m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, 174 m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll,
175 new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, 175 new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents,
@@ -234,9 +234,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
234 return; 234 return;
235 } 235 }
236 236
237 foreach (UUID req in data.requests.Keys) 237 lock (m_RequestMap)
238 m_RequestMap.Remove(req); 238 {
239 239 foreach (UUID req in data.requests.Keys)
240 m_RequestMap.Remove(req);
241 }
242
240 RemoveUrl(data); 243 RemoveUrl(data);
241 m_UrlMap.Remove(url); 244 m_UrlMap.Remove(url);
242 } 245 }
@@ -244,32 +247,42 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
244 247
245 public void HttpResponse(UUID request, int status, string body) 248 public void HttpResponse(UUID request, int status, string body)
246 { 249 {
247 if (m_RequestMap.ContainsKey(request)) 250 lock (m_RequestMap)
248 {
249 UrlData urlData = m_RequestMap[request];
250 urlData.requests[request].responseCode = status;
251 urlData.requests[request].responseBody = body;
252 //urlData.requests[request].ev.Set();
253 urlData.requests[request].requestDone =true;
254 }
255 else
256 { 251 {
257 m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); 252 if (m_RequestMap.ContainsKey(request))
253 {
254 UrlData urlData = m_RequestMap[request];
255 if (!urlData.requests[request].responseSent)
256 {
257 urlData.requests[request].responseCode = status;
258 urlData.requests[request].responseBody = body;
259 //urlData.requests[request].ev.Set();
260 urlData.requests[request].requestDone = true;
261 urlData.requests[request].responseSent = true;
262 }
263 }
264 else
265 {
266 m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
267 }
258 } 268 }
259 } 269 }
260 270
261 public string GetHttpHeader(UUID requestId, string header) 271 public string GetHttpHeader(UUID requestId, string header)
262 { 272 {
263 if (m_RequestMap.ContainsKey(requestId)) 273 lock (m_RequestMap)
264 {
265 UrlData urlData=m_RequestMap[requestId];
266 string value;
267 if (urlData.requests[requestId].headers.TryGetValue(header,out value))
268 return value;
269 }
270 else
271 { 274 {
272 m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); 275 if (m_RequestMap.ContainsKey(requestId))
276 {
277 UrlData urlData = m_RequestMap[requestId];
278 string value;
279 if (urlData.requests[requestId].headers.TryGetValue(header, out value))
280 return value;
281 }
282 else
283 {
284 m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId);
285 }
273 } 286 }
274 return String.Empty; 287 return String.Empty;
275 } 288 }
@@ -291,8 +304,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
291 { 304 {
292 RemoveUrl(url.Value); 305 RemoveUrl(url.Value);
293 removeURLs.Add(url.Key); 306 removeURLs.Add(url.Key);
294 foreach (UUID req in url.Value.requests.Keys) 307 lock (m_RequestMap)
295 m_RequestMap.Remove(req); 308 {
309 foreach (UUID req in url.Value.requests.Keys)
310 m_RequestMap.Remove(req);
311 }
296 } 312 }
297 } 313 }
298 314
@@ -313,8 +329,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
313 { 329 {
314 RemoveUrl(url.Value); 330 RemoveUrl(url.Value);
315 removeURLs.Add(url.Key); 331 removeURLs.Add(url.Key);
316 foreach (UUID req in url.Value.requests.Keys) 332 lock (m_RequestMap)
317 m_RequestMap.Remove(req); 333 {
334 foreach (UUID req in url.Value.requests.Keys)
335 m_RequestMap.Remove(req);
336 }
318 } 337 }
319 } 338 }
320 339
@@ -333,14 +352,16 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
333 { 352 {
334 Hashtable response = new Hashtable(); 353 Hashtable response = new Hashtable();
335 UrlData url; 354 UrlData url;
355 int startTime = 0;
336 lock (m_RequestMap) 356 lock (m_RequestMap)
337 { 357 {
338 if (!m_RequestMap.ContainsKey(requestID)) 358 if (!m_RequestMap.ContainsKey(requestID))
339 return response; 359 return response;
340 url = m_RequestMap[requestID]; 360 url = m_RequestMap[requestID];
361 startTime = url.requests[requestID].startTime;
341 } 362 }
342 363
343 if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) 364 if (System.Environment.TickCount - startTime > 25000)
344 { 365 {
345 response["int_response_code"] = 500; 366 response["int_response_code"] = 500;
346 response["str_response_string"] = "Script timeout"; 367 response["str_response_string"] = "Script timeout";
@@ -349,9 +370,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
349 response["reusecontext"] = false; 370 response["reusecontext"] = false;
350 371
351 //remove from map 372 //remove from map
352 lock (url) 373 lock (url.requests)
353 { 374 {
354 url.requests.Remove(requestID); 375 url.requests.Remove(requestID);
376 }
377 lock (m_RequestMap)
378 {
355 m_RequestMap.Remove(requestID); 379 m_RequestMap.Remove(requestID);
356 } 380 }
357 381
@@ -373,22 +397,25 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
373 return false; 397 return false;
374 } 398 }
375 url = m_RequestMap[requestID]; 399 url = m_RequestMap[requestID];
400 }
401 lock (url.requests)
402 {
376 if (!url.requests.ContainsKey(requestID)) 403 if (!url.requests.ContainsKey(requestID))
377 { 404 {
378 return false; 405 return false;
379 } 406 }
407 else
408 {
409 if (System.Environment.TickCount - url.requests[requestID].startTime > 25000)
410 {
411 return true;
412 }
413 if (url.requests[requestID].requestDone)
414 return true;
415 else
416 return false;
417 }
380 } 418 }
381
382 if (System.Environment.TickCount-url.requests[requestID].startTime>25000)
383 {
384 return true;
385 }
386
387 if (url.requests[requestID].requestDone)
388 return true;
389 else
390 return false;
391
392 } 419 }
393 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) 420 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request)
394 { 421 {
@@ -400,9 +427,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
400 if (!m_RequestMap.ContainsKey(requestID)) 427 if (!m_RequestMap.ContainsKey(requestID))
401 return NoEvents(requestID,sessionID); 428 return NoEvents(requestID,sessionID);
402 url = m_RequestMap[requestID]; 429 url = m_RequestMap[requestID];
430 }
431 lock (url.requests)
432 {
403 requestData = url.requests[requestID]; 433 requestData = url.requests[requestID];
404 } 434 }
405 435
406 if (!requestData.requestDone) 436 if (!requestData.requestDone)
407 return NoEvents(requestID,sessionID); 437 return NoEvents(requestID,sessionID);
408 438
@@ -425,14 +455,18 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
425 response["reusecontext"] = false; 455 response["reusecontext"] = false;
426 456
427 //remove from map 457 //remove from map
428 lock (url) 458 lock (url.requests)
429 { 459 {
430 url.requests.Remove(requestID); 460 url.requests.Remove(requestID);
461 }
462 lock (m_RequestMap)
463 {
431 m_RequestMap.Remove(requestID); 464 m_RequestMap.Remove(requestID);
432 } 465 }
433 466
434 return response; 467 return response;
435 } 468 }
469
436 public void HttpRequestHandler(UUID requestID, Hashtable request) 470 public void HttpRequestHandler(UUID requestID, Hashtable request)
437 { 471 {
438 lock (request) 472 lock (request)
@@ -448,8 +482,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
448 482
449 int pos1 = uri.IndexOf("/");// /lslhttp 483 int pos1 = uri.IndexOf("/");// /lslhttp
450 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ 484 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/
451 int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/ 485 int pos3 = pos2 + 37; // /lslhttp/urlcode
452 string uri_tmp = uri.Substring(0, pos3 + 1); 486 string uri_tmp = uri.Substring(0, pos3);
453 //HTTP server code doesn't provide us with QueryStrings 487 //HTTP server code doesn't provide us with QueryStrings
454 string pathInfo; 488 string pathInfo;
455 string queryString; 489 string queryString;
@@ -458,10 +492,21 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
458 pathInfo = uri.Substring(pos3); 492 pathInfo = uri.Substring(pos3);
459 493
460 UrlData url = null; 494 UrlData url = null;
495 string urlkey;
461 if (!is_ssl) 496 if (!is_ssl)
462 url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; 497 urlkey = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp;
498 //m_UrlMap[];
463 else 499 else
464 url = m_UrlMap["https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp]; 500 urlkey = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp;
501
502 if (m_UrlMap.ContainsKey(urlkey))
503 {
504 url = m_UrlMap[urlkey];
505 }
506 else
507 {
508 m_log.Warn("[HttpRequestHandler]: http-in request failed; no such url: "+urlkey.ToString());
509 }
465 510
466 //for llGetHttpHeader support we need to store original URI here 511 //for llGetHttpHeader support we need to store original URI here
467 //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers 512 //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers
@@ -491,7 +536,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
491 if (request.ContainsKey(key)) 536 if (request.ContainsKey(key))
492 { 537 {
493 string val = (String)request[key]; 538 string val = (String)request[key];
494 queryString = queryString + key + "=" + val + "&"; 539 if (key != "")
540 {
541 queryString = queryString + key + "=" + val + "&";
542 }
543 else
544 {
545 queryString = queryString + val + "&";
546 }
495 } 547 }
496 } 548 }
497 if (queryString.Length > 1) 549 if (queryString.Length > 1)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index a17c6ae..faa1def 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -271,7 +271,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
271 if (s.RegionInfo.RegionID == destination.RegionID) 271 if (s.RegionInfo.RegionID == destination.RegionID)
272 return s.QueryAccess(id, position, out reason); 272 return s.QueryAccess(id, position, out reason);
273 } 273 }
274 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
275 return false; 274 return false;
276 } 275 }
277 276
@@ -301,10 +300,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
301 if (s.RegionInfo.RegionID == destination.RegionID) 300 if (s.RegionInfo.RegionID == destination.RegionID)
302 { 301 {
303 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); 302 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
304 // Let's spawn a threadlet right here, because this may take 303 return s.IncomingCloseAgent(id);
305 // a while 304 }
306 Util.FireAndForget(delegate { s.IncomingCloseAgent(id); }); 305 }
307 return true; 306 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
307 return false;
308 }
309
310 public bool CloseChildAgent(GridRegion destination, UUID id)
311 {
312 if (destination == null)
313 return false;
314
315 foreach (Scene s in m_sceneList)
316 {
317 if (s.RegionInfo.RegionID == destination.RegionID)
318 {
319 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
320 return s.IncomingCloseChildAgent(id);
308 } 321 }
309 } 322 }
310 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); 323 //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 f8cea71..391b1a1 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -261,6 +261,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
261 return false; 261 return false;
262 } 262 }
263 263
264 public bool CloseChildAgent(GridRegion destination, UUID id)
265 {
266 if (destination == null)
267 return false;
268
269 // Try local first
270 if (m_localBackend.CloseChildAgent(destination, id))
271 return true;
272
273 // else do the remote thing
274 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
275 return m_remoteConnector.CloseChildAgent(destination, id);
276
277 return false;
278 }
264 279
265 public bool CloseAgent(GridRegion destination, UUID id) 280 public bool CloseAgent(GridRegion destination, UUID id)
266 { 281 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
index 0a0ce3c..1ffd480 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
@@ -127,6 +127,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
127 // FIXME: Why do we bother setting this module and caching up if we just end up registering the inner 127 // FIXME: Why do we bother setting this module and caching up if we just end up registering the inner
128 // user account service?! 128 // user account service?!
129 scene.RegisterModuleInterface<IUserAccountService>(UserAccountService); 129 scene.RegisterModuleInterface<IUserAccountService>(UserAccountService);
130 scene.RegisterModuleInterface<IUserAccountCacheModule>(m_Cache);
130 } 131 }
131 132
132 public void RemoveRegion(Scene scene) 133 public void RemoveRegion(Scene scene)
@@ -179,6 +180,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
179 return UserAccountService.GetUserAccount(scopeID, Email); 180 return UserAccountService.GetUserAccount(scopeID, Email);
180 } 181 }
181 182
183 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
184 {
185 return null;
186 }
187
182 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 188 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
183 { 189 {
184 return UserAccountService.GetUserAccounts(scopeID, query); 190 return UserAccountService.GetUserAccounts(scopeID, query);
@@ -193,4 +199,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
193 199
194 #endregion 200 #endregion
195 } 201 }
196} \ No newline at end of file 202}
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 587d260..238863e 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -292,6 +292,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver
292 // being no copy/no mod for everyone 292 // being no copy/no mod for everyone
293 lock (part.TaskInventory) 293 lock (part.TaskInventory)
294 { 294 {
295 if (!ResolveUserUuid(part.CreatorID))
296 part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
297
298 if (!ResolveUserUuid(part.OwnerID))
299 part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
300
301 if (!ResolveUserUuid(part.LastOwnerID))
302 part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
303
304 // And zap any troublesome sit target information
305 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
306 part.SitTargetPosition = new Vector3(0, 0, 0);
307
308 // Fix ownership/creator of inventory items
309 // Not doing so results in inventory items
310 // being no copy/no mod for everyone
311 part.TaskInventory.LockItemsForRead(true);
295 TaskInventoryDictionary inv = part.TaskInventory; 312 TaskInventoryDictionary inv = part.TaskInventory;
296 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) 313 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
297 { 314 {
@@ -307,6 +324,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
307 if (UserManager != null) 324 if (UserManager != null)
308 UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData); 325 UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData);
309 } 326 }
327 part.TaskInventory.LockItemsForRead(false);
310 } 328 }
311 } 329 }
312 330
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index 948aac8..900260d 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -251,18 +251,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver
251 251
252 if (asset != null) 252 if (asset != null)
253 { 253 {
254 if (m_options.ContainsKey("verbose")) 254// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
255 m_log.InfoFormat("[ARCHIVER]: Writing asset {0}", id);
256
257 m_foundAssetUuids.Add(asset.FullID); 255 m_foundAssetUuids.Add(asset.FullID);
258 256
259 m_assetsArchiver.WriteAsset(PostProcess(asset)); 257 m_assetsArchiver.WriteAsset(PostProcess(asset));
260 } 258 }
261 else 259 else
262 { 260 {
263 if (m_options.ContainsKey("verbose")) 261// m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id);
264 m_log.InfoFormat("[ARCHIVER]: Recording asset {0} as not found", id);
265
266 m_notFoundAssetUuids.Add(new UUID(id)); 262 m_notFoundAssetUuids.Add(new UUID(id));
267 } 263 }
268 264
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 58d9455..0067615 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
@@ -60,8 +62,15 @@ namespace OpenSim.Region.CoreModules.World.Estate
60 62
61 #region Packet Data Responders 63 #region Packet Data Responders
62 64
65 private void clientSendDetailedEstateData(IClientAPI remote_client, UUID invoice)
66 {
67 sendDetailedEstateData(remote_client, invoice);
68 sendEstateLists(remote_client, invoice);
69 }
70
63 private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) 71 private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice)
64 { 72 {
73 m_log.DebugFormat("[ESTATE]: Invoice is {0}", invoice.ToString());
65 uint sun = 0; 74 uint sun = 0;
66 75
67 if (!Scene.RegionInfo.EstateSettings.UseGlobalTime) 76 if (!Scene.RegionInfo.EstateSettings.UseGlobalTime)
@@ -81,7 +90,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
81 Scene.RegionInfo.RegionSettings.Covenant, 90 Scene.RegionInfo.RegionSettings.Covenant,
82 Scene.RegionInfo.EstateSettings.AbuseEmail, 91 Scene.RegionInfo.EstateSettings.AbuseEmail,
83 estateOwner); 92 estateOwner);
93 }
84 94
95 private void sendEstateLists(IClientAPI remote_client, UUID invoice)
96 {
85 remote_client.SendEstateList(invoice, 97 remote_client.SendEstateList(invoice,
86 (int)Constants.EstateAccessCodex.EstateManagers, 98 (int)Constants.EstateAccessCodex.EstateManagers,
87 Scene.RegionInfo.EstateSettings.EstateManagers, 99 Scene.RegionInfo.EstateSettings.EstateManagers,
@@ -256,7 +268,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
256 timeInSeconds -= 15; 268 timeInSeconds -= 15;
257 } 269 }
258 270
259 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); 271 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), false);
260 } 272 }
261 } 273 }
262 274
@@ -463,7 +475,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
463 { 475 {
464 if (!s.IsChildAgent) 476 if (!s.IsChildAgent)
465 { 477 {
466 Scene.TeleportClientHome(user, s.ControllingClient); 478 if (!Scene.TeleportClientHome(user, s.ControllingClient))
479 {
480 s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
481 s.ControllingClient.Close();
482 }
467 } 483 }
468 } 484 }
469 485
@@ -472,7 +488,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
472 { 488 {
473 remote_client.SendAlertMessage("User is already on the region ban list"); 489 remote_client.SendAlertMessage("User is already on the region ban list");
474 } 490 }
475 //m_scene.RegionInfo.regionBanlist.Add(Manager(user); 491 //Scene.RegionInfo.regionBanlist.Add(Manager(user);
476 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); 492 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
477 } 493 }
478 else 494 else
@@ -527,7 +543,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
527 remote_client.SendAlertMessage("User is not on the region ban list"); 543 remote_client.SendAlertMessage("User is not on the region ban list");
528 } 544 }
529 545
530 //m_scene.RegionInfo.regionBanlist.Add(Manager(user); 546 //Scene.RegionInfo.regionBanlist.Add(Manager(user);
531 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); 547 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
532 } 548 }
533 else 549 else
@@ -648,7 +664,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
648 ScenePresence s = Scene.GetScenePresence(prey); 664 ScenePresence s = Scene.GetScenePresence(prey);
649 if (s != null) 665 if (s != null)
650 { 666 {
651 Scene.TeleportClientHome(prey, s.ControllingClient); 667 if (!Scene.TeleportClientHome(prey, s.ControllingClient))
668 {
669 s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
670 s.ControllingClient.Close();
671 }
652 } 672 }
653 } 673 }
654 } 674 }
@@ -666,7 +686,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
666 // Also make sure they are actually in the region 686 // Also make sure they are actually in the region
667 ScenePresence p; 687 ScenePresence p;
668 if(Scene.TryGetScenePresence(client.AgentId, out p)) 688 if(Scene.TryGetScenePresence(client.AgentId, out p))
669 Scene.TeleportClientHome(p.UUID, p.ControllingClient); 689 {
690 if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient))
691 {
692 p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
693 p.ControllingClient.Close();
694 }
695 }
670 } 696 }
671 }); 697 });
672 } 698 }
@@ -910,7 +936,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
910 936
911 for (int i = 0; i < uuidarr.Length; i++) 937 for (int i = 0; i < uuidarr.Length; i++)
912 { 938 {
913 // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]); 939 // string lookupname = Scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
914 940
915 IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>(); 941 IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>();
916 if (userManager != null) 942 if (userManager != null)
@@ -1051,6 +1077,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
1051 1077
1052 public void AddRegion(Scene scene) 1078 public void AddRegion(Scene scene)
1053 { 1079 {
1080 m_regionChangeTimer.AutoReset = false;
1081 m_regionChangeTimer.Interval = 2000;
1082 m_regionChangeTimer.Elapsed += RaiseRegionInfoChange;
1083
1054 Scene = scene; 1084 Scene = scene;
1055 Scene.RegisterModuleInterface<IEstateModule>(this); 1085 Scene.RegisterModuleInterface<IEstateModule>(this);
1056 Scene.EventManager.OnNewClient += EventManager_OnNewClient; 1086 Scene.EventManager.OnNewClient += EventManager_OnNewClient;
@@ -1099,7 +1129,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
1099 1129
1100 private void EventManager_OnNewClient(IClientAPI client) 1130 private void EventManager_OnNewClient(IClientAPI client)
1101 { 1131 {
1102 client.OnDetailedEstateDataRequest += sendDetailedEstateData; 1132 client.OnDetailedEstateDataRequest += clientSendDetailedEstateData;
1103 client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler; 1133 client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler;
1104// client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture; 1134// client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture;
1105 client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture; 1135 client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture;
@@ -1150,6 +1180,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
1150 flags |= RegionFlags.AllowParcelChanges; 1180 flags |= RegionFlags.AllowParcelChanges;
1151 if (Scene.RegionInfo.RegionSettings.BlockShowInSearch) 1181 if (Scene.RegionInfo.RegionSettings.BlockShowInSearch)
1152 flags |= RegionFlags.BlockParcelSearch; 1182 flags |= RegionFlags.BlockParcelSearch;
1183 if (Scene.RegionInfo.RegionSettings.GodBlockSearch)
1184 flags |= (RegionFlags)(1 << 11);
1185 if (Scene.RegionInfo.RegionSettings.Casino)
1186 flags |= (RegionFlags)(1 << 10);
1153 1187
1154 if (Scene.RegionInfo.RegionSettings.FixedSun) 1188 if (Scene.RegionInfo.RegionSettings.FixedSun)
1155 flags |= RegionFlags.SunFixed; 1189 flags |= RegionFlags.SunFixed;
@@ -1157,11 +1191,15 @@ namespace OpenSim.Region.CoreModules.World.Estate
1157 flags |= RegionFlags.Sandbox; 1191 flags |= RegionFlags.Sandbox;
1158 if (Scene.RegionInfo.EstateSettings.AllowVoice) 1192 if (Scene.RegionInfo.EstateSettings.AllowVoice)
1159 flags |= RegionFlags.AllowVoice; 1193 flags |= RegionFlags.AllowVoice;
1194 if (Scene.RegionInfo.EstateSettings.AllowLandmark)
1195 flags |= RegionFlags.AllowLandmark;
1196 if (Scene.RegionInfo.EstateSettings.AllowSetHome)
1197 flags |= RegionFlags.AllowSetHome;
1198 if (Scene.RegionInfo.EstateSettings.BlockDwell)
1199 flags |= RegionFlags.BlockDwell;
1200 if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
1201 flags |= RegionFlags.ResetHomeOnTeleport;
1160 1202
1161 // Fudge these to always on, so the menu options activate
1162 //
1163 flags |= RegionFlags.AllowLandmark;
1164 flags |= RegionFlags.AllowSetHome;
1165 1203
1166 // TODO: SkipUpdateInterestList 1204 // TODO: SkipUpdateInterestList
1167 1205
@@ -1202,6 +1240,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
1202 flags |= RegionFlags.ResetHomeOnTeleport; 1240 flags |= RegionFlags.ResetHomeOnTeleport;
1203 if (Scene.RegionInfo.EstateSettings.TaxFree) 1241 if (Scene.RegionInfo.EstateSettings.TaxFree)
1204 flags |= RegionFlags.TaxFree; 1242 flags |= RegionFlags.TaxFree;
1243 if (Scene.RegionInfo.EstateSettings.AllowLandmark)
1244 flags |= RegionFlags.AllowLandmark;
1245 if (Scene.RegionInfo.EstateSettings.AllowParcelChanges)
1246 flags |= RegionFlags.AllowParcelChanges;
1247 if (Scene.RegionInfo.EstateSettings.AllowSetHome)
1248 flags |= RegionFlags.AllowSetHome;
1205 if (Scene.RegionInfo.EstateSettings.DenyMinors) 1249 if (Scene.RegionInfo.EstateSettings.DenyMinors)
1206 flags |= (RegionFlags)(1 << 30); 1250 flags |= (RegionFlags)(1 << 30);
1207 1251
@@ -1222,6 +1266,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
1222 1266
1223 public void TriggerRegionInfoChange() 1267 public void TriggerRegionInfoChange()
1224 { 1268 {
1269 m_regionChangeTimer.Stop();
1270 m_regionChangeTimer.Start();
1271 }
1272
1273 protected void RaiseRegionInfoChange(object sender, ElapsedEventArgs e)
1274 {
1225 ChangeDelegate change = OnRegionInfoChange; 1275 ChangeDelegate change = OnRegionInfoChange;
1226 1276
1227 if (change != null) 1277 if (change != null)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 2117827..474905a 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -91,6 +91,8 @@ namespace OpenSim.Region.CoreModules.World.Land
91 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 91 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
92 92
93 private bool m_allowedForcefulBans = true; 93 private bool m_allowedForcefulBans = true;
94 private UUID DefaultGodParcelGroup;
95 private string DefaultGodParcelName;
94 96
95 // caches ExtendedLandData 97 // caches ExtendedLandData
96 private Cache parcelInfoCache; 98 private Cache parcelInfoCache;
@@ -106,6 +108,12 @@ namespace OpenSim.Region.CoreModules.World.Land
106 108
107 public void Initialise(IConfigSource source) 109 public void Initialise(IConfigSource source)
108 { 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 }
109 } 117 }
110 118
111 public void AddRegion(Scene scene) 119 public void AddRegion(Scene scene)
@@ -157,13 +165,6 @@ namespace OpenSim.Region.CoreModules.World.Land
157 m_scene.UnregisterModuleCommander(m_commander.Name); 165 m_scene.UnregisterModuleCommander(m_commander.Name);
158 } 166 }
159 167
160// private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
161// {
162// ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
163// reason = "You are not allowed to enter this sim.";
164// return nearestParcel != null;
165// }
166
167 /// <summary> 168 /// <summary>
168 /// Processes commandline input. Do not call directly. 169 /// Processes commandline input. Do not call directly.
169 /// </summary> 170 /// </summary>
@@ -215,36 +216,6 @@ namespace OpenSim.Region.CoreModules.World.Land
215 216
216 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 217 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
217 { 218 {
218 //If we are forcing a position for them to go
219 if (forcedPosition.ContainsKey(remoteClient.AgentId))
220 {
221 ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
222
223 //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
224 //When the avatar walks into a ban line on the ground, it prevents getting stuck
225 agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
226
227
228 //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
229 if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2)
230 {
231 Debug.WriteLine(string.Format("Stopping force position because {0} is close enough to position {1}", forcedPosition[remoteClient.AgentId], clientAvatar.AbsolutePosition));
232 forcedPosition.Remove(remoteClient.AgentId);
233 }
234 //if we are far away, teleport
235 else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3)
236 {
237 Debug.WriteLine(string.Format("Teleporting out because {0} is too far from avatar position {1}", forcedPosition[remoteClient.AgentId], clientAvatar.AbsolutePosition));
238 clientAvatar.Teleport(forcedPosition[remoteClient.AgentId]);
239 forcedPosition.Remove(remoteClient.AgentId);
240 }
241 else
242 {
243 //Forces them toward the forced position we want if they aren't there yet
244 agentData.UseClientAgentPosition = true;
245 agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId];
246 }
247 }
248 } 219 }
249 220
250 public void Close() 221 public void Close()
@@ -363,10 +334,16 @@ namespace OpenSim.Region.CoreModules.World.Land
363 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) 334 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
364 { 335 {
365 if (m_scene.Permissions.IsGod(avatar.UUID)) return; 336 if (m_scene.Permissions.IsGod(avatar.UUID)) return;
366 if (position.HasValue) 337
367 { 338 if (!position.HasValue)
368 forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; 339 return;
369 } 340
341 bool isFlying = avatar.PhysicsActor.Flying;
342 avatar.RemoveFromPhysicalScene();
343
344 avatar.AbsolutePosition = (Vector3)position;
345
346 avatar.AddToPhysicalScene(isFlying);
370 } 347 }
371 348
372 public void SendYouAreRestrictedNotice(ScenePresence avatar) 349 public void SendYouAreRestrictedNotice(ScenePresence avatar)
@@ -386,29 +363,7 @@ namespace OpenSim.Region.CoreModules.World.Land
386 } 363 }
387 364
388 if (parcelAvatarIsEntering != null) 365 if (parcelAvatarIsEntering != null)
389 { 366 EnforceBans(parcelAvatarIsEntering, avatar);
390 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
391 {
392 if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
393 {
394 SendYouAreBannedNotice(avatar);
395 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
396 }
397 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
398 {
399 SendYouAreRestrictedNotice(avatar);
400 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
401 }
402 else
403 {
404 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
405 }
406 }
407 else
408 {
409 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
410 }
411 }
412 } 367 }
413 } 368 }
414 369
@@ -512,6 +467,7 @@ namespace OpenSim.Region.CoreModules.World.Land
512 //when we are finally in a safe place, lets release the forced position lock 467 //when we are finally in a safe place, lets release the forced position lock
513 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); 468 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
514 } 469 }
470 EnforceBans(parcel, clientAvatar);
515 } 471 }
516 } 472 }
517 473
@@ -720,7 +676,7 @@ namespace OpenSim.Region.CoreModules.World.Land
720 int x; 676 int x;
721 int y; 677 int y;
722 678
723 if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) 679 if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0)
724 return null; 680 return null;
725 681
726 try 682 try
@@ -770,14 +726,13 @@ namespace OpenSim.Region.CoreModules.World.Land
770 { 726 {
771 try 727 try
772 { 728 {
773 return m_landList[m_landIDList[x / 4, y / 4]]; 729 //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4]))
730 return m_landList[m_landIDList[x / 4, y / 4]];
731 //else
732 // return null;
774 } 733 }
775 catch (IndexOutOfRangeException) 734 catch (IndexOutOfRangeException)
776 { 735 {
777// m_log.WarnFormat(
778// "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}",
779// x, y, m_scene.RegionInfo.RegionName);
780
781 return null; 736 return null;
782 } 737 }
783 } 738 }
@@ -1060,6 +1015,10 @@ namespace OpenSim.Region.CoreModules.World.Land
1060 //Owner Flag 1015 //Owner Flag
1061 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); 1016 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER);
1062 } 1017 }
1018 else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID))
1019 {
1020 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP);
1021 }
1063 else if (currentParcelBlock.LandData.SalePrice > 0 && 1022 else if (currentParcelBlock.LandData.SalePrice > 0 &&
1064 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || 1023 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
1065 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) 1024 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
@@ -1360,18 +1319,31 @@ namespace OpenSim.Region.CoreModules.World.Land
1360 1319
1361 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1320 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
1362 { 1321 {
1363 for (int i = 0; i < data.Count; i++) 1322 lock (m_landList)
1364 { 1323 {
1365 IncomingLandObjectFromStorage(data[i]); 1324 //Remove all the land objects in the sim and then process our new data
1325 foreach (int n in m_landList.Keys)
1326 {
1327 m_scene.EventManager.TriggerLandObjectRemoved(m_landList[n].LandData.GlobalID);
1328 }
1329 m_landIDList.Initialize();
1330 m_landList.Clear();
1331
1332 for (int i = 0; i < data.Count; i++)
1333 {
1334 IncomingLandObjectFromStorage(data[i]);
1335 }
1366 } 1336 }
1367 } 1337 }
1368 1338
1369 public void IncomingLandObjectFromStorage(LandData data) 1339 public void IncomingLandObjectFromStorage(LandData data)
1370 { 1340 {
1341
1371 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); 1342 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1372 new_land.LandData = data.Copy(); 1343 new_land.LandData = data.Copy();
1373 new_land.SetLandBitmapFromByteArray(); 1344 new_land.SetLandBitmapFromByteArray();
1374 AddLandObject(new_land); 1345 AddLandObject(new_land);
1346 new_land.SendLandUpdateToAvatarsOverMe();
1375 } 1347 }
1376 1348
1377 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) 1349 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
@@ -1649,6 +1621,322 @@ namespace OpenSim.Region.CoreModules.World.Land
1649 1621
1650 UpdateLandObject(localID, land.LandData); 1622 UpdateLandObject(localID, land.LandData);
1651 } 1623 }
1624
1625 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
1626 {
1627 ILandObject land = null;
1628 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
1629 foreach (ILandObject landObject in Land)
1630 {
1631 if (landObject.LandData.LocalID == landID)
1632 {
1633 land = landObject;
1634 }
1635 }
1636 land.DeedToGroup(DefaultGodParcelGroup);
1637 land.LandData.Name = DefaultGodParcelName;
1638 land.SendLandUpdateToAvatarsOverMe();
1639 }
1640
1641 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
1642 {
1643 ScenePresence SP;
1644 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP);
1645 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
1646 if (SP.UserLevel != 0)
1647 {
1648 if (flags == 0) //All parcels, scripted or not
1649 {
1650 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1651 {
1652 if (e.OwnerID == targetID)
1653 {
1654 returns.Add(e);
1655 }
1656 }
1657 );
1658 }
1659 if (flags == 4) //All parcels, scripted object
1660 {
1661 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1662 {
1663 if (e.OwnerID == targetID)
1664 {
1665 if (e.scriptScore >= 0.01)
1666 {
1667 returns.Add(e);
1668 }
1669 }
1670 }
1671 );
1672 }
1673 if (flags == 4) //not target parcel, scripted object
1674 {
1675 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1676 {
1677 if (e.OwnerID == targetID)
1678 {
1679 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1680 if (landobject.LandData.OwnerID != e.OwnerID)
1681 {
1682 if (e.scriptScore >= 0.01)
1683 {
1684 returns.Add(e);
1685 }
1686 }
1687 }
1688 }
1689 );
1690 }
1691 foreach (SceneObjectGroup ol in returns)
1692 {
1693 ReturnObject(ol, client);
1694 }
1695 }
1696 }
1697 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
1698 {
1699 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1700 objs[0] = obj;
1701 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
1702 }
1703
1704 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1705
1706 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1707 {
1708 ScenePresence targetAvatar = null;
1709 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1710 ScenePresence parcelManager = null;
1711 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1712 System.Threading.Timer Timer;
1713
1714 if (targetAvatar.UserLevel == 0)
1715 {
1716 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1717 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1718 return;
1719 if (flags == 0)
1720 {
1721 targetAvatar.AllowMovement = false;
1722 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
1723 parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
1724 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
1725 Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
1726 Timers.Add(targetAvatar.UUID, Timer);
1727 }
1728 else
1729 {
1730 targetAvatar.AllowMovement = true;
1731 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
1732 parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
1733 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1734 Timers.Remove(targetAvatar.UUID);
1735 Timer.Dispose();
1736 }
1737 }
1738 }
1739 private void OnEndParcelFrozen(object avatar)
1740 {
1741 ScenePresence targetAvatar = (ScenePresence)avatar;
1742 targetAvatar.AllowMovement = true;
1743 System.Threading.Timer Timer;
1744 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1745 Timers.Remove(targetAvatar.UUID);
1746 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1747 }
1748
1749
1750 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1751 {
1752 ScenePresence targetAvatar = null;
1753 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1754 ScenePresence parcelManager = null;
1755 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1756 //Just eject
1757 if (flags == 0)
1758 {
1759 if (targetAvatar.UserLevel == 0)
1760 {
1761 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1762 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1763 return;
1764
1765 Vector3 position = new Vector3(0, 0, 0);
1766 List<ILandObject> allParcels = new List<ILandObject>();
1767 allParcels = AllParcels();
1768 if (allParcels.Count != 1)
1769 {
1770 foreach (ILandObject parcel in allParcels)
1771 {
1772 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1773 {
1774 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1775 {
1776 for (int x = 1; x <= Constants.RegionSize; x += 2)
1777 {
1778 for (int y = 1; y <= Constants.RegionSize; y += 2)
1779 {
1780 if (parcel.ContainsPoint(x, y))
1781 {
1782 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1783 targetAvatar.TeleportWithMomentum(position);
1784 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1785 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1786 return;
1787 }
1788 }
1789 }
1790 }
1791 }
1792 }
1793 }
1794 Vector3 targetVector;
1795 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1796 {
1797 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1798 {
1799 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1800 targetAvatar.TeleportWithMomentum(targetVector);
1801 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1802 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1803 return;
1804 }
1805 else
1806 {
1807 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1808 targetAvatar.TeleportWithMomentum(targetVector);
1809 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1810 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1811 return;
1812 }
1813 }
1814 else
1815 {
1816 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1817 {
1818 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1819 targetAvatar.TeleportWithMomentum(targetVector);
1820 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1821 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1822 return;
1823 }
1824 else
1825 {
1826 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1827 targetAvatar.TeleportWithMomentum(targetVector);
1828 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1829 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1830 return;
1831 }
1832 }
1833 }
1834 }
1835 //Eject and ban
1836 if (flags == 1)
1837 {
1838 if (targetAvatar.UserLevel == 0)
1839 {
1840 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1841 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1842 return;
1843
1844 Vector3 position = new Vector3(0, 0, 0);
1845 List<ILandObject> allParcels = new List<ILandObject>();
1846 allParcels = AllParcels();
1847 if (allParcels.Count != 1)
1848 {
1849 foreach (ILandObject parcel in allParcels)
1850 {
1851 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1852 {
1853 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1854 {
1855 for (int x = 1; x <= Constants.RegionSize; x += 2)
1856 {
1857 for (int y = 1; y <= Constants.RegionSize; y += 2)
1858 {
1859 if (parcel.ContainsPoint(x, y))
1860 {
1861 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1862 targetAvatar.TeleportWithMomentum(position);
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 }
1874 }
1875 }
1876 }
1877 }
1878 Vector3 targetVector;
1879 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1880 {
1881 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1882 {
1883 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1884 targetAvatar.TeleportWithMomentum(targetVector);
1885 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1886 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1887 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1888 entry.AgentID = targetAvatar.UUID;
1889 entry.Flags = AccessList.Ban;
1890 entry.Time = new DateTime();
1891 land.LandData.ParcelAccessList.Add(entry);
1892 return;
1893 }
1894 else
1895 {
1896 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1897 targetAvatar.TeleportWithMomentum(targetVector);
1898 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1899 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1900 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1901 entry.AgentID = targetAvatar.UUID;
1902 entry.Flags = AccessList.Ban;
1903 entry.Time = new DateTime();
1904 land.LandData.ParcelAccessList.Add(entry);
1905 return;
1906 }
1907 }
1908 else
1909 {
1910 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1911 {
1912 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1913 targetAvatar.TeleportWithMomentum(targetVector);
1914 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1915 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1916 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1917 entry.AgentID = targetAvatar.UUID;
1918 entry.Flags = AccessList.Ban;
1919 entry.Time = new DateTime();
1920 land.LandData.ParcelAccessList.Add(entry);
1921 return;
1922 }
1923 else
1924 {
1925 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1926 targetAvatar.TeleportWithMomentum(targetVector);
1927 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1928 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1929 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1930 entry.AgentID = targetAvatar.UUID;
1931 entry.Flags = AccessList.Ban;
1932 entry.Time = new DateTime();
1933 land.LandData.ParcelAccessList.Add(entry);
1934 return;
1935 }
1936 }
1937 }
1938 }
1939 }
1652 1940
1653 protected void InstallInterfaces() 1941 protected void InstallInterfaces()
1654 { 1942 {
@@ -1711,5 +1999,27 @@ namespace OpenSim.Region.CoreModules.World.Land
1711 1999
1712 MainConsole.Instance.Output(report.ToString()); 2000 MainConsole.Instance.Output(report.ToString());
1713 } 2001 }
2002
2003 public void EnforceBans(ILandObject land, ScenePresence avatar)
2004 {
2005 if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
2006 return;
2007
2008 if (land.IsEitherBannedOrRestricted(avatar.UUID))
2009 {
2010 if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
2011 {
2012 Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
2013 if (pos == null)
2014 m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
2015 else
2016 ForceAvatarToPosition(avatar, (Vector3)pos);
2017 }
2018 else
2019 {
2020 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
2021 }
2022 }
2023 }
1714 } 2024 }
1715} \ No newline at end of file 2025}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 0da0de3..4f10fbf 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -190,10 +190,26 @@ namespace OpenSim.Region.CoreModules.World.Land
190 else 190 else
191 { 191 {
192 // Normal Calculations 192 // Normal Calculations
193 int parcelMax = (int)(((float)LandData.Area / 65536.0f) 193 int parcelMax = (int)((double)(LandData.Area
194 * (float)m_scene.RegionInfo.ObjectCapacity 194 * m_scene.RegionInfo.ObjectCapacity)
195 * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); 195 * m_scene.RegionInfo.RegionSettings.ObjectBonus)
196 // TODO: The calculation of ObjectBonus should be refactored. It does still not work in the same manner as SL! 196 / 65536;
197 return parcelMax;
198 }
199 }
200
201 private int GetParcelBasePrimCount()
202 {
203 if (overrideParcelMaxPrimCount != null)
204 {
205 return overrideParcelMaxPrimCount(this);
206 }
207 else
208 {
209 // Normal Calculations
210 int parcelMax = LandData.Area
211 * m_scene.RegionInfo.ObjectCapacity
212 / 65536;
197 return parcelMax; 213 return parcelMax;
198 } 214 }
199 } 215 }
@@ -245,7 +261,7 @@ namespace OpenSim.Region.CoreModules.World.Land
245 remote_client.SendLandProperties(seq_id, 261 remote_client.SendLandProperties(seq_id,
246 snap_selection, request_result, this, 262 snap_selection, request_result, this,
247 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, 263 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus,
248 GetParcelMaxPrimCount(), 264 GetParcelBasePrimCount(),
249 GetSimulatorMaxPrimCount(), regionFlags); 265 GetSimulatorMaxPrimCount(), regionFlags);
250 } 266 }
251 267
@@ -304,7 +320,7 @@ namespace OpenSim.Region.CoreModules.World.Land
304 320
305 allowedDelta |= (uint)(ParcelFlags.ShowDirectory | 321 allowedDelta |= (uint)(ParcelFlags.ShowDirectory |
306 ParcelFlags.AllowPublish | 322 ParcelFlags.AllowPublish |
307 ParcelFlags.MaturePublish); 323 ParcelFlags.MaturePublish) | (uint)(1 << 23);
308 } 324 }
309 325
310 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) 326 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity))
@@ -416,9 +432,43 @@ namespace OpenSim.Region.CoreModules.World.Land
416 return false; 432 return false;
417 } 433 }
418 434
435 public bool HasGroupAccess(UUID avatar)
436 {
437 if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup)
438 {
439 ScenePresence sp;
440 if (!m_scene.TryGetScenePresence(avatar, out sp))
441 {
442 IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
443 if (groupsModule == null)
444 return false;
445
446 GroupMembershipData[] membership = groupsModule.GetMembershipData(avatar);
447 if (membership == null || membership.Length == 0)
448 return false;
449
450 foreach (GroupMembershipData d in membership)
451 {
452 if (d.GroupID == LandData.GroupID)
453 return true;
454 }
455 return false;
456 }
457
458 if (!sp.ControllingClient.IsGroupMember(LandData.GroupID))
459 return false;
460
461 return true;
462 }
463 return false;
464 }
465
419 public bool IsBannedFromLand(UUID avatar) 466 public bool IsBannedFromLand(UUID avatar)
420 { 467 {
421 if (m_scene.Permissions.CanEditParcelProperties(avatar, this, 0)) 468 if (m_scene.Permissions.IsAdministrator(avatar))
469 return false;
470
471 if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar))
422 return false; 472 return false;
423 473
424 if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0) 474 if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0)
@@ -429,7 +479,7 @@ namespace OpenSim.Region.CoreModules.World.Land
429 if (e.AgentID == avatar && e.Flags == AccessList.Ban) 479 if (e.AgentID == avatar && e.Flags == AccessList.Ban)
430 return true; 480 return true;
431 return false; 481 return false;
432 }) != -1) 482 }) != -1 && LandData.OwnerID != avatar)
433 { 483 {
434 return true; 484 return true;
435 } 485 }
@@ -439,7 +489,10 @@ namespace OpenSim.Region.CoreModules.World.Land
439 489
440 public bool IsRestrictedFromLand(UUID avatar) 490 public bool IsRestrictedFromLand(UUID avatar)
441 { 491 {
442 if (m_scene.Permissions.CanEditParcelProperties(avatar, this, 0)) 492 if (m_scene.Permissions.IsAdministrator(avatar))
493 return false;
494
495 if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar))
443 return false; 496 return false;
444 497
445 if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0) 498 if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0)
@@ -450,11 +503,15 @@ namespace OpenSim.Region.CoreModules.World.Land
450 if (e.AgentID == avatar && e.Flags == AccessList.Access) 503 if (e.AgentID == avatar && e.Flags == AccessList.Access)
451 return true; 504 return true;
452 return false; 505 return false;
453 }) == -1) 506 }) == -1 && LandData.OwnerID != avatar)
454 { 507 {
455 return true; 508 if (!HasGroupAccess(avatar))
509 {
510 return true;
511 }
456 } 512 }
457 } 513 }
514
458 return false; 515 return false;
459 } 516 }
460 517
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index efede5c..5122734 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.World.Land
206 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) 206 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
207 { 207 {
208 UUID landOwner = landData.OwnerID; 208 UUID landOwner = landData.OwnerID;
209 int partCount = obj.Parts.Length; 209 int partCount = obj.GetPartCount();
210 210
211 m_SimwideCounts[landOwner] += partCount; 211 m_SimwideCounts[landOwner] += partCount;
212 if (parcelCounts.Users.ContainsKey(obj.OwnerID)) 212 if (parcelCounts.Users.ContainsKey(obj.OwnerID))
@@ -593,4 +593,4 @@ namespace OpenSim.Region.CoreModules.World.Land
593 } 593 }
594 } 594 }
595 } 595 }
596} \ No newline at end of file 596}
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 1e4f0a4..eb4731c 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -176,6 +176,13 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
176 return false; 176 return false;
177 } 177 }
178 178
179 if ((perms & (uint)PermissionMask.Copy) == 0)
180 {
181 if (m_dialogModule != null)
182 m_dialogModule.SendAlertToUser(remoteClient, "This sale has been blocked by the permissions system");
183 return false;
184 }
185
179 AssetBase asset = m_scene.CreateAsset( 186 AssetBase asset = m_scene.CreateAsset(
180 group.GetPartName(localID), 187 group.GetPartName(localID),
181 group.GetPartDescription(localID), 188 group.GetPartDescription(localID),
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index f416f06..3963474 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -364,7 +364,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
364 364
365 public string Name 365 public string Name
366 { 366 {
367 get { return "PermissionsModule"; } 367 get { return "DefaultPermissionsModule"; }
368 } 368 }
369 369
370 public bool IsSharedModule 370 public bool IsSharedModule
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
index 0f37ddd..7f6f4df 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 79
68 scene.RegisterModuleInterface<IRestartModule>(this); 80 scene.RegisterModuleInterface<IRestartModule>(this);
@@ -121,6 +133,7 @@ namespace OpenSim.Region.CoreModules.World.Region
121 133
122 if (alerts == null) 134 if (alerts == null)
123 { 135 {
136 CreateMarkerFile();
124 m_Scene.RestartNow(); 137 m_Scene.RestartNow();
125 return; 138 return;
126 } 139 }
@@ -134,6 +147,7 @@ namespace OpenSim.Region.CoreModules.World.Region
134 147
135 if (m_Alerts[0] == 0) 148 if (m_Alerts[0] == 0)
136 { 149 {
150 CreateMarkerFile();
137 m_Scene.RestartNow(); 151 m_Scene.RestartNow();
138 return; 152 return;
139 } 153 }
@@ -147,6 +161,7 @@ namespace OpenSim.Region.CoreModules.World.Region
147 { 161 {
148 if (m_Alerts.Count == 0 || m_Alerts[0] == 0) 162 if (m_Alerts.Count == 0 || m_Alerts[0] == 0)
149 { 163 {
164 CreateMarkerFile();
150 m_Scene.RestartNow(); 165 m_Scene.RestartNow();
151 return 0; 166 return 0;
152 } 167 }
@@ -266,5 +281,25 @@ namespace OpenSim.Region.CoreModules.World.Region
266 281
267 ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); 282 ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice);
268 } 283 }
284
285 protected void CreateMarkerFile()
286 {
287 if (m_MarkerPath == String.Empty)
288 return;
289
290 string path = Path.Combine(m_MarkerPath, m_Scene.RegionInfo.RegionID.ToString());
291 try
292 {
293 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
294 FileStream fs = File.Create(path);
295 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
296 Byte[] buf = enc.GetBytes(pidstring);
297 fs.Write(buf, 0, buf.Length);
298 fs.Close();
299 }
300 catch (Exception)
301 {
302 }
303 }
269 } 304 }
270} 305}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index cf000a4..4805ccb 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -606,6 +606,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
606 m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); 606 m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised());
607 m_scene.SaveTerrain(); 607 m_scene.SaveTerrain();
608 608
609 m_scene.EventManager.TriggerTerrainUpdate();
610
609 // Clients who look at the map will never see changes after they looked at the map, so i've commented this out. 611 // Clients who look at the map will never see changes after they looked at the map, so i've commented this out.
610 //m_scene.CreateTerrainTexture(true); 612 //m_scene.CreateTerrainTexture(true);
611 } 613 }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 657975b..44475a5 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, uint flags) 87 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags)
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
@@ -99,7 +99,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
99 if (regionInfos.Count == 0) 99 if (regionInfos.Count == 0)
100 remoteClient.SendAlertMessage("Hyperlink could not be established."); 100 remoteClient.SendAlertMessage("Hyperlink could not be established.");
101 101
102 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); 102 //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count);
103 List<MapBlockData> blocks = new List<MapBlockData>(); 103 List<MapBlockData> blocks = new List<MapBlockData>();
104 104
105 MapBlockData data; 105 MapBlockData data;
@@ -128,7 +128,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
128 data.Agents = 0; 128 data.Agents = 0;
129 data.Access = 255; 129 data.Access = 255;
130 data.MapImageId = UUID.Zero; 130 data.MapImageId = UUID.Zero;
131 data.Name = ""; // mapName; 131 data.Name = mapName;
132 data.RegionFlags = 0; 132 data.RegionFlags = 0;
133 data.WaterHeight = 0; // not used 133 data.WaterHeight = 0; // not used
134 data.X = 0; 134 data.X = 0;
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 95c727f..ba4ddc1 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -1182,7 +1182,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1182 } 1182 }
1183 else 1183 else
1184 { 1184 {
1185 OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); 1185 OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount());
1186 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 1186 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
1187 { 1187 {
1188 OSDMap responsemapdata = new OSDMap(); 1188 OSDMap responsemapdata = new OSDMap();