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.cs59
-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.cs38
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs62
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs8
-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.cs789
-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.cs39
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs427
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs37
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs2
-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
37 files changed, 1778 insertions, 654 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 c023a6f..5c5cb70 100644
--- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
@@ -88,7 +88,8 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
88 88
89 public void AddCapsHandler(UUID agentId) 89 public void AddCapsHandler(UUID agentId)
90 { 90 {
91 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) 91 int flags = m_scene.GetUserFlags(agentId);
92 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
92 return; 93 return;
93 94
94 String capsObjectPath = GetCapsPath(agentId); 95 String capsObjectPath = GetCapsPath(agentId);
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 6ed4867..e542d7d 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -271,7 +271,16 @@ namespace Flotsam.RegionModules.AssetCache
271 // If the file is already cached, don't cache it, just touch it so access time is updated 271 // If the file is already cached, don't cache it, just touch it so access time is updated
272 if (File.Exists(filename)) 272 if (File.Exists(filename))
273 { 273 {
274 File.SetLastAccessTime(filename, DateTime.Now); 274 // We don't really want to know about sharing
275 // violations here. If the file is locked, then
276 // the other thread has updated the time for us.
277 try
278 {
279 File.SetLastAccessTime(filename, DateTime.Now);
280 }
281 catch
282 {
283 }
275 } else { 284 } else {
276 285
277 // Once we start writing, make sure we flag that we're writing 286 // 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..8c92588 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;
@@ -226,15 +227,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
226 public UUID RezSingleAttachmentFromInventory( 227 public UUID RezSingleAttachmentFromInventory(
227 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) 228 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus)
228 { 229 {
229 m_log.DebugFormat( 230 return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true, null);
230 "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", 231 }
231 (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); 232
232 233 public UUID RezSingleAttachmentFromInventory(
234 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc)
235 {
233 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 236 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
234 // be removed when that functionality is implemented in opensim 237 // be removed when that functionality is implemented in opensim
235 AttachmentPt &= 0x7f; 238 AttachmentPt &= 0x7f;
236 239
237 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); 240 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt, doc);
238 241
239 if (updateInventoryStatus) 242 if (updateInventoryStatus)
240 { 243 {
@@ -251,7 +254,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
251 } 254 }
252 255
253 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 256 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
254 IClientAPI remoteClient, UUID itemID, uint AttachmentPt) 257 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, XmlDocument doc)
255 { 258 {
256 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 259 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
257 if (invAccess != null) 260 if (invAccess != null)
@@ -289,13 +292,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
289 if (tainted) 292 if (tainted)
290 objatt.HasGroupChanged = true; 293 objatt.HasGroupChanged = true;
291 294
295 if (doc != null)
296 {
297 objatt.LoadScriptState(doc);
298 objatt.ResetOwnerChangeFlag();
299 }
300
292 // Fire after attach, so we don't get messy perms dialogs 301 // Fire after attach, so we don't get messy perms dialogs
293 // 4 == AttachedRez 302 // 4 == AttachedRez
294 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); 303 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
295 objatt.ResumeScripts(); 304 objatt.ResumeScripts();
296 305
297 // Do this last so that event listeners have access to all the effects of the attachment 306 // 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); 307 //m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
299 } 308 }
300 else 309 else
301 { 310 {
@@ -332,7 +341,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
332 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) 341 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
333 { 342 {
334 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 343 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
335 item = m_scene.InventoryService.GetItem(item); 344 if (m_scene.InventoryService != null)
345 item = m_scene.InventoryService.GetItem(item);
336 346
337 bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); 347 bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
338 if (changed && m_scene.AvatarFactory != null) 348 if (changed && m_scene.AvatarFactory != null)
@@ -379,6 +389,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
379 { 389 {
380 // XXYY!! 390 // XXYY!!
381 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 391 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
392 if (item == null)
393 m_log.Error("[ATTACHMENT]: item == null");
394 if (m_scene == null)
395 m_log.Error("[ATTACHMENT]: m_scene == null");
396 if (m_scene.InventoryService == null)
397 m_log.Error("[ATTACHMENT]: m_scene.InventoryService == null");
382 item = m_scene.InventoryService.GetItem(item); 398 item = m_scene.InventoryService.GetItem(item);
383 bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); 399 bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
384 if (changed && m_scene.AvatarFactory != null) 400 if (changed && m_scene.AvatarFactory != null)
@@ -465,6 +481,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
465 if (group.GetFromItemID() == itemID) 481 if (group.GetFromItemID() == itemID)
466 { 482 {
467 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); 483 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
484 // CM / XMREngine!!!! Needed to conclude attach event
485 //SceneObjectSerializer.ToOriginalXmlFormat(group);
468 group.DetachToInventoryPrep(); 486 group.DetachToInventoryPrep();
469 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); 487 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
470 488
@@ -482,22 +500,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
482 } 500 }
483 } 501 }
484 502
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> 503 /// <summary>
502 /// Update the attachment asset for the new sog details if they have changed. 504 /// Update the attachment asset for the new sog details if they have changed.
503 /// </summary> 505 /// </summary>
@@ -601,15 +603,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
601 603
602 if (!silent) 604 if (!silent)
603 { 605 {
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.... 606 so.IsSelected = false; // fudge....
614 so.ScheduleGroupForFullUpdate(); 607 so.ScheduleGroupForFullUpdate();
615 } 608 }
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 2b3d2a9..a514a83 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -239,4 +239,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
239 return result; 239 return result;
240 } 240 }
241 } 241 }
242} \ No newline at end of file 242}
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..dd9819a 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);
@@ -533,7 +549,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
533 549
534 if (upd != null) 550 if (upd != null)
535 { 551 {
536 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, 552 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(UUID.Zero,
537 upd.RegionID); 553 upd.RegionID);
538 if (reginfo != null) 554 if (reginfo != null)
539 { 555 {
@@ -682,6 +698,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
682 gim["position_z"] = msg.Position.Z.ToString(); 698 gim["position_z"] = msg.Position.Z.ToString();
683 gim["region_id"] = msg.RegionID.ToString(); 699 gim["region_id"] = msg.RegionID.ToString();
684 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); 700 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None);
701 if (m_MessageKey != String.Empty)
702 gim["message_key"] = m_MessageKey;
685 return gim; 703 return gim;
686 } 704 }
687 705
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/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 26edba4..68538c9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -122,14 +122,17 @@ 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
129 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine 129 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine
130 + "-p|--profile=<url> adds the url of the profile service to the saved user information." + Environment.NewLine 130 + "-p|--profile=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
131<<<<<<< HEAD:OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
132=======
131 + "-c|--creators preserves information about foreign creators." + Environment.NewLine 133 + "-c|--creators preserves information about foreign creators." + Environment.NewLine
132 + "-v|--verbose extra debug messages." + Environment.NewLine 134 + "-v|--verbose extra debug messages." + Environment.NewLine
135>>>>>>> master:OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
133 + "<IAR path> is the filesystem path at which to save the IAR." 136 + "<IAR path> is the filesystem path at which to save the IAR."
134 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), 137 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME),
135 HandleSaveInvConsoleCommand); 138 HandleSaveInvConsoleCommand);
@@ -396,8 +399,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
396 OptionSet ops = new OptionSet(); 399 OptionSet ops = new OptionSet();
397 //ops.Add("v|version=", delegate(string v) { options["version"] = v; }); 400 //ops.Add("v|version=", delegate(string v) { options["version"] = v; });
398 ops.Add("p|profile=", delegate(string v) { options["profile"] = v; }); 401 ops.Add("p|profile=", delegate(string v) { options["profile"] = v; });
402<<<<<<< HEAD:OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
403=======
399 ops.Add("v|verbose", delegate(string v) { options["verbose"] = v; }); 404 ops.Add("v|verbose", delegate(string v) { options["verbose"] = v; });
400 ops.Add("c|creators", delegate(string v) { options["creators"] = v; }); 405 ops.Add("c|creators", delegate(string v) { options["creators"] = v; });
406>>>>>>> master:OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
401 407
402 List<string> mainParams = ops.Parse(cmdparams); 408 List<string> mainParams = ops.Parse(cmdparams);
403 409
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..6532bbb 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
@@ -148,14 +148,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
148 (uint)presence.AbsolutePosition.Y, 148 (uint)presence.AbsolutePosition.Y,
149 (uint)presence.AbsolutePosition.Z); 149 (uint)presence.AbsolutePosition.Z);
150 150
151 m_log.DebugFormat("TP invite with message {0}", message); 151 m_log.DebugFormat("[LURE]: TP invite with message {0}", message);
152 152
153 GridInstantMessage m = new GridInstantMessage(scene, client.AgentId, 153 GridInstantMessage m;
154 client.FirstName+" "+client.LastName, targetid, 154
155 (byte)InstantMessageDialog.RequestTeleport, false, 155 if (scene.Permissions.IsAdministrator(client.AgentId) && presence.GodLevel >= 200 && (!scene.Permissions.IsAdministrator(targetid)))
156 message, dest, false, presence.AbsolutePosition, 156 {
157 new Byte[0]); 157 m = new GridInstantMessage(scene, client.AgentId,
158 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 }
171
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 80a8041..ca29a7c 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
@@ -514,7 +515,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
514 515
515 protected void KillEntity(Scene scene, uint localID) 516 protected void KillEntity(Scene scene, uint localID)
516 { 517 {
517 scene.SendKillObject(localID); 518 scene.SendKillObject(new List<uint>() { localID });
518 } 519 }
519 520
520 protected virtual GridRegion GetFinalDestination(GridRegion region) 521 protected virtual GridRegion GetFinalDestination(GridRegion region)
@@ -552,7 +553,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
552 553
553 #region Teleport Home 554 #region Teleport Home
554 555
555 public virtual void TeleportHome(UUID id, IClientAPI client) 556 public void TeleportHomeFired(UUID id, IClientAPI client)
557 {
558 TeleportHome(id, client);
559 }
560
561 public virtual bool TeleportHome(UUID id, IClientAPI client)
556 { 562 {
557 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); 563 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
558 564
@@ -561,12 +567,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
561 567
562 if (uinfo != null) 568 if (uinfo != null)
563 { 569 {
570 if (uinfo.HomeRegionID == UUID.Zero)
571 {
572 // can't find the Home region: Tell viewer and abort
573 client.SendTeleportFailed("You don't have a home position set.");
574 return false;
575 }
564 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); 576 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
565 if (regionInfo == null) 577 if (regionInfo == null)
566 { 578 {
567 // can't find the Home region: Tell viewer and abort 579 // can't find the Home region: Tell viewer and abort
568 client.SendTeleportFailed("Your home region could not be found."); 580 client.SendTeleportFailed("Your home region could not be found.");
569 return; 581 return false;
570 } 582 }
571 583
572 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})", 584 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})",
@@ -577,6 +589,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
577 client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt, 589 client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt,
578 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); 590 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
579 } 591 }
592 else
593 {
594 // can't find the Home region: Tell viewer and abort
595 client.SendTeleportFailed("Your home region could not be found.");
596 return false;
597 }
598 return true;
580 } 599 }
581 600
582 #endregion 601 #endregion
@@ -910,15 +929,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
910 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); 929 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
911 930
912 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>(); 931 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
913 if (eq != null) 932 IPEndPoint neighbourExternal = neighbourRegion.ExternalEndPoint;
914 { 933 if (neighbourExternal != null)
915 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
916 capsPath, agent.UUID, agent.ControllingClient.SessionId);
917 }
918 else
919 { 934 {
920 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, 935 if (eq != null)
921 capsPath); 936 {
937 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal,
938 capsPath, agent.UUID, agent.ControllingClient.SessionId);
939 }
940 else
941 {
942 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal,
943 capsPath);
944 }
922 } 945 }
923 946
924 if (!WaitForCallback(agent.UUID)) 947 if (!WaitForCallback(agent.UUID))
@@ -1022,10 +1045,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1022 agent.Id0 = currentAgentCircuit.Id0; 1045 agent.Id0 = currentAgentCircuit.Id0;
1023 } 1046 }
1024 1047
1025 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 1048 IPEndPoint external = region.ExternalEndPoint;
1026 d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, 1049 if (external != null)
1050 {
1051 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1052 d.BeginInvoke(sp, agent, region, external, true,
1027 InformClientOfNeighbourCompleted, 1053 InformClientOfNeighbourCompleted,
1028 d); 1054 d);
1055 }
1029 } 1056 }
1030 #endregion 1057 #endregion
1031 1058
@@ -1158,6 +1185,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1158 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 1185 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1159 try 1186 try
1160 { 1187 {
1188 //neighbour.ExternalEndPoint may return null, which will be caught
1161 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, 1189 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
1162 InformClientOfNeighbourCompleted, 1190 InformClientOfNeighbourCompleted,
1163 d); 1191 d);
@@ -1261,8 +1289,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1261 1289
1262 m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); 1290 m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString());
1263 } 1291 }
1264 if (!regionAccepted)
1265 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Region {0} did not accept agent: {1}", reg.RegionName, reason);
1266 } 1292 }
1267 1293
1268 /// <summary> 1294 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 35dcd95..c75bc0a 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 7bb8789..0163060 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Xml;
31using System.Reflection; 32using System.Reflection;
32using System.Threading; 33using System.Threading;
33 34
@@ -202,11 +203,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
202 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, 203 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
203 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient) 204 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient)
204 { 205 {
205 // HACK: This is only working for lists containing a single item!
206 // It's just a hack to make this WIP compile and run. Nothing
207 // currently calls this with multiple items.
208 UUID ret = UUID.Zero; 206 UUID ret = UUID.Zero;
209 207
208 // The following code groups the SOG's by owner. No objects
209 // belonging to different people can be coalesced, for obvious
210 // reasons.
210 Dictionary<UUID, List<SceneObjectGroup>> deletes = 211 Dictionary<UUID, List<SceneObjectGroup>> deletes =
211 new Dictionary<UUID, List<SceneObjectGroup>>(); 212 new Dictionary<UUID, List<SceneObjectGroup>>();
212 213
@@ -218,262 +219,337 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
218 deletes[g.OwnerID].Add(g); 219 deletes[g.OwnerID].Add(g);
219 } 220 }
220 221
222 // This is pethod scoped and will be returned. It will be the
223 // last created asset id
224 UUID assetID = UUID.Zero;
225
226 // Each iteration is really a separate asset being created,
227 // with distinct destinations as well.
221 foreach (List<SceneObjectGroup> objlist in deletes.Values) 228 foreach (List<SceneObjectGroup> objlist in deletes.Values)
222 { 229 {
223 foreach (SceneObjectGroup g in objlist) 230 Dictionary<UUID, string> xmlStrings =
224 ret = DeleteToInventory(action, folderID, g, remoteClient); 231 new Dictionary<UUID, string>();
225 }
226
227 return ret;
228 }
229 232
230 private UUID DeleteToInventory(DeRezAction action, UUID folderID, 233 foreach (SceneObjectGroup objectGroup in objlist)
231 SceneObjectGroup objectGroup, IClientAPI remoteClient) 234 {
232 { 235 Vector3 inventoryStoredPosition = new Vector3
233 UUID assetID = UUID.Zero; 236 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
237 ? 250
238 : objectGroup.AbsolutePosition.X)
239 ,
240 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
241 ? 250
242 : objectGroup.AbsolutePosition.X,
243 objectGroup.AbsolutePosition.Z);
234 244
235 Vector3 inventoryStoredPosition = new Vector3 245 Vector3 originalPosition = objectGroup.AbsolutePosition;
236 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
237 ? 250
238 : objectGroup.AbsolutePosition.X)
239 ,
240 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
241 ? 250
242 : objectGroup.AbsolutePosition.X,
243 objectGroup.AbsolutePosition.Z);
244 246
245 Vector3 originalPosition = objectGroup.AbsolutePosition; 247 // Restore attachment data after trip through the sim
248 if (objectGroup.RootPart.AttachPoint > 0)
249 inventoryStoredPosition = objectGroup.RootPart.AttachOffset;
250 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
246 251
247 objectGroup.AbsolutePosition = inventoryStoredPosition; 252 objectGroup.AbsolutePosition = inventoryStoredPosition;
248 253
249 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); 254 // Make sure all bits but the ones we want are clear
255 // on take.
256 // This will be applied to the current perms, so
257 // it will do what we want.
258 objectGroup.RootPart.NextOwnerMask &=
259 ((uint)PermissionMask.Copy |
260 (uint)PermissionMask.Transfer |
261 (uint)PermissionMask.Modify);
262 objectGroup.RootPart.NextOwnerMask |=
263 (uint)PermissionMask.Move;
250 264
251 objectGroup.AbsolutePosition = originalPosition; 265 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
252 266
253 // Get the user info of the item destination 267 objectGroup.AbsolutePosition = originalPosition;
254 //
255 UUID userID = UUID.Zero;
256 268
257 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || 269 xmlStrings[objectGroup.UUID] = sceneObjectXml;
258 action == DeRezAction.SaveToExistingUserInventoryItem) 270 }
259 {
260 // Take or take copy require a taker
261 // Saving changes requires a local user
262 //
263 if (remoteClient == null)
264 return UUID.Zero;
265 271
266 userID = remoteClient.AgentId; 272 string itemXml;
267 }
268 else
269 {
270 // All returns / deletes go to the object owner
271 //
272 273
273 userID = objectGroup.RootPart.OwnerID; 274 if (objlist.Count > 1)
274 } 275 {
276 float minX, minY, minZ;
277 float maxX, maxY, maxZ;
275 278
276 if (userID == UUID.Zero) // Can't proceed 279 Vector3[] offsets = m_Scene.GetCombinedBoundingBox(objlist,
277 { 280 out minX, out maxX, out minY, out maxY,
278 return UUID.Zero; 281 out minZ, out maxZ);
279 }
280 282
281 // If we're returning someone's item, it goes back to the 283 // CreateWrapper
282 // owner's Lost And Found folder. 284 XmlDocument itemDoc = new XmlDocument();
283 // Delete is treated like return in this case 285 XmlElement root = itemDoc.CreateElement("", "CoalescedObject", "");
284 // Deleting your own items makes them go to trash 286 itemDoc.AppendChild(root);
285 //
286 287
287 InventoryFolderBase folder = null; 288 // Embed the offsets into the group XML
288 InventoryItemBase item = null; 289 for ( int i = 0 ; i < objlist.Count ; i++ )
290 {
291 XmlDocument doc = new XmlDocument();
292 SceneObjectGroup g = objlist[i];
293 doc.LoadXml(xmlStrings[g.UUID]);
294 XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup");
295 e.SetAttribute("offsetx", offsets[i].X.ToString());
296 e.SetAttribute("offsety", offsets[i].Y.ToString());
297 e.SetAttribute("offsetz", offsets[i].Z.ToString());
298
299 XmlNode objectNode = itemDoc.ImportNode(e, true);
300 root.AppendChild(objectNode);
301 }
289 302
290 if (DeRezAction.SaveToExistingUserInventoryItem == action) 303 float sizeX = maxX - minX;
291 { 304 float sizeY = maxY - minY;
292 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); 305 float sizeZ = maxZ - minZ;
293 item = m_Scene.InventoryService.GetItem(item);
294 306
295 //item = userInfo.RootFolder.FindItem( 307 root.SetAttribute("x", sizeX.ToString());
296 // objectGroup.RootPart.FromUserInventoryItemID); 308 root.SetAttribute("y", sizeY.ToString());
309 root.SetAttribute("z", sizeZ.ToString());
297 310
298 if (null == item) 311 itemXml = itemDoc.InnerXml;
312 }
313 else
299 { 314 {
300 m_log.DebugFormat( 315 itemXml = xmlStrings[objlist[0].UUID];
301 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
302 objectGroup.Name, objectGroup.UUID);
303 return UUID.Zero;
304 } 316 }
305 } 317
306 else 318 // Get the user info of the item destination
307 {
308 // Folder magic
309 // 319 //
310 if (action == DeRezAction.Delete) 320 UUID userID = UUID.Zero;
321
322 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
323 action == DeRezAction.SaveToExistingUserInventoryItem)
311 { 324 {
312 // Deleting someone else's item 325 // Take or take copy require a taker
326 // Saving changes requires a local user
313 // 327 //
314 if (remoteClient == null || 328 if (remoteClient == null)
315 objectGroup.OwnerID != remoteClient.AgentId) 329 return UUID.Zero;
316 {
317 330
318 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 331 userID = remoteClient.AgentId;
319 }
320 else
321 {
322 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
323 }
324 } 332 }
325 else if (action == DeRezAction.Return) 333 else
326 { 334 {
327 335 // All returns / deletes go to the object owner
328 // Dump to lost + found unconditionally
329 // 336 //
330 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 337
338 userID = objlist[0].RootPart.OwnerID;
331 } 339 }
332 340
333 if (folderID == UUID.Zero && folder == null) 341 if (userID == UUID.Zero) // Can't proceed
334 { 342 {
335 if (action == DeRezAction.Delete) 343 return UUID.Zero;
344 }
345
346 // If we're returning someone's item, it goes back to the
347 // owner's Lost And Found folder.
348 // Delete is treated like return in this case
349 // Deleting your own items makes them go to trash
350 //
351
352 InventoryFolderBase folder = null;
353 InventoryItemBase item = null;
354
355 if (DeRezAction.SaveToExistingUserInventoryItem == action)
356 {
357 item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID);
358 item = m_Scene.InventoryService.GetItem(item);
359
360 //item = userInfo.RootFolder.FindItem(
361 // objectGroup.RootPart.FromUserInventoryItemID);
362
363 if (null == item)
336 { 364 {
337 // Deletes go to trash by default 365 m_log.DebugFormat(
338 // 366 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
339 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); 367 objlist[0].Name, objlist[0].UUID);
368 return UUID.Zero;
340 } 369 }
341 else 370 }
371 else
372 {
373 // Folder magic
374 //
375 if (action == DeRezAction.Delete)
342 { 376 {
377 // Deleting someone else's item
378 //
343 if (remoteClient == null || 379 if (remoteClient == null ||
344 objectGroup.OwnerID != remoteClient.AgentId) 380 objlist[0].OwnerID != remoteClient.AgentId)
345 { 381 {
346 // Taking copy of another person's item. Take to 382
347 // Objects folder. 383 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
348 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
349 } 384 }
350 else 385 else
351 { 386 {
352 // Catch all. Use lost & found 387 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
388 }
389 }
390 else if (action == DeRezAction.Return)
391 {
392
393 // Dump to lost + found unconditionally
394 //
395 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
396 }
397
398 if (folderID == UUID.Zero && folder == null)
399 {
400 if (action == DeRezAction.Delete)
401 {
402 // Deletes go to trash by default
353 // 403 //
404 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
405 }
406 else
407 {
408 if (remoteClient == null ||
409 objlist[0].OwnerID != remoteClient.AgentId)
410 {
411 // Taking copy of another person's item. Take to
412 // Objects folder.
413 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
414 }
415 else
416 {
417 // Catch all. Use lost & found
418 //
354 419
355 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 420 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
421 }
356 } 422 }
357 } 423 }
358 }
359 424
360 // Override and put into where it came from, if it came 425 // Override and put into where it came from, if it came
361 // from anywhere in inventory 426 // from anywhere in inventory
362 // 427 //
363 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) 428 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
364 {
365 if (objectGroup.RootPart.FromFolderID != UUID.Zero)
366 { 429 {
367 InventoryFolderBase f = new InventoryFolderBase(objectGroup.RootPart.FromFolderID, userID); 430 if (objlist[0].RootPart.FromFolderID != UUID.Zero && objlist[0].OwnerID == remoteClient.AgentId)
368 folder = m_Scene.InventoryService.GetFolder(f); 431 {
432 InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID);
433 folder = m_Scene.InventoryService.GetFolder(f);
434 }
369 } 435 }
370 }
371 436
372 if (folder == null) // None of the above 437 if (folder == null) // None of the above
373 { 438 {
374 folder = new InventoryFolderBase(folderID); 439 folder = new InventoryFolderBase(folderID);
440
441 if (folder == null) // Nowhere to put it
442 {
443 return UUID.Zero;
444 }
445 }
375 446
376 if (folder == null) // Nowhere to put it 447 item = new InventoryItemBase();
448 // Can't know creator is the same, so null it in inventory
449 if (objlist.Count > 1)
377 { 450 {
378 return UUID.Zero; 451 item.CreatorId = UUID.Zero.ToString();
452 item.CreatorData = String.Empty;
453 }
454 else
455 {
456 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
457 item.CreatorData = objlist[0].RootPart.CreatorData;
458 }
459 item.ID = UUID.Random();
460 item.InvType = (int)InventoryType.Object;
461 item.Folder = folder.ID;
462 item.Owner = userID;
463 if (objlist.Count > 1)
464 {
465 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
466 }
467 else
468 {
469 item.SaleType = objlist[0].RootPart.ObjectSaleType;
470 item.SalePrice = objlist[0].RootPart.SalePrice;
379 } 471 }
380 } 472 }
381 473
382 item = new InventoryItemBase(); 474 AssetBase asset = CreateAsset(
383 item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); 475 objlist[0].GetPartName(objlist[0].RootPart.LocalId),
384 item.CreatorData = objectGroup.RootPart.CreatorData; 476 objlist[0].GetPartDescription(objlist[0].RootPart.LocalId),
385 item.ID = UUID.Random(); 477 (sbyte)AssetType.Object,
386 item.InvType = (int)InventoryType.Object; 478 Utils.StringToBytes(itemXml),
387 item.Folder = folder.ID; 479 objlist[0].OwnerID.ToString());
388 item.Owner = userID; 480 m_Scene.AssetService.Store(asset);
389 } 481 assetID = asset.FullID;
390
391 AssetBase asset = CreateAsset(
392 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
393 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
394 (sbyte)AssetType.Object,
395 Utils.StringToBytes(sceneObjectXml),
396 objectGroup.OwnerID.ToString());
397 m_Scene.AssetService.Store(asset);
398 assetID = asset.FullID;
399
400 if (DeRezAction.SaveToExistingUserInventoryItem == action)
401 {
402 item.AssetID = asset.FullID;
403 m_Scene.InventoryService.UpdateItem(item);
404 }
405 else
406 {
407 item.AssetID = asset.FullID;
408 482
409 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 483 if (DeRezAction.SaveToExistingUserInventoryItem == action)
410 { 484 {
411 uint perms = objectGroup.GetEffectivePermissions(); 485 item.AssetID = asset.FullID;
412 uint nextPerms = (perms & 7) << 13; 486 m_Scene.InventoryService.UpdateItem(item);
413 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
414 perms &= ~(uint)PermissionMask.Copy;
415 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
416 perms &= ~(uint)PermissionMask.Transfer;
417 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
418 perms &= ~(uint)PermissionMask.Modify;
419
420 // Make sure all bits but the ones we want are clear
421 // on take.
422 // This will be applied to the current perms, so
423 // it will do what we want.
424 objectGroup.RootPart.NextOwnerMask &=
425 ((uint)PermissionMask.Copy |
426 (uint)PermissionMask.Transfer |
427 (uint)PermissionMask.Modify);
428 objectGroup.RootPart.NextOwnerMask |=
429 (uint)PermissionMask.Move;
430
431 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
432 item.CurrentPermissions = item.BasePermissions;
433 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
434 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
435 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
436
437 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
438 } 487 }
439 else 488 else
440 { 489 {
441 item.BasePermissions = objectGroup.GetEffectivePermissions(); 490 item.AssetID = asset.FullID;
442 item.CurrentPermissions = objectGroup.GetEffectivePermissions();
443 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
444 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
445 item.GroupPermissions = objectGroup.RootPart.GroupMask;
446 491
447 item.CurrentPermissions &= 492 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7;
448 ((uint)PermissionMask.Copy | 493 foreach (SceneObjectGroup grp in objlist)
449 (uint)PermissionMask.Transfer | 494 effectivePerms &= grp.GetEffectivePermissions();
450 (uint)PermissionMask.Modify | 495 effectivePerms |= (uint)PermissionMask.Move;
451 (uint)PermissionMask.Move |
452 7); // Preserve folded permissions
453 }
454 496
455 // TODO: add the new fields (Flags, Sale info, etc) 497 if (remoteClient != null && (remoteClient.AgentId != objlist[0].RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
456 item.CreationDate = Util.UnixTimeSinceEpoch(); 498 {
457 item.Description = asset.Description; 499 uint perms = effectivePerms;
458 item.Name = asset.Name; 500 uint nextPerms = (perms & 7) << 13;
459 item.AssetType = asset.Type; 501 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
502 perms &= ~(uint)PermissionMask.Copy;
503 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
504 perms &= ~(uint)PermissionMask.Transfer;
505 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
506 perms &= ~(uint)PermissionMask.Modify;
507
508 item.BasePermissions = perms & objlist[0].RootPart.NextOwnerMask;
509 item.CurrentPermissions = item.BasePermissions;
510 item.NextPermissions = perms & objlist[0].RootPart.NextOwnerMask;
511 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & objlist[0].RootPart.NextOwnerMask;
512 item.GroupPermissions = objlist[0].RootPart.GroupMask & objlist[0].RootPart.NextOwnerMask;
513
514 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
515 }
516 else
517 {
518 item.BasePermissions = effectivePerms;
519 item.CurrentPermissions = effectivePerms;
520 item.NextPermissions = objlist[0].RootPart.NextOwnerMask & effectivePerms;
521 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & effectivePerms;
522 item.GroupPermissions = objlist[0].RootPart.GroupMask & effectivePerms;
523
524 item.CurrentPermissions &=
525 ((uint)PermissionMask.Copy |
526 (uint)PermissionMask.Transfer |
527 (uint)PermissionMask.Modify |
528 (uint)PermissionMask.Move |
529 7); // Preserve folded permissions
530 }
460 531
461 m_Scene.AddInventoryItem(item); 532 item.CreationDate = Util.UnixTimeSinceEpoch();
533 item.Description = asset.Description;
534 item.Name = asset.Name;
535 item.AssetType = asset.Type;
462 536
463 if (remoteClient != null && item.Owner == remoteClient.AgentId) 537 m_Scene.AddInventoryItem(item);
464 { 538
465 remoteClient.SendInventoryItemCreateUpdate(item, 0); 539 if (remoteClient != null && item.Owner == remoteClient.AgentId)
466 }
467 else
468 {
469 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner);
470 if (notifyUser != null)
471 { 540 {
472 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); 541 remoteClient.SendInventoryItemCreateUpdate(item, 0);
542 }
543 else
544 {
545 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner);
546 if (notifyUser != null)
547 {
548 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
549 }
473 } 550 }
474 } 551 }
475 } 552 }
476
477 return assetID; 553 return assetID;
478 } 554 }
479 555
@@ -524,8 +600,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
524 600
525 if (item != null) 601 if (item != null)
526 { 602 {
603 if (item.ID == UUID.Zero)
604 {
605 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 1");
606 }
607
527 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); 608 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
528 609
610 SceneObjectGroup group = null;
611
529 if (rezAsset != null) 612 if (rezAsset != null)
530 { 613 {
531 UUID itemId = UUID.Zero; 614 UUID itemId = UUID.Zero;
@@ -534,34 +617,83 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
534 // item that it came from. This allows us to enable 'save object to inventory' 617 // item that it came from. This allows us to enable 'save object to inventory'
535 if (!m_Scene.Permissions.BypassPermissions()) 618 if (!m_Scene.Permissions.BypassPermissions())
536 { 619 {
537 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) 620 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
538 { 621 {
539 itemId = item.ID; 622 itemId = item.ID;
540 } 623 }
541 } 624 }
542 else 625 else
543 { 626 {
544 // Brave new fullperm world 627 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
545 // 628 {
546 itemId = item.ID; 629 // Brave new fullperm world
630 itemId = item.ID;
631 }
632 }
633
634 if (item.ID == UUID.Zero)
635 {
636 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 2");
547 } 637 }
548 638
549 string xmlData = Utils.BytesToString(rezAsset.Data); 639 string xmlData = Utils.BytesToString(rezAsset.Data);
550 SceneObjectGroup group 640 List<SceneObjectGroup> objlist =
551 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); 641 new List<SceneObjectGroup>();
642 List<Vector3> veclist = new List<Vector3>();
643
644 XmlDocument doc = new XmlDocument();
645 doc.LoadXml(xmlData);
646 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject");
647 if (e == null || attachment) // Single
648 {
649 SceneObjectGroup g =
650 SceneObjectSerializer.FromOriginalXmlFormat(
651 itemId, xmlData);
652 objlist.Add(g);
653 veclist.Add(new Vector3(0, 0, 0));
552 654
553 Util.FireAndForget(delegate { AddUserData(group); }); 655 float offsetHeight = 0;
554 656 pos = m_Scene.GetNewRezLocation(
555 group.RootPart.FromFolderID = item.Folder; 657 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
658 BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false);
659 pos.Z += offsetHeight;
660 }
661 else
662 {
663 XmlElement coll = (XmlElement)e;
664 float bx = Convert.ToSingle(coll.GetAttribute("x"));
665 float by = Convert.ToSingle(coll.GetAttribute("y"));
666 float bz = Convert.ToSingle(coll.GetAttribute("z"));
667 Vector3 bbox = new Vector3(bx, by, bz);
556 668
557 // If it's rezzed in world, select it. Much easier to 669 pos = m_Scene.GetNewRezLocation(RayStart, RayEnd,
558 // find small items. 670 RayTargetID, Quaternion.Identity,
559 // 671 BypassRayCast, bRayEndIsIntersection, true,
560 if (!attachment) 672 bbox, false);
561 group.RootPart.CreateSelected = true; 673
674 pos -= bbox / 2;
675
676 XmlNodeList groups = e.SelectNodes("SceneObjectGroup");
677 foreach (XmlNode n in groups)
678 {
679 SceneObjectGroup g =
680 SceneObjectSerializer.FromOriginalXmlFormat(
681 itemId, n.OuterXml);
682 objlist.Add(g);
683 XmlElement el = (XmlElement)n;
684 float x = Convert.ToSingle(el.GetAttribute("offsetx"));
685 float y = Convert.ToSingle(el.GetAttribute("offsety"));
686 float z = Convert.ToSingle(el.GetAttribute("offsetz"));
687 veclist.Add(new Vector3(x, y, z));
688 }
689 }
690
691 int primcount = 0;
692 foreach (SceneObjectGroup g in objlist)
693 primcount += g.PrimCount;
562 694
563 if (!m_Scene.Permissions.CanRezObject( 695 if (!m_Scene.Permissions.CanRezObject(
564 group.PrimCount, remoteClient.AgentId, pos) 696 primcount, remoteClient.AgentId, pos)
565 && !attachment) 697 && !attachment)
566 { 698 {
567 // The client operates in no fail mode. It will 699 // The client operates in no fail mode. It will
@@ -574,131 +706,161 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
574 return null; 706 return null;
575 } 707 }
576 708
577 group.ResetIDs(); 709 for (int i = 0 ; i < objlist.Count ; i++ )
578
579 if (attachment)
580 { 710 {
581 group.RootPart.Flags |= PrimFlags.Phantom; 711 group = objlist[i];
582 group.RootPart.IsAttachment = true;
583
584 // If we're rezzing an attachment then don't ask
585 // AddNewSceneObject() to update the client since
586 // we'll be doing that later on. Scheduling more
587 // than one full update during the attachment
588 // process causes some clients to fail to display
589 // the attachment properly.
590 // Also, don't persist attachments.
591 m_Scene.AddNewSceneObject(group, false, false);
592 }
593 else
594 {
595 m_Scene.AddNewSceneObject(group, true, false);
596 }
597 712
598 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); 713 Vector3 storedPosition = group.AbsolutePosition;
599 // if attachment we set it's asset id so object updates can reflect that 714 if (group.UUID == UUID.Zero)
600 // if not, we set it's position in world. 715 {
601 if (!attachment) 716 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3");
602 { 717 }
603 group.ScheduleGroupForFullUpdate(); 718 group.RootPart.FromFolderID = item.Folder;
604
605 float offsetHeight = 0;
606 pos = m_Scene.GetNewRezLocation(
607 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
608 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
609 pos.Z += offsetHeight;
610 group.AbsolutePosition = pos;
611 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
612 719
613 } 720 // If it's rezzed in world, select it. Much easier to
614 else 721 // find small items.
615 { 722 //
616 group.SetFromItemID(itemID); 723 if (!attachment)
617 } 724 {
725 group.RootPart.CreateSelected = true;
726 foreach (SceneObjectPart child in group.Parts)
727 child.CreateSelected = true;
728 }
618 729
619 SceneObjectPart rootPart = null; 730 group.ResetIDs();
620 try
621 {
622 rootPart = group.GetChildPart(group.UUID);
623 }
624 catch (NullReferenceException)
625 {
626 string isAttachment = "";
627 731
628 if (attachment) 732 if (attachment)
629 isAttachment = " Object was an attachment"; 733 {
734 group.RootPart.Flags |= PrimFlags.Phantom;
735 group.RootPart.IsAttachment = true;
736
737 // If we're rezzing an attachment then don't ask
738 // AddNewSceneObject() to update the client since
739 // we'll be doing that later on. Scheduling more
740 // than one full update during the attachment
741 // process causes some clients to fail to display
742 // the attachment properly.
743 // Also, don't persist attachments.
744 m_Scene.AddNewSceneObject(group, false, false);
745 }
746 else
747 {
748 m_Scene.AddNewSceneObject(group, true, false);
749 }
630 750
631 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); 751 // if attachment we set it's asset id so object updates
632 } 752 // can reflect that, if not, we set it's position in world.
753 if (!attachment)
754 {
755 group.ScheduleGroupForFullUpdate();
756
757 group.AbsolutePosition = pos + veclist[i];
758 }
759 else
760 {
761 group.SetFromItemID(itemID);
762 }
633 763
634 // Since renaming the item in the inventory does not affect the name stored 764 SceneObjectPart rootPart = null;
635 // in the serialization, transfer the correct name from the inventory to the
636 // object itself before we rez.
637 rootPart.Name = item.Name;
638 rootPart.Description = item.Description;
639 765
640 if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0) 766 try
641 { 767 {
642 rootPart.ObjectSaleType = item.SaleType; 768 rootPart = group.GetChildPart(group.UUID);
643 rootPart.SalePrice = item.SalePrice; 769 }
644 } 770 catch (NullReferenceException)
771 {
772 string isAttachment = "";
773
774 if (attachment)
775 isAttachment = " Object was an attachment";
776
777 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
778 }
779
780 // Since renaming the item in the inventory does not
781 // affect the name stored in the serialization, transfer
782 // the correct name from the inventory to the
783 // object itself before we rez.
784 // On coalesced objects, this has no effect.
785 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
786 {
787 rootPart.Name = item.Name;
788 rootPart.Description = item.Description;
789 }
790 if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0)
791 {
792 rootPart.ObjectSaleType = item.SaleType;
793 rootPart.SalePrice = item.SalePrice;
794 }
645 795
646 group.SetGroup(remoteClient.ActiveGroupId, remoteClient); 796 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
647 if ((rootPart.OwnerID != item.Owner) || 797 // TODO: Remove the magic number badness
798
799 if ((rootPart.OwnerID != item.Owner) ||
648 (item.CurrentPermissions & 16) != 0 || // Magic number 800 (item.CurrentPermissions & 16) != 0 || // Magic number
649 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) 801 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
650 {
651 //Need to kill the for sale here
652 rootPart.ObjectSaleType = 0;
653 rootPart.SalePrice = 10;
654
655 if (m_Scene.Permissions.PropagatePermissions())
656 { 802 {
657 foreach (SceneObjectPart part in group.Parts) 803 //Need to kill the for sale here
804 rootPart.ObjectSaleType = 0;
805 rootPart.SalePrice = 10;
806
807 if (m_Scene.Permissions.PropagatePermissions())
658 { 808 {
659 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) 809 foreach (SceneObjectPart part in group.Parts)
660 part.EveryoneMask = item.EveryOnePermissions; 810 {
661 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) 811 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
662 part.NextOwnerMask = item.NextPermissions; 812 {
663 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) 813 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
664 part.GroupMask = item.GroupPermissions; 814 part.EveryoneMask = item.EveryOnePermissions;
815 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
816 part.NextOwnerMask = item.NextPermissions;
817 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
818 part.GroupMask = item.GroupPermissions;
819 }
820 }
821
822 group.ApplyNextOwnerPermissions();
665 } 823 }
666
667 group.ApplyNextOwnerPermissions();
668 } 824 }
669 }
670 825
671 foreach (SceneObjectPart part in group.Parts) 826 foreach (SceneObjectPart part in group.Parts)
672 {
673 if ((part.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0)
674 { 827 {
675 part.LastOwnerID = part.OwnerID; 828 // TODO: Remove the magic number badness
676 part.OwnerID = item.Owner; 829 if ((part.OwnerID != item.Owner) ||
677 part.Inventory.ChangeInventoryOwner(item.Owner); 830 (item.CurrentPermissions & 16) != 0 || // Magic number
678 part.GroupMask = 0; // DO NOT propagate here 831 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
832 {
833 part.LastOwnerID = part.OwnerID;
834 part.OwnerID = item.Owner;
835 part.Inventory.ChangeInventoryOwner(item.Owner);
836 }
837 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
838 part.EveryoneMask = item.EveryOnePermissions;
839 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
840 part.NextOwnerMask = item.NextPermissions;
841 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
842 part.GroupMask = item.GroupPermissions;
679 } 843 }
680 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
681 part.EveryoneMask = item.EveryOnePermissions;
682 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
683 part.NextOwnerMask = item.NextPermissions;
684 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
685 part.GroupMask = item.GroupPermissions;
686 }
687 844
688 rootPart.TrimPermissions(); 845 rootPart.TrimPermissions();
689 846
690 if (!attachment) 847 if (!attachment)
691 {
692 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
693 { 848 {
694 group.ClearPartAttachmentData(); 849 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
695 } 850 {
696 851 // Save attachment data
697 // Fire on_rez 852 group.RootPart.AttachPoint = group.RootPart.Shape.State;
698 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); 853 group.RootPart.AttachOffset = storedPosition;
699 rootPart.ParentGroup.ResumeScripts();
700 854
701 rootPart.ScheduleFullUpdate(); 855 group.ClearPartAttachmentData();
856 }
857
858 // Fire on_rez
859 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1);
860 rootPart.ParentGroup.ResumeScripts();
861
862 rootPart.ScheduleFullUpdate();
863 }
702 } 864 }
703 865
704 if (!m_Scene.Permissions.BypassPermissions()) 866 if (!m_Scene.Permissions.BypassPermissions())
@@ -716,9 +878,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
716 } 878 }
717 } 879 }
718 } 880 }
719
720 return rootPart.ParentGroup;
721 } 881 }
882 return group;
722 } 883 }
723 884
724 return null; 885 return null;
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index d78931a..51742ff 100644
--- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -341,6 +341,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
341 try 341 try
342 { 342 {
343 Request = (HttpWebRequest) WebRequest.Create(Url); 343 Request = (HttpWebRequest) WebRequest.Create(Url);
344
345 //This works around some buggy HTTP Servers like Lighttpd
346 Request.ServicePoint.Expect100Continue = false;
347
344 Request.Method = HttpMethod; 348 Request.Method = HttpMethod;
345 Request.ContentType = HttpMIMEType; 349 Request.ContentType = HttpMIMEType;
346 350
@@ -404,7 +408,17 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
404 { 408 {
405 HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response; 409 HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response;
406 Status = (int)webRsp.StatusCode; 410 Status = (int)webRsp.StatusCode;
407 ResponseBody = webRsp.StatusDescription; 411 try
412 {
413 using (Stream responseStream = webRsp.GetResponseStream())
414 {
415 ResponseBody = responseStream.GetStreamString();
416 }
417 }
418 catch
419 {
420 ResponseBody = webRsp.StatusDescription;
421 }
408 } 422 }
409 else 423 else
410 { 424 {
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 9b565ed..66eb747 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 = 1000;
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 e54ee02..ebfba2b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -57,9 +57,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
57 config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); 57 config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
58 config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); 58 config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
59 config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); 59 config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
60 config.Configs["GridService"].Set("Region_Test_Region_1", "DefaultRegion"); 60 config.Configs["GridService"].Set("Region_Test_Region_1", "DefaultRegion");
61 config.Configs["GridService"].Set("Region_Test_Region_2", "FallbackRegion"); 61 config.Configs["GridService"].Set("Region_Test_Region_2", "FallbackRegion");
62 config.Configs["GridService"].Set("Region_Test_Region_3", "FallbackRegion"); 62 config.Configs["GridService"].Set("Region_Test_Region_3", "FallbackRegion");
63 config.Configs["GridService"].Set("Region_Other_Region_4", "FallbackRegion"); 63 config.Configs["GridService"].Set("Region_Other_Region_4", "FallbackRegion");
64 64
65 m_LocalConnector = new LocalGridServicesConnector(config); 65 m_LocalConnector = new LocalGridServicesConnector(config);
@@ -128,8 +128,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
128 Assert.IsNotNull(result, "Retrieved GetRegionByName is null"); 128 Assert.IsNotNull(result, "Retrieved GetRegionByName is null");
129 Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match"); 129 Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match");
130 130
131 m_LocalConnector.RegisterRegion(UUID.Zero, r2); 131 m_LocalConnector.RegisterRegion(UUID.Zero, r2);
132 m_LocalConnector.RegisterRegion(UUID.Zero, r3); 132 m_LocalConnector.RegisterRegion(UUID.Zero, r3);
133 m_LocalConnector.RegisterRegion(UUID.Zero, r4); 133 m_LocalConnector.RegisterRegion(UUID.Zero, r4);
134 134
135 result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1)); 135 result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1));
@@ -154,38 +154,38 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
154 Assert.IsNotNull(results, "Retrieved GetRegionRange collection is null"); 154 Assert.IsNotNull(results, "Retrieved GetRegionRange collection is null");
155 Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected"); 155 Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected");
156 156
157 results = m_LocalConnector.GetDefaultRegions(UUID.Zero); 157 results = m_LocalConnector.GetDefaultRegions(UUID.Zero);
158 Assert.IsNotNull(results, "Retrieved GetDefaultRegions collection is null"); 158 Assert.IsNotNull(results, "Retrieved GetDefaultRegions collection is null");
159 Assert.That(results.Count, Is.EqualTo(1), "Retrieved default regions collection has not the expected size"); 159 Assert.That(results.Count, Is.EqualTo(1), "Retrieved default regions collection has not the expected size");
160 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(1)), "Retrieved default region's UUID does not match"); 160 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(1)), "Retrieved default region's UUID does not match");
161 161
162 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r1.RegionLocX, r1.RegionLocY); 162 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r1.RegionLocX, r1.RegionLocY);
163 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 1 is null"); 163 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 1 is null");
164 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 1 has not the expected size"); 164 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 1 has not the expected size");
165 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[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions for default region are not in the expected order 2-4-3");
166 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[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions for default region are not in the expected order 2-4-3");
167 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 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");
168 168
169 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r2.RegionLocX, r2.RegionLocY); 169 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r2.RegionLocX, r2.RegionLocY);
170 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 2 is null"); 170 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 2 is null");
171 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 2 has not the expected size"); 171 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 2 has not the expected size");
172 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[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 2-4-3");
173 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[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 2-4-3");
174 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 2-4-3"); 174 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 2-4-3");
175 175
176 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r3.RegionLocX, r3.RegionLocY); 176 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r3.RegionLocX, r3.RegionLocY);
177 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 3 is null"); 177 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 3 is null");
178 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 3 has not the expected size"); 178 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 3 has not the expected size");
179 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[0].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 3-4-2");
180 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[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 3-4-2");
181 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 3-4-2"); 181 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 3-4-2");
182 182
183 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r4.RegionLocX, r4.RegionLocY); 183 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r4.RegionLocX, r4.RegionLocY);
184 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 4 is null"); 184 Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 4 is null");
185 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 4 has not the expected size"); 185 Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 4 has not the expected size");
186 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[0].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 4-3-2");
187 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[1].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 4-3-2");
188 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 4-3-2"); 188 Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 4-3-2");
189 189
190 results = m_LocalConnector.GetHyperlinks(UUID.Zero); 190 results = m_LocalConnector.GetHyperlinks(UUID.Zero);
191 Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null"); 191 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 56720b7..9363714 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -267,7 +267,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
267 if (s.RegionInfo.RegionID == destination.RegionID) 267 if (s.RegionInfo.RegionID == destination.RegionID)
268 return s.QueryAccess(id, position); 268 return s.QueryAccess(id, position);
269 } 269 }
270 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
271 return false; 270 return false;
272 } 271 }
273 272
@@ -297,10 +296,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
297 if (s.RegionInfo.RegionID == destination.RegionID) 296 if (s.RegionInfo.RegionID == destination.RegionID)
298 { 297 {
299 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); 298 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
300 // Let's spawn a threadlet right here, because this may take 299 return s.IncomingCloseAgent(id);
301 // a while 300 }
302 Util.FireAndForget(delegate { s.IncomingCloseAgent(id); }); 301 }
303 return true; 302 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
303 return false;
304 }
305
306 public bool CloseChildAgent(GridRegion destination, UUID id)
307 {
308 if (destination == null)
309 return false;
310
311 foreach (Scene s in m_sceneList)
312 {
313 if (s.RegionInfo.RegionID == destination.RegionID)
314 {
315 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
316 return s.IncomingCloseChildAgent(id);
304 } 317 }
305 } 318 }
306 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); 319 //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 c4919b3..e8a6629 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -269,6 +269,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
269 return false; 269 return false;
270 } 270 }
271 271
272 public bool CloseChildAgent(GridRegion destination, UUID id)
273 {
274 if (destination == null)
275 return false;
276
277 // Try local first
278 if (m_localBackend.CloseChildAgent(destination, id))
279 return true;
280
281 // else do the remote thing
282 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
283 return m_remoteConnector.CloseChildAgent(destination, id);
284
285 return false;
286 }
272 287
273 public bool CloseAgent(GridRegion destination, UUID id) 288 public bool CloseAgent(GridRegion destination, UUID id)
274 { 289 {
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 01f04d9..3653842 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -29,6 +29,7 @@ using System.Collections.Generic;
29using System.IO; 29using System.IO;
30using System.Reflection; 30using System.Reflection;
31using System.Security; 31using System.Security;
32using System.Timers;
32using log4net; 33using log4net;
33using Nini.Config; 34using Nini.Config;
34using OpenMetaverse; 35using OpenMetaverse;
@@ -45,6 +46,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
45 private delegate void LookupUUIDS(List<UUID> uuidLst); 46 private delegate void LookupUUIDS(List<UUID> uuidLst);
46 47
47 private Scene m_scene; 48 private Scene m_scene;
49 private Timer m_regionChangeTimer = new Timer();
48 50
49 private EstateTerrainXferHandler TerrainUploader; 51 private EstateTerrainXferHandler TerrainUploader;
50 52
@@ -246,7 +248,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
246 timeInSeconds -= 15; 248 timeInSeconds -= 15;
247 } 249 }
248 250
249 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); 251 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), false);
250 } 252 }
251 } 253 }
252 254
@@ -266,7 +268,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
266 268
267 if ((estateAccessType & 4) != 0) // User add 269 if ((estateAccessType & 4) != 0) // User add
268 { 270 {
269 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 271 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
270 { 272 {
271 m_scene.RegionInfo.EstateSettings.AddEstateUser(user); 273 m_scene.RegionInfo.EstateSettings.AddEstateUser(user);
272 m_scene.RegionInfo.EstateSettings.Save(); 274 m_scene.RegionInfo.EstateSettings.Save();
@@ -281,7 +283,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
281 } 283 }
282 if ((estateAccessType & 8) != 0) // User remove 284 if ((estateAccessType & 8) != 0) // User remove
283 { 285 {
284 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 286 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
285 { 287 {
286 m_scene.RegionInfo.EstateSettings.RemoveEstateUser(user); 288 m_scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
287 m_scene.RegionInfo.EstateSettings.Save(); 289 m_scene.RegionInfo.EstateSettings.Save();
@@ -296,7 +298,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
296 } 298 }
297 if ((estateAccessType & 16) != 0) // Group add 299 if ((estateAccessType & 16) != 0) // Group add
298 { 300 {
299 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 301 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
300 { 302 {
301 m_scene.RegionInfo.EstateSettings.AddEstateGroup(user); 303 m_scene.RegionInfo.EstateSettings.AddEstateGroup(user);
302 m_scene.RegionInfo.EstateSettings.Save(); 304 m_scene.RegionInfo.EstateSettings.Save();
@@ -310,7 +312,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
310 } 312 }
311 if ((estateAccessType & 32) != 0) // Group remove 313 if ((estateAccessType & 32) != 0) // Group remove
312 { 314 {
313 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 315 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
314 { 316 {
315 m_scene.RegionInfo.EstateSettings.RemoveEstateGroup(user); 317 m_scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
316 m_scene.RegionInfo.EstateSettings.Save(); 318 m_scene.RegionInfo.EstateSettings.Save();
@@ -359,7 +361,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
359 { 361 {
360 if (!s.IsChildAgent) 362 if (!s.IsChildAgent)
361 { 363 {
362 m_scene.TeleportClientHome(user, s.ControllingClient); 364 if (!m_scene.TeleportClientHome(user, s.ControllingClient))
365 {
366 s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
367 s.ControllingClient.Close();
368 }
363 } 369 }
364 } 370 }
365 371
@@ -493,7 +499,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
493 ScenePresence s = m_scene.GetScenePresence(prey); 499 ScenePresence s = m_scene.GetScenePresence(prey);
494 if (s != null) 500 if (s != null)
495 { 501 {
496 m_scene.TeleportClientHome(prey, s.ControllingClient); 502 if (!m_scene.TeleportClientHome(prey, s.ControllingClient))
503 {
504 s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
505 s.ControllingClient.Close();
506 }
497 } 507 }
498 } 508 }
499 } 509 }
@@ -512,7 +522,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
512 // Also make sure they are actually in the region 522 // Also make sure they are actually in the region
513 if (p != null && !p.IsChildAgent) 523 if (p != null && !p.IsChildAgent)
514 { 524 {
515 m_scene.TeleportClientHome(p.UUID, p.ControllingClient); 525 if (!m_scene.TeleportClientHome(p.UUID, p.ControllingClient))
526 {
527 p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
528 p.ControllingClient.Close();
529 }
516 } 530 }
517 } 531 }
518 }); 532 });
@@ -898,6 +912,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
898 m_scene.RegisterModuleInterface<IEstateModule>(this); 912 m_scene.RegisterModuleInterface<IEstateModule>(this);
899 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 913 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
900 m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight; 914 m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
915 m_regionChangeTimer.AutoReset = false;
916 m_regionChangeTimer.Interval = 2000;
917 m_regionChangeTimer.Elapsed += RaiseRegionInfoChange;
901 918
902 m_scene.AddCommand(this, "set terrain texture", 919 m_scene.AddCommand(this, "set terrain texture",
903 "set terrain texture <number> <uuid> [<x>] [<y>]", 920 "set terrain texture <number> <uuid> [<x>] [<y>]",
@@ -1170,6 +1187,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
1170 1187
1171 protected void TriggerRegionInfoChange() 1188 protected void TriggerRegionInfoChange()
1172 { 1189 {
1190 m_regionChangeTimer.Stop();
1191 m_regionChangeTimer.Start();
1192 }
1193
1194 protected void RaiseRegionInfoChange(object sender, ElapsedEventArgs e)
1195 {
1173 ChangeDelegate change = OnRegionInfoChange; 1196 ChangeDelegate change = OnRegionInfoChange;
1174 1197
1175 if (change != null) 1198 if (change != null)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 98ba8c3..b671aec 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -92,11 +92,11 @@ namespace OpenSim.Region.CoreModules.World.Land
92 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 92 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
93 93
94 private bool m_allowedForcefulBans = true; 94 private bool m_allowedForcefulBans = true;
95 private UUID DefaultGodParcelGroup;
96 private string DefaultGodParcelName;
95 97
96 // caches ExtendedLandData 98 // caches ExtendedLandData
97 private Cache parcelInfoCache; 99 private Cache parcelInfoCache;
98 private Dictionary<UUID, Vector3> forcedPosition =
99 new Dictionary<UUID, Vector3>();
100 100
101 #region INonSharedRegionModule Members 101 #region INonSharedRegionModule Members
102 102
@@ -107,6 +107,12 @@ namespace OpenSim.Region.CoreModules.World.Land
107 107
108 public void Initialise(IConfigSource source) 108 public void Initialise(IConfigSource source)
109 { 109 {
110 IConfig cnf = source.Configs["LandManagement"];
111 if (cnf != null)
112 {
113 DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
114 DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
115 }
110 } 116 }
111 117
112 public void AddRegion(Scene scene) 118 public void AddRegion(Scene scene)
@@ -215,36 +221,6 @@ namespace OpenSim.Region.CoreModules.World.Land
215 221
216 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 222 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
217 { 223 {
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 } 224 }
249 225
250 public void Close() 226 public void Close()
@@ -359,10 +335,16 @@ namespace OpenSim.Region.CoreModules.World.Land
359 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) 335 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
360 { 336 {
361 if (m_scene.Permissions.IsGod(avatar.UUID)) return; 337 if (m_scene.Permissions.IsGod(avatar.UUID)) return;
362 if (position.HasValue) 338
363 { 339 if (!position.HasValue)
364 forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; 340 return;
365 } 341
342 bool isFlying = avatar.PhysicsActor.Flying;
343 avatar.RemoveFromPhysicalScene();
344
345 avatar.AbsolutePosition = (Vector3)position;
346
347 avatar.AddToPhysicalScene(isFlying);
366 } 348 }
367 349
368 public void SendYouAreRestrictedNotice(ScenePresence avatar) 350 public void SendYouAreRestrictedNotice(ScenePresence avatar)
@@ -385,15 +367,17 @@ namespace OpenSim.Region.CoreModules.World.Land
385 { 367 {
386 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT) 368 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
387 { 369 {
388 if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID)) 370 if (parcelAvatarIsEntering.IsEitherBannedOrRestricted(avatar.UUID))
389 { 371 {
390 SendYouAreBannedNotice(avatar); 372 SendYouAreBannedNotice(avatar);
391 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); 373 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
374 //ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
392 } 375 }
393 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID)) 376 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
394 { 377 {
395 SendYouAreRestrictedNotice(avatar); 378 SendYouAreRestrictedNotice(avatar);
396 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); 379 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
380 //ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
397 } 381 }
398 else 382 else
399 { 383 {
@@ -491,26 +475,15 @@ namespace OpenSim.Region.CoreModules.World.Land
491 else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT && 475 else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
492 parcel.IsBannedFromLand(clientAvatar.UUID)) 476 parcel.IsBannedFromLand(clientAvatar.UUID))
493 { 477 {
494 //once we've sent the message once, keep going toward the target until we are done 478 // SendYouAreBannedNotice(clientAvatar);
495 if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId)) 479 //ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
496 { 480 ForceAvatarToPosition(clientAvatar, clientAvatar.lastKnownAllowedPosition);
497 SendYouAreBannedNotice(clientAvatar);
498 ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
499 }
500 } 481 }
501 else if (parcel.IsRestrictedFromLand(clientAvatar.UUID)) 482 else if (parcel.IsRestrictedFromLand(clientAvatar.UUID))
502 { 483 {
503 //once we've sent the message once, keep going toward the target until we are done 484 // SendYouAreRestrictedNotice(clientAvatar);
504 if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId)) 485 //ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
505 { 486 ForceAvatarToPosition(clientAvatar, clientAvatar.lastKnownAllowedPosition);
506 SendYouAreRestrictedNotice(clientAvatar);
507 ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
508 }
509 }
510 else
511 {
512 //when we are finally in a safe place, lets release the forced position lock
513 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
514 } 487 }
515 } 488 }
516 } 489 }
@@ -709,7 +682,7 @@ namespace OpenSim.Region.CoreModules.World.Land
709 int x; 682 int x;
710 int y; 683 int y;
711 684
712 if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) 685 if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0)
713 return null; 686 return null;
714 687
715 try 688 try
@@ -1052,6 +1025,10 @@ namespace OpenSim.Region.CoreModules.World.Land
1052 //Owner Flag 1025 //Owner Flag
1053 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); 1026 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER);
1054 } 1027 }
1028 else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID))
1029 {
1030 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP);
1031 }
1055 else if (currentParcelBlock.LandData.SalePrice > 0 && 1032 else if (currentParcelBlock.LandData.SalePrice > 0 &&
1056 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || 1033 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
1057 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) 1034 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
@@ -1345,24 +1322,38 @@ namespace OpenSim.Region.CoreModules.World.Land
1345 { 1322 {
1346 land.DeedToGroup(groupID); 1323 land.DeedToGroup(groupID);
1347 } 1324 }
1325 EventManagerOnParcelPrimCountTainted();
1348 } 1326 }
1349 1327
1350 #region Land Object From Storage Functions 1328 #region Land Object From Storage Functions
1351 1329
1352 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1330 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
1353 { 1331 {
1354 for (int i = 0; i < data.Count; i++) 1332 lock (m_landList)
1355 { 1333 {
1356 IncomingLandObjectFromStorage(data[i]); 1334 //Remove all the land objects in the sim and then process our new data
1335 foreach (int n in m_landList.Keys)
1336 {
1337 m_scene.EventManager.TriggerLandObjectRemoved(m_landList[n].LandData.GlobalID);
1338 }
1339 m_landIDList.Initialize();
1340 m_landList.Clear();
1341
1342 for (int i = 0; i < data.Count; i++)
1343 {
1344 IncomingLandObjectFromStorage(data[i]);
1345 }
1357 } 1346 }
1358 } 1347 }
1359 1348
1360 public void IncomingLandObjectFromStorage(LandData data) 1349 public void IncomingLandObjectFromStorage(LandData data)
1361 { 1350 {
1351
1362 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); 1352 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1363 new_land.LandData = data.Copy(); 1353 new_land.LandData = data.Copy();
1364 new_land.SetLandBitmapFromByteArray(); 1354 new_land.SetLandBitmapFromByteArray();
1365 AddLandObject(new_land); 1355 AddLandObject(new_land);
1356 new_land.SendLandUpdateToAvatarsOverMe();
1366 } 1357 }
1367 1358
1368 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) 1359 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
@@ -1636,6 +1627,322 @@ namespace OpenSim.Region.CoreModules.World.Land
1636 1627
1637 UpdateLandObject(localID, land.LandData); 1628 UpdateLandObject(localID, land.LandData);
1638 } 1629 }
1630
1631 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
1632 {
1633 ILandObject land = null;
1634 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
1635 foreach (ILandObject landObject in Land)
1636 {
1637 if (landObject.LandData.LocalID == landID)
1638 {
1639 land = landObject;
1640 }
1641 }
1642 land.DeedToGroup(DefaultGodParcelGroup);
1643 land.LandData.Name = DefaultGodParcelName;
1644 land.SendLandUpdateToAvatarsOverMe();
1645 }
1646
1647 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
1648 {
1649 ScenePresence SP;
1650 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP);
1651 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
1652 if (SP.UserLevel != 0)
1653 {
1654 if (flags == 0) //All parcels, scripted or not
1655 {
1656 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1657 {
1658 if (e.OwnerID == targetID)
1659 {
1660 returns.Add(e);
1661 }
1662 }
1663 );
1664 }
1665 if (flags == 4) //All parcels, scripted object
1666 {
1667 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1668 {
1669 if (e.OwnerID == targetID)
1670 {
1671 if (e.scriptScore >= 0.01)
1672 {
1673 returns.Add(e);
1674 }
1675 }
1676 }
1677 );
1678 }
1679 if (flags == 4) //not target parcel, scripted object
1680 {
1681 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1682 {
1683 if (e.OwnerID == targetID)
1684 {
1685 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1686 if (landobject.LandData.OwnerID != e.OwnerID)
1687 {
1688 if (e.scriptScore >= 0.01)
1689 {
1690 returns.Add(e);
1691 }
1692 }
1693 }
1694 }
1695 );
1696 }
1697 foreach (SceneObjectGroup ol in returns)
1698 {
1699 ReturnObject(ol, client);
1700 }
1701 }
1702 }
1703 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
1704 {
1705 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1706 objs[0] = obj;
1707 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
1708 }
1709
1710 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1711
1712 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1713 {
1714 ScenePresence targetAvatar = null;
1715 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1716 ScenePresence parcelManager = null;
1717 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1718 System.Threading.Timer Timer;
1719
1720 if (targetAvatar.UserLevel == 0)
1721 {
1722 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1723 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1724 return;
1725 if (flags == 0)
1726 {
1727 targetAvatar.AllowMovement = false;
1728 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
1729 parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
1730 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
1731 Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
1732 Timers.Add(targetAvatar.UUID, Timer);
1733 }
1734 else
1735 {
1736 targetAvatar.AllowMovement = true;
1737 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
1738 parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
1739 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1740 Timers.Remove(targetAvatar.UUID);
1741 Timer.Dispose();
1742 }
1743 }
1744 }
1745 private void OnEndParcelFrozen(object avatar)
1746 {
1747 ScenePresence targetAvatar = (ScenePresence)avatar;
1748 targetAvatar.AllowMovement = true;
1749 System.Threading.Timer Timer;
1750 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1751 Timers.Remove(targetAvatar.UUID);
1752 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1753 }
1754
1755
1756 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1757 {
1758 ScenePresence targetAvatar = null;
1759 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1760 ScenePresence parcelManager = null;
1761 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1762 //Just eject
1763 if (flags == 0)
1764 {
1765 if (targetAvatar.UserLevel == 0)
1766 {
1767 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1768 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1769 return;
1770
1771 Vector3 position = new Vector3(0, 0, 0);
1772 List<ILandObject> allParcels = new List<ILandObject>();
1773 allParcels = AllParcels();
1774 if (allParcels.Count != 1)
1775 {
1776 foreach (ILandObject parcel in allParcels)
1777 {
1778 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1779 {
1780 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1781 {
1782 for (int x = 1; x <= Constants.RegionSize; x += 2)
1783 {
1784 for (int y = 1; y <= Constants.RegionSize; y += 2)
1785 {
1786 if (parcel.ContainsPoint(x, y))
1787 {
1788 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1789 targetAvatar.TeleportWithMomentum(position);
1790 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1791 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1792 return;
1793 }
1794 }
1795 }
1796 }
1797 }
1798 }
1799 }
1800 Vector3 targetVector;
1801 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1802 {
1803 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1804 {
1805 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1806 targetAvatar.TeleportWithMomentum(targetVector);
1807 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1808 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1809 return;
1810 }
1811 else
1812 {
1813 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1814 targetAvatar.TeleportWithMomentum(targetVector);
1815 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1816 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1817 return;
1818 }
1819 }
1820 else
1821 {
1822 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1823 {
1824 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1825 targetAvatar.TeleportWithMomentum(targetVector);
1826 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1827 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1828 return;
1829 }
1830 else
1831 {
1832 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1833 targetAvatar.TeleportWithMomentum(targetVector);
1834 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1835 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1836 return;
1837 }
1838 }
1839 }
1840 }
1841 //Eject and ban
1842 if (flags == 1)
1843 {
1844 if (targetAvatar.UserLevel == 0)
1845 {
1846 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1847 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1848 return;
1849
1850 Vector3 position = new Vector3(0, 0, 0);
1851 List<ILandObject> allParcels = new List<ILandObject>();
1852 allParcels = AllParcels();
1853 if (allParcels.Count != 1)
1854 {
1855 foreach (ILandObject parcel in allParcels)
1856 {
1857 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1858 {
1859 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1860 {
1861 for (int x = 1; x <= Constants.RegionSize; x += 2)
1862 {
1863 for (int y = 1; y <= Constants.RegionSize; y += 2)
1864 {
1865 if (parcel.ContainsPoint(x, y))
1866 {
1867 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1868 targetAvatar.TeleportWithMomentum(position);
1869 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1870 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1871 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1872 entry.AgentID = targetAvatar.UUID;
1873 entry.Flags = AccessList.Ban;
1874 entry.Time = new DateTime();
1875 land.LandData.ParcelAccessList.Add(entry);
1876 return;
1877 }
1878 }
1879 }
1880 }
1881 }
1882 }
1883 }
1884 Vector3 targetVector;
1885 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1886 {
1887 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1888 {
1889 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1890 targetAvatar.TeleportWithMomentum(targetVector);
1891 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1892 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1893 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1894 entry.AgentID = targetAvatar.UUID;
1895 entry.Flags = AccessList.Ban;
1896 entry.Time = new DateTime();
1897 land.LandData.ParcelAccessList.Add(entry);
1898 return;
1899 }
1900 else
1901 {
1902 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1903 targetAvatar.TeleportWithMomentum(targetVector);
1904 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1905 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1906 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1907 entry.AgentID = targetAvatar.UUID;
1908 entry.Flags = AccessList.Ban;
1909 entry.Time = new DateTime();
1910 land.LandData.ParcelAccessList.Add(entry);
1911 return;
1912 }
1913 }
1914 else
1915 {
1916 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1917 {
1918 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1919 targetAvatar.TeleportWithMomentum(targetVector);
1920 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1921 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1922 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1923 entry.AgentID = targetAvatar.UUID;
1924 entry.Flags = AccessList.Ban;
1925 entry.Time = new DateTime();
1926 land.LandData.ParcelAccessList.Add(entry);
1927 return;
1928 }
1929 else
1930 {
1931 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1932 targetAvatar.TeleportWithMomentum(targetVector);
1933 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1934 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1935 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1936 entry.AgentID = targetAvatar.UUID;
1937 entry.Flags = AccessList.Ban;
1938 entry.Time = new DateTime();
1939 land.LandData.ParcelAccessList.Add(entry);
1940 return;
1941 }
1942 }
1943 }
1944 }
1945 }
1639 1946
1640 protected void InstallInterfaces() 1947 protected void InstallInterfaces()
1641 { 1948 {
@@ -1699,4 +2006,4 @@ namespace OpenSim.Region.CoreModules.World.Land
1699 MainConsole.Instance.Output(report.ToString()); 2006 MainConsole.Instance.Output(report.ToString());
1700 } 2007 }
1701 } 2008 }
1702} \ No newline at end of file 2009}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 46c15ed..b114db1 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -414,6 +414,37 @@ namespace OpenSim.Region.CoreModules.World.Land
414 return false; 414 return false;
415 } 415 }
416 416
417 public bool HasGroupAccess(UUID avatar)
418 {
419 if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup)
420 {
421 ScenePresence sp;
422 if (!m_scene.TryGetScenePresence(avatar, out sp))
423 {
424 IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
425 if (groupsModule == null)
426 return false;
427
428 GroupMembershipData[] membership = groupsModule.GetMembershipData(avatar);
429 if (membership == null || membership.Length == 0)
430 return false;
431
432 foreach (GroupMembershipData d in membership)
433 {
434 if (d.GroupID == LandData.GroupID)
435 return true;
436 }
437 return false;
438 }
439
440 if (!sp.ControllingClient.IsGroupMember(LandData.GroupID))
441 return false;
442
443 return true;
444 }
445 return false;
446 }
447
417 public bool IsBannedFromLand(UUID avatar) 448 public bool IsBannedFromLand(UUID avatar)
418 { 449 {
419 if (m_scene.Permissions.IsAdministrator(avatar)) 450 if (m_scene.Permissions.IsAdministrator(avatar))
@@ -450,9 +481,13 @@ namespace OpenSim.Region.CoreModules.World.Land
450 return false; 481 return false;
451 }) == -1 && LandData.OwnerID != avatar) 482 }) == -1 && LandData.OwnerID != avatar)
452 { 483 {
453 return true; 484 if (!HasGroupAccess(avatar))
485 {
486 return true;
487 }
454 } 488 }
455 } 489 }
490
456 return false; 491 return false;
457 } 492 }
458 493
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 34ef67f..2d1979f 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.World.Land
169 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) 169 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
170 { 170 {
171 UUID landOwner = landData.OwnerID; 171 UUID landOwner = landData.OwnerID;
172 int partCount = obj.Parts.Length; 172 int partCount = obj.GetPartCount();
173 173
174 m_SimwideCounts[landOwner] += partCount; 174 m_SimwideCounts[landOwner] += partCount;
175 if (parcelCounts.Users.ContainsKey(obj.OwnerID)) 175 if (parcelCounts.Users.ContainsKey(obj.OwnerID))
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 364dd6c..f9b2384 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 a9e46d0..334dcb0 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
@@ -102,7 +102,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
102 GridRegion info = m_scene.GridService.GetRegionByName(m_scene.RegionInfo.ScopeID, mapName); 102 GridRegion info = m_scene.GridService.GetRegionByName(m_scene.RegionInfo.ScopeID, mapName);
103 if (info != null) regionInfos.Add(info); 103 if (info != null) regionInfos.Add(info);
104 } 104 }
105 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); 105
106 List<MapBlockData> blocks = new List<MapBlockData>(); 106 List<MapBlockData> blocks = new List<MapBlockData>();
107 107
108 MapBlockData data; 108 MapBlockData data;
@@ -128,14 +128,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
128 data.Agents = 0; 128 data.Agents = 0;
129 data.Access = 255; 129 data.Access = 255;
130 data.MapImageId = UUID.Zero; 130 data.MapImageId = UUID.Zero;
131 data.Name = ""; // mapName; 131 data.Name = mapName;
132 data.RegionFlags = 0; 132 data.RegionFlags = 0;
133 data.WaterHeight = 0; // not used 133 data.WaterHeight = 0; // not used
134 data.X = 0; 134 data.X = 0;
135 data.Y = 0; 135 data.Y = 0;
136 blocks.Add(data); 136 blocks.Add(data);
137 137
138 remoteClient.SendMapBlock(blocks, 0); 138 remoteClient.SendMapBlock(blocks, 2);
139 } 139 }
140 140
141// private Scene GetClientScene(IClientAPI client) 141// private Scene GetClientScene(IClientAPI client)