diff options
author | Melanie | 2012-10-07 02:48:28 +0100 |
---|---|---|
committer | Melanie | 2012-10-07 02:48:28 +0100 |
commit | f7df68d922758c0a78664abe82d631579f6aa63f (patch) | |
tree | 85daa41ff4b35653b4fbb987cbc852ad853decef /OpenSim/Framework | |
parent | Merge branch 'master' into careminster (diff) | |
parent | refactor: Rename UserSessioNID -> UserSession in WebStatsModule since this is... (diff) | |
download | opensim-SC-f7df68d922758c0a78664abe82d631579f6aa63f.zip opensim-SC-f7df68d922758c0a78664abe82d631579f6aa63f.tar.gz opensim-SC-f7df68d922758c0a78664abe82d631579f6aa63f.tar.bz2 opensim-SC-f7df68d922758c0a78664abe82d631579f6aa63f.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
OpenSim/Region/Framework/Scenes/Scene.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Console/ConsoleUtil.cs | 114 | ||||
-rw-r--r-- | OpenSim/Framework/GridInstantMessage.cs | 9 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 13 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs (renamed from OpenSim/Framework/PacketPool.cs) | 8 |
4 files changed, 137 insertions, 7 deletions
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs new file mode 100644 index 0000000..2612a50 --- /dev/null +++ b/OpenSim/Framework/Console/ConsoleUtil.cs | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using OpenMetaverse; | ||
34 | |||
35 | public class ConsoleUtil | ||
36 | { | ||
37 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
38 | |||
39 | public const string MinRawConsoleVectorValue = "-~"; | ||
40 | public const string MaxRawConsoleVectorValue = "~"; | ||
41 | |||
42 | public const string VectorSeparator = ","; | ||
43 | public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); | ||
44 | |||
45 | /// <summary> | ||
46 | /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 | ||
47 | /// </summary> | ||
48 | /// <param name='rawConsoleVector'>/param> | ||
49 | /// <param name='vector'></param> | ||
50 | /// <returns></returns> | ||
51 | public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector) | ||
52 | { | ||
53 | return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector); | ||
54 | } | ||
55 | |||
56 | /// <summary> | ||
57 | /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3 | ||
58 | /// </summary> | ||
59 | /// <param name='rawConsoleVector'>/param> | ||
60 | /// <param name='vector'></param> | ||
61 | /// <returns></returns> | ||
62 | public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector) | ||
63 | { | ||
64 | return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector); | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// Convert a vector input from the console to an OpenMetaverse.Vector3 | ||
69 | /// </summary> | ||
70 | /// <param name='rawConsoleVector'> | ||
71 | /// A string in the form <x>,<y>,<z> where there is no space between values. | ||
72 | /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value | ||
73 | /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40) | ||
74 | /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue | ||
75 | /// Other than that, component values must be numeric. | ||
76 | /// </param> | ||
77 | /// <param name='blankComponentFunc'></param> | ||
78 | /// <param name='vector'></param> | ||
79 | /// <returns></returns> | ||
80 | public static bool TryParseConsoleVector( | ||
81 | string rawConsoleVector, Func<string, string> blankComponentFunc, out Vector3 vector) | ||
82 | { | ||
83 | List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); | ||
84 | |||
85 | if (components.Count < 1 || components.Count > 3) | ||
86 | { | ||
87 | vector = Vector3.Zero; | ||
88 | return false; | ||
89 | } | ||
90 | |||
91 | for (int i = components.Count; i < 3; i++) | ||
92 | components.Add(""); | ||
93 | |||
94 | List<string> semiDigestedComponents | ||
95 | = components.ConvertAll<string>( | ||
96 | c => | ||
97 | { | ||
98 | if (c == "") | ||
99 | return blankComponentFunc.Invoke(c); | ||
100 | else if (c == MaxRawConsoleVectorValue) | ||
101 | return float.MaxValue.ToString(); | ||
102 | else if (c == MinRawConsoleVectorValue) | ||
103 | return float.MinValue.ToString(); | ||
104 | else | ||
105 | return c; | ||
106 | }); | ||
107 | |||
108 | string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray()); | ||
109 | |||
110 | m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector); | ||
111 | |||
112 | return Vector3.TryParse(semiDigestedConsoleVector, out vector); | ||
113 | } | ||
114 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/GridInstantMessage.cs b/OpenSim/Framework/GridInstantMessage.cs index a6bf6e3..6ae0488 100644 --- a/OpenSim/Framework/GridInstantMessage.cs +++ b/OpenSim/Framework/GridInstantMessage.cs | |||
@@ -44,7 +44,6 @@ namespace OpenSim.Framework | |||
44 | public Vector3 Position; | 44 | public Vector3 Position; |
45 | public byte[] binaryBucket; | 45 | public byte[] binaryBucket; |
46 | 46 | ||
47 | |||
48 | public uint ParentEstateID; | 47 | public uint ParentEstateID; |
49 | public Guid RegionID; | 48 | public Guid RegionID; |
50 | public uint timestamp; | 49 | public uint timestamp; |
@@ -58,7 +57,7 @@ namespace OpenSim.Framework | |||
58 | string _fromAgentName, UUID _toAgentID, | 57 | string _fromAgentName, UUID _toAgentID, |
59 | byte _dialog, bool _fromGroup, string _message, | 58 | byte _dialog, bool _fromGroup, string _message, |
60 | UUID _imSessionID, bool _offline, Vector3 _position, | 59 | UUID _imSessionID, bool _offline, Vector3 _position, |
61 | byte[] _binaryBucket) | 60 | byte[] _binaryBucket, bool addTimestamp) |
62 | { | 61 | { |
63 | fromAgentID = _fromAgentID.Guid; | 62 | fromAgentID = _fromAgentID.Guid; |
64 | fromAgentName = _fromAgentName; | 63 | fromAgentName = _fromAgentName; |
@@ -79,7 +78,9 @@ namespace OpenSim.Framework | |||
79 | ParentEstateID = scene.RegionInfo.EstateSettings.ParentEstateID; | 78 | ParentEstateID = scene.RegionInfo.EstateSettings.ParentEstateID; |
80 | RegionID = scene.RegionInfo.RegionSettings.RegionUUID.Guid; | 79 | RegionID = scene.RegionInfo.RegionSettings.RegionUUID.Guid; |
81 | } | 80 | } |
82 | timestamp = (uint)Util.UnixTimeSinceEpoch(); | 81 | |
82 | if (addTimestamp) | ||
83 | timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
83 | } | 84 | } |
84 | 85 | ||
85 | public GridInstantMessage(IScene scene, UUID _fromAgentID, | 86 | public GridInstantMessage(IScene scene, UUID _fromAgentID, |
@@ -87,7 +88,7 @@ namespace OpenSim.Framework | |||
87 | string _message, bool _offline, | 88 | string _message, bool _offline, |
88 | Vector3 _position) : this(scene, _fromAgentID, _fromAgentName, | 89 | Vector3 _position) : this(scene, _fromAgentID, _fromAgentName, |
89 | _toAgentID, _dialog, false, _message, | 90 | _toAgentID, _dialog, false, _message, |
90 | _fromAgentID ^ _toAgentID, _offline, _position, new byte[0]) | 91 | _fromAgentID ^ _toAgentID, _offline, _position, new byte[0], true) |
91 | { | 92 | { |
92 | } | 93 | } |
93 | } | 94 | } |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index a26e930..74551ea 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -546,6 +546,19 @@ namespace OpenSim.Framework | |||
546 | } | 546 | } |
547 | 547 | ||
548 | /// <summary> | 548 | /// <summary> |
549 | /// Determines whether a point is inside a bounding box. | ||
550 | /// </summary> | ||
551 | /// <param name='v'>/param> | ||
552 | /// <param name='min'></param> | ||
553 | /// <param name='max'></param> | ||
554 | /// <returns></returns> | ||
555 | public static bool IsInsideBox(Vector3 v, Vector3 min, Vector3 max) | ||
556 | { | ||
557 | return v.X >= min.X & v.Y >= min.Y && v.Z >= min.Z | ||
558 | && v.X <= max.X && v.Y <= max.Y && v.Z <= max.Z; | ||
559 | } | ||
560 | |||
561 | /// <summary> | ||
549 | /// Are the co-ordinates of the new region visible from the old region? | 562 | /// Are the co-ordinates of the new region visible from the old region? |
550 | /// </summary> | 563 | /// </summary> |
551 | /// <param name="oldx">Old region x-coord</param> | 564 | /// <param name="oldx">Old region x-coord</param> |
diff --git a/OpenSim/Framework/PacketPool.cs b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs index 41d17c5..fc9406b 100644 --- a/OpenSim/Framework/PacketPool.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs | |||
@@ -32,9 +32,8 @@ using OpenMetaverse; | |||
32 | using OpenMetaverse.Packets; | 32 | using OpenMetaverse.Packets; |
33 | using log4net; | 33 | using log4net; |
34 | 34 | ||
35 | namespace OpenSim.Framework | 35 | namespace OpenSim.Region.ClientStack.LindenUDP |
36 | { | 36 | { |
37 | |||
38 | public sealed class PacketPool | 37 | public sealed class PacketPool |
39 | { | 38 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -44,6 +43,9 @@ namespace OpenSim.Framework | |||
44 | private bool packetPoolEnabled = true; | 43 | private bool packetPoolEnabled = true; |
45 | private bool dataBlockPoolEnabled = true; | 44 | private bool dataBlockPoolEnabled = true; |
46 | 45 | ||
46 | /// <summary> | ||
47 | /// Pool of packets available for reuse. | ||
48 | /// </summary> | ||
47 | private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>(); | 49 | private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>(); |
48 | 50 | ||
49 | private static Dictionary<Type, Stack<Object>> DataBlocks = | 51 | private static Dictionary<Type, Stack<Object>> DataBlocks = |
@@ -244,4 +246,4 @@ namespace OpenSim.Framework | |||
244 | } | 246 | } |
245 | } | 247 | } |
246 | } | 248 | } |
247 | } | 249 | } \ No newline at end of file |