diff options
author | Melanie | 2010-09-17 22:12:48 +0100 |
---|---|---|
committer | Melanie | 2010-09-17 22:12:48 +0100 |
commit | bdd4dcf69b6cb957025280689d28317b2f4b97b8 (patch) | |
tree | deec0f3b684b933485000952ee4d3422e3ade4b6 /OpenSim | |
parent | Merge branch 'careminster-presence-refactor' of ssh://melanie@3dhosting.de/va... (diff) | |
parent | Add LandServices to make landmarks work right in grids (diff) | |
download | opensim-SC-bdd4dcf69b6cb957025280689d28317b2f4b97b8.zip opensim-SC-bdd4dcf69b6cb957025280689d28317b2f4b97b8.tar.gz opensim-SC-bdd4dcf69b6cb957025280689d28317b2f4b97b8.tar.bz2 opensim-SC-bdd4dcf69b6cb957025280689d28317b2f4b97b8.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Tests/AnimationTests.cs | 96 | ||||
-rw-r--r-- | OpenSim/Framework/tests/PrimeNumberHelperTests.cs | 146 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 97 |
3 files changed, 302 insertions, 37 deletions
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/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/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index caa39ba..cd8353f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -5949,11 +5949,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5949 | ScriptSleep(5000); | 5949 | ScriptSleep(5000); |
5950 | } | 5950 | } |
5951 | 5951 | ||
5952 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | ||
5953 | { | ||
5954 | return ParseString2List(str, separators, in_spacers, false); | ||
5955 | } | ||
5956 | |||
5957 | public LSL_Integer llOverMyLand(string id) | 5952 | public LSL_Integer llOverMyLand(string id) |
5958 | { | 5953 | { |
5959 | m_host.AddScriptLPS(1); | 5954 | m_host.AddScriptLPS(1); |
@@ -8936,7 +8931,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8936 | // garbage generation. | 8931 | // garbage generation. |
8937 | // </remarks> | 8932 | // </remarks> |
8938 | 8933 | ||
8939 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | 8934 | private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
8940 | { | 8935 | { |
8941 | return ParseString2List(src, separators, spacers, true); | 8936 | return ParseString2List(src, separators, spacers, true); |
8942 | } | 8937 | } |
@@ -8957,19 +8952,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8957 | int i, j; | 8952 | int i, j; |
8958 | string d; | 8953 | string d; |
8959 | 8954 | ||
8960 | m_host.AddScriptLPS(1); | 8955 | // All entries are initially valid |
8961 | 8956 | ||
8962 | /* | 8957 | for (int i = 0; i < mlen; i++) |
8963 | * Convert separator and spacer lists to C# strings. | 8958 | active[i] = true; |
8964 | * Also filter out null strings so we don't hang. | 8959 | |
8965 | */ | 8960 | offset[mlen] = srclen; |
8966 | for (i = 0; i < seplen; i ++) { | 8961 | |
8967 | d = separray[i].ToString(); | 8962 | while (beginning < srclen) |
8968 | if (d.Length > 0) { | 8963 | { |
8969 | delarray[dellen++] = d; | 8964 | |
8970 | } | 8965 | best = mlen; // as bad as it gets |
8971 | } | 8966 | |
8972 | seplen = dellen; | 8967 | // Scan for separators |
8973 | 8968 | ||
8974 | for (i = 0; i < spclen; i ++) { | 8969 | for (i = 0; i < spclen; i ++) { |
8975 | d = spcarray[i].ToString(); | 8970 | d = spcarray[i].ToString(); |
@@ -9004,29 +8999,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9004 | } | 8999 | } |
9005 | } | 9000 | } |
9006 | 9001 | ||
9007 | /* | 9002 | // This is the normal exit from the scanning loop |
9008 | * Output source string starting at i through start of earliest delimeter. | 9003 | |
9009 | */ | 9004 | if (best == mlen) |
9010 | if (keepNulls || (earliestSrc > i)) { | 9005 | { |
9011 | outarray[outlen++] = src.Substring(i, earliestSrc - i); | 9006 | // no markers were found on this pass |
9007 | // so we're pretty much done | ||
9008 | if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) | ||
9009 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
9010 | break; | ||
9012 | } | 9011 | } |
9013 | 9012 | ||
9014 | /* | 9013 | // Otherwise we just add the newly delimited token |
9015 | * If no delimeter found at or after i, we're done scanning. | 9014 | // and recalculate where the search should continue. |
9016 | */ | 9015 | if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) |
9017 | if (earliestDel < 0) break; | 9016 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); |
9018 | 9017 | ||
9019 | /* | 9018 | if (best < seplen) |
9020 | * If delimeter was a spacer, output the spacer. | 9019 | { |
9021 | */ | 9020 | beginning = offset[best] + (separray[best].ToString()).Length; |
9022 | if (earliestDel >= seplen) { | 9021 | } |
9023 | outarray[outlen++] = earliestStr; | 9022 | else |
9023 | { | ||
9024 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | ||
9025 | string str = spcarray[best - seplen].ToString(); | ||
9026 | if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) | ||
9027 | tokens.Add(new LSL_String(str)); | ||
9024 | } | 9028 | } |
9029 | } | ||
9025 | 9030 | ||
9026 | /* | 9031 | // This an awkward an not very intuitive boundary case. If the |
9027 | * Look at rest of src string following delimeter. | 9032 | // last substring is a tokenizer, then there is an implied trailing |
9028 | */ | 9033 | // null list entry. Hopefully the single comparison will not be too |
9029 | i = earliestSrc + earliestStr.Length; | 9034 | // arduous. Alternatively the 'break' could be replced with a return |
9035 | // but that's shabby programming. | ||
9036 | |||
9037 | if ((beginning == srclen) && (keepNulls)) | ||
9038 | { | ||
9039 | if (srclen != 0) | ||
9040 | tokens.Add(new LSL_String("")); | ||
9030 | } | 9041 | } |
9031 | 9042 | ||
9032 | /* | 9043 | /* |
@@ -9038,7 +9049,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9038 | } | 9049 | } |
9039 | return new LSL_List(outlist); | 9050 | return new LSL_List(outlist); |
9040 | } | 9051 | } |
9041 | 9052 | ||
9053 | public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) | ||
9054 | { | ||
9055 | m_host.AddScriptLPS(1); | ||
9056 | return this.ParseString(src, separators, spacers, false); | ||
9057 | } | ||
9058 | |||
9059 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | ||
9060 | { | ||
9061 | m_host.AddScriptLPS(1); | ||
9062 | return this.ParseString(src, separators, spacers, true); | ||
9063 | } | ||
9064 | |||
9042 | public LSL_Integer llGetObjectPermMask(int mask) | 9065 | public LSL_Integer llGetObjectPermMask(int mask) |
9043 | { | 9066 | { |
9044 | m_host.AddScriptLPS(1); | 9067 | m_host.AddScriptLPS(1); |