diff options
Diffstat (limited to 'OpenSim/Region/Framework')
41 files changed, 1245 insertions, 436 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 32f4eea..8732ec0 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -174,7 +174,17 @@ namespace OpenSim.Region.Framework.Interfaces | |||
174 | /// If no inventory item has that name then an empty list is returned. | 174 | /// If no inventory item has that name then an empty list is returned. |
175 | /// </returns> | 175 | /// </returns> |
176 | List<TaskInventoryItem> GetInventoryItems(string name); | 176 | List<TaskInventoryItem> GetInventoryItems(string name); |
177 | 177 | ||
178 | /// <summary> | ||
179 | /// Get inventory items by type. | ||
180 | /// </summary> | ||
181 | /// <param type="name"></param> | ||
182 | /// <returns> | ||
183 | /// A list of inventory items of that type. | ||
184 | /// If no inventory items of that type then an empty list is returned. | ||
185 | /// </returns> | ||
186 | List<TaskInventoryItem> GetInventoryItems(InventoryType type); | ||
187 | |||
178 | /// <summary> | 188 | /// <summary> |
179 | /// Get the scene object referenced by an inventory item. | 189 | /// Get the scene object referenced by an inventory item. |
180 | /// </summary> | 190 | /// </summary> |
@@ -228,6 +238,16 @@ namespace OpenSim.Region.Framework.Interfaces | |||
228 | bool ContainsScripts(); | 238 | bool ContainsScripts(); |
229 | 239 | ||
230 | /// <summary> | 240 | /// <summary> |
241 | /// Returns the count of scripts contained | ||
242 | /// </summary></returns> | ||
243 | int ScriptCount(); | ||
244 | |||
245 | /// <summary> | ||
246 | /// Returns the count of running scripts contained | ||
247 | /// </summary></returns> | ||
248 | int RunningScriptCount(); | ||
249 | |||
250 | /// <summary> | ||
231 | /// Get the uuids of all items in this inventory | 251 | /// Get the uuids of all items in this inventory |
232 | /// </summary> | 252 | /// </summary> |
233 | /// <returns></returns> | 253 | /// <returns></returns> |
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs index 76f1641..9cd27f9 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs | |||
@@ -39,13 +39,23 @@ namespace OpenSim.Region.Framework.Interfaces | |||
39 | 39 | ||
40 | public interface IEntityTransferModule | 40 | public interface IEntityTransferModule |
41 | { | 41 | { |
42 | void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, | 42 | /// <summary> |
43 | Vector3 lookAt, uint teleportFlags); | 43 | /// Teleport an agent within the same or to a different region. |
44 | /// </summary> | ||
45 | /// <param name='agent'></param> | ||
46 | /// <param name='regionHandle'> | ||
47 | /// The handle of the destination region. If it's the same as the region currently | ||
48 | /// occupied by the agent then the teleport will be within that region. | ||
49 | /// </param> | ||
50 | /// <param name='position'></param> | ||
51 | /// <param name='lookAt'></param> | ||
52 | /// <param name='teleportFlags'></param> | ||
53 | void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags); | ||
44 | 54 | ||
45 | bool TeleportHome(UUID id, IClientAPI client); | 55 | bool TeleportHome(UUID id, IClientAPI client); |
46 | 56 | ||
47 | void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, | 57 | void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, |
48 | Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq); | 58 | Vector3 position, Vector3 lookAt, uint teleportFlags); |
49 | 59 | ||
50 | bool Cross(ScenePresence agent, bool isFlying); | 60 | bool Cross(ScenePresence agent, bool isFlying); |
51 | 61 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs index 72e79ed..ca2ad94 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs | |||
@@ -47,5 +47,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
47 | void sendRegionHandshakeToAll(); | 47 | void sendRegionHandshakeToAll(); |
48 | void TriggerEstateInfoChange(); | 48 | void TriggerEstateInfoChange(); |
49 | void TriggerRegionInfoChange(); | 49 | void TriggerRegionInfoChange(); |
50 | |||
51 | void setEstateTerrainBaseTexture(int level, UUID texture); | ||
52 | void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue); | ||
50 | } | 53 | } |
51 | } | 54 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs new file mode 100644 index 0000000..baac6e8 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Region.Framework.Interfaces | ||
33 | { | ||
34 | public delegate void TakeValueCallback(string s); | ||
35 | |||
36 | public interface IJsonStoreModule | ||
37 | { | ||
38 | bool CreateStore(string value, out UUID result); | ||
39 | bool DestroyStore(UUID storeID); | ||
40 | bool TestPath(UUID storeID, string path, bool useJson); | ||
41 | bool SetValue(UUID storeID, string path, string value, bool useJson); | ||
42 | bool RemoveValue(UUID storeID, string path); | ||
43 | bool GetValue(UUID storeID, string path, bool useJson, out string value); | ||
44 | |||
45 | void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); | ||
46 | void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); | ||
47 | } | ||
48 | } | ||
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index dc3ff89..860483d 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs | |||
@@ -113,9 +113,11 @@ namespace OpenSim.Region.Framework.Interfaces | |||
113 | /// </param> | 113 | /// </param> |
114 | /// <param name="landAtTarget"> | 114 | /// <param name="landAtTarget"> |
115 | /// If true and the avatar is flying when it reaches the target, land. | 115 | /// If true and the avatar is flying when it reaches the target, land. |
116 | /// </param> | 116 | /// </param> name="running"> |
117 | /// If true, NPC moves with running speed. | ||
117 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | 118 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> |
118 | bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget); | 119 | /// |
120 | bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running); | ||
119 | 121 | ||
120 | /// <summary> | 122 | /// <summary> |
121 | /// Stop the NPC's current movement. | 123 | /// Stop the NPC's current movement. |
@@ -135,6 +137,36 @@ namespace OpenSim.Region.Framework.Interfaces | |||
135 | bool Say(UUID agentID, Scene scene, string text); | 137 | bool Say(UUID agentID, Scene scene, string text); |
136 | 138 | ||
137 | /// <summary> | 139 | /// <summary> |
140 | /// Get the NPC to say something. | ||
141 | /// </summary> | ||
142 | /// <param name="agentID">The UUID of the NPC</param> | ||
143 | /// <param name="scene"></param> | ||
144 | /// <param name="text"></param> | ||
145 | /// <param name="channel"></param> | ||
146 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | ||
147 | bool Say(UUID agentID, Scene scene, string text, int channel); | ||
148 | |||
149 | /// <summary> | ||
150 | /// Get the NPC to shout something. | ||
151 | /// </summary> | ||
152 | /// <param name="agentID">The UUID of the NPC</param> | ||
153 | /// <param name="scene"></param> | ||
154 | /// <param name="text"></param> | ||
155 | /// <param name="channel"></param> | ||
156 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | ||
157 | bool Shout(UUID agentID, Scene scene, string text, int channel); | ||
158 | |||
159 | /// <summary> | ||
160 | /// Get the NPC to whisper something. | ||
161 | /// </summary> | ||
162 | /// <param name="agentID">The UUID of the NPC</param> | ||
163 | /// <param name="scene"></param> | ||
164 | /// <param name="text"></param> | ||
165 | /// <param name="channel"></param> | ||
166 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | ||
167 | bool Whisper(UUID agentID, Scene scene, string text, int channel); | ||
168 | |||
169 | /// <summary> | ||
138 | /// Sit the NPC. | 170 | /// Sit the NPC. |
139 | /// </summary> | 171 | /// </summary> |
140 | /// <param name="agentID"></param> | 172 | /// <param name="agentID"></param> |
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index ce66100..143af48 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs | |||
@@ -71,6 +71,12 @@ namespace OpenSim.Region.Framework.Interfaces | |||
71 | 71 | ||
72 | bool HasScript(UUID itemID, out bool running); | 72 | bool HasScript(UUID itemID, out bool running); |
73 | 73 | ||
74 | /// <summary> | ||
75 | /// Returns true if a script is running. | ||
76 | /// </summary> | ||
77 | /// <param name="itemID">The item ID of the script.</param> | ||
78 | bool GetScriptState(UUID itemID); | ||
79 | |||
74 | void SaveAllState(); | 80 | void SaveAllState(); |
75 | 81 | ||
76 | /// <summary> | 82 | /// <summary> |
@@ -79,6 +85,14 @@ namespace OpenSim.Region.Framework.Interfaces | |||
79 | void StartProcessing(); | 85 | void StartProcessing(); |
80 | 86 | ||
81 | /// <summary> | 87 | /// <summary> |
88 | /// Get the execution times of all scripts in the given array if they are currently running. | ||
89 | /// </summary> | ||
90 | /// <returns> | ||
91 | /// A float the value is a representative execution time in milliseconds of all scripts in that Array. | ||
92 | /// </returns> | ||
93 | float GetScriptExecutionTime(List<UUID> itemIDs); | ||
94 | |||
95 | /// <summary> | ||
82 | /// Get the execution times of all scripts in each object. | 96 | /// Get the execution times of all scripts in each object. |
83 | /// </summary> | 97 | /// </summary> |
84 | /// <returns> | 98 | /// <returns> |
@@ -87,4 +101,4 @@ namespace OpenSim.Region.Framework.Interfaces | |||
87 | /// </returns> | 101 | /// </returns> |
88 | Dictionary<uint, float> GetObjectScriptsExecutionTimes(); | 102 | Dictionary<uint, float> GetObjectScriptsExecutionTimes(); |
89 | } | 103 | } |
90 | } \ No newline at end of file | 104 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index e8e375e..4e74781 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs | |||
@@ -103,7 +103,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
103 | /// <param name='msg'> | 103 | /// <param name='msg'> |
104 | /// Message. | 104 | /// Message. |
105 | /// </param> | 105 | /// </param> |
106 | bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error); | 106 | void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg); |
107 | 107 | ||
108 | /// <summary> | 108 | /// <summary> |
109 | /// Are there any listen events ready to be dispatched? | 109 | /// Are there any listen events ready to be dispatched? |
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index f5623bd..14ae287 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -278,6 +278,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
278 | return "FALLDOWN"; | 278 | return "FALLDOWN"; |
279 | } | 279 | } |
280 | 280 | ||
281 | // Check if the user has stopped walking just now | ||
282 | if (CurrentMovementAnimation == "WALK" && (move == Vector3.Zero)) | ||
283 | return "STAND"; | ||
284 | |||
281 | return CurrentMovementAnimation; | 285 | return CurrentMovementAnimation; |
282 | } | 286 | } |
283 | 287 | ||
@@ -402,13 +406,16 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
402 | /// </summary> | 406 | /// </summary> |
403 | public void UpdateMovementAnimations() | 407 | public void UpdateMovementAnimations() |
404 | { | 408 | { |
405 | CurrentMovementAnimation = DetermineMovementAnimation(); | 409 | lock (m_animations) |
410 | { | ||
411 | CurrentMovementAnimation = DetermineMovementAnimation(); | ||
406 | 412 | ||
407 | // m_log.DebugFormat( | 413 | // m_log.DebugFormat( |
408 | // "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", | 414 | // "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", |
409 | // CurrentMovementAnimation, m_scenePresence.Name); | 415 | // CurrentMovementAnimation, m_scenePresence.Name); |
410 | 416 | ||
411 | TrySetMovementAnimation(CurrentMovementAnimation); | 417 | TrySetMovementAnimation(CurrentMovementAnimation); |
418 | } | ||
412 | } | 419 | } |
413 | 420 | ||
414 | public UUID[] GetAnimationArray() | 421 | public UUID[] GetAnimationArray() |
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index f678d07..834464b 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs | |||
@@ -117,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
117 | 117 | ||
118 | private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e) | 118 | private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e) |
119 | { | 119 | { |
120 | m_log.Debug("[ASYNC DELETER]: Starting send to inventory loop"); | 120 | // m_log.Debug("[ASYNC DELETER]: Starting send to inventory loop"); |
121 | 121 | ||
122 | // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved | 122 | // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved |
123 | // in a culture where decimal points are commas and then reloaded in a culture which just treats them as | 123 | // in a culture where decimal points are commas and then reloaded in a culture which just treats them as |
@@ -147,9 +147,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
147 | { | 147 | { |
148 | x = m_inventoryDeletes.Dequeue(); | 148 | x = m_inventoryDeletes.Dequeue(); |
149 | 149 | ||
150 | m_log.DebugFormat( | 150 | // m_log.DebugFormat( |
151 | "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.", | 151 | // "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.", |
152 | left, x.action, x.objectGroups.Count); | 152 | // left, x.action, x.objectGroups.Count); |
153 | 153 | ||
154 | try | 154 | try |
155 | { | 155 | { |
@@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
185 | e.StackTrace); | 185 | e.StackTrace); |
186 | } | 186 | } |
187 | 187 | ||
188 | m_log.Debug("[ASYNC DELETER]: No objects left in inventory send queue."); | 188 | // m_log.Debug("[ASYNC DELETER]: No objects left in inventory send queue."); |
189 | 189 | ||
190 | return false; | 190 | return false; |
191 | } | 191 | } |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 2365cfe..7688cf8 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -53,6 +53,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
53 | 53 | ||
54 | public event ClientMovement OnClientMovement; | 54 | public event ClientMovement OnClientMovement; |
55 | 55 | ||
56 | public delegate void OnTerrainTaintedDelegate(); | ||
57 | |||
58 | public event OnTerrainTaintedDelegate OnTerrainTainted; | ||
59 | |||
56 | public delegate void OnTerrainTickDelegate(); | 60 | public delegate void OnTerrainTickDelegate(); |
57 | 61 | ||
58 | public delegate void OnTerrainUpdateDelegate(); | 62 | public delegate void OnTerrainUpdateDelegate(); |
@@ -484,6 +488,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
484 | public delegate void SceneObjectPartUpdated(SceneObjectPart sop); | 488 | public delegate void SceneObjectPartUpdated(SceneObjectPart sop); |
485 | public event SceneObjectPartUpdated OnSceneObjectPartUpdated; | 489 | public event SceneObjectPartUpdated OnSceneObjectPartUpdated; |
486 | 490 | ||
491 | public delegate void ScenePresenceUpdated(ScenePresence sp); | ||
492 | public event ScenePresenceUpdated OnScenePresenceUpdated; | ||
493 | |||
487 | public delegate void RegionUp(GridRegion region); | 494 | public delegate void RegionUp(GridRegion region); |
488 | public event RegionUp OnRegionUp; | 495 | public event RegionUp OnRegionUp; |
489 | 496 | ||
@@ -935,6 +942,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
935 | } | 942 | } |
936 | } | 943 | } |
937 | 944 | ||
945 | public void TriggerTerrainTainted() | ||
946 | { | ||
947 | OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted; | ||
948 | if (handlerTerrainTainted != null) | ||
949 | { | ||
950 | foreach (OnTerrainTickDelegate d in handlerTerrainTainted.GetInvocationList()) | ||
951 | { | ||
952 | try | ||
953 | { | ||
954 | d(); | ||
955 | } | ||
956 | catch (Exception e) | ||
957 | { | ||
958 | m_log.ErrorFormat( | ||
959 | "[EVENT MANAGER]: Delegate for TriggerTerrainTainted failed - continuing. {0} {1}", | ||
960 | e.Message, e.StackTrace); | ||
961 | } | ||
962 | } | ||
963 | } | ||
964 | } | ||
965 | |||
938 | public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) | 966 | public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) |
939 | { | 967 | { |
940 | OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = OnParcelPrimCountAdd; | 968 | OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = OnParcelPrimCountAdd; |
@@ -2367,6 +2395,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2367 | } | 2395 | } |
2368 | } | 2396 | } |
2369 | 2397 | ||
2398 | public void TriggerScenePresenceUpdated(ScenePresence sp) | ||
2399 | { | ||
2400 | ScenePresenceUpdated handler = OnScenePresenceUpdated; | ||
2401 | if (handler != null) | ||
2402 | { | ||
2403 | foreach (ScenePresenceUpdated d in handler.GetInvocationList()) | ||
2404 | { | ||
2405 | try | ||
2406 | { | ||
2407 | d(sp); | ||
2408 | } | ||
2409 | catch (Exception e) | ||
2410 | { | ||
2411 | m_log.ErrorFormat( | ||
2412 | "[EVENT MANAGER]: Delegate for TriggerScenePresenceUpdated failed - continuing. {0} {1}", | ||
2413 | e.Message, e.StackTrace); | ||
2414 | } | ||
2415 | } | ||
2416 | } | ||
2417 | } | ||
2418 | |||
2370 | public void TriggerOnParcelPropertiesUpdateRequest(LandUpdateArgs args, | 2419 | public void TriggerOnParcelPropertiesUpdateRequest(LandUpdateArgs args, |
2371 | int local_id, IClientAPI remote_client) | 2420 | int local_id, IClientAPI remote_client) |
2372 | { | 2421 | { |
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs index 6c5685c..1365831 100644 --- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs +++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs | |||
@@ -48,16 +48,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
48 | { | 48 | { |
49 | public class RegionStatsHandler : IStreamedRequestHandler | 49 | public class RegionStatsHandler : IStreamedRequestHandler |
50 | { | 50 | { |
51 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
51 | private string osRXStatsURI = String.Empty; | 53 | private string osRXStatsURI = String.Empty; |
52 | private string osXStatsURI = String.Empty; | 54 | private string osXStatsURI = String.Empty; |
53 | //private string osSecret = String.Empty; | 55 | //private string osSecret = String.Empty; |
54 | private OpenSim.Framework.RegionInfo regionInfo; | 56 | private OpenSim.Framework.RegionInfo regionInfo; |
55 | public string localZone = TimeZone.CurrentTimeZone.StandardName; | 57 | public string localZone = TimeZone.CurrentTimeZone.StandardName; |
56 | public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); | 58 | public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); |
57 | |||
58 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
59 | 59 | ||
60 | public RegionStatsHandler(OpenSim.Framework.RegionInfo region_info) | 60 | public string Name { get { return "RegionStats"; } } |
61 | public string Description { get { return "Region Statistics"; } } | ||
62 | |||
63 | public RegionStatsHandler(RegionInfo region_info) | ||
61 | { | 64 | { |
62 | regionInfo = region_info; | 65 | regionInfo = region_info; |
63 | osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret); | 66 | osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 0089c7d..0837ca5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -300,6 +300,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
300 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId); | 300 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId); |
301 | AssetService.Store(asset); | 301 | AssetService.Store(asset); |
302 | 302 | ||
303 | // m_log.DebugFormat( | ||
304 | // "[PRIM INVENTORY]: Stored asset {0} when updating item {1} in prim {2} for {3}", | ||
305 | // asset.ID, item.Name, part.Name, remoteClient.Name); | ||
306 | |||
303 | if (isScriptRunning) | 307 | if (isScriptRunning) |
304 | { | 308 | { |
305 | part.Inventory.RemoveScriptInstance(item.ItemID, false); | 309 | part.Inventory.RemoveScriptInstance(item.ItemID, false); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 3ef1e29..cf68ff4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -38,8 +38,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
38 | { | 38 | { |
39 | public partial class Scene | 39 | public partial class Scene |
40 | { | 40 | { |
41 | |||
41 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 42 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
42 | UUID fromID, bool fromAgent, bool broadcast) | 43 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) |
43 | { | 44 | { |
44 | OSChatMessage args = new OSChatMessage(); | 45 | OSChatMessage args = new OSChatMessage(); |
45 | 46 | ||
@@ -63,14 +64,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
63 | } | 64 | } |
64 | 65 | ||
65 | args.From = fromName; | 66 | args.From = fromName; |
66 | //args. | 67 | args.TargetUUID = targetID; |
67 | 68 | ||
68 | if (broadcast) | 69 | if (broadcast) |
69 | EventManager.TriggerOnChatBroadcast(this, args); | 70 | EventManager.TriggerOnChatBroadcast(this, args); |
70 | else | 71 | else |
71 | EventManager.TriggerOnChatFromWorld(this, args); | 72 | EventManager.TriggerOnChatFromWorld(this, args); |
72 | } | 73 | } |
73 | 74 | ||
75 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | ||
76 | UUID fromID, bool fromAgent, bool broadcast) | ||
77 | { | ||
78 | SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast); | ||
79 | } | ||
80 | |||
74 | /// <summary> | 81 | /// <summary> |
75 | /// | 82 | /// |
76 | /// </summary> | 83 | /// </summary> |
@@ -108,6 +115,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
108 | { | 115 | { |
109 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); | 116 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); |
110 | } | 117 | } |
118 | /// <summary> | ||
119 | /// | ||
120 | /// </summary> | ||
121 | /// <param name="message"></param> | ||
122 | /// <param name="type"></param> | ||
123 | /// <param name="fromPos"></param> | ||
124 | /// <param name="fromName"></param> | ||
125 | /// <param name="fromAgentID"></param> | ||
126 | /// <param name="targetID"></param> | ||
127 | public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent) | ||
128 | { | ||
129 | SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false); | ||
130 | } | ||
111 | 131 | ||
112 | /// <summary> | 132 | /// <summary> |
113 | /// Invoked when the client requests a prim. | 133 | /// Invoked when the client requests a prim. |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index e1fedf4..535d87a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | |||
@@ -67,6 +67,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
67 | public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); | 67 | public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); |
68 | public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); | 68 | public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); |
69 | public delegate bool IsGodHandler(UUID user, Scene requestFromScene); | 69 | public delegate bool IsGodHandler(UUID user, Scene requestFromScene); |
70 | public delegate bool IsGridGodHandler(UUID user, Scene requestFromScene); | ||
70 | public delegate bool IsAdministratorHandler(UUID user); | 71 | public delegate bool IsAdministratorHandler(UUID user); |
71 | public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); | 72 | public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); |
72 | public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene); | 73 | public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene); |
@@ -134,6 +135,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
134 | public event RunConsoleCommandHandler OnRunConsoleCommand; | 135 | public event RunConsoleCommandHandler OnRunConsoleCommand; |
135 | public event IssueEstateCommandHandler OnIssueEstateCommand; | 136 | public event IssueEstateCommandHandler OnIssueEstateCommand; |
136 | public event IsGodHandler OnIsGod; | 137 | public event IsGodHandler OnIsGod; |
138 | public event IsGridGodHandler OnIsGridGod; | ||
137 | public event IsAdministratorHandler OnIsAdministrator; | 139 | public event IsAdministratorHandler OnIsAdministrator; |
138 | // public event EditParcelHandler OnEditParcel; | 140 | // public event EditParcelHandler OnEditParcel; |
139 | public event EditParcelPropertiesHandler OnEditParcelProperties; | 141 | public event EditParcelPropertiesHandler OnEditParcelProperties; |
@@ -728,6 +730,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
728 | return true; | 730 | return true; |
729 | } | 731 | } |
730 | 732 | ||
733 | public bool IsGridGod(UUID user) | ||
734 | { | ||
735 | IsGridGodHandler handler = OnIsGridGod; | ||
736 | if (handler != null) | ||
737 | { | ||
738 | Delegate[] list = handler.GetInvocationList(); | ||
739 | foreach (IsGridGodHandler h in list) | ||
740 | { | ||
741 | if (h(user, m_scene) == false) | ||
742 | return false; | ||
743 | } | ||
744 | } | ||
745 | return true; | ||
746 | } | ||
747 | |||
731 | public bool IsAdministrator(UUID user) | 748 | public bool IsAdministrator(UUID user) |
732 | { | 749 | { |
733 | IsAdministratorHandler handler = OnIsAdministrator; | 750 | IsAdministratorHandler handler = OnIsAdministrator; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a9a4cda..89cde05 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -103,6 +103,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
103 | public bool m_trustBinaries; | 103 | public bool m_trustBinaries; |
104 | public bool m_allowScriptCrossings; | 104 | public bool m_allowScriptCrossings; |
105 | public bool m_useFlySlow; | 105 | public bool m_useFlySlow; |
106 | public bool m_useTrashOnDelete = true; | ||
106 | 107 | ||
107 | /// <summary> | 108 | /// <summary> |
108 | /// Temporarily setting to trigger appearance resends at 60 second intervals. | 109 | /// Temporarily setting to trigger appearance resends at 60 second intervals. |
@@ -458,6 +459,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
458 | { | 459 | { |
459 | if (m_simulationService == null) | 460 | if (m_simulationService == null) |
460 | m_simulationService = RequestModuleInterface<ISimulationService>(); | 461 | m_simulationService = RequestModuleInterface<ISimulationService>(); |
462 | |||
461 | return m_simulationService; | 463 | return m_simulationService; |
462 | } | 464 | } |
463 | } | 465 | } |
@@ -735,6 +737,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
735 | m_clampPrimSize = true; | 737 | m_clampPrimSize = true; |
736 | } | 738 | } |
737 | 739 | ||
740 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); | ||
738 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 741 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
739 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 742 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
740 | m_dontPersistBefore = | 743 | m_dontPersistBefore = |
@@ -833,13 +836,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
833 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 836 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
834 | } | 837 | } |
835 | 838 | ||
836 | /// <summary> | ||
837 | /// Mock constructor for scene group persistency unit tests. | ||
838 | /// SceneObjectGroup RegionId property is delegated to Scene. | ||
839 | /// </summary> | ||
840 | /// <param name="regInfo"></param> | ||
841 | public Scene(RegionInfo regInfo) | 839 | public Scene(RegionInfo regInfo) |
842 | { | 840 | { |
841 | PhysicalPrims = true; | ||
842 | CollidablePrims = true; | ||
843 | |||
843 | BordersLocked = true; | 844 | BordersLocked = true; |
844 | Border northBorder = new Border(); | 845 | Border northBorder = new Border(); |
845 | northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- | 846 | northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- |
@@ -866,8 +867,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
866 | m_eventManager = new EventManager(); | 867 | m_eventManager = new EventManager(); |
867 | 868 | ||
868 | m_permissions = new ScenePermissions(this); | 869 | m_permissions = new ScenePermissions(this); |
869 | |||
870 | // m_lastUpdate = Util.EnvironmentTickCount(); | ||
871 | } | 870 | } |
872 | 871 | ||
873 | #endregion | 872 | #endregion |
@@ -1404,6 +1403,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1404 | 1403 | ||
1405 | try | 1404 | try |
1406 | { | 1405 | { |
1406 | // Apply taints in terrain module to terrain in physics scene | ||
1407 | if (Frame % m_update_terrain == 0) | ||
1408 | { | ||
1409 | terMS = Util.EnvironmentTickCount(); | ||
1410 | UpdateTerrain(); | ||
1411 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | ||
1412 | } | ||
1413 | |||
1407 | tmpPhysicsMS2 = Util.EnvironmentTickCount(); | 1414 | tmpPhysicsMS2 = Util.EnvironmentTickCount(); |
1408 | if ((Frame % m_update_physics == 0) && m_physics_enabled) | 1415 | if ((Frame % m_update_physics == 0) && m_physics_enabled) |
1409 | m_sceneGraph.UpdatePreparePhysics(); | 1416 | m_sceneGraph.UpdatePreparePhysics(); |
@@ -1468,13 +1475,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1468 | backupMS = Util.EnvironmentTickCountSubtract(backMS); | 1475 | backupMS = Util.EnvironmentTickCountSubtract(backMS); |
1469 | } | 1476 | } |
1470 | 1477 | ||
1471 | if (Frame % m_update_terrain == 0) | ||
1472 | { | ||
1473 | terMS = Util.EnvironmentTickCount(); | ||
1474 | UpdateTerrain(); | ||
1475 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | ||
1476 | } | ||
1477 | |||
1478 | //if (Frame % m_update_land == 0) | 1478 | //if (Frame % m_update_land == 0) |
1479 | //{ | 1479 | //{ |
1480 | // int ldMS = Util.EnvironmentTickCount(); | 1480 | // int ldMS = Util.EnvironmentTickCount(); |
@@ -3382,8 +3382,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3382 | try | 3382 | try |
3383 | { | 3383 | { |
3384 | m_log.DebugFormat( | 3384 | m_log.DebugFormat( |
3385 | "[SCENE]: Removing {0} agent {1} from region {2}", | 3385 | "[SCENE]: Removing {0} agent {1} {2} from region {3}", |
3386 | (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName); | 3386 | (isChildAgent ? "child" : "root"), avatar.Name, agentID, RegionInfo.RegionName); |
3387 | 3387 | ||
3388 | m_sceneGraph.removeUserCount(!isChildAgent); | 3388 | m_sceneGraph.removeUserCount(!isChildAgent); |
3389 | 3389 | ||
@@ -3981,41 +3981,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
3981 | return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); | 3981 | return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); |
3982 | } | 3982 | } |
3983 | 3983 | ||
3984 | /// <summary> | 3984 | // /// <summary> |
3985 | /// The Grid has requested that we log-off a user. Log them off. | 3985 | // /// The Grid has requested that we log-off a user. Log them off. |
3986 | /// </summary> | 3986 | // /// </summary> |
3987 | /// <param name="AvatarID">Unique ID of the avatar to log-off</param> | 3987 | // /// <param name="AvatarID">Unique ID of the avatar to log-off</param> |
3988 | /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param> | 3988 | // /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param> |
3989 | /// <param name="message">message to display to the user. Reason for being logged off</param> | 3989 | // /// <param name="message">message to display to the user. Reason for being logged off</param> |
3990 | public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) | 3990 | // public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) |
3991 | { | 3991 | // { |
3992 | ScenePresence loggingOffUser = GetScenePresence(AvatarID); | 3992 | // ScenePresence loggingOffUser = GetScenePresence(AvatarID); |
3993 | if (loggingOffUser != null) | 3993 | // if (loggingOffUser != null) |
3994 | { | 3994 | // { |
3995 | UUID localRegionSecret = UUID.Zero; | 3995 | // UUID localRegionSecret = UUID.Zero; |
3996 | bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret); | 3996 | // bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret); |
3997 | 3997 | // | |
3998 | // Region Secret is used here in case a new sessionid overwrites an old one on the user server. | 3998 | // // Region Secret is used here in case a new sessionid overwrites an old one on the user server. |
3999 | // Will update the user server in a few revisions to use it. | 3999 | // // Will update the user server in a few revisions to use it. |
4000 | 4000 | // | |
4001 | if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) | 4001 | // if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) |
4002 | { | 4002 | // { |
4003 | m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); | 4003 | // m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); |
4004 | loggingOffUser.ControllingClient.Kick(message); | 4004 | // loggingOffUser.ControllingClient.Kick(message); |
4005 | // Give them a second to receive the message! | 4005 | // // Give them a second to receive the message! |
4006 | Thread.Sleep(1000); | 4006 | // Thread.Sleep(1000); |
4007 | loggingOffUser.ControllingClient.Close(); | 4007 | // loggingOffUser.ControllingClient.Close(); |
4008 | } | 4008 | // } |
4009 | else | 4009 | // else |
4010 | { | 4010 | // { |
4011 | m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); | 4011 | // m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); |
4012 | } | 4012 | // } |
4013 | } | 4013 | // } |
4014 | else | 4014 | // else |
4015 | { | 4015 | // { |
4016 | m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString()); | 4016 | // m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString()); |
4017 | } | 4017 | // } |
4018 | } | 4018 | // } |
4019 | 4019 | ||
4020 | /// <summary> | 4020 | /// <summary> |
4021 | /// Triggered when an agent crosses into this sim. Also happens on initial login. | 4021 | /// Triggered when an agent crosses into this sim. Also happens on initial login. |
@@ -4071,7 +4071,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
4071 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4071 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4072 | if (nearestParcel == null) | 4072 | if (nearestParcel == null) |
4073 | { | 4073 | { |
4074 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: no allowed parcel", cAgentData.AgentID); | 4074 | m_log.DebugFormat( |
4075 | "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel", | ||
4076 | cAgentData.AgentID, RegionInfo.RegionName); | ||
4077 | |||
4075 | return false; | 4078 | return false; |
4076 | } | 4079 | } |
4077 | 4080 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index b806d91..77e808e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -156,7 +156,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
156 | // that the region position is cached or performance will degrade | 156 | // that the region position is cached or performance will degrade |
157 | Utils.LongToUInts(regionHandle, out x, out y); | 157 | Utils.LongToUInts(regionHandle, out x, out y); |
158 | GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | 158 | GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); |
159 | // bool v = true; | 159 | if (dest == null) |
160 | continue; | ||
161 | |||
160 | if (!simulatorList.Contains(dest.ServerURI)) | 162 | if (!simulatorList.Contains(dest.ServerURI)) |
161 | { | 163 | { |
162 | // we havent seen this simulator before, add it to the list | 164 | // we havent seen this simulator before, add it to the list |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 0d178c3..00f76e0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -101,6 +101,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
101 | /// </summary> | 101 | /// </summary> |
102 | protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); | 102 | protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); |
103 | 103 | ||
104 | /// <summary> | ||
105 | /// Lock to prevent object group update, linking, delinking and duplication operations from running concurrently. | ||
106 | /// </summary> | ||
107 | /// <remarks> | ||
108 | /// These operations rely on the parts composition of the object. If allowed to run concurrently then race | ||
109 | /// conditions can occur. | ||
110 | /// </remarks> | ||
104 | private Object m_updateLock = new Object(); | 111 | private Object m_updateLock = new Object(); |
105 | 112 | ||
106 | #endregion | 113 | #endregion |
@@ -2064,12 +2071,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2064 | /// <param name="AgentID"></param> | 2071 | /// <param name="AgentID"></param> |
2065 | /// <param name="GroupID"></param> | 2072 | /// <param name="GroupID"></param> |
2066 | /// <param name="rot"></param> | 2073 | /// <param name="rot"></param> |
2074 | /// <returns>null if duplication fails, otherwise the duplicated object</returns> | ||
2075 | /// <summary> | ||
2067 | public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) | 2076 | public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) |
2068 | { | 2077 | { |
2069 | // m_log.DebugFormat( | 2078 | // m_log.DebugFormat( |
2070 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | 2079 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", |
2071 | // originalPrimID, offset, AgentID); | 2080 | // originalPrimID, offset, AgentID); |
2072 | 2081 | ||
2073 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); | 2082 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); |
2074 | if (original != null) | 2083 | if (original != null) |
2075 | { | 2084 | { |
@@ -2099,25 +2108,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2099 | 2108 | ||
2100 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() | 2109 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() |
2101 | Entities.Add(copy); | 2110 | Entities.Add(copy); |
2102 | 2111 | ||
2103 | lock (SceneObjectGroupsByFullID) | 2112 | lock (SceneObjectGroupsByFullID) |
2104 | SceneObjectGroupsByFullID[copy.UUID] = copy; | 2113 | SceneObjectGroupsByFullID[copy.UUID] = copy; |
2105 | 2114 | ||
2106 | SceneObjectPart[] children = copy.Parts; | 2115 | SceneObjectPart[] children = copy.Parts; |
2107 | 2116 | ||
2108 | lock (SceneObjectGroupsByFullPartID) | 2117 | lock (SceneObjectGroupsByFullPartID) |
2109 | { | 2118 | { |
2110 | SceneObjectGroupsByFullPartID[copy.UUID] = copy; | 2119 | SceneObjectGroupsByFullPartID[copy.UUID] = copy; |
2111 | foreach (SceneObjectPart part in children) | 2120 | foreach (SceneObjectPart part in children) |
2112 | SceneObjectGroupsByFullPartID[part.UUID] = copy; | 2121 | SceneObjectGroupsByFullPartID[part.UUID] = copy; |
2113 | } | 2122 | } |
2114 | 2123 | ||
2115 | lock (SceneObjectGroupsByLocalPartID) | 2124 | lock (SceneObjectGroupsByLocalPartID) |
2116 | { | 2125 | { |
2117 | SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; | 2126 | SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; |
2118 | foreach (SceneObjectPart part in children) | 2127 | foreach (SceneObjectPart part in children) |
2119 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; | 2128 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; |
2120 | } | 2129 | } |
2121 | // PROBABLE END OF FIXME | 2130 | // PROBABLE END OF FIXME |
2122 | 2131 | ||
2123 | // Since we copy from a source group that is in selected | 2132 | // Since we copy from a source group that is in selected |
@@ -2149,11 +2158,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2149 | { | 2158 | { |
2150 | m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); | 2159 | m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); |
2151 | } | 2160 | } |
2152 | 2161 | ||
2153 | return null; | 2162 | return null; |
2154 | } | 2163 | } |
2155 | 2164 | ||
2156 | /// <summary> | ||
2157 | /// Calculates the distance between two Vector3s | 2165 | /// Calculates the distance between two Vector3s |
2158 | /// </summary> | 2166 | /// </summary> |
2159 | /// <param name="v1"></param> | 2167 | /// <param name="v1"></param> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f9c2193..72d96d1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -2681,6 +2681,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2681 | /// <summary> | 2681 | /// <summary> |
2682 | /// Link the prims in a given group to this group | 2682 | /// Link the prims in a given group to this group |
2683 | /// </summary> | 2683 | /// </summary> |
2684 | /// <remarks> | ||
2685 | /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads. | ||
2686 | /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition. | ||
2687 | /// </remarks> | ||
2684 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> | 2688 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> |
2685 | public void LinkToGroup(SceneObjectGroup objectGroup) | 2689 | public void LinkToGroup(SceneObjectGroup objectGroup) |
2686 | { | 2690 | { |
@@ -2762,6 +2766,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2762 | } | 2766 | } |
2763 | 2767 | ||
2764 | linkPart.LinkNum = linkNum++; | 2768 | linkPart.LinkNum = linkNum++; |
2769 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2765 | 2770 | ||
2766 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2771 | SceneObjectPart[] ogParts = objectGroup.Parts; |
2767 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) | 2772 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) |
@@ -2813,6 +2818,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2813 | /// Delink the given prim from this group. The delinked prim is established as | 2818 | /// Delink the given prim from this group. The delinked prim is established as |
2814 | /// an independent SceneObjectGroup. | 2819 | /// an independent SceneObjectGroup. |
2815 | /// </summary> | 2820 | /// </summary> |
2821 | /// <remarks> | ||
2822 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2823 | /// condition. But currently there is no | ||
2824 | /// alternative method that does take a lonk to delink a single prim. | ||
2825 | /// </remarks> | ||
2816 | /// <param name="partID"></param> | 2826 | /// <param name="partID"></param> |
2817 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> | 2827 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
2818 | public SceneObjectGroup DelinkFromGroup(uint partID) | 2828 | public SceneObjectGroup DelinkFromGroup(uint partID) |
@@ -2824,6 +2834,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2824 | /// Delink the given prim from this group. The delinked prim is established as | 2834 | /// Delink the given prim from this group. The delinked prim is established as |
2825 | /// an independent SceneObjectGroup. | 2835 | /// an independent SceneObjectGroup. |
2826 | /// </summary> | 2836 | /// </summary> |
2837 | /// <remarks> | ||
2838 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2839 | /// condition. But currently there is no | ||
2840 | /// alternative method that does take a lonk to delink a single prim. | ||
2841 | /// </remarks> | ||
2827 | /// <param name="partID"></param> | 2842 | /// <param name="partID"></param> |
2828 | /// <param name="sendEvents"></param> | 2843 | /// <param name="sendEvents"></param> |
2829 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> | 2844 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
@@ -2849,6 +2864,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2849 | /// Delink the given prim from this group. The delinked prim is established as | 2864 | /// Delink the given prim from this group. The delinked prim is established as |
2850 | /// an independent SceneObjectGroup. | 2865 | /// an independent SceneObjectGroup. |
2851 | /// </summary> | 2866 | /// </summary> |
2867 | /// <remarks> | ||
2868 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2869 | /// condition. But currently there is no | ||
2870 | /// alternative method that does take a lonk to delink a single prim. | ||
2871 | /// </remarks> | ||
2852 | /// <param name="partID"></param> | 2872 | /// <param name="partID"></param> |
2853 | /// <param name="sendEvents"></param> | 2873 | /// <param name="sendEvents"></param> |
2854 | /// <returns>The object group of the newly delinked prim.</returns> | 2874 | /// <returns>The object group of the newly delinked prim.</returns> |
@@ -2982,6 +3002,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2982 | oldRot = part.RotationOffset; | 3002 | oldRot = part.RotationOffset; |
2983 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; | 3003 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
2984 | part.RotationOffset = newRot; | 3004 | part.RotationOffset = newRot; |
3005 | |||
3006 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2985 | } | 3007 | } |
2986 | 3008 | ||
2987 | /// <summary> | 3009 | /// <summary> |
@@ -3493,7 +3515,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3493 | 3515 | ||
3494 | //we need to do a terse update even if the move wasn't allowed | 3516 | //we need to do a terse update even if the move wasn't allowed |
3495 | // so that the position is reset in the client (the object snaps back) | 3517 | // so that the position is reset in the client (the object snaps back) |
3496 | ScheduleGroupForTerseUpdate(); | 3518 | RootPart.ScheduleTerseUpdate(); |
3497 | } | 3519 | } |
3498 | 3520 | ||
3499 | /// <summary> | 3521 | /// <summary> |
@@ -4192,7 +4214,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
4192 | for (int i = 0; i < parts.Length; i++) | 4214 | for (int i = 0; i < parts.Length; i++) |
4193 | parts[i].TriggerScriptChangedEvent(val); | 4215 | parts[i].TriggerScriptChangedEvent(val); |
4194 | } | 4216 | } |
4195 | 4217 | ||
4218 | /// <summary> | ||
4219 | /// Returns a count of the number of scripts in this groups parts. | ||
4220 | /// </summary> | ||
4221 | public int ScriptCount() | ||
4222 | { | ||
4223 | int count = 0; | ||
4224 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4225 | for (int i = 0; i < parts.Length; i++) | ||
4226 | count += parts[i].Inventory.ScriptCount(); | ||
4227 | |||
4228 | return count; | ||
4229 | } | ||
4230 | |||
4231 | /// <summary> | ||
4232 | /// A float the value is a representative execution time in milliseconds of all scripts in the link set. | ||
4233 | /// </summary> | ||
4234 | public float ScriptExecutionTime() | ||
4235 | { | ||
4236 | IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>(); | ||
4237 | |||
4238 | if (engines.Length == 0) // No engine at all | ||
4239 | return 0.0f; | ||
4240 | |||
4241 | float time = 0.0f; | ||
4242 | |||
4243 | // get all the scripts in all parts | ||
4244 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4245 | List<TaskInventoryItem> scripts = new List<TaskInventoryItem>(); | ||
4246 | for (int i = 0; i < parts.Length; i++) | ||
4247 | { | ||
4248 | scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL)); | ||
4249 | } | ||
4250 | // extract the UUIDs | ||
4251 | List<UUID> ids = new List<UUID>(scripts.Count); | ||
4252 | foreach (TaskInventoryItem script in scripts) | ||
4253 | { | ||
4254 | if (!ids.Contains(script.ItemID)) | ||
4255 | { | ||
4256 | ids.Add(script.ItemID); | ||
4257 | } | ||
4258 | } | ||
4259 | // Offer the list of script UUIDs to each engine found and accumulate the time | ||
4260 | foreach (IScriptModule e in engines) | ||
4261 | { | ||
4262 | if (e != null) | ||
4263 | { | ||
4264 | time += e.GetScriptExecutionTime(ids); | ||
4265 | } | ||
4266 | } | ||
4267 | return time; | ||
4268 | } | ||
4269 | |||
4270 | /// <summary> | ||
4271 | /// Returns a count of the number of running scripts in this groups parts. | ||
4272 | /// </summary> | ||
4273 | public int RunningScriptCount() | ||
4274 | { | ||
4275 | int count = 0; | ||
4276 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4277 | for (int i = 0; i < parts.Length; i++) | ||
4278 | count += parts[i].Inventory.RunningScriptCount(); | ||
4279 | |||
4280 | return count; | ||
4281 | } | ||
4282 | |||
4196 | public override string ToString() | 4283 | public override string ToString() |
4197 | { | 4284 | { |
4198 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); | 4285 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b0bc188..82bba35 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -2091,6 +2091,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2091 | /// <param name="isNew"></param> | 2091 | /// <param name="isNew"></param> |
2092 | public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) | 2092 | public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) |
2093 | { | 2093 | { |
2094 | if (ParentGroup.Scene == null) | ||
2095 | return; | ||
2096 | |||
2094 | if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) | 2097 | if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) |
2095 | return; | 2098 | return; |
2096 | 2099 | ||
@@ -3832,7 +3835,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3832 | hasProfileCut = hasDimple; // is it the same thing? | 3835 | hasProfileCut = hasDimple; // is it the same thing? |
3833 | } | 3836 | } |
3834 | 3837 | ||
3835 | |||
3836 | public void SetGroup(UUID groupID, IClientAPI client) | 3838 | public void SetGroup(UUID groupID, IClientAPI client) |
3837 | { | 3839 | { |
3838 | // Scene.AddNewPrims() calls with client == null so can't use this. | 3840 | // Scene.AddNewPrims() calls with client == null so can't use this. |
@@ -3862,10 +3864,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3862 | 3864 | ||
3863 | public void SetPhysicsAxisRotation() | 3865 | public void SetPhysicsAxisRotation() |
3864 | { | 3866 | { |
3865 | if (PhysActor != null) | 3867 | PhysicsActor pa = PhysActor; |
3868 | |||
3869 | if (pa != null) | ||
3866 | { | 3870 | { |
3867 | PhysActor.LockAngularMotion(RotationAxis); | 3871 | pa.LockAngularMotion(RotationAxis); |
3868 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 3872 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); |
3869 | } | 3873 | } |
3870 | } | 3874 | } |
3871 | 3875 | ||
@@ -4582,7 +4586,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4582 | // For now, we use the NINJA naming scheme for identifying joints. | 4586 | // For now, we use the NINJA naming scheme for identifying joints. |
4583 | // In the future, we can support other joint specification schemes such as a | 4587 | // In the future, we can support other joint specification schemes such as a |
4584 | // custom checkbox in the viewer GUI. | 4588 | // custom checkbox in the viewer GUI. |
4585 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | 4589 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) |
4586 | { | 4590 | { |
4587 | string hingeString = "hingejoint"; | 4591 | string hingeString = "hingejoint"; |
4588 | return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); | 4592 | return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); |
@@ -4598,7 +4602,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4598 | // For now, we use the NINJA naming scheme for identifying joints. | 4602 | // For now, we use the NINJA naming scheme for identifying joints. |
4599 | // In the future, we can support other joint specification schemes such as a | 4603 | // In the future, we can support other joint specification schemes such as a |
4600 | // custom checkbox in the viewer GUI. | 4604 | // custom checkbox in the viewer GUI. |
4601 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | 4605 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) |
4602 | { | 4606 | { |
4603 | string ballString = "balljoint"; | 4607 | string ballString = "balljoint"; |
4604 | return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); | 4608 | return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); |
@@ -4614,7 +4618,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4614 | // For now, we use the NINJA naming scheme for identifying joints. | 4618 | // For now, we use the NINJA naming scheme for identifying joints. |
4615 | // In the future, we can support other joint specification schemes such as a | 4619 | // In the future, we can support other joint specification schemes such as a |
4616 | // custom checkbox in the viewer GUI. | 4620 | // custom checkbox in the viewer GUI. |
4617 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | 4621 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) |
4618 | { | 4622 | { |
4619 | return IsHingeJoint() || IsBallJoint(); | 4623 | return IsHingeJoint() || IsBallJoint(); |
4620 | } | 4624 | } |
@@ -4733,7 +4737,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4733 | } | 4737 | } |
4734 | } | 4738 | } |
4735 | } | 4739 | } |
4736 | |||
4737 | else // it already has a physical representation | 4740 | else // it already has a physical representation |
4738 | { | 4741 | { |
4739 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. | 4742 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 959046a..141cf66 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -267,14 +267,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
267 | /// </summary> | 267 | /// </summary> |
268 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 268 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
269 | { | 269 | { |
270 | Items.LockItemsForRead(true); | 270 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
271 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 271 | foreach (TaskInventoryItem item in scripts) |
272 | Items.LockItemsForRead(false); | 272 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
273 | foreach (TaskInventoryItem item in items) | ||
274 | { | ||
275 | if ((int)InventoryType.LSL == item.InvType) | ||
276 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | ||
277 | } | ||
278 | } | 273 | } |
279 | 274 | ||
280 | public ArrayList GetScriptErrors(UUID itemID) | 275 | public ArrayList GetScriptErrors(UUID itemID) |
@@ -305,17 +300,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
305 | /// </param> | 300 | /// </param> |
306 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 301 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
307 | { | 302 | { |
308 | Items.LockItemsForRead(true); | 303 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
309 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 304 | foreach (TaskInventoryItem item in scripts) |
310 | Items.LockItemsForRead(false); | ||
311 | |||
312 | foreach (TaskInventoryItem item in items) | ||
313 | { | 305 | { |
314 | if ((int)InventoryType.LSL == item.InvType) | 306 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
315 | { | 307 | m_part.RemoveScriptEvents(item.ItemID); |
316 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | ||
317 | m_part.RemoveScriptEvents(item.ItemID); | ||
318 | } | ||
319 | } | 308 | } |
320 | } | 309 | } |
321 | 310 | ||
@@ -1281,9 +1270,57 @@ namespace OpenSim.Region.Framework.Scenes | |||
1281 | return true; | 1270 | return true; |
1282 | } | 1271 | } |
1283 | } | 1272 | } |
1273 | |||
1284 | return false; | 1274 | return false; |
1285 | } | 1275 | } |
1286 | 1276 | ||
1277 | /// <summary> | ||
1278 | /// Returns the count of scripts in this parts inventory. | ||
1279 | /// </summary> | ||
1280 | /// <returns></returns> | ||
1281 | public int ScriptCount() | ||
1282 | { | ||
1283 | int count = 0; | ||
1284 | Items.LockItemsForRead(true); | ||
1285 | foreach (TaskInventoryItem item in m_items.Values) | ||
1286 | { | ||
1287 | if (item.InvType == (int)InventoryType.LSL) | ||
1288 | { | ||
1289 | count++; | ||
1290 | } | ||
1291 | } | ||
1292 | Items.LockItemsForRead(false); | ||
1293 | return count; | ||
1294 | } | ||
1295 | /// <summary> | ||
1296 | /// Returns the count of running scripts in this parts inventory. | ||
1297 | /// </summary> | ||
1298 | /// <returns></returns> | ||
1299 | public int RunningScriptCount() | ||
1300 | { | ||
1301 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
1302 | if (engines.Length == 0) | ||
1303 | return 0; | ||
1304 | |||
1305 | int count = 0; | ||
1306 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | ||
1307 | |||
1308 | foreach (TaskInventoryItem item in scripts) | ||
1309 | { | ||
1310 | foreach (IScriptModule engine in engines) | ||
1311 | { | ||
1312 | if (engine != null) | ||
1313 | { | ||
1314 | if (engine.GetScriptState(item.ItemID)) | ||
1315 | { | ||
1316 | count++; | ||
1317 | } | ||
1318 | } | ||
1319 | } | ||
1320 | } | ||
1321 | return count; | ||
1322 | } | ||
1323 | |||
1287 | public List<UUID> GetInventoryList() | 1324 | public List<UUID> GetInventoryList() |
1288 | { | 1325 | { |
1289 | List<UUID> ret = new List<UUID>(); | 1326 | List<UUID> ret = new List<UUID>(); |
@@ -1298,22 +1335,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1298 | { | 1335 | { |
1299 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1336 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1300 | 1337 | ||
1301 | lock (m_items) | 1338 | Items.LockItemsForRead(true); |
1302 | ret = new List<TaskInventoryItem>(m_items.Values); | 1339 | ret = new List<TaskInventoryItem>(m_items.Values); |
1340 | Items.LockItemsForRead(false); | ||
1303 | 1341 | ||
1304 | return ret; | 1342 | return ret; |
1305 | } | 1343 | } |
1306 | 1344 | ||
1307 | public List<TaskInventoryItem> GetInventoryScripts() | 1345 | public List<TaskInventoryItem> GetInventoryItems(InventoryType type) |
1308 | { | 1346 | { |
1309 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1347 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1310 | 1348 | ||
1311 | lock (m_items) | 1349 | Items.LockItemsForRead(true); |
1312 | { | 1350 | |
1313 | foreach (TaskInventoryItem item in m_items.Values) | 1351 | foreach (TaskInventoryItem item in m_items.Values) |
1314 | if (item.InvType == (int)InventoryType.LSL) | 1352 | if (item.InvType == (int)type) |
1315 | ret.Add(item); | 1353 | ret.Add(item); |
1316 | } | 1354 | |
1355 | Items.LockItemsForRead(false); | ||
1317 | 1356 | ||
1318 | return ret; | 1357 | return ret; |
1319 | } | 1358 | } |
@@ -1335,35 +1374,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1335 | if (engines.Length == 0) // No engine at all | 1374 | if (engines.Length == 0) // No engine at all |
1336 | return ret; | 1375 | return ret; |
1337 | 1376 | ||
1338 | Items.LockItemsForRead(true); | 1377 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
1339 | foreach (TaskInventoryItem item in m_items.Values) | 1378 | |
1379 | foreach (TaskInventoryItem item in scripts) | ||
1340 | { | 1380 | { |
1341 | if (item.InvType == (int)InventoryType.LSL) | 1381 | foreach (IScriptModule e in engines) |
1342 | { | 1382 | { |
1343 | foreach (IScriptModule e in engines) | 1383 | if (e != null) |
1344 | { | 1384 | { |
1345 | if (e != null) | 1385 | string n = e.GetXMLState(item.ItemID); |
1386 | if (n != String.Empty) | ||
1346 | { | 1387 | { |
1347 | string n = e.GetXMLState(item.ItemID); | 1388 | if (oldIDs) |
1348 | if (n != String.Empty) | 1389 | { |
1390 | if (!ret.ContainsKey(item.OldItemID)) | ||
1391 | ret[item.OldItemID] = n; | ||
1392 | } | ||
1393 | else | ||
1349 | { | 1394 | { |
1350 | if (oldIDs) | 1395 | if (!ret.ContainsKey(item.ItemID)) |
1351 | { | 1396 | ret[item.ItemID] = n; |
1352 | if (!ret.ContainsKey(item.OldItemID)) | ||
1353 | ret[item.OldItemID] = n; | ||
1354 | } | ||
1355 | else | ||
1356 | { | ||
1357 | if (!ret.ContainsKey(item.ItemID)) | ||
1358 | ret[item.ItemID] = n; | ||
1359 | } | ||
1360 | break; | ||
1361 | } | 1397 | } |
1398 | break; | ||
1362 | } | 1399 | } |
1363 | } | 1400 | } |
1364 | } | 1401 | } |
1365 | } | 1402 | } |
1366 | Items.LockItemsForRead(false); | ||
1367 | return ret; | 1403 | return ret; |
1368 | } | 1404 | } |
1369 | 1405 | ||
@@ -1373,27 +1409,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
1373 | if (engines.Length == 0) | 1409 | if (engines.Length == 0) |
1374 | return; | 1410 | return; |
1375 | 1411 | ||
1412 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | ||
1376 | 1413 | ||
1377 | Items.LockItemsForRead(true); | 1414 | foreach (TaskInventoryItem item in scripts) |
1378 | |||
1379 | foreach (TaskInventoryItem item in m_items.Values) | ||
1380 | { | 1415 | { |
1381 | if (item.InvType == (int)InventoryType.LSL) | 1416 | foreach (IScriptModule engine in engines) |
1382 | { | 1417 | { |
1383 | foreach (IScriptModule engine in engines) | 1418 | if (engine != null) |
1384 | { | 1419 | { |
1385 | if (engine != null) | 1420 | // m_log.DebugFormat( |
1386 | { | 1421 | // "[PRIM INVENTORY]: Resuming script {0} {1} for {2}, OwnerChanged {3}", |
1387 | if (item.OwnerChanged) | 1422 | // item.Name, item.ItemID, item.OwnerID, item.OwnerChanged); |
1388 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | 1423 | |
1389 | item.OwnerChanged = false; | 1424 | engine.ResumeScript(item.ItemID); |
1390 | engine.ResumeScript(item.ItemID); | 1425 | |
1391 | } | 1426 | if (item.OwnerChanged) |
1427 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | ||
1428 | |||
1429 | item.OwnerChanged = false; | ||
1392 | } | 1430 | } |
1393 | } | 1431 | } |
1394 | } | 1432 | } |
1395 | |||
1396 | Items.LockItemsForRead(false); | ||
1397 | } | 1433 | } |
1398 | } | 1434 | } |
1399 | } | 1435 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 212720e..99ad685 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -45,6 +45,7 @@ using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags; | |||
45 | 45 | ||
46 | namespace OpenSim.Region.Framework.Scenes | 46 | namespace OpenSim.Region.Framework.Scenes |
47 | { | 47 | { |
48 | [Flags] | ||
48 | enum ScriptControlled : uint | 49 | enum ScriptControlled : uint |
49 | { | 50 | { |
50 | CONTROL_ZERO = 0, | 51 | CONTROL_ZERO = 0, |
@@ -76,6 +77,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
76 | // { | 77 | // { |
77 | // m_log.Debug("[SCENE PRESENCE] Destructor called"); | 78 | // m_log.Debug("[SCENE PRESENCE] Destructor called"); |
78 | // } | 79 | // } |
80 | private void TriggerScenePresenceUpdated() | ||
81 | { | ||
82 | if (m_scene != null) | ||
83 | m_scene.EventManager.TriggerScenePresenceUpdated(this); | ||
84 | } | ||
79 | 85 | ||
80 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 86 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
81 | 87 | ||
@@ -497,6 +503,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
497 | //m_log.DebugFormat( | 503 | //m_log.DebugFormat( |
498 | // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", | 504 | // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", |
499 | // Scene.RegionInfo.RegionName, Name, m_pos); | 505 | // Scene.RegionInfo.RegionName, Name, m_pos); |
506 | TriggerScenePresenceUpdated(); | ||
500 | } | 507 | } |
501 | } | 508 | } |
502 | 509 | ||
@@ -516,6 +523,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
516 | return; | 523 | return; |
517 | 524 | ||
518 | m_pos = value; | 525 | m_pos = value; |
526 | TriggerScenePresenceUpdated(); | ||
519 | } | 527 | } |
520 | } | 528 | } |
521 | 529 | ||
@@ -1084,23 +1092,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1084 | /// <param name="pos"></param> | 1092 | /// <param name="pos"></param> |
1085 | public void Teleport(Vector3 pos) | 1093 | public void Teleport(Vector3 pos) |
1086 | { | 1094 | { |
1087 | bool isFlying = Flying; | 1095 | TeleportWithMomentum(pos, Vector3.Zero); |
1088 | RemoveFromPhysicalScene(); | ||
1089 | Velocity = Vector3.Zero; | ||
1090 | CheckLandingPoint(ref pos); | ||
1091 | AbsolutePosition = pos; | ||
1092 | AddToPhysicalScene(isFlying); | ||
1093 | |||
1094 | SendTerseUpdateToAllClients(); | ||
1095 | } | ||
1096 | |||
1097 | public void TeleportWithMomentum(Vector3 pos) | ||
1098 | { | ||
1099 | TeleportWithMomentum(pos, null); | ||
1100 | } | 1096 | } |
1101 | 1097 | ||
1102 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1098 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
1103 | { | 1099 | { |
1100 | if (ParentID != (uint)0) | ||
1101 | StandUp(); | ||
1104 | bool isFlying = Flying; | 1102 | bool isFlying = Flying; |
1105 | Vector3 vel = Velocity; | 1103 | Vector3 vel = Velocity; |
1106 | RemoveFromPhysicalScene(); | 1104 | RemoveFromPhysicalScene(); |
@@ -1280,17 +1278,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
1280 | 1278 | ||
1281 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1279 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1282 | MakeRootAgent(AbsolutePosition, flying); | 1280 | MakeRootAgent(AbsolutePosition, flying); |
1281 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); | ||
1282 | |||
1283 | // m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); | ||
1283 | 1284 | ||
1284 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) | 1285 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) |
1285 | { | 1286 | { |
1286 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); | 1287 | // We cannot sleep here since this would hold up the inbound packet processing thread, as |
1288 | // CompleteMovement() is executed synchronously. However, it might be better to delay the release | ||
1289 | // here until we know for sure that the agent is active in this region. Sending AgentMovementComplete | ||
1290 | // is not enough for Imprudence clients - there appears to be a small delay (<200ms, <500ms) until they regard this | ||
1291 | // region as the current region, meaning that a close sent before then will fail the teleport. | ||
1292 | // System.Threading.Thread.Sleep(2000); | ||
1293 | |||
1294 | m_log.DebugFormat( | ||
1295 | "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}", | ||
1296 | client.Name, client.AgentId, m_callbackURI); | ||
1297 | |||
1287 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); | 1298 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); |
1288 | m_callbackURI = null; | 1299 | m_callbackURI = null; |
1289 | } | 1300 | } |
1290 | 1301 | ||
1291 | // m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); | ||
1292 | |||
1293 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); | ||
1294 | ValidateAndSendAppearanceAndAgentData(); | 1302 | ValidateAndSendAppearanceAndAgentData(); |
1295 | 1303 | ||
1296 | // Create child agents in neighbouring regions | 1304 | // Create child agents in neighbouring regions |
@@ -1305,7 +1313,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1305 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1313 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1306 | } | 1314 | } |
1307 | 1315 | ||
1308 | |||
1309 | // m_log.DebugFormat( | 1316 | // m_log.DebugFormat( |
1310 | // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", | 1317 | // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", |
1311 | // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); | 1318 | // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); |
@@ -1358,7 +1365,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1358 | { | 1365 | { |
1359 | // m_log.DebugFormat( | 1366 | // m_log.DebugFormat( |
1360 | // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", | 1367 | // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", |
1361 | // Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags); | 1368 | // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); |
1362 | 1369 | ||
1363 | if (IsChildAgent) | 1370 | if (IsChildAgent) |
1364 | { | 1371 | { |
@@ -1468,14 +1475,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1468 | } | 1475 | } |
1469 | } | 1476 | } |
1470 | 1477 | ||
1471 | lock (scriptedcontrols) | 1478 | uint flagsForScripts = (uint)flags; |
1472 | { | 1479 | flags = RemoveIgnoredControls(flags, IgnoredControls); |
1473 | if (scriptedcontrols.Count > 0) | ||
1474 | { | ||
1475 | SendControlToScripts((uint)flags); | ||
1476 | flags = RemoveIgnoredControls(flags, IgnoredControls); | ||
1477 | } | ||
1478 | } | ||
1479 | 1480 | ||
1480 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1481 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1481 | HandleAgentSitOnGround(); | 1482 | HandleAgentSitOnGround(); |
@@ -1489,6 +1490,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1489 | PhysicsActor actor = PhysicsActor; | 1490 | PhysicsActor actor = PhysicsActor; |
1490 | if (actor == null) | 1491 | if (actor == null) |
1491 | { | 1492 | { |
1493 | SendControlsToScripts(flagsForScripts); | ||
1492 | return; | 1494 | return; |
1493 | } | 1495 | } |
1494 | 1496 | ||
@@ -1568,7 +1570,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1568 | MovementFlag |= (byte)nudgehack; | 1570 | MovementFlag |= (byte)nudgehack; |
1569 | } | 1571 | } |
1570 | 1572 | ||
1571 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); | 1573 | //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); |
1572 | MovementFlag += (byte)(uint)DCF; | 1574 | MovementFlag += (byte)(uint)DCF; |
1573 | update_movementflag = true; | 1575 | update_movementflag = true; |
1574 | } | 1576 | } |
@@ -1581,7 +1583,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1581 | && ((MovementFlag & (byte)nudgehack) == nudgehack)) | 1583 | && ((MovementFlag & (byte)nudgehack) == nudgehack)) |
1582 | ) // This or is for Nudge forward | 1584 | ) // This or is for Nudge forward |
1583 | { | 1585 | { |
1584 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); | 1586 | //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); |
1585 | MovementFlag -= ((byte)(uint)DCF); | 1587 | MovementFlag -= ((byte)(uint)DCF); |
1586 | update_movementflag = true; | 1588 | update_movementflag = true; |
1587 | 1589 | ||
@@ -1662,11 +1664,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1662 | // } | 1664 | // } |
1663 | // } | 1665 | // } |
1664 | 1666 | ||
1665 | // if (update_movementflag && ParentID == 0) | 1667 | if (update_movementflag && ParentID == 0) |
1666 | // Animator.UpdateMovementAnimations(); | 1668 | Animator.UpdateMovementAnimations(); |
1669 | |||
1670 | SendControlsToScripts(flagsForScripts); | ||
1667 | } | 1671 | } |
1668 | 1672 | ||
1669 | m_scene.EventManager.TriggerOnClientMovement(this); | 1673 | m_scene.EventManager.TriggerOnClientMovement(this); |
1674 | TriggerScenePresenceUpdated(); | ||
1670 | } | 1675 | } |
1671 | 1676 | ||
1672 | /// <summary> | 1677 | /// <summary> |
@@ -2599,6 +2604,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2599 | 2604 | ||
2600 | m_scene.ForEachClient(SendTerseUpdateToClient); | 2605 | m_scene.ForEachClient(SendTerseUpdateToClient); |
2601 | } | 2606 | } |
2607 | TriggerScenePresenceUpdated(); | ||
2602 | } | 2608 | } |
2603 | 2609 | ||
2604 | public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) | 2610 | public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
@@ -3081,8 +3087,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3081 | x = x / Constants.RegionSize; | 3087 | x = x / Constants.RegionSize; |
3082 | y = y / Constants.RegionSize; | 3088 | y = y / Constants.RegionSize; |
3083 | 3089 | ||
3084 | //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); | 3090 | // m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); |
3085 | //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); | 3091 | // m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); |
3086 | if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) | 3092 | if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) |
3087 | { | 3093 | { |
3088 | byebyeRegions.Add(handle); | 3094 | byebyeRegions.Add(handle); |
@@ -3384,6 +3390,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3384 | Velocity = force; | 3390 | Velocity = force; |
3385 | 3391 | ||
3386 | m_forceToApply = null; | 3392 | m_forceToApply = null; |
3393 | TriggerScenePresenceUpdated(); | ||
3387 | } | 3394 | } |
3388 | } | 3395 | } |
3389 | 3396 | ||
@@ -3489,25 +3496,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
3489 | } | 3496 | } |
3490 | } | 3497 | } |
3491 | 3498 | ||
3492 | RaiseCollisionScriptEvents(coldata); | 3499 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3493 | 3500 | if (Invulnerable || GodLevel > 0) | |
3494 | if (Invulnerable) | ||
3495 | return; | 3501 | return; |
3496 | 3502 | ||
3503 | // The following may be better in the ICombatModule | ||
3504 | // probably tweaking of the values for ground and normal prim collisions will be needed | ||
3497 | float starthealth = Health; | 3505 | float starthealth = Health; |
3498 | uint killerObj = 0; | 3506 | uint killerObj = 0; |
3507 | SceneObjectPart part = null; | ||
3499 | foreach (uint localid in coldata.Keys) | 3508 | foreach (uint localid in coldata.Keys) |
3500 | { | 3509 | { |
3501 | SceneObjectPart part = Scene.GetSceneObjectPart(localid); | 3510 | if (localid == 0) |
3502 | 3511 | { | |
3503 | if (part != null && part.ParentGroup.Damage != -1.0f) | 3512 | part = null; |
3504 | Health -= part.ParentGroup.Damage; | 3513 | } |
3505 | else | 3514 | else |
3506 | { | 3515 | { |
3507 | if (coldata[localid].PenetrationDepth >= 0.10f) | 3516 | part = Scene.GetSceneObjectPart(localid); |
3517 | } | ||
3518 | if (part != null) | ||
3519 | { | ||
3520 | // Ignore if it has been deleted or volume detect | ||
3521 | if (!part.ParentGroup.IsDeleted && !part.ParentGroup.IsVolumeDetect) | ||
3522 | { | ||
3523 | if (part.ParentGroup.Damage > 0.0f) | ||
3524 | { | ||
3525 | // Something with damage... | ||
3526 | Health -= part.ParentGroup.Damage; | ||
3527 | part.ParentGroup.Scene.DeleteSceneObject(part.ParentGroup, false); | ||
3528 | } | ||
3529 | else | ||
3530 | { | ||
3531 | // An ordinary prim | ||
3532 | if (coldata[localid].PenetrationDepth >= 0.10f) | ||
3533 | Health -= coldata[localid].PenetrationDepth * 5.0f; | ||
3534 | } | ||
3535 | } | ||
3536 | } | ||
3537 | else | ||
3538 | { | ||
3539 | // 0 is the ground | ||
3540 | // what about collisions with other avatars? | ||
3541 | if (localid == 0 && coldata[localid].PenetrationDepth >= 0.10f) | ||
3508 | Health -= coldata[localid].PenetrationDepth * 5.0f; | 3542 | Health -= coldata[localid].PenetrationDepth * 5.0f; |
3509 | } | 3543 | } |
3510 | 3544 | ||
3545 | |||
3511 | if (Health <= 0.0f) | 3546 | if (Health <= 0.0f) |
3512 | { | 3547 | { |
3513 | if (localid != 0) | 3548 | if (localid != 0) |
@@ -3523,7 +3558,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3523 | ControllingClient.SendHealth(Health); | 3558 | ControllingClient.SendHealth(Health); |
3524 | } | 3559 | } |
3525 | if (Health <= 0) | 3560 | if (Health <= 0) |
3561 | { | ||
3526 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); | 3562 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); |
3563 | } | ||
3564 | if (starthealth == Health && Health < 100.0f) | ||
3565 | { | ||
3566 | Health += 0.03f; | ||
3567 | if (Health > 100.0f) | ||
3568 | Health = 100.0f; | ||
3569 | ControllingClient.SendHealth(Health); | ||
3570 | } | ||
3527 | } | 3571 | } |
3528 | } | 3572 | } |
3529 | 3573 | ||
@@ -3605,6 +3649,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
3605 | return m_attachments.Count > 0; | 3649 | return m_attachments.Count > 0; |
3606 | } | 3650 | } |
3607 | 3651 | ||
3652 | /// <summary> | ||
3653 | /// Returns the total count of scripts in all parts inventories. | ||
3654 | /// </summary> | ||
3655 | public int ScriptCount() | ||
3656 | { | ||
3657 | int count = 0; | ||
3658 | lock (m_attachments) | ||
3659 | { | ||
3660 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3661 | { | ||
3662 | if (gobj != null) | ||
3663 | { | ||
3664 | count += gobj.ScriptCount(); | ||
3665 | } | ||
3666 | } | ||
3667 | } | ||
3668 | return count; | ||
3669 | } | ||
3670 | |||
3671 | /// <summary> | ||
3672 | /// A float the value is a representative execution time in milliseconds of all scripts in all attachments. | ||
3673 | /// </summary> | ||
3674 | public float ScriptExecutionTime() | ||
3675 | { | ||
3676 | float time = 0.0f; | ||
3677 | lock (m_attachments) | ||
3678 | { | ||
3679 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3680 | { | ||
3681 | if (gobj != null) | ||
3682 | { | ||
3683 | time += gobj.ScriptExecutionTime(); | ||
3684 | } | ||
3685 | } | ||
3686 | } | ||
3687 | return time; | ||
3688 | } | ||
3689 | |||
3690 | /// <summary> | ||
3691 | /// Returns the total count of running scripts in all parts. | ||
3692 | /// </summary> | ||
3693 | public int RunningScriptCount() | ||
3694 | { | ||
3695 | int count = 0; | ||
3696 | lock (m_attachments) | ||
3697 | { | ||
3698 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3699 | { | ||
3700 | if (gobj != null) | ||
3701 | { | ||
3702 | count += gobj.RunningScriptCount(); | ||
3703 | } | ||
3704 | } | ||
3705 | } | ||
3706 | return count; | ||
3707 | } | ||
3708 | |||
3608 | public bool HasScriptedAttachments() | 3709 | public bool HasScriptedAttachments() |
3609 | { | 3710 | { |
3610 | lock (m_attachments) | 3711 | lock (m_attachments) |
@@ -3822,77 +3923,92 @@ namespace OpenSim.Region.Framework.Scenes | |||
3822 | } | 3923 | } |
3823 | } | 3924 | } |
3824 | 3925 | ||
3825 | internal void SendControlToScripts(uint flags) | 3926 | private void SendControlsToScripts(uint flags) |
3826 | { | 3927 | { |
3827 | ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; | 3928 | // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script |
3828 | 3929 | // (e.g., a walking script) checks which animation is active it will be the correct animation. | |
3829 | if (MouseDown) | 3930 | lock (scriptedcontrols) |
3830 | { | 3931 | { |
3831 | allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); | 3932 | if (scriptedcontrols.Count <= 0) |
3832 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) | 3933 | return; |
3934 | |||
3935 | ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; | ||
3936 | |||
3937 | if (MouseDown) | ||
3833 | { | 3938 | { |
3834 | allflags = ScriptControlled.CONTROL_ZERO; | 3939 | allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); |
3940 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) | ||
3941 | { | ||
3942 | allflags = ScriptControlled.CONTROL_ZERO; | ||
3943 | MouseDown = true; | ||
3944 | } | ||
3945 | } | ||
3946 | |||
3947 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) | ||
3948 | { | ||
3949 | allflags |= ScriptControlled.CONTROL_ML_LBUTTON; | ||
3835 | MouseDown = true; | 3950 | MouseDown = true; |
3836 | } | 3951 | } |
3837 | } | 3952 | |
3953 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) | ||
3954 | { | ||
3955 | allflags |= ScriptControlled.CONTROL_LBUTTON; | ||
3956 | MouseDown = true; | ||
3957 | } | ||
3958 | |||
3959 | // find all activated controls, whether the scripts are interested in them or not | ||
3960 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) | ||
3961 | { | ||
3962 | allflags |= ScriptControlled.CONTROL_FWD; | ||
3963 | } | ||
3964 | |||
3965 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) | ||
3966 | { | ||
3967 | allflags |= ScriptControlled.CONTROL_BACK; | ||
3968 | } | ||
3969 | |||
3970 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) | ||
3971 | { | ||
3972 | allflags |= ScriptControlled.CONTROL_UP; | ||
3973 | } | ||
3974 | |||
3975 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) | ||
3976 | { | ||
3977 | allflags |= ScriptControlled.CONTROL_DOWN; | ||
3978 | } | ||
3838 | 3979 | ||
3839 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) | 3980 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) |
3840 | { | 3981 | { |
3841 | allflags |= ScriptControlled.CONTROL_ML_LBUTTON; | 3982 | allflags |= ScriptControlled.CONTROL_LEFT; |
3842 | MouseDown = true; | 3983 | } |
3843 | } | 3984 | |
3844 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) | 3985 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) |
3845 | { | 3986 | { |
3846 | allflags |= ScriptControlled.CONTROL_LBUTTON; | 3987 | allflags |= ScriptControlled.CONTROL_RIGHT; |
3847 | MouseDown = true; | 3988 | } |
3848 | } | 3989 | |
3990 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) | ||
3991 | { | ||
3992 | allflags |= ScriptControlled.CONTROL_ROT_RIGHT; | ||
3993 | } | ||
3994 | |||
3995 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) | ||
3996 | { | ||
3997 | allflags |= ScriptControlled.CONTROL_ROT_LEFT; | ||
3998 | } | ||
3849 | 3999 | ||
3850 | // find all activated controls, whether the scripts are interested in them or not | 4000 | // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that |
3851 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) | 4001 | if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) |
3852 | { | ||
3853 | allflags |= ScriptControlled.CONTROL_FWD; | ||
3854 | } | ||
3855 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) | ||
3856 | { | ||
3857 | allflags |= ScriptControlled.CONTROL_BACK; | ||
3858 | } | ||
3859 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) | ||
3860 | { | ||
3861 | allflags |= ScriptControlled.CONTROL_UP; | ||
3862 | } | ||
3863 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) | ||
3864 | { | ||
3865 | allflags |= ScriptControlled.CONTROL_DOWN; | ||
3866 | } | ||
3867 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) | ||
3868 | { | ||
3869 | allflags |= ScriptControlled.CONTROL_LEFT; | ||
3870 | } | ||
3871 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) | ||
3872 | { | ||
3873 | allflags |= ScriptControlled.CONTROL_RIGHT; | ||
3874 | } | ||
3875 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) | ||
3876 | { | ||
3877 | allflags |= ScriptControlled.CONTROL_ROT_RIGHT; | ||
3878 | } | ||
3879 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) | ||
3880 | { | ||
3881 | allflags |= ScriptControlled.CONTROL_ROT_LEFT; | ||
3882 | } | ||
3883 | // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that | ||
3884 | if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) | ||
3885 | { | ||
3886 | lock (scriptedcontrols) | ||
3887 | { | 4002 | { |
3888 | foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) | 4003 | foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) |
3889 | { | 4004 | { |
3890 | UUID scriptUUID = kvp.Key; | 4005 | UUID scriptUUID = kvp.Key; |
3891 | ScriptControllers scriptControlData = kvp.Value; | 4006 | ScriptControllers scriptControlData = kvp.Value; |
3892 | 4007 | ||
3893 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us | 4008 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us |
3894 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle | 4009 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle |
3895 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits | 4010 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits |
4011 | |||
3896 | if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) | 4012 | if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) |
3897 | { | 4013 | { |
3898 | // only send if still pressed or just changed | 4014 | // only send if still pressed or just changed |
@@ -3900,9 +4016,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3900 | } | 4016 | } |
3901 | } | 4017 | } |
3902 | } | 4018 | } |
4019 | |||
4020 | LastCommands = allflags; | ||
3903 | } | 4021 | } |
3904 | |||
3905 | LastCommands = allflags; | ||
3906 | } | 4022 | } |
3907 | 4023 | ||
3908 | internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) | 4024 | internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) |
@@ -3982,7 +4098,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3982 | land.LandData.UserLocation != Vector3.Zero && | 4098 | land.LandData.UserLocation != Vector3.Zero && |
3983 | land.LandData.OwnerID != m_uuid && | 4099 | land.LandData.OwnerID != m_uuid && |
3984 | (!m_scene.Permissions.IsGod(m_uuid)) && | 4100 | (!m_scene.Permissions.IsGod(m_uuid)) && |
3985 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | 4101 | (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid))) |
3986 | { | 4102 | { |
3987 | float curr = Vector3.Distance(AbsolutePosition, pos); | 4103 | float curr = Vector3.Distance(AbsolutePosition, pos); |
3988 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | 4104 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) |
@@ -4002,7 +4118,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4002 | { | 4118 | { |
4003 | if (GodLevel < 200 && | 4119 | if (GodLevel < 200 && |
4004 | ((!m_scene.Permissions.IsGod(m_uuid) && | 4120 | ((!m_scene.Permissions.IsGod(m_uuid) && |
4005 | !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || | 4121 | !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || |
4006 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || | 4122 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || |
4007 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) | 4123 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) |
4008 | { | 4124 | { |
@@ -4076,7 +4192,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4076 | GodLevel < 200 && | 4192 | GodLevel < 200 && |
4077 | ((land.LandData.OwnerID != m_uuid && | 4193 | ((land.LandData.OwnerID != m_uuid && |
4078 | !m_scene.Permissions.IsGod(m_uuid) && | 4194 | !m_scene.Permissions.IsGod(m_uuid) && |
4079 | !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || | 4195 | !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || |
4080 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || | 4196 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || |
4081 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) | 4197 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) |
4082 | { | 4198 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs index ab6311b..4a21dc9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.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.IO; | ||
30 | using System.Text; | 31 | using System.Text; |
31 | using NUnit.Framework; | 32 | using NUnit.Framework; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
@@ -68,11 +69,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
68 | Vector3 position = new Vector3(200,200,21); | 69 | Vector3 position = new Vector3(200,200,21); |
69 | 70 | ||
70 | foreach (Border b in testborders) | 71 | foreach (Border b in testborders) |
71 | { | ||
72 | Assert.That(!b.TestCross(position)); | 72 | Assert.That(!b.TestCross(position)); |
73 | 73 | ||
74 | } | ||
75 | |||
76 | position = new Vector3(200,280,21); | 74 | position = new Vector3(200,280,21); |
77 | Assert.That(NorthBorder.TestCross(position)); | 75 | Assert.That(NorthBorder.TestCross(position)); |
78 | 76 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs index a5d2b23..ea9fc93 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs | |||
@@ -45,7 +45,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
45 | { | 45 | { |
46 | static public Random random; | 46 | static public Random random; |
47 | SceneObjectGroup found; | 47 | SceneObjectGroup found; |
48 | Scene scene = SceneHelpers.SetupScene(); | 48 | Scene scene = new SceneHelpers().SetupScene(); |
49 | 49 | ||
50 | [Test] | 50 | [Test] |
51 | public void T010_AddObjects() | 51 | public void T010_AddObjects() |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs index 9a60e50..d23c965 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs | |||
@@ -26,7 +26,9 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Text; | ||
30 | using NUnit.Framework; | 32 | using NUnit.Framework; |
31 | using OpenMetaverse; | 33 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -44,7 +46,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
44 | public void TestDuplicateObject() | 46 | public void TestDuplicateObject() |
45 | { | 47 | { |
46 | TestHelpers.InMethod(); | 48 | TestHelpers.InMethod(); |
47 | Scene scene = SceneHelpers.SetupScene(); | 49 | // TestHelpers.EnableLogging(); |
50 | |||
51 | Scene scene = new SceneHelpers().SetupScene(); | ||
48 | 52 | ||
49 | UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010"); | 53 | UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010"); |
50 | string part1Name = "part1"; | 54 | string part1Name = "part1"; |
@@ -82,6 +86,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
82 | Assert.That(dupePart1.PhysActor, Is.Not.Null); | 86 | Assert.That(dupePart1.PhysActor, Is.Not.Null); |
83 | Assert.That(dupePart2.PhysActor, Is.Not.Null); | 87 | Assert.That(dupePart2.PhysActor, Is.Not.Null); |
84 | */ | 88 | */ |
89 | |||
90 | // TestHelpers.DisableLogging(); | ||
85 | } | 91 | } |
86 | } | 92 | } |
87 | } \ No newline at end of file | 93 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 7737d8e..453e077 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | |||
@@ -88,7 +88,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
88 | { | 88 | { |
89 | TestHelpers.InMethod(); | 89 | TestHelpers.InMethod(); |
90 | 90 | ||
91 | Scene scene = SceneHelpers.SetupScene(); | 91 | Scene scene = new SceneHelpers().SetupScene(); |
92 | int partsToTestCount = 3; | 92 | int partsToTestCount = 3; |
93 | 93 | ||
94 | SceneObjectGroup so | 94 | SceneObjectGroup so |
@@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
118 | { | 118 | { |
119 | TestHelpers.InMethod(); | 119 | TestHelpers.InMethod(); |
120 | 120 | ||
121 | Scene scene = SceneHelpers.SetupScene(); | 121 | Scene scene = new SceneHelpers().SetupScene(); |
122 | 122 | ||
123 | string obj1Name = "Alfred"; | 123 | string obj1Name = "Alfred"; |
124 | string obj2Name = "Betty"; | 124 | string obj2Name = "Betty"; |
@@ -152,7 +152,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
152 | { | 152 | { |
153 | TestHelpers.InMethod(); | 153 | TestHelpers.InMethod(); |
154 | 154 | ||
155 | Scene scene = SceneHelpers.SetupScene(); | 155 | Scene scene = new SceneHelpers().SetupScene(); |
156 | int partsToTestCount = 3; | 156 | int partsToTestCount = 3; |
157 | 157 | ||
158 | SceneObjectGroup so | 158 | SceneObjectGroup so |
@@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
185 | { | 185 | { |
186 | TestHelpers.InMethod(); | 186 | TestHelpers.InMethod(); |
187 | 187 | ||
188 | TestScene scene = SceneHelpers.SetupScene(); | 188 | TestScene scene = new SceneHelpers().SetupScene(); |
189 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 189 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); |
190 | scene.DeleteSceneObject(part.ParentGroup, false); | 190 | scene.DeleteSceneObject(part.ParentGroup, false); |
191 | 191 | ||
@@ -204,7 +204,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
204 | 204 | ||
205 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | 205 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
206 | 206 | ||
207 | TestScene scene = SceneHelpers.SetupScene(); | 207 | TestScene scene = new SceneHelpers().SetupScene(); |
208 | 208 | ||
209 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | 209 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. |
210 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | 210 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index 654b1a2..0076f41 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs | |||
@@ -61,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
61 | 61 | ||
62 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 62 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
63 | 63 | ||
64 | TestScene scene = SceneHelpers.SetupScene(); | 64 | TestScene scene = new SceneHelpers().SetupScene(); |
65 | IConfigSource configSource = new IniConfigSource(); | 65 | IConfigSource configSource = new IniConfigSource(); |
66 | IConfig config = configSource.AddConfig("Startup"); | 66 | IConfig config = configSource.AddConfig("Startup"); |
67 | config.Set("serverside_object_permissions", true); | 67 | config.Set("serverside_object_permissions", true); |
@@ -100,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
100 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 100 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
101 | UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); | 101 | UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); |
102 | 102 | ||
103 | TestScene scene = SceneHelpers.SetupScene(); | 103 | TestScene scene = new SceneHelpers().SetupScene(); |
104 | IConfigSource configSource = new IniConfigSource(); | 104 | IConfigSource configSource = new IniConfigSource(); |
105 | IConfig config = configSource.AddConfig("Startup"); | 105 | IConfig config = configSource.AddConfig("Startup"); |
106 | config.Set("serverside_object_permissions", true); | 106 | config.Set("serverside_object_permissions", true); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index be5b4a8..1add3dd 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs | |||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
55 | UUID ownerId = TestHelpers.ParseTail(0x1); | 55 | UUID ownerId = TestHelpers.ParseTail(0x1); |
56 | int nParts = 3; | 56 | int nParts = 3; |
57 | 57 | ||
58 | TestScene scene = SceneHelpers.SetupScene(); | 58 | TestScene scene = new SceneHelpers().SetupScene(); |
59 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(nParts, ownerId, "TestLinkToSelf_", 0x10); | 59 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(nParts, ownerId, "TestLinkToSelf_", 0x10); |
60 | scene.AddSceneObject(sog1); | 60 | scene.AddSceneObject(sog1); |
61 | scene.LinkObjects(ownerId, sog1.LocalId, new List<uint>() { sog1.Parts[1].LocalId }); | 61 | scene.LinkObjects(ownerId, sog1.LocalId, new List<uint>() { sog1.Parts[1].LocalId }); |
@@ -71,7 +71,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
71 | 71 | ||
72 | bool debugtest = false; | 72 | bool debugtest = false; |
73 | 73 | ||
74 | Scene scene = SceneHelpers.SetupScene(); | 74 | Scene scene = new SceneHelpers().SetupScene(); |
75 | SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); | 75 | SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); |
76 | SceneObjectGroup grp1 = part1.ParentGroup; | 76 | SceneObjectGroup grp1 = part1.ParentGroup; |
77 | SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); | 77 | SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); |
@@ -153,7 +153,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
153 | 153 | ||
154 | bool debugtest = false; | 154 | bool debugtest = false; |
155 | 155 | ||
156 | Scene scene = SceneHelpers.SetupScene(); | 156 | Scene scene = new SceneHelpers().SetupScene(); |
157 | SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); | 157 | SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); |
158 | SceneObjectGroup grp1 = part1.ParentGroup; | 158 | SceneObjectGroup grp1 = part1.ParentGroup; |
159 | SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); | 159 | SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); |
@@ -286,7 +286,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
286 | TestHelpers.InMethod(); | 286 | TestHelpers.InMethod(); |
287 | //log4net.Config.XmlConfigurator.Configure(); | 287 | //log4net.Config.XmlConfigurator.Configure(); |
288 | 288 | ||
289 | TestScene scene = SceneHelpers.SetupScene(); | 289 | TestScene scene = new SceneHelpers().SetupScene(); |
290 | 290 | ||
291 | string rootPartName = "rootpart"; | 291 | string rootPartName = "rootpart"; |
292 | UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); | 292 | UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); |
@@ -325,7 +325,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
325 | TestHelpers.InMethod(); | 325 | TestHelpers.InMethod(); |
326 | //log4net.Config.XmlConfigurator.Configure(); | 326 | //log4net.Config.XmlConfigurator.Configure(); |
327 | 327 | ||
328 | TestScene scene = SceneHelpers.SetupScene(); | 328 | TestScene scene = new SceneHelpers().SetupScene(); |
329 | 329 | ||
330 | string rootPartName = "rootpart"; | 330 | string rootPartName = "rootpart"; |
331 | UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); | 331 | UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index b49c6e7..0a94c19 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
52 | TestHelpers.InMethod(); | 52 | TestHelpers.InMethod(); |
53 | // log4net.Config.XmlConfigurator.Configure(); | 53 | // log4net.Config.XmlConfigurator.Configure(); |
54 | 54 | ||
55 | Scene scene = SceneHelpers.SetupScene(); | 55 | Scene scene = new SceneHelpers().SetupScene(); |
56 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene).ParentGroup; | 56 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene).ParentGroup; |
57 | 57 | ||
58 | g1.GroupResize(new Vector3(2, 3, 4)); | 58 | g1.GroupResize(new Vector3(2, 3, 4)); |
@@ -75,7 +75,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
75 | TestHelpers.InMethod(); | 75 | TestHelpers.InMethod(); |
76 | //log4net.Config.XmlConfigurator.Configure(); | 76 | //log4net.Config.XmlConfigurator.Configure(); |
77 | 77 | ||
78 | Scene scene = SceneHelpers.SetupScene(); | 78 | Scene scene = new SceneHelpers().SetupScene(); |
79 | 79 | ||
80 | SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(2, UUID.Zero); | 80 | SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(2, UUID.Zero); |
81 | g1.RootPart.Scale = new Vector3(2, 3, 4); | 81 | g1.RootPart.Scale = new Vector3(2, 3, 4); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs index c582cf6..d2361f8 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
52 | // UUID itemId = TestHelpers.ParseTail(0x2); | 52 | // UUID itemId = TestHelpers.ParseTail(0x2); |
53 | string itemName = "Test Script Item"; | 53 | string itemName = "Test Script Item"; |
54 | 54 | ||
55 | Scene scene = SceneHelpers.SetupScene(); | 55 | Scene scene = new SceneHelpers().SetupScene(); |
56 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); | 56 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); |
57 | scene.AddNewSceneObject(so, true); | 57 | scene.AddNewSceneObject(so, true); |
58 | 58 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs new file mode 100644 index 0000000..6d255aa --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs | |||
@@ -0,0 +1,154 @@ | |||
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.Reflection; | ||
30 | using System.Threading; | ||
31 | using NUnit.Framework; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Tests.Common; | ||
37 | using OpenSim.Tests.Common.Mock; | ||
38 | |||
39 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.) | ||
43 | /// </summary> | ||
44 | [TestFixture] | ||
45 | public class SceneObjectSpatialTests | ||
46 | { | ||
47 | TestScene m_scene; | ||
48 | UUID m_ownerId = TestHelpers.ParseTail(0x1); | ||
49 | |||
50 | [SetUp] | ||
51 | public void SetUp() | ||
52 | { | ||
53 | m_scene = new SceneHelpers().SetupScene(); | ||
54 | } | ||
55 | |||
56 | [Test] | ||
57 | public void TestGetSceneObjectGroupPosition() | ||
58 | { | ||
59 | TestHelpers.InMethod(); | ||
60 | |||
61 | Vector3 position = new Vector3(10, 20, 30); | ||
62 | |||
63 | SceneObjectGroup so | ||
64 | = SceneHelpers.CreateSceneObject(1, m_ownerId, "obj1", 0x10); | ||
65 | so.AbsolutePosition = position; | ||
66 | m_scene.AddNewSceneObject(so, false); | ||
67 | |||
68 | Assert.That(so.AbsolutePosition, Is.EqualTo(position)); | ||
69 | } | ||
70 | |||
71 | [Test] | ||
72 | public void TestGetRootPartPosition() | ||
73 | { | ||
74 | TestHelpers.InMethod(); | ||
75 | |||
76 | Vector3 partPosition = new Vector3(10, 20, 30); | ||
77 | |||
78 | SceneObjectGroup so | ||
79 | = SceneHelpers.CreateSceneObject(1, m_ownerId, "obj1", 0x10); | ||
80 | so.AbsolutePosition = partPosition; | ||
81 | m_scene.AddNewSceneObject(so, false); | ||
82 | |||
83 | Assert.That(so.RootPart.AbsolutePosition, Is.EqualTo(partPosition)); | ||
84 | Assert.That(so.RootPart.GroupPosition, Is.EqualTo(partPosition)); | ||
85 | Assert.That(so.RootPart.GetWorldPosition(), Is.EqualTo(partPosition)); | ||
86 | Assert.That(so.RootPart.RelativePosition, Is.EqualTo(partPosition)); | ||
87 | Assert.That(so.RootPart.OffsetPosition, Is.EqualTo(Vector3.Zero)); | ||
88 | } | ||
89 | |||
90 | [Test] | ||
91 | public void TestGetChildPartPosition() | ||
92 | { | ||
93 | TestHelpers.InMethod(); | ||
94 | |||
95 | Vector3 rootPartPosition = new Vector3(10, 20, 30); | ||
96 | Vector3 childOffsetPosition = new Vector3(2, 3, 4); | ||
97 | |||
98 | SceneObjectGroup so | ||
99 | = SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10); | ||
100 | so.AbsolutePosition = rootPartPosition; | ||
101 | so.Parts[1].OffsetPosition = childOffsetPosition; | ||
102 | |||
103 | m_scene.AddNewSceneObject(so, false); | ||
104 | |||
105 | // Calculate child absolute position. | ||
106 | Vector3 childPosition = new Vector3(rootPartPosition + childOffsetPosition); | ||
107 | |||
108 | SceneObjectPart childPart = so.Parts[1]; | ||
109 | Assert.That(childPart.AbsolutePosition, Is.EqualTo(childPosition)); | ||
110 | Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition)); | ||
111 | Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); | ||
112 | Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); | ||
113 | Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); | ||
114 | } | ||
115 | |||
116 | [Test] | ||
117 | public void TestGetChildPartPositionAfterObjectRotation() | ||
118 | { | ||
119 | TestHelpers.InMethod(); | ||
120 | |||
121 | Vector3 rootPartPosition = new Vector3(10, 20, 30); | ||
122 | Vector3 childOffsetPosition = new Vector3(2, 3, 4); | ||
123 | |||
124 | SceneObjectGroup so | ||
125 | = SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10); | ||
126 | so.AbsolutePosition = rootPartPosition; | ||
127 | so.Parts[1].OffsetPosition = childOffsetPosition; | ||
128 | |||
129 | m_scene.AddNewSceneObject(so, false); | ||
130 | |||
131 | so.UpdateGroupRotationR(Quaternion.CreateFromEulers(0, 0, -90 * Utils.DEG_TO_RAD)); | ||
132 | |||
133 | // Calculate child absolute position. | ||
134 | Vector3 rotatedChildOffsetPosition | ||
135 | = new Vector3(childOffsetPosition.Y, -childOffsetPosition.X, childOffsetPosition.Z); | ||
136 | |||
137 | Vector3 childPosition = new Vector3(rootPartPosition + rotatedChildOffsetPosition); | ||
138 | |||
139 | SceneObjectPart childPart = so.Parts[1]; | ||
140 | |||
141 | // FIXME: Should be childPosition after rotation? | ||
142 | Assert.That(childPart.AbsolutePosition, Is.EqualTo(rootPartPosition + childOffsetPosition)); | ||
143 | |||
144 | Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition)); | ||
145 | Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); | ||
146 | |||
147 | // Relative to root part as (0, 0, 0) | ||
148 | Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); | ||
149 | |||
150 | // Relative to root part as (0, 0, 0) | ||
151 | Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); | ||
152 | } | ||
153 | } | ||
154 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 2a342d5..742c769 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using NUnit.Framework; | 31 | using NUnit.Framework; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
@@ -43,24 +44,141 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
43 | [TestFixture] | 44 | [TestFixture] |
44 | public class SceneObjectStatusTests | 45 | public class SceneObjectStatusTests |
45 | { | 46 | { |
47 | private TestScene m_scene; | ||
48 | private UUID m_ownerId = TestHelpers.ParseTail(0x1); | ||
49 | private SceneObjectGroup m_so1; | ||
50 | private SceneObjectGroup m_so2; | ||
51 | |||
52 | [SetUp] | ||
53 | public void Init() | ||
54 | { | ||
55 | m_scene = new SceneHelpers().SetupScene(); | ||
56 | m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10); | ||
57 | m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20); | ||
58 | } | ||
59 | |||
46 | [Test] | 60 | [Test] |
47 | public void TestSetPhantom() | 61 | public void TestSetPhantomSinglePrim() |
48 | { | 62 | { |
49 | TestHelpers.InMethod(); | 63 | TestHelpers.InMethod(); |
50 | 64 | ||
51 | // Scene scene = SceneSetupHelpers.SetupScene(); | 65 | m_scene.AddSceneObject(m_so1); |
52 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); | 66 | |
53 | SceneObjectPart rootPart = so.RootPart; | 67 | SceneObjectPart rootPart = m_so1.RootPart; |
54 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | 68 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); |
55 | 69 | ||
56 | so.ScriptSetPhantomStatus(true); | 70 | m_so1.ScriptSetPhantomStatus(true); |
57 | 71 | ||
58 | // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); | 72 | // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); |
59 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); | 73 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); |
60 | 74 | ||
61 | so.ScriptSetPhantomStatus(false); | 75 | m_so1.ScriptSetPhantomStatus(false); |
62 | 76 | ||
63 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | 77 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); |
64 | } | 78 | } |
79 | |||
80 | [Test] | ||
81 | public void TestSetPhysicsSinglePrim() | ||
82 | { | ||
83 | TestHelpers.InMethod(); | ||
84 | |||
85 | m_scene.AddSceneObject(m_so1); | ||
86 | |||
87 | SceneObjectPart rootPart = m_so1.RootPart; | ||
88 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
89 | |||
90 | m_so1.ScriptSetPhysicsStatus(true); | ||
91 | |||
92 | // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); | ||
93 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
94 | |||
95 | m_so1.ScriptSetPhysicsStatus(false); | ||
96 | |||
97 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
98 | } | ||
99 | |||
100 | [Test] | ||
101 | public void TestSetPhysicsLinkset() | ||
102 | { | ||
103 | TestHelpers.InMethod(); | ||
104 | |||
105 | m_scene.AddSceneObject(m_so1); | ||
106 | m_scene.AddSceneObject(m_so2); | ||
107 | |||
108 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
109 | |||
110 | m_so1.ScriptSetPhysicsStatus(true); | ||
111 | |||
112 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
113 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
114 | |||
115 | m_so1.ScriptSetPhysicsStatus(false); | ||
116 | |||
117 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
118 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None)); | ||
119 | |||
120 | m_so1.ScriptSetPhysicsStatus(true); | ||
121 | |||
122 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
123 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
124 | } | ||
125 | |||
126 | /// <summary> | ||
127 | /// Test that linking results in the correct physical status for all linkees. | ||
128 | /// </summary> | ||
129 | [Test] | ||
130 | public void TestLinkPhysicsBothPhysical() | ||
131 | { | ||
132 | TestHelpers.InMethod(); | ||
133 | |||
134 | m_scene.AddSceneObject(m_so1); | ||
135 | m_scene.AddSceneObject(m_so2); | ||
136 | |||
137 | m_so1.ScriptSetPhysicsStatus(true); | ||
138 | m_so2.ScriptSetPhysicsStatus(true); | ||
139 | |||
140 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
141 | |||
142 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
143 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
144 | } | ||
145 | |||
146 | /// <summary> | ||
147 | /// Test that linking results in the correct physical status for all linkees. | ||
148 | /// </summary> | ||
149 | [Test] | ||
150 | public void TestLinkPhysicsRootPhysicalOnly() | ||
151 | { | ||
152 | TestHelpers.InMethod(); | ||
153 | |||
154 | m_scene.AddSceneObject(m_so1); | ||
155 | m_scene.AddSceneObject(m_so2); | ||
156 | |||
157 | m_so1.ScriptSetPhysicsStatus(true); | ||
158 | |||
159 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
160 | |||
161 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
162 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// Test that linking results in the correct physical status for all linkees. | ||
167 | /// </summary> | ||
168 | [Test] | ||
169 | public void TestLinkPhysicsChildPhysicalOnly() | ||
170 | { | ||
171 | TestHelpers.InMethod(); | ||
172 | |||
173 | m_scene.AddSceneObject(m_so1); | ||
174 | m_scene.AddSceneObject(m_so2); | ||
175 | |||
176 | m_so2.ScriptSetPhysicsStatus(true); | ||
177 | |||
178 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
179 | |||
180 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
181 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None)); | ||
182 | } | ||
65 | } | 183 | } |
66 | } \ No newline at end of file | 184 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index c13d82e..c7eaff9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
58 | 58 | ||
59 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 59 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
60 | 60 | ||
61 | TestScene scene = SceneHelpers.SetupScene(); | 61 | TestScene scene = new SceneHelpers().SetupScene(); |
62 | IConfigSource configSource = new IniConfigSource(); | 62 | IConfigSource configSource = new IniConfigSource(); |
63 | 63 | ||
64 | IConfig startupConfig = configSource.AddConfig("Startup"); | 64 | IConfig startupConfig = configSource.AddConfig("Startup"); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index ed9b179..1aa48d7 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | |||
@@ -67,10 +67,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
67 | public void Init() | 67 | public void Init() |
68 | { | 68 | { |
69 | TestHelpers.InMethod(); | 69 | TestHelpers.InMethod(); |
70 | 70 | ||
71 | scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); | 71 | SceneHelpers sh = new SceneHelpers(); |
72 | scene2 = SceneHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); | 72 | |
73 | scene3 = SceneHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); | 73 | scene = sh.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); |
74 | scene2 = sh.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); | ||
75 | scene3 = sh.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); | ||
74 | 76 | ||
75 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); | 77 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); |
76 | interregionComms.Initialise(new IniConfigSource()); | 78 | interregionComms.Initialise(new IniConfigSource()); |
@@ -101,7 +103,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
101 | TestHelpers.InMethod(); | 103 | TestHelpers.InMethod(); |
102 | // log4net.Config.XmlConfigurator.Configure(); | 104 | // log4net.Config.XmlConfigurator.Configure(); |
103 | 105 | ||
104 | TestScene scene = SceneHelpers.SetupScene(); | 106 | TestScene scene = new SceneHelpers().SetupScene(); |
105 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | 107 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
106 | 108 | ||
107 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); | 109 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); |
@@ -126,7 +128,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
126 | IConfig config = configSource.AddConfig("Modules"); | 128 | IConfig config = configSource.AddConfig("Modules"); |
127 | config.Set("SimulationServices", "LocalSimulationConnectorModule"); | 129 | config.Set("SimulationServices", "LocalSimulationConnectorModule"); |
128 | 130 | ||
129 | TestScene scene = SceneHelpers.SetupScene(); | 131 | SceneHelpers sceneHelpers = new SceneHelpers(); |
132 | TestScene scene = sceneHelpers.SetupScene(); | ||
130 | SceneHelpers.SetupSceneModules(scene, configSource, lsc); | 133 | SceneHelpers.SetupSceneModules(scene, configSource, lsc); |
131 | 134 | ||
132 | UUID agentId = TestHelpers.ParseTail(0x01); | 135 | UUID agentId = TestHelpers.ParseTail(0x01); |
@@ -176,8 +179,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
176 | 179 | ||
177 | // UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); | 180 | // UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
178 | 181 | ||
179 | TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); | 182 | TestScene myScene1 = new SceneHelpers().SetupScene("Neighbour y", UUID.Random(), 1000, 1000); |
180 | TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); | 183 | TestScene myScene2 = new SceneHelpers().SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); |
181 | 184 | ||
182 | IConfigSource configSource = new IniConfigSource(); | 185 | IConfigSource configSource = new IniConfigSource(); |
183 | IConfig config = configSource.AddConfig("Startup"); | 186 | IConfig config = configSource.AddConfig("Startup"); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs index 89f8007..646e5fa 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
59 | TestHelpers.InMethod(); | 59 | TestHelpers.InMethod(); |
60 | // log4net.Config.XmlConfigurator.Configure(); | 60 | // log4net.Config.XmlConfigurator.Configure(); |
61 | 61 | ||
62 | TestScene scene = SceneHelpers.SetupScene(); | 62 | TestScene scene = new SceneHelpers().SetupScene(); |
63 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | 63 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
64 | sp.Flying = true; | 64 | sp.Flying = true; |
65 | sp.PhysicsCollisionUpdate(new CollisionEventUpdate()); | 65 | sp.PhysicsCollisionUpdate(new CollisionEventUpdate()); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs index cfea10d..1d1ff88 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs | |||
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
64 | [SetUp] | 64 | [SetUp] |
65 | public void Init() | 65 | public void Init() |
66 | { | 66 | { |
67 | m_scene = SceneHelpers.SetupScene(); | 67 | m_scene = new SceneHelpers().SetupScene(); |
68 | } | 68 | } |
69 | 69 | ||
70 | [Test] | 70 | [Test] |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs index b7b8db4..313e350 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
50 | [SetUp] | 50 | [SetUp] |
51 | public void Init() | 51 | public void Init() |
52 | { | 52 | { |
53 | m_scene = SceneHelpers.SetupScene(); | 53 | m_scene = new SceneHelpers().SetupScene(); |
54 | m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 54 | m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
55 | } | 55 | } |
56 | 56 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index bebc10c..ea4fb66 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |||
@@ -34,10 +34,13 @@ using OpenSim.Framework; | |||
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
36 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.CoreModules.Framework; | ||
38 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 39 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
38 | using OpenSim.Tests.Common; | 40 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 41 | using OpenSim.Tests.Common.Mock; |
40 | using System.Threading; | 42 | using System.IO; |
43 | using System.Text; | ||
41 | 44 | ||
42 | namespace OpenSim.Region.Framework.Scenes.Tests | 45 | namespace OpenSim.Region.Framework.Scenes.Tests |
43 | { | 46 | { |
@@ -47,145 +50,190 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
47 | [TestFixture] | 50 | [TestFixture] |
48 | public class ScenePresenceTeleportTests | 51 | public class ScenePresenceTeleportTests |
49 | { | 52 | { |
50 | /// <summary> | 53 | [TestFixtureSetUp] |
51 | /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common. | 54 | public void FixtureInit() |
52 | /// </summary> | 55 | { |
53 | /// Does not yet do what is says on the tin. | 56 | // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. |
54 | /// Commenting for now | 57 | Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; |
55 | //[Test, LongRunning] | 58 | } |
56 | public void TestSimpleNotNeighboursTeleport() | 59 | |
60 | [TestFixtureTearDown] | ||
61 | public void TearDown() | ||
62 | { | ||
63 | // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple | ||
64 | // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression | ||
65 | // tests really shouldn't). | ||
66 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | ||
67 | } | ||
68 | |||
69 | [Test] | ||
70 | public void TestSameRegionTeleport() | ||
57 | { | 71 | { |
58 | TestHelpers.InMethod(); | 72 | TestHelpers.InMethod(); |
59 | ThreadRunResults results = new ThreadRunResults(); | 73 | // log4net.Config.XmlConfigurator.Configure(); |
60 | results.Result = false; | ||
61 | results.Message = "Test did not run"; | ||
62 | TestRunning testClass = new TestRunning(results); | ||
63 | 74 | ||
64 | Thread testThread = new Thread(testClass.run); | 75 | EntityTransferModule etm = new EntityTransferModule(); |
65 | 76 | ||
66 | // Seems kind of redundant to start a thread and then join it, however.. We need to protect against | 77 | IConfigSource config = new IniConfigSource(); |
67 | // A thread abort exception in the simulator code. | 78 | config.AddConfig("Modules"); |
68 | testThread.Start(); | 79 | // Not strictly necessary since FriendsModule assumes it is the default (!) |
69 | testThread.Join(); | 80 | config.Configs["Modules"].Set("EntityTransferModule", etm.Name); |
70 | 81 | ||
71 | Assert.That(testClass.results.Result, Is.EqualTo(true), testClass.results.Message); | 82 | TestScene scene = new SceneHelpers().SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
72 | // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); | 83 | SceneHelpers.SetupSceneModules(scene, config, etm); |
84 | |||
85 | Vector3 teleportPosition = new Vector3(10, 11, 12); | ||
86 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | ||
87 | |||
88 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | ||
89 | sp.AbsolutePosition = new Vector3(30, 31, 32); | ||
90 | scene.RequestTeleportLocation( | ||
91 | sp.ControllingClient, | ||
92 | scene.RegionInfo.RegionHandle, | ||
93 | teleportPosition, | ||
94 | teleportLookAt, | ||
95 | (uint)TeleportFlags.ViaLocation); | ||
96 | |||
97 | Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition)); | ||
98 | |||
99 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera | ||
100 | // position instead). | ||
101 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); | ||
73 | } | 102 | } |
74 | 103 | ||
75 | [TearDown] | 104 | [Test] |
76 | public void TearDown() | 105 | public void TestSameSimulatorSeparatedRegionsTeleport() |
77 | { | 106 | { |
78 | try | 107 | TestHelpers.InMethod(); |
79 | { | 108 | // log4net.Config.XmlConfigurator.Configure(); |
80 | if (MainServer.Instance != null) MainServer.Instance.Stop(); | ||
81 | } | ||
82 | catch (NullReferenceException) | ||
83 | { } | ||
84 | } | ||
85 | 109 | ||
86 | } | 110 | UUID userId = TestHelpers.ParseTail(0x1); |
87 | 111 | ||
88 | public class ThreadRunResults | 112 | EntityTransferModule etm = new EntityTransferModule(); |
89 | { | 113 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); |
90 | public bool Result = false; | ||
91 | public string Message = string.Empty; | ||
92 | } | ||
93 | 114 | ||
94 | public class TestRunning | 115 | IConfigSource config = new IniConfigSource(); |
95 | { | 116 | IConfig modulesConfig = config.AddConfig("Modules"); |
96 | public ThreadRunResults results; | 117 | modulesConfig.Set("EntityTransferModule", etm.Name); |
97 | public TestRunning(ThreadRunResults t) | 118 | modulesConfig.Set("SimulationServices", lscm.Name); |
98 | { | 119 | IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); |
99 | results = t; | 120 | |
121 | // In order to run a single threaded regression test we do not want the entity transfer module waiting | ||
122 | // for a callback from the destination scene before removing its avatar data. | ||
123 | entityTransferConfig.Set("wait_for_callback", false); | ||
124 | |||
125 | SceneHelpers sh = new SceneHelpers(); | ||
126 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); | ||
127 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000); | ||
128 | |||
129 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, etm, lscm); | ||
130 | |||
131 | Vector3 teleportPosition = new Vector3(10, 11, 12); | ||
132 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | ||
133 | |||
134 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); | ||
135 | sp.AbsolutePosition = new Vector3(30, 31, 32); | ||
136 | |||
137 | // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole | ||
138 | // UDP stack (?) | ||
139 | // ((TestClient)sp.ControllingClient).TeleportTargetScene = sceneB; | ||
140 | |||
141 | sceneA.RequestTeleportLocation( | ||
142 | sp.ControllingClient, | ||
143 | sceneB.RegionInfo.RegionHandle, | ||
144 | teleportPosition, | ||
145 | teleportLookAt, | ||
146 | (uint)TeleportFlags.ViaLocation); | ||
147 | |||
148 | ((TestClient)sp.ControllingClient).CompleteTeleportClientSide(); | ||
149 | |||
150 | Assert.That(sceneA.GetScenePresence(userId), Is.Null); | ||
151 | |||
152 | ScenePresence sceneBSp = sceneB.GetScenePresence(userId); | ||
153 | Assert.That(sceneBSp, Is.Not.Null); | ||
154 | Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName)); | ||
155 | Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition)); | ||
156 | |||
157 | // TODO: Add assertions to check correct circuit details in both scenes. | ||
158 | |||
159 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera | ||
160 | // position instead). | ||
161 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); | ||
100 | } | 162 | } |
101 | public void run(object o) | 163 | |
164 | [Test] | ||
165 | public void TestSameSimulatorNeighbouringRegionsTeleport() | ||
102 | { | 166 | { |
103 | 167 | TestHelpers.InMethod(); | |
104 | //results.Result = true; | 168 | // TestHelpers.EnableLogging(); |
105 | log4net.Config.XmlConfigurator.Configure(); | 169 | |
106 | 170 | UUID userId = TestHelpers.ParseTail(0x1); | |
107 | UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); | 171 | |
108 | UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); | 172 | EntityTransferModule etm = new EntityTransferModule(); |
109 | 173 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); | |
110 | // shared module | 174 | |
111 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); | 175 | IConfigSource config = new IniConfigSource(); |
112 | 176 | IConfig modulesConfig = config.AddConfig("Modules"); | |
113 | 177 | modulesConfig.Set("EntityTransferModule", etm.Name); | |
114 | Scene sceneB = SceneHelpers.SetupScene("sceneB", sceneBId, 1010, 1010); | 178 | modulesConfig.Set("SimulationServices", lscm.Name); |
115 | SceneHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); | 179 | IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); |
116 | sceneB.RegisterRegionWithGrid(); | 180 | |
117 | 181 | // In order to run a single threaded regression test we do not want the entity transfer module waiting | |
118 | Scene sceneA = SceneHelpers.SetupScene("sceneA", sceneAId, 1000, 1000); | 182 | // for a callback from the destination scene before removing its avatar data. |
119 | SceneHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); | 183 | entityTransferConfig.Set("wait_for_callback", false); |
120 | sceneA.RegisterRegionWithGrid(); | 184 | |
121 | 185 | SceneHelpers sh = new SceneHelpers(); | |
122 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041"); | 186 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
123 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(sceneA, agentId).ControllingClient; | 187 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); |
124 | 188 | ||
125 | ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface<ICapabilitiesModule>(); | 189 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, etm, lscm); |
126 | 190 | SceneHelpers.SetupSceneModules(sceneA, new CapabilitiesModule()); | |
127 | results.Result = (sceneACapsModule.GetCapsPath(agentId) == client.CapsSeedUrl); | 191 | SceneHelpers.SetupSceneModules(sceneB, new CapabilitiesModule()); |
128 | 192 | ||
129 | if (!results.Result) | 193 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
130 | { | 194 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
131 | results.Message = "Incorrect caps object path set up in sceneA"; | 195 | |
132 | return; | 196 | ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); |
133 | } | 197 | originalSp.AbsolutePosition = new Vector3(30, 31, 32); |
134 | 198 | ||
135 | /* | 199 | ScenePresence beforeSceneASp = sceneA.GetScenePresence(userId); |
136 | Assert.That( | 200 | Assert.That(beforeSceneASp, Is.Not.Null); |
137 | sceneACapsModule.GetCapsPath(agentId), | 201 | Assert.That(beforeSceneASp.IsChildAgent, Is.False); |
138 | Is.EqualTo(client.CapsSeedUrl), | 202 | |
139 | "Incorrect caps object path set up in sceneA"); | 203 | ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId); |
140 | */ | 204 | Assert.That(beforeSceneBSp, Is.Not.Null); |
141 | // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used. | 205 | Assert.That(beforeSceneBSp.IsChildAgent, Is.True); |
142 | 206 | ||
143 | 207 | // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole | |
144 | client.TeleportTargetScene = sceneB; | 208 | // UDP stack (?) |
145 | client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40)); | 209 | // ((TestClient)beforeSceneASp.ControllingClient).TeleportTargetScene = sceneB; |
146 | 210 | ||
147 | results.Result = (sceneB.GetScenePresence(agentId) != null); | 211 | sceneA.RequestTeleportLocation( |
148 | if (!results.Result) | 212 | beforeSceneASp.ControllingClient, |
149 | { | 213 | sceneB.RegionInfo.RegionHandle, |
150 | results.Message = "Client does not have an agent in sceneB"; | 214 | teleportPosition, |
151 | return; | 215 | teleportLookAt, |
152 | } | 216 | (uint)TeleportFlags.ViaLocation); |
153 | 217 | ||
154 | //Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB"); | 218 | ((TestClient)beforeSceneASp.ControllingClient).CompleteTeleportClientSide(); |
155 | 219 | ||
156 | //Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA"); | 220 | ScenePresence afterSceneASp = sceneA.GetScenePresence(userId); |
157 | 221 | Assert.That(afterSceneASp, Is.Not.Null); | |
158 | results.Result = (sceneA.GetScenePresence(agentId) == null); | 222 | Assert.That(afterSceneASp.IsChildAgent, Is.True); |
159 | if (!results.Result) | 223 | |
160 | { | 224 | ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId); |
161 | results.Message = "Client still had an agent in sceneA"; | 225 | Assert.That(afterSceneBSp, Is.Not.Null); |
162 | return; | 226 | Assert.That(afterSceneBSp.IsChildAgent, Is.False); |
163 | } | 227 | Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName)); |
164 | 228 | Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition)); | |
165 | ICapabilitiesModule sceneBCapsModule = sceneB.RequestModuleInterface<ICapabilitiesModule>(); | 229 | |
166 | 230 | // TODO: Add assertions to check correct circuit details in both scenes. | |
167 | 231 | ||
168 | results.Result = ("http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + | 232 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera |
169 | "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/" == client.CapsSeedUrl); | 233 | // position instead). |
170 | if (!results.Result) | 234 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
171 | { | 235 | |
172 | results.Message = "Incorrect caps object path set up in sceneB"; | 236 | // TestHelpers.DisableLogging(); |
173 | return; | ||
174 | } | ||
175 | |||
176 | // Temporary assertion - caps url construction should at least be doable through a method. | ||
177 | /* | ||
178 | Assert.That( | ||
179 | "http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/", | ||
180 | Is.EqualTo(client.CapsSeedUrl), | ||
181 | "Incorrect caps object path set up in sceneB"); | ||
182 | */ | ||
183 | // This assertion will currently fail since we don't remove the caps paths when no longer needed | ||
184 | //Assert.That(sceneACapsModule.GetCapsPath(agentId), Is.Null, "sceneA still had a caps object path"); | ||
185 | |||
186 | // TODO: Check that more of everything is as it should be | ||
187 | |||
188 | // TODO: test what happens if we try to teleport to a region that doesn't exist | ||
189 | } | 237 | } |
190 | } | 238 | } |
191 | } | 239 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index 5c9a77d..d722a09 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | |||
@@ -60,7 +60,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
60 | { | 60 | { |
61 | TestHelpers.InMethod(); | 61 | TestHelpers.InMethod(); |
62 | 62 | ||
63 | Scene scene = SceneHelpers.SetupScene(); | 63 | Scene scene = new SceneHelpers().SetupScene(); |
64 | scene.Update(1); | 64 | scene.Update(1); |
65 | 65 | ||
66 | Assert.That(scene.Frame, Is.EqualTo(1)); | 66 | Assert.That(scene.Frame, Is.EqualTo(1)); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 55c80f5..d15141b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Tests | |||
58 | TestHelpers.InMethod(); | 58 | TestHelpers.InMethod(); |
59 | // log4net.Config.XmlConfigurator.Configure(); | 59 | // log4net.Config.XmlConfigurator.Configure(); |
60 | 60 | ||
61 | Scene scene = SceneHelpers.SetupScene(); | 61 | Scene scene = new SceneHelpers().SetupScene(); |
62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
63 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); | 63 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
64 | SceneObjectPart sop1 = sog1.RootPart; | 64 | SceneObjectPart sop1 = sog1.RootPart; |
@@ -81,7 +81,7 @@ namespace OpenSim.Region.Framework.Tests | |||
81 | TestHelpers.InMethod(); | 81 | TestHelpers.InMethod(); |
82 | // log4net.Config.XmlConfigurator.Configure(); | 82 | // log4net.Config.XmlConfigurator.Configure(); |
83 | 83 | ||
84 | Scene scene = SceneHelpers.SetupScene(); | 84 | Scene scene = new SceneHelpers().SetupScene(); |
85 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 85 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
86 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); | 86 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
87 | SceneObjectPart sop1 = sog1.RootPart; | 87 | SceneObjectPart sop1 = sog1.RootPart; |
@@ -124,7 +124,7 @@ namespace OpenSim.Region.Framework.Tests | |||
124 | TestHelpers.InMethod(); | 124 | TestHelpers.InMethod(); |
125 | // log4net.Config.XmlConfigurator.Configure(); | 125 | // log4net.Config.XmlConfigurator.Configure(); |
126 | 126 | ||
127 | Scene scene = SceneHelpers.SetupScene(); | 127 | Scene scene = new SceneHelpers().SetupScene(); |
128 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 128 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
129 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); | 129 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
130 | SceneObjectPart sop1 = sog1.RootPart; | 130 | SceneObjectPart sop1 = sog1.RootPart; |
@@ -153,7 +153,7 @@ namespace OpenSim.Region.Framework.Tests | |||
153 | TestHelpers.InMethod(); | 153 | TestHelpers.InMethod(); |
154 | // log4net.Config.XmlConfigurator.Configure(); | 154 | // log4net.Config.XmlConfigurator.Configure(); |
155 | 155 | ||
156 | Scene scene = SceneHelpers.SetupScene(); | 156 | Scene scene = new SceneHelpers().SetupScene(); |
157 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 157 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
158 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); | 158 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
159 | SceneObjectPart sop1 = sog1.RootPart; | 159 | SceneObjectPart sop1 = sog1.RootPart; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs index 55fc1e7..44d2d45 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Tests | |||
58 | TestHelpers.InMethod(); | 58 | TestHelpers.InMethod(); |
59 | // log4net.Config.XmlConfigurator.Configure(); | 59 | // log4net.Config.XmlConfigurator.Configure(); |
60 | 60 | ||
61 | Scene scene = SceneHelpers.SetupScene(); | 61 | Scene scene = new SceneHelpers().SetupScene(); |
62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); | 62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); |
63 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); | 63 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); |
64 | InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); | 64 | InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); |
@@ -85,7 +85,7 @@ namespace OpenSim.Region.Framework.Tests | |||
85 | TestHelpers.InMethod(); | 85 | TestHelpers.InMethod(); |
86 | // log4net.Config.XmlConfigurator.Configure(); | 86 | // log4net.Config.XmlConfigurator.Configure(); |
87 | 87 | ||
88 | Scene scene = SceneHelpers.SetupScene(); | 88 | Scene scene = new SceneHelpers().SetupScene(); |
89 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); | 89 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); |
90 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); | 90 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); |
91 | InventoryFolderBase folder1 | 91 | InventoryFolderBase folder1 |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index d9fe87c..198e487 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | |||
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
47 | public void Init() | 47 | public void Init() |
48 | { | 48 | { |
49 | // FIXME: We don't need a full scene here - it would be enough to set up the asset service. | 49 | // FIXME: We don't need a full scene here - it would be enough to set up the asset service. |
50 | Scene scene = SceneHelpers.SetupScene(); | 50 | Scene scene = new SceneHelpers().SetupScene(); |
51 | m_assetService = scene.AssetService; | 51 | m_assetService = scene.AssetService; |
52 | m_uuidGatherer = new UuidGatherer(m_assetService); | 52 | m_uuidGatherer = new UuidGatherer(m_assetService); |
53 | } | 53 | } |