diff options
author | UbitUmarov | 2014-08-04 21:52:29 +0100 |
---|---|---|
committer | UbitUmarov | 2014-08-04 21:52:29 +0100 |
commit | 3cca5ec6674b413a419d3f1c42467e57fb883f56 (patch) | |
tree | 8b68df5055f7cd518fa0a634ae3c17f763b6361c /OpenSim/Region | |
parent | Revert "start sending terrain in scenePresence after well defined avatar. Minor" (diff) | |
download | opensim-SC-3cca5ec6674b413a419d3f1c42467e57fb883f56.zip opensim-SC-3cca5ec6674b413a419d3f1c42467e57fb883f56.tar.gz opensim-SC-3cca5ec6674b413a419d3f1c42467e57fb883f56.tar.bz2 opensim-SC-3cca5ec6674b413a419d3f1c42467e57fb883f56.tar.xz |
check...
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 34 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneBase.cs | 1160 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 |
3 files changed, 598 insertions, 606 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index b7c8594..a3fdae1 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -1750,25 +1750,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1750 | endPoint, | 1750 | endPoint, |
1751 | sessionInfo); | 1751 | sessionInfo); |
1752 | 1752 | ||
1753 | // Send ack straight away to let the viewer know that the connection is active. | ||
1754 | // The client will be null if it already exists (e.g. if on a region crossing the client sends a use | ||
1755 | // circuit code to the existing child agent. This is not particularly obvious. | ||
1756 | SendAckImmediate(endPoint, uccp.Header.Sequence); | ||
1757 | |||
1758 | // We only want to send initial data to new clients, not ones which are being converted from child to root. | ||
1759 | if (client != null) | ||
1760 | { | ||
1761 | AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(uccp.CircuitCode.Code); | ||
1762 | bool tp = (aCircuit.teleportFlags > 0); | ||
1763 | // Let's delay this for TP agents, otherwise the viewer doesn't know where to get resources from | ||
1764 | if (!tp) | ||
1765 | client.SceneAgent.SendInitialDataToMe(); | ||
1766 | } | ||
1767 | |||
1768 | // Now we know we can handle more data | 1753 | // Now we know we can handle more data |
1769 | Thread.Sleep(200); | 1754 | // Thread.Sleep(200); |
1770 | 1755 | ||
1771 | // Obtain the queue and remove it from the cache | 1756 | // Obtain the pending queue and remove it from the cache |
1772 | Queue<UDPPacketBuffer> queue = null; | 1757 | Queue<UDPPacketBuffer> queue = null; |
1773 | 1758 | ||
1774 | lock (m_pendingCache) | 1759 | lock (m_pendingCache) |
@@ -1790,6 +1775,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1790 | PacketReceived(buf); | 1775 | PacketReceived(buf); |
1791 | } | 1776 | } |
1792 | queue = null; | 1777 | queue = null; |
1778 | |||
1779 | // Send ack straight away to let the viewer know that the connection is active. | ||
1780 | // The client will be null if it already exists (e.g. if on a region crossing the client sends a use | ||
1781 | // circuit code to the existing child agent. This is not particularly obvious. | ||
1782 | SendAckImmediate(endPoint, uccp.Header.Sequence); | ||
1783 | |||
1784 | // We only want to send initial data to new clients, not ones which are being converted from child to root. | ||
1785 | if (client != null) | ||
1786 | { | ||
1787 | AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(uccp.CircuitCode.Code); | ||
1788 | bool tp = (aCircuit.teleportFlags > 0); | ||
1789 | // Let's delay this for TP agents, otherwise the viewer doesn't know where to get resources from | ||
1790 | if (!tp) | ||
1791 | client.SceneAgent.SendInitialDataToMe(); | ||
1792 | } | ||
1793 | } | 1793 | } |
1794 | else | 1794 | else |
1795 | { | 1795 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 08e26c5..dd0c828 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -1,581 +1,581 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Threading; | 31 | using System.Threading; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using log4net; | 33 | 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 | 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 | ||
41 | namespace OpenSim.Region.Framework.Scenes | 41 | namespace OpenSim.Region.Framework.Scenes |
42 | { | 42 | { |
43 | public abstract class SceneBase : IScene | 43 | public abstract class SceneBase : IScene |
44 | { | 44 | { |
45 | protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | protected static readonly string LogHeader = "[SCENE]"; | 46 | protected static readonly string LogHeader = "[SCENE]"; |
47 | 47 | ||
48 | #region Events | 48 | #region Events |
49 | 49 | ||
50 | public event restart OnRestart; | 50 | public event restart OnRestart; |
51 | 51 | ||
52 | #endregion | 52 | #endregion |
53 | 53 | ||
54 | #region Fields | 54 | #region Fields |
55 | 55 | ||
56 | public string Name { get { return RegionInfo.RegionName; } } | 56 | public string Name { get { return RegionInfo.RegionName; } } |
57 | 57 | ||
58 | public IConfigSource Config | 58 | public IConfigSource Config |
59 | { | 59 | { |
60 | get { return GetConfig(); } | 60 | get { return GetConfig(); } |
61 | } | 61 | } |
62 | 62 | ||
63 | protected virtual IConfigSource GetConfig() | 63 | protected virtual IConfigSource GetConfig() |
64 | { | 64 | { |
65 | return null; | 65 | return null; |
66 | } | 66 | } |
67 | 67 | ||
68 | /// <value> | 68 | /// <value> |
69 | /// All the region modules attached to this scene. | 69 | /// All the region modules attached to this scene. |
70 | /// </value> | 70 | /// </value> |
71 | public Dictionary<string, IRegionModuleBase> RegionModules | 71 | public Dictionary<string, IRegionModuleBase> RegionModules |
72 | { | 72 | { |
73 | get { return m_regionModules; } | 73 | get { return m_regionModules; } |
74 | } | 74 | } |
75 | private Dictionary<string, IRegionModuleBase> m_regionModules = new Dictionary<string, IRegionModuleBase>(); | 75 | private Dictionary<string, IRegionModuleBase> m_regionModules = new Dictionary<string, IRegionModuleBase>(); |
76 | 76 | ||
77 | /// <value> | 77 | /// <value> |
78 | /// The module interfaces available from this scene. | 78 | /// The module interfaces available from this scene. |
79 | /// </value> | 79 | /// </value> |
80 | protected Dictionary<Type, List<object>> ModuleInterfaces = new Dictionary<Type, List<object>>(); | 80 | protected Dictionary<Type, List<object>> ModuleInterfaces = new Dictionary<Type, List<object>>(); |
81 | 81 | ||
82 | protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>(); | 82 | protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>(); |
83 | 83 | ||
84 | /// <value> | 84 | /// <value> |
85 | /// The module commanders available from this scene | 85 | /// The module commanders available from this scene |
86 | /// </value> | 86 | /// </value> |
87 | protected Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>(); | 87 | protected Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>(); |
88 | 88 | ||
89 | /// <value> | 89 | /// <value> |
90 | /// Registered classes that are capable of creating entities. | 90 | /// Registered classes that are capable of creating entities. |
91 | /// </value> | 91 | /// </value> |
92 | protected Dictionary<PCode, IEntityCreator> m_entityCreators = new Dictionary<PCode, IEntityCreator>(); | 92 | protected Dictionary<PCode, IEntityCreator> m_entityCreators = new Dictionary<PCode, IEntityCreator>(); |
93 | 93 | ||
94 | /// <summary> | 94 | /// <summary> |
95 | /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is | 95 | /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is |
96 | /// dispensed. | 96 | /// dispensed. |
97 | /// </summary> | 97 | /// </summary> |
98 | protected uint m_lastAllocatedLocalId = 720000; | 98 | protected uint m_lastAllocatedLocalId = 720000; |
99 | 99 | ||
100 | private readonly Mutex _primAllocateMutex = new Mutex(false); | 100 | private readonly Mutex _primAllocateMutex = new Mutex(false); |
101 | 101 | ||
102 | protected readonly ClientManager m_clientManager = new ClientManager(); | 102 | protected readonly ClientManager m_clientManager = new ClientManager(); |
103 | 103 | ||
104 | public bool LoginsEnabled | 104 | public bool LoginsEnabled |
105 | { | 105 | { |
106 | get | 106 | get |
107 | { | 107 | { |
108 | return m_loginsEnabled; | 108 | return m_loginsEnabled; |
109 | } | 109 | } |
110 | 110 | ||
111 | set | 111 | set |
112 | { | 112 | { |
113 | if (m_loginsEnabled != value) | 113 | if (m_loginsEnabled != value) |
114 | { | 114 | { |
115 | m_loginsEnabled = value; | 115 | m_loginsEnabled = value; |
116 | EventManager.TriggerRegionLoginsStatusChange(this); | 116 | EventManager.TriggerRegionLoginsStatusChange(this); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | private bool m_loginsEnabled; | 120 | private bool m_loginsEnabled; |
121 | 121 | ||
122 | public bool Ready | 122 | public bool Ready |
123 | { | 123 | { |
124 | get | 124 | get |
125 | { | 125 | { |
126 | return m_ready; | 126 | return m_ready; |
127 | } | 127 | } |
128 | 128 | ||
129 | set | 129 | set |
130 | { | 130 | { |
131 | if (m_ready != value) | 131 | if (m_ready != value) |
132 | { | 132 | { |
133 | m_ready = value; | 133 | m_ready = value; |
134 | EventManager.TriggerRegionReadyStatusChange(this); | 134 | EventManager.TriggerRegionReadyStatusChange(this); |
135 | } | 135 | } |
136 | } | 136 | } |
137 | } | 137 | } |
138 | private bool m_ready; | 138 | private bool m_ready; |
139 | 139 | ||
140 | public float TimeDilation | 140 | public float TimeDilation |
141 | { | 141 | { |
142 | get { return 1.0f; } | 142 | get { return 1.0f; } |
143 | } | 143 | } |
144 | 144 | ||
145 | protected ulong m_regionHandle; | 145 | protected ulong m_regionHandle; |
146 | protected string m_regionName; | 146 | protected string m_regionName; |
147 | 147 | ||
148 | public ITerrainChannel Heightmap; | 148 | public ITerrainChannel Heightmap; |
149 | 149 | ||
150 | /// <value> | 150 | /// <value> |
151 | /// Allows retrieval of land information for this scene. | 151 | /// Allows retrieval of land information for this scene. |
152 | /// </value> | 152 | /// </value> |
153 | public ILandChannel LandChannel; | 153 | public ILandChannel LandChannel; |
154 | 154 | ||
155 | /// <value> | 155 | /// <value> |
156 | /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules | 156 | /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules |
157 | /// to subscribe to scene events. | 157 | /// to subscribe to scene events. |
158 | /// </value> | 158 | /// </value> |
159 | public EventManager EventManager | 159 | public EventManager EventManager |
160 | { | 160 | { |
161 | get { return m_eventManager; } | 161 | get { return m_eventManager; } |
162 | } | 162 | } |
163 | protected EventManager m_eventManager; | 163 | protected EventManager m_eventManager; |
164 | 164 | ||
165 | protected ScenePermissions m_permissions; | 165 | protected ScenePermissions m_permissions; |
166 | public ScenePermissions Permissions | 166 | public ScenePermissions Permissions |
167 | { | 167 | { |
168 | get { return m_permissions; } | 168 | get { return m_permissions; } |
169 | } | 169 | } |
170 | 170 | ||
171 | protected string m_datastore; | 171 | protected string m_datastore; |
172 | 172 | ||
173 | /* Used by the loadbalancer plugin on GForge */ | 173 | /* Used by the loadbalancer plugin on GForge */ |
174 | protected RegionStatus m_regStatus; | 174 | protected RegionStatus m_regStatus; |
175 | public RegionStatus RegionStatus | 175 | public RegionStatus RegionStatus |
176 | { | 176 | { |
177 | get { return m_regStatus; } | 177 | get { return m_regStatus; } |
178 | set { m_regStatus = value; } | 178 | set { m_regStatus = value; } |
179 | } | 179 | } |
180 | 180 | ||
181 | #endregion | 181 | #endregion |
182 | 182 | ||
183 | public SceneBase(RegionInfo regInfo) | 183 | public SceneBase(RegionInfo regInfo) |
184 | { | 184 | { |
185 | RegionInfo = regInfo; | 185 | RegionInfo = regInfo; |
186 | } | 186 | } |
187 | 187 | ||
188 | #region Update Methods | 188 | #region Update Methods |
189 | 189 | ||
190 | /// <summary> | 190 | /// <summary> |
191 | /// Called to update the scene loop by a number of frames and until shutdown. | 191 | /// Called to update the scene loop by a number of frames and until shutdown. |
192 | /// </summary> | 192 | /// </summary> |
193 | /// <param name="frames"> | 193 | /// <param name="frames"> |
194 | /// Number of frames to update. Exits on shutdown even if there are frames remaining. | 194 | /// Number of frames to update. Exits on shutdown even if there are frames remaining. |
195 | /// If -1 then updates until shutdown. | 195 | /// If -1 then updates until shutdown. |
196 | /// </param> | 196 | /// </param> |
197 | public abstract void Update(int frames); | 197 | public abstract void Update(int frames); |
198 | 198 | ||
199 | #endregion | 199 | #endregion |
200 | 200 | ||
201 | #region Terrain Methods | 201 | #region Terrain Methods |
202 | 202 | ||
203 | /// <summary> | 203 | /// <summary> |
204 | /// Loads the World heightmap | 204 | /// Loads the World heightmap |
205 | /// </summary> | 205 | /// </summary> |
206 | public abstract void LoadWorldMap(); | 206 | public abstract void LoadWorldMap(); |
207 | 207 | ||
208 | /// <summary> | 208 | /// <summary> |
209 | /// Send the region heightmap to the client | 209 | /// Send the region heightmap to the client |
210 | /// </summary> | 210 | /// </summary> |
211 | /// <param name="RemoteClient">Client to send to</param> | 211 | /// <param name="RemoteClient">Client to send to</param> |
212 | public virtual void SendLayerData(IClientAPI RemoteClient) | 212 | public virtual void SendLayerData(IClientAPI RemoteClient) |
213 | { | 213 | { |
214 | RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); | 214 | RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); |
215 | } | 215 | } |
216 | 216 | ||
217 | #endregion | 217 | #endregion |
218 | 218 | ||
219 | #region Add/Remove Agent/Avatar | 219 | #region Add/Remove Agent/Avatar |
220 | 220 | ||
221 | public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type); | 221 | public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type); |
222 | 222 | ||
223 | public abstract bool CloseAgent(UUID agentID, bool force); | 223 | public abstract bool CloseAgent(UUID agentID, bool force); |
224 | 224 | ||
225 | public bool TryGetScenePresence(UUID agentID, out object scenePresence) | 225 | public bool TryGetScenePresence(UUID agentID, out object scenePresence) |
226 | { | 226 | { |
227 | scenePresence = null; | 227 | scenePresence = null; |
228 | ScenePresence sp = null; | 228 | ScenePresence sp = null; |
229 | if (TryGetScenePresence(agentID, out sp)) | 229 | if (TryGetScenePresence(agentID, out sp)) |
230 | { | 230 | { |
231 | scenePresence = sp; | 231 | scenePresence = sp; |
232 | return true; | 232 | return true; |
233 | } | 233 | } |
234 | 234 | ||
235 | return false; | 235 | return false; |
236 | } | 236 | } |
237 | 237 | ||
238 | /// <summary> | 238 | /// <summary> |
239 | /// Try to get a scene presence from the scene | 239 | /// Try to get a scene presence from the scene |
240 | /// </summary> | 240 | /// </summary> |
241 | /// <param name="agentID"></param> | 241 | /// <param name="agentID"></param> |
242 | /// <param name="scenePresence">null if there is no scene presence with the given agent id</param> | 242 | /// <param name="scenePresence">null if there is no scene presence with the given agent id</param> |
243 | /// <returns>true if there was a scene presence with the given id, false otherwise.</returns> | 243 | /// <returns>true if there was a scene presence with the given id, false otherwise.</returns> |
244 | public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); | 244 | public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); |
245 | 245 | ||
246 | #endregion | 246 | #endregion |
247 | 247 | ||
248 | /// <summary> | 248 | /// <summary> |
249 | /// | 249 | /// |
250 | /// </summary> | 250 | /// </summary> |
251 | /// <returns></returns> | 251 | /// <returns></returns> |
252 | public virtual RegionInfo RegionInfo { get; private set; } | 252 | public virtual RegionInfo RegionInfo { get; private set; } |
253 | 253 | ||
254 | #region admin stuff | 254 | #region admin stuff |
255 | 255 | ||
256 | public abstract void OtherRegionUp(GridRegion otherRegion); | 256 | public abstract void OtherRegionUp(GridRegion otherRegion); |
257 | 257 | ||
258 | public virtual string GetSimulatorVersion() | 258 | public virtual string GetSimulatorVersion() |
259 | { | 259 | { |
260 | return "OpenSimulator Server"; | 260 | return "OpenSimulator Server"; |
261 | } | 261 | } |
262 | 262 | ||
263 | #endregion | 263 | #endregion |
264 | 264 | ||
265 | #region Shutdown | 265 | #region Shutdown |
266 | 266 | ||
267 | /// <summary> | 267 | /// <summary> |
268 | /// Tidy before shutdown | 268 | /// Tidy before shutdown |
269 | /// </summary> | 269 | /// </summary> |
270 | public virtual void Close() | 270 | public virtual void Close() |
271 | { | 271 | { |
272 | try | 272 | try |
273 | { | 273 | { |
274 | EventManager.TriggerShutdown(); | 274 | EventManager.TriggerShutdown(); |
275 | } | 275 | } |
276 | catch (Exception e) | 276 | catch (Exception e) |
277 | { | 277 | { |
278 | m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); | 278 | m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | #endregion | 282 | #endregion |
283 | 283 | ||
284 | /// <summary> | 284 | /// <summary> |
285 | /// Returns a new unallocated local ID | 285 | /// Returns a new unallocated local ID |
286 | /// </summary> | 286 | /// </summary> |
287 | /// <returns>A brand new local ID</returns> | 287 | /// <returns>A brand new local ID</returns> |
288 | public uint AllocateLocalId() | 288 | public uint AllocateLocalId() |
289 | { | 289 | { |
290 | uint myID; | 290 | uint myID; |
291 | 291 | ||
292 | _primAllocateMutex.WaitOne(); | 292 | _primAllocateMutex.WaitOne(); |
293 | myID = ++m_lastAllocatedLocalId; | 293 | myID = ++m_lastAllocatedLocalId; |
294 | _primAllocateMutex.ReleaseMutex(); | 294 | _primAllocateMutex.ReleaseMutex(); |
295 | 295 | ||
296 | return myID; | 296 | return myID; |
297 | } | 297 | } |
298 | 298 | ||
299 | #region Module Methods | 299 | #region Module Methods |
300 | 300 | ||
301 | /// <summary> | 301 | /// <summary> |
302 | /// Add a region-module to this scene. TODO: This will replace AddModule in the future. | 302 | /// Add a region-module to this scene. TODO: This will replace AddModule in the future. |
303 | /// </summary> | 303 | /// </summary> |
304 | /// <param name="name"></param> | 304 | /// <param name="name"></param> |
305 | /// <param name="module"></param> | 305 | /// <param name="module"></param> |
306 | public void AddRegionModule(string name, IRegionModuleBase module) | 306 | public void AddRegionModule(string name, IRegionModuleBase module) |
307 | { | 307 | { |
308 | if (!RegionModules.ContainsKey(name)) | 308 | if (!RegionModules.ContainsKey(name)) |
309 | { | 309 | { |
310 | RegionModules.Add(name, module); | 310 | RegionModules.Add(name, module); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | public void RemoveRegionModule(string name) | 314 | public void RemoveRegionModule(string name) |
315 | { | 315 | { |
316 | RegionModules.Remove(name); | 316 | RegionModules.Remove(name); |
317 | } | 317 | } |
318 | 318 | ||
319 | /// <summary> | 319 | /// <summary> |
320 | /// Register a module commander. | 320 | /// Register a module commander. |
321 | /// </summary> | 321 | /// </summary> |
322 | /// <param name="commander"></param> | 322 | /// <param name="commander"></param> |
323 | public void RegisterModuleCommander(ICommander commander) | 323 | public void RegisterModuleCommander(ICommander commander) |
324 | { | 324 | { |
325 | lock (m_moduleCommanders) | 325 | lock (m_moduleCommanders) |
326 | { | 326 | { |
327 | m_moduleCommanders.Add(commander.Name, commander); | 327 | m_moduleCommanders.Add(commander.Name, commander); |
328 | } | 328 | } |
329 | } | 329 | } |
330 | 330 | ||
331 | /// <summary> | 331 | /// <summary> |
332 | /// Unregister a module commander and all its commands | 332 | /// Unregister a module commander and all its commands |
333 | /// </summary> | 333 | /// </summary> |
334 | /// <param name="name"></param> | 334 | /// <param name="name"></param> |
335 | public void UnregisterModuleCommander(string name) | 335 | public void UnregisterModuleCommander(string name) |
336 | { | 336 | { |
337 | lock (m_moduleCommanders) | 337 | lock (m_moduleCommanders) |
338 | { | 338 | { |
339 | ICommander commander; | 339 | ICommander commander; |
340 | if (m_moduleCommanders.TryGetValue(name, out commander)) | 340 | if (m_moduleCommanders.TryGetValue(name, out commander)) |
341 | m_moduleCommanders.Remove(name); | 341 | m_moduleCommanders.Remove(name); |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | /// <summary> | 345 | /// <summary> |
346 | /// Get a module commander | 346 | /// Get a module commander |
347 | /// </summary> | 347 | /// </summary> |
348 | /// <param name="name"></param> | 348 | /// <param name="name"></param> |
349 | /// <returns>The module commander, null if no module commander with that name was found</returns> | 349 | /// <returns>The module commander, null if no module commander with that name was found</returns> |
350 | public ICommander GetCommander(string name) | 350 | public ICommander GetCommander(string name) |
351 | { | 351 | { |
352 | lock (m_moduleCommanders) | 352 | lock (m_moduleCommanders) |
353 | { | 353 | { |
354 | if (m_moduleCommanders.ContainsKey(name)) | 354 | if (m_moduleCommanders.ContainsKey(name)) |
355 | return m_moduleCommanders[name]; | 355 | return m_moduleCommanders[name]; |
356 | } | 356 | } |
357 | 357 | ||
358 | return null; | 358 | return null; |
359 | } | 359 | } |
360 | 360 | ||
361 | public Dictionary<string, ICommander> GetCommanders() | 361 | public Dictionary<string, ICommander> GetCommanders() |
362 | { | 362 | { |
363 | return m_moduleCommanders; | 363 | return m_moduleCommanders; |
364 | } | 364 | } |
365 | 365 | ||
366 | /// <summary> | 366 | /// <summary> |
367 | /// Register an interface to a region module. This allows module methods to be called directly as | 367 | /// Register an interface to a region module. This allows module methods to be called directly as |
368 | /// well as via events. If there is already a module registered for this interface, it is not replaced | 368 | /// well as via events. If there is already a module registered for this interface, it is not replaced |
369 | /// (is this the best behaviour?) | 369 | /// (is this the best behaviour?) |
370 | /// </summary> | 370 | /// </summary> |
371 | /// <param name="mod"></param> | 371 | /// <param name="mod"></param> |
372 | public void RegisterModuleInterface<M>(M mod) | 372 | public void RegisterModuleInterface<M>(M mod) |
373 | { | 373 | { |
374 | // m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); | 374 | // m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); |
375 | 375 | ||
376 | List<Object> l = null; | 376 | List<Object> l = null; |
377 | if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) | 377 | if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) |
378 | { | 378 | { |
379 | l = new List<Object>(); | 379 | l = new List<Object>(); |
380 | ModuleInterfaces.Add(typeof(M), l); | 380 | ModuleInterfaces.Add(typeof(M), l); |
381 | } | 381 | } |
382 | 382 | ||
383 | if (l.Count > 0) | 383 | if (l.Count > 0) |
384 | return; | 384 | return; |
385 | 385 | ||
386 | l.Add(mod); | 386 | l.Add(mod); |
387 | 387 | ||
388 | if (mod is IEntityCreator) | 388 | if (mod is IEntityCreator) |
389 | { | 389 | { |
390 | IEntityCreator entityCreator = (IEntityCreator)mod; | 390 | IEntityCreator entityCreator = (IEntityCreator)mod; |
391 | foreach (PCode pcode in entityCreator.CreationCapabilities) | 391 | foreach (PCode pcode in entityCreator.CreationCapabilities) |
392 | { | 392 | { |
393 | m_entityCreators[pcode] = entityCreator; | 393 | m_entityCreators[pcode] = entityCreator; |
394 | } | 394 | } |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | public void UnregisterModuleInterface<M>(M mod) | 398 | public void UnregisterModuleInterface<M>(M mod) |
399 | { | 399 | { |
400 | List<Object> l; | 400 | List<Object> l; |
401 | if (ModuleInterfaces.TryGetValue(typeof(M), out l)) | 401 | if (ModuleInterfaces.TryGetValue(typeof(M), out l)) |
402 | { | 402 | { |
403 | if (l.Remove(mod)) | 403 | if (l.Remove(mod)) |
404 | { | 404 | { |
405 | if (mod is IEntityCreator) | 405 | if (mod is IEntityCreator) |
406 | { | 406 | { |
407 | IEntityCreator entityCreator = (IEntityCreator)mod; | 407 | IEntityCreator entityCreator = (IEntityCreator)mod; |
408 | foreach (PCode pcode in entityCreator.CreationCapabilities) | 408 | foreach (PCode pcode in entityCreator.CreationCapabilities) |
409 | { | 409 | { |
410 | m_entityCreators[pcode] = null; | 410 | m_entityCreators[pcode] = null; |
411 | } | 411 | } |
412 | } | 412 | } |
413 | } | 413 | } |
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | public void StackModuleInterface<M>(M mod) | 417 | public void StackModuleInterface<M>(M mod) |
418 | { | 418 | { |
419 | List<Object> l; | 419 | List<Object> l; |
420 | if (ModuleInterfaces.ContainsKey(typeof(M))) | 420 | if (ModuleInterfaces.ContainsKey(typeof(M))) |
421 | l = ModuleInterfaces[typeof(M)]; | 421 | l = ModuleInterfaces[typeof(M)]; |
422 | else | 422 | else |
423 | l = new List<Object>(); | 423 | l = new List<Object>(); |
424 | 424 | ||
425 | if (l.Contains(mod)) | 425 | if (l.Contains(mod)) |
426 | return; | 426 | return; |
427 | 427 | ||
428 | l.Add(mod); | 428 | l.Add(mod); |
429 | 429 | ||
430 | if (mod is IEntityCreator) | 430 | if (mod is IEntityCreator) |
431 | { | 431 | { |
432 | IEntityCreator entityCreator = (IEntityCreator)mod; | 432 | IEntityCreator entityCreator = (IEntityCreator)mod; |
433 | foreach (PCode pcode in entityCreator.CreationCapabilities) | 433 | foreach (PCode pcode in entityCreator.CreationCapabilities) |
434 | { | 434 | { |
435 | m_entityCreators[pcode] = entityCreator; | 435 | m_entityCreators[pcode] = entityCreator; |
436 | } | 436 | } |
437 | } | 437 | } |
438 | 438 | ||
439 | ModuleInterfaces[typeof(M)] = l; | 439 | ModuleInterfaces[typeof(M)] = l; |
440 | } | 440 | } |
441 | 441 | ||
442 | /// <summary> | 442 | /// <summary> |
443 | /// For the given interface, retrieve the region module which implements it. | 443 | /// For the given interface, retrieve the region module which implements it. |
444 | /// </summary> | 444 | /// </summary> |
445 | /// <returns>null if there is no registered module implementing that interface</returns> | 445 | /// <returns>null if there is no registered module implementing that interface</returns> |
446 | public T RequestModuleInterface<T>() | 446 | public T RequestModuleInterface<T>() |
447 | { | 447 | { |
448 | if (ModuleInterfaces.ContainsKey(typeof(T)) && | 448 | if (ModuleInterfaces.ContainsKey(typeof(T)) && |
449 | (ModuleInterfaces[typeof(T)].Count > 0)) | 449 | (ModuleInterfaces[typeof(T)].Count > 0)) |
450 | return (T)ModuleInterfaces[typeof(T)][0]; | 450 | return (T)ModuleInterfaces[typeof(T)][0]; |
451 | else | 451 | else |
452 | return default(T); | 452 | return default(T); |
453 | } | 453 | } |
454 | 454 | ||
455 | /// <summary> | 455 | /// <summary> |
456 | /// For the given interface, retrieve an array of region modules that implement it. | 456 | /// For the given interface, retrieve an array of region modules that implement it. |
457 | /// </summary> | 457 | /// </summary> |
458 | /// <returns>an empty array if there are no registered modules implementing that interface</returns> | 458 | /// <returns>an empty array if there are no registered modules implementing that interface</returns> |
459 | public T[] RequestModuleInterfaces<T>() | 459 | public T[] RequestModuleInterfaces<T>() |
460 | { | 460 | { |
461 | if (ModuleInterfaces.ContainsKey(typeof(T))) | 461 | if (ModuleInterfaces.ContainsKey(typeof(T))) |
462 | { | 462 | { |
463 | List<T> ret = new List<T>(); | 463 | List<T> ret = new List<T>(); |
464 | 464 | ||
465 | foreach (Object o in ModuleInterfaces[typeof(T)]) | 465 | foreach (Object o in ModuleInterfaces[typeof(T)]) |
466 | ret.Add((T)o); | 466 | ret.Add((T)o); |
467 | return ret.ToArray(); | 467 | return ret.ToArray(); |
468 | } | 468 | } |
469 | else | 469 | else |
470 | { | 470 | { |
471 | return new T[] {}; | 471 | return new T[] {}; |
472 | } | 472 | } |
473 | } | 473 | } |
474 | 474 | ||
475 | #endregion | 475 | #endregion |
476 | 476 | ||
477 | /// <summary> | 477 | /// <summary> |
478 | /// Call this from a region module to add a command to the OpenSim console. | 478 | /// Call this from a region module to add a command to the OpenSim console. |
479 | /// </summary> | 479 | /// </summary> |
480 | /// <param name="mod"></param> | 480 | /// <param name="mod"></param> |
481 | /// <param name="command"></param> | 481 | /// <param name="command"></param> |
482 | /// <param name="shorthelp"></param> | 482 | /// <param name="shorthelp"></param> |
483 | /// <param name="longhelp"></param> | 483 | /// <param name="longhelp"></param> |
484 | /// <param name="callback"></param> | 484 | /// <param name="callback"></param> |
485 | public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) | 485 | public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) |
486 | { | 486 | { |
487 | AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); | 487 | AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); |
488 | } | 488 | } |
489 | 489 | ||
490 | /// <summary> | 490 | /// <summary> |
491 | /// Call this from a region module to add a command to the OpenSim console. | 491 | /// Call this from a region module to add a command to the OpenSim console. |
492 | /// </summary> | 492 | /// </summary> |
493 | /// <param name="mod"> | 493 | /// <param name="mod"> |
494 | /// The use of IRegionModuleBase is a cheap trick to get a different method signature, | 494 | /// The use of IRegionModuleBase is a cheap trick to get a different method signature, |
495 | /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. | 495 | /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. |
496 | /// </param> | 496 | /// </param> |
497 | /// <param name="category"> | 497 | /// <param name="category"> |
498 | /// Category of the command. This is the section under which it will appear when the user asks for help | 498 | /// Category of the command. This is the section under which it will appear when the user asks for help |
499 | /// </param> | 499 | /// </param> |
500 | /// <param name="command"></param> | 500 | /// <param name="command"></param> |
501 | /// <param name="shorthelp"></param> | 501 | /// <param name="shorthelp"></param> |
502 | /// <param name="longhelp"></param> | 502 | /// <param name="longhelp"></param> |
503 | /// <param name="callback"></param> | 503 | /// <param name="callback"></param> |
504 | public void AddCommand( | 504 | public void AddCommand( |
505 | string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) | 505 | string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) |
506 | { | 506 | { |
507 | AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); | 507 | AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); |
508 | } | 508 | } |
509 | 509 | ||
510 | /// <summary> | 510 | /// <summary> |
511 | /// Call this from a region module to add a command to the OpenSim console. | 511 | /// Call this from a region module to add a command to the OpenSim console. |
512 | /// </summary> | 512 | /// </summary> |
513 | /// <param name="mod"></param> | 513 | /// <param name="mod"></param> |
514 | /// <param name="command"></param> | 514 | /// <param name="command"></param> |
515 | /// <param name="shorthelp"></param> | 515 | /// <param name="shorthelp"></param> |
516 | /// <param name="longhelp"></param> | 516 | /// <param name="longhelp"></param> |
517 | /// <param name="descriptivehelp"></param> | 517 | /// <param name="descriptivehelp"></param> |
518 | /// <param name="callback"></param> | 518 | /// <param name="callback"></param> |
519 | public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) | 519 | public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) |
520 | { | 520 | { |
521 | string moduleName = ""; | 521 | string moduleName = ""; |
522 | 522 | ||
523 | if (module != null) | 523 | if (module != null) |
524 | moduleName = module.Name; | 524 | moduleName = module.Name; |
525 | 525 | ||
526 | AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); | 526 | AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); |
527 | } | 527 | } |
528 | 528 | ||
529 | /// <summary> | 529 | /// <summary> |
530 | /// Call this from a region module to add a command to the OpenSim console. | 530 | /// Call this from a region module to add a command to the OpenSim console. |
531 | /// </summary> | 531 | /// </summary> |
532 | /// <param name="category"> | 532 | /// <param name="category"> |
533 | /// Category of the command. This is the section under which it will appear when the user asks for help | 533 | /// Category of the command. This is the section under which it will appear when the user asks for help |
534 | /// </param> | 534 | /// </param> |
535 | /// <param name="mod"></param> | 535 | /// <param name="mod"></param> |
536 | /// <param name="command"></param> | 536 | /// <param name="command"></param> |
537 | /// <param name="shorthelp"></param> | 537 | /// <param name="shorthelp"></param> |
538 | /// <param name="longhelp"></param> | 538 | /// <param name="longhelp"></param> |
539 | /// <param name="descriptivehelp"></param> | 539 | /// <param name="descriptivehelp"></param> |
540 | /// <param name="callback"></param> | 540 | /// <param name="callback"></param> |
541 | public void AddCommand( | 541 | public void AddCommand( |
542 | string category, IRegionModuleBase module, string command, | 542 | string category, IRegionModuleBase module, string command, |
543 | string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) | 543 | string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) |
544 | { | 544 | { |
545 | if (MainConsole.Instance == null) | 545 | if (MainConsole.Instance == null) |
546 | return; | 546 | return; |
547 | 547 | ||
548 | bool shared = false; | 548 | bool shared = false; |
549 | 549 | ||
550 | if (module != null) | 550 | if (module != null) |
551 | shared = module is ISharedRegionModule; | 551 | shared = module is ISharedRegionModule; |
552 | 552 | ||
553 | MainConsole.Instance.Commands.AddCommand( | 553 | MainConsole.Instance.Commands.AddCommand( |
554 | category, shared, command, shorthelp, longhelp, descriptivehelp, callback); | 554 | category, shared, command, shorthelp, longhelp, descriptivehelp, callback); |
555 | } | 555 | } |
556 | 556 | ||
557 | public virtual ISceneObject DeserializeObject(string representation) | 557 | public virtual ISceneObject DeserializeObject(string representation) |
558 | { | 558 | { |
559 | return null; | 559 | return null; |
560 | } | 560 | } |
561 | 561 | ||
562 | public virtual bool AllowScriptCrossings | 562 | public virtual bool AllowScriptCrossings |
563 | { | 563 | { |
564 | get { return false; } | 564 | get { return false; } |
565 | } | 565 | } |
566 | 566 | ||
567 | public virtual void Start() | 567 | public virtual void Start() |
568 | { | 568 | { |
569 | } | 569 | } |
570 | 570 | ||
571 | public void Restart() | 571 | public void Restart() |
572 | { | 572 | { |
573 | // This has to be here to fire the event | 573 | // This has to be here to fire the event |
574 | restart handlerPhysicsCrash = OnRestart; | 574 | restart handlerPhysicsCrash = OnRestart; |
575 | if (handlerPhysicsCrash != null) | 575 | if (handlerPhysicsCrash != null) |
576 | handlerPhysicsCrash(RegionInfo); | 576 | handlerPhysicsCrash(RegionInfo); |
577 | } | 577 | } |
578 | 578 | ||
579 | public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); | 579 | public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); |
580 | } | 580 | } |
581 | } | 581 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 24a92eb..596feb1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3369,19 +3369,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3369 | 3369 | ||
3370 | public void SendTerseUpdateToAgentClient(ScenePresence p) | 3370 | public void SendTerseUpdateToAgentClient(ScenePresence p) |
3371 | { | 3371 | { |
3372 | // messy checks because a client doesn't know what presence it belongs too | ||
3373 | |||
3374 | IClientAPI remoteClient = p.ControllingClient; | 3372 | IClientAPI remoteClient = p.ControllingClient; |
3375 | if (remoteClient == null) | 3373 | |
3376 | return; | ||
3377 | |||
3378 | if (!remoteClient.IsActive) | ||
3379 | return; | ||
3380 | |||
3381 | if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200) | 3374 | if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200) |
3382 | return; | 3375 | return; |
3383 | 3376 | ||
3384 | |||
3385 | //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); | 3377 | //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); |
3386 | remoteClient.SendEntityUpdate( | 3378 | remoteClient.SendEntityUpdate( |
3387 | this, | 3379 | this, |