aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs15
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs16
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs120
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs367
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs5
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs8
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs168
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs10
-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.cs96
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs9
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs139
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverException.cs (renamed from OpenSim/Framework/ConfigBase.cs)16
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs111
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs125
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs22
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs126
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs3
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs46
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs10
-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/CoreModules/World/WorldMap/WorldMapModule.cs2
-rw-r--r--OpenSim/Region/DataSnapshot/ObjectSnapshot.cs2
-rw-r--r--OpenSim/Region/DataSnapshot/SnapshotStore.cs21
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IHyperService.cs37
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs209
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs95
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs23
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs431
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs37
-rw-r--r--OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs269
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs5
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs59
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs4
-rw-r--r--OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs89
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs11
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/EventManager.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs264
55 files changed, 1374 insertions, 1729 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/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
index 9869a99..e9e2dca 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
55 public IJ2KDecoder J2KDecoder; 55 public IJ2KDecoder J2KDecoder;
56 public IAssetService AssetService; 56 public IAssetService AssetService;
57 public UUID AgentID; 57 public UUID AgentID;
58 public IHyperAssetService HyperAssets; 58 public IInventoryAccessModule InventoryAccessModule;
59 public OpenJPEG.J2KLayerInfo[] Layers; 59 public OpenJPEG.J2KLayerInfo[] Layers;
60 public bool IsDecoded; 60 public bool IsDecoded;
61 public bool HasAsset; 61 public bool HasAsset;
@@ -375,14 +375,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
375 UUID assetID = UUID.Zero; 375 UUID assetID = UUID.Zero;
376 if (asset != null) 376 if (asset != null)
377 assetID = asset.FullID; 377 assetID = asset.FullID;
378 else if ((HyperAssets != null) && (sender != HyperAssets)) 378 else if ((InventoryAccessModule != null) && (sender != InventoryAccessModule))
379 { 379 {
380 // Try the user's inventory, but only if it's different from the regions' 380 // Unfortunately we need this here, there's no other way.
381 string userAssets = HyperAssets.GetUserAssetServer(AgentID); 381 // This is due to the fact that textures opened directly from the agent's inventory
382 if ((userAssets != string.Empty) && (userAssets != HyperAssets.GetSimAssetServer())) 382 // don't have any distinguishing feature. As such, in order to serve those when the
383 // foreign user is visiting, we need to try again after the first fail to the local
384 // asset service.
385 string assetServerURL = string.Empty;
386 if (InventoryAccessModule.IsForeignUser(AgentID, out assetServerURL))
383 { 387 {
384 m_log.DebugFormat("[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", id); 388 m_log.DebugFormat("[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", id);
385 AssetService.Get(userAssets + "/" + id, HyperAssets, AssetReceived); 389 AssetService.Get(assetServerURL + "/" + id, InventoryAccessModule, AssetReceived);
386 return; 390 return;
387 } 391 }
388 } 392 }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index d2824bd..0aec01a 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -357,7 +357,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
357 protected uint m_agentFOVCounter; 357 protected uint m_agentFOVCounter;
358 358
359 protected IAssetService m_assetService; 359 protected IAssetService m_assetService;
360 private IHyperAssetService m_hyperAssets;
361 private const bool m_checkPackets = true; 360 private const bool m_checkPackets = true;
362 361
363 private Timer m_propertiesPacketTimer; 362 private Timer m_propertiesPacketTimer;
@@ -432,7 +431,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
432// m_attachmentsSent = new HashSet<uint>(); 431// m_attachmentsSent = new HashSet<uint>();
433 432
434 m_assetService = m_scene.RequestModuleInterface<IAssetService>(); 433 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
435 m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>();
436 m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>(); 434 m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
437 m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>()); 435 m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
438 m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion()); 436 m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
@@ -3680,30 +3678,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3680 3678
3681 #endregion Primitive Packet/Data Sending Methods 3679 #endregion Primitive Packet/Data Sending Methods
3682 3680
3683 /// <summary>
3684 ///
3685 /// </summary>
3686 /// <param name="localID"></param>
3687 /// <param name="rotation"></param>
3688 /// <param name="attachPoint"></param>
3689 public void AttachObject(uint localID, Quaternion rotation, byte attachPoint, UUID ownerID)
3690 {
3691 if (attachPoint > 30 && ownerID != AgentId) // Someone else's HUD
3692 return;
3693
3694 ObjectAttachPacket attach = (ObjectAttachPacket)PacketPool.Instance.GetPacket(PacketType.ObjectAttach);
3695 // TODO: don't create new blocks if recycling an old packet
3696 attach.AgentData.AgentID = AgentId;
3697 attach.AgentData.SessionID = m_sessionId;
3698 attach.AgentData.AttachmentPoint = attachPoint;
3699 attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1];
3700 attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock();
3701 attach.ObjectData[0].ObjectLocalID = localID;
3702 attach.ObjectData[0].Rotation = rotation;
3703 attach.Header.Zerocoded = true;
3704 OutPacket(attach, ThrottleOutPacketType.Task);
3705 }
3706
3707 void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories) 3681 void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
3708 { 3682 {
3709 if ((categories & ThrottleOutPacketTypeFlags.Task) != 0) 3683 if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
@@ -5733,7 +5707,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5733 { 5707 {
5734 if (att.ObjectData.Length > 0) 5708 if (att.ObjectData.Length > 0)
5735 { 5709 {
5736 handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, att.ObjectData[0].Rotation, false); 5710 handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
5737 } 5711 }
5738 } 5712 }
5739 } 5713 }
@@ -7196,59 +7170,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7196 } 7170 }
7197 else // Agent 7171 else // Agent
7198 { 7172 {
7199 IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>(); 7173 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
7200 InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, AgentId); 7174 if (invAccess != null)
7201 assetRequestItem = invService.GetItem(assetRequestItem);
7202 if (assetRequestItem == null)
7203 { 7175 {
7204 ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>(); 7176 if (!invAccess.GetAgentInventoryItem(this, itemID, requestID))
7205 if (lib != null) 7177 return false;
7206 assetRequestItem = lib.LibraryRootFolder.FindItem(itemID);
7207 if (assetRequestItem == null)
7208 return true;
7209 }
7210 7178
7211 // At this point, we need to apply perms
7212 // only to notecards and scripts. All
7213 // other asset types are always available
7214 //
7215 if (assetRequestItem.AssetType == (int)AssetType.LSLText)
7216 {
7217 if (!((Scene)m_scene).Permissions.CanViewScript(itemID, UUID.Zero, AgentId))
7218 {
7219 SendAgentAlertMessage("Insufficient permissions to view script", false);
7220 return true;
7221 }
7222 }
7223 else if (assetRequestItem.AssetType == (int)AssetType.Notecard)
7224 {
7225 if (!((Scene)m_scene).Permissions.CanViewNotecard(itemID, UUID.Zero, AgentId))
7226 {
7227 SendAgentAlertMessage("Insufficient permissions to view notecard", false);
7228 return true;
7229 }
7230 } 7179 }
7180 else
7181 return false;
7231 7182
7232 if (assetRequestItem.AssetID != requestID)
7233 {
7234 m_log.WarnFormat(
7235 "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}",
7236 Name, requestID, itemID, assetRequestItem.AssetID);
7237 return true;
7238 }
7239 } 7183 }
7240 } 7184 }
7241 } 7185 }
7242 7186
7243 //m_assetCache.AddAssetRequest(this, transfer);
7244
7245 MakeAssetRequest(transfer, taskID); 7187 MakeAssetRequest(transfer, taskID);
7246 7188
7247 /* RequestAsset = OnRequestAsset;
7248 if (RequestAsset != null)
7249 {
7250 RequestAsset(this, transfer);
7251 }*/
7252 return true; 7189 return true;
7253 } 7190 }
7254 7191
@@ -11459,15 +11396,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11459 else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) 11396 else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
11460 { 11397 {
11461 requestID = new UUID(transferRequest.TransferInfo.Params, 80); 11398 requestID = new UUID(transferRequest.TransferInfo.Params, 80);
11462 //m_log.Debug("[XXX] inventory asset request " + requestID);
11463 //if (taskID == UUID.Zero) // Agent
11464 // if (m_scene is HGScene)
11465 // {
11466 // m_log.Debug("[XXX] hg asset request " + requestID);
11467 // // We may need to fetch the asset from the user's asset server into the local asset server
11468 // HGAssetMapper mapper = ((HGScene)m_scene).AssetMapper;
11469 // mapper.Get(requestID, AgentId);
11470 // }
11471 } 11399 }
11472 11400
11473// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); 11401// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID);
@@ -11483,49 +11411,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11483 /// <param name="asset"></param> 11411 /// <param name="asset"></param>
11484 protected void AssetReceived(string id, Object sender, AssetBase asset) 11412 protected void AssetReceived(string id, Object sender, AssetBase asset)
11485 { 11413 {
11414 if (asset == null)
11415 return;
11416
11486 TransferRequestPacket transferRequest = (TransferRequestPacket)sender; 11417 TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
11487 11418
11488 UUID requestID = UUID.Zero; 11419 UUID requestID = UUID.Zero;
11489 byte source = (byte)SourceType.Asset; 11420 byte source = (byte)SourceType.Asset;
11490 11421
11491 if ((transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) 11422 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
11492 || (transferRequest.TransferInfo.SourceType == 2222))
11493 { 11423 {
11494 requestID = new UUID(transferRequest.TransferInfo.Params, 0); 11424 requestID = new UUID(transferRequest.TransferInfo.Params, 0);
11495 } 11425 }
11496 else if ((transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) 11426 else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
11497 || (transferRequest.TransferInfo.SourceType == 3333))
11498 { 11427 {
11499 requestID = new UUID(transferRequest.TransferInfo.Params, 80); 11428 requestID = new UUID(transferRequest.TransferInfo.Params, 80);
11500 source = (byte)SourceType.SimInventoryItem; 11429 source = (byte)SourceType.SimInventoryItem;
11501 //m_log.Debug("asset request " + requestID); 11430 //m_log.Debug("asset request " + requestID);
11502 } 11431 }
11503 11432
11504 if (null == asset)
11505 {
11506 if ((m_hyperAssets != null) && (transferRequest.TransferInfo.SourceType < 2000))
11507 {
11508 // Try the user's inventory, but only if it's different from the regions'
11509 string userAssets = m_hyperAssets.GetUserAssetServer(AgentId);
11510 if ((userAssets != string.Empty) && (userAssets != m_hyperAssets.GetSimAssetServer()))
11511 {
11512 m_log.DebugFormat("[CLIENT]: asset {0} not found in local asset storage. Trying user's storage.", id);
11513 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
11514 transferRequest.TransferInfo.SourceType = 2222; // marker
11515 else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
11516 transferRequest.TransferInfo.SourceType = 3333; // marker
11517
11518 m_assetService.Get(userAssets + "/" + id, transferRequest, AssetReceived);
11519 return;
11520 }
11521 }
11522
11523 //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID);
11524
11525 // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right.
11526 return;
11527 }
11528
11529 // Scripts cannot be retrieved by direct request 11433 // Scripts cannot be retrieved by direct request
11530 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10) 11434 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
11531 return; 11435 return;
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/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
index 938cf50..9e0db12 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
@@ -58,8 +58,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
58 private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); 58 private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer());
59 private object m_syncRoot = new object(); 59 private object m_syncRoot = new object();
60 60
61 private IHyperAssetService m_hyperAssets;
62
63 public LLClientView Client { get { return m_client; } } 61 public LLClientView Client { get { return m_client; } }
64 public AssetBase MissingImage { get { return m_missingImage; } } 62 public AssetBase MissingImage { get { return m_missingImage; } }
65 63
@@ -75,7 +73,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
75 m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client"); 73 m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client");
76 74
77 m_j2kDecodeModule = pJ2kDecodeModule; 75 m_j2kDecodeModule = pJ2kDecodeModule;
78 m_hyperAssets = client.Scene.RequestModuleInterface<IHyperAssetService>();
79 } 76 }
80 77
81 /// <summary> 78 /// <summary>
@@ -149,7 +146,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
149 imgrequest.J2KDecoder = m_j2kDecodeModule; 146 imgrequest.J2KDecoder = m_j2kDecodeModule;
150 imgrequest.AssetService = m_assetCache; 147 imgrequest.AssetService = m_assetCache;
151 imgrequest.AgentID = m_client.AgentId; 148 imgrequest.AgentID = m_client.AgentId;
152 imgrequest.HyperAssets = m_hyperAssets; 149 imgrequest.InventoryAccessModule = m_client.Scene.RequestModuleInterface<IInventoryAccessModule>();
153 imgrequest.DiscardLevel = newRequest.DiscardLevel; 150 imgrequest.DiscardLevel = newRequest.DiscardLevel;
154 imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); 151 imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber);
155 imgrequest.Priority = newRequest.Priority; 152 imgrequest.Priority = newRequest.Priority;
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index d30e954..3d6e7f3 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -182,7 +182,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
182 182
183 if (part.Inventory.UpdateInventoryItem(item)) 183 if (part.Inventory.UpdateInventoryItem(item))
184 { 184 {
185 remoteClient.SendAgentAlertMessage("Notecard saved", false); 185 if ((InventoryType)item.InvType == InventoryType.Notecard)
186 remoteClient.SendAgentAlertMessage("Notecard saved", false);
187 else if ((InventoryType)item.InvType == InventoryType.LSL)
188 remoteClient.SendAgentAlertMessage("Script saved", false);
189 else
190 remoteClient.SendAgentAlertMessage("Item saved", false);
191
186 part.GetProperties(remoteClient); 192 part.GetProperties(remoteClient);
187 } 193 }
188 } 194 }
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
index 7e08ecf..ae31050 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
243 243
244 if (mm != null) 244 if (mm != null)
245 { 245 {
246 if (!mm.UploadCovered(remoteClient)) 246 if (!mm.UploadCovered(remoteClient, mm.UploadCharge))
247 { 247 {
248 remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); 248 remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
249 return; 249 return;
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
index 75efb79..8aa87fd 100644
--- a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.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 *
@@ -190,7 +190,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
190 end = Utils.Clamp(end, 1, texture.Data.Length); 190 end = Utils.Clamp(end, 1, texture.Data.Length);
191 start = Utils.Clamp(start, 0, end - 1); 191 start = Utils.Clamp(start, 0, end - 1);
192 192
193 m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID); 193 //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
194 194
195 if (end - start < texture.Data.Length) 195 if (end - start < texture.Data.Length)
196 response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent; 196 response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index a7b4c66..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,37 +40,65 @@ 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 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent) 94 /// <summary>
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>
101 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent)
73 { 102 {
74 m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); 103 m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject");
75 104
@@ -84,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
84 return; 113 return;
85 114
86 // Calls attach with a Zero position 115 // Calls attach with a Zero position
87 if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) 116 if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false))
88 { 117 {
89 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); 118 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
90 119
@@ -106,72 +135,78 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
106 } 135 }
107 } 136 }
108 137
109 public bool AttachObject( 138 public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent)
110 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent)
111 { 139 {
112 SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); 140 Vector3 attachPos = group.AbsolutePosition;
113 if (group != null) 141
142 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
114 { 143 {
115 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) 144 // If the attachment point isn't the same as the one previously used
145 // set it's offset position = 0 so that it appears on the attachment point
146 // and not in a weird location somewhere unknown.
147 if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
116 { 148 {
117 // If the attachment point isn't the same as the one previously used 149 attachPos = Vector3.Zero;
118 // set it's offset position = 0 so that it appears on the attachment point 150 }
119 // and not in a weird location somewhere unknown.
120 if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
121 {
122 attachPos = Vector3.Zero;
123 }
124
125 // AttachmentPt 0 means the client chose to 'wear' the attachment.
126 if (AttachmentPt == 0)
127 {
128 // Check object for stored attachment point
129 AttachmentPt = (uint)group.GetAttachmentPoint();
130 }
131 151
132 // if we still didn't find a suitable attachment point....... 152 // AttachmentPt 0 means the client chose to 'wear' the attachment.
133 if (AttachmentPt == 0) 153 if (AttachmentPt == 0)
134 { 154 {
135 // Stick it on left hand with Zero Offset from the attachment point. 155 // Check object for stored attachment point
136 AttachmentPt = (uint)AttachmentPoint.LeftHand; 156 AttachmentPt = (uint)group.GetAttachmentPoint();
137 attachPos = Vector3.Zero; 157 }
138 }
139 158
140 group.SetAttachmentPoint((byte)AttachmentPt); 159 // if we still didn't find a suitable attachment point.......
141 group.AbsolutePosition = attachPos; 160 if (AttachmentPt == 0)
161 {
162 // Stick it on left hand with Zero Offset from the attachment point.
163 AttachmentPt = (uint)AttachmentPoint.LeftHand;
164 attachPos = Vector3.Zero;
165 }
142 166
143 // Saves and gets itemID 167 group.SetAttachmentPoint((byte)AttachmentPt);
144 UUID itemId; 168 group.AbsolutePosition = attachPos;
145 169
146 if (group.GetFromItemID() == UUID.Zero) 170 // Remove any previous attachments
147 { 171 ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
148 m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId); 172 UUID itemID = UUID.Zero;
149 } 173 if (sp != null)
150 else 174 {
175 foreach(SceneObjectGroup grp in sp.Attachments)
151 { 176 {
152 itemId = group.GetFromItemID(); 177 if (grp.GetAttachmentPoint() == (byte)AttachmentPt)
178 {
179 itemID = grp.GetFromItemID();
180 break;
181 }
153 } 182 }
183 if (itemID != UUID.Zero)
184 DetachSingleAttachmentToInv(itemID, remoteClient);
185 }
154 186
155 SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemId, group); 187 if (group.GetFromItemID() == UUID.Zero)
156 188 {
157 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent); 189 m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID);
158
159 // In case it is later dropped again, don't let
160 // it get cleaned up
161 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
162 group.HasGroupChanged = false;
163 } 190 }
164 else 191 else
165 { 192 {
166 remoteClient.SendAgentAlertMessage( 193 itemID = group.GetFromItemID();
167 "You don't have sufficient permissions to attach this object", false);
168
169 return false;
170 } 194 }
195
196 SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemID, group);
197
198 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent);
199
200 // In case it is later dropped again, don't let
201 // it get cleaned up
202 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
203 group.HasGroupChanged = false;
171 } 204 }
172 else 205 else
173 { 206 {
174 m_log.DebugFormat("[ATTACHMENTS MODULE]: AttachObject found no such scene object {0}", objectLocalID); 207 remoteClient.SendAgentAlertMessage(
208 "You don't have sufficient permissions to attach this object", false);
209
175 return false; 210 return false;
176 } 211 }
177 212
@@ -237,8 +272,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
237 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) 272 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
238 tainted = true; 273 tainted = true;
239 274
240 AttachObject( 275 AttachObject(remoteClient, objatt, AttachmentPt, false);
241 remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
242 //objatt.ScheduleGroupForFullUpdate(); 276 //objatt.ScheduleGroupForFullUpdate();
243 277
244 if (tainted) 278 if (tainted)
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index b5c3176..2105f3c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -81,14 +81,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
81 { 81 {
82 ScenePresence sp = m_scene.GetScenePresence(agentID); 82 ScenePresence sp = m_scene.GetScenePresence(agentID);
83 83
84 if (sp != null && !sp.IsChildAgent) 84 if (sp != null)
85 sp.ControllingClient.SendAgentAlertMessage(message, modal); 85 sp.ControllingClient.SendAgentAlertMessage(message, modal);
86 } 86 }
87 87
88 public void SendAlertToUser(string firstName, string lastName, string message, bool modal) 88 public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
89 { 89 {
90 ScenePresence presence = m_scene.GetScenePresence(firstName, lastName); 90 ScenePresence presence = m_scene.GetScenePresence(firstName, lastName);
91 if (presence != null && !presence.IsChildAgent) 91 if (presence != null)
92 presence.ControllingClient.SendAgentAlertMessage(message, modal); 92 presence.ControllingClient.SendAgentAlertMessage(message, modal);
93 } 93 }
94 94
@@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
119 } 119 }
120 120
121 ScenePresence sp = m_scene.GetScenePresence(avatarID); 121 ScenePresence sp = m_scene.GetScenePresence(avatarID);
122 if (sp != null && !sp.IsChildAgent) 122 if (sp != null)
123 sp.ControllingClient.SendDialog(objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); 123 sp.ControllingClient.SendDialog(objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels);
124 } 124 }
125 125
@@ -128,7 +128,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
128 { 128 {
129 ScenePresence sp = m_scene.GetScenePresence(avatarID); 129 ScenePresence sp = m_scene.GetScenePresence(avatarID);
130 130
131 if (sp != null && !sp.IsChildAgent) 131 if (sp != null)
132 sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url); 132 sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url);
133 } 133 }
134 134
@@ -149,7 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
149 149
150 ScenePresence sp = m_scene.GetScenePresence(avatarid); 150 ScenePresence sp = m_scene.GetScenePresence(avatarid);
151 151
152 if (sp != null && !sp.IsChildAgent) 152 if (sp != null)
153 sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerFirstName, ownerLastName, objectid); 153 sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerFirstName, ownerLastName, objectid);
154 } 154 }
155 155
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 f130b3e..7683288 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -100,37 +100,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
100 /// </returns> 100 /// </returns>
101 public HashSet<InventoryNodeBase> Execute() 101 public HashSet<InventoryNodeBase> Execute()
102 { 102 {
103 string filePath = "ERROR";
104 int successfulAssetRestores = 0;
105 int failedAssetRestores = 0;
106 int successfulItemRestores = 0;
107
108 HashSet<InventoryNodeBase> loadedNodes = new HashSet<InventoryNodeBase>();
109
110 List<InventoryFolderBase> folderCandidates
111 = InventoryArchiveUtils.FindFolderByPath(
112 m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath);
113
114 if (folderCandidates.Count == 0)
115 {
116 // Possibly provide an option later on to automatically create this folder if it does not exist
117 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
118
119 return loadedNodes;
120 }
121
122 InventoryFolderBase rootDestinationFolder = folderCandidates[0];
123 archive = new TarArchiveReader(m_loadStream);
124
125 // In order to load identically named folders, we need to keep track of the folders that we have already
126 // resolved
127 Dictionary <string, InventoryFolderBase> resolvedFolders = new Dictionary<string, InventoryFolderBase>();
128
129 byte[] data;
130 TarArchiveReader.TarEntryType entryType;
131
132 try 103 try
133 { 104 {
105 string filePath = "ERROR";
106 int successfulAssetRestores = 0;
107 int failedAssetRestores = 0;
108 int successfulItemRestores = 0;
109
110 HashSet<InventoryNodeBase> loadedNodes = new HashSet<InventoryNodeBase>();
111
112 List<InventoryFolderBase> folderCandidates
113 = InventoryArchiveUtils.FindFolderByPath(
114 m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath);
115
116 if (folderCandidates.Count == 0)
117 {
118 // Possibly provide an option later on to automatically create this folder if it does not exist
119 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
120
121 return loadedNodes;
122 }
123
124 InventoryFolderBase rootDestinationFolder = folderCandidates[0];
125 archive = new TarArchiveReader(m_loadStream);
126
127 // In order to load identically named folders, we need to keep track of the folders that we have already
128 // resolved
129 Dictionary <string, InventoryFolderBase> resolvedFolders = new Dictionary<string, InventoryFolderBase>();
130
131 byte[] data;
132 TarArchiveReader.TarEntryType entryType;
133
134 while ((data = archive.ReadEntry(out filePath, out entryType)) != null) 134 while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
135 { 135 {
136 if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 136 if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
@@ -173,18 +173,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
173 } 173 }
174 } 174 }
175 } 175 }
176
177 archive.Close();
178
179 m_log.DebugFormat(
180 "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures",
181 successfulAssetRestores, failedAssetRestores);
182 m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores);
183
184 return loadedNodes;
176 } 185 }
177 finally 186 finally
178 { 187 {
179 archive.Close(); 188 m_loadStream.Close();
180 } 189 }
181
182 m_log.DebugFormat(
183 "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures",
184 successfulAssetRestores, failedAssetRestores);
185 m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores);
186
187 return loadedNodes;
188 } 190 }
189 191
190 public void Close() 192 public void Close()
@@ -220,9 +222,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
220 InventoryFolderBase destFolder 222 InventoryFolderBase destFolder
221 = ResolveDestinationFolder(rootDestFolder, ref iarPathExisting, resolvedFolders); 223 = ResolveDestinationFolder(rootDestFolder, ref iarPathExisting, resolvedFolders);
222 224
223 m_log.DebugFormat( 225// m_log.DebugFormat(
224 "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]", 226// "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]",
225 iarPath, iarPathExisting); 227// iarPath, iarPathExisting);
226 228
227 string iarPathToCreate = iarPath.Substring(iarPathExisting.Length); 229 string iarPathToCreate = iarPath.Substring(iarPathExisting.Length);
228 CreateFoldersForPath(destFolder, iarPathExisting, iarPathToCreate, resolvedFolders, loadedNodes); 230 CreateFoldersForPath(destFolder, iarPathExisting, iarPathToCreate, resolvedFolders, loadedNodes);
@@ -255,7 +257,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
255 ref string archivePath, 257 ref string archivePath,
256 Dictionary <string, InventoryFolderBase> resolvedFolders) 258 Dictionary <string, InventoryFolderBase> resolvedFolders)
257 { 259 {
258 string originalArchivePath = archivePath; 260// string originalArchivePath = archivePath;
259 261
260 while (archivePath.Length > 0) 262 while (archivePath.Length > 0)
261 { 263 {
@@ -263,8 +265,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
263 265
264 if (resolvedFolders.ContainsKey(archivePath)) 266 if (resolvedFolders.ContainsKey(archivePath))
265 { 267 {
266 m_log.DebugFormat( 268// m_log.DebugFormat(
267 "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); 269// "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath);
268 return resolvedFolders[archivePath]; 270 return resolvedFolders[archivePath];
269 } 271 }
270 else 272 else
@@ -296,9 +298,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
296 } 298 }
297 else 299 else
298 { 300 {
299 m_log.DebugFormat( 301// m_log.DebugFormat(
300 "[INVENTORY ARCHIVER]: Found no previously created folder for archive path {0}", 302// "[INVENTORY ARCHIVER]: Found no previously created folder for archive path {0}",
301 originalArchivePath); 303// originalArchivePath);
302 archivePath = string.Empty; 304 archivePath = string.Empty;
303 return rootDestFolder; 305 return rootDestFolder;
304 } 306 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
index ca33968..84afb40 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
@@ -206,11 +206,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
206 206
207 if (components.Length == 1) 207 if (components.Length == 1)
208 { 208 {
209// m_log.DebugFormat("FOUND SINGLE COMPONENT [{0}]", components[0]); 209// m_log.DebugFormat(
210// "FOUND SINGLE COMPONENT [{0}]. Looking for this in [{1}] {2}",
211// components[0], startFolder.Name, startFolder.ID);
210 212
211 List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID); 213 List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID);
214
215// m_log.DebugFormat("[INVENTORY ARCHIVE UTILS]: Found {0} items in FindItemByPath()", items.Count);
216
212 foreach (InventoryItemBase item in items) 217 foreach (InventoryItemBase item in items)
213 { 218 {
219// m_log.DebugFormat("[INVENTORY ARCHIVE UTILS]: Inspecting item {0} {1}", item.Name, item.ID);
220
214 if (item.Name == components[0]) 221 if (item.Name == components[0])
215 return item; 222 return item;
216 } 223 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 2c2724e..25a78ff 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -119,22 +119,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
119 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) 119 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
120 { 120 {
121 Exception reportedException = null; 121 Exception reportedException = null;
122 bool succeeded = true; 122 bool succeeded = true;
123 123
124 try 124 try
125 { 125 {
126 // We're almost done. Just need to write out the control file now 126 // We're almost done. Just need to write out the control file now
127 m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile()); 127 m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
128 m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); 128 m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
129
130 m_archiveWriter.Close(); 129 m_archiveWriter.Close();
131 } 130 }
132 catch (Exception e) 131 catch (Exception e)
133 { 132 {
134 m_saveStream.Close();
135 reportedException = e; 133 reportedException = e;
136 succeeded = false; 134 succeeded = false;
137 } 135 }
136 finally
137 {
138 m_saveStream.Close();
139 }
138 140
139 m_module.TriggerInventoryArchiveSaved( 141 m_module.TriggerInventoryArchiveSaved(
140 m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); 142 m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException);
@@ -213,70 +215,68 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
213 /// </summary> 215 /// </summary>
214 public void Execute() 216 public void Execute()
215 { 217 {
216 InventoryFolderBase inventoryFolder = null; 218 try
217 InventoryItemBase inventoryItem = null;
218 InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID);
219
220 bool foundStar = false;
221
222 // Eliminate double slashes and any leading / on the path.
223 string[] components
224 = m_invPath.Split(
225 new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries);
226
227 int maxComponentIndex = components.Length - 1;
228
229 // If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the
230 // folder itself. This may get more sophisicated later on
231 if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD)
232 {
233 foundStar = true;
234 maxComponentIndex--;
235 }
236
237 m_invPath = String.Empty;
238 for (int i = 0; i <= maxComponentIndex; i++)
239 {
240 m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER;
241 }
242
243 // Annoyingly Split actually returns the original string if the input string consists only of delimiters
244 // Therefore if we still start with a / after the split, then we need the root folder
245 if (m_invPath.Length == 0)
246 {
247 inventoryFolder = rootFolder;
248 }
249 else
250 {
251 m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
252 List<InventoryFolderBase> candidateFolders
253 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath);
254 if (candidateFolders.Count > 0)
255 inventoryFolder = candidateFolders[0];
256 }
257
258 // The path may point to an item instead
259 if (inventoryFolder == null)
260 {
261 inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath);
262 //inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath);
263 }
264
265 if (null == inventoryFolder && null == inventoryItem)
266 { 219 {
267 // We couldn't find the path indicated 220 InventoryFolderBase inventoryFolder = null;
268 string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); 221 InventoryItemBase inventoryItem = null;
269 m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", errorMessage); 222 InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID);
270 m_module.TriggerInventoryArchiveSaved( 223
271 m_id, false, m_userInfo, m_invPath, m_saveStream, 224 bool foundStar = false;
272 new Exception(errorMessage)); 225
273 return; 226 // Eliminate double slashes and any leading / on the path.
274 } 227 string[] components
228 = m_invPath.Split(
229 new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries);
230
231 int maxComponentIndex = components.Length - 1;
232
233 // If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the
234 // folder itself. This may get more sophisicated later on
235 if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD)
236 {
237 foundStar = true;
238 maxComponentIndex--;
239 }
240
241 m_invPath = String.Empty;
242 for (int i = 0; i <= maxComponentIndex; i++)
243 {
244 m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER;
245 }
246
247 // Annoyingly Split actually returns the original string if the input string consists only of delimiters
248 // Therefore if we still start with a / after the split, then we need the root folder
249 if (m_invPath.Length == 0)
250 {
251 inventoryFolder = rootFolder;
252 }
253 else
254 {
255 m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
256 List<InventoryFolderBase> candidateFolders
257 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath);
258 if (candidateFolders.Count > 0)
259 inventoryFolder = candidateFolders[0];
260 }
261
262 // The path may point to an item instead
263 if (inventoryFolder == null)
264 {
265 inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath);
266 //inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath);
267 }
268
269 if (null == inventoryFolder && null == inventoryItem)
270 {
271 // We couldn't find the path indicated
272 string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath);
273 Exception e = new InventoryArchiverException(errorMessage);
274 m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e);
275 throw e;
276 }
275 277
276 m_archiveWriter = new TarArchiveWriter(m_saveStream); 278 m_archiveWriter = new TarArchiveWriter(m_saveStream);
277 279
278 try
279 {
280 if (inventoryFolder != null) 280 if (inventoryFolder != null)
281 { 281 {
282 m_log.DebugFormat( 282 m_log.DebugFormat(
@@ -297,16 +297,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
297 297
298 // Don't put all this profile information into the archive right now. 298 // Don't put all this profile information into the archive right now.
299 //SaveUsers(); 299 //SaveUsers();
300
301 new AssetsRequest(
302 new AssetsArchiver(m_archiveWriter), m_assetUuids, m_scene.AssetService, ReceivedAllAssets).Execute();
300 } 303 }
301 catch (Exception) 304 catch (Exception)
302 { 305 {
303 m_archiveWriter.Close(); 306 m_saveStream.Close();
304 throw; 307 throw;
305 } 308 }
306
307 new AssetsRequest(
308 new AssetsArchiver(m_archiveWriter), m_assetUuids,
309 m_scene.AssetService, ReceivedAllAssets).Execute();
310 } 309 }
311 310
312 /// <summary> 311 /// <summary>
diff --git a/OpenSim/Framework/ConfigBase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverException.cs
index 40ec32f..e07e2ca 100644
--- a/OpenSim/Framework/ConfigBase.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverException.cs
@@ -26,13 +26,15 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
30using System.Text;
31 29
32namespace OpenSim.Framework 30namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
33{ 31{
34 public abstract class ConfigBase 32 /// <summary>
35 { 33 /// Signals an inventory archiving problem
36 protected ConfigurationMember m_configMember; 34 /// </summary>
35 public class InventoryArchiverException : Exception
36 {
37 public InventoryArchiverException(string message) : base(message) {}
38 public InventoryArchiverException(string message, Exception e) : base(message, e) {}
37 } 39 }
38} 40} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 668c344..f03f2a1 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -324,34 +324,41 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
324 /// <param name="cmdparams"></param> 324 /// <param name="cmdparams"></param>
325 protected void HandleLoadInvConsoleCommand(string module, string[] cmdparams) 325 protected void HandleLoadInvConsoleCommand(string module, string[] cmdparams)
326 { 326 {
327 m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME."); 327 try
328 328 {
329 Dictionary<string, object> options = new Dictionary<string, object>(); 329 m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME.");
330 OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; }); 330
331 331 Dictionary<string, object> options = new Dictionary<string, object>();
332 List<string> mainParams = optionSet.Parse(cmdparams); 332 OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; });
333 333
334 if (mainParams.Count < 6) 334 List<string> mainParams = optionSet.Parse(cmdparams);
335 { 335
336 m_log.Error( 336 if (mainParams.Count < 6)
337 "[INVENTORY ARCHIVER]: usage is load iar <first name> <last name> <inventory path> <user password> [<load file path>]"); 337 {
338 return; 338 m_log.Error(
339 } 339 "[INVENTORY ARCHIVER]: usage is load iar [--merge] <first name> <last name> <inventory path> <user password> [<load file path>]");
340 340 return;
341 string firstName = mainParams[2]; 341 }
342 string lastName = mainParams[3]; 342
343 string invPath = mainParams[4]; 343 string firstName = mainParams[2];
344 string pass = mainParams[5]; 344 string lastName = mainParams[3];
345 string loadPath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); 345 string invPath = mainParams[4];
346 346 string pass = mainParams[5];
347 m_log.InfoFormat( 347 string loadPath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME);
348 "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", 348
349 loadPath, invPath, firstName, lastName);
350
351 if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options))
352 m_log.InfoFormat( 349 m_log.InfoFormat(
353 "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", 350 "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}",
354 loadPath, firstName, lastName); 351 loadPath, invPath, firstName, lastName);
352
353 if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options))
354 m_log.InfoFormat(
355 "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}",
356 loadPath, firstName, lastName);
357 }
358 catch (InventoryArchiverException e)
359 {
360 m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message);
361 }
355 } 362 }
356 363
357 /// <summary> 364 /// <summary>
@@ -360,30 +367,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
360 /// <param name="cmdparams"></param> 367 /// <param name="cmdparams"></param>
361 protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams) 368 protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams)
362 { 369 {
363 if (cmdparams.Length < 6) 370 Guid id = Guid.NewGuid();
371
372 try
364 { 373 {
365 m_log.Error( 374 if (cmdparams.Length < 6)
366 "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]"); 375 {
367 return; 376 m_log.Error(
377 "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]");
378 return;
379 }
380
381 m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME.");
382
383 string firstName = cmdparams[2];
384 string lastName = cmdparams[3];
385 string invPath = cmdparams[4];
386 string pass = cmdparams[5];
387 string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME);
388
389 m_log.InfoFormat(
390 "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}",
391 savePath, invPath, firstName, lastName);
392
393 ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, new Dictionary<string, object>());
368 } 394 }
369 395 catch (InventoryArchiverException e)
370 m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME."); 396 {
371 397 m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message);
372 string firstName = cmdparams[2]; 398 }
373 string lastName = cmdparams[3]; 399
374 string invPath = cmdparams[4];
375 string pass = cmdparams[5];
376 string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME);
377
378 m_log.InfoFormat(
379 "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}",
380 savePath, invPath, firstName, lastName);
381
382 Guid id = Guid.NewGuid();
383 ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, new Dictionary<string, object>());
384
385 lock (m_pendingConsoleSaves) 400 lock (m_pendingConsoleSaves)
386 m_pendingConsoleSaves.Add(id); 401 m_pendingConsoleSaves.Add(id);
387 } 402 }
388 403
389 private void SaveInvConsoleCommandCompleted( 404 private void SaveInvConsoleCommandCompleted(
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 5fad0a9..2d80382 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -63,13 +63,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
63 } 63 }
64 64
65 /// <summary> 65 /// <summary>
66 /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). 66 /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive
67 /// (subject to change since there is no fixed format yet).
67 /// </summary> 68 /// </summary>
68 // Commenting for now! The mock inventory service needs more beef, at least for
69 // GetFolderForType
70 // REFACTORING PROBLEM. This needs to be rewritten.
71 [Test] 69 [Test]
72 public void TestSaveIarV0_1() 70 public void TestSavePathToIarV0_1()
73 { 71 {
74 TestHelper.InMethod(); 72 TestHelper.InMethod();
75// log4net.Config.XmlConfigurator.Configure(); 73// log4net.Config.XmlConfigurator.Configure();
@@ -182,6 +180,123 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
182 } 180 }
183 181
184 /// <summary> 182 /// <summary>
183 /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive
184 /// (subject to change since there is no fixed format yet).
185 /// </summary>
186 [Test]
187 public void TestSaveItemToIarV0_1()
188 {
189 TestHelper.InMethod();
190// log4net.Config.XmlConfigurator.Configure();
191
192 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
193
194 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
195 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
196
197 // Create user
198 string userFirstName = "Jock";
199 string userLastName = "Stirrup";
200 string userPassword = "troll";
201 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
202 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
203
204 // Create asset
205 SceneObjectGroup object1;
206 SceneObjectPart part1;
207 {
208 string partName = "My Little Dog Object";
209 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
210 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
211 Vector3 groupPosition = new Vector3(10, 20, 30);
212 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
213 Vector3 offsetPosition = new Vector3(5, 10, 15);
214
215 part1
216 = new SceneObjectPart(
217 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
218 part1.Name = partName;
219
220 object1 = new SceneObjectGroup(part1);
221 scene.AddNewSceneObject(object1, false);
222 }
223
224 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
225 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
226 scene.AssetService.Store(asset1);
227
228 // Create item
229 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
230 string item1Name = "My Little Dog";
231 InventoryItemBase item1 = new InventoryItemBase();
232 item1.Name = item1Name;
233 item1.AssetID = asset1.FullID;
234 item1.ID = item1Id;
235 InventoryFolderBase objsFolder
236 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
237 item1.Folder = objsFolder.ID;
238 scene.AddInventoryItem(userId, item1);
239
240 MemoryStream archiveWriteStream = new MemoryStream();
241 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
242
243 mre.Reset();
244 archiverModule.ArchiveInventory(
245 Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream);
246 mre.WaitOne(60000, false);
247
248 byte[] archive = archiveWriteStream.ToArray();
249 MemoryStream archiveReadStream = new MemoryStream(archive);
250 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
251
252 //bool gotControlFile = false;
253 bool gotObject1File = false;
254 //bool gotObject2File = false;
255 string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
256 string expectedObject1FilePath = string.Format(
257 "{0}{1}",
258 ArchiveConstants.INVENTORY_PATH,
259 expectedObject1FileName);
260
261 string filePath;
262 TarArchiveReader.TarEntryType tarEntryType;
263
264// Console.WriteLine("Reading archive");
265
266 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
267 {
268 Console.WriteLine("Got {0}", filePath);
269
270// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
271// {
272// gotControlFile = true;
273// }
274
275 if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
276 {
277// string fileName = filePath.Remove(0, "Objects/".Length);
278//
279// if (fileName.StartsWith(part1.Name))
280// {
281 Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
282 gotObject1File = true;
283// }
284// else if (fileName.StartsWith(part2.Name))
285// {
286// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
287// gotObject2File = true;
288// }
289 }
290 }
291
292// Assert.That(gotControlFile, Is.True, "No control file in archive");
293 Assert.That(gotObject1File, Is.True, "No item1 file in archive");
294// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
295
296 // TODO: Test presence of more files and contents of files.
297 }
298
299 /// <summary>
185 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 300 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
186 /// an account exists with the creator name. 301 /// an account exists with the creator name.
187 /// </summary> 302 /// </summary>
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
index c1e92f5..b13b9d8 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
@@ -157,6 +157,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
157 Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); 157 Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>();
158 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL); 158 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
159 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); 159 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
160 if (ids.ContainsKey(assetID))
161 ids.Remove(assetID);
160 foreach (UUID uuid in ids.Keys) 162 foreach (UUID uuid in ids.Keys)
161 FetchAsset(userAssetURL, uuid); 163 FetchAsset(userAssetURL, uuid);
162 164
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index b0555da..8ccc941 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -131,7 +131,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
131 return ret; 131 return ret;
132 } 132 }
133 133
134 // DO NOT OVERRIDE THIS METHOD 134 // DO NOT OVERRIDE THE BASE METHOD
135 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, 135 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
136 SceneObjectGroup objectGroup, IClientAPI remoteClient) 136 SceneObjectGroup objectGroup, IClientAPI remoteClient)
137 { 137 {
@@ -139,7 +139,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
139 139
140 if (!assetID.Equals(UUID.Zero)) 140 if (!assetID.Equals(UUID.Zero))
141 { 141 {
142 UploadInventoryItem(remoteClient.AgentId, assetID, "", 0); 142 if (remoteClient != null)
143 UploadInventoryItem(remoteClient.AgentId, assetID, "", 0);
143 } 144 }
144 else 145 else
145 m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); 146 m_log.Debug("[HGScene]: Scene.Inventory did not create asset");
@@ -192,9 +193,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
192 m_assMapper.Post(item.AssetID, receiver, userAssetServer); 193 m_assMapper.Post(item.AssetID, receiver, userAssetServer);
193 } 194 }
194 195
195 #endregion 196 public override bool IsForeignUser(UUID userID, out string assetServerURL)
196
197 public bool IsForeignUser(UUID userID, out string assetServerURL)
198 { 197 {
199 assetServerURL = string.Empty; 198 assetServerURL = string.Empty;
200 UserAccount account = null; 199 UserAccount account = null;
@@ -217,5 +216,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
217 216
218 return false; 217 return false;
219 } 218 }
219
220 #endregion
221
222 protected override InventoryItemBase GetItem(UUID agentID, UUID itemID)
223 {
224 InventoryItemBase item = base.GetItem(agentID, itemID);
225
226 string userAssetServer = string.Empty;
227 if (IsForeignUser(agentID, out userAssetServer))
228 m_assMapper.Get(item.AssetID, agentID, userAssetServer);
229
230 return item;
231 }
220 } 232 }
221} 233}
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 12b6aa0..1a7da61 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -322,6 +322,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
322 } 322 }
323 } 323 }
324 324
325 // Override and put into where it came from, if it came
326 // from anywhere in inventory
327 //
328 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
329 {
330 if (objectGroup.RootPart.FromFolderID != UUID.Zero)
331 {
332 InventoryFolderBase f = new InventoryFolderBase(objectGroup.RootPart.FromFolderID, userID);
333 folder = m_Scene.InventoryService.GetFolder(f);
334 }
335 }
336
325 if (folder == null) // None of the above 337 if (folder == null) // None of the above
326 { 338 {
327 folder = new InventoryFolderBase(folderID); 339 folder = new InventoryFolderBase(folderID);
@@ -369,12 +381,27 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
369 if ((nextPerms & (uint)PermissionMask.Modify) == 0) 381 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
370 perms &= ~(uint)PermissionMask.Modify; 382 perms &= ~(uint)PermissionMask.Modify;
371 383
384 // Make sure all bits but the ones we want are clear
385 // on take.
386 // This will be applied to the current perms, so
387 // it will do what we want.
388 objectGroup.RootPart.NextOwnerMask &=
389 ((uint)PermissionMask.Copy |
390 (uint)PermissionMask.Transfer |
391 (uint)PermissionMask.Modify);
392 objectGroup.RootPart.NextOwnerMask |=
393 (uint)PermissionMask.Move;
394
372 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; 395 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
373 item.CurrentPermissions = item.BasePermissions; 396 item.CurrentPermissions = item.BasePermissions;
374 item.NextPermissions = objectGroup.RootPart.NextOwnerMask; 397 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
375 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; 398 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
376 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; 399 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
377 item.CurrentPermissions |= 8; // Slam! 400
401 // Magic number badness. Maybe this deserves an enum.
402 // bit 4 (16) is the "Slam" bit, it means treat as passed
403 // and apply next owner perms on rez
404 item.CurrentPermissions |= 16; // Slam!
378 } 405 }
379 else 406 else
380 { 407 {
@@ -384,7 +411,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
384 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; 411 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
385 item.GroupPermissions = objectGroup.RootPart.GroupMask; 412 item.GroupPermissions = objectGroup.RootPart.GroupMask;
386 413
387 item.CurrentPermissions |= 8; // Slam! 414 item.CurrentPermissions &=
415 ((uint)PermissionMask.Copy |
416 (uint)PermissionMask.Transfer |
417 (uint)PermissionMask.Modify |
418 (uint)PermissionMask.Move |
419 7); // Preserve folded permissions
388 } 420 }
389 421
390 // TODO: add the new fields (Flags, Sale info, etc) 422 // TODO: add the new fields (Flags, Sale info, etc)
@@ -485,6 +517,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
485 SceneObjectGroup group 517 SceneObjectGroup group
486 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); 518 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData);
487 519
520 group.RootPart.FromFolderID = item.Folder;
521
522 // If it's rezzed in world, select it. Much easier to
523 // find small items.
524 //
525 if (!attachment)
526 group.RootPart.CreateSelected = true;
527
488 if (!m_Scene.Permissions.CanRezObject( 528 if (!m_Scene.Permissions.CanRezObject(
489 group.Children.Count, remoteClient.AgentId, pos) 529 group.Children.Count, remoteClient.AgentId, pos)
490 && !attachment) 530 && !attachment)
@@ -557,7 +597,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
557 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); 597 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
558 598
559 group.SetGroup(remoteClient.ActiveGroupId, remoteClient); 599 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
560 if (rootPart.OwnerID != item.Owner) 600 if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0)
561 { 601 {
562 //Need to kill the for sale here 602 //Need to kill the for sale here
563 rootPart.ObjectSaleType = 0; 603 rootPart.ObjectSaleType = 0;
@@ -565,14 +605,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
565 605
566 if (m_Scene.Permissions.PropagatePermissions()) 606 if (m_Scene.Permissions.PropagatePermissions())
567 { 607 {
568 if ((item.CurrentPermissions & 8) != 0) 608 foreach (SceneObjectPart part in partList)
569 { 609 {
570 foreach (SceneObjectPart part in partList) 610 part.EveryoneMask = item.EveryOnePermissions;
571 { 611 part.NextOwnerMask = item.NextPermissions;
572 part.EveryoneMask = item.EveryOnePermissions; 612 part.GroupMask = 0; // DO NOT propagate here
573 part.NextOwnerMask = item.NextPermissions;
574 part.GroupMask = 0; // DO NOT propagate here
575 }
576 } 613 }
577 614
578 group.ApplyNextOwnerPermissions(); 615 group.ApplyNextOwnerPermissions();
@@ -581,19 +618,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
581 618
582 foreach (SceneObjectPart part in partList) 619 foreach (SceneObjectPart part in partList)
583 { 620 {
584 if (part.OwnerID != item.Owner) 621 if ((part.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0)
585 { 622 {
586 part.LastOwnerID = part.OwnerID; 623 part.LastOwnerID = part.OwnerID;
587 part.OwnerID = item.Owner; 624 part.OwnerID = item.Owner;
588 part.Inventory.ChangeInventoryOwner(item.Owner); 625 part.Inventory.ChangeInventoryOwner(item.Owner);
589 }
590 else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
591 {
592 part.EveryoneMask = item.EveryOnePermissions;
593 part.NextOwnerMask = item.NextPermissions;
594
595 part.GroupMask = 0; // DO NOT propagate here 626 part.GroupMask = 0; // DO NOT propagate here
596 } 627 }
628 part.EveryoneMask = item.EveryOnePermissions;
629 part.NextOwnerMask = item.NextPermissions;
597 } 630 }
598 631
599 rootPart.TrimPermissions(); 632 rootPart.TrimPermissions();
@@ -639,6 +672,57 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
639 { 672 {
640 } 673 }
641 674
675 public virtual bool GetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID)
676 {
677 InventoryItemBase assetRequestItem = GetItem(remoteClient.AgentId, itemID);
678 if (assetRequestItem == null)
679 {
680 ILibraryService lib = m_Scene.RequestModuleInterface<ILibraryService>();
681 if (lib != null)
682 assetRequestItem = lib.LibraryRootFolder.FindItem(itemID);
683 if (assetRequestItem == null)
684 return false;
685 }
686
687 // At this point, we need to apply perms
688 // only to notecards and scripts. All
689 // other asset types are always available
690 //
691 if (assetRequestItem.AssetType == (int)AssetType.LSLText)
692 {
693 if (!m_Scene.Permissions.CanViewScript(itemID, UUID.Zero, remoteClient.AgentId))
694 {
695 remoteClient.SendAgentAlertMessage("Insufficient permissions to view script", false);
696 return false;
697 }
698 }
699 else if (assetRequestItem.AssetType == (int)AssetType.Notecard)
700 {
701 if (!m_Scene.Permissions.CanViewNotecard(itemID, UUID.Zero, remoteClient.AgentId))
702 {
703 remoteClient.SendAgentAlertMessage("Insufficient permissions to view notecard", false);
704 return false;
705 }
706 }
707
708 if (assetRequestItem.AssetID != requestID)
709 {
710 m_log.WarnFormat(
711 "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}",
712 Name, requestID, itemID, assetRequestItem.AssetID);
713 return false;
714 }
715
716 return true;
717 }
718
719
720 public virtual bool IsForeignUser(UUID userID, out string assetServerURL)
721 {
722 assetServerURL = string.Empty;
723 return false;
724 }
725
642 #endregion 726 #endregion
643 727
644 #region Misc 728 #region Misc
@@ -661,6 +745,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
661 return asset; 745 return asset;
662 } 746 }
663 747
748 protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID)
749 {
750 IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>();
751 InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, agentID);
752 assetRequestItem = invService.GetItem(assetRequestItem);
753 return assetRequestItem;
754 }
755
664 #endregion 756 #endregion
665 } 757 }
666} 758}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
index ebd6bbd..034e692 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
@@ -41,7 +41,7 @@ using OpenMetaverse;
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset 41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
42{ 42{
43 public class HGAssetBroker : 43 public class HGAssetBroker :
44 ISharedRegionModule, IAssetService, IHyperAssetService 44 ISharedRegionModule, IAssetService
45 { 45 {
46 private static readonly ILog m_log = 46 private static readonly ILog m_log =
47 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -150,7 +150,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
150 m_aScene = scene; 150 m_aScene = scene;
151 151
152 scene.RegisterModuleInterface<IAssetService>(this); 152 scene.RegisterModuleInterface<IAssetService>(this);
153 scene.RegisterModuleInterface<IHyperAssetService>(this);
154 } 153 }
155 154
156 public void RemoveRegion(Scene scene) 155 public void RemoveRegion(Scene scene)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index e09db15..97161fc 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -202,9 +202,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
202 } 202 }
203 } 203 }
204 } 204 }
205
206 // else put a null; it means that the methods should forward to local grid's inventory
207 m_InventoryURLs.Add(userID, null);
208 } 205 }
209 206
210 private void DropInventoryServiceURL(UUID userID) 207 private void DropInventoryServiceURL(UUID userID)
@@ -223,10 +220,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
223 if (m_InventoryURLs.ContainsKey(userID)) 220 if (m_InventoryURLs.ContainsKey(userID))
224 return m_InventoryURLs[userID]; 221 return m_InventoryURLs[userID];
225 222
226 else 223 CacheInventoryServiceURL(userID);
227 CacheInventoryServiceURL(userID);
228 224
229 return m_InventoryURLs[userID]; 225 if (m_InventoryURLs.ContainsKey(userID))
226 return m_InventoryURLs[userID];
227
228 return null; //it means that the methods should forward to local grid's inventory
229
230 } 230 }
231 #endregion 231 #endregion
232 232
@@ -253,7 +253,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
253 253
254 public InventoryFolderBase GetRootFolder(UUID userID) 254 public InventoryFolderBase GetRootFolder(UUID userID)
255 { 255 {
256 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID); 256 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID);
257 257
258 string invURL = GetInventoryServiceURL(userID); 258 string invURL = GetInventoryServiceURL(userID);
259 259
@@ -267,7 +267,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
267 267
268 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) 268 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
269 { 269 {
270 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type); 270 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type);
271 271
272 string invURL = GetInventoryServiceURL(userID); 272 string invURL = GetInventoryServiceURL(userID);
273 273
@@ -281,7 +281,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
281 281
282 public InventoryCollection GetFolderContent(UUID userID, UUID folderID) 282 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
283 { 283 {
284 m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderContent " + folderID); 284 //m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderContent " + folderID);
285 285
286 string invURL = GetInventoryServiceURL(userID); 286 string invURL = GetInventoryServiceURL(userID);
287 287
@@ -296,7 +296,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
296 296
297 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 297 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
298 { 298 {
299 m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderItems " + folderID); 299 //m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderItems " + folderID);
300 300
301 string invURL = GetInventoryServiceURL(userID); 301 string invURL = GetInventoryServiceURL(userID);
302 302
@@ -314,7 +314,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
314 if (folder == null) 314 if (folder == null)
315 return false; 315 return false;
316 316
317 m_log.Debug("[HG INVENTORY CONNECTOR]: AddFolder " + folder.ID); 317 //m_log.Debug("[HG INVENTORY CONNECTOR]: AddFolder " + folder.ID);
318 318
319 string invURL = GetInventoryServiceURL(folder.Owner); 319 string invURL = GetInventoryServiceURL(folder.Owner);
320 320
@@ -331,7 +331,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
331 if (folder == null) 331 if (folder == null)
332 return false; 332 return false;
333 333
334 m_log.Debug("[HG INVENTORY CONNECTOR]: UpdateFolder " + folder.ID); 334 //m_log.Debug("[HG INVENTORY CONNECTOR]: UpdateFolder " + folder.ID);
335 335
336 string invURL = GetInventoryServiceURL(folder.Owner); 336 string invURL = GetInventoryServiceURL(folder.Owner);
337 337
@@ -350,7 +350,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
350 if (folderIDs.Count == 0) 350 if (folderIDs.Count == 0)
351 return false; 351 return false;
352 352
353 m_log.Debug("[HG INVENTORY CONNECTOR]: DeleteFolders for " + ownerID); 353 //m_log.Debug("[HG INVENTORY CONNECTOR]: DeleteFolders for " + ownerID);
354 354
355 string invURL = GetInventoryServiceURL(ownerID); 355 string invURL = GetInventoryServiceURL(ownerID);
356 356
@@ -367,7 +367,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
367 if (folder == null) 367 if (folder == null)
368 return false; 368 return false;
369 369
370 m_log.Debug("[HG INVENTORY CONNECTOR]: MoveFolder for " + folder.Owner); 370 //m_log.Debug("[HG INVENTORY CONNECTOR]: MoveFolder for " + folder.Owner);
371 371
372 string invURL = GetInventoryServiceURL(folder.Owner); 372 string invURL = GetInventoryServiceURL(folder.Owner);
373 373
@@ -384,7 +384,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
384 if (folder == null) 384 if (folder == null)
385 return false; 385 return false;
386 386
387 m_log.Debug("[HG INVENTORY CONNECTOR]: PurgeFolder for " + folder.Owner); 387 //m_log.Debug("[HG INVENTORY CONNECTOR]: PurgeFolder for " + folder.Owner);
388 388
389 string invURL = GetInventoryServiceURL(folder.Owner); 389 string invURL = GetInventoryServiceURL(folder.Owner);
390 390
@@ -401,7 +401,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
401 if (item == null) 401 if (item == null)
402 return false; 402 return false;
403 403
404 m_log.Debug("[HG INVENTORY CONNECTOR]: AddItem " + item.ID); 404 //m_log.Debug("[HG INVENTORY CONNECTOR]: AddItem " + item.ID);
405 405
406 string invURL = GetInventoryServiceURL(item.Owner); 406 string invURL = GetInventoryServiceURL(item.Owner);
407 407
@@ -418,7 +418,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
418 if (item == null) 418 if (item == null)
419 return false; 419 return false;
420 420
421 m_log.Debug("[HG INVENTORY CONNECTOR]: UpdateItem " + item.ID); 421 //m_log.Debug("[HG INVENTORY CONNECTOR]: UpdateItem " + item.ID);
422 422
423 string invURL = GetInventoryServiceURL(item.Owner); 423 string invURL = GetInventoryServiceURL(item.Owner);
424 424
@@ -437,7 +437,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
437 if (items.Count == 0) 437 if (items.Count == 0)
438 return true; 438 return true;
439 439
440 m_log.Debug("[HG INVENTORY CONNECTOR]: MoveItems for " + ownerID); 440 //m_log.Debug("[HG INVENTORY CONNECTOR]: MoveItems for " + ownerID);
441 441
442 string invURL = GetInventoryServiceURL(ownerID); 442 string invURL = GetInventoryServiceURL(ownerID);
443 443
@@ -451,15 +451,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
451 451
452 public bool DeleteItems(UUID ownerID, List<UUID> itemIDs) 452 public bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
453 { 453 {
454 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Delete {0} items for user {1}", itemIDs.Count, ownerID); 454 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Delete {0} items for user {1}", itemIDs.Count, ownerID);
455 455
456 if (itemIDs == null) 456 if (itemIDs == null)
457 return false; 457 return false;
458 if (itemIDs.Count == 0) 458 if (itemIDs.Count == 0)
459 return true; 459 return true;
460 460
461 m_log.Debug("[HG INVENTORY CONNECTOR]: DeleteItems for " + ownerID);
462
463 string invURL = GetInventoryServiceURL(ownerID); 461 string invURL = GetInventoryServiceURL(ownerID);
464 462
465 if (invURL == null) // not there, forward to local inventory connector to resolve 463 if (invURL == null) // not there, forward to local inventory connector to resolve
@@ -474,7 +472,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
474 { 472 {
475 if (item == null) 473 if (item == null)
476 return null; 474 return null;
477 m_log.Debug("[HG INVENTORY CONNECTOR]: GetItem " + item.ID); 475 //m_log.Debug("[HG INVENTORY CONNECTOR]: GetItem " + item.ID);
478 476
479 string invURL = GetInventoryServiceURL(item.Owner); 477 string invURL = GetInventoryServiceURL(item.Owner);
480 478
@@ -491,7 +489,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
491 if (folder == null) 489 if (folder == null)
492 return null; 490 return null;
493 491
494 m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolder " + folder.ID); 492 //m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolder " + folder.ID);
495 493
496 string invURL = GetInventoryServiceURL(folder.Owner); 494 string invURL = GetInventoryServiceURL(folder.Owner);
497 495
@@ -515,7 +513,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
515 513
516 public int GetAssetPermissions(UUID userID, UUID assetID) 514 public int GetAssetPermissions(UUID userID, UUID assetID)
517 { 515 {
518 m_log.Debug("[HG INVENTORY CONNECTOR]: GetAssetPermissions " + assetID); 516 //m_log.Debug("[HG INVENTORY CONNECTOR]: GetAssetPermissions " + assetID);
519 517
520 string invURL = GetInventoryServiceURL(userID); 518 string invURL = GetInventoryServiceURL(userID);
521 519
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 3945142..6864629 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -146,7 +146,7 @@ namespace OpenSim.Region.CoreModules.World.Land
146 else 146 else
147 { 147 {
148 // Normal Calculations 148 // Normal Calculations
149 return (int)Math.Round(((float)LandData.Area / 65536.0f) * (float)m_scene.objectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); 149 return (int)Math.Round(((float)LandData.Area / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
150 } 150 }
151 } 151 }
152 public int GetSimulatorMaxPrimCount(ILandObject thisObject) 152 public int GetSimulatorMaxPrimCount(ILandObject thisObject)
@@ -158,7 +158,7 @@ namespace OpenSim.Region.CoreModules.World.Land
158 else 158 else
159 { 159 {
160 //Normal Calculations 160 //Normal Calculations
161 return m_scene.objectCapacity; 161 return m_scene.RegionInfo.ObjectCapacity;
162 } 162 }
163 } 163 }
164 #endregion 164 #endregion
@@ -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/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 69b247c..1d70546 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -209,6 +209,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
209 m_scene.Permissions.OnDeedParcel += CanDeedParcel; 209 m_scene.Permissions.OnDeedParcel += CanDeedParcel;
210 m_scene.Permissions.OnDeedObject += CanDeedObject; 210 m_scene.Permissions.OnDeedObject += CanDeedObject;
211 m_scene.Permissions.OnIsGod += IsGod; 211 m_scene.Permissions.OnIsGod += IsGod;
212 m_scene.Permissions.OnIsAdministrator += IsAdministrator;
212 m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; 213 m_scene.Permissions.OnDuplicateObject += CanDuplicateObject;
213 m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED 214 m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED
214 m_scene.Permissions.OnEditObject += CanEditObject; //MAYBE FULLY IMPLEMENTED 215 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/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 0e849e5..9d9967a 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -805,7 +805,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
805 imgstream = new MemoryStream(); 805 imgstream = new MemoryStream();
806 806
807 // non-async because we know we have the asset immediately. 807 // non-async because we know we have the asset immediately.
808 AssetBase mapasset = m_scene.AssetService.Get(m_scene.RegionInfo.lastMapUUID.ToString()); 808 AssetBase mapasset = m_scene.AssetService.Get(m_scene.RegionInfo.RegionSettings.TerrainImageID.ToString());
809 809
810 // Decode image to System.Drawing.Image 810 // Decode image to System.Drawing.Image
811 if (OpenJPEG.DecodeToImage(mapasset.Data, out managedImage, out image)) 811 if (OpenJPEG.DecodeToImage(mapasset.Data, out managedImage, out image))
diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
index 6e69902..00f6918 100644
--- a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
+++ b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
@@ -73,7 +73,7 @@ namespace OpenSim.Region.DataSnapshot.Providers
73 client.OnGrabUpdate += delegate(UUID objectID, Vector3 offset, Vector3 grapPos, 73 client.OnGrabUpdate += delegate(UUID objectID, Vector3 offset, Vector3 grapPos,
74 IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) { this.Stale = true; }; 74 IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) { this.Stale = true; };
75 client.OnObjectAttach += delegate(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, 75 client.OnObjectAttach += delegate(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt,
76 Quaternion rot, bool silent) { this.Stale = true; }; 76 bool silent) { this.Stale = true; };
77 client.OnObjectDuplicate += delegate(uint localID, Vector3 offset, uint dupeFlags, UUID AgentID, 77 client.OnObjectDuplicate += delegate(uint localID, Vector3 offset, uint dupeFlags, UUID AgentID,
78 UUID GroupID) { this.Stale = true; }; 78 UUID GroupID) { this.Stale = true; };
79 client.OnObjectDuplicateOnRay += delegate(uint localID, uint dupeFlags, UUID AgentID, UUID GroupID, 79 client.OnObjectDuplicateOnRay += delegate(uint localID, uint dupeFlags, UUID AgentID, UUID GroupID,
diff --git a/OpenSim/Region/DataSnapshot/SnapshotStore.cs b/OpenSim/Region/DataSnapshot/SnapshotStore.cs
index 976c2c1..70cb205 100644
--- a/OpenSim/Region/DataSnapshot/SnapshotStore.cs
+++ b/OpenSim/Region/DataSnapshot/SnapshotStore.cs
@@ -258,21 +258,16 @@ namespace OpenSim.Region.DataSnapshot
258 258
259 private String GetRegionCategory(Scene scene) 259 private String GetRegionCategory(Scene scene)
260 { 260 {
261 //Boolean choice between: 261 if (scene.RegionInfo.RegionSettings.Maturity == 0)
262 // "PG" - Mormontown 262 return "PG";
263 // "Mature" - Sodom and Gomorrah 263
264 if (scene.RegionInfo.RegionSettings.Maturity == 1) 264 if (scene.RegionInfo.RegionSettings.Maturity == 1)
265 {
266 return "Mature"; 265 return "Mature";
267 } 266
268 else if (scene.RegionInfo.RegionSettings.Maturity == 0) 267 if (scene.RegionInfo.RegionSettings.Maturity == 2)
269 { 268 return "Adult";
270 return "PG"; 269
271 } 270 return "Unknown";
272 else
273 {
274 return "Unknown";
275 }
276 } 271 }
277 272
278 private XmlNode GetGridSnapshotData(XmlDocument factory) 273 private XmlNode GetGridSnapshotData(XmlDocument factory)
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index af9df45..f6e6163 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -536,10 +536,6 @@ namespace OpenSim.Region.Examples.SimpleModule
536 { 536 {
537 } 537 }
538 538
539 public virtual void AttachObject(uint localID, Quaternion rotation, byte attachPoint, UUID ownerID)
540 {
541 }
542
543 public virtual void SendDialog(string objectname, UUID objectID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels) 539 public virtual void SendDialog(string objectname, UUID objectID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels)
544 { 540 {
545 } 541 }
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index f8af367..2af2548 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Region.Framework.Interfaces
44 /// <param name="rot"></param> 44 /// <param name="rot"></param>
45 /// <param name="silent"></param> 45 /// <param name="silent"></param>
46 void AttachObject( 46 void AttachObject(
47 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent); 47 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent);
48 48
49 /// <summary> 49 /// <summary>
50 /// Attach an object to an avatar. 50 /// Attach an object to an avatar.
@@ -57,7 +57,7 @@ namespace OpenSim.Region.Framework.Interfaces
57 /// <param name="silent"></param> 57 /// <param name="silent"></param>
58 /// <returns>true if the object was successfully attached, false otherwise</returns> 58 /// <returns>true if the object was successfully attached, false otherwise</returns>
59 bool AttachObject( 59 bool AttachObject(
60 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent); 60 IClientAPI remoteClient, SceneObjectGroup grp, uint AttachmentPt, bool silent);
61 61
62 /// <summary> 62 /// <summary>
63 /// Rez an attachment from user inventory and change inventory status to match. 63 /// Rez an attachment from user inventory and change inventory status to match.
diff --git a/OpenSim/Region/Framework/Interfaces/IHyperService.cs b/OpenSim/Region/Framework/Interfaces/IHyperService.cs
deleted file mode 100644
index 51ea28a..0000000
--- a/OpenSim/Region/Framework/Interfaces/IHyperService.cs
+++ /dev/null
@@ -1,37 +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 */
27using System;
28using OpenMetaverse;
29
30namespace OpenSim.Region.Framework.Interfaces
31{
32 public interface IHyperAssetService
33 {
34 string GetUserAssetServer(UUID userID);
35 string GetSimAssetServer();
36 }
37}
diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
index 97f4188..05fc2ad 100644
--- a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
@@ -43,5 +43,9 @@ namespace OpenSim.Region.Framework.Interfaces
43 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 43 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
44 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment); 44 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment);
45 void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver); 45 void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver);
46 bool GetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID);
47
48 // Must be here because of textures in user's inventory
49 bool IsForeignUser(UUID userID, out string assetServerURL);
46 } 50 }
47} 51}
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index ef125cd..9db2e41 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -179,7 +179,7 @@ namespace OpenSim.Region.Framework.Scenes
179 public event ScriptChangedEvent OnScriptChangedEvent; 179 public event ScriptChangedEvent OnScriptChangedEvent;
180 public delegate void ScriptChangedEvent(uint localID, uint change); 180 public delegate void ScriptChangedEvent(uint localID, uint change);
181 181
182 public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed); 182 public delegate void ScriptControlEvent(UUID item, UUID avatarID, uint held, uint changed);
183 public event ScriptControlEvent OnScriptControlEvent; 183 public event ScriptControlEvent OnScriptControlEvent;
184 184
185 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); 185 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
@@ -1595,7 +1595,7 @@ namespace OpenSim.Region.Framework.Scenes
1595 } 1595 }
1596 } 1596 }
1597 1597
1598 internal void TriggerControlEvent(uint p, UUID scriptUUID, UUID avatarID, uint held, uint _changed) 1598 internal void TriggerControlEvent(UUID scriptUUID, UUID avatarID, uint held, uint _changed)
1599 { 1599 {
1600 ScriptControlEvent handlerScriptControlEvent = OnScriptControlEvent; 1600 ScriptControlEvent handlerScriptControlEvent = OnScriptControlEvent;
1601 if (handlerScriptControlEvent != null) 1601 if (handlerScriptControlEvent != null)
@@ -1604,7 +1604,7 @@ namespace OpenSim.Region.Framework.Scenes
1604 { 1604 {
1605 try 1605 try
1606 { 1606 {
1607 d(p, scriptUUID, avatarID, held, _changed); 1607 d(scriptUUID, avatarID, held, _changed);
1608 } 1608 }
1609 catch (Exception e) 1609 catch (Exception e)
1610 { 1610 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index f9da341..01edf51 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes
73 IMoneyModule money=RequestModuleInterface<IMoneyModule>(); 73 IMoneyModule money=RequestModuleInterface<IMoneyModule>();
74 if (money != null) 74 if (money != null)
75 { 75 {
76 money.ApplyUploadCharge(agentID); 76 money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload");
77 } 77 }
78 78
79 AddInventoryItem(agentID, item); 79 AddInventoryItem(agentID, item);
@@ -265,6 +265,10 @@ namespace OpenSim.Region.Framework.Scenes
265 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID, 265 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
266 UUID itemID, InventoryItemBase itemUpd) 266 UUID itemID, InventoryItemBase itemUpd)
267 { 267 {
268 // This one will let people set next perms on items in agent
269 // inventory. Rut-Roh. Whatever. Make this secure. Yeah.
270 //
271 // Passing something to another avatar or a an object will already
268 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 272 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
269 item = InventoryService.GetItem(item); 273 item = InventoryService.GetItem(item);
270 274
@@ -274,11 +278,9 @@ namespace OpenSim.Region.Framework.Scenes
274 { 278 {
275 item.Name = itemUpd.Name; 279 item.Name = itemUpd.Name;
276 item.Description = itemUpd.Description; 280 item.Description = itemUpd.Description;
277 item.NextPermissions = itemUpd.NextPermissions; 281 item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions;
278 item.CurrentPermissions |= 8; // Slam! 282 item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions;
279 item.EveryOnePermissions = itemUpd.EveryOnePermissions; 283 item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions;
280 item.GroupPermissions = itemUpd.GroupPermissions;
281
282 item.GroupID = itemUpd.GroupID; 284 item.GroupID = itemUpd.GroupID;
283 item.GroupOwned = itemUpd.GroupOwned; 285 item.GroupOwned = itemUpd.GroupOwned;
284 item.CreationDate = itemUpd.CreationDate; 286 item.CreationDate = itemUpd.CreationDate;
@@ -384,28 +386,103 @@ namespace OpenSim.Region.Framework.Scenes
384 386
385 if (Permissions.PropagatePermissions() && recipient != senderId) 387 if (Permissions.PropagatePermissions() && recipient != senderId)
386 { 388 {
387 // First, make sore base is limited to the next perms 389 // Trying to do this right this time. This is evil. If
388 itemCopy.BasePermissions = item.BasePermissions & (item.NextPermissions | (uint)PermissionMask.Move); 390 // you believe in Good, go elsewhere. Vampires and other
389 // By default, current equals base 391 // evil creatores only beyond this point. You have been
390 itemCopy.CurrentPermissions = itemCopy.BasePermissions & item.CurrentPermissions; 392 // warned.
391 393
392 // If this is an object, replace current perms 394 // We're going to mask a lot of things by the next perms
393 // with folded perms 395 // Tweak the next perms to be nicer to our data
396 //
397 // In this mask, all the bits we do NOT want to mess
398 // with are set. These are:
399 //
400 // Transfer
401 // Copy
402 // Modufy
403 uint permsMask = ~ ((uint)PermissionMask.Copy |
404 (uint)PermissionMask.Transfer |
405 (uint)PermissionMask.Modify);
406
407 // Now, reduce the next perms to the mask bits
408 // relevant to the operation
409 uint nextPerms = permsMask | (item.NextPermissions &
410 ((uint)PermissionMask.Copy |
411 (uint)PermissionMask.Transfer |
412 (uint)PermissionMask.Modify));
413
414 // nextPerms now has all bits set, except for the actual
415 // next permission bits.
416
417 // This checks for no mod, no copy, no trans.
418 // This indicates an error or messed up item. Do it like
419 // SL and assume trans
420 if (nextPerms == permsMask)
421 nextPerms |= (uint)PermissionMask.Transfer;
422
423 // Inventory owner perms are the logical AND of the
424 // folded perms and the root prim perms, however, if
425 // the root prim is mod, the inventory perms will be
426 // mod. This happens on "take" and is of little concern
427 // here, save for preventing escalation
428
429 // This hack ensures that items previously permalocked
430 // get unlocked when they're passed or rezzed
431 uint basePerms = item.BasePermissions |
432 (uint)PermissionMask.Move;
433 uint ownerPerms = item.CurrentPermissions;
434
435 // If this is an object, root prim perms may be more
436 // permissive than folded perms. Use folded perms as
437 // a mask
394 if (item.InvType == (int)InventoryType.Object) 438 if (item.InvType == (int)InventoryType.Object)
395 { 439 {
396 itemCopy.CurrentPermissions &= ~(uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); 440 // Create a safe mask for the current perms
397 itemCopy.CurrentPermissions |= (item.CurrentPermissions & 7) << 13; 441 uint foldedPerms = (item.CurrentPermissions & 7) << 13;
442 foldedPerms |= permsMask;
443
444 bool isRootMod = (item.CurrentPermissions &
445 (uint)PermissionMask.Modify) != 0 ?
446 true : false;
447
448 // Mask the owner perms to the folded perms
449 ownerPerms &= foldedPerms;
450 basePerms &= foldedPerms;
451
452 // If the root was mod, let the mask reflect that
453 // We also need to adjust the base here, because
454 // we should be able to edit in-inventory perms
455 // for the root prim, if it's mod.
456 if (isRootMod)
457 {
458 ownerPerms |= (uint)PermissionMask.Modify;
459 basePerms |= (uint)PermissionMask.Modify;
460 }
398 } 461 }
399 462
400 // Ensure there is no escalation 463 // These will be applied to the root prim at next rez.
401 itemCopy.CurrentPermissions &= (item.NextPermissions | (uint)PermissionMask.Move); 464 // The slam bit (bit 3) and folded permission (bits 0-2)
465 // are preserved due to the above mangling
466 ownerPerms &= nextPerms;
402 467
403 // Need slam bit on xfer 468 // Mask the base permissions. This is a conservative
404 itemCopy.CurrentPermissions |= 8; 469 // approach altering only the three main perms
470 basePerms &= nextPerms;
471
472 // Assign to the actual item. Make sure the slam bit is
473 // set, if it wasn't set before.
474 itemCopy.BasePermissions = basePerms;
475 itemCopy.CurrentPermissions = ownerPerms | 16; // Slam
405 476
406 itemCopy.NextPermissions = item.NextPermissions; 477 itemCopy.NextPermissions = item.NextPermissions;
407 478
408 itemCopy.EveryOnePermissions = 0; 479 // This preserves "everyone can move"
480 itemCopy.EveryOnePermissions = item.EveryOnePermissions &
481 nextPerms;
482
483 // Intentionally killing "share with group" here, as
484 // the recipient will not have the group this is
485 // set to
409 itemCopy.GroupPermissions = 0; 486 itemCopy.GroupPermissions = 0;
410 } 487 }
411 else 488 else
@@ -839,6 +916,9 @@ namespace OpenSim.Region.Framework.Scenes
839 SceneObjectGroup group = part.ParentGroup; 916 SceneObjectGroup group = part.ParentGroup;
840 if (group != null) 917 if (group != null)
841 { 918 {
919 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
920 return;
921
842 TaskInventoryItem item = group.GetInventoryItem(localID, itemID); 922 TaskInventoryItem item = group.GetInventoryItem(localID, itemID);
843 if (item == null) 923 if (item == null)
844 return; 924 return;
@@ -903,7 +983,7 @@ namespace OpenSim.Region.Framework.Scenes
903 else 983 else
904 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; 984 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions;
905 985
906 agentItem.CurrentPermissions |= 8; 986 agentItem.CurrentPermissions |= 16; // Slam
907 agentItem.NextPermissions = taskItem.NextPermissions; 987 agentItem.NextPermissions = taskItem.NextPermissions;
908 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); 988 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
909 agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; 989 agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions;
@@ -978,9 +1058,21 @@ namespace OpenSim.Region.Framework.Scenes
978 return; 1058 return;
979 } 1059 }
980 1060
981 // Only owner can copy 1061 TaskInventoryItem item = part.Inventory.GetInventoryItem(itemId);
982 if (remoteClient.AgentId != taskItem.OwnerID) 1062 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
983 return; 1063 {
1064 // If the item to be moved is no copy, we need to be able to
1065 // edit the prim.
1066 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
1067 return;
1068 }
1069 else
1070 {
1071 // If the item is copiable, then we just need to have perms
1072 // on it. The delete check is a pure rights check
1073 if (!Permissions.CanDeleteObject(part.UUID, remoteClient.AgentId))
1074 return;
1075 }
984 1076
985 MoveTaskInventoryItem(remoteClient, folderId, part, itemId); 1077 MoveTaskInventoryItem(remoteClient, folderId, part, itemId);
986 } 1078 }
@@ -1094,7 +1186,7 @@ namespace OpenSim.Region.Framework.Scenes
1094 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); 1186 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move);
1095 destTaskItem.BasePermissions = srcTaskItem.BasePermissions & 1187 destTaskItem.BasePermissions = srcTaskItem.BasePermissions &
1096 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move); 1188 (srcTaskItem.NextPermissions | (uint)PermissionMask.Move);
1097 destTaskItem.CurrentPermissions |= 8; // Slam! 1189 destTaskItem.CurrentPermissions |= 16; // Slam!
1098 } 1190 }
1099 } 1191 }
1100 1192
@@ -1263,10 +1355,48 @@ namespace OpenSim.Region.Framework.Scenes
1263 { 1355 {
1264 agentTransactions.HandleTaskItemUpdateFromTransaction( 1356 agentTransactions.HandleTaskItemUpdateFromTransaction(
1265 remoteClient, part, transactionID, currentItem); 1357 remoteClient, part, transactionID, currentItem);
1358
1359 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1360 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1361 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1362 remoteClient.SendAgentAlertMessage("Script saved", false);
1363 else
1364 remoteClient.SendAgentAlertMessage("Item saved", false);
1365 }
1366
1367 // Base ALWAYS has move
1368 currentItem.BasePermissions |= (uint)PermissionMask.Move;
1369
1370 // Check if we're allowed to mess with permissions
1371 if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god
1372 {
1373 if (remoteClient.AgentId != part.OwnerID) // Not owner
1374 {
1375 // Friends and group members can't change any perms
1376 itemInfo.BasePermissions = currentItem.BasePermissions;
1377 itemInfo.EveryonePermissions = currentItem.EveryonePermissions;
1378 itemInfo.GroupPermissions = currentItem.GroupPermissions;
1379 itemInfo.NextPermissions = currentItem.NextPermissions;
1380 itemInfo.CurrentPermissions = currentItem.CurrentPermissions;
1381 }
1382 else
1383 {
1384 // Owner can't change base, and can change other
1385 // only up to base
1386 itemInfo.BasePermissions = currentItem.BasePermissions;
1387 itemInfo.EveryonePermissions &= currentItem.BasePermissions;
1388 itemInfo.GroupPermissions &= currentItem.BasePermissions;
1389 itemInfo.CurrentPermissions &= currentItem.BasePermissions;
1390 itemInfo.NextPermissions &= currentItem.BasePermissions;
1391 }
1392
1266 } 1393 }
1394
1395 // Next ALWAYS has move
1396 itemInfo.NextPermissions |= (uint)PermissionMask.Move;
1397
1267 if (part.Inventory.UpdateInventoryItem(itemInfo)) 1398 if (part.Inventory.UpdateInventoryItem(itemInfo))
1268 { 1399 {
1269 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1270 part.GetProperties(remoteClient); 1400 part.GetProperties(remoteClient);
1271 } 1401 }
1272 } 1402 }
@@ -1478,7 +1608,7 @@ namespace OpenSim.Region.Framework.Scenes
1478 srcTaskItem.NextPermissions; 1608 srcTaskItem.NextPermissions;
1479 destTaskItem.BasePermissions = srcTaskItem.BasePermissions & 1609 destTaskItem.BasePermissions = srcTaskItem.BasePermissions &
1480 srcTaskItem.NextPermissions; 1610 srcTaskItem.NextPermissions;
1481 destTaskItem.CurrentPermissions |= 8; // Slam! 1611 destTaskItem.CurrentPermissions |= 16; // Slam!
1482 } 1612 }
1483 } 1613 }
1484 1614
@@ -1597,7 +1727,7 @@ namespace OpenSim.Region.Framework.Scenes
1597 } 1727 }
1598 1728
1599 // Handle god perms 1729 // Handle god perms
1600 if (Permissions.IsGod(remoteClient.AgentId)) 1730 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1601 { 1731 {
1602 permissionToTake = true; 1732 permissionToTake = true;
1603 permissionToTakeCopy = true; 1733 permissionToTakeCopy = true;
@@ -1608,7 +1738,7 @@ namespace OpenSim.Region.Framework.Scenes
1608 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1738 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1609 permissionToDelete = false; 1739 permissionToDelete = false;
1610 1740
1611 // if we want to take a copy,, we also don't want to delete 1741 // if we want to take a copy, we also don't want to delete
1612 // Note: after this point, the permissionToTakeCopy flag 1742 // Note: after this point, the permissionToTakeCopy flag
1613 // becomes irrelevant. It already includes the permissionToTake 1743 // becomes irrelevant. It already includes the permissionToTake
1614 // permission and after excluding no copy items here, we can 1744 // permission and after excluding no copy items here, we can
@@ -1619,6 +1749,7 @@ namespace OpenSim.Region.Framework.Scenes
1619 if (!permissionToTakeCopy) 1749 if (!permissionToTakeCopy)
1620 return; 1750 return;
1621 1751
1752 permissionToTake = true;
1622 // Don't delete 1753 // Don't delete
1623 permissionToDelete = false; 1754 permissionToDelete = false;
1624 } 1755 }
@@ -1863,17 +1994,14 @@ namespace OpenSim.Region.Framework.Scenes
1863 1994
1864 group.SetGroup(sourcePart.GroupID, null); 1995 group.SetGroup(sourcePart.GroupID, null);
1865 1996
1866 if (rootPart.OwnerID != item.OwnerID) 1997 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
1867 { 1998 {
1868 if (Permissions.PropagatePermissions()) 1999 if (Permissions.PropagatePermissions())
1869 { 2000 {
1870 if ((item.CurrentPermissions & 8) != 0) 2001 foreach (SceneObjectPart part in partList)
1871 { 2002 {
1872 foreach (SceneObjectPart part in partList) 2003 part.EveryoneMask = item.EveryonePermissions;
1873 { 2004 part.NextOwnerMask = item.NextPermissions;
1874 part.EveryoneMask = item.EveryonePermissions;
1875 part.NextOwnerMask = item.NextPermissions;
1876 }
1877 } 2005 }
1878 group.ApplyNextOwnerPermissions(); 2006 group.ApplyNextOwnerPermissions();
1879 } 2007 }
@@ -1881,17 +2009,14 @@ namespace OpenSim.Region.Framework.Scenes
1881 2009
1882 foreach (SceneObjectPart part in partList) 2010 foreach (SceneObjectPart part in partList)
1883 { 2011 {
1884 if (part.OwnerID != item.OwnerID) 2012 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
1885 { 2013 {
1886 part.LastOwnerID = part.OwnerID; 2014 part.LastOwnerID = part.OwnerID;
1887 part.OwnerID = item.OwnerID; 2015 part.OwnerID = item.OwnerID;
1888 part.Inventory.ChangeInventoryOwner(item.OwnerID); 2016 part.Inventory.ChangeInventoryOwner(item.OwnerID);
1889 } 2017 }
1890 else if ((item.CurrentPermissions & 8) != 0) // Slam! 2018 part.EveryoneMask = item.EveryonePermissions;
1891 { 2019 part.NextOwnerMask = item.NextPermissions;
1892 part.EveryoneMask = item.EveryonePermissions;
1893 part.NextOwnerMask = item.NextPermissions;
1894 }
1895 } 2020 }
1896 2021
1897 rootPart.TrimPermissions(); 2022 rootPart.TrimPermissions();
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
index 7dab04f..a523351 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);
@@ -122,6 +123,7 @@ namespace OpenSim.Region.Framework.Scenes
122 public event RunConsoleCommandHandler OnRunConsoleCommand; 123 public event RunConsoleCommandHandler OnRunConsoleCommand;
123 public event IssueEstateCommandHandler OnIssueEstateCommand; 124 public event IssueEstateCommandHandler OnIssueEstateCommand;
124 public event IsGodHandler OnIsGod; 125 public event IsGodHandler OnIsGod;
126 public event IsAdministratorHandler OnIsAdministrator;
125 public event EditParcelHandler OnEditParcel; 127 public event EditParcelHandler OnEditParcel;
126 public event SellParcelHandler OnSellParcel; 128 public event SellParcelHandler OnSellParcel;
127 public event AbandonParcelHandler OnAbandonParcel; 129 public event AbandonParcelHandler OnAbandonParcel;
@@ -652,6 +654,21 @@ namespace OpenSim.Region.Framework.Scenes
652 } 654 }
653 return true; 655 return true;
654 } 656 }
657
658 public bool IsAdministrator(UUID user)
659 {
660 IsAdministratorHandler handler = OnIsAdministrator;
661 if (handler != null)
662 {
663 Delegate[] list = handler.GetInvocationList();
664 foreach (IsAdministratorHandler h in list)
665 {
666 if (h(user) == false)
667 return false;
668 }
669 }
670 return true;
671 }
655 #endregion 672 #endregion
656 673
657 #region EDIT PARCEL 674 #region EDIT PARCEL
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e2ab643..93f684c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -136,6 +136,7 @@ namespace OpenSim.Region.Framework.Scenes
136 136
137 protected SceneCommunicationService m_sceneGridService; 137 protected SceneCommunicationService m_sceneGridService;
138 public bool LoginsDisabled = true; 138 public bool LoginsDisabled = true;
139 public bool LoadingPrims = false;
139 140
140 public new float TimeDilation 141 public new float TimeDilation
141 { 142 {
@@ -478,8 +479,6 @@ namespace OpenSim.Region.Framework.Scenes
478 set { m_sceneGraph.RestorePresences = value; } 479 set { m_sceneGraph.RestorePresences = value; }
479 } 480 }
480 481
481 public int objectCapacity = 45000;
482
483 #endregion 482 #endregion
484 483
485 #region BinaryStats 484 #region BinaryStats
@@ -687,7 +686,7 @@ namespace OpenSim.Region.Framework.Scenes
687 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 686 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
688 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 687 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
689 688
690 StatsReporter.SetObjectCapacity(objectCapacity); 689 StatsReporter.SetObjectCapacity(RegionInfo.ObjectCapacity);
691 690
692 // Old 691 // Old
693 /* 692 /*
@@ -1879,6 +1878,7 @@ namespace OpenSim.Region.Framework.Scenes
1879 /// </summary> 1878 /// </summary>
1880 public virtual void LoadPrimsFromStorage(UUID regionID) 1879 public virtual void LoadPrimsFromStorage(UUID regionID)
1881 { 1880 {
1881 LoadingPrims = true;
1882 m_log.Info("[SCENE]: Loading objects from datastore"); 1882 m_log.Info("[SCENE]: Loading objects from datastore");
1883 1883
1884 List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(regionID); 1884 List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(regionID);
@@ -1902,6 +1902,7 @@ namespace OpenSim.Region.Framework.Scenes
1902 } 1902 }
1903 1903
1904 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); 1904 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
1905 LoadingPrims = false;
1905 } 1906 }
1906 1907
1907 1908
@@ -2573,8 +2574,7 @@ namespace OpenSim.Region.Framework.Scenes
2573 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2574 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2574 2575
2575 if (AttachmentsModule != null) 2576 if (AttachmentsModule != null)
2576 AttachmentsModule.AttachObject( 2577 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2577 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
2578 2578
2579 } 2579 }
2580 else 2580 else
@@ -2725,7 +2725,9 @@ namespace OpenSim.Region.Framework.Scenes
2725 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); 2725 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2726 if (userVerification != null && ep != null) 2726 if (userVerification != null && ep != null)
2727 { 2727 {
2728 if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString())) 2728 System.Net.IPAddress addr = NetworkUtil.GetExternalIPOf(ep.Address);
2729
2730 if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString()))
2729 { 2731 {
2730 // uh-oh, this is fishy 2732 // uh-oh, this is fishy
2731 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); 2733 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
@@ -2783,17 +2785,11 @@ namespace OpenSim.Region.Framework.Scenes
2783 SubscribeToClientPrimEvents(client); 2785 SubscribeToClientPrimEvents(client);
2784 SubscribeToClientPrimRezEvents(client); 2786 SubscribeToClientPrimRezEvents(client);
2785 SubscribeToClientInventoryEvents(client); 2787 SubscribeToClientInventoryEvents(client);
2786 SubscribeToClientAttachmentEvents(client);
2787 SubscribeToClientTeleportEvents(client); 2788 SubscribeToClientTeleportEvents(client);
2788 SubscribeToClientScriptEvents(client); 2789 SubscribeToClientScriptEvents(client);
2789 SubscribeToClientParcelEvents(client); 2790 SubscribeToClientParcelEvents(client);
2790 SubscribeToClientGridEvents(client); 2791 SubscribeToClientGridEvents(client);
2791 SubscribeToClientGodEvents(client);
2792
2793 SubscribeToClientNetworkEvents(client); 2792 SubscribeToClientNetworkEvents(client);
2794
2795
2796 // EventManager.TriggerOnNewClient(client);
2797 } 2793 }
2798 2794
2799 public virtual void SubscribeToClientTerrainEvents(IClientAPI client) 2795 public virtual void SubscribeToClientTerrainEvents(IClientAPI client)
@@ -2803,8 +2799,7 @@ namespace OpenSim.Region.Framework.Scenes
2803 } 2799 }
2804 2800
2805 public virtual void SubscribeToClientPrimEvents(IClientAPI client) 2801 public virtual void SubscribeToClientPrimEvents(IClientAPI client)
2806 { 2802 {
2807
2808 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition; 2803 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition;
2809 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 2804 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2810 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation; 2805 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation;
@@ -2874,18 +2869,6 @@ namespace OpenSim.Region.Framework.Scenes
2874 client.OnMoveTaskItem += ClientMoveTaskInventoryItem; 2869 client.OnMoveTaskItem += ClientMoveTaskInventoryItem;
2875 } 2870 }
2876 2871
2877 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client)
2878 {
2879 if (AttachmentsModule != null)
2880 {
2881 client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory;
2882 client.OnRezMultipleAttachmentsFromInv += AttachmentsModule.RezMultipleAttachmentsFromInventory;
2883 client.OnObjectAttach += AttachmentsModule.AttachObject;
2884 client.OnObjectDetach += AttachmentsModule.DetachObject;
2885 client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory;
2886 }
2887 }
2888
2889 public virtual void SubscribeToClientTeleportEvents(IClientAPI client) 2872 public virtual void SubscribeToClientTeleportEvents(IClientAPI client)
2890 { 2873 {
2891 client.OnTeleportLocationRequest += RequestTeleportLocation; 2874 client.OnTeleportLocationRequest += RequestTeleportLocation;
@@ -2915,44 +2898,29 @@ namespace OpenSim.Region.Framework.Scenes
2915 client.OnSetStartLocationRequest += SetHomeRezPoint; 2898 client.OnSetStartLocationRequest += SetHomeRezPoint;
2916 client.OnRegionHandleRequest += RegionHandleRequest; 2899 client.OnRegionHandleRequest += RegionHandleRequest;
2917 } 2900 }
2918 2901
2919 public virtual void SubscribeToClientGodEvents(IClientAPI client)
2920 {
2921 IGodsModule godsModule = RequestModuleInterface<IGodsModule>();
2922 client.OnGodKickUser += godsModule.KickUser;
2923 client.OnRequestGodlikePowers += godsModule.RequestGodlikePowers;
2924 }
2925
2926 public virtual void SubscribeToClientNetworkEvents(IClientAPI client) 2902 public virtual void SubscribeToClientNetworkEvents(IClientAPI client)
2927 { 2903 {
2928 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; 2904 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats;
2929 client.OnViewerEffect += ProcessViewerEffect; 2905 client.OnViewerEffect += ProcessViewerEffect;
2930 } 2906 }
2931 2907
2932 protected virtual void UnsubscribeToClientEvents(IClientAPI client)
2933 {
2934 }
2935
2936 /// <summary> 2908 /// <summary>
2937 /// Register for events from the client 2909 /// Unsubscribe the client from events.
2938 /// </summary> 2910 /// </summary>
2939 /// <param name="client">The IClientAPI of the connected client</param> 2911 /// FIXME: Not called anywhere!
2912 /// <param name="client">The IClientAPI of the client</param>
2940 public virtual void UnSubscribeToClientEvents(IClientAPI client) 2913 public virtual void UnSubscribeToClientEvents(IClientAPI client)
2941 { 2914 {
2942 UnSubscribeToClientTerrainEvents(client); 2915 UnSubscribeToClientTerrainEvents(client);
2943 UnSubscribeToClientPrimEvents(client); 2916 UnSubscribeToClientPrimEvents(client);
2944 UnSubscribeToClientPrimRezEvents(client); 2917 UnSubscribeToClientPrimRezEvents(client);
2945 UnSubscribeToClientInventoryEvents(client); 2918 UnSubscribeToClientInventoryEvents(client);
2946 UnSubscribeToClientAttachmentEvents(client);
2947 UnSubscribeToClientTeleportEvents(client); 2919 UnSubscribeToClientTeleportEvents(client);
2948 UnSubscribeToClientScriptEvents(client); 2920 UnSubscribeToClientScriptEvents(client);
2949 UnSubscribeToClientParcelEvents(client); 2921 UnSubscribeToClientParcelEvents(client);
2950 UnSubscribeToClientGridEvents(client); 2922 UnSubscribeToClientGridEvents(client);
2951 UnSubscribeToClientGodEvents(client);
2952
2953 UnSubscribeToClientNetworkEvents(client); 2923 UnSubscribeToClientNetworkEvents(client);
2954
2955 // EventManager.TriggerOnNewClient(client);
2956 } 2924 }
2957 2925
2958 public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) 2926 public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client)
@@ -3029,18 +2997,6 @@ namespace OpenSim.Region.Framework.Scenes
3029 client.OnMoveTaskItem -= ClientMoveTaskInventoryItem; 2997 client.OnMoveTaskItem -= ClientMoveTaskInventoryItem;
3030 } 2998 }
3031 2999
3032 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client)
3033 {
3034 if (AttachmentsModule != null)
3035 {
3036 client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory;
3037 client.OnRezMultipleAttachmentsFromInv -= AttachmentsModule.RezMultipleAttachmentsFromInventory;
3038 client.OnObjectAttach -= AttachmentsModule.AttachObject;
3039 client.OnObjectDetach -= AttachmentsModule.DetachObject;
3040 client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory;
3041 }
3042 }
3043
3044 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) 3000 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client)
3045 { 3001 {
3046 client.OnTeleportLocationRequest -= RequestTeleportLocation; 3002 client.OnTeleportLocationRequest -= RequestTeleportLocation;
@@ -3072,13 +3028,6 @@ namespace OpenSim.Region.Framework.Scenes
3072 client.OnRegionHandleRequest -= RegionHandleRequest; 3028 client.OnRegionHandleRequest -= RegionHandleRequest;
3073 } 3029 }
3074 3030
3075 public virtual void UnSubscribeToClientGodEvents(IClientAPI client)
3076 {
3077 IGodsModule godsModule = RequestModuleInterface<IGodsModule>();
3078 client.OnGodKickUser -= godsModule.KickUser;
3079 client.OnRequestGodlikePowers -= godsModule.RequestGodlikePowers;
3080 }
3081
3082 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) 3031 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client)
3083 { 3032 {
3084 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats; 3033 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats;
@@ -4119,20 +4068,6 @@ namespace OpenSim.Region.Framework.Scenes
4119 4068
4120 #region Other Methods 4069 #region Other Methods
4121 4070
4122 public void SetObjectCapacity(int objects)
4123 {
4124 // Region specific config overrides global
4125 //
4126 if (RegionInfo.ObjectCapacity != 0)
4127 objects = RegionInfo.ObjectCapacity;
4128
4129 if (StatsReporter != null)
4130 {
4131 StatsReporter.SetObjectCapacity(objects);
4132 }
4133 objectCapacity = objects;
4134 }
4135
4136 #endregion 4071 #endregion
4137 4072
4138 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) 4073 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set)
@@ -4731,7 +4666,7 @@ namespace OpenSim.Region.Framework.Scenes
4731 part.NextOwnerMask; 4666 part.NextOwnerMask;
4732 item.GroupPermissions = part.GroupMask & 4667 item.GroupPermissions = part.GroupMask &
4733 part.NextOwnerMask; 4668 part.NextOwnerMask;
4734 item.CurrentPermissions |= 8; // Slam! 4669 item.CurrentPermissions |= 16; // Slam!
4735 item.CreationDate = Util.UnixTimeSinceEpoch(); 4670 item.CreationDate = Util.UnixTimeSinceEpoch();
4736 4671
4737 if (InventoryService.AddItem(item)) 4672 if (InventoryService.AddItem(item))
@@ -5306,4 +5241,4 @@ namespace OpenSim.Region.Framework.Scenes
5306 return offsets.ToArray(); 5241 return offsets.ToArray();
5307 } 5242 }
5308 } 5243 }
5309} 5244} \ 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/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index f7e46af..9a01a28 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -172,13 +172,14 @@ namespace OpenSim.Region.Framework.Scenes
172 taskItem.GroupPermissions = item.GroupPermissions & 172 taskItem.GroupPermissions = item.GroupPermissions &
173 item.NextPermissions; 173 item.NextPermissions;
174 taskItem.NextPermissions = item.NextPermissions; 174 taskItem.NextPermissions = item.NextPermissions;
175 taskItem.CurrentPermissions |= 8; 175 // We're adding this to a prim we don't own. Force
176 // owner change
177 taskItem.CurrentPermissions |= 16; // Slam
176 } 178 }
177 else 179 else
178 { 180 {
179 taskItem.BasePermissions = item.BasePermissions; 181 taskItem.BasePermissions = item.BasePermissions;
180 taskItem.CurrentPermissions = item.CurrentPermissions; 182 taskItem.CurrentPermissions = item.CurrentPermissions;
181 taskItem.CurrentPermissions |= 8;
182 taskItem.EveryonePermissions = item.EveryOnePermissions; 183 taskItem.EveryonePermissions = item.EveryOnePermissions;
183 taskItem.GroupPermissions = item.GroupPermissions; 184 taskItem.GroupPermissions = item.GroupPermissions;
184 taskItem.NextPermissions = item.NextPermissions; 185 taskItem.NextPermissions = item.NextPermissions;
@@ -281,7 +282,7 @@ namespace OpenSim.Region.Framework.Scenes
281 PermissionMask.Move | 282 PermissionMask.Move |
282 PermissionMask.Transfer) | 7; 283 PermissionMask.Transfer) | 7;
283 284
284 uint ownerMask = 0x7ffffff; 285 uint ownerMask = 0x7fffffff;
285 foreach (SceneObjectPart part in m_parts.Values) 286 foreach (SceneObjectPart part in m_parts.Values)
286 { 287 {
287 ownerMask &= part.OwnerMask; 288 ownerMask &= part.OwnerMask;
@@ -295,12 +296,16 @@ namespace OpenSim.Region.Framework.Scenes
295 if ((ownerMask & (uint)PermissionMask.Transfer) == 0) 296 if ((ownerMask & (uint)PermissionMask.Transfer) == 0)
296 perms &= ~(uint)PermissionMask.Transfer; 297 perms &= ~(uint)PermissionMask.Transfer;
297 298
298 if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Modify) == 0) 299 // If root prim permissions are applied here, this would screw
299 perms &= ~((uint)PermissionMask.Modify >> 13); 300 // with in-inventory manipulation of the next owner perms
300 if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Copy) == 0) 301 // in a major way. So, let's move this to the give itself.
301 perms &= ~((uint)PermissionMask.Copy >> 13); 302 // Yes. I know. Evil.
302 if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Transfer) == 0) 303// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Modify) == 0)
303 perms &= ~((uint)PermissionMask.Transfer >> 13); 304// perms &= ~((uint)PermissionMask.Modify >> 13);
305// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Copy) == 0)
306// perms &= ~((uint)PermissionMask.Copy >> 13);
307// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Transfer) == 0)
308// perms &= ~((uint)PermissionMask.Transfer >> 13);
304 309
305 return perms; 310 return perms;
306 } 311 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 1ca390a..17275d0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -294,7 +294,7 @@ namespace OpenSim.Region.Framework.Scenes
294 294
295 if ((m_scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || m_scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) 295 if ((m_scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || m_scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W)
296 || m_scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || m_scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) 296 || m_scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || m_scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S))
297 && !IsAttachmentCheckFull()) 297 && !IsAttachmentCheckFull() && (!m_scene.LoadingPrims))
298 { 298 {
299 m_scene.CrossPrimGroupIntoNewRegion(val, this, true); 299 m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
300 } 300 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 59fd805..e331bb0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -180,6 +180,9 @@ namespace OpenSim.Region.Framework.Scenes
180 public UUID FromItemID; 180 public UUID FromItemID;
181 181
182 [XmlIgnore] 182 [XmlIgnore]
183 public UUID FromFolderID;
184
185 [XmlIgnore]
183 public int STATUS_ROTATE_X; 186 public int STATUS_ROTATE_X;
184 187
185 [XmlIgnore] 188 [XmlIgnore]
@@ -4137,6 +4140,13 @@ namespace OpenSim.Region.Framework.Scenes
4137 case 16: 4140 case 16:
4138 _nextOwnerMask = ApplyMask(_nextOwnerMask, set, mask) & 4141 _nextOwnerMask = ApplyMask(_nextOwnerMask, set, mask) &
4139 baseMask; 4142 baseMask;
4143 // Prevent the client from creating no mod, no copy
4144 // objects
4145 if ((_nextOwnerMask & (uint)PermissionMask.Copy) == 0)
4146 _nextOwnerMask |= (uint)PermissionMask.Transfer;
4147
4148 _nextOwnerMask |= (uint)PermissionMask.Move;
4149
4140 break; 4150 break;
4141 } 4151 }
4142 SendFullUpdateToAllClients(); 4152 SendFullUpdateToAllClients();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 3a8f168..4ae53a2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -118,20 +118,20 @@ namespace OpenSim.Region.Framework.Scenes
118 /// <param name="linkNum">Link number for the part</param> 118 /// <param name="linkNum">Link number for the part</param>
119 public void ResetInventoryIDs() 119 public void ResetInventoryIDs()
120 { 120 {
121 lock (Items) 121 lock (m_items)
122 { 122 {
123 if (0 == Items.Count) 123 if (0 == m_items.Count)
124 return; 124 return;
125 125
126 HasInventoryChanged = true; 126 HasInventoryChanged = true;
127 m_part.ParentGroup.HasGroupChanged = true; 127 m_part.ParentGroup.HasGroupChanged = true;
128 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 128 IList<TaskInventoryItem> items = GetInventoryItems();
129 Items.Clear(); 129 m_items.Clear();
130 130
131 foreach (TaskInventoryItem item in items) 131 foreach (TaskInventoryItem item in items)
132 { 132 {
133 item.ResetIDs(m_part.UUID); 133 item.ResetIDs(m_part.UUID);
134 Items.Add(item.ItemID, item); 134 m_items.Add(item.ItemID, item);
135 } 135 }
136 } 136 }
137 } 137 }
@@ -148,17 +148,17 @@ namespace OpenSim.Region.Framework.Scenes
148 { 148 {
149 return; 149 return;
150 } 150 }
151 }
151 152
152 HasInventoryChanged = true; 153 HasInventoryChanged = true;
153 m_part.ParentGroup.HasGroupChanged = true; 154 m_part.ParentGroup.HasGroupChanged = true;
154 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 155 List<TaskInventoryItem> items = GetInventoryItems();
155 foreach (TaskInventoryItem item in items) 156 foreach (TaskInventoryItem item in items)
157 {
158 if (ownerId != item.OwnerID)
156 { 159 {
157 if (ownerId != item.OwnerID) 160 item.LastOwnerID = item.OwnerID;
158 { 161 item.OwnerID = ownerId;
159 item.LastOwnerID = item.OwnerID;
160 item.OwnerID = ownerId;
161 }
162 } 162 }
163 } 163 }
164 } 164 }
@@ -175,17 +175,15 @@ namespace OpenSim.Region.Framework.Scenes
175 { 175 {
176 return; 176 return;
177 } 177 }
178 }
178 179
179 HasInventoryChanged = true; 180 HasInventoryChanged = true;
180 m_part.ParentGroup.HasGroupChanged = true; 181 m_part.ParentGroup.HasGroupChanged = true;
181 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 182 List<TaskInventoryItem> items = GetInventoryItems();
182 foreach (TaskInventoryItem item in items) 183 foreach (TaskInventoryItem item in items)
183 { 184 {
184 if (groupID != item.GroupID) 185 if (groupID != item.GroupID)
185 { 186 item.GroupID = groupID;
186 item.GroupID = groupID;
187 }
188 }
189 } 187 }
190 } 188 }
191 189
@@ -194,17 +192,9 @@ namespace OpenSim.Region.Framework.Scenes
194 /// </summary> 192 /// </summary>
195 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) 193 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
196 { 194 {
197 lock (m_items) 195 List<TaskInventoryItem> scripts = GetInventoryScripts();
198 { 196 foreach (TaskInventoryItem item in scripts)
199 foreach (TaskInventoryItem item in Items.Values) 197 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
200 {
201 if ((int)InventoryType.LSL == item.InvType)
202 {
203 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
204 Thread.Sleep(10); // workaround for Mono cpu utilization > 100% bug
205 }
206 }
207 }
208 } 198 }
209 199
210 public ArrayList GetScriptErrors(UUID itemID) 200 public ArrayList GetScriptErrors(UUID itemID)
@@ -237,16 +227,9 @@ namespace OpenSim.Region.Framework.Scenes
237 /// </param> 227 /// </param>
238 public void RemoveScriptInstances(bool sceneObjectBeingDeleted) 228 public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
239 { 229 {
240 lock (Items) 230 List<TaskInventoryItem> scripts = GetInventoryScripts();
241 { 231 foreach (TaskInventoryItem item in scripts)
242 foreach (TaskInventoryItem item in Items.Values) 232 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
243 {
244 if ((int)InventoryType.LSL == item.InvType)
245 {
246 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
247 }
248 }
249 }
250 } 233 }
251 234
252 /// <summary> 235 /// <summary>
@@ -259,7 +242,7 @@ namespace OpenSim.Region.Framework.Scenes
259 // m_log.InfoFormat( 242 // m_log.InfoFormat(
260 // "[PRIM INVENTORY]: " + 243 // "[PRIM INVENTORY]: " +
261 // "Starting script {0}, {1} in prim {2}, {3}", 244 // "Starting script {0}, {1} in prim {2}, {3}",
262 // item.Name, item.ItemID, m_part.Name, m_part.UUID); 245 // item.Name, item.ItemID, Name, UUID);
263 246
264 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 247 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
265 return; 248 return;
@@ -295,20 +278,20 @@ namespace OpenSim.Region.Framework.Scenes
295 } 278 }
296 else 279 else
297 { 280 {
281 if (m_part.ParentGroup.m_savedScriptState != null)
282 RestoreSavedScriptState(item.OldItemID, item.ItemID);
283
298 lock (m_items) 284 lock (m_items)
299 { 285 {
300 if (m_part.ParentGroup.m_savedScriptState != null)
301 RestoreSavedScriptState(item.OldItemID, item.ItemID);
302
303 m_items[item.ItemID].PermsMask = 0; 286 m_items[item.ItemID].PermsMask = 0;
304 m_items[item.ItemID].PermsGranter = UUID.Zero; 287 m_items[item.ItemID].PermsGranter = UUID.Zero;
305
306 string script = Utils.BytesToString(asset.Data);
307 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
308 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
309 m_part.ParentGroup.AddActiveScriptCount(1);
310 m_part.ScheduleFullUpdate();
311 } 288 }
289
290 string script = Utils.BytesToString(asset.Data);
291 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
292 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
293 m_part.ParentGroup.AddActiveScriptCount(1);
294 m_part.ScheduleFullUpdate();
312 } 295 }
313 } 296 }
314 } 297 }
@@ -376,21 +359,15 @@ namespace OpenSim.Region.Framework.Scenes
376 /// </param> 359 /// </param>
377 public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) 360 public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
378 { 361 {
379 lock (m_items) 362 TaskInventoryItem item = GetInventoryItem(itemId);
380 { 363 if (item != null)
381 if (m_items.ContainsKey(itemId)) 364 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
382 { 365 else
383 CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); 366 m_log.ErrorFormat(
384 } 367 "[PRIM INVENTORY]: " +
385 else 368 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
386 { 369 itemId, m_part.Name, m_part.UUID,
387 m_log.ErrorFormat( 370 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
388 "[PRIM INVENTORY]: " +
389 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
390 itemId, m_part.Name, m_part.UUID,
391 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
392 }
393 }
394 } 371 }
395 372
396 /// <summary> 373 /// <summary>
@@ -431,16 +408,18 @@ namespace OpenSim.Region.Framework.Scenes
431 408
432 /// <summary> 409 /// <summary>
433 /// Check if the inventory holds an item with a given name. 410 /// Check if the inventory holds an item with a given name.
434 /// This method assumes that the task inventory is already locked.
435 /// </summary> 411 /// </summary>
436 /// <param name="name"></param> 412 /// <param name="name"></param>
437 /// <returns></returns> 413 /// <returns></returns>
438 private bool InventoryContainsName(string name) 414 private bool InventoryContainsName(string name)
439 { 415 {
440 foreach (TaskInventoryItem item in Items.Values) 416 lock (m_items)
441 { 417 {
442 if (item.Name == name) 418 foreach (TaskInventoryItem item in m_items.Values)
443 return true; 419 {
420 if (item.Name == name)
421 return true;
422 }
444 } 423 }
445 return false; 424 return false;
446 } 425 }
@@ -483,12 +462,7 @@ namespace OpenSim.Region.Framework.Scenes
483 /// <param name="item"></param> 462 /// <param name="item"></param>
484 public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) 463 public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop)
485 { 464 {
486 List<TaskInventoryItem> il; 465 List<TaskInventoryItem> il = GetInventoryItems();
487
488 lock (m_items)
489 {
490 il = new List<TaskInventoryItem>(m_items.Values);
491 }
492 466
493 foreach (TaskInventoryItem i in il) 467 foreach (TaskInventoryItem i in il)
494 { 468 {
@@ -528,14 +502,12 @@ namespace OpenSim.Region.Framework.Scenes
528 item.GroupID = m_part.GroupID; 502 item.GroupID = m_part.GroupID;
529 503
530 lock (m_items) 504 lock (m_items)
531 {
532 m_items.Add(item.ItemID, item); 505 m_items.Add(item.ItemID, item);
533 506
534 if (allowedDrop) 507 if (allowedDrop)
535 m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); 508 m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP);
536 else 509 else
537 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 510 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
538 }
539 511
540 m_inventorySerial++; 512 m_inventorySerial++;
541 //m_inventorySerial += 2; 513 //m_inventorySerial += 2;
@@ -559,9 +531,8 @@ namespace OpenSim.Region.Framework.Scenes
559 m_items.Add(item.ItemID, item); 531 m_items.Add(item.ItemID, item);
560// m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 532// m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
561 } 533 }
534 m_inventorySerial++;
562 } 535 }
563
564 m_inventorySerial++;
565 } 536 }
566 537
567 /// <summary> 538 /// <summary>
@@ -616,45 +587,44 @@ namespace OpenSim.Region.Framework.Scenes
616 587
617 public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) 588 public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents)
618 { 589 {
619 lock(m_items) 590 TaskInventoryItem it = GetInventoryItem(item.ItemID);
591 if (it != null)
620 { 592 {
621 if (m_items.ContainsKey(item.ItemID)) 593 item.ParentID = m_part.UUID;
622 { 594 item.ParentPartID = m_part.UUID;
623 if (m_items.ContainsKey(item.ItemID)) 595 item.Flags = m_items[item.ItemID].Flags;
624 { 596
625 item.ParentID = m_part.UUID; 597 // If group permissions have been set on, check that the groupID is up to date in case it has
626 item.ParentPartID = m_part.UUID; 598 // changed since permissions were last set.
627 item.Flags = m_items[item.ItemID].Flags; 599 if (item.GroupPermissions != (uint)PermissionMask.None)
628 600 item.GroupID = m_part.GroupID;
629 // If group permissions have been set on, check that the groupID is up to date in case it has 601
630 // changed since permissions were last set. 602 if (item.AssetID == UUID.Zero)
631 if (item.GroupPermissions != (uint)PermissionMask.None) 603 item.AssetID = it.AssetID;
632 item.GroupID = m_part.GroupID;
633
634 if (item.AssetID == UUID.Zero)
635 {
636 item.AssetID = m_items[item.ItemID].AssetID;
637 }
638 m_items[item.ItemID] = item;
639 m_inventorySerial++;
640 if (fireScriptEvents)
641 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
642 HasInventoryChanged = true;
643 m_part.ParentGroup.HasGroupChanged = true;
644 return true;
645 }
646 else
647 {
648 m_log.ErrorFormat(
649 "[PRIM INVENTORY]: " +
650 "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
651 item.ItemID, m_part.Name, m_part.UUID,
652 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
653 }
654 604
605 lock (m_items)
606 {
607 m_items[item.ItemID] = item;
608 m_inventorySerial++;
655 } 609 }
656 return false; 610
611 if (fireScriptEvents)
612 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
613
614 HasInventoryChanged = true;
615 m_part.ParentGroup.HasGroupChanged = true;
616 return true;
657 } 617 }
618 else
619 {
620 m_log.ErrorFormat(
621 "[PRIM INVENTORY]: " +
622 "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
623 item.ItemID, m_part.Name, m_part.UUID,
624 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
625 }
626 return false;
627
658 } 628 }
659 629
660 /// <summary> 630 /// <summary>
@@ -665,52 +635,37 @@ namespace OpenSim.Region.Framework.Scenes
665 /// in this prim's inventory.</returns> 635 /// in this prim's inventory.</returns>
666 public int RemoveInventoryItem(UUID itemID) 636 public int RemoveInventoryItem(UUID itemID)
667 { 637 {
668 lock (m_items) 638 TaskInventoryItem item = GetInventoryItem(itemID);
639 if (item != null)
669 { 640 {
670 if (m_items.ContainsKey(itemID)) 641 int type = m_items[itemID].InvType;
642 if (type == 10) // Script
671 { 643 {
672 int type = m_items[itemID].InvType; 644 m_part.RemoveScriptEvents(itemID);
673 if (type == 10) // Script 645 m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID);
674 { 646 }
675 m_part.RemoveScriptEvents(itemID); 647 m_items.Remove(itemID);
676 m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); 648 m_inventorySerial++;
677 } 649 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
678 m_items.Remove(itemID);
679 m_inventorySerial++;
680 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
681
682 HasInventoryChanged = true;
683 m_part.ParentGroup.HasGroupChanged = true;
684 650
685 int scriptcount = 0; 651 HasInventoryChanged = true;
686 lock (m_items) 652 m_part.ParentGroup.HasGroupChanged = true;
687 {
688 foreach (TaskInventoryItem item in m_items.Values)
689 {
690 if (item.Type == 10)
691 {
692 scriptcount++;
693 }
694 }
695 }
696 653
697 if (scriptcount <= 0) 654 if (!ContainsScripts())
698 { 655 m_part.RemFlag(PrimFlags.Scripted);
699 m_part.RemFlag(PrimFlags.Scripted);
700 }
701 656
702 m_part.ScheduleFullUpdate(); 657 m_part.ScheduleFullUpdate();
703 658
704 return type; 659 return type;
705 } 660
706 else 661 }
707 { 662 else
708 m_log.ErrorFormat( 663 {
709 "[PRIM INVENTORY]: " + 664 m_log.ErrorFormat(
710 "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", 665 "[PRIM INVENTORY]: " +
711 itemID, m_part.Name, m_part.UUID, 666 "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
712 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); 667 itemID, m_part.Name, m_part.UUID,
713 } 668 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
714 } 669 }
715 670
716 return -1; 671 return -1;
@@ -764,52 +719,50 @@ namespace OpenSim.Region.Framework.Scenes
764 // isn't available (such as drag from prim inventory to agent inventory) 719 // isn't available (such as drag from prim inventory to agent inventory)
765 InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); 720 InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
766 721
767 lock (m_items) 722 List<TaskInventoryItem> items = GetInventoryItems();
723 foreach (TaskInventoryItem item in items)
768 { 724 {
769 foreach (TaskInventoryItem item in m_items.Values) 725 UUID ownerID = item.OwnerID;
770 { 726 uint everyoneMask = 0;
771 UUID ownerID = item.OwnerID; 727 uint baseMask = item.BasePermissions;
772 uint everyoneMask = 0; 728 uint ownerMask = item.CurrentPermissions;
773 uint baseMask = item.BasePermissions; 729 uint groupMask = item.GroupPermissions;
774 uint ownerMask = item.CurrentPermissions;
775 uint groupMask = item.GroupPermissions;
776 730
777 invString.AddItemStart(); 731 invString.AddItemStart();
778 invString.AddNameValueLine("item_id", item.ItemID.ToString()); 732 invString.AddNameValueLine("item_id", item.ItemID.ToString());
779 invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); 733 invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
780 734
781 invString.AddPermissionsStart(); 735 invString.AddPermissionsStart();
782 736
783 invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); 737 invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
784 invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); 738 invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
785 invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); 739 invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask));
786 invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); 740 invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
787 invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); 741 invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
788 742
789 invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); 743 invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
790 invString.AddNameValueLine("owner_id", ownerID.ToString()); 744 invString.AddNameValueLine("owner_id", ownerID.ToString());
791 745
792 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); 746 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
793 747
794 invString.AddNameValueLine("group_id", item.GroupID.ToString()); 748 invString.AddNameValueLine("group_id", item.GroupID.ToString());
795 invString.AddSectionEnd(); 749 invString.AddSectionEnd();
796 750
797 invString.AddNameValueLine("asset_id", item.AssetID.ToString()); 751 invString.AddNameValueLine("asset_id", item.AssetID.ToString());
798 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); 752 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
799 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); 753 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
800 invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); 754 invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));
801 755
802 invString.AddSaleStart(); 756 invString.AddSaleStart();
803 invString.AddNameValueLine("sale_type", "not"); 757 invString.AddNameValueLine("sale_type", "not");
804 invString.AddNameValueLine("sale_price", "0"); 758 invString.AddNameValueLine("sale_price", "0");
805 invString.AddSectionEnd(); 759 invString.AddSectionEnd();
806 760
807 invString.AddNameValueLine("name", item.Name + "|"); 761 invString.AddNameValueLine("name", item.Name + "|");
808 invString.AddNameValueLine("desc", item.Description + "|"); 762 invString.AddNameValueLine("desc", item.Description + "|");
809 763
810 invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); 764 invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
811 invString.AddSectionEnd(); 765 invString.AddSectionEnd();
812 }
813 } 766 }
814 767
815 fileData = Utils.StringToBytes(invString.BuildString); 768 fileData = Utils.StringToBytes(invString.BuildString);
@@ -831,12 +784,10 @@ namespace OpenSim.Region.Framework.Scenes
831 { 784 {
832 if (HasInventoryChanged) 785 if (HasInventoryChanged)
833 { 786 {
834 lock (Items)
835 {
836 datastore.StorePrimInventory(m_part.UUID, Items.Values);
837 }
838
839 HasInventoryChanged = false; 787 HasInventoryChanged = false;
788 List<TaskInventoryItem> items = GetInventoryItems();
789 datastore.StorePrimInventory(m_part.UUID, items);
790
840 } 791 }
841 } 792 }
842 793
@@ -952,7 +903,6 @@ namespace OpenSim.Region.Framework.Scenes
952 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; 903 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
953 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) 904 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
954 item.CurrentPermissions &= ~(uint)PermissionMask.Modify; 905 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
955 item.CurrentPermissions |= 8;
956 } 906 }
957 item.CurrentPermissions &= item.NextPermissions; 907 item.CurrentPermissions &= item.NextPermissions;
958 item.BasePermissions &= item.NextPermissions; 908 item.BasePermissions &= item.NextPermissions;
@@ -1002,6 +952,30 @@ namespace OpenSim.Region.Framework.Scenes
1002 952
1003 return ret; 953 return ret;
1004 } 954 }
955
956 public List<TaskInventoryItem> GetInventoryItems()
957 {
958 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
959
960 lock (m_items)
961 ret = new List<TaskInventoryItem>(m_items.Values);
962
963 return ret;
964 }
965
966 public List<TaskInventoryItem> GetInventoryScripts()
967 {
968 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
969
970 lock (m_items)
971 {
972 foreach (TaskInventoryItem item in m_items.Values)
973 if (item.InvType == (int)InventoryType.LSL)
974 ret.Add(item);
975 }
976
977 return ret;
978 }
1005 979
1006 public Dictionary<UUID, string> GetScriptStates() 980 public Dictionary<UUID, string> GetScriptStates()
1007 { 981 {
@@ -1011,24 +985,20 @@ namespace OpenSim.Region.Framework.Scenes
1011 if (engines == null) // No engine at all 985 if (engines == null) // No engine at all
1012 return ret; 986 return ret;
1013 987
1014 lock (m_items) 988 List<TaskInventoryItem> scripts = GetInventoryScripts();
989
990 foreach (TaskInventoryItem item in scripts)
1015 { 991 {
1016 foreach (TaskInventoryItem item in m_items.Values) 992 foreach (IScriptModule e in engines)
1017 { 993 {
1018 if (item.InvType == (int)InventoryType.LSL) 994 if (e != null)
1019 { 995 {
1020 foreach (IScriptModule e in engines) 996 string n = e.GetXMLState(item.ItemID);
997 if (n != String.Empty)
1021 { 998 {
1022 if (e != null) 999 if (!ret.ContainsKey(item.ItemID))
1023 { 1000 ret[item.ItemID] = n;
1024 string n = e.GetXMLState(item.ItemID); 1001 break;
1025 if (n != String.Empty)
1026 {
1027 if (!ret.ContainsKey(item.ItemID))
1028 ret[item.ItemID] = n;
1029 break;
1030 }
1031 }
1032 } 1002 }
1033 } 1003 }
1034 } 1004 }
@@ -1043,25 +1013,22 @@ namespace OpenSim.Region.Framework.Scenes
1043 if (engines == null) 1013 if (engines == null)
1044 return; 1014 return;
1045 1015
1046 lock (m_items) 1016 List<TaskInventoryItem> scripts = GetInventoryScripts();
1017
1018 foreach (TaskInventoryItem item in scripts)
1047 { 1019 {
1048 foreach (TaskInventoryItem item in m_items.Values) 1020 foreach (IScriptModule engine in engines)
1049 { 1021 {
1050 if (item.InvType == (int)InventoryType.LSL) 1022 if (engine != null)
1051 { 1023 {
1052 foreach (IScriptModule engine in engines) 1024 if (item.OwnerChanged)
1053 { 1025 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1054 if (engine != null) 1026 item.OwnerChanged = false;
1055 { 1027 engine.ResumeScript(item.ItemID);
1056 if (item.OwnerChanged)
1057 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1058 item.OwnerChanged = false;
1059 engine.ResumeScript(item.ItemID);
1060 }
1061 }
1062 } 1028 }
1063 } 1029 }
1064 } 1030 }
1065 } 1031 }
1032
1066 } 1033 }
1067} 1034}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6c119c2..1e8ce22 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -60,7 +60,6 @@ namespace OpenSim.Region.Framework.Scenes
60 struct ScriptControllers 60 struct ScriptControllers
61 { 61 {
62 public UUID itemID; 62 public UUID itemID;
63 public uint objID;
64 public ScriptControlled ignoreControls; 63 public ScriptControlled ignoreControls;
65 public ScriptControlled eventControls; 64 public ScriptControlled eventControls;
66 } 65 }
@@ -3057,6 +3056,18 @@ namespace OpenSim.Region.Framework.Scenes
3057 cAgent.Attachments = attachs; 3056 cAgent.Attachments = attachs;
3058 } 3057 }
3059 3058
3059 lock (scriptedcontrols)
3060 {
3061 ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
3062 int i = 0;
3063
3064 foreach (ScriptControllers c in scriptedcontrols.Values)
3065 {
3066 controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls);
3067 }
3068 cAgent.Controllers = controls;
3069 }
3070
3060 // Animations 3071 // Animations
3061 try 3072 try
3062 { 3073 {
@@ -3137,6 +3148,27 @@ namespace OpenSim.Region.Framework.Scenes
3137 } 3148 }
3138 catch { } 3149 catch { }
3139 3150
3151 try
3152 {
3153 lock (scriptedcontrols)
3154 {
3155 if (cAgent.Controllers != null)
3156 {
3157 scriptedcontrols.Clear();
3158
3159 foreach (ControllerData c in cAgent.Controllers)
3160 {
3161 ScriptControllers sc = new ScriptControllers();
3162 sc.itemID = c.ItemID;
3163 sc.ignoreControls = (ScriptControlled)c.IgnoreControls;
3164 sc.eventControls = (ScriptControlled)c.EventControls;
3165
3166 scriptedcontrols[sc.itemID] = sc;
3167 }
3168 }
3169 }
3170 }
3171 catch { }
3140 // Animations 3172 // Animations
3141 try 3173 try
3142 { 3174 {
@@ -3468,7 +3500,6 @@ namespace OpenSim.Region.Framework.Scenes
3468 obj.eventControls = ScriptControlled.CONTROL_ZERO; 3500 obj.eventControls = ScriptControlled.CONTROL_ZERO;
3469 3501
3470 obj.itemID = Script_item_UUID; 3502 obj.itemID = Script_item_UUID;
3471 obj.objID = Obj_localID;
3472 if (pass_on == 0 && accept == 0) 3503 if (pass_on == 0 && accept == 0)
3473 { 3504 {
3474 IgnoredControls |= (ScriptControlled)controls; 3505 IgnoredControls |= (ScriptControlled)controls;
@@ -3611,7 +3642,7 @@ namespace OpenSim.Region.Framework.Scenes
3611 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) 3642 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO)
3612 { 3643 {
3613 // only send if still pressed or just changed 3644 // only send if still pressed or just changed
3614 m_scene.EventManager.TriggerControlEvent(scriptControlData.objID, scriptUUID, UUID, (uint)localHeld, (uint)localChange); 3645 m_scene.EventManager.TriggerControlEvent(scriptUUID, UUID, (uint)localHeld, (uint)localChange);
3615 } 3646 }
3616 } 3647 }
3617 } 3648 }
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/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 754b925..ee7aa2da 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -1055,11 +1055,6 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1055 1055
1056 } 1056 }
1057 1057
1058 public void AttachObject(uint localID, Quaternion rotation, byte attachPoint, UUID ownerID)
1059 {
1060
1061 }
1062
1063 public void SendAvatarDataImmediate(ISceneEntity avatar) 1058 public void SendAvatarDataImmediate(ISceneEntity avatar)
1064 { 1059 {
1065 1060
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 56c0d98..3f15b69 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -722,11 +722,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
722 if (money != null) 722 if (money != null)
723 { 723 {
724 // do the transaction, that is if the agent has got sufficient funds 724 // do the transaction, that is if the agent has got sufficient funds
725 if (!money.GroupCreationCovered(remoteClient)) { 725 if (!money.AmountCovered(remoteClient, money.GroupCreationCharge)) {
726 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); 726 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group.");
727 return UUID.Zero; 727 return UUID.Zero;
728 } 728 }
729 money.ApplyGroupCreationCharge(GetRequestingAgentID(remoteClient)); 729 money.ApplyCharge(GetRequestingAgentID(remoteClient), money.GroupCreationCharge, "Group Creation");
730 } 730 }
731 UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient)); 731 UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient));
732 732
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
index b9a75cc..653f856 100644
--- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
+++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
@@ -108,6 +108,16 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
108 108
109 public event ObjectPaid OnObjectPaid; 109 public event ObjectPaid OnObjectPaid;
110 110
111 public int UploadCharge
112 {
113 get { return 0; }
114 }
115
116 public int GroupCreationCharge
117 {
118 get { return 0; }
119 }
120
111 /// <summary> 121 /// <summary>
112 /// Startup 122 /// Startup
113 /// </summary> 123 /// </summary>
@@ -128,8 +138,6 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
128 public void AddRegion(Scene scene) 138 public void AddRegion(Scene scene)
129 { 139 {
130 // Send ObjectCapacity to Scene.. Which sends it to the SimStatsReporter. 140 // Send ObjectCapacity to Scene.. Which sends it to the SimStatsReporter.
131 scene.SetObjectCapacity(ObjectCapacity);
132
133 if (m_enabled) 141 if (m_enabled)
134 { 142 {
135 scene.RegisterModuleInterface<IMoneyModule>(this); 143 scene.RegisterModuleInterface<IMoneyModule>(this);
@@ -188,15 +196,10 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
188 // Please do not refactor these to be just one method 196 // Please do not refactor these to be just one method
189 // Existing implementations need the distinction 197 // Existing implementations need the distinction
190 // 198 //
191 public void ApplyUploadCharge(UUID agentID) 199 public void ApplyCharge(UUID agentID, int amount, string text)
192 {
193 }
194
195 public void ApplyGroupCreationCharge(UUID agentID)
196 { 200 {
197 } 201 }
198 202 public void ApplyUploadCharge(UUID agentID, int amount, string text)
199 public void ApplyCharge(UUID agentID, int amount, string text)
200 { 203 {
201 } 204 }
202 205
@@ -247,7 +250,6 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
247 250
248 if (config == "Economy" && startupConfig != null) 251 if (config == "Economy" && startupConfig != null)
249 { 252 {
250 ObjectCapacity = startupConfig.GetInt("ObjectCapacity", 45000);
251 PriceEnergyUnit = startupConfig.GetInt("PriceEnergyUnit", 100); 253 PriceEnergyUnit = startupConfig.GetInt("PriceEnergyUnit", 100);
252 PriceObjectClaim = startupConfig.GetInt("PriceObjectClaim", 10); 254 PriceObjectClaim = startupConfig.GetInt("PriceObjectClaim", 10);
253 PricePublicObjectDecay = startupConfig.GetInt("PricePublicObjectDecay", 4); 255 PricePublicObjectDecay = startupConfig.GetInt("PricePublicObjectDecay", 4);
@@ -268,27 +270,6 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
268 270
269 } 271 }
270 272
271 public EconomyData GetEconomyData()
272 {
273 EconomyData edata = new EconomyData();
274 edata.ObjectCapacity = ObjectCapacity;
275 edata.ObjectCount = ObjectCount;
276 edata.PriceEnergyUnit = PriceEnergyUnit;
277 edata.PriceGroupCreate = PriceGroupCreate;
278 edata.PriceObjectClaim = PriceObjectClaim;
279 edata.PriceObjectRent = PriceObjectRent;
280 edata.PriceObjectScaleFactor = PriceObjectScaleFactor;
281 edata.PriceParcelClaim = PriceParcelClaim;
282 edata.PriceParcelClaimFactor = PriceParcelClaimFactor;
283 edata.PriceParcelRent = PriceParcelRent;
284 edata.PricePublicObjectDecay = PricePublicObjectDecay;
285 edata.PricePublicObjectDelete = PricePublicObjectDelete;
286 edata.PriceRentLight = PriceRentLight;
287 edata.PriceUpload = PriceUpload;
288 edata.TeleportMinPrice = TeleportMinPrice;
289 return edata;
290 }
291
292 private void GetClientFunds(IClientAPI client) 273 private void GetClientFunds(IClientAPI client)
293 { 274 {
294 CheckExistAndRefreshFunds(client.AgentId); 275 CheckExistAndRefreshFunds(client.AgentId);
@@ -717,7 +698,9 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
717 698
718 if (user != null) 699 if (user != null)
719 { 700 {
720 user.SendEconomyData(EnergyEfficiency, ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, 701 Scene s = LocateSceneClientIn(user.AgentId);
702
703 user.SendEconomyData(EnergyEfficiency, s.RegionInfo.ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate,
721 PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, 704 PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor,
722 PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload, 705 PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload,
723 TeleportMinPrice, TeleportPriceExponent); 706 TeleportMinPrice, TeleportPriceExponent);
@@ -790,7 +773,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
790 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); 773 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
791 } 774 }
792 775
793 public int GetBalance(IClientAPI client) 776 public int GetBalance(UUID agentID)
794 { 777 {
795 return 0; 778 return 0;
796 } 779 }
@@ -798,16 +781,10 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
798 // Please do not refactor these to be just one method 781 // Please do not refactor these to be just one method
799 // Existing implementations need the distinction 782 // Existing implementations need the distinction
800 // 783 //
801 public bool UploadCovered(IClientAPI client) 784 public bool UploadCovered(IClientAPI client, int amount)
802 { 785 {
803 return AmountCovered(client, PriceUpload); 786 return true;
804 }
805
806 public bool GroupCreationCovered(IClientAPI client)
807 {
808 return AmountCovered(client, PriceGroupCreate);
809 } 787 }
810
811 public bool AmountCovered(IClientAPI client, int amount) 788 public bool AmountCovered(IClientAPI client, int amount)
812 { 789 {
813 return true; 790 return true;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 12d6643..2e0450c 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -627,10 +627,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC
627 { 627 {
628 } 628 }
629 629
630 public virtual void AttachObject(uint localID, Quaternion rotation, byte attachPoint, UUID ownerID)
631 {
632 }
633
634 public virtual void SendDialog(string objectname, UUID objectID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels) 630 public virtual void SendDialog(string objectname, UUID objectID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels)
635 { 631 {
636 } 632 }
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/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 712bd7d..ed63aee 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -451,12 +451,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
451 public LSL_Vector llVecNorm(LSL_Vector v) 451 public LSL_Vector llVecNorm(LSL_Vector v)
452 { 452 {
453 m_host.AddScriptLPS(1); 453 m_host.AddScriptLPS(1);
454 double mag = LSL_Vector.Mag(v); 454 return LSL_Vector.Norm(v);
455 LSL_Vector nor = new LSL_Vector();
456 nor.x = v.x / mag;
457 nor.y = v.y / mag;
458 nor.z = v.z / mag;
459 return nor;
460 } 455 }
461 456
462 public LSL_Float llVecDist(LSL_Vector a, LSL_Vector b) 457 public LSL_Float llVecDist(LSL_Vector a, LSL_Vector b)
@@ -470,22 +465,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
470 465
471 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke 466 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
472 467
473 // Utility function for llRot2Euler 468 // Old implementation of llRot2Euler. Normalization not required as Atan2 function will
474 469 // only return values >= -PI (-180 degrees) and <= PI (180 degrees).
475 // normalize an angle between -PI and PI (-180 to +180 degrees)
476 protected double NormalizeAngle(double angle)
477 {
478 if (angle > -Math.PI && angle < Math.PI)
479 return angle;
480
481 int numPis = (int)(Math.PI / angle);
482 double remainder = angle - Math.PI * numPis;
483 if (numPis % 2 == 1)
484 return Math.PI - angle;
485 return remainder;
486 }
487
488 // Old implementation of llRot2Euler, now normalized
489 470
490 public LSL_Vector llRot2Euler(LSL_Rotation r) 471 public LSL_Vector llRot2Euler(LSL_Rotation r)
491 { 472 {
@@ -497,13 +478,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
497 double n = 2 * (r.y * r.s + r.x * r.z); 478 double n = 2 * (r.y * r.s + r.x * r.z);
498 double p = m * m - n * n; 479 double p = m * m - n * n;
499 if (p > 0) 480 if (p > 0)
500 return new LSL_Vector(NormalizeAngle(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s))), 481 return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)),
501 NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), 482 Math.Atan2(n, Math.Sqrt(p)),
502 NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); 483 Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)));
503 else if (n > 0) 484 else if (n > 0)
504 return new LSL_Vector(0.0, Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); 485 return new LSL_Vector(0.0, Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z));
505 else 486 else
506 return new LSL_Vector(0.0, -Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); 487 return new LSL_Vector(0.0, -Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z));
507 } 488 }
508 489
509 /* From wiki: 490 /* From wiki:
@@ -1953,13 +1934,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1953 } 1934 }
1954 else 1935 else
1955 { 1936 {
1956 if (llVecDist(new LSL_Vector(0,0,0), targetPos) <= 10.0f) 1937 LSL_Vector rel_vec = SetPosAdjust(currentPos, targetPos);
1957 { 1938 part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z);
1958 part.OffsetPosition = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z); 1939 SceneObjectGroup parent = part.ParentGroup;
1959 SceneObjectGroup parent = part.ParentGroup; 1940 parent.HasGroupChanged = true;
1960 parent.HasGroupChanged = true; 1941 parent.ScheduleGroupForTerseUpdate();
1961 parent.ScheduleGroupForTerseUpdate();
1962 }
1963 } 1942 }
1964 } 1943 }
1965 1944
@@ -2945,9 +2924,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2945 2924
2946 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 2925 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
2947 if (attachmentsModule != null) 2926 if (attachmentsModule != null)
2948 attachmentsModule.AttachObject( 2927 attachmentsModule.AttachObject(presence.ControllingClient,
2949 presence.ControllingClient, grp.LocalId, 2928 grp, (uint)attachment, false);
2950 (uint)attachment, Quaternion.Identity, Vector3.Zero, false);
2951 } 2929 }
2952 } 2930 }
2953 2931
@@ -3270,17 +3248,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3270 public void llPointAt(LSL_Vector pos) 3248 public void llPointAt(LSL_Vector pos)
3271 { 3249 {
3272 m_host.AddScriptLPS(1); 3250 m_host.AddScriptLPS(1);
3273 ScenePresence Owner = World.GetScenePresence(m_host.UUID);
3274 LSL_Rotation rot = llEuler2Rot(pos);
3275 Owner.PreviousRotation = Owner.Rotation;
3276 Owner.Rotation = (new Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s));
3277 } 3251 }
3278 3252
3279 public void llStopPointAt() 3253 public void llStopPointAt()
3280 { 3254 {
3281 m_host.AddScriptLPS(1); 3255 m_host.AddScriptLPS(1);
3282 ScenePresence Owner = m_host.ParentGroup.Scene.GetScenePresence(m_host.OwnerID);
3283 Owner.Rotation = Owner.PreviousRotation;
3284 } 3256 }
3285 3257
3286 public void llTargetOmega(LSL_Vector axis, double spinrate, double gain) 3258 public void llTargetOmega(LSL_Vector axis, double spinrate, double gain)
@@ -3938,22 +3910,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3938 UUID uuid = (UUID)id; 3910 UUID uuid = (UUID)id;
3939 3911
3940 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); 3912 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
3913 if (account == null)
3914 return UUID.Zero.ToString();
3915
3941 3916
3942 PresenceInfo pinfo = null; 3917 PresenceInfo pinfo = null;
3943 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); 3918 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
3944 if (pinfos != null && pinfos.Length > 0) 3919 if (pinfos != null && pinfos.Length > 0)
3945 pinfo = pinfos[0]; 3920 pinfo = pinfos[0];
3946 3921
3947 if (pinfo == null)
3948 return UUID.Zero.ToString();
3949
3950 string reply = String.Empty; 3922 string reply = String.Empty;
3951 3923
3952 switch (data) 3924 switch (data)
3953 { 3925 {
3954 case 1: // DATA_ONLINE (0|1) 3926 case 1: // DATA_ONLINE (0|1)
3955 // TODO: implement fetching of this information 3927 if (pinfo != null && pinfo.RegionID != UUID.Zero)
3956 if (pinfo != null)
3957 reply = "1"; 3928 reply = "1";
3958 else 3929 else
3959 reply = "0"; 3930 reply = "0";
@@ -4950,7 +4921,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4950 case ',': 4921 case ',':
4951 if (parens == 0) 4922 if (parens == 0)
4952 { 4923 {
4953 result.Add(src.Substring(start,length).Trim()); 4924 result.Add(new LSL_String(src.Substring(start,length).Trim()));
4954 start += length+1; 4925 start += length+1;
4955 length = 0; 4926 length = 0;
4956 } 4927 }
@@ -5879,6 +5850,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5879 PSYS_PART_MAX_AGE = 7, 5850 PSYS_PART_MAX_AGE = 7,
5880 PSYS_SRC_ACCEL = 8, 5851 PSYS_SRC_ACCEL = 8,
5881 PSYS_SRC_PATTERN = 9, 5852 PSYS_SRC_PATTERN = 9,
5853 PSYS_SRC_INNERANGLE = 10,
5854 PSYS_SRC_OUTERANGLE = 11,
5882 PSYS_SRC_TEXTURE = 12, 5855 PSYS_SRC_TEXTURE = 12,
5883 PSYS_SRC_BURST_RATE = 13, 5856 PSYS_SRC_BURST_RATE = 13,
5884 PSYS_SRC_BURST_PART_COUNT = 15, 5857 PSYS_SRC_BURST_PART_COUNT = 15,
@@ -6011,6 +5984,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6011 prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; 5984 prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi;
6012 break; 5985 break;
6013 5986
5987 // PSYS_SRC_INNERANGLE and PSYS_SRC_ANGLE_BEGIN use the same variables. The
5988 // PSYS_SRC_OUTERANGLE and PSYS_SRC_ANGLE_END also use the same variable. The
5989 // client tells the difference between the two by looking at the 0x02 bit in
5990 // the PartFlags variable.
5991 case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE:
5992 tempf = (float)rules.GetLSLFloatItem(i + 1);
5993 prules.InnerAngle = (float)tempf;
5994 prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off.
5995 break;
5996
5997 case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE:
5998 tempf = (float)rules.GetLSLFloatItem(i + 1);
5999 prules.OuterAngle = (float)tempf;
6000 prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off.
6001 break;
6002
6014 case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: 6003 case (int)ScriptBaseClass.PSYS_SRC_TEXTURE:
6015 prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); 6004 prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1));
6016 break; 6005 break;
@@ -6067,11 +6056,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6067 case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: 6056 case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN:
6068 tempf = (float)rules.GetLSLFloatItem(i + 1); 6057 tempf = (float)rules.GetLSLFloatItem(i + 1);
6069 prules.InnerAngle = (float)tempf; 6058 prules.InnerAngle = (float)tempf;
6059 prules.PartFlags |= 0x02; // Set new angle format.
6070 break; 6060 break;
6071 6061
6072 case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: 6062 case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END:
6073 tempf = (float)rules.GetLSLFloatItem(i + 1); 6063 tempf = (float)rules.GetLSLFloatItem(i + 1);
6074 prules.OuterAngle = (float)tempf; 6064 prules.OuterAngle = (float)tempf;
6065 prules.PartFlags |= 0x02; // Set new angle format.
6075 break; 6066 break;
6076 } 6067 }
6077 6068
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 1ea52c5..91e03ac 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -262,7 +262,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
262 public static Vector3 Norm(Vector3 vector) 262 public static Vector3 Norm(Vector3 vector)
263 { 263 {
264 double mag = Mag(vector); 264 double mag = Mag(vector);
265 return new Vector3(vector.x / mag, vector.y / mag, vector.z / mag); 265 if (mag > 0.0)
266 {
267 double invMag = 1.0 / mag;
268 return vector * invMag;
269 }
270 return new Vector3(0, 0, 0);
266 } 271 }
267 272
268 #endregion 273 #endregion
@@ -663,13 +668,13 @@ namespace OpenSim.Region.ScriptEngine.Shared
663 Object[] ret; 668 Object[] ret;
664 669
665 if (start < 0) 670 if (start < 0)
666 start=m_data.Length-start; 671 start=m_data.Length+start;
667 672
668 if (start < 0) 673 if (start < 0)
669 start=0; 674 start=0;
670 675
671 if (end < 0) 676 if (end < 0)
672 end=m_data.Length-end; 677 end=m_data.Length+end;
673 if (end < 0) 678 if (end < 0)
674 end=0; 679 end=0;
675 680
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index 09b79d0..0ac8b5c 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -356,9 +356,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
356 // timer: not handled here 356 // timer: not handled here
357 // listen: not handled here 357 // listen: not handled here
358 358
359 public void control(uint localID, UUID itemID, UUID agentID, uint held, uint change) 359 public void control(UUID itemID, UUID agentID, uint held, uint change)
360 { 360 {
361 myScriptEngine.PostObjectEvent(localID, new EventParams( 361 myScriptEngine.PostScriptEvent(itemID, new EventParams(
362 "control",new object[] { 362 "control",new object[] {
363 new LSL_Types.LSLString(agentID.ToString()), 363 new LSL_Types.LSLString(agentID.ToString()),
364 new LSL_Types.LSLInteger(held), 364 new LSL_Types.LSLInteger(held),
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 4715690..b050349 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -488,6 +488,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
488 488
489 if (stateSource == (int)StateSource.ScriptedRez) 489 if (stateSource == (int)StateSource.ScriptedRez)
490 { 490 {
491 lock (m_CompileDict)
492 {
493 m_CompileDict[itemID] = 0;
494 }
495
491 DoOnRezScript(parms); 496 DoOnRezScript(parms);
492 } 497 }
493 else 498 else
@@ -696,9 +701,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
696 } 701 }
697 } 702 }
698 703
704 ScriptInstance instance = null;
699 lock (m_Scripts) 705 lock (m_Scripts)
700 { 706 {
701 ScriptInstance instance = null;
702 // Create the object record 707 // Create the object record
703 708
704 if ((!m_Scripts.ContainsKey(itemID)) || 709 if ((!m_Scripts.ContainsKey(itemID)) ||
@@ -765,8 +770,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
765 item.Name, startParam, postOnRez, 770 item.Name, startParam, postOnRez,
766 stateSource, m_MaxScriptQueue); 771 stateSource, m_MaxScriptQueue);
767 772
768 m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}", 773 m_log.DebugFormat(
769 part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString()); 774 "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}",
775 part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID,
776 part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName);
770 777
771 if (presence != null) 778 if (presence != null)
772 { 779 {
@@ -779,28 +786,29 @@ namespace OpenSim.Region.ScriptEngine.XEngine
779 786
780 m_Scripts[itemID] = instance; 787 m_Scripts[itemID] = instance;
781 } 788 }
789 }
782 790
783 lock (m_PrimObjects) 791 lock (m_PrimObjects)
784 { 792 {
785 if (!m_PrimObjects.ContainsKey(localID)) 793 if (!m_PrimObjects.ContainsKey(localID))
786 m_PrimObjects[localID] = new List<UUID>(); 794 m_PrimObjects[localID] = new List<UUID>();
787 795
788 if (!m_PrimObjects[localID].Contains(itemID)) 796 if (!m_PrimObjects[localID].Contains(itemID))
789 m_PrimObjects[localID].Add(itemID); 797 m_PrimObjects[localID].Add(itemID);
790 798
791 } 799 }
792 800
793 if (!m_Assemblies.ContainsKey(assetID)) 801 if (!m_Assemblies.ContainsKey(assetID))
794 m_Assemblies[assetID] = assembly; 802 m_Assemblies[assetID] = assembly;
795 803
796 lock (m_AddingAssemblies) 804 lock (m_AddingAssemblies)
797 { 805 {
798 m_AddingAssemblies[assembly]--; 806 m_AddingAssemblies[assembly]--;
799 }
800
801 if (instance!=null)
802 instance.Init();
803 } 807 }
808
809 if (instance != null)
810 instance.Init();
811
804 return true; 812 return true;
805 } 813 }
806 814
@@ -813,60 +821,60 @@ namespace OpenSim.Region.ScriptEngine.XEngine
813 m_CompileDict.Remove(itemID); 821 m_CompileDict.Remove(itemID);
814 } 822 }
815 823
824 IScriptInstance instance = null;
825
816 lock (m_Scripts) 826 lock (m_Scripts)
817 { 827 {
818 // Do we even have it? 828 // Do we even have it?
819 if (!m_Scripts.ContainsKey(itemID)) 829 if (!m_Scripts.ContainsKey(itemID))
820 return; 830 return;
821 831
822 IScriptInstance instance=m_Scripts[itemID]; 832 instance=m_Scripts[itemID];
823 m_Scripts.Remove(itemID); 833 m_Scripts.Remove(itemID);
834 }
824 835
825 instance.ClearQueue(); 836 instance.ClearQueue();
826 instance.Stop(0); 837 instance.Stop(0);
827
828// bool objectRemoved = false; 838// bool objectRemoved = false;
829 839
830 lock (m_PrimObjects) 840 lock (m_PrimObjects)
841 {
842 // Remove the script from it's prim
843 if (m_PrimObjects.ContainsKey(localID))
831 { 844 {
832 // Remove the script from it's prim 845 // Remove inventory item record
833 if (m_PrimObjects.ContainsKey(localID)) 846 if (m_PrimObjects[localID].Contains(itemID))
834 { 847 m_PrimObjects[localID].Remove(itemID);
835 // Remove inventory item record
836 if (m_PrimObjects[localID].Contains(itemID))
837 m_PrimObjects[localID].Remove(itemID);
838 848
839 // If there are no more scripts, remove prim 849 // If there are no more scripts, remove prim
840 if (m_PrimObjects[localID].Count == 0) 850 if (m_PrimObjects[localID].Count == 0)
841 { 851 {
842 m_PrimObjects.Remove(localID); 852 m_PrimObjects.Remove(localID);
843// objectRemoved = true; 853// objectRemoved = true;
844 }
845 } 854 }
846 } 855 }
856 }
847 857
848 instance.RemoveState(); 858 instance.RemoveState();
849 instance.DestroyScriptInstance(); 859 instance.DestroyScriptInstance();
850 860
851 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); 861 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
852 if (m_DomainScripts[instance.AppDomain].Count == 0) 862 if (m_DomainScripts[instance.AppDomain].Count == 0)
853 { 863 {
854 m_DomainScripts.Remove(instance.AppDomain); 864 m_DomainScripts.Remove(instance.AppDomain);
855 UnloadAppDomain(instance.AppDomain); 865 UnloadAppDomain(instance.AppDomain);
856 } 866 }
857 867
858 instance = null; 868 instance = null;
859 869
860 ObjectRemoved handlerObjectRemoved = OnObjectRemoved; 870 ObjectRemoved handlerObjectRemoved = OnObjectRemoved;
861 if (handlerObjectRemoved != null) 871 if (handlerObjectRemoved != null)
862 { 872 {
863 SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); 873 SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
864 handlerObjectRemoved(part.UUID); 874 handlerObjectRemoved(part.UUID);
865 }
866
867 CleanAssemblies();
868 } 875 }
869 876
877
870 ScriptRemoved handlerScriptRemoved = OnScriptRemoved; 878 ScriptRemoved handlerScriptRemoved = OnScriptRemoved;
871 if (handlerScriptRemoved != null) 879 if (handlerScriptRemoved != null)
872 handlerScriptRemoved(itemID); 880 handlerScriptRemoved(itemID);
@@ -1000,26 +1008,33 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1000 public bool PostObjectEvent(uint localID, EventParams p) 1008 public bool PostObjectEvent(uint localID, EventParams p)
1001 { 1009 {
1002 bool result = false; 1010 bool result = false;
1003 1011 List<UUID> uuids = null;
1012
1004 lock (m_PrimObjects) 1013 lock (m_PrimObjects)
1005 { 1014 {
1006 if (!m_PrimObjects.ContainsKey(localID)) 1015 if (!m_PrimObjects.ContainsKey(localID))
1007 return false; 1016 return false;
1008 1017
1009 1018 uuids = m_PrimObjects[localID];
1010 foreach (UUID itemID in m_PrimObjects[localID]) 1019 }
1020
1021 foreach (UUID itemID in uuids)
1022 {
1023 IScriptInstance instance = null;
1024 try
1011 { 1025 {
1012 if (m_Scripts.ContainsKey(itemID)) 1026 if (m_Scripts.ContainsKey(itemID))
1013 { 1027 instance = m_Scripts[itemID];
1014 IScriptInstance instance = m_Scripts[itemID]; 1028 }
1015 if (instance != null) 1029 catch { /* ignore race conditions */ }
1016 { 1030
1017 instance.PostEvent(p); 1031 if (instance != null)
1018 result = true; 1032 {
1019 } 1033 instance.PostEvent(p);
1020 } 1034 result = true;
1021 } 1035 }
1022 } 1036 }
1037
1023 return result; 1038 return result;
1024 } 1039 }
1025 1040
@@ -1336,10 +1351,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1336 1351
1337 try 1352 try
1338 { 1353 {
1339 FileStream tfs = File.Open(assemName + ".text", 1354 using (FileStream tfs = File.Open(assemName + ".text",
1340 FileMode.Open, FileAccess.Read); 1355 FileMode.Open, FileAccess.Read))
1341 tfs.Read(tdata, 0, tdata.Length); 1356 {
1342 tfs.Close(); 1357 tfs.Read(tdata, 0, tdata.Length);
1358 tfs.Close();
1359 }
1343 1360
1344 assem = new System.Text.ASCIIEncoding().GetString(tdata); 1361 assem = new System.Text.ASCIIEncoding().GetString(tdata);
1345 } 1362 }
@@ -1359,9 +1376,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1359 1376
1360 try 1377 try
1361 { 1378 {
1362 FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); 1379 using (FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read))
1363 fs.Read(data, 0, data.Length); 1380 {
1364 fs.Close(); 1381 fs.Read(data, 0, data.Length);
1382 fs.Close();
1383 }
1365 1384
1366 assem = System.Convert.ToBase64String(data); 1385 assem = System.Convert.ToBase64String(data);
1367 } 1386 }
@@ -1377,13 +1396,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1377 1396
1378 if (File.Exists(fn + ".map")) 1397 if (File.Exists(fn + ".map"))
1379 { 1398 {
1380 FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read); 1399 using (FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read))
1381 StreamReader msr = new StreamReader(mfs); 1400 {
1382 1401 using (StreamReader msr = new StreamReader(mfs))
1383 map = msr.ReadToEnd(); 1402 {
1384 1403 map = msr.ReadToEnd();
1385 msr.Close(); 1404 msr.Close();
1386 mfs.Close(); 1405 }
1406 mfs.Close();
1407 }
1387 } 1408 }
1388 1409
1389 XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); 1410 XmlElement assemblyData = doc.CreateElement("", "Assembly", "");
@@ -1471,30 +1492,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1471 { 1492 {
1472 Byte[] filedata = Convert.FromBase64String(base64); 1493 Byte[] filedata = Convert.FromBase64String(base64);
1473 1494
1474 FileStream fs = File.Create(path); 1495 try
1475 fs.Write(filedata, 0, filedata.Length); 1496 {
1476 fs.Close(); 1497 using (FileStream fs = File.Create(path))
1477 1498 {
1478 fs = File.Create(path + ".text"); 1499 fs.Write(filedata, 0, filedata.Length);
1479 StreamWriter sw = new StreamWriter(fs); 1500 fs.Close();
1480 1501 }
1481 sw.Write(base64); 1502 }
1482 1503 catch (IOException ex)
1483 sw.Close(); 1504 {
1484 fs.Close(); 1505 // if there already exists a file at that location, it may be locked.
1506 m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message);
1507 }
1508 try
1509 {
1510 using (FileStream fs = File.Create(path + ".text"))
1511 {
1512 using (StreamWriter sw = new StreamWriter(fs))
1513 {
1514 sw.Write(base64);
1515 sw.Close();
1516 }
1517 fs.Close();
1518 }
1519 }
1520 catch (IOException ex)
1521 {
1522 // if there already exists a file at that location, it may be locked.
1523 m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message);
1524 }
1485 } 1525 }
1486 } 1526 }
1487 1527
1488 string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); 1528 string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
1489 statepath = Path.Combine(statepath, itemID.ToString() + ".state"); 1529 statepath = Path.Combine(statepath, itemID.ToString() + ".state");
1490 1530
1491 FileStream sfs = File.Create(statepath); 1531 try
1492 StreamWriter ssw = new StreamWriter(sfs); 1532 {
1493 1533 using (FileStream sfs = File.Create(statepath))
1494 ssw.Write(stateE.OuterXml); 1534 {
1495 1535 using (StreamWriter ssw = new StreamWriter(sfs))
1496 ssw.Close(); 1536 {
1497 sfs.Close(); 1537 ssw.Write(stateE.OuterXml);
1538 ssw.Close();
1539 }
1540 sfs.Close();
1541 }
1542 }
1543 catch (IOException ex)
1544 {
1545 // if there already exists a file at that location, it may be locked.
1546 m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message);
1547 }
1498 1548
1499 XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); 1549 XmlNodeList mapL = rootE.GetElementsByTagName("LineMap");
1500 if (mapL.Count > 0) 1550 if (mapL.Count > 0)
@@ -1504,13 +1554,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1504 string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); 1554 string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
1505 mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); 1555 mappath = Path.Combine(mappath, mapE.GetAttribute("Filename"));
1506 1556
1507 FileStream mfs = File.Create(mappath); 1557 try
1508 StreamWriter msw = new StreamWriter(mfs); 1558 {
1509 1559 using (FileStream mfs = File.Create(mappath))
1510 msw.Write(mapE.InnerText); 1560 {
1511 1561 using (StreamWriter msw = new StreamWriter(mfs))
1512 msw.Close(); 1562 {
1513 mfs.Close(); 1563 msw.Write(mapE.InnerText);
1564 msw.Close();
1565 }
1566 mfs.Close();
1567 }
1568 }
1569 catch (IOException ex)
1570 {
1571 // if there already exists a file at that location, it may be locked.
1572 m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message);
1573 }
1514 } 1574 }
1515 1575
1516 return true; 1576 return true;