diff options
Diffstat (limited to '')
19 files changed, 867 insertions, 150 deletions
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 89ee39c..0dc5dbc 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs | |||
@@ -150,10 +150,10 @@ namespace OpenSim.Framework | |||
150 | Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); | 150 | Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); |
151 | 151 | ||
152 | if (args["left_axis"] != null) | 152 | if (args["left_axis"] != null) |
153 | Vector3.TryParse(args["left_axis"].AsString(), out AtAxis); | 153 | Vector3.TryParse(args["left_axis"].AsString(), out LeftAxis); |
154 | 154 | ||
155 | if (args["up_axis"] != null) | 155 | if (args["up_axis"] != null) |
156 | Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); | 156 | Vector3.TryParse(args["up_axis"].AsString(), out UpAxis); |
157 | 157 | ||
158 | if (args["changed_grid"] != null) | 158 | if (args["changed_grid"] != null) |
159 | ChangedGrid = args["changed_grid"].AsBoolean(); | 159 | ChangedGrid = args["changed_grid"].AsBoolean(); |
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index c038aac..7eb289b 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -288,7 +288,7 @@ namespace OpenSim.Framework.Console | |||
288 | 288 | ||
289 | reply["str_response_string"] = xmldoc.InnerXml; | 289 | reply["str_response_string"] = xmldoc.InnerXml; |
290 | reply["int_response_code"] = 200; | 290 | reply["int_response_code"] = 200; |
291 | reply["content_type"] = "text/plain"; | 291 | reply["content_type"] = "text/xml"; |
292 | 292 | ||
293 | return reply; | 293 | return reply; |
294 | } | 294 | } |
@@ -343,7 +343,7 @@ namespace OpenSim.Framework.Console | |||
343 | 343 | ||
344 | reply["str_response_string"] = xmldoc.InnerXml; | 344 | reply["str_response_string"] = xmldoc.InnerXml; |
345 | reply["int_response_code"] = 200; | 345 | reply["int_response_code"] = 200; |
346 | reply["content_type"] = "text/plain"; | 346 | reply["content_type"] = "text/xml"; |
347 | 347 | ||
348 | return reply; | 348 | return reply; |
349 | } | 349 | } |
diff --git a/OpenSim/Framework/MapAndArray.cs b/OpenSim/Framework/MapAndArray.cs index bbe6a9e..c98d3cc 100644 --- a/OpenSim/Framework/MapAndArray.cs +++ b/OpenSim/Framework/MapAndArray.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 | * |
@@ -131,7 +131,8 @@ namespace OpenSim.Framework | |||
131 | /// <returns>True if the key was found, otherwise false</returns> | 131 | /// <returns>True if the key was found, otherwise false</returns> |
132 | public bool ContainsKey(TKey key) | 132 | public bool ContainsKey(TKey key) |
133 | { | 133 | { |
134 | return m_dict.ContainsKey(key); | 134 | lock (m_syncRoot) |
135 | return m_dict.ContainsKey(key); | ||
135 | } | 136 | } |
136 | 137 | ||
137 | /// <summary> | 138 | /// <summary> |
diff --git a/OpenSim/Framework/Tests/AnimationTests.cs b/OpenSim/Framework/Tests/AnimationTests.cs new file mode 100644 index 0000000..719ddce --- /dev/null +++ b/OpenSim/Framework/Tests/AnimationTests.cs | |||
@@ -0,0 +1,96 @@ | |||
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 NUnit.Framework; | ||
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | ||
33 | using OpenMetaverse.StructuredData; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Tests.Common; | ||
36 | using OpenSim.Tests.Common.Mock; | ||
37 | using OpenSim.Tests.Common.Setup; | ||
38 | using Animation = OpenSim.Framework.Animation; | ||
39 | |||
40 | namespace OpenSim.Framework.Tests | ||
41 | { | ||
42 | [TestFixture] | ||
43 | public class AnimationTests | ||
44 | { | ||
45 | private Animation anim1 = null; | ||
46 | private Animation anim2 = null; | ||
47 | private UUID animUUID1 = UUID.Zero; | ||
48 | private UUID objUUID1 = UUID.Zero; | ||
49 | private UUID animUUID2 = UUID.Zero; | ||
50 | private UUID objUUID2 = UUID.Zero; | ||
51 | |||
52 | [SetUp] | ||
53 | public void Setup() | ||
54 | { | ||
55 | animUUID1 = UUID.Random(); | ||
56 | animUUID2 = UUID.Random(); | ||
57 | objUUID1 = UUID.Random(); | ||
58 | objUUID2 = UUID.Random(); | ||
59 | |||
60 | anim1 = new Animation(animUUID1, 1, objUUID1); | ||
61 | anim2 = new Animation(animUUID2, 1, objUUID2); | ||
62 | } | ||
63 | |||
64 | [Test] | ||
65 | public void AnimationOSDTest() | ||
66 | { | ||
67 | Assert.That(anim1.AnimID==animUUID1 && anim1.ObjectID == objUUID1 && anim1.SequenceNum ==1, "The Animation Constructor didn't set the fields correctly"); | ||
68 | OSD updateMessage = anim1.PackUpdateMessage(); | ||
69 | Assert.That(updateMessage is OSDMap, "Packed UpdateMessage isn't an OSDMap"); | ||
70 | OSDMap updateMap = (OSDMap) updateMessage; | ||
71 | Assert.That(updateMap.ContainsKey("animation"), "Packed Message doesn't contain an animation element"); | ||
72 | Assert.That(updateMap.ContainsKey("object_id"), "Packed Message doesn't contain an object_id element"); | ||
73 | Assert.That(updateMap.ContainsKey("seq_num"), "Packed Message doesn't contain a seq_num element"); | ||
74 | Assert.That(updateMap["animation"].AsUUID() == animUUID1); | ||
75 | Assert.That(updateMap["object_id"].AsUUID() == objUUID1); | ||
76 | Assert.That(updateMap["seq_num"].AsInteger() == 1); | ||
77 | |||
78 | Animation anim3 = new Animation(updateMap); | ||
79 | |||
80 | Assert.That(anim3.ObjectID == anim1.ObjectID && anim3.AnimID == anim1.AnimID && anim3.SequenceNum == anim1.SequenceNum, "OSDMap Constructor failed to set the properties correctly."); | ||
81 | |||
82 | anim3.UnpackUpdateMessage(anim2.PackUpdateMessage()); | ||
83 | |||
84 | Assert.That(anim3.ObjectID == objUUID2 && anim3.AnimID == animUUID2 && anim3.SequenceNum == 1, "Animation.UnpackUpdateMessage failed to set the properties correctly."); | ||
85 | |||
86 | Animation anim4 = new Animation(); | ||
87 | anim4.AnimID = anim2.AnimID; | ||
88 | anim4.ObjectID = anim2.ObjectID; | ||
89 | anim4.SequenceNum = anim2.SequenceNum; | ||
90 | |||
91 | Assert.That(anim4.ObjectID == objUUID2 && anim4.AnimID == animUUID2 && anim4.SequenceNum == 1, "void constructor and manual field population failed to set the properties correctly."); | ||
92 | |||
93 | |||
94 | } | ||
95 | } | ||
96 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Tests/CacheTests.cs b/OpenSim/Framework/Tests/CacheTests.cs index 32c0c95..c3613e6 100644 --- a/OpenSim/Framework/Tests/CacheTests.cs +++ b/OpenSim/Framework/Tests/CacheTests.cs | |||
@@ -40,6 +40,7 @@ namespace OpenSim.Framework.Tests | |||
40 | public void Build() | 40 | public void Build() |
41 | { | 41 | { |
42 | cache = new Cache(); | 42 | cache = new Cache(); |
43 | cache = new Cache(CacheMedium.Memory,CacheStrategy.Aggressive,CacheFlags.AllowUpdate); | ||
43 | cacheItemUUID = UUID.Random(); | 44 | cacheItemUUID = UUID.Random(); |
44 | MemoryCacheItem cachedItem = new MemoryCacheItem(cacheItemUUID.ToString(),DateTime.Now + TimeSpan.FromDays(1)); | 45 | MemoryCacheItem cachedItem = new MemoryCacheItem(cacheItemUUID.ToString(),DateTime.Now + TimeSpan.FromDays(1)); |
45 | byte[] foo = new byte[1]; | 46 | byte[] foo = new byte[1]; |
@@ -68,36 +69,55 @@ namespace OpenSim.Framework.Tests | |||
68 | Assert.That(citem == null, "Item should not be in Cache"); | 69 | Assert.That(citem == null, "Item should not be in Cache"); |
69 | } | 70 | } |
70 | 71 | ||
71 | //NOTE: Test Case disabled until Cache is fixed | 72 | |
72 | [Test] | 73 | [Test] |
73 | public void TestTTLExpiredEntry() | 74 | public void ExpireItemManually() |
74 | { | 75 | { |
75 | UUID ImmediateExpiryUUID = UUID.Random(); | 76 | UUID ImmediateExpiryUUID = UUID.Random(); |
76 | MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(-1)); | 77 | MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(1)); |
77 | byte[] foo = new byte[1]; | 78 | byte[] foo = new byte[1]; |
78 | foo[0] = 1; | 79 | foo[0] = 1; |
79 | cachedItem.Store(foo); | 80 | cachedItem.Store(foo); |
80 | cache.Store(cacheItemUUID.ToString(), cachedItem); | 81 | cache.Store(cacheItemUUID.ToString(), cachedItem); |
81 | 82 | cache.Invalidate(cacheItemUUID.ToString()); | |
82 | cache.Get(cacheItemUUID.ToString()); | 83 | cache.Get(cacheItemUUID.ToString()); |
83 | //object citem = cache.Get(cacheItemUUID.ToString()); | 84 | object citem = cache.Get(cacheItemUUID.ToString()); |
84 | //Assert.That(citem == null, "Item should not be in Cache because the expiry time was before now"); | 85 | Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); |
85 | } | 86 | } |
86 | 87 | ||
87 | //NOTE: Test Case disabled until Cache is fixed | ||
88 | [Test] | 88 | [Test] |
89 | public void ExpireItemManually() | 89 | public void ClearCacheTest() |
90 | { | 90 | { |
91 | UUID ImmediateExpiryUUID = UUID.Random(); | 91 | UUID ImmediateExpiryUUID = UUID.Random(); |
92 | MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(1)); | 92 | MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), DateTime.Now - TimeSpan.FromDays(1)); |
93 | byte[] foo = new byte[1]; | 93 | byte[] foo = new byte[1]; |
94 | foo[0] = 1; | 94 | foo[0] = 1; |
95 | cachedItem.Store(foo); | 95 | cachedItem.Store(foo); |
96 | cache.Store(cacheItemUUID.ToString(), cachedItem); | 96 | cache.Store(cacheItemUUID.ToString(), cachedItem); |
97 | cache.Invalidate(ImmediateExpiryUUID.ToString()); | 97 | cache.Clear(); |
98 | cache.Get(cacheItemUUID.ToString()); | 98 | |
99 | //object citem = cache.Get(cacheItemUUID.ToString()); | 99 | object citem = cache.Get(cacheItemUUID.ToString()); |
100 | //Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); | 100 | Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); |
101 | } | ||
102 | |||
103 | [Test] | ||
104 | public void CacheItemMundane() | ||
105 | { | ||
106 | UUID Random1 = UUID.Random(); | ||
107 | UUID Random2 = UUID.Random(); | ||
108 | byte[] data = new byte[0]; | ||
109 | CacheItemBase cb1 = new CacheItemBase(Random1.ToString(), DateTime.Now + TimeSpan.FromDays(1)); | ||
110 | CacheItemBase cb2 = new CacheItemBase(Random2.ToString(), DateTime.Now + TimeSpan.FromDays(1)); | ||
111 | CacheItemBase cb3 = new CacheItemBase(Random1.ToString(), DateTime.Now + TimeSpan.FromDays(1)); | ||
112 | |||
113 | cb1.Store(data); | ||
114 | |||
115 | Assert.That(cb1.Equals(cb3), "cb1 should equal cb3, their uuids are the same"); | ||
116 | Assert.That(!cb2.Equals(cb1), "cb2 should not equal cb1, their uuids are NOT the same"); | ||
117 | Assert.That(cb1.IsLocked() == false, "CacheItemBase default is false"); | ||
118 | Assert.That(cb1.Retrieve() == null, "Virtual Retrieve method should return null"); | ||
119 | |||
120 | |||
101 | } | 121 | } |
102 | 122 | ||
103 | } | 123 | } |
diff --git a/OpenSim/Framework/Tests/LocationTest.cs b/OpenSim/Framework/Tests/LocationTest.cs index 237568f..2707afa 100644 --- a/OpenSim/Framework/Tests/LocationTest.cs +++ b/OpenSim/Framework/Tests/LocationTest.cs | |||
@@ -54,9 +54,28 @@ namespace OpenSim.Framework.Tests | |||
54 | Location TestLocation2 = new Location(1099511628032000); | 54 | Location TestLocation2 = new Location(1099511628032000); |
55 | Assert.That(TestLocation1 == TestLocation2); | 55 | Assert.That(TestLocation1 == TestLocation2); |
56 | 56 | ||
57 | Assert.That(TestLocation2.X == 256000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided"); | ||
58 | |||
59 | Assert.That(TestLocation2.RegionHandle == 1099511628032000, | ||
60 | "Location RegionHandle Property didn't match regionhandle provided in constructor"); | ||
61 | |||
62 | |||
57 | TestLocation1 = new Location(256001, 256001); | 63 | TestLocation1 = new Location(256001, 256001); |
58 | TestLocation2 = new Location(1099511628032000); | 64 | TestLocation2 = new Location(1099511628032000); |
59 | Assert.That(TestLocation1 != TestLocation2); | 65 | Assert.That(TestLocation1 != TestLocation2); |
66 | |||
67 | Assert.That(TestLocation1.Equals(256001, 256001), "Equals(x,y) failed to match the position in the constructor"); | ||
68 | |||
69 | Assert.That(TestLocation2.GetHashCode() == (TestLocation2.X.GetHashCode() ^ TestLocation2.Y.GetHashCode()), "GetHashCode failed to produce the expected hashcode"); | ||
70 | |||
71 | Location TestLocation3; | ||
72 | object cln = TestLocation2.Clone(); | ||
73 | TestLocation3 = (Location) cln; | ||
74 | Assert.That(TestLocation3.X == TestLocation2.X && TestLocation3.Y == TestLocation2.Y, | ||
75 | "Cloned Location values do not match"); | ||
76 | |||
77 | Assert.That(TestLocation2.Equals(cln), "Cloned object failed .Equals(obj) Test"); | ||
78 | |||
60 | } | 79 | } |
61 | 80 | ||
62 | } | 81 | } |
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs new file mode 100644 index 0000000..04be083 --- /dev/null +++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs | |||
@@ -0,0 +1,311 @@ | |||
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 NUnit.Framework; | ||
29 | using OpenSim.Framework; | ||
30 | using OpenMetaverse; | ||
31 | using OpenMetaverse.StructuredData; | ||
32 | using System; | ||
33 | using System.Globalization; | ||
34 | using System.Threading; | ||
35 | |||
36 | namespace OpenSim.Framework.Tests | ||
37 | { | ||
38 | [TestFixture] | ||
39 | public class MundaneFrameworkTests | ||
40 | { | ||
41 | private bool m_RegionSettingsOnSaveEventFired; | ||
42 | private bool m_RegionLightShareDataOnSaveEventFired; | ||
43 | |||
44 | |||
45 | [Test] | ||
46 | public void ChildAgentDataUpdate01() | ||
47 | { | ||
48 | // code coverage | ||
49 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | ||
50 | Assert.IsFalse(cadu.alwaysrun, "Default is false"); | ||
51 | } | ||
52 | |||
53 | [Test] | ||
54 | public void AgentPositionTest01() | ||
55 | { | ||
56 | UUID AgentId1 = UUID.Random(); | ||
57 | UUID SessionId1 = UUID.Random(); | ||
58 | uint CircuitCode1 = uint.MinValue; | ||
59 | Vector3 Size1 = Vector3.UnitZ; | ||
60 | Vector3 Position1 = Vector3.UnitX; | ||
61 | Vector3 LeftAxis1 = Vector3.UnitY; | ||
62 | Vector3 UpAxis1 = Vector3.UnitZ; | ||
63 | Vector3 AtAxis1 = Vector3.UnitX; | ||
64 | |||
65 | ulong RegionHandle1 = ulong.MinValue; | ||
66 | byte[] Throttles1 = new byte[] {0, 1, 0}; | ||
67 | |||
68 | Vector3 Velocity1 = Vector3.Zero; | ||
69 | float Far1 = 256; | ||
70 | |||
71 | bool ChangedGrid1 = false; | ||
72 | Vector3 Center1 = Vector3.Zero; | ||
73 | |||
74 | AgentPosition position1 = new AgentPosition(); | ||
75 | position1.AgentID = AgentId1; | ||
76 | position1.SessionID = SessionId1; | ||
77 | position1.CircuitCode = CircuitCode1; | ||
78 | position1.Size = Size1; | ||
79 | position1.Position = Position1; | ||
80 | position1.LeftAxis = LeftAxis1; | ||
81 | position1.UpAxis = UpAxis1; | ||
82 | position1.AtAxis = AtAxis1; | ||
83 | position1.RegionHandle = RegionHandle1; | ||
84 | position1.Throttles = Throttles1; | ||
85 | position1.Velocity = Velocity1; | ||
86 | position1.Far = Far1; | ||
87 | position1.ChangedGrid = ChangedGrid1; | ||
88 | position1.Center = Center1; | ||
89 | |||
90 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | ||
91 | cadu.AgentID = AgentId1.Guid; | ||
92 | cadu.ActiveGroupID = UUID.Zero.Guid; | ||
93 | cadu.throttles = Throttles1; | ||
94 | cadu.drawdistance = Far1; | ||
95 | cadu.Position = Position1; | ||
96 | cadu.Velocity = Velocity1; | ||
97 | cadu.regionHandle = RegionHandle1; | ||
98 | cadu.cameraPosition = Center1; | ||
99 | cadu.AVHeight = Size1.Z; | ||
100 | |||
101 | AgentPosition position2 = new AgentPosition(); | ||
102 | position2.CopyFrom(cadu); | ||
103 | |||
104 | Assert.IsTrue( | ||
105 | position2.AgentID == position1.AgentID | ||
106 | && position2.Size == position1.Size | ||
107 | && position2.Position == position1.Position | ||
108 | && position2.Velocity == position1.Velocity | ||
109 | && position2.Center == position1.Center | ||
110 | && position2.RegionHandle == position1.RegionHandle | ||
111 | && position2.Far == position1.Far | ||
112 | |||
113 | ,"Copy From ChildAgentDataUpdate failed"); | ||
114 | |||
115 | position2 = new AgentPosition(); | ||
116 | |||
117 | Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition"); | ||
118 | position2.Unpack(position1.Pack()); | ||
119 | |||
120 | Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed"); | ||
121 | Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed"); | ||
122 | Assert.IsTrue(position2.Velocity == position1.Velocity, "Velocity didn't unpack the same way it packed"); | ||
123 | Assert.IsTrue(position2.SessionID == position1.SessionID, "SessionID didn't unpack the same way it packed"); | ||
124 | Assert.IsTrue(position2.CircuitCode == position1.CircuitCode, "CircuitCode didn't unpack the same way it packed"); | ||
125 | Assert.IsTrue(position2.LeftAxis == position1.LeftAxis, "LeftAxis didn't unpack the same way it packed"); | ||
126 | Assert.IsTrue(position2.UpAxis == position1.UpAxis, "UpAxis didn't unpack the same way it packed"); | ||
127 | Assert.IsTrue(position2.AtAxis == position1.AtAxis, "AtAxis didn't unpack the same way it packed"); | ||
128 | Assert.IsTrue(position2.RegionHandle == position1.RegionHandle, "RegionHandle didn't unpack the same way it packed"); | ||
129 | Assert.IsTrue(position2.ChangedGrid == position1.ChangedGrid, "ChangedGrid didn't unpack the same way it packed"); | ||
130 | Assert.IsTrue(position2.Center == position1.Center, "Center didn't unpack the same way it packed"); | ||
131 | Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed"); | ||
132 | |||
133 | } | ||
134 | |||
135 | [Test] | ||
136 | public void RegionSettingsTest01() | ||
137 | { | ||
138 | RegionSettings settings = new RegionSettings(); | ||
139 | settings.OnSave += RegionSaveFired; | ||
140 | settings.Save(); | ||
141 | settings.OnSave -= RegionSaveFired; | ||
142 | |||
143 | string str = settings.LoadedCreationDate; | ||
144 | int dt = settings.LoadedCreationDateTime; | ||
145 | string id = settings.LoadedCreationID; | ||
146 | string time = settings.LoadedCreationTime; | ||
147 | |||
148 | Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire"); | ||
149 | |||
150 | } | ||
151 | public void RegionSaveFired(RegionSettings settings) | ||
152 | { | ||
153 | m_RegionSettingsOnSaveEventFired = true; | ||
154 | } | ||
155 | |||
156 | [Test] | ||
157 | public void InventoryItemBaseConstructorTest01() | ||
158 | { | ||
159 | InventoryItemBase b1 = new InventoryItemBase(); | ||
160 | Assert.That(b1.ID == UUID.Zero, "void constructor should create an inventory item with ID = UUID.Zero"); | ||
161 | Assert.That(b1.Owner == UUID.Zero, "void constructor should create an inventory item with Owner = UUID.Zero"); | ||
162 | |||
163 | UUID ItemID = UUID.Random(); | ||
164 | UUID OwnerID = UUID.Random(); | ||
165 | |||
166 | InventoryItemBase b2 = new InventoryItemBase(ItemID); | ||
167 | Assert.That(b2.ID == ItemID, "ID constructor should create an inventory item with ID = ItemID"); | ||
168 | Assert.That(b2.Owner == UUID.Zero, "ID constructor should create an inventory item with Owner = UUID.Zero"); | ||
169 | |||
170 | InventoryItemBase b3 = new InventoryItemBase(ItemID,OwnerID); | ||
171 | Assert.That(b3.ID == ItemID, "ID,OwnerID constructor should create an inventory item with ID = ItemID"); | ||
172 | Assert.That(b3.Owner == OwnerID, "ID,OwnerID constructor should create an inventory item with Owner = OwnerID"); | ||
173 | |||
174 | } | ||
175 | |||
176 | [Test] | ||
177 | public void AssetMetaDataNonNullContentTypeTest01() | ||
178 | { | ||
179 | AssetMetadata assetMetadata = new AssetMetadata(); | ||
180 | assetMetadata.ContentType = "image/jp2"; | ||
181 | Assert.That(assetMetadata.Type == (sbyte)AssetType.Texture, "Content type should be AssetType.Texture"); | ||
182 | Assert.That(assetMetadata.ContentType == "image/jp2", "Text of content type should be image/jp2"); | ||
183 | UUID rndID = UUID.Random(); | ||
184 | assetMetadata.ID = rndID.ToString(); | ||
185 | Assert.That(assetMetadata.ID.ToLower() == rndID.ToString().ToLower(), "assetMetadata.ID Setter/Getter not Consistent"); | ||
186 | DateTime fixedTime = DateTime.Now; | ||
187 | assetMetadata.CreationDate = fixedTime; | ||
188 | } | ||
189 | |||
190 | [Test] | ||
191 | public void RegionLightShareDataCloneSaveTest01() | ||
192 | { | ||
193 | RegionLightShareData rlsd = new RegionLightShareData(); | ||
194 | rlsd.OnSave += RegionLightShareDataSaveFired; | ||
195 | rlsd.Save(); | ||
196 | rlsd.OnSave -= RegionLightShareDataSaveFired; | ||
197 | Assert.IsTrue(m_RegionLightShareDataOnSaveEventFired, "OnSave Event Never Fired"); | ||
198 | |||
199 | object o = rlsd.Clone(); | ||
200 | RegionLightShareData dupe = (RegionLightShareData) o; | ||
201 | Assert.IsTrue(rlsd.sceneGamma == dupe.sceneGamma, "Memberwise Clone of RegionLightShareData failed"); | ||
202 | } | ||
203 | public void RegionLightShareDataSaveFired(RegionLightShareData settings) | ||
204 | { | ||
205 | m_RegionLightShareDataOnSaveEventFired = true; | ||
206 | } | ||
207 | |||
208 | [Test] | ||
209 | public void EstateSettingsMundateTests() | ||
210 | { | ||
211 | EstateSettings es = new EstateSettings(); | ||
212 | es.AddBan(null); | ||
213 | UUID bannedUserId = UUID.Random(); | ||
214 | es.AddBan(new EstateBan() | ||
215 | { BannedHostAddress = string.Empty, | ||
216 | BannedHostIPMask = string.Empty, | ||
217 | BannedHostNameMask = string.Empty, | ||
218 | BannedUserID = bannedUserId} | ||
219 | ); | ||
220 | Assert.IsTrue(es.IsBanned(bannedUserId), "User Should be banned but is not."); | ||
221 | Assert.IsFalse(es.IsBanned(UUID.Zero), "User Should not be banned but is."); | ||
222 | |||
223 | es.RemoveBan(bannedUserId); | ||
224 | |||
225 | Assert.IsFalse(es.IsBanned(bannedUserId), "User Should not be banned but is."); | ||
226 | |||
227 | es.AddEstateManager(UUID.Zero); | ||
228 | |||
229 | es.AddEstateManager(bannedUserId); | ||
230 | Assert.IsTrue(es.IsEstateManager(bannedUserId), "bannedUserId should be EstateManager but isn't."); | ||
231 | |||
232 | es.RemoveEstateManager(bannedUserId); | ||
233 | Assert.IsFalse(es.IsEstateManager(bannedUserId), "bannedUserID is estateManager but shouldn't be"); | ||
234 | |||
235 | Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't"); | ||
236 | |||
237 | es.AddEstateUser(bannedUserId); | ||
238 | |||
239 | Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should"); | ||
240 | es.RemoveEstateUser(bannedUserId); | ||
241 | |||
242 | es.AddEstateManager(bannedUserId); | ||
243 | |||
244 | Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should"); | ||
245 | |||
246 | Assert.That(es.EstateGroups.Length == 0, "No Estate Groups Added.. so the array should be 0 length"); | ||
247 | |||
248 | es.AddEstateGroup(bannedUserId); | ||
249 | |||
250 | Assert.That(es.EstateGroups.Length == 1, "1 Estate Groups Added.. so the array should be 1 length"); | ||
251 | |||
252 | Assert.That(es.EstateGroups[0] == bannedUserId,"User ID should be in EstateGroups"); | ||
253 | |||
254 | } | ||
255 | |||
256 | [Test] | ||
257 | public void InventoryFolderBaseConstructorTest01() | ||
258 | { | ||
259 | UUID uuid1 = UUID.Random(); | ||
260 | UUID uuid2 = UUID.Random(); | ||
261 | |||
262 | InventoryFolderBase fld = new InventoryFolderBase(uuid1); | ||
263 | Assert.That(fld.ID == uuid1, "ID constructor failed to save value in ID field."); | ||
264 | |||
265 | fld = new InventoryFolderBase(uuid1, uuid2); | ||
266 | Assert.That(fld.ID == uuid1, "ID,Owner constructor failed to save value in ID field."); | ||
267 | Assert.That(fld.Owner == uuid2, "ID,Owner constructor failed to save value in ID field."); | ||
268 | } | ||
269 | |||
270 | [Test] | ||
271 | public void AsssetBaseConstructorTest01() | ||
272 | { | ||
273 | AssetBase abase = new AssetBase(); | ||
274 | Assert.IsNotNull(abase.Metadata, "void constructor of AssetBase should have created a MetaData element but didn't."); | ||
275 | UUID itemID = UUID.Random(); | ||
276 | UUID creatorID = UUID.Random(); | ||
277 | abase = new AssetBase(itemID.ToString(), "test item", (sbyte) AssetType.Texture, creatorID.ToString()); | ||
278 | |||
279 | Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase should have created a MetaData element but didn't."); | ||
280 | Assert.That(abase.ID == itemID.ToString(), "string,string,sbyte,string constructor failed to set ID property"); | ||
281 | Assert.That(abase.Metadata.CreatorID == creatorID.ToString(), "string,string,sbyte,string constructor failed to set Creator ID"); | ||
282 | |||
283 | |||
284 | abase = new AssetBase(itemID.ToString(), "test item", -1, creatorID.ToString()); | ||
285 | Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase with unknown type should have created a MetaData element but didn't."); | ||
286 | Assert.That(abase.Metadata.Type == -1, "Unknown Type passed to string,string,sbyte,string constructor and was a known type when it came out again"); | ||
287 | |||
288 | AssetMetadata metts = new AssetMetadata(); | ||
289 | metts.FullID = itemID; | ||
290 | metts.ID = string.Empty; | ||
291 | metts.Name = "test item"; | ||
292 | abase.Metadata = metts; | ||
293 | |||
294 | Assert.That(abase.ToString() == itemID.ToString(), "ToString is overriden to be fullID.ToString()"); | ||
295 | Assert.That(abase.ID == itemID.ToString(),"ID should be MetaData.FullID.ToString() when string.empty or null is provided to the ID property"); | ||
296 | } | ||
297 | |||
298 | [Test] | ||
299 | public void CultureSetCultureTest01() | ||
300 | { | ||
301 | CultureInfo ci = new CultureInfo("en-US", false); | ||
302 | Culture.SetCurrentCulture(); | ||
303 | Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US"); | ||
304 | |||
305 | } | ||
306 | |||
307 | |||
308 | |||
309 | } | ||
310 | } | ||
311 | |||
diff --git a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs new file mode 100644 index 0000000..d741f91 --- /dev/null +++ b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs | |||
@@ -0,0 +1,146 @@ | |||
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 NUnit.Framework; | ||
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | ||
33 | using OpenMetaverse.StructuredData; | ||
34 | using OpenSim.Framework; | ||
35 | |||
36 | namespace OpenSim.Framework.Tests | ||
37 | { | ||
38 | [TestFixture] | ||
39 | public class PrimeNumberHelperTests | ||
40 | { | ||
41 | |||
42 | |||
43 | [Test] | ||
44 | public void TestGetPrime() | ||
45 | { | ||
46 | int prime1 = PrimeNumberHelper.GetPrime(7919); | ||
47 | Assert.That(prime1 == 8419, "Prime Number Get Prime Failed, 7919 is prime"); | ||
48 | Assert.That(PrimeNumberHelper.IsPrime(prime1),"Prime1 should be prime"); | ||
49 | Assert.That(PrimeNumberHelper.IsPrime(7919), "7919 is prime but is falsely failing the prime test"); | ||
50 | prime1 = PrimeNumberHelper.GetPrime(Int32.MaxValue - 1); | ||
51 | Assert.That(prime1 == -1, "prime1 should have been -1 since there are no primes between Int32.MaxValue-1 and Int32.MaxValue"); | ||
52 | |||
53 | } | ||
54 | |||
55 | [Test] | ||
56 | public void Test1000SmallPrimeNumbers() | ||
57 | { | ||
58 | int[] primes = { | ||
59 | 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, | ||
60 | 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191 | ||
61 | , 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, | ||
62 | 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, | ||
63 | 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, | ||
64 | 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, | ||
65 | 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, | ||
66 | 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, | ||
67 | 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, | ||
68 | 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, | ||
69 | 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, | ||
70 | 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, | ||
71 | 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, | ||
72 | 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, | ||
73 | 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, | ||
74 | 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, | ||
75 | 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, | ||
76 | 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, | ||
77 | 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, | ||
78 | 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, | ||
79 | 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, | ||
80 | 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, | ||
81 | 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, | ||
82 | 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, | ||
83 | 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, | ||
84 | 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, | ||
85 | 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, | ||
86 | 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, | ||
87 | 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, | ||
88 | 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, | ||
89 | 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, | ||
90 | 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, | ||
91 | 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, | ||
92 | 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, | ||
93 | 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, | ||
94 | 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, | ||
95 | 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, | ||
96 | 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, | ||
97 | 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, | ||
98 | 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, | ||
99 | 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, | ||
100 | 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, | ||
101 | 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, | ||
102 | 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, | ||
103 | 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, | ||
104 | 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, | ||
105 | 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, | ||
106 | 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, | ||
107 | 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, | ||
108 | 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, | ||
109 | 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, | ||
110 | 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, | ||
111 | 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, | ||
112 | 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, | ||
113 | 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, | ||
114 | 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, | ||
115 | 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, | ||
116 | 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, | ||
117 | 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, | ||
118 | 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, | ||
119 | 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, | ||
120 | 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, | ||
121 | 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, | ||
122 | 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, | ||
123 | 7877, 7879, 7883, 7901, 7907, 7919 | ||
124 | }; | ||
125 | for (int i = 0; i < primes.Length; i++) | ||
126 | { | ||
127 | Assert.That(PrimeNumberHelper.IsPrime(primes[i]),primes[i] + " is prime but is erroniously failing the prime test"); | ||
128 | } | ||
129 | |||
130 | int[] nonprimes = { | ||
131 | 4, 6, 8, 10, 14, 16, 18, 22, 28, 30, 36, 40, 42, 46, 52, 58, 60, 66, 70, 72, 78, 82, 88, | ||
132 | 96, 366, 372, 378, 382, 388, 396, 400, 408, 418, 420, 430, 432, 438, 442, 448, 456, 460, 462, | ||
133 | 466, 478, 486, 490, 498, 502, 508, 856, 858, 862, 876, 880, 882, 886, 906, 910, 918, 928, 936, | ||
134 | 940, 946, 952, 966, 970, 976, 982, 990, 996, 1008, 1740, 1746, 1752, 1758, 4650, 4656, 4662, | ||
135 | 4672, 4678, 4690, 7740, 7752, 7756, 7758, 7788, 7792, 7816, 7822, 7828, 7840, 7852, 7866, 7872, | ||
136 | 7876, 7878, 7882, 7900, 7906, 7918 | ||
137 | }; | ||
138 | for (int i = 0; i < nonprimes.Length; i++) | ||
139 | { | ||
140 | Assert.That(!PrimeNumberHelper.IsPrime(nonprimes[i]), nonprimes[i] + " is not prime but is erroniously passing the prime test"); | ||
141 | } | ||
142 | |||
143 | Assert.That(PrimeNumberHelper.IsPrime(3)); | ||
144 | } | ||
145 | } | ||
146 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index 45d822c..89f5c0c 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs | |||
@@ -170,5 +170,119 @@ namespace OpenSim.Framework.Tests | |||
170 | // Varying secrets should not eqal the same | 170 | // Varying secrets should not eqal the same |
171 | Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2")); | 171 | Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2")); |
172 | } | 172 | } |
173 | |||
174 | [Test] | ||
175 | public void SLUtilTypeConvertTests() | ||
176 | { | ||
177 | int[] assettypes = new int[]{-1,0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 | ||
178 | ,23,24,25,46,47,48}; | ||
179 | string[] contenttypes = new string[] | ||
180 | { | ||
181 | "application/octet-stream", | ||
182 | "image/x-j2c", | ||
183 | "audio/ogg", | ||
184 | "application/vnd.ll.callingcard", | ||
185 | "application/vnd.ll.landmark", | ||
186 | "application/vnd.ll.clothing", | ||
187 | "application/vnd.ll.primitive", | ||
188 | "application/vnd.ll.notecard", | ||
189 | "application/vnd.ll.folder", | ||
190 | "application/vnd.ll.rootfolder", | ||
191 | "application/vnd.ll.lsltext", | ||
192 | "application/vnd.ll.lslbyte", | ||
193 | "image/tga", | ||
194 | "application/vnd.ll.bodypart", | ||
195 | "application/vnd.ll.trashfolder", | ||
196 | "application/vnd.ll.snapshotfolder", | ||
197 | "application/vnd.ll.lostandfoundfolder", | ||
198 | "audio/x-wav", | ||
199 | "image/tga", | ||
200 | "image/jpeg", | ||
201 | "application/vnd.ll.animation", | ||
202 | "application/vnd.ll.gesture", | ||
203 | "application/x-metaverse-simstate", | ||
204 | "application/vnd.ll.favoritefolder", | ||
205 | "application/vnd.ll.link", | ||
206 | "application/vnd.ll.linkfolder", | ||
207 | "application/vnd.ll.currentoutfitfolder", | ||
208 | "application/vnd.ll.outfitfolder", | ||
209 | "application/vnd.ll.myoutfitsfolder" | ||
210 | }; | ||
211 | for (int i=0;i<assettypes.Length;i++) | ||
212 | { | ||
213 | Assert.That(SLUtil.SLAssetTypeToContentType(assettypes[i]) == contenttypes[i], "Expecting {0} but got {1}", contenttypes[i], SLUtil.SLAssetTypeToContentType(assettypes[i])); | ||
214 | } | ||
215 | |||
216 | for (int i = 0; i < contenttypes.Length; i++) | ||
217 | { | ||
218 | if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18) | ||
219 | { | ||
220 | Assert.That(contenttypes[i] == "image/tga"); | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i], | ||
225 | "Expecting {0} but got {1}", assettypes[i], | ||
226 | SLUtil.ContentTypeToSLAssetType(contenttypes[i])); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20}; | ||
231 | string[] invcontenttypes = new string[] | ||
232 | { | ||
233 | "application/octet-stream", | ||
234 | "image/x-j2c", | ||
235 | "audio/ogg", | ||
236 | "application/vnd.ll.callingcard", | ||
237 | "application/vnd.ll.landmark", | ||
238 | "application/vnd.ll.primitive", | ||
239 | "application/vnd.ll.notecard", | ||
240 | "application/vnd.ll.folder", | ||
241 | "application/octet-stream", | ||
242 | "application/vnd.ll.lsltext", | ||
243 | "image/x-j2c", | ||
244 | "application/vnd.ll.primitive", | ||
245 | "application/vnd.ll.clothing", | ||
246 | "application/vnd.ll.gesture" | ||
247 | }; | ||
248 | |||
249 | for (int i=0;i<inventorytypes.Length;i++) | ||
250 | { | ||
251 | Assert.That(SLUtil.SLInvTypeToContentType(inventorytypes[i]) == invcontenttypes[i], "Expected {0}, Got {1}", invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i])); | ||
252 | } | ||
253 | |||
254 | invcontenttypes = new string[] | ||
255 | { | ||
256 | "image/x-j2c","image/jp2","image/tga", | ||
257 | "image/jpeg","application/ogg","audio/ogg", | ||
258 | "audio/x-wav","application/vnd.ll.callingcard", | ||
259 | "application/x-metaverse-callingcard", | ||
260 | "application/vnd.ll.landmark", | ||
261 | "application/x-metaverse-landmark", | ||
262 | "application/vnd.ll.clothing", | ||
263 | "application/x-metaverse-clothing","application/vnd.ll.bodypart", | ||
264 | "application/x-metaverse-bodypart","application/vnd.ll.primitive", | ||
265 | "application/x-metaverse-primitive","application/vnd.ll.notecard", | ||
266 | "application/x-metaverse-notecard","application/vnd.ll.folder", | ||
267 | "application/vnd.ll.rootfolder","application/vnd.ll.lsltext", | ||
268 | "application/x-metaverse-lsl","application/vnd.ll.lslbyte", | ||
269 | "application/x-metaverse-lso","application/vnd.ll.trashfolder", | ||
270 | "application/vnd.ll.snapshotfolder", | ||
271 | "application/vnd.ll.lostandfoundfolder","application/vnd.ll.animation", | ||
272 | "application/x-metaverse-animation","application/vnd.ll.gesture", | ||
273 | "application/x-metaverse-gesture","application/x-metaverse-simstate", | ||
274 | "application/octet-stream" | ||
275 | }; | ||
276 | sbyte[] invtypes = new sbyte[] | ||
277 | { | ||
278 | 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 18, 18, 18, 18, 6, 6, 7, 7, 8, 9, 10, 10, 10, 10 | ||
279 | , 8, 8, 8, 19, 19, 20, 20, 15, -1 | ||
280 | }; | ||
281 | |||
282 | for (int i = 0; i < invtypes.Length; i++) | ||
283 | { | ||
284 | Assert.That(SLUtil.ContentTypeToSLInvType(invcontenttypes[i]) == invtypes[i], "Expected {0}, Got {1}", invtypes[i], SLUtil.ContentTypeToSLInvType(invcontenttypes[i])); | ||
285 | } | ||
286 | } | ||
173 | } | 287 | } |
174 | } | 288 | } |
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index c85ff82..7a0142f 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -316,7 +316,7 @@ namespace OpenSim | |||
316 | m_console.Commands.AddCommand("region", false, "create region", | 316 | m_console.Commands.AddCommand("region", false, "create region", |
317 | "create region [\"region name\"] <region_file.ini>", | 317 | "create region [\"region name\"] <region_file.ini>", |
318 | "Create a new region.", | 318 | "Create a new region.", |
319 | "The settings for \"region name\" are read from <region_file.ini> in your Regions directory." | 319 | "The settings for \"region name\" are read from <region_file.ini>. Paths specified with <region_file.ini> are relative to your Regions directory, unless an absolute path is given." |
320 | + " If \"region name\" does not exist in <region_file.ini>, it will be added." + Environment.NewLine | 320 | + " If \"region name\" does not exist in <region_file.ini>, it will be added." + Environment.NewLine |
321 | + "Without \"region name\", the first region found in <region_file.ini> will be created." + Environment.NewLine | 321 | + "Without \"region name\", the first region found in <region_file.ini> will be created." + Environment.NewLine |
322 | + "If <region_file.ini> does not exist, it will be created.", | 322 | + "If <region_file.ini> does not exist, it will be created.", |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index cede050..48d5a12 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -1531,6 +1531,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1531 | OutPacket(kill, ThrottleOutPacketType.Task); | 1531 | OutPacket(kill, ThrottleOutPacketType.Task); |
1532 | } | 1532 | } |
1533 | } | 1533 | } |
1534 | else | ||
1535 | { | ||
1536 | OutPacket(kill, ThrottleOutPacketType.State); | ||
1537 | } | ||
1534 | } | 1538 | } |
1535 | 1539 | ||
1536 | /// <summary> | 1540 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 02f0968..ef5efdd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -237,9 +237,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
237 | 237 | ||
238 | public virtual void OnChatBroadcast(Object sender, OSChatMessage c) | 238 | public virtual void OnChatBroadcast(Object sender, OSChatMessage c) |
239 | { | 239 | { |
240 | // unless the chat to be broadcast is of type Region, we | 240 | if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return; |
241 | // drop it if its channel is neither 0 nor DEBUG_CHANNEL | ||
242 | if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL && c.Type != ChatTypeEnum.Region) return; | ||
243 | 241 | ||
244 | ChatTypeEnum cType = c.Type; | 242 | ChatTypeEnum cType = c.Type; |
245 | if (c.Channel == DEBUG_CHANNEL) | 243 | if (c.Channel == DEBUG_CHANNEL) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 4e4eee9..7a21d5e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -317,7 +317,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
317 | continue; | 317 | continue; |
318 | 318 | ||
319 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, fromAgentID); | 319 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, fromAgentID); |
320 | PresenceInfo presence = PresenceService.GetAgent(fromAgentID); | 320 | |
321 | PresenceInfo presence = null; | ||
322 | PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid }); | ||
323 | if (presences != null && presences.Length > 0) | ||
324 | presence = presences[0]; | ||
325 | if (presence != null) | ||
326 | im.offline = 0; | ||
321 | 327 | ||
322 | im.fromAgentID = fromAgentID.Guid; | 328 | im.fromAgentID = fromAgentID.Guid; |
323 | im.fromAgentName = account.FirstName + " " + account.LastName; | 329 | im.fromAgentName = account.FirstName + " " + account.LastName; |
@@ -430,13 +436,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
430 | return; | 436 | return; |
431 | 437 | ||
432 | // The friend is not here [as root]. Let's forward. | 438 | // The friend is not here [as root]. Let's forward. |
433 | PresenceInfo friendSession = PresenceService.GetAgent(friendID); | 439 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
434 | if (friendSession != null && friendSession.RegionID != UUID.Zero) // let's guard against sessions-gone-bad with the RegionID check | 440 | if (friendSessions != null && friendSessions.Length > 0) |
435 | { | 441 | { |
436 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 442 | PresenceInfo friendSession = null; |
437 | //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); | 443 | foreach (PresenceInfo pinfo in friendSessions) |
438 | m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); | 444 | if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad |
445 | { | ||
446 | friendSession = pinfo; | ||
447 | break; | ||
448 | } | ||
449 | |||
450 | if (friendSession != null) | ||
451 | { | ||
452 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
453 | //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); | ||
454 | m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); | ||
455 | } | ||
439 | } | 456 | } |
457 | |||
458 | // Friend is not online. Ignore. | ||
440 | } | 459 | } |
441 | else | 460 | else |
442 | { | 461 | { |
@@ -477,11 +496,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
477 | return; | 496 | return; |
478 | 497 | ||
479 | // The prospective friend is not here [as root]. Let's forward. | 498 | // The prospective friend is not here [as root]. Let's forward. |
480 | PresenceInfo friendSession = PresenceService.GetAgent(friendID); | 499 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
481 | if (friendSession != null) | 500 | if (friendSessions != null && friendSessions.Length > 0) |
482 | { | 501 | { |
483 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 502 | PresenceInfo friendSession = friendSessions[0]; |
484 | m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); | 503 | if (friendSession != null) |
504 | { | ||
505 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
506 | m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); | ||
507 | } | ||
485 | } | 508 | } |
486 | // If the prospective friend is not online, he'll get the message upon login. | 509 | // If the prospective friend is not online, he'll get the message upon login. |
487 | } | 510 | } |
@@ -508,12 +531,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
508 | } | 531 | } |
509 | 532 | ||
510 | // The friend is not here | 533 | // The friend is not here |
511 | PresenceInfo friendSession = PresenceService.GetAgent(friendID); | 534 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
512 | if (friendSession != null) | 535 | if (friendSessions != null && friendSessions.Length > 0) |
513 | { | 536 | { |
514 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 537 | PresenceInfo friendSession = friendSessions[0]; |
515 | m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); | 538 | if (friendSession != null) |
516 | client.SendAgentOnline(new UUID[] { friendID }); | 539 | { |
540 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
541 | m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); | ||
542 | client.SendAgentOnline(new UUID[] { friendID }); | ||
543 | } | ||
517 | } | 544 | } |
518 | } | 545 | } |
519 | 546 | ||
@@ -532,14 +559,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
532 | if (LocalFriendshipDenied(agentID, client.Name, friendID)) | 559 | if (LocalFriendshipDenied(agentID, client.Name, friendID)) |
533 | return; | 560 | return; |
534 | 561 | ||
535 | PresenceInfo friendSession = PresenceService.GetAgent(friendID); | 562 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
536 | if (friendSession != null) | 563 | if (friendSessions != null && friendSessions.Length > 0) |
537 | { | 564 | { |
538 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 565 | PresenceInfo friendSession = friendSessions[0]; |
539 | if (region != null) | 566 | if (friendSession != null) |
540 | m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); | 567 | { |
541 | else | 568 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); |
542 | m_log.WarnFormat("[FRIENDS]: Could not find region {0} in locating {1}", friendSession.RegionID, friendID); | 569 | if (region != null) |
570 | m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); | ||
571 | else | ||
572 | m_log.WarnFormat("[FRIENDS]: Could not find region {0} in locating {1}", friendSession.RegionID, friendID); | ||
573 | } | ||
543 | } | 574 | } |
544 | } | 575 | } |
545 | 576 | ||
@@ -561,11 +592,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
561 | if (LocalFriendshipTerminated(exfriendID)) | 592 | if (LocalFriendshipTerminated(exfriendID)) |
562 | return; | 593 | return; |
563 | 594 | ||
564 | PresenceInfo friendSession = PresenceService.GetAgent(exfriendID); | 595 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() }); |
565 | if (friendSession != null) | 596 | if (friendSessions != null && friendSessions.Length > 0) |
566 | { | 597 | { |
567 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 598 | PresenceInfo friendSession = friendSessions[0]; |
568 | m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); | 599 | if (friendSession != null) |
600 | { | ||
601 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
602 | m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); | ||
603 | } | ||
569 | } | 604 | } |
570 | } | 605 | } |
571 | 606 | ||
@@ -604,13 +639,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
604 | if (LocalGrantRights(requester, target, myFlags, rights)) | 639 | if (LocalGrantRights(requester, target, myFlags, rights)) |
605 | return; | 640 | return; |
606 | 641 | ||
607 | PresenceInfo friendSession = PresenceService.GetAgent(target); | 642 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); |
608 | if (friendSession != null) | 643 | if (friendSessions != null && friendSessions.Length > 0) |
609 | { | 644 | { |
610 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 645 | PresenceInfo friendSession = friendSessions[0]; |
611 | // TODO: You might want to send the delta to save the lookup | 646 | if (friendSession != null) |
612 | // on the other end!! | 647 | { |
613 | m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); | 648 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); |
649 | // TODO: You might want to send the delta to save the lookup | ||
650 | // on the other end!! | ||
651 | m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); | ||
652 | } | ||
614 | } | 653 | } |
615 | } | 654 | } |
616 | } | 655 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 43bbf0d..9b1222b 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -498,7 +498,18 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
498 | if (lookupAgent) | 498 | if (lookupAgent) |
499 | { | 499 | { |
500 | // Non-cached user agent lookup. | 500 | // Non-cached user agent lookup. |
501 | upd = PresenceService.GetAgent(toAgentID); | 501 | PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); |
502 | if (presences != null && presences.Length > 0) | ||
503 | { | ||
504 | foreach (PresenceInfo p in presences) | ||
505 | { | ||
506 | if (p.RegionID != UUID.Zero) | ||
507 | { | ||
508 | upd = p; | ||
509 | break; | ||
510 | } | ||
511 | } | ||
512 | } | ||
502 | 513 | ||
503 | if (upd != null) | 514 | if (upd != null) |
504 | { | 515 | { |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index a88c5e2..5fabbb0 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs | |||
@@ -957,7 +957,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
957 | CacheKey = sb.ToString(); | 957 | CacheKey = sb.ToString(); |
958 | m_memoryCache.TryGetValue(CacheKey, out resp); | 958 | m_memoryCache.TryGetValue(CacheKey, out resp); |
959 | } | 959 | } |
960 | |||
961 | } | 960 | } |
962 | 961 | ||
963 | if (resp == null) | 962 | if (resp == null) |
@@ -965,22 +964,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
965 | string UserService; | 964 | string UserService; |
966 | UUID SessionID; | 965 | UUID SessionID; |
967 | GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); | 966 | GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); |
968 | param.Add("requestingAgentID", requestingAgentID.ToString()); | 967 | |
968 | param.Add("RequestingAgentID", requestingAgentID.ToString()); | ||
969 | param.Add("RequestingAgentUserService", UserService); | 969 | param.Add("RequestingAgentUserService", UserService); |
970 | param.Add("RequestingSessionID", SessionID.ToString()); | 970 | param.Add("RequestingSessionID", SessionID.ToString()); |
971 | |||
972 | |||
973 | param.Add("ReadKey", m_groupReadKey); | 971 | param.Add("ReadKey", m_groupReadKey); |
974 | param.Add("WriteKey", m_groupWriteKey); | 972 | param.Add("WriteKey", m_groupWriteKey); |
975 | 973 | ||
976 | |||
977 | IList parameters = new ArrayList(); | 974 | IList parameters = new ArrayList(); |
978 | parameters.Add(param); | 975 | parameters.Add(param); |
979 | 976 | ||
980 | ConfigurableKeepAliveXmlRpcRequest req; | 977 | ConfigurableKeepAliveXmlRpcRequest req; |
981 | req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); | 978 | req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); |
982 | 979 | ||
983 | |||
984 | try | 980 | try |
985 | { | 981 | { |
986 | resp = req.Send(m_groupsServerURI, 10000); | 982 | resp = req.Send(m_groupsServerURI, 10000); |
@@ -989,7 +985,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
989 | { | 985 | { |
990 | m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout)); | 986 | m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout)); |
991 | } | 987 | } |
992 | |||
993 | } | 988 | } |
994 | catch (Exception e) | 989 | catch (Exception e) |
995 | { | 990 | { |
@@ -1058,10 +1053,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1058 | { | 1053 | { |
1059 | m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line); | 1054 | m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line); |
1060 | } | 1055 | } |
1061 | |||
1062 | } | 1056 | } |
1063 | } | 1057 | } |
1064 | |||
1065 | 1058 | ||
1066 | /// <summary> | 1059 | /// <summary> |
1067 | /// Group Request Tokens are an attempt to allow the groups service to authenticate | 1060 | /// Group Request Tokens are an attempt to allow the groups service to authenticate |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 01c026e..a6ca171 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -3956,7 +3956,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3956 | } | 3956 | } |
3957 | 3957 | ||
3958 | 3958 | ||
3959 | pinfo = World.PresenceService.GetAgent(uuid); | 3959 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
3960 | if (pinfos != null && pinfos.Length > 0) | ||
3961 | { | ||
3962 | foreach (PresenceInfo p in pinfos) | ||
3963 | { | ||
3964 | if (p.RegionID != UUID.Zero) | ||
3965 | { | ||
3966 | pinfo = p; | ||
3967 | } | ||
3968 | } | ||
3969 | } | ||
3960 | 3970 | ||
3961 | ce = new UserInfoCacheEntry(); | 3971 | ce = new UserInfoCacheEntry(); |
3962 | ce.time = Util.EnvironmentTickCount(); | 3972 | ce.time = Util.EnvironmentTickCount(); |
@@ -3974,7 +3984,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3974 | 3984 | ||
3975 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) | 3985 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) |
3976 | { | 3986 | { |
3977 | pinfo = World.PresenceService.GetAgent(uuid); | 3987 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
3988 | if (pinfos != null && pinfos.Length > 0) | ||
3989 | { | ||
3990 | foreach (PresenceInfo p in pinfos) | ||
3991 | { | ||
3992 | if (p.RegionID != UUID.Zero) | ||
3993 | { | ||
3994 | pinfo = p; | ||
3995 | } | ||
3996 | } | ||
3997 | } | ||
3998 | else | ||
3999 | pinfo = null; | ||
3978 | 4000 | ||
3979 | ce.time = Util.EnvironmentTickCount(); | 4001 | ce.time = Util.EnvironmentTickCount(); |
3980 | ce.pinfo = pinfo; | 4002 | ce.pinfo = pinfo; |
@@ -5579,78 +5601,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5579 | ScriptSleep(5000); | 5601 | ScriptSleep(5000); |
5580 | } | 5602 | } |
5581 | 5603 | ||
5582 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | ||
5583 | { | ||
5584 | m_host.AddScriptLPS(1); | ||
5585 | LSL_List ret = new LSL_List(); | ||
5586 | LSL_List spacers = new LSL_List(); | ||
5587 | if (in_spacers.Length > 0 && separators.Length > 0) | ||
5588 | { | ||
5589 | for (int i = 0; i < in_spacers.Length; i++) | ||
5590 | { | ||
5591 | object s = in_spacers.Data[i]; | ||
5592 | for (int j = 0; j < separators.Length; j++) | ||
5593 | { | ||
5594 | if (separators.Data[j].ToString() == s.ToString()) | ||
5595 | { | ||
5596 | s = null; | ||
5597 | break; | ||
5598 | } | ||
5599 | } | ||
5600 | if (s != null) | ||
5601 | { | ||
5602 | spacers.Add(s); | ||
5603 | } | ||
5604 | } | ||
5605 | } | ||
5606 | object[] delimiters = new object[separators.Length + spacers.Length]; | ||
5607 | separators.Data.CopyTo(delimiters, 0); | ||
5608 | spacers.Data.CopyTo(delimiters, separators.Length); | ||
5609 | bool dfound = false; | ||
5610 | do | ||
5611 | { | ||
5612 | dfound = false; | ||
5613 | int cindex = -1; | ||
5614 | string cdeli = ""; | ||
5615 | for (int i = 0; i < delimiters.Length; i++) | ||
5616 | { | ||
5617 | int index = str.IndexOf(delimiters[i].ToString()); | ||
5618 | bool found = index != -1; | ||
5619 | if (found && String.Empty != delimiters[i].ToString()) | ||
5620 | { | ||
5621 | if ((cindex > index) || (cindex == -1)) | ||
5622 | { | ||
5623 | cindex = index; | ||
5624 | cdeli = delimiters[i].ToString(); | ||
5625 | } | ||
5626 | dfound = dfound || found; | ||
5627 | } | ||
5628 | } | ||
5629 | if (cindex != -1) | ||
5630 | { | ||
5631 | if (cindex > 0) | ||
5632 | { | ||
5633 | ret.Add(new LSL_String(str.Substring(0, cindex))); | ||
5634 | } | ||
5635 | // Cannot use spacers.Contains() because spacers may be either type String or LSLString | ||
5636 | for (int j = 0; j < spacers.Length; j++) | ||
5637 | { | ||
5638 | if (spacers.Data[j].ToString() == cdeli) | ||
5639 | { | ||
5640 | ret.Add(new LSL_String(cdeli)); | ||
5641 | break; | ||
5642 | } | ||
5643 | } | ||
5644 | str = str.Substring(cindex + cdeli.Length); | ||
5645 | } | ||
5646 | } while (dfound); | ||
5647 | if (str != "") | ||
5648 | { | ||
5649 | ret.Add(new LSL_String(str)); | ||
5650 | } | ||
5651 | return ret; | ||
5652 | } | ||
5653 | |||
5654 | public LSL_Integer llOverMyLand(string id) | 5604 | public LSL_Integer llOverMyLand(string id) |
5655 | { | 5605 | { |
5656 | m_host.AddScriptLPS(1); | 5606 | m_host.AddScriptLPS(1); |
@@ -8414,7 +8364,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8414 | // of arrays or other objects. | 8364 | // of arrays or other objects. |
8415 | // </remarks> | 8365 | // </remarks> |
8416 | 8366 | ||
8417 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | 8367 | private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
8418 | { | 8368 | { |
8419 | int beginning = 0; | 8369 | int beginning = 0; |
8420 | int srclen = src.Length; | 8370 | int srclen = src.Length; |
@@ -8434,8 +8384,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8434 | 8384 | ||
8435 | LSL_List tokens = new LSL_List(); | 8385 | LSL_List tokens = new LSL_List(); |
8436 | 8386 | ||
8437 | m_host.AddScriptLPS(1); | ||
8438 | |||
8439 | // All entries are initially valid | 8387 | // All entries are initially valid |
8440 | 8388 | ||
8441 | for (int i = 0; i < mlen; i++) | 8389 | for (int i = 0; i < mlen; i++) |
@@ -8507,14 +8455,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8507 | { | 8455 | { |
8508 | // no markers were found on this pass | 8456 | // no markers were found on this pass |
8509 | // so we're pretty much done | 8457 | // so we're pretty much done |
8510 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | 8458 | if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) |
8459 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
8511 | break; | 8460 | break; |
8512 | } | 8461 | } |
8513 | 8462 | ||
8514 | // Otherwise we just add the newly delimited token | 8463 | // Otherwise we just add the newly delimited token |
8515 | // and recalculate where the search should continue. | 8464 | // and recalculate where the search should continue. |
8516 | 8465 | if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) | |
8517 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 8466 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); |
8518 | 8467 | ||
8519 | if (best < seplen) | 8468 | if (best < seplen) |
8520 | { | 8469 | { |
@@ -8523,7 +8472,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8523 | else | 8472 | else |
8524 | { | 8473 | { |
8525 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | 8474 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; |
8526 | tokens.Add(new LSL_String(spcarray[best - seplen].ToString())); | 8475 | string str = spcarray[best - seplen].ToString(); |
8476 | if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) | ||
8477 | tokens.Add(new LSL_String(str)); | ||
8527 | } | 8478 | } |
8528 | } | 8479 | } |
8529 | 8480 | ||
@@ -8533,7 +8484,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8533 | // arduous. Alternatively the 'break' could be replced with a return | 8484 | // arduous. Alternatively the 'break' could be replced with a return |
8534 | // but that's shabby programming. | 8485 | // but that's shabby programming. |
8535 | 8486 | ||
8536 | if (beginning == srclen) | 8487 | if ((beginning == srclen) && (keepNulls)) |
8537 | { | 8488 | { |
8538 | if (srclen != 0) | 8489 | if (srclen != 0) |
8539 | tokens.Add(new LSL_String("")); | 8490 | tokens.Add(new LSL_String("")); |
@@ -8541,7 +8492,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8541 | 8492 | ||
8542 | return tokens; | 8493 | return tokens; |
8543 | } | 8494 | } |
8544 | 8495 | ||
8496 | public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) | ||
8497 | { | ||
8498 | m_host.AddScriptLPS(1); | ||
8499 | return this.ParseString(src, separators, spacers, false); | ||
8500 | } | ||
8501 | |||
8502 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | ||
8503 | { | ||
8504 | m_host.AddScriptLPS(1); | ||
8505 | return this.ParseString(src, separators, spacers, true); | ||
8506 | } | ||
8507 | |||
8545 | public LSL_Integer llGetObjectPermMask(int mask) | 8508 | public LSL_Integer llGetObjectPermMask(int mask) |
8546 | { | 8509 | { |
8547 | m_host.AddScriptLPS(1); | 8510 | m_host.AddScriptLPS(1); |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs index b7e8538..0ef4974 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs | |||
@@ -291,8 +291,8 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
291 | // Check if the user is online | 291 | // Check if the user is online |
292 | if (client.Scene is Scene) | 292 | if (client.Scene is Scene) |
293 | { | 293 | { |
294 | OpenSim.Services.Interfaces.PresenceInfo presence = ((Scene)client.Scene).PresenceService.GetAgent(avatarID); | 294 | OpenSim.Services.Interfaces.PresenceInfo[] presences = ((Scene)client.Scene).PresenceService.GetAgents(new string[] { avatarID.ToString() }); |
295 | if (presence != null) | 295 | if (presences != null && presences.Length > 0) |
296 | flags |= ProfileFlags.Online; | 296 | flags |= ProfileFlags.Online; |
297 | } | 297 | } |
298 | 298 | ||
diff --git a/bin/config-include/Grid.ini b/bin/config-include/Grid.ini index 1794573..5624a38 100644 --- a/bin/config-include/Grid.ini +++ b/bin/config-include/Grid.ini | |||
@@ -20,6 +20,7 @@ | |||
20 | SimulationServices = "RemoteSimulationConnectorModule" | 20 | SimulationServices = "RemoteSimulationConnectorModule" |
21 | EntityTransferModule = "BasicEntityTransferModule" | 21 | EntityTransferModule = "BasicEntityTransferModule" |
22 | InventoryAccessModule = "BasicInventoryAccessModule" | 22 | InventoryAccessModule = "BasicInventoryAccessModule" |
23 | LandServices = "RemoteLandServicesConnector" | ||
23 | 24 | ||
24 | LandServiceInConnector = true | 25 | LandServiceInConnector = true |
25 | NeighbourServiceInConnector = true | 26 | NeighbourServiceInConnector = true |
diff --git a/bin/config-include/GridHypergrid.ini b/bin/config-include/GridHypergrid.ini index cb9ead4..409b2a9 100644 --- a/bin/config-include/GridHypergrid.ini +++ b/bin/config-include/GridHypergrid.ini | |||
@@ -23,6 +23,7 @@ | |||
23 | SimulationServices = "RemoteSimulationConnectorModule" | 23 | SimulationServices = "RemoteSimulationConnectorModule" |
24 | EntityTransferModule = "HGEntityTransferModule" | 24 | EntityTransferModule = "HGEntityTransferModule" |
25 | InventoryAccessModule = "HGInventoryAccessModule" | 25 | InventoryAccessModule = "HGInventoryAccessModule" |
26 | LandServices = "RemoteLandServicesConnector" | ||
26 | 27 | ||
27 | LandServiceInConnector = true | 28 | LandServiceInConnector = true |
28 | NeighbourServiceInConnector = true | 29 | NeighbourServiceInConnector = true |