aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs15
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs367
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs59
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs13
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs13
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs110
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs54
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs50
-rw-r--r--OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs (renamed from OpenSim/Region/CoreModules/World/Terrain/DefaultEffects/ChannelDigger.cs)2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs69
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs269
-rw-r--r--OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs9
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs78
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs6
28 files changed, 346 insertions, 875 deletions
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index cac5fa9..09f7bea 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -308,21 +308,6 @@ namespace OpenSim
308 } 308 }
309 309
310 { 310 {
311 IConfig config = defaultConfig.Configs["StandAlone"];
312
313 if (null == config)
314 config = defaultConfig.AddConfig("StandAlone");
315
316 config.Set("accounts_authenticate", true);
317 config.Set("welcome_message", "Welcome to OpenSimulator");
318 config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll");
319 config.Set("inventory_source", "");
320 config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll");
321 config.Set("user_source", "");
322 config.Set("LibrariesXMLFile", string.Format(".{0}inventory{0}Libraries.xml", Path.DirectorySeparatorChar));
323 }
324
325 {
326 IConfig config = defaultConfig.Configs["Network"]; 311 IConfig config = defaultConfig.Configs["Network"];
327 312
328 if (null == config) 313 if (null == config)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs
deleted file mode 100644
index 10e5a95..0000000
--- a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs
+++ /dev/null
@@ -1,367 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Region.ClientStack.LindenUDP
34{
35 /// <summary>
36 /// A work in progress, to contain the SL specific file transfer code that is currently in various region modules
37 /// This file currently contains multiple classes that need to be split out into their own files.
38 /// </summary>
39 public class LLFileTransfer : IClientFileTransfer
40 {
41 protected IClientAPI m_clientAPI;
42
43 /// Dictionary of handlers for uploading files from client
44 /// TODO: Need to add cleanup code to remove handlers that have completed their upload
45 protected Dictionary<ulong, XferUploadHandler> m_uploadHandlers;
46 protected object m_uploadHandlersLock = new object();
47
48
49 /// <summary>
50 /// Dictionary of files ready to be sent to clients
51 /// </summary>
52 protected static Dictionary<string, byte[]> m_files;
53
54 /// <summary>
55 /// Dictionary of Download Transfers in progess
56 /// </summary>
57 protected Dictionary<ulong, XferDownloadHandler> m_downloadHandlers = new Dictionary<ulong, XferDownloadHandler>();
58
59
60 public LLFileTransfer(IClientAPI clientAPI)
61 {
62 m_uploadHandlers = new Dictionary<ulong, XferUploadHandler>();
63 m_clientAPI = clientAPI;
64
65 m_clientAPI.OnXferReceive += XferReceive;
66 m_clientAPI.OnAbortXfer += AbortXferUploadHandler;
67 }
68
69 public void Close()
70 {
71 if (m_clientAPI != null)
72 {
73 m_clientAPI.OnXferReceive -= XferReceive;
74 m_clientAPI.OnAbortXfer -= AbortXferUploadHandler;
75 m_clientAPI = null;
76 }
77 }
78
79 #region Upload Handling
80
81 public bool RequestUpload(string clientFileName, UploadComplete uploadCompleteCallback, UploadAborted abortCallback)
82 {
83 if ((String.IsNullOrEmpty(clientFileName)) || (uploadCompleteCallback == null))
84 {
85 return false;
86 }
87
88 XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, clientFileName);
89
90 return StartUpload(uploader, uploadCompleteCallback, abortCallback);
91 }
92
93 public bool RequestUpload(UUID fileID, UploadComplete uploadCompleteCallback, UploadAborted abortCallback)
94 {
95 if ((fileID == UUID.Zero) || (uploadCompleteCallback == null))
96 {
97 return false;
98 }
99
100 XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, fileID);
101
102 return StartUpload(uploader, uploadCompleteCallback, abortCallback);
103 }
104
105 private bool StartUpload(XferUploadHandler uploader, UploadComplete uploadCompleteCallback, UploadAborted abortCallback)
106 {
107 uploader.UploadDone += uploadCompleteCallback;
108 uploader.UploadDone += RemoveXferUploadHandler;
109
110 if (abortCallback != null)
111 {
112 uploader.UploadAborted += abortCallback;
113 }
114
115 lock (m_uploadHandlersLock)
116 {
117 if (!m_uploadHandlers.ContainsKey(uploader.XferID))
118 {
119 m_uploadHandlers.Add(uploader.XferID, uploader);
120 uploader.RequestStartXfer(m_clientAPI);
121 return true;
122 }
123 else
124 {
125 // something went wrong with the xferID allocation
126 uploader.UploadDone -= uploadCompleteCallback;
127 uploader.UploadDone -= RemoveXferUploadHandler;
128 if (abortCallback != null)
129 {
130 uploader.UploadAborted -= abortCallback;
131 }
132 return false;
133 }
134 }
135 }
136
137 protected void AbortXferUploadHandler(IClientAPI remoteClient, ulong xferID)
138 {
139 lock (m_uploadHandlersLock)
140 {
141 if (m_uploadHandlers.ContainsKey(xferID))
142 {
143 m_uploadHandlers[xferID].AbortUpload(remoteClient);
144 m_uploadHandlers.Remove(xferID);
145 }
146 }
147 }
148
149 protected void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
150 {
151 lock (m_uploadHandlersLock)
152 {
153 if (m_uploadHandlers.ContainsKey(xferID))
154 {
155 m_uploadHandlers[xferID].XferReceive(remoteClient, xferID, packetID, data);
156 }
157 }
158 }
159
160 protected void RemoveXferUploadHandler(string filename, UUID fileID, ulong transferID, byte[] fileData, IClientAPI remoteClient)
161 {
162
163 }
164 #endregion
165
166 }
167
168 public class XferUploadHandler
169 {
170 private AssetBase m_asset;
171
172 public event UploadComplete UploadDone;
173 public event UploadAborted UploadAborted;
174
175 private sbyte type = 0;
176
177 public ulong mXferID;
178 private UploadComplete handlerUploadDone;
179 private UploadAborted handlerAbort;
180
181 private bool m_complete = false;
182
183 public bool UploadComplete
184 {
185 get { return m_complete; }
186 }
187
188 public XferUploadHandler(IClientAPI pRemoteClient, string pClientFilename)
189 {
190 Initialise(UUID.Zero, pClientFilename);
191 }
192
193 public XferUploadHandler(IClientAPI pRemoteClient, UUID fileID)
194 {
195 Initialise(fileID, String.Empty);
196 }
197
198 private void Initialise(UUID fileID, string fileName)
199 {
200 m_asset = new AssetBase(fileID, fileName, type, UUID.Zero.ToString());
201 m_asset.Data = new byte[0];
202 m_asset.Description = "empty";
203 m_asset.Local = true;
204 m_asset.Temporary = true;
205 mXferID = Util.GetNextXferID();
206 }
207
208 public ulong XferID
209 {
210 get { return mXferID; }
211 }
212
213 public void RequestStartXfer(IClientAPI pRemoteClient)
214 {
215 m_asset.Metadata.CreatorID = pRemoteClient.AgentId.ToString();
216
217 if (!String.IsNullOrEmpty(m_asset.Name))
218 {
219 pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, Utils.StringToBytes(m_asset.Name));
220 }
221 else
222 {
223 pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, new byte[0]);
224 }
225 }
226
227 /// <summary>
228 /// Process transfer data received from the client.
229 /// </summary>
230 /// <param name="xferID"></param>
231 /// <param name="packetID"></param>
232 /// <param name="data"></param>
233 public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
234 {
235 if (mXferID == xferID)
236 {
237 if (m_asset.Data.Length > 1)
238 {
239 byte[] destinationArray = new byte[m_asset.Data.Length + data.Length];
240 Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length);
241 Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length);
242 m_asset.Data = destinationArray;
243 }
244 else
245 {
246 byte[] buffer2 = new byte[data.Length - 4];
247 Array.Copy(data, 4, buffer2, 0, data.Length - 4);
248 m_asset.Data = buffer2;
249 }
250
251 remoteClient.SendConfirmXfer(xferID, packetID);
252
253 if ((packetID & 0x80000000) != 0)
254 {
255 SendCompleteMessage(remoteClient);
256
257 }
258 }
259 }
260
261 protected void SendCompleteMessage(IClientAPI remoteClient)
262 {
263 m_complete = true;
264 handlerUploadDone = UploadDone;
265 if (handlerUploadDone != null)
266 {
267 handlerUploadDone(m_asset.Name, m_asset.FullID, mXferID, m_asset.Data, remoteClient);
268 }
269 }
270
271 public void AbortUpload(IClientAPI remoteClient)
272 {
273 handlerAbort = UploadAborted;
274 if (handlerAbort != null)
275 {
276 handlerAbort(m_asset.Name, m_asset.FullID, mXferID, remoteClient);
277 }
278 }
279 }
280
281 public class XferDownloadHandler
282 {
283 public IClientAPI Client;
284 private bool complete;
285 public byte[] Data = new byte[0];
286 public int DataPointer = 0;
287 public string FileName = String.Empty;
288 public uint Packet = 0;
289 public uint Serial = 1;
290 public ulong XferID = 0;
291
292 public XferDownloadHandler(string fileName, byte[] data, ulong xferID, IClientAPI client)
293 {
294 FileName = fileName;
295 Data = data;
296 XferID = xferID;
297 Client = client;
298 }
299
300 public XferDownloadHandler()
301 {
302 }
303
304 /// <summary>
305 /// Start a transfer
306 /// </summary>
307 /// <returns>True if the transfer is complete, false if not</returns>
308 public bool StartSend()
309 {
310 if (Data.Length < 1000)
311 {
312 // for now (testing) we only support files under 1000 bytes
313 byte[] transferData = new byte[Data.Length + 4];
314 Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4);
315 Array.Copy(Data, 0, transferData, 4, Data.Length);
316 Client.SendXferPacket(XferID, 0 + 0x80000000, transferData);
317
318 complete = true;
319 }
320 else
321 {
322 byte[] transferData = new byte[1000 + 4];
323 Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4);
324 Array.Copy(Data, 0, transferData, 4, 1000);
325 Client.SendXferPacket(XferID, 0, transferData);
326 Packet++;
327 DataPointer = 1000;
328 }
329
330 return complete;
331 }
332
333 /// <summary>
334 /// Respond to an ack packet from the client
335 /// </summary>
336 /// <param name="packet"></param>
337 /// <returns>True if the transfer is complete, false otherwise</returns>
338 public bool AckPacket(uint packet)
339 {
340 if (!complete)
341 {
342 if ((Data.Length - DataPointer) > 1000)
343 {
344 byte[] transferData = new byte[1000];
345 Array.Copy(Data, DataPointer, transferData, 0, 1000);
346 Client.SendXferPacket(XferID, Packet, transferData);
347 Packet++;
348 DataPointer += 1000;
349 }
350 else
351 {
352 byte[] transferData = new byte[Data.Length - DataPointer];
353 Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer);
354 uint endPacket = Packet |= (uint)0x80000000;
355 Client.SendXferPacket(XferID, endPacket, transferData);
356 Packet++;
357 DataPointer += (Data.Length - DataPointer);
358
359 complete = true;
360 }
361 }
362
363 return complete;
364 }
365 }
366
367}
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index ff3036a..d895bb1 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using log4net; 31using log4net;
32using Mono.Addins;
32using Nini.Config; 33using Nini.Config;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenMetaverse.Packets; 35using OpenMetaverse.Packets;
@@ -39,38 +40,64 @@ using OpenSim.Region.Framework.Scenes;
39 40
40namespace OpenSim.Region.CoreModules.Avatar.Attachments 41namespace OpenSim.Region.CoreModules.Avatar.Attachments
41{ 42{
42 public class AttachmentsModule : IAttachmentsModule, IRegionModule 43 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AttachmentsModule")]
44 public class AttachmentsModule : IAttachmentsModule, INonSharedRegionModule
43 { 45 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 47
46 protected Scene m_scene = null; 48 protected Scene m_scene = null;
49
50 public string Name { get { return "Attachments Module"; } }
51 public Type ReplaceableInterface { get { return null; } }
47 52
48 public void Initialise(Scene scene, IConfigSource source) 53 public void Initialise(IConfigSource source) {}
54
55 public void AddRegion(Scene scene)
49 { 56 {
50 scene.RegisterModuleInterface<IAttachmentsModule>(this);
51 m_scene = scene; 57 m_scene = scene;
58 m_scene.RegisterModuleInterface<IAttachmentsModule>(this);
59 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
60 // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI
52 } 61 }
53 62
54 public void PostInitialise() 63 public void RemoveRegion(Scene scene)
55 { 64 {
65 m_scene.UnregisterModuleInterface<IAttachmentsModule>(this);
66 m_scene.EventManager.OnNewClient -= SubscribeToClientEvents;
56 } 67 }
57 68
58 public void Close() 69 public void RegionLoaded(Scene scene) {}
70
71 public void Close()
59 { 72 {
73 RemoveRegion(m_scene);
60 } 74 }
61 75
62 public string Name 76 public void SubscribeToClientEvents(IClientAPI client)
63 { 77 {
64 get { return "Attachments Module"; } 78 client.OnRezSingleAttachmentFromInv += RezSingleAttachmentFromInventory;
79 client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachmentsFromInventory;
80 client.OnObjectAttach += AttachObject;
81 client.OnObjectDetach += DetachObject;
82 client.OnDetachAttachmentIntoInv += ShowDetachInUserInventory;
65 } 83 }
66 84
67 public bool IsSharedModule 85 public void UnsubscribeFromClientEvents(IClientAPI client)
68 { 86 {
69 get { return false; } 87 client.OnRezSingleAttachmentFromInv -= RezSingleAttachmentFromInventory;
88 client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachmentsFromInventory;
89 client.OnObjectAttach -= AttachObject;
90 client.OnObjectDetach -= DetachObject;
91 client.OnDetachAttachmentIntoInv -= ShowDetachInUserInventory;
70 } 92 }
71 93
72 // Called by client 94 /// <summary>
73 // 95 /// Called by client
96 /// </summary>
97 /// <param name="remoteClient"></param>
98 /// <param name="objectLocalID"></param>
99 /// <param name="AttachmentPt"></param>
100 /// <param name="silent"></param>
74 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) 101 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent)
75 { 102 {
76 m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); 103 m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject");
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index 50171a3..4b30b0d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -47,6 +47,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
47 m_scene = scene; 47 m_scene = scene;
48 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); 48 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
49 m_scene.RegisterModuleInterface<IGodsModule>(this); 49 m_scene.RegisterModuleInterface<IGodsModule>(this);
50 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
50 } 51 }
51 52
52 public void PostInitialise() {} 53 public void PostInitialise() {}
@@ -54,6 +55,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
54 public string Name { get { return "Gods Module"; } } 55 public string Name { get { return "Gods Module"; } }
55 public bool IsSharedModule { get { return false; } } 56 public bool IsSharedModule { get { return false; } }
56 57
58 public void SubscribeToClientEvents(IClientAPI client)
59 {
60 client.OnGodKickUser += KickUser;
61 client.OnRequestGodlikePowers += RequestGodlikePowers;
62 }
63
64 public void UnsubscribeFromClientEvents(IClientAPI client)
65 {
66 client.OnGodKickUser -= KickUser;
67 client.OnRequestGodlikePowers -= RequestGodlikePowers;
68 }
69
57 public void RequestGodlikePowers( 70 public void RequestGodlikePowers(
58 UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) 71 UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient)
59 { 72 {
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index ab141eb..a3c40e0 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -162,7 +162,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
162 delegate(bool success) 162 delegate(bool success)
163 { 163 {
164 if (dialog == (uint)InstantMessageDialog.StartTyping || 164 if (dialog == (uint)InstantMessageDialog.StartTyping ||
165 dialog == (uint)InstantMessageDialog.StopTyping) 165 dialog == (uint)InstantMessageDialog.StopTyping ||
166 dialog == (uint)InstantMessageDialog.MessageFromObject)
166 { 167 {
167 return; 168 return;
168 } 169 }
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 83209fc..d025f0c 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -185,13 +185,16 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
185 { 185 {
186 UndeliveredMessage handlerUndeliveredMessage = OnUndeliveredMessage; 186 UndeliveredMessage handlerUndeliveredMessage = OnUndeliveredMessage;
187 187
188 // If this event has handlers, then the IM will be considered 188 // If this event has handlers, then an IM from an agent will be
189 // delivered. This will suppress the error message. 189 // considered delivered. This will suppress the error message.
190 // 190 //
191 if (handlerUndeliveredMessage != null) 191 if (handlerUndeliveredMessage != null)
192 { 192 {
193 handlerUndeliveredMessage(im); 193 handlerUndeliveredMessage(im);
194 result(true); 194 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
195 result(true);
196 else
197 result(false);
195 return; 198 return;
196 } 199 }
197 200
@@ -504,14 +507,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
504 // 507 //
505 if (upd.RegionID == prevRegionID) 508 if (upd.RegionID == prevRegionID)
506 { 509 {
507 m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); 510 // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
508 HandleUndeliveredMessage(im, result); 511 HandleUndeliveredMessage(im, result);
509 return; 512 return;
510 } 513 }
511 } 514 }
512 else 515 else
513 { 516 {
514 m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); 517 // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
515 HandleUndeliveredMessage(im, result); 518 HandleUndeliveredMessage(im, result);
516 return; 519 return;
517 } 520 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 31dfe14..7683288 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -54,6 +54,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
54 54
55 private UserAccount m_userInfo; 55 private UserAccount m_userInfo;
56 private string m_invPath; 56 private string m_invPath;
57
58 /// <summary>
59 /// Do we want to merge this load with existing inventory?
60 /// </summary>
61 protected bool m_merge;
57 62
58 /// <value> 63 /// <value>
59 /// We only use this to request modules 64 /// We only use this to request modules
@@ -66,19 +71,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
66 private Stream m_loadStream; 71 private Stream m_loadStream;
67 72
68 public InventoryArchiveReadRequest( 73 public InventoryArchiveReadRequest(
69 Scene scene, UserAccount userInfo, string invPath, string loadPath) 74 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge)
70 : this( 75 : this(
71 scene, 76 scene,
72 userInfo, 77 userInfo,
73 invPath, 78 invPath,
74 new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress)) 79 new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress),
80 merge)
75 { 81 {
76 } 82 }
77 83
78 public InventoryArchiveReadRequest( 84 public InventoryArchiveReadRequest(
79 Scene scene, UserAccount userInfo, string invPath, Stream loadStream) 85 Scene scene, UserAccount userInfo, string invPath, Stream loadStream, bool merge)
80 { 86 {
81 m_scene = scene; 87 m_scene = scene;
88 m_merge = merge;
82 m_userInfo = userInfo; 89 m_userInfo = userInfo;
83 m_invPath = invPath; 90 m_invPath = invPath;
84 m_loadStream = loadStream; 91 m_loadStream = loadStream;
@@ -91,7 +98,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
91 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are 98 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are
92 /// returned 99 /// returned
93 /// </returns> 100 /// </returns>
94 public List<InventoryNodeBase> Execute() 101 public HashSet<InventoryNodeBase> Execute()
95 { 102 {
96 try 103 try
97 { 104 {
@@ -100,7 +107,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
100 int failedAssetRestores = 0; 107 int failedAssetRestores = 0;
101 int successfulItemRestores = 0; 108 int successfulItemRestores = 0;
102 109
103 List<InventoryNodeBase> loadedNodes = new List<InventoryNodeBase>(); 110 HashSet<InventoryNodeBase> loadedNodes = new HashSet<InventoryNodeBase>();
104 111
105 List<InventoryFolderBase> folderCandidates 112 List<InventoryFolderBase> folderCandidates
106 = InventoryArchiveUtils.FindFolderByPath( 113 = InventoryArchiveUtils.FindFolderByPath(
@@ -158,9 +165,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
158 { 165 {
159 successfulItemRestores++; 166 successfulItemRestores++;
160 167
161 // If we're loading an item directly into the given destination folder then we need to record 168 // If we aren't loading the folder containing the item then well need to update the
162 // it separately from any loaded root folders 169 // viewer separately for that item.
163 if (rootDestinationFolder == foundFolder) 170 if (!loadedNodes.Contains(foundFolder))
164 loadedNodes.Add(item); 171 loadedNodes.Add(item);
165 } 172 }
166 } 173 }
@@ -205,14 +212,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
205 string iarPath, 212 string iarPath,
206 InventoryFolderBase rootDestFolder, 213 InventoryFolderBase rootDestFolder,
207 Dictionary <string, InventoryFolderBase> resolvedFolders, 214 Dictionary <string, InventoryFolderBase> resolvedFolders,
208 List<InventoryNodeBase> loadedNodes) 215 HashSet<InventoryNodeBase> loadedNodes)
209 { 216 {
210 string iarPathExisting = iarPath; 217 string iarPathExisting = iarPath;
211 218
212// m_log.DebugFormat( 219// m_log.DebugFormat(
213// "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); 220// "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID);
214 221
215 InventoryFolderBase destFolder = ResolveDestinationFolder(rootDestFolder, ref iarPathExisting, resolvedFolders); 222 InventoryFolderBase destFolder
223 = ResolveDestinationFolder(rootDestFolder, ref iarPathExisting, resolvedFolders);
216 224
217// m_log.DebugFormat( 225// m_log.DebugFormat(
218// "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]", 226// "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]",
@@ -251,46 +259,55 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
251 { 259 {
252// string originalArchivePath = archivePath; 260// string originalArchivePath = archivePath;
253 261
254 InventoryFolderBase destFolder = null; 262 while (archivePath.Length > 0)
255
256 if (archivePath.Length > 0)
257 { 263 {
258 while (null == destFolder && archivePath.Length > 0) 264 m_log.DebugFormat("[INVENTORY ARCHIVER]: Trying to resolve destination folder {0}", archivePath);
265
266 if (resolvedFolders.ContainsKey(archivePath))
267 {
268// m_log.DebugFormat(
269// "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath);
270 return resolvedFolders[archivePath];
271 }
272 else
259 { 273 {
260// m_log.DebugFormat("[INVENTORY ARCHIVER]: Trying to resolve destination folder {0}", archivePath); 274 if (m_merge)
275 {
276 // TODO: Using m_invPath is totally wrong - what we need to do is strip the uuid from the
277 // iar name and try to find that instead.
278 string plainPath = ArchiveConstants.ExtractPlainPathFromIarPath(archivePath);
279 List<InventoryFolderBase> folderCandidates
280 = InventoryArchiveUtils.FindFolderByPath(
281 m_scene.InventoryService, m_userInfo.PrincipalID, plainPath);
282
283 if (folderCandidates.Count != 0)
284 {
285 InventoryFolderBase destFolder = folderCandidates[0];
286 resolvedFolders[archivePath] = destFolder;
287 return destFolder;
288 }
289 }
261 290
262 if (resolvedFolders.ContainsKey(archivePath)) 291 // Don't include the last slash so find the penultimate one
292 int penultimateSlashIndex = archivePath.LastIndexOf("/", archivePath.Length - 2);
293
294 if (penultimateSlashIndex >= 0)
263 { 295 {
264// m_log.DebugFormat( 296 // Remove the last section of path so that we can see if we've already resolved the parent
265// "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); 297 archivePath = archivePath.Remove(penultimateSlashIndex + 1);
266 destFolder = resolvedFolders[archivePath];
267 } 298 }
268 else 299 else
269 { 300 {
270 // Don't include the last slash so find the penultimate one 301// m_log.DebugFormat(
271 int penultimateSlashIndex = archivePath.LastIndexOf("/", archivePath.Length - 2); 302// "[INVENTORY ARCHIVER]: Found no previously created folder for archive path {0}",
272 303// originalArchivePath);
273 if (penultimateSlashIndex >= 0) 304 archivePath = string.Empty;
274 { 305 return rootDestFolder;
275 // Remove the last section of path so that we can see if we've already resolved the parent
276 archivePath = archivePath.Remove(penultimateSlashIndex + 1);
277 }
278 else
279 {
280// m_log.DebugFormat(
281// "[INVENTORY ARCHIVER]: Found no previously created folder for archive path {0}",
282// originalArchivePath);
283 archivePath = string.Empty;
284 destFolder = rootDestFolder;
285 }
286 } 306 }
287 } 307 }
288 } 308 }
289 309
290 if (null == destFolder) 310 return rootDestFolder;
291 destFolder = rootDestFolder;
292
293 return destFolder;
294 } 311 }
295 312
296 /// <summary> 313 /// <summary>
@@ -316,24 +333,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
316 string iarPathExisting, 333 string iarPathExisting,
317 string iarPathToReplicate, 334 string iarPathToReplicate,
318 Dictionary <string, InventoryFolderBase> resolvedFolders, 335 Dictionary <string, InventoryFolderBase> resolvedFolders,
319 List<InventoryNodeBase> loadedNodes) 336 HashSet<InventoryNodeBase> loadedNodes)
320 { 337 {
321 string[] rawDirsToCreate = iarPathToReplicate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); 338 string[] rawDirsToCreate = iarPathToReplicate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
322 int i = 0;
323 339
324 while (i < rawDirsToCreate.Length) 340 for (int i = 0; i < rawDirsToCreate.Length; i++)
325 { 341 {
326// m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0} from IAR", rawDirsToCreate[i]); 342// m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0} from IAR", rawDirsToCreate[i]);
327 343
344 if (!rawDirsToCreate[i].Contains(ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR))
345 continue;
346
328 int identicalNameIdentifierIndex 347 int identicalNameIdentifierIndex
329 = rawDirsToCreate[i].LastIndexOf( 348 = rawDirsToCreate[i].LastIndexOf(
330 ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); 349 ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
331 350
332 if (identicalNameIdentifierIndex < 0)
333 {
334 i++;
335 continue;
336 }
337 string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); 351 string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
338 352
339 newFolderName = InventoryArchiveUtils.UnescapeArchivePath(newFolderName); 353 newFolderName = InventoryArchiveUtils.UnescapeArchivePath(newFolderName);
@@ -356,8 +370,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
356 370
357 if (0 == i) 371 if (0 == i)
358 loadedNodes.Add(destFolder); 372 loadedNodes.Add(destFolder);
359
360 i++;
361 } 373 }
362 } 374 }
363 375
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index f7a2b09..f03f2a1 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -91,12 +91,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
91 91
92 scene.AddCommand( 92 scene.AddCommand(
93 this, "load iar", 93 this, "load iar",
94 "load iar <first> <last> <inventory path> <password> [<IAR path>]", 94 "load iar <first> <last> <inventory path> <password> [<IAR path>]",
95 //"load iar [--merge] <first> <last> <inventory path> <password> [<IAR path>]", 95 //"load iar [--merge] <first> <last> <inventory path> <password> [<IAR path>]",
96 "Load user inventory archive (IAR).", 96 "Load user inventory archive (IAR).",
97 //"--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" 97 //"--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones"
98 //+ "<first> is user's first name." + Environment.NewLine 98 //+ "<first> is user's first name." + Environment.NewLine
99 "<first> is user's first name." + Environment.NewLine 99 "<first> is user's first name." + Environment.NewLine
100 + "<last> is user's last name." + Environment.NewLine 100 + "<last> is user's last name." + Environment.NewLine
101 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine 101 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine
102 + "<password> is the user's password." + Environment.NewLine 102 + "<password> is the user's password." + Environment.NewLine
@@ -136,16 +136,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
136 if (handlerInventoryArchiveSaved != null) 136 if (handlerInventoryArchiveSaved != null)
137 handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); 137 handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException);
138 } 138 }
139 139
140 public bool ArchiveInventory( 140 public bool ArchiveInventory(
141 Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) 141 Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream)
142 { 142 {
143 return ArchiveInventory(id, firstName, lastName, invPath, pass, saveStream, new Dictionary<string, object>()); 143 return ArchiveInventory(id, firstName, lastName, invPath, pass, saveStream, new Dictionary<string, object>());
144 } 144 }
145 145
146 public bool ArchiveInventory( 146 public bool ArchiveInventory(
147 Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream, 147 Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream,
148 Dictionary<string, object> options) 148 Dictionary<string, object> options)
149 { 149 {
150 if (m_scenes.Count > 0) 150 if (m_scenes.Count > 0)
151 { 151 {
@@ -184,8 +184,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
184 } 184 }
185 185
186 public bool ArchiveInventory( 186 public bool ArchiveInventory(
187 Guid id, string firstName, string lastName, string invPath, string pass, string savePath, 187 Guid id, string firstName, string lastName, string invPath, string pass, string savePath,
188 Dictionary<string, object> options) 188 Dictionary<string, object> options)
189 { 189 {
190 if (m_scenes.Count > 0) 190 if (m_scenes.Count > 0)
191 { 191 {
@@ -224,13 +224,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
224 } 224 }
225 225
226 public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream) 226 public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream)
227 { 227 {
228 return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>()); 228 return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>());
229 } 229 }
230 230
231 public bool DearchiveInventory( 231 public bool DearchiveInventory(
232 string firstName, string lastName, string invPath, string pass, Stream loadStream, 232 string firstName, string lastName, string invPath, string pass, Stream loadStream,
233 Dictionary<string, object> options) 233 Dictionary<string, object> options)
234 { 234 {
235 if (m_scenes.Count > 0) 235 if (m_scenes.Count > 0)
236 { 236 {
@@ -241,10 +241,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
241 if (CheckPresence(userInfo.PrincipalID)) 241 if (CheckPresence(userInfo.PrincipalID))
242 { 242 {
243 InventoryArchiveReadRequest request; 243 InventoryArchiveReadRequest request;
244 bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false);
244 245
245 try 246 try
246 { 247 {
247 request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); 248 request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream, merge);
248 } 249 }
249 catch (EntryPointNotFoundException e) 250 catch (EntryPointNotFoundException e)
250 { 251 {
@@ -273,8 +274,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
273 } 274 }
274 275
275 public bool DearchiveInventory( 276 public bool DearchiveInventory(
276 string firstName, string lastName, string invPath, string pass, string loadPath, 277 string firstName, string lastName, string invPath, string pass, string loadPath,
277 Dictionary<string, object> options) 278 Dictionary<string, object> options)
278 { 279 {
279 if (m_scenes.Count > 0) 280 if (m_scenes.Count > 0)
280 { 281 {
@@ -285,10 +286,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
285 if (CheckPresence(userInfo.PrincipalID)) 286 if (CheckPresence(userInfo.PrincipalID))
286 { 287 {
287 InventoryArchiveReadRequest request; 288 InventoryArchiveReadRequest request;
289 bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false);
288 290
289 try 291 try
290 { 292 {
291 request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); 293 request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath, merge);
292 } 294 }
293 catch (EntryPointNotFoundException e) 295 catch (EntryPointNotFoundException e)
294 { 296 {
@@ -334,7 +336,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
334 if (mainParams.Count < 6) 336 if (mainParams.Count < 6)
335 { 337 {
336 m_log.Error( 338 m_log.Error(
337 "[INVENTORY ARCHIVER]: usage is load iar <first name> <last name> <inventory path> <user password> [<load file path>]"); 339 "[INVENTORY ARCHIVER]: usage is load iar [--merge] <first name> <last name> <inventory path> <user password> [<load file path>]");
338 return; 340 return;
339 } 341 }
340 342
@@ -356,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
356 catch (InventoryArchiverException e) 358 catch (InventoryArchiverException e)
357 { 359 {
358 m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); 360 m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message);
359 } 361 }
360 } 362 }
361 363
362 /// <summary> 364 /// <summary>
@@ -469,7 +471,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
469 /// Notify the client of loaded nodes if they are logged in 471 /// Notify the client of loaded nodes if they are logged in
470 /// </summary> 472 /// </summary>
471 /// <param name="loadedNodes">Can be empty. In which case, nothing happens</param> 473 /// <param name="loadedNodes">Can be empty. In which case, nothing happens</param>
472 private void UpdateClientWithLoadedNodes(UserAccount userInfo, List<InventoryNodeBase> loadedNodes) 474 private void UpdateClientWithLoadedNodes(UserAccount userInfo, HashSet<InventoryNodeBase> loadedNodes)
473 { 475 {
474 if (loadedNodes.Count == 0) 476 if (loadedNodes.Count == 0)
475 return; 477 return;
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 4531bfd..2d80382 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -629,7 +629,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
629 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); 629 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
630 630
631 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); 631 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
632 List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); 632 HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>();
633 633
634 string folder1Name = "1"; 634 string folder1Name = "1";
635 string folder2aName = "2a"; 635 string folder2aName = "2a";
@@ -644,7 +644,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
644 644
645 { 645 {
646 // Test replication of path1 646 // Test replication of path1
647 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) 647 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
648 .ReplicateArchivePathToUserInventory( 648 .ReplicateArchivePathToUserInventory(
649 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), 649 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
650 foldersCreated, nodesLoaded); 650 foldersCreated, nodesLoaded);
@@ -661,7 +661,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
661 661
662 { 662 {
663 // Test replication of path2 663 // Test replication of path2
664 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) 664 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
665 .ReplicateArchivePathToUserInventory( 665 .ReplicateArchivePathToUserInventory(
666 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), 666 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
667 foldersCreated, nodesLoaded); 667 foldersCreated, nodesLoaded);
@@ -707,10 +707,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
707 707
708 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); 708 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
709 709
710 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) 710 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
711 .ReplicateArchivePathToUserInventory( 711 .ReplicateArchivePathToUserInventory(
712 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), 712 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
713 new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>()); 713 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
714 714
715 List<InventoryFolderBase> folder1PostCandidates 715 List<InventoryFolderBase> folder1PostCandidates
716 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); 716 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
@@ -732,5 +732,45 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
732 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b"); 732 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
733 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); 733 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
734 } 734 }
735
736 /// <summary>
737 /// Test replication of a partly existing archive path to the user's inventory. This should create
738 /// a merged path.
739 /// </summary>
740 [Test]
741 public void TestMergeIarPath()
742 {
743 TestHelper.InMethod();
744 log4net.Config.XmlConfigurator.Configure();
745
746 Scene scene = SceneSetupHelpers.SetupScene("inventory");
747 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
748
749 string folder1ExistingName = "a";
750 string folder2Name = "b";
751
752 InventoryFolderBase folder1
753 = UserInventoryTestUtils.CreateInventoryFolder(
754 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
755
756 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
757 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
758
759 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
760
761 new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true)
762 .ReplicateArchivePathToUserInventory(
763 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
764 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
765
766 List<InventoryFolderBase> folder1PostCandidates
767 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
768 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
769 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
770
771 List<InventoryFolderBase> folder2PostCandidates
772 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b");
773 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
774 }
735 } 775 }
736} \ No newline at end of file 776} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
index 36dae6b..9c20d68 100644
--- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -173,16 +173,16 @@ namespace OpenSim.Region.CoreModules.Framework.Library
173 m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName); 173 m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName);
174 simpleName = GetInventoryPathFromName(simpleName); 174 simpleName = GetInventoryPathFromName(simpleName);
175 175
176 InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, simpleName, iarFileName); 176 InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, simpleName, iarFileName, false);
177 try 177 try
178 { 178 {
179 List<InventoryNodeBase> nodes = archread.Execute(); 179 HashSet<InventoryNodeBase> nodes = archread.Execute();
180 if (nodes != null && nodes.Count == 0) 180 if (nodes != null && nodes.Count == 0)
181 { 181 {
182 // didn't find the subfolder with the given name; place it on the top 182 // didn't find the subfolder with the given name; place it on the top
183 m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName); 183 m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName);
184 archread.Close(); 184 archread.Close();
185 archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName); 185 archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false);
186 archread.Execute(); 186 archread.Execute();
187 } 187 }
188 foreach (InventoryNodeBase node in nodes) 188 foreach (InventoryNodeBase node in nodes)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 2a87da2..6864629 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -283,6 +283,9 @@ namespace OpenSim.Region.CoreModules.World.Land
283 283
284 public bool IsBannedFromLand(UUID avatar) 284 public bool IsBannedFromLand(UUID avatar)
285 { 285 {
286 if (m_scene.Permissions.IsAdministrator(avatar))
287 return false;
288
286 if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0) 289 if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0)
287 { 290 {
288 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 291 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
@@ -301,6 +304,9 @@ namespace OpenSim.Region.CoreModules.World.Land
301 304
302 public bool IsRestrictedFromLand(UUID avatar) 305 public bool IsRestrictedFromLand(UUID avatar)
303 { 306 {
307 if (m_scene.Permissions.IsAdministrator(avatar))
308 return false;
309
304 if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0) 310 if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0)
305 { 311 {
306 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 312 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index 8549b36..82ad109 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -59,9 +59,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
59 59
60 public string Name { get { return "MoapModule"; } } 60 public string Name { get { return "MoapModule"; } }
61 public Type ReplaceableInterface { get { return null; } } 61 public Type ReplaceableInterface { get { return null; } }
62 62
63 public const string MEDIA_TEXTURE_TYPE = "sl";
64
65 /// <summary> 63 /// <summary>
66 /// Is this module enabled? 64 /// Is this module enabled?
67 /// </summary> 65 /// </summary>
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 3a642f4..bc54997 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -210,6 +210,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
210 m_scene.Permissions.OnDeedParcel += CanDeedParcel; 210 m_scene.Permissions.OnDeedParcel += CanDeedParcel;
211 m_scene.Permissions.OnDeedObject += CanDeedObject; 211 m_scene.Permissions.OnDeedObject += CanDeedObject;
212 m_scene.Permissions.OnIsGod += IsGod; 212 m_scene.Permissions.OnIsGod += IsGod;
213 m_scene.Permissions.OnIsAdministrator += IsAdministrator;
213 m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; 214 m_scene.Permissions.OnDuplicateObject += CanDuplicateObject;
214 m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED 215 m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED
215 m_scene.Permissions.OnEditObject += CanEditObject; //MAYBE FULLY IMPLEMENTED 216 m_scene.Permissions.OnEditObject += CanEditObject; //MAYBE FULLY IMPLEMENTED
diff --git a/OpenSim/Region/CoreModules/World/Terrain/DefaultEffects/ChannelDigger.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs
index e23be59..36917e9 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/DefaultEffects/ChannelDigger.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs
@@ -30,7 +30,7 @@ using OpenSim.Region.CoreModules.World.Terrain;
30using OpenSim.Region.CoreModules.World.Terrain.FloodBrushes; 30using OpenSim.Region.CoreModules.World.Terrain.FloodBrushes;
31using OpenSim.Region.Framework.Interfaces; 31using OpenSim.Region.Framework.Interfaces;
32 32
33namespace OpenSim.Region.Modules.Terrain.Extensions.DefaultEffects.Effects 33namespace OpenSim.Region.CoreModules.World.Terrain.Effects
34{ 34{
35 public class ChannelDigger : ITerrainEffect 35 public class ChannelDigger : ITerrainEffect
36 { 36 {
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 1e7ea7b..2c5e444 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
68 #endregion 68 #endregion
69 69
70 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 70 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
71 71
72 private readonly Commander m_commander = new Commander("terrain"); 72 private readonly Commander m_commander = new Commander("terrain");
73 73
74 private readonly Dictionary<StandardTerrainEffects, ITerrainFloodEffect> m_floodeffects = 74 private readonly Dictionary<StandardTerrainEffects, ITerrainFloodEffect> m_floodeffects =
@@ -381,8 +381,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain
381 private void LoadPlugins() 381 private void LoadPlugins()
382 { 382 {
383 m_plugineffects = new Dictionary<string, ITerrainEffect>(); 383 m_plugineffects = new Dictionary<string, ITerrainEffect>();
384 string plugineffectsPath = "Terrain";
385
384 // Load the files in the Terrain/ dir 386 // Load the files in the Terrain/ dir
385 string[] files = Directory.GetFiles("Terrain"); 387 if (!Directory.Exists(plugineffectsPath))
388 return;
389
390 string[] files = Directory.GetFiles(plugineffectsPath);
386 foreach (string file in files) 391 foreach (string file in files)
387 { 392 {
388 m_log.Info("Loading effects in " + file); 393 m_log.Info("Loading effects in " + file);
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index de4c5fb..a90e0f3 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -131,7 +131,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
131 anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) 131 anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID))
132 { 132 {
133 // 16384 is CHANGED_ANIMATION 133 // 16384 is CHANGED_ANIMATION
134 m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 }); 134 m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION});
135 SendAnimPack(); 135 SendAnimPack();
136 } 136 }
137 } 137 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
index 0033900..4e80bf2 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
@@ -64,6 +64,7 @@ namespace OpenSim.Region.Framework.Scenes
64 public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); 64 public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene);
65 public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); 65 public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand);
66 public delegate bool IsGodHandler(UUID user, Scene requestFromScene); 66 public delegate bool IsGodHandler(UUID user, Scene requestFromScene);
67 public delegate bool IsAdministratorHandler(UUID user);
67 public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); 68 public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene);
68 public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); 69 public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene);
69 public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); 70 public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene);
@@ -124,6 +125,7 @@ namespace OpenSim.Region.Framework.Scenes
124 public event RunConsoleCommandHandler OnRunConsoleCommand; 125 public event RunConsoleCommandHandler OnRunConsoleCommand;
125 public event IssueEstateCommandHandler OnIssueEstateCommand; 126 public event IssueEstateCommandHandler OnIssueEstateCommand;
126 public event IsGodHandler OnIsGod; 127 public event IsGodHandler OnIsGod;
128 public event IsAdministratorHandler OnIsAdministrator;
127 public event EditParcelHandler OnEditParcel; 129 public event EditParcelHandler OnEditParcel;
128 public event SellParcelHandler OnSellParcel; 130 public event SellParcelHandler OnSellParcel;
129 public event AbandonParcelHandler OnAbandonParcel; 131 public event AbandonParcelHandler OnAbandonParcel;
@@ -656,6 +658,21 @@ namespace OpenSim.Region.Framework.Scenes
656 } 658 }
657 return true; 659 return true;
658 } 660 }
661
662 public bool IsAdministrator(UUID user)
663 {
664 IsAdministratorHandler handler = OnIsAdministrator;
665 if (handler != null)
666 {
667 Delegate[] list = handler.GetInvocationList();
668 foreach (IsAdministratorHandler h in list)
669 {
670 if (h(user) == false)
671 return false;
672 }
673 }
674 return true;
675 }
659 #endregion 676 #endregion
660 677
661 #region EDIT PARCEL 678 #region EDIT PARCEL
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e8dce08..dcd7f3d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2727,7 +2727,9 @@ namespace OpenSim.Region.Framework.Scenes
2727 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); 2727 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2728 if (userVerification != null && ep != null) 2728 if (userVerification != null && ep != null)
2729 { 2729 {
2730 if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString())) 2730 System.Net.IPAddress addr = NetworkUtil.GetExternalIPOf(ep.Address);
2731
2732 if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString()))
2731 { 2733 {
2732 // uh-oh, this is fishy 2734 // uh-oh, this is fishy
2733 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); 2735 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
@@ -2785,17 +2787,11 @@ namespace OpenSim.Region.Framework.Scenes
2785 SubscribeToClientPrimEvents(client); 2787 SubscribeToClientPrimEvents(client);
2786 SubscribeToClientPrimRezEvents(client); 2788 SubscribeToClientPrimRezEvents(client);
2787 SubscribeToClientInventoryEvents(client); 2789 SubscribeToClientInventoryEvents(client);
2788 SubscribeToClientAttachmentEvents(client);
2789 SubscribeToClientTeleportEvents(client); 2790 SubscribeToClientTeleportEvents(client);
2790 SubscribeToClientScriptEvents(client); 2791 SubscribeToClientScriptEvents(client);
2791 SubscribeToClientParcelEvents(client); 2792 SubscribeToClientParcelEvents(client);
2792 SubscribeToClientGridEvents(client); 2793 SubscribeToClientGridEvents(client);
2793 SubscribeToClientGodEvents(client);
2794
2795 SubscribeToClientNetworkEvents(client); 2794 SubscribeToClientNetworkEvents(client);
2796
2797
2798 // EventManager.TriggerOnNewClient(client);
2799 } 2795 }
2800 2796
2801 public virtual void SubscribeToClientTerrainEvents(IClientAPI client) 2797 public virtual void SubscribeToClientTerrainEvents(IClientAPI client)
@@ -2805,8 +2801,7 @@ namespace OpenSim.Region.Framework.Scenes
2805 } 2801 }
2806 2802
2807 public virtual void SubscribeToClientPrimEvents(IClientAPI client) 2803 public virtual void SubscribeToClientPrimEvents(IClientAPI client)
2808 { 2804 {
2809
2810 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition; 2805 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition;
2811 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 2806 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2812 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation; 2807 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation;
@@ -2876,18 +2871,6 @@ namespace OpenSim.Region.Framework.Scenes
2876 client.OnMoveTaskItem += ClientMoveTaskInventoryItem; 2871 client.OnMoveTaskItem += ClientMoveTaskInventoryItem;
2877 } 2872 }
2878 2873
2879 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client)
2880 {
2881 if (AttachmentsModule != null)
2882 {
2883 client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory;
2884 client.OnRezMultipleAttachmentsFromInv += AttachmentsModule.RezMultipleAttachmentsFromInventory;
2885 client.OnObjectAttach += AttachmentsModule.AttachObject;
2886 client.OnObjectDetach += AttachmentsModule.DetachObject;
2887 client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory;
2888 }
2889 }
2890
2891 public virtual void SubscribeToClientTeleportEvents(IClientAPI client) 2874 public virtual void SubscribeToClientTeleportEvents(IClientAPI client)
2892 { 2875 {
2893 client.OnTeleportLocationRequest += RequestTeleportLocation; 2876 client.OnTeleportLocationRequest += RequestTeleportLocation;
@@ -2917,44 +2900,29 @@ namespace OpenSim.Region.Framework.Scenes
2917 client.OnSetStartLocationRequest += SetHomeRezPoint; 2900 client.OnSetStartLocationRequest += SetHomeRezPoint;
2918 client.OnRegionHandleRequest += RegionHandleRequest; 2901 client.OnRegionHandleRequest += RegionHandleRequest;
2919 } 2902 }
2920 2903
2921 public virtual void SubscribeToClientGodEvents(IClientAPI client)
2922 {
2923 IGodsModule godsModule = RequestModuleInterface<IGodsModule>();
2924 client.OnGodKickUser += godsModule.KickUser;
2925 client.OnRequestGodlikePowers += godsModule.RequestGodlikePowers;
2926 }
2927
2928 public virtual void SubscribeToClientNetworkEvents(IClientAPI client) 2904 public virtual void SubscribeToClientNetworkEvents(IClientAPI client)
2929 { 2905 {
2930 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; 2906 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats;
2931 client.OnViewerEffect += ProcessViewerEffect; 2907 client.OnViewerEffect += ProcessViewerEffect;
2932 } 2908 }
2933 2909
2934 protected virtual void UnsubscribeToClientEvents(IClientAPI client)
2935 {
2936 }
2937
2938 /// <summary> 2910 /// <summary>
2939 /// Register for events from the client 2911 /// Unsubscribe the client from events.
2940 /// </summary> 2912 /// </summary>
2941 /// <param name="client">The IClientAPI of the connected client</param> 2913 /// FIXME: Not called anywhere!
2914 /// <param name="client">The IClientAPI of the client</param>
2942 public virtual void UnSubscribeToClientEvents(IClientAPI client) 2915 public virtual void UnSubscribeToClientEvents(IClientAPI client)
2943 { 2916 {
2944 UnSubscribeToClientTerrainEvents(client); 2917 UnSubscribeToClientTerrainEvents(client);
2945 UnSubscribeToClientPrimEvents(client); 2918 UnSubscribeToClientPrimEvents(client);
2946 UnSubscribeToClientPrimRezEvents(client); 2919 UnSubscribeToClientPrimRezEvents(client);
2947 UnSubscribeToClientInventoryEvents(client); 2920 UnSubscribeToClientInventoryEvents(client);
2948 UnSubscribeToClientAttachmentEvents(client);
2949 UnSubscribeToClientTeleportEvents(client); 2921 UnSubscribeToClientTeleportEvents(client);
2950 UnSubscribeToClientScriptEvents(client); 2922 UnSubscribeToClientScriptEvents(client);
2951 UnSubscribeToClientParcelEvents(client); 2923 UnSubscribeToClientParcelEvents(client);
2952 UnSubscribeToClientGridEvents(client); 2924 UnSubscribeToClientGridEvents(client);
2953 UnSubscribeToClientGodEvents(client);
2954
2955 UnSubscribeToClientNetworkEvents(client); 2925 UnSubscribeToClientNetworkEvents(client);
2956
2957 // EventManager.TriggerOnNewClient(client);
2958 } 2926 }
2959 2927
2960 public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) 2928 public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client)
@@ -3031,18 +2999,6 @@ namespace OpenSim.Region.Framework.Scenes
3031 client.OnMoveTaskItem -= ClientMoveTaskInventoryItem; 2999 client.OnMoveTaskItem -= ClientMoveTaskInventoryItem;
3032 } 3000 }
3033 3001
3034 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client)
3035 {
3036 if (AttachmentsModule != null)
3037 {
3038 client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory;
3039 client.OnRezMultipleAttachmentsFromInv -= AttachmentsModule.RezMultipleAttachmentsFromInventory;
3040 client.OnObjectAttach -= AttachmentsModule.AttachObject;
3041 client.OnObjectDetach -= AttachmentsModule.DetachObject;
3042 client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory;
3043 }
3044 }
3045
3046 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) 3002 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client)
3047 { 3003 {
3048 client.OnTeleportLocationRequest -= RequestTeleportLocation; 3004 client.OnTeleportLocationRequest -= RequestTeleportLocation;
@@ -3074,13 +3030,6 @@ namespace OpenSim.Region.Framework.Scenes
3074 client.OnRegionHandleRequest -= RegionHandleRequest; 3030 client.OnRegionHandleRequest -= RegionHandleRequest;
3075 } 3031 }
3076 3032
3077 public virtual void UnSubscribeToClientGodEvents(IClientAPI client)
3078 {
3079 IGodsModule godsModule = RequestModuleInterface<IGodsModule>();
3080 client.OnGodKickUser -= godsModule.KickUser;
3081 client.OnRequestGodlikePowers -= godsModule.RequestGodlikePowers;
3082 }
3083
3084 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) 3033 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client)
3085 { 3034 {
3086 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats; 3035 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats;
@@ -5294,4 +5243,4 @@ namespace OpenSim.Region.Framework.Scenes
5294 return offsets.ToArray(); 5243 return offsets.ToArray();
5295 } 5244 }
5296 } 5245 }
5297} 5246} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 40332a6..f47450f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -78,8 +78,6 @@ namespace OpenSim.Region.Framework.Scenes
78// protected internal Dictionary<UUID, EntityBase> Entities = new Dictionary<UUID, EntityBase>(); 78// protected internal Dictionary<UUID, EntityBase> Entities = new Dictionary<UUID, EntityBase>();
79 protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>(); 79 protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>();
80 80
81 protected internal BasicQuadTreeNode QuadTree;
82
83 protected RegionInfo m_regInfo; 81 protected RegionInfo m_regInfo;
84 protected Scene m_parentScene; 82 protected Scene m_parentScene;
85 protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>(); 83 protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>();
@@ -107,9 +105,6 @@ namespace OpenSim.Region.Framework.Scenes
107 { 105 {
108 m_parentScene = parent; 106 m_parentScene = parent;
109 m_regInfo = regInfo; 107 m_regInfo = regInfo;
110 QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, (short)Constants.RegionSize, (short)Constants.RegionSize);
111 QuadTree.Subdivide();
112 QuadTree.Subdivide();
113 } 108 }
114 109
115 public PhysicsScene PhysicsScene 110 public PhysicsScene PhysicsScene
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 32332f7..3dac0ad 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -56,10 +56,11 @@ namespace OpenSim.Region.Framework.Scenes
56 LINK = 32, 56 LINK = 32,
57 ALLOWED_DROP = 64, 57 ALLOWED_DROP = 64,
58 OWNER = 128, 58 OWNER = 128,
59 REGION_RESTART = 256, 59 REGION = 256,
60 REGION = 512, 60 TELEPORT = 512,
61 TELEPORT = 1024, 61 REGION_RESTART = 1024,
62 MEDIA = 2048 62 MEDIA = 2048,
63 ANIMATION = 16384
63 } 64 }
64 65
65 // I don't really know where to put this except here. 66 // I don't really know where to put this except here.
@@ -871,7 +872,6 @@ namespace OpenSim.Region.Framework.Scenes
871 set 872 set
872 { 873 {
873 m_color = value; 874 m_color = value;
874 TriggerScriptChangedEvent(Changed.COLOR);
875 875
876 /* ScheduleFullUpdate() need not be called b/c after 876 /* ScheduleFullUpdate() need not be called b/c after
877 * setting the color, the text will be set, so then 877 * setting the color, the text will be set, so then
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 1e8ce22..4c17615 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -929,7 +929,12 @@ namespace OpenSim.Region.Framework.Scenes
929 /// </summary> 929 /// </summary>
930 public void MakeChildAgent() 930 public void MakeChildAgent()
931 { 931 {
932 Animator.ResetAnimations(); 932 // It looks like m_animator is set to null somewhere, and MakeChild
933 // is called after that. Probably in aborted teleports.
934 if (m_animator == null)
935 m_animator = new ScenePresenceAnimator(this);
936 else
937 Animator.ResetAnimations();
933 938
934// m_log.DebugFormat( 939// m_log.DebugFormat(
935// "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", 940// "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}",
@@ -3455,7 +3460,7 @@ namespace OpenSim.Region.Framework.Scenes
3455 if (m == null) // No script engine loaded 3460 if (m == null) // No script engine loaded
3456 continue; 3461 continue;
3457 3462
3458 m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { 16384 }); 3463 m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION });
3459 } 3464 }
3460 } 3465 }
3461 } 3466 }
diff --git a/OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs
deleted file mode 100644
index 38a9203..0000000
--- a/OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs
+++ /dev/null
@@ -1,269 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenSim.Region.Framework.Scenes;
31
32namespace OpenSim.Region.Framework.Scenes.Types
33{
34 public class BasicQuadTreeNode
35 {
36 private List<SceneObjectGroup> m_objects = new List<SceneObjectGroup>();
37 private BasicQuadTreeNode[] m_childNodes = null;
38 private BasicQuadTreeNode m_parent = null;
39
40 private short m_leftX;
41 private short m_leftY;
42 private short m_width;
43 private short m_height;
44 //private int m_quadNumber;
45 private string m_quadID;
46
47 public BasicQuadTreeNode(BasicQuadTreeNode parent, string quadID, short leftX, short leftY, short width,
48 short height)
49 {
50 m_parent = parent;
51 m_quadID = quadID;
52 m_leftX = leftX;
53 m_leftY = leftY;
54 m_width = width;
55 m_height = height;
56 // m_log.Debug("creating quadtree node " + m_quadID);
57 }
58
59 public void AddObject(SceneObjectGroup obj)
60 {
61 if (m_childNodes == null)
62 {
63 if (!m_objects.Contains(obj))
64 {
65 m_objects.Add(obj);
66 }
67 }
68 else
69 {
70 if (obj.AbsolutePosition.X < (m_leftX + (m_width/2)))
71 {
72 if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2)))
73 {
74 m_childNodes[0].AddObject(obj);
75 }
76 else
77 {
78 m_childNodes[2].AddObject(obj);
79 }
80 }
81 else
82 {
83 if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2)))
84 {
85 m_childNodes[1].AddObject(obj);
86 }
87 else
88 {
89 m_childNodes[3].AddObject(obj);
90 }
91 }
92 }
93 }
94
95 public void Subdivide()
96 {
97 if (m_childNodes == null)
98 {
99 m_childNodes = new BasicQuadTreeNode[4];
100 m_childNodes[0] =
101 new BasicQuadTreeNode(this, m_quadID + "1/", m_leftX, m_leftY, (short) (m_width/2),
102 (short) (m_height/2));
103 m_childNodes[1] =
104 new BasicQuadTreeNode(this, m_quadID + "2/", (short) (m_leftX + (m_width/2)), m_leftY,
105 (short) (m_width/2), (short) (m_height/2));
106 m_childNodes[2] =
107 new BasicQuadTreeNode(this, m_quadID + "3/", m_leftX, (short) (m_leftY + (m_height/2)),
108 (short) (m_width/2), (short) (m_height/2));
109 m_childNodes[3] =
110 new BasicQuadTreeNode(this, m_quadID + "4/", (short) (m_leftX + (m_width/2)),
111 (short) (m_height + (m_height/2)), (short) (m_width/2), (short) (m_height/2));
112 }
113 else
114 {
115 for (int i = 0; i < m_childNodes.Length; i++)
116 {
117 m_childNodes[i].Subdivide();
118 }
119 }
120 }
121
122 public List<SceneObjectGroup> GetObjectsFrom(float x, float y)
123 {
124 if (m_childNodes == null)
125 {
126 return new List<SceneObjectGroup>(m_objects);
127 }
128 else
129 {
130 if (x < m_leftX + (m_width/2))
131 {
132 if (y < m_leftY + (m_height/2))
133 {
134 return m_childNodes[0].GetObjectsFrom(x, y);
135 }
136 else
137 {
138 return m_childNodes[2].GetObjectsFrom(x, y);
139 }
140 }
141 else
142 {
143 if (y < m_leftY + (m_height/2))
144 {
145 return m_childNodes[1].GetObjectsFrom(x, y);
146 }
147 else
148 {
149 return m_childNodes[3].GetObjectsFrom(x, y);
150 }
151 }
152 }
153 }
154
155 public List<SceneObjectGroup> GetObjectsFrom(string nodeName)
156 {
157 if (nodeName == m_quadID)
158 {
159 return new List<SceneObjectGroup>(m_objects);
160 }
161 else if (m_childNodes != null)
162 {
163 for (int i = 0; i < 4; i++)
164 {
165 List<SceneObjectGroup> retVal;
166 retVal = m_childNodes[i].GetObjectsFrom(nodeName);
167 if (retVal != null)
168 {
169 return retVal;
170 }
171 }
172 }
173 return null;
174 }
175
176 public string GetNodeID(float x, float y)
177 {
178 if (m_childNodes == null)
179 {
180 return m_quadID;
181 }
182 else
183 {
184 if (x < m_leftX + (m_width/2))
185 {
186 if (y < m_leftY + (m_height/2))
187 {
188 return m_childNodes[0].GetNodeID(x, y);
189 }
190 else
191 {
192 return m_childNodes[2].GetNodeID(x, y);
193 }
194 }
195 else
196 {
197 if (y < m_leftY + (m_height/2))
198 {
199 return m_childNodes[1].GetNodeID(x, y);
200 }
201 else
202 {
203 return m_childNodes[3].GetNodeID(x, y);
204 }
205 }
206 }
207 }
208
209 public void Update()
210 {
211 if (m_childNodes != null)
212 {
213 for (int i = 0; i < 4; i++)
214 {
215 m_childNodes[i].Update();
216 }
217 }
218 else
219 {
220 List<SceneObjectGroup> outBounds = new List<SceneObjectGroup>();
221 foreach (SceneObjectGroup group in m_objects)
222 {
223 if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) &&
224 ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height))))
225 {
226 //still in bounds
227 }
228 else
229 {
230 outBounds.Add(group);
231 }
232 }
233
234 foreach (SceneObjectGroup removee in outBounds)
235 {
236 m_objects.Remove(removee);
237 if (m_parent != null)
238 {
239 m_parent.PassUp(removee);
240 }
241 }
242 outBounds.Clear();
243 }
244 }
245
246 public void PassUp(SceneObjectGroup group)
247 {
248 if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) &&
249 ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height))))
250 {
251 AddObject(group);
252 }
253 else
254 {
255 if (m_parent != null)
256 {
257 m_parent.PassUp(group);
258 }
259 }
260 }
261
262 public string[] GetNeighbours(string nodeName)
263 {
264 string[] retVal = new string[1];
265 retVal[0] = String.Empty;
266 return retVal;
267 }
268 }
269}
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs
index 9d41c9c..a0d6197 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs
@@ -28,11 +28,14 @@
28using System; 28using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Region.CoreModules.Avatar.Attachments;
32using OpenSim.Region.CoreModules.Avatar.Gods;
33using OpenSim.Region.Framework.Interfaces;
31using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
32 35
33namespace OpenSim.Region.RegionCombinerModule 36namespace OpenSim.Region.RegionCombinerModule
34{ 37{
35 public class RegionCombinerIndividualEventForwarder 38 public class RegionCombinerIndividualEventForwarder
36 { 39 {
37 private Scene m_rootScene; 40 private Scene m_rootScene;
38 private Scene m_virtScene; 41 private Scene m_virtScene;
@@ -46,22 +49,31 @@ namespace OpenSim.Region.RegionCombinerModule
46 public void ClientConnect(IClientAPI client) 49 public void ClientConnect(IClientAPI client)
47 { 50 {
48 m_virtScene.UnSubscribeToClientPrimEvents(client); 51 m_virtScene.UnSubscribeToClientPrimEvents(client);
49 m_virtScene.UnSubscribeToClientPrimRezEvents(client); 52 m_virtScene.UnSubscribeToClientPrimRezEvents(client);
50 m_virtScene.UnSubscribeToClientInventoryEvents(client); 53 m_virtScene.UnSubscribeToClientInventoryEvents(client);
51 m_virtScene.UnSubscribeToClientAttachmentEvents(client); 54 ((AttachmentsModule)m_virtScene.AttachmentsModule).UnsubscribeFromClientEvents(client);
52 //m_virtScene.UnSubscribeToClientTeleportEvents(client); 55 //m_virtScene.UnSubscribeToClientTeleportEvents(client);
53 m_virtScene.UnSubscribeToClientScriptEvents(client); 56 m_virtScene.UnSubscribeToClientScriptEvents(client);
54 m_virtScene.UnSubscribeToClientGodEvents(client); 57
58 IGodsModule virtGodsModule = m_virtScene.RequestModuleInterface<IGodsModule>();
59 if (virtGodsModule != null)
60 ((GodsModule)virtGodsModule).UnsubscribeFromClientEvents(client);
61
55 m_virtScene.UnSubscribeToClientNetworkEvents(client); 62 m_virtScene.UnSubscribeToClientNetworkEvents(client);
56 63
57 m_rootScene.SubscribeToClientPrimEvents(client); 64 m_rootScene.SubscribeToClientPrimEvents(client);
58 client.OnAddPrim += LocalAddNewPrim; 65 client.OnAddPrim += LocalAddNewPrim;
59 client.OnRezObject += LocalRezObject; 66 client.OnRezObject += LocalRezObject;
67
60 m_rootScene.SubscribeToClientInventoryEvents(client); 68 m_rootScene.SubscribeToClientInventoryEvents(client);
61 m_rootScene.SubscribeToClientAttachmentEvents(client); 69 ((AttachmentsModule)m_rootScene.AttachmentsModule).SubscribeToClientEvents(client);
62 //m_rootScene.SubscribeToClientTeleportEvents(client); 70 //m_rootScene.SubscribeToClientTeleportEvents(client);
63 m_rootScene.SubscribeToClientScriptEvents(client); 71 m_rootScene.SubscribeToClientScriptEvents(client);
64 m_rootScene.SubscribeToClientGodEvents(client); 72
73 IGodsModule rootGodsModule = m_virtScene.RequestModuleInterface<IGodsModule>();
74 if (rootGodsModule != null)
75 ((GodsModule)rootGodsModule).UnsubscribeFromClientEvents(client);
76
65 m_rootScene.SubscribeToClientNetworkEvents(client); 77 m_rootScene.SubscribeToClientNetworkEvents(client);
66 } 78 }
67 79
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index 9f6ea35..0c99d8c 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -38,10 +38,11 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
38{ 38{
39 public enum StateSource 39 public enum StateSource
40 { 40 {
41 NewRez = 0, 41 RegionStart = 0,
42 PrimCrossing = 1, 42 NewRez = 1,
43 ScriptedRez = 2, 43 PrimCrossing = 2,
44 AttachedRez = 3 44 ScriptedRez = 3,
45 AttachedRez = 4
45 } 46 }
46 47
47 public interface IScriptWorkItem 48 public interface IScriptWorkItem
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 8903c3b..139b4f1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -68,6 +68,14 @@ using System.Reflection;
68 68
69namespace OpenSim.Region.ScriptEngine.Shared.Api 69namespace OpenSim.Region.ScriptEngine.Shared.Api
70{ 70{
71 // MUST be a ref type
72 public class UserInfoCacheEntry
73 {
74 public int time;
75 public UserAccount account;
76 public PresenceInfo pinfo;
77 }
78
71 /// <summary> 79 /// <summary>
72 /// Contains all LSL ll-functions. This class will be in Default AppDomain. 80 /// Contains all LSL ll-functions. This class will be in Default AppDomain.
73 /// </summary> 81 /// </summary>
@@ -92,6 +100,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
92 protected int m_scriptConsoleChannel = 0; 100 protected int m_scriptConsoleChannel = 0;
93 protected bool m_scriptConsoleChannelEnabled = false; 101 protected bool m_scriptConsoleChannelEnabled = false;
94 protected IUrlModule m_UrlModule = null; 102 protected IUrlModule m_UrlModule = null;
103 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
104 new Dictionary<UUID, UserInfoCacheEntry>();
95 105
96 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 106 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
97 { 107 {
@@ -1934,13 +1944,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1934 } 1944 }
1935 else 1945 else
1936 { 1946 {
1937 if (llVecDist(new LSL_Vector(0,0,0), targetPos) <= 10.0f) 1947 LSL_Vector rel_vec = SetPosAdjust(currentPos, targetPos);
1938 { 1948 part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z);
1939 part.OffsetPosition = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z); 1949 SceneObjectGroup parent = part.ParentGroup;
1940 SceneObjectGroup parent = part.ParentGroup; 1950 parent.HasGroupChanged = true;
1941 parent.HasGroupChanged = true; 1951 parent.ScheduleGroupForTerseUpdate();
1942 parent.ScheduleGroupForTerseUpdate();
1943 }
1944 } 1952 }
1945 } 1953 }
1946 1954
@@ -3250,17 +3258,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3250 public void llPointAt(LSL_Vector pos) 3258 public void llPointAt(LSL_Vector pos)
3251 { 3259 {
3252 m_host.AddScriptLPS(1); 3260 m_host.AddScriptLPS(1);
3253 ScenePresence Owner = World.GetScenePresence(m_host.UUID);
3254 LSL_Rotation rot = llEuler2Rot(pos);
3255 Owner.PreviousRotation = Owner.Rotation;
3256 Owner.Rotation = (new Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s));
3257 } 3261 }
3258 3262
3259 public void llStopPointAt() 3263 public void llStopPointAt()
3260 { 3264 {
3261 m_host.AddScriptLPS(1); 3265 m_host.AddScriptLPS(1);
3262 ScenePresence Owner = m_host.ParentGroup.Scene.GetScenePresence(m_host.OwnerID);
3263 Owner.Rotation = Owner.PreviousRotation;
3264 } 3266 }
3265 3267
3266 public void llTargetOmega(LSL_Vector axis, double spinrate, double gain) 3268 public void llTargetOmega(LSL_Vector axis, double spinrate, double gain)
@@ -3916,24 +3918,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3916 m_host.AddScriptLPS(1); 3918 m_host.AddScriptLPS(1);
3917 3919
3918 UUID uuid = (UUID)id; 3920 UUID uuid = (UUID)id;
3921 PresenceInfo pinfo = null;
3922 UserAccount account;
3919 3923
3920 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); 3924 UserInfoCacheEntry ce;
3925 if (!m_userInfoCache.TryGetValue(uuid, out ce))
3926 {
3927 account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
3928 if (account == null)
3929 {
3930 m_userInfoCache[uuid] = null; // Cache negative
3931 return UUID.Zero.ToString();
3932 }
3921 3933
3922 PresenceInfo pinfo = null;
3923 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
3924 if (pinfos != null && pinfos.Length > 0)
3925 pinfo = pinfos[0];
3926 3934
3927 if (pinfo == null) 3935 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
3928 return UUID.Zero.ToString(); 3936 if (pinfos != null && pinfos.Length > 0)
3937 pinfo = pinfos[0];
3938
3939 ce = new UserInfoCacheEntry();
3940 ce.time = Util.EnvironmentTickCount();
3941 ce.account = account;
3942 ce.pinfo = pinfo;
3943 }
3944 else
3945 {
3946 if (ce == null)
3947 return UUID.Zero.ToString();
3948
3949 account = ce.account;
3950 pinfo = ce.pinfo;
3951 }
3952
3953 if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000)
3954 {
3955 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
3956 if (pinfos != null && pinfos.Length > 0)
3957 pinfo = pinfos[0];
3958 else
3959 pinfo = null;
3960
3961 ce.time = Util.EnvironmentTickCount();
3962 ce.pinfo = pinfo;
3963 }
3929 3964
3930 string reply = String.Empty; 3965 string reply = String.Empty;
3931 3966
3932 switch (data) 3967 switch (data)
3933 { 3968 {
3934 case 1: // DATA_ONLINE (0|1) 3969 case 1: // DATA_ONLINE (0|1)
3935 // TODO: implement fetching of this information 3970 if (pinfo != null && pinfo.RegionID != UUID.Zero)
3936 if (pinfo != null)
3937 reply = "1"; 3971 reply = "1";
3938 else 3972 else
3939 reply = "0"; 3973 reply = "0";
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index fe71ed5..5ae6439 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 06f9426..5da6bb9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -273,9 +273,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
273 public const int CHANGED_LINK = 32; 273 public const int CHANGED_LINK = 32;
274 public const int CHANGED_ALLOWED_DROP = 64; 274 public const int CHANGED_ALLOWED_DROP = 64;
275 public const int CHANGED_OWNER = 128; 275 public const int CHANGED_OWNER = 128;
276 public const int CHANGED_REGION_RESTART = 256; 276 public const int CHANGED_REGION = 256;
277 public const int CHANGED_REGION = 512; 277 public const int CHANGED_TELEPORT = 512;
278 public const int CHANGED_TELEPORT = 1024; 278 public const int CHANGED_REGION_RESTART = 1024;
279 public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART
279 public const int CHANGED_MEDIA = 2048; 280 public const int CHANGED_MEDIA = 2048;
280 public const int CHANGED_ANIMATION = 16384; 281 public const int CHANGED_ANIMATION = 16384;
281 public const int TYPE_INVALID = 0; 282 public const int TYPE_INVALID = 0;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 3dd381d..6663aa5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -388,17 +388,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
388 PostEvent(new EventParams("attach", 388 PostEvent(new EventParams("attach",
389 new object[] { new LSL_Types.LSLString(m_AttachedAvatar.ToString()) }, new DetectParams[0])); 389 new object[] { new LSL_Types.LSLString(m_AttachedAvatar.ToString()) }, new DetectParams[0]));
390 } 390 }
391 else if (m_stateSource == StateSource.NewRez) 391 else if (m_stateSource == StateSource.RegionStart)
392 { 392 {
393// m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script"); 393// m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script");
394 PostEvent(new EventParams("changed", 394 PostEvent(new EventParams("changed",
395 new Object[] {new LSL_Types.LSLInteger(256)}, new DetectParams[0])); 395 new Object[] { (int)Changed.REGION_RESTART }, new DetectParams[0]));
396 } 396 }
397 else if (m_stateSource == StateSource.PrimCrossing) 397 else if (m_stateSource == StateSource.PrimCrossing)
398 { 398 {
399 // CHANGED_REGION 399 // CHANGED_REGION
400 PostEvent(new EventParams("changed", 400 PostEvent(new EventParams("changed",
401 new Object[] {new LSL_Types.LSLInteger(512)}, new DetectParams[0])); 401 new Object[] { (int)Changed.REGION }, new DetectParams[0]));
402 } 402 }
403 } 403 }
404 else 404 else