aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs39
-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.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs25
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs70
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs61
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs19
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs744
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs10
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs74
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs17
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs18
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs37
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs349
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs24
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs2
21 files changed, 1196 insertions, 438 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2a0c0b1..bf71c07 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;
@@ -232,15 +233,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
232 public UUID RezSingleAttachmentFromInventory( 233 public UUID RezSingleAttachmentFromInventory(
233 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) 234 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus)
234 { 235 {
235 m_log.DebugFormat( 236 return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true, null);
236 "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", 237 }
237 (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); 238
238 239 public UUID RezSingleAttachmentFromInventory(
240 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc)
241 {
239 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 242 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
240 // be removed when that functionality is implemented in opensim 243 // be removed when that functionality is implemented in opensim
241 AttachmentPt &= 0x7f; 244 AttachmentPt &= 0x7f;
242 245
243 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); 246 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt, doc);
244 247
245 if (updateInventoryStatus) 248 if (updateInventoryStatus)
246 { 249 {
@@ -257,7 +260,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
257 } 260 }
258 261
259 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 262 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
260 IClientAPI remoteClient, UUID itemID, uint AttachmentPt) 263 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, XmlDocument doc)
261 { 264 {
262 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 265 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
263 if (invAccess != null) 266 if (invAccess != null)
@@ -291,13 +294,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
291 if (tainted) 294 if (tainted)
292 objatt.HasGroupChanged = true; 295 objatt.HasGroupChanged = true;
293 296
297 if (doc != null)
298 {
299 objatt.LoadScriptState(doc);
300 objatt.ResetOwnerChangeFlag();
301 }
302
294 // Fire after attach, so we don't get messy perms dialogs 303 // Fire after attach, so we don't get messy perms dialogs
295 // 4 == AttachedRez 304 // 4 == AttachedRez
296 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); 305 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
297 objatt.ResumeScripts(); 306 objatt.ResumeScripts();
298 307
299 // Do this last so that event listeners have access to all the effects of the attachment 308 // Do this last so that event listeners have access to all the effects of the attachment
300 m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); 309 //m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
301 } 310 }
302 else 311 else
303 { 312 {
@@ -334,9 +343,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
334 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) 343 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
335 { 344 {
336 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 345 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
337 item = m_scene.InventoryService.GetItem(item); 346 if (m_scene.InventoryService != null)
347 item = m_scene.InventoryService.GetItem(item);
338 348
339 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); 349 if (presence.Appearance != null)
350 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
340 } 351 }
341 352
342 return att.UUID; 353 return att.UUID;
@@ -379,6 +390,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
379 { 390 {
380 // XXYY!! 391 // XXYY!!
381 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 392 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
393 if (item == null)
394 m_log.Error("[ATTACHMENT]: item == null");
395 if (m_scene == null)
396 m_log.Error("[ATTACHMENT]: m_scene == null");
397 if (m_scene.InventoryService == null)
398 m_log.Error("[ATTACHMENT]: m_scene.InventoryService == null");
382 item = m_scene.InventoryService.GetItem(item); 399 item = m_scene.InventoryService.GetItem(item);
383 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); 400 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
384 401
@@ -470,6 +487,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
470 if (group.GetFromItemID() == itemID) 487 if (group.GetFromItemID() == itemID)
471 { 488 {
472 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); 489 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
490 // CM / XMREngine!!!! Needed to conclude attach event
491 SceneObjectSerializer.ToOriginalXmlFormat(group);
473 group.DetachToInventoryPrep(); 492 group.DetachToInventoryPrep();
474 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); 493 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
475 UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID); 494 UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID);
@@ -609,7 +628,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
609 // 628 //
610 if (so.IsSelected) 629 if (so.IsSelected)
611 { 630 {
612 m_scene.SendKillObject(so.RootPart.LocalId); 631 m_scene.SendKillObject(new List<uint> { so.RootPart.LocalId });
613 } 632 }
614 633
615 so.IsSelected = false; // fudge.... 634 so.IsSelected = false; // fudge....
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index d76ff47..8ab4391 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 b3f0a25..45c3f49 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);
@@ -701,7 +701,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
701 // we're done 701 // we're done
702 return true; 702 return true;
703 } 703 }
704 704
705 return false; 705 return false;
706 } 706 }
707 707
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index af39565..347708d 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -156,6 +156,31 @@ 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 im.timestamp = (uint)Util.ToUnixTime(dt);
179
180 // If client is null, this message comes from storage and IS offline
181 if (client != null)
182 im.offline = 0;
183
159 if (m_TransferModule != null) 184 if (m_TransferModule != null)
160 { 185 {
161 if (client != null) 186 if (client != null)
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 918fa04..d8e0f96 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -145,8 +145,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
145 ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; 145 ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
146 if (!user.IsChildAgent) 146 if (!user.IsChildAgent)
147 { 147 {
148 // Local message 148 // 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); 149 user.ControllingClient.SendInstantMessage(im);
151 150
152 // Message sent 151 // Message sent
@@ -168,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
168 // Local message 167 // Local message
169 ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; 168 ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
170 169
171 m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); 170 // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering to client");
172 user.ControllingClient.SendInstantMessage(im); 171 user.ControllingClient.SendInstantMessage(im);
173 172
174 // Message sent 173 // Message sent
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index fdfcd10..d3db5b7 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,17 @@ 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
198 // Reconstruct imSessionID
199 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
200 {
201 UUID fromAgentID = new UUID(im.fromAgentID);
202 UUID sessionID = fromAgentID ^ client.AgentId;
203 im.imSessionID = new Guid(sessionID.ToString());
204 }
205
192 Scene s = FindScene(client.AgentId); 206 Scene s = FindScene(client.AgentId);
193 if (s != null) 207 if (s != null)
194 s.EventManager.TriggerIncomingInstantMessage(im); 208 s.EventManager.TriggerIncomingInstantMessage(im);
@@ -198,26 +212,38 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
198 212
199 private void UndeliveredMessage(GridInstantMessage im) 213 private void UndeliveredMessage(GridInstantMessage im)
200 { 214 {
201 if ((im.offline != 0) 215 if (im.dialog != (byte)InstantMessageDialog.MessageFromObject &&
202 && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages))) 216 im.dialog != (byte)InstantMessageDialog.MessageFromAgent &&
217 im.dialog != (byte)InstantMessageDialog.GroupNotice &&
218 im.dialog != (byte)InstantMessageDialog.GroupInvitation &&
219 im.dialog != (byte)InstantMessageDialog.InventoryOffered)
203 { 220 {
204 bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>( 221 return;
205 "POST", m_RestURL+"/SaveMessage/", im); 222 }
206 223
207 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 224 // It's not delivered. Make sure the scope id is saved
208 { 225 // We don't need the imSessionID here anymore, overwrite it
209 IClientAPI client = FindClient(new UUID(im.fromAgentID)); 226 Scene scene = FindScene(new UUID(im.fromAgentID));
210 if (client == null) 227 if (scene == null)
211 return; 228 scene = m_SceneList[0];
212 229 im.imSessionID = new Guid(scene.RegionInfo.ScopeID.ToString());
213 client.SendInstantMessage(new GridInstantMessage( 230
214 null, new UUID(im.toAgentID), 231 bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>(
215 "System", new UUID(im.fromAgentID), 232 "POST", m_RestURL+"/SaveMessage/", im);
216 (byte)InstantMessageDialog.MessageFromAgent, 233
217 "User is not logged in. "+ 234 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
218 (success ? "Message saved." : "Message not saved"), 235 {
219 false, new Vector3())); 236 IClientAPI client = FindClient(new UUID(im.fromAgentID));
220 } 237 if (client == null)
238 return;
239
240 client.SendInstantMessage(new GridInstantMessage(
241 null, new UUID(im.toAgentID),
242 "System", new UUID(im.fromAgentID),
243 (byte)InstantMessageDialog.MessageFromAgent,
244 "User is not logged in. "+
245 (success ? "Message saved." : "Message not saved"),
246 false, new Vector3()));
221 } 247 }
222 } 248 }
223 } 249 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index e3d4969..6badc74 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -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.
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 38fff1c..2921b0d 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -99,7 +99,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
99 99
100 protected virtual void OnNewClient(IClientAPI client) 100 protected virtual void OnNewClient(IClientAPI client)
101 { 101 {
102 client.OnTeleportHomeRequest += TeleportHome; 102 client.OnTeleportHomeRequest += TeleportHomeFired;
103 } 103 }
104 104
105 public virtual void Close() 105 public virtual void Close()
@@ -268,7 +268,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
268 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, 268 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
269 // it's actually doing a lot of work. 269 // it's actually doing a lot of work.
270 IPEndPoint endPoint = finalDestination.ExternalEndPoint; 270 IPEndPoint endPoint = finalDestination.ExternalEndPoint;
271 if (endPoint.Address != null) 271 if (endPoint != null && endPoint.Address != null)
272 { 272 {
273 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from 273 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
274 // both regions 274 // both regions
@@ -459,6 +459,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
459 // Now let's make it officially a child agent 459 // Now let's make it officially a child agent
460 sp.MakeChildAgent(); 460 sp.MakeChildAgent();
461 461
462 sp.Scene.CleanDroppedAttachments();
463
462 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone 464 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
463 465
464 if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 466 if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
@@ -527,7 +529,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
527 529
528 protected void KillEntity(Scene scene, uint localID) 530 protected void KillEntity(Scene scene, uint localID)
529 { 531 {
530 scene.SendKillObject(localID); 532 scene.SendKillObject(new List<uint>() { localID });
531 } 533 }
532 534
533 protected virtual GridRegion GetFinalDestination(GridRegion region) 535 protected virtual GridRegion GetFinalDestination(GridRegion region)
@@ -565,7 +567,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
565 567
566 #region Teleport Home 568 #region Teleport Home
567 569
568 public virtual void TeleportHome(UUID id, IClientAPI client) 570 public void TeleportHomeFired(UUID id, IClientAPI client)
571 {
572 TeleportHome(id, client);
573 }
574
575 public virtual bool TeleportHome(UUID id, IClientAPI client)
569 { 576 {
570 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); 577 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
571 578
@@ -574,14 +581,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
574 581
575 if (uinfo != null) 582 if (uinfo != null)
576 { 583 {
584 if (uinfo.HomeRegionID == UUID.Zero)
585 {
586 // can't find the Home region: Tell viewer and abort
587 client.SendTeleportFailed("You don't have a home position set.");
588 return false;
589 }
577 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); 590 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
578 if (regionInfo == null) 591 if (regionInfo == null)
579 { 592 {
580 // can't find the Home region: Tell viewer and abort 593 // can't find the Home region: Tell viewer and abort
581 client.SendTeleportFailed("Your home region could not be found."); 594 client.SendTeleportFailed("Your home region could not be found.");
582 return; 595 return false;
583 } 596 }
584 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})", 597 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})",
585 regionInfo.RegionName, regionInfo.RegionID, regionInfo.RegionLocX / Constants.RegionSize, regionInfo.RegionLocY / Constants.RegionSize); 598 regionInfo.RegionName, regionInfo.RegionID, regionInfo.RegionLocX / Constants.RegionSize, regionInfo.RegionLocY / Constants.RegionSize);
586 599
587 // a little eekie that this goes back to Scene and with a forced cast, will fix that at some point... 600 // a little eekie that this goes back to Scene and with a forced cast, will fix that at some point...
@@ -589,6 +602,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
589 client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt, 602 client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt,
590 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); 603 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
591 } 604 }
605 else
606 {
607 // can't find the Home region: Tell viewer and abort
608 client.SendTeleportFailed("Your home region could not be found.");
609 return false;
610 }
611 return true;
592 } 612 }
593 613
594 #endregion 614 #endregion
@@ -876,15 +896,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
876 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); 896 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
877 897
878 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>(); 898 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
879 if (eq != null) 899 IPEndPoint neighbourExternal = neighbourRegion.ExternalEndPoint;
880 { 900 if (neighbourExternal != null)
881 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
882 capsPath, agent.UUID, agent.ControllingClient.SessionId);
883 }
884 else
885 { 901 {
886 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, 902 if (eq != null)
887 capsPath); 903 {
904 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal,
905 capsPath, agent.UUID, agent.ControllingClient.SessionId);
906 }
907 else
908 {
909 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourExternal,
910 capsPath);
911 }
888 } 912 }
889 913
890 if (!WaitForCallback(agent.UUID)) 914 if (!WaitForCallback(agent.UUID))
@@ -986,10 +1010,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
986 agent.Id0 = currentAgentCircuit.Id0; 1010 agent.Id0 = currentAgentCircuit.Id0;
987 } 1011 }
988 1012
989 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 1013 IPEndPoint external = region.ExternalEndPoint;
990 d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, 1014 if (external != null)
1015 {
1016 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1017 d.BeginInvoke(sp, agent, region, external, true,
991 InformClientOfNeighbourCompleted, 1018 InformClientOfNeighbourCompleted,
992 d); 1019 d);
1020 }
993 } 1021 }
994 #endregion 1022 #endregion
995 1023
@@ -1122,6 +1150,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1122 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 1150 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1123 try 1151 try
1124 { 1152 {
1153 //neighbour.ExternalEndPoint may return null, which will be caught
1125 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, 1154 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
1126 InformClientOfNeighbourCompleted, 1155 InformClientOfNeighbourCompleted,
1127 d); 1156 d);
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 1ac7508..47898cc 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
@@ -174,7 +174,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
174 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); 174 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
175 } 175 }
176 176
177 public override void TeleportHome(UUID id, IClientAPI client) 177 public void TeleportHomeFired(UUID id, IClientAPI client)
178 {
179 TeleportHome(id, client);
180 }
181
182 public override bool TeleportHome(UUID id, IClientAPI client)
178 { 183 {
179 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); 184 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
180 185
@@ -184,8 +189,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
184 { 189 {
185 // local grid user 190 // local grid user
186 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); 191 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local");
187 base.TeleportHome(id, client); 192 return base.TeleportHome(id, client);
188 return;
189 } 193 }
190 194
191 // Foreign user wants to go home 195 // Foreign user wants to go home
@@ -195,7 +199,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
195 { 199 {
196 client.SendTeleportFailed("Your information has been lost"); 200 client.SendTeleportFailed("Your information has been lost");
197 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); 201 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information");
198 return; 202 return false;
199 } 203 }
200 204
201 IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); 205 IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString());
@@ -205,7 +209,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
205 { 209 {
206 client.SendTeleportFailed("Your home region could not be found"); 210 client.SendTeleportFailed("Your home region could not be found");
207 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); 211 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found");
208 return; 212 return false;
209 } 213 }
210 214
211 ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId); 215 ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId);
@@ -213,7 +217,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
213 { 217 {
214 client.SendTeleportFailed("Internal error"); 218 client.SendTeleportFailed("Internal error");
215 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be"); 219 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be");
216 return; 220 return false;
217 } 221 }
218 222
219 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); 223 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
@@ -223,6 +227,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
223 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName); 227 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName);
224 228
225 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq); 229 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq);
230 return true;
226 } 231 }
227 #endregion 232 #endregion
228 233
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 7a175ea..d429979 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
@@ -191,11 +192,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
191 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, 192 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
192 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient) 193 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient)
193 { 194 {
194 // HACK: This is only working for lists containing a single item!
195 // It's just a hack to make this WIP compile and run. Nothing
196 // currently calls this with multiple items.
197 UUID ret = UUID.Zero; 195 UUID ret = UUID.Zero;
198 196
197 // The following code groups the SOG's by owner. No objects
198 // belonging to different people can be coalesced, for obvious
199 // reasons.
199 Dictionary<UUID, List<SceneObjectGroup>> deletes = 200 Dictionary<UUID, List<SceneObjectGroup>> deletes =
200 new Dictionary<UUID, List<SceneObjectGroup>>(); 201 new Dictionary<UUID, List<SceneObjectGroup>>();
201 202
@@ -207,264 +208,334 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
207 deletes[g.OwnerID].Add(g); 208 deletes[g.OwnerID].Add(g);
208 } 209 }
209 210
211 // This is pethod scoped and will be returned. It will be the
212 // last created asset id
213 UUID assetID = UUID.Zero;
214
215 // Each iteration is really a separate asset being created,
216 // with distinct destinations as well.
210 foreach (List<SceneObjectGroup> objlist in deletes.Values) 217 foreach (List<SceneObjectGroup> objlist in deletes.Values)
211 { 218 {
212 foreach (SceneObjectGroup g in objlist) 219 Dictionary<UUID, string> xmlStrings =
213 ret = DeleteToInventory(action, folderID, g, remoteClient); 220 new Dictionary<UUID, string>();
214 }
215 221
216 return ret; 222 foreach (SceneObjectGroup objectGroup in objlist)
217 } 223 {
224 Vector3 inventoryStoredPosition = new Vector3
225 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
226 ? 250
227 : objectGroup.AbsolutePosition.X)
228 ,
229 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
230 ? 250
231 : objectGroup.AbsolutePosition.X,
232 objectGroup.AbsolutePosition.Z);
218 233
219 private UUID DeleteToInventory(DeRezAction action, UUID folderID, 234 Vector3 originalPosition = objectGroup.AbsolutePosition;
220 SceneObjectGroup objectGroup, IClientAPI remoteClient)
221 {
222 UUID assetID = UUID.Zero;
223 235
224 Vector3 inventoryStoredPosition = new Vector3 236 // Restore attachment data after trip through the sim
225 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) 237 if (objectGroup.RootPart.AttachPoint > 0)
226 ? 250 238 inventoryStoredPosition = objectGroup.RootPart.AttachOffset;
227 : objectGroup.AbsolutePosition.X) 239 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
228 ,
229 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
230 ? 250
231 : objectGroup.AbsolutePosition.X,
232 objectGroup.AbsolutePosition.Z);
233 240
234 Vector3 originalPosition = objectGroup.AbsolutePosition; 241 objectGroup.AbsolutePosition = inventoryStoredPosition;
235 242
236 objectGroup.AbsolutePosition = inventoryStoredPosition; 243 // Make sure all bits but the ones we want are clear
244 // on take.
245 // This will be applied to the current perms, so
246 // it will do what we want.
247 objectGroup.RootPart.NextOwnerMask &=
248 ((uint)PermissionMask.Copy |
249 (uint)PermissionMask.Transfer |
250 (uint)PermissionMask.Modify);
251 objectGroup.RootPart.NextOwnerMask |=
252 (uint)PermissionMask.Move;
237 253
238 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); 254 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
239 255
240 objectGroup.AbsolutePosition = originalPosition; 256 objectGroup.AbsolutePosition = originalPosition;
241 257
242 // Get the user info of the item destination 258 xmlStrings[objectGroup.UUID] = sceneObjectXml;
243 // 259 }
244 UUID userID = UUID.Zero;
245 260
246 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || 261 string itemXml;
247 action == DeRezAction.SaveToExistingUserInventoryItem)
248 {
249 // Take or take copy require a taker
250 // Saving changes requires a local user
251 //
252 if (remoteClient == null)
253 return UUID.Zero;
254 262
255 userID = remoteClient.AgentId; 263 if (objlist.Count > 1)
256 } 264 {
257 else 265 float minX, minY, minZ;
258 { 266 float maxX, maxY, maxZ;
259 // All returns / deletes go to the object owner
260 //
261 267
262 userID = objectGroup.RootPart.OwnerID; 268 Vector3[] offsets = m_Scene.GetCombinedBoundingBox(objlist,
263 } 269 out minX, out maxX, out minY, out maxY,
270 out minZ, out maxZ);
264 271
265 if (userID == UUID.Zero) // Can't proceed 272 // CreateWrapper
266 { 273 XmlDocument itemDoc = new XmlDocument();
267 return UUID.Zero; 274 XmlElement root = itemDoc.CreateElement("", "CoalescedObject", "");
268 } 275 itemDoc.AppendChild(root);
269 276
270 // If we're returning someone's item, it goes back to the 277 // Embed the offsets into the group XML
271 // owner's Lost And Found folder. 278 for ( int i = 0 ; i < objlist.Count ; i++ )
272 // Delete is treated like return in this case 279 {
273 // Deleting your own items makes them go to trash 280 XmlDocument doc = new XmlDocument();
274 // 281 SceneObjectGroup g = objlist[i];
275 282 doc.LoadXml(xmlStrings[g.UUID]);
276 InventoryFolderBase folder = null; 283 XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup");
277 InventoryItemBase item = null; 284 e.SetAttribute("offsetx", offsets[i].X.ToString());
285 e.SetAttribute("offsety", offsets[i].Y.ToString());
286 e.SetAttribute("offsetz", offsets[i].Z.ToString());
287
288 XmlNode objectNode = itemDoc.ImportNode(e, true);
289 root.AppendChild(objectNode);
290 }
278 291
279 if (DeRezAction.SaveToExistingUserInventoryItem == action) 292 float sizeX = maxX - minX;
280 { 293 float sizeY = maxY - minY;
281 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); 294 float sizeZ = maxZ - minZ;
282 item = m_Scene.InventoryService.GetItem(item);
283 295
284 //item = userInfo.RootFolder.FindItem( 296 root.SetAttribute("x", sizeX.ToString());
285 // objectGroup.RootPart.FromUserInventoryItemID); 297 root.SetAttribute("y", sizeY.ToString());
298 root.SetAttribute("z", sizeZ.ToString());
286 299
287 if (null == item) 300 itemXml = itemDoc.InnerXml;
301 }
302 else
288 { 303 {
289 m_log.DebugFormat( 304 itemXml = xmlStrings[objlist[0].UUID];
290 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
291 objectGroup.Name, objectGroup.UUID);
292 return UUID.Zero;
293 } 305 }
294 } 306
295 else 307 // Get the user info of the item destination
296 {
297 // Folder magic
298 // 308 //
299 if (action == DeRezAction.Delete) 309 UUID userID = UUID.Zero;
310
311 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
312 action == DeRezAction.SaveToExistingUserInventoryItem)
300 { 313 {
301 // Deleting someone else's item 314 // Take or take copy require a taker
315 // Saving changes requires a local user
302 // 316 //
303 if (remoteClient == null || 317 if (remoteClient == null)
304 objectGroup.OwnerID != remoteClient.AgentId) 318 return UUID.Zero;
305 {
306 319
307 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 320 userID = remoteClient.AgentId;
308 }
309 else
310 {
311 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
312 }
313 } 321 }
314 else if (action == DeRezAction.Return) 322 else
315 { 323 {
316 324 // All returns / deletes go to the object owner
317 // Dump to lost + found unconditionally
318 // 325 //
319 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 326
327 userID = objlist[0].RootPart.OwnerID;
320 } 328 }
321 329
322 if (folderID == UUID.Zero && folder == null) 330 if (userID == UUID.Zero) // Can't proceed
323 { 331 {
324 if (action == DeRezAction.Delete) 332 return UUID.Zero;
333 }
334
335 // If we're returning someone's item, it goes back to the
336 // owner's Lost And Found folder.
337 // Delete is treated like return in this case
338 // Deleting your own items makes them go to trash
339 //
340
341 InventoryFolderBase folder = null;
342 InventoryItemBase item = null;
343
344 if (DeRezAction.SaveToExistingUserInventoryItem == action)
345 {
346 item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID);
347 item = m_Scene.InventoryService.GetItem(item);
348
349 //item = userInfo.RootFolder.FindItem(
350 // objectGroup.RootPart.FromUserInventoryItemID);
351
352 if (null == item)
325 { 353 {
326 // Deletes go to trash by default 354 m_log.DebugFormat(
327 // 355 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
328 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); 356 objlist[0].Name, objlist[0].UUID);
357 return UUID.Zero;
329 } 358 }
330 else 359 }
360 else
361 {
362 // Folder magic
363 //
364 if (action == DeRezAction.Delete)
331 { 365 {
366 // Deleting someone else's item
367 //
332 if (remoteClient == null || 368 if (remoteClient == null ||
333 objectGroup.OwnerID != remoteClient.AgentId) 369 objlist[0].OwnerID != remoteClient.AgentId)
334 { 370 {
335 // Taking copy of another person's item. Take to 371
336 // Objects folder. 372 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
337 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
338 } 373 }
339 else 374 else
340 { 375 {
341 // Catch all. Use lost & found 376 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
377 }
378 }
379 else if (action == DeRezAction.Return)
380 {
381
382 // Dump to lost + found unconditionally
383 //
384 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
385 }
386
387 if (folderID == UUID.Zero && folder == null)
388 {
389 if (action == DeRezAction.Delete)
390 {
391 // Deletes go to trash by default
342 // 392 //
393 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
394 }
395 else
396 {
397 if (remoteClient == null ||
398 objlist[0].OwnerID != remoteClient.AgentId)
399 {
400 // Taking copy of another person's item. Take to
401 // Objects folder.
402 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
403 }
404 else
405 {
406 // Catch all. Use lost & found
407 //
343 408
344 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 409 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
410 }
345 } 411 }
346 } 412 }
347 }
348 413
349 // Override and put into where it came from, if it came 414 // Override and put into where it came from, if it came
350 // from anywhere in inventory 415 // from anywhere in inventory
351 // 416 //
352 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) 417 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
353 {
354 if (objectGroup.RootPart.FromFolderID != UUID.Zero)
355 { 418 {
356 InventoryFolderBase f = new InventoryFolderBase(objectGroup.RootPart.FromFolderID, userID); 419 if (objlist[0].RootPart.FromFolderID != UUID.Zero)
357 folder = m_Scene.InventoryService.GetFolder(f); 420 {
421 InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID);
422 folder = m_Scene.InventoryService.GetFolder(f);
423 }
358 } 424 }
359 }
360 425
361 if (folder == null) // None of the above 426 if (folder == null) // None of the above
362 { 427 {
363 folder = new InventoryFolderBase(folderID); 428 folder = new InventoryFolderBase(folderID);
364 429
365 if (folder == null) // Nowhere to put it 430 if (folder == null) // Nowhere to put it
431 {
432 return UUID.Zero;
433 }
434 }
435
436 item = new InventoryItemBase();
437 // Can't know creator is the same, so null it in inventory
438 if (objlist.Count > 1)
439 item.CreatorId = UUID.Zero.ToString();
440 else
441 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
442 item.ID = UUID.Random();
443 item.InvType = (int)InventoryType.Object;
444 item.Folder = folder.ID;
445 item.Owner = userID;
446 if (objlist.Count > 1)
366 { 447 {
367 return UUID.Zero; 448 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
449 }
450 else
451 {
452 item.SaleType = objlist[0].RootPart.ObjectSaleType;
453 item.SalePrice = objlist[0].RootPart.SalePrice;
368 } 454 }
369 } 455 }
370 456
371 item = new InventoryItemBase(); 457 AssetBase asset = CreateAsset(
372 item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); 458 objlist[0].GetPartName(objlist[0].RootPart.LocalId),
373 item.ID = UUID.Random(); 459 objlist[0].GetPartDescription(objlist[0].RootPart.LocalId),
374 item.InvType = (int)InventoryType.Object; 460 (sbyte)AssetType.Object,
375 item.Folder = folder.ID; 461 Utils.StringToBytes(itemXml),
376 item.Owner = userID; 462 objlist[0].OwnerID.ToString());
377 } 463 m_Scene.AssetService.Store(asset);
378 464 assetID = asset.FullID;
379 AssetBase asset = CreateAsset(
380 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
381 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
382 (sbyte)AssetType.Object,
383 Utils.StringToBytes(sceneObjectXml),
384 objectGroup.OwnerID.ToString());
385 m_Scene.AssetService.Store(asset);
386 assetID = asset.FullID;
387
388 if (DeRezAction.SaveToExistingUserInventoryItem == action)
389 {
390 item.AssetID = asset.FullID;
391 m_Scene.InventoryService.UpdateItem(item);
392 }
393 else
394 {
395 item.AssetID = asset.FullID;
396 465
397 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 466 if (DeRezAction.SaveToExistingUserInventoryItem == action)
398 { 467 {
399 uint perms = objectGroup.GetEffectivePermissions(); 468 item.AssetID = asset.FullID;
400 uint nextPerms = (perms & 7) << 13; 469 m_Scene.InventoryService.UpdateItem(item);
401 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
402 perms &= ~(uint)PermissionMask.Copy;
403 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
404 perms &= ~(uint)PermissionMask.Transfer;
405 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
406 perms &= ~(uint)PermissionMask.Modify;
407
408 // Make sure all bits but the ones we want are clear
409 // on take.
410 // This will be applied to the current perms, so
411 // it will do what we want.
412 objectGroup.RootPart.NextOwnerMask &=
413 ((uint)PermissionMask.Copy |
414 (uint)PermissionMask.Transfer |
415 (uint)PermissionMask.Modify);
416 objectGroup.RootPart.NextOwnerMask |=
417 (uint)PermissionMask.Move;
418
419 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
420 item.CurrentPermissions = item.BasePermissions;
421 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
422 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
423 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
424
425 // Magic number badness. Maybe this deserves an enum.
426 // bit 4 (16) is the "Slam" bit, it means treat as passed
427 // and apply next owner perms on rez
428 item.CurrentPermissions |= 16; // Slam!
429 } 470 }
430 else 471 else
431 { 472 {
432 item.BasePermissions = objectGroup.GetEffectivePermissions(); 473 item.AssetID = asset.FullID;
433 item.CurrentPermissions = objectGroup.GetEffectivePermissions();
434 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
435 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
436 item.GroupPermissions = objectGroup.RootPart.GroupMask;
437 474
438 item.CurrentPermissions &= 475 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7;
439 ((uint)PermissionMask.Copy | 476 foreach (SceneObjectGroup grp in objlist)
440 (uint)PermissionMask.Transfer | 477 effectivePerms &= grp.GetEffectivePermissions();
441 (uint)PermissionMask.Modify | 478 effectivePerms |= (uint)PermissionMask.Move;
442 (uint)PermissionMask.Move | 479
443 7); // Preserve folded permissions 480 if (remoteClient != null && (remoteClient.AgentId != objlist[0].RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
444 } 481 {
482 uint perms = effectivePerms;
483 uint nextPerms = (perms & 7) << 13;
484 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
485 perms &= ~(uint)PermissionMask.Copy;
486 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
487 perms &= ~(uint)PermissionMask.Transfer;
488 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
489 perms &= ~(uint)PermissionMask.Modify;
490
491 item.BasePermissions = perms & objlist[0].RootPart.NextOwnerMask;
492 item.CurrentPermissions = item.BasePermissions;
493 item.NextPermissions = perms & objlist[0].RootPart.NextOwnerMask;
494 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & objlist[0].RootPart.NextOwnerMask;
495 item.GroupPermissions = objlist[0].RootPart.GroupMask & objlist[0].RootPart.NextOwnerMask;
496
497 // Magic number badness. Maybe this deserves an enum.
498 // bit 4 (16) is the "Slam" bit, it means treat as passed
499 // and apply next owner perms on rez
500 item.CurrentPermissions |= 16; // Slam!
501 }
502 else
503 {
504 item.BasePermissions = effectivePerms;
505 item.CurrentPermissions = effectivePerms;
506 item.NextPermissions = objlist[0].RootPart.NextOwnerMask & effectivePerms;
507 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & effectivePerms;
508 item.GroupPermissions = objlist[0].RootPart.GroupMask & effectivePerms;
509
510 item.CurrentPermissions &=
511 ((uint)PermissionMask.Copy |
512 (uint)PermissionMask.Transfer |
513 (uint)PermissionMask.Modify |
514 (uint)PermissionMask.Move |
515 7); // Preserve folded permissions
516 }
445 517
446 // TODO: add the new fields (Flags, Sale info, etc) 518 item.CreationDate = Util.UnixTimeSinceEpoch();
447 item.CreationDate = Util.UnixTimeSinceEpoch(); 519 item.Description = asset.Description;
448 item.Description = asset.Description; 520 item.Name = asset.Name;
449 item.Name = asset.Name; 521 item.AssetType = asset.Type;
450 item.AssetType = asset.Type;
451 522
452 m_Scene.AddInventoryItem(item); 523 m_Scene.AddInventoryItem(item);
453 524
454 if (remoteClient != null && item.Owner == remoteClient.AgentId) 525 if (remoteClient != null && item.Owner == remoteClient.AgentId)
455 {
456 remoteClient.SendInventoryItemCreateUpdate(item, 0);
457 }
458 else
459 {
460 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner);
461 if (notifyUser != null)
462 { 526 {
463 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); 527 remoteClient.SendInventoryItemCreateUpdate(item, 0);
528 }
529 else
530 {
531 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner);
532 if (notifyUser != null)
533 {
534 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
535 }
464 } 536 }
465 } 537 }
466 } 538 }
467
468 return assetID; 539 return assetID;
469 } 540 }
470 541
@@ -515,8 +586,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
515 586
516 if (item != null) 587 if (item != null)
517 { 588 {
589 if (item.ID == UUID.Zero)
590 {
591 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 1");
592 }
593
518 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); 594 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
519 595
596 SceneObjectGroup group = null;
597
520 if (rezAsset != null) 598 if (rezAsset != null)
521 { 599 {
522 UUID itemId = UUID.Zero; 600 UUID itemId = UUID.Zero;
@@ -525,32 +603,83 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
525 // item that it came from. This allows us to enable 'save object to inventory' 603 // item that it came from. This allows us to enable 'save object to inventory'
526 if (!m_Scene.Permissions.BypassPermissions()) 604 if (!m_Scene.Permissions.BypassPermissions())
527 { 605 {
528 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) 606 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
529 { 607 {
530 itemId = item.ID; 608 itemId = item.ID;
531 } 609 }
532 } 610 }
533 else 611 else
534 { 612 {
535 // Brave new fullperm world 613 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
536 // 614 {
537 itemId = item.ID; 615 // Brave new fullperm world
616 itemId = item.ID;
617 }
618 }
619
620 if (item.ID == UUID.Zero)
621 {
622 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 2");
538 } 623 }
539 624
540 string xmlData = Utils.BytesToString(rezAsset.Data); 625 string xmlData = Utils.BytesToString(rezAsset.Data);
541 SceneObjectGroup group 626 List<SceneObjectGroup> objlist =
542 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); 627 new List<SceneObjectGroup>();
628 List<Vector3> veclist = new List<Vector3>();
629
630 XmlDocument doc = new XmlDocument();
631 doc.LoadXml(xmlData);
632 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject");
633 if (e == null || attachment) // Single
634 {
635 SceneObjectGroup g =
636 SceneObjectSerializer.FromOriginalXmlFormat(
637 itemId, xmlData);
638 objlist.Add(g);
639 veclist.Add(new Vector3(0, 0, 0));
640
641 float offsetHeight = 0;
642 pos = m_Scene.GetNewRezLocation(
643 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
644 BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false);
645 pos.Z += offsetHeight;
646 }
647 else
648 {
649 XmlElement coll = (XmlElement)e;
650 float bx = Convert.ToSingle(coll.GetAttribute("x"));
651 float by = Convert.ToSingle(coll.GetAttribute("y"));
652 float bz = Convert.ToSingle(coll.GetAttribute("z"));
653 Vector3 bbox = new Vector3(bx, by, bz);
543 654
544 group.RootPart.FromFolderID = item.Folder; 655 pos = m_Scene.GetNewRezLocation(RayStart, RayEnd,
656 RayTargetID, Quaternion.Identity,
657 BypassRayCast, bRayEndIsIntersection, true,
658 bbox, false);
545 659
546 // If it's rezzed in world, select it. Much easier to 660 pos -= bbox / 2;
547 // find small items. 661
548 // 662 XmlNodeList groups = e.SelectNodes("SceneObjectGroup");
549 if (!attachment) 663 foreach (XmlNode n in groups)
550 group.RootPart.CreateSelected = true; 664 {
665 SceneObjectGroup g =
666 SceneObjectSerializer.FromOriginalXmlFormat(
667 itemId, n.OuterXml);
668 objlist.Add(g);
669 XmlElement el = (XmlElement)n;
670 float x = Convert.ToSingle(el.GetAttribute("offsetx"));
671 float y = Convert.ToSingle(el.GetAttribute("offsety"));
672 float z = Convert.ToSingle(el.GetAttribute("offsetz"));
673 veclist.Add(new Vector3(x, y, z));
674 }
675 }
676
677 int primcount = 0;
678 foreach (SceneObjectGroup g in objlist)
679 primcount += g.PrimCount;
551 680
552 if (!m_Scene.Permissions.CanRezObject( 681 if (!m_Scene.Permissions.CanRezObject(
553 group.PrimCount, remoteClient.AgentId, pos) 682 primcount, remoteClient.AgentId, pos)
554 && !attachment) 683 && !attachment)
555 { 684 {
556 // The client operates in no fail mode. It will 685 // The client operates in no fail mode. It will
@@ -563,108 +692,138 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
563 return null; 692 return null;
564 } 693 }
565 694
566 group.ResetIDs(); 695 for (int i = 0 ; i < objlist.Count ; i++ )
567
568 if (attachment)
569 { 696 {
570 group.RootPart.Flags |= PrimFlags.Phantom; 697 group = objlist[i];
571 group.RootPart.IsAttachment = true;
572 }
573
574 // If we're rezzing an attachment then don't ask AddNewSceneObject() to update the client since
575 // we'll be doing that later on. Scheduling more than one full update during the attachment
576 // process causes some clients to fail to display the attachment properly.
577 m_Scene.AddNewSceneObject(group, true, false);
578 698
579 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); 699 Vector3 storedPosition = group.AbsolutePosition;
580 // if attachment we set it's asset id so object updates can reflect that 700 if (group.UUID == UUID.Zero)
581 // if not, we set it's position in world. 701 {
582 if (!attachment) 702 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3");
583 { 703 }
584 group.ScheduleGroupForFullUpdate(); 704 group.RootPart.FromFolderID = item.Folder;
585
586 float offsetHeight = 0;
587 pos = m_Scene.GetNewRezLocation(
588 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
589 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
590 pos.Z += offsetHeight;
591 group.AbsolutePosition = pos;
592 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
593 705
594 } 706 // If it's rezzed in world, select it. Much easier to
595 else 707 // find small items.
596 { 708 //
597 group.SetFromItemID(itemID); 709 if (!attachment)
598 } 710 {
711 group.RootPart.CreateSelected = true;
712 foreach (SceneObjectPart child in group.Parts)
713 child.CreateSelected = true;
714 }
599 715
600 SceneObjectPart rootPart = null; 716 group.ResetIDs();
601 try
602 {
603 rootPart = group.GetChildPart(group.UUID);
604 }
605 catch (NullReferenceException)
606 {
607 string isAttachment = "";
608 717
609 if (attachment) 718 if (attachment)
610 isAttachment = " Object was an attachment"; 719 {
720 group.RootPart.Flags |= PrimFlags.Phantom;
721 group.RootPart.IsAttachment = true;
722 }
611 723
612 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); 724 // If we're rezzing an attachment then don't ask
613 } 725 // AddNewSceneObject() to update the client since
726 // we'll be doing that later on. Scheduling more than
727 // one full update during the attachment
728 // process causes some clients to fail to display the
729 // attachment properly.
730 m_Scene.AddNewSceneObject(group, true, false);
731
732 // if attachment we set it's asset id so object updates
733 // can reflect that, if not, we set it's position in world.
734 if (!attachment)
735 {
736 group.ScheduleGroupForFullUpdate();
737
738 group.AbsolutePosition = pos + veclist[i];
739 }
740 else
741 {
742 group.SetFromItemID(itemID);
743 }
614 744
615 // Since renaming the item in the inventory does not affect the name stored 745 SceneObjectPart rootPart = null;
616 // in the serialization, transfer the correct name from the inventory to the
617 // object itself before we rez.
618 rootPart.Name = item.Name;
619 rootPart.Description = item.Description;
620 746
621 group.SetGroup(remoteClient.ActiveGroupId, remoteClient); 747 try
622 if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0) 748 {
623 { 749 rootPart = group.GetChildPart(group.UUID);
624 //Need to kill the for sale here 750 }
625 rootPart.ObjectSaleType = 0; 751 catch (NullReferenceException)
626 rootPart.SalePrice = 10; 752 {
753 string isAttachment = "";
627 754
628 if (m_Scene.Permissions.PropagatePermissions()) 755 if (attachment)
756 isAttachment = " Object was an attachment";
757
758 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
759 }
760
761 // Since renaming the item in the inventory does not
762 // affect the name stored in the serialization, transfer
763 // the correct name from the inventory to the
764 // object itself before we rez.
765 rootPart.Name = item.Name;
766 rootPart.Description = item.Description;
767 rootPart.ObjectSaleType = item.SaleType;
768 rootPart.SalePrice = item.SalePrice;
769
770 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
771 if ((rootPart.OwnerID != item.Owner) ||
772 (item.CurrentPermissions & 16) != 0)
629 { 773 {
630 foreach (SceneObjectPart part in group.Parts) 774 //Need to kill the for sale here
775 rootPart.ObjectSaleType = 0;
776 rootPart.SalePrice = 10;
777
778 if (m_Scene.Permissions.PropagatePermissions())
631 { 779 {
632 part.EveryoneMask = item.EveryOnePermissions; 780 foreach (SceneObjectPart part in group.Parts)
633 part.NextOwnerMask = item.NextPermissions; 781 {
634 part.GroupMask = 0; // DO NOT propagate here 782 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
783 {
784 part.EveryoneMask = item.EveryOnePermissions;
785 part.NextOwnerMask = item.NextPermissions;
786 }
787 part.GroupMask = 0; // DO NOT propagate here
788 }
789
790 group.ApplyNextOwnerPermissions();
635 } 791 }
636
637 group.ApplyNextOwnerPermissions();
638 } 792 }
639 }
640 793
641 foreach (SceneObjectPart part in group.Parts) 794 foreach (SceneObjectPart part in group.Parts)
642 {
643 if ((part.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0)
644 { 795 {
645 part.LastOwnerID = part.OwnerID; 796 if ((part.OwnerID != item.Owner) ||
646 part.OwnerID = item.Owner; 797 (item.CurrentPermissions & 16) != 0)
647 part.Inventory.ChangeInventoryOwner(item.Owner); 798 {
648 part.GroupMask = 0; // DO NOT propagate here 799 part.LastOwnerID = part.OwnerID;
800 part.OwnerID = item.Owner;
801 part.Inventory.ChangeInventoryOwner(item.Owner);
802 part.GroupMask = 0; // DO NOT propagate here
803 }
804 part.EveryoneMask = item.EveryOnePermissions;
805 part.NextOwnerMask = item.NextPermissions;
649 } 806 }
650 part.EveryoneMask = item.EveryOnePermissions;
651 part.NextOwnerMask = item.NextPermissions;
652 }
653 807
654 rootPart.TrimPermissions(); 808 rootPart.TrimPermissions();
655 809
656 if (!attachment) 810 if (!attachment)
657 {
658 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
659 { 811 {
660 group.ClearPartAttachmentData(); 812 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
661 } 813 {
662 814 // Save attachment data
663 // Fire on_rez 815 group.RootPart.AttachPoint = group.RootPart.Shape.State;
664 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); 816 group.RootPart.AttachOffset = storedPosition;
665 rootPart.ParentGroup.ResumeScripts();
666 817
667 rootPart.ScheduleFullUpdate(); 818 group.ClearPartAttachmentData();
819 }
820
821 // Fire on_rez
822 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1);
823 rootPart.ParentGroup.ResumeScripts();
824
825 rootPart.ScheduleFullUpdate();
826 }
668 } 827 }
669 828
670 if (!m_Scene.Permissions.BypassPermissions()) 829 if (!m_Scene.Permissions.BypassPermissions())
@@ -682,9 +841,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
682 } 841 }
683 } 842 }
684 } 843 }
685
686 return rootPart.ParentGroup;
687 } 844 }
845 return group;
688 } 846 }
689 847
690 return null; 848 return null;
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 9b565ed..1fd1f47 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -142,7 +142,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
142 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 142 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
143 return urlcode; 143 return urlcode;
144 } 144 }
145 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; 145 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString();
146 146
147 UrlData urlData = new UrlData(); 147 UrlData urlData = new UrlData();
148 urlData.hostID = host.UUID; 148 urlData.hostID = host.UUID;
@@ -152,10 +152,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
152 urlData.urlcode = urlcode; 152 urlData.urlcode = urlcode;
153 urlData.requests = new Dictionary<UUID, RequestData>(); 153 urlData.requests = new Dictionary<UUID, RequestData>();
154 154
155
156 m_UrlMap[url] = urlData; 155 m_UrlMap[url] = urlData;
157 156
158 string uri = "/lslhttp/" + urlcode.ToString() + "/"; 157 string uri = "/lslhttp/" + urlcode.ToString();
159 158
160 m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, 159 m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll,
161 new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, 160 new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents,
@@ -386,6 +385,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
386 385
387 return response; 386 return response;
388 } 387 }
388
389 public void HttpRequestHandler(UUID requestID, Hashtable request) 389 public void HttpRequestHandler(UUID requestID, Hashtable request)
390 { 390 {
391 lock (request) 391 lock (request)
@@ -400,8 +400,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
400 400
401 int pos1 = uri.IndexOf("/");// /lslhttp 401 int pos1 = uri.IndexOf("/");// /lslhttp
402 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ 402 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/
403 int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/ 403 int pos3 = pos2 + 37; // /lslhttp/urlcode
404 string uri_tmp = uri.Substring(0, pos3 + 1); 404 string uri_tmp = uri.Substring(0, pos3);
405 //HTTP server code doesn't provide us with QueryStrings 405 //HTTP server code doesn't provide us with QueryStrings
406 string pathInfo; 406 string pathInfo;
407 string queryString; 407 string queryString;
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 e32dbb3..329a259 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -290,6 +290,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
290 return false; 290 return false;
291 } 291 }
292 292
293 public bool CloseChildAgent(GridRegion destination, UUID id)
294 {
295 if (destination == null)
296 return false;
297
298 foreach (Scene s in m_sceneList)
299 {
300 if (s.RegionInfo.RegionID == destination.RegionID)
301 {
302 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
303 return s.IncomingCloseChildAgent(id);
304 }
305 }
306 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
307 return false;
308 }
309
293 /** 310 /**
294 * Object-related communications 311 * Object-related communications
295 */ 312 */
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index 3f577f2..e16e273 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -252,6 +252,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
252 return false; 252 return false;
253 } 253 }
254 254
255 public bool CloseChildAgent(GridRegion destination, UUID id)
256 {
257 if (destination == null)
258 return false;
259
260 // Try local first
261 if (m_localBackend.CloseChildAgent(destination, id))
262 return true;
263
264 // else do the remote thing
265 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
266 return m_remoteConnector.CloseChildAgent(destination, id);
267
268 return false;
269 }
255 270
256 public bool CloseAgent(GridRegion destination, UUID id) 271 public bool CloseAgent(GridRegion destination, UUID id)
257 { 272 {
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 117b2fd..1f85278 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -269,6 +269,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver
269 // being no copy/no mod for everyone 269 // being no copy/no mod for everyone
270 lock (part.TaskInventory) 270 lock (part.TaskInventory)
271 { 271 {
272 if (!ResolveUserUuid(part.CreatorID))
273 part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
274
275 if (!ResolveUserUuid(part.OwnerID))
276 part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
277
278 if (!ResolveUserUuid(part.LastOwnerID))
279 part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
280
281 // And zap any troublesome sit target information
282 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
283 part.SitTargetPosition = new Vector3(0, 0, 0);
284
285 // Fix ownership/creator of inventory items
286 // Not doing so results in inventory items
287 // being no copy/no mod for everyone
288 part.TaskInventory.LockItemsForRead(true);
272 TaskInventoryDictionary inv = part.TaskInventory; 289 TaskInventoryDictionary inv = part.TaskInventory;
273 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) 290 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
274 { 291 {
@@ -281,6 +298,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
281 kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; 298 kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
282 } 299 }
283 } 300 }
301 part.TaskInventory.LockItemsForRead(false);
284 } 302 }
285 } 303 }
286 304
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 1bf0d67..9df13d8 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
@@ -250,7 +252,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
250 252
251 if ((estateAccessType & 4) != 0) // User add 253 if ((estateAccessType & 4) != 0) // User add
252 { 254 {
253 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 255 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
254 { 256 {
255 m_scene.RegionInfo.EstateSettings.AddEstateUser(user); 257 m_scene.RegionInfo.EstateSettings.AddEstateUser(user);
256 m_scene.RegionInfo.EstateSettings.Save(); 258 m_scene.RegionInfo.EstateSettings.Save();
@@ -265,7 +267,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
265 } 267 }
266 if ((estateAccessType & 8) != 0) // User remove 268 if ((estateAccessType & 8) != 0) // User remove
267 { 269 {
268 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 270 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
269 { 271 {
270 m_scene.RegionInfo.EstateSettings.RemoveEstateUser(user); 272 m_scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
271 m_scene.RegionInfo.EstateSettings.Save(); 273 m_scene.RegionInfo.EstateSettings.Save();
@@ -280,7 +282,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
280 } 282 }
281 if ((estateAccessType & 16) != 0) // Group add 283 if ((estateAccessType & 16) != 0) // Group add
282 { 284 {
283 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 285 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
284 { 286 {
285 m_scene.RegionInfo.EstateSettings.AddEstateGroup(user); 287 m_scene.RegionInfo.EstateSettings.AddEstateGroup(user);
286 m_scene.RegionInfo.EstateSettings.Save(); 288 m_scene.RegionInfo.EstateSettings.Save();
@@ -294,7 +296,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
294 } 296 }
295 if ((estateAccessType & 32) != 0) // Group remove 297 if ((estateAccessType & 32) != 0) // Group remove
296 { 298 {
297 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 299 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
298 { 300 {
299 m_scene.RegionInfo.EstateSettings.RemoveEstateGroup(user); 301 m_scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
300 m_scene.RegionInfo.EstateSettings.Save(); 302 m_scene.RegionInfo.EstateSettings.Save();
@@ -343,7 +345,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
343 { 345 {
344 if (!s.IsChildAgent) 346 if (!s.IsChildAgent)
345 { 347 {
346 m_scene.TeleportClientHome(user, s.ControllingClient); 348 if (!m_scene.TeleportClientHome(user, s.ControllingClient))
349 {
350 s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
351 s.ControllingClient.Close();
352 }
347 } 353 }
348 } 354 }
349 355
@@ -477,7 +483,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
477 ScenePresence s = m_scene.GetScenePresence(prey); 483 ScenePresence s = m_scene.GetScenePresence(prey);
478 if (s != null) 484 if (s != null)
479 { 485 {
480 m_scene.TeleportClientHome(prey, s.ControllingClient); 486 if (!m_scene.TeleportClientHome(prey, s.ControllingClient))
487 {
488 s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
489 s.ControllingClient.Close();
490 }
481 } 491 }
482 } 492 }
483 } 493 }
@@ -496,7 +506,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
496 // Also make sure they are actually in the region 506 // Also make sure they are actually in the region
497 if (p != null && !p.IsChildAgent) 507 if (p != null && !p.IsChildAgent)
498 { 508 {
499 m_scene.TeleportClientHome(p.UUID, p.ControllingClient); 509 if (!m_scene.TeleportClientHome(p.UUID, p.ControllingClient))
510 {
511 p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
512 p.ControllingClient.Close();
513 }
500 } 514 }
501 } 515 }
502 }); 516 });
@@ -899,6 +913,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
899 m_scene.RegisterModuleInterface<IEstateModule>(this); 913 m_scene.RegisterModuleInterface<IEstateModule>(this);
900 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 914 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
901 m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight; 915 m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
916 m_regionChangeTimer.AutoReset = false;
917 m_regionChangeTimer.Interval = 2000;
918 m_regionChangeTimer.Elapsed += RaiseRegionInfoChange;
902 919
903 m_scene.AddCommand(this, "set terrain texture", 920 m_scene.AddCommand(this, "set terrain texture",
904 "set terrain texture <number> <uuid> [<x>] [<y>]", 921 "set terrain texture <number> <uuid> [<x>] [<y>]",
@@ -1169,6 +1186,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
1169 1186
1170 protected void TriggerRegionInfoChange() 1187 protected void TriggerRegionInfoChange()
1171 { 1188 {
1189 m_regionChangeTimer.Stop();
1190 m_regionChangeTimer.Start();
1191 }
1192
1193 protected void RaiseRegionInfoChange(object sender, ElapsedEventArgs e)
1194 {
1172 ChangeDelegate change = OnRegionInfoChange; 1195 ChangeDelegate change = OnRegionInfoChange;
1173 1196
1174 if (change != null) 1197 if (change != null)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 634685a..5bd72ee 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -85,6 +85,8 @@ namespace OpenSim.Region.CoreModules.World.Land
85 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 85 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
86 86
87 private bool m_allowedForcefulBans = true; 87 private bool m_allowedForcefulBans = true;
88 private UUID DefaultGodParcelGroup;
89 private string DefaultGodParcelName;
88 90
89 // caches ExtendedLandData 91 // caches ExtendedLandData
90 private Cache parcelInfoCache; 92 private Cache parcelInfoCache;
@@ -99,6 +101,12 @@ namespace OpenSim.Region.CoreModules.World.Land
99 101
100 public void Initialise(IConfigSource source) 102 public void Initialise(IConfigSource source)
101 { 103 {
104 IConfig cnf = source.Configs["LandManagement"];
105 if (cnf != null)
106 {
107 DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
108 DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
109 }
102 } 110 }
103 111
104 public void AddRegion(Scene scene) 112 public void AddRegion(Scene scene)
@@ -350,7 +358,7 @@ namespace OpenSim.Region.CoreModules.World.Land
350 { 358 {
351 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT) 359 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
352 { 360 {
353 if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID)) 361 if (parcelAvatarIsEntering.IsEitherBannedOrRestricted(avatar.UUID))
354 { 362 {
355 SendYouAreBannedNotice(avatar); 363 SendYouAreBannedNotice(avatar);
356 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); 364 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
@@ -647,7 +655,7 @@ namespace OpenSim.Region.CoreModules.World.Land
647 int x; 655 int x;
648 int y; 656 int y;
649 657
650 if (x_float > Constants.RegionSize || x_float <= 0 || y_float > Constants.RegionSize || y_float <= 0) 658 if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0)
651 return null; 659 return null;
652 660
653 try 661 try
@@ -990,6 +998,10 @@ namespace OpenSim.Region.CoreModules.World.Land
990 //Owner Flag 998 //Owner Flag
991 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); 999 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER);
992 } 1000 }
1001 else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID))
1002 {
1003 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP);
1004 }
993 else if (currentParcelBlock.LandData.SalePrice > 0 && 1005 else if (currentParcelBlock.LandData.SalePrice > 0 &&
994 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || 1006 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
995 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) 1007 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
@@ -1292,18 +1304,31 @@ namespace OpenSim.Region.CoreModules.World.Land
1292 1304
1293 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1305 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
1294 { 1306 {
1295 for (int i = 0; i < data.Count; i++) 1307 lock (m_landList)
1296 { 1308 {
1297 IncomingLandObjectFromStorage(data[i]); 1309 //Remove all the land objects in the sim and then process our new data
1310 foreach (int n in m_landList.Keys)
1311 {
1312 m_scene.EventManager.TriggerLandObjectRemoved(m_landList[n].LandData.GlobalID);
1313 }
1314 m_landIDList.Initialize();
1315 m_landList.Clear();
1316
1317 for (int i = 0; i < data.Count; i++)
1318 {
1319 IncomingLandObjectFromStorage(data[i]);
1320 }
1298 } 1321 }
1299 } 1322 }
1300 1323
1301 public void IncomingLandObjectFromStorage(LandData data) 1324 public void IncomingLandObjectFromStorage(LandData data)
1302 { 1325 {
1326
1303 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); 1327 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1304 new_land.LandData = data.Copy(); 1328 new_land.LandData = data.Copy();
1305 new_land.SetLandBitmapFromByteArray(); 1329 new_land.SetLandBitmapFromByteArray();
1306 AddLandObject(new_land); 1330 AddLandObject(new_land);
1331 new_land.SendLandUpdateToAvatarsOverMe();
1307 } 1332 }
1308 1333
1309 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) 1334 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
@@ -1576,5 +1601,321 @@ namespace OpenSim.Region.CoreModules.World.Land
1576 1601
1577 UpdateLandObject(localID, land.LandData); 1602 UpdateLandObject(localID, land.LandData);
1578 } 1603 }
1604
1605 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
1606 {
1607 ILandObject land = null;
1608 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
1609 foreach (ILandObject landObject in Land)
1610 {
1611 if (landObject.LandData.LocalID == landID)
1612 {
1613 land = landObject;
1614 }
1615 }
1616 land.DeedToGroup(DefaultGodParcelGroup);
1617 land.LandData.Name = DefaultGodParcelName;
1618 land.SendLandUpdateToAvatarsOverMe();
1619 }
1620
1621 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
1622 {
1623 ScenePresence SP;
1624 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP);
1625 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
1626 if (SP.GodLevel != 0)
1627 {
1628 if (flags == 0) //All parcels, scripted or not
1629 {
1630 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1631 {
1632 if (e.OwnerID == targetID)
1633 {
1634 returns.Add(e);
1635 }
1636 }
1637 );
1638 }
1639 if (flags == 4) //All parcels, scripted object
1640 {
1641 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1642 {
1643 if (e.OwnerID == targetID)
1644 {
1645 if (e.scriptScore >= 0.01)
1646 {
1647 returns.Add(e);
1648 }
1649 }
1650 }
1651 );
1652 }
1653 if (flags == 4) //not target parcel, scripted object
1654 {
1655 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1656 {
1657 if (e.OwnerID == targetID)
1658 {
1659 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1660 if (landobject.LandData.OwnerID != e.OwnerID)
1661 {
1662 if (e.scriptScore >= 0.01)
1663 {
1664 returns.Add(e);
1665 }
1666 }
1667 }
1668 }
1669 );
1670 }
1671 foreach (SceneObjectGroup ol in returns)
1672 {
1673 ReturnObject(ol, client);
1674 }
1675 }
1676 }
1677 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
1678 {
1679 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1680 objs[0] = obj;
1681 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
1682 }
1683
1684 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1685
1686 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1687 {
1688 ScenePresence targetAvatar = null;
1689 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1690 ScenePresence parcelManager = null;
1691 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1692 System.Threading.Timer Timer;
1693
1694 if (targetAvatar.GodLevel == 0)
1695 {
1696 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1697 if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
1698 return;
1699 if (flags == 0)
1700 {
1701 targetAvatar.AllowMovement = false;
1702 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
1703 parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
1704 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
1705 Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
1706 Timers.Add(targetAvatar.UUID, Timer);
1707 }
1708 else
1709 {
1710 targetAvatar.AllowMovement = true;
1711 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
1712 parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
1713 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1714 Timers.Remove(targetAvatar.UUID);
1715 Timer.Dispose();
1716 }
1717 }
1718 }
1719 private void OnEndParcelFrozen(object avatar)
1720 {
1721 ScenePresence targetAvatar = (ScenePresence)avatar;
1722 targetAvatar.AllowMovement = true;
1723 System.Threading.Timer Timer;
1724 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1725 Timers.Remove(targetAvatar.UUID);
1726 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1727 }
1728
1729
1730 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1731 {
1732 ScenePresence targetAvatar = null;
1733 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1734 ScenePresence parcelManager = null;
1735 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1736 //Just eject
1737 if (flags == 0)
1738 {
1739 if (targetAvatar.GodLevel == 0)
1740 {
1741 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1742 if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
1743 return;
1744
1745 Vector3 position = new Vector3(0, 0, 0);
1746 List<ILandObject> allParcels = new List<ILandObject>();
1747 allParcels = AllParcels();
1748 if (allParcels.Count != 1)
1749 {
1750 foreach (ILandObject parcel in allParcels)
1751 {
1752 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1753 {
1754 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1755 {
1756 for (int x = 1; x <= Constants.RegionSize; x += 2)
1757 {
1758 for (int y = 1; y <= Constants.RegionSize; y += 2)
1759 {
1760 if (parcel.ContainsPoint(x, y))
1761 {
1762 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1763 targetAvatar.TeleportWithMomentum(position);
1764 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1765 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1766 return;
1767 }
1768 }
1769 }
1770 }
1771 }
1772 }
1773 }
1774 Vector3 targetVector;
1775 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1776 {
1777 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1778 {
1779 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1780 targetAvatar.TeleportWithMomentum(targetVector);
1781 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1782 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1783 return;
1784 }
1785 else
1786 {
1787 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1788 targetAvatar.TeleportWithMomentum(targetVector);
1789 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1790 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1791 return;
1792 }
1793 }
1794 else
1795 {
1796 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1797 {
1798 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1799 targetAvatar.TeleportWithMomentum(targetVector);
1800 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1801 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1802 return;
1803 }
1804 else
1805 {
1806 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1807 targetAvatar.TeleportWithMomentum(targetVector);
1808 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1809 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1810 return;
1811 }
1812 }
1813 }
1814 }
1815 //Eject and ban
1816 if (flags == 1)
1817 {
1818 if (targetAvatar.GodLevel == 0)
1819 {
1820 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1821 if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
1822 return;
1823
1824 Vector3 position = new Vector3(0, 0, 0);
1825 List<ILandObject> allParcels = new List<ILandObject>();
1826 allParcels = AllParcels();
1827 if (allParcels.Count != 1)
1828 {
1829 foreach (ILandObject parcel in allParcels)
1830 {
1831 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1832 {
1833 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1834 {
1835 for (int x = 1; x <= Constants.RegionSize; x += 2)
1836 {
1837 for (int y = 1; y <= Constants.RegionSize; y += 2)
1838 {
1839 if (parcel.ContainsPoint(x, y))
1840 {
1841 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1842 targetAvatar.TeleportWithMomentum(position);
1843 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1844 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1845 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1846 entry.AgentID = targetAvatar.UUID;
1847 entry.Flags = AccessList.Ban;
1848 entry.Time = new DateTime();
1849 land.LandData.ParcelAccessList.Add(entry);
1850 return;
1851 }
1852 }
1853 }
1854 }
1855 }
1856 }
1857 }
1858 Vector3 targetVector;
1859 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1860 {
1861 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1862 {
1863 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1864 targetAvatar.TeleportWithMomentum(targetVector);
1865 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1866 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1867 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1868 entry.AgentID = targetAvatar.UUID;
1869 entry.Flags = AccessList.Ban;
1870 entry.Time = new DateTime();
1871 land.LandData.ParcelAccessList.Add(entry);
1872 return;
1873 }
1874 else
1875 {
1876 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1877 targetAvatar.TeleportWithMomentum(targetVector);
1878 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1879 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1880 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1881 entry.AgentID = targetAvatar.UUID;
1882 entry.Flags = AccessList.Ban;
1883 entry.Time = new DateTime();
1884 land.LandData.ParcelAccessList.Add(entry);
1885 return;
1886 }
1887 }
1888 else
1889 {
1890 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1891 {
1892 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1893 targetAvatar.TeleportWithMomentum(targetVector);
1894 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1895 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1896 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1897 entry.AgentID = targetAvatar.UUID;
1898 entry.Flags = AccessList.Ban;
1899 entry.Time = new DateTime();
1900 land.LandData.ParcelAccessList.Add(entry);
1901 return;
1902 }
1903 else
1904 {
1905 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1906 targetAvatar.TeleportWithMomentum(targetVector);
1907 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1908 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1909 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1910 entry.AgentID = targetAvatar.UUID;
1911 entry.Flags = AccessList.Ban;
1912 entry.Time = new DateTime();
1913 land.LandData.ParcelAccessList.Add(entry);
1914 return;
1915 }
1916 }
1917 }
1918 }
1919 }
1579 } 1920 }
1580} 1921}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index d87352f..d0517b7 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -288,6 +288,22 @@ namespace OpenSim.Region.CoreModules.World.Land
288 return false; 288 return false;
289 } 289 }
290 290
291 public bool HasGroupAccess(UUID avatar)
292 {
293 if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup)
294 {
295 ScenePresence sp;
296 if (!m_scene.TryGetScenePresence(avatar, out sp))
297 return false;
298
299 if (!sp.ControllingClient.IsGroupMember(LandData.GroupID))
300 return false;
301
302 return true;
303 }
304 return false;
305 }
306
291 public bool IsBannedFromLand(UUID avatar) 307 public bool IsBannedFromLand(UUID avatar)
292 { 308 {
293 if (m_scene.Permissions.IsAdministrator(avatar)) 309 if (m_scene.Permissions.IsAdministrator(avatar))
@@ -324,10 +340,14 @@ namespace OpenSim.Region.CoreModules.World.Land
324 //If they are not on the access list and are not the owner 340 //If they are not on the access list and are not the owner
325 if (!LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar) 341 if (!LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar)
326 { 342 {
327 //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel 343 if (!HasGroupAccess(avatar))
328 return true; 344 {
345 //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
346 return true;
347 }
329 } 348 }
330 } 349 }
350
331 return false; 351 return false;
332 } 352 }
333 353
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index f5f3839..289741f 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -412,7 +412,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
412 412
413 public string Name 413 public string Name
414 { 414 {
415 get { return "PermissionsModule"; } 415 get { return "DefaultPermissionsModule"; }
416 } 416 }
417 417
418 public bool IsSharedModule 418 public bool IsSharedModule
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 25d73c2..4611352 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -549,6 +549,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
549 m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); 549 m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised());
550 m_scene.SaveTerrain(); 550 m_scene.SaveTerrain();
551 551
552 m_scene.EventManager.TriggerTerrainUpdate();
553
552 // Clients who look at the map will never see changes after they looked at the map, so i've commented this out. 554 // Clients who look at the map will never see changes after they looked at the map, so i've commented this out.
553 //m_scene.CreateTerrainTexture(true); 555 //m_scene.CreateTerrainTexture(true);
554 } 556 }