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