aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/IAvatarData.cs (renamed from OpenSim/Region/Framework/Interfaces/ITeleportModule.cs)20
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs (renamed from OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs)129
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs (renamed from OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs)3
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs106
-rw-r--r--OpenSim/Region/Framework/Interfaces/IDialogModule.cs5
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs (renamed from OpenSim/Services/Interfaces/IHyperlink.cs)33
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs8
-rw-r--r--OpenSim/Region/Framework/Interfaces/IFriendsModule.cs16
-rw-r--r--OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs (renamed from OpenSim/Framework/Communications/IInterServiceInventoryServices.cs)57
-rw-r--r--OpenSim/Region/Framework/Interfaces/IGroupsModule.cs39
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs (renamed from OpenSim/Grid/MessagingServer.Modules/UserPresenceData.cs)27
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IPresenceModule.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs55
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs265
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs77
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs391
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs740
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs73
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs1164
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs28
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs1243
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs402
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs88
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs153
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs279
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneViewer.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs48
41 files changed, 1563 insertions, 4007 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/ITeleportModule.cs b/OpenSim/Data/IAvatarData.cs
index 5f9129d..0a18e21 100644
--- a/OpenSim/Region/Framework/Interfaces/ITeleportModule.cs
+++ b/OpenSim/Data/IAvatarData.cs
@@ -27,15 +27,23 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text;
31using OpenMetaverse; 30using OpenMetaverse;
32using OpenSim.Region.Framework.Scenes; 31using OpenSim.Framework;
33 32
34namespace OpenSim.Region.Framework.Interfaces 33namespace OpenSim.Data
35{ 34{
36 public interface ITeleportModule 35 // This MUST be a ref type!
36 public class AvatarBaseData
37 { 37 {
38 void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position, 38 public UUID PrincipalID;
39 Vector3 lookAt, uint teleportFlags); 39 public Dictionary<string, string> Data;
40 }
41
42 public interface IAvatarData
43 {
44 AvatarBaseData[] Get(string field, string val);
45 bool Store(AvatarBaseData data);
46 bool Delete(UUID principalID, string name);
47 bool Delete(string field, string val);
40 } 48 }
41} 49}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 6f7f34f..93aeb94 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.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 *
@@ -25,55 +25,67 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using System.Collections.Generic;
28using System.Reflection; 30using System.Reflection;
29using log4net; 31
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Connectors.Hypergrid;
36using OpenSim.Services.Interfaces;
37using OpenSim.Server.Base;
36 38
37namespace OpenSim.Region.Framework.Scenes.Hypergrid 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40
41using OpenMetaverse;
42using log4net;
43using Nini.Config;
44
45namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
38{ 46{
39 public partial class HGScene : Scene 47 public class HGInventoryAccessModule : BasicInventoryAccessModule, INonSharedRegionModule, IInventoryAccessModule
40 { 48 {
41 #region Fields
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 50
44 private HGAssetMapper m_assMapper; 51 private static HGAssetMapper m_assMapper;
45 public HGAssetMapper AssetMapper 52 public static HGAssetMapper AssetMapper
46 { 53 {
47 get { return m_assMapper; } 54 get { return m_assMapper; }
48 } 55 }
49 56
50 private IHyperAssetService m_hyper; 57 private bool m_Initialized = false;
51 private IHyperAssetService HyperAssets 58
59 #region INonSharedRegionModule
60
61 public override string Name
62 {
63 get { return "HGInventoryAccessModule"; }
64 }
65
66 public override void Initialise(IConfigSource source)
52 { 67 {
53 get 68 IConfig moduleConfig = source.Configs["Modules"];
69 if (moduleConfig != null)
54 { 70 {
55 if (m_hyper == null) 71 string name = moduleConfig.GetString("InventoryAccessModule", "");
56 m_hyper = RequestModuleInterface<IHyperAssetService>(); 72 if (name == Name)
57 return m_hyper; 73 {
74 m_Enabled = true;
75 m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name);
76 }
58 } 77 }
59 } 78 }
60 79
61 #endregion 80 public override void AddRegion(Scene scene)
62
63 #region Constructors
64
65 public HGScene(RegionInfo regInfo, AgentCircuitManager authen,
66 CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
67 StorageManager storeManager,
68 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
69 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
70 : base(regInfo, authen, commsMan, sceneGridService, storeManager, moduleLoader,
71 dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion)
72 { 81 {
73 m_log.Info("[HGScene]: Starting HGScene."); 82 if (!m_Enabled)
74 m_assMapper = new HGAssetMapper(this); 83 return;
84
85 base.AddRegion(scene);
86 m_assMapper = new HGAssetMapper(scene);
87 scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
75 88
76 EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
77 } 89 }
78 90
79 #endregion 91 #endregion
@@ -82,17 +94,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
82 94
83 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) 95 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
84 { 96 {
85 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID); 97 string userAssetServer = string.Empty;
86 if (userInfo != null) 98 if (IsForeignUser(avatarID, out userAssetServer))
87 { 99 {
88 m_assMapper.Post(assetID, avatarID); 100 m_assMapper.Post(assetID, avatarID, userAssetServer);
89 } 101 }
90 } 102 }
91 103
92 #endregion 104 #endregion
93 105
94 #region Overrides of Scene.Inventory methods 106 #region Overrides of Basic Inventory Access methods
95
96 /// 107 ///
97 /// CapsUpdateInventoryItemAsset 108 /// CapsUpdateInventoryItemAsset
98 /// 109 ///
@@ -135,7 +146,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
135 //{ 146 //{
136 InventoryItemBase item = new InventoryItemBase(itemID); 147 InventoryItemBase item = new InventoryItemBase(itemID);
137 item.Owner = remoteClient.AgentId; 148 item.Owner = remoteClient.AgentId;
138 item = InventoryService.GetItem(item); 149 item = m_Scene.InventoryService.GetItem(item);
139 //if (item == null) 150 //if (item == null)
140 //{ // Fetch the item 151 //{ // Fetch the item
141 // item = new InventoryItemBase(); 152 // item = new InventoryItemBase();
@@ -143,32 +154,54 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
143 // item.ID = itemID; 154 // item.ID = itemID;
144 // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); 155 // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
145 //} 156 //}
146 if (item != null) 157 string userAssetServer = string.Empty;
158 if (item != null && IsForeignUser(remoteClient.AgentId, out userAssetServer))
147 { 159 {
148 m_assMapper.Get(item.AssetID, remoteClient.AgentId); 160 m_assMapper.Get(item.AssetID, remoteClient.AgentId, userAssetServer);
149 161
150 } 162 }
151 //} 163 //}
152 164
153 // OK, we're done fetching. Pass it up to the default RezObject 165 // OK, we're done fetching. Pass it up to the default RezObject
154 return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 166 return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
155 RezSelected, RemoveItem, fromTaskID, attachment); 167 RezSelected, RemoveItem, fromTaskID, attachment);
156 168
157 } 169 }
158 170
159 protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) 171 public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
160 { 172 {
161 string userAssetServer = HyperAssets.GetUserAssetServer(sender); 173 string userAssetServer = string.Empty;
162 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) 174 if (IsForeignUser(sender, out userAssetServer))
163 m_assMapper.Get(item.AssetID, sender); 175 m_assMapper.Get(item.AssetID, sender, userAssetServer);
164 176
165 userAssetServer = HyperAssets.GetUserAssetServer(receiver); 177 if (IsForeignUser(receiver, out userAssetServer))
166 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) 178 m_assMapper.Post(item.AssetID, receiver, userAssetServer);
167 m_assMapper.Post(item.AssetID, receiver);
168 } 179 }
169 180
170 #endregion 181 #endregion
171 182
172 } 183 public bool IsForeignUser(UUID userID, out string assetServerURL)
184 {
185 assetServerURL = string.Empty;
186 UserAccount account = null;
187 if (m_Scene.UserAccountService != null)
188 account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID);
189
190 if (account == null) // foreign
191 {
192 ScenePresence sp = null;
193 if (m_Scene.TryGetScenePresence(userID, out sp))
194 {
195 AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
196 if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
197 {
198 assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString();
199 assetServerURL = assetServerURL.Trim(new char[] { '/' }); return true;
200 }
201 }
202 }
173 203
204 return false;
205 }
206 }
174} 207}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs
index 5d4e7ac..fcb544f 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs
@@ -29,10 +29,11 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
32using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
33using OpenMetaverse; 34using OpenMetaverse;
34 35
35namespace OpenSim.Region.Framework.Scenes.Hypergrid 36namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
36{ 37{
37 public class HGUuidGatherer : UuidGatherer 38 public class HGUuidGatherer : UuidGatherer
38 { 39 {
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
new file mode 100644
index 0000000..0222b02
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -0,0 +1,106 @@
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 OpenSim 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 OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes;
32
33namespace OpenSim.Region.Framework.Interfaces
34{
35 public interface IAttachmentsModule
36 {
37 /// <summary>
38 /// Attach an object to an avatar from the world.
39 /// </summary>
40 /// <param name="controllingClient"></param>
41 /// <param name="localID"></param>
42 /// <param name="attachPoint"></param>
43 /// <param name="rot"></param>
44 /// <param name="silent"></param>
45 void AttachObject(
46 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent);
47
48 /// <summary>
49 /// Attach an object to an avatar.
50 /// </summary>
51 /// <param name="controllingClient"></param>
52 /// <param name="localID"></param>
53 /// <param name="attachPoint"></param>
54 /// <param name="rot"></param>
55 /// <param name="attachPos"></param>
56 /// <param name="silent"></param>
57 /// <returns>true if the object was successfully attached, false otherwise</returns>
58 bool AttachObject(
59 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent);
60
61 /// <summary>
62 /// Rez an attachment from user inventory and change inventory status to match.
63 /// </summary>
64 /// <param name="remoteClient"></param>
65 /// <param name="itemID"></param>
66 /// <param name="AttachmentPt"></param>
67 /// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
68 UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
69
70 /// <summary>
71 /// Rez an attachment from user inventory
72 /// </summary>
73 /// <param name="remoteClient"></param>
74 /// <param name="itemID"></param>
75 /// <param name="AttachmentPt"></param>
76 /// <param name="updateinventoryStatus">
77 /// If true, we also update the user's inventory to show that the attachment is set. If false, we do not.
78 /// False is required so that we don't attempt to update information when a user enters a scene with the
79 /// attachment already correctly set up in inventory.
80 /// <returns>The uuid of the scene object that was attached. Null if the scene object could not be found</returns>
81 UUID RezSingleAttachmentFromInventory(
82 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus);
83
84 /// <summary>
85 /// Update the user inventory to the attachment of an item
86 /// </summary>
87 /// <param name="att"></param>
88 /// <param name="remoteClient"></param>
89 /// <param name="itemID"></param>
90 /// <param name="AttachmentPt"></param>
91 /// <returns></returns>
92 UUID SetAttachmentInventoryStatus(
93 SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
94
95 /// <summary>
96 /// Update the user inventory to show a detach.
97 /// </summary>
98 /// <param name="itemID">
99 /// A <see cref="UUID"/>
100 /// </param>
101 /// <param name="remoteClient">
102 /// A <see cref="IClientAPI"/>
103 /// </param>
104 void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient);
105 }
106} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs
index ce57c44..35b4b63 100644
--- a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs
@@ -131,5 +131,10 @@ namespace OpenSim.Region.Framework.Interfaces
131 /// <param name="fromAvatarName">The name of the user doing the sending</param> 131 /// <param name="fromAvatarName">The name of the user doing the sending</param>
132 /// <param name="message">The message being sent to the user</param> 132 /// <param name="message">The message being sent to the user</param>
133 void SendNotificationToUsersInEstate(UUID fromAvatarID, string fromAvatarName, string message); 133 void SendNotificationToUsersInEstate(UUID fromAvatarID, string fromAvatarName, string message);
134
135 /// <summary>
136 /// Send a textbox entry for the client to respond to
137 /// </summary>
138 void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid);
134 } 139 }
135} 140}
diff --git a/OpenSim/Services/Interfaces/IHyperlink.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index ed3ff23..e8738c4 100644
--- a/OpenSim/Services/Interfaces/IHyperlink.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -25,25 +25,36 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using OpenSim.Framework; 28using System;
29using OpenSim.Services.Interfaces;
29using GridRegion = OpenSim.Services.Interfaces.GridRegion; 30using GridRegion = OpenSim.Services.Interfaces.GridRegion;
30 31
31using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Region.Framework.Scenes;
32 35
33namespace OpenSim.Services.Interfaces 36namespace OpenSim.Region.Framework.Interfaces
34{ 37{
35 public interface IHyperlinkService 38 public interface IEntityTransferModule
36 { 39 {
37 GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor); 40 void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position,
38 GridRegion GetHyperlinkRegion(ulong handle); 41 Vector3 lookAt, uint teleportFlags);
39 ulong FindRegionHandle(ulong handle); 42
43 void TeleportHome(UUID id, IClientAPI client);
44
45 void Cross(ScenePresence agent, bool isFlying);
40 46
41 bool SendUserInformation(GridRegion region, AgentCircuitData aCircuit); 47 void AgentArrivedAtDestination(UUID agent);
42 void AdjustUserInformation(AgentCircuitData aCircuit);
43 48
44 bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome); 49 void EnableChildAgents(ScenePresence agent);
45 void AcceptUser(ForeignUserProfileData user, GridRegion home);
46 50
47 bool IsLocalUser(UUID userID); 51 void EnableChildAgent(ScenePresence agent, GridRegion region);
52
53 void Cross(SceneObjectGroup sog, Vector3 position, bool silent);
54 }
55
56 public interface IUserAgentVerificationModule
57 {
58 bool VerifyClient(AgentCircuitData aCircuit, string token);
48 } 59 }
49} 60}
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
index 668ff98..87c7a05 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic;
28using OpenMetaverse; 29using OpenMetaverse;
29using OpenSim.Framework; 30using OpenSim.Framework;
30 31
@@ -34,7 +35,12 @@ namespace OpenSim.Region.Framework.Interfaces
34 { 35 {
35 void Initialise(string connectstring); 36 void Initialise(string connectstring);
36 37
37 EstateSettings LoadEstateSettings(UUID regionID); 38 EstateSettings LoadEstateSettings(UUID regionID, bool create);
39 EstateSettings LoadEstateSettings(int estateID);
38 void StoreEstateSettings(EstateSettings es); 40 void StoreEstateSettings(EstateSettings es);
41 List<int> GetEstates(string search);
42 bool LinkRegion(UUID regionID, int estateID);
43 List<UUID> GetRegions(int estateID);
44 bool DeleteEstate(int estateID);
39 } 45 }
40} 46}
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
index 8386030..0ff7dee 100644
--- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
@@ -33,19 +33,7 @@ namespace OpenSim.Region.Framework.Interfaces
33{ 33{
34 public interface IFriendsModule 34 public interface IFriendsModule
35 { 35 {
36 /// <summary> 36 uint GetFriendPerms(UUID PrincipalID, UUID FriendID);
37 /// Offer a friendship to a user from the server end rather than by direct initiation from a client. 37 void SendFriendsOnlineIfNeeded(IClientAPI client);
38 /// </summary>
39 /// <param name="fromUserId">
40 /// A user with this id must existing in the user data store, but need not be logged on.
41 /// </param>
42 /// <param name="toUserClient">
43 /// An actually logged in client to which the offer is being made.
44 /// FIXME: This is somewhat too tightly coupled - it should arguably be possible to offer friendships even if the
45 /// receiving user is not currently online.
46 /// </param>
47 /// <param name="offerMessage"></param>
48 void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage);
49 List<FriendListItem> GetUserFriends(UUID agentID);
50 } 38 }
51} 39}
diff --git a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs b/OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs
index 7f17872..f158236 100644
--- a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs
+++ b/OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs
@@ -25,40 +25,49 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic;
29using OpenMetaverse; 28using OpenMetaverse;
29using OpenSim.Framework;
30 30
31namespace OpenSim.Framework.Communications 31namespace OpenSim.Region.Framework.Interfaces
32{ 32{
33 /// <summary> 33 /// <summary>
34 /// Inventory operations used between grid services. 34 /// Provide mechanisms for messaging groups.
35 /// </summary> 35 /// </summary>
36 public interface IInterServiceInventoryServices 36 ///
37 /// TODO: Provide a mechanism for receiving group messages as well as sending them
38 ///
39 public interface IGroupsMessagingModule
37 { 40 {
38 /// <summary> 41 /// <summary>
39 /// Create a new inventory for the given user. 42 /// Start a group chat session.
40 /// </summary> 43 /// </summary>
41 /// <param name="user"></param> 44 /// You must call this before calling SendMessageToGroup(). If a chat session for this group is already taking
42 /// <returns>true if the inventory was successfully created, false otherwise</returns> 45 /// place then the agent will added to that session.
43 bool CreateNewUserInventory(UUID user); 46 /// <param name="agentID">
44 47 /// A UUID that represents the agent being added. If you are agentless (e.g. you are
45 /// <summary> 48 /// a region module), then you can use any random ID.
46 /// Returns a list of all the folders in a given user's inventory. 49 /// </param>
47 /// </summary> 50 /// <param name="groupID">
48 /// <param name="userId"></param> 51 /// The ID for the group to join. Currently, the session ID used is identical to the
49 /// <returns>A flat list of the user's inventory folder tree, 52 /// group ID.
50 /// null if there is no inventory for this user</returns> 53 /// </param>
51 List<InventoryFolderBase> GetInventorySkeleton(UUID userId); 54 /// <returns>
55 /// True if the chat session was started successfully, false otherwise.
56 /// </returns>
57 bool StartGroupChatSession(UUID agentID, UUID groupID);
52 58
53 /// <summary> 59 /// <summary>
54 /// Returns a list of all the active gestures in a user's inventory. 60 /// Send a message to an entire group.
55 /// </summary> 61 /// </summary>
56 /// <param name="userId"> 62 /// <param name="im">
57 /// The <see cref="UUID"/> of the user 63 /// The message itself. The fields that must be populated are
64 ///
65 /// imSessionID - Populate this with the group ID (session ID and group ID are currently identical)
66 /// fromAgentName - Populate this with whatever arbitrary name you want to show up in the chat dialog
67 /// message - The message itself
68 /// dialog - This must be (byte)InstantMessageDialog.SessionSend
58 /// </param> 69 /// </param>
59 /// <returns> 70 /// <param name="groupID"></param>
60 /// A flat list of the gesture items. 71 void SendMessageToGroup(GridInstantMessage im, UUID groupID);
61 /// </returns>
62 List<InventoryItemBase> GetActiveGestures(UUID userId);
63 } 72 }
64} 73} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
index 8980b2d..2c091e7 100644
--- a/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
@@ -37,21 +37,51 @@ namespace OpenSim.Region.Framework.Interfaces
37 { 37 {
38 event NewGroupNotice OnNewGroupNotice; 38 event NewGroupNotice OnNewGroupNotice;
39 39
40 /// <summary>
41 /// Create a group
42 /// </summary>
43 /// <param name="remoteClient"></param>
44 /// <param name="name"></param>
45 /// <param name="charter"></param>
46 /// <param name="showInList"></param>
47 /// <param name="insigniaID"></param>
48 /// <param name="membershipFee"></param>
49 /// <param name="openEnrollment"></param>
50 /// <param name="allowPublish"></param>
51 /// <param name="maturePublish"></param>
52 /// <returns>The UUID of the created group</returns>
53 UUID CreateGroup(
54 IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee,
55 bool openEnrollment, bool allowPublish, bool maturePublish);
56
57 /// <summary>
58 /// Get a group
59 /// </summary>
60 /// <param name="name">Name of the group</param>
61 /// <returns>The group's data. Null if there is no such group.</returns>
62 GroupRecord GetGroupRecord(string name);
63
64 /// <summary>
65 /// Get a group
66 /// </summary>
67 /// <param name="GroupID">ID of the group</param>
68 /// <returns>The group's data. Null if there is no such group.</returns>
69 GroupRecord GetGroupRecord(UUID GroupID);
70
40 void ActivateGroup(IClientAPI remoteClient, UUID groupID); 71 void ActivateGroup(IClientAPI remoteClient, UUID groupID);
41 List<GroupTitlesData> GroupTitlesRequest(IClientAPI remoteClient, UUID groupID); 72 List<GroupTitlesData> GroupTitlesRequest(IClientAPI remoteClient, UUID groupID);
42 List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID); 73 List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID);
43 List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID); 74 List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID);
44 List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID); 75 List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID);
45 GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID); 76 GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID);
46 GroupMembershipData[] GetMembershipData(UUID UserID); 77 GroupMembershipData[] GetMembershipData(UUID UserID);
47 GroupMembershipData GetMembershipData(UUID GroupID, UUID UserID); 78 GroupMembershipData GetMembershipData(UUID GroupID, UUID UserID);
48 79
49 void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); 80 void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish);
50 81
51 void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile); 82 void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile);
52 83
53 void GroupTitleUpdate(IClientAPI remoteClient, UUID GroupID, UUID TitleRoleID); 84 void GroupTitleUpdate(IClientAPI remoteClient, UUID GroupID, UUID TitleRoleID);
54 UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish);
55 85
56 GroupNoticeData[] GroupNoticesListRequest(IClientAPI remoteClient, UUID GroupID); 86 GroupNoticeData[] GroupNoticesListRequest(IClientAPI remoteClient, UUID GroupID);
57 string GetGroupTitle(UUID avatarID); 87 string GetGroupTitle(UUID avatarID);
@@ -64,7 +94,6 @@ namespace OpenSim.Region.Framework.Interfaces
64 void LeaveGroupRequest(IClientAPI remoteClient, UUID GroupID); 94 void LeaveGroupRequest(IClientAPI remoteClient, UUID GroupID);
65 void EjectGroupMemberRequest(IClientAPI remoteClient, UUID GroupID, UUID EjecteeID); 95 void EjectGroupMemberRequest(IClientAPI remoteClient, UUID GroupID, UUID EjecteeID);
66 void InviteGroupRequest(IClientAPI remoteClient, UUID GroupID, UUID InviteeID, UUID RoleID); 96 void InviteGroupRequest(IClientAPI remoteClient, UUID GroupID, UUID InviteeID, UUID RoleID);
67 GroupRecord GetGroupRecord(UUID GroupID);
68 void NotifyChange(UUID GroupID); 97 void NotifyChange(UUID GroupID);
69 } 98 }
70} 99} \ No newline at end of file
diff --git a/OpenSim/Grid/MessagingServer.Modules/UserPresenceData.cs b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
index 7d4e45c..8185258 100644
--- a/OpenSim/Grid/MessagingServer.Modules/UserPresenceData.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
@@ -27,24 +27,21 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenMetaverse; 30
31using OpenSim.Data;
32using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
33 33
34namespace OpenSim.Grid.MessagingServer 34using OpenMetaverse;
35
36namespace OpenSim.Region.Framework.Interfaces
35{ 37{
36 public class UserPresenceData 38 public interface IInventoryAccessModule
37 { 39 {
38 public AgentCircuitData agentData = new AgentCircuitData(); 40 UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data);
39 public RegionProfileData regionData = new RegionProfileData(); 41 UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient);
40 public string httpURI = String.Empty; 42 SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
41 public Dictionary<UUID, FriendListItem> friendData = new Dictionary<UUID,FriendListItem>(); 43 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
42 public List<UUID> subscriptionData = new List<UUID>(); 44 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment);
43 public bool OnlineYN = true; 45 void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver);
44 public bool lookupUserRegionYN = true;
45
46 public UserPresenceData()
47 {
48 }
49 } 46 }
50} 47}
diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
index 2d038ce..fbadd91 100644
--- a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
@@ -27,7 +27,7 @@
27 27
28using System; 28using System;
29using System.IO; 29using System.IO;
30using OpenSim.Framework.Communications.Cache; 30using OpenSim.Services.Interfaces;
31 31
32namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Region.Framework.Interfaces
33{ 33{
@@ -41,7 +41,7 @@ namespace OpenSim.Region.Framework.Interfaces
41 /// <param name="savePath">The stream to which the archive was saved</param> 41 /// <param name="savePath">The stream to which the archive was saved</param>
42 /// <param name="reportedException">Contains the exception generated if the save did not succeed</param> 42 /// <param name="reportedException">Contains the exception generated if the save did not succeed</param>
43 public delegate void InventoryArchiveSaved( 43 public delegate void InventoryArchiveSaved(
44 Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException); 44 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, Exception reportedException);
45 45
46 public interface IInventoryArchiverModule 46 public interface IInventoryArchiverModule
47 { 47 {
diff --git a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs
index 630c6a3..d44c1e1 100644
--- a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs
@@ -31,13 +31,13 @@ namespace OpenSim.Region.Framework.Interfaces
31{ 31{
32 public struct PresenceInfo 32 public struct PresenceInfo
33 { 33 {
34 public UUID userID; 34 public string UserID;
35 public UUID regionID; 35 public UUID RegionID;
36 36
37 public PresenceInfo(UUID userID, UUID regionID) 37 public PresenceInfo(string userID, UUID regionID)
38 { 38 {
39 this.userID = userID; 39 UserID = userID;
40 this.regionID = regionID; 40 RegionID = regionID;
41 } 41 }
42 } 42 }
43 43
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
index 7312799..3e8e196 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
@@ -103,8 +103,8 @@ namespace OpenSim.Region.Framework.Interfaces
103 103
104 void StoreRegionSettings(RegionSettings rs); 104 void StoreRegionSettings(RegionSettings rs);
105 RegionSettings LoadRegionSettings(UUID regionUUID); 105 RegionSettings LoadRegionSettings(UUID regionUUID);
106 RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID); 106 RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID);
107 void StoreRegionWindlightSettings(RegionMeta7WindlightData wl); 107 void StoreRegionWindlightSettings(RegionLightShareData wl);
108 108
109 void Shutdown(); 109 void Shutdown();
110 } 110 }
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index be0e985..fd7d44f 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -385,7 +385,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
385 } 385 }
386 } 386 }
387 387
388 AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); 388 AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation, m_scenePresence.UUID.ToString());
389 Animasset.Data = anim.ToBytes(); 389 Animasset.Data = anim.ToBytes();
390 Animasset.Temporary = true; 390 Animasset.Temporary = true;
391 Animasset.Local = true; 391 Animasset.Local = true;
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index 9a7863b..c08b961 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -32,6 +32,7 @@ using System.Timers;
32using log4net; 32using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
35 36
36namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
37{ 38{
@@ -137,7 +138,9 @@ namespace OpenSim.Region.Framework.Scenes
137 138
138 try 139 try
139 { 140 {
140 m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); 141 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
142 if (invAccess != null)
143 invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient);
141 if (x.permissionToDelete) 144 if (x.permissionToDelete)
142 m_scene.DeleteSceneObject(x.objectGroup, false); 145 m_scene.DeleteSceneObject(x.objectGroup, false);
143 } 146 }
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 7fb1cd8..ef125cd 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -66,13 +66,16 @@ namespace OpenSim.Region.Framework.Scenes
66 public event OnClientConnectCoreDelegate OnClientConnect; 66 public event OnClientConnectCoreDelegate OnClientConnect;
67 67
68 public delegate void OnNewClientDelegate(IClientAPI client); 68 public delegate void OnNewClientDelegate(IClientAPI client);
69 69
70 /// <summary> 70 /// <summary>
71 /// Deprecated in favour of OnClientConnect. 71 /// Deprecated in favour of OnClientConnect.
72 /// Will be marked Obsolete after IClientCore has 100% of IClientAPI interfaces. 72 /// Will be marked Obsolete after IClientCore has 100% of IClientAPI interfaces.
73 /// </summary> 73 /// </summary>
74 public event OnNewClientDelegate OnNewClient; 74 public event OnNewClientDelegate OnNewClient;
75 75
76 public delegate void OnClientLoginDelegate(IClientAPI client);
77 public event OnClientLoginDelegate OnClientLogin;
78
76 public delegate void OnNewPresenceDelegate(ScenePresence presence); 79 public delegate void OnNewPresenceDelegate(ScenePresence presence);
77 80
78 public event OnNewPresenceDelegate OnNewPresence; 81 public event OnNewPresenceDelegate OnNewPresence;
@@ -107,12 +110,12 @@ namespace OpenSim.Region.Framework.Scenes
107 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; 110 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene;
108 111
109 /// <summary> 112 /// <summary>
110 /// Called when an object is touched/grabbed. 113 /// Fired when an object is touched/grabbed.
111 /// </summary> 114 /// </summary>
112 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of 115 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of
113 /// the root part. 116 /// the root part.
114 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
115 public event ObjectGrabDelegate OnObjectGrab; 117 public event ObjectGrabDelegate OnObjectGrab;
118 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
116 119
117 public event ObjectGrabDelegate OnObjectGrabbing; 120 public event ObjectGrabDelegate OnObjectGrabbing;
118 public event ObjectDeGrabDelegate OnObjectDeGrab; 121 public event ObjectDeGrabDelegate OnObjectDeGrab;
@@ -120,8 +123,11 @@ namespace OpenSim.Region.Framework.Scenes
120 123
121 public event OnPermissionErrorDelegate OnPermissionError; 124 public event OnPermissionErrorDelegate OnPermissionError;
122 125
123 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); 126 /// <summary>
127 /// Fired when a new script is created.
128 /// </summary>
124 public event NewRezScript OnRezScript; 129 public event NewRezScript OnRezScript;
130 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource);
125 131
126 public delegate void RemoveScript(uint localID, UUID itemID); 132 public delegate void RemoveScript(uint localID, UUID itemID);
127 public event RemoveScript OnRemoveScript; 133 public event RemoveScript OnRemoveScript;
@@ -165,36 +171,33 @@ namespace OpenSim.Region.Framework.Scenes
165 171
166 public event ClientClosed OnClientClosed; 172 public event ClientClosed OnClientClosed;
167 173
168 public delegate void ScriptChangedEvent(uint localID, uint change); 174 /// <summary>
169 175 /// This is fired when a scene object property that a script might be interested in (such as color, scale or
176 /// inventory) changes. Only enough information is sent for the LSL changed event
177 /// (see http://lslwiki.net/lslwiki/wakka.php?wakka=changed)
178 /// </summary>
170 public event ScriptChangedEvent OnScriptChangedEvent; 179 public event ScriptChangedEvent OnScriptChangedEvent;
180 public delegate void ScriptChangedEvent(uint localID, uint change);
171 181
172 public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed); 182 public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed);
173
174 public event ScriptControlEvent OnScriptControlEvent; 183 public event ScriptControlEvent OnScriptControlEvent;
175 184
176 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);
177
178 public event ScriptAtTargetEvent OnScriptAtTargetEvent; 186 public event ScriptAtTargetEvent OnScriptAtTargetEvent;
179 187
180 public delegate void ScriptNotAtTargetEvent(uint localID); 188 public delegate void ScriptNotAtTargetEvent(uint localID);
181
182 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; 189 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent;
183 190
184 public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot); 191 public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot);
185
186 public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent; 192 public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent;
187 193
188 public delegate void ScriptNotAtRotTargetEvent(uint localID); 194 public delegate void ScriptNotAtRotTargetEvent(uint localID);
189
190 public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent; 195 public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent;
191 196
192 public delegate void ScriptColliding(uint localID, ColliderArgs colliders); 197 public delegate void ScriptColliding(uint localID, ColliderArgs colliders);
193
194 public event ScriptColliding OnScriptColliderStart; 198 public event ScriptColliding OnScriptColliderStart;
195 public event ScriptColliding OnScriptColliding; 199 public event ScriptColliding OnScriptColliding;
196 public event ScriptColliding OnScriptCollidingEnd; 200 public event ScriptColliding OnScriptCollidingEnd;
197
198 public event ScriptColliding OnScriptLandColliderStart; 201 public event ScriptColliding OnScriptLandColliderStart;
199 public event ScriptColliding OnScriptLandColliding; 202 public event ScriptColliding OnScriptLandColliding;
200 public event ScriptColliding OnScriptLandColliderEnd; 203 public event ScriptColliding OnScriptLandColliderEnd;
@@ -204,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes
204 207
205 public delegate void OnMakeRootAgentDelegate(ScenePresence presence); 208 public delegate void OnMakeRootAgentDelegate(ScenePresence presence);
206 public delegate void OnSaveNewWindlightProfileDelegate(); 209 public delegate void OnSaveNewWindlightProfileDelegate();
207 public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionMeta7WindlightData wl, UUID user); 210 public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionLightShareData wl, UUID user);
208 public event OnMakeRootAgentDelegate OnMakeRootAgent; 211 public event OnMakeRootAgentDelegate OnMakeRootAgent;
209 public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted; 212 public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted;
210 public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile; 213 public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile;
@@ -587,6 +590,28 @@ namespace OpenSim.Region.Framework.Scenes
587 } 590 }
588 } 591 }
589 592
593 public void TriggerOnClientLogin(IClientAPI client)
594 {
595 OnClientLoginDelegate handlerClientLogin = OnClientLogin;
596 if (handlerClientLogin != null)
597 {
598 foreach (OnClientLoginDelegate d in handlerClientLogin.GetInvocationList())
599 {
600 try
601 {
602 d(client);
603 }
604 catch (Exception e)
605 {
606 m_log.ErrorFormat(
607 "[EVENT MANAGER]: Delegate for TriggerOnClientLogin failed - continuing. {0} {1}",
608 e.Message, e.StackTrace);
609 }
610 }
611 }
612
613 }
614
590 public void TriggerOnNewPresence(ScenePresence presence) 615 public void TriggerOnNewPresence(ScenePresence presence)
591 { 616 {
592 OnNewPresenceDelegate handlerNewPresence = OnNewPresence; 617 OnNewPresenceDelegate handlerNewPresence = OnNewPresence;
@@ -1195,7 +1220,7 @@ namespace OpenSim.Region.Framework.Scenes
1195 } 1220 }
1196 } 1221 }
1197 1222
1198 public void TriggerOnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID user) 1223 public void TriggerOnSendNewWindlightProfileTargeted(RegionLightShareData wl, UUID user)
1199 { 1224 {
1200 OnSendNewWindlightProfileTargetedDelegate handlerSendNewWindlightProfileTargeted = OnSendNewWindlightProfileTargeted; 1225 OnSendNewWindlightProfileTargetedDelegate handlerSendNewWindlightProfileTargeted = OnSendNewWindlightProfileTargeted;
1201 if (handlerSendNewWindlightProfileTargeted != null) 1226 if (handlerSendNewWindlightProfileTargeted != null)
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
deleted file mode 100644
index ec50598..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ /dev/null
@@ -1,265 +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 System.Reflection;
31using System.Threading;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Services.Interfaces;
40
41//using HyperGrid.Framework;
42//using OpenSim.Region.Communications.Hypergrid;
43
44namespace OpenSim.Region.Framework.Scenes.Hypergrid
45{
46 public class HGAssetMapper
47 {
48 #region Fields
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 // This maps between inventory server urls and inventory server clients
52// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
53
54 private Scene m_scene;
55
56 private IHyperAssetService m_hyper;
57 IHyperAssetService HyperlinkAssets
58 {
59 get
60 {
61 if (m_hyper == null)
62 m_hyper = m_scene.RequestModuleInterface<IHyperAssetService>();
63 return m_hyper;
64 }
65 }
66
67 #endregion
68
69 #region Constructor
70
71 public HGAssetMapper(Scene scene)
72 {
73 m_scene = scene;
74 }
75
76 #endregion
77
78 #region Internal functions
79
80// private string UserAssetURL(UUID userID)
81// {
82// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
83// if (uinfo != null)
84// return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI;
85// return null;
86// }
87
88// private string UserInventoryURL(UUID userID)
89// {
90// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
91// if (uinfo != null)
92// return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI;
93// return null;
94// }
95
96
97 public AssetBase FetchAsset(string url, UUID assetID)
98 {
99 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
100
101 if (asset != null)
102 {
103 m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
104 return asset;
105 }
106 return null;
107 }
108
109 public bool PostAsset(string url, AssetBase asset)
110 {
111 if (asset != null)
112 {
113 // See long comment in AssetCache.AddAsset
114 if (!asset.Temporary || asset.Local)
115 {
116 // We need to copy the asset into a new asset, because
117 // we need to set its ID to be URL+UUID, so that the
118 // HGAssetService dispatches it to the remote grid.
119 // It's not pretty, but the best that can be done while
120 // not having a global naming infrastructure
121 AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type);
122 Copy(asset, asset1);
123 try
124 {
125 asset1.ID = url + "/" + asset.ID;
126 }
127 catch
128 {
129 m_log.Warn("[HGScene]: Oops.");
130 }
131
132 m_scene.AssetService.Store(asset1);
133 m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
134 }
135 return true;
136 }
137 else
138 m_log.Warn("[HGScene]: Tried to post asset to remote server, but asset not in local cache.");
139
140 return false;
141 }
142
143 private void Copy(AssetBase from, AssetBase to)
144 {
145 to.Data = from.Data;
146 to.Description = from.Description;
147 to.FullID = from.FullID;
148 to.ID = from.ID;
149 to.Local = from.Local;
150 to.Name = from.Name;
151 to.Temporary = from.Temporary;
152 to.Type = from.Type;
153
154 }
155
156 // TODO: unused
157 // private void Dump(Dictionary<UUID, bool> lst)
158 // {
159 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
160 // foreach (KeyValuePair<UUID, bool> kvp in lst)
161 // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")");
162 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
163 // }
164
165 #endregion
166
167
168 #region Public interface
169
170 public void Get(UUID assetID, UUID ownerID)
171 {
172 // Get the item from the remote asset server onto the local AssetCache
173 // and place an entry in m_assetMap
174
175 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
176 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
177 {
178 m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL);
179 AssetBase asset = FetchAsset(userAssetURL, assetID);
180
181 if (asset != null)
182 {
183 // OK, now fetch the inside.
184 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
185 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
186 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
187 foreach (UUID uuid in ids.Keys)
188 FetchAsset(userAssetURL, uuid);
189
190 m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
191
192 }
193 else
194 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
195 }
196 else
197 m_log.Debug("[HGScene]: user's asset server is the local region's asset server");
198 }
199
200 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
201 //{
202 // InventoryClient invCli = null;
203 // string inventoryURL = UserInventoryURL(item.Owner);
204 // if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli))
205 // {
206 // m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL);
207 // invCli = new InventoryClient(inventoryURL);
208 // m_inventoryServers.Add(inventoryURL, invCli);
209 // }
210
211 // item = invCli.GetInventoryItem(item);
212 // if (item != null)
213 // {
214 // // Change the folder, stick it in root folder, all items flattened out here in this region cache
215 // item.Folder = rootFolder;
216 // //userInfo.AddItem(item); don't use this, it calls back to the inventory server
217 // lock (userInfo.RootFolder.Items)
218 // {
219 // userInfo.RootFolder.Items[item.ID] = item;
220 // }
221
222 // }
223 // return item;
224 //}
225
226 public void Post(UUID assetID, UUID ownerID)
227 {
228 // Post the item from the local AssetCache onto the remote asset server
229 // and place an entry in m_assetMap
230
231 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
232 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
233 {
234 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
235 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
236 if (asset != null)
237 {
238 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
239 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
240 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
241 foreach (UUID uuid in ids.Keys)
242 {
243 asset = m_scene.AssetService.Get(uuid.ToString());
244 if (asset == null)
245 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
246 else
247 PostAsset(userAssetURL, asset);
248 }
249
250 // maybe all pieces got there...
251 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
252
253 }
254 else
255 m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID);
256 }
257 else
258 m_log.Debug("[HGScene]: user's asset server is local region's asset server");
259
260 }
261
262 #endregion
263
264 }
265}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
deleted file mode 100644
index b1981b6..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
+++ /dev/null
@@ -1,77 +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 OpenMetaverse;
29using OpenSim.Framework;
30using OpenSim.Framework.Communications.Cache;
31using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
33
34namespace OpenSim.Region.Framework.Scenes.Hypergrid
35{
36 public partial class HGScene : Scene
37 {
38 /// <summary>
39 /// Teleport an avatar to their home region
40 /// </summary>
41 /// <param name="agentId"></param>
42 /// <param name="client"></param>
43 public override void TeleportClientHome(UUID agentId, IClientAPI client)
44 {
45 m_log.Debug("[HGScene]: TeleportClientHome " + client.FirstName + " " + client.LastName);
46
47 CachedUserInfo uinfo = CommsManager.UserProfileCacheService.GetUserDetails(agentId);
48 if (uinfo != null)
49 {
50 UserProfileData UserProfile = uinfo.UserProfile;
51
52 if (UserProfile != null)
53 {
54 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
55 //if (regionInfo != null)
56 //{
57 // UserProfile.HomeRegionID = regionInfo.RegionID;
58 // //CommsManager.UserService.UpdateUserProfile(UserProfile);
59 //}
60 if (regionInfo == null)
61 {
62 // can't find the Home region: Tell viewer and abort
63 client.SendTeleportFailed("Your home-region could not be found.");
64 return;
65 }
66 RequestTeleportLocation(
67 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
68 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
69 }
70 }
71 else
72 client.SendTeleportFailed("Sorry! I lost your home-region information.");
73
74 }
75
76 }
77}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
deleted file mode 100644
index 416826c..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ /dev/null
@@ -1,391 +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 System.Net;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Client;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Capabilities;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Services.Interfaces;
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43
44namespace OpenSim.Region.Framework.Scenes.Hypergrid
45{
46 public class HGSceneCommunicationService : SceneCommunicationService
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private IHyperlinkService m_hg;
51 IHyperlinkService HyperlinkService
52 {
53 get
54 {
55 if (m_hg == null)
56 m_hg = m_scene.RequestModuleInterface<IHyperlinkService>();
57 return m_hg;
58 }
59 }
60
61 public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
62 {
63 }
64
65
66 /// <summary>
67 /// Try to teleport an agent to a new region.
68 /// </summary>
69 /// <param name="remoteClient"></param>
70 /// <param name="RegionHandle"></param>
71 /// <param name="position"></param>
72 /// <param name="lookAt"></param>
73 /// <param name="flags"></param>
74 public override void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
75 Vector3 lookAt, uint teleportFlags)
76 {
77 if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
78 return;
79
80 bool destRegionUp = true;
81
82 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
83
84 // Reset animations; the viewer does that in teleports.
85 avatar.Animator.ResetAnimations();
86
87 if (regionHandle == m_regionInfo.RegionHandle)
88 {
89 // Teleport within the same region
90 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
91 {
92 Vector3 emergencyPos = new Vector3(128, 128, 128);
93
94 m_log.WarnFormat(
95 "[HGSceneCommService]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
96 position, avatar.Name, avatar.UUID, emergencyPos);
97 position = emergencyPos;
98 }
99 // TODO: Get proper AVG Height
100 float localAVHeight = 1.56f;
101
102 float posZLimit = 22;
103
104 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
105 {
106 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
107 }
108
109 float newPosZ = posZLimit + localAVHeight;
110 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
111 {
112 position.Z = newPosZ;
113 }
114
115 // Only send this if the event queue is null
116 if (eq == null)
117 avatar.ControllingClient.SendTeleportLocationStart();
118
119
120 avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
121 avatar.Teleport(position);
122 }
123 else
124 {
125 uint x = 0, y = 0;
126 Utils.LongToUInts(regionHandle, out x, out y);
127 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
128
129 if (reg != null)
130 {
131
132 uint newRegionX = (uint)(reg.RegionHandle >> 40);
133 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
134 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
135 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
136
137 ///
138 /// Hypergrid mod start
139 ///
140 ///
141 bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
142 bool isHomeUser = true;
143 ulong realHandle = regionHandle;
144 CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
145 if (uinfo != null)
146 {
147 isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
148 realHandle = m_hg.FindRegionHandle(regionHandle);
149 m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
150 }
151 ///
152 /// Hypergrid mod stop
153 ///
154 ///
155
156 if (eq == null)
157 avatar.ControllingClient.SendTeleportLocationStart();
158
159
160 // Let's do DNS resolution only once in this process, please!
161 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
162 // it's actually doing a lot of work.
163 IPEndPoint endPoint = reg.ExternalEndPoint;
164 if (endPoint.Address == null)
165 {
166 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
167 destRegionUp = false;
168 }
169
170 if (destRegionUp)
171 {
172 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
173 // both regions
174 if (avatar.ParentID != (uint)0)
175 avatar.StandUp();
176
177 if (!avatar.ValidateAttachments())
178 {
179 avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
180 return;
181 }
182
183 // the avatar.Close below will clear the child region list. We need this below for (possibly)
184 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
185 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
186 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
187 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
188 // once we reach here...
189 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
190
191 string capsPath = String.Empty;
192 AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
193 agentCircuit.BaseFolder = UUID.Zero;
194 agentCircuit.InventoryFolder = UUID.Zero;
195 agentCircuit.startpos = position;
196 agentCircuit.child = true;
197 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
198 {
199 // brand new agent, let's create a new caps seed
200 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
201 }
202
203 string reason = String.Empty;
204
205 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
206 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
207 {
208 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
209 reason));
210 return;
211 }
212
213 // Let's close some agents
214 if (isHyperLink) // close them all except this one
215 {
216 List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles);
217 regions.Remove(avatar.Scene.RegionInfo.RegionHandle);
218 SendCloseChildAgentConnections(avatar.UUID, regions);
219 }
220 else // close just a few
221 avatar.CloseChildAgents(newRegionX, newRegionY);
222
223 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink)
224 {
225 capsPath
226 = "http://"
227 + reg.ExternalHostName
228 + ":"
229 + reg.HttpPort
230 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
231
232 if (eq != null)
233 {
234 #region IP Translation for NAT
235 IClientIPEndpoint ipepClient;
236 if (avatar.ClientView.TryGet(out ipepClient))
237 {
238 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
239 }
240 #endregion
241
242 eq.EnableSimulator(realHandle, endPoint, avatar.UUID);
243
244 // ES makes the client send a UseCircuitCode message to the destination,
245 // which triggers a bunch of things there.
246 // So let's wait
247 Thread.Sleep(2000);
248
249 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
250 }
251 else
252 {
253 avatar.ControllingClient.InformClientOfNeighbour(realHandle, endPoint);
254 // TODO: make Event Queue disablable!
255 }
256 }
257 else
258 {
259 // child agent already there
260 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
261 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
262 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
263 }
264
265 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
266 // position, false);
267
268 //if (!m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
269 // position, false))
270 //{
271 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
272 // // We should close that agent we just created over at destination...
273 // List<ulong> lst = new List<ulong>();
274 // lst.Add(realHandle);
275 // SendCloseChildAgentAsync(avatar.UUID, lst);
276 // return;
277 //}
278
279 SetInTransit(avatar.UUID);
280 // Let's send a full update of the agent. This is a synchronous call.
281 AgentData agent = new AgentData();
282 avatar.CopyTo(agent);
283 agent.Position = position;
284 agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
285 "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
286
287 m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
288
289 m_log.DebugFormat(
290 "[CAPS]: Sending new CAPS seed url {0} to client {1}", agentCircuit.CapsPath, avatar.UUID);
291
292
293 ///
294 /// Hypergrid mod: realHandle instead of reg.RegionHandle
295 ///
296 ///
297 if (eq != null)
298 {
299 eq.TeleportFinishEvent(realHandle, 13, endPoint,
300 4, teleportFlags, capsPath, avatar.UUID);
301 }
302 else
303 {
304 avatar.ControllingClient.SendRegionTeleport(realHandle, 13, endPoint, 4,
305 teleportFlags, capsPath);
306 }
307 ///
308 /// Hypergrid mod stop
309 ///
310
311
312 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
313 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
314 // that the client contacted the destination before we send the attachments and close things here.
315 if (!WaitForCallback(avatar.UUID))
316 {
317 // Client never contacted destination. Let's restore everything back
318 avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
319
320 ResetFromTransit(avatar.UUID);
321 // Yikes! We should just have a ref to scene here.
322 avatar.Scene.InformClientOfNeighbours(avatar);
323
324 // Finally, kill the agent we just created at the destination.
325 m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
326
327 return;
328 }
329
330 // Can't go back from here
331 if (KiPrimitive != null)
332 {
333 KiPrimitive(avatar.LocalId);
334 }
335
336 avatar.MakeChildAgent();
337
338 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
339 avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
340
341
342 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
343 ///
344 /// Hypergrid mod: extra check for isHyperLink
345 ///
346 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink)
347 {
348 Thread.Sleep(5000);
349 avatar.Close();
350 CloseConnection(avatar.UUID);
351 }
352 // if (teleport success) // seems to be always success here
353 // the user may change their profile information in other region,
354 // so the userinfo in UserProfileCache is not reliable any more, delete it
355 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID) || isHyperLink)
356 {
357 m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
358 m_log.DebugFormat(
359 "[HGSceneCommService]: User {0} is going to another region, profile cache removed",
360 avatar.UUID);
361 }
362 }
363 else
364 {
365 avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
366 }
367 }
368 else
369 {
370 // TP to a place that doesn't exist (anymore)
371 // Inform the viewer about that
372 avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
373
374 // and set the map-tile to '(Offline)'
375 uint regX, regY;
376 Utils.LongToUInts(regionHandle, out regX, out regY);
377
378 MapBlockData block = new MapBlockData();
379 block.X = (ushort)(regX / Constants.RegionSize);
380 block.Y = (ushort)(regY / Constants.RegionSize);
381 block.Access = 254; // == not there
382
383 List<MapBlockData> blocks = new List<MapBlockData>();
384 blocks.Add(block);
385 avatar.ControllingClient.SendMapBlock(blocks, 0);
386 }
387 }
388 }
389
390 }
391}
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
index e9660b1..d25d5dd 100644
--- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
+++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
@@ -36,8 +36,7 @@ using OpenMetaverse;
36using OpenMetaverse.StructuredData; 36using OpenMetaverse.StructuredData;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Services; 39
40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
42using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
43using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index b04871e..1875c48 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -35,7 +35,7 @@ using OpenMetaverse;
35using OpenMetaverse.Packets; 35using OpenMetaverse.Packets;
36using log4net; 36using log4net;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications.Cache; 38
39using OpenSim.Region.Framework; 39using OpenSim.Region.Framework;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes.Serialization; 41using OpenSim.Region.Framework.Scenes.Serialization;
@@ -101,12 +101,6 @@ namespace OpenSim.Region.Framework.Scenes
101 { 101 {
102 userlevel = 1; 102 userlevel = 1;
103 } 103 }
104 // TODO: remove this cruft once MasterAvatar is fully deprecated
105 //
106 if (m_regInfo.MasterAvatarAssignedUUID == AgentID)
107 {
108 userlevel = 2;
109 }
110 EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel); 104 EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel);
111 } 105 }
112 else 106 else
@@ -132,70 +126,17 @@ namespace OpenSim.Region.Framework.Scenes
132 } 126 }
133 127
134 /// <summary> 128 /// <summary>
135 /// Capability originating call to update the asset of an item in an agent's inventory
136 /// </summary>
137 /// <param name="remoteClient"></param>
138 /// <param name="itemID"></param>
139 /// <param name="data"></param>
140 /// <returns></returns>
141 public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
142 {
143 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
144 item = InventoryService.GetItem(item);
145
146 if (item != null)
147 {
148 if ((InventoryType)item.InvType == InventoryType.Notecard)
149 {
150 if (!Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId))
151 {
152 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
153 return UUID.Zero;
154 }
155
156 remoteClient.SendAgentAlertMessage("Notecard saved", false);
157 }
158 else if ((InventoryType)item.InvType == InventoryType.LSL)
159 {
160 if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
161 {
162 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
163 return UUID.Zero;
164 }
165
166 remoteClient.SendAgentAlertMessage("Script saved", false);
167 }
168
169 AssetBase asset =
170 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data);
171 item.AssetID = asset.FullID;
172 AssetService.Store(asset);
173
174 InventoryService.UpdateItem(item);
175
176 // remoteClient.SendInventoryItemCreateUpdate(item);
177 return (asset.FullID);
178 }
179 else
180 {
181 m_log.ErrorFormat(
182 "[AGENT INVENTORY]: Could not find item {0} for caps inventory update",
183 itemID);
184 }
185
186 return UUID.Zero;
187 }
188
189 /// <summary>
190 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> 129 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
191 /// </summary> 130 /// </summary>
192 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) 131 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data)
193 { 132 {
194 ScenePresence avatar; 133 ScenePresence avatar;
195 134
196 if (TryGetAvatar(avatarId, out avatar)) 135 if (TryGetScenePresence(avatarId, out avatar))
197 { 136 {
198 return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); 137 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
138 if (invAccess != null)
139 return invAccess.CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
199 } 140 }
200 else 141 else
201 { 142 {
@@ -251,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes
251 return new ArrayList(); 192 return new ArrayList();
252 } 193 }
253 194
254 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data); 195 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId);
255 AssetService.Store(asset); 196 AssetService.Store(asset);
256 197
257 if (isScriptRunning) 198 if (isScriptRunning)
@@ -289,7 +230,7 @@ namespace OpenSim.Region.Framework.Scenes
289 { 230 {
290 ScenePresence avatar; 231 ScenePresence avatar;
291 232
292 if (TryGetAvatar(avatarId, out avatar)) 233 if (TryGetScenePresence(avatarId, out avatar))
293 { 234 {
294 return CapsUpdateTaskInventoryScriptAsset( 235 return CapsUpdateTaskInventoryScriptAsset(
295 avatar.ControllingClient, itemId, primId, isScriptRunning, data); 236 avatar.ControllingClient, itemId, primId, isScriptRunning, data);
@@ -478,7 +419,11 @@ namespace OpenSim.Region.Framework.Scenes
478 itemCopy.SaleType = item.SaleType; 419 itemCopy.SaleType = item.SaleType;
479 420
480 if (InventoryService.AddItem(itemCopy)) 421 if (InventoryService.AddItem(itemCopy))
481 TransferInventoryAssets(itemCopy, senderId, recipient); 422 {
423 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
424 if (invAccess != null)
425 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
426 }
482 427
483 if (!Permissions.BypassPermissions()) 428 if (!Permissions.BypassPermissions())
484 { 429 {
@@ -500,10 +445,6 @@ namespace OpenSim.Region.Framework.Scenes
500 445
501 } 446 }
502 447
503 protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
504 {
505 }
506
507 /// <summary> 448 /// <summary>
508 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent 449 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent
509 /// folders) is given. 450 /// folders) is given.
@@ -573,7 +514,9 @@ namespace OpenSim.Region.Framework.Scenes
573 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", 514 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
574 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); 515 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
575 516
576 InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); 517 InventoryItemBase item = null;
518 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
519 item = LibraryService.LibraryRootFolder.FindItem(oldItemID);
577 520
578 if (item == null) 521 if (item == null)
579 { 522 {
@@ -627,15 +570,9 @@ namespace OpenSim.Region.Framework.Scenes
627 /// <summary> 570 /// <summary>
628 /// Create a new asset data structure. 571 /// Create a new asset data structure.
629 /// </summary> 572 /// </summary>
630 /// <param name="name"></param> 573 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, UUID creatorID)
631 /// <param name="description"></param>
632 /// <param name="invType"></param>
633 /// <param name="assetType"></param>
634 /// <param name="data"></param>
635 /// <returns></returns>
636 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data)
637 { 574 {
638 AssetBase asset = new AssetBase(UUID.Random(), name, assetType); 575 AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID.ToString());
639 asset.Description = description; 576 asset.Description = description;
640 asset.Data = (data == null) ? new byte[1] : data; 577 asset.Data = (data == null) ? new byte[1] : data;
641 578
@@ -745,13 +682,9 @@ namespace OpenSim.Region.Framework.Scenes
745 682
746 if (transactionID == UUID.Zero) 683 if (transactionID == UUID.Zero)
747 { 684 {
748 CachedUserInfo userInfo 685 ScenePresence presence;
749 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 686 if (TryGetScenePresence(remoteClient.AgentId, out presence))
750
751 if (userInfo != null)
752 { 687 {
753 ScenePresence presence;
754 TryGetAvatar(remoteClient.AgentId, out presence);
755 byte[] data = null; 688 byte[] data = null;
756 689
757 if (invType == (sbyte)InventoryType.Landmark && presence != null) 690 if (invType == (sbyte)InventoryType.Landmark && presence != null)
@@ -765,7 +698,7 @@ namespace OpenSim.Region.Framework.Scenes
765 data = Encoding.ASCII.GetBytes(strdata); 698 data = Encoding.ASCII.GetBytes(strdata);
766 } 699 }
767 700
768 AssetBase asset = CreateAsset(name, description, assetType, data); 701 AssetBase asset = CreateAsset(name, description, assetType, data, remoteClient.AgentId);
769 AssetService.Store(asset); 702 AssetService.Store(asset);
770 703
771 CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate); 704 CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate);
@@ -773,7 +706,7 @@ namespace OpenSim.Region.Framework.Scenes
773 else 706 else
774 { 707 {
775 m_log.ErrorFormat( 708 m_log.ErrorFormat(
776 "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem", 709 "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
777 remoteClient.AgentId); 710 remoteClient.AgentId);
778 } 711 }
779 } 712 }
@@ -1012,7 +945,7 @@ namespace OpenSim.Region.Framework.Scenes
1012 { 945 {
1013 ScenePresence avatar; 946 ScenePresence avatar;
1014 947
1015 if (TryGetAvatar(avatarId, out avatar)) 948 if (TryGetScenePresence(avatarId, out avatar))
1016 { 949 {
1017 return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); 950 return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId);
1018 } 951 }
@@ -1126,7 +1059,7 @@ namespace OpenSim.Region.Framework.Scenes
1126 1059
1127 ScenePresence avatar; 1060 ScenePresence avatar;
1128 1061
1129 if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) 1062 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
1130 { 1063 {
1131 destPart.GetProperties(avatar.ControllingClient); 1064 destPart.GetProperties(avatar.ControllingClient);
1132 } 1065 }
@@ -1154,7 +1087,7 @@ namespace OpenSim.Region.Framework.Scenes
1154 } 1087 }
1155 1088
1156 ScenePresence avatar = null; 1089 ScenePresence avatar = null;
1157 if (TryGetAvatar(destID, out avatar)) 1090 if (TryGetScenePresence(destID, out avatar))
1158 { 1091 {
1159 //profile.SendInventoryDecendents(avatar.ControllingClient, 1092 //profile.SendInventoryDecendents(avatar.ControllingClient,
1160 // profile.RootFolder.ID, true, false); 1093 // profile.RootFolder.ID, true, false);
@@ -1170,15 +1103,21 @@ namespace OpenSim.Region.Framework.Scenes
1170 1103
1171 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) 1104 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems)
1172 { 1105 {
1173 m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); 1106 if (folder == null)
1107 return;
1108
1109 // Fetch the folder contents
1174 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); 1110 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID);
1175 InventoryFolderBase containingFolder = new InventoryFolderBase(); 1111
1176 containingFolder.ID = folder.ID; 1112 // Fetch the folder itself to get its current version
1177 containingFolder.Owner = client.AgentId; 1113 InventoryFolderBase containingFolder = new InventoryFolderBase(folder.ID, client.AgentId);
1178 containingFolder = InventoryService.GetFolder(containingFolder); 1114 containingFolder = InventoryService.GetFolder(containingFolder);
1179 int version = containingFolder.Version;
1180 1115
1181 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); 1116 //m_log.DebugFormat("[AGENT INVENTORY]: Sending inventory folder contents ({0} nodes) for \"{1}\" to {2} {3}",
1117 // contents.Folders.Count + contents.Items.Count, containingFolder.Name, client.FirstName, client.LastName);
1118
1119 if (containingFolder != null)
1120 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, containingFolder.Version, fetchFolders, fetchItems);
1182 } 1121 }
1183 1122
1184 /// <summary> 1123 /// <summary>
@@ -1220,9 +1159,9 @@ namespace OpenSim.Region.Framework.Scenes
1220 item = InventoryService.GetItem(item); 1159 item = InventoryService.GetItem(item);
1221 1160
1222 // Try library 1161 // Try library
1223 if (null == item) 1162 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1224 { 1163 {
1225 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1164 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1226 } 1165 }
1227 1166
1228 if (item != null) 1167 if (item != null)
@@ -1289,9 +1228,9 @@ namespace OpenSim.Region.Framework.Scenes
1289 1228
1290 // Try library 1229 // Try library
1291 // XXX clumsy, possibly should be one call 1230 // XXX clumsy, possibly should be one call
1292 if (null == item) 1231 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1293 { 1232 {
1294 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1233 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1295 } 1234 }
1296 1235
1297 if (item != null) 1236 if (item != null)
@@ -1348,7 +1287,9 @@ namespace OpenSim.Region.Framework.Scenes
1348 itemBase.InvType, part.UUID, remoteClient.AgentId)) 1287 itemBase.InvType, part.UUID, remoteClient.AgentId))
1349 return; 1288 return;
1350 1289
1351 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}")); 1290 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1291 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"),
1292 remoteClient.AgentId);
1352 AssetService.Store(asset); 1293 AssetService.Store(asset);
1353 1294
1354 TaskInventoryItem taskItem = new TaskInventoryItem(); 1295 TaskInventoryItem taskItem = new TaskInventoryItem();
@@ -1483,7 +1424,7 @@ namespace OpenSim.Region.Framework.Scenes
1483 1424
1484 ScenePresence avatar; 1425 ScenePresence avatar;
1485 1426
1486 if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) 1427 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
1487 { 1428 {
1488 destPart.GetProperties(avatar.ControllingClient); 1429 destPart.GetProperties(avatar.ControllingClient);
1489 } 1430 }
@@ -1617,237 +1558,6 @@ namespace OpenSim.Region.Framework.Scenes
1617 } 1558 }
1618 } 1559 }
1619 1560
1620 /// <summary>
1621 /// Delete a scene object from a scene and place in the given avatar's inventory.
1622 /// Returns the UUID of the newly created asset.
1623 /// </summary>
1624 /// <param name="action"></param>
1625 /// <param name="folderID"></param>
1626 /// <param name="objectGroup"></param>
1627 /// <param name="remoteClient"> </param>
1628 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
1629 SceneObjectGroup objectGroup, IClientAPI remoteClient)
1630 {
1631 UUID assetID = UUID.Zero;
1632
1633 Vector3 inventoryStoredPosition = new Vector3
1634 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1635 ? 250
1636 : objectGroup.AbsolutePosition.X)
1637 ,
1638 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1639 ? 250
1640 : objectGroup.AbsolutePosition.X,
1641 objectGroup.AbsolutePosition.Z);
1642
1643 Vector3 originalPosition = objectGroup.AbsolutePosition;
1644
1645 objectGroup.AbsolutePosition = inventoryStoredPosition;
1646
1647 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
1648
1649 objectGroup.AbsolutePosition = originalPosition;
1650
1651 // Get the user info of the item destination
1652 //
1653 UUID userID = UUID.Zero;
1654
1655 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
1656 action == DeRezAction.SaveToExistingUserInventoryItem)
1657 {
1658 // Take or take copy require a taker
1659 // Saving changes requires a local user
1660 //
1661 if (remoteClient == null)
1662 return UUID.Zero;
1663
1664 userID = remoteClient.AgentId;
1665 }
1666 else
1667 {
1668 // All returns / deletes go to the object owner
1669 //
1670
1671 userID = objectGroup.RootPart.OwnerID;
1672 }
1673
1674 if (userID == UUID.Zero) // Can't proceed
1675 {
1676 return UUID.Zero;
1677 }
1678
1679 // If we're returning someone's item, it goes back to the
1680 // owner's Lost And Found folder.
1681 // Delete is treated like return in this case
1682 // Deleting your own items makes them go to trash
1683 //
1684
1685 InventoryFolderBase folder = null;
1686 InventoryItemBase item = null;
1687
1688 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1689 {
1690 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID);
1691 item = InventoryService.GetItem(item);
1692
1693 //item = userInfo.RootFolder.FindItem(
1694 // objectGroup.RootPart.FromUserInventoryItemID);
1695
1696 if (null == item)
1697 {
1698 m_log.DebugFormat(
1699 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
1700 objectGroup.Name, objectGroup.UUID);
1701 return UUID.Zero;
1702 }
1703 }
1704 else
1705 {
1706 // Folder magic
1707 //
1708 if (action == DeRezAction.Delete)
1709 {
1710 // Deleting someone else's item
1711 //
1712
1713
1714 if (remoteClient == null ||
1715 objectGroup.OwnerID != remoteClient.AgentId)
1716 {
1717 // Folder skeleton may not be loaded and we
1718 // have to wait for the inventory to find
1719 // the destination folder
1720 //
1721 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1722 }
1723 else
1724 {
1725 // Assume inventory skeleton was loaded during login
1726 // and all folders can be found
1727 //
1728 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1729 }
1730 }
1731 else if (action == DeRezAction.Return)
1732 {
1733
1734 // Dump to lost + found unconditionally
1735 //
1736 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1737 }
1738
1739 if (folderID == UUID.Zero && folder == null)
1740 {
1741 if (action == DeRezAction.Delete)
1742 {
1743 // Deletes go to trash by default
1744 //
1745 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1746 }
1747 else
1748 {
1749 // Catch all. Use lost & found
1750 //
1751
1752 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1753 }
1754 }
1755
1756 if (folder == null) // None of the above
1757 {
1758 //folder = userInfo.RootFolder.FindFolder(folderID);
1759 folder = new InventoryFolderBase(folderID);
1760
1761 if (folder == null) // Nowhere to put it
1762 {
1763 return UUID.Zero;
1764 }
1765 }
1766
1767 item = new InventoryItemBase();
1768 item.CreatorId = objectGroup.RootPart.CreatorID.ToString();
1769 item.ID = UUID.Random();
1770 item.InvType = (int)InventoryType.Object;
1771 item.Folder = folder.ID;
1772 item.Owner = userID;
1773 }
1774
1775 AssetBase asset = CreateAsset(
1776 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
1777 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
1778 (sbyte)AssetType.Object,
1779 Utils.StringToBytes(sceneObjectXml));
1780 AssetService.Store(asset);
1781 assetID = asset.FullID;
1782
1783 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1784 {
1785 item.AssetID = asset.FullID;
1786 InventoryService.UpdateItem(item);
1787 }
1788 else
1789 {
1790 item.AssetID = asset.FullID;
1791
1792 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions())
1793 {
1794 uint perms=objectGroup.GetEffectivePermissions();
1795 uint nextPerms=(perms & 7) << 13;
1796 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
1797 perms &= ~(uint)PermissionMask.Copy;
1798 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
1799 perms &= ~(uint)PermissionMask.Transfer;
1800 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
1801 perms &= ~(uint)PermissionMask.Modify;
1802
1803 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
1804 item.CurrentPermissions = item.BasePermissions;
1805 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1806 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
1807 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
1808 item.CurrentPermissions |= 8; // Slam!
1809 }
1810 else
1811 {
1812 uint ownerPerms = objectGroup.GetEffectivePermissions();
1813 if ((objectGroup.RootPart.OwnerMask & (uint)PermissionMask.Modify) != 0)
1814 ownerPerms |= (uint)PermissionMask.Modify;
1815
1816 item.BasePermissions = ownerPerms;
1817 item.CurrentPermissions = ownerPerms;
1818
1819 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1820 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1821 item.GroupPermissions = objectGroup.RootPart.GroupMask;
1822
1823 item.CurrentPermissions |= 8; // Slam!
1824 }
1825
1826 // TODO: add the new fields (Flags, Sale info, etc)
1827 item.CreationDate = Util.UnixTimeSinceEpoch();
1828 item.Description = asset.Description;
1829 item.Name = asset.Name;
1830 item.AssetType = asset.Type;
1831
1832 InventoryService.AddItem(item);
1833
1834 if (remoteClient != null && item.Owner == remoteClient.AgentId)
1835 {
1836 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1837 }
1838 else
1839 {
1840 ScenePresence notifyUser = GetScenePresence(item.Owner);
1841 if (notifyUser != null)
1842 {
1843 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
1844 }
1845 }
1846 }
1847
1848 return assetID;
1849 }
1850
1851 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) 1561 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
1852 { 1562 {
1853 SceneObjectGroup objectGroup = grp; 1563 SceneObjectGroup objectGroup = grp;
@@ -1874,7 +1584,8 @@ namespace OpenSim.Region.Framework.Scenes
1874 objectGroup.GetPartName(objectGroup.LocalId), 1584 objectGroup.GetPartName(objectGroup.LocalId),
1875 objectGroup.GetPartDescription(objectGroup.LocalId), 1585 objectGroup.GetPartDescription(objectGroup.LocalId),
1876 (sbyte)AssetType.Object, 1586 (sbyte)AssetType.Object,
1877 Utils.StringToBytes(sceneObjectXml)); 1587 Utils.StringToBytes(sceneObjectXml),
1588 remoteClient.AgentId);
1878 AssetService.Store(asset); 1589 AssetService.Store(asset);
1879 1590
1880 item.AssetID = asset.FullID; 1591 item.AssetID = asset.FullID;
@@ -1921,7 +1632,8 @@ namespace OpenSim.Region.Framework.Scenes
1921 grp.GetPartName(grp.LocalId), 1632 grp.GetPartName(grp.LocalId),
1922 grp.GetPartDescription(grp.LocalId), 1633 grp.GetPartDescription(grp.LocalId),
1923 (sbyte)AssetType.Object, 1634 (sbyte)AssetType.Object,
1924 Utils.StringToBytes(sceneObjectXml)); 1635 Utils.StringToBytes(sceneObjectXml),
1636 remoteClient.AgentId);
1925 AssetService.Store(asset); 1637 AssetService.Store(asset);
1926 1638
1927 InventoryItemBase item = new InventoryItemBase(); 1639 InventoryItemBase item = new InventoryItemBase();
@@ -1988,225 +1700,11 @@ namespace OpenSim.Region.Framework.Scenes
1988 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 1700 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1989 bool RezSelected, bool RemoveItem, UUID fromTaskID) 1701 bool RezSelected, bool RemoveItem, UUID fromTaskID)
1990 { 1702 {
1991 RezObject( 1703 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
1992 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 1704 if (invAccess != null)
1993 RezSelected, RemoveItem, fromTaskID, false); 1705 invAccess.RezObject(
1994 } 1706 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
1995 1707 RezSelected, RemoveItem, fromTaskID, false);
1996 /// <summary>
1997 /// Rez an object into the scene from the user's inventory
1998 /// </summary>
1999 /// <param name="remoteClient"></param>
2000 /// <param name="itemID"></param>
2001 /// <param name="RayEnd"></param>
2002 /// <param name="RayStart"></param>
2003 /// <param name="RayTargetID"></param>
2004 /// <param name="BypassRayCast"></param>
2005 /// <param name="RayEndIsIntersection"></param>
2006 /// <param name="RezSelected"></param>
2007 /// <param name="RemoveItem"></param>
2008 /// <param name="fromTaskID"></param>
2009 /// <param name="attachment"></param>
2010 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns>
2011 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
2012 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
2013 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
2014 {
2015 // Work out position details
2016 byte bRayEndIsIntersection = (byte)0;
2017
2018 if (RayEndIsIntersection)
2019 {
2020 bRayEndIsIntersection = (byte)1;
2021 }
2022 else
2023 {
2024 bRayEndIsIntersection = (byte)0;
2025 }
2026
2027 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f);
2028
2029
2030 Vector3 pos = GetNewRezLocation(
2031 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2032 BypassRayCast, bRayEndIsIntersection,true,scale, false);
2033
2034 // Rez object
2035 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2036 item = InventoryService.GetItem(item);
2037
2038 if (item != null)
2039 {
2040 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString());
2041
2042 if (rezAsset != null)
2043 {
2044 UUID itemId = UUID.Zero;
2045
2046 // If we have permission to copy then link the rezzed object back to the user inventory
2047 // item that it came from. This allows us to enable 'save object to inventory'
2048 if (!Permissions.BypassPermissions())
2049 {
2050 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
2051 {
2052 itemId = item.ID;
2053 }
2054 }
2055 else
2056 {
2057 // Brave new fullperm world
2058 //
2059 itemId = item.ID;
2060 }
2061
2062 string xmlData = Utils.BytesToString(rezAsset.Data);
2063 SceneObjectGroup group
2064 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData);
2065
2066 if (!Permissions.CanRezObject(
2067 group.Children.Count, remoteClient.AgentId, pos)
2068 && !attachment)
2069 {
2070 // The client operates in no fail mode. It will
2071 // have already removed the item from the folder
2072 // if it's no copy.
2073 // Put it back if it's not an attachment
2074 //
2075 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
2076 remoteClient.SendBulkUpdateInventory(item);
2077 return null;
2078 }
2079
2080 group.ResetIDs();
2081
2082 if (attachment)
2083 {
2084 group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
2085 group.RootPart.IsAttachment = true;
2086 }
2087
2088 AddNewSceneObject(group, true);
2089
2090 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
2091 // if attachment we set it's asset id so object updates can reflect that
2092 // if not, we set it's position in world.
2093 if (!attachment)
2094 {
2095 float offsetHeight = 0;
2096 pos = GetNewRezLocation(
2097 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2098 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
2099 pos.Z += offsetHeight;
2100 group.AbsolutePosition = pos;
2101 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
2102
2103 }
2104 else
2105 {
2106 group.SetFromItemID(itemID);
2107 }
2108
2109 SceneObjectPart rootPart = null;
2110 try
2111 {
2112 rootPart = group.GetChildPart(group.UUID);
2113 }
2114 catch (NullReferenceException)
2115 {
2116 string isAttachment = "";
2117
2118 if (attachment)
2119 isAttachment = " Object was an attachment";
2120
2121 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
2122 }
2123
2124 // Since renaming the item in the inventory does not affect the name stored
2125 // in the serialization, transfer the correct name from the inventory to the
2126 // object itself before we rez.
2127 rootPart.Name = item.Name;
2128 rootPart.Description = item.Description;
2129
2130 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
2131
2132 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
2133 if (rootPart.OwnerID != item.Owner)
2134 {
2135 //Need to kill the for sale here
2136 rootPart.ObjectSaleType = 0;
2137 rootPart.SalePrice = 10;
2138
2139 if (Permissions.PropagatePermissions())
2140 {
2141 if ((item.CurrentPermissions & 8) != 0)
2142 {
2143 foreach (SceneObjectPart part in partList)
2144 {
2145 part.EveryoneMask = item.EveryOnePermissions;
2146 part.NextOwnerMask = item.NextPermissions;
2147 part.GroupMask = 0; // DO NOT propagate here
2148 }
2149 }
2150 group.ApplyNextOwnerPermissions();
2151 }
2152 }
2153
2154 foreach (SceneObjectPart part in partList)
2155 {
2156 if (part.OwnerID != item.Owner)
2157 {
2158 part.LastOwnerID = part.OwnerID;
2159 part.OwnerID = item.Owner;
2160 part.Inventory.ChangeInventoryOwner(item.Owner);
2161 }
2162 else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
2163 {
2164 part.EveryoneMask = item.EveryOnePermissions;
2165 part.NextOwnerMask = item.NextPermissions;
2166
2167 part.GroupMask = 0; // DO NOT propagate here
2168 }
2169 }
2170
2171 rootPart.TrimPermissions();
2172
2173 if (!attachment)
2174 {
2175 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
2176 {
2177 group.ClearPartAttachmentData();
2178 }
2179 }
2180
2181 if (!attachment)
2182 {
2183 // Fire on_rez
2184 group.CreateScriptInstances(0, true, DefaultScriptEngine, 0);
2185
2186 rootPart.ScheduleFullUpdate();
2187 }
2188
2189 if (!Permissions.BypassPermissions())
2190 {
2191 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
2192 {
2193 // If this is done on attachments, no
2194 // copy ones will be lost, so avoid it
2195 //
2196 if (!attachment)
2197 {
2198 List<UUID> uuids = new List<UUID>();
2199 uuids.Add(item.ID);
2200 InventoryService.DeleteItems(item.Owner, uuids);
2201 }
2202 }
2203 }
2204
2205 return rootPart.ParentGroup;
2206 }
2207 }
2208
2209 return null;
2210 } 1708 }
2211 1709
2212 /// <summary> 1710 /// <summary>
@@ -2349,122 +1847,12 @@ namespace OpenSim.Region.Framework.Scenes
2349 EventManager.TriggerOnAttach(localID, itemID, avatarID); 1847 EventManager.TriggerOnAttach(localID, itemID, avatarID);
2350 } 1848 }
2351 1849
2352 /// <summary>
2353 /// Called when the client receives a request to rez a single attachment on to the avatar from inventory
2354 /// (RezSingleAttachmentFromInv packet).
2355 /// </summary>
2356 /// <param name="remoteClient"></param>
2357 /// <param name="itemID"></param>
2358 /// <param name="AttachmentPt"></param>
2359 /// <returns></returns>
2360 public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
2361 {
2362 m_log.DebugFormat("[USER INVENTORY]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name);
2363
2364 SceneObjectGroup att = m_sceneGraph.RezSingleAttachment(remoteClient, itemID, AttachmentPt);
2365
2366 if (att == null)
2367 {
2368 DetachSingleAttachmentToInv(itemID, remoteClient);
2369 return UUID.Zero;
2370 }
2371
2372 return RezSingleAttachment(att, remoteClient, itemID, AttachmentPt);
2373 }
2374
2375 /// <summary>
2376 /// Update the user inventory to reflect an attachment
2377 /// </summary>
2378 /// <param name="att"></param>
2379 /// <param name="remoteClient"></param>
2380 /// <param name="itemID"></param>
2381 /// <param name="AttachmentPt"></param>
2382 /// <returns></returns>
2383 public UUID RezSingleAttachment(SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
2384 {
2385 m_log.DebugFormat(
2386 "[USER INVENTORY]: Updating inventory of {0} to show attachment of {1} (item ID {2})",
2387 remoteClient.Name, att.Name, itemID);
2388
2389 if (!att.IsDeleted)
2390 AttachmentPt = att.RootPart.AttachmentPoint;
2391
2392 ScenePresence presence;
2393 if (TryGetAvatar(remoteClient.AgentId, out presence))
2394 {
2395 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2396 item = InventoryService.GetItem(item);
2397
2398 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
2399 }
2400 return att.UUID;
2401 }
2402
2403 public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, 1850 public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
2404 RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects) 1851 RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects)
2405 { 1852 {
2406 foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects) 1853 foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
2407 { 1854 {
2408 RezSingleAttachment(remoteClient, obj.ItemID, obj.AttachmentPt); 1855 AttachmentsModule.RezSingleAttachmentFromInventory(remoteClient, obj.ItemID, obj.AttachmentPt);
2409 }
2410 }
2411
2412 /// <summary>
2413 /// Attach an object.
2414 /// </summary>
2415 /// <param name="controllingClient"></param>
2416 /// <param name="localID"></param>
2417 /// <param name="attachPoint"></param>
2418 /// <param name="rot"></param>
2419 /// <param name="pos"></param>
2420 /// <param name="silent"></param>
2421 /// <returns>true if the object was successfully attached, false otherwise</returns>
2422 public bool AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, Quaternion rot, Vector3 pos, bool silent)
2423 {
2424 return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent);
2425 }
2426
2427 /// <summary>
2428 /// This registers the item as attached in a user's inventory
2429 /// </summary>
2430 /// <param name="remoteClient"></param>
2431 /// <param name="AttachmentPt"></param>
2432 /// <param name="itemID"></param>
2433 /// <param name="att"></param>
2434 public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
2435 {
2436// m_log.DebugFormat(
2437// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
2438// att.Name, remoteClient.Name, AttachmentPt, itemID);
2439
2440 if (UUID.Zero == itemID)
2441 {
2442 m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID.");
2443 return;
2444 }
2445
2446 if (0 == AttachmentPt)
2447 {
2448 m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error attachment point.");
2449 return;
2450 }
2451
2452 if (null == att.RootPart)
2453 {
2454 m_log.Error("[SCENE INVENTORY]: Unable to save attachment for a prim without the rootpart!");
2455 return;
2456 }
2457
2458 ScenePresence presence;
2459 if (TryGetAvatar(remoteClient.AgentId, out presence))
2460 {
2461 // XXYY!!
2462 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2463 item = InventoryService.GetItem(item);
2464 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
2465
2466 if (m_AvatarFactory != null)
2467 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
2468 } 1856 }
2469 } 1857 }
2470 1858
@@ -2477,7 +1865,7 @@ namespace OpenSim.Region.Framework.Scenes
2477 UUID inventoryID = part.ParentGroup.GetFromItemID(); 1865 UUID inventoryID = part.ParentGroup.GetFromItemID();
2478 1866
2479 ScenePresence presence; 1867 ScenePresence presence;
2480 if (TryGetAvatar(remoteClient.AgentId, out presence)) 1868 if (TryGetScenePresence(remoteClient.AgentId, out presence))
2481 { 1869 {
2482 if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) 1870 if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
2483 return; 1871 return;
@@ -2498,24 +1886,6 @@ namespace OpenSim.Region.Framework.Scenes
2498 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); 1886 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero);
2499 } 1887 }
2500 1888
2501 public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
2502 {
2503 ScenePresence presence;
2504 if (TryGetAvatar(remoteClient.AgentId, out presence))
2505 {
2506 presence.Appearance.DetachAttachment(itemID);
2507
2508 // Save avatar attachment information
2509 if (m_AvatarFactory != null)
2510 {
2511 m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID);
2512 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
2513 }
2514 }
2515
2516 m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient);
2517 }
2518
2519 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 1889 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
2520 { 1890 {
2521 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); 1891 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index ac04dc7..bc10230 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -32,7 +32,7 @@ using OpenMetaverse;
32using OpenMetaverse.Packets; 32using OpenMetaverse.Packets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Services.Interfaces;
36 36
37namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
38{ 38{
@@ -371,14 +371,16 @@ namespace OpenSim.Region.Framework.Scenes
371 { 371 {
372 //EventManager.TriggerAvatarPickerRequest(); 372 //EventManager.TriggerAvatarPickerRequest();
373 373
374 List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>(); 374 List<UserAccount> accounts = UserAccountService.GetUserAccounts(RegionInfo.ScopeID, query);
375 AvatarResponses = m_sceneGridService.GenerateAgentPickerRequestResponse(RequestID, query); 375
376 if (accounts == null)
377 return;
376 378
377 AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); 379 AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
378 // TODO: don't create new blocks if recycling an old packet 380 // TODO: don't create new blocks if recycling an old packet
379 381
380 AvatarPickerReplyPacket.DataBlock[] searchData = 382 AvatarPickerReplyPacket.DataBlock[] searchData =
381 new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; 383 new AvatarPickerReplyPacket.DataBlock[accounts.Count];
382 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); 384 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
383 385
384 agentData.AgentID = avatarID; 386 agentData.AgentID = avatarID;
@@ -387,16 +389,16 @@ namespace OpenSim.Region.Framework.Scenes
387 //byte[] bytes = new byte[AvatarResponses.Count*32]; 389 //byte[] bytes = new byte[AvatarResponses.Count*32];
388 390
389 int i = 0; 391 int i = 0;
390 foreach (AvatarPickerAvatar item in AvatarResponses) 392 foreach (UserAccount item in accounts)
391 { 393 {
392 UUID translatedIDtem = item.AvatarID; 394 UUID translatedIDtem = item.PrincipalID;
393 searchData[i] = new AvatarPickerReplyPacket.DataBlock(); 395 searchData[i] = new AvatarPickerReplyPacket.DataBlock();
394 searchData[i].AvatarID = translatedIDtem; 396 searchData[i].AvatarID = translatedIDtem;
395 searchData[i].FirstName = Utils.StringToBytes((string) item.firstName); 397 searchData[i].FirstName = Utils.StringToBytes((string) item.FirstName);
396 searchData[i].LastName = Utils.StringToBytes((string) item.lastName); 398 searchData[i].LastName = Utils.StringToBytes((string) item.LastName);
397 i++; 399 i++;
398 } 400 }
399 if (AvatarResponses.Count == 0) 401 if (accounts.Count == 0)
400 { 402 {
401 searchData = new AvatarPickerReplyPacket.DataBlock[0]; 403 searchData = new AvatarPickerReplyPacket.DataBlock[0];
402 } 404 }
@@ -455,7 +457,24 @@ namespace OpenSim.Region.Framework.Scenes
455 } 457 }
456 ); 458 );
457 } 459 }
458 460
461 public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client)
462 {
463 if (LibraryService != null && (LibraryService.LibraryRootFolder.Owner == uuid))
464 {
465 remote_client.SendNameReply(uuid, "Mr", "OpenSim");
466 }
467 else
468 {
469 string[] names = GetUserNames(uuid);
470 if (names.Length == 2)
471 {
472 remote_client.SendNameReply(uuid, names[0], names[1]);
473 }
474
475 }
476 }
477
459 /// <summary> 478 /// <summary>
460 /// Handle a fetch inventory request from the client 479 /// Handle a fetch inventory request from the client
461 /// </summary> 480 /// </summary>
@@ -464,7 +483,7 @@ namespace OpenSim.Region.Framework.Scenes
464 /// <param name="ownerID"></param> 483 /// <param name="ownerID"></param>
465 public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) 484 public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
466 { 485 {
467 if (ownerID == CommsManager.UserProfileCacheService.LibraryRoot.Owner) 486 if (LibraryService != null && LibraryService.LibraryRootFolder != null && ownerID == LibraryService.LibraryRootFolder.Owner)
468 { 487 {
469 //m_log.Debug("request info for library item"); 488 //m_log.Debug("request info for library item");
470 return; 489 return;
@@ -498,13 +517,14 @@ namespace OpenSim.Region.Framework.Scenes
498 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. 517 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
499 // can be handled transparently). 518 // can be handled transparently).
500 InventoryFolderImpl fold = null; 519 InventoryFolderImpl fold = null;
501 if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) 520 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
502 { 521 if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
503 remoteClient.SendInventoryFolderDetails( 522 {
504 fold.Owner, folderID, fold.RequestListOfItems(), 523 remoteClient.SendInventoryFolderDetails(
505 fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); 524 fold.Owner, folderID, fold.RequestListOfItems(),
506 return; 525 fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems);
507 } 526 return;
527 }
508 528
509 // We're going to send the reply async, because there may be 529 // We're going to send the reply async, because there may be
510 // an enormous quantity of packets -- basically the entire inventory! 530 // an enormous quantity of packets -- basically the entire inventory!
@@ -552,15 +572,16 @@ namespace OpenSim.Region.Framework.Scenes
552 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. 572 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
553 // can be handled transparently). 573 // can be handled transparently).
554 InventoryFolderImpl fold; 574 InventoryFolderImpl fold;
555 if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) 575 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
556 { 576 if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
557 version = 0; 577 {
558 InventoryCollection ret = new InventoryCollection(); 578 version = 0;
559 ret.Folders = new List<InventoryFolderBase>(); 579 InventoryCollection ret = new InventoryCollection();
560 ret.Items = fold.RequestListOfItems(); 580 ret.Folders = new List<InventoryFolderBase>();
581 ret.Items = fold.RequestListOfItems();
561 582
562 return ret; 583 return ret;
563 } 584 }
564 585
565 InventoryCollection contents = new InventoryCollection(); 586 InventoryCollection contents = new InventoryCollection();
566 587
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index fec8aa7..e4daa0b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics;
30using System.Drawing; 31using System.Drawing;
31using System.Drawing.Imaging; 32using System.Drawing.Imaging;
32using System.IO; 33using System.IO;
@@ -41,8 +42,7 @@ using OpenMetaverse.Imaging;
41using OpenSim.Framework; 42using OpenSim.Framework;
42using OpenSim.Services.Interfaces; 43using OpenSim.Services.Interfaces;
43using OpenSim.Framework.Communications; 44using OpenSim.Framework.Communications;
44using OpenSim.Framework.Communications.Cache; 45
45using OpenSim.Framework.Communications.Clients;
46using OpenSim.Framework.Console; 46using OpenSim.Framework.Console;
47using OpenSim.Region.Framework.Interfaces; 47using OpenSim.Region.Framework.Interfaces;
48using OpenSim.Region.Framework.Scenes.Scripting; 48using OpenSim.Region.Framework.Scenes.Scripting;
@@ -131,7 +131,6 @@ namespace OpenSim.Region.Framework.Scenes
131 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 131 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
132 private int m_incrementsof15seconds; 132 private int m_incrementsof15seconds;
133 private volatile bool m_backingup; 133 private volatile bool m_backingup;
134 private bool m_useAsyncWhenPossible;
135 134
136 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 135 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
137 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); 136 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>();
@@ -141,7 +140,6 @@ namespace OpenSim.Region.Framework.Scenes
141 protected ModuleLoader m_moduleLoader; 140 protected ModuleLoader m_moduleLoader;
142 protected StorageManager m_storageManager; 141 protected StorageManager m_storageManager;
143 protected AgentCircuitManager m_authenticateHandler; 142 protected AgentCircuitManager m_authenticateHandler;
144 public CommunicationsManager CommsManager;
145 143
146 protected SceneCommunicationService m_sceneGridService; 144 protected SceneCommunicationService m_sceneGridService;
147 public bool LoginsDisabled = true; 145 public bool LoginsDisabled = true;
@@ -189,11 +187,11 @@ namespace OpenSim.Region.Framework.Scenes
189 { 187 {
190 m_AuthorizationService = RequestModuleInterface<IAuthorizationService>(); 188 m_AuthorizationService = RequestModuleInterface<IAuthorizationService>();
191 189
192 if (m_AuthorizationService == null) 190 //if (m_AuthorizationService == null)
193 { 191 //{
194 // don't throw an exception if no authorization service is set for the time being 192 // // don't throw an exception if no authorization service is set for the time being
195 m_log.InfoFormat("[SCENE]: No Authorization service is configured"); 193 // m_log.InfoFormat("[SCENE]: No Authorization service is configured");
196 } 194 //}
197 } 195 }
198 196
199 return m_AuthorizationService; 197 return m_AuthorizationService;
@@ -240,8 +238,76 @@ namespace OpenSim.Region.Framework.Scenes
240 } 238 }
241 } 239 }
242 240
241 protected ILibraryService m_LibraryService;
242
243 public ILibraryService LibraryService
244 {
245 get
246 {
247 if (m_LibraryService == null)
248 m_LibraryService = RequestModuleInterface<ILibraryService>();
249
250 return m_LibraryService;
251 }
252 }
253
254 protected ISimulationService m_simulationService;
255 public ISimulationService SimulationService
256 {
257 get
258 {
259 if (m_simulationService == null)
260 m_simulationService = RequestModuleInterface<ISimulationService>();
261 return m_simulationService;
262 }
263 }
264
265 protected IAuthenticationService m_AuthenticationService;
266 public IAuthenticationService AuthenticationService
267 {
268 get
269 {
270 if (m_AuthenticationService == null)
271 m_AuthenticationService = RequestModuleInterface<IAuthenticationService>();
272 return m_AuthenticationService;
273 }
274 }
275
276 protected IPresenceService m_PresenceService;
277 public IPresenceService PresenceService
278 {
279 get
280 {
281 if (m_PresenceService == null)
282 m_PresenceService = RequestModuleInterface<IPresenceService>();
283 return m_PresenceService;
284 }
285 }
286 protected IUserAccountService m_UserAccountService;
287 public IUserAccountService UserAccountService
288 {
289 get
290 {
291 if (m_UserAccountService == null)
292 m_UserAccountService = RequestModuleInterface<IUserAccountService>();
293 return m_UserAccountService;
294 }
295 }
296
297 protected OpenSim.Services.Interfaces.IAvatarService m_AvatarService;
298 public OpenSim.Services.Interfaces.IAvatarService AvatarService
299 {
300 get
301 {
302 if (m_AvatarService == null)
303 m_AvatarService = RequestModuleInterface<IAvatarService>();
304 return m_AvatarService;
305 }
306 }
307
243 protected IXMLRPC m_xmlrpcModule; 308 protected IXMLRPC m_xmlrpcModule;
244 protected IWorldComm m_worldCommModule; 309 protected IWorldComm m_worldCommModule;
310 public IAttachmentsModule AttachmentsModule { get; set; }
245 protected IAvatarFactory m_AvatarFactory; 311 protected IAvatarFactory m_AvatarFactory;
246 public IAvatarFactory AvatarFactory 312 public IAvatarFactory AvatarFactory
247 { 313 {
@@ -249,10 +315,8 @@ namespace OpenSim.Region.Framework.Scenes
249 } 315 }
250 protected IConfigSource m_config; 316 protected IConfigSource m_config;
251 protected IRegionSerialiserModule m_serialiser; 317 protected IRegionSerialiserModule m_serialiser;
252 protected IInterregionCommsOut m_interregionCommsOut;
253 protected IInterregionCommsIn m_interregionCommsIn;
254 protected IDialogModule m_dialogModule; 318 protected IDialogModule m_dialogModule;
255 protected ITeleportModule m_teleportModule; 319 protected IEntityTransferModule m_teleportModule;
256 320
257 protected ICapabilitiesModule m_capsModule; 321 protected ICapabilitiesModule m_capsModule;
258 public ICapabilitiesModule CapsModule 322 public ICapabilitiesModule CapsModule
@@ -483,7 +547,7 @@ namespace OpenSim.Region.Framework.Scenes
483 #region Constructors 547 #region Constructors
484 548
485 public Scene(RegionInfo regInfo, AgentCircuitManager authen, 549 public Scene(RegionInfo regInfo, AgentCircuitManager authen,
486 CommunicationsManager commsMan, SceneCommunicationService sceneGridService, 550 SceneCommunicationService sceneGridService,
487 StorageManager storeManager, 551 StorageManager storeManager,
488 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, 552 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
489 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) 553 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
@@ -519,7 +583,6 @@ namespace OpenSim.Region.Framework.Scenes
519 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); 583 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4);
520 m_moduleLoader = moduleLoader; 584 m_moduleLoader = moduleLoader;
521 m_authenticateHandler = authen; 585 m_authenticateHandler = authen;
522 CommsManager = commsMan;
523 m_sceneGridService = sceneGridService; 586 m_sceneGridService = sceneGridService;
524 m_storageManager = storeManager; 587 m_storageManager = storeManager;
525 m_regInfo = regInfo; 588 m_regInfo = regInfo;
@@ -543,7 +606,46 @@ namespace OpenSim.Region.Framework.Scenes
543 606
544 if (m_storageManager.EstateDataStore != null) 607 if (m_storageManager.EstateDataStore != null)
545 { 608 {
546 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); 609 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false);
610 if (m_regInfo.EstateSettings.EstateID == 0) // No record at all
611 {
612 MainConsole.Instance.Output("Your region is not part of an estate.");
613 while (true)
614 {
615 string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List<string>() {"yes", "no"});
616 if (response == "no")
617 {
618 // Create a new estate
619 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true);
620
621 m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName);
622 m_regInfo.EstateSettings.Save();
623 break;
624 }
625 else
626 {
627 response = MainConsole.Instance.CmdPrompt("Estate name to join", "None");
628 if (response == "None")
629 continue;
630
631 List<int> estateIDs = m_storageManager.EstateDataStore.GetEstates(response);
632 if (estateIDs.Count < 1)
633 {
634 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again");
635 continue;
636 }
637
638 int estateID = estateIDs[0];
639
640 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID);
641
642 if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID))
643 break;
644
645 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
646 }
647 }
648 }
547 } 649 }
548 650
549 //Bind Storage Manager functions to some land manager functions for this scene 651 //Bind Storage Manager functions to some land manager functions for this scene
@@ -592,9 +694,6 @@ namespace OpenSim.Region.Framework.Scenes
592 // 694 //
593 IConfig startupConfig = m_config.Configs["Startup"]; 695 IConfig startupConfig = m_config.Configs["Startup"];
594 696
595 // Should we try to run loops synchronously or asynchronously?
596 m_useAsyncWhenPossible = startupConfig.GetBoolean("use_async_when_possible", false);
597
598 //Animation states 697 //Animation states
599 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 698 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
600 // TODO: Change default to true once the feature is supported 699 // TODO: Change default to true once the feature is supported
@@ -778,6 +877,36 @@ namespace OpenSim.Region.Framework.Scenes
778 return m_simulatorVersion; 877 return m_simulatorVersion;
779 } 878 }
780 879
880 public string[] GetUserNames(UUID uuid)
881 {
882 string[] returnstring = new string[0];
883
884 UserAccount account = UserAccountService.GetUserAccount(RegionInfo.ScopeID, uuid);
885
886 if (account != null)
887 {
888 returnstring = new string[2];
889 returnstring[0] = account.FirstName;
890 returnstring[1] = account.LastName;
891 }
892
893 return returnstring;
894 }
895
896 public string GetUserName(UUID uuid)
897 {
898 string[] names = GetUserNames(uuid);
899 if (names.Length == 2)
900 {
901 string firstname = names[0];
902 string lastname = names[1];
903
904 return firstname + " " + lastname;
905
906 }
907 return "(hippos)";
908 }
909
781 /// <summary> 910 /// <summary>
782 /// Another region is up. 911 /// Another region is up.
783 /// 912 ///
@@ -811,7 +940,7 @@ namespace OpenSim.Region.Framework.Scenes
811 regInfo.RegionName = otherRegion.RegionName; 940 regInfo.RegionName = otherRegion.RegionName;
812 regInfo.ScopeID = otherRegion.ScopeID; 941 regInfo.ScopeID = otherRegion.ScopeID;
813 regInfo.ExternalHostName = otherRegion.ExternalHostName; 942 regInfo.ExternalHostName = otherRegion.ExternalHostName;
814 943 GridRegion r = new GridRegion(regInfo);
815 try 944 try
816 { 945 {
817 ForEachScenePresence(delegate(ScenePresence agent) 946 ForEachScenePresence(delegate(ScenePresence agent)
@@ -825,7 +954,8 @@ namespace OpenSim.Region.Framework.Scenes
825 List<ulong> old = new List<ulong>(); 954 List<ulong> old = new List<ulong>();
826 old.Add(otherRegion.RegionHandle); 955 old.Add(otherRegion.RegionHandle);
827 agent.DropOldNeighbours(old); 956 agent.DropOldNeighbours(old);
828 InformClientOfNeighbor(agent, regInfo); 957 if (m_teleportModule != null)
958 m_teleportModule.EnableChildAgent(agent, r);
829 } 959 }
830 } 960 }
831 ); 961 );
@@ -985,6 +1115,7 @@ namespace OpenSim.Region.Framework.Scenes
985 { 1115 {
986 foreach (RegionInfo region in m_regionRestartNotifyList) 1116 foreach (RegionInfo region in m_regionRestartNotifyList)
987 { 1117 {
1118 GridRegion r = new GridRegion(region);
988 try 1119 try
989 { 1120 {
990 ForEachScenePresence(delegate(ScenePresence agent) 1121 ForEachScenePresence(delegate(ScenePresence agent)
@@ -992,9 +1123,8 @@ namespace OpenSim.Region.Framework.Scenes
992 // If agent is a root agent. 1123 // If agent is a root agent.
993 if (!agent.IsChildAgent) 1124 if (!agent.IsChildAgent)
994 { 1125 {
995 //agent.ControllingClient.new 1126 if (m_teleportModule != null)
996 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 1127 m_teleportModule.EnableChildAgent(agent, r);
997 InformClientOfNeighbor(agent, region);
998 } 1128 }
999 } 1129 }
1000 ); 1130 );
@@ -1053,10 +1183,7 @@ namespace OpenSim.Region.Framework.Scenes
1053 1183
1054 public int GetInaccurateNeighborCount() 1184 public int GetInaccurateNeighborCount()
1055 { 1185 {
1056 lock (m_neighbours) 1186 return m_neighbours.Count;
1057 {
1058 return m_neighbours.Count;
1059 }
1060 } 1187 }
1061 1188
1062 // This is the method that shuts down the scene. 1189 // This is the method that shuts down the scene.
@@ -1136,12 +1263,89 @@ namespace OpenSim.Region.Framework.Scenes
1136 m_worldCommModule = RequestModuleInterface<IWorldComm>(); 1263 m_worldCommModule = RequestModuleInterface<IWorldComm>();
1137 XferManager = RequestModuleInterface<IXfer>(); 1264 XferManager = RequestModuleInterface<IXfer>();
1138 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); 1265 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>();
1266 AttachmentsModule = RequestModuleInterface<IAttachmentsModule>();
1139 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1267 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1140 m_interregionCommsOut = RequestModuleInterface<IInterregionCommsOut>();
1141 m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>();
1142 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1268 m_dialogModule = RequestModuleInterface<IDialogModule>();
1143 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1269 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1144 m_teleportModule = RequestModuleInterface<ITeleportModule>(); 1270 m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
1271
1272 // Shoving this in here for now, because we have the needed
1273 // interfaces at this point
1274 //
1275 // TODO: Find a better place for this
1276 //
1277 while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
1278 {
1279 MainConsole.Instance.Output("The current estate has no owner set.");
1280 string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test");
1281 string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User");
1282
1283 UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last);
1284
1285 if (account == null)
1286 {
1287 // Create a new account
1288 account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty);
1289 if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
1290 {
1291 account.ServiceURLs = new Dictionary<string, object>();
1292 account.ServiceURLs["HomeURI"] = string.Empty;
1293 account.ServiceURLs["GatekeeperURI"] = string.Empty;
1294 account.ServiceURLs["InventoryServerURI"] = string.Empty;
1295 account.ServiceURLs["AssetServerURI"] = string.Empty;
1296 }
1297
1298 if (UserAccountService.StoreUserAccount(account))
1299 {
1300 string password = MainConsole.Instance.PasswdPrompt("Password");
1301 string email = MainConsole.Instance.CmdPrompt("Email", "");
1302
1303 account.Email = email;
1304 UserAccountService.StoreUserAccount(account);
1305
1306 bool success = false;
1307 success = AuthenticationService.SetPassword(account.PrincipalID, password);
1308 if (!success)
1309 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
1310 first, last);
1311
1312 GridRegion home = null;
1313 if (GridService != null)
1314 {
1315 List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero);
1316 if (defaultRegions != null && defaultRegions.Count >= 1)
1317 home = defaultRegions[0];
1318
1319 if (PresenceService != null && home != null)
1320 PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1321 else
1322 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
1323 first, last);
1324
1325 }
1326 else
1327 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
1328 first, last);
1329
1330 if (InventoryService != null)
1331 success = InventoryService.CreateUserInventory(account.PrincipalID);
1332 if (!success)
1333 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
1334 first, last);
1335
1336
1337 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last);
1338
1339 m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
1340 m_regInfo.EstateSettings.Save();
1341 }
1342 }
1343 else
1344 {
1345 m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
1346 m_regInfo.EstateSettings.Save();
1347 }
1348 }
1145 } 1349 }
1146 1350
1147 #endregion 1351 #endregion
@@ -1525,7 +1729,7 @@ namespace OpenSim.Region.Framework.Scenes
1525 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 1729 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
1526 } 1730 }
1527 1731
1528 public void StoreWindlightProfile(RegionMeta7WindlightData wl) 1732 public void StoreWindlightProfile(RegionLightShareData wl)
1529 { 1733 {
1530 m_regInfo.WindlightSettings = wl; 1734 m_regInfo.WindlightSettings = wl;
1531 m_storageManager.DataStore.StoreRegionWindlightSettings(wl); 1735 m_storageManager.DataStore.StoreRegionWindlightSettings(wl);
@@ -1591,7 +1795,9 @@ namespace OpenSim.Region.Framework.Scenes
1591 GridRegion region = new GridRegion(RegionInfo); 1795 GridRegion region = new GridRegion(RegionInfo);
1592 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); 1796 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
1593 if (error != String.Empty) 1797 if (error != String.Empty)
1798 {
1594 throw new Exception(error); 1799 throw new Exception(error);
1800 }
1595 1801
1596 m_sceneGridService.SetScene(this); 1802 m_sceneGridService.SetScene(this);
1597 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1803 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
@@ -2003,7 +2209,6 @@ namespace OpenSim.Region.Framework.Scenes
2003 /// Move the given scene object into a new region depending on which region its absolute position has moved 2209 /// Move the given scene object into a new region depending on which region its absolute position has moved
2004 /// into. 2210 /// into.
2005 /// 2211 ///
2006 /// This method locates the new region handle and offsets the prim position for the new region
2007 /// </summary> 2212 /// </summary>
2008 /// <param name="attemptedPosition">the attempted out of region position of the scene object</param> 2213 /// <param name="attemptedPosition">the attempted out of region position of the scene object</param>
2009 /// <param name="grp">the scene object that we're crossing</param> 2214 /// <param name="grp">the scene object that we're crossing</param>
@@ -2045,191 +2250,8 @@ namespace OpenSim.Region.Framework.Scenes
2045 return; 2250 return;
2046 } 2251 }
2047 2252
2048 int thisx = (int)RegionInfo.RegionLocX; 2253 if (m_teleportModule != null)
2049 int thisy = (int)RegionInfo.RegionLocY; 2254 m_teleportModule.Cross(grp, attemptedPosition, silent);
2050 Vector3 EastCross = new Vector3(0.1f,0,0);
2051 Vector3 WestCross = new Vector3(-0.1f, 0, 0);
2052 Vector3 NorthCross = new Vector3(0, 0.1f, 0);
2053 Vector3 SouthCross = new Vector3(0, -0.1f, 0);
2054
2055
2056 // use this if no borders were crossed!
2057 ulong newRegionHandle
2058 = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize),
2059 (uint)((thisy) * Constants.RegionSize));
2060
2061 Vector3 pos = attemptedPosition;
2062
2063 int changeX = 1;
2064 int changeY = 1;
2065
2066 if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W))
2067 {
2068 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2069 {
2070
2071 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2072
2073 if (crossedBorderx.BorderLine.Z > 0)
2074 {
2075 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2076 changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize);
2077 }
2078 else
2079 pos.X = ((pos.X + Constants.RegionSize));
2080
2081 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2082 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2083
2084 if (crossedBordery.BorderLine.Z > 0)
2085 {
2086 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2087 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2088 }
2089 else
2090 pos.Y = ((pos.Y + Constants.RegionSize));
2091
2092
2093
2094 newRegionHandle
2095 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2096 (uint)((thisy - changeY) * Constants.RegionSize));
2097 // x - 1
2098 // y - 1
2099 }
2100 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2101 {
2102 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2103
2104 if (crossedBorderx.BorderLine.Z > 0)
2105 {
2106 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2107 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
2108 }
2109 else
2110 pos.X = ((pos.X + Constants.RegionSize));
2111
2112
2113 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2114 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2115
2116 try
2117 {
2118 if (crossedBordery.BorderLine.Z > 0)
2119 {
2120 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2121 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2122 }
2123 else
2124 pos.Y = ((pos.Y + Constants.RegionSize));
2125
2126 newRegionHandle
2127 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2128 (uint)((thisy + changeY) * Constants.RegionSize));
2129 // x - 1
2130 // y + 1
2131 }
2132 catch (Exception ex)
2133 {
2134 }
2135 }
2136 else
2137 {
2138 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2139
2140 if (crossedBorderx.BorderLine.Z > 0)
2141 {
2142 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2143 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
2144 }
2145 else
2146 pos.X = ((pos.X + Constants.RegionSize));
2147
2148 newRegionHandle
2149 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2150 (uint) (thisy*Constants.RegionSize));
2151 // x - 1
2152 }
2153 }
2154 else if (TestBorderCross(attemptedPosition + EastCross, Cardinals.E))
2155 {
2156 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2157 {
2158
2159 pos.X = ((pos.X - Constants.RegionSize));
2160 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2161 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2162
2163 if (crossedBordery.BorderLine.Z > 0)
2164 {
2165 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2166 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2167 }
2168 else
2169 pos.Y = ((pos.Y + Constants.RegionSize));
2170
2171
2172 newRegionHandle
2173 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2174 (uint)((thisy - changeY) * Constants.RegionSize));
2175 // x + 1
2176 // y - 1
2177 }
2178 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2179 {
2180 pos.X = ((pos.X - Constants.RegionSize));
2181 pos.Y = ((pos.Y - Constants.RegionSize));
2182 newRegionHandle
2183 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2184 (uint)((thisy + changeY) * Constants.RegionSize));
2185 // x + 1
2186 // y + 1
2187 }
2188 else
2189 {
2190 pos.X = ((pos.X - Constants.RegionSize));
2191 newRegionHandle
2192 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2193 (uint) (thisy*Constants.RegionSize));
2194 // x + 1
2195 }
2196 }
2197 else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2198 {
2199 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2200 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2201
2202 if (crossedBordery.BorderLine.Z > 0)
2203 {
2204 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2205 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2206 }
2207 else
2208 pos.Y = ((pos.Y + Constants.RegionSize));
2209
2210 newRegionHandle
2211 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize));
2212 // y - 1
2213 }
2214 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2215 {
2216
2217 pos.Y = ((pos.Y - Constants.RegionSize));
2218 newRegionHandle
2219 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize));
2220 // y + 1
2221 }
2222
2223 // Offset the positions for the new region across the border
2224 Vector3 oldGroupPosition = grp.RootPart.GroupPosition;
2225 grp.OffsetForNewRegion(pos);
2226
2227 // If we fail to cross the border, then reset the position of the scene object on that border.
2228 if (!CrossPrimGroupIntoNewRegion(newRegionHandle, grp, silent))
2229 {
2230 grp.OffsetForNewRegion(oldGroupPosition);
2231 grp.ScheduleGroupForFullUpdate();
2232 }
2233 } 2255 }
2234 2256
2235 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2257 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
@@ -2413,75 +2435,6 @@ namespace OpenSim.Region.Framework.Scenes
2413 2435
2414 2436
2415 /// <summary> 2437 /// <summary>
2416 /// Move the given scene object into a new region
2417 /// </summary>
2418 /// <param name="newRegionHandle"></param>
2419 /// <param name="grp">Scene Object Group that we're crossing</param>
2420 /// <returns>
2421 /// true if the crossing itself was successful, false on failure
2422 /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region
2423 /// </returns>
2424 public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp, bool silent)
2425 {
2426 //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<");
2427
2428 bool successYN = false;
2429 grp.RootPart.UpdateFlag = 0;
2430 //int primcrossingXMLmethod = 0;
2431
2432 if (newRegionHandle != 0)
2433 {
2434 //string objectState = grp.GetStateSnapshot();
2435
2436 //successYN
2437 // = m_sceneGridService.PrimCrossToNeighboringRegion(
2438 // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod);
2439 //if (successYN && (objectState != "") && m_allowScriptCrossings)
2440 //{
2441 // successYN = m_sceneGridService.PrimCrossToNeighboringRegion(
2442 // newRegionHandle, grp.UUID, objectState, 100);
2443 //}
2444
2445 // And the new channel...
2446 if (m_interregionCommsOut != null)
2447 successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true);
2448
2449 if (successYN)
2450 {
2451 // We remove the object here
2452 try
2453 {
2454 DeleteSceneObject(grp, silent);
2455 }
2456 catch (Exception e)
2457 {
2458 m_log.ErrorFormat(
2459 "[INTERREGION]: Exception deleting the old object left behind on a border crossing for {0}, {1}",
2460 grp, e);
2461 }
2462 }
2463 else
2464 {
2465 if (!grp.IsDeleted)
2466 {
2467 if (grp.RootPart.PhysActor != null)
2468 {
2469 grp.RootPart.PhysActor.CrossingFailure();
2470 }
2471 }
2472
2473 m_log.ErrorFormat("[INTERREGION]: Prim crossing failed for {0}", grp);
2474 }
2475 }
2476 else
2477 {
2478 m_log.Error("[INTERREGION]: region handle was unexpectedly 0 in Scene.CrossPrimGroupIntoNewRegion()");
2479 }
2480
2481 return successYN;
2482 }
2483
2484 /// <summary>
2485 /// Called when objects or attachments cross the border between regions. 2438 /// Called when objects or attachments cross the border between regions.
2486 /// </summary> 2439 /// </summary>
2487 /// <param name="sog"></param> 2440 /// <param name="sog"></param>
@@ -2525,10 +2478,10 @@ namespace OpenSim.Region.Framework.Scenes
2525 //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID); 2478 //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID);
2526 2479
2527 ScenePresence sp = GetScenePresence(userID); 2480 ScenePresence sp = GetScenePresence(userID);
2528 if (sp != null) 2481 if (sp != null && AttachmentsModule != null)
2529 { 2482 {
2530 uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); 2483 uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID);
2531 m_sceneGraph.RezSingleAttachment(sp.ControllingClient, itemID, attPt); 2484 AttachmentsModule.RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, attPt);
2532 } 2485 }
2533 2486
2534 return false; 2487 return false;
@@ -2553,6 +2506,9 @@ namespace OpenSim.Region.Framework.Scenes
2553 2506
2554 return false; 2507 return false;
2555 } 2508 }
2509
2510 sceneObject.SetScene(this);
2511
2556 // Force allocation of new LocalId 2512 // Force allocation of new LocalId
2557 // 2513 //
2558 foreach (SceneObjectPart p in sceneObject.Children.Values) 2514 foreach (SceneObjectPart p in sceneObject.Children.Values)
@@ -2589,9 +2545,11 @@ namespace OpenSim.Region.Framework.Scenes
2589 //grp.SetFromAssetID(grp.RootPart.LastOwnerID); 2545 //grp.SetFromAssetID(grp.RootPart.LastOwnerID);
2590 m_log.DebugFormat( 2546 m_log.DebugFormat(
2591 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2547 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2548
2549 if (AttachmentsModule != null)
2550 AttachmentsModule.AttachObject(
2551 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
2592 2552
2593 AttachObject(
2594 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
2595 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2553 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2596 grp.SendGroupFullUpdate(); 2554 grp.SendGroupFullUpdate();
2597 } 2555 }
@@ -2631,6 +2589,8 @@ namespace OpenSim.Region.Framework.Scenes
2631 /// <param name="client"></param> 2589 /// <param name="client"></param>
2632 public override void AddNewClient(IClientAPI client) 2590 public override void AddNewClient(IClientAPI client)
2633 { 2591 {
2592 bool vialogin = false;
2593
2634 m_clientManager.Add(client); 2594 m_clientManager.Add(client);
2635 2595
2636 CheckHeartbeat(); 2596 CheckHeartbeat();
@@ -2665,23 +2625,48 @@ namespace OpenSim.Region.Framework.Scenes
2665 { 2625 {
2666 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); 2626 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
2667 2627
2668 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); 2628 // Do the verification here
2669 /* 2629 System.Net.EndPoint ep = client.GetClientEP();
2670 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}", 2630 if (aCircuit != null)
2671 ((aCircuit.child == true) ? "child" : "root"), client.Name, 2631 {
2672 RegionInfo.RegionName); 2632 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
2673 2633 {
2674 m_log.Debug(logMsg); 2634 m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2675 */ 2635 vialogin = true;
2636 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2637 if (userVerification != null && ep != null)
2638 {
2639 if (!userVerification.VerifyClient(aCircuit, ep.ToString()))
2640 {
2641 // uh-oh, this is fishy
2642 m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
2643 client.AgentId, client.SessionId, ep.ToString());
2644 try
2645 {
2646 client.Close();
2647 }
2648 catch (Exception e)
2649 {
2650 m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace);
2651 }
2652 return;
2653 }
2654 else
2655 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} returned true", aCircuit.firstname, aCircuit.lastname);
2656 }
2657 }
2658 }
2676 2659
2677 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); 2660 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
2678 2661
2679 ScenePresence sp = CreateAndAddScenePresence(client); 2662 ScenePresence sp = CreateAndAddScenePresence(client);
2663 if (aCircuit != null)
2664 sp.Appearance = aCircuit.Appearance;
2680 2665
2681 // HERE!!! Do the initial attachments right here 2666 // HERE!!! Do the initial attachments right here
2682 // first agent upon login is a root agent by design. 2667 // first agent upon login is a root agent by design.
2683 // All other AddNewClient calls find aCircuit.child to be true 2668 // All other AddNewClient calls find aCircuit.child to be true
2684 if (aCircuit == null || aCircuit.child == false) 2669 if (aCircuit == null || (aCircuit != null && aCircuit.child == false))
2685 { 2670 {
2686 sp.IsChildAgent = false; 2671 sp.IsChildAgent = false;
2687 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); 2672 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
@@ -2690,6 +2675,8 @@ namespace OpenSim.Region.Framework.Scenes
2690 2675
2691 m_LastLogin = Util.EnvironmentTickCount(); 2676 m_LastLogin = Util.EnvironmentTickCount();
2692 EventManager.TriggerOnNewClient(client); 2677 EventManager.TriggerOnNewClient(client);
2678 if (vialogin)
2679 EventManager.TriggerOnClientLogin(client);
2693 } 2680 }
2694 2681
2695 2682
@@ -2795,19 +2782,22 @@ namespace OpenSim.Region.Framework.Scenes
2795 } 2782 }
2796 2783
2797 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) 2784 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client)
2798 { 2785 {
2799 client.OnRezSingleAttachmentFromInv += RezSingleAttachment; 2786 client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments;
2800 client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments;
2801 client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv;
2802 client.OnObjectAttach += m_sceneGraph.AttachObject;
2803 client.OnObjectDetach += m_sceneGraph.DetachObject; 2787 client.OnObjectDetach += m_sceneGraph.DetachObject;
2788
2789 if (AttachmentsModule != null)
2790 {
2791 client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory;
2792 client.OnObjectAttach += AttachmentsModule.AttachObject;
2793 client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory;
2794 }
2804 } 2795 }
2805 2796
2806 public virtual void SubscribeToClientTeleportEvents(IClientAPI client) 2797 public virtual void SubscribeToClientTeleportEvents(IClientAPI client)
2807 { 2798 {
2808 client.OnTeleportLocationRequest += RequestTeleportLocation; 2799 client.OnTeleportLocationRequest += RequestTeleportLocation;
2809 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 2800 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
2810 client.OnTeleportHomeRequest += TeleportClientHome;
2811 } 2801 }
2812 2802
2813 public virtual void SubscribeToClientScriptEvents(IClientAPI client) 2803 public virtual void SubscribeToClientScriptEvents(IClientAPI client)
@@ -2827,7 +2817,7 @@ namespace OpenSim.Region.Framework.Scenes
2827 2817
2828 public virtual void SubscribeToClientGridEvents(IClientAPI client) 2818 public virtual void SubscribeToClientGridEvents(IClientAPI client)
2829 { 2819 {
2830 client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; 2820 client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
2831 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; 2821 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
2832 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; 2822 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest;
2833 client.OnSetStartLocationRequest += SetHomeRezPoint; 2823 client.OnSetStartLocationRequest += SetHomeRezPoint;
@@ -2849,7 +2839,6 @@ namespace OpenSim.Region.Framework.Scenes
2849 2839
2850 protected virtual void UnsubscribeToClientEvents(IClientAPI client) 2840 protected virtual void UnsubscribeToClientEvents(IClientAPI client)
2851 { 2841 {
2852
2853 } 2842 }
2854 2843
2855 /// <summary> 2844 /// <summary>
@@ -2871,7 +2860,6 @@ namespace OpenSim.Region.Framework.Scenes
2871 2860
2872 UnSubscribeToClientNetworkEvents(client); 2861 UnSubscribeToClientNetworkEvents(client);
2873 2862
2874
2875 // EventManager.TriggerOnNewClient(client); 2863 // EventManager.TriggerOnNewClient(client);
2876 } 2864 }
2877 2865
@@ -2928,7 +2916,6 @@ namespace OpenSim.Region.Framework.Scenes
2928 client.OnRezObject -= RezObject; 2916 client.OnRezObject -= RezObject;
2929 } 2917 }
2930 2918
2931
2932 public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client) 2919 public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client)
2933 { 2920 {
2934 client.OnCreateNewInventoryItem -= CreateNewInventoryItem; 2921 client.OnCreateNewInventoryItem -= CreateNewInventoryItem;
@@ -2952,18 +2939,22 @@ namespace OpenSim.Region.Framework.Scenes
2952 2939
2953 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) 2940 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client)
2954 { 2941 {
2955 client.OnRezSingleAttachmentFromInv -= RezSingleAttachment; 2942 client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments;
2956 client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments;
2957 client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv;
2958 client.OnObjectAttach -= m_sceneGraph.AttachObject;
2959 client.OnObjectDetach -= m_sceneGraph.DetachObject; 2943 client.OnObjectDetach -= m_sceneGraph.DetachObject;
2944
2945 if (AttachmentsModule != null)
2946 {
2947 client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory;
2948 client.OnObjectAttach -= AttachmentsModule.AttachObject;
2949 client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory;
2950 }
2960 } 2951 }
2961 2952
2962 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) 2953 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client)
2963 { 2954 {
2964 client.OnTeleportLocationRequest -= RequestTeleportLocation; 2955 client.OnTeleportLocationRequest -= RequestTeleportLocation;
2965 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; 2956 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark;
2966 client.OnTeleportHomeRequest -= TeleportClientHome; 2957 //client.OnTeleportHomeRequest -= TeleportClientHome;
2967 } 2958 }
2968 2959
2969 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) 2960 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client)
@@ -2983,7 +2974,7 @@ namespace OpenSim.Region.Framework.Scenes
2983 2974
2984 public virtual void UnSubscribeToClientGridEvents(IClientAPI client) 2975 public virtual void UnSubscribeToClientGridEvents(IClientAPI client)
2985 { 2976 {
2986 client.OnNameFromUUIDRequest -= CommsManager.HandleUUIDNameRequest; 2977 client.OnNameFromUUIDRequest -= HandleUUIDNameRequest;
2987 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; 2978 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
2988 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; 2979 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest;
2989 client.OnSetStartLocationRequest -= SetHomeRezPoint; 2980 client.OnSetStartLocationRequest -= SetHomeRezPoint;
@@ -3010,30 +3001,12 @@ namespace OpenSim.Region.Framework.Scenes
3010 /// <param name="client">The IClientAPI for the client</param> 3001 /// <param name="client">The IClientAPI for the client</param>
3011 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3002 public virtual void TeleportClientHome(UUID agentId, IClientAPI client)
3012 { 3003 {
3013 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); 3004 if (m_teleportModule != null)
3014 if (UserProfile != null) 3005 m_teleportModule.TeleportHome(agentId, client);
3006 else
3015 { 3007 {
3016 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); 3008 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3017 if (regionInfo == null) 3009 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3018 {
3019 uint x = 0, y = 0;
3020 Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
3021 regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
3022 if (regionInfo != null) // home region can be away temporarily, too
3023 {
3024 UserProfile.HomeRegionID = regionInfo.RegionID;
3025 CommsManager.UserService.UpdateUserProfile(UserProfile);
3026 }
3027 }
3028 if (regionInfo == null)
3029 {
3030 // can't find the Home region: Tell viewer and abort
3031 client.SendTeleportFailed("Your home-region could not be found.");
3032 return;
3033 }
3034 RequestTeleportLocation(
3035 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
3036 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
3037 } 3010 }
3038 } 3011 }
3039 3012
@@ -3124,7 +3097,7 @@ namespace OpenSim.Region.Framework.Scenes
3124 } 3097 }
3125 3098
3126 /// <summary> 3099 /// <summary>
3127 /// Sets the Home Point. The GridService uses this to know where to put a user when they log-in 3100 /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in
3128 /// </summary> 3101 /// </summary>
3129 /// <param name="remoteClient"></param> 3102 /// <param name="remoteClient"></param>
3130 /// <param name="regionHandle"></param> 3103 /// <param name="regionHandle"></param>
@@ -3133,27 +3106,11 @@ namespace OpenSim.Region.Framework.Scenes
3133 /// <param name="flags"></param> 3106 /// <param name="flags"></param>
3134 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3107 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3135 { 3108 {
3136 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); 3109 if (PresenceService.SetHomeLocation(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3137 if (UserProfile != null)
3138 {
3139 // I know I'm ignoring the regionHandle provided by the teleport location request.
3140 // reusing the TeleportLocationRequest delegate, so regionHandle isn't valid
3141 UserProfile.HomeRegionID = RegionInfo.RegionID;
3142 // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around.
3143 // TODO: The HomeRegion property can be removed then, too
3144 UserProfile.HomeRegion = RegionInfo.RegionHandle;
3145
3146 UserProfile.HomeLocation = position;
3147 UserProfile.HomeLookAt = lookAt;
3148 CommsManager.UserService.UpdateUserProfile(UserProfile);
3149
3150 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3110 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3151 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3111 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
3152 }
3153 else 3112 else
3154 {
3155 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); 3113 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed.");
3156 }
3157 } 3114 }
3158 3115
3159 /// <summary> 3116 /// <summary>
@@ -3226,14 +3183,12 @@ namespace OpenSim.Region.Framework.Scenes
3226 m_sceneGraph.removeUserCount(!childagentYN); 3183 m_sceneGraph.removeUserCount(!childagentYN);
3227 CapsModule.RemoveCapsHandler(agentID); 3184 CapsModule.RemoveCapsHandler(agentID);
3228 3185
3229 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) 3186 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3230 { 3187 // this method is doing is HORRIBLE!!!
3231 CommsManager.UserProfileCacheService.RemoveUser(agentID); 3188 avatar.Scene.NeedSceneCacheClear(avatar.UUID);
3232 }
3233 3189
3234 if (!avatar.IsChildAgent) 3190 if (!avatar.IsChildAgent)
3235 { 3191 {
3236 m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat);
3237 //List<ulong> childknownRegions = new List<ulong>(); 3192 //List<ulong> childknownRegions = new List<ulong>();
3238 //List<ulong> ckn = avatar.KnownChildRegionHandles; 3193 //List<ulong> ckn = avatar.KnownChildRegionHandles;
3239 //for (int i = 0; i < ckn.Count; i++) 3194 //for (int i = 0; i < ckn.Count; i++)
@@ -3288,12 +3243,6 @@ namespace OpenSim.Region.Framework.Scenes
3288 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3243 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3289 } 3244 }
3290 3245
3291 // Remove client agent from profile, so new logins will work
3292 if (!childagentYN)
3293 {
3294 m_sceneGridService.ClearUserAgent(agentID);
3295 }
3296
3297 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3246 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3298 3247
3299 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3248 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
@@ -3366,14 +3315,6 @@ namespace OpenSim.Region.Framework.Scenes
3366 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3315 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3367 m_sceneGridService.KiPrimitive += SendKillObject; 3316 m_sceneGridService.KiPrimitive += SendKillObject;
3368 m_sceneGridService.OnGetLandData += GetLandData; 3317 m_sceneGridService.OnGetLandData += GetLandData;
3369
3370 if (m_interregionCommsIn != null)
3371 {
3372 m_log.Debug("[SCENE]: Registering with InterregionCommsIn");
3373 m_interregionCommsIn.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3374 }
3375 else
3376 m_log.Debug("[SCENE]: Unable to register with InterregionCommsIn");
3377 } 3318 }
3378 3319
3379 /// <summary> 3320 /// <summary>
@@ -3391,9 +3332,6 @@ namespace OpenSim.Region.Framework.Scenes
3391 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; 3332 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
3392 m_sceneGridService.OnGetLandData -= GetLandData; 3333 m_sceneGridService.OnGetLandData -= GetLandData;
3393 3334
3394 if (m_interregionCommsIn != null)
3395 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3396
3397 // this does nothing; should be removed 3335 // this does nothing; should be removed
3398 m_sceneGridService.Close(); 3336 m_sceneGridService.Close();
3399 3337
@@ -3430,6 +3368,7 @@ namespace OpenSim.Region.Framework.Scenes
3430 /// also return a reason.</returns> 3368 /// also return a reason.</returns>
3431 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) 3369 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason)
3432 { 3370 {
3371 TeleportFlags tp = (TeleportFlags)teleportFlags;
3433 //Teleport flags: 3372 //Teleport flags:
3434 // 3373 //
3435 // TeleportFlags.ViaGodlikeLure - Border Crossing 3374 // TeleportFlags.ViaGodlikeLure - Border Crossing
@@ -3450,7 +3389,7 @@ namespace OpenSim.Region.Framework.Scenes
3450 agent.AgentID, agent.circuitcode, teleportFlags); 3389 agent.AgentID, agent.circuitcode, teleportFlags);
3451 3390
3452 reason = String.Empty; 3391 reason = String.Empty;
3453 if (!AuthenticateUser(agent, out reason)) 3392 if (!VerifyUserPresence(agent, out reason))
3454 return false; 3393 return false;
3455 3394
3456 if (!AuthorizeUser(agent, out reason)) 3395 if (!AuthorizeUser(agent, out reason))
@@ -3463,7 +3402,18 @@ namespace OpenSim.Region.Framework.Scenes
3463 3402
3464 CapsModule.NewUserConnection(agent); 3403 CapsModule.NewUserConnection(agent);
3465 3404
3466 ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); 3405 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3406
3407 //On login or border crossing test land permisions
3408 if (tp != TeleportFlags.Default)
3409 {
3410 if (land != null && !TestLandRestrictions(agent, land, out reason))
3411 {
3412 return false;
3413 }
3414 }
3415
3416 ScenePresence sp = GetScenePresence(agent.AgentID);
3467 if (sp != null) 3417 if (sp != null)
3468 { 3418 {
3469 m_log.DebugFormat( 3419 m_log.DebugFormat(
@@ -3550,40 +3500,73 @@ namespace OpenSim.Region.Framework.Scenes
3550 */// This is now handled properly in ScenePresence.MakeRootAgent 3500 */// This is now handled properly in ScenePresence.MakeRootAgent
3551 } 3501 }
3552 3502
3503 agent.teleportFlags = teleportFlags;
3553 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3504 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3554 3505
3555 // rewrite session_id 3506 return true;
3556 CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID); 3507 }
3557 if (userinfo != null) 3508
3558 { 3509 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason)
3559 userinfo.SessionID = agent.SessionID; 3510 {
3560 } 3511
3561 else 3512 bool banned = land.IsBannedFromLand(agent.AgentID);
3513 bool restricted = land.IsRestrictedFromLand(agent.AgentID);
3514
3515 if (banned || restricted)
3562 { 3516 {
3563 m_log.WarnFormat( 3517 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y);
3564 "[CONNECTION BEGIN]: We couldn't find a User Info record for {0}. This is usually an indication that the UUID we're looking up is invalid", agent.AgentID); 3518 if (nearestParcel != null)
3519 {
3520 //Move agent to nearest allowed
3521 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3522 agent.startpos.X = newPosition.X;
3523 agent.startpos.Y = newPosition.Y;
3524 }
3525 else
3526 {
3527 if (banned)
3528 {
3529 reason = "Cannot regioncross into banned parcel.";
3530 }
3531 else
3532 {
3533 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3534 RegionInfo.RegionName);
3535 }
3536 return false;
3537 }
3565 } 3538 }
3566 3539 reason = "";
3567 return true; 3540 return true;
3568 } 3541 }
3569 3542
3570 /// <summary> 3543 /// <summary>
3571 /// Verifies that the user has a session on the Grid 3544 /// Verifies that the user has a presence on the Grid
3572 /// </summary> 3545 /// </summary>
3573 /// <param name="agent">Circuit Data of the Agent we're verifying</param> 3546 /// <param name="agent">Circuit Data of the Agent we're verifying</param>
3574 /// <param name="reason">Outputs the reason for the false response on this string</param> 3547 /// <param name="reason">Outputs the reason for the false response on this string</param>
3575 /// <returns>True if the user has a session on the grid. False if it does not. False will 3548 /// <returns>True if the user has a session on the grid. False if it does not. False will
3576 /// also return a reason.</returns> 3549 /// also return a reason.</returns>
3577 public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason) 3550 public virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason)
3578 { 3551 {
3579 reason = String.Empty; 3552 reason = String.Empty;
3580 3553
3581 bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); 3554 IPresenceService presence = RequestModuleInterface<IPresenceService>();
3582 m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); 3555 if (presence == null)
3583 if (!result) 3556 {
3584 reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); 3557 reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3558 return false;
3559 }
3560
3561 OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID);
3585 3562
3586 return result; 3563 if (pinfo == null || (pinfo != null && pinfo.Online == false))
3564 {
3565 reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3566 return false;
3567 }
3568
3569 return true;
3587 } 3570 }
3588 3571
3589 /// <summary> 3572 /// <summary>
@@ -3688,6 +3671,18 @@ namespace OpenSim.Region.Framework.Scenes
3688 return true; 3671 return true;
3689 } 3672 }
3690 3673
3674 private ILandObject GetParcelAtPoint(float x, float y)
3675 {
3676 foreach (var parcel in AllParcels())
3677 {
3678 if (parcel.ContainsPoint((int)x,(int)y))
3679 {
3680 return parcel;
3681 }
3682 }
3683 return null;
3684 }
3685
3691 /// <summary> 3686 /// <summary>
3692 /// Update an AgentCircuitData object with new information 3687 /// Update an AgentCircuitData object with new information
3693 /// </summary> 3688 /// </summary>
@@ -3716,8 +3711,7 @@ namespace OpenSim.Region.Framework.Scenes
3716 /// <param name="message">message to display to the user. Reason for being logged off</param> 3711 /// <param name="message">message to display to the user. Reason for being logged off</param>
3717 public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) 3712 public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
3718 { 3713 {
3719 ScenePresence loggingOffUser = null; 3714 ScenePresence loggingOffUser = GetScenePresence(AvatarID);
3720 loggingOffUser = GetScenePresence(AvatarID);
3721 if (loggingOffUser != null) 3715 if (loggingOffUser != null)
3722 { 3716 {
3723 UUID localRegionSecret = UUID.Zero; 3717 UUID localRegionSecret = UUID.Zero;
@@ -3753,10 +3747,8 @@ namespace OpenSim.Region.Framework.Scenes
3753 /// <param name="isFlying"></param> 3747 /// <param name="isFlying"></param>
3754 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 3748 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
3755 { 3749 {
3756 ScenePresence presence; 3750 ScenePresence presence = GetScenePresence(agentID);
3757 m_sceneGraph.TryGetAvatar(agentID, out presence); 3751 if(presence != null)
3758
3759 if (presence != null)
3760 { 3752 {
3761 try 3753 try
3762 { 3754 {
@@ -3784,8 +3776,8 @@ namespace OpenSim.Region.Framework.Scenes
3784 /// <returns>true if we handled it.</returns> 3776 /// <returns>true if we handled it.</returns>
3785 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) 3777 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData)
3786 { 3778 {
3787// m_log.DebugFormat( 3779 m_log.DebugFormat(
3788// "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 3780 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
3789 3781
3790 // We have to wait until the viewer contacts this region after receiving EAC. 3782 // We have to wait until the viewer contacts this region after receiving EAC.
3791 // That calls AddNewClient, which finally creates the ScenePresence 3783 // That calls AddNewClient, which finally creates the ScenePresence
@@ -3854,16 +3846,6 @@ namespace OpenSim.Region.Framework.Scenes
3854 return false; 3846 return false;
3855 } 3847 }
3856 3848
3857 public virtual bool IncomingReleaseAgent(UUID id)
3858 {
3859 return m_sceneGridService.ReleaseAgent(id);
3860 }
3861
3862 public void SendReleaseAgent(ulong regionHandle, UUID id, string uri)
3863 {
3864 m_interregionCommsOut.SendReleaseAgent(regionHandle, id, uri);
3865 }
3866
3867 /// <summary> 3849 /// <summary>
3868 /// Tell a single agent to disconnect from the region. 3850 /// Tell a single agent to disconnect from the region.
3869 /// </summary> 3851 /// </summary>
@@ -3908,30 +3890,6 @@ namespace OpenSim.Region.Framework.Scenes
3908 } 3890 }
3909 3891
3910 /// <summary> 3892 /// <summary>
3911 /// Tell neighboring regions about this agent
3912 /// When the regions respond with a true value,
3913 /// tell the agents about the region.
3914 ///
3915 /// We have to tell the regions about the agents first otherwise it'll deny them access
3916 ///
3917 /// </summary>
3918 /// <param name="presence"></param>
3919 public void InformClientOfNeighbours(ScenePresence presence)
3920 {
3921 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3922 }
3923
3924 /// <summary>
3925 /// Tell a neighboring region about this agent
3926 /// </summary>
3927 /// <param name="presence"></param>
3928 /// <param name="region"></param>
3929 public void InformClientOfNeighbor(ScenePresence presence, RegionInfo region)
3930 {
3931 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3932 }
3933
3934 /// <summary>
3935 /// Tries to teleport agent to other region. 3893 /// Tries to teleport agent to other region.
3936 /// </summary> 3894 /// </summary>
3937 /// <param name="remoteClient"></param> 3895 /// <param name="remoteClient"></param>
@@ -3964,9 +3922,7 @@ namespace OpenSim.Region.Framework.Scenes
3964 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, 3922 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position,
3965 Vector3 lookAt, uint teleportFlags) 3923 Vector3 lookAt, uint teleportFlags)
3966 { 3924 {
3967 ScenePresence sp; 3925 ScenePresence sp = GetScenePresence(remoteClient.AgentId);
3968 m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp);
3969
3970 if (sp != null) 3926 if (sp != null)
3971 { 3927 {
3972 uint regionX = m_regInfo.RegionLocX; 3928 uint regionX = m_regInfo.RegionLocX;
@@ -4006,16 +3962,12 @@ namespace OpenSim.Region.Framework.Scenes
4006 } 3962 }
4007 3963
4008 if (m_teleportModule != null) 3964 if (m_teleportModule != null)
4009 { 3965 m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
4010 m_teleportModule.RequestTeleportToLocation(sp, regionHandle,
4011 position, lookAt, teleportFlags);
4012 }
4013 else 3966 else
4014 { 3967 {
4015 m_sceneGridService.RequestTeleportToLocation(sp, regionHandle, 3968 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
4016 position, lookAt, teleportFlags); 3969 sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator.");
4017 } 3970 }
4018
4019 } 3971 }
4020 } 3972 }
4021 3973
@@ -4041,7 +3993,12 @@ namespace OpenSim.Region.Framework.Scenes
4041 3993
4042 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 3994 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
4043 { 3995 {
4044 m_sceneGridService.CrossAgentToNewRegion(this, agent, isFlying); 3996 if (m_teleportModule != null)
3997 m_teleportModule.Cross(agent, isFlying);
3998 else
3999 {
4000 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
4001 }
4045 } 4002 }
4046 4003
4047 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) 4004 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence)
@@ -4067,35 +4024,6 @@ namespace OpenSim.Region.Framework.Scenes
4067 objectCapacity = objects; 4024 objectCapacity = objects;
4068 } 4025 }
4069 4026
4070 public List<FriendListItem> GetFriendList(string id)
4071 {
4072 UUID avatarID;
4073 if (!UUID.TryParse(id, out avatarID))
4074 return new List<FriendListItem>();
4075
4076 return CommsManager.GetUserFriendList(avatarID);
4077 }
4078
4079 public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
4080 {
4081 return CommsManager.GetFriendRegionInfos(uuids);
4082 }
4083
4084 public virtual void StoreAddFriendship(UUID ownerID, UUID friendID, uint perms)
4085 {
4086 m_sceneGridService.AddNewUserFriend(ownerID, friendID, perms);
4087 }
4088
4089 public virtual void StoreUpdateFriendship(UUID ownerID, UUID friendID, uint perms)
4090 {
4091 m_sceneGridService.UpdateUserFriendPerms(ownerID, friendID, perms);
4092 }
4093
4094 public virtual void StoreRemoveFriendship(UUID ownerID, UUID ExfriendID)
4095 {
4096 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID);
4097 }
4098
4099 #endregion 4027 #endregion
4100 4028
4101 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) 4029 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set)
@@ -4173,17 +4101,17 @@ namespace OpenSim.Region.Framework.Scenes
4173 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", 4101 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname",
4174 "Agent ID", "Session ID", "Circuit", "IP", "World"); 4102 "Agent ID", "Session ID", "Circuit", "IP", "World");
4175 4103
4176 foreach (ScenePresence scenePresence in GetAvatars()) 4104 ForEachScenePresence(delegate(ScenePresence sp)
4177 { 4105 {
4178 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", 4106 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}",
4179 scenePresence.Firstname, 4107 sp.Firstname,
4180 scenePresence.Lastname, 4108 sp.Lastname,
4181 scenePresence.UUID, 4109 sp.UUID,
4182 scenePresence.ControllingClient.AgentId, 4110 sp.ControllingClient.AgentId,
4183 "Unknown", 4111 "Unknown",
4184 "Unknown", 4112 "Unknown",
4185 RegionInfo.RegionName); 4113 RegionInfo.RegionName);
4186 } 4114 });
4187 4115
4188 break; 4116 break;
4189 } 4117 }
@@ -4349,48 +4277,45 @@ namespace OpenSim.Region.Framework.Scenes
4349 m_sceneGraph.RemovePhysicalPrim(num); 4277 m_sceneGraph.RemovePhysicalPrim(num);
4350 } 4278 }
4351 4279
4352 //The idea is to have a group of method that return a list of avatars meeting some requirement 4280 public int GetRootAgentCount()
4353 // ie it could be all m_scenePresences within a certain range of the calling prim/avatar. 4281 {
4282 return m_sceneGraph.GetRootAgentCount();
4283 }
4354 4284
4355 /// <summary> 4285 public int GetChildAgentCount()
4356 /// Return a list of all avatars in this region.
4357 /// This list is a new object, so it can be iterated over without locking.
4358 /// </summary>
4359 /// <returns></returns>
4360 public List<ScenePresence> GetAvatars()
4361 { 4286 {
4362 return m_sceneGraph.GetAvatars(); 4287 return m_sceneGraph.GetChildAgentCount();
4363 } 4288 }
4364 4289
4365 /// <summary> 4290 /// <summary>
4366 /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. 4291 /// Request a scene presence by UUID. Fast, indexed lookup.
4367 /// This list is a new object, so it can be iterated over without locking.
4368 /// </summary> 4292 /// </summary>
4369 /// <returns></returns> 4293 /// <param name="agentID"></param>
4370 public ScenePresence[] GetScenePresences() 4294 /// <returns>null if the presence was not found</returns>
4295 public ScenePresence GetScenePresence(UUID agentID)
4371 { 4296 {
4372 return m_sceneGraph.GetScenePresences(); 4297 return m_sceneGraph.GetScenePresence(agentID);
4373 } 4298 }
4374 4299
4375 /// <summary> 4300 /// <summary>
4376 /// Request a filtered list of ScenePresences in this region. 4301 /// Request the scene presence by name.
4377 /// This list is a new object, so it can be iterated over without locking.
4378 /// </summary> 4302 /// </summary>
4379 /// <param name="filter"></param> 4303 /// <param name="firstName"></param>
4380 /// <returns></returns> 4304 /// <param name="lastName"></param>
4381 public List<ScenePresence> GetScenePresences(FilterAvatarList filter) 4305 /// <returns>null if the presence was not found</returns>
4306 public ScenePresence GetScenePresence(string firstName, string lastName)
4382 { 4307 {
4383 return m_sceneGraph.GetScenePresences(filter); 4308 return m_sceneGraph.GetScenePresence(firstName, lastName);
4384 } 4309 }
4385 4310
4386 /// <summary> 4311 /// <summary>
4387 /// Request a scene presence by UUID 4312 /// Request the scene presence by localID.
4388 /// </summary> 4313 /// </summary>
4389 /// <param name="avatarID"></param> 4314 /// <param name="localID"></param>
4390 /// <returns></returns> 4315 /// <returns>null if the presence was not found</returns>
4391 public ScenePresence GetScenePresence(UUID avatarID) 4316 public ScenePresence GetScenePresence(uint localID)
4392 { 4317 {
4393 return m_sceneGraph.GetScenePresence(avatarID); 4318 return m_sceneGraph.GetScenePresence(localID);
4394 } 4319 }
4395 4320
4396 public override bool PresenceChildStatus(UUID avatarID) 4321 public override bool PresenceChildStatus(UUID avatarID)
@@ -4408,25 +4333,14 @@ namespace OpenSim.Region.Framework.Scenes
4408 } 4333 }
4409 4334
4410 /// <summary> 4335 /// <summary>
4411 /// 4336 /// Performs action on all scene presences.
4412 /// </summary> 4337 /// </summary>
4413 /// <param name="action"></param> 4338 /// <param name="action"></param>
4414 public void ForEachScenePresence(Action<ScenePresence> action) 4339 public void ForEachScenePresence(Action<ScenePresence> action)
4415 { 4340 {
4416 // We don't want to try to send messages if there are no avatars.
4417 if (m_sceneGraph != null) 4341 if (m_sceneGraph != null)
4418 { 4342 {
4419 try 4343 m_sceneGraph.ForEachScenePresence(action);
4420 {
4421 ScenePresence[] presences = GetScenePresences();
4422 for (int i = 0; i < presences.Length; i++)
4423 action(presences[i]);
4424 }
4425 catch (Exception e)
4426 {
4427 m_log.Info("[BUG] in " + RegionInfo.RegionName + ": " + e.ToString());
4428 m_log.Info("[BUG] Stack Trace: " + e.StackTrace);
4429 }
4430 } 4344 }
4431 } 4345 }
4432 4346
@@ -4490,9 +4404,9 @@ namespace OpenSim.Region.Framework.Scenes
4490 return m_sceneGraph.GetGroupByPrim(localID); 4404 return m_sceneGraph.GetGroupByPrim(localID);
4491 } 4405 }
4492 4406
4493 public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) 4407 public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
4494 { 4408 {
4495 return m_sceneGraph.TryGetAvatar(avatarId, out avatar); 4409 return m_sceneGraph.TryGetScenePresence(avatarId, out avatar);
4496 } 4410 }
4497 4411
4498 public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) 4412 public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
@@ -4502,20 +4416,7 @@ namespace OpenSim.Region.Framework.Scenes
4502 4416
4503 public void ForEachClient(Action<IClientAPI> action) 4417 public void ForEachClient(Action<IClientAPI> action)
4504 { 4418 {
4505 ForEachClient(action, m_useAsyncWhenPossible);
4506 }
4507
4508 public void ForEachClient(Action<IClientAPI> action, bool doAsynchronous)
4509 {
4510 // FIXME: Asynchronous iteration is disabled until we have a threading model that
4511 // can support calling this function from an async packet handler without
4512 // potentially deadlocking
4513 m_clientManager.ForEachSync(action); 4419 m_clientManager.ForEachSync(action);
4514
4515 //if (doAsynchronous)
4516 // m_clientManager.ForEach(action);
4517 //else
4518 // m_clientManager.ForEachSync(action);
4519 } 4420 }
4520 4421
4521 public bool TryGetClient(UUID avatarID, out IClientAPI client) 4422 public bool TryGetClient(UUID avatarID, out IClientAPI client)
@@ -4687,7 +4588,8 @@ namespace OpenSim.Region.Framework.Scenes
4687 group.GetPartName(localID), 4588 group.GetPartName(localID),
4688 group.GetPartDescription(localID), 4589 group.GetPartDescription(localID),
4689 (sbyte)AssetType.Object, 4590 (sbyte)AssetType.Object,
4690 Utils.StringToBytes(sceneObjectXml)); 4591 Utils.StringToBytes(sceneObjectXml),
4592 group.OwnerID);
4691 AssetService.Store(asset); 4593 AssetService.Store(asset);
4692 4594
4693 InventoryItemBase item = new InventoryItemBase(); 4595 InventoryItemBase item = new InventoryItemBase();
@@ -5011,5 +4913,185 @@ namespace OpenSim.Region.Framework.Scenes
5011 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4913 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000)
5012 StartTimer(); 4914 StartTimer();
5013 } 4915 }
4916
4917 public override ISceneObject DeserializeObject(string representation)
4918 {
4919 return SceneObjectSerializer.FromXml2Format(representation);
4920 }
4921
4922 public override bool AllowScriptCrossings
4923 {
4924 get { return m_allowScriptCrossings; }
4925 }
4926
4927 public Vector3? GetNearestAllowedPosition(ScenePresence avatar)
4928 {
4929 //simulate to make sure we have pretty up to date positions
4930 PhysicsScene.Simulate(0);
4931
4932 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
4933
4934 if (nearestParcel != null)
4935 {
4936 Vector3 dir = Vector3.Normalize(Vector3.Multiply(avatar.Velocity, -1));
4937 //Try to get a location that feels like where they came from
4938 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4939 if (nearestPoint != null)
4940 {
4941 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
4942 return nearestPoint.Value;
4943 }
4944
4945 //Sometimes velocity might be zero (local teleport), so try finding point along path from avatar to center of nearest parcel
4946 Vector3 directionToParcelCenter = Vector3.Subtract(GetParcelCenterAtGround(nearestParcel), avatar.AbsolutePosition);
4947 dir = Vector3.Normalize(directionToParcelCenter);
4948 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4949 if (nearestPoint != null)
4950 {
4951 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
4952 return nearestPoint.Value;
4953 }
4954
4955 //Ultimate backup if we have no idea where they are
4956 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
4957 return avatar.lastKnownAllowedPosition;
4958
4959 }
4960
4961 //Go to the edge, this happens in teleporting to a region with no available parcels
4962 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar);
4963 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString());
4964 return nearestRegionEdgePoint;
4965 return null;
4966 }
4967
4968 private Vector3 GetParcelCenterAtGround(ILandObject parcel)
4969 {
4970 Vector2 center = GetParcelCenter(parcel);
4971 return GetPositionAtGround(center.X, center.Y);
4972 }
4973
4974 private Vector3? GetNearestPointInParcelAlongDirectionFromPoint(Vector3 pos, Vector3 direction, ILandObject parcel)
4975 {
4976 Vector3 unitDirection = Vector3.Normalize(direction);
4977 //Making distance to search go through some sane limit of distance
4978 for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f)
4979 {
4980 Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance));
4981 if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y))
4982 {
4983 return testPos;
4984 }
4985 }
4986 return null;
4987 }
4988
4989 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
4990 {
4991 List<ILandObject> all = AllParcels();
4992 float minParcelDistance = float.MaxValue;
4993 ILandObject nearestParcel = null;
4994
4995 foreach (var parcel in all)
4996 {
4997 if (!parcel.IsEitherBannedOrRestricted(avatarId))
4998 {
4999 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
5000 if (parcelDistance < minParcelDistance)
5001 {
5002 minParcelDistance = parcelDistance;
5003 nearestParcel = parcel;
5004 }
5005 }
5006 }
5007
5008 return nearestParcel;
5009 }
5010
5011 private List<ILandObject> AllParcels()
5012 {
5013 return LandChannel.AllParcels();
5014 }
5015
5016 private float GetParcelDistancefromPoint(ILandObject parcel, float x, float y)
5017 {
5018 return Vector2.Distance(new Vector2(x, y), GetParcelCenter(parcel));
5019 }
5020
5021 //calculate the average center point of a parcel
5022 private Vector2 GetParcelCenter(ILandObject parcel)
5023 {
5024 int count = 0;
5025 int avgx = 0;
5026 int avgy = 0;
5027 for (int x = 0; x < Constants.RegionSize; x++)
5028 {
5029 for (int y = 0; y < Constants.RegionSize; y++)
5030 {
5031 //Just keep a running average as we check if all the points are inside or not
5032 if (parcel.ContainsPoint(x, y))
5033 {
5034 if (count == 0)
5035 {
5036 avgx = x;
5037 avgy = y;
5038 }
5039 else
5040 {
5041 avgx = (avgx * count + x) / (count + 1);
5042 avgy = (avgy * count + y) / (count + 1);
5043 }
5044 count += 1;
5045 }
5046 }
5047 }
5048 return new Vector2(avgx, avgy);
5049 }
5050
5051 private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar)
5052 {
5053 float xdistance = avatar.AbsolutePosition.X < Constants.RegionSize / 2 ? avatar.AbsolutePosition.X : Constants.RegionSize - avatar.AbsolutePosition.X;
5054 float ydistance = avatar.AbsolutePosition.Y < Constants.RegionSize / 2 ? avatar.AbsolutePosition.Y : Constants.RegionSize - avatar.AbsolutePosition.Y;
5055
5056 //find out what vertical edge to go to
5057 if (xdistance < ydistance)
5058 {
5059 if (avatar.AbsolutePosition.X < Constants.RegionSize / 2)
5060 {
5061 return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y);
5062 }
5063 else
5064 {
5065 return GetPositionAtAvatarHeightOrGroundHeight(avatar, Constants.RegionSize, avatar.AbsolutePosition.Y);
5066 }
5067 }
5068 //find out what horizontal edge to go to
5069 else
5070 {
5071 if (avatar.AbsolutePosition.Y < Constants.RegionSize / 2)
5072 {
5073 return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f);
5074 }
5075 else
5076 {
5077 return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, Constants.RegionSize);
5078 }
5079 }
5080 }
5081
5082 private Vector3 GetPositionAtAvatarHeightOrGroundHeight(ScenePresence avatar, float x, float y)
5083 {
5084 Vector3 ground = GetPositionAtGround(x, y);
5085 if (avatar.AbsolutePosition.Z > ground.Z)
5086 {
5087 ground.Z = avatar.AbsolutePosition.Z;
5088 }
5089 return ground;
5090 }
5091
5092 private Vector3 GetPositionAtGround(float x, float y)
5093 {
5094 return new Vector3(x, y, GetGroundHeight(x, y));
5095 }
5014 } 5096 }
5015} 5097}
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 5e798c0..3218dad 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -34,7 +34,7 @@ using log4net;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Communications.Cache; 37
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 40
@@ -190,6 +190,21 @@ namespace OpenSim.Region.Framework.Scenes
190 /// <param name="agentID"></param> 190 /// <param name="agentID"></param>
191 public abstract void RemoveClient(UUID agentID); 191 public abstract void RemoveClient(UUID agentID);
192 192
193 public bool TryGetScenePresence(UUID agentID, out object scenePresence)
194 {
195 scenePresence = null;
196 ScenePresence sp = null;
197 if (TryGetScenePresence(agentID, out sp))
198 {
199 scenePresence = sp;
200 return true;
201 }
202
203 return false;
204 }
205
206 public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence);
207
193 #endregion 208 #endregion
194 209
195 /// <summary> 210 /// <summary>
@@ -510,5 +525,16 @@ namespace OpenSim.Region.Framework.Scenes
510 525
511 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); 526 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback);
512 } 527 }
528
529 public virtual ISceneObject DeserializeObject(string representation)
530 {
531 return null;
532 }
533
534 public virtual bool AllowScriptCrossings
535 {
536 get { return false; }
537 }
538
513 } 539 }
514} 540}
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 5f84252..9d0e6f4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -36,7 +36,6 @@ using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Client; 37using OpenSim.Framework.Client;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Capabilities; 39using OpenSim.Framework.Capabilities;
41using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Services.Interfaces; 41using OpenSim.Services.Interfaces;
@@ -56,8 +55,6 @@ namespace OpenSim.Region.Framework.Scenes
56 { 55 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 57
59 protected CommunicationsManager m_commsProvider;
60 protected IInterregionCommsOut m_interregionCommsOut;
61 protected RegionInfo m_regionInfo; 58 protected RegionInfo m_regionInfo;
62 protected Scene m_scene; 59 protected Scene m_scene;
63 60
@@ -106,29 +103,26 @@ namespace OpenSim.Region.Framework.Scenes
106 /// </summary> 103 /// </summary>
107 public event GetLandData OnGetLandData; 104 public event GetLandData OnGetLandData;
108 105
109 private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; 106// private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
110 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser; 107// private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser;
111 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; 108// private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
112 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; 109// private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
113 //private RegionUp handlerRegionUp = null; // OnRegionUp; 110 //private RegionUp handlerRegionUp = null; // OnRegionUp;
114 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; 111// private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
115 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar; 112 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
116 private LogOffUser handlerLogOffUser = null; 113// private LogOffUser handlerLogOffUser = null;
117 private GetLandData handlerGetLandData = null; // OnGetLandData 114// private GetLandData handlerGetLandData = null; // OnGetLandData
118 115
119 public KiPrimitiveDelegate KiPrimitive; 116 public KiPrimitiveDelegate KiPrimitive;
120 117
121 public SceneCommunicationService(CommunicationsManager commsMan) 118 public SceneCommunicationService()
122 { 119 {
123 m_commsProvider = commsMan;
124 m_agentsInTransit = new List<UUID>();
125 } 120 }
126 121
127 public void SetScene(Scene s) 122 public void SetScene(Scene s)
128 { 123 {
129 m_scene = s; 124 m_scene = s;
130 m_regionInfo = s.RegionInfo; 125 m_regionInfo = s.RegionInfo;
131 m_interregionCommsOut = m_scene.RequestModuleInterface<IInterregionCommsOut>();
132 } 126 }
133 127
134 /// <summary> 128 /// <summary>
@@ -148,377 +142,6 @@ namespace OpenSim.Region.Framework.Scenes
148 { 142 {
149 } 143 }
150 144
151 #region CommsManager Event handlers
152
153 /// <summary>
154 /// A New User will arrive shortly, Informs the scene that there's a new user on the way
155 /// </summary>
156 /// <param name="agent">Data we need to ensure that the agent can connect</param>
157 ///
158 protected void NewUserConnection(AgentCircuitData agent)
159 {
160 handlerExpectUser = OnExpectUser;
161 if (handlerExpectUser != null)
162 {
163 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname);
164 handlerExpectUser(agent);
165 }
166 }
167
168 /// <summary>
169 /// The Grid has requested us to log-off the user
170 /// </summary>
171 /// <param name="AgentID">Unique ID of agent to log-off</param>
172 /// <param name="RegionSecret">The secret string that the region establishes with the grid when registering</param>
173 /// <param name="message">The message to send to the user that tells them why they were logged off</param>
174 protected void GridLogOffUser(UUID AgentID, UUID RegionSecret, string message)
175 {
176 handlerLogOffUser = OnLogOffUser;
177 if (handlerLogOffUser != null)
178 {
179 handlerLogOffUser(AgentID, RegionSecret, message);
180 }
181 }
182
183 /// <summary>
184 /// Inform the scene that we've got an update about a child agent that we have
185 /// </summary>
186 /// <param name="cAgentData"></param>
187 /// <returns></returns>
188 protected bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData)
189 {
190 handlerChildAgentUpdate = OnChildAgentUpdate;
191 if (handlerChildAgentUpdate != null)
192 handlerChildAgentUpdate(cAgentData);
193
194 return true;
195 }
196
197
198 protected void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
199 {
200 handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
201 if (handlerAvatarCrossingIntoRegion != null)
202 {
203 handlerAvatarCrossingIntoRegion(agentID, position, isFlying);
204 }
205 }
206
207 protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical)
208 {
209 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
210 if (handlerPrimCrossingIntoRegion != null)
211 {
212 handlerPrimCrossingIntoRegion(primID, position, isPhysical);
213 }
214 }
215
216 protected bool CloseConnection(UUID agentID)
217 {
218 m_log.Debug("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID);
219
220 handlerCloseAgentConnection = OnCloseAgentConnection;
221 if (handlerCloseAgentConnection != null)
222 {
223 return handlerCloseAgentConnection(agentID);
224 }
225
226 return false;
227 }
228
229 protected LandData FetchLandData(uint x, uint y)
230 {
231 handlerGetLandData = OnGetLandData;
232 if (handlerGetLandData != null)
233 {
234 return handlerGetLandData(x, y);
235 }
236 return null;
237 }
238
239 #endregion
240
241 #region Inform Client of Neighbours
242
243 private delegate void InformClientOfNeighbourDelegate(
244 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
245
246 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
247 {
248 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState;
249 icon.EndInvoke(iar);
250 }
251
252 /// <summary>
253 /// Async component for informing client of which neighbours exist
254 /// </summary>
255 /// <remarks>
256 /// This needs to run asynchronously, as a network timeout may block the thread for a long while
257 /// </remarks>
258 /// <param name="remoteClient"></param>
259 /// <param name="a"></param>
260 /// <param name="regionHandle"></param>
261 /// <param name="endPoint"></param>
262 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
263 IPEndPoint endPoint, bool newAgent)
264 {
265 // Let's wait just a little to give time to originating regions to catch up with closing child agents
266 // after a cross here
267 Thread.Sleep(500);
268
269 uint x, y;
270 Utils.LongToUInts(reg.RegionHandle, out x, out y);
271 x = x / Constants.RegionSize;
272 y = y / Constants.RegionSize;
273 m_log.Info("[INTERGRID]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
274
275 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
276 + "/CAPS/" + a.CapsPath + "0000/";
277
278 string reason = String.Empty;
279
280
281 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason);
282
283 if (regionAccepted && newAgent)
284 {
285 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
286 if (eq != null)
287 {
288 #region IP Translation for NAT
289 IClientIPEndpoint ipepClient;
290 if (avatar.ClientView.TryGet(out ipepClient))
291 {
292 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
293 }
294 #endregion
295
296 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
297 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
298 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}",
299 capsPath, avatar.UUID, avatar.Scene.RegionInfo.RegionName);
300 }
301 else
302 {
303 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
304 // TODO: make Event Queue disablable!
305 }
306
307 m_log.Info("[INTERGRID]: Completed inform client about neighbour " + endPoint.ToString());
308
309 }
310
311 }
312
313 public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
314 {
315 Border[] northBorders = pScene.NorthBorders.ToArray();
316 Border[] southBorders = pScene.SouthBorders.ToArray();
317 Border[] eastBorders = pScene.EastBorders.ToArray();
318 Border[] westBorders = pScene.WestBorders.ToArray();
319
320 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
321 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
322 {
323 return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
324 }
325 else
326 {
327 Vector2 extent = Vector2.Zero;
328 for (int i = 0; i < eastBorders.Length; i++)
329 {
330 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
331 }
332 for (int i = 0; i < northBorders.Length; i++)
333 {
334 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
335 }
336
337 // Loss of fraction on purpose
338 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
339 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
340
341 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
342 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
343
344 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
345 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
346
347 List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
348 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
349
350 return neighbours;
351 }
352 }
353
354 /// <summary>
355 /// This informs all neighboring regions about agent "avatar".
356 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
357 /// </summary>
358 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
359 {
360 List<GridRegion> neighbours = new List<GridRegion>();
361
362 if (m_regionInfo != null)
363 {
364 neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
365 }
366 else
367 {
368 m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?");
369 }
370
371 /// We need to find the difference between the new regions where there are no child agents
372 /// and the regions where there are already child agents. We only send notification to the former.
373 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
374 neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too
375 List<ulong> previousRegionNeighbourHandles ;
376
377 if (avatar.Scene.CapsModule != null)
378 {
379 previousRegionNeighbourHandles =
380 new List<ulong>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys);
381 }
382 else
383 {
384 previousRegionNeighbourHandles = new List<ulong>();
385 }
386
387 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
388 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
389
390 //Dump("Current Neighbors", neighbourHandles);
391 //Dump("Previous Neighbours", previousRegionNeighbourHandles);
392 //Dump("New Neighbours", newRegions);
393 //Dump("Old Neighbours", oldRegions);
394
395 /// Update the scene presence's known regions here on this region
396 avatar.DropOldNeighbours(oldRegions);
397
398 /// Collect as many seeds as possible
399 Dictionary<ulong, string> seeds;
400 if (avatar.Scene.CapsModule != null)
401 seeds
402 = new Dictionary<ulong, string>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID));
403 else
404 seeds = new Dictionary<ulong, string>();
405
406 //m_log.Debug(" !!! No. of seeds: " + seeds.Count);
407 if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle))
408 seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath);
409
410 /// Create the necessary child agents
411 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
412 foreach (GridRegion neighbour in neighbours)
413 {
414 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
415 {
416
417 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
418 agent.BaseFolder = UUID.Zero;
419 agent.InventoryFolder = UUID.Zero;
420 agent.startpos = new Vector3(128, 128, 70);
421 agent.child = true;
422
423 if (newRegions.Contains(neighbour.RegionHandle))
424 {
425 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
426 avatar.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
427 seeds.Add(neighbour.RegionHandle, agent.CapsPath);
428 }
429 else
430 agent.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
431
432 cagents.Add(agent);
433 }
434 }
435
436 /// Update all child agent with everyone's seeds
437 foreach (AgentCircuitData a in cagents)
438 {
439 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
440 }
441
442 if (avatar.Scene.CapsModule != null)
443 {
444 // These two are the same thing!
445 avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds);
446 }
447 avatar.KnownRegions = seeds;
448 //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
449 //avatar.DumpKnownRegions();
450
451 bool newAgent = false;
452 int count = 0;
453 foreach (GridRegion neighbour in neighbours)
454 {
455 // Don't do it if there's already an agent in that region
456 if (newRegions.Contains(neighbour.RegionHandle))
457 newAgent = true;
458 else
459 newAgent = false;
460
461 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
462 {
463 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
464 try
465 {
466 d.BeginInvoke(avatar, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
467 InformClientOfNeighbourCompleted,
468 d);
469 }
470
471 catch (ArgumentOutOfRangeException)
472 {
473 m_log.ErrorFormat(
474 "[REGIONINFO]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).",
475 neighbour.ExternalHostName,
476 neighbour.RegionHandle,
477 neighbour.RegionLocX,
478 neighbour.RegionLocY);
479 }
480 catch (Exception e)
481 {
482 m_log.ErrorFormat(
483 "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
484 neighbour.ExternalHostName,
485 neighbour.RegionHandle,
486 neighbour.RegionLocX,
487 neighbour.RegionLocY,
488 e);
489
490 // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
491 // since I don't know what will happen if we just let the client continue
492
493 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
494 // throw e;
495
496 }
497 }
498 count++;
499 }
500 }
501
502 /// <summary>
503 /// This informs a single neighboring region about agent "avatar".
504 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
505 /// </summary>
506 public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
507 {
508 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
509 agent.BaseFolder = UUID.Zero;
510 agent.InventoryFolder = UUID.Zero;
511 agent.startpos = new Vector3(128, 128, 70);
512 agent.child = true;
513
514 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
515 d.BeginInvoke(avatar, agent, region, region.ExternalEndPoint, true,
516 InformClientOfNeighbourCompleted,
517 d);
518 }
519
520 #endregion
521
522 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle); 145 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle);
523 146
524 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) 147 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
@@ -550,7 +173,7 @@ namespace OpenSim.Region.Framework.Scenes
550 } 173 }
551 else 174 else
552 { 175 {
553 m_log.WarnFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize); 176 m_log.InfoFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
554 } 177 }
555 } 178 }
556 179
@@ -592,7 +215,10 @@ namespace OpenSim.Region.Framework.Scenes
592 try 215 try
593 { 216 {
594 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); 217 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData);
595 m_interregionCommsOut.SendChildAgentUpdate(regionHandle, cAgentData); 218 uint x = 0, y = 0;
219 Utils.LongToUInts(regionHandle, out x, out y);
220 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
221 m_scene.SimulationService.UpdateAgent(destination, cAgentData);
596 } 222 }
597 catch 223 catch
598 { 224 {
@@ -652,7 +278,10 @@ namespace OpenSim.Region.Framework.Scenes
652 // let's do our best, but there's not much we can do if the neighbour doesn't accept. 278 // let's do our best, but there's not much we can do if the neighbour doesn't accept.
653 279
654 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); 280 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
655 m_interregionCommsOut.SendCloseAgent(regionHandle, agentID); 281 uint x = 0, y = 0;
282 Utils.LongToUInts(regionHandle, out x, out y);
283 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
284 m_scene.SimulationService.CloseAgent(destination, agentID);
656 } 285 }
657 286
658 private void SendCloseChildAgentCompleted(IAsyncResult iar) 287 private void SendCloseChildAgentCompleted(IAsyncResult iar)
@@ -672,848 +301,10 @@ namespace OpenSim.Region.Framework.Scenes
672 } 301 }
673 } 302 }
674 303
675
676 /// <summary>
677 /// Try to teleport an agent to a new region.
678 /// </summary>
679 /// <param name="remoteClient"></param>
680 /// <param name="RegionHandle"></param>
681 /// <param name="position"></param>
682 /// <param name="lookAt"></param>
683 /// <param name="flags"></param>
684 public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
685 Vector3 lookAt, uint teleportFlags)
686 {
687 if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
688 return;
689
690 bool destRegionUp = true;
691
692 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
693
694 // Reset animations; the viewer does that in teleports.
695 avatar.Animator.ResetAnimations();
696
697 if (regionHandle == m_regionInfo.RegionHandle)
698 {
699 m_log.DebugFormat(
700 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}",
701 position, m_regionInfo.RegionName);
702
703 // Teleport within the same region
704 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
705 {
706 Vector3 emergencyPos = new Vector3(128, 128, 128);
707
708 m_log.WarnFormat(
709 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
710 position, avatar.Name, avatar.UUID, emergencyPos);
711 position = emergencyPos;
712 }
713
714 Vector3 currentPos = avatar.AbsolutePosition;
715 ILandObject srcLand = m_scene.LandChannel.GetLandObject(currentPos.X, currentPos.Y);
716 ILandObject destLand = m_scene.LandChannel.GetLandObject(position.X, position.Y);
717 if (srcLand != null && destLand != null && (teleportFlags & (uint)TeleportFlags.ViaLure) == 0 && (teleportFlags & (uint)TeleportFlags.ViaGodlikeLure) == 0)
718 {
719 if (srcLand.LandData.LocalID == destLand.LandData.LocalID)
720 {
721 //TPing within the same parcel. If the landing point is restricted, block the TP.
722 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni.
723 if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID)
724 {
725 //Disabling this behaviour for now pending review. ~CasperW
726
727 //avatar.ControllingClient.SendAgentAlertMessage("Can't TP to the destination; landing point set.", false);
728 //position = currentPos;
729 }
730 }
731 else
732 {
733 //Tping to a different parcel. Respect the landing point on the destination parcel.
734 if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID)
735 {
736 position = destLand.LandData.UserLocation;
737 }
738 }
739 }
740
741 // TODO: Get proper AVG Height
742 float localAVHeight = 1.56f;
743 float posZLimit = 22;
744
745 // TODO: Check other Scene HeightField
746 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <=(int)Constants.RegionSize)
747 {
748 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
749 }
750
751 float newPosZ = posZLimit + localAVHeight;
752 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
753 {
754 position.Z = newPosZ;
755 }
756
757 // Only send this if the event queue is null
758 if (eq == null)
759 avatar.ControllingClient.SendTeleportLocationStart();
760
761 avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
762 avatar.Teleport(position);
763 }
764 else
765 {
766 uint x = 0, y = 0;
767 Utils.LongToUInts(regionHandle, out x, out y);
768 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
769
770 if (reg != null)
771 {
772 m_log.DebugFormat(
773 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation to {0} in {1}",
774 position, reg.RegionName);
775
776 if (eq == null)
777 avatar.ControllingClient.SendTeleportLocationStart();
778
779 // Let's do DNS resolution only once in this process, please!
780 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
781 // it's actually doing a lot of work.
782 IPEndPoint endPoint = reg.ExternalEndPoint;
783 if (endPoint.Address == null)
784 {
785 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
786 destRegionUp = false;
787 }
788
789 if (destRegionUp)
790 {
791 uint newRegionX = (uint)(reg.RegionHandle >> 40);
792 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
793 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
794 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
795
796 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
797 // both regions
798 if (avatar.ParentID != (uint)0)
799 avatar.StandUp();
800
801 if (!avatar.ValidateAttachments())
802 {
803 avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
804 return;
805 }
806
807 // the avatar.Close below will clear the child region list. We need this below for (possibly)
808 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
809 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
810 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
811 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
812 // once we reach here...
813 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
814
815 string capsPath = String.Empty;
816 AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
817 agentCircuit.BaseFolder = UUID.Zero;
818 agentCircuit.InventoryFolder = UUID.Zero;
819 agentCircuit.startpos = position;
820 agentCircuit.child = true;
821
822 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
823 {
824 // brand new agent, let's create a new caps seed
825 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
826 }
827
828 string reason = String.Empty;
829
830 // Let's create an agent there if one doesn't exist yet.
831 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
832 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
833 {
834 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
835 reason));
836 return;
837 }
838
839 // OK, it got this agent. Let's close some child agents
840 avatar.CloseChildAgents(newRegionX, newRegionY);
841
842 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
843 {
844 #region IP Translation for NAT
845 IClientIPEndpoint ipepClient;
846 if (avatar.ClientView.TryGet(out ipepClient))
847 {
848 capsPath
849 = "http://"
850 + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName)
851 + ":"
852 + reg.HttpPort
853 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
854 }
855 else
856 {
857 capsPath
858 = "http://"
859 + reg.ExternalHostName
860 + ":"
861 + reg.HttpPort
862 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
863 }
864 #endregion
865
866 if (eq != null)
867 {
868 #region IP Translation for NAT
869 // Uses ipepClient above
870 if (avatar.ClientView.TryGet(out ipepClient))
871 {
872 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
873 }
874 #endregion
875
876 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
877
878 // ES makes the client send a UseCircuitCode message to the destination,
879 // which triggers a bunch of things there.
880 // So let's wait
881 Thread.Sleep(2000);
882
883 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
884 }
885 else
886 {
887 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
888 }
889 }
890 else
891 {
892 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
893 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
894 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
895 }
896
897 // Expect avatar crossing is a heavy-duty function at the destination.
898 // That is where MakeRoot is called, which fetches appearance and inventory.
899 // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates.
900 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
901 // position, false);
902
903 //{
904 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
905 // // We should close that agent we just created over at destination...
906 // List<ulong> lst = new List<ulong>();
907 // lst.Add(reg.RegionHandle);
908 // SendCloseChildAgentAsync(avatar.UUID, lst);
909 // return;
910 //}
911
912 SetInTransit(avatar.UUID);
913 // Let's send a full update of the agent. This is a synchronous call.
914 AgentData agent = new AgentData();
915 avatar.CopyTo(agent);
916 agent.Position = position;
917 agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
918 "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
919
920 m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
921
922 m_log.DebugFormat(
923 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID);
924
925
926 if (eq != null)
927 {
928 eq.TeleportFinishEvent(reg.RegionHandle, 13, endPoint,
929 0, teleportFlags, capsPath, avatar.UUID);
930 }
931 else
932 {
933 avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, endPoint, 4,
934 teleportFlags, capsPath);
935 }
936
937 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
938 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
939 // that the client contacted the destination before we send the attachments and close things here.
940 if (!WaitForCallback(avatar.UUID))
941 {
942 // Client never contacted destination. Let's restore everything back
943 avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
944
945 ResetFromTransit(avatar.UUID);
946
947 // Yikes! We should just have a ref to scene here.
948 avatar.Scene.InformClientOfNeighbours(avatar);
949
950 // Finally, kill the agent we just created at the destination.
951 m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
952
953 return;
954 }
955
956 // Can't go back from here
957 if (KiPrimitive != null)
958 {
959 KiPrimitive(avatar.LocalId);
960 }
961
962 avatar.MakeChildAgent();
963
964 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
965 avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
966
967 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
968
969 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
970 {
971 Thread.Sleep(5000);
972 avatar.Close();
973 CloseConnection(avatar.UUID);
974 }
975 else
976 // now we have a child agent in this region.
977 avatar.Reset();
978
979
980 // if (teleport success) // seems to be always success here
981 // the user may change their profile information in other region,
982 // so the userinfo in UserProfileCache is not reliable any more, delete it
983 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
984 {
985 m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
986 m_log.DebugFormat(
987 "[SCENE COMMUNICATION SERVICE]: User {0} is going to another region, profile cache removed",
988 avatar.UUID);
989 }
990 }
991 else
992 {
993 avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
994 }
995 }
996 else
997 {
998 // TP to a place that doesn't exist (anymore)
999 // Inform the viewer about that
1000 avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
1001
1002 // and set the map-tile to '(Offline)'
1003 uint regX, regY;
1004 Utils.LongToUInts(regionHandle, out regX, out regY);
1005
1006 MapBlockData block = new MapBlockData();
1007 block.X = (ushort)(regX / Constants.RegionSize);
1008 block.Y = (ushort)(regY / Constants.RegionSize);
1009 block.Access = 254; // == not there
1010
1011 List<MapBlockData> blocks = new List<MapBlockData>();
1012 blocks.Add(block);
1013 avatar.ControllingClient.SendMapBlock(blocks, 0);
1014 }
1015 }
1016 }
1017
1018 protected bool IsOutsideRegion(Scene s, Vector3 pos)
1019 {
1020
1021 if (s.TestBorderCross(pos,Cardinals.N))
1022 return true;
1023 if (s.TestBorderCross(pos, Cardinals.S))
1024 return true;
1025 if (s.TestBorderCross(pos, Cardinals.E))
1026 return true;
1027 if (s.TestBorderCross(pos, Cardinals.W))
1028 return true;
1029
1030 return false;
1031 }
1032
1033 public bool WaitForCallback(UUID id)
1034 {
1035 int count = 200;
1036 while (m_agentsInTransit.Contains(id) && count-- > 0)
1037 {
1038 //m_log.Debug(" >>> Waiting... " + count);
1039 Thread.Sleep(100);
1040 }
1041
1042 if (count > 0)
1043 return true;
1044 else
1045 return false;
1046 }
1047
1048 public bool ReleaseAgent(UUID id)
1049 {
1050 //m_log.Debug(" >>> ReleaseAgent called <<< ");
1051 return ResetFromTransit(id);
1052 }
1053
1054 public void SetInTransit(UUID id)
1055 {
1056 lock (m_agentsInTransit)
1057 {
1058 if (!m_agentsInTransit.Contains(id))
1059 m_agentsInTransit.Add(id);
1060 }
1061 }
1062
1063 protected bool ResetFromTransit(UUID id)
1064 {
1065 lock (m_agentsInTransit)
1066 {
1067 if (m_agentsInTransit.Contains(id))
1068 {
1069 m_agentsInTransit.Remove(id);
1070 return true;
1071 }
1072 }
1073 return false;
1074 }
1075
1076 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1077 {
1078 List<ulong> handles = new List<ulong>();
1079 foreach (GridRegion reg in neighbours)
1080 {
1081 handles.Add(reg.RegionHandle);
1082 }
1083 return handles;
1084 }
1085
1086 private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1087 {
1088 return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
1089 }
1090
1091// private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1092// {
1093// return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
1094// }
1095
1096 private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1097 {
1098 return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
1099 }
1100
1101 public void CrossAgentToNewRegion(Scene scene, ScenePresence agent, bool isFlying)
1102 {
1103 Vector3 pos = agent.AbsolutePosition;
1104 Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z);
1105 uint neighbourx = m_regionInfo.RegionLocX;
1106 uint neighboury = m_regionInfo.RegionLocY;
1107 const float boundaryDistance = 1.7f;
1108 Vector3 northCross = new Vector3(0,boundaryDistance, 0);
1109 Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0);
1110 Vector3 eastCross = new Vector3(boundaryDistance, 0, 0);
1111 Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0);
1112
1113 // distance to edge that will trigger crossing
1114
1115
1116 // distance into new region to place avatar
1117 const float enterDistance = 0.5f;
1118
1119 if (scene.TestBorderCross(pos + westCross, Cardinals.W))
1120 {
1121 if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1122 {
1123 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1124 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1125 }
1126 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1127 {
1128 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1129 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1130 {
1131 neighboury--;
1132 newpos.Y = Constants.RegionSize - enterDistance;
1133 }
1134 else
1135 {
1136 neighboury = b.TriggerRegionY;
1137 neighbourx = b.TriggerRegionX;
1138
1139 Vector3 newposition = pos;
1140 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1141 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1142 agent.ControllingClient.SendAgentAlertMessage(
1143 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1144 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1145 return;
1146 }
1147 }
1148
1149 Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W);
1150 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1151 {
1152 neighbourx--;
1153 newpos.X = Constants.RegionSize - enterDistance;
1154 }
1155 else
1156 {
1157 neighboury = ba.TriggerRegionY;
1158 neighbourx = ba.TriggerRegionX;
1159
1160
1161 Vector3 newposition = pos;
1162 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1163 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1164 agent.ControllingClient.SendAgentAlertMessage(
1165 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1166 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1167
1168
1169 return;
1170 }
1171
1172 }
1173 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E))
1174 {
1175 Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E);
1176 neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1177 newpos.X = enterDistance;
1178
1179 if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1180 {
1181 Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1182 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1183 {
1184 neighboury--;
1185 newpos.Y = Constants.RegionSize - enterDistance;
1186 }
1187 else
1188 {
1189 neighboury = ba.TriggerRegionY;
1190 neighbourx = ba.TriggerRegionX;
1191 Vector3 newposition = pos;
1192 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1193 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1194 agent.ControllingClient.SendAgentAlertMessage(
1195 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1196 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1197 return;
1198 }
1199 }
1200 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1201 {
1202 Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1203 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
1204 newpos.Y = enterDistance;
1205 }
1206
1207
1208 }
1209 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1210 {
1211 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1212 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1213 {
1214 neighboury--;
1215 newpos.Y = Constants.RegionSize - enterDistance;
1216 }
1217 else
1218 {
1219 neighboury = b.TriggerRegionY;
1220 neighbourx = b.TriggerRegionX;
1221 Vector3 newposition = pos;
1222 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1223 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1224 agent.ControllingClient.SendAgentAlertMessage(
1225 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1226 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1227 return;
1228 }
1229 }
1230 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1231 {
1232
1233 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1234 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1235 newpos.Y = enterDistance;
1236 }
1237
1238 /*
1239
1240 if (pos.X < boundaryDistance) //West
1241 {
1242 neighbourx--;
1243 newpos.X = Constants.RegionSize - enterDistance;
1244 }
1245 else if (pos.X > Constants.RegionSize - boundaryDistance) // East
1246 {
1247 neighbourx++;
1248 newpos.X = enterDistance;
1249 }
1250
1251 if (pos.Y < boundaryDistance) // South
1252 {
1253 neighboury--;
1254 newpos.Y = Constants.RegionSize - enterDistance;
1255 }
1256 else if (pos.Y > Constants.RegionSize - boundaryDistance) // North
1257 {
1258 neighboury++;
1259 newpos.Y = enterDistance;
1260 }
1261 */
1262
1263 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
1264 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);
1265 }
1266
1267 public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY,
1268 Vector3 position,
1269 Scene initiatingScene);
1270
1271 public void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1272 Scene initiatingScene)
1273 {
1274
1275 // This assumes that we know what our neighbors are.
1276
1277 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync;
1278 d.BeginInvoke(agent,regionX,regionY,position,initiatingScene,
1279 InformClientToInitiateTeleportToLocationCompleted,
1280 d);
1281 }
1282
1283 public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1284 Scene initiatingScene)
1285 {
1286 Thread.Sleep(10000);
1287 IMessageTransferModule im = initiatingScene.RequestModuleInterface<IMessageTransferModule>();
1288 if (im != null)
1289 {
1290 UUID gotoLocation = Util.BuildFakeParcelID(
1291 Util.UIntsToLong(
1292 (regionX *
1293 (uint)Constants.RegionSize),
1294 (regionY *
1295 (uint)Constants.RegionSize)),
1296 (uint)(int)position.X,
1297 (uint)(int)position.Y,
1298 (uint)(int)position.Z);
1299 GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero,
1300 "Region", agent.UUID,
1301 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
1302 "", gotoLocation, false, new Vector3(127, 0, 0),
1303 new Byte[0]);
1304 im.SendInstantMessage(m, delegate(bool success)
1305 {
1306 m_log.DebugFormat("[CLIENT]: Client Initiating Teleport sending IM success = {0}", success);
1307 });
1308
1309 }
1310 }
1311
1312 private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar)
1313 {
1314 InformClientToInitateTeleportToLocationDelegate icon =
1315 (InformClientToInitateTeleportToLocationDelegate) iar.AsyncState;
1316 icon.EndInvoke(iar);
1317 }
1318
1319 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying);
1320
1321 /// <summary>
1322 /// This Closes child agents on neighboring regions
1323 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
1324 /// </summary>
1325 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying)
1326 {
1327 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
1328
1329 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
1330
1331 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
1332 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1333
1334 if (neighbourRegion != null && agent.ValidateAttachments())
1335 {
1336 pos = pos + (agent.Velocity);
1337
1338 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1339 //if (userInfo != null)
1340 //{
1341 // userInfo.DropInventory();
1342 //}
1343 //else
1344 //{
1345 // m_log.WarnFormat("[SCENE COMM]: No cached user info found for {0} {1} on leaving region {2}",
1346 // agent.Name, agent.UUID, agent.Scene.RegionInfo.RegionName);
1347 //}
1348
1349 //bool crossingSuccessful =
1350 // CrossToNeighbouringRegion(neighbourHandle, agent.ControllingClient.AgentId, pos,
1351 //isFlying);
1352
1353 SetInTransit(agent.UUID);
1354 AgentData cAgent = new AgentData();
1355 agent.CopyTo(cAgent);
1356 cAgent.Position = pos;
1357 if (isFlying)
1358 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1359 cAgent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
1360 "/agent/" + agent.UUID.ToString() + "/" + agent.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
1361
1362 m_interregionCommsOut.SendChildAgentUpdate(neighbourHandle, cAgent);
1363
1364 // Next, let's close the child agent connections that are too far away.
1365 agent.CloseChildAgents(neighbourx, neighboury);
1366
1367 //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
1368 agent.ControllingClient.RequestClientInfo();
1369
1370 //m_log.Debug("BEFORE CROSS");
1371 //Scene.DumpChildrenSeeds(UUID);
1372 //DumpKnownRegions();
1373 string agentcaps;
1374 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
1375 {
1376 m_log.ErrorFormat("[SCENE COMM]: No CAPS information for region handle {0}, exiting CrossToNewRegion.",
1377 neighbourRegion.RegionHandle);
1378 return agent;
1379 }
1380 // TODO Should construct this behind a method
1381 string capsPath =
1382 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
1383 + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/";
1384
1385 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
1386
1387 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
1388 if (eq != null)
1389 {
1390 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1391 capsPath, agent.UUID, agent.ControllingClient.SessionId);
1392 }
1393 else
1394 {
1395 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1396 capsPath);
1397 }
1398
1399 if (!WaitForCallback(agent.UUID))
1400 {
1401 ResetFromTransit(agent.UUID);
1402
1403 // Yikes! We should just have a ref to scene here.
1404 agent.Scene.InformClientOfNeighbours(agent);
1405
1406 return agent;
1407 }
1408
1409 agent.MakeChildAgent();
1410 // now we have a child agent in this region. Request all interesting data about other (root) agents
1411 agent.SendInitialFullUpdateToAllClients();
1412
1413 agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true);
1414
1415 // m_scene.SendKillObject(m_localId);
1416
1417 agent.Scene.NotifyMyCoarseLocationChange();
1418 // the user may change their profile information in other region,
1419 // so the userinfo in UserProfileCache is not reliable any more, delete it
1420 if (agent.Scene.NeedSceneCacheClear(agent.UUID))
1421 {
1422 agent.Scene.CommsManager.UserProfileCacheService.RemoveUser(agent.UUID);
1423 m_log.DebugFormat(
1424 "[SCENE COMM]: User {0} is going to another region, profile cache removed", agent.UUID);
1425 }
1426 }
1427
1428 //m_log.Debug("AFTER CROSS");
1429 //Scene.DumpChildrenSeeds(UUID);
1430 //DumpKnownRegions();
1431 return agent;
1432 }
1433
1434 private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
1435 {
1436 CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState;
1437 ScenePresence agent = icon.EndInvoke(iar);
1438
1439 // If the cross was successful, this agent is a child agent
1440 if (agent.IsChildAgent)
1441 {
1442 agent.Reset();
1443 }
1444 else // Not successful
1445 {
1446 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1447 //if (userInfo != null)
1448 //{
1449 // userInfo.FetchInventory();
1450 //}
1451 agent.RestoreInCurrentScene();
1452 }
1453 // In any case
1454 agent.NotInTransit();
1455
1456 //m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
1457 }
1458
1459
1460 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
1461 {
1462 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
1463 }
1464
1465 // deprecated as of 2008-08-27
1466 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
1467 {
1468 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
1469 }
1470
1471 public void ClearUserAgent(UUID avatarID)
1472 {
1473 m_commsProvider.UserService.ClearUserAgent(avatarID);
1474 }
1475
1476 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
1477 {
1478 m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms);
1479 }
1480
1481 public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
1482 {
1483 m_commsProvider.UpdateUserFriendPerms(friendlistowner, friend, perms);
1484 }
1485
1486 public void RemoveUserFriend(UUID friendlistowner, UUID friend)
1487 {
1488 m_commsProvider.RemoveUserFriend(friendlistowner, friend);
1489 }
1490
1491 public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
1492 {
1493 return m_commsProvider.GetUserFriendList(friendlistowner);
1494 }
1495
1496 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
1497 {
1498 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
1499 }
1500
1501 public List<GridRegion> RequestNamedRegions(string name, int maxNumber) 304 public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
1502 { 305 {
1503 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); 306 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
1504 } 307 }
1505 308
1506 //private void Dump(string msg, List<ulong> handles)
1507 //{
1508 // m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
1509 // foreach (ulong handle in handles)
1510 // {
1511 // uint x, y;
1512 // Utils.LongToUInts(handle, out x, out y);
1513 // x = x / Constants.RegionSize;
1514 // y = y / Constants.RegionSize;
1515 // m_log.InfoFormat("({0}, {1})", x, y);
1516 // }
1517 //}
1518 } 309 }
1519} 310}
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index bbcb85e..3a1962c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -35,6 +35,7 @@ using log4net;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes.Types; 36using OpenSim.Region.Framework.Scenes.Types;
37using OpenSim.Region.Physics.Manager; 37using OpenSim.Region.Physics.Manager;
38using OpenSim.Region.Framework.Interfaces;
38 39
39namespace OpenSim.Region.Framework.Scenes 40namespace OpenSim.Region.Framework.Scenes
40{ 41{
@@ -164,9 +165,10 @@ namespace OpenSim.Region.Framework.Scenes
164 165
165 protected internal void UpdatePresences() 166 protected internal void UpdatePresences()
166 { 167 {
167 ScenePresence[] updateScenePresences = GetScenePresences(); 168 ForEachScenePresence(delegate(ScenePresence presence)
168 for (int i = 0; i < updateScenePresences.Length; i++) 169 {
169 updateScenePresences[i].Update(); 170 presence.Update();
171 });
170 } 172 }
171 173
172 protected internal float UpdatePhysics(double elapsed) 174 protected internal float UpdatePhysics(double elapsed)
@@ -195,9 +197,10 @@ namespace OpenSim.Region.Framework.Scenes
195 197
196 protected internal void UpdateScenePresenceMovement() 198 protected internal void UpdateScenePresenceMovement()
197 { 199 {
198 ScenePresence[] moveEntities = GetScenePresences(); 200 ForEachScenePresence(delegate(ScenePresence presence)
199 for (int i = 0; i < moveEntities.Length; i++) 201 {
200 moveEntities[i].UpdateMovement(); 202 presence.UpdateMovement();
203 });
201 } 204 }
202 205
203 #endregion 206 #endregion
@@ -475,7 +478,7 @@ namespace OpenSim.Region.Framework.Scenes
475 if (group != null) 478 if (group != null)
476 { 479 {
477 //group.DetachToGround(); 480 //group.DetachToGround();
478 m_parentScene.DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); 481 m_parentScene.AttachmentsModule.ShowDetachInUserInventory(group.GetFromItemID(), remoteClient);
479 } 482 }
480 } 483 }
481 484
@@ -509,212 +512,6 @@ namespace OpenSim.Region.Framework.Scenes
509 } 512 }
510 } 513 }
511 514
512 /// <summary>
513 /// Event Handling routine for Attach Object
514 /// </summary>
515 /// <param name="remoteClient"></param>
516 /// <param name="objectLocalID"></param>
517 /// <param name="AttachmentPt"></param>
518 /// <param name="rot"></param>
519 protected internal void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent)
520 {
521 // If we can't take it, we can't attach it!
522 SceneObjectPart part = m_parentScene.GetSceneObjectPart(objectLocalID);
523 if (part == null)
524 return;
525
526 if (!m_parentScene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId))
527 return;
528
529 // Calls attach with a Zero position
530 if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false))
531 {
532 m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
533
534 // Save avatar attachment information
535 ScenePresence presence;
536 if (m_parentScene.AvatarFactory != null && m_parentScene.TryGetAvatar(remoteClient.AgentId, out presence))
537 {
538 m_log.Info(
539 "[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
540 + ", AttachmentPoint: " + AttachmentPt);
541
542 m_parentScene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
543 }
544 }
545 }
546
547 /// <summary>
548 /// Rez an attachment
549 /// </summary>
550 /// <param name="remoteClient"></param>
551 /// <param name="itemID"></param>
552 /// <param name="AttachmentPt"></param>
553 /// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
554 public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
555 {
556 SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient,
557 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
558 false, false, remoteClient.AgentId, true);
559
560// m_log.DebugFormat(
561// "[SCENE GRAPH]: Retrieved single object {0} for attachment to {1} on point {2}",
562// objatt.Name, remoteClient.Name, AttachmentPt);
563
564 if (objatt != null)
565 {
566 bool tainted = false;
567 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
568 tainted = true;
569
570 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
571 //objatt.ScheduleGroupForFullUpdate();
572
573 if (tainted)
574 objatt.HasGroupChanged = true;
575
576 // Fire after attach, so we don't get messy perms dialogs
577 // 3 == AttachedRez
578 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3);
579
580 // Do this last so that event listeners have access to all the effects of the attachment
581 m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
582 }
583 else
584 {
585 m_log.WarnFormat(
586 "[SCENE GRAPH]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
587 itemID, remoteClient.Name, AttachmentPt);
588 }
589
590 return objatt;
591 }
592
593 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
594 // To LocalId or UUID, *THAT* is the question. How now Brown UUID??
595 public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
596 {
597 if (itemID == UUID.Zero) // If this happened, someone made a mistake....
598 return;
599
600 // We can NOT use the dictionries here, as we are looking
601 // for an entity by the fromAssetID, which is NOT the prim UUID
602 //
603 List<EntityBase> detachEntities = GetEntities();
604 SceneObjectGroup group;
605
606 foreach (EntityBase entity in detachEntities)
607 {
608 if (entity is SceneObjectGroup)
609 {
610 group = (SceneObjectGroup)entity;
611 if (group.GetFromItemID() == itemID)
612 {
613 m_parentScene.SendAttachEvent(group.LocalId, itemID, UUID.Zero);
614 bool hasScripts = false;
615 foreach (SceneObjectPart part in group.Children.Values)
616 {
617 if (part.Inventory.ContainsScripts())
618 {
619 hasScripts = true;
620 break;
621 }
622 }
623
624 if (hasScripts) // Allow the object to execute the attach(NULL_KEY) event
625 System.Threading.Thread.Sleep(100);
626 group.DetachToInventoryPrep();
627 m_log.Debug("[DETACH]: Saving attachpoint: " +
628 ((uint)group.GetAttachmentPoint()).ToString());
629 m_parentScene.UpdateKnownItem(remoteClient, group,
630 group.GetFromItemID(), group.OwnerID);
631 m_parentScene.DeleteSceneObject(group, false);
632 return;
633 }
634 }
635 }
636 }
637
638 /// <summary>
639 /// Attach a scene object to an avatar.
640 /// </summary>
641 /// <param name="remoteClient"></param>
642 /// <param name="objectLocalID"></param>
643 /// <param name="AttachmentPt"></param>
644 /// <param name="rot"></param>
645 /// <param name="attachPos"></param>
646 /// <param name="silent"></param>
647 /// <returns>true if the attachment was successful, false otherwise</returns>
648 protected internal bool AttachObject(
649 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent)
650 {
651 SceneObjectGroup group = GetGroupByPrim(objectLocalID);
652 if (group != null)
653 {
654 if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
655 {
656 // If the attachment point isn't the same as the one previously used
657 // set it's offset position = 0 so that it appears on the attachment point
658 // and not in a weird location somewhere unknown.
659 if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
660 {
661 attachPos = Vector3.Zero;
662 }
663
664 // AttachmentPt 0 means the client chose to 'wear' the attachment.
665 if (AttachmentPt == 0)
666 {
667 // Check object for stored attachment point
668 AttachmentPt = (uint)group.GetAttachmentPoint();
669 }
670
671 // if we still didn't find a suitable attachment point.......
672 if (AttachmentPt == 0)
673 {
674 // Stick it on left hand with Zero Offset from the attachment point.
675 AttachmentPt = (uint)AttachmentPoint.LeftHand;
676 attachPos = Vector3.Zero;
677 }
678
679 group.SetAttachmentPoint((byte)AttachmentPt);
680 group.AbsolutePosition = attachPos;
681
682 // Saves and gets itemID
683 UUID itemId;
684
685 if (group.GetFromItemID() == UUID.Zero)
686 {
687 m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId);
688 }
689 else
690 {
691 itemId = group.GetFromItemID();
692 }
693
694 m_parentScene.AttachObject(remoteClient, AttachmentPt, itemId, group);
695
696 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent);
697 // In case it is later dropped again, don't let
698 // it get cleaned up
699 //
700 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
701 group.HasGroupChanged = false;
702 }
703 else
704 {
705 remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false);
706 return false;
707 }
708 }
709 else
710 {
711 m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID);
712 return false;
713 }
714
715 return true;
716 }
717
718 protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) 515 protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance)
719 { 516 {
720 ScenePresence newAvatar = null; 517 ScenePresence newAvatar = null;
@@ -845,18 +642,16 @@ namespace OpenSim.Region.Framework.Scenes
845 642
846 public void RecalculateStats() 643 public void RecalculateStats()
847 { 644 {
848 ScenePresence[] presences = GetScenePresences();
849 int rootcount = 0; 645 int rootcount = 0;
850 int childcount = 0; 646 int childcount = 0;
851 647
852 for (int i = 0; i < presences.Length; i++) 648 ForEachScenePresence(delegate(ScenePresence presence)
853 { 649 {
854 ScenePresence user = presences[i]; 650 if (presence.IsChildAgent)
855 if (user.IsChildAgent)
856 ++childcount; 651 ++childcount;
857 else 652 else
858 ++rootcount; 653 ++rootcount;
859 } 654 });
860 655
861 m_numRootAgents = rootcount; 656 m_numRootAgents = rootcount;
862 m_numChildAgents = childcount; 657 m_numChildAgents = childcount;
@@ -903,25 +698,6 @@ namespace OpenSim.Region.Framework.Scenes
903 #endregion 698 #endregion
904 699
905 #region Get Methods 700 #region Get Methods
906
907 /// <summary>
908 /// Request a List of all scene presences in this scene. This is a new list, so no
909 /// locking is required to iterate over it.
910 /// </summary>
911 /// <returns></returns>
912 protected internal ScenePresence[] GetScenePresences()
913 {
914 return m_scenePresenceArray;
915 }
916
917 protected internal List<ScenePresence> GetAvatars()
918 {
919 List<ScenePresence> result =
920 GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; });
921
922 return result;
923 }
924
925 /// <summary> 701 /// <summary>
926 /// Get the controlling client for the given avatar, if there is one. 702 /// Get the controlling client for the given avatar, if there is one.
927 /// 703 ///
@@ -948,41 +724,83 @@ namespace OpenSim.Region.Framework.Scenes
948 } 724 }
949 725
950 /// <summary> 726 /// <summary>
951 /// Request a filtered list of m_scenePresences in this World 727 /// Request a copy of m_scenePresences in this World
728 /// There is no guarantee that presences will remain in the scene after the list is returned.
729 /// This list should remain private to SceneGraph. Callers wishing to iterate should instead
730 /// pass a delegate to ForEachScenePresence.
952 /// </summary> 731 /// </summary>
953 /// <returns></returns> 732 /// <returns></returns>
954 protected internal List<ScenePresence> GetScenePresences(FilterAvatarList filter) 733 private List<ScenePresence> GetScenePresences()
955 { 734 {
956 // No locking of scene presences here since we're passing back a list... 735 lock (m_scenePresences)
957 736 return new List<ScenePresence>(m_scenePresenceArray);
958 List<ScenePresence> result = new List<ScenePresence>(); 737 }
959 ScenePresence[] scenePresences = GetScenePresences();
960 738
961 for (int i = 0; i < scenePresences.Length; i++) 739 /// <summary>
740 /// Request a scene presence by UUID. Fast, indexed lookup.
741 /// </summary>
742 /// <param name="agentID"></param>
743 /// <returns>null if the presence was not found</returns>
744 protected internal ScenePresence GetScenePresence(UUID agentID)
745 {
746 ScenePresence sp;
747 lock (m_scenePresences)
962 { 748 {
963 ScenePresence avatar = scenePresences[i]; 749 m_scenePresences.TryGetValue(agentID, out sp);
964 if (filter(avatar))
965 result.Add(avatar);
966 } 750 }
751 return sp;
752 }
967 753
968 return result; 754 /// <summary>
755 /// Request the scene presence by name.
756 /// </summary>
757 /// <param name="firstName"></param>
758 /// <param name="lastName"></param>
759 /// <returns>null if the presence was not found</returns>
760 protected internal ScenePresence GetScenePresence(string firstName, string lastName)
761 {
762 foreach (ScenePresence presence in GetScenePresences())
763 {
764 if (presence.Firstname == firstName && presence.Lastname == lastName)
765 return presence;
766 }
767 return null;
969 } 768 }
970 769
971 /// <summary> 770 /// <summary>
972 /// Request a scene presence by UUID 771 /// Request the scene presence by localID.
973 /// </summary> 772 /// </summary>
974 /// <param name="avatarID"></param> 773 /// <param name="localID"></param>
975 /// <returns>null if the agent was not found</returns> 774 /// <returns>null if the presence was not found</returns>
976 protected internal ScenePresence GetScenePresence(UUID agentID) 775 protected internal ScenePresence GetScenePresence(uint localID)
776 {
777 foreach (ScenePresence presence in GetScenePresences())
778 if (presence.LocalId == localID)
779 return presence;
780 return null;
781 }
782
783 protected internal bool TryGetScenePresence(UUID agentID, out ScenePresence avatar)
977 { 784 {
978 ScenePresence sp;
979
980 lock (m_scenePresences) 785 lock (m_scenePresences)
981 { 786 {
982 m_scenePresences.TryGetValue(agentID, out sp); 787 m_scenePresences.TryGetValue(agentID, out avatar);
983 } 788 }
789 return (avatar != null);
790 }
984 791
985 return sp; 792 protected internal bool TryGetAvatarByName(string name, out ScenePresence avatar)
793 {
794 avatar = null;
795 foreach (ScenePresence presence in GetScenePresences())
796 {
797 if (String.Compare(name, presence.ControllingClient.Name, true) == 0)
798 {
799 avatar = presence;
800 break;
801 }
802 }
803 return (avatar != null);
986 } 804 }
987 805
988 /// <summary> 806 /// <summary>
@@ -1136,34 +954,6 @@ namespace OpenSim.Region.Framework.Scenes
1136 return group.GetChildPart(fullID); 954 return group.GetChildPart(fullID);
1137 } 955 }
1138 956
1139 protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
1140 {
1141 lock (m_scenePresences)
1142 return m_scenePresences.TryGetValue(avatarId, out avatar);
1143 }
1144
1145 protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
1146 {
1147 ScenePresence[] presences = GetScenePresences();
1148
1149 for (int i = 0; i < presences.Length; i++)
1150 {
1151 ScenePresence presence = presences[i];
1152
1153 if (!presence.IsChildAgent)
1154 {
1155 if (String.Compare(avatarName, presence.ControllingClient.Name, true) == 0)
1156 {
1157 avatar = presence;
1158 return true;
1159 }
1160 }
1161 }
1162
1163 avatar = null;
1164 return false;
1165 }
1166
1167 /// <summary> 957 /// <summary>
1168 /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over 958 /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over
1169 /// it 959 /// it
@@ -1226,6 +1016,10 @@ namespace OpenSim.Region.Framework.Scenes
1226 return UUID.Zero; 1016 return UUID.Zero;
1227 } 1017 }
1228 1018
1019 /// <summary>
1020 /// Performs action on all scene object groups.
1021 /// </summary>
1022 /// <param name="action"></param>
1229 protected internal void ForEachSOG(Action<SceneObjectGroup> action) 1023 protected internal void ForEachSOG(Action<SceneObjectGroup> action)
1230 { 1024 {
1231 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); 1025 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
@@ -1242,6 +1036,46 @@ namespace OpenSim.Region.Framework.Scenes
1242 } 1036 }
1243 } 1037 }
1244 } 1038 }
1039
1040
1041 /// <summary>
1042 /// Performs action on all scene presences. This can ultimately run the actions in parallel but
1043 /// any delegates passed in will need to implement their own locking on data they reference and
1044 /// modify outside of the scope of the delegate.
1045 /// </summary>
1046 /// <param name="action"></param>
1047 public void ForEachScenePresence(Action<ScenePresence> action)
1048 {
1049 // Once all callers have their delegates configured for parallelism, we can unleash this
1050 /*
1051 Action<ScenePresence> protectedAction = new Action<ScenePresence>(delegate(ScenePresence sp)
1052 {
1053 try
1054 {
1055 action(sp);
1056 }
1057 catch (Exception e)
1058 {
1059 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1060 m_log.Info("[BUG] Stack Trace: " + e.StackTrace);
1061 }
1062 });
1063 Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction);
1064 */
1065 // For now, perform actiona serially
1066 foreach (ScenePresence sp in GetScenePresences())
1067 {
1068 try
1069 {
1070 action(sp);
1071 }
1072 catch (Exception e)
1073 {
1074 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1075 m_log.Info("[BUG] Stack Trace: " + e.StackTrace);
1076 }
1077 }
1078 }
1245 1079
1246 #endregion 1080 #endregion
1247 1081
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index c2e3370..3b84734 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -414,22 +414,18 @@ namespace OpenSim.Region.Framework.Scenes
414 ForEachCurrentScene( 414 ForEachCurrentScene(
415 delegate(Scene scene) 415 delegate(Scene scene)
416 { 416 {
417 ScenePresence[] scenePresences = scene.GetScenePresences(); 417 scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
418
419 for (int i = 0; i < scenePresences.Length; i++)
420 { 418 {
421 ScenePresence scenePresence = scenePresences[i];
422
423 if (!scenePresence.IsChildAgent) 419 if (!scenePresence.IsChildAgent)
424 { 420 {
425 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}", 421 m_log.DebugFormat("Packet debug for {0} {1} set to {2}",
426 scenePresence.Firstname, 422 scenePresence.Firstname,
427 scenePresence.Lastname, 423 scenePresence.Lastname,
428 newDebug); 424 newDebug);
429 425
430 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug); 426 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug);
431 } 427 }
432 } 428 });
433 } 429 }
434 ); 430 );
435 } 431 }
@@ -441,14 +437,11 @@ namespace OpenSim.Region.Framework.Scenes
441 ForEachCurrentScene( 437 ForEachCurrentScene(
442 delegate(Scene scene) 438 delegate(Scene scene)
443 { 439 {
444 ScenePresence[] scenePresences = scene.GetScenePresences(); 440 scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
445
446 for (int i = 0; i < scenePresences.Length; i++)
447 { 441 {
448 ScenePresence scenePresence = scenePresences[i];
449 if (!scenePresence.IsChildAgent) 442 if (!scenePresence.IsChildAgent)
450 avatars.Add(scenePresence); 443 avatars.Add(scenePresence);
451 } 444 });
452 } 445 }
453 ); 446 );
454 447
@@ -461,18 +454,20 @@ namespace OpenSim.Region.Framework.Scenes
461 454
462 ForEachCurrentScene(delegate(Scene scene) 455 ForEachCurrentScene(delegate(Scene scene)
463 { 456 {
464 ScenePresence[] scenePresences = scene.GetScenePresences(); 457 scene.ForEachScenePresence(delegate(ScenePresence sp)
465 presences.AddRange(scenePresences); 458 {
459 presences.Add(sp);
460 });
466 }); 461 });
467 462
468 return presences; 463 return presences;
469 } 464 }
470 465
471 public RegionInfo GetRegionInfo(ulong regionHandle) 466 public RegionInfo GetRegionInfo(UUID regionID)
472 { 467 {
473 foreach (Scene scene in m_localScenes) 468 foreach (Scene scene in m_localScenes)
474 { 469 {
475 if (scene.RegionInfo.RegionHandle == regionHandle) 470 if (scene.RegionInfo.RegionID == regionID)
476 { 471 {
477 return scene.RegionInfo; 472 return scene.RegionInfo;
478 } 473 }
@@ -491,11 +486,11 @@ namespace OpenSim.Region.Framework.Scenes
491 ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); }); 486 ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
492 } 487 }
493 488
494 public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) 489 public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
495 { 490 {
496 foreach (Scene scene in m_localScenes) 491 foreach (Scene scene in m_localScenes)
497 { 492 {
498 if (scene.TryGetAvatar(avatarId, out avatar)) 493 if (scene.TryGetScenePresence(avatarId, out avatar))
499 { 494 {
500 return true; 495 return true;
501 } 496 }
@@ -510,7 +505,7 @@ namespace OpenSim.Region.Framework.Scenes
510 ScenePresence avatar = null; 505 ScenePresence avatar = null;
511 foreach (Scene mScene in m_localScenes) 506 foreach (Scene mScene in m_localScenes)
512 { 507 {
513 if (mScene.TryGetAvatar(avatarId, out avatar)) 508 if (mScene.TryGetScenePresence(avatarId, out avatar))
514 { 509 {
515 scene = mScene; 510 scene = mScene;
516 return true; 511 return true;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 5951a92..014b007 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -377,6 +377,7 @@ namespace OpenSim.Region.Framework.Scenes
377 RootPart.ScriptSetPhysicsStatus(false); 377 RootPart.ScriptSetPhysicsStatus(false);
378 Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), 378 Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
379 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); 379 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
380 lockPartsForRead(false);
380 return; 381 return;
381 } 382 }
382 } 383 }
@@ -489,8 +490,8 @@ namespace OpenSim.Region.Framework.Scenes
489 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); 490 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
490 public List<SceneObjectPart> PlaySoundSlavePrims 491 public List<SceneObjectPart> PlaySoundSlavePrims
491 { 492 {
492 get { return m_LoopSoundSlavePrims; } 493 get { return m_PlaySoundSlavePrims; }
493 set { m_LoopSoundSlavePrims = value; } 494 set { m_PlaySoundSlavePrims = value; }
494 } 495 }
495 496
496 private SceneObjectPart m_LoopSoundMasterPrim = null; 497 private SceneObjectPart m_LoopSoundMasterPrim = null;
@@ -644,7 +645,7 @@ namespace OpenSim.Region.Framework.Scenes
644 ApplyPhysics(m_scene.m_physicalPrim); 645 ApplyPhysics(m_scene.m_physicalPrim);
645 646
646 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled 647 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
647 // for the same object with very different properties. The caller must schedule the update. 648 // for the same object with very different properties. The caller must schedule the update.
648 //ScheduleGroupForFullUpdate(); 649 //ScheduleGroupForFullUpdate();
649 } 650 }
650 651
@@ -1369,21 +1370,20 @@ namespace OpenSim.Region.Framework.Scenes
1369 { 1370 {
1370// part.Inventory.RemoveScriptInstances(); 1371// part.Inventory.RemoveScriptInstances();
1371 1372
1372 ScenePresence[] avatars = Scene.GetScenePresences(); 1373 Scene.ForEachScenePresence(delegate (ScenePresence sp)
1373 for (int i = 0; i < avatars.Length; i++)
1374 { 1374 {
1375 if (avatars[i].ParentID == LocalId) 1375 if (sp.ParentID == LocalId)
1376 { 1376 {
1377 avatars[i].StandUp(); 1377 sp.StandUp();
1378 } 1378 }
1379 1379
1380 if (!silent) 1380 if (!silent)
1381 { 1381 {
1382 part.UpdateFlag = 0; 1382 part.UpdateFlag = 0;
1383 if (part == m_rootPart) 1383 if (part == m_rootPart)
1384 avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId); 1384 sp.ControllingClient.SendKillObject(m_regionHandle, part.LocalId);
1385 } 1385 }
1386 } 1386 });
1387 1387
1388 } 1388 }
1389 1389
@@ -1605,11 +1605,10 @@ namespace OpenSim.Region.Framework.Scenes
1605 1605
1606 #endregion 1606 #endregion
1607 1607
1608 #region Client Updating
1609
1610 public void SendFullUpdateToClient(IClientAPI remoteClient) 1608 public void SendFullUpdateToClient(IClientAPI remoteClient)
1611 { 1609 {
1612 SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); 1610 RootPart.SendFullUpdate(
1611 remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID));
1613 1612
1614 lockPartsForRead(true); 1613 lockPartsForRead(true);
1615 { 1614 {
@@ -1617,42 +1616,12 @@ namespace OpenSim.Region.Framework.Scenes
1617 { 1616 {
1618 1617
1619 if (part != RootPart) 1618 if (part != RootPart)
1620 SendPartFullUpdate(remoteClient, part, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); 1619 part.SendFullUpdate(
1621 1620 remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID));
1622 }
1623 }
1624 lockPartsForRead(false);
1625 }
1626
1627 /// <summary>
1628 /// Send a full update to the client for the given part
1629 /// </summary>
1630 /// <param name="remoteClient"></param>
1631 /// <param name="part"></param>
1632 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags)
1633 {
1634// m_log.DebugFormat(
1635// "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
1636
1637 if (m_rootPart.UUID == part.UUID)
1638 {
1639 if (IsAttachment)
1640 {
1641 part.SendFullUpdateToClient(remoteClient, m_rootPart.AttachedPos, clientFlags);
1642 }
1643 else
1644 {
1645 part.SendFullUpdateToClient(remoteClient, AbsolutePosition, clientFlags);
1646 } 1621 }
1647 } 1622 }
1648 else
1649 {
1650 part.SendFullUpdateToClient(remoteClient, clientFlags);
1651 }
1652 } 1623 }
1653 1624
1654 #endregion
1655
1656 #region Copying 1625 #region Copying
1657 1626
1658 /// <summary> 1627 /// <summary>
@@ -2164,14 +2133,12 @@ namespace OpenSim.Region.Framework.Scenes
2164 public void ScheduleTerseUpdateToAvatar(ScenePresence presence) 2133 public void ScheduleTerseUpdateToAvatar(ScenePresence presence)
2165 { 2134 {
2166 lockPartsForRead(true); 2135 lockPartsForRead(true);
2136
2137 foreach (SceneObjectPart part in m_parts.Values)
2167 { 2138 {
2168 foreach (SceneObjectPart part in m_parts.Values) 2139 part.AddTerseUpdateToAvatar(presence);
2169 {
2170
2171 part.AddTerseUpdateToAvatar(presence);
2172
2173 }
2174 } 2140 }
2141
2175 lockPartsForRead(false); 2142 lockPartsForRead(false);
2176 } 2143 }
2177 2144
@@ -2203,21 +2170,12 @@ namespace OpenSim.Region.Framework.Scenes
2203 /// </summary> 2170 /// </summary>
2204 public void ScheduleGroupForTerseUpdate() 2171 public void ScheduleGroupForTerseUpdate()
2205 { 2172 {
2206<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
2207 lockPartsForRead(true); 2173 lockPartsForRead(true);
2208======= 2174 foreach (SceneObjectPart part in m_parts.Values)
2209// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID);
2210
2211 lock (m_parts)
2212>>>>>>> 0.6.9-post-fixes:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
2213 { 2175 {
2214 foreach (SceneObjectPart part in m_parts.Values) 2176 part.ScheduleTerseUpdate();
2215 {
2216
2217 part.ScheduleTerseUpdate();
2218
2219 }
2220 } 2177 }
2178
2221 lockPartsForRead(false); 2179 lockPartsForRead(false);
2222 } 2180 }
2223 2181
@@ -3071,8 +3029,8 @@ namespace OpenSim.Region.Framework.Scenes
3071 { 3029 {
3072 if (obPart.UUID != m_rootPart.UUID) 3030 if (obPart.UUID != m_rootPart.UUID)
3073 { 3031 {
3074 obPart.IgnoreUndoUpdate = true;
3075 Vector3 oldSize = new Vector3(obPart.Scale); 3032 Vector3 oldSize = new Vector3(obPart.Scale);
3033 obPart.IgnoreUndoUpdate = true;
3076 3034
3077 float f = 1.0f; 3035 float f = 1.0f;
3078 float a = 1.0f; 3036 float a = 1.0f;
@@ -3765,15 +3723,11 @@ namespace OpenSim.Region.Framework.Scenes
3765 3723
3766 HasGroupChanged = true; 3724 HasGroupChanged = true;
3767 } 3725 }
3768<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
3769 lockPartsForRead(false); 3726 lockPartsForRead(false);
3770 ScheduleGroupForFullUpdate();
3771=======
3772 3727
3773 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled 3728 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
3774 // for the same object with very different properties. The caller must schedule the update. 3729 // for the same object with very different properties. The caller must schedule the update.
3775 //ScheduleGroupForFullUpdate(); 3730 //ScheduleGroupForFullUpdate();
3776>>>>>>> 0.6.9-post-fixes:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
3777 } 3731 }
3778 3732
3779 public void TriggerScriptChangedEvent(Changed val) 3733 public void TriggerScriptChangedEvent(Changed val)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 548a64f..4b2641c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -573,8 +573,8 @@ namespace OpenSim.Region.Framework.Scenes
573 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); 573 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
574 public List<SceneObjectPart> PlaySoundSlavePrims 574 public List<SceneObjectPart> PlaySoundSlavePrims
575 { 575 {
576 get { return m_LoopSoundSlavePrims; } 576 get { return m_PlaySoundSlavePrims; }
577 set { m_LoopSoundSlavePrims = value; } 577 set { m_PlaySoundSlavePrims = value; }
578 } 578 }
579 579
580 private SceneObjectPart m_LoopSoundMasterPrim = null; 580 private SceneObjectPart m_LoopSoundMasterPrim = null;
@@ -682,7 +682,7 @@ namespace OpenSim.Region.Framework.Scenes
682 if (m_parentGroup != null) // TODO can there be a SOP without a SOG? 682 if (m_parentGroup != null) // TODO can there be a SOP without a SOG?
683 { 683 {
684 ScenePresence avatar; 684 ScenePresence avatar;
685 if (m_parentGroup.Scene.TryGetAvatar(m_sitTargetAvatar, out avatar)) 685 if (m_parentGroup.Scene.TryGetScenePresence(m_sitTargetAvatar, out avatar))
686 { 686 {
687 avatar.ParentPosition = GetWorldPosition(); 687 avatar.ParentPosition = GetWorldPosition();
688 } 688 }
@@ -1208,15 +1208,14 @@ namespace OpenSim.Region.Framework.Scenes
1208 1208
1209 private void SendObjectPropertiesToClient(UUID AgentID) 1209 private void SendObjectPropertiesToClient(UUID AgentID)
1210 { 1210 {
1211 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1211 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
1212 for (int i = 0; i < avatars.Length; i++)
1213 { 1212 {
1214 // Ugly reference :( 1213 // Ugly reference :(
1215 if (avatars[i].UUID == AgentID) 1214 if (avatar.UUID == AgentID)
1216 { 1215 {
1217 m_parentGroup.GetProperties(avatars[i].ControllingClient); 1216 m_parentGroup.GetProperties(avatar.ControllingClient);
1218 } 1217 }
1219 } 1218 });
1220 } 1219 }
1221 1220
1222 // TODO: unused: 1221 // TODO: unused:
@@ -1271,11 +1270,10 @@ namespace OpenSim.Region.Framework.Scenes
1271 /// </summary> 1270 /// </summary>
1272 public void AddFullUpdateToAllAvatars() 1271 public void AddFullUpdateToAllAvatars()
1273 { 1272 {
1274 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1273 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
1275 for (int i = 0; i < avatars.Length; i++)
1276 { 1274 {
1277 avatars[i].SceneViewer.QueuePartForUpdate(this); 1275 avatar.SceneViewer.QueuePartForUpdate(this);
1278 } 1276 });
1279 } 1277 }
1280 1278
1281 public void AddFullUpdateToAvatar(ScenePresence presence) 1279 public void AddFullUpdateToAvatar(ScenePresence presence)
@@ -1296,11 +1294,10 @@ namespace OpenSim.Region.Framework.Scenes
1296 /// Terse updates 1294 /// Terse updates
1297 public void AddTerseUpdateToAllAvatars() 1295 public void AddTerseUpdateToAllAvatars()
1298 { 1296 {
1299 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1297 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
1300 for (int i = 0; i < avatars.Length; i++)
1301 { 1298 {
1302 avatars[i].SceneViewer.QueuePartForUpdate(this); 1299 avatar.SceneViewer.QueuePartForUpdate(this);
1303 } 1300 });
1304 } 1301 }
1305 1302
1306 public void AddTerseUpdateToAvatar(ScenePresence presence) 1303 public void AddTerseUpdateToAvatar(ScenePresence presence)
@@ -1335,11 +1332,11 @@ namespace OpenSim.Region.Framework.Scenes
1335 if (volume < 0) 1332 if (volume < 0)
1336 volume = 0; 1333 volume = 0;
1337 1334
1338 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 1335 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp)
1339 foreach (ScenePresence p in avatarts)
1340 { 1336 {
1341 p.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); 1337 if(!sp.IsChildAgent)
1342 } 1338 sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume);
1339 });
1343 } 1340 }
1344 1341
1345 /// <summary> 1342 /// <summary>
@@ -2060,6 +2057,7 @@ namespace OpenSim.Region.Framework.Scenes
2060 { 2057 {
2061 m_lastColliders.Remove(localID); 2058 m_lastColliders.Remove(localID);
2062 } 2059 }
2060
2063 if (m_parentGroup == null) 2061 if (m_parentGroup == null)
2064 return; 2062 return;
2065 if (m_parentGroup.IsDeleted) 2063 if (m_parentGroup.IsDeleted)
@@ -2136,17 +2134,13 @@ namespace OpenSim.Region.Framework.Scenes
2136 } 2134 }
2137 else 2135 else
2138 { 2136 {
2139 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); 2137 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
2140
2141 for (int i = 0; i < avlist.Length; i++)
2142 { 2138 {
2143 ScenePresence av = avlist[i];
2144
2145 if (av.LocalId == localId) 2139 if (av.LocalId == localId)
2146 { 2140 {
2147 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 2141 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name))
2148 { 2142 {
2149 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2143 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2150 //If it is 1, it is to accept ONLY collisions from this avatar 2144 //If it is 1, it is to accept ONLY collisions from this avatar
2151 if (found) 2145 if (found)
2152 { 2146 {
@@ -2168,7 +2162,7 @@ namespace OpenSim.Region.Framework.Scenes
2168 } 2162 }
2169 else 2163 else
2170 { 2164 {
2171 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2165 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2172 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work 2166 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
2173 if (!found) 2167 if (!found)
2174 { 2168 {
@@ -2186,7 +2180,7 @@ namespace OpenSim.Region.Framework.Scenes
2186 } 2180 }
2187 2181
2188 } 2182 }
2189 } 2183 });
2190 } 2184 }
2191 } 2185 }
2192 if (colliding.Count > 0) 2186 if (colliding.Count > 0)
@@ -2272,17 +2266,13 @@ namespace OpenSim.Region.Framework.Scenes
2272 } 2266 }
2273 else 2267 else
2274 { 2268 {
2275 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); 2269 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
2276
2277 for (int i = 0; i < avlist.Length; i++)
2278 { 2270 {
2279 ScenePresence av = avlist[i];
2280
2281 if (av.LocalId == localId) 2271 if (av.LocalId == localId)
2282 { 2272 {
2283 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 2273 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name))
2284 { 2274 {
2285 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2275 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2286 //If it is 1, it is to accept ONLY collisions from this avatar 2276 //If it is 1, it is to accept ONLY collisions from this avatar
2287 if (found) 2277 if (found)
2288 { 2278 {
@@ -2304,7 +2294,7 @@ namespace OpenSim.Region.Framework.Scenes
2304 } 2294 }
2305 else 2295 else
2306 { 2296 {
2307 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2297 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2308 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work 2298 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
2309 if (!found) 2299 if (!found)
2310 { 2300 {
@@ -2322,7 +2312,7 @@ namespace OpenSim.Region.Framework.Scenes
2322 } 2312 }
2323 2313
2324 } 2314 }
2325 } 2315 });
2326 } 2316 }
2327 } 2317 }
2328 if (colliding.Count > 0) 2318 if (colliding.Count > 0)
@@ -2403,17 +2393,13 @@ namespace OpenSim.Region.Framework.Scenes
2403 } 2393 }
2404 else 2394 else
2405 { 2395 {
2406 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); 2396 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
2407
2408 for (int i = 0; i < avlist.Length; i++)
2409 { 2397 {
2410 ScenePresence av = avlist[i];
2411
2412 if (av.LocalId == localId) 2398 if (av.LocalId == localId)
2413 { 2399 {
2414 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 2400 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name))
2415 { 2401 {
2416 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2402 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2417 //If it is 1, it is to accept ONLY collisions from this avatar 2403 //If it is 1, it is to accept ONLY collisions from this avatar
2418 if (found) 2404 if (found)
2419 { 2405 {
@@ -2435,7 +2421,7 @@ namespace OpenSim.Region.Framework.Scenes
2435 } 2421 }
2436 else 2422 else
2437 { 2423 {
2438 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2424 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2439 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work 2425 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
2440 if (!found) 2426 if (!found)
2441 { 2427 {
@@ -2453,7 +2439,7 @@ namespace OpenSim.Region.Framework.Scenes
2453 } 2439 }
2454 2440
2455 } 2441 }
2456 } 2442 });
2457 } 2443 }
2458 } 2444 }
2459 2445
@@ -2640,12 +2626,13 @@ namespace OpenSim.Region.Framework.Scenes
2640 TaskInventory.LockItemsForRead(false); 2626 TaskInventory.LockItemsForRead(false);
2641 } 2627 }
2642 2628
2643 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 2629 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp)
2644 foreach (ScenePresence p in avatarts)
2645 { 2630 {
2646 if (!(Util.GetDistanceTo(p.AbsolutePosition, AbsolutePosition) >= 100)) 2631 if (sp.IsChildAgent)
2647 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); 2632 return;
2648 } 2633 if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100))
2634 sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
2635 });
2649 } 2636 }
2650 2637
2651 public void RemFlag(PrimFlags flag) 2638 public void RemFlag(PrimFlags flag)
@@ -2820,41 +2807,66 @@ namespace OpenSim.Region.Framework.Scenes
2820 } 2807 }
2821 } 2808 }
2822 2809
2810// /// <summary>
2811// ///
2812// /// </summary>
2813// /// <param name="remoteClient"></param>
2814// public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
2815// {
2816// m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
2817// }
2818
2819
2823 /// <summary> 2820 /// <summary>
2824 /// 2821 /// Send a full update to the client for the given part
2825 /// </summary> 2822 /// </summary>
2826 /// <param name="remoteClient"></param> 2823 /// <param name="remoteClient"></param>
2827 public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags) 2824 /// <param name="clientFlags"></param>
2825 protected internal void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
2828 { 2826 {
2829 m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags); 2827// m_log.DebugFormat(
2828// "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
2829
2830 if (IsRoot)
2831 {
2832 if (IsAttachment)
2833 {
2834 SendFullUpdateToClient(remoteClient, AttachedPos, clientFlags);
2835 }
2836 else
2837 {
2838 SendFullUpdateToClient(remoteClient, AbsolutePosition, clientFlags);
2839 }
2840 }
2841 else
2842 {
2843 SendFullUpdateToClient(remoteClient, clientFlags);
2844 }
2830 } 2845 }
2831 2846
2832 /// <summary> 2847 /// <summary>
2833 /// 2848 /// Send a full update for this part to all clients.
2834 /// </summary> 2849 /// </summary>
2835 public void SendFullUpdateToAllClients() 2850 public void SendFullUpdateToAllClients()
2836 { 2851 {
2837 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 2852 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
2838 for (int i = 0; i < avatars.Length; i++)
2839 { 2853 {
2840 // Ugly reference :( 2854 SendFullUpdate(avatar.ControllingClient, avatar.GenerateClientFlags(UUID));
2841 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, 2855 });
2842 avatars[i].GenerateClientFlags(UUID));
2843 }
2844 } 2856 }
2845 2857
2858 /// <summary>
2859 /// Send a full update to all clients except the one nominated.
2860 /// </summary>
2861 /// <param name="agentID"></param>
2846 public void SendFullUpdateToAllClientsExcept(UUID agentID) 2862 public void SendFullUpdateToAllClientsExcept(UUID agentID)
2847 { 2863 {
2848 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 2864 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
2849 for (int i = 0; i < avatars.Length; i++)
2850 { 2865 {
2851 // Ugly reference :( 2866 // Ugly reference :(
2852 if (avatars[i].UUID != agentID) 2867 if (avatar.UUID != agentID)
2853 { 2868 SendFullUpdate(avatar.ControllingClient, avatar.GenerateClientFlags(UUID));
2854 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, 2869 });
2855 avatars[i].GenerateClientFlags(UUID));
2856 }
2857 }
2858 } 2870 }
2859 2871
2860 /// <summary> 2872 /// <summary>
@@ -3055,11 +3067,10 @@ namespace OpenSim.Region.Framework.Scenes
3055 /// </summary> 3067 /// </summary>
3056 public void SendTerseUpdateToAllClients() 3068 public void SendTerseUpdateToAllClients()
3057 { 3069 {
3058 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 3070 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
3059 for (int i = 0; i < avatars.Length; i++)
3060 { 3071 {
3061 SendTerseUpdateToClient(avatars[i].ControllingClient); 3072 SendTerseUpdateToClient(avatar.ControllingClient);
3062 } 3073 });
3063 } 3074 }
3064 3075
3065 public void SetAttachmentPoint(uint AttachmentPoint) 3076 public void SetAttachmentPoint(uint AttachmentPoint)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 5d00917..836622d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -34,7 +34,6 @@ using System.Reflection;
34using OpenMetaverse; 34using OpenMetaverse;
35using log4net; 35using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications.Cache;
38using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes.Scripting; 38using OpenSim.Region.Framework.Scenes.Scripting;
40 39
@@ -642,7 +641,6 @@ namespace OpenSim.Region.Framework.Scenes
642 m_items[item.ItemID] = item; 641 m_items[item.ItemID] = item;
643 m_inventorySerial++; 642 m_inventorySerial++;
644 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 643 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
645
646 HasInventoryChanged = true; 644 HasInventoryChanged = true;
647 m_part.ParentGroup.HasGroupChanged = true; 645 m_part.ParentGroup.HasGroupChanged = true;
648 m_items.LockItemsForWrite(false); 646 m_items.LockItemsForWrite(false);
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 2603fe1..5c54616 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -33,12 +33,12 @@ using OpenMetaverse;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Client; 35using OpenSim.Framework.Client;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes.Animation; 37using OpenSim.Region.Framework.Scenes.Animation;
39using OpenSim.Region.Framework.Scenes.Types; 38using OpenSim.Region.Framework.Scenes.Types;
40using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.Physics.Manager;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Services.Interfaces;
42 42
43namespace OpenSim.Region.Framework.Scenes 43namespace OpenSim.Region.Framework.Scenes
44{ 44{
@@ -150,7 +150,8 @@ namespace OpenSim.Region.Framework.Scenes
150 150
151 private float m_sitAvatarHeight = 2.0f; 151 private float m_sitAvatarHeight = 2.0f;
152 152
153 private float m_godlevel; 153 private int m_godLevel;
154 private int m_userLevel;
154 155
155 private bool m_invulnerable = true; 156 private bool m_invulnerable = true;
156 157
@@ -266,6 +267,8 @@ namespace OpenSim.Region.Framework.Scenes
266 267
267 // For teleports and crossings callbacks 268 // For teleports and crossings callbacks
268 string m_callbackURI; 269 string m_callbackURI;
270 UUID m_originRegionID;
271
269 ulong m_rootRegionHandle; 272 ulong m_rootRegionHandle;
270 273
271 /// <value> 274 /// <value>
@@ -302,9 +305,14 @@ namespace OpenSim.Region.Framework.Scenes
302 get { return m_invulnerable; } 305 get { return m_invulnerable; }
303 } 306 }
304 307
305 public float GodLevel 308 public int UserLevel
309 {
310 get { return m_userLevel; }
311 }
312
313 public int GodLevel
306 { 314 {
307 get { return m_godlevel; } 315 get { return m_godLevel; }
308 } 316 }
309 317
310 public ulong RegionHandle 318 public ulong RegionHandle
@@ -457,7 +465,7 @@ namespace OpenSim.Region.Framework.Scenes
457 PhysicsActor actor = m_physicsActor; 465 PhysicsActor actor = m_physicsActor;
458// if (actor != null) 466// if (actor != null)
459 if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! 467 if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting!
460 m_pos = actor.Position; 468 m_pos = actor.Position;
461 469
462 return m_parentPosition + m_pos; 470 return m_parentPosition + m_pos;
463 } 471 }
@@ -678,6 +686,11 @@ namespace OpenSim.Region.Framework.Scenes
678 m_regionInfo = reginfo; 686 m_regionInfo = reginfo;
679 m_localId = m_scene.AllocateLocalId(); 687 m_localId = m_scene.AllocateLocalId();
680 688
689 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
690
691 if (account != null)
692 m_userLevel = account.UserLevel;
693
681 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 694 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
682 if (gm != null) 695 if (gm != null)
683 m_grouptitle = gm.GetGroupTitle(m_uuid); 696 m_grouptitle = gm.GetGroupTitle(m_uuid);
@@ -868,47 +881,22 @@ namespace OpenSim.Region.Framework.Scenes
868 if (land != null) 881 if (land != null)
869 { 882 {
870 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. 883 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni.
871 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_godlevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) 884 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_userLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid)
872 { 885 {
873 pos = land.LandData.UserLocation; 886 pos = land.LandData.UserLocation;
874 } 887 }
875 } 888 }
876 } 889 }
877 890
878 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) 891 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
879 { 892 {
880 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128);
881
882 if (pos.X < 0)
883 {
884 emergencyPos.X = (int)Constants.RegionSize + pos.X;
885 if (!(pos.Y < 0))
886 emergencyPos.Y = pos.Y;
887 if (!(pos.Z < 0))
888 emergencyPos.X = pos.X;
889 }
890 if (pos.Y < 0)
891 {
892 emergencyPos.Y = (int)Constants.RegionSize + pos.Y;
893 if (!(pos.X < 0))
894 emergencyPos.X = pos.X;
895 if (!(pos.Z < 0))
896 emergencyPos.Z = pos.Z;
897 }
898 if (pos.Z < 0)
899 {
900 if (!(pos.X < 0))
901 emergencyPos.X = pos.X;
902 if (!(pos.Y < 0))
903 emergencyPos.Y = pos.Y;
904 //Leave as 128
905 }
906
907 m_log.WarnFormat( 893 m_log.WarnFormat(
908 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", 894 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping",
909 pos, Name, UUID, emergencyPos); 895 pos, Name, UUID);
910 896
911 pos = emergencyPos; 897 if (pos.X < 0f) pos.X = 0f;
898 if (pos.Y < 0f) pos.Y = 0f;
899 if (pos.Z < 0f) pos.Z = 0f;
912 } 900 }
913 901
914 float localAVHeight = 1.56f; 902 float localAVHeight = 1.56f;
@@ -919,7 +907,7 @@ namespace OpenSim.Region.Framework.Scenes
919 907
920 float posZLimit = 0; 908 float posZLimit = 0;
921 909
922 if (pos.X <Constants.RegionSize && pos.Y < Constants.RegionSize) 910 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
923 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 911 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
924 912
925 float newPosZ = posZLimit + localAVHeight / 2; 913 float newPosZ = posZLimit + localAVHeight / 2;
@@ -971,14 +959,11 @@ namespace OpenSim.Region.Framework.Scenes
971 959
972 m_isChildAgent = false; 960 m_isChildAgent = false;
973 961
974 ScenePresence[] animAgents = m_scene.GetScenePresences(); 962 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
975 for (int i = 0; i < animAgents.Length; i++)
976 { 963 {
977 ScenePresence presence = animAgents[i];
978
979 if (presence != this) 964 if (presence != this)
980 presence.Animator.SendAnimPackToClient(ControllingClient); 965 presence.Animator.SendAnimPackToClient(ControllingClient);
981 } 966 });
982 967
983 m_scene.EventManager.TriggerOnMakeRootAgent(this); 968 m_scene.EventManager.TriggerOnMakeRootAgent(this);
984 } 969 }
@@ -1162,8 +1147,10 @@ namespace OpenSim.Region.Framework.Scenes
1162 /// This is called upon a very important packet sent from the client, 1147 /// This is called upon a very important packet sent from the client,
1163 /// so it's client-controlled. Never call this method directly. 1148 /// so it's client-controlled. Never call this method directly.
1164 /// </summary> 1149 /// </summary>
1165 public void CompleteMovement() 1150 public void CompleteMovement(IClientAPI client)
1166 { 1151 {
1152 //m_log.Debug("[SCENE PRESENCE]: CompleteMovement");
1153
1167 Vector3 look = Velocity; 1154 Vector3 look = Velocity;
1168 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1155 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1169 { 1156 {
@@ -1188,7 +1175,7 @@ namespace OpenSim.Region.Framework.Scenes
1188 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1175 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1189 { 1176 {
1190 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1177 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
1191 Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); 1178 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1192 m_callbackURI = null; 1179 m_callbackURI = null;
1193 } 1180 }
1194 1181
@@ -1196,6 +1183,21 @@ namespace OpenSim.Region.Framework.Scenes
1196 1183
1197 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 1184 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
1198 SendInitialData(); 1185 SendInitialData();
1186
1187 // Create child agents in neighbouring regions
1188 if (!m_isChildAgent)
1189 {
1190 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1191 if (m_agentTransfer != null)
1192 m_agentTransfer.EnableChildAgents(this);
1193 else
1194 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active");
1195
1196 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1197 if (friendsModule != null)
1198 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1199 }
1200
1199 } 1201 }
1200 1202
1201 /// <summary> 1203 /// <summary>
@@ -1264,6 +1266,7 @@ namespace OpenSim.Region.Framework.Scenes
1264 m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); 1266 m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902");
1265 1267
1266 m_pos = m_LastFinitePos; 1268 m_pos = m_LastFinitePos;
1269
1267 if (!m_pos.IsFinite()) 1270 if (!m_pos.IsFinite())
1268 { 1271 {
1269 m_pos.X = 127f; 1272 m_pos.X = 127f;
@@ -1901,6 +1904,7 @@ namespace OpenSim.Region.Framework.Scenes
1901 { 1904 {
1902 m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center 1905 m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center
1903 autopilotTarget = part.AbsolutePosition; 1906 autopilotTarget = part.AbsolutePosition;
1907//Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget);
1904 } 1908 }
1905 else return; // occupied small 1909 else return; // occupied small
1906 } // end large/small 1910 } // end large/small
@@ -2277,7 +2281,8 @@ namespace OpenSim.Region.Framework.Scenes
2277 m_pos += SIT_TARGET_ADJUSTMENT; 2281 m_pos += SIT_TARGET_ADJUSTMENT;
2278 m_bodyRot = sitTargetOrient; 2282 m_bodyRot = sitTargetOrient;
2279 m_parentPosition = part.AbsolutePosition; 2283 m_parentPosition = part.AbsolutePosition;
2280 part.IsOccupied = true; 2284 part.IsOccupied = true;
2285Console.WriteLine("Scripted Sit ofset {0}", m_pos);
2281 } 2286 }
2282 else 2287 else
2283 { 2288 {
@@ -2399,6 +2404,7 @@ namespace OpenSim.Region.Framework.Scenes
2399 { 2404 {
2400 if (m_isChildAgent) 2405 if (m_isChildAgent)
2401 { 2406 {
2407 // WHAT???
2402 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); 2408 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!");
2403 2409
2404 // we have to reset the user's child agent connections. 2410 // we have to reset the user's child agent connections.
@@ -2422,7 +2428,9 @@ namespace OpenSim.Region.Framework.Scenes
2422 2428
2423 if (m_scene.SceneGridService != null) 2429 if (m_scene.SceneGridService != null)
2424 { 2430 {
2425 m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); 2431 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
2432 if (m_agentTransfer != null)
2433 m_agentTransfer.EnableChildAgents(this);
2426 } 2434 }
2427 2435
2428 return; 2436 return;
@@ -2590,35 +2598,33 @@ namespace OpenSim.Region.Framework.Scenes
2590 2598
2591 List<Vector3> CoarseLocations = new List<Vector3>(); 2599 List<Vector3> CoarseLocations = new List<Vector3>();
2592 List<UUID> AvatarUUIDs = new List<UUID>(); 2600 List<UUID> AvatarUUIDs = new List<UUID>();
2593 List<ScenePresence> avatars = m_scene.GetAvatars(); 2601 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2594 for (int i = 0; i < avatars.Count; i++)
2595 { 2602 {
2596 // Requested by LibOMV. Send Course Location on self. 2603 if (sp.IsChildAgent)
2597 //if (avatars[i] != this) 2604 return;
2598 //{ 2605
2599 if (avatars[i].ParentID != 0) 2606 if (sp.ParentID != 0)
2607 {
2608 // sitting avatar
2609 SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID);
2610 if (sop != null)
2600 { 2611 {
2601 // sitting avatar 2612 CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos);
2602 SceneObjectPart sop = m_scene.GetSceneObjectPart(avatars[i].ParentID); 2613 AvatarUUIDs.Add(sp.UUID);
2603 if (sop != null)
2604 {
2605 CoarseLocations.Add(sop.AbsolutePosition + avatars[i].m_pos);
2606 AvatarUUIDs.Add(avatars[i].UUID);
2607 }
2608 else
2609 {
2610 // we can't find the parent.. ! arg!
2611 CoarseLocations.Add(avatars[i].m_pos);
2612 AvatarUUIDs.Add(avatars[i].UUID);
2613 }
2614 } 2614 }
2615 else 2615 else
2616 { 2616 {
2617 CoarseLocations.Add(avatars[i].m_pos); 2617 // we can't find the parent.. ! arg!
2618 AvatarUUIDs.Add(avatars[i].UUID); 2618 CoarseLocations.Add(sp.m_pos);
2619 AvatarUUIDs.Add(sp.UUID);
2619 } 2620 }
2620 //} 2621 }
2621 } 2622 else
2623 {
2624 CoarseLocations.Add(sp.m_pos);
2625 AvatarUUIDs.Add(sp.UUID);
2626 }
2627 });
2622 2628
2623 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); 2629 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations);
2624 2630
@@ -2660,13 +2666,10 @@ namespace OpenSim.Region.Framework.Scenes
2660 public void SendInitialFullUpdateToAllClients() 2666 public void SendInitialFullUpdateToAllClients()
2661 { 2667 {
2662 m_perfMonMS = Util.EnvironmentTickCount(); 2668 m_perfMonMS = Util.EnvironmentTickCount();
2663 2669 int avUpdates = 0;
2664 ScenePresence[] avatars = m_scene.GetScenePresences(); 2670 m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
2665
2666 for (int i = 0; i < avatars.Length; i++)
2667 { 2671 {
2668 ScenePresence avatar = avatars[i]; 2672 ++avUpdates;
2669
2670 // only send if this is the root (children are only "listening posts" in a foreign region) 2673 // only send if this is the root (children are only "listening posts" in a foreign region)
2671 if (!IsChildAgent) 2674 if (!IsChildAgent)
2672 { 2675 {
@@ -2682,9 +2685,9 @@ namespace OpenSim.Region.Framework.Scenes
2682 avatar.Animator.SendAnimPackToClient(ControllingClient); 2685 avatar.Animator.SendAnimPackToClient(ControllingClient);
2683 } 2686 }
2684 } 2687 }
2685 } 2688 });
2686 2689
2687 m_scene.StatsReporter.AddAgentUpdates(avatars.Length); 2690 m_scene.StatsReporter.AddAgentUpdates(avUpdates);
2688 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2691 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2689 2692
2690 //Animator.SendAnimPack(); 2693 //Animator.SendAnimPack();
@@ -2695,13 +2698,15 @@ namespace OpenSim.Region.Framework.Scenes
2695 m_perfMonMS = Util.EnvironmentTickCount(); 2698 m_perfMonMS = Util.EnvironmentTickCount();
2696 2699
2697 // only send update from root agents to other clients; children are only "listening posts" 2700 // only send update from root agents to other clients; children are only "listening posts"
2698 List<ScenePresence> avatars = m_scene.GetAvatars(); 2701 int count = 0;
2699 foreach (ScenePresence avatar in avatars) 2702 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2700 { 2703 {
2701 SendFullUpdateToOtherClient(avatar); 2704 if (sp.IsChildAgent)
2702 2705 return;
2703 } 2706 SendFullUpdateToOtherClient(sp);
2704 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2707 ++count;
2708 });
2709 m_scene.StatsReporter.AddAgentUpdates(count);
2705 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2710 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2706 2711
2707 Animator.SendAnimPack(); 2712 Animator.SendAnimPack();
@@ -2722,14 +2727,9 @@ namespace OpenSim.Region.Framework.Scenes
2722 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2727 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2723 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); 2728 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot));
2724 2729
2725 if (!m_isChildAgent)
2726 {
2727 m_scene.InformClientOfNeighbours(this);
2728 }
2729
2730 SendInitialFullUpdateToAllClients(); 2730 SendInitialFullUpdateToAllClients();
2731 SendAppearanceToAllOtherAgents(); 2731 SendAppearanceToAllOtherAgents();
2732 } 2732 }
2733 2733
2734 /// <summary> 2734 /// <summary>
2735 /// Tell the client for this scene presence what items it should be wearing now 2735 /// Tell the client for this scene presence what items it should be wearing now
@@ -2811,14 +2811,19 @@ namespace OpenSim.Region.Framework.Scenes
2811 } 2811 }
2812 } 2812 }
2813 } 2813 }
2814
2814 } 2815 }
2815 2816
2817
2816 #endregion Bake Cache Check 2818 #endregion Bake Cache Check
2817 2819
2818 m_appearance.SetAppearance(textureEntry, visualParams); 2820 m_appearance.SetAppearance(textureEntry, visualParams);
2819 if (m_appearance.AvatarHeight > 0) 2821 if (m_appearance.AvatarHeight > 0)
2820 SetHeight(m_appearance.AvatarHeight); 2822 SetHeight(m_appearance.AvatarHeight);
2821 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2823
2824 // This is not needed, because only the transient data changed
2825 //AvatarData adata = new AvatarData(m_appearance);
2826 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2822 2827
2823 SendAppearanceToAllOtherAgents(); 2828 SendAppearanceToAllOtherAgents();
2824 if (!m_startAnimationSet) 2829 if (!m_startAnimationSet)
@@ -2838,7 +2843,8 @@ namespace OpenSim.Region.Framework.Scenes
2838 public void SetWearable(int wearableId, AvatarWearable wearable) 2843 public void SetWearable(int wearableId, AvatarWearable wearable)
2839 { 2844 {
2840 m_appearance.SetWearable(wearableId, wearable); 2845 m_appearance.SetWearable(wearableId, wearable);
2841 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2846 AvatarData adata = new AvatarData(m_appearance);
2847 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2842 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); 2848 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2843 } 2849 }
2844 2850
@@ -2860,7 +2866,12 @@ namespace OpenSim.Region.Framework.Scenes
2860 /// </summary> 2866 /// </summary>
2861 protected void CheckForSignificantMovement() 2867 protected void CheckForSignificantMovement()
2862 { 2868 {
2863 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.5) 2869 // Movement updates for agents in neighboring regions are sent directly to clients.
2870 // This value only affects how often agent positions are sent to neighbor regions
2871 // for things such as distance-based update prioritization
2872 const float SIGNIFICANT_MOVEMENT = 2.0f;
2873
2874 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT)
2864 { 2875 {
2865 posLastSignificantMove = AbsolutePosition; 2876 posLastSignificantMove = AbsolutePosition;
2866 m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); 2877 m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient);
@@ -2871,18 +2882,19 @@ namespace OpenSim.Region.Framework.Scenes
2871 if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || 2882 if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance ||
2872 Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) 2883 Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance)
2873 { 2884 {
2885 m_lastChildAgentUpdatePosition = AbsolutePosition;
2886 m_lastChildAgentUpdateCamPosition = CameraPosition;
2887
2874 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); 2888 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
2875 cadu.ActiveGroupID = UUID.Zero.Guid; 2889 cadu.ActiveGroupID = UUID.Zero.Guid;
2876 cadu.AgentID = UUID.Guid; 2890 cadu.AgentID = UUID.Guid;
2877 cadu.alwaysrun = m_setAlwaysRun; 2891 cadu.alwaysrun = m_setAlwaysRun;
2878 cadu.AVHeight = m_avHeight; 2892 cadu.AVHeight = m_avHeight;
2879 sLLVector3 tempCameraCenter = new sLLVector3(new Vector3(m_CameraCenter.X, m_CameraCenter.Y, m_CameraCenter.Z)); 2893 Vector3 tempCameraCenter = m_CameraCenter;
2880 cadu.cameraPosition = tempCameraCenter; 2894 cadu.cameraPosition = tempCameraCenter;
2881 cadu.drawdistance = m_DrawDistance; 2895 cadu.drawdistance = m_DrawDistance;
2882 if (m_scene.Permissions.IsGod(new UUID(cadu.AgentID)))
2883 cadu.godlevel = m_godlevel;
2884 cadu.GroupAccess = 0; 2896 cadu.GroupAccess = 0;
2885 cadu.Position = new sLLVector3(AbsolutePosition); 2897 cadu.Position = AbsolutePosition;
2886 cadu.regionHandle = m_rootRegionHandle; 2898 cadu.regionHandle = m_rootRegionHandle;
2887 float multiplier = 1; 2899 float multiplier = 1;
2888 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); 2900 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount();
@@ -2897,15 +2909,12 @@ namespace OpenSim.Region.Framework.Scenes
2897 2909
2898 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); 2910 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString());
2899 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); 2911 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier);
2900 cadu.Velocity = new sLLVector3(Velocity); 2912 cadu.Velocity = Velocity;
2901 2913
2902 AgentPosition agentpos = new AgentPosition(); 2914 AgentPosition agentpos = new AgentPosition();
2903 agentpos.CopyFrom(cadu); 2915 agentpos.CopyFrom(cadu);
2904 2916
2905 m_scene.SendOutChildAgentUpdates(agentpos, this); 2917 m_scene.SendOutChildAgentUpdates(agentpos, this);
2906
2907 m_lastChildAgentUpdatePosition = AbsolutePosition;
2908 m_lastChildAgentUpdateCamPosition = CameraPosition;
2909 } 2918 }
2910 } 2919 }
2911 2920
@@ -3161,18 +3170,21 @@ namespace OpenSim.Region.Framework.Scenes
3161 // For now, assign god level 200 to anyone 3170 // For now, assign god level 200 to anyone
3162 // who is granted god powers, but has no god level set. 3171 // who is granted god powers, but has no god level set.
3163 // 3172 //
3164 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 3173 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID);
3165 if (profile.UserProfile.GodLevel > 0) 3174 if (account != null)
3166 m_godlevel = profile.UserProfile.GodLevel; 3175 {
3167 else 3176 if (account.UserLevel > 0)
3168 m_godlevel = 200; 3177 m_godLevel = account.UserLevel;
3178 else
3179 m_godLevel = 200;
3180 }
3169 } 3181 }
3170 else 3182 else
3171 { 3183 {
3172 m_godlevel = 0; 3184 m_godLevel = 0;
3173 } 3185 }
3174 3186
3175 ControllingClient.SendAdminResponse(token, (uint)m_godlevel); 3187 ControllingClient.SendAdminResponse(token, (uint)m_godLevel);
3176 } 3188 }
3177 3189
3178 #region Child Agent Updates 3190 #region Child Agent Updates
@@ -3231,7 +3243,7 @@ namespace OpenSim.Region.Framework.Scenes
3231 public void CopyTo(AgentData cAgent) 3243 public void CopyTo(AgentData cAgent)
3232 { 3244 {
3233 cAgent.AgentID = UUID; 3245 cAgent.AgentID = UUID;
3234 cAgent.RegionHandle = m_rootRegionHandle; 3246 cAgent.RegionID = Scene.RegionInfo.RegionID;
3235 3247
3236 cAgent.Position = AbsolutePosition; 3248 cAgent.Position = AbsolutePosition;
3237 cAgent.Velocity = m_velocity; 3249 cAgent.Velocity = m_velocity;
@@ -3263,7 +3275,7 @@ namespace OpenSim.Region.Framework.Scenes
3263 cAgent.ControlFlags = (uint)m_AgentControlFlags; 3275 cAgent.ControlFlags = (uint)m_AgentControlFlags;
3264 3276
3265 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) 3277 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID)))
3266 cAgent.GodLevel = (byte)m_godlevel; 3278 cAgent.GodLevel = (byte)m_godLevel;
3267 else 3279 else
3268 cAgent.GodLevel = (byte) 0; 3280 cAgent.GodLevel = (byte) 0;
3269 3281
@@ -3330,11 +3342,12 @@ namespace OpenSim.Region.Framework.Scenes
3330 3342
3331 public void CopyFrom(AgentData cAgent) 3343 public void CopyFrom(AgentData cAgent)
3332 { 3344 {
3333 m_rootRegionHandle = cAgent.RegionHandle; 3345 m_originRegionID = cAgent.RegionID;
3334 3346
3335 m_callbackURI = cAgent.CallbackURI; 3347 m_callbackURI = cAgent.CallbackURI;
3336 3348
3337 m_pos = cAgent.Position; 3349 m_pos = cAgent.Position;
3350
3338 m_velocity = cAgent.Velocity; 3351 m_velocity = cAgent.Velocity;
3339 m_CameraCenter = cAgent.Center; 3352 m_CameraCenter = cAgent.Center;
3340 //m_avHeight = cAgent.Size.Z; 3353 //m_avHeight = cAgent.Size.Z;
@@ -3352,7 +3365,7 @@ namespace OpenSim.Region.Framework.Scenes
3352 m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; 3365 m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags;
3353 3366
3354 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) 3367 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID)))
3355 m_godlevel = cAgent.GodLevel; 3368 m_godLevel = cAgent.GodLevel;
3356 m_setAlwaysRun = cAgent.AlwaysRun; 3369 m_setAlwaysRun = cAgent.AlwaysRun;
3357 3370
3358 uint i = 0; 3371 uint i = 0;
@@ -3710,36 +3723,6 @@ namespace OpenSim.Region.Framework.Scenes
3710 } 3723 }
3711 } 3724 }
3712 3725
3713 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent)
3714 {
3715 lock (m_attachments)
3716 {
3717 // Validate
3718 foreach (SceneObjectGroup gobj in m_attachments)
3719 {
3720 if (gobj == null || gobj.IsDeleted)
3721 return false;
3722 }
3723
3724 foreach (SceneObjectGroup gobj in m_attachments)
3725 {
3726 // If the prim group is null then something must have happened to it!
3727 if (gobj != null && gobj.RootPart != null)
3728 {
3729 // Set the parent localID to 0 so it transfers over properly.
3730 gobj.RootPart.SetParentLocalId(0);
3731 gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
3732 gobj.RootPart.IsAttachment = false;
3733 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
3734 m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle);
3735 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent);
3736 }
3737 }
3738 m_attachments.Clear();
3739
3740 return true;
3741 }
3742 }
3743 3726
3744 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) 3727 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
3745 { 3728 {
@@ -3975,7 +3958,7 @@ namespace OpenSim.Region.Framework.Scenes
3975 { 3958 {
3976 if (null == m_appearance) 3959 if (null == m_appearance)
3977 { 3960 {
3978 m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID); 3961 m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID);
3979 return; 3962 return;
3980 } 3963 }
3981 3964
@@ -3999,12 +3982,12 @@ namespace OpenSim.Region.Framework.Scenes
3999 try 3982 try
4000 { 3983 {
4001 // Rez from inventory 3984 // Rez from inventory
4002 UUID asset = m_scene.RezSingleAttachment(ControllingClient, 3985 UUID asset
4003 itemID, (uint)p); 3986 = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p);
4004
4005 m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
4006 p, itemID, assetID, asset);
4007 3987
3988 m_log.InfoFormat(
3989 "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
3990 p, itemID, assetID, asset);
4008 } 3991 }
4009 catch (Exception e) 3992 catch (Exception e)
4010 { 3993 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
index 1cff0eb..4ba4fab 100644
--- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
@@ -31,7 +31,6 @@ using OpenMetaverse;
31using log4net; 31using log4net;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Client; 33using OpenSim.Framework.Client;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes.Types; 35using OpenSim.Region.Framework.Scenes.Types;
37 36
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
index 8230f32..dd9f8f6 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
@@ -65,6 +65,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
65 { 65 {
66 throw new NotImplementedException(); 66 throw new NotImplementedException();
67 } 67 }
68
69 public override bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence)
70 {
71 throw new NotImplementedException();
72 }
68 } 73 }
69 74
70 [Test] 75 [Test]
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 0ed00de..78f2ae3 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -32,8 +32,7 @@ using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 38using OpenSim.Tests.Common.Mock;
@@ -87,6 +86,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
87 public void TestDeleteSceneObjectAsync() 86 public void TestDeleteSceneObjectAsync()
88 { 87 {
89 TestHelper.InMethod(); 88 TestHelper.InMethod();
89 //log4net.Config.XmlConfigurator.Configure();
90 90
91 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); 91 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
92 92
@@ -95,16 +95,18 @@ namespace OpenSim.Region.Framework.Scenes.Tests
95 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 95 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
96 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; 96 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
97 sogd.Enabled = false; 97 sogd.Enabled = false;
98 98
99 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); 99 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
100 100
101 IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); 101 IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId);
102 scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero); 102 scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero);
103 103
104 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 104 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
105
105 Assert.That(retrievedPart, Is.Not.Null); 106 Assert.That(retrievedPart, Is.Not.Null);
106 107
107 sogd.InventoryDeQueueAndDelete(); 108 sogd.InventoryDeQueueAndDelete();
109
108 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); 110 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
109 Assert.That(retrievedPart2, Is.Null); 111 Assert.That(retrievedPart2, Is.Null);
110 } 112 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index 709cca2..0b7608d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -32,8 +32,7 @@ using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 38using OpenSim.Tests.Common.Mock;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index f00dd66..501207e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -40,8 +40,8 @@ using OpenSim.Framework;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion;
44using OpenSim.Region.CoreModules.World.Serialiser; 43using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock; 46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup; 47using OpenSim.Tests.Common.Setup;
@@ -58,7 +58,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 public UUID agent1, agent2, agent3; 58 public UUID agent1, agent2, agent3;
59 public static Random random; 59 public static Random random;
60 public ulong region1,region2,region3; 60 public ulong region1,region2,region3;
61 public TestCommunicationsManager cm;
62 public AgentCircuitData acd1; 61 public AgentCircuitData acd1;
63 public SceneObjectGroup sog1, sog2, sog3; 62 public SceneObjectGroup sog1, sog2, sog3;
64 public TestClient testclient; 63 public TestClient testclient;
@@ -66,12 +65,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
66 [TestFixtureSetUp] 65 [TestFixtureSetUp]
67 public void Init() 66 public void Init()
68 { 67 {
69 cm = new TestCommunicationsManager(); 68 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
70 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000, cm); 69 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
71 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000, cm); 70 scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000);
72 scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm);
73 71
74 ISharedRegionModule interregionComms = new RESTInterregionComms(); 72 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
75 interregionComms.Initialise(new IniConfigSource()); 73 interregionComms.Initialise(new IniConfigSource());
76 interregionComms.PostInitialise(); 74 interregionComms.PostInitialise();
77 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); 75 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
@@ -373,7 +371,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
373 371
374 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); 372 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
375 373
376 Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); 374 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
377 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); 375 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
378 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); 376 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
379 } 377 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index 5abbb82..8b2d387 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -101,13 +101,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
101 { 101 {
102 throw new NotImplementedException(); 102 throw new NotImplementedException();
103 } 103 }
104 public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID) 104 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
105 { 105 {
106 //This connector doesn't support the windlight module yet 106 //This connector doesn't support the windlight module yet
107 //Return default LL windlight settings 107 //Return default LL windlight settings
108 return new RegionMeta7WindlightData(); 108 return new RegionLightShareData();
109 } 109 }
110 public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl) 110 public void StoreRegionWindlightSettings(RegionLightShareData wl)
111 { 111 {
112 //This connector doesn't support the windlight module yet 112 //This connector doesn't support the windlight module yet
113 } 113 }
@@ -141,7 +141,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
141 RegionInfo regionInfo = new RegionInfo(0,0,null,null); 141 RegionInfo regionInfo = new RegionInfo(0,0,null,null);
142 FakeStorageManager storageManager = new FakeStorageManager(); 142 FakeStorageManager storageManager = new FakeStorageManager();
143 143
144 new Scene(regionInfo, null, null, null, storageManager, null, false, false, false, null, null); 144 new Scene(regionInfo, null, null, storageManager, null, false, false, false, null, null);
145 } 145 }
146 } 146 }
147} 147}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
index b46eb8e..cafe48a 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
@@ -34,7 +34,7 @@ using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; 37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
38using OpenSim.Tests.Common; 38using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 39using OpenSim.Tests.Common.Mock;
40using OpenSim.Tests.Common.Setup; 40using OpenSim.Tests.Common.Setup;
@@ -113,17 +113,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests
113 113
114 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); 114 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100");
115 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); 115 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200");
116 TestCommunicationsManager cm = new TestCommunicationsManager();
117 116
118 // shared module 117 // shared module
119 ISharedRegionModule interregionComms = new RESTInterregionComms(); 118 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
120 119
121 120
122 Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm, "grid"); 121 Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, "grid");
123 SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); 122 SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms);
124 sceneB.RegisterRegionWithGrid(); 123 sceneB.RegisterRegionWithGrid();
125 124
126 Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, cm, "grid"); 125 Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, "grid");
127 SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); 126 SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
128 sceneA.RegisterRegionWithGrid(); 127 sceneA.RegisterRegionWithGrid();
129 128
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index a36c4db..8b80ebe 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -58,10 +58,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 TestHelper.InMethod(); 58 TestHelper.InMethod();
59 59
60 UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); 60 UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
61 AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET"); 61 AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET", UUID.Zero);
62 m_assetService.Store(corruptAsset); 62 m_assetService.Store(corruptAsset);
63 63
64 IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); 64 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
65 m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids); 65 m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids);
66 66
67 // We count the uuid as gathered even if the asset itself is corrupt. 67 // We count the uuid as gathered even if the asset itself is corrupt.
@@ -77,7 +77,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
77 TestHelper.InMethod(); 77 TestHelper.InMethod();
78 78
79 UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); 79 UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
80 IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); 80 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
81 81
82 m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); 82 m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids);
83 83
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 3edb677..0ec3cc3 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -84,9 +84,9 @@ namespace OpenSim.Region.Framework.Scenes
84 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param> 84 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
85 /// <param name="assetType">The type of the asset for the uuid given</param> 85 /// <param name="assetType">The type of the asset for the uuid given</param>
86 /// <param name="assetUuids">The assets gathered</param> 86 /// <param name="assetUuids">The assets gathered</param>
87 public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, int> assetUuids) 87 public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids)
88 { 88 {
89 assetUuids[assetUuid] = 1; 89 assetUuids[assetUuid] = assetType;
90 90
91 if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType) 91 if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType)
92 { 92 {
@@ -116,7 +116,7 @@ namespace OpenSim.Region.Framework.Scenes
116 /// 116 ///
117 /// <param name="sceneObject">The scene object for which to gather assets</param> 117 /// <param name="sceneObject">The scene object for which to gather assets</param>
118 /// <param name="assetUuids">The assets gathered</param> 118 /// <param name="assetUuids">The assets gathered</param>
119 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, int> assetUuids) 119 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids)
120 { 120 {
121// m_log.DebugFormat( 121// m_log.DebugFormat(
122// "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); 122// "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
@@ -129,25 +129,26 @@ namespace OpenSim.Region.Framework.Scenes
129 try 129 try
130 { 130 {
131 Primitive.TextureEntry textureEntry = part.Shape.Textures; 131 Primitive.TextureEntry textureEntry = part.Shape.Textures;
132 132 if (textureEntry != null)
133 // Get the prim's default texture. This will be used for faces which don't have their own texture
134 assetUuids[textureEntry.DefaultTexture.TextureID] = 1;
135
136 // XXX: Not a great way to iterate through face textures, but there's no
137 // other method available to tell how many faces there actually are
138 //int i = 0;
139 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
140 { 133 {
141 if (texture != null) 134 // Get the prim's default texture. This will be used for faces which don't have their own texture
135 if (textureEntry.DefaultTexture != null)
136 assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture;
137
138 if (textureEntry.FaceTextures != null)
142 { 139 {
143 //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++); 140 // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture)
144 assetUuids[texture.TextureID] = 1; 141 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
142 {
143 if (texture != null)
144 assetUuids[texture.TextureID] = AssetType.Texture;
145 }
145 } 146 }
146 } 147 }
147 148
148 // If the prim is a sculpt then preserve this information too 149 // If the prim is a sculpt then preserve this information too
149 if (part.Shape.SculptTexture != UUID.Zero) 150 if (part.Shape.SculptTexture != UUID.Zero)
150 assetUuids[part.Shape.SculptTexture] = 1; 151 assetUuids[part.Shape.SculptTexture] = AssetType.Texture;
151 152
152 TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); 153 TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
153 154
@@ -217,7 +218,7 @@ namespace OpenSim.Region.Framework.Scenes
217 /// </summary> 218 /// </summary>
218 /// <param name="scriptUuid"></param> 219 /// <param name="scriptUuid"></param>
219 /// <param name="assetUuids">Dictionary in which to record the references</param> 220 /// <param name="assetUuids">Dictionary in which to record the references</param>
220 protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary<UUID, int> assetUuids) 221 protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary<UUID, AssetType> assetUuids)
221 { 222 {
222 AssetBase scriptAsset = GetAsset(scriptUuid); 223 AssetBase scriptAsset = GetAsset(scriptUuid);
223 224
@@ -232,7 +233,9 @@ namespace OpenSim.Region.Framework.Scenes
232 { 233 {
233 UUID uuid = new UUID(uuidMatch.Value); 234 UUID uuid = new UUID(uuidMatch.Value);
234 //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid); 235 //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid);
235 assetUuids[uuid] = 1; 236
237 // Assume AssetIDs embedded in scripts are textures
238 assetUuids[uuid] = AssetType.Texture;
236 } 239 }
237 } 240 }
238 } 241 }
@@ -242,7 +245,7 @@ namespace OpenSim.Region.Framework.Scenes
242 /// </summary> 245 /// </summary>
243 /// <param name="wearableAssetUuid"></param> 246 /// <param name="wearableAssetUuid"></param>
244 /// <param name="assetUuids">Dictionary in which to record the references</param> 247 /// <param name="assetUuids">Dictionary in which to record the references</param>
245 protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, int> assetUuids) 248 protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids)
246 { 249 {
247 AssetBase assetBase = GetAsset(wearableAssetUuid); 250 AssetBase assetBase = GetAsset(wearableAssetUuid);
248 251
@@ -257,8 +260,7 @@ namespace OpenSim.Region.Framework.Scenes
257 260
258 foreach (UUID uuid in wearableAsset.Textures.Values) 261 foreach (UUID uuid in wearableAsset.Textures.Values)
259 { 262 {
260 //m_log.DebugFormat("[ARCHIVER]: Got bodypart uuid {0}", uuid); 263 assetUuids[uuid] = AssetType.Texture;
261 assetUuids[uuid] = 1;
262 } 264 }
263 } 265 }
264 } 266 }
@@ -270,7 +272,7 @@ namespace OpenSim.Region.Framework.Scenes
270 /// </summary> 272 /// </summary>
271 /// <param name="sceneObject"></param> 273 /// <param name="sceneObject"></param>
272 /// <param name="assetUuids"></param> 274 /// <param name="assetUuids"></param>
273 protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, int> assetUuids) 275 protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids)
274 { 276 {
275 AssetBase objectAsset = GetAsset(sceneObjectUuid); 277 AssetBase objectAsset = GetAsset(sceneObjectUuid);
276 278
@@ -284,7 +286,7 @@ namespace OpenSim.Region.Framework.Scenes
284 } 286 }
285 } 287 }
286 288
287 protected void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, int> assetUuids) 289 protected void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids)
288 { 290 {
289 AssetBase assetBase = GetAsset(gestureUuid); 291 AssetBase assetBase = GetAsset(gestureUuid);
290 292
@@ -316,7 +318,7 @@ namespace OpenSim.Region.Framework.Scenes
316 // If it can be parsed as a UUID, it is an asset ID 318 // If it can be parsed as a UUID, it is an asset ID
317 UUID uuid; 319 UUID uuid;
318 if (UUID.TryParse(id, out uuid)) 320 if (UUID.TryParse(id, out uuid))
319 assetUuids[uuid] = 1; 321 assetUuids[uuid] = AssetType.Animation;
320 } 322 }
321 } 323 }
322 } 324 }