diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
31 files changed, 1599 insertions, 4205 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index b43caf2..702a1e2 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -378,7 +378,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); | 381 | AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation, m_scenePresence.UUID.ToString()); |
382 | Animasset.Data = anim.ToBytes(); | 382 | Animasset.Data = anim.ToBytes(); |
383 | Animasset.Temporary = true; | 383 | Animasset.Temporary = true; |
384 | Animasset.Local = true; | 384 | Animasset.Local = true; |
@@ -413,11 +413,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
413 | if (m_scenePresence.IsChildAgent) | 413 | if (m_scenePresence.IsChildAgent) |
414 | return; | 414 | return; |
415 | 415 | ||
416 | m_scenePresence.Scene.ForEachScenePresence( | 416 | UUID[] animIDs; |
417 | delegate(ScenePresence SP) | 417 | int[] sequenceNums; |
418 | { | 418 | UUID[] objectIDs; |
419 | SP.Animator.SendAnimPack(); | 419 | |
420 | }); | 420 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); |
421 | client.SendAnimations(animIDs, sequenceNums, m_scenePresence.ControllingClient.AgentId, objectIDs); | ||
421 | } | 422 | } |
422 | 423 | ||
423 | /// <summary> | 424 | /// <summary> |
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; | |||
32 | using log4net; | 32 | using log4net; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.Framework.Interfaces; | ||
35 | 36 | ||
36 | namespace OpenSim.Region.Framework.Scenes | 37 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using log4net; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Framework.Communications.Clients; | ||
37 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | |||
41 | //using HyperGrid.Framework; | ||
42 | //using OpenSim.Region.Communications.Hypergrid; | ||
43 | |||
44 | namespace 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.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs deleted file mode 100644 index 6f7f34f..0000000 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs +++ /dev/null | |||
@@ -1,174 +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 | |||
28 | using System.Reflection; | ||
29 | using log4net; | ||
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Communications; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | |||
37 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | ||
38 | { | ||
39 | public partial class HGScene : Scene | ||
40 | { | ||
41 | #region Fields | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | private HGAssetMapper m_assMapper; | ||
45 | public HGAssetMapper AssetMapper | ||
46 | { | ||
47 | get { return m_assMapper; } | ||
48 | } | ||
49 | |||
50 | private IHyperAssetService m_hyper; | ||
51 | private IHyperAssetService HyperAssets | ||
52 | { | ||
53 | get | ||
54 | { | ||
55 | if (m_hyper == null) | ||
56 | m_hyper = RequestModuleInterface<IHyperAssetService>(); | ||
57 | return m_hyper; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | #endregion | ||
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 | { | ||
73 | m_log.Info("[HGScene]: Starting HGScene."); | ||
74 | m_assMapper = new HGAssetMapper(this); | ||
75 | |||
76 | EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; | ||
77 | } | ||
78 | |||
79 | #endregion | ||
80 | |||
81 | #region Event handlers | ||
82 | |||
83 | public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) | ||
84 | { | ||
85 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID); | ||
86 | if (userInfo != null) | ||
87 | { | ||
88 | m_assMapper.Post(assetID, avatarID); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | #endregion | ||
93 | |||
94 | #region Overrides of Scene.Inventory methods | ||
95 | |||
96 | /// | ||
97 | /// CapsUpdateInventoryItemAsset | ||
98 | /// | ||
99 | public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) | ||
100 | { | ||
101 | UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); | ||
102 | |||
103 | UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); | ||
104 | |||
105 | return newAssetID; | ||
106 | } | ||
107 | |||
108 | /// | ||
109 | /// DeleteToInventory | ||
110 | /// | ||
111 | public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient) | ||
112 | { | ||
113 | UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient); | ||
114 | |||
115 | if (!assetID.Equals(UUID.Zero)) | ||
116 | { | ||
117 | UploadInventoryItem(remoteClient.AgentId, assetID, "", 0); | ||
118 | } | ||
119 | else | ||
120 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); | ||
121 | |||
122 | return assetID; | ||
123 | } | ||
124 | |||
125 | /// | ||
126 | /// RezObject | ||
127 | /// | ||
128 | public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | ||
129 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
130 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
131 | { | ||
132 | m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); | ||
133 | |||
134 | //if (fromTaskID.Equals(UUID.Zero)) | ||
135 | //{ | ||
136 | InventoryItemBase item = new InventoryItemBase(itemID); | ||
137 | item.Owner = remoteClient.AgentId; | ||
138 | item = InventoryService.GetItem(item); | ||
139 | //if (item == null) | ||
140 | //{ // Fetch the item | ||
141 | // item = new InventoryItemBase(); | ||
142 | // item.Owner = remoteClient.AgentId; | ||
143 | // item.ID = itemID; | ||
144 | // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); | ||
145 | //} | ||
146 | if (item != null) | ||
147 | { | ||
148 | m_assMapper.Get(item.AssetID, remoteClient.AgentId); | ||
149 | |||
150 | } | ||
151 | //} | ||
152 | |||
153 | // OK, we're done fetching. Pass it up to the default RezObject | ||
154 | return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | ||
155 | RezSelected, RemoveItem, fromTaskID, attachment); | ||
156 | |||
157 | } | ||
158 | |||
159 | protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) | ||
160 | { | ||
161 | string userAssetServer = HyperAssets.GetUserAssetServer(sender); | ||
162 | if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) | ||
163 | m_assMapper.Get(item.AssetID, sender); | ||
164 | |||
165 | userAssetServer = HyperAssets.GetUserAssetServer(receiver); | ||
166 | if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) | ||
167 | m_assMapper.Post(item.AssetID, receiver); | ||
168 | } | ||
169 | |||
170 | #endregion | ||
171 | |||
172 | } | ||
173 | |||
174 | } | ||
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 | |||
28 | using OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | using OpenSim.Framework.Communications.Cache; | ||
31 | using TPFlags = OpenSim.Framework.Constants.TeleportFlags; | ||
32 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
33 | |||
34 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Client; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | using OpenSim.Framework.Capabilities; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Services.Interfaces; | ||
42 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
43 | |||
44 | namespace 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/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs deleted file mode 100644 index 5d4e7ac..0000000 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs +++ /dev/null | |||
@@ -1,56 +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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Services.Interfaces; | ||
33 | using OpenMetaverse; | ||
34 | |||
35 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | ||
36 | { | ||
37 | public class HGUuidGatherer : UuidGatherer | ||
38 | { | ||
39 | protected string m_assetServerURL; | ||
40 | protected HGAssetMapper m_assetMapper; | ||
41 | |||
42 | public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache) | ||
43 | { | ||
44 | m_assetMapper = assMap; | ||
45 | m_assetServerURL = assetServerURL; | ||
46 | } | ||
47 | |||
48 | protected override AssetBase GetAsset(UUID uuid) | ||
49 | { | ||
50 | if (string.Empty == m_assetServerURL) | ||
51 | return m_assetCache.Get(uuid.ToString()); | ||
52 | else | ||
53 | return m_assetMapper.FetchAsset(m_assetServerURL, uuid); | ||
54 | } | ||
55 | } | ||
56 | } | ||
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; | |||
36 | using OpenMetaverse.StructuredData; | 36 | using OpenMetaverse.StructuredData; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications.Services; | 39 | |
40 | using OpenSim.Framework.Communications.Cache; | ||
41 | using OpenSim.Framework.Console; | 40 | using OpenSim.Framework.Console; |
42 | using OpenSim.Framework.Servers; | 41 | using OpenSim.Framework.Servers; |
43 | using OpenSim.Framework.Servers.HttpServer; | 42 | using OpenSim.Framework.Servers.HttpServer; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e031ebc..386aab4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -35,7 +35,6 @@ using OpenMetaverse; | |||
35 | using OpenMetaverse.Packets; | 35 | using OpenMetaverse.Packets; |
36 | using log4net; | 36 | using log4net; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | using OpenSim.Region.Framework; | 38 | using OpenSim.Region.Framework; |
40 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes.Serialization; | 40 | using OpenSim.Region.Framework.Scenes.Serialization; |
@@ -64,6 +63,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
64 | if (group is SceneObjectGroup) | 63 | if (group is SceneObjectGroup) |
65 | { | 64 | { |
66 | ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0); | 65 | ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0); |
66 | ((SceneObjectGroup) group).ResumeScripts(); | ||
67 | } | 67 | } |
68 | } | 68 | } |
69 | } | 69 | } |
@@ -94,6 +94,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
94 | 94 | ||
95 | public void AddInventoryItem(UUID AgentID, InventoryItemBase item) | 95 | public void AddInventoryItem(UUID AgentID, InventoryItemBase item) |
96 | { | 96 | { |
97 | InventoryFolderBase folder; | ||
98 | |||
99 | if (item.Folder == UUID.Zero) | ||
100 | { | ||
101 | folder = InventoryService.GetFolderForType(AgentID, (AssetType)item.AssetType); | ||
102 | if (folder == null) | ||
103 | { | ||
104 | folder = InventoryService.GetRootFolder(AgentID); | ||
105 | |||
106 | if (folder == null) | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | item.Folder = folder.ID; | ||
111 | } | ||
112 | |||
97 | if (InventoryService.AddItem(item)) | 113 | if (InventoryService.AddItem(item)) |
98 | { | 114 | { |
99 | int userlevel = 0; | 115 | int userlevel = 0; |
@@ -101,12 +117,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
101 | { | 117 | { |
102 | userlevel = 1; | 118 | userlevel = 1; |
103 | } | 119 | } |
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); | 120 | EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel); |
111 | } | 121 | } |
112 | else | 122 | else |
@@ -132,70 +142,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
132 | } | 142 | } |
133 | 143 | ||
134 | /// <summary> | 144 | /// <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> | 145 | /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> |
191 | /// </summary> | 146 | /// </summary> |
192 | public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) | 147 | public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) |
193 | { | 148 | { |
194 | ScenePresence avatar; | 149 | ScenePresence avatar; |
195 | 150 | ||
196 | if (TryGetAvatar(avatarId, out avatar)) | 151 | if (TryGetScenePresence(avatarId, out avatar)) |
197 | { | 152 | { |
198 | return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); | 153 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); |
154 | if (invAccess != null) | ||
155 | return invAccess.CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); | ||
199 | } | 156 | } |
200 | else | 157 | else |
201 | { | 158 | { |
@@ -251,7 +208,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
251 | return new ArrayList(); | 208 | return new ArrayList(); |
252 | } | 209 | } |
253 | 210 | ||
254 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data); | 211 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId); |
255 | AssetService.Store(asset); | 212 | AssetService.Store(asset); |
256 | 213 | ||
257 | if (isScriptRunning) | 214 | if (isScriptRunning) |
@@ -261,7 +218,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
261 | 218 | ||
262 | // Update item with new asset | 219 | // Update item with new asset |
263 | item.AssetID = asset.FullID; | 220 | item.AssetID = asset.FullID; |
264 | group.UpdateInventoryItem(item); | 221 | if (group.UpdateInventoryItem(item)) |
222 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
223 | |||
265 | part.GetProperties(remoteClient); | 224 | part.GetProperties(remoteClient); |
266 | 225 | ||
267 | // Trigger rerunning of script (use TriggerRezScript event, see RezScript) | 226 | // Trigger rerunning of script (use TriggerRezScript event, see RezScript) |
@@ -277,6 +236,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
277 | { | 236 | { |
278 | remoteClient.SendAgentAlertMessage("Script saved", false); | 237 | remoteClient.SendAgentAlertMessage("Script saved", false); |
279 | } | 238 | } |
239 | part.ParentGroup.ResumeScripts(); | ||
280 | return errors; | 240 | return errors; |
281 | } | 241 | } |
282 | 242 | ||
@@ -288,7 +248,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
288 | { | 248 | { |
289 | ScenePresence avatar; | 249 | ScenePresence avatar; |
290 | 250 | ||
291 | if (TryGetAvatar(avatarId, out avatar)) | 251 | if (TryGetScenePresence(avatarId, out avatar)) |
292 | { | 252 | { |
293 | return CapsUpdateTaskInventoryScriptAsset( | 253 | return CapsUpdateTaskInventoryScriptAsset( |
294 | avatar.ControllingClient, itemId, primId, isScriptRunning, data); | 254 | avatar.ControllingClient, itemId, primId, isScriptRunning, data); |
@@ -470,6 +430,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
470 | itemCopy.BasePermissions = item.BasePermissions; | 430 | itemCopy.BasePermissions = item.BasePermissions; |
471 | } | 431 | } |
472 | 432 | ||
433 | if (itemCopy.Folder == UUID.Zero) | ||
434 | { | ||
435 | InventoryFolderBase folder = InventoryService.GetFolderForType(recipient, (AssetType)itemCopy.AssetType); | ||
436 | |||
437 | if (folder != null) | ||
438 | { | ||
439 | itemCopy.Folder = folder.ID; | ||
440 | } | ||
441 | else | ||
442 | { | ||
443 | InventoryFolderBase root = InventoryService.GetRootFolder(recipient); | ||
444 | |||
445 | if (root != null) | ||
446 | itemCopy.Folder = root.ID; | ||
447 | else | ||
448 | return null; // No destination | ||
449 | } | ||
450 | } | ||
451 | |||
473 | itemCopy.GroupID = UUID.Zero; | 452 | itemCopy.GroupID = UUID.Zero; |
474 | itemCopy.GroupOwned = false; | 453 | itemCopy.GroupOwned = false; |
475 | itemCopy.Flags = item.Flags; | 454 | itemCopy.Flags = item.Flags; |
@@ -477,7 +456,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
477 | itemCopy.SaleType = item.SaleType; | 456 | itemCopy.SaleType = item.SaleType; |
478 | 457 | ||
479 | if (InventoryService.AddItem(itemCopy)) | 458 | if (InventoryService.AddItem(itemCopy)) |
480 | TransferInventoryAssets(itemCopy, senderId, recipient); | 459 | { |
460 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); | ||
461 | if (invAccess != null) | ||
462 | invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); | ||
463 | } | ||
481 | 464 | ||
482 | if (!Permissions.BypassPermissions()) | 465 | if (!Permissions.BypassPermissions()) |
483 | { | 466 | { |
@@ -499,10 +482,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
499 | 482 | ||
500 | } | 483 | } |
501 | 484 | ||
502 | protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) | ||
503 | { | ||
504 | } | ||
505 | |||
506 | /// <summary> | 485 | /// <summary> |
507 | /// Give an entire inventory folder from one user to another. The entire contents (including all descendent | 486 | /// Give an entire inventory folder from one user to another. The entire contents (including all descendent |
508 | /// folders) is given. | 487 | /// folders) is given. |
@@ -530,7 +509,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
530 | return null; | 509 | return null; |
531 | } | 510 | } |
532 | 511 | ||
533 | |||
534 | if (recipientParentFolderId == UUID.Zero) | 512 | if (recipientParentFolderId == UUID.Zero) |
535 | { | 513 | { |
536 | InventoryFolderBase recipientRootFolder = InventoryService.GetRootFolder(recipientId); | 514 | InventoryFolderBase recipientRootFolder = InventoryService.GetRootFolder(recipientId); |
@@ -572,7 +550,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
572 | "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", | 550 | "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", |
573 | remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); | 551 | remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); |
574 | 552 | ||
575 | InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); | 553 | InventoryItemBase item = null; |
554 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) | ||
555 | item = LibraryService.LibraryRootFolder.FindItem(oldItemID); | ||
576 | 556 | ||
577 | if (item == null) | 557 | if (item == null) |
578 | { | 558 | { |
@@ -626,15 +606,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
626 | /// <summary> | 606 | /// <summary> |
627 | /// Create a new asset data structure. | 607 | /// Create a new asset data structure. |
628 | /// </summary> | 608 | /// </summary> |
629 | /// <param name="name"></param> | 609 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, UUID creatorID) |
630 | /// <param name="description"></param> | ||
631 | /// <param name="invType"></param> | ||
632 | /// <param name="assetType"></param> | ||
633 | /// <param name="data"></param> | ||
634 | /// <returns></returns> | ||
635 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) | ||
636 | { | 610 | { |
637 | AssetBase asset = new AssetBase(UUID.Random(), name, assetType); | 611 | AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID.ToString()); |
638 | asset.Description = description; | 612 | asset.Description = description; |
639 | asset.Data = (data == null) ? new byte[1] : data; | 613 | asset.Data = (data == null) ? new byte[1] : data; |
640 | 614 | ||
@@ -744,13 +718,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
744 | 718 | ||
745 | if (transactionID == UUID.Zero) | 719 | if (transactionID == UUID.Zero) |
746 | { | 720 | { |
747 | CachedUserInfo userInfo | 721 | ScenePresence presence; |
748 | = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | 722 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) |
749 | |||
750 | if (userInfo != null) | ||
751 | { | 723 | { |
752 | ScenePresence presence; | ||
753 | TryGetAvatar(remoteClient.AgentId, out presence); | ||
754 | byte[] data = null; | 724 | byte[] data = null; |
755 | 725 | ||
756 | if (invType == (sbyte)InventoryType.Landmark && presence != null) | 726 | if (invType == (sbyte)InventoryType.Landmark && presence != null) |
@@ -764,7 +734,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
764 | data = Encoding.ASCII.GetBytes(strdata); | 734 | data = Encoding.ASCII.GetBytes(strdata); |
765 | } | 735 | } |
766 | 736 | ||
767 | AssetBase asset = CreateAsset(name, description, assetType, data); | 737 | AssetBase asset = CreateAsset(name, description, assetType, data, remoteClient.AgentId); |
768 | AssetService.Store(asset); | 738 | AssetService.Store(asset); |
769 | 739 | ||
770 | CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate); | 740 | CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate); |
@@ -772,7 +742,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
772 | else | 742 | else |
773 | { | 743 | { |
774 | m_log.ErrorFormat( | 744 | m_log.ErrorFormat( |
775 | "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem", | 745 | "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", |
776 | remoteClient.AgentId); | 746 | remoteClient.AgentId); |
777 | } | 747 | } |
778 | } | 748 | } |
@@ -788,6 +758,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
788 | } | 758 | } |
789 | } | 759 | } |
790 | 760 | ||
761 | private void HandleLinkInventoryItem(IClientAPI remoteClient, UUID transActionID, UUID folderID, | ||
762 | uint callbackID, string description, string name, | ||
763 | sbyte invType, sbyte type, UUID olditemID) | ||
764 | { | ||
765 | m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item link {0} in folder {1} pointing to {2}", name, folderID, olditemID); | ||
766 | |||
767 | if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) | ||
768 | return; | ||
769 | |||
770 | ScenePresence presence; | ||
771 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
772 | { | ||
773 | byte[] data = null; | ||
774 | |||
775 | AssetBase asset = new AssetBase(); | ||
776 | asset.FullID = olditemID; | ||
777 | asset.Type = type; | ||
778 | asset.Name = name; | ||
779 | asset.Description = description; | ||
780 | |||
781 | CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, name, 0, callbackID, asset, invType, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); | ||
782 | |||
783 | } | ||
784 | else | ||
785 | { | ||
786 | m_log.ErrorFormat( | ||
787 | "ScenePresence for agent uuid {0} unexpectedly not found in HandleLinkInventoryItem", | ||
788 | remoteClient.AgentId); | ||
789 | } | ||
790 | } | ||
791 | |||
791 | /// <summary> | 792 | /// <summary> |
792 | /// Remove an inventory item for the client's inventory | 793 | /// Remove an inventory item for the client's inventory |
793 | /// </summary> | 794 | /// </summary> |
@@ -1011,7 +1012,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1011 | { | 1012 | { |
1012 | ScenePresence avatar; | 1013 | ScenePresence avatar; |
1013 | 1014 | ||
1014 | if (TryGetAvatar(avatarId, out avatar)) | 1015 | if (TryGetScenePresence(avatarId, out avatar)) |
1015 | { | 1016 | { |
1016 | return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); | 1017 | return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); |
1017 | } | 1018 | } |
@@ -1125,7 +1126,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1125 | 1126 | ||
1126 | ScenePresence avatar; | 1127 | ScenePresence avatar; |
1127 | 1128 | ||
1128 | if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) | 1129 | if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) |
1129 | { | 1130 | { |
1130 | destPart.GetProperties(avatar.ControllingClient); | 1131 | destPart.GetProperties(avatar.ControllingClient); |
1131 | } | 1132 | } |
@@ -1153,7 +1154,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1153 | } | 1154 | } |
1154 | 1155 | ||
1155 | ScenePresence avatar = null; | 1156 | ScenePresence avatar = null; |
1156 | if (TryGetAvatar(destID, out avatar)) | 1157 | if (TryGetScenePresence(destID, out avatar)) |
1157 | { | 1158 | { |
1158 | //profile.SendInventoryDecendents(avatar.ControllingClient, | 1159 | //profile.SendInventoryDecendents(avatar.ControllingClient, |
1159 | // profile.RootFolder.ID, true, false); | 1160 | // profile.RootFolder.ID, true, false); |
@@ -1169,15 +1170,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
1169 | 1170 | ||
1170 | private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) | 1171 | private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) |
1171 | { | 1172 | { |
1172 | m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); | 1173 | if (folder == null) |
1174 | return; | ||
1175 | |||
1176 | // TODO: This code for looking in the folder for the library should be folded somewhere else | ||
1177 | // so that this class doesn't have to know the details (and so that multiple libraries, etc. | ||
1178 | // can be handled transparently). | ||
1179 | InventoryFolderImpl fold = null; | ||
1180 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) | ||
1181 | { | ||
1182 | if ((fold = LibraryService.LibraryRootFolder.FindFolder(folder.ID)) != null) | ||
1183 | { | ||
1184 | client.SendInventoryFolderDetails( | ||
1185 | fold.Owner, folder.ID, fold.RequestListOfItems(), | ||
1186 | fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); | ||
1187 | return; | ||
1188 | } | ||
1189 | } | ||
1190 | |||
1191 | // Fetch the folder contents | ||
1173 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); | 1192 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); |
1174 | InventoryFolderBase containingFolder = new InventoryFolderBase(); | 1193 | |
1175 | containingFolder.ID = folder.ID; | 1194 | // Fetch the folder itself to get its current version |
1176 | containingFolder.Owner = client.AgentId; | 1195 | InventoryFolderBase containingFolder = new InventoryFolderBase(folder.ID, client.AgentId); |
1177 | containingFolder = InventoryService.GetFolder(containingFolder); | 1196 | containingFolder = InventoryService.GetFolder(containingFolder); |
1178 | int version = containingFolder.Version; | ||
1179 | 1197 | ||
1180 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); | 1198 | //m_log.DebugFormat("[AGENT INVENTORY]: Sending inventory folder contents ({0} nodes) for \"{1}\" to {2} {3}", |
1199 | // contents.Folders.Count + contents.Items.Count, containingFolder.Name, client.FirstName, client.LastName); | ||
1200 | |||
1201 | if (containingFolder != null && containingFolder != null) | ||
1202 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, containingFolder.Version, fetchFolders, fetchItems); | ||
1181 | } | 1203 | } |
1182 | 1204 | ||
1183 | /// <summary> | 1205 | /// <summary> |
@@ -1219,11 +1241,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1219 | item = InventoryService.GetItem(item); | 1241 | item = InventoryService.GetItem(item); |
1220 | 1242 | ||
1221 | // Try library | 1243 | // Try library |
1222 | if (null == item) | 1244 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1223 | { | 1245 | { |
1224 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1246 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1225 | } | 1247 | } |
1226 | 1248 | ||
1249 | // If we've found the item in the user's inventory or in the library | ||
1227 | if (item != null) | 1250 | if (item != null) |
1228 | { | 1251 | { |
1229 | part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); | 1252 | part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); |
@@ -1258,7 +1281,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1258 | remoteClient, part, transactionID, currentItem); | 1281 | remoteClient, part, transactionID, currentItem); |
1259 | } | 1282 | } |
1260 | if (part.Inventory.UpdateInventoryItem(itemInfo)) | 1283 | if (part.Inventory.UpdateInventoryItem(itemInfo)) |
1284 | { | ||
1285 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
1261 | part.GetProperties(remoteClient); | 1286 | part.GetProperties(remoteClient); |
1287 | } | ||
1262 | } | 1288 | } |
1263 | } | 1289 | } |
1264 | else | 1290 | else |
@@ -1288,9 +1314,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1288 | 1314 | ||
1289 | // Try library | 1315 | // Try library |
1290 | // XXX clumsy, possibly should be one call | 1316 | // XXX clumsy, possibly should be one call |
1291 | if (null == item) | 1317 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1292 | { | 1318 | { |
1293 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1319 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1294 | } | 1320 | } |
1295 | 1321 | ||
1296 | if (item != null) | 1322 | if (item != null) |
@@ -1310,6 +1336,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1310 | // "Rezzed script {0} into prim local ID {1} for user {2}", | 1336 | // "Rezzed script {0} into prim local ID {1} for user {2}", |
1311 | // item.inventoryName, localID, remoteClient.Name); | 1337 | // item.inventoryName, localID, remoteClient.Name); |
1312 | part.GetProperties(remoteClient); | 1338 | part.GetProperties(remoteClient); |
1339 | part.ParentGroup.ResumeScripts(); | ||
1313 | } | 1340 | } |
1314 | else | 1341 | else |
1315 | { | 1342 | { |
@@ -1347,7 +1374,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1347 | itemBase.InvType, part.UUID, remoteClient.AgentId)) | 1374 | itemBase.InvType, part.UUID, remoteClient.AgentId)) |
1348 | return; | 1375 | return; |
1349 | 1376 | ||
1350 | 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}")); | 1377 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1378 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | ||
1379 | remoteClient.AgentId); | ||
1351 | AssetService.Store(asset); | 1380 | AssetService.Store(asset); |
1352 | 1381 | ||
1353 | TaskInventoryItem taskItem = new TaskInventoryItem(); | 1382 | TaskInventoryItem taskItem = new TaskInventoryItem(); |
@@ -1377,6 +1406,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1377 | part.GetProperties(remoteClient); | 1406 | part.GetProperties(remoteClient); |
1378 | 1407 | ||
1379 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); | 1408 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); |
1409 | part.ParentGroup.ResumeScripts(); | ||
1380 | } | 1410 | } |
1381 | } | 1411 | } |
1382 | 1412 | ||
@@ -1480,9 +1510,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1480 | destPart.Inventory.CreateScriptInstance(destTaskItem, start_param, false, DefaultScriptEngine, 0); | 1510 | destPart.Inventory.CreateScriptInstance(destTaskItem, start_param, false, DefaultScriptEngine, 0); |
1481 | } | 1511 | } |
1482 | 1512 | ||
1513 | destPart.ParentGroup.ResumeScripts(); | ||
1514 | |||
1483 | ScenePresence avatar; | 1515 | ScenePresence avatar; |
1484 | 1516 | ||
1485 | if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) | 1517 | if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) |
1486 | { | 1518 | { |
1487 | destPart.GetProperties(avatar.ControllingClient); | 1519 | destPart.GetProperties(avatar.ControllingClient); |
1488 | } | 1520 | } |
@@ -1616,237 +1648,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1616 | } | 1648 | } |
1617 | } | 1649 | } |
1618 | 1650 | ||
1619 | /// <summary> | ||
1620 | /// Delete a scene object from a scene and place in the given avatar's inventory. | ||
1621 | /// Returns the UUID of the newly created asset. | ||
1622 | /// </summary> | ||
1623 | /// <param name="action"></param> | ||
1624 | /// <param name="folderID"></param> | ||
1625 | /// <param name="objectGroup"></param> | ||
1626 | /// <param name="remoteClient"> </param> | ||
1627 | public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, | ||
1628 | SceneObjectGroup objectGroup, IClientAPI remoteClient) | ||
1629 | { | ||
1630 | UUID assetID = UUID.Zero; | ||
1631 | |||
1632 | Vector3 inventoryStoredPosition = new Vector3 | ||
1633 | (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1634 | ? 250 | ||
1635 | : objectGroup.AbsolutePosition.X) | ||
1636 | , | ||
1637 | (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1638 | ? 250 | ||
1639 | : objectGroup.AbsolutePosition.X, | ||
1640 | objectGroup.AbsolutePosition.Z); | ||
1641 | |||
1642 | Vector3 originalPosition = objectGroup.AbsolutePosition; | ||
1643 | |||
1644 | objectGroup.AbsolutePosition = inventoryStoredPosition; | ||
1645 | |||
1646 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); | ||
1647 | |||
1648 | objectGroup.AbsolutePosition = originalPosition; | ||
1649 | |||
1650 | // Get the user info of the item destination | ||
1651 | // | ||
1652 | UUID userID = UUID.Zero; | ||
1653 | |||
1654 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || | ||
1655 | action == DeRezAction.SaveToExistingUserInventoryItem) | ||
1656 | { | ||
1657 | // Take or take copy require a taker | ||
1658 | // Saving changes requires a local user | ||
1659 | // | ||
1660 | if (remoteClient == null) | ||
1661 | return UUID.Zero; | ||
1662 | |||
1663 | userID = remoteClient.AgentId; | ||
1664 | } | ||
1665 | else | ||
1666 | { | ||
1667 | // All returns / deletes go to the object owner | ||
1668 | // | ||
1669 | |||
1670 | userID = objectGroup.RootPart.OwnerID; | ||
1671 | } | ||
1672 | |||
1673 | if (userID == UUID.Zero) // Can't proceed | ||
1674 | { | ||
1675 | return UUID.Zero; | ||
1676 | } | ||
1677 | |||
1678 | // If we're returning someone's item, it goes back to the | ||
1679 | // owner's Lost And Found folder. | ||
1680 | // Delete is treated like return in this case | ||
1681 | // Deleting your own items makes them go to trash | ||
1682 | // | ||
1683 | |||
1684 | InventoryFolderBase folder = null; | ||
1685 | InventoryItemBase item = null; | ||
1686 | |||
1687 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | ||
1688 | { | ||
1689 | item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); | ||
1690 | item = InventoryService.GetItem(item); | ||
1691 | |||
1692 | //item = userInfo.RootFolder.FindItem( | ||
1693 | // objectGroup.RootPart.FromUserInventoryItemID); | ||
1694 | |||
1695 | if (null == item) | ||
1696 | { | ||
1697 | m_log.DebugFormat( | ||
1698 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", | ||
1699 | objectGroup.Name, objectGroup.UUID); | ||
1700 | return UUID.Zero; | ||
1701 | } | ||
1702 | } | ||
1703 | else | ||
1704 | { | ||
1705 | // Folder magic | ||
1706 | // | ||
1707 | if (action == DeRezAction.Delete) | ||
1708 | { | ||
1709 | // Deleting someone else's item | ||
1710 | // | ||
1711 | |||
1712 | |||
1713 | if (remoteClient == null || | ||
1714 | objectGroup.OwnerID != remoteClient.AgentId) | ||
1715 | { | ||
1716 | // Folder skeleton may not be loaded and we | ||
1717 | // have to wait for the inventory to find | ||
1718 | // the destination folder | ||
1719 | // | ||
1720 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1721 | } | ||
1722 | else | ||
1723 | { | ||
1724 | // Assume inventory skeleton was loaded during login | ||
1725 | // and all folders can be found | ||
1726 | // | ||
1727 | folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | ||
1728 | } | ||
1729 | } | ||
1730 | else if (action == DeRezAction.Return) | ||
1731 | { | ||
1732 | |||
1733 | // Dump to lost + found unconditionally | ||
1734 | // | ||
1735 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1736 | } | ||
1737 | |||
1738 | if (folderID == UUID.Zero && folder == null) | ||
1739 | { | ||
1740 | if (action == DeRezAction.Delete) | ||
1741 | { | ||
1742 | // Deletes go to trash by default | ||
1743 | // | ||
1744 | folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | ||
1745 | } | ||
1746 | else | ||
1747 | { | ||
1748 | // Catch all. Use lost & found | ||
1749 | // | ||
1750 | |||
1751 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1752 | } | ||
1753 | } | ||
1754 | |||
1755 | if (folder == null) // None of the above | ||
1756 | { | ||
1757 | //folder = userInfo.RootFolder.FindFolder(folderID); | ||
1758 | folder = new InventoryFolderBase(folderID); | ||
1759 | |||
1760 | if (folder == null) // Nowhere to put it | ||
1761 | { | ||
1762 | return UUID.Zero; | ||
1763 | } | ||
1764 | } | ||
1765 | |||
1766 | item = new InventoryItemBase(); | ||
1767 | item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); | ||
1768 | item.ID = UUID.Random(); | ||
1769 | item.InvType = (int)InventoryType.Object; | ||
1770 | item.Folder = folder.ID; | ||
1771 | item.Owner = userID; | ||
1772 | } | ||
1773 | |||
1774 | AssetBase asset = CreateAsset( | ||
1775 | objectGroup.GetPartName(objectGroup.RootPart.LocalId), | ||
1776 | objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), | ||
1777 | (sbyte)AssetType.Object, | ||
1778 | Utils.StringToBytes(sceneObjectXml)); | ||
1779 | AssetService.Store(asset); | ||
1780 | assetID = asset.FullID; | ||
1781 | |||
1782 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | ||
1783 | { | ||
1784 | item.AssetID = asset.FullID; | ||
1785 | InventoryService.UpdateItem(item); | ||
1786 | } | ||
1787 | else | ||
1788 | { | ||
1789 | item.AssetID = asset.FullID; | ||
1790 | |||
1791 | if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
1792 | { | ||
1793 | uint perms=objectGroup.GetEffectivePermissions(); | ||
1794 | uint nextPerms=(perms & 7) << 13; | ||
1795 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
1796 | perms &= ~(uint)PermissionMask.Copy; | ||
1797 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
1798 | perms &= ~(uint)PermissionMask.Transfer; | ||
1799 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
1800 | perms &= ~(uint)PermissionMask.Modify; | ||
1801 | |||
1802 | item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; | ||
1803 | item.CurrentPermissions = item.BasePermissions; | ||
1804 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; | ||
1805 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; | ||
1806 | item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; | ||
1807 | item.CurrentPermissions |= 8; // Slam! | ||
1808 | } | ||
1809 | else | ||
1810 | { | ||
1811 | uint ownerPerms = objectGroup.GetEffectivePermissions(); | ||
1812 | if ((objectGroup.RootPart.OwnerMask & (uint)PermissionMask.Modify) != 0) | ||
1813 | ownerPerms |= (uint)PermissionMask.Modify; | ||
1814 | |||
1815 | item.BasePermissions = ownerPerms; | ||
1816 | item.CurrentPermissions = ownerPerms; | ||
1817 | |||
1818 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; | ||
1819 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; | ||
1820 | item.GroupPermissions = objectGroup.RootPart.GroupMask; | ||
1821 | |||
1822 | item.CurrentPermissions |= 8; // Slam! | ||
1823 | } | ||
1824 | |||
1825 | // TODO: add the new fields (Flags, Sale info, etc) | ||
1826 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
1827 | item.Description = asset.Description; | ||
1828 | item.Name = asset.Name; | ||
1829 | item.AssetType = asset.Type; | ||
1830 | |||
1831 | InventoryService.AddItem(item); | ||
1832 | |||
1833 | if (remoteClient != null && item.Owner == remoteClient.AgentId) | ||
1834 | { | ||
1835 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
1836 | } | ||
1837 | else | ||
1838 | { | ||
1839 | ScenePresence notifyUser = GetScenePresence(item.Owner); | ||
1840 | if (notifyUser != null) | ||
1841 | { | ||
1842 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); | ||
1843 | } | ||
1844 | } | ||
1845 | } | ||
1846 | |||
1847 | return assetID; | ||
1848 | } | ||
1849 | |||
1850 | public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) | 1651 | public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) |
1851 | { | 1652 | { |
1852 | SceneObjectGroup objectGroup = grp; | 1653 | SceneObjectGroup objectGroup = grp; |
@@ -1873,7 +1674,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1873 | objectGroup.GetPartName(objectGroup.LocalId), | 1674 | objectGroup.GetPartName(objectGroup.LocalId), |
1874 | objectGroup.GetPartDescription(objectGroup.LocalId), | 1675 | objectGroup.GetPartDescription(objectGroup.LocalId), |
1875 | (sbyte)AssetType.Object, | 1676 | (sbyte)AssetType.Object, |
1876 | Utils.StringToBytes(sceneObjectXml)); | 1677 | Utils.StringToBytes(sceneObjectXml), |
1678 | remoteClient.AgentId); | ||
1877 | AssetService.Store(asset); | 1679 | AssetService.Store(asset); |
1878 | 1680 | ||
1879 | item.AssetID = asset.FullID; | 1681 | item.AssetID = asset.FullID; |
@@ -1920,7 +1722,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1920 | grp.GetPartName(grp.LocalId), | 1722 | grp.GetPartName(grp.LocalId), |
1921 | grp.GetPartDescription(grp.LocalId), | 1723 | grp.GetPartDescription(grp.LocalId), |
1922 | (sbyte)AssetType.Object, | 1724 | (sbyte)AssetType.Object, |
1923 | Utils.StringToBytes(sceneObjectXml)); | 1725 | Utils.StringToBytes(sceneObjectXml), |
1726 | remoteClient.AgentId); | ||
1924 | AssetService.Store(asset); | 1727 | AssetService.Store(asset); |
1925 | 1728 | ||
1926 | InventoryItemBase item = new InventoryItemBase(); | 1729 | InventoryItemBase item = new InventoryItemBase(); |
@@ -1987,225 +1790,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1987 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | 1790 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, |
1988 | bool RezSelected, bool RemoveItem, UUID fromTaskID) | 1791 | bool RezSelected, bool RemoveItem, UUID fromTaskID) |
1989 | { | 1792 | { |
1990 | RezObject( | 1793 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); |
1991 | remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | 1794 | if (invAccess != null) |
1992 | RezSelected, RemoveItem, fromTaskID, false); | 1795 | invAccess.RezObject( |
1993 | } | 1796 | remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, |
1994 | 1797 | RezSelected, RemoveItem, fromTaskID, false); | |
1995 | /// <summary> | ||
1996 | /// Rez an object into the scene from the user's inventory | ||
1997 | /// </summary> | ||
1998 | /// <param name="remoteClient"></param> | ||
1999 | /// <param name="itemID"></param> | ||
2000 | /// <param name="RayEnd"></param> | ||
2001 | /// <param name="RayStart"></param> | ||
2002 | /// <param name="RayTargetID"></param> | ||
2003 | /// <param name="BypassRayCast"></param> | ||
2004 | /// <param name="RayEndIsIntersection"></param> | ||
2005 | /// <param name="RezSelected"></param> | ||
2006 | /// <param name="RemoveItem"></param> | ||
2007 | /// <param name="fromTaskID"></param> | ||
2008 | /// <param name="attachment"></param> | ||
2009 | /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns> | ||
2010 | public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | ||
2011 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
2012 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
2013 | { | ||
2014 | // Work out position details | ||
2015 | byte bRayEndIsIntersection = (byte)0; | ||
2016 | |||
2017 | if (RayEndIsIntersection) | ||
2018 | { | ||
2019 | bRayEndIsIntersection = (byte)1; | ||
2020 | } | ||
2021 | else | ||
2022 | { | ||
2023 | bRayEndIsIntersection = (byte)0; | ||
2024 | } | ||
2025 | |||
2026 | Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); | ||
2027 | |||
2028 | |||
2029 | Vector3 pos = GetNewRezLocation( | ||
2030 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | ||
2031 | BypassRayCast, bRayEndIsIntersection,true,scale, false); | ||
2032 | |||
2033 | // Rez object | ||
2034 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
2035 | item = InventoryService.GetItem(item); | ||
2036 | |||
2037 | if (item != null) | ||
2038 | { | ||
2039 | AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); | ||
2040 | |||
2041 | if (rezAsset != null) | ||
2042 | { | ||
2043 | UUID itemId = UUID.Zero; | ||
2044 | |||
2045 | // If we have permission to copy then link the rezzed object back to the user inventory | ||
2046 | // item that it came from. This allows us to enable 'save object to inventory' | ||
2047 | if (!Permissions.BypassPermissions()) | ||
2048 | { | ||
2049 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) | ||
2050 | { | ||
2051 | itemId = item.ID; | ||
2052 | } | ||
2053 | } | ||
2054 | else | ||
2055 | { | ||
2056 | // Brave new fullperm world | ||
2057 | // | ||
2058 | itemId = item.ID; | ||
2059 | } | ||
2060 | |||
2061 | string xmlData = Utils.BytesToString(rezAsset.Data); | ||
2062 | SceneObjectGroup group | ||
2063 | = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); | ||
2064 | |||
2065 | if (!Permissions.CanRezObject( | ||
2066 | group.Children.Count, remoteClient.AgentId, pos) | ||
2067 | && !attachment) | ||
2068 | { | ||
2069 | // The client operates in no fail mode. It will | ||
2070 | // have already removed the item from the folder | ||
2071 | // if it's no copy. | ||
2072 | // Put it back if it's not an attachment | ||
2073 | // | ||
2074 | if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) | ||
2075 | remoteClient.SendBulkUpdateInventory(item); | ||
2076 | return null; | ||
2077 | } | ||
2078 | |||
2079 | group.ResetIDs(); | ||
2080 | |||
2081 | if (attachment) | ||
2082 | { | ||
2083 | group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom; | ||
2084 | group.RootPart.IsAttachment = true; | ||
2085 | } | ||
2086 | |||
2087 | AddNewSceneObject(group, true); | ||
2088 | |||
2089 | // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); | ||
2090 | // if attachment we set it's asset id so object updates can reflect that | ||
2091 | // if not, we set it's position in world. | ||
2092 | if (!attachment) | ||
2093 | { | ||
2094 | float offsetHeight = 0; | ||
2095 | pos = GetNewRezLocation( | ||
2096 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | ||
2097 | BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false); | ||
2098 | pos.Z += offsetHeight; | ||
2099 | group.AbsolutePosition = pos; | ||
2100 | // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight); | ||
2101 | |||
2102 | } | ||
2103 | else | ||
2104 | { | ||
2105 | group.SetFromItemID(itemID); | ||
2106 | } | ||
2107 | |||
2108 | SceneObjectPart rootPart = null; | ||
2109 | try | ||
2110 | { | ||
2111 | rootPart = group.GetChildPart(group.UUID); | ||
2112 | } | ||
2113 | catch (NullReferenceException) | ||
2114 | { | ||
2115 | string isAttachment = ""; | ||
2116 | |||
2117 | if (attachment) | ||
2118 | isAttachment = " Object was an attachment"; | ||
2119 | |||
2120 | m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); | ||
2121 | } | ||
2122 | |||
2123 | // Since renaming the item in the inventory does not affect the name stored | ||
2124 | // in the serialization, transfer the correct name from the inventory to the | ||
2125 | // object itself before we rez. | ||
2126 | rootPart.Name = item.Name; | ||
2127 | rootPart.Description = item.Description; | ||
2128 | |||
2129 | List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); | ||
2130 | |||
2131 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); | ||
2132 | if (rootPart.OwnerID != item.Owner) | ||
2133 | { | ||
2134 | //Need to kill the for sale here | ||
2135 | rootPart.ObjectSaleType = 0; | ||
2136 | rootPart.SalePrice = 10; | ||
2137 | |||
2138 | if (Permissions.PropagatePermissions()) | ||
2139 | { | ||
2140 | if ((item.CurrentPermissions & 8) != 0) | ||
2141 | { | ||
2142 | foreach (SceneObjectPart part in partList) | ||
2143 | { | ||
2144 | part.EveryoneMask = item.EveryOnePermissions; | ||
2145 | part.NextOwnerMask = item.NextPermissions; | ||
2146 | part.GroupMask = 0; // DO NOT propagate here | ||
2147 | } | ||
2148 | } | ||
2149 | group.ApplyNextOwnerPermissions(); | ||
2150 | } | ||
2151 | } | ||
2152 | |||
2153 | foreach (SceneObjectPart part in partList) | ||
2154 | { | ||
2155 | if (part.OwnerID != item.Owner) | ||
2156 | { | ||
2157 | part.LastOwnerID = part.OwnerID; | ||
2158 | part.OwnerID = item.Owner; | ||
2159 | part.Inventory.ChangeInventoryOwner(item.Owner); | ||
2160 | } | ||
2161 | else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam! | ||
2162 | { | ||
2163 | part.EveryoneMask = item.EveryOnePermissions; | ||
2164 | part.NextOwnerMask = item.NextPermissions; | ||
2165 | |||
2166 | part.GroupMask = 0; // DO NOT propagate here | ||
2167 | } | ||
2168 | } | ||
2169 | |||
2170 | rootPart.TrimPermissions(); | ||
2171 | |||
2172 | if (!attachment) | ||
2173 | { | ||
2174 | if (group.RootPart.Shape.PCode == (byte)PCode.Prim) | ||
2175 | { | ||
2176 | group.ClearPartAttachmentData(); | ||
2177 | } | ||
2178 | } | ||
2179 | |||
2180 | if (!attachment) | ||
2181 | { | ||
2182 | // Fire on_rez | ||
2183 | group.CreateScriptInstances(0, true, DefaultScriptEngine, 0); | ||
2184 | |||
2185 | rootPart.ScheduleFullUpdate(); | ||
2186 | } | ||
2187 | |||
2188 | if (!Permissions.BypassPermissions()) | ||
2189 | { | ||
2190 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
2191 | { | ||
2192 | // If this is done on attachments, no | ||
2193 | // copy ones will be lost, so avoid it | ||
2194 | // | ||
2195 | if (!attachment) | ||
2196 | { | ||
2197 | List<UUID> uuids = new List<UUID>(); | ||
2198 | uuids.Add(item.ID); | ||
2199 | InventoryService.DeleteItems(item.Owner, uuids); | ||
2200 | } | ||
2201 | } | ||
2202 | } | ||
2203 | |||
2204 | return rootPart.ParentGroup; | ||
2205 | } | ||
2206 | } | ||
2207 | |||
2208 | return null; | ||
2209 | } | 1798 | } |
2210 | 1799 | ||
2211 | /// <summary> | 1800 | /// <summary> |
@@ -2343,178 +1932,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2343 | EventManager.TriggerStopScript(part.LocalId, itemID); | 1932 | EventManager.TriggerStopScript(part.LocalId, itemID); |
2344 | } | 1933 | } |
2345 | 1934 | ||
2346 | internal void SendAttachEvent(uint localID, UUID itemID, UUID avatarID) | ||
2347 | { | ||
2348 | EventManager.TriggerOnAttach(localID, itemID, avatarID); | ||
2349 | } | ||
2350 | |||
2351 | /// <summary> | ||
2352 | /// Called when the client receives a request to rez a single attachment on to the avatar from inventory | ||
2353 | /// (RezSingleAttachmentFromInv packet). | ||
2354 | /// </summary> | ||
2355 | /// <param name="remoteClient"></param> | ||
2356 | /// <param name="itemID"></param> | ||
2357 | /// <param name="AttachmentPt"></param> | ||
2358 | /// <returns></returns> | ||
2359 | public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | ||
2360 | { | ||
2361 | m_log.DebugFormat("[USER INVENTORY]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name); | ||
2362 | |||
2363 | SceneObjectGroup att = m_sceneGraph.RezSingleAttachment(remoteClient, itemID, AttachmentPt); | ||
2364 | |||
2365 | if (att == null) | ||
2366 | { | ||
2367 | DetachSingleAttachmentToInv(itemID, remoteClient); | ||
2368 | return UUID.Zero; | ||
2369 | } | ||
2370 | |||
2371 | return RezSingleAttachment(att, remoteClient, itemID, AttachmentPt); | ||
2372 | } | ||
2373 | |||
2374 | /// <summary> | ||
2375 | /// Update the user inventory to reflect an attachment | ||
2376 | /// </summary> | ||
2377 | /// <param name="att"></param> | ||
2378 | /// <param name="remoteClient"></param> | ||
2379 | /// <param name="itemID"></param> | ||
2380 | /// <param name="AttachmentPt"></param> | ||
2381 | /// <returns></returns> | ||
2382 | public UUID RezSingleAttachment(SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | ||
2383 | { | ||
2384 | m_log.DebugFormat( | ||
2385 | "[USER INVENTORY]: Updating inventory of {0} to show attachment of {1} (item ID {2})", | ||
2386 | remoteClient.Name, att.Name, itemID); | ||
2387 | |||
2388 | if (!att.IsDeleted) | ||
2389 | AttachmentPt = att.RootPart.AttachmentPoint; | ||
2390 | |||
2391 | ScenePresence presence; | ||
2392 | if (TryGetAvatar(remoteClient.AgentId, out presence)) | ||
2393 | { | ||
2394 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
2395 | item = InventoryService.GetItem(item); | ||
2396 | |||
2397 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); | ||
2398 | } | ||
2399 | return att.UUID; | ||
2400 | } | ||
2401 | |||
2402 | public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, | ||
2403 | RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects) | ||
2404 | { | ||
2405 | foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects) | ||
2406 | { | ||
2407 | RezSingleAttachment(remoteClient, obj.ItemID, obj.AttachmentPt); | ||
2408 | } | ||
2409 | } | ||
2410 | |||
2411 | /// <summary> | ||
2412 | /// Attach an object. | ||
2413 | /// </summary> | ||
2414 | /// <param name="controllingClient"></param> | ||
2415 | /// <param name="localID"></param> | ||
2416 | /// <param name="attachPoint"></param> | ||
2417 | /// <param name="rot"></param> | ||
2418 | /// <param name="pos"></param> | ||
2419 | /// <param name="silent"></param> | ||
2420 | /// <returns>true if the object was successfully attached, false otherwise</returns> | ||
2421 | public bool AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, Quaternion rot, Vector3 pos, bool silent) | ||
2422 | { | ||
2423 | return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent); | ||
2424 | } | ||
2425 | |||
2426 | /// <summary> | ||
2427 | /// This registers the item as attached in a user's inventory | ||
2428 | /// </summary> | ||
2429 | /// <param name="remoteClient"></param> | ||
2430 | /// <param name="AttachmentPt"></param> | ||
2431 | /// <param name="itemID"></param> | ||
2432 | /// <param name="att"></param> | ||
2433 | public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) | ||
2434 | { | ||
2435 | // m_log.DebugFormat( | ||
2436 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", | ||
2437 | // att.Name, remoteClient.Name, AttachmentPt, itemID); | ||
2438 | |||
2439 | if (UUID.Zero == itemID) | ||
2440 | { | ||
2441 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID."); | ||
2442 | return; | ||
2443 | } | ||
2444 | |||
2445 | if (0 == AttachmentPt) | ||
2446 | { | ||
2447 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error attachment point."); | ||
2448 | return; | ||
2449 | } | ||
2450 | |||
2451 | if (null == att.RootPart) | ||
2452 | { | ||
2453 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment for a prim without the rootpart!"); | ||
2454 | return; | ||
2455 | } | ||
2456 | |||
2457 | ScenePresence presence; | ||
2458 | if (TryGetAvatar(remoteClient.AgentId, out presence)) | ||
2459 | { | ||
2460 | // XXYY!! | ||
2461 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
2462 | item = InventoryService.GetItem(item); | ||
2463 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); | ||
2464 | |||
2465 | if (m_AvatarFactory != null) | ||
2466 | m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
2467 | } | ||
2468 | } | ||
2469 | |||
2470 | public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) | ||
2471 | { | ||
2472 | SceneObjectPart part = GetSceneObjectPart(itemID); | ||
2473 | if (part == null || part.ParentGroup == null) | ||
2474 | return; | ||
2475 | |||
2476 | UUID inventoryID = part.ParentGroup.GetFromItemID(); | ||
2477 | |||
2478 | ScenePresence presence; | ||
2479 | if (TryGetAvatar(remoteClient.AgentId, out presence)) | ||
2480 | { | ||
2481 | if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) | ||
2482 | return; | ||
2483 | |||
2484 | presence.Appearance.DetachAttachment(itemID); | ||
2485 | IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>(); | ||
2486 | if (ava != null) | ||
2487 | { | ||
2488 | ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
2489 | } | ||
2490 | part.ParentGroup.DetachToGround(); | ||
2491 | |||
2492 | List<UUID> uuids = new List<UUID>(); | ||
2493 | uuids.Add(inventoryID); | ||
2494 | InventoryService.DeleteItems(remoteClient.AgentId, uuids); | ||
2495 | remoteClient.SendRemoveInventoryItem(inventoryID); | ||
2496 | } | ||
2497 | SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); | ||
2498 | } | ||
2499 | |||
2500 | public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) | ||
2501 | { | ||
2502 | ScenePresence presence; | ||
2503 | if (TryGetAvatar(remoteClient.AgentId, out presence)) | ||
2504 | { | ||
2505 | presence.Appearance.DetachAttachment(itemID); | ||
2506 | |||
2507 | // Save avatar attachment information | ||
2508 | if (m_AvatarFactory != null) | ||
2509 | { | ||
2510 | m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID); | ||
2511 | m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
2512 | } | ||
2513 | } | ||
2514 | |||
2515 | m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient); | ||
2516 | } | ||
2517 | |||
2518 | public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) | 1935 | public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) |
2519 | { | 1936 | { |
2520 | EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); | 1937 | 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..e25b1f1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -32,7 +32,7 @@ using OpenMetaverse; | |||
32 | using OpenMetaverse.Packets; | 32 | using OpenMetaverse.Packets; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | using OpenSim.Services.Interfaces; |
36 | 36 | ||
37 | namespace OpenSim.Region.Framework.Scenes | 37 | namespace 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; |
@@ -494,17 +513,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
494 | { | 513 | { |
495 | // FIXME MAYBE: We're not handling sortOrder! | 514 | // FIXME MAYBE: We're not handling sortOrder! |
496 | 515 | ||
497 | // TODO: This code for looking in the folder for the library should be folded back into the | 516 | // TODO: This code for looking in the folder for the library should be folded somewhere else |
498 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. | 517 | // 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 ee097bc..122ed02 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; | ||
30 | using System.Drawing; | 31 | using System.Drawing; |
31 | using System.Drawing.Imaging; | 32 | using System.Drawing.Imaging; |
32 | using System.IO; | 33 | using System.IO; |
@@ -41,8 +42,7 @@ using OpenMetaverse.Imaging; | |||
41 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
42 | using OpenSim.Services.Interfaces; | 43 | using OpenSim.Services.Interfaces; |
43 | using OpenSim.Framework.Communications; | 44 | using OpenSim.Framework.Communications; |
44 | using OpenSim.Framework.Communications.Cache; | 45 | |
45 | using OpenSim.Framework.Communications.Clients; | ||
46 | using OpenSim.Framework.Console; | 46 | using OpenSim.Framework.Console; |
47 | using OpenSim.Region.Framework.Interfaces; | 47 | using OpenSim.Region.Framework.Interfaces; |
48 | using OpenSim.Region.Framework.Scenes.Scripting; | 48 | using 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; |
@@ -203,11 +201,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
203 | { | 201 | { |
204 | m_AuthorizationService = RequestModuleInterface<IAuthorizationService>(); | 202 | m_AuthorizationService = RequestModuleInterface<IAuthorizationService>(); |
205 | 203 | ||
206 | if (m_AuthorizationService == null) | 204 | //if (m_AuthorizationService == null) |
207 | { | 205 | //{ |
208 | // don't throw an exception if no authorization service is set for the time being | 206 | // // don't throw an exception if no authorization service is set for the time being |
209 | m_log.InfoFormat("[SCENE]: No Authorization service is configured"); | 207 | // m_log.InfoFormat("[SCENE]: No Authorization service is configured"); |
210 | } | 208 | //} |
211 | } | 209 | } |
212 | 210 | ||
213 | return m_AuthorizationService; | 211 | return m_AuthorizationService; |
@@ -254,8 +252,87 @@ namespace OpenSim.Region.Framework.Scenes | |||
254 | } | 252 | } |
255 | } | 253 | } |
256 | 254 | ||
255 | protected ILibraryService m_LibraryService; | ||
256 | |||
257 | public ILibraryService LibraryService | ||
258 | { | ||
259 | get | ||
260 | { | ||
261 | if (m_LibraryService == null) | ||
262 | m_LibraryService = RequestModuleInterface<ILibraryService>(); | ||
263 | |||
264 | return m_LibraryService; | ||
265 | } | ||
266 | } | ||
267 | |||
268 | protected ISimulationService m_simulationService; | ||
269 | public ISimulationService SimulationService | ||
270 | { | ||
271 | get | ||
272 | { | ||
273 | if (m_simulationService == null) | ||
274 | m_simulationService = RequestModuleInterface<ISimulationService>(); | ||
275 | return m_simulationService; | ||
276 | } | ||
277 | } | ||
278 | |||
279 | protected IAuthenticationService m_AuthenticationService; | ||
280 | public IAuthenticationService AuthenticationService | ||
281 | { | ||
282 | get | ||
283 | { | ||
284 | if (m_AuthenticationService == null) | ||
285 | m_AuthenticationService = RequestModuleInterface<IAuthenticationService>(); | ||
286 | return m_AuthenticationService; | ||
287 | } | ||
288 | } | ||
289 | |||
290 | protected IPresenceService m_PresenceService; | ||
291 | public IPresenceService PresenceService | ||
292 | { | ||
293 | get | ||
294 | { | ||
295 | if (m_PresenceService == null) | ||
296 | m_PresenceService = RequestModuleInterface<IPresenceService>(); | ||
297 | return m_PresenceService; | ||
298 | } | ||
299 | } | ||
300 | protected IUserAccountService m_UserAccountService; | ||
301 | public IUserAccountService UserAccountService | ||
302 | { | ||
303 | get | ||
304 | { | ||
305 | if (m_UserAccountService == null) | ||
306 | m_UserAccountService = RequestModuleInterface<IUserAccountService>(); | ||
307 | return m_UserAccountService; | ||
308 | } | ||
309 | } | ||
310 | |||
311 | protected OpenSim.Services.Interfaces.IAvatarService m_AvatarService; | ||
312 | public OpenSim.Services.Interfaces.IAvatarService AvatarService | ||
313 | { | ||
314 | get | ||
315 | { | ||
316 | if (m_AvatarService == null) | ||
317 | m_AvatarService = RequestModuleInterface<IAvatarService>(); | ||
318 | return m_AvatarService; | ||
319 | } | ||
320 | } | ||
321 | |||
322 | protected IGridUserService m_GridUserService; | ||
323 | public IGridUserService GridUserService | ||
324 | { | ||
325 | get | ||
326 | { | ||
327 | if (m_GridUserService == null) | ||
328 | m_GridUserService = RequestModuleInterface<IGridUserService>(); | ||
329 | return m_GridUserService; | ||
330 | } | ||
331 | } | ||
332 | |||
257 | protected IXMLRPC m_xmlrpcModule; | 333 | protected IXMLRPC m_xmlrpcModule; |
258 | protected IWorldComm m_worldCommModule; | 334 | protected IWorldComm m_worldCommModule; |
335 | public IAttachmentsModule AttachmentsModule { get; set; } | ||
259 | protected IAvatarFactory m_AvatarFactory; | 336 | protected IAvatarFactory m_AvatarFactory; |
260 | public IAvatarFactory AvatarFactory | 337 | public IAvatarFactory AvatarFactory |
261 | { | 338 | { |
@@ -263,10 +340,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
263 | } | 340 | } |
264 | protected IConfigSource m_config; | 341 | protected IConfigSource m_config; |
265 | protected IRegionSerialiserModule m_serialiser; | 342 | protected IRegionSerialiserModule m_serialiser; |
266 | protected IInterregionCommsOut m_interregionCommsOut; | ||
267 | protected IInterregionCommsIn m_interregionCommsIn; | ||
268 | protected IDialogModule m_dialogModule; | 343 | protected IDialogModule m_dialogModule; |
269 | protected ITeleportModule m_teleportModule; | 344 | protected IEntityTransferModule m_teleportModule; |
270 | 345 | ||
271 | protected ICapabilitiesModule m_capsModule; | 346 | protected ICapabilitiesModule m_capsModule; |
272 | public ICapabilitiesModule CapsModule | 347 | public ICapabilitiesModule CapsModule |
@@ -497,7 +572,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
497 | #region Constructors | 572 | #region Constructors |
498 | 573 | ||
499 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, | 574 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, |
500 | CommunicationsManager commsMan, SceneCommunicationService sceneGridService, | 575 | SceneCommunicationService sceneGridService, |
501 | StorageManager storeManager, | 576 | StorageManager storeManager, |
502 | ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, | 577 | ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, |
503 | bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) | 578 | bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) |
@@ -533,7 +608,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
533 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); | 608 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); |
534 | m_moduleLoader = moduleLoader; | 609 | m_moduleLoader = moduleLoader; |
535 | m_authenticateHandler = authen; | 610 | m_authenticateHandler = authen; |
536 | CommsManager = commsMan; | ||
537 | m_sceneGridService = sceneGridService; | 611 | m_sceneGridService = sceneGridService; |
538 | m_storageManager = storeManager; | 612 | m_storageManager = storeManager; |
539 | m_regInfo = regInfo; | 613 | m_regInfo = regInfo; |
@@ -557,9 +631,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
557 | 631 | ||
558 | if (m_storageManager.EstateDataStore != null) | 632 | if (m_storageManager.EstateDataStore != null) |
559 | { | 633 | { |
560 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); | 634 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); |
635 | if (m_regInfo.EstateSettings.EstateID == 0) // No record at all | ||
636 | { | ||
637 | MainConsole.Instance.Output("Your region is not part of an estate."); | ||
638 | while (true) | ||
639 | { | ||
640 | string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List<string>() {"yes", "no"}); | ||
641 | if (response == "no") | ||
642 | { | ||
643 | // Create a new estate | ||
644 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true); | ||
645 | |||
646 | m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName); | ||
647 | m_regInfo.EstateSettings.Save(); | ||
648 | break; | ||
649 | } | ||
650 | else | ||
651 | { | ||
652 | response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); | ||
653 | if (response == "None") | ||
654 | continue; | ||
655 | |||
656 | List<int> estateIDs = m_storageManager.EstateDataStore.GetEstates(response); | ||
657 | if (estateIDs.Count < 1) | ||
658 | { | ||
659 | MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); | ||
660 | continue; | ||
661 | } | ||
662 | |||
663 | int estateID = estateIDs[0]; | ||
664 | |||
665 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID); | ||
666 | |||
667 | if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID)) | ||
668 | break; | ||
669 | |||
670 | MainConsole.Instance.Output("Joining the estate failed. Please try again."); | ||
671 | } | ||
672 | } | ||
673 | } | ||
561 | } | 674 | } |
562 | 675 | ||
676 | MainConsole.Instance.Commands.AddCommand("region", false, "reload estate", | ||
677 | "reload estate", | ||
678 | "Reload the estate data", HandleReloadEstate); | ||
679 | |||
563 | //Bind Storage Manager functions to some land manager functions for this scene | 680 | //Bind Storage Manager functions to some land manager functions for this scene |
564 | EventManager.OnLandObjectAdded += | 681 | EventManager.OnLandObjectAdded += |
565 | new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); | 682 | new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); |
@@ -606,9 +723,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
606 | // | 723 | // |
607 | IConfig startupConfig = m_config.Configs["Startup"]; | 724 | IConfig startupConfig = m_config.Configs["Startup"]; |
608 | 725 | ||
609 | // Should we try to run loops synchronously or asynchronously? | ||
610 | m_useAsyncWhenPossible = startupConfig.GetBoolean("use_async_when_possible", false); | ||
611 | |||
612 | //Animation states | 726 | //Animation states |
613 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 727 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
614 | // TODO: Change default to true once the feature is supported | 728 | // TODO: Change default to true once the feature is supported |
@@ -792,6 +906,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
792 | return m_simulatorVersion; | 906 | return m_simulatorVersion; |
793 | } | 907 | } |
794 | 908 | ||
909 | public string[] GetUserNames(UUID uuid) | ||
910 | { | ||
911 | string[] returnstring = new string[0]; | ||
912 | |||
913 | UserAccount account = UserAccountService.GetUserAccount(RegionInfo.ScopeID, uuid); | ||
914 | |||
915 | if (account != null) | ||
916 | { | ||
917 | returnstring = new string[2]; | ||
918 | returnstring[0] = account.FirstName; | ||
919 | returnstring[1] = account.LastName; | ||
920 | } | ||
921 | |||
922 | return returnstring; | ||
923 | } | ||
924 | |||
925 | public string GetUserName(UUID uuid) | ||
926 | { | ||
927 | string[] names = GetUserNames(uuid); | ||
928 | if (names.Length == 2) | ||
929 | { | ||
930 | string firstname = names[0]; | ||
931 | string lastname = names[1]; | ||
932 | |||
933 | return firstname + " " + lastname; | ||
934 | |||
935 | } | ||
936 | return "(hippos)"; | ||
937 | } | ||
938 | |||
795 | /// <summary> | 939 | /// <summary> |
796 | /// Another region is up. | 940 | /// Another region is up. |
797 | /// | 941 | /// |
@@ -825,7 +969,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
825 | regInfo.RegionName = otherRegion.RegionName; | 969 | regInfo.RegionName = otherRegion.RegionName; |
826 | regInfo.ScopeID = otherRegion.ScopeID; | 970 | regInfo.ScopeID = otherRegion.ScopeID; |
827 | regInfo.ExternalHostName = otherRegion.ExternalHostName; | 971 | regInfo.ExternalHostName = otherRegion.ExternalHostName; |
828 | 972 | GridRegion r = new GridRegion(regInfo); | |
829 | try | 973 | try |
830 | { | 974 | { |
831 | ForEachScenePresence(delegate(ScenePresence agent) | 975 | ForEachScenePresence(delegate(ScenePresence agent) |
@@ -839,7 +983,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
839 | List<ulong> old = new List<ulong>(); | 983 | List<ulong> old = new List<ulong>(); |
840 | old.Add(otherRegion.RegionHandle); | 984 | old.Add(otherRegion.RegionHandle); |
841 | agent.DropOldNeighbours(old); | 985 | agent.DropOldNeighbours(old); |
842 | InformClientOfNeighbor(agent, regInfo); | 986 | if (m_teleportModule != null) |
987 | m_teleportModule.EnableChildAgent(agent, r); | ||
843 | } | 988 | } |
844 | } | 989 | } |
845 | ); | 990 | ); |
@@ -999,6 +1144,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
999 | { | 1144 | { |
1000 | foreach (RegionInfo region in m_regionRestartNotifyList) | 1145 | foreach (RegionInfo region in m_regionRestartNotifyList) |
1001 | { | 1146 | { |
1147 | GridRegion r = new GridRegion(region); | ||
1002 | try | 1148 | try |
1003 | { | 1149 | { |
1004 | ForEachScenePresence(delegate(ScenePresence agent) | 1150 | ForEachScenePresence(delegate(ScenePresence agent) |
@@ -1006,9 +1152,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1006 | // If agent is a root agent. | 1152 | // If agent is a root agent. |
1007 | if (!agent.IsChildAgent) | 1153 | if (!agent.IsChildAgent) |
1008 | { | 1154 | { |
1009 | //agent.ControllingClient.new | 1155 | if (m_teleportModule != null) |
1010 | //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); | 1156 | m_teleportModule.EnableChildAgent(agent, r); |
1011 | InformClientOfNeighbor(agent, region); | ||
1012 | } | 1157 | } |
1013 | } | 1158 | } |
1014 | ); | 1159 | ); |
@@ -1029,7 +1174,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1029 | { | 1174 | { |
1030 | if (m_scripts_enabled != !ScriptEngine) | 1175 | if (m_scripts_enabled != !ScriptEngine) |
1031 | { | 1176 | { |
1032 | // Tedd! Here's the method to disable the scripting engine! | ||
1033 | if (ScriptEngine) | 1177 | if (ScriptEngine) |
1034 | { | 1178 | { |
1035 | m_log.Info("Stopping all Scripts in Scene"); | 1179 | m_log.Info("Stopping all Scripts in Scene"); |
@@ -1051,6 +1195,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1051 | if (ent is SceneObjectGroup) | 1195 | if (ent is SceneObjectGroup) |
1052 | { | 1196 | { |
1053 | ((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0); | 1197 | ((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0); |
1198 | ((SceneObjectGroup)ent).ResumeScripts(); | ||
1054 | } | 1199 | } |
1055 | } | 1200 | } |
1056 | } | 1201 | } |
@@ -1067,10 +1212,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1067 | 1212 | ||
1068 | public int GetInaccurateNeighborCount() | 1213 | public int GetInaccurateNeighborCount() |
1069 | { | 1214 | { |
1070 | lock (m_neighbours) | 1215 | return m_neighbours.Count; |
1071 | { | ||
1072 | return m_neighbours.Count; | ||
1073 | } | ||
1074 | } | 1216 | } |
1075 | 1217 | ||
1076 | // This is the method that shuts down the scene. | 1218 | // This is the method that shuts down the scene. |
@@ -1150,12 +1292,89 @@ namespace OpenSim.Region.Framework.Scenes | |||
1150 | m_worldCommModule = RequestModuleInterface<IWorldComm>(); | 1292 | m_worldCommModule = RequestModuleInterface<IWorldComm>(); |
1151 | XferManager = RequestModuleInterface<IXfer>(); | 1293 | XferManager = RequestModuleInterface<IXfer>(); |
1152 | m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); | 1294 | m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); |
1295 | AttachmentsModule = RequestModuleInterface<IAttachmentsModule>(); | ||
1153 | m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); | 1296 | m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); |
1154 | m_interregionCommsOut = RequestModuleInterface<IInterregionCommsOut>(); | ||
1155 | m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>(); | ||
1156 | m_dialogModule = RequestModuleInterface<IDialogModule>(); | 1297 | m_dialogModule = RequestModuleInterface<IDialogModule>(); |
1157 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); | 1298 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); |
1158 | m_teleportModule = RequestModuleInterface<ITeleportModule>(); | 1299 | m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); |
1300 | |||
1301 | // Shoving this in here for now, because we have the needed | ||
1302 | // interfaces at this point | ||
1303 | // | ||
1304 | // TODO: Find a better place for this | ||
1305 | // | ||
1306 | while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) | ||
1307 | { | ||
1308 | MainConsole.Instance.Output("The current estate has no owner set."); | ||
1309 | string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test"); | ||
1310 | string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User"); | ||
1311 | |||
1312 | UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last); | ||
1313 | |||
1314 | if (account == null) | ||
1315 | { | ||
1316 | // Create a new account | ||
1317 | account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty); | ||
1318 | if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) | ||
1319 | { | ||
1320 | account.ServiceURLs = new Dictionary<string, object>(); | ||
1321 | account.ServiceURLs["HomeURI"] = string.Empty; | ||
1322 | account.ServiceURLs["GatekeeperURI"] = string.Empty; | ||
1323 | account.ServiceURLs["InventoryServerURI"] = string.Empty; | ||
1324 | account.ServiceURLs["AssetServerURI"] = string.Empty; | ||
1325 | } | ||
1326 | |||
1327 | if (UserAccountService.StoreUserAccount(account)) | ||
1328 | { | ||
1329 | string password = MainConsole.Instance.PasswdPrompt("Password"); | ||
1330 | string email = MainConsole.Instance.CmdPrompt("Email", ""); | ||
1331 | |||
1332 | account.Email = email; | ||
1333 | UserAccountService.StoreUserAccount(account); | ||
1334 | |||
1335 | bool success = false; | ||
1336 | success = AuthenticationService.SetPassword(account.PrincipalID, password); | ||
1337 | if (!success) | ||
1338 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", | ||
1339 | first, last); | ||
1340 | |||
1341 | GridRegion home = null; | ||
1342 | if (GridService != null) | ||
1343 | { | ||
1344 | List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero); | ||
1345 | if (defaultRegions != null && defaultRegions.Count >= 1) | ||
1346 | home = defaultRegions[0]; | ||
1347 | |||
1348 | if (GridUserService != null && home != null) | ||
1349 | GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
1350 | else | ||
1351 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", | ||
1352 | first, last); | ||
1353 | |||
1354 | } | ||
1355 | else | ||
1356 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", | ||
1357 | first, last); | ||
1358 | |||
1359 | if (InventoryService != null) | ||
1360 | success = InventoryService.CreateUserInventory(account.PrincipalID); | ||
1361 | if (!success) | ||
1362 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", | ||
1363 | first, last); | ||
1364 | |||
1365 | |||
1366 | m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last); | ||
1367 | |||
1368 | m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; | ||
1369 | m_regInfo.EstateSettings.Save(); | ||
1370 | } | ||
1371 | } | ||
1372 | else | ||
1373 | { | ||
1374 | m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; | ||
1375 | m_regInfo.EstateSettings.Save(); | ||
1376 | } | ||
1377 | } | ||
1159 | } | 1378 | } |
1160 | 1379 | ||
1161 | #endregion | 1380 | #endregion |
@@ -1539,7 +1758,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1539 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); | 1758 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); |
1540 | } | 1759 | } |
1541 | 1760 | ||
1542 | public void StoreWindlightProfile(RegionMeta7WindlightData wl) | 1761 | public void StoreWindlightProfile(RegionLightShareData wl) |
1543 | { | 1762 | { |
1544 | m_regInfo.WindlightSettings = wl; | 1763 | m_regInfo.WindlightSettings = wl; |
1545 | m_storageManager.DataStore.StoreRegionWindlightSettings(wl); | 1764 | m_storageManager.DataStore.StoreRegionWindlightSettings(wl); |
@@ -1605,7 +1824,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1605 | GridRegion region = new GridRegion(RegionInfo); | 1824 | GridRegion region = new GridRegion(RegionInfo); |
1606 | string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); | 1825 | string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); |
1607 | if (error != String.Empty) | 1826 | if (error != String.Empty) |
1827 | { | ||
1608 | throw new Exception(error); | 1828 | throw new Exception(error); |
1829 | } | ||
1609 | 1830 | ||
1610 | m_sceneGridService.SetScene(this); | 1831 | m_sceneGridService.SetScene(this); |
1611 | m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); | 1832 | m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); |
@@ -2017,7 +2238,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2017 | /// Move the given scene object into a new region depending on which region its absolute position has moved | 2238 | /// Move the given scene object into a new region depending on which region its absolute position has moved |
2018 | /// into. | 2239 | /// into. |
2019 | /// | 2240 | /// |
2020 | /// This method locates the new region handle and offsets the prim position for the new region | ||
2021 | /// </summary> | 2241 | /// </summary> |
2022 | /// <param name="attemptedPosition">the attempted out of region position of the scene object</param> | 2242 | /// <param name="attemptedPosition">the attempted out of region position of the scene object</param> |
2023 | /// <param name="grp">the scene object that we're crossing</param> | 2243 | /// <param name="grp">the scene object that we're crossing</param> |
@@ -2059,191 +2279,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2059 | return; | 2279 | return; |
2060 | } | 2280 | } |
2061 | 2281 | ||
2062 | int thisx = (int)RegionInfo.RegionLocX; | 2282 | if (m_teleportModule != null) |
2063 | int thisy = (int)RegionInfo.RegionLocY; | 2283 | m_teleportModule.Cross(grp, attemptedPosition, silent); |
2064 | Vector3 EastCross = new Vector3(0.1f,0,0); | ||
2065 | Vector3 WestCross = new Vector3(-0.1f, 0, 0); | ||
2066 | Vector3 NorthCross = new Vector3(0, 0.1f, 0); | ||
2067 | Vector3 SouthCross = new Vector3(0, -0.1f, 0); | ||
2068 | |||
2069 | |||
2070 | // use this if no borders were crossed! | ||
2071 | ulong newRegionHandle | ||
2072 | = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize), | ||
2073 | (uint)((thisy) * Constants.RegionSize)); | ||
2074 | |||
2075 | Vector3 pos = attemptedPosition; | ||
2076 | |||
2077 | int changeX = 1; | ||
2078 | int changeY = 1; | ||
2079 | |||
2080 | if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W)) | ||
2081 | { | ||
2082 | if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) | ||
2083 | { | ||
2084 | |||
2085 | Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); | ||
2086 | |||
2087 | if (crossedBorderx.BorderLine.Z > 0) | ||
2088 | { | ||
2089 | pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); | ||
2090 | changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize); | ||
2091 | } | ||
2092 | else | ||
2093 | pos.X = ((pos.X + Constants.RegionSize)); | ||
2094 | |||
2095 | Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); | ||
2096 | //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) | ||
2097 | |||
2098 | if (crossedBordery.BorderLine.Z > 0) | ||
2099 | { | ||
2100 | pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); | ||
2101 | changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); | ||
2102 | } | ||
2103 | else | ||
2104 | pos.Y = ((pos.Y + Constants.RegionSize)); | ||
2105 | |||
2106 | |||
2107 | |||
2108 | newRegionHandle | ||
2109 | = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), | ||
2110 | (uint)((thisy - changeY) * Constants.RegionSize)); | ||
2111 | // x - 1 | ||
2112 | // y - 1 | ||
2113 | } | ||
2114 | else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) | ||
2115 | { | ||
2116 | Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); | ||
2117 | |||
2118 | if (crossedBorderx.BorderLine.Z > 0) | ||
2119 | { | ||
2120 | pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); | ||
2121 | changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); | ||
2122 | } | ||
2123 | else | ||
2124 | pos.X = ((pos.X + Constants.RegionSize)); | ||
2125 | |||
2126 | |||
2127 | Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); | ||
2128 | //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) | ||
2129 | |||
2130 | try | ||
2131 | { | ||
2132 | if (crossedBordery.BorderLine.Z > 0) | ||
2133 | { | ||
2134 | pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); | ||
2135 | changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); | ||
2136 | } | ||
2137 | else | ||
2138 | pos.Y = ((pos.Y + Constants.RegionSize)); | ||
2139 | |||
2140 | newRegionHandle | ||
2141 | = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), | ||
2142 | (uint)((thisy + changeY) * Constants.RegionSize)); | ||
2143 | // x - 1 | ||
2144 | // y + 1 | ||
2145 | } | ||
2146 | catch (Exception ex) | ||
2147 | { | ||
2148 | } | ||
2149 | } | ||
2150 | else | ||
2151 | { | ||
2152 | Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); | ||
2153 | |||
2154 | if (crossedBorderx.BorderLine.Z > 0) | ||
2155 | { | ||
2156 | pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); | ||
2157 | changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); | ||
2158 | } | ||
2159 | else | ||
2160 | pos.X = ((pos.X + Constants.RegionSize)); | ||
2161 | |||
2162 | newRegionHandle | ||
2163 | = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), | ||
2164 | (uint) (thisy*Constants.RegionSize)); | ||
2165 | // x - 1 | ||
2166 | } | ||
2167 | } | ||
2168 | else if (TestBorderCross(attemptedPosition + EastCross, Cardinals.E)) | ||
2169 | { | ||
2170 | if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) | ||
2171 | { | ||
2172 | |||
2173 | pos.X = ((pos.X - Constants.RegionSize)); | ||
2174 | Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); | ||
2175 | //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) | ||
2176 | |||
2177 | if (crossedBordery.BorderLine.Z > 0) | ||
2178 | { | ||
2179 | pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); | ||
2180 | changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); | ||
2181 | } | ||
2182 | else | ||
2183 | pos.Y = ((pos.Y + Constants.RegionSize)); | ||
2184 | |||
2185 | |||
2186 | newRegionHandle | ||
2187 | = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), | ||
2188 | (uint)((thisy - changeY) * Constants.RegionSize)); | ||
2189 | // x + 1 | ||
2190 | // y - 1 | ||
2191 | } | ||
2192 | else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) | ||
2193 | { | ||
2194 | pos.X = ((pos.X - Constants.RegionSize)); | ||
2195 | pos.Y = ((pos.Y - Constants.RegionSize)); | ||
2196 | newRegionHandle | ||
2197 | = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), | ||
2198 | (uint)((thisy + changeY) * Constants.RegionSize)); | ||
2199 | // x + 1 | ||
2200 | // y + 1 | ||
2201 | } | ||
2202 | else | ||
2203 | { | ||
2204 | pos.X = ((pos.X - Constants.RegionSize)); | ||
2205 | newRegionHandle | ||
2206 | = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), | ||
2207 | (uint) (thisy*Constants.RegionSize)); | ||
2208 | // x + 1 | ||
2209 | } | ||
2210 | } | ||
2211 | else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) | ||
2212 | { | ||
2213 | Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); | ||
2214 | //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) | ||
2215 | |||
2216 | if (crossedBordery.BorderLine.Z > 0) | ||
2217 | { | ||
2218 | pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); | ||
2219 | changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); | ||
2220 | } | ||
2221 | else | ||
2222 | pos.Y = ((pos.Y + Constants.RegionSize)); | ||
2223 | |||
2224 | newRegionHandle | ||
2225 | = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize)); | ||
2226 | // y - 1 | ||
2227 | } | ||
2228 | else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) | ||
2229 | { | ||
2230 | |||
2231 | pos.Y = ((pos.Y - Constants.RegionSize)); | ||
2232 | newRegionHandle | ||
2233 | = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize)); | ||
2234 | // y + 1 | ||
2235 | } | ||
2236 | |||
2237 | // Offset the positions for the new region across the border | ||
2238 | Vector3 oldGroupPosition = grp.RootPart.GroupPosition; | ||
2239 | grp.OffsetForNewRegion(pos); | ||
2240 | |||
2241 | // If we fail to cross the border, then reset the position of the scene object on that border. | ||
2242 | if (!CrossPrimGroupIntoNewRegion(newRegionHandle, grp, silent)) | ||
2243 | { | ||
2244 | grp.OffsetForNewRegion(oldGroupPosition); | ||
2245 | grp.ScheduleGroupForFullUpdate(); | ||
2246 | } | ||
2247 | } | 2284 | } |
2248 | 2285 | ||
2249 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) | 2286 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) |
@@ -2427,75 +2464,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2427 | 2464 | ||
2428 | 2465 | ||
2429 | /// <summary> | 2466 | /// <summary> |
2430 | /// Move the given scene object into a new region | ||
2431 | /// </summary> | ||
2432 | /// <param name="newRegionHandle"></param> | ||
2433 | /// <param name="grp">Scene Object Group that we're crossing</param> | ||
2434 | /// <returns> | ||
2435 | /// true if the crossing itself was successful, false on failure | ||
2436 | /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region | ||
2437 | /// </returns> | ||
2438 | public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp, bool silent) | ||
2439 | { | ||
2440 | //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); | ||
2441 | |||
2442 | bool successYN = false; | ||
2443 | grp.RootPart.UpdateFlag = 0; | ||
2444 | //int primcrossingXMLmethod = 0; | ||
2445 | |||
2446 | if (newRegionHandle != 0) | ||
2447 | { | ||
2448 | //string objectState = grp.GetStateSnapshot(); | ||
2449 | |||
2450 | //successYN | ||
2451 | // = m_sceneGridService.PrimCrossToNeighboringRegion( | ||
2452 | // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod); | ||
2453 | //if (successYN && (objectState != "") && m_allowScriptCrossings) | ||
2454 | //{ | ||
2455 | // successYN = m_sceneGridService.PrimCrossToNeighboringRegion( | ||
2456 | // newRegionHandle, grp.UUID, objectState, 100); | ||
2457 | //} | ||
2458 | |||
2459 | // And the new channel... | ||
2460 | if (m_interregionCommsOut != null) | ||
2461 | successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); | ||
2462 | |||
2463 | if (successYN) | ||
2464 | { | ||
2465 | // We remove the object here | ||
2466 | try | ||
2467 | { | ||
2468 | DeleteSceneObject(grp, silent); | ||
2469 | } | ||
2470 | catch (Exception e) | ||
2471 | { | ||
2472 | m_log.ErrorFormat( | ||
2473 | "[INTERREGION]: Exception deleting the old object left behind on a border crossing for {0}, {1}", | ||
2474 | grp, e); | ||
2475 | } | ||
2476 | } | ||
2477 | else | ||
2478 | { | ||
2479 | if (!grp.IsDeleted) | ||
2480 | { | ||
2481 | if (grp.RootPart.PhysActor != null) | ||
2482 | { | ||
2483 | grp.RootPart.PhysActor.CrossingFailure(); | ||
2484 | } | ||
2485 | } | ||
2486 | |||
2487 | m_log.ErrorFormat("[INTERREGION]: Prim crossing failed for {0}", grp); | ||
2488 | } | ||
2489 | } | ||
2490 | else | ||
2491 | { | ||
2492 | m_log.Error("[INTERREGION]: region handle was unexpectedly 0 in Scene.CrossPrimGroupIntoNewRegion()"); | ||
2493 | } | ||
2494 | |||
2495 | return successYN; | ||
2496 | } | ||
2497 | |||
2498 | /// <summary> | ||
2499 | /// Called when objects or attachments cross the border between regions. | 2467 | /// Called when objects or attachments cross the border between regions. |
2500 | /// </summary> | 2468 | /// </summary> |
2501 | /// <param name="sog"></param> | 2469 | /// <param name="sog"></param> |
@@ -2539,10 +2507,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2539 | //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID); | 2507 | //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID); |
2540 | 2508 | ||
2541 | ScenePresence sp = GetScenePresence(userID); | 2509 | ScenePresence sp = GetScenePresence(userID); |
2542 | if (sp != null) | 2510 | if (sp != null && AttachmentsModule != null) |
2543 | { | 2511 | { |
2544 | uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); | 2512 | uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); |
2545 | m_sceneGraph.RezSingleAttachment(sp.ControllingClient, itemID, attPt); | 2513 | AttachmentsModule.RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, attPt); |
2546 | } | 2514 | } |
2547 | 2515 | ||
2548 | return false; | 2516 | return false; |
@@ -2567,6 +2535,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2567 | 2535 | ||
2568 | return false; | 2536 | return false; |
2569 | } | 2537 | } |
2538 | |||
2539 | sceneObject.SetScene(this); | ||
2540 | |||
2570 | // Force allocation of new LocalId | 2541 | // Force allocation of new LocalId |
2571 | // | 2542 | // |
2572 | foreach (SceneObjectPart p in sceneObject.Children.Values) | 2543 | foreach (SceneObjectPart p in sceneObject.Children.Values) |
@@ -2603,9 +2574,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2603 | //grp.SetFromAssetID(grp.RootPart.LastOwnerID); | 2574 | //grp.SetFromAssetID(grp.RootPart.LastOwnerID); |
2604 | m_log.DebugFormat( | 2575 | m_log.DebugFormat( |
2605 | "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); | 2576 | "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); |
2577 | |||
2578 | if (AttachmentsModule != null) | ||
2579 | AttachmentsModule.AttachObject( | ||
2580 | sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); | ||
2606 | 2581 | ||
2607 | AttachObject( | ||
2608 | sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); | ||
2609 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2582 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2610 | grp.SendGroupFullUpdate(); | 2583 | grp.SendGroupFullUpdate(); |
2611 | } | 2584 | } |
@@ -2645,6 +2618,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2645 | /// <param name="client"></param> | 2618 | /// <param name="client"></param> |
2646 | public override void AddNewClient(IClientAPI client) | 2619 | public override void AddNewClient(IClientAPI client) |
2647 | { | 2620 | { |
2621 | bool vialogin = false; | ||
2622 | |||
2648 | m_clientManager.Add(client); | 2623 | m_clientManager.Add(client); |
2649 | 2624 | ||
2650 | CheckHeartbeat(); | 2625 | CheckHeartbeat(); |
@@ -2679,23 +2654,48 @@ namespace OpenSim.Region.Framework.Scenes | |||
2679 | { | 2654 | { |
2680 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); | 2655 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); |
2681 | 2656 | ||
2682 | m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); | 2657 | // Do the verification here |
2683 | /* | 2658 | System.Net.EndPoint ep = client.GetClientEP(); |
2684 | string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}", | 2659 | if (aCircuit != null) |
2685 | ((aCircuit.child == true) ? "child" : "root"), client.Name, | 2660 | { |
2686 | RegionInfo.RegionName); | 2661 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) |
2687 | 2662 | { | |
2688 | m_log.Debug(logMsg); | 2663 | m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); |
2689 | */ | 2664 | vialogin = true; |
2665 | IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); | ||
2666 | if (userVerification != null && ep != null) | ||
2667 | { | ||
2668 | if (!userVerification.VerifyClient(aCircuit, ep.ToString())) | ||
2669 | { | ||
2670 | // uh-oh, this is fishy | ||
2671 | m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", | ||
2672 | client.AgentId, client.SessionId, ep.ToString()); | ||
2673 | try | ||
2674 | { | ||
2675 | client.Close(); | ||
2676 | } | ||
2677 | catch (Exception e) | ||
2678 | { | ||
2679 | m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace); | ||
2680 | } | ||
2681 | return; | ||
2682 | } | ||
2683 | else | ||
2684 | m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} returned true", aCircuit.firstname, aCircuit.lastname); | ||
2685 | } | ||
2686 | } | ||
2687 | } | ||
2690 | 2688 | ||
2691 | CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); | 2689 | m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); |
2692 | 2690 | ||
2693 | ScenePresence sp = CreateAndAddScenePresence(client); | 2691 | ScenePresence sp = CreateAndAddScenePresence(client); |
2692 | if (aCircuit != null) | ||
2693 | sp.Appearance = aCircuit.Appearance; | ||
2694 | 2694 | ||
2695 | // HERE!!! Do the initial attachments right here | 2695 | // HERE!!! Do the initial attachments right here |
2696 | // first agent upon login is a root agent by design. | 2696 | // first agent upon login is a root agent by design. |
2697 | // All other AddNewClient calls find aCircuit.child to be true | 2697 | // All other AddNewClient calls find aCircuit.child to be true |
2698 | if (aCircuit == null || aCircuit.child == false) | 2698 | if (aCircuit == null || (aCircuit != null && aCircuit.child == false)) |
2699 | { | 2699 | { |
2700 | sp.IsChildAgent = false; | 2700 | sp.IsChildAgent = false; |
2701 | Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); | 2701 | Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); |
@@ -2704,6 +2704,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2704 | 2704 | ||
2705 | m_LastLogin = Util.EnvironmentTickCount(); | 2705 | m_LastLogin = Util.EnvironmentTickCount(); |
2706 | EventManager.TriggerOnNewClient(client); | 2706 | EventManager.TriggerOnNewClient(client); |
2707 | if (vialogin) | ||
2708 | EventManager.TriggerOnClientLogin(client); | ||
2707 | } | 2709 | } |
2708 | 2710 | ||
2709 | 2711 | ||
@@ -2790,6 +2792,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2790 | public virtual void SubscribeToClientInventoryEvents(IClientAPI client) | 2792 | public virtual void SubscribeToClientInventoryEvents(IClientAPI client) |
2791 | { | 2793 | { |
2792 | client.OnCreateNewInventoryItem += CreateNewInventoryItem; | 2794 | client.OnCreateNewInventoryItem += CreateNewInventoryItem; |
2795 | client.OnLinkInventoryItem += HandleLinkInventoryItem; | ||
2793 | client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder; | 2796 | client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder; |
2794 | client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder; | 2797 | client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder; |
2795 | client.OnMoveInventoryFolder += HandleMoveInventoryFolder; // 2; //!! | 2798 | client.OnMoveInventoryFolder += HandleMoveInventoryFolder; // 2; //!! |
@@ -2809,19 +2812,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
2809 | } | 2812 | } |
2810 | 2813 | ||
2811 | public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) | 2814 | public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) |
2812 | { | 2815 | { |
2813 | client.OnRezSingleAttachmentFromInv += RezSingleAttachment; | 2816 | if (AttachmentsModule != null) |
2814 | client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; | 2817 | { |
2815 | client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; | 2818 | client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory; |
2816 | client.OnObjectAttach += m_sceneGraph.AttachObject; | 2819 | client.OnRezMultipleAttachmentsFromInv += AttachmentsModule.RezMultipleAttachmentsFromInventory; |
2817 | client.OnObjectDetach += m_sceneGraph.DetachObject; | 2820 | client.OnObjectAttach += AttachmentsModule.AttachObject; |
2821 | client.OnObjectDetach += AttachmentsModule.DetachObject; | ||
2822 | client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory; | ||
2823 | } | ||
2818 | } | 2824 | } |
2819 | 2825 | ||
2820 | public virtual void SubscribeToClientTeleportEvents(IClientAPI client) | 2826 | public virtual void SubscribeToClientTeleportEvents(IClientAPI client) |
2821 | { | 2827 | { |
2822 | client.OnTeleportLocationRequest += RequestTeleportLocation; | 2828 | client.OnTeleportLocationRequest += RequestTeleportLocation; |
2823 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; | 2829 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; |
2824 | client.OnTeleportHomeRequest += TeleportClientHome; | ||
2825 | } | 2830 | } |
2826 | 2831 | ||
2827 | public virtual void SubscribeToClientScriptEvents(IClientAPI client) | 2832 | public virtual void SubscribeToClientScriptEvents(IClientAPI client) |
@@ -2841,7 +2846,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2841 | 2846 | ||
2842 | public virtual void SubscribeToClientGridEvents(IClientAPI client) | 2847 | public virtual void SubscribeToClientGridEvents(IClientAPI client) |
2843 | { | 2848 | { |
2844 | client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; | 2849 | client.OnNameFromUUIDRequest += HandleUUIDNameRequest; |
2845 | client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; | 2850 | client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; |
2846 | client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; | 2851 | client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; |
2847 | client.OnSetStartLocationRequest += SetHomeRezPoint; | 2852 | client.OnSetStartLocationRequest += SetHomeRezPoint; |
@@ -2863,7 +2868,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2863 | 2868 | ||
2864 | protected virtual void UnsubscribeToClientEvents(IClientAPI client) | 2869 | protected virtual void UnsubscribeToClientEvents(IClientAPI client) |
2865 | { | 2870 | { |
2866 | |||
2867 | } | 2871 | } |
2868 | 2872 | ||
2869 | /// <summary> | 2873 | /// <summary> |
@@ -2885,7 +2889,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2885 | 2889 | ||
2886 | UnSubscribeToClientNetworkEvents(client); | 2890 | UnSubscribeToClientNetworkEvents(client); |
2887 | 2891 | ||
2888 | |||
2889 | // EventManager.TriggerOnNewClient(client); | 2892 | // EventManager.TriggerOnNewClient(client); |
2890 | } | 2893 | } |
2891 | 2894 | ||
@@ -2942,7 +2945,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2942 | client.OnRezObject -= RezObject; | 2945 | client.OnRezObject -= RezObject; |
2943 | } | 2946 | } |
2944 | 2947 | ||
2945 | |||
2946 | public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client) | 2948 | public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client) |
2947 | { | 2949 | { |
2948 | client.OnCreateNewInventoryItem -= CreateNewInventoryItem; | 2950 | client.OnCreateNewInventoryItem -= CreateNewInventoryItem; |
@@ -2965,19 +2967,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2965 | } | 2967 | } |
2966 | 2968 | ||
2967 | public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) | 2969 | public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) |
2968 | { | 2970 | { |
2969 | client.OnRezSingleAttachmentFromInv -= RezSingleAttachment; | 2971 | if (AttachmentsModule != null) |
2970 | client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments; | 2972 | { |
2971 | client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; | 2973 | client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory; |
2972 | client.OnObjectAttach -= m_sceneGraph.AttachObject; | 2974 | client.OnRezMultipleAttachmentsFromInv -= AttachmentsModule.RezMultipleAttachmentsFromInventory; |
2973 | client.OnObjectDetach -= m_sceneGraph.DetachObject; | 2975 | client.OnObjectAttach -= AttachmentsModule.AttachObject; |
2976 | client.OnObjectDetach -= AttachmentsModule.DetachObject; | ||
2977 | client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory; | ||
2978 | } | ||
2974 | } | 2979 | } |
2975 | 2980 | ||
2976 | public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) | 2981 | public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) |
2977 | { | 2982 | { |
2978 | client.OnTeleportLocationRequest -= RequestTeleportLocation; | 2983 | client.OnTeleportLocationRequest -= RequestTeleportLocation; |
2979 | client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; | 2984 | client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; |
2980 | client.OnTeleportHomeRequest -= TeleportClientHome; | 2985 | //client.OnTeleportHomeRequest -= TeleportClientHome; |
2981 | } | 2986 | } |
2982 | 2987 | ||
2983 | public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) | 2988 | public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) |
@@ -2997,7 +3002,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2997 | 3002 | ||
2998 | public virtual void UnSubscribeToClientGridEvents(IClientAPI client) | 3003 | public virtual void UnSubscribeToClientGridEvents(IClientAPI client) |
2999 | { | 3004 | { |
3000 | client.OnNameFromUUIDRequest -= CommsManager.HandleUUIDNameRequest; | 3005 | client.OnNameFromUUIDRequest -= HandleUUIDNameRequest; |
3001 | client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; | 3006 | client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; |
3002 | client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; | 3007 | client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; |
3003 | client.OnSetStartLocationRequest -= SetHomeRezPoint; | 3008 | client.OnSetStartLocationRequest -= SetHomeRezPoint; |
@@ -3024,30 +3029,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3024 | /// <param name="client">The IClientAPI for the client</param> | 3029 | /// <param name="client">The IClientAPI for the client</param> |
3025 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3030 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) |
3026 | { | 3031 | { |
3027 | UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); | 3032 | if (m_teleportModule != null) |
3028 | if (UserProfile != null) | 3033 | m_teleportModule.TeleportHome(agentId, client); |
3034 | else | ||
3029 | { | 3035 | { |
3030 | GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); | 3036 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3031 | if (regionInfo == null) | 3037 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3032 | { | ||
3033 | uint x = 0, y = 0; | ||
3034 | Utils.LongToUInts(UserProfile.HomeRegion, out x, out y); | ||
3035 | regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
3036 | if (regionInfo != null) // home region can be away temporarily, too | ||
3037 | { | ||
3038 | UserProfile.HomeRegionID = regionInfo.RegionID; | ||
3039 | CommsManager.UserService.UpdateUserProfile(UserProfile); | ||
3040 | } | ||
3041 | } | ||
3042 | if (regionInfo == null) | ||
3043 | { | ||
3044 | // can't find the Home region: Tell viewer and abort | ||
3045 | client.SendTeleportFailed("Your home-region could not be found."); | ||
3046 | return; | ||
3047 | } | ||
3048 | RequestTeleportLocation( | ||
3049 | client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt, | ||
3050 | (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome)); | ||
3051 | } | 3038 | } |
3052 | } | 3039 | } |
3053 | 3040 | ||
@@ -3138,7 +3125,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3138 | } | 3125 | } |
3139 | 3126 | ||
3140 | /// <summary> | 3127 | /// <summary> |
3141 | /// Sets the Home Point. The GridService uses this to know where to put a user when they log-in | 3128 | /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in |
3142 | /// </summary> | 3129 | /// </summary> |
3143 | /// <param name="remoteClient"></param> | 3130 | /// <param name="remoteClient"></param> |
3144 | /// <param name="regionHandle"></param> | 3131 | /// <param name="regionHandle"></param> |
@@ -3147,27 +3134,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3147 | /// <param name="flags"></param> | 3134 | /// <param name="flags"></param> |
3148 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3135 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3149 | { | 3136 | { |
3150 | UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); | 3137 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3151 | if (UserProfile != null) | ||
3152 | { | ||
3153 | // I know I'm ignoring the regionHandle provided by the teleport location request. | ||
3154 | // reusing the TeleportLocationRequest delegate, so regionHandle isn't valid | ||
3155 | UserProfile.HomeRegionID = RegionInfo.RegionID; | ||
3156 | // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around. | ||
3157 | // TODO: The HomeRegion property can be removed then, too | ||
3158 | UserProfile.HomeRegion = RegionInfo.RegionHandle; | ||
3159 | |||
3160 | UserProfile.HomeLocation = position; | ||
3161 | UserProfile.HomeLookAt = lookAt; | ||
3162 | CommsManager.UserService.UpdateUserProfile(UserProfile); | ||
3163 | |||
3164 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3138 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3165 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3139 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
3166 | } | ||
3167 | else | 3140 | else |
3168 | { | ||
3169 | m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); | 3141 | m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); |
3170 | } | ||
3171 | } | 3142 | } |
3172 | 3143 | ||
3173 | /// <summary> | 3144 | /// <summary> |
@@ -3240,14 +3211,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3240 | m_sceneGraph.removeUserCount(!childagentYN); | 3211 | m_sceneGraph.removeUserCount(!childagentYN); |
3241 | CapsModule.RemoveCapsHandler(agentID); | 3212 | CapsModule.RemoveCapsHandler(agentID); |
3242 | 3213 | ||
3243 | if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) | 3214 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever |
3244 | { | 3215 | // this method is doing is HORRIBLE!!! |
3245 | CommsManager.UserProfileCacheService.RemoveUser(agentID); | 3216 | avatar.Scene.NeedSceneCacheClear(avatar.UUID); |
3246 | } | ||
3247 | 3217 | ||
3248 | if (!avatar.IsChildAgent) | 3218 | if (!avatar.IsChildAgent) |
3249 | { | 3219 | { |
3250 | m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat); | ||
3251 | //List<ulong> childknownRegions = new List<ulong>(); | 3220 | //List<ulong> childknownRegions = new List<ulong>(); |
3252 | //List<ulong> ckn = avatar.KnownChildRegionHandles; | 3221 | //List<ulong> ckn = avatar.KnownChildRegionHandles; |
3253 | //for (int i = 0; i < ckn.Count; i++) | 3222 | //for (int i = 0; i < ckn.Count; i++) |
@@ -3302,12 +3271,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3302 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3271 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3303 | } | 3272 | } |
3304 | 3273 | ||
3305 | // Remove client agent from profile, so new logins will work | ||
3306 | if (!childagentYN) | ||
3307 | { | ||
3308 | m_sceneGridService.ClearUserAgent(agentID); | ||
3309 | } | ||
3310 | |||
3311 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3274 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3312 | 3275 | ||
3313 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3276 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
@@ -3380,14 +3343,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3380 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3343 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3381 | m_sceneGridService.KiPrimitive += SendKillObject; | 3344 | m_sceneGridService.KiPrimitive += SendKillObject; |
3382 | m_sceneGridService.OnGetLandData += GetLandData; | 3345 | m_sceneGridService.OnGetLandData += GetLandData; |
3383 | |||
3384 | if (m_interregionCommsIn != null) | ||
3385 | { | ||
3386 | m_log.Debug("[SCENE]: Registering with InterregionCommsIn"); | ||
3387 | m_interregionCommsIn.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | ||
3388 | } | ||
3389 | else | ||
3390 | m_log.Debug("[SCENE]: Unable to register with InterregionCommsIn"); | ||
3391 | } | 3346 | } |
3392 | 3347 | ||
3393 | /// <summary> | 3348 | /// <summary> |
@@ -3405,9 +3360,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3405 | m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; | 3360 | m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; |
3406 | m_sceneGridService.OnGetLandData -= GetLandData; | 3361 | m_sceneGridService.OnGetLandData -= GetLandData; |
3407 | 3362 | ||
3408 | if (m_interregionCommsIn != null) | ||
3409 | m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | ||
3410 | |||
3411 | // this does nothing; should be removed | 3363 | // this does nothing; should be removed |
3412 | m_sceneGridService.Close(); | 3364 | m_sceneGridService.Close(); |
3413 | 3365 | ||
@@ -3444,6 +3396,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3444 | /// also return a reason.</returns> | 3396 | /// also return a reason.</returns> |
3445 | public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) | 3397 | public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) |
3446 | { | 3398 | { |
3399 | TeleportFlags tp = (TeleportFlags)teleportFlags; | ||
3447 | //Teleport flags: | 3400 | //Teleport flags: |
3448 | // | 3401 | // |
3449 | // TeleportFlags.ViaGodlikeLure - Border Crossing | 3402 | // TeleportFlags.ViaGodlikeLure - Border Crossing |
@@ -3464,7 +3417,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3464 | agent.AgentID, agent.circuitcode, teleportFlags); | 3417 | agent.AgentID, agent.circuitcode, teleportFlags); |
3465 | 3418 | ||
3466 | reason = String.Empty; | 3419 | reason = String.Empty; |
3467 | if (!AuthenticateUser(agent, out reason)) | 3420 | if (!VerifyUserPresence(agent, out reason)) |
3468 | return false; | 3421 | return false; |
3469 | 3422 | ||
3470 | if (!AuthorizeUser(agent, out reason)) | 3423 | if (!AuthorizeUser(agent, out reason)) |
@@ -3477,7 +3430,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3477 | 3430 | ||
3478 | CapsModule.NewUserConnection(agent); | 3431 | CapsModule.NewUserConnection(agent); |
3479 | 3432 | ||
3480 | ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); | 3433 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); |
3434 | |||
3435 | //On login or border crossing test land permisions | ||
3436 | if (tp != TeleportFlags.Default) | ||
3437 | { | ||
3438 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | ||
3439 | { | ||
3440 | return false; | ||
3441 | } | ||
3442 | } | ||
3443 | |||
3444 | ScenePresence sp = GetScenePresence(agent.AgentID); | ||
3481 | if (sp != null) | 3445 | if (sp != null) |
3482 | { | 3446 | { |
3483 | m_log.DebugFormat( | 3447 | m_log.DebugFormat( |
@@ -3564,40 +3528,73 @@ namespace OpenSim.Region.Framework.Scenes | |||
3564 | */// This is now handled properly in ScenePresence.MakeRootAgent | 3528 | */// This is now handled properly in ScenePresence.MakeRootAgent |
3565 | } | 3529 | } |
3566 | 3530 | ||
3531 | agent.teleportFlags = teleportFlags; | ||
3567 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | 3532 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); |
3568 | 3533 | ||
3569 | // rewrite session_id | 3534 | return true; |
3570 | CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID); | 3535 | } |
3571 | if (userinfo != null) | 3536 | |
3572 | { | 3537 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) |
3573 | userinfo.SessionID = agent.SessionID; | 3538 | { |
3574 | } | 3539 | |
3575 | else | 3540 | bool banned = land.IsBannedFromLand(agent.AgentID); |
3541 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | ||
3542 | |||
3543 | if (banned || restricted) | ||
3576 | { | 3544 | { |
3577 | m_log.WarnFormat( | 3545 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); |
3578 | "[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); | 3546 | if (nearestParcel != null) |
3547 | { | ||
3548 | //Move agent to nearest allowed | ||
3549 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | ||
3550 | agent.startpos.X = newPosition.X; | ||
3551 | agent.startpos.Y = newPosition.Y; | ||
3552 | } | ||
3553 | else | ||
3554 | { | ||
3555 | if (banned) | ||
3556 | { | ||
3557 | reason = "Cannot regioncross into banned parcel."; | ||
3558 | } | ||
3559 | else | ||
3560 | { | ||
3561 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | ||
3562 | RegionInfo.RegionName); | ||
3563 | } | ||
3564 | return false; | ||
3565 | } | ||
3579 | } | 3566 | } |
3580 | 3567 | reason = ""; | |
3581 | return true; | 3568 | return true; |
3582 | } | 3569 | } |
3583 | 3570 | ||
3584 | /// <summary> | 3571 | /// <summary> |
3585 | /// Verifies that the user has a session on the Grid | 3572 | /// Verifies that the user has a presence on the Grid |
3586 | /// </summary> | 3573 | /// </summary> |
3587 | /// <param name="agent">Circuit Data of the Agent we're verifying</param> | 3574 | /// <param name="agent">Circuit Data of the Agent we're verifying</param> |
3588 | /// <param name="reason">Outputs the reason for the false response on this string</param> | 3575 | /// <param name="reason">Outputs the reason for the false response on this string</param> |
3589 | /// <returns>True if the user has a session on the grid. False if it does not. False will | 3576 | /// <returns>True if the user has a session on the grid. False if it does not. False will |
3590 | /// also return a reason.</returns> | 3577 | /// also return a reason.</returns> |
3591 | public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason) | 3578 | public virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason) |
3592 | { | 3579 | { |
3593 | reason = String.Empty; | 3580 | reason = String.Empty; |
3594 | 3581 | ||
3595 | bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); | 3582 | IPresenceService presence = RequestModuleInterface<IPresenceService>(); |
3596 | m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); | 3583 | if (presence == null) |
3597 | if (!result) | 3584 | { |
3598 | reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); | 3585 | reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName); |
3586 | return false; | ||
3587 | } | ||
3588 | |||
3589 | OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID); | ||
3590 | |||
3591 | if (pinfo == null) | ||
3592 | { | ||
3593 | reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3594 | return false; | ||
3595 | } | ||
3599 | 3596 | ||
3600 | return result; | 3597 | return true; |
3601 | } | 3598 | } |
3602 | 3599 | ||
3603 | /// <summary> | 3600 | /// <summary> |
@@ -3702,6 +3699,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3702 | return true; | 3699 | return true; |
3703 | } | 3700 | } |
3704 | 3701 | ||
3702 | private ILandObject GetParcelAtPoint(float x, float y) | ||
3703 | { | ||
3704 | foreach (var parcel in AllParcels()) | ||
3705 | { | ||
3706 | if (parcel.ContainsPoint((int)x,(int)y)) | ||
3707 | { | ||
3708 | return parcel; | ||
3709 | } | ||
3710 | } | ||
3711 | return null; | ||
3712 | } | ||
3713 | |||
3705 | /// <summary> | 3714 | /// <summary> |
3706 | /// Update an AgentCircuitData object with new information | 3715 | /// Update an AgentCircuitData object with new information |
3707 | /// </summary> | 3716 | /// </summary> |
@@ -3730,8 +3739,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3730 | /// <param name="message">message to display to the user. Reason for being logged off</param> | 3739 | /// <param name="message">message to display to the user. Reason for being logged off</param> |
3731 | public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) | 3740 | public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) |
3732 | { | 3741 | { |
3733 | ScenePresence loggingOffUser = null; | 3742 | ScenePresence loggingOffUser = GetScenePresence(AvatarID); |
3734 | loggingOffUser = GetScenePresence(AvatarID); | ||
3735 | if (loggingOffUser != null) | 3743 | if (loggingOffUser != null) |
3736 | { | 3744 | { |
3737 | UUID localRegionSecret = UUID.Zero; | 3745 | UUID localRegionSecret = UUID.Zero; |
@@ -3767,10 +3775,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3767 | /// <param name="isFlying"></param> | 3775 | /// <param name="isFlying"></param> |
3768 | public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) | 3776 | public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) |
3769 | { | 3777 | { |
3770 | ScenePresence presence; | 3778 | ScenePresence presence = GetScenePresence(agentID); |
3771 | m_sceneGraph.TryGetAvatar(agentID, out presence); | 3779 | if(presence != null) |
3772 | |||
3773 | if (presence != null) | ||
3774 | { | 3780 | { |
3775 | try | 3781 | try |
3776 | { | 3782 | { |
@@ -3798,8 +3804,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3798 | /// <returns>true if we handled it.</returns> | 3804 | /// <returns>true if we handled it.</returns> |
3799 | public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) | 3805 | public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) |
3800 | { | 3806 | { |
3801 | // m_log.DebugFormat( | 3807 | m_log.DebugFormat( |
3802 | // "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); | 3808 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); |
3803 | 3809 | ||
3804 | // We have to wait until the viewer contacts this region after receiving EAC. | 3810 | // We have to wait until the viewer contacts this region after receiving EAC. |
3805 | // That calls AddNewClient, which finally creates the ScenePresence | 3811 | // That calls AddNewClient, which finally creates the ScenePresence |
@@ -3868,16 +3874,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3868 | return false; | 3874 | return false; |
3869 | } | 3875 | } |
3870 | 3876 | ||
3871 | public virtual bool IncomingReleaseAgent(UUID id) | ||
3872 | { | ||
3873 | return m_sceneGridService.ReleaseAgent(id); | ||
3874 | } | ||
3875 | |||
3876 | public void SendReleaseAgent(ulong regionHandle, UUID id, string uri) | ||
3877 | { | ||
3878 | m_interregionCommsOut.SendReleaseAgent(regionHandle, id, uri); | ||
3879 | } | ||
3880 | |||
3881 | /// <summary> | 3877 | /// <summary> |
3882 | /// Tell a single agent to disconnect from the region. | 3878 | /// Tell a single agent to disconnect from the region. |
3883 | /// </summary> | 3879 | /// </summary> |
@@ -3922,30 +3918,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3922 | } | 3918 | } |
3923 | 3919 | ||
3924 | /// <summary> | 3920 | /// <summary> |
3925 | /// Tell neighboring regions about this agent | ||
3926 | /// When the regions respond with a true value, | ||
3927 | /// tell the agents about the region. | ||
3928 | /// | ||
3929 | /// We have to tell the regions about the agents first otherwise it'll deny them access | ||
3930 | /// | ||
3931 | /// </summary> | ||
3932 | /// <param name="presence"></param> | ||
3933 | public void InformClientOfNeighbours(ScenePresence presence) | ||
3934 | { | ||
3935 | m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours); | ||
3936 | } | ||
3937 | |||
3938 | /// <summary> | ||
3939 | /// Tell a neighboring region about this agent | ||
3940 | /// </summary> | ||
3941 | /// <param name="presence"></param> | ||
3942 | /// <param name="region"></param> | ||
3943 | public void InformClientOfNeighbor(ScenePresence presence, RegionInfo region) | ||
3944 | { | ||
3945 | m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours); | ||
3946 | } | ||
3947 | |||
3948 | /// <summary> | ||
3949 | /// Tries to teleport agent to other region. | 3921 | /// Tries to teleport agent to other region. |
3950 | /// </summary> | 3922 | /// </summary> |
3951 | /// <param name="remoteClient"></param> | 3923 | /// <param name="remoteClient"></param> |
@@ -3978,9 +3950,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3978 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, | 3950 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, |
3979 | Vector3 lookAt, uint teleportFlags) | 3951 | Vector3 lookAt, uint teleportFlags) |
3980 | { | 3952 | { |
3981 | ScenePresence sp; | 3953 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); |
3982 | m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp); | ||
3983 | |||
3984 | if (sp != null) | 3954 | if (sp != null) |
3985 | { | 3955 | { |
3986 | uint regionX = m_regInfo.RegionLocX; | 3956 | uint regionX = m_regInfo.RegionLocX; |
@@ -4020,16 +3990,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4020 | } | 3990 | } |
4021 | 3991 | ||
4022 | if (m_teleportModule != null) | 3992 | if (m_teleportModule != null) |
4023 | { | 3993 | m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); |
4024 | m_teleportModule.RequestTeleportToLocation(sp, regionHandle, | ||
4025 | position, lookAt, teleportFlags); | ||
4026 | } | ||
4027 | else | 3994 | else |
4028 | { | 3995 | { |
4029 | m_sceneGridService.RequestTeleportToLocation(sp, regionHandle, | 3996 | m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); |
4030 | position, lookAt, teleportFlags); | 3997 | sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator."); |
4031 | } | 3998 | } |
4032 | |||
4033 | } | 3999 | } |
4034 | } | 4000 | } |
4035 | 4001 | ||
@@ -4055,7 +4021,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4055 | 4021 | ||
4056 | public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) | 4022 | public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) |
4057 | { | 4023 | { |
4058 | m_sceneGridService.CrossAgentToNewRegion(this, agent, isFlying); | 4024 | if (m_teleportModule != null) |
4025 | m_teleportModule.Cross(agent, isFlying); | ||
4026 | else | ||
4027 | { | ||
4028 | m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); | ||
4029 | } | ||
4059 | } | 4030 | } |
4060 | 4031 | ||
4061 | public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) | 4032 | public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) |
@@ -4081,35 +4052,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4081 | objectCapacity = objects; | 4052 | objectCapacity = objects; |
4082 | } | 4053 | } |
4083 | 4054 | ||
4084 | public List<FriendListItem> GetFriendList(string id) | ||
4085 | { | ||
4086 | UUID avatarID; | ||
4087 | if (!UUID.TryParse(id, out avatarID)) | ||
4088 | return new List<FriendListItem>(); | ||
4089 | |||
4090 | return CommsManager.GetUserFriendList(avatarID); | ||
4091 | } | ||
4092 | |||
4093 | public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) | ||
4094 | { | ||
4095 | return CommsManager.GetFriendRegionInfos(uuids); | ||
4096 | } | ||
4097 | |||
4098 | public virtual void StoreAddFriendship(UUID ownerID, UUID friendID, uint perms) | ||
4099 | { | ||
4100 | m_sceneGridService.AddNewUserFriend(ownerID, friendID, perms); | ||
4101 | } | ||
4102 | |||
4103 | public virtual void StoreUpdateFriendship(UUID ownerID, UUID friendID, uint perms) | ||
4104 | { | ||
4105 | m_sceneGridService.UpdateUserFriendPerms(ownerID, friendID, perms); | ||
4106 | } | ||
4107 | |||
4108 | public virtual void StoreRemoveFriendship(UUID ownerID, UUID ExfriendID) | ||
4109 | { | ||
4110 | m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID); | ||
4111 | } | ||
4112 | |||
4113 | #endregion | 4055 | #endregion |
4114 | 4056 | ||
4115 | public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) | 4057 | public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) |
@@ -4187,17 +4129,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
4187 | m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", | 4129 | m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", |
4188 | "Agent ID", "Session ID", "Circuit", "IP", "World"); | 4130 | "Agent ID", "Session ID", "Circuit", "IP", "World"); |
4189 | 4131 | ||
4190 | foreach (ScenePresence scenePresence in GetAvatars()) | 4132 | ForEachScenePresence(delegate(ScenePresence sp) |
4191 | { | 4133 | { |
4192 | m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", | 4134 | m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", |
4193 | scenePresence.Firstname, | 4135 | sp.Firstname, |
4194 | scenePresence.Lastname, | 4136 | sp.Lastname, |
4195 | scenePresence.UUID, | 4137 | sp.UUID, |
4196 | scenePresence.ControllingClient.AgentId, | 4138 | sp.ControllingClient.AgentId, |
4197 | "Unknown", | 4139 | "Unknown", |
4198 | "Unknown", | 4140 | "Unknown", |
4199 | RegionInfo.RegionName); | 4141 | RegionInfo.RegionName); |
4200 | } | 4142 | }); |
4201 | 4143 | ||
4202 | break; | 4144 | break; |
4203 | } | 4145 | } |
@@ -4363,56 +4305,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
4363 | m_sceneGraph.RemovePhysicalPrim(num); | 4305 | m_sceneGraph.RemovePhysicalPrim(num); |
4364 | } | 4306 | } |
4365 | 4307 | ||
4366 | //The idea is to have a group of method that return a list of avatars meeting some requirement | 4308 | public int GetRootAgentCount() |
4367 | // ie it could be all m_scenePresences within a certain range of the calling prim/avatar. | ||
4368 | |||
4369 | /// <summary> | ||
4370 | /// Return a list of all avatars in this region. | ||
4371 | /// This list is a new object, so it can be iterated over without locking. | ||
4372 | /// </summary> | ||
4373 | /// <returns></returns> | ||
4374 | public List<ScenePresence> GetAvatars() | ||
4375 | { | 4309 | { |
4376 | return m_sceneGraph.GetAvatars(); | 4310 | return m_sceneGraph.GetRootAgentCount(); |
4377 | } | 4311 | } |
4378 | 4312 | ||
4379 | /// <summary> | 4313 | public int GetChildAgentCount() |
4380 | /// Cheaply return the number of avatars in a region (without fetching a list object) | ||
4381 | /// </summary> | ||
4382 | public int GetRootAgentCount() | ||
4383 | { | 4314 | { |
4384 | return m_sceneGraph.GetRootAgentCount(); | 4315 | return m_sceneGraph.GetChildAgentCount(); |
4385 | } | 4316 | } |
4386 | 4317 | ||
4387 | /// <summary> | 4318 | /// <summary> |
4388 | /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. | 4319 | /// Request a scene presence by UUID. Fast, indexed lookup. |
4389 | /// This list is a new object, so it can be iterated over without locking. | ||
4390 | /// </summary> | 4320 | /// </summary> |
4391 | /// <returns></returns> | 4321 | /// <param name="agentID"></param> |
4392 | public ScenePresence[] GetScenePresences() | 4322 | /// <returns>null if the presence was not found</returns> |
4323 | public ScenePresence GetScenePresence(UUID agentID) | ||
4393 | { | 4324 | { |
4394 | return m_sceneGraph.GetScenePresences(); | 4325 | return m_sceneGraph.GetScenePresence(agentID); |
4395 | } | 4326 | } |
4396 | 4327 | ||
4397 | /// <summary> | 4328 | /// <summary> |
4398 | /// Request a filtered list of ScenePresences in this region. | 4329 | /// Request the scene presence by name. |
4399 | /// This list is a new object, so it can be iterated over without locking. | ||
4400 | /// </summary> | 4330 | /// </summary> |
4401 | /// <param name="filter"></param> | 4331 | /// <param name="firstName"></param> |
4402 | /// <returns></returns> | 4332 | /// <param name="lastName"></param> |
4403 | public List<ScenePresence> GetScenePresences(FilterAvatarList filter) | 4333 | /// <returns>null if the presence was not found</returns> |
4334 | public ScenePresence GetScenePresence(string firstName, string lastName) | ||
4404 | { | 4335 | { |
4405 | return m_sceneGraph.GetScenePresences(filter); | 4336 | return m_sceneGraph.GetScenePresence(firstName, lastName); |
4406 | } | 4337 | } |
4407 | 4338 | ||
4408 | /// <summary> | 4339 | /// <summary> |
4409 | /// Request a scene presence by UUID | 4340 | /// Request the scene presence by localID. |
4410 | /// </summary> | 4341 | /// </summary> |
4411 | /// <param name="avatarID"></param> | 4342 | /// <param name="localID"></param> |
4412 | /// <returns></returns> | 4343 | /// <returns>null if the presence was not found</returns> |
4413 | public ScenePresence GetScenePresence(UUID avatarID) | 4344 | public ScenePresence GetScenePresence(uint localID) |
4414 | { | 4345 | { |
4415 | return m_sceneGraph.GetScenePresence(avatarID); | 4346 | return m_sceneGraph.GetScenePresence(localID); |
4416 | } | 4347 | } |
4417 | 4348 | ||
4418 | public override bool PresenceChildStatus(UUID avatarID) | 4349 | public override bool PresenceChildStatus(UUID avatarID) |
@@ -4430,25 +4361,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4430 | } | 4361 | } |
4431 | 4362 | ||
4432 | /// <summary> | 4363 | /// <summary> |
4433 | /// | 4364 | /// Performs action on all scene presences. |
4434 | /// </summary> | 4365 | /// </summary> |
4435 | /// <param name="action"></param> | 4366 | /// <param name="action"></param> |
4436 | public void ForEachScenePresence(Action<ScenePresence> action) | 4367 | public void ForEachScenePresence(Action<ScenePresence> action) |
4437 | { | 4368 | { |
4438 | // We don't want to try to send messages if there are no avatars. | ||
4439 | if (m_sceneGraph != null) | 4369 | if (m_sceneGraph != null) |
4440 | { | 4370 | { |
4441 | try | 4371 | m_sceneGraph.ForEachScenePresence(action); |
4442 | { | ||
4443 | ScenePresence[] presences = GetScenePresences(); | ||
4444 | for (int i = 0; i < presences.Length; i++) | ||
4445 | action(presences[i]); | ||
4446 | } | ||
4447 | catch (Exception e) | ||
4448 | { | ||
4449 | m_log.Info("[BUG] in " + RegionInfo.RegionName + ": " + e.ToString()); | ||
4450 | m_log.Info("[BUG] Stack Trace: " + e.StackTrace); | ||
4451 | } | ||
4452 | } | 4372 | } |
4453 | } | 4373 | } |
4454 | 4374 | ||
@@ -4512,9 +4432,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4512 | return m_sceneGraph.GetGroupByPrim(localID); | 4432 | return m_sceneGraph.GetGroupByPrim(localID); |
4513 | } | 4433 | } |
4514 | 4434 | ||
4515 | public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) | 4435 | public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) |
4516 | { | 4436 | { |
4517 | return m_sceneGraph.TryGetAvatar(avatarId, out avatar); | 4437 | return m_sceneGraph.TryGetScenePresence(avatarId, out avatar); |
4518 | } | 4438 | } |
4519 | 4439 | ||
4520 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 4440 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
@@ -4524,20 +4444,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4524 | 4444 | ||
4525 | public void ForEachClient(Action<IClientAPI> action) | 4445 | public void ForEachClient(Action<IClientAPI> action) |
4526 | { | 4446 | { |
4527 | ForEachClient(action, m_useAsyncWhenPossible); | ||
4528 | } | ||
4529 | |||
4530 | public void ForEachClient(Action<IClientAPI> action, bool doAsynchronous) | ||
4531 | { | ||
4532 | // FIXME: Asynchronous iteration is disabled until we have a threading model that | ||
4533 | // can support calling this function from an async packet handler without | ||
4534 | // potentially deadlocking | ||
4535 | m_clientManager.ForEachSync(action); | 4447 | m_clientManager.ForEachSync(action); |
4536 | |||
4537 | //if (doAsynchronous) | ||
4538 | // m_clientManager.ForEach(action); | ||
4539 | //else | ||
4540 | // m_clientManager.ForEachSync(action); | ||
4541 | } | 4448 | } |
4542 | 4449 | ||
4543 | public bool TryGetClient(UUID avatarID, out IClientAPI client) | 4450 | public bool TryGetClient(UUID avatarID, out IClientAPI client) |
@@ -4664,6 +4571,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4664 | foreach (SceneObjectPart child in partList) | 4571 | foreach (SceneObjectPart child in partList) |
4665 | { | 4572 | { |
4666 | child.Inventory.ChangeInventoryOwner(remoteClient.AgentId); | 4573 | child.Inventory.ChangeInventoryOwner(remoteClient.AgentId); |
4574 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
4667 | child.ApplyNextOwnerPermissions(); | 4575 | child.ApplyNextOwnerPermissions(); |
4668 | } | 4576 | } |
4669 | } | 4577 | } |
@@ -4673,6 +4581,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4673 | 4581 | ||
4674 | group.HasGroupChanged = true; | 4582 | group.HasGroupChanged = true; |
4675 | part.GetProperties(remoteClient); | 4583 | part.GetProperties(remoteClient); |
4584 | part.TriggerScriptChangedEvent(Changed.OWNER); | ||
4585 | group.ResumeScripts(); | ||
4676 | part.ScheduleFullUpdate(); | 4586 | part.ScheduleFullUpdate(); |
4677 | 4587 | ||
4678 | break; | 4588 | break; |
@@ -4709,7 +4619,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4709 | group.GetPartName(localID), | 4619 | group.GetPartName(localID), |
4710 | group.GetPartDescription(localID), | 4620 | group.GetPartDescription(localID), |
4711 | (sbyte)AssetType.Object, | 4621 | (sbyte)AssetType.Object, |
4712 | Utils.StringToBytes(sceneObjectXml)); | 4622 | Utils.StringToBytes(sceneObjectXml), |
4623 | group.OwnerID); | ||
4713 | AssetService.Store(asset); | 4624 | AssetService.Store(asset); |
4714 | 4625 | ||
4715 | InventoryItemBase item = new InventoryItemBase(); | 4626 | InventoryItemBase item = new InventoryItemBase(); |
@@ -5033,5 +4944,241 @@ namespace OpenSim.Region.Framework.Scenes | |||
5033 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4944 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) |
5034 | StartTimer(); | 4945 | StartTimer(); |
5035 | } | 4946 | } |
4947 | |||
4948 | public override ISceneObject DeserializeObject(string representation) | ||
4949 | { | ||
4950 | return SceneObjectSerializer.FromXml2Format(representation); | ||
4951 | } | ||
4952 | |||
4953 | public override bool AllowScriptCrossings | ||
4954 | { | ||
4955 | get { return m_allowScriptCrossings; } | ||
4956 | } | ||
4957 | |||
4958 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | ||
4959 | { | ||
4960 | //simulate to make sure we have pretty up to date positions | ||
4961 | PhysicsScene.Simulate(0); | ||
4962 | |||
4963 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | ||
4964 | |||
4965 | if (nearestParcel != null) | ||
4966 | { | ||
4967 | Vector3 dir = Vector3.Normalize(Vector3.Multiply(avatar.Velocity, -1)); | ||
4968 | //Try to get a location that feels like where they came from | ||
4969 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | ||
4970 | if (nearestPoint != null) | ||
4971 | { | ||
4972 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); | ||
4973 | return nearestPoint.Value; | ||
4974 | } | ||
4975 | |||
4976 | //Sometimes velocity might be zero (local teleport), so try finding point along path from avatar to center of nearest parcel | ||
4977 | Vector3 directionToParcelCenter = Vector3.Subtract(GetParcelCenterAtGround(nearestParcel), avatar.AbsolutePosition); | ||
4978 | dir = Vector3.Normalize(directionToParcelCenter); | ||
4979 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | ||
4980 | if (nearestPoint != null) | ||
4981 | { | ||
4982 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); | ||
4983 | return nearestPoint.Value; | ||
4984 | } | ||
4985 | |||
4986 | //Ultimate backup if we have no idea where they are | ||
4987 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
4988 | return avatar.lastKnownAllowedPosition; | ||
4989 | |||
4990 | } | ||
4991 | |||
4992 | //Go to the edge, this happens in teleporting to a region with no available parcels | ||
4993 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); | ||
4994 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); | ||
4995 | return nearestRegionEdgePoint; | ||
4996 | return null; | ||
4997 | } | ||
4998 | |||
4999 | private Vector3 GetParcelCenterAtGround(ILandObject parcel) | ||
5000 | { | ||
5001 | Vector2 center = GetParcelCenter(parcel); | ||
5002 | return GetPositionAtGround(center.X, center.Y); | ||
5003 | } | ||
5004 | |||
5005 | private Vector3? GetNearestPointInParcelAlongDirectionFromPoint(Vector3 pos, Vector3 direction, ILandObject parcel) | ||
5006 | { | ||
5007 | Vector3 unitDirection = Vector3.Normalize(direction); | ||
5008 | //Making distance to search go through some sane limit of distance | ||
5009 | for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f) | ||
5010 | { | ||
5011 | Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance)); | ||
5012 | if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y)) | ||
5013 | { | ||
5014 | return testPos; | ||
5015 | } | ||
5016 | } | ||
5017 | return null; | ||
5018 | } | ||
5019 | |||
5020 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | ||
5021 | { | ||
5022 | List<ILandObject> all = AllParcels(); | ||
5023 | float minParcelDistance = float.MaxValue; | ||
5024 | ILandObject nearestParcel = null; | ||
5025 | |||
5026 | foreach (var parcel in all) | ||
5027 | { | ||
5028 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | ||
5029 | { | ||
5030 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | ||
5031 | if (parcelDistance < minParcelDistance) | ||
5032 | { | ||
5033 | minParcelDistance = parcelDistance; | ||
5034 | nearestParcel = parcel; | ||
5035 | } | ||
5036 | } | ||
5037 | } | ||
5038 | |||
5039 | return nearestParcel; | ||
5040 | } | ||
5041 | |||
5042 | private List<ILandObject> AllParcels() | ||
5043 | { | ||
5044 | return LandChannel.AllParcels(); | ||
5045 | } | ||
5046 | |||
5047 | private float GetParcelDistancefromPoint(ILandObject parcel, float x, float y) | ||
5048 | { | ||
5049 | return Vector2.Distance(new Vector2(x, y), GetParcelCenter(parcel)); | ||
5050 | } | ||
5051 | |||
5052 | //calculate the average center point of a parcel | ||
5053 | private Vector2 GetParcelCenter(ILandObject parcel) | ||
5054 | { | ||
5055 | int count = 0; | ||
5056 | int avgx = 0; | ||
5057 | int avgy = 0; | ||
5058 | for (int x = 0; x < Constants.RegionSize; x++) | ||
5059 | { | ||
5060 | for (int y = 0; y < Constants.RegionSize; y++) | ||
5061 | { | ||
5062 | //Just keep a running average as we check if all the points are inside or not | ||
5063 | if (parcel.ContainsPoint(x, y)) | ||
5064 | { | ||
5065 | if (count == 0) | ||
5066 | { | ||
5067 | avgx = x; | ||
5068 | avgy = y; | ||
5069 | } | ||
5070 | else | ||
5071 | { | ||
5072 | avgx = (avgx * count + x) / (count + 1); | ||
5073 | avgy = (avgy * count + y) / (count + 1); | ||
5074 | } | ||
5075 | count += 1; | ||
5076 | } | ||
5077 | } | ||
5078 | } | ||
5079 | return new Vector2(avgx, avgy); | ||
5080 | } | ||
5081 | |||
5082 | private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar) | ||
5083 | { | ||
5084 | float xdistance = avatar.AbsolutePosition.X < Constants.RegionSize / 2 ? avatar.AbsolutePosition.X : Constants.RegionSize - avatar.AbsolutePosition.X; | ||
5085 | float ydistance = avatar.AbsolutePosition.Y < Constants.RegionSize / 2 ? avatar.AbsolutePosition.Y : Constants.RegionSize - avatar.AbsolutePosition.Y; | ||
5086 | |||
5087 | //find out what vertical edge to go to | ||
5088 | if (xdistance < ydistance) | ||
5089 | { | ||
5090 | if (avatar.AbsolutePosition.X < Constants.RegionSize / 2) | ||
5091 | { | ||
5092 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y); | ||
5093 | } | ||
5094 | else | ||
5095 | { | ||
5096 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, Constants.RegionSize, avatar.AbsolutePosition.Y); | ||
5097 | } | ||
5098 | } | ||
5099 | //find out what horizontal edge to go to | ||
5100 | else | ||
5101 | { | ||
5102 | if (avatar.AbsolutePosition.Y < Constants.RegionSize / 2) | ||
5103 | { | ||
5104 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f); | ||
5105 | } | ||
5106 | else | ||
5107 | { | ||
5108 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, Constants.RegionSize); | ||
5109 | } | ||
5110 | } | ||
5111 | } | ||
5112 | |||
5113 | private Vector3 GetPositionAtAvatarHeightOrGroundHeight(ScenePresence avatar, float x, float y) | ||
5114 | { | ||
5115 | Vector3 ground = GetPositionAtGround(x, y); | ||
5116 | if (avatar.AbsolutePosition.Z > ground.Z) | ||
5117 | { | ||
5118 | ground.Z = avatar.AbsolutePosition.Z; | ||
5119 | } | ||
5120 | return ground; | ||
5121 | } | ||
5122 | |||
5123 | private Vector3 GetPositionAtGround(float x, float y) | ||
5124 | { | ||
5125 | return new Vector3(x, y, GetGroundHeight(x, y)); | ||
5126 | } | ||
5127 | |||
5128 | public List<UUID> GetEstateRegions(int estateID) | ||
5129 | { | ||
5130 | if (m_storageManager.EstateDataStore == null) | ||
5131 | return new List<UUID>(); | ||
5132 | |||
5133 | return m_storageManager.EstateDataStore.GetRegions(estateID); | ||
5134 | } | ||
5135 | |||
5136 | public void ReloadEstateData() | ||
5137 | { | ||
5138 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); | ||
5139 | |||
5140 | TriggerEstateSunUpdate(); | ||
5141 | } | ||
5142 | |||
5143 | public void TriggerEstateSunUpdate() | ||
5144 | { | ||
5145 | float sun; | ||
5146 | if (RegionInfo.RegionSettings.UseEstateSun) | ||
5147 | { | ||
5148 | sun = (float)RegionInfo.EstateSettings.SunPosition; | ||
5149 | if (RegionInfo.EstateSettings.UseGlobalTime) | ||
5150 | { | ||
5151 | sun = EventManager.GetCurrentTimeAsSunLindenHour() - 6.0f; | ||
5152 | } | ||
5153 | |||
5154 | // | ||
5155 | EventManager.TriggerEstateToolsSunUpdate( | ||
5156 | RegionInfo.RegionHandle, | ||
5157 | RegionInfo.EstateSettings.FixedSun, | ||
5158 | RegionInfo.RegionSettings.UseEstateSun, | ||
5159 | sun); | ||
5160 | } | ||
5161 | else | ||
5162 | { | ||
5163 | // Use the Sun Position from the Region Settings | ||
5164 | sun = (float)RegionInfo.RegionSettings.SunPosition - 6.0f; | ||
5165 | |||
5166 | EventManager.TriggerEstateToolsSunUpdate( | ||
5167 | RegionInfo.RegionHandle, | ||
5168 | RegionInfo.RegionSettings.FixedSun, | ||
5169 | RegionInfo.RegionSettings.UseEstateSun, | ||
5170 | sun); | ||
5171 | } | ||
5172 | } | ||
5173 | |||
5174 | private void HandleReloadEstate(string module, string[] cmd) | ||
5175 | { | ||
5176 | if (MainConsole.Instance.ConsoleScene == null || | ||
5177 | (MainConsole.Instance.ConsoleScene is Scene && | ||
5178 | (Scene)MainConsole.Instance.ConsoleScene == this)) | ||
5179 | { | ||
5180 | ReloadEstateData(); | ||
5181 | } | ||
5182 | } | ||
5036 | } | 5183 | } |
5037 | } | 5184 | } |
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; | |||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Communications.Cache; | 37 | |
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 39 | using 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 04626d3..9d0e6f4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -36,7 +36,6 @@ using log4net; | |||
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Client; | 37 | using OpenSim.Framework.Client; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications.Cache; | ||
40 | using OpenSim.Framework.Capabilities; | 39 | using OpenSim.Framework.Capabilities; |
41 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Services.Interfaces; | 41 | using 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 = 400; | ||
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 090f379..f43de20 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -35,6 +35,7 @@ using log4net; | |||
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Scenes.Types; | 36 | using OpenSim.Region.Framework.Scenes.Types; |
37 | using OpenSim.Region.Physics.Manager; | 37 | using OpenSim.Region.Physics.Manager; |
38 | using OpenSim.Region.Framework.Interfaces; | ||
38 | 39 | ||
39 | namespace OpenSim.Region.Framework.Scenes | 40 | namespace 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 |
@@ -464,9 +467,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
464 | { | 467 | { |
465 | SceneObjectGroup group = GetGroupByPrim(objectLocalID); | 468 | SceneObjectGroup group = GetGroupByPrim(objectLocalID); |
466 | if (group != null) | 469 | if (group != null) |
467 | { | 470 | m_parentScene.AttachmentsModule.DetachSingleAttachmentToGround(group.UUID, remoteClient); |
468 | m_parentScene.DetachSingleAttachmentToGround(group.UUID, remoteClient); | ||
469 | } | ||
470 | } | 471 | } |
471 | 472 | ||
472 | protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient) | 473 | protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient) |
@@ -475,7 +476,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
475 | if (group != null) | 476 | if (group != null) |
476 | { | 477 | { |
477 | //group.DetachToGround(); | 478 | //group.DetachToGround(); |
478 | m_parentScene.DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); | 479 | m_parentScene.AttachmentsModule.ShowDetachInUserInventory(group.GetFromItemID(), remoteClient); |
479 | } | 480 | } |
480 | } | 481 | } |
481 | 482 | ||
@@ -509,212 +510,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
509 | } | 510 | } |
510 | } | 511 | } |
511 | 512 | ||
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) | 513 | protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) |
719 | { | 514 | { |
720 | ScenePresence newAvatar = null; | 515 | ScenePresence newAvatar = null; |
@@ -845,18 +640,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
845 | 640 | ||
846 | public void RecalculateStats() | 641 | public void RecalculateStats() |
847 | { | 642 | { |
848 | ScenePresence[] presences = GetScenePresences(); | ||
849 | int rootcount = 0; | 643 | int rootcount = 0; |
850 | int childcount = 0; | 644 | int childcount = 0; |
851 | 645 | ||
852 | for (int i = 0; i < presences.Length; i++) | 646 | ForEachScenePresence(delegate(ScenePresence presence) |
853 | { | 647 | { |
854 | ScenePresence user = presences[i]; | 648 | if (presence.IsChildAgent) |
855 | if (user.IsChildAgent) | ||
856 | ++childcount; | 649 | ++childcount; |
857 | else | 650 | else |
858 | ++rootcount; | 651 | ++rootcount; |
859 | } | 652 | }); |
860 | 653 | ||
861 | m_numRootAgents = rootcount; | 654 | m_numRootAgents = rootcount; |
862 | m_numChildAgents = childcount; | 655 | m_numChildAgents = childcount; |
@@ -903,25 +696,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
903 | #endregion | 696 | #endregion |
904 | 697 | ||
905 | #region Get Methods | 698 | #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> | 699 | /// <summary> |
926 | /// Get the controlling client for the given avatar, if there is one. | 700 | /// Get the controlling client for the given avatar, if there is one. |
927 | /// | 701 | /// |
@@ -948,41 +722,83 @@ namespace OpenSim.Region.Framework.Scenes | |||
948 | } | 722 | } |
949 | 723 | ||
950 | /// <summary> | 724 | /// <summary> |
951 | /// Request a filtered list of m_scenePresences in this World | 725 | /// Request a copy of m_scenePresences in this World |
726 | /// There is no guarantee that presences will remain in the scene after the list is returned. | ||
727 | /// This list should remain private to SceneGraph. Callers wishing to iterate should instead | ||
728 | /// pass a delegate to ForEachScenePresence. | ||
952 | /// </summary> | 729 | /// </summary> |
953 | /// <returns></returns> | 730 | /// <returns></returns> |
954 | protected internal List<ScenePresence> GetScenePresences(FilterAvatarList filter) | 731 | private List<ScenePresence> GetScenePresences() |
955 | { | 732 | { |
956 | // No locking of scene presences here since we're passing back a list... | 733 | lock (m_scenePresences) |
957 | 734 | return new List<ScenePresence>(m_scenePresenceArray); | |
958 | List<ScenePresence> result = new List<ScenePresence>(); | 735 | } |
959 | ScenePresence[] scenePresences = GetScenePresences(); | ||
960 | 736 | ||
961 | for (int i = 0; i < scenePresences.Length; i++) | 737 | /// <summary> |
738 | /// Request a scene presence by UUID. Fast, indexed lookup. | ||
739 | /// </summary> | ||
740 | /// <param name="agentID"></param> | ||
741 | /// <returns>null if the presence was not found</returns> | ||
742 | protected internal ScenePresence GetScenePresence(UUID agentID) | ||
743 | { | ||
744 | ScenePresence sp; | ||
745 | lock (m_scenePresences) | ||
962 | { | 746 | { |
963 | ScenePresence avatar = scenePresences[i]; | 747 | m_scenePresences.TryGetValue(agentID, out sp); |
964 | if (filter(avatar)) | ||
965 | result.Add(avatar); | ||
966 | } | 748 | } |
749 | return sp; | ||
750 | } | ||
967 | 751 | ||
968 | return result; | 752 | /// <summary> |
753 | /// Request the scene presence by name. | ||
754 | /// </summary> | ||
755 | /// <param name="firstName"></param> | ||
756 | /// <param name="lastName"></param> | ||
757 | /// <returns>null if the presence was not found</returns> | ||
758 | protected internal ScenePresence GetScenePresence(string firstName, string lastName) | ||
759 | { | ||
760 | foreach (ScenePresence presence in GetScenePresences()) | ||
761 | { | ||
762 | if (presence.Firstname == firstName && presence.Lastname == lastName) | ||
763 | return presence; | ||
764 | } | ||
765 | return null; | ||
969 | } | 766 | } |
970 | 767 | ||
971 | /// <summary> | 768 | /// <summary> |
972 | /// Request a scene presence by UUID | 769 | /// Request the scene presence by localID. |
973 | /// </summary> | 770 | /// </summary> |
974 | /// <param name="avatarID"></param> | 771 | /// <param name="localID"></param> |
975 | /// <returns>null if the agent was not found</returns> | 772 | /// <returns>null if the presence was not found</returns> |
976 | protected internal ScenePresence GetScenePresence(UUID agentID) | 773 | protected internal ScenePresence GetScenePresence(uint localID) |
774 | { | ||
775 | foreach (ScenePresence presence in GetScenePresences()) | ||
776 | if (presence.LocalId == localID) | ||
777 | return presence; | ||
778 | return null; | ||
779 | } | ||
780 | |||
781 | protected internal bool TryGetScenePresence(UUID agentID, out ScenePresence avatar) | ||
977 | { | 782 | { |
978 | ScenePresence sp; | ||
979 | |||
980 | lock (m_scenePresences) | 783 | lock (m_scenePresences) |
981 | { | 784 | { |
982 | m_scenePresences.TryGetValue(agentID, out sp); | 785 | m_scenePresences.TryGetValue(agentID, out avatar); |
983 | } | 786 | } |
787 | return (avatar != null); | ||
788 | } | ||
984 | 789 | ||
985 | return sp; | 790 | protected internal bool TryGetAvatarByName(string name, out ScenePresence avatar) |
791 | { | ||
792 | avatar = null; | ||
793 | foreach (ScenePresence presence in GetScenePresences()) | ||
794 | { | ||
795 | if (String.Compare(name, presence.ControllingClient.Name, true) == 0) | ||
796 | { | ||
797 | avatar = presence; | ||
798 | break; | ||
799 | } | ||
800 | } | ||
801 | return (avatar != null); | ||
986 | } | 802 | } |
987 | 803 | ||
988 | /// <summary> | 804 | /// <summary> |
@@ -1136,34 +952,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1136 | return group.GetChildPart(fullID); | 952 | return group.GetChildPart(fullID); |
1137 | } | 953 | } |
1138 | 954 | ||
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> | 955 | /// <summary> |
1168 | /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over | 956 | /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over |
1169 | /// it | 957 | /// it |
@@ -1226,6 +1014,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1226 | return UUID.Zero; | 1014 | return UUID.Zero; |
1227 | } | 1015 | } |
1228 | 1016 | ||
1017 | /// <summary> | ||
1018 | /// Performs action on all scene object groups. | ||
1019 | /// </summary> | ||
1020 | /// <param name="action"></param> | ||
1229 | protected internal void ForEachSOG(Action<SceneObjectGroup> action) | 1021 | protected internal void ForEachSOG(Action<SceneObjectGroup> action) |
1230 | { | 1022 | { |
1231 | List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); | 1023 | List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); |
@@ -1242,6 +1034,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
1242 | } | 1034 | } |
1243 | } | 1035 | } |
1244 | } | 1036 | } |
1037 | |||
1038 | |||
1039 | /// <summary> | ||
1040 | /// Performs action on all scene presences. This can ultimately run the actions in parallel but | ||
1041 | /// any delegates passed in will need to implement their own locking on data they reference and | ||
1042 | /// modify outside of the scope of the delegate. | ||
1043 | /// </summary> | ||
1044 | /// <param name="action"></param> | ||
1045 | public void ForEachScenePresence(Action<ScenePresence> action) | ||
1046 | { | ||
1047 | // Once all callers have their delegates configured for parallelism, we can unleash this | ||
1048 | /* | ||
1049 | Action<ScenePresence> protectedAction = new Action<ScenePresence>(delegate(ScenePresence sp) | ||
1050 | { | ||
1051 | try | ||
1052 | { | ||
1053 | action(sp); | ||
1054 | } | ||
1055 | catch (Exception e) | ||
1056 | { | ||
1057 | m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); | ||
1058 | m_log.Info("[BUG] Stack Trace: " + e.StackTrace); | ||
1059 | } | ||
1060 | }); | ||
1061 | Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction); | ||
1062 | */ | ||
1063 | // For now, perform actiona serially | ||
1064 | foreach (ScenePresence sp in GetScenePresences()) | ||
1065 | { | ||
1066 | try | ||
1067 | { | ||
1068 | action(sp); | ||
1069 | } | ||
1070 | catch (Exception e) | ||
1071 | { | ||
1072 | m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); | ||
1073 | m_log.Info("[BUG] Stack Trace: " + e.StackTrace); | ||
1074 | } | ||
1075 | } | ||
1076 | } | ||
1245 | 1077 | ||
1246 | #endregion | 1078 | #endregion |
1247 | 1079 | ||
@@ -1924,6 +1756,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1924 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0); | 1756 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0); |
1925 | copy.HasGroupChanged = true; | 1757 | copy.HasGroupChanged = true; |
1926 | copy.ScheduleGroupForFullUpdate(); | 1758 | copy.ScheduleGroupForFullUpdate(); |
1759 | copy.ResumeScripts(); | ||
1927 | 1760 | ||
1928 | // required for physics to update it's position | 1761 | // required for physics to update it's position |
1929 | copy.AbsolutePosition = copy.AbsolutePosition; | 1762 | copy.AbsolutePosition = copy.AbsolutePosition; |
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.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 8b58b3e..1149a20 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -171,7 +171,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
171 | item.NextPermissions; | 171 | item.NextPermissions; |
172 | taskItem.NextPermissions = item.NextPermissions; | 172 | taskItem.NextPermissions = item.NextPermissions; |
173 | taskItem.CurrentPermissions |= 8; | 173 | taskItem.CurrentPermissions |= 8; |
174 | } else { | 174 | } |
175 | else | ||
176 | { | ||
175 | taskItem.BasePermissions = item.BasePermissions; | 177 | taskItem.BasePermissions = item.BasePermissions; |
176 | taskItem.CurrentPermissions = item.CurrentPermissions; | 178 | taskItem.CurrentPermissions = item.CurrentPermissions; |
177 | taskItem.CurrentPermissions |= 8; | 179 | taskItem.CurrentPermissions |= 8; |
@@ -412,5 +414,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
412 | scriptModule.SetXMLState(itemID, n.OuterXml); | 414 | scriptModule.SetXMLState(itemID, n.OuterXml); |
413 | } | 415 | } |
414 | } | 416 | } |
417 | |||
418 | public void ResumeScripts() | ||
419 | { | ||
420 | foreach (SceneObjectPart part in m_parts.Values) | ||
421 | { | ||
422 | part.Inventory.ResumeScripts(); | ||
423 | } | ||
424 | } | ||
415 | } | 425 | } |
416 | } | 426 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 13d1d4e..ff471e0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -418,6 +418,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
418 | RootPart.ScriptSetPhysicsStatus(false); | 418 | RootPart.ScriptSetPhysicsStatus(false); |
419 | Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), | 419 | Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), |
420 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); | 420 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); |
421 | lockPartsForRead(false); | ||
421 | return; | 422 | return; |
422 | } | 423 | } |
423 | } | 424 | } |
@@ -530,8 +531,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
530 | private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); | 531 | private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); |
531 | public List<SceneObjectPart> PlaySoundSlavePrims | 532 | public List<SceneObjectPart> PlaySoundSlavePrims |
532 | { | 533 | { |
533 | get { return m_LoopSoundSlavePrims; } | 534 | get { return m_PlaySoundSlavePrims; } |
534 | set { m_LoopSoundSlavePrims = value; } | 535 | set { m_PlaySoundSlavePrims = value; } |
535 | } | 536 | } |
536 | 537 | ||
537 | private SceneObjectPart m_LoopSoundMasterPrim = null; | 538 | private SceneObjectPart m_LoopSoundMasterPrim = null; |
@@ -686,7 +687,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
686 | ApplyPhysics(m_scene.m_physicalPrim); | 687 | ApplyPhysics(m_scene.m_physicalPrim); |
687 | 688 | ||
688 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | 689 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
689 | // for the same object with very different properties. The caller must schedule the update. | 690 | // for the same object with very different properties. The caller must schedule the update. |
690 | //ScheduleGroupForFullUpdate(); | 691 | //ScheduleGroupForFullUpdate(); |
691 | } | 692 | } |
692 | 693 | ||
@@ -1040,6 +1041,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1040 | 1041 | ||
1041 | public void SaveScriptedState(XmlTextWriter writer) | 1042 | public void SaveScriptedState(XmlTextWriter writer) |
1042 | { | 1043 | { |
1044 | SaveScriptedState(writer, false); | ||
1045 | } | ||
1046 | |||
1047 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1048 | { | ||
1043 | XmlDocument doc = new XmlDocument(); | 1049 | XmlDocument doc = new XmlDocument(); |
1044 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1050 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
1045 | 1051 | ||
@@ -1049,7 +1055,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1049 | foreach (SceneObjectPart part in m_parts.Values) | 1055 | foreach (SceneObjectPart part in m_parts.Values) |
1050 | { | 1056 | { |
1051 | 1057 | ||
1052 | Dictionary<UUID,string> pstates = part.Inventory.GetScriptStates(); | 1058 | Dictionary<UUID,string> pstates = part.Inventory.GetScriptStates(oldIDs); |
1053 | foreach (UUID itemid in pstates.Keys) | 1059 | foreach (UUID itemid in pstates.Keys) |
1054 | { | 1060 | { |
1055 | states.Add(itemid, pstates[itemid]); | 1061 | states.Add(itemid, pstates[itemid]); |
@@ -1411,21 +1417,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1411 | { | 1417 | { |
1412 | // part.Inventory.RemoveScriptInstances(); | 1418 | // part.Inventory.RemoveScriptInstances(); |
1413 | 1419 | ||
1414 | ScenePresence[] avatars = Scene.GetScenePresences(); | 1420 | Scene.ForEachScenePresence(delegate (ScenePresence sp) |
1415 | for (int i = 0; i < avatars.Length; i++) | ||
1416 | { | 1421 | { |
1417 | if (avatars[i].ParentID == LocalId) | 1422 | if (sp.ParentID == LocalId) |
1418 | { | 1423 | { |
1419 | avatars[i].StandUp(); | 1424 | sp.StandUp(); |
1420 | } | 1425 | } |
1421 | 1426 | ||
1422 | if (!silent) | 1427 | if (!silent) |
1423 | { | 1428 | { |
1424 | part.UpdateFlag = 0; | 1429 | part.UpdateFlag = 0; |
1425 | if (part == m_rootPart) | 1430 | if (part == m_rootPart) |
1426 | avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId); | 1431 | sp.ControllingClient.SendKillObject(m_regionHandle, part.LocalId); |
1427 | } | 1432 | } |
1428 | } | 1433 | }); |
1429 | 1434 | ||
1430 | } | 1435 | } |
1431 | 1436 | ||
@@ -1647,11 +1652,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1647 | 1652 | ||
1648 | #endregion | 1653 | #endregion |
1649 | 1654 | ||
1650 | #region Client Updating | ||
1651 | |||
1652 | public void SendFullUpdateToClient(IClientAPI remoteClient) | 1655 | public void SendFullUpdateToClient(IClientAPI remoteClient) |
1653 | { | 1656 | { |
1654 | SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); | 1657 | RootPart.SendFullUpdate( |
1658 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); | ||
1655 | 1659 | ||
1656 | lockPartsForRead(true); | 1660 | lockPartsForRead(true); |
1657 | { | 1661 | { |
@@ -1659,42 +1663,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1659 | { | 1663 | { |
1660 | 1664 | ||
1661 | if (part != RootPart) | 1665 | if (part != RootPart) |
1662 | SendPartFullUpdate(remoteClient, part, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); | 1666 | part.SendFullUpdate( |
1663 | 1667 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); | |
1664 | } | 1668 | } |
1665 | } | 1669 | } |
1666 | lockPartsForRead(false); | ||
1667 | } | 1670 | } |
1668 | 1671 | ||
1669 | /// <summary> | ||
1670 | /// Send a full update to the client for the given part | ||
1671 | /// </summary> | ||
1672 | /// <param name="remoteClient"></param> | ||
1673 | /// <param name="part"></param> | ||
1674 | internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags) | ||
1675 | { | ||
1676 | // m_log.DebugFormat( | ||
1677 | // "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); | ||
1678 | |||
1679 | if (m_rootPart.UUID == part.UUID) | ||
1680 | { | ||
1681 | if (IsAttachment) | ||
1682 | { | ||
1683 | part.SendFullUpdateToClient(remoteClient, m_rootPart.AttachedPos, clientFlags); | ||
1684 | } | ||
1685 | else | ||
1686 | { | ||
1687 | part.SendFullUpdateToClient(remoteClient, AbsolutePosition, clientFlags); | ||
1688 | } | ||
1689 | } | ||
1690 | else | ||
1691 | { | ||
1692 | part.SendFullUpdateToClient(remoteClient, clientFlags); | ||
1693 | } | ||
1694 | } | ||
1695 | |||
1696 | #endregion | ||
1697 | |||
1698 | #region Copying | 1672 | #region Copying |
1699 | 1673 | ||
1700 | /// <summary> | 1674 | /// <summary> |
@@ -2206,14 +2180,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2206 | public void ScheduleTerseUpdateToAvatar(ScenePresence presence) | 2180 | public void ScheduleTerseUpdateToAvatar(ScenePresence presence) |
2207 | { | 2181 | { |
2208 | lockPartsForRead(true); | 2182 | lockPartsForRead(true); |
2183 | |||
2184 | foreach (SceneObjectPart part in m_parts.Values) | ||
2209 | { | 2185 | { |
2210 | foreach (SceneObjectPart part in m_parts.Values) | 2186 | part.AddTerseUpdateToAvatar(presence); |
2211 | { | ||
2212 | |||
2213 | part.AddTerseUpdateToAvatar(presence); | ||
2214 | |||
2215 | } | ||
2216 | } | 2187 | } |
2188 | |||
2217 | lockPartsForRead(false); | 2189 | lockPartsForRead(false); |
2218 | } | 2190 | } |
2219 | 2191 | ||
@@ -2246,14 +2218,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2246 | public void ScheduleGroupForTerseUpdate() | 2218 | public void ScheduleGroupForTerseUpdate() |
2247 | { | 2219 | { |
2248 | lockPartsForRead(true); | 2220 | lockPartsForRead(true); |
2221 | foreach (SceneObjectPart part in m_parts.Values) | ||
2249 | { | 2222 | { |
2250 | foreach (SceneObjectPart part in m_parts.Values) | 2223 | part.ScheduleTerseUpdate(); |
2251 | { | ||
2252 | |||
2253 | part.ScheduleTerseUpdate(); | ||
2254 | |||
2255 | } | ||
2256 | } | 2224 | } |
2225 | |||
2257 | lockPartsForRead(false); | 2226 | lockPartsForRead(false); |
2258 | } | 2227 | } |
2259 | 2228 | ||
@@ -3107,8 +3076,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3107 | { | 3076 | { |
3108 | if (obPart.UUID != m_rootPart.UUID) | 3077 | if (obPart.UUID != m_rootPart.UUID) |
3109 | { | 3078 | { |
3110 | obPart.IgnoreUndoUpdate = true; | ||
3111 | Vector3 oldSize = new Vector3(obPart.Scale); | 3079 | Vector3 oldSize = new Vector3(obPart.Scale); |
3080 | obPart.IgnoreUndoUpdate = true; | ||
3112 | 3081 | ||
3113 | float f = 1.0f; | 3082 | float f = 1.0f; |
3114 | float a = 1.0f; | 3083 | float a = 1.0f; |
@@ -3962,5 +3931,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3962 | 3931 | ||
3963 | return priority; | 3932 | return priority; |
3964 | } | 3933 | } |
3934 | |||
3935 | public void ResetOwnerChangeFlag() | ||
3936 | { | ||
3937 | ForEachPart(delegate(SceneObjectPart part) | ||
3938 | { | ||
3939 | part.ResetOwnerChangeFlag(); | ||
3940 | }); | ||
3941 | } | ||
3965 | } | 3942 | } |
3966 | } | 3943 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 548a64f..48e65a5 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) |
@@ -4672,5 +4683,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
4672 | { | 4683 | { |
4673 | return new Color4((byte)Color.R, (byte)Color.G, (byte)Color.B, (byte)(0xFF - Color.A)); | 4684 | return new Color4((byte)Color.R, (byte)Color.G, (byte)Color.B, (byte)(0xFF - Color.A)); |
4674 | } | 4685 | } |
4686 | |||
4687 | public void ResetOwnerChangeFlag() | ||
4688 | { | ||
4689 | List<UUID> inv = Inventory.GetInventoryList(); | ||
4690 | |||
4691 | foreach (UUID itemID in inv) | ||
4692 | { | ||
4693 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
4694 | item.OwnerChanged = false; | ||
4695 | Inventory.UpdateInventoryItem(item); | ||
4696 | } | ||
4697 | } | ||
4675 | } | 4698 | } |
4676 | } | 4699 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index a2fceb7..62b44bd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -34,7 +34,6 @@ using System.Reflection; | |||
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using log4net; | 35 | using log4net; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Communications.Cache; | ||
38 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes.Scripting; | 38 | using OpenSim.Region.Framework.Scenes.Scripting; |
40 | 39 | ||
@@ -213,7 +212,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
213 | } | 212 | } |
214 | } | 213 | } |
215 | 214 | ||
216 | private ArrayList GetScriptErrors(UUID itemID) | 215 | public ArrayList GetScriptErrors(UUID itemID) |
217 | { | 216 | { |
218 | ArrayList ret = new ArrayList(); | 217 | ArrayList ret = new ArrayList(); |
219 | 218 | ||
@@ -296,38 +295,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
296 | return; | 295 | return; |
297 | } | 296 | } |
298 | 297 | ||
299 | m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) | 298 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
300 | { | 299 | if (null == asset) |
301 | if (null == asset) | 300 | { |
302 | { | 301 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); |
303 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | 302 | StoreScriptError(item.ItemID, msg); |
304 | StoreScriptError(item.ItemID, msg); | 303 | m_log.ErrorFormat( |
305 | m_log.ErrorFormat( | 304 | "[PRIM INVENTORY]: " + |
306 | "[PRIM INVENTORY]: " + | 305 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
307 | "Couldn't start script {0}, {1} at {2} in {3} since {4}", | 306 | item.Name, item.ItemID, m_part.AbsolutePosition, |
308 | item.Name, item.ItemID, m_part.AbsolutePosition, | 307 | m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); |
309 | m_part.ParentGroup.Scene.RegionInfo.RegionName, msg); | 308 | } |
310 | } | 309 | else |
311 | else | 310 | { |
312 | { | 311 | if (m_part.ParentGroup.m_savedScriptState != null) |
313 | if (m_part.ParentGroup.m_savedScriptState != null) | 312 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
314 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 313 | |
315 | m_items.LockItemsForWrite(true); | 314 | m_items.LockItemsForWrite(true); |
316 | m_items[item.ItemID].PermsMask = 0; | 315 | |
317 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 316 | m_items[item.ItemID].PermsMask = 0; |
318 | m_items.LockItemsForWrite(false); | 317 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
319 | string script = Utils.BytesToString(asset.Data); | 318 | |
320 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 319 | m_items.LockItemsForWrite(false); |
321 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 320 | |
322 | StoreScriptErrors(item.ItemID, null); | 321 | string script = Utils.BytesToString(asset.Data); |
323 | m_part.ParentGroup.AddActiveScriptCount(1); | 322 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
324 | m_part.ScheduleFullUpdate(); | 323 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
325 | } | 324 | StoreScriptErrors(item.ItemID, null); |
326 | }); | 325 | m_part.ParentGroup.AddActiveScriptCount(1); |
327 | } | 326 | m_part.ScheduleFullUpdate(); |
328 | else | 327 | } |
329 | { | ||
330 | StoreScriptError(item.ItemID, "scripts disabled"); | ||
331 | } | 328 | } |
332 | } | 329 | } |
333 | 330 | ||
@@ -654,6 +651,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
654 | item.ParentID = m_part.UUID; | 651 | item.ParentID = m_part.UUID; |
655 | item.ParentPartID = m_part.UUID; | 652 | item.ParentPartID = m_part.UUID; |
656 | item.Name = name; | 653 | item.Name = name; |
654 | item.GroupID = m_part.GroupID; | ||
657 | 655 | ||
658 | m_items.LockItemsForWrite(true); | 656 | m_items.LockItemsForWrite(true); |
659 | m_items.Add(item.ItemID, item); | 657 | m_items.Add(item.ItemID, item); |
@@ -716,15 +714,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
716 | { | 714 | { |
717 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 715 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
718 | 716 | ||
719 | lock (m_items) | 717 | m_items.LockItemsForRead(true); |
718 | |||
719 | foreach (TaskInventoryItem item in m_items.Values) | ||
720 | { | 720 | { |
721 | foreach (TaskInventoryItem item in m_items.Values) | 721 | if (item.Name == name) |
722 | { | 722 | items.Add(item); |
723 | if (item.Name == name) | ||
724 | items.Add(item); | ||
725 | } | ||
726 | } | 723 | } |
727 | 724 | ||
725 | m_items.LockItemsForRead(false); | ||
726 | |||
728 | return items; | 727 | return items; |
729 | } | 728 | } |
730 | 729 | ||
@@ -736,6 +735,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
736 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> | 735 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> |
737 | public bool UpdateInventoryItem(TaskInventoryItem item) | 736 | public bool UpdateInventoryItem(TaskInventoryItem item) |
738 | { | 737 | { |
738 | return UpdateInventoryItem(item, true); | ||
739 | } | ||
740 | |||
741 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) | ||
742 | { | ||
739 | m_items.LockItemsForWrite(true); | 743 | m_items.LockItemsForWrite(true); |
740 | 744 | ||
741 | if (m_items.ContainsKey(item.ItemID)) | 745 | if (m_items.ContainsKey(item.ItemID)) |
@@ -743,6 +747,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
743 | item.ParentID = m_part.UUID; | 747 | item.ParentID = m_part.UUID; |
744 | item.ParentPartID = m_part.UUID; | 748 | item.ParentPartID = m_part.UUID; |
745 | item.Flags = m_items[item.ItemID].Flags; | 749 | item.Flags = m_items[item.ItemID].Flags; |
750 | |||
751 | // If group permissions have been set on, check that the groupID is up to date in case it has | ||
752 | // changed since permissions were last set. | ||
753 | if (item.GroupPermissions != (uint)PermissionMask.None) | ||
754 | item.GroupID = m_part.GroupID; | ||
755 | |||
746 | if (item.AssetID == UUID.Zero) | 756 | if (item.AssetID == UUID.Zero) |
747 | { | 757 | { |
748 | item.AssetID = m_items[item.ItemID].AssetID; | 758 | item.AssetID = m_items[item.ItemID].AssetID; |
@@ -760,8 +770,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
760 | 770 | ||
761 | m_items[item.ItemID] = item; | 771 | m_items[item.ItemID] = item; |
762 | m_inventorySerial++; | 772 | m_inventorySerial++; |
763 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 773 | if (fireScriptEvents) |
764 | 774 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | |
765 | HasInventoryChanged = true; | 775 | HasInventoryChanged = true; |
766 | m_part.ParentGroup.HasGroupChanged = true; | 776 | m_part.ParentGroup.HasGroupChanged = true; |
767 | m_items.LockItemsForWrite(false); | 777 | m_items.LockItemsForWrite(false); |
@@ -896,6 +906,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
896 | uint everyoneMask = 0; | 906 | uint everyoneMask = 0; |
897 | uint baseMask = item.BasePermissions; | 907 | uint baseMask = item.BasePermissions; |
898 | uint ownerMask = item.CurrentPermissions; | 908 | uint ownerMask = item.CurrentPermissions; |
909 | uint groupMask = item.GroupPermissions; | ||
899 | 910 | ||
900 | invString.AddItemStart(); | 911 | invString.AddItemStart(); |
901 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 912 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
@@ -905,7 +916,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
905 | 916 | ||
906 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 917 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); |
907 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 918 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); |
908 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); | 919 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); |
909 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | 920 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); |
910 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | 921 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); |
911 | 922 | ||
@@ -1071,12 +1082,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1071 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | 1082 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
1072 | item.CurrentPermissions |= 8; | 1083 | item.CurrentPermissions |= 8; |
1073 | } | 1084 | } |
1085 | item.OwnerChanged = true; | ||
1074 | item.CurrentPermissions &= item.NextPermissions; | 1086 | item.CurrentPermissions &= item.NextPermissions; |
1075 | item.BasePermissions &= item.NextPermissions; | 1087 | item.BasePermissions &= item.NextPermissions; |
1076 | item.EveryonePermissions &= item.NextPermissions; | 1088 | item.EveryonePermissions &= item.NextPermissions; |
1077 | } | 1089 | } |
1078 | |||
1079 | m_part.TriggerScriptChangedEvent(Changed.OWNER); | ||
1080 | } | 1090 | } |
1081 | 1091 | ||
1082 | public void ApplyGodPermissions(uint perms) | 1092 | public void ApplyGodPermissions(uint perms) |
@@ -1112,6 +1122,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1112 | 1122 | ||
1113 | public Dictionary<UUID, string> GetScriptStates() | 1123 | public Dictionary<UUID, string> GetScriptStates() |
1114 | { | 1124 | { |
1125 | return GetScriptStates(false); | ||
1126 | } | ||
1127 | |||
1128 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1129 | { | ||
1115 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 1130 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
1116 | 1131 | ||
1117 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1132 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
@@ -1129,8 +1144,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1129 | string n = e.GetXMLState(item.ItemID); | 1144 | string n = e.GetXMLState(item.ItemID); |
1130 | if (n != String.Empty) | 1145 | if (n != String.Empty) |
1131 | { | 1146 | { |
1132 | if (!ret.ContainsKey(item.ItemID)) | 1147 | if (oldIDs) |
1133 | ret[item.ItemID] = n; | 1148 | { |
1149 | if (!ret.ContainsKey(item.OldItemID)) | ||
1150 | ret[item.OldItemID] = n; | ||
1151 | } | ||
1152 | else | ||
1153 | { | ||
1154 | if (!ret.ContainsKey(item.ItemID)) | ||
1155 | ret[item.ItemID] = n; | ||
1156 | } | ||
1134 | break; | 1157 | break; |
1135 | } | 1158 | } |
1136 | } | 1159 | } |
@@ -1139,5 +1162,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
1139 | } | 1162 | } |
1140 | return ret; | 1163 | return ret; |
1141 | } | 1164 | } |
1165 | |||
1166 | public void ResumeScripts() | ||
1167 | { | ||
1168 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
1169 | if (engines == null) | ||
1170 | return; | ||
1171 | |||
1172 | |||
1173 | Items.LockItemsForRead(true); | ||
1174 | |||
1175 | foreach (TaskInventoryItem item in m_items.Values) | ||
1176 | { | ||
1177 | if (item.InvType == (int)InventoryType.LSL) | ||
1178 | { | ||
1179 | foreach (IScriptModule engine in engines) | ||
1180 | { | ||
1181 | if (engine != null) | ||
1182 | { | ||
1183 | if (item.OwnerChanged) | ||
1184 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | ||
1185 | item.OwnerChanged = false; | ||
1186 | engine.ResumeScript(item.ItemID); | ||
1187 | } | ||
1188 | } | ||
1189 | } | ||
1190 | } | ||
1191 | |||
1192 | Items.LockItemsForRead(false); | ||
1193 | } | ||
1142 | } | 1194 | } |
1143 | } | 1195 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 565438d..d76f029 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Timers; | 32 | using System.Timers; |
@@ -33,12 +34,12 @@ using OpenMetaverse; | |||
33 | using log4net; | 34 | using log4net; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Client; | 36 | using OpenSim.Framework.Client; |
36 | using OpenSim.Framework.Communications.Cache; | ||
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes.Animation; | 38 | using OpenSim.Region.Framework.Scenes.Animation; |
39 | using OpenSim.Region.Framework.Scenes.Types; | 39 | using OpenSim.Region.Framework.Scenes.Types; |
40 | using OpenSim.Region.Physics.Manager; | 40 | using OpenSim.Region.Physics.Manager; |
41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
42 | using OpenSim.Services.Interfaces; | ||
42 | 43 | ||
43 | namespace OpenSim.Region.Framework.Scenes | 44 | namespace OpenSim.Region.Framework.Scenes |
44 | { | 45 | { |
@@ -150,7 +151,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
150 | 151 | ||
151 | private float m_sitAvatarHeight = 2.0f; | 152 | private float m_sitAvatarHeight = 2.0f; |
152 | 153 | ||
153 | private float m_godlevel; | 154 | private int m_godLevel; |
155 | private int m_userLevel; | ||
154 | 156 | ||
155 | private bool m_invulnerable = true; | 157 | private bool m_invulnerable = true; |
156 | 158 | ||
@@ -225,7 +227,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
225 | private int m_lastColCount = -1; //KF: Look for Collision chnages | 227 | private int m_lastColCount = -1; //KF: Look for Collision chnages |
226 | private int m_updateCount = 0; //KF: Update Anims for a while | 228 | private int m_updateCount = 0; //KF: Update Anims for a while |
227 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 229 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
228 | |||
229 | private const int NumMovementsBetweenRayCast = 5; | 230 | private const int NumMovementsBetweenRayCast = 5; |
230 | 231 | ||
231 | private bool CameraConstraintActive; | 232 | private bool CameraConstraintActive; |
@@ -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 |
306 | { | 309 | { |
307 | get { return m_godlevel; } | 310 | get { return m_userLevel; } |
311 | } | ||
312 | |||
313 | public int GodLevel | ||
314 | { | ||
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 | } |
@@ -655,6 +663,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
655 | set { m_flyDisabled = value; } | 663 | set { m_flyDisabled = value; } |
656 | } | 664 | } |
657 | 665 | ||
666 | public string Viewer | ||
667 | { | ||
668 | get { return m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode).Viewer; } | ||
669 | } | ||
670 | |||
658 | #endregion | 671 | #endregion |
659 | 672 | ||
660 | #region Constructor(s) | 673 | #region Constructor(s) |
@@ -678,6 +691,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
678 | m_regionInfo = reginfo; | 691 | m_regionInfo = reginfo; |
679 | m_localId = m_scene.AllocateLocalId(); | 692 | m_localId = m_scene.AllocateLocalId(); |
680 | 693 | ||
694 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); | ||
695 | |||
696 | if (account != null) | ||
697 | m_userLevel = account.UserLevel; | ||
698 | |||
681 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 699 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
682 | if (gm != null) | 700 | if (gm != null) |
683 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 701 | m_grouptitle = gm.GetGroupTitle(m_uuid); |
@@ -868,47 +886,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
868 | if (land != null) | 886 | if (land != null) |
869 | { | 887 | { |
870 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. | 888 | //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) | 889 | 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 | { | 890 | { |
873 | pos = land.LandData.UserLocation; | 891 | pos = land.LandData.UserLocation; |
874 | } | 892 | } |
875 | } | 893 | } |
876 | } | 894 | } |
877 | 895 | ||
878 | if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) | 896 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
879 | { | 897 | { |
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( | 898 | m_log.WarnFormat( |
908 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", | 899 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
909 | pos, Name, UUID, emergencyPos); | 900 | pos, Name, UUID); |
910 | 901 | ||
911 | pos = emergencyPos; | 902 | if (pos.X < 0f) pos.X = 0f; |
903 | if (pos.Y < 0f) pos.Y = 0f; | ||
904 | if (pos.Z < 0f) pos.Z = 0f; | ||
912 | } | 905 | } |
913 | 906 | ||
914 | float localAVHeight = 1.56f; | 907 | float localAVHeight = 1.56f; |
@@ -919,7 +912,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
919 | 912 | ||
920 | float posZLimit = 0; | 913 | float posZLimit = 0; |
921 | 914 | ||
922 | if (pos.X <Constants.RegionSize && pos.Y < Constants.RegionSize) | 915 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
923 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 916 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
924 | 917 | ||
925 | float newPosZ = posZLimit + localAVHeight / 2; | 918 | float newPosZ = posZLimit + localAVHeight / 2; |
@@ -971,14 +964,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
971 | 964 | ||
972 | m_isChildAgent = false; | 965 | m_isChildAgent = false; |
973 | 966 | ||
974 | ScenePresence[] animAgents = m_scene.GetScenePresences(); | 967 | // send the animations of the other presences to me |
975 | for (int i = 0; i < animAgents.Length; i++) | 968 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) |
976 | { | 969 | { |
977 | ScenePresence presence = animAgents[i]; | ||
978 | |||
979 | if (presence != this) | 970 | if (presence != this) |
980 | presence.Animator.SendAnimPackToClient(ControllingClient); | 971 | presence.Animator.SendAnimPackToClient(ControllingClient); |
981 | } | 972 | }); |
982 | 973 | ||
983 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 974 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
984 | } | 975 | } |
@@ -1162,8 +1153,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1162 | /// This is called upon a very important packet sent from the client, | 1153 | /// This is called upon a very important packet sent from the client, |
1163 | /// so it's client-controlled. Never call this method directly. | 1154 | /// so it's client-controlled. Never call this method directly. |
1164 | /// </summary> | 1155 | /// </summary> |
1165 | public void CompleteMovement() | 1156 | public void CompleteMovement(IClientAPI client) |
1166 | { | 1157 | { |
1158 | //m_log.Debug("[SCENE PRESENCE]: CompleteMovement"); | ||
1159 | |||
1167 | Vector3 look = Velocity; | 1160 | Vector3 look = Velocity; |
1168 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1161 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1169 | { | 1162 | { |
@@ -1188,7 +1181,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1188 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) | 1181 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) |
1189 | { | 1182 | { |
1190 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); | 1183 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); |
1191 | Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); | 1184 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); |
1192 | m_callbackURI = null; | 1185 | m_callbackURI = null; |
1193 | } | 1186 | } |
1194 | 1187 | ||
@@ -1196,6 +1189,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1196 | 1189 | ||
1197 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); | 1190 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); |
1198 | SendInitialData(); | 1191 | SendInitialData(); |
1192 | |||
1193 | // Create child agents in neighbouring regions | ||
1194 | if (!m_isChildAgent) | ||
1195 | { | ||
1196 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | ||
1197 | if (m_agentTransfer != null) | ||
1198 | m_agentTransfer.EnableChildAgents(this); | ||
1199 | else | ||
1200 | m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); | ||
1201 | |||
1202 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | ||
1203 | if (friendsModule != null) | ||
1204 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | ||
1205 | } | ||
1206 | |||
1199 | } | 1207 | } |
1200 | 1208 | ||
1201 | /// <summary> | 1209 | /// <summary> |
@@ -1264,6 +1272,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1264 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); | 1272 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); |
1265 | 1273 | ||
1266 | m_pos = m_LastFinitePos; | 1274 | m_pos = m_LastFinitePos; |
1275 | |||
1267 | if (!m_pos.IsFinite()) | 1276 | if (!m_pos.IsFinite()) |
1268 | { | 1277 | { |
1269 | m_pos.X = 127f; | 1278 | m_pos.X = 127f; |
@@ -1900,6 +1909,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1900 | { | 1909 | { |
1901 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center | 1910 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center |
1902 | autopilotTarget = part.AbsolutePosition; | 1911 | autopilotTarget = part.AbsolutePosition; |
1912 | //Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); | ||
1903 | } | 1913 | } |
1904 | else return; // occupied small | 1914 | else return; // occupied small |
1905 | } // end large/small | 1915 | } // end large/small |
@@ -2276,7 +2286,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2276 | m_pos += SIT_TARGET_ADJUSTMENT; | 2286 | m_pos += SIT_TARGET_ADJUSTMENT; |
2277 | m_bodyRot = sitTargetOrient; | 2287 | m_bodyRot = sitTargetOrient; |
2278 | m_parentPosition = part.AbsolutePosition; | 2288 | m_parentPosition = part.AbsolutePosition; |
2279 | part.IsOccupied = true; | 2289 | part.IsOccupied = true; |
2290 | Console.WriteLine("Scripted Sit ofset {0}", m_pos); | ||
2280 | } | 2291 | } |
2281 | else | 2292 | else |
2282 | { | 2293 | { |
@@ -2398,6 +2409,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2398 | { | 2409 | { |
2399 | if (m_isChildAgent) | 2410 | if (m_isChildAgent) |
2400 | { | 2411 | { |
2412 | // WHAT??? | ||
2401 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); | 2413 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); |
2402 | 2414 | ||
2403 | // we have to reset the user's child agent connections. | 2415 | // we have to reset the user's child agent connections. |
@@ -2421,7 +2433,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2421 | 2433 | ||
2422 | if (m_scene.SceneGridService != null) | 2434 | if (m_scene.SceneGridService != null) |
2423 | { | 2435 | { |
2424 | m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); | 2436 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
2437 | if (m_agentTransfer != null) | ||
2438 | m_agentTransfer.EnableChildAgents(this); | ||
2425 | } | 2439 | } |
2426 | 2440 | ||
2427 | return; | 2441 | return; |
@@ -2597,35 +2611,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
2597 | 2611 | ||
2598 | List<Vector3> CoarseLocations = new List<Vector3>(); | 2612 | List<Vector3> CoarseLocations = new List<Vector3>(); |
2599 | List<UUID> AvatarUUIDs = new List<UUID>(); | 2613 | List<UUID> AvatarUUIDs = new List<UUID>(); |
2600 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 2614 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
2601 | for (int i = 0; i < avatars.Count; i++) | ||
2602 | { | 2615 | { |
2603 | // Requested by LibOMV. Send Course Location on self. | 2616 | if (sp.IsChildAgent) |
2604 | //if (avatars[i] != this) | 2617 | return; |
2605 | //{ | 2618 | |
2606 | if (avatars[i].ParentID != 0) | 2619 | if (sp.ParentID != 0) |
2620 | { | ||
2621 | // sitting avatar | ||
2622 | SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID); | ||
2623 | if (sop != null) | ||
2607 | { | 2624 | { |
2608 | // sitting avatar | 2625 | CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos); |
2609 | SceneObjectPart sop = m_scene.GetSceneObjectPart(avatars[i].ParentID); | 2626 | AvatarUUIDs.Add(sp.UUID); |
2610 | if (sop != null) | ||
2611 | { | ||
2612 | CoarseLocations.Add(sop.AbsolutePosition + avatars[i].m_pos); | ||
2613 | AvatarUUIDs.Add(avatars[i].UUID); | ||
2614 | } | ||
2615 | else | ||
2616 | { | ||
2617 | // we can't find the parent.. ! arg! | ||
2618 | CoarseLocations.Add(avatars[i].m_pos); | ||
2619 | AvatarUUIDs.Add(avatars[i].UUID); | ||
2620 | } | ||
2621 | } | 2627 | } |
2622 | else | 2628 | else |
2623 | { | 2629 | { |
2624 | CoarseLocations.Add(avatars[i].m_pos); | 2630 | // we can't find the parent.. ! arg! |
2625 | AvatarUUIDs.Add(avatars[i].UUID); | 2631 | CoarseLocations.Add(sp.m_pos); |
2632 | AvatarUUIDs.Add(sp.UUID); | ||
2626 | } | 2633 | } |
2627 | //} | 2634 | } |
2628 | } | 2635 | else |
2636 | { | ||
2637 | CoarseLocations.Add(sp.m_pos); | ||
2638 | AvatarUUIDs.Add(sp.UUID); | ||
2639 | } | ||
2640 | }); | ||
2629 | 2641 | ||
2630 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); | 2642 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); |
2631 | 2643 | ||
@@ -2667,13 +2679,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2667 | public void SendInitialFullUpdateToAllClients() | 2679 | public void SendInitialFullUpdateToAllClients() |
2668 | { | 2680 | { |
2669 | m_perfMonMS = Util.EnvironmentTickCount(); | 2681 | m_perfMonMS = Util.EnvironmentTickCount(); |
2670 | 2682 | int avUpdates = 0; | |
2671 | ScenePresence[] avatars = m_scene.GetScenePresences(); | 2683 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2672 | |||
2673 | for (int i = 0; i < avatars.Length; i++) | ||
2674 | { | 2684 | { |
2675 | ScenePresence avatar = avatars[i]; | 2685 | ++avUpdates; |
2676 | |||
2677 | // only send if this is the root (children are only "listening posts" in a foreign region) | 2686 | // only send if this is the root (children are only "listening posts" in a foreign region) |
2678 | if (!IsChildAgent) | 2687 | if (!IsChildAgent) |
2679 | { | 2688 | { |
@@ -2689,9 +2698,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2689 | avatar.Animator.SendAnimPackToClient(ControllingClient); | 2698 | avatar.Animator.SendAnimPackToClient(ControllingClient); |
2690 | } | 2699 | } |
2691 | } | 2700 | } |
2692 | } | 2701 | }); |
2693 | 2702 | ||
2694 | m_scene.StatsReporter.AddAgentUpdates(avatars.Length); | 2703 | m_scene.StatsReporter.AddAgentUpdates(avUpdates); |
2695 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2704 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2696 | 2705 | ||
2697 | //Animator.SendAnimPack(); | 2706 | //Animator.SendAnimPack(); |
@@ -2702,13 +2711,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2702 | m_perfMonMS = Util.EnvironmentTickCount(); | 2711 | m_perfMonMS = Util.EnvironmentTickCount(); |
2703 | 2712 | ||
2704 | // only send update from root agents to other clients; children are only "listening posts" | 2713 | // only send update from root agents to other clients; children are only "listening posts" |
2705 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 2714 | int count = 0; |
2706 | foreach (ScenePresence avatar in avatars) | 2715 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
2707 | { | 2716 | { |
2708 | SendFullUpdateToOtherClient(avatar); | 2717 | if (sp.IsChildAgent) |
2709 | 2718 | return; | |
2710 | } | 2719 | SendFullUpdateToOtherClient(sp); |
2711 | m_scene.StatsReporter.AddAgentUpdates(avatars.Count); | 2720 | ++count; |
2721 | }); | ||
2722 | m_scene.StatsReporter.AddAgentUpdates(count); | ||
2712 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2723 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2713 | 2724 | ||
2714 | Animator.SendAnimPack(); | 2725 | Animator.SendAnimPack(); |
@@ -2729,14 +2740,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2729 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, | 2740 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, |
2730 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); | 2741 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); |
2731 | 2742 | ||
2732 | if (!m_isChildAgent) | ||
2733 | { | ||
2734 | m_scene.InformClientOfNeighbours(this); | ||
2735 | } | ||
2736 | |||
2737 | SendInitialFullUpdateToAllClients(); | 2743 | SendInitialFullUpdateToAllClients(); |
2738 | SendAppearanceToAllOtherAgents(); | 2744 | SendAppearanceToAllOtherAgents(); |
2739 | } | 2745 | } |
2740 | 2746 | ||
2741 | /// <summary> | 2747 | /// <summary> |
2742 | /// Tell the client for this scene presence what items it should be wearing now | 2748 | /// Tell the client for this scene presence what items it should be wearing now |
@@ -2818,14 +2824,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2818 | } | 2824 | } |
2819 | } | 2825 | } |
2820 | } | 2826 | } |
2827 | |||
2821 | } | 2828 | } |
2822 | 2829 | ||
2830 | |||
2823 | #endregion Bake Cache Check | 2831 | #endregion Bake Cache Check |
2824 | 2832 | ||
2825 | m_appearance.SetAppearance(textureEntry, visualParams); | 2833 | m_appearance.SetAppearance(textureEntry, visualParams); |
2826 | if (m_appearance.AvatarHeight > 0) | 2834 | if (m_appearance.AvatarHeight > 0) |
2827 | SetHeight(m_appearance.AvatarHeight); | 2835 | SetHeight(m_appearance.AvatarHeight); |
2828 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); | 2836 | |
2837 | // This is not needed, because only the transient data changed | ||
2838 | //AvatarData adata = new AvatarData(m_appearance); | ||
2839 | //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); | ||
2829 | 2840 | ||
2830 | SendAppearanceToAllOtherAgents(); | 2841 | SendAppearanceToAllOtherAgents(); |
2831 | if (!m_startAnimationSet) | 2842 | if (!m_startAnimationSet) |
@@ -2845,7 +2856,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2845 | public void SetWearable(int wearableId, AvatarWearable wearable) | 2856 | public void SetWearable(int wearableId, AvatarWearable wearable) |
2846 | { | 2857 | { |
2847 | m_appearance.SetWearable(wearableId, wearable); | 2858 | m_appearance.SetWearable(wearableId, wearable); |
2848 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); | 2859 | AvatarData adata = new AvatarData(m_appearance); |
2860 | m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); | ||
2849 | m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); | 2861 | m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); |
2850 | } | 2862 | } |
2851 | 2863 | ||
@@ -2867,7 +2879,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2867 | /// </summary> | 2879 | /// </summary> |
2868 | protected void CheckForSignificantMovement() | 2880 | protected void CheckForSignificantMovement() |
2869 | { | 2881 | { |
2870 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.5) | 2882 | // Movement updates for agents in neighboring regions are sent directly to clients. |
2883 | // This value only affects how often agent positions are sent to neighbor regions | ||
2884 | // for things such as distance-based update prioritization | ||
2885 | const float SIGNIFICANT_MOVEMENT = 2.0f; | ||
2886 | |||
2887 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) | ||
2871 | { | 2888 | { |
2872 | posLastSignificantMove = AbsolutePosition; | 2889 | posLastSignificantMove = AbsolutePosition; |
2873 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); | 2890 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); |
@@ -2878,18 +2895,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2878 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || | 2895 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || |
2879 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) | 2896 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) |
2880 | { | 2897 | { |
2898 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
2899 | m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
2900 | |||
2881 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | 2901 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); |
2882 | cadu.ActiveGroupID = UUID.Zero.Guid; | 2902 | cadu.ActiveGroupID = UUID.Zero.Guid; |
2883 | cadu.AgentID = UUID.Guid; | 2903 | cadu.AgentID = UUID.Guid; |
2884 | cadu.alwaysrun = m_setAlwaysRun; | 2904 | cadu.alwaysrun = m_setAlwaysRun; |
2885 | cadu.AVHeight = m_avHeight; | 2905 | cadu.AVHeight = m_avHeight; |
2886 | sLLVector3 tempCameraCenter = new sLLVector3(new Vector3(m_CameraCenter.X, m_CameraCenter.Y, m_CameraCenter.Z)); | 2906 | Vector3 tempCameraCenter = m_CameraCenter; |
2887 | cadu.cameraPosition = tempCameraCenter; | 2907 | cadu.cameraPosition = tempCameraCenter; |
2888 | cadu.drawdistance = m_DrawDistance; | 2908 | cadu.drawdistance = m_DrawDistance; |
2889 | if (m_scene.Permissions.IsGod(new UUID(cadu.AgentID))) | ||
2890 | cadu.godlevel = m_godlevel; | ||
2891 | cadu.GroupAccess = 0; | 2909 | cadu.GroupAccess = 0; |
2892 | cadu.Position = new sLLVector3(AbsolutePosition); | 2910 | cadu.Position = AbsolutePosition; |
2893 | cadu.regionHandle = m_rootRegionHandle; | 2911 | cadu.regionHandle = m_rootRegionHandle; |
2894 | float multiplier = 1; | 2912 | float multiplier = 1; |
2895 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); | 2913 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); |
@@ -2904,15 +2922,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2904 | 2922 | ||
2905 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); | 2923 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); |
2906 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); | 2924 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); |
2907 | cadu.Velocity = new sLLVector3(Velocity); | 2925 | cadu.Velocity = Velocity; |
2908 | 2926 | ||
2909 | AgentPosition agentpos = new AgentPosition(); | 2927 | AgentPosition agentpos = new AgentPosition(); |
2910 | agentpos.CopyFrom(cadu); | 2928 | agentpos.CopyFrom(cadu); |
2911 | 2929 | ||
2912 | m_scene.SendOutChildAgentUpdates(agentpos, this); | 2930 | m_scene.SendOutChildAgentUpdates(agentpos, this); |
2913 | |||
2914 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
2915 | m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
2916 | } | 2931 | } |
2917 | } | 2932 | } |
2918 | 2933 | ||
@@ -3168,18 +3183,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3168 | // For now, assign god level 200 to anyone | 3183 | // For now, assign god level 200 to anyone |
3169 | // who is granted god powers, but has no god level set. | 3184 | // who is granted god powers, but has no god level set. |
3170 | // | 3185 | // |
3171 | CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); | 3186 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID); |
3172 | if (profile.UserProfile.GodLevel > 0) | 3187 | if (account != null) |
3173 | m_godlevel = profile.UserProfile.GodLevel; | 3188 | { |
3174 | else | 3189 | if (account.UserLevel > 0) |
3175 | m_godlevel = 200; | 3190 | m_godLevel = account.UserLevel; |
3191 | else | ||
3192 | m_godLevel = 200; | ||
3193 | } | ||
3176 | } | 3194 | } |
3177 | else | 3195 | else |
3178 | { | 3196 | { |
3179 | m_godlevel = 0; | 3197 | m_godLevel = 0; |
3180 | } | 3198 | } |
3181 | 3199 | ||
3182 | ControllingClient.SendAdminResponse(token, (uint)m_godlevel); | 3200 | ControllingClient.SendAdminResponse(token, (uint)m_godLevel); |
3183 | } | 3201 | } |
3184 | 3202 | ||
3185 | #region Child Agent Updates | 3203 | #region Child Agent Updates |
@@ -3238,7 +3256,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3238 | public void CopyTo(AgentData cAgent) | 3256 | public void CopyTo(AgentData cAgent) |
3239 | { | 3257 | { |
3240 | cAgent.AgentID = UUID; | 3258 | cAgent.AgentID = UUID; |
3241 | cAgent.RegionHandle = m_rootRegionHandle; | 3259 | cAgent.RegionID = Scene.RegionInfo.RegionID; |
3242 | 3260 | ||
3243 | cAgent.Position = AbsolutePosition; | 3261 | cAgent.Position = AbsolutePosition; |
3244 | cAgent.Velocity = m_velocity; | 3262 | cAgent.Velocity = m_velocity; |
@@ -3270,7 +3288,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3270 | cAgent.ControlFlags = (uint)m_AgentControlFlags; | 3288 | cAgent.ControlFlags = (uint)m_AgentControlFlags; |
3271 | 3289 | ||
3272 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3290 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3273 | cAgent.GodLevel = (byte)m_godlevel; | 3291 | cAgent.GodLevel = (byte)m_godLevel; |
3274 | else | 3292 | else |
3275 | cAgent.GodLevel = (byte) 0; | 3293 | cAgent.GodLevel = (byte) 0; |
3276 | 3294 | ||
@@ -3337,11 +3355,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3337 | 3355 | ||
3338 | public void CopyFrom(AgentData cAgent) | 3356 | public void CopyFrom(AgentData cAgent) |
3339 | { | 3357 | { |
3340 | m_rootRegionHandle = cAgent.RegionHandle; | 3358 | m_originRegionID = cAgent.RegionID; |
3341 | 3359 | ||
3342 | m_callbackURI = cAgent.CallbackURI; | 3360 | m_callbackURI = cAgent.CallbackURI; |
3343 | 3361 | ||
3344 | m_pos = cAgent.Position; | 3362 | m_pos = cAgent.Position; |
3363 | |||
3345 | m_velocity = cAgent.Velocity; | 3364 | m_velocity = cAgent.Velocity; |
3346 | m_CameraCenter = cAgent.Center; | 3365 | m_CameraCenter = cAgent.Center; |
3347 | //m_avHeight = cAgent.Size.Z; | 3366 | //m_avHeight = cAgent.Size.Z; |
@@ -3359,7 +3378,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3359 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; | 3378 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; |
3360 | 3379 | ||
3361 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3380 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3362 | m_godlevel = cAgent.GodLevel; | 3381 | m_godLevel = cAgent.GodLevel; |
3363 | m_setAlwaysRun = cAgent.AlwaysRun; | 3382 | m_setAlwaysRun = cAgent.AlwaysRun; |
3364 | 3383 | ||
3365 | uint i = 0; | 3384 | uint i = 0; |
@@ -3717,36 +3736,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3717 | } | 3736 | } |
3718 | } | 3737 | } |
3719 | 3738 | ||
3720 | public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent) | ||
3721 | { | ||
3722 | lock (m_attachments) | ||
3723 | { | ||
3724 | // Validate | ||
3725 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3726 | { | ||
3727 | if (gobj == null || gobj.IsDeleted) | ||
3728 | return false; | ||
3729 | } | ||
3730 | |||
3731 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3732 | { | ||
3733 | // If the prim group is null then something must have happened to it! | ||
3734 | if (gobj != null && gobj.RootPart != null) | ||
3735 | { | ||
3736 | // Set the parent localID to 0 so it transfers over properly. | ||
3737 | gobj.RootPart.SetParentLocalId(0); | ||
3738 | gobj.AbsolutePosition = gobj.RootPart.AttachedPos; | ||
3739 | gobj.RootPart.IsAttachment = false; | ||
3740 | //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); | ||
3741 | m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle); | ||
3742 | m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent); | ||
3743 | } | ||
3744 | } | ||
3745 | m_attachments.Clear(); | ||
3746 | |||
3747 | return true; | ||
3748 | } | ||
3749 | } | ||
3750 | 3739 | ||
3751 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) | 3740 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) |
3752 | { | 3741 | { |
@@ -3982,10 +3971,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
3982 | { | 3971 | { |
3983 | if (null == m_appearance) | 3972 | if (null == m_appearance) |
3984 | { | 3973 | { |
3985 | m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID); | 3974 | m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); |
3986 | return; | 3975 | return; |
3987 | } | 3976 | } |
3988 | 3977 | ||
3978 | XmlDocument doc = new XmlDocument(); | ||
3979 | string stateData = String.Empty; | ||
3980 | |||
3981 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
3982 | if (attServ != null) | ||
3983 | { | ||
3984 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
3985 | stateData = attServ.Get(ControllingClient.AgentId.ToString()); | ||
3986 | doc.LoadXml(stateData); | ||
3987 | } | ||
3988 | |||
3989 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
3990 | |||
3991 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
3992 | if (nodes.Count > 0) | ||
3993 | { | ||
3994 | foreach (XmlNode n in nodes) | ||
3995 | { | ||
3996 | XmlElement elem = (XmlElement)n; | ||
3997 | string itemID = elem.GetAttribute("ItemID"); | ||
3998 | string xml = elem.InnerXml; | ||
3999 | |||
4000 | itemData[new UUID(itemID)] = xml; | ||
4001 | } | ||
4002 | } | ||
4003 | |||
3989 | List<int> attPoints = m_appearance.GetAttachedPoints(); | 4004 | List<int> attPoints = m_appearance.GetAttachedPoints(); |
3990 | foreach (int p in attPoints) | 4005 | foreach (int p in attPoints) |
3991 | { | 4006 | { |
@@ -4005,13 +4020,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
4005 | 4020 | ||
4006 | try | 4021 | try |
4007 | { | 4022 | { |
4008 | // Rez from inventory | 4023 | string xmlData; |
4009 | UUID asset = m_scene.RezSingleAttachment(ControllingClient, | 4024 | XmlDocument d = new XmlDocument(); |
4010 | itemID, (uint)p); | 4025 | UUID asset; |
4026 | if (itemData.TryGetValue(itemID, out xmlData)) | ||
4027 | { | ||
4028 | d.LoadXml(xmlData); | ||
4029 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); | ||
4030 | |||
4031 | // Rez from inventory | ||
4032 | asset | ||
4033 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); | ||
4011 | 4034 | ||
4012 | m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | 4035 | } |
4013 | p, itemID, assetID, asset); | 4036 | else |
4037 | { | ||
4038 | // Rez from inventory (with a null doc to let | ||
4039 | // CHANGED_OWNER happen) | ||
4040 | asset | ||
4041 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); | ||
4042 | } | ||
4014 | 4043 | ||
4044 | m_log.InfoFormat( | ||
4045 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | ||
4046 | p, itemID, assetID, asset); | ||
4015 | } | 4047 | } |
4016 | catch (Exception e) | 4048 | catch (Exception e) |
4017 | { | 4049 | { |
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; | |||
31 | using log4net; | 31 | using log4net; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Client; | 33 | using OpenSim.Framework.Client; |
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes.Types; | 35 | using OpenSim.Region.Framework.Scenes.Types; |
37 | 36 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index cf0f345..b6677f0 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs | |||
@@ -182,6 +182,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
182 | foreach (SceneObjectGroup sceneObject in sceneObjects) | 182 | foreach (SceneObjectGroup sceneObject in sceneObjects) |
183 | { | 183 | { |
184 | sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine, 0); | 184 | sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine, 0); |
185 | sceneObject.ResumeScripts(); | ||
185 | } | 186 | } |
186 | } | 187 | } |
187 | 188 | ||
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; | |||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | |
36 | using OpenSim.Region.Communications.Local; | ||
37 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Tests.Common; | 37 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 38 | using 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; | |||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | |
36 | using OpenSim.Region.Communications.Local; | ||
37 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Tests.Common; | 37 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 38 | using 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; | |||
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; | ||
44 | using OpenSim.Region.CoreModules.World.Serialiser; | 43 | using OpenSim.Region.CoreModules.World.Serialiser; |
44 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
45 | using OpenSim.Tests.Common; | 45 | using OpenSim.Tests.Common; |
46 | using OpenSim.Tests.Common.Mock; | 46 | using OpenSim.Tests.Common.Mock; |
47 | using OpenSim.Tests.Common.Setup; | 47 | using 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; | |||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; | 37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
38 | using OpenSim.Tests.Common; | 38 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 39 | using OpenSim.Tests.Common.Mock; |
40 | using OpenSim.Tests.Common.Setup; | 40 | using 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 | } |