aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/AgentCircuitData.cs4
-rw-r--r--OpenSim/Framework/AnimationSet.cs168
-rw-r--r--OpenSim/Framework/AssetBase.cs11
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs107
-rw-r--r--OpenSim/Framework/AvatarWearable.cs24
-rw-r--r--OpenSim/Framework/BlockingQueue.cs5
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs222
-rw-r--r--OpenSim/Framework/ColliderData.cs1
-rw-r--r--OpenSim/Framework/ConfigurationMember.cs530
-rw-r--r--OpenSim/Framework/Console/CommandConsole.cs4
-rw-r--r--OpenSim/Framework/CustomTypes.cs43
-rw-r--r--OpenSim/Framework/EntityTransferContext.cs70
-rw-r--r--OpenSim/Framework/EstateSettings.cs36
-rw-r--r--OpenSim/Framework/IClientAPI.cs44
-rw-r--r--OpenSim/Framework/ILandChannel.cs2
-rw-r--r--OpenSim/Framework/ILandObject.cs2
-rw-r--r--OpenSim/Framework/IMoneyModule.cs3
-rw-r--r--OpenSim/Framework/ISceneAgent.cs9
-rw-r--r--OpenSim/Framework/LandData.cs34
-rw-r--r--OpenSim/Framework/LandUpdateArgs.cs3
-rw-r--r--OpenSim/Framework/LocklessQueue.cs8
-rw-r--r--OpenSim/Framework/Monitoring/BaseStatsCollector.cs21
-rw-r--r--OpenSim/Framework/Monitoring/ServerStatsCollector.cs43
-rwxr-xr-xOpenSim/Framework/Monitoring/SimExtraStatsCollector.cs28
-rw-r--r--OpenSim/Framework/Monitoring/Stats/Stat.cs13
-rw-r--r--OpenSim/Framework/Monitoring/StatsManager.cs4
-rw-r--r--OpenSim/Framework/Monitoring/Watchdog.cs6
-rw-r--r--OpenSim/Framework/NetworkServersInfo.cs2
-rw-r--r--OpenSim/Framework/OSChatMessage.cs21
-rw-r--r--OpenSim/Framework/ObjectChangeData.cs80
-rw-r--r--OpenSim/Framework/ParcelMediaCommandEnum.cs2
-rw-r--r--OpenSim/Framework/PermissionsUtil.cs4
-rw-r--r--OpenSim/Framework/PluginLoader.cs17
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs38
-rw-r--r--OpenSim/Framework/PriorityQueue.cs37
-rw-r--r--OpenSim/Framework/RegionInfo.cs271
-rw-r--r--OpenSim/Framework/RegionSettings.cs24
-rw-r--r--OpenSim/Framework/RestClient.cs27
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs22
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs116
-rw-r--r--OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs6
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs4
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs60
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs361
-rw-r--r--OpenSim/Framework/Servers/ServerBase.cs2
-rw-r--r--OpenSim/Framework/Servers/Tests/OSHttpTests.cs324
-rw-r--r--OpenSim/Framework/SimStats.cs14
-rw-r--r--OpenSim/Framework/TaskInventoryDictionary.cs189
-rw-r--r--OpenSim/Framework/TaskInventoryItem.cs2
-rw-r--r--OpenSim/Framework/TerrainData.cs320
-rw-r--r--OpenSim/Framework/Tests/AgentCircuitDataTest.cs3
-rw-r--r--OpenSim/Framework/Tests/MundaneFrameworkTests.cs11
-rw-r--r--OpenSim/Framework/ThrottleOutPacketType.cs2
-rw-r--r--OpenSim/Framework/UserProfileData.cs2
-rw-r--r--OpenSim/Framework/Util.cs246
-rw-r--r--OpenSim/Framework/WearableCacheItem.cs70
-rw-r--r--OpenSim/Framework/WebUtil.cs63
57 files changed, 3268 insertions, 517 deletions
diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs
index 0d053e4..4529944 100644
--- a/OpenSim/Framework/AgentCircuitData.cs
+++ b/OpenSim/Framework/AgentCircuitData.cs
@@ -184,7 +184,7 @@ namespace OpenSim.Framework
184 /// Pack AgentCircuitData into an OSDMap for transmission over LLSD XML or LLSD json 184 /// Pack AgentCircuitData into an OSDMap for transmission over LLSD XML or LLSD json
185 /// </summary> 185 /// </summary>
186 /// <returns>map of the agent circuit data</returns> 186 /// <returns>map of the agent circuit data</returns>
187 public OSDMap PackAgentCircuitData() 187 public OSDMap PackAgentCircuitData(EntityTransferContext ctx)
188 { 188 {
189 OSDMap args = new OSDMap(); 189 OSDMap args = new OSDMap();
190 args["agent_id"] = OSD.FromUUID(AgentID); 190 args["agent_id"] = OSD.FromUUID(AgentID);
@@ -224,7 +224,7 @@ namespace OpenSim.Framework
224 { 224 {
225 args["appearance_serial"] = OSD.FromInteger(Appearance.Serial); 225 args["appearance_serial"] = OSD.FromInteger(Appearance.Serial);
226 226
227 OSDMap appmap = Appearance.Pack(); 227 OSDMap appmap = Appearance.Pack(ctx);
228 args["packed_appearance"] = appmap; 228 args["packed_appearance"] = appmap;
229 } 229 }
230 230
diff --git a/OpenSim/Framework/AnimationSet.cs b/OpenSim/Framework/AnimationSet.cs
new file mode 100644
index 0000000..6c5b15c
--- /dev/null
+++ b/OpenSim/Framework/AnimationSet.cs
@@ -0,0 +1,168 @@
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
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31
32namespace OpenSim.Framework
33{
34 public delegate bool AnimationSetValidator(UUID animID);
35
36 public class AnimationSet
37 {
38 private bool m_parseError = false;
39
40 public const uint createBasePermitions = (uint)(PermissionMask.All); // no export ?
41 public const uint createNextPermitions = (uint)(PermissionMask.Copy | PermissionMask.Modify);
42
43 public const uint allowedBasePermitions = (uint)(PermissionMask.Copy | PermissionMask.Modify);
44 public const uint allowedNextPermitions = 0;
45
46 public static void setCreateItemPermitions(InventoryItemBase it)
47 {
48 if (it == null)
49 return;
50
51 it.BasePermissions = createBasePermitions;
52 it.CurrentPermissions = createBasePermitions;
53 // it.GroupPermissions &= allowedPermitions;
54 it.NextPermissions = createNextPermitions;
55 // it.EveryOnePermissions &= allowedPermitions;
56 it.GroupPermissions = 0;
57 it.EveryOnePermissions = 0;
58 }
59
60 public static void enforceItemPermitions(InventoryItemBase it, bool IsCreator)
61 {
62 if (it == null)
63 return;
64
65 uint bp;
66 uint np;
67
68 if (IsCreator)
69 {
70 bp = createBasePermitions;
71 np = createNextPermitions;
72 }
73 else
74 {
75 bp = allowedBasePermitions;
76 np = allowedNextPermitions;
77 }
78
79 it.BasePermissions &= bp;
80 it.CurrentPermissions &= bp;
81 // it.GroupPermissions &= allowedPermitions;
82 it.NextPermissions &= np;
83 // it.EveryOnePermissions &= allowedPermitions;
84 it.GroupPermissions = 0;
85 it.EveryOnePermissions = 0;
86 }
87
88 public int AnimationCount { get; private set; }
89 private Dictionary<string, KeyValuePair<string, UUID>> m_animations = new Dictionary<string, KeyValuePair<string, UUID>>();
90
91 public UUID GetAnimation(string index)
92 {
93 KeyValuePair<string, UUID> val;
94 if (m_animations.TryGetValue(index, out val))
95 return val.Value;
96
97 return UUID.Zero;
98 }
99
100 public string GetAnimationName(string index)
101 {
102 KeyValuePair<string, UUID> val;
103 if (m_animations.TryGetValue(index, out val))
104 return val.Key;
105
106 return String.Empty;
107 }
108
109 public void SetAnimation(string index, string name, UUID anim)
110 {
111 if (anim == UUID.Zero)
112 {
113 m_animations.Remove(index);
114 return;
115 }
116
117 m_animations[index] = new KeyValuePair<string, UUID>(name, anim);
118 }
119
120 public AnimationSet(Byte[] data)
121 {
122 string assetData = System.Text.Encoding.ASCII.GetString(data);
123 Console.WriteLine("--------------------");
124 Console.WriteLine("AnimationSet length {0} bytes", assetData.Length);
125 Console.WriteLine(assetData);
126 Console.WriteLine("--------------------");
127 }
128
129 public Byte[] ToBytes()
130 {
131 // If there was an error parsing the input, we give back an
132 // empty set rather than the original data.
133 if (m_parseError)
134 {
135 string dummy = "version 1\ncount 0\n";
136 return System.Text.Encoding.ASCII.GetBytes(dummy);
137 }
138
139 string assetData = String.Format("version 1\ncount {0}\n", m_animations.Count);
140 foreach (KeyValuePair<string, KeyValuePair<string, UUID>> kvp in m_animations)
141 assetData += String.Format("{0} {1} {2}\n", kvp.Key, kvp.Value.Value.ToString(), kvp.Value.Key);
142 return System.Text.Encoding.ASCII.GetBytes(assetData);
143 }
144
145 public bool Validate(AnimationSetValidator val)
146 {
147 if (m_parseError)
148 return false;
149
150 List<string> badAnims = new List<string>();
151
152 bool allOk = true;
153 foreach (KeyValuePair<string, KeyValuePair<string, UUID>> kvp in m_animations)
154 {
155 if (!val(kvp.Value.Value))
156 {
157 allOk = false;
158 badAnims.Add(kvp.Key);
159 }
160 }
161
162 foreach (string idx in badAnims)
163 m_animations.Remove(idx);
164
165 return allOk;
166 }
167 }
168}
diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs
index 2f04d2e..33be612 100644
--- a/OpenSim/Framework/AssetBase.cs
+++ b/OpenSim/Framework/AssetBase.cs
@@ -63,6 +63,8 @@ namespace OpenSim.Framework
63 /// </summary> 63 /// </summary>
64 private AssetMetadata m_metadata; 64 private AssetMetadata m_metadata;
65 65
66 private int m_uploadAttempts;
67
66 // This is needed for .NET serialization!!! 68 // This is needed for .NET serialization!!!
67 // Do NOT "Optimize" away! 69 // Do NOT "Optimize" away!
68 public AssetBase() 70 public AssetBase()
@@ -148,7 +150,8 @@ namespace OpenSim.Framework
148 Type == (sbyte)AssetType.Folder || 150 Type == (sbyte)AssetType.Folder ||
149 Type == (sbyte)AssetType.ImageJPEG || 151 Type == (sbyte)AssetType.ImageJPEG ||
150 Type == (sbyte)AssetType.ImageTGA || 152 Type == (sbyte)AssetType.ImageTGA ||
151 Type == (sbyte)AssetType.LSLBytecode); 153 Type == (sbyte)AssetType.Mesh ||
154 Type == (sbyte) AssetType.LSLBytecode);
152 } 155 }
153 } 156 }
154 157
@@ -197,6 +200,12 @@ namespace OpenSim.Framework
197 set { m_metadata.Type = value; } 200 set { m_metadata.Type = value; }
198 } 201 }
199 202
203 public int UploadAttempts
204 {
205 get { return m_uploadAttempts; }
206 set { m_uploadAttempts = value; }
207 }
208
200 /// <summary> 209 /// <summary>
201 /// Is this a region only asset, or does this exist on the asset server also 210 /// Is this a region only asset, or does this exist on the asset server also
202 /// </summary> 211 /// </summary>
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index e1725a9..79a66ab 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -53,7 +53,11 @@ namespace OpenSim.Framework
53 // should be only used as initial default value ( V1 viewers ) 53 // should be only used as initial default value ( V1 viewers )
54 public readonly static int VISUALPARAM_COUNT = 218; 54 public readonly static int VISUALPARAM_COUNT = 218;
55 55
56 public readonly static int TEXTURE_COUNT = 21; 56// public readonly static int TEXTURE_COUNT = 21
57 // 21 bad, make it be updated as libovm gets update
58 // also keeping in sync with it
59 public readonly static int TEXTURE_COUNT = Primitive.TextureEntry.MAX_FACES;
60
57 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; 61 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
58 62
59 protected int m_serial = 0; 63 protected int m_serial = 0;
@@ -179,11 +183,16 @@ namespace OpenSim.Framework
179 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 183 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
180 } 184 }
181 185
182 public AvatarAppearance(AvatarAppearance appearance) : this(appearance, true) 186 public AvatarAppearance(AvatarAppearance appearance): this(appearance, true,true)
183 { 187 {
184 } 188 }
185 189
186 public AvatarAppearance(AvatarAppearance appearance, bool copyWearables) 190 public AvatarAppearance(AvatarAppearance appearance, bool copyWearables)
191 : this(appearance, copyWearables, true)
192 {
193 }
194
195 public AvatarAppearance(AvatarAppearance appearance, bool copyWearables, bool copyBaked)
187 { 196 {
188// m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance"); 197// m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance");
189 198
@@ -202,21 +211,29 @@ namespace OpenSim.Framework
202 211
203 m_serial = appearance.Serial; 212 m_serial = appearance.Serial;
204 213
205 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES];
206 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
207 m_wearables[i] = new AvatarWearable();
208
209 if (copyWearables && (appearance.Wearables != null)) 214 if (copyWearables && (appearance.Wearables != null))
210 { 215 {
211 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 216 m_wearables = new AvatarWearable[appearance.Wearables.Length];
212 SetWearable(i,appearance.Wearables[i]); 217 for (int i = 0; i < appearance.Wearables.Length; i++)
218 {
219 m_wearables[i] = new AvatarWearable();
220 AvatarWearable wearable = appearance.Wearables[i];
221 for (int j = 0; j < wearable.Count; j++)
222 m_wearables[i].Add(wearable[j].ItemID, wearable[j].AssetID);
223 }
213 } 224 }
225 else
226 ClearWearables();
214 227
215 m_texture = null; 228 m_texture = null;
216 if (appearance.Texture != null) 229 if (appearance.Texture != null)
217 { 230 {
218 byte[] tbytes = appearance.Texture.GetBytes(); 231 byte[] tbytes = appearance.Texture.GetBytes();
219 m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length); 232 m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length);
233 if (copyBaked && appearance.m_cacheitems != null)
234 m_cacheitems = (WearableCacheItem[])appearance.m_cacheitems.Clone();
235 else
236 m_cacheitems = null;
220 } 237 }
221 238
222 m_visualparams = null; 239 m_visualparams = null;
@@ -234,9 +251,17 @@ namespace OpenSim.Framework
234 251
235 public void GetAssetsFrom(AvatarAppearance app) 252 public void GetAssetsFrom(AvatarAppearance app)
236 { 253 {
237 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 254 int len = m_wearables.Length;
255 if(len > app.m_wearables.Length)
256 len = app.m_wearables.Length;
257
258 for (int i = 0; i < len; i++)
238 { 259 {
239 for (int j = 0; j < m_wearables[i].Count; j++) 260 int count = m_wearables[i].Count;
261 if(count > app.m_wearables[i].Count)
262 count = app.m_wearables[i].Count;
263
264 for (int j = 0; j < count; j++)
240 { 265 {
241 UUID itemID = m_wearables[i][j].ItemID; 266 UUID itemID = m_wearables[i][j].ItemID;
242 UUID assetID = app.Wearables[i].GetAsset(itemID); 267 UUID assetID = app.Wearables[i].GetAsset(itemID);
@@ -249,8 +274,8 @@ namespace OpenSim.Framework
249 274
250 public void ClearWearables() 275 public void ClearWearables()
251 { 276 {
252 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; 277 m_wearables = new AvatarWearable[AvatarWearable.LEGACY_VERSION_MAX_WEARABLES];
253 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 278 for (int i = 0; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES; i++)
254 m_wearables[i] = new AvatarWearable(); 279 m_wearables[i] = new AvatarWearable();
255 } 280 }
256 281
@@ -457,11 +482,22 @@ namespace OpenSim.Framework
457// DEBUG ON 482// DEBUG ON
458// m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID); 483// m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID);
459// DEBUG OFF 484// DEBUG OFF
485 if (wearableId >= m_wearables.Length)
486 {
487 int currentLength = m_wearables.Length;
488 Array.Resize(ref m_wearables, wearableId + 1);
489 for (int i = currentLength ; i < m_wearables.Length ; i++)
490 m_wearables[i] = new AvatarWearable();
491 }
460 m_wearables[wearableId].Clear(); 492 m_wearables[wearableId].Clear();
493<<<<<<< HEAD
494 for (int i = 0; i < wearable.Count; i++)
495=======
461 int count = wearable.Count; 496 int count = wearable.Count;
462 if (count > AvatarWearable.MAX_WEARABLES) 497 if (count > AvatarWearable.MAX_WEARABLES)
463 count = AvatarWearable.MAX_WEARABLES; 498 count = AvatarWearable.MAX_WEARABLES;
464 for (int i = 0; i < count; i++) 499 for (int i = 0; i < count; i++)
500>>>>>>> master
465 m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID); 501 m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID);
466 } 502 }
467 503
@@ -701,7 +737,7 @@ namespace OpenSim.Framework
701 /// <summary> 737 /// <summary>
702 /// Create an OSDMap from the appearance data 738 /// Create an OSDMap from the appearance data
703 /// </summary> 739 /// </summary>
704 public OSDMap Pack() 740 public OSDMap Pack(EntityTransferContext ctx)
705 { 741 {
706 OSDMap data = new OSDMap(); 742 OSDMap data = new OSDMap();
707 743
@@ -709,9 +745,22 @@ namespace OpenSim.Framework
709 data["height"] = OSD.FromReal(m_avatarHeight); 745 data["height"] = OSD.FromReal(m_avatarHeight);
710 746
711 // Wearables 747 // Wearables
712 OSDArray wears = new OSDArray(AvatarWearable.MAX_WEARABLES); 748 //
713 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 749 // This will send as many or as few wearables as we have, unless a count
714 wears.Add(m_wearables[i].Pack()); 750 // is given. Used for legacy (pre 0.4) versions.
751 int count = ctx.WearablesCount;
752 if (ctx.WearablesCount == -1)
753 count = m_wearables.Length;
754 OSDArray wears = new OSDArray(count);
755 for (int i = 0; i < count; i++)
756 {
757 AvatarWearable dummyWearable = new AvatarWearable();
758
759 if (i < m_wearables.Length)
760 wears.Add(m_wearables[i].Pack());
761 else
762 wears.Add(dummyWearable.Pack());
763 }
715 data["wearables"] = wears; 764 data["wearables"] = wears;
716 765
717 // Avatar Textures 766 // Avatar Textures
@@ -725,6 +774,13 @@ namespace OpenSim.Framework
725 } 774 }
726 data["textures"] = textures; 775 data["textures"] = textures;
727 776
777 if (m_cacheitems != null)
778 {
779 OSDArray baked = WearableCacheItem.BakedToOSD(m_cacheitems);
780 if (baked != null)
781 data["bakedcache"] = baked;
782 }
783
728 // Visual Parameters 784 // Visual Parameters
729 OSDBinary visualparams = new OSDBinary(m_visualparams); 785 OSDBinary visualparams = new OSDBinary(m_visualparams);
730 data["visualparams"] = visualparams; 786 data["visualparams"] = visualparams;
@@ -760,9 +816,11 @@ namespace OpenSim.Framework
760 if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array) 816 if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array)
761 { 817 {
762 OSDArray wears = (OSDArray)(data["wearables"]); 818 OSDArray wears = (OSDArray)(data["wearables"]);
819
763 int count = wears.Count; 820 int count = wears.Count;
764 if (count > AvatarWearable.MAX_WEARABLES) 821
765 count = AvatarWearable.MAX_WEARABLES; 822 m_wearables = new AvatarWearable[count];
823
766 for (int i = 0; i < count; i++) 824 for (int i = 0; i < count; i++)
767 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]); 825 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]);
768 } 826 }
@@ -789,6 +847,12 @@ namespace OpenSim.Framework
789 m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures"); 847 m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures");
790 } 848 }
791 849
850 if ((data != null) && (data["bakedcache"] != null) && (data["bakedcache"]).Type == OSDType.Array)
851 {
852 OSDArray bakedOSDArray = (OSDArray)(data["bakedcache"]);
853 m_cacheitems = WearableCacheItem.BakedFromOSD(bakedOSDArray);
854 }
855
792 // Visual Parameters 856 // Visual Parameters
793 SetDefaultParams(); 857 SetDefaultParams();
794 if ((data != null) && (data["visualparams"] != null)) 858 if ((data != null) && (data["visualparams"] != null))
@@ -1638,7 +1702,12 @@ namespace OpenSim.Framework
1638 BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247, 1702 BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247,
1639 BREAST_PHYSICS_LEFTRIGHT_SPRING= 248, 1703 BREAST_PHYSICS_LEFTRIGHT_SPRING= 248,
1640 BREAST_PHYSICS_LEFTRIGHT_GAIN = 249, 1704 BREAST_PHYSICS_LEFTRIGHT_GAIN = 249,
1641 BREAST_PHYSICS_LEFTRIGHT_DAMPING = 250 1705 BREAST_PHYSICS_LEFTRIGHT_DAMPING = 250,
1706
1707 // Ubit: 07/96/2013 new parameters
1708 _APPEARANCEMESSAGE_VERSION = 251, //ID 11000
1709
1710 SHAPE_HOVER = 252, //ID 11001
1642 } 1711 }
1643 #endregion 1712 #endregion
1644 } 1713 }
diff --git a/OpenSim/Framework/AvatarWearable.cs b/OpenSim/Framework/AvatarWearable.cs
index 8e27596..80ed77f 100644
--- a/OpenSim/Framework/AvatarWearable.cs
+++ b/OpenSim/Framework/AvatarWearable.cs
@@ -62,10 +62,16 @@ namespace OpenSim.Framework
62 public static readonly int UNDERSHIRT = 10; 62 public static readonly int UNDERSHIRT = 10;
63 public static readonly int UNDERPANTS = 11; 63 public static readonly int UNDERPANTS = 11;
64 public static readonly int SKIRT = 12; 64 public static readonly int SKIRT = 12;
65
66 public static readonly int MAX_BASICWEARABLES = 13;
67
65 public static readonly int ALPHA = 13; 68 public static readonly int ALPHA = 13;
66 public static readonly int TATTOO = 14; 69 public static readonly int TATTOO = 14;
67 70
68 public static readonly int MAX_WEARABLES = 15; 71 public static readonly int LEGACY_VERSION_MAX_WEARABLES = 15;
72// public static readonly int PHYSICS = 15;
73// public static int MAX_WEARABLES = 16;
74
69 75
70 public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9"); 76 public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9");
71 public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73"); 77 public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73");
@@ -219,8 +225,9 @@ namespace OpenSim.Framework
219 { 225 {
220 get 226 get
221 { 227 {
222 AvatarWearable[] defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 15 of these 228 // We use the legacy count here because this is just a fallback anyway
223 for (int i = 0; i < MAX_WEARABLES; i++) 229 AvatarWearable[] defaultWearables = new AvatarWearable[LEGACY_VERSION_MAX_WEARABLES];
230 for (int i = 0; i < LEGACY_VERSION_MAX_WEARABLES; i++)
224 { 231 {
225 defaultWearables[i] = new AvatarWearable(); 232 defaultWearables[i] = new AvatarWearable();
226 } 233 }
@@ -242,10 +249,13 @@ namespace OpenSim.Framework
242 249
243// // Alpha 250// // Alpha
244// defaultWearables[ALPHA].Add(DEFAULT_ALPHA_ITEM, DEFAULT_ALPHA_ASSET); 251// defaultWearables[ALPHA].Add(DEFAULT_ALPHA_ITEM, DEFAULT_ALPHA_ASSET);
245 252
246// // Tattoo 253 // // Tattoo
247// defaultWearables[TATTOO].Add(DEFAULT_TATTOO_ITEM, DEFAULT_TATTOO_ASSET); 254 // defaultWearables[TATTOO].Add(DEFAULT_TATTOO_ITEM, DEFAULT_TATTOO_ASSET);
248 255
256 // // Physics
257 // defaultWearables[PHYSICS].Add(DEFAULT_TATTOO_ITEM, DEFAULT_TATTOO_ASSET);
258
249 return defaultWearables; 259 return defaultWearables;
250 } 260 }
251 } 261 }
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs
index d11ad11..daf99a8 100644
--- a/OpenSim/Framework/BlockingQueue.cs
+++ b/OpenSim/Framework/BlockingQueue.cs
@@ -76,10 +76,9 @@ namespace OpenSim.Framework
76 { 76 {
77 lock (m_queueSync) 77 lock (m_queueSync)
78 { 78 {
79 bool success = true; 79 if (m_queue.Count < 1 && m_pqueue.Count < 1)
80 while (m_queue.Count < 1 && m_pqueue.Count < 1 && success)
81 { 80 {
82 success = Monitor.Wait(m_queueSync, msTimeout); 81 Monitor.Wait(m_queueSync, msTimeout);
83 } 82 }
84 83
85 if (m_pqueue.Count > 0) 84 if (m_pqueue.Count > 0)
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index 2a8e67d..72c2c34 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -61,8 +61,8 @@ namespace OpenSim.Framework
61 { 61 {
62 UUID AgentID { get; set; } 62 UUID AgentID { get; set; }
63 63
64 OSDMap Pack(); 64 OSDMap Pack(EntityTransferContext ctx);
65 void Unpack(OSDMap map, IScene scene); 65 void Unpack(OSDMap map, IScene scene, EntityTransferContext ctx);
66 } 66 }
67 67
68 /// <summary> 68 /// <summary>
@@ -94,8 +94,9 @@ namespace OpenSim.Framework
94 // This probably shouldn't be here 94 // This probably shouldn't be here
95 public byte[] Throttles; 95 public byte[] Throttles;
96 96
97 public Dictionary<ulong, string> ChildrenCapSeeds = null;
97 98
98 public OSDMap Pack() 99 public OSDMap Pack(EntityTransferContext ctx)
99 { 100 {
100 OSDMap args = new OSDMap(); 101 OSDMap args = new OSDMap();
101 args["message_type"] = OSD.FromString("AgentPosition"); 102 args["message_type"] = OSD.FromString("AgentPosition");
@@ -119,10 +120,23 @@ namespace OpenSim.Framework
119 if ((Throttles != null) && (Throttles.Length > 0)) 120 if ((Throttles != null) && (Throttles.Length > 0))
120 args["throttles"] = OSD.FromBinary(Throttles); 121 args["throttles"] = OSD.FromBinary(Throttles);
121 122
123 if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0)
124 {
125 OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count);
126 foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds)
127 {
128 OSDMap pair = new OSDMap();
129 pair["handle"] = OSD.FromString(kvp.Key.ToString());
130 pair["seed"] = OSD.FromString(kvp.Value);
131 childrenSeeds.Add(pair);
132 }
133 args["children_seeds"] = childrenSeeds;
134 }
135
122 return args; 136 return args;
123 } 137 }
124 138
125 public void Unpack(OSDMap args, IScene scene) 139 public void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)
126 { 140 {
127 if (args.ContainsKey("region_handle")) 141 if (args.ContainsKey("region_handle"))
128 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); 142 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
@@ -165,6 +179,30 @@ namespace OpenSim.Framework
165 179
166 if (args["throttles"] != null) 180 if (args["throttles"] != null)
167 Throttles = args["throttles"].AsBinary(); 181 Throttles = args["throttles"].AsBinary();
182
183 if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) &&
184 (args["children_seeds"].Type == OSDType.Array))
185 {
186 OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
187 ChildrenCapSeeds = new Dictionary<ulong, string>();
188 foreach (OSD o in childrenSeeds)
189 {
190 if (o.Type == OSDType.Map)
191 {
192 ulong handle = 0;
193 string seed = "";
194 OSDMap pair = (OSDMap)o;
195 if (pair["handle"] != null)
196 if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
197 continue;
198 if (pair["seed"] != null)
199 seed = pair["seed"].AsString();
200 if (!ChildrenCapSeeds.ContainsKey(handle))
201 ChildrenCapSeeds.Add(handle, seed);
202 }
203 }
204 }
205
168 } 206 }
169 207
170 /// <summary> 208 /// <summary>
@@ -317,9 +355,11 @@ namespace OpenSim.Framework
317 public UUID ActiveGroupID; 355 public UUID ActiveGroupID;
318 356
319 public AgentGroupData[] Groups; 357 public AgentGroupData[] Groups;
358 public Dictionary<ulong, string> ChildrenCapSeeds = null;
320 public Animation[] Anims; 359 public Animation[] Anims;
321 public Animation DefaultAnim = null; 360 public Animation DefaultAnim = null;
322 public Animation AnimState = null; 361 public Animation AnimState = null;
362 public Byte MotionState = 0;
323 363
324 public UUID GranterID; 364 public UUID GranterID;
325 public UUID ParentPart; 365 public UUID ParentPart;
@@ -349,8 +389,12 @@ namespace OpenSim.Framework
349 public List<ISceneObject> AttachmentObjects; 389 public List<ISceneObject> AttachmentObjects;
350 public List<string> AttachmentObjectStates; 390 public List<string> AttachmentObjectStates;
351 391
352 public virtual OSDMap Pack() 392 public Dictionary<string, UUID> MovementAnimationOverRides = new Dictionary<string, UUID>();
393
394 public virtual OSDMap Pack(EntityTransferContext ctx)
353 { 395 {
396 int wearablesCount = -1;
397
354// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); 398// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");
355 399
356 OSDMap args = new OSDMap(); 400 OSDMap args = new OSDMap();
@@ -399,6 +443,19 @@ namespace OpenSim.Framework
399 args["groups"] = groups; 443 args["groups"] = groups;
400 } 444 }
401 445
446 if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0)
447 {
448 OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count);
449 foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds)
450 {
451 OSDMap pair = new OSDMap();
452 pair["handle"] = OSD.FromString(kvp.Key.ToString());
453 pair["seed"] = OSD.FromString(kvp.Value);
454 childrenSeeds.Add(pair);
455 }
456 args["children_seeds"] = childrenSeeds;
457 }
458
402 if ((Anims != null) && (Anims.Length > 0)) 459 if ((Anims != null) && (Anims.Length > 0))
403 { 460 {
404 OSDArray anims = new OSDArray(Anims.Length); 461 OSDArray anims = new OSDArray(Anims.Length);
@@ -417,8 +474,28 @@ namespace OpenSim.Framework
417 args["animation_state"] = AnimState.PackUpdateMessage(); 474 args["animation_state"] = AnimState.PackUpdateMessage();
418 } 475 }
419 476
477 if (MovementAnimationOverRides.Count > 0)
478 {
479 OSDArray AOs = new OSDArray(MovementAnimationOverRides.Count);
480 {
481 foreach (KeyValuePair<string, UUID> kvp in MovementAnimationOverRides)
482 {
483 OSDMap ao = new OSDMap(2);
484 ao["state"] = OSD.FromString(kvp.Key);
485 ao["uuid"] = OSD.FromUUID(kvp.Value);
486 AOs.Add(ao);
487 }
488 }
489 args["movementAO"] = AOs;
490 }
491
492 if (MotionState != 0)
493 {
494 args["motion_state"] = OSD.FromInteger(MotionState);
495 }
496
420 if (Appearance != null) 497 if (Appearance != null)
421 args["packed_appearance"] = Appearance.Pack(); 498 args["packed_appearance"] = Appearance.Pack(ctx);
422 499
423 //if ((AgentTextures != null) && (AgentTextures.Length > 0)) 500 //if ((AgentTextures != null) && (AgentTextures.Length > 0))
424 //{ 501 //{
@@ -431,6 +508,8 @@ namespace OpenSim.Framework
431 // The code to pack textures, visuals, wearables and attachments 508 // The code to pack textures, visuals, wearables and attachments
432 // should be removed; packed appearance contains the full appearance 509 // should be removed; packed appearance contains the full appearance
433 // This is retained for backward compatibility only 510 // This is retained for backward compatibility only
511
512/* then lets remove
434 if (Appearance.Texture != null) 513 if (Appearance.Texture != null)
435 { 514 {
436 byte[] rawtextures = Appearance.Texture.GetBytes(); 515 byte[] rawtextures = Appearance.Texture.GetBytes();
@@ -459,7 +538,7 @@ namespace OpenSim.Framework
459 args["attachments"] = attachs; 538 args["attachments"] = attachs;
460 } 539 }
461 // End of code to remove 540 // End of code to remove
462 541*/
463 if ((Controllers != null) && (Controllers.Length > 0)) 542 if ((Controllers != null) && (Controllers.Length > 0))
464 { 543 {
465 OSDArray controls = new OSDArray(Controllers.Length); 544 OSDArray controls = new OSDArray(Controllers.Length);
@@ -507,7 +586,7 @@ namespace OpenSim.Framework
507 /// Avoiding reflection makes it painful to write, but that's the price! 586 /// Avoiding reflection makes it painful to write, but that's the price!
508 /// </summary> 587 /// </summary>
509 /// <param name="hash"></param> 588 /// <param name="hash"></param>
510 public virtual void Unpack(OSDMap args, IScene scene) 589 public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)
511 { 590 {
512 //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data"); 591 //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data");
513 592
@@ -600,6 +679,29 @@ namespace OpenSim.Framework
600 } 679 }
601 } 680 }
602 681
682 if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) &&
683 (args["children_seeds"].Type == OSDType.Array))
684 {
685 OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
686 ChildrenCapSeeds = new Dictionary<ulong, string>();
687 foreach (OSD o in childrenSeeds)
688 {
689 if (o.Type == OSDType.Map)
690 {
691 ulong handle = 0;
692 string seed = "";
693 OSDMap pair = (OSDMap)o;
694 if (pair["handle"] != null)
695 if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
696 continue;
697 if (pair["seed"] != null)
698 seed = pair["seed"].AsString();
699 if (!ChildrenCapSeeds.ContainsKey(handle))
700 ChildrenCapSeeds.Add(handle, seed);
701 }
702 }
703 }
704
603 if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array) 705 if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array)
604 { 706 {
605 OSDArray anims = (OSDArray)(args["animations"]); 707 OSDArray anims = (OSDArray)(args["animations"]);
@@ -638,6 +740,28 @@ namespace OpenSim.Framework
638 } 740 }
639 } 741 }
640 742
743 MovementAnimationOverRides.Clear();
744
745 if (args["movementAO"] != null && args["movementAO"].Type == OSDType.Array)
746 {
747 OSDArray AOs = (OSDArray)(args["movementAO"]);
748 int count = AOs.Count;
749
750 for (int i = 0; i < count; i++)
751 {
752 OSDMap ao = (OSDMap)AOs[i];
753 if (ao["state"] != null && ao["uuid"] != null)
754 {
755 string state = ao["state"].AsString();
756 UUID id = ao["uuid"].AsUUID();
757 MovementAnimationOverRides[state] = id;
758 }
759 }
760 }
761
762 if (args.ContainsKey("motion_state"))
763 MotionState = (byte)args["motion_state"].AsInteger();
764
641 //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) 765 //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
642 //{ 766 //{
643 // OSDArray textures = (OSDArray)(args["agent_textures"]); 767 // OSDArray textures = (OSDArray)(args["agent_textures"]);
@@ -647,53 +771,67 @@ namespace OpenSim.Framework
647 // AgentTextures[i++] = o.AsUUID(); 771 // AgentTextures[i++] = o.AsUUID();
648 //} 772 //}
649 773
650 Appearance = new AvatarAppearance();
651 774
652 // The code to unpack textures, visuals, wearables and attachments 775 // packed_appearence should contain all appearance information
653 // should be removed; packed appearance contains the full appearance 776 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
654 // This is retained for backward compatibility only
655 if (args["texture_entry"] != null)
656 { 777 {
657 byte[] rawtextures = args["texture_entry"].AsBinary(); 778 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] got packed appearance");
658 Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures,0,rawtextures.Length); 779 Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]);
659 Appearance.SetTextureEntries(textures);
660 } 780 }
781 else
782 {
783 // if missing try the old pack method
784 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance, checking old method");
661 785
662 if (args["visual_params"] != null) 786 Appearance = new AvatarAppearance();
663 Appearance.SetVisualParams(args["visual_params"].AsBinary());
664 787
665 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) 788 // The code to unpack textures, visuals, wearables and attachments
666 { 789 // should be removed; packed appearance contains the full appearance
667 OSDArray wears = (OSDArray)(args["wearables"]); 790 // This is retained for backward compatibility only
668 for (int i = 0; i < wears.Count / 2; i++) 791 if (args["texture_entry"] != null)
669 { 792 {
670 AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); 793 byte[] rawtextures = args["texture_entry"].AsBinary();
671 Appearance.SetWearable(i,awear); 794 Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length);
795 Appearance.SetTextureEntries(textures);
672 } 796 }
673 }
674 797
675 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) 798 if (args["visual_params"] != null)
676 { 799 Appearance.SetVisualParams(args["visual_params"].AsBinary());
677 OSDArray attachs = (OSDArray)(args["attachments"]); 800
678 foreach (OSD o in attachs) 801 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
679 { 802 {
680 if (o.Type == OSDType.Map) 803 OSDArray wears = (OSDArray)(args["wearables"]);
804
805 for (int i = 0; i < wears.Count / 2; i++)
681 { 806 {
682 // We know all of these must end up as attachments so we 807 AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]);
683 // append rather than replace to ensure multiple attachments 808 Appearance.SetWearable(i, awear);
684 // per point continues to work
685// m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID);
686 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
687 } 809 }
688 } 810 }
689 }
690 // end of code to remove
691 811
812 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
813 {
814 OSDArray attachs = (OSDArray)(args["attachments"]);
815 foreach (OSD o in attachs)
816 {
817 if (o.Type == OSDType.Map)
818 {
819 // We know all of these must end up as attachments so we
820 // append rather than replace to ensure multiple attachments
821 // per point continues to work
822 // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID);
823 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
824 }
825 }
826 }
827 // end of code to remove
828 }
829/* moved above
692 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) 830 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
693 Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]); 831 Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]);
694 else 832 else
695 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); 833 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance");
696 834*/
697 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) 835 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
698 { 836 {
699 OSDArray controls = (OSDArray)(args["controllers"]); 837 OSDArray controls = (OSDArray)(args["controllers"]);
@@ -757,14 +895,14 @@ namespace OpenSim.Framework
757 895
758 public class CompleteAgentData : AgentData 896 public class CompleteAgentData : AgentData
759 { 897 {
760 public override OSDMap Pack() 898 public override OSDMap Pack(EntityTransferContext ctx)
761 { 899 {
762 return base.Pack(); 900 return base.Pack(ctx);
763 } 901 }
764 902
765 public override void Unpack(OSDMap map, IScene scene) 903 public override void Unpack(OSDMap map, IScene scene, EntityTransferContext ctx)
766 { 904 {
767 base.Unpack(map, scene); 905 base.Unpack(map, scene, ctx);
768 } 906 }
769 } 907 }
770} 908}
diff --git a/OpenSim/Framework/ColliderData.cs b/OpenSim/Framework/ColliderData.cs
index 1b7b682..00013e1 100644
--- a/OpenSim/Framework/ColliderData.cs
+++ b/OpenSim/Framework/ColliderData.cs
@@ -42,6 +42,7 @@ namespace OpenSim.Framework
42 public Vector3 velVector = Vector3.Zero; 42 public Vector3 velVector = Vector3.Zero;
43 public string nameStr = String.Empty; 43 public string nameStr = String.Empty;
44 public int colliderType = 0; 44 public int colliderType = 0;
45 public int linkNumber;
45 } 46 }
46 47
47 public class ColliderArgs : EventArgs 48 public class ColliderArgs : EventArgs
diff --git a/OpenSim/Framework/ConfigurationMember.cs b/OpenSim/Framework/ConfigurationMember.cs
new file mode 100644
index 0000000..7afa68a
--- /dev/null
+++ b/OpenSim/Framework/ConfigurationMember.cs
@@ -0,0 +1,530 @@
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
28using System;
29using System.Collections.Generic;
30using System.Globalization;
31using System.Net;
32using System.Reflection;
33using System.Xml;
34using log4net;
35using OpenMetaverse;
36//using OpenSim.Framework.Console;
37
38namespace OpenSim.Framework
39{
40 public class ConfigurationMember
41 {
42 #region Delegates
43
44 public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result);
45
46 public delegate void ConfigurationOptionsLoad();
47
48 #endregion
49
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 private int cE = 0;
52
53 private string configurationDescription = String.Empty;
54 private string configurationFilename = String.Empty;
55 private XmlNode configurationFromXMLNode = null;
56 private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>();
57 private IGenericConfig configurationPlugin = null;
58
59 /// <summary>
60 /// This is the default configuration DLL loaded
61 /// </summary>
62 private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll";
63
64 private ConfigurationOptionsLoad loadFunction;
65 private ConfigurationOptionResult resultFunction;
66
67 private bool useConsoleToPromptOnError = true;
68
69 public ConfigurationMember(string configuration_filename, string configuration_description,
70 ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function, bool use_console_to_prompt_on_error)
71 {
72 configurationFilename = configuration_filename;
73 configurationDescription = configuration_description;
74 loadFunction = load_function;
75 resultFunction = result_function;
76 useConsoleToPromptOnError = use_console_to_prompt_on_error;
77 }
78
79 public ConfigurationMember(XmlNode configuration_xml, string configuration_description,
80 ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function, bool use_console_to_prompt_on_error)
81 {
82 configurationFilename = String.Empty;
83 configurationFromXMLNode = configuration_xml;
84 configurationDescription = configuration_description;
85 loadFunction = load_function;
86 resultFunction = result_function;
87 useConsoleToPromptOnError = use_console_to_prompt_on_error;
88 }
89
90 public void setConfigurationFilename(string filename)
91 {
92 configurationFilename = filename;
93 }
94
95 public void setConfigurationDescription(string desc)
96 {
97 configurationDescription = desc;
98 }
99
100 public void setConfigurationResultFunction(ConfigurationOptionResult result)
101 {
102 resultFunction = result;
103 }
104
105 public void forceConfigurationPluginLibrary(string dll_filename)
106 {
107 configurationPluginFilename = dll_filename;
108 }
109
110 private void checkAndAddConfigOption(ConfigurationOption option)
111 {
112 if ((option.configurationKey != String.Empty && option.configurationQuestion != String.Empty) ||
113 (option.configurationKey != String.Empty && option.configurationUseDefaultNoPrompt))
114 {
115 if (!configurationOptions.Contains(option))
116 {
117 configurationOptions.Add(option);
118 }
119 }
120 else
121 {
122 m_log.Info(
123 "Required fields for adding a configuration option is invalid. Will not add this option (" +
124 option.configurationKey + ")");
125 }
126 }
127
128 public void addConfigurationOption(string configuration_key,
129 ConfigurationOption.ConfigurationTypes configuration_type,
130 string configuration_question, string configuration_default,
131 bool use_default_no_prompt)
132 {
133 ConfigurationOption configOption = new ConfigurationOption();
134 configOption.configurationKey = configuration_key;
135 configOption.configurationQuestion = configuration_question;
136 configOption.configurationDefault = configuration_default;
137 configOption.configurationType = configuration_type;
138 configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
139 configOption.shouldIBeAsked = null; //Assumes true, I can ask whenever
140 checkAndAddConfigOption(configOption);
141 }
142
143 public void addConfigurationOption(string configuration_key,
144 ConfigurationOption.ConfigurationTypes configuration_type,
145 string configuration_question, string configuration_default,
146 bool use_default_no_prompt,
147 ConfigurationOption.ConfigurationOptionShouldBeAsked shouldIBeAskedDelegate)
148 {
149 ConfigurationOption configOption = new ConfigurationOption();
150 configOption.configurationKey = configuration_key;
151 configOption.configurationQuestion = configuration_question;
152 configOption.configurationDefault = configuration_default;
153 configOption.configurationType = configuration_type;
154 configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
155 configOption.shouldIBeAsked = shouldIBeAskedDelegate;
156 checkAndAddConfigOption(configOption);
157 }
158
159 // TEMP - REMOVE
160 public void performConfigurationRetrieve()
161 {
162 if (cE > 1)
163 m_log.Error("READING CONFIGURATION COUT: " + cE.ToString());
164
165
166 configurationPlugin = LoadConfigDll(configurationPluginFilename);
167 configurationOptions.Clear();
168 if (loadFunction == null)
169 {
170 m_log.Error("Load Function for '" + configurationDescription +
171 "' is null. Refusing to run configuration.");
172 return;
173 }
174
175 if (resultFunction == null)
176 {
177 m_log.Error("Result Function for '" + configurationDescription +
178 "' is null. Refusing to run configuration.");
179 return;
180 }
181
182 //m_log.Debug("[CONFIG]: Calling Configuration Load Function...");
183 loadFunction();
184
185 if (configurationOptions.Count <= 0)
186 {
187 m_log.Error("[CONFIG]: No configuration options were specified for '" + configurationOptions +
188 "'. Refusing to continue configuration.");
189 return;
190 }
191
192 bool useFile = true;
193 if (configurationPlugin == null)
194 {
195 m_log.Error("[CONFIG]: Configuration Plugin NOT LOADED!");
196 return;
197 }
198
199 if (configurationFilename.Trim() != String.Empty)
200 {
201 configurationPlugin.SetFileName(configurationFilename);
202 try
203 {
204 configurationPlugin.LoadData();
205 useFile = true;
206 }
207 catch (XmlException e)
208 {
209 m_log.WarnFormat("[CONFIG] Not using {0}: {1}",
210 configurationFilename,
211 e.Message.ToString());
212 //m_log.Error("Error loading " + configurationFilename + ": " + e.ToString());
213 useFile = false;
214 }
215 }
216 else
217 {
218 if (configurationFromXMLNode != null)
219 {
220 m_log.Info("Loading from XML Node, will not save to the file");
221 configurationPlugin.LoadDataFromString(configurationFromXMLNode.OuterXml);
222 }
223
224 m_log.Info("XML Configuration Filename is not valid; will not save to the file.");
225 useFile = false;
226 }
227
228 foreach (ConfigurationOption configOption in configurationOptions)
229 {
230 bool convertSuccess = false;
231 object return_result = null;
232 string errorMessage = String.Empty;
233 bool ignoreNextFromConfig = false;
234 while (convertSuccess == false)
235 {
236 string console_result = String.Empty;
237 string attribute = null;
238 if (useFile || configurationFromXMLNode != null)
239 {
240 if (!ignoreNextFromConfig)
241 {
242 attribute = configurationPlugin.GetAttribute(configOption.configurationKey);
243 }
244 else
245 {
246 ignoreNextFromConfig = false;
247 }
248 }
249
250 if (attribute == null)
251 {
252 if (configOption.configurationUseDefaultNoPrompt || useConsoleToPromptOnError == false)
253 {
254 console_result = configOption.configurationDefault;
255 }
256 else
257 {
258 if ((configOption.shouldIBeAsked != null &&
259 configOption.shouldIBeAsked(configOption.configurationKey)) ||
260 configOption.shouldIBeAsked == null)
261 {
262 if (configurationDescription.Trim() != String.Empty)
263 {
264 console_result =
265 MainConsole.Instance.CmdPrompt(
266 configurationDescription + ": " + configOption.configurationQuestion,
267 configOption.configurationDefault);
268 }
269 else
270 {
271 console_result =
272 MainConsole.Instance.CmdPrompt(configOption.configurationQuestion,
273 configOption.configurationDefault);
274 }
275 }
276 else
277 {
278 //Dont Ask! Just use default
279 console_result = configOption.configurationDefault;
280 }
281 }
282 }
283 else
284 {
285 console_result = attribute;
286 }
287
288 // if the first character is a "$", assume it's the name
289 // of an environment variable and substitute with the value of that variable
290 if (console_result.StartsWith("$"))
291 console_result = Environment.GetEnvironmentVariable(console_result.Substring(1));
292
293 switch (configOption.configurationType)
294 {
295 case ConfigurationOption.ConfigurationTypes.TYPE_STRING:
296 return_result = console_result;
297 convertSuccess = true;
298 break;
299 case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY:
300 if (console_result.Length > 0)
301 {
302 return_result = console_result;
303 convertSuccess = true;
304 }
305 errorMessage = "a string that is not empty";
306 break;
307 case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN:
308 bool boolResult;
309 if (Boolean.TryParse(console_result, out boolResult))
310 {
311 convertSuccess = true;
312 return_result = boolResult;
313 }
314 errorMessage = "'true' or 'false' (Boolean)";
315 break;
316 case ConfigurationOption.ConfigurationTypes.TYPE_BYTE:
317 byte byteResult;
318 if (Byte.TryParse(console_result, out byteResult))
319 {
320 convertSuccess = true;
321 return_result = byteResult;
322 }
323 errorMessage = "a byte (Byte)";
324 break;
325 case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER:
326 char charResult;
327 if (Char.TryParse(console_result, out charResult))
328 {
329 convertSuccess = true;
330 return_result = charResult;
331 }
332 errorMessage = "a character (Char)";
333 break;
334 case ConfigurationOption.ConfigurationTypes.TYPE_INT16:
335 short shortResult;
336 if (Int16.TryParse(console_result, out shortResult))
337 {
338 convertSuccess = true;
339 return_result = shortResult;
340 }
341 errorMessage = "a signed 32 bit integer (short)";
342 break;
343 case ConfigurationOption.ConfigurationTypes.TYPE_INT32:
344 int intResult;
345 if (Int32.TryParse(console_result, out intResult))
346 {
347 convertSuccess = true;
348 return_result = intResult;
349 }
350 errorMessage = "a signed 32 bit integer (int)";
351 break;
352 case ConfigurationOption.ConfigurationTypes.TYPE_INT64:
353 long longResult;
354 if (Int64.TryParse(console_result, out longResult))
355 {
356 convertSuccess = true;
357 return_result = longResult;
358 }
359 errorMessage = "a signed 32 bit integer (long)";
360 break;
361 case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS:
362 IPAddress ipAddressResult;
363 if (IPAddress.TryParse(console_result, out ipAddressResult))
364 {
365 convertSuccess = true;
366 return_result = ipAddressResult;
367 }
368 errorMessage = "an IP Address (IPAddress)";
369 break;
370 case ConfigurationOption.ConfigurationTypes.TYPE_UUID:
371 UUID uuidResult;
372 if (UUID.TryParse(console_result, out uuidResult))
373 {
374 convertSuccess = true;
375 return_result = uuidResult;
376 }
377 errorMessage = "a UUID (UUID)";
378 break;
379 case ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE:
380 UUID uuidResult2;
381 if (UUID.TryParse(console_result, out uuidResult2))
382 {
383 convertSuccess = true;
384
385 if (uuidResult2 == UUID.Zero)
386 uuidResult2 = UUID.Random();
387
388 return_result = uuidResult2;
389 }
390 errorMessage = "a non-null UUID (UUID)";
391 break;
392 case ConfigurationOption.ConfigurationTypes.TYPE_Vector3:
393 Vector3 vectorResult;
394 if (Vector3.TryParse(console_result, out vectorResult))
395 {
396 convertSuccess = true;
397 return_result = vectorResult;
398 }
399 errorMessage = "a vector (Vector3)";
400 break;
401 case ConfigurationOption.ConfigurationTypes.TYPE_UINT16:
402 ushort ushortResult;
403 if (UInt16.TryParse(console_result, out ushortResult))
404 {
405 convertSuccess = true;
406 return_result = ushortResult;
407 }
408 errorMessage = "an unsigned 16 bit integer (ushort)";
409 break;
410 case ConfigurationOption.ConfigurationTypes.TYPE_UINT32:
411 uint uintResult;
412 if (UInt32.TryParse(console_result, out uintResult))
413 {
414 convertSuccess = true;
415 return_result = uintResult;
416 }
417 errorMessage = "an unsigned 32 bit integer (uint)";
418 break;
419 case ConfigurationOption.ConfigurationTypes.TYPE_UINT64:
420 ulong ulongResult;
421 if (UInt64.TryParse(console_result, out ulongResult))
422 {
423 convertSuccess = true;
424 return_result = ulongResult;
425 }
426 errorMessage = "an unsigned 64 bit integer (ulong)";
427 break;
428 case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT:
429 float floatResult;
430 if (
431 float.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo,
432 out floatResult))
433 {
434 convertSuccess = true;
435 return_result = floatResult;
436 }
437 errorMessage = "a single-precision floating point number (float)";
438 break;
439 case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE:
440 double doubleResult;
441 if (
442 Double.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo,
443 out doubleResult))
444 {
445 convertSuccess = true;
446 return_result = doubleResult;
447 }
448 errorMessage = "an double-precision floating point number (double)";
449 break;
450 }
451
452 if (convertSuccess)
453 {
454 if (useFile)
455 {
456 configurationPlugin.SetAttribute(configOption.configurationKey, console_result);
457 }
458
459 if (!resultFunction(configOption.configurationKey, return_result))
460 {
461 m_log.Info(
462 "The handler for the last configuration option denied that input, please try again.");
463 convertSuccess = false;
464 ignoreNextFromConfig = true;
465 }
466 }
467 else
468 {
469 if (configOption.configurationUseDefaultNoPrompt)
470 {
471 m_log.Error(string.Format(
472 "[CONFIG]: [{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n",
473 configOption.configurationKey, console_result, errorMessage,
474 configurationFilename));
475 convertSuccess = true;
476 }
477 else
478 {
479 m_log.Warn(string.Format(
480 "[CONFIG]: [{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n",
481 configOption.configurationKey, console_result, errorMessage,
482 configurationFilename));
483 ignoreNextFromConfig = true;
484 }
485 }
486 }
487 }
488
489 if (useFile)
490 {
491 configurationPlugin.Commit();
492 configurationPlugin.Close();
493 }
494 }
495
496 private static IGenericConfig LoadConfigDll(string dllName)
497 {
498 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
499 IGenericConfig plug = null;
500
501 foreach (Type pluginType in pluginAssembly.GetTypes())
502 {
503 if (pluginType.IsPublic)
504 {
505 if (!pluginType.IsAbstract)
506 {
507 Type typeInterface = pluginType.GetInterface("IGenericConfig", true);
508
509 if (typeInterface != null)
510 {
511 plug =
512 (IGenericConfig) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
513 }
514 }
515 }
516 }
517
518 pluginAssembly = null;
519 return plug;
520 }
521
522 public void forceSetConfigurationOption(string configuration_key, string configuration_value)
523 {
524 configurationPlugin.LoadData();
525 configurationPlugin.SetAttribute(configuration_key, configuration_value);
526 configurationPlugin.Commit();
527 configurationPlugin.Close();
528 }
529 }
530}
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs
index 0f68afe..6b7cdf8 100644
--- a/OpenSim/Framework/Console/CommandConsole.cs
+++ b/OpenSim/Framework/Console/CommandConsole.cs
@@ -83,8 +83,8 @@ namespace OpenSim.Framework.Console
83 = "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n"; 83 = "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n";
84 84
85 public const string ItemHelpText 85 public const string ItemHelpText
86= @"For more information, type 'help all' to get a list of all commands, 86 = @"For more information, type 'help all' to get a list of all commands,
87 or type help <item>' where <item> is one of the following:"; 87 or type help <item>' where <item> is one of the following:";
88 88
89 /// <value> 89 /// <value>
90 /// Commands organized by keyword in a tree 90 /// Commands organized by keyword in a tree
diff --git a/OpenSim/Framework/CustomTypes.cs b/OpenSim/Framework/CustomTypes.cs
new file mode 100644
index 0000000..d109c26
--- /dev/null
+++ b/OpenSim/Framework/CustomTypes.cs
@@ -0,0 +1,43 @@
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
28using System;
29
30namespace OpenSim.Framework
31{
32 public enum CustomAssetType : sbyte
33 {
34 CustomTypeBase = 0x60,
35 AnimationSet = 0x60,
36 }
37
38 public enum CustomInventoryType : sbyte
39 {
40 CustomTypeBase = 0x60,
41 AnimationSet = 0x60,
42 }
43}
diff --git a/OpenSim/Framework/EntityTransferContext.cs b/OpenSim/Framework/EntityTransferContext.cs
new file mode 100644
index 0000000..860414e
--- /dev/null
+++ b/OpenSim/Framework/EntityTransferContext.cs
@@ -0,0 +1,70 @@
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
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenMetaverse.StructuredData;
32
33namespace OpenSim.Framework
34{
35 public class EntityTransferContext
36 {
37 public EntityTransferContext()
38 {
39 InboundVersion = VersionInfo.SimulationServiceVersionAcceptedMax;
40 OutboundVersion = VersionInfo.SimulationServiceVersionSupportedMax;
41 WearablesCount = -1;
42 }
43
44 public float InboundVersion { get; set; }
45 public float OutboundVersion { get; set; }
46 public int WearablesCount { get; set; }
47
48 public OSD Pack()
49 {
50 OSDMap data = new OSDMap();
51 data["InboundVersion"] = OSD.FromReal(InboundVersion);
52 data["OutboundVersion"] = OSD.FromReal(OutboundVersion);
53 data["WearablesCount"] = OSD.FromInteger(WearablesCount);
54
55 return data;
56 }
57
58 public void Unpack(OSD data)
59 {
60 OSDMap map = (OSDMap)data;
61
62 if (map.ContainsKey("InboundVersion"))
63 InboundVersion = (float)map["InboundVersion"].AsReal();
64 if (map.ContainsKey("OutboundVersion"))
65 OutboundVersion = (float)map["OutboundVersion"].AsReal();
66 if (map.ContainsKey("WearablesCount"))
67 WearablesCount = map["WearablesCount"].AsInteger();
68 }
69 }
70}
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs
index 4df7860..4c9f6e9 100644
--- a/OpenSim/Framework/EstateSettings.cs
+++ b/OpenSim/Framework/EstateSettings.cs
@@ -365,9 +365,41 @@ namespace OpenSim.Framework
365 365
366 public bool IsBanned(UUID avatarID) 366 public bool IsBanned(UUID avatarID)
367 { 367 {
368 foreach (EstateBan ban in l_EstateBans) 368 if (!IsEstateManagerOrOwner(avatarID))
369 {
370 foreach (EstateBan ban in l_EstateBans)
371 if (ban.BannedUserID == avatarID)
372 return true;
373 }
374 return false;
375 }
376
377 public bool IsBanned(UUID avatarID, int userFlags)
378 {
379 if (!IsEstateManagerOrOwner(avatarID))
380 {
381 foreach (EstateBan ban in l_EstateBans)
369 if (ban.BannedUserID == avatarID) 382 if (ban.BannedUserID == avatarID)
370 return true; 383 return true;
384
385 if (!HasAccess(avatarID))
386 {
387 if (DenyMinors)
388 {
389 if ((userFlags & 32) == 0)
390 {
391 return true;
392 }
393 }
394 if (DenyAnonymous)
395 {
396 if ((userFlags & 4) == 0)
397 {
398 return true;
399 }
400 }
401 }
402 }
371 return false; 403 return false;
372 } 404 }
373 405
@@ -375,7 +407,7 @@ namespace OpenSim.Framework
375 { 407 {
376 if (ban == null) 408 if (ban == null)
377 return; 409 return;
378 if (!IsBanned(ban.BannedUserID)) 410 if (!IsBanned(ban.BannedUserID, 32)) //Ignore age-based bans
379 l_EstateBans.Add(ban); 411 l_EstateBans.Add(ban);
380 } 412 }
381 413
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index e36edb2..85edce3 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -64,14 +64,15 @@ namespace OpenSim.Framework
64 64
65 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); 65 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes);
66 66
67 public delegate void CachedTextureRequest(IClientAPI remoteClient, int serial, List<CachedTextureRequestArg> cachedTextureRequest);
68
69 public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize, WearableCacheItem[] CacheItems); 67 public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize, WearableCacheItem[] CacheItems);
68 public delegate void CachedTextureRequest(IClientAPI remoteClient, int serial, List<CachedTextureRequestArg> cachedTextureRequest);
70 69
71 public delegate void StartAnim(IClientAPI remoteClient, UUID animID); 70 public delegate void StartAnim(IClientAPI remoteClient, UUID animID);
72 71
73 public delegate void StopAnim(IClientAPI remoteClient, UUID animID); 72 public delegate void StopAnim(IClientAPI remoteClient, UUID animID);
74 73
74 public delegate void ChangeAnim(UUID animID, bool addOrRemove, bool sendPack);
75
75 public delegate void LinkObjects(IClientAPI remoteClient, uint parent, List<uint> children); 76 public delegate void LinkObjects(IClientAPI remoteClient, uint parent, List<uint> children);
76 77
77 public delegate void DelinkObjects(List<uint> primIds, IClientAPI client); 78 public delegate void DelinkObjects(List<uint> primIds, IClientAPI client);
@@ -132,6 +133,8 @@ namespace OpenSim.Framework
132 133
133 public delegate void UpdateVector(uint localID, Vector3 pos, IClientAPI remoteClient); 134 public delegate void UpdateVector(uint localID, Vector3 pos, IClientAPI remoteClient);
134 135
136 public delegate void ClientChangeObject(uint localID, object data ,IClientAPI remoteClient);
137
135 public delegate void UpdatePrimRotation(uint localID, Quaternion rot, IClientAPI remoteClient); 138 public delegate void UpdatePrimRotation(uint localID, Quaternion rot, IClientAPI remoteClient);
136 139
137 public delegate void UpdatePrimSingleRotation(uint localID, Quaternion rot, IClientAPI remoteClient); 140 public delegate void UpdatePrimSingleRotation(uint localID, Quaternion rot, IClientAPI remoteClient);
@@ -268,6 +271,9 @@ namespace OpenSim.Framework
268 public delegate void MoveInventoryItem( 271 public delegate void MoveInventoryItem(
269 IClientAPI remoteClient, List<InventoryItemBase> items); 272 IClientAPI remoteClient, List<InventoryItemBase> items);
270 273
274 public delegate void MoveItemsAndLeaveCopy(
275 IClientAPI remoteClient, List<InventoryItemBase> items, UUID destFolder);
276
271 public delegate void RemoveInventoryItem( 277 public delegate void RemoveInventoryItem(
272 IClientAPI remoteClient, List<UUID> itemIDs); 278 IClientAPI remoteClient, List<UUID> itemIDs);
273 279
@@ -443,6 +449,7 @@ namespace OpenSim.Framework
443 public delegate void ClassifiedInfoRequest(UUID classifiedID, IClientAPI client); 449 public delegate void ClassifiedInfoRequest(UUID classifiedID, IClientAPI client);
444 public delegate void ClassifiedInfoUpdate(UUID classifiedID, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, Vector3 globalPos, byte classifiedFlags, int price, IClientAPI client); 450 public delegate void ClassifiedInfoUpdate(UUID classifiedID, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, Vector3 globalPos, byte classifiedFlags, int price, IClientAPI client);
445 public delegate void ClassifiedDelete(UUID classifiedID, IClientAPI client); 451 public delegate void ClassifiedDelete(UUID classifiedID, IClientAPI client);
452 public delegate void ClassifiedGodDelete(UUID classifiedID, UUID queryID, IClientAPI client);
446 453
447 public delegate void EventNotificationAddRequest(uint EventID, IClientAPI client); 454 public delegate void EventNotificationAddRequest(uint EventID, IClientAPI client);
448 public delegate void EventNotificationRemoveRequest(uint EventID, IClientAPI client); 455 public delegate void EventNotificationRemoveRequest(uint EventID, IClientAPI client);
@@ -465,9 +472,9 @@ namespace OpenSim.Framework
465 472
466 public delegate void AgentFOV(IClientAPI client, float verticalAngle); 473 public delegate void AgentFOV(IClientAPI client, float verticalAngle);
467 474
468 public delegate void MuteListEntryUpdate(IClientAPI client, UUID MuteID, string Name, int Flags,UUID AgentID); 475 public delegate void MuteListEntryUpdate(IClientAPI client, UUID MuteID, string Name, int type, uint flags);
469 476
470 public delegate void MuteListEntryRemove(IClientAPI client, UUID MuteID, string Name, UUID AgentID); 477 public delegate void MuteListEntryRemove(IClientAPI client, UUID MuteID, string Name);
471 478
472 public delegate void AvatarInterestReply(IClientAPI client,UUID target, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages); 479 public delegate void AvatarInterestReply(IClientAPI client,UUID target, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages);
473 480
@@ -505,6 +512,7 @@ namespace OpenSim.Framework
505 public delegate void SimWideDeletesDelegate(IClientAPI client,UUID agentID, int flags, UUID targetID); 512 public delegate void SimWideDeletesDelegate(IClientAPI client,UUID agentID, int flags, UUID targetID);
506 513
507 public delegate void SendPostcard(IClientAPI client); 514 public delegate void SendPostcard(IClientAPI client);
515 public delegate void ChangeInventoryItemFlags(IClientAPI client, UUID itemID, uint flags);
508 516
509 #endregion 517 #endregion
510 518
@@ -734,6 +742,8 @@ namespace OpenSim.Framework
734 742
735 IScene Scene { get; } 743 IScene Scene { get; }
736 744
745 List<uint> SelectedObjects { get; }
746
737 // [Obsolete("LLClientView Specific - Replace with ???")] 747 // [Obsolete("LLClientView Specific - Replace with ???")]
738 int NextAnimationSequenceNumber { get; } 748 int NextAnimationSequenceNumber { get; }
739 749
@@ -747,6 +757,8 @@ namespace OpenSim.Framework
747 /// </summary> 757 /// </summary>
748 bool IsActive { get; set; } 758 bool IsActive { get; set; }
749 759
760 int PingTimeMS { get; }
761
750 /// <summary> 762 /// <summary>
751 /// Set if the client is closing due to a logout request 763 /// Set if the client is closing due to a logout request
752 /// </summary> 764 /// </summary>
@@ -794,6 +806,7 @@ namespace OpenSim.Framework
794 event ObjectDrop OnObjectDrop; 806 event ObjectDrop OnObjectDrop;
795 event StartAnim OnStartAnim; 807 event StartAnim OnStartAnim;
796 event StopAnim OnStopAnim; 808 event StopAnim OnStopAnim;
809 event ChangeAnim OnChangeAnim;
797 event LinkObjects OnLinkObjects; 810 event LinkObjects OnLinkObjects;
798 event DelinkObjects OnDelinkObjects; 811 event DelinkObjects OnDelinkObjects;
799 event RequestMapBlocks OnRequestMapBlocks; 812 event RequestMapBlocks OnRequestMapBlocks;
@@ -860,6 +873,7 @@ namespace OpenSim.Framework
860 event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily; 873 event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
861 event UpdatePrimFlags OnUpdatePrimFlags; 874 event UpdatePrimFlags OnUpdatePrimFlags;
862 event UpdatePrimTexture OnUpdatePrimTexture; 875 event UpdatePrimTexture OnUpdatePrimTexture;
876 event ClientChangeObject onClientChangeObject;
863 event UpdateVector OnUpdatePrimGroupPosition; 877 event UpdateVector OnUpdatePrimGroupPosition;
864 event UpdateVector OnUpdatePrimSinglePosition; 878 event UpdateVector OnUpdatePrimSinglePosition;
865 event UpdatePrimRotation OnUpdatePrimGroupRotation; 879 event UpdatePrimRotation OnUpdatePrimGroupRotation;
@@ -884,6 +898,7 @@ namespace OpenSim.Framework
884 event RequestTaskInventory OnRequestTaskInventory; 898 event RequestTaskInventory OnRequestTaskInventory;
885 event UpdateInventoryItem OnUpdateInventoryItem; 899 event UpdateInventoryItem OnUpdateInventoryItem;
886 event CopyInventoryItem OnCopyInventoryItem; 900 event CopyInventoryItem OnCopyInventoryItem;
901 event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy;
887 event MoveInventoryItem OnMoveInventoryItem; 902 event MoveInventoryItem OnMoveInventoryItem;
888 event RemoveInventoryFolder OnRemoveInventoryFolder; 903 event RemoveInventoryFolder OnRemoveInventoryFolder;
889 event RemoveInventoryItem OnRemoveInventoryItem; 904 event RemoveInventoryItem OnRemoveInventoryItem;
@@ -1002,7 +1017,7 @@ namespace OpenSim.Framework
1002 event ClassifiedInfoRequest OnClassifiedInfoRequest; 1017 event ClassifiedInfoRequest OnClassifiedInfoRequest;
1003 event ClassifiedInfoUpdate OnClassifiedInfoUpdate; 1018 event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
1004 event ClassifiedDelete OnClassifiedDelete; 1019 event ClassifiedDelete OnClassifiedDelete;
1005 event ClassifiedDelete OnClassifiedGodDelete; 1020 event ClassifiedGodDelete OnClassifiedGodDelete;
1006 1021
1007 event EventNotificationAddRequest OnEventNotificationAddRequest; 1022 event EventNotificationAddRequest OnEventNotificationAddRequest;
1008 event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; 1023 event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
@@ -1041,11 +1056,12 @@ namespace OpenSim.Framework
1041 event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; 1056 event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
1042 event SimWideDeletesDelegate OnSimWideDeletes; 1057 event SimWideDeletesDelegate OnSimWideDeletes;
1043 event SendPostcard OnSendPostcard; 1058 event SendPostcard OnSendPostcard;
1059 event ChangeInventoryItemFlags OnChangeInventoryItemFlags;
1044 event MuteListEntryUpdate OnUpdateMuteListEntry; 1060 event MuteListEntryUpdate OnUpdateMuteListEntry;
1045 event MuteListEntryRemove OnRemoveMuteListEntry; 1061 event MuteListEntryRemove OnRemoveMuteListEntry;
1046 event GodlikeMessage onGodlikeMessage; 1062 event GodlikeMessage onGodlikeMessage;
1047 event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; 1063 event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
1048 1064 event GenericCall2 OnUpdateThrottles;
1049 /// <summary> 1065 /// <summary>
1050 /// Set the debug level at which packet output should be printed to console. 1066 /// Set the debug level at which packet output should be printed to console.
1051 /// </summary> 1067 /// </summary>
@@ -1066,7 +1082,7 @@ namespace OpenSim.Framework
1066 /// If true, attempts the close without checking active status. You do not want to try this except as a last 1082 /// If true, attempts the close without checking active status. You do not want to try this except as a last
1067 /// ditch attempt where Active == false but the ScenePresence still exists. 1083 /// ditch attempt where Active == false but the ScenePresence still exists.
1068 /// </param> 1084 /// </param>
1069 void Close(bool force); 1085 void Close(bool sendStop, bool force);
1070 1086
1071 void Kick(string message); 1087 void Kick(string message);
1072 1088
@@ -1102,6 +1118,8 @@ namespace OpenSim.Framework
1102 /// <param name="localID"></param> 1118 /// <param name="localID"></param>
1103 void SendKillObject(List<uint> localID); 1119 void SendKillObject(List<uint> localID);
1104 1120
1121 void SendPartFullUpdate(ISceneEntity ent, uint? parentID);
1122
1105 void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs); 1123 void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs);
1106 void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args); 1124 void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args);
1107 1125
@@ -1125,6 +1143,8 @@ namespace OpenSim.Framework
1125 void SendGenericMessage(string method, UUID invoice, List<string> message); 1143 void SendGenericMessage(string method, UUID invoice, List<string> message);
1126 void SendGenericMessage(string method, UUID invoice, List<byte[]> message); 1144 void SendGenericMessage(string method, UUID invoice, List<byte[]> message);
1127 1145
1146 bool CanSendLayerData();
1147
1128 void SendLayerData(float[] map); 1148 void SendLayerData(float[] map);
1129 void SendLayerData(int px, int py, float[] map); 1149 void SendLayerData(int px, int py, float[] map);
1130 1150
@@ -1168,6 +1188,10 @@ namespace OpenSim.Framework
1168 void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations); 1188 void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations);
1169 1189
1170 void SetChildAgentThrottle(byte[] throttle); 1190 void SetChildAgentThrottle(byte[] throttle);
1191 void SetChildAgentThrottle(byte[] throttle,float factor);
1192
1193 void SetAgentThrottleSilent(int throttle, int setting);
1194 int GetAgentThrottleSilent(int throttle);
1171 1195
1172 void SendAvatarDataImmediate(ISceneEntity avatar); 1196 void SendAvatarDataImmediate(ISceneEntity avatar);
1173 1197
@@ -1192,6 +1216,7 @@ namespace OpenSim.Framework
1192 /// </summary> 1216 /// </summary>
1193 /// <param name="Item"></param> 1217 /// <param name="Item"></param>
1194 void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId); 1218 void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId);
1219 void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId);
1195 1220
1196 void SendRemoveInventoryItem(UUID itemID); 1221 void SendRemoveInventoryItem(UUID itemID);
1197 1222
@@ -1211,7 +1236,7 @@ namespace OpenSim.Framework
1211 /// <param name="node"></param> 1236 /// <param name="node"></param>
1212 void SendBulkUpdateInventory(InventoryNodeBase node); 1237 void SendBulkUpdateInventory(InventoryNodeBase node);
1213 1238
1214 void SendXferPacket(ulong xferID, uint packet, byte[] data); 1239 void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory);
1215 1240
1216 void SendAbortXferPacket(ulong xferID); 1241 void SendAbortXferPacket(ulong xferID);
1217 1242
@@ -1367,6 +1392,8 @@ namespace OpenSim.Framework
1367 1392
1368 void SendAgentOnline(UUID[] agentIDs); 1393 void SendAgentOnline(UUID[] agentIDs);
1369 1394
1395 void SendFindAgent(UUID HunterID, UUID PreyID, double GlobalX, double GlobalY);
1396
1370 void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, 1397 void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
1371 Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook); 1398 Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook);
1372 1399
@@ -1432,6 +1459,7 @@ namespace OpenSim.Framework
1432 void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags); 1459 void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags);
1433 1460
1434 void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data); 1461 void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data);
1462 void SendAgentGroupDataUpdate(UUID avatarID, GroupMembershipData[] data);
1435 void SendOfferCallingCard(UUID srcID, UUID transactionID); 1463 void SendOfferCallingCard(UUID srcID, UUID transactionID);
1436 void SendAcceptCallingCard(UUID transactionID); 1464 void SendAcceptCallingCard(UUID transactionID);
1437 void SendDeclineCallingCard(UUID transactionID); 1465 void SendDeclineCallingCard(UUID transactionID);
diff --git a/OpenSim/Framework/ILandChannel.cs b/OpenSim/Framework/ILandChannel.cs
index c46c03c..63cc7eb 100644
--- a/OpenSim/Framework/ILandChannel.cs
+++ b/OpenSim/Framework/ILandChannel.cs
@@ -93,5 +93,7 @@ namespace OpenSim.Region.Framework.Interfaces
93 93
94 void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); 94 void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id);
95 void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); 95 void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id);
96 void sendClientInitialLandInfo(IClientAPI remoteClient);
97
96 } 98 }
97} 99}
diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs
index 8465c86..db1496c 100644
--- a/OpenSim/Framework/ILandObject.cs
+++ b/OpenSim/Framework/ILandObject.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Framework
68 void SendLandUpdateToAvatarsOverMe(); 68 void SendLandUpdateToAvatarsOverMe();
69 69
70 void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client); 70 void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client);
71 void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client); 71 bool UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client, out bool snap_selection, out bool needOverlay);
72 bool IsEitherBannedOrRestricted(UUID avatar); 72 bool IsEitherBannedOrRestricted(UUID avatar);
73 bool IsBannedFromLand(UUID avatar); 73 bool IsBannedFromLand(UUID avatar);
74 bool CanBeOnThisLand(UUID avatar, float posHeight); 74 bool CanBeOnThisLand(UUID avatar, float posHeight);
diff --git a/OpenSim/Framework/IMoneyModule.cs b/OpenSim/Framework/IMoneyModule.cs
index 52f3e83..55c9613 100644
--- a/OpenSim/Framework/IMoneyModule.cs
+++ b/OpenSim/Framework/IMoneyModule.cs
@@ -33,7 +33,7 @@ namespace OpenSim.Framework
33 public interface IMoneyModule 33 public interface IMoneyModule
34 { 34 {
35 bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, 35 bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID,
36 int amount); 36 int amount, UUID txn, out string reason);
37 37
38 int GetBalance(UUID agentID); 38 int GetBalance(UUID agentID);
39 bool UploadCovered(UUID agentID, int amount); 39 bool UploadCovered(UUID agentID, int amount);
@@ -41,6 +41,7 @@ namespace OpenSim.Framework
41 void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type); 41 void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type);
42 void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type, string extraData); 42 void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type, string extraData);
43 void ApplyUploadCharge(UUID agentID, int amount, string text); 43 void ApplyUploadCharge(UUID agentID, int amount, string text);
44 void MoveMoney(UUID fromUser, UUID toUser, int amount, string text);
44 45
45 int UploadCharge { get; } 46 int UploadCharge { get; }
46 int GroupCreationCharge { get; } 47 int GroupCreationCharge { get; }
diff --git a/OpenSim/Framework/ISceneAgent.cs b/OpenSim/Framework/ISceneAgent.cs
index ca1399c..be11931 100644
--- a/OpenSim/Framework/ISceneAgent.cs
+++ b/OpenSim/Framework/ISceneAgent.cs
@@ -66,19 +66,14 @@ namespace OpenSim.Framework
66 AvatarAppearance Appearance { get; set; } 66 AvatarAppearance Appearance { get; set; }
67 67
68 /// <summary> 68 /// <summary>
69 /// Set if initial data about the scene (avatars, objects) has been sent to the client.
70 /// </summary>
71 bool SentInitialDataToClient { get; }
72
73 /// <summary>
74 /// Send initial scene data to the client controlling this agent 69 /// Send initial scene data to the client controlling this agent
75 /// </summary> 70 /// </summary>
76 /// <remarks> 71 /// <remarks>
77 /// This includes scene object data and the appearance data of other avatars. 72 /// This includes scene object data and the appearance data of other avatars.
78 /// </remarks> 73 /// </remarks>
79 void SendInitialDataToClient(); 74 void SendInitialDataToMe();
80 75
81 /// <summary> 76 /// <summary>
82 /// Direction in which the scene presence is looking. 77 /// Direction in which the scene presence is looking.
83 /// </summary> 78 /// </summary>
84 /// <remarks>Will be Vector3.Zero for a child agent.</remarks> 79 /// <remarks>Will be Vector3.Zero for a child agent.</remarks>
diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs
index fc02f33..4fbbbc1 100644
--- a/OpenSim/Framework/LandData.cs
+++ b/OpenSim/Framework/LandData.cs
@@ -67,9 +67,9 @@ namespace OpenSim.Framework
67 67
68 private uint _flags = (uint)ParcelFlags.AllowFly | (uint)ParcelFlags.AllowLandmark | 68 private uint _flags = (uint)ParcelFlags.AllowFly | (uint)ParcelFlags.AllowLandmark |
69 (uint)ParcelFlags.AllowAPrimitiveEntry | 69 (uint)ParcelFlags.AllowAPrimitiveEntry |
70 (uint)ParcelFlags.AllowDeedToGroup | (uint)ParcelFlags.AllowTerraform | 70 (uint)ParcelFlags.AllowDeedToGroup |
71 (uint)ParcelFlags.CreateObjects | (uint)ParcelFlags.AllowOtherScripts | 71 (uint)ParcelFlags.CreateObjects | (uint)ParcelFlags.AllowOtherScripts |
72 (uint)ParcelFlags.SoundLocal | (uint)ParcelFlags.AllowVoiceChat; 72 (uint)ParcelFlags.AllowVoiceChat;
73 73
74 private byte _landingType = 0; 74 private byte _landingType = 0;
75 private string _name = "Your Parcel"; 75 private string _name = "Your Parcel";
@@ -99,6 +99,10 @@ namespace OpenSim.Framework
99 private bool _obscureMedia = false; 99 private bool _obscureMedia = false;
100 private float _dwell = 0; 100 private float _dwell = 0;
101 101
102 public bool SeeAVs { get; set; }
103 public bool AnyAVSounds { get; set; }
104 public bool GroupAVSounds { get; set; }
105
102 /// <summary> 106 /// <summary>
103 /// Traffic count of parcel 107 /// Traffic count of parcel
104 /// </summary> 108 /// </summary>
@@ -728,6 +732,9 @@ namespace OpenSim.Framework
728 public LandData() 732 public LandData()
729 { 733 {
730 _globalID = UUID.Random(); 734 _globalID = UUID.Random();
735 SeeAVs = true;
736 AnyAVSounds = true;
737 GroupAVSounds = true;
731 } 738 }
732 739
733 /// <summary> 740 /// <summary>
@@ -778,6 +785,9 @@ namespace OpenSim.Framework
778 landData._simwideArea = _simwideArea; 785 landData._simwideArea = _simwideArea;
779 landData._simwidePrims = _simwidePrims; 786 landData._simwidePrims = _simwidePrims;
780 landData._dwell = _dwell; 787 landData._dwell = _dwell;
788 landData.SeeAVs = SeeAVs;
789 landData.AnyAVSounds = AnyAVSounds;
790 landData.GroupAVSounds = GroupAVSounds;
781 791
782 landData._parcelAccessList.Clear(); 792 landData._parcelAccessList.Clear();
783 foreach (LandAccessEntry entry in _parcelAccessList) 793 foreach (LandAccessEntry entry in _parcelAccessList)
@@ -793,21 +803,21 @@ namespace OpenSim.Framework
793 return landData; 803 return landData;
794 } 804 }
795 805
796 public void ToXml(XmlWriter xmlWriter) 806// public void ToXml(XmlWriter xmlWriter)
797 { 807// {
798 serializer.Serialize(xmlWriter, this); 808// serializer.Serialize(xmlWriter, this);
799 } 809// }
800 810
801 /// <summary> 811 /// <summary>
802 /// Restore a LandData object from the serialized xml representation. 812 /// Restore a LandData object from the serialized xml representation.
803 /// </summary> 813 /// </summary>
804 /// <param name="xmlReader"></param> 814 /// <param name="xmlReader"></param>
805 /// <returns></returns> 815 /// <returns></returns>
806 public static LandData FromXml(XmlReader xmlReader) 816// public static LandData FromXml(XmlReader xmlReader)
807 { 817// {
808 LandData land = (LandData)serializer.Deserialize(xmlReader); 818// LandData land = (LandData)serializer.Deserialize(xmlReader);
809 819//
810 return land; 820// return land;
811 } 821// }
812 } 822 }
813} 823}
diff --git a/OpenSim/Framework/LandUpdateArgs.cs b/OpenSim/Framework/LandUpdateArgs.cs
index 7d6c4f2..a48b8bf 100644
--- a/OpenSim/Framework/LandUpdateArgs.cs
+++ b/OpenSim/Framework/LandUpdateArgs.cs
@@ -56,5 +56,8 @@ namespace OpenSim.Framework
56 public bool MediaLoop; 56 public bool MediaLoop;
57 public bool ObscureMusic; 57 public bool ObscureMusic;
58 public bool ObscureMedia; 58 public bool ObscureMedia;
59 public bool SeeAVs;
60 public bool AnyAVSounds;
61 public bool GroupAVSounds;
59 } 62 }
60} 63}
diff --git a/OpenSim/Framework/LocklessQueue.cs b/OpenSim/Framework/LocklessQueue.cs
index 84f887c..9bd9baf 100644
--- a/OpenSim/Framework/LocklessQueue.cs
+++ b/OpenSim/Framework/LocklessQueue.cs
@@ -29,7 +29,7 @@ using System.Threading;
29 29
30namespace OpenSim.Framework 30namespace OpenSim.Framework
31{ 31{
32 public sealed class LocklessQueue<T> 32 public class LocklessQueue<T>
33 { 33 {
34 private sealed class SingleLinkNode 34 private sealed class SingleLinkNode
35 { 35 {
@@ -41,7 +41,7 @@ namespace OpenSim.Framework
41 SingleLinkNode tail; 41 SingleLinkNode tail;
42 int count; 42 int count;
43 43
44 public int Count { get { return count; } } 44 public virtual int Count { get { return count; } }
45 45
46 public LocklessQueue() 46 public LocklessQueue()
47 { 47 {
@@ -76,7 +76,7 @@ namespace OpenSim.Framework
76 Interlocked.Increment(ref count); 76 Interlocked.Increment(ref count);
77 } 77 }
78 78
79 public bool Dequeue(out T item) 79 public virtual bool Dequeue(out T item)
80 { 80 {
81 item = default(T); 81 item = default(T);
82 SingleLinkNode oldHead = null; 82 SingleLinkNode oldHead = null;
@@ -136,4 +136,4 @@ namespace OpenSim.Framework
136 (object)Interlocked.CompareExchange<SingleLinkNode>(ref location, newValue, comparand); 136 (object)Interlocked.CompareExchange<SingleLinkNode>(ref location, newValue, comparand);
137 } 137 }
138 } 138 }
139} \ No newline at end of file 139}
diff --git a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
index 20495f6..96536e8 100644
--- a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
@@ -43,7 +43,6 @@ namespace OpenSim.Framework.Monitoring
43 StringBuilder sb = new StringBuilder(Environment.NewLine); 43 StringBuilder sb = new StringBuilder(Environment.NewLine);
44 sb.Append("MEMORY STATISTICS"); 44 sb.Append("MEMORY STATISTICS");
45 sb.Append(Environment.NewLine); 45 sb.Append(Environment.NewLine);
46
47 sb.AppendFormat( 46 sb.AppendFormat(
48 "Heap allocated to OpenSim : {0} MB\n", 47 "Heap allocated to OpenSim : {0} MB\n",
49 Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)); 48 Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0));
@@ -56,9 +55,23 @@ namespace OpenSim.Framework.Monitoring
56 "Average heap allocation rate: {0} MB/s\n", 55 "Average heap allocation rate: {0} MB/s\n",
57 Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1024.0 / 1024, 3)); 56 Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1024.0 / 1024, 3));
58 57
59 sb.AppendFormat( 58 Process myprocess = Process.GetCurrentProcess();
60 "Process memory : {0} MB\n", 59 if (!myprocess.HasExited)
61 Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0)); 60 {
61 myprocess.Refresh();
62 sb.AppendFormat(
63 "Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
64 Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0),
65 Math.Round(Process.GetCurrentProcess().PagedMemorySize64 / 1024.0 / 1024.0),
66 Math.Round(Process.GetCurrentProcess().VirtualMemorySize64 / 1024.0 / 1024.0));
67 sb.AppendFormat(
68 "Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
69 Math.Round(Process.GetCurrentProcess().PeakWorkingSet64 / 1024.0 / 1024.0),
70 Math.Round(Process.GetCurrentProcess().PeakPagedMemorySize64 / 1024.0 / 1024.0),
71 Math.Round(Process.GetCurrentProcess().PeakVirtualMemorySize64 / 1024.0 / 1024.0));
72 }
73 else
74 sb.Append("Process reported as Exited \n");
62 75
63 return sb.ToString(); 76 return sb.ToString();
64 } 77 }
diff --git a/OpenSim/Framework/Monitoring/ServerStatsCollector.cs b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs
index 77315bb..be4a8b4 100644
--- a/OpenSim/Framework/Monitoring/ServerStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs
@@ -249,6 +249,49 @@ namespace OpenSim.Framework.Monitoring
249 (s) => { s.Value = Math.Round(MemoryWatchdog.LastHeapAllocationRate * 1000d / 1024d / 1024d, 3); }); 249 (s) => { s.Value = Math.Round(MemoryWatchdog.LastHeapAllocationRate * 1000d / 1024d / 1024d, 3); });
250 MakeStat("AverageHeapAllocationRate", null, "MB/sec", ContainerMemory, 250 MakeStat("AverageHeapAllocationRate", null, "MB/sec", ContainerMemory,
251 (s) => { s.Value = Math.Round(MemoryWatchdog.AverageHeapAllocationRate * 1000d / 1024d / 1024d, 3); }); 251 (s) => { s.Value = Math.Round(MemoryWatchdog.AverageHeapAllocationRate * 1000d / 1024d / 1024d, 3); });
252
253 MakeStat("ProcessResident", null, "MB", ContainerProcess,
254 (s) =>
255 {
256 Process myprocess = Process.GetCurrentProcess();
257 myprocess.Refresh();
258 s.Value = Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0);
259 });
260 MakeStat("ProcessPaged", null, "MB", ContainerProcess,
261 (s) =>
262 {
263 Process myprocess = Process.GetCurrentProcess();
264 myprocess.Refresh();
265 s.Value = Math.Round(Process.GetCurrentProcess().PagedMemorySize64 / 1024.0 / 1024.0);
266 });
267 MakeStat("ProcessVirtual", null, "MB", ContainerProcess,
268 (s) =>
269 {
270 Process myprocess = Process.GetCurrentProcess();
271 myprocess.Refresh();
272 s.Value = Math.Round(Process.GetCurrentProcess().VirtualMemorySize64 / 1024.0 / 1024.0);
273 });
274 MakeStat("PeakProcessResident", null, "MB", ContainerProcess,
275 (s) =>
276 {
277 Process myprocess = Process.GetCurrentProcess();
278 myprocess.Refresh();
279 s.Value = Math.Round(Process.GetCurrentProcess().PeakWorkingSet64 / 1024.0 / 1024.0);
280 });
281 MakeStat("PeakProcessPaged", null, "MB", ContainerProcess,
282 (s) =>
283 {
284 Process myprocess = Process.GetCurrentProcess();
285 myprocess.Refresh();
286 s.Value = Math.Round(Process.GetCurrentProcess().PeakPagedMemorySize64 / 1024.0 / 1024.0);
287 });
288 MakeStat("PeakProcessVirtual", null, "MB", ContainerProcess,
289 (s) =>
290 {
291 Process myprocess = Process.GetCurrentProcess();
292 myprocess.Refresh();
293 s.Value = Math.Round(Process.GetCurrentProcess().PeakVirtualMemorySize64 / 1024.0 / 1024.0);
294 });
252 } 295 }
253 296
254 // Notes on performance counters: 297 // Notes on performance counters:
diff --git a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
index e4df7ee..08c2409 100755
--- a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
@@ -34,6 +34,7 @@ using OpenMetaverse;
34using OpenMetaverse.StructuredData; 34using OpenMetaverse.StructuredData;
35using OpenSim.Framework.Monitoring.Interfaces; 35using OpenSim.Framework.Monitoring.Interfaces;
36 36
37
37namespace OpenSim.Framework.Monitoring 38namespace OpenSim.Framework.Monitoring
38{ 39{
39 /// <summary> 40 /// <summary>
@@ -71,6 +72,11 @@ namespace OpenSim.Framework.Monitoring
71 private volatile float pendingDownloads; 72 private volatile float pendingDownloads;
72 private volatile float pendingUploads; 73 private volatile float pendingUploads;
73 private volatile float activeScripts; 74 private volatile float activeScripts;
75 private volatile float spareTime;
76 private volatile float sleepTime;
77 private volatile float physicsStep;
78
79
74 private volatile float scriptLinesPerSecond; 80 private volatile float scriptLinesPerSecond;
75 private volatile float m_frameDilation; 81 private volatile float m_frameDilation;
76 private volatile float m_usersLoggingIn; 82 private volatile float m_usersLoggingIn;
@@ -253,7 +259,7 @@ namespace OpenSim.Framework.Monitoring
253 /// <param name="pack"></param> 259 /// <param name="pack"></param>
254 public void ReceiveClassicSimStatsPacket(SimStats stats) 260 public void ReceiveClassicSimStatsPacket(SimStats stats)
255 { 261 {
256 // FIXME: SimStats shouldn't allow an arbitrary stat packing order (which is inherited from the original 262 // FIXME: SimStats shouldn't allow an arbitrary stat packing order (which is inherited from the original
257 // SimStatsPacket that was being used). 263 // SimStatsPacket that was being used).
258 264
259 // For an unknown reason the original designers decided not to 265 // For an unknown reason the original designers decided not to
@@ -270,8 +276,8 @@ namespace OpenSim.Framework.Monitoring
270 totalFrameTime = stats.StatsBlock[8].StatValue; 276 totalFrameTime = stats.StatsBlock[8].StatValue;
271 netFrameTime = stats.StatsBlock[9].StatValue; 277 netFrameTime = stats.StatsBlock[9].StatValue;
272 physicsFrameTime = stats.StatsBlock[10].StatValue; 278 physicsFrameTime = stats.StatsBlock[10].StatValue;
273 otherFrameTime = stats.StatsBlock[11].StatValue; 279 imageFrameTime = stats.StatsBlock[11].StatValue;
274 imageFrameTime = stats.StatsBlock[12].StatValue; 280 otherFrameTime = stats.StatsBlock[12].StatValue;
275 inPacketsPerSecond = stats.StatsBlock[13].StatValue; 281 inPacketsPerSecond = stats.StatsBlock[13].StatValue;
276 outPacketsPerSecond = stats.StatsBlock[14].StatValue; 282 outPacketsPerSecond = stats.StatsBlock[14].StatValue;
277 unackedBytes = stats.StatsBlock[15].StatValue; 283 unackedBytes = stats.StatsBlock[15].StatValue;
@@ -279,12 +285,16 @@ namespace OpenSim.Framework.Monitoring
279 pendingDownloads = stats.StatsBlock[17].StatValue; 285 pendingDownloads = stats.StatsBlock[17].StatValue;
280 pendingUploads = stats.StatsBlock[18].StatValue; 286 pendingUploads = stats.StatsBlock[18].StatValue;
281 activeScripts = stats.StatsBlock[19].StatValue; 287 activeScripts = stats.StatsBlock[19].StatValue;
282 scriptLinesPerSecond = stats.StatsBlock[20].StatValue; 288 sleepTime = stats.StatsBlock[20].StatValue;
283 m_frameDilation = stats.StatsBlock[22].StatValue; 289 spareTime = stats.StatsBlock[21].StatValue;
284 m_usersLoggingIn = stats.StatsBlock[23].StatValue; 290 physicsStep = stats.StatsBlock[22].StatValue;
285 m_totalGeoPrims = stats.StatsBlock[24].StatValue; 291
286 m_totalMeshes = stats.StatsBlock[25].StatValue; 292 scriptLinesPerSecond = stats.ExtraStatsBlock[0].StatValue;
287 m_inUseThreads = stats.StatsBlock[26].StatValue; 293 m_frameDilation = stats.ExtraStatsBlock[1].StatValue;
294 m_usersLoggingIn = stats.ExtraStatsBlock[2].StatValue;
295 m_totalGeoPrims = stats.ExtraStatsBlock[3].StatValue;
296 m_totalMeshes = stats.ExtraStatsBlock[4].StatValue;
297 m_inUseThreads = stats.ExtraStatsBlock[5].StatValue;
288 } 298 }
289 299
290 /// <summary> 300 /// <summary>
diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs
index a7cb2a6..916fa53 100644
--- a/OpenSim/Framework/Monitoring/Stats/Stat.cs
+++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs
@@ -239,6 +239,17 @@ namespace OpenSim.Framework.Monitoring
239 return sb.ToString(); 239 return sb.ToString();
240 } 240 }
241 241
242 public virtual OSDMap ToBriefOSDMap()
243 {
244 OSDMap ret = new OSDMap();
245
246 ret.Add("Value", OSD.FromReal(Value));
247
248 double lastChangeOverTime, averageChangeOverTime;
249
250 return ret;
251 }
252
242 public virtual OSDMap ToOSDMap() 253 public virtual OSDMap ToOSDMap()
243 { 254 {
244 OSDMap ret = new OSDMap(); 255 OSDMap ret = new OSDMap();
@@ -323,4 +334,4 @@ namespace OpenSim.Framework.Monitoring
323 } 334 }
324 } 335 }
325 } 336 }
326} \ No newline at end of file 337}
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index 3136ee8..d0d1947 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -283,7 +283,7 @@ namespace OpenSim.Framework.Monitoring
283 if (!(String.IsNullOrEmpty(pStatName) || pStatName == AllSubCommand || pStatName == statName)) 283 if (!(String.IsNullOrEmpty(pStatName) || pStatName == AllSubCommand || pStatName == statName))
284 continue; 284 continue;
285 285
286 statMap.Add(statName, theStats[statName].ToOSDMap()); 286 statMap.Add(statName, theStats[statName].ToBriefOSDMap());
287 } 287 }
288 288
289 contMap.Add(contName, statMap); 289 contMap.Add(contName, statMap);
@@ -554,4 +554,4 @@ namespace OpenSim.Framework.Monitoring
554 Debug, 554 Debug,
555 Info 555 Info
556 } 556 }
557} \ No newline at end of file 557}
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs
index a644fa5..4485a9c 100644
--- a/OpenSim/Framework/Monitoring/Watchdog.cs
+++ b/OpenSim/Framework/Monitoring/Watchdog.cs
@@ -335,7 +335,9 @@ namespace OpenSim.Framework.Monitoring
335 335
336 lock (m_threads) 336 lock (m_threads)
337 { 337 {
338 foreach (ThreadWatchdogInfo threadInfo in m_threads.Values) 338 // get a copy since we may change m_threads
339 List<ThreadWatchdogInfo> threadsInfo = m_threads.Values.ToList();
340 foreach (ThreadWatchdogInfo threadInfo in threadsInfo)
339 { 341 {
340 if (threadInfo.Thread.ThreadState == ThreadState.Stopped) 342 if (threadInfo.Thread.ThreadState == ThreadState.Stopped)
341 { 343 {
@@ -377,4 +379,4 @@ namespace OpenSim.Framework.Monitoring
377 m_watchdogTimer.Start(); 379 m_watchdogTimer.Start();
378 } 380 }
379 } 381 }
380} \ No newline at end of file 382}
diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs
index 4b7d4c7..dfe9695 100644
--- a/OpenSim/Framework/NetworkServersInfo.cs
+++ b/OpenSim/Framework/NetworkServersInfo.cs
@@ -41,6 +41,7 @@ namespace OpenSim.Framework
41 41
42 // "Out of band" managemnt https 42 // "Out of band" managemnt https
43 public bool ssl_listener = false; 43 public bool ssl_listener = false;
44 public bool ssl_external = false;
44 public uint https_port = 0; 45 public uint https_port = 0;
45 public string cert_path = String.Empty; 46 public string cert_path = String.Empty;
46 public string cert_pass = String.Empty; 47 public string cert_pass = String.Empty;
@@ -64,6 +65,7 @@ namespace OpenSim.Framework
64 65
65 // "Out of band management https" 66 // "Out of band management https"
66 ssl_listener = config.Configs["Network"].GetBoolean("https_listener",false); 67 ssl_listener = config.Configs["Network"].GetBoolean("https_listener",false);
68 ssl_external = config.Configs["Network"].GetBoolean("https_external",false);
67 if( ssl_listener) 69 if( ssl_listener)
68 { 70 {
69 cert_path = config.Configs["Network"].GetString("cert_path",String.Empty); 71 cert_path = config.Configs["Network"].GetString("cert_path",String.Empty);
diff --git a/OpenSim/Framework/OSChatMessage.cs b/OpenSim/Framework/OSChatMessage.cs
index 455756d..7450be2 100644
--- a/OpenSim/Framework/OSChatMessage.cs
+++ b/OpenSim/Framework/OSChatMessage.cs
@@ -51,12 +51,11 @@ namespace OpenSim.Framework
51 protected object m_senderObject; 51 protected object m_senderObject;
52 protected ChatTypeEnum m_type; 52 protected ChatTypeEnum m_type;
53 protected UUID m_fromID; 53 protected UUID m_fromID;
54 protected UUID m_toID; 54 protected UUID m_destination = UUID.Zero;
55 55
56 public OSChatMessage() 56 public OSChatMessage()
57 { 57 {
58 m_position = new Vector3(); 58 m_position = new Vector3();
59 m_toID = UUID.Zero;
60 } 59 }
61 60
62 /// <summary> 61 /// <summary>
@@ -104,15 +103,6 @@ namespace OpenSim.Framework
104 set { m_from = value; } 103 set { m_from = value; }
105 } 104 }
106 105
107 /// <summary>
108 /// The name of the sender (needed for scripts)
109 /// </summary>
110 public string To
111 {
112 get { return m_from; }
113 set { m_from = value; }
114 }
115
116 #region IEventArgs Members 106 #region IEventArgs Members
117 107
118 /// TODO: Sender and SenderObject should just be Sender and of 108 /// TODO: Sender and SenderObject should just be Sender and of
@@ -142,13 +132,10 @@ namespace OpenSim.Framework
142 set { m_fromID = value; } 132 set { m_fromID = value; }
143 } 133 }
144 134
145 /// <summary> 135 public UUID Destination
146 /// The single recipient or all if not set.
147 /// </summary>
148 public UUID TargetUUID
149 { 136 {
150 get { return m_toID; } 137 get { return m_destination; }
151 set { m_toID = value; } 138 set { m_destination = value; }
152 } 139 }
153 140
154 /// <summary> 141 /// <summary>
diff --git a/OpenSim/Framework/ObjectChangeData.cs b/OpenSim/Framework/ObjectChangeData.cs
new file mode 100644
index 0000000..8d56291
--- /dev/null
+++ b/OpenSim/Framework/ObjectChangeData.cs
@@ -0,0 +1,80 @@
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
28using OpenMetaverse;
29
30namespace OpenSim.Framework
31{
32 public enum ObjectChangeType : uint
33 {
34 // bits definitions
35 Position = 0x01,
36 Rotation = 0x02,
37 Scale = 0x04,
38 Group = 0x08,
39 UniformScale = 0x10,
40
41 // macros from above
42 // single prim
43 primP = 0x01,
44 primR = 0x02,
45 primPR = 0x03,
46 primS = 0x04,
47 primPS = 0x05,
48 primRS = 0x06,
49 primPSR = 0x07,
50
51 primUS = 0x14,
52 primPUS = 0x15,
53 primRUS = 0x16,
54 primPUSR = 0x17,
55
56 // group
57 groupP = 0x09,
58 groupR = 0x0A,
59 groupPR = 0x0B,
60 groupS = 0x0C,
61 groupPS = 0x0D,
62 groupRS = 0x0E,
63 groupPSR = 0x0F,
64
65 groupUS = 0x1C,
66 groupPUS = 0x1D,
67 groupRUS = 0x1E,
68 groupPUSR = 0x1F,
69
70 PRSmask = 0x07
71 }
72
73 public struct ObjectChangeData
74 {
75 public Quaternion rotation;
76 public Vector3 position;
77 public Vector3 scale;
78 public ObjectChangeType change;
79 }
80}
diff --git a/OpenSim/Framework/ParcelMediaCommandEnum.cs b/OpenSim/Framework/ParcelMediaCommandEnum.cs
index 93c41ec..e714382 100644
--- a/OpenSim/Framework/ParcelMediaCommandEnum.cs
+++ b/OpenSim/Framework/ParcelMediaCommandEnum.cs
@@ -27,7 +27,7 @@
27 27
28namespace OpenSim.Framework 28namespace OpenSim.Framework
29{ 29{
30 public enum ParcelMediaCommandEnum 30 public enum ParcelMediaCommandEnum : int
31 { 31 {
32 Stop = 0, 32 Stop = 0,
33 Pause = 1, 33 Pause = 1,
diff --git a/OpenSim/Framework/PermissionsUtil.cs b/OpenSim/Framework/PermissionsUtil.cs
index d785a78..5d3186d 100644
--- a/OpenSim/Framework/PermissionsUtil.cs
+++ b/OpenSim/Framework/PermissionsUtil.cs
@@ -72,8 +72,8 @@ namespace OpenSim.Framework
72 /// <param name="mainPerms">The permissions variable to modify.</param> 72 /// <param name="mainPerms">The permissions variable to modify.</param>
73 public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms) 73 public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms)
74 { 74 {
75 if ((foldedPerms & 7) == 0) 75// if ((foldedPerms & 7) == 0)
76 return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded 76// return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded
77 77
78 if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0) 78 if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0)
79 mainPerms &= ~(uint)PermissionMask.Copy; 79 mainPerms &= ~(uint)PermissionMask.Copy;
diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs
index d12aa61..1e5e8bf 100644
--- a/OpenSim/Framework/PluginLoader.cs
+++ b/OpenSim/Framework/PluginLoader.cs
@@ -245,13 +245,22 @@ namespace OpenSim.Framework
245 // occasionally seems to corrupt its addin cache 245 // occasionally seems to corrupt its addin cache
246 // Hence, as a temporary solution we'll remove it before each startup 246 // Hence, as a temporary solution we'll remove it before each startup
247 247
248 string customDir = Environment.GetEnvironmentVariable ("MONO_ADDINS_REGISTRY");
249 string v0 = "addin-db-000";
250 string v1 = "addin-db-001";
251 if (customDir != null && customDir != String.Empty)
252 {
253 v0 = Path.Combine(customDir, v0);
254 v1 = Path.Combine(customDir, v1);
255 }
248 try 256 try
249 { 257 {
250 if (Directory.Exists(dir + "/addin-db-000")) 258 if (Directory.Exists(v0))
251 Directory.Delete(dir + "/addin-db-000", true); 259 Directory.Delete(v0, true);
260
261 if (Directory.Exists(v1))
262 Directory.Delete(v1, true);
252 263
253 if (Directory.Exists(dir + "/addin-db-001"))
254 Directory.Delete(dir + "/addin-db-001", true);
255 } 264 }
256 catch (IOException) 265 catch (IOException)
257 { 266 {
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index c8a5376..6a12a45 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -728,7 +728,12 @@ namespace OpenSim.Framework
728 return _lightColorR; 728 return _lightColorR;
729 } 729 }
730 set { 730 set {
731 _lightColorR = value; 731 if (value < 0)
732 _lightColorR = 0;
733 else if (value > 1.0f)
734 _lightColorR = 1.0f;
735 else
736 _lightColorR = value;
732 } 737 }
733 } 738 }
734 739
@@ -737,7 +742,12 @@ namespace OpenSim.Framework
737 return _lightColorG; 742 return _lightColorG;
738 } 743 }
739 set { 744 set {
740 _lightColorG = value; 745 if (value < 0)
746 _lightColorG = 0;
747 else if (value > 1.0f)
748 _lightColorG = 1.0f;
749 else
750 _lightColorG = value;
741 } 751 }
742 } 752 }
743 753
@@ -746,7 +756,12 @@ namespace OpenSim.Framework
746 return _lightColorB; 756 return _lightColorB;
747 } 757 }
748 set { 758 set {
749 _lightColorB = value; 759 if (value < 0)
760 _lightColorB = 0;
761 else if (value > 1.0f)
762 _lightColorB = 1.0f;
763 else
764 _lightColorB = value;
750 } 765 }
751 } 766 }
752 767
@@ -755,7 +770,12 @@ namespace OpenSim.Framework
755 return _lightColorA; 770 return _lightColorA;
756 } 771 }
757 set { 772 set {
758 _lightColorA = value; 773 if (value < 0)
774 _lightColorA = 0;
775 else if (value > 1.0f)
776 _lightColorA = 1.0f;
777 else
778 _lightColorA = value;
759 } 779 }
760 } 780 }
761 781
@@ -869,6 +889,11 @@ namespace OpenSim.Framework
869 889
870 public ulong GetMeshKey(Vector3 size, float lod) 890 public ulong GetMeshKey(Vector3 size, float lod)
871 { 891 {
892 return GetMeshKey(size, lod, false);
893 }
894
895 public ulong GetMeshKey(Vector3 size, float lod, bool convex)
896 {
872 ulong hash = 5381; 897 ulong hash = 5381;
873 898
874 hash = djb2(hash, this.PathCurve); 899 hash = djb2(hash, this.PathCurve);
@@ -914,6 +939,9 @@ namespace OpenSim.Framework
914 hash = djb2(hash, scaleBytes[i]); 939 hash = djb2(hash, scaleBytes[i]);
915 } 940 }
916 941
942 if(convex)
943 hash = djb2(hash, 0xa5);
944
917 return hash; 945 return hash;
918 } 946 }
919 947
@@ -1417,7 +1445,7 @@ namespace OpenSim.Framework
1417 prim.Textures = this.Textures; 1445 prim.Textures = this.Textures;
1418 1446
1419 prim.Properties = new Primitive.ObjectProperties(); 1447 prim.Properties = new Primitive.ObjectProperties();
1420 prim.Properties.Name = "Primitive"; 1448 prim.Properties.Name = "Object";
1421 prim.Properties.Description = ""; 1449 prim.Properties.Description = "";
1422 prim.Properties.CreatorID = UUID.Zero; 1450 prim.Properties.CreatorID = UUID.Zero;
1423 prim.Properties.GroupID = UUID.Zero; 1451 prim.Properties.GroupID = UUID.Zero;
diff --git a/OpenSim/Framework/PriorityQueue.cs b/OpenSim/Framework/PriorityQueue.cs
index e7a7f7f..4f05f65 100644
--- a/OpenSim/Framework/PriorityQueue.cs
+++ b/OpenSim/Framework/PriorityQueue.cs
@@ -45,7 +45,8 @@ namespace OpenSim.Framework
45 /// <summary> 45 /// <summary>
46 /// Total number of queues (priorities) available 46 /// Total number of queues (priorities) available
47 /// </summary> 47 /// </summary>
48 public const uint NumberOfQueues = 12; 48
49 public const uint NumberOfQueues = 12; // includes immediate queues, m_queueCounts need to be set acording
49 50
50 /// <summary> 51 /// <summary>
51 /// Number of queuest (priorities) that are processed immediately 52 /// Number of queuest (priorities) that are processed immediately
@@ -60,7 +61,10 @@ namespace OpenSim.Framework
60 // each pass. weighted towards the higher priority queues 61 // each pass. weighted towards the higher priority queues
61 private uint m_nextQueue = 0; 62 private uint m_nextQueue = 0;
62 private uint m_countFromQueue = 0; 63 private uint m_countFromQueue = 0;
63 private uint[] m_queueCounts = { 8, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 1 }; 64 // first queues are imediate, so no counts
65// private uint[] m_queueCounts = { 0, 0, 8, 4, 4, 2, 2, 2, 2, 1, 1, 1 };
66 private uint[] m_queueCounts = {0, 0, 8, 8, 5, 4, 3, 2, 1, 1, 1, 1};
67 // this is ava, ava, attach, <10m, 20,40,80,160m,320,640,1280, +
64 68
65 // next request is a counter of the number of updates queued, it provides 69 // next request is a counter of the number of updates queued, it provides
66 // a total ordering on the updates coming through the queue and is more 70 // a total ordering on the updates coming through the queue and is more
@@ -130,6 +134,21 @@ namespace OpenSim.Framework
130 return true; 134 return true;
131 } 135 }
132 136
137
138 public void Remove(List<uint> ids)
139 {
140 LookupItem lookup;
141
142 foreach (uint localid in ids)
143 {
144 if (m_lookupTable.TryGetValue(localid, out lookup))
145 {
146 lookup.Heap.Remove(lookup.Handle);
147 m_lookupTable.Remove(localid);
148 }
149 }
150 }
151
133 /// <summary> 152 /// <summary>
134 /// Remove an item from one of the queues. Specifically, it removes the 153 /// Remove an item from one of the queues. Specifically, it removes the
135 /// oldest item from the next queue in order to provide fair access to 154 /// oldest item from the next queue in order to provide fair access to
@@ -137,7 +156,7 @@ namespace OpenSim.Framework
137 /// </summary> 156 /// </summary>
138 public bool TryDequeue(out IEntityUpdate value, out Int32 timeinqueue) 157 public bool TryDequeue(out IEntityUpdate value, out Int32 timeinqueue)
139 { 158 {
140 // If there is anything in priority queue 0, return it first no 159 // If there is anything in imediate queues, return it first no
141 // matter what else. Breaks fairness. But very useful. 160 // matter what else. Breaks fairness. But very useful.
142 for (int iq = 0; iq < NumberOfImmediateQueues; iq++) 161 for (int iq = 0; iq < NumberOfImmediateQueues; iq++)
143 { 162 {
@@ -172,14 +191,13 @@ namespace OpenSim.Framework
172 } 191 }
173 192
174 // Find the next non-immediate queue with updates in it 193 // Find the next non-immediate queue with updates in it
175 for (int i = 0; i < NumberOfQueues; ++i) 194 for (uint i = NumberOfImmediateQueues; i < NumberOfQueues; ++i)
176 { 195 {
177 m_nextQueue = (uint)((m_nextQueue + 1) % NumberOfQueues); 196 m_nextQueue++;
178 m_countFromQueue = m_queueCounts[m_nextQueue]; 197 if(m_nextQueue >= NumberOfQueues)
198 m_nextQueue = NumberOfImmediateQueues;
179 199
180 // if this is one of the immediate queues, just skip it 200 m_countFromQueue = m_queueCounts[m_nextQueue];
181 if (m_nextQueue < NumberOfImmediateQueues)
182 continue;
183 201
184 if (m_heaps[m_nextQueue].Count > 0) 202 if (m_heaps[m_nextQueue].Count > 0)
185 { 203 {
@@ -189,7 +207,6 @@ namespace OpenSim.Framework
189 m_lookupTable.Remove(item.Value.Entity.LocalId); 207 m_lookupTable.Remove(item.Value.Entity.LocalId);
190 timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); 208 timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime);
191 value = item.Value; 209 value = item.Value;
192
193 return true; 210 return true;
194 } 211 }
195 } 212 }
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 79fbd96..ac77352 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -40,6 +40,7 @@ using OpenMetaverse.StructuredData;
40 40
41namespace OpenSim.Framework 41namespace OpenSim.Framework
42{ 42{
43 [Serializable]
43 public class RegionLightShareData : ICloneable 44 public class RegionLightShareData : ICloneable
44 { 45 {
45 public bool valid = false; 46 public bool valid = false;
@@ -101,6 +102,11 @@ namespace OpenSim.Framework
101 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 102 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
102 private static readonly string LogHeader = "[REGION INFO]"; 103 private static readonly string LogHeader = "[REGION INFO]";
103 104
105
106 public bool commFailTF = false;
107 public ConfigurationMember configMember;
108 public string DataStore = String.Empty;
109
104 public string RegionFile = String.Empty; 110 public string RegionFile = String.Empty;
105 public bool isSandbox = false; 111 public bool isSandbox = false;
106 public bool Persistent = true; 112 public bool Persistent = true;
@@ -527,7 +533,7 @@ namespace OpenSim.Framework
527 return null; 533 return null;
528 } 534 }
529 535
530 private void SetExtraSetting(string key, string value) 536 public void SetExtraSetting(string key, string value)
531 { 537 {
532 string keylower = key.ToLower(); 538 string keylower = key.ToLower();
533 m_extraSettings[keylower] = value; 539 m_extraSettings[keylower] = value;
@@ -823,14 +829,16 @@ namespace OpenSim.Framework
823 string location = String.Format("{0},{1}", RegionLocX, RegionLocY); 829 string location = String.Format("{0},{1}", RegionLocX, RegionLocY);
824 config.Set("Location", location); 830 config.Set("Location", location);
825 831
826 if (RegionSizeX > 0) 832 if (DataStore != String.Empty)
827 config.Set("SizeX", RegionSizeX); 833 config.Set("Datastore", DataStore);
828 834
829 if (RegionSizeY > 0) 835 if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize)
836 {
837 config.Set("SizeX", RegionSizeX);
830 config.Set("SizeY", RegionSizeY); 838 config.Set("SizeY", RegionSizeY);
831 839 // if (RegionSizeZ > 0)
832// if (RegionSizeZ > 0) 840 // config.Set("SizeZ", RegionSizeZ);
833// config.Set("SizeZ", RegionSizeZ); 841 }
834 842
835 config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); 843 config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
836 config.Set("InternalPort", m_internalEndPoint.Port); 844 config.Set("InternalPort", m_internalEndPoint.Port);
@@ -901,6 +909,232 @@ namespace OpenSim.Framework
901 throw new Exception("Invalid file type for region persistence."); 909 throw new Exception("Invalid file type for region persistence.");
902 } 910 }
903 911
912 public void loadConfigurationOptionsFromMe()
913 {
914 configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE,
915 "UUID of Region (Default is recommended, random UUID)",
916 RegionID.ToString(), true);
917 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
918 "Region Name", RegionName, true);
919
920 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
921 "Grid Location (X Axis)", RegionLocX.ToString(), true);
922 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
923 "Grid Location (Y Axis)", RegionLocY.ToString(), true);
924 configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
925 "Size of region in X dimension", RegionSizeX.ToString(), true);
926 configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
927 "Size of region in Y dimension", RegionSizeY.ToString(), true);
928 configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
929 "Size of region in Z dimension", RegionSizeZ.ToString(), true);
930
931 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
932 configMember.addConfigurationOption("internal_ip_address",
933 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
934 "Internal IP Address for incoming UDP client connections",
935 m_internalEndPoint.Address.ToString(),
936 true);
937 configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
938 "Internal IP Port for incoming UDP client connections",
939 m_internalEndPoint.Port.ToString(), true);
940 configMember.addConfigurationOption("allow_alternate_ports",
941 ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
942 "Allow sim to find alternate UDP ports when ports are in use?",
943 m_allow_alternate_ports.ToString(), true);
944 configMember.addConfigurationOption("external_host_name",
945 ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
946 "External Host Name", m_externalHostName, true);
947 configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
948 "Last Map UUID", lastMapUUID.ToString(), true);
949 configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
950 "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true);
951
952 configMember.addConfigurationOption("nonphysical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
953 "Minimum size for nonphysical prims", m_nonphysPrimMin.ToString(), true);
954
955 configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
956 "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true);
957
958 configMember.addConfigurationOption("physical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
959 "Minimum size for nonphysical prims", m_physPrimMin.ToString(), true);
960
961 configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
962 "Maximum size for physical prims", m_physPrimMax.ToString(), true);
963
964 configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
965 "Clamp prims to max size", m_clampPrimSize.ToString(), true);
966
967 configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
968 "Max objects this sim will hold", m_objectCapacity.ToString(), true);
969
970 configMember.addConfigurationOption("linkset_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
971 "Max prims an object will hold", m_linksetCapacity.ToString(), true);
972
973 configMember.addConfigurationOption("agent_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
974 "Max avatars this sim will hold",AgentCapacity.ToString(), true);
975
976 configMember.addConfigurationOption("scope_id", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
977 "Scope ID for this region", ScopeID.ToString(), true);
978
979 configMember.addConfigurationOption("region_type", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
980 "Free form string describing the type of region", String.Empty, true);
981
982 configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
983 "UUID of a texture to use as the map for this region", m_maptileStaticUUID.ToString(), true);
984 }
985
986 public void loadConfigurationOptions()
987 {
988 configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
989 "UUID of Region (Default is recommended, random UUID)",
990 UUID.Random().ToString(), true);
991 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
992 "Region Name", "OpenSim Test", false);
993
994 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
995 "Grid Location (X Axis)", "1000", false);
996 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
997 "Grid Location (Y Axis)", "1000", false);
998 configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
999 "Size of region in X dimension", Constants.RegionSize.ToString(), false);
1000 configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
1001 "Size of region in Y dimension", Constants.RegionSize.ToString(), false);
1002 configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
1003 "Size of region in Z dimension", Constants.RegionHeight.ToString(), false);
1004
1005 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
1006 configMember.addConfigurationOption("internal_ip_address",
1007 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
1008 "Internal IP Address for incoming UDP client connections", "0.0.0.0",
1009 false);
1010 configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
1011 "Internal IP Port for incoming UDP client connections",
1012 ConfigSettings.DefaultRegionHttpPort.ToString(), false);
1013 configMember.addConfigurationOption("allow_alternate_ports", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
1014 "Allow sim to find alternate UDP ports when ports are in use?",
1015 "false", true);
1016 configMember.addConfigurationOption("external_host_name",
1017 ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
1018 "External Host Name", "127.0.0.1", false);
1019 configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
1020 "Last Map UUID", lastMapUUID.ToString(), true);
1021
1022 configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
1023 "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true);
1024
1025 configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
1026 "Maximum size for nonphysical prims", "0", true);
1027
1028 configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
1029 "Maximum size for physical prims", "0", true);
1030
1031 configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
1032 "Clamp prims to max size", "false", true);
1033
1034 configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
1035 "Max objects this sim will hold", "15000", true);
1036
1037 configMember.addConfigurationOption("agent_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
1038 "Max avatars this sim will hold", "100", true);
1039
1040 configMember.addConfigurationOption("scope_id", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
1041 "Scope ID for this region", UUID.Zero.ToString(), true);
1042
1043 configMember.addConfigurationOption("region_type", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
1044 "Region Type", String.Empty, true);
1045
1046 configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
1047 "UUID of a texture to use as the map for this region", String.Empty, true);
1048 }
1049
1050 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
1051 {
1052 switch (configuration_key)
1053 {
1054 case "sim_UUID":
1055 RegionID = (UUID) configuration_result;
1056 originRegionID = (UUID) configuration_result;
1057 break;
1058 case "sim_name":
1059 RegionName = (string) configuration_result;
1060 break;
1061 case "sim_location_x":
1062 RegionLocX = (uint) configuration_result;
1063 break;
1064 case "sim_location_y":
1065 RegionLocY = (uint) configuration_result;
1066 break;
1067 case "sim_size_x":
1068 RegionSizeX = (uint) configuration_result;
1069 break;
1070 case "sim_size_y":
1071 RegionSizeY = (uint) configuration_result;
1072 break;
1073 case "sim_size_z":
1074 RegionSizeZ = (uint) configuration_result;
1075 break;
1076 case "datastore":
1077 DataStore = (string) configuration_result;
1078 break;
1079 case "internal_ip_address":
1080 IPAddress address = (IPAddress) configuration_result;
1081 m_internalEndPoint = new IPEndPoint(address, 0);
1082 break;
1083 case "internal_ip_port":
1084 m_internalEndPoint.Port = (int) configuration_result;
1085 break;
1086 case "allow_alternate_ports":
1087 m_allow_alternate_ports = (bool) configuration_result;
1088 break;
1089 case "external_host_name":
1090 if ((string) configuration_result != "SYSTEMIP")
1091 {
1092 m_externalHostName = (string) configuration_result;
1093 }
1094 else
1095 {
1096 m_externalHostName = Util.GetLocalHost().ToString();
1097 }
1098 break;
1099 case "lastmap_uuid":
1100 lastMapUUID = (UUID)configuration_result;
1101 break;
1102 case "lastmap_refresh":
1103 lastMapRefresh = (string)configuration_result;
1104 break;
1105 case "nonphysical_prim_max":
1106 m_nonphysPrimMax = (int)configuration_result;
1107 break;
1108 case "physical_prim_max":
1109 m_physPrimMax = (int)configuration_result;
1110 break;
1111 case "clamp_prim_size":
1112 m_clampPrimSize = (bool)configuration_result;
1113 break;
1114 case "object_capacity":
1115 m_objectCapacity = (int)configuration_result;
1116 break;
1117 case "linkset_capacity":
1118 m_linksetCapacity = (int)configuration_result;
1119 break;
1120 case "agent_capacity":
1121 AgentCapacity = (int)configuration_result;
1122 break;
1123 case "scope_id":
1124 ScopeID = (UUID)configuration_result;
1125 break;
1126 case "region_type":
1127 m_regionType = (string)configuration_result;
1128 break;
1129 case "region_static_maptile":
1130 m_maptileStaticUUID = (UUID)configuration_result;
1131 break;
1132 }
1133
1134 return true;
1135 }
1136
1137
904 public void SaveLastMapUUID(UUID mapUUID) 1138 public void SaveLastMapUUID(UUID mapUUID)
905 { 1139 {
906 lastMapUUID = mapUUID; 1140 lastMapUUID = mapUUID;
@@ -1004,5 +1238,28 @@ namespace OpenSim.Framework
1004 regionInfo.ServerURI = serverURI; 1238 regionInfo.ServerURI = serverURI;
1005 return regionInfo; 1239 return regionInfo;
1006 } 1240 }
1241
1242 public int getInternalEndPointPort()
1243 {
1244 return m_internalEndPoint.Port;
1245 }
1246
1247 public Dictionary<string, object> ToKeyValuePairs()
1248 {
1249 Dictionary<string, object> kvp = new Dictionary<string, object>();
1250 kvp["uuid"] = RegionID.ToString();
1251 kvp["locX"] = RegionLocX.ToString();
1252 kvp["locY"] = RegionLocY.ToString();
1253 kvp["external_ip_address"] = ExternalEndPoint.Address.ToString();
1254 kvp["external_port"] = ExternalEndPoint.Port.ToString();
1255 kvp["external_host_name"] = ExternalHostName;
1256 kvp["http_port"] = HttpPort.ToString();
1257 kvp["internal_ip_address"] = InternalEndPoint.Address.ToString();
1258 kvp["internal_port"] = InternalEndPoint.Port.ToString();
1259 kvp["alternate_ports"] = m_allow_alternate_ports.ToString();
1260 kvp["server_uri"] = ServerURI;
1261
1262 return kvp;
1263 }
1007 } 1264 }
1008} 1265}
diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs
index a895c40..dec01ea 100644
--- a/OpenSim/Framework/RegionSettings.cs
+++ b/OpenSim/Framework/RegionSettings.cs
@@ -482,6 +482,28 @@ namespace OpenSim.Framework
482 set { m_LoadedCreationID = value; } 482 set { m_LoadedCreationID = value; }
483 } 483 }
484 484
485 private bool m_GodBlockSearch = false;
486 public bool GodBlockSearch
487 {
488 get { return m_GodBlockSearch; }
489 set { m_GodBlockSearch = value; }
490 }
491
492 private bool m_Casino = false;
493 public bool Casino
494 {
495 get { return m_Casino; }
496 set { m_Casino = value; }
497 }
498
499 // Telehub support
500 private bool m_TelehubEnabled = false;
501 public bool HasTelehub
502 {
503 get { return m_TelehubEnabled; }
504 set { m_TelehubEnabled = value; }
505 }
506
485 /// <summary> 507 /// <summary>
486 /// Connected Telehub object 508 /// Connected Telehub object
487 /// </summary> 509 /// </summary>
@@ -520,4 +542,4 @@ namespace OpenSim.Framework
520 l_SpawnPoints.Clear(); 542 l_SpawnPoints.Clear();
521 } 543 }
522 } 544 }
523} \ No newline at end of file 545}
diff --git a/OpenSim/Framework/RestClient.cs b/OpenSim/Framework/RestClient.cs
index 7080ca5..ca19392 100644
--- a/OpenSim/Framework/RestClient.cs
+++ b/OpenSim/Framework/RestClient.cs
@@ -388,10 +388,10 @@ namespace OpenSim.Framework
388 m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e); 388 m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e);
389 } 389 }
390 } 390 }
391
392 return null; 391 return null;
393 } 392 }
394 393
394
395 if (_asyncException != null) 395 if (_asyncException != null)
396 throw _asyncException; 396 throw _asyncException;
397 397
@@ -413,7 +413,7 @@ namespace OpenSim.Framework
413 _request = (HttpWebRequest) WebRequest.Create(buildUri()); 413 _request = (HttpWebRequest) WebRequest.Create(buildUri());
414 _request.KeepAlive = false; 414 _request.KeepAlive = false;
415 _request.ContentType = "application/xml"; 415 _request.ContentType = "application/xml";
416 _request.Timeout = 900000; 416 _request.Timeout = 90000;
417 _request.Method = RequestMethod; 417 _request.Method = RequestMethod;
418 _asyncException = null; 418 _asyncException = null;
419 _request.ContentLength = src.Length; 419 _request.ContentLength = src.Length;
@@ -428,14 +428,18 @@ namespace OpenSim.Framework
428 if (WebUtil.DebugLevel >= 5) 428 if (WebUtil.DebugLevel >= 5)
429 WebUtil.LogOutgoingDetail(string.Format("SEND {0}: ", reqnum), src); 429 WebUtil.LogOutgoingDetail(string.Format("SEND {0}: ", reqnum), src);
430 430
431 Stream dst = _request.GetRequestStream(); 431 using (Stream dst = _request.GetRequestStream())
432
433 byte[] buf = new byte[1024];
434 int length = src.Read(buf, 0, 1024);
435 while (length > 0)
436 { 432 {
437 dst.Write(buf, 0, length); 433 m_log.Info("[REST]: GetRequestStream is ok");
438 length = src.Read(buf, 0, 1024); 434
435 byte[] buf = new byte[1024];
436 int length = src.Read(buf, 0, 1024);
437 m_log.Info("[REST]: First Read is ok");
438 while (length > 0)
439 {
440 dst.Write(buf, 0, length);
441 length = src.Read(buf, 0, 1024);
442 }
439 } 443 }
440 444
441 try 445 try
@@ -468,7 +472,8 @@ namespace OpenSim.Framework
468 } 472 }
469 } 473 }
470 474
471 _response.Close(); 475 if (_response != null)
476 _response.Close();
472 477
473// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); 478// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);
474 479
@@ -673,4 +678,4 @@ namespace OpenSim.Framework
673 } 678 }
674 } 679 }
675 680
676} \ No newline at end of file 681}
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 828a852..3426d10 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -65,6 +65,7 @@ namespace OpenSim.Framework.Servers
65 /// This will control a periodic log printout of the current 'show stats' (if they are active) for this 65 /// This will control a periodic log printout of the current 'show stats' (if they are active) for this
66 /// server. 66 /// server.
67 /// </summary> 67 /// </summary>
68
68 private int m_periodDiagnosticTimerMS = 60 * 60 * 1000; 69 private int m_periodDiagnosticTimerMS = 60 * 60 * 1000;
69 private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000); 70 private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000);
70 71
@@ -83,7 +84,6 @@ namespace OpenSim.Framework.Servers
83 { 84 {
84 // Random uuid for private data 85 // Random uuid for private data
85 m_osSecret = UUID.Random().ToString(); 86 m_osSecret = UUID.Random().ToString();
86
87 } 87 }
88 88
89 /// <summary> 89 /// <summary>
@@ -146,14 +146,24 @@ namespace OpenSim.Framework.Servers
146 /// Performs initialisation of the scene, such as loading configuration from disk. 146 /// Performs initialisation of the scene, such as loading configuration from disk.
147 /// </summary> 147 /// </summary>
148 public virtual void Startup() 148 public virtual void Startup()
149 { 149 {
150 m_log.Info("[STARTUP]: Beginning startup processing");
151
152 m_log.Info("[STARTUP]: version: " + m_version + Environment.NewLine);
153 // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and
154 // the clr version number doesn't match the project version number under Mono.
155 //m_log.Info("[STARTUP]: Virtual machine runtime version: " + Environment.Version + Environment.NewLine);
156 m_log.InfoFormat(
157 "[STARTUP]: Operating system version: {0}, .NET platform {1}, {2}-bit\n",
158 Environment.OSVersion, Environment.OSVersion.Platform, Util.Is64BitProcess() ? "64" : "32");
159
150 StartupSpecific(); 160 StartupSpecific();
151 161
152 TimeSpan timeTaken = DateTime.Now - m_startuptime; 162 TimeSpan timeTaken = DateTime.Now - m_startuptime;
153 163
154 MainConsole.Instance.OutputFormat( 164// MainConsole.Instance.OutputFormat(
155 "PLEASE WAIT FOR LOGINS TO BE ENABLED ON REGIONS ONCE SCRIPTS HAVE STARTED. Non-script portion of startup took {0}m {1}s.", 165// "PLEASE WAIT FOR LOGINS TO BE ENABLED ON REGIONS ONCE SCRIPTS HAVE STARTED. Non-script portion of startup took {0}m {1}s.",
156 timeTaken.Minutes, timeTaken.Seconds); 166// timeTaken.Minutes, timeTaken.Seconds);
157 } 167 }
158 168
159 public string osSecret 169 public string osSecret
@@ -175,4 +185,4 @@ namespace OpenSim.Framework.Servers
175 } 185 }
176 } 186 }
177 } 187 }
178} \ No newline at end of file 188}
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index f252bd5..cd14212 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -403,6 +403,7 @@ namespace OpenSim.Framework.Servers.HttpServer
403 StreamReader reader = new StreamReader(requestStream, encoding); 403 StreamReader reader = new StreamReader(requestStream, encoding);
404 404
405 string requestBody = reader.ReadToEnd(); 405 string requestBody = reader.ReadToEnd();
406 reader.Close();
406 407
407 Hashtable keysvals = new Hashtable(); 408 Hashtable keysvals = new Hashtable();
408 Hashtable headervals = new Hashtable(); 409 Hashtable headervals = new Hashtable();
@@ -460,7 +461,7 @@ namespace OpenSim.Framework.Servers.HttpServer
460 } 461 }
461 462
462 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); 463 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
463 resp.ReuseContext = true; 464 resp.ReuseContext = false;
464 HandleRequest(req, resp); 465 HandleRequest(req, resp);
465 466
466 // !!!HACK ALERT!!! 467 // !!!HACK ALERT!!!
@@ -759,7 +760,7 @@ namespace OpenSim.Framework.Servers.HttpServer
759 // Every month or so this will wrap and give bad numbers, not really a problem 760 // Every month or so this will wrap and give bad numbers, not really a problem
760 // since its just for reporting 761 // since its just for reporting
761 int tickdiff = requestEndTick - requestStartTick; 762 int tickdiff = requestEndTick - requestStartTick;
762 if (tickdiff > 3000 && requestHandler != null && requestHandler.Name != "GetTexture") 763 if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture"))
763 { 764 {
764 m_log.InfoFormat( 765 m_log.InfoFormat(
765 "[LOGHTTP] Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", 766 "[LOGHTTP] Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms",
@@ -1024,6 +1025,19 @@ namespace OpenSim.Framework.Servers.HttpServer
1024 string responseString = String.Empty; 1025 string responseString = String.Empty;
1025 XmlRpcRequest xmlRprcRequest = null; 1026 XmlRpcRequest xmlRprcRequest = null;
1026 1027
1028 bool gridproxy = false;
1029 if (requestBody.Contains("encoding=\"utf-8"))
1030 {
1031 int channelindx = -1;
1032 int optionsindx = requestBody.IndexOf(">options<");
1033 if(optionsindx >0)
1034 {
1035 channelindx = requestBody.IndexOf(">channel<");
1036 if (optionsindx < channelindx)
1037 gridproxy = true;
1038 }
1039 }
1040
1027 try 1041 try
1028 { 1042 {
1029 xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody); 1043 xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody);
@@ -1081,6 +1095,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1081 } 1095 }
1082 xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3] 1096 xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3]
1083 1097
1098 if (gridproxy)
1099 xmlRprcRequest.Params.Add("gridproxy"); // Param[4]
1084 try 1100 try
1085 { 1101 {
1086 xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint); 1102 xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint);
@@ -1254,7 +1270,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1254 requestStream.Close(); 1270 requestStream.Close();
1255 1271
1256 //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody); 1272 //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody);
1257 response.KeepAlive = true; 1273 // response.KeepAlive = true;
1274 response.KeepAlive = false;
1258 1275
1259 OSD llsdRequest = null; 1276 OSD llsdRequest = null;
1260 OSD llsdResponse = null; 1277 OSD llsdResponse = null;
@@ -1732,10 +1749,40 @@ namespace OpenSim.Framework.Servers.HttpServer
1732 1749
1733 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) 1750 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response)
1734 { 1751 {
1735 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); 1752 int responsecode;
1736 int responsecode = (int)responsedata["int_response_code"]; 1753 string responseString = String.Empty;
1737 string responseString = (string)responsedata["str_response_string"]; 1754 byte[] responseData = null;
1738 string contentType = (string)responsedata["content_type"]; 1755 string contentType;
1756
1757 if (responsedata == null)
1758 {
1759 responsecode = 500;
1760 responseString = "No response could be obtained";
1761 contentType = "text/plain";
1762 responsedata = new Hashtable();
1763 }
1764 else
1765 {
1766 try
1767 {
1768 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response");
1769 responsecode = (int)responsedata["int_response_code"];
1770 if (responsedata["bin_response_data"] != null)
1771 responseData = (byte[])responsedata["bin_response_data"];
1772 else
1773 responseString = (string)responsedata["str_response_string"];
1774 contentType = (string)responsedata["content_type"];
1775 if (responseString == null)
1776 responseString = String.Empty;
1777 }
1778 catch
1779 {
1780 responsecode = 500;
1781 responseString = "No response could be obtained";
1782 contentType = "text/plain";
1783 responsedata = new Hashtable();
1784 }
1785 }
1739 1786
1740 if (responsedata.ContainsKey("error_status_text")) 1787 if (responsedata.ContainsKey("error_status_text"))
1741 { 1788 {
@@ -1745,16 +1792,19 @@ namespace OpenSim.Framework.Servers.HttpServer
1745 { 1792 {
1746 response.ProtocolVersion = (string)responsedata["http_protocol_version"]; 1793 response.ProtocolVersion = (string)responsedata["http_protocol_version"];
1747 } 1794 }
1748 1795/*
1749 if (responsedata.ContainsKey("keepalive")) 1796 if (responsedata.ContainsKey("keepalive"))
1750 { 1797 {
1751 bool keepalive = (bool)responsedata["keepalive"]; 1798 bool keepalive = (bool)responsedata["keepalive"];
1752 response.KeepAlive = keepalive; 1799 response.KeepAlive = keepalive;
1753
1754 } 1800 }
1755 1801
1756 if (responsedata.ContainsKey("reusecontext")) 1802 if (responsedata.ContainsKey("reusecontext"))
1757 response.ReuseContext = (bool) responsedata["reusecontext"]; 1803 response.ReuseContext = (bool) responsedata["reusecontext"];
1804*/
1805 // disable this things
1806 response.KeepAlive = false;
1807 response.ReuseContext = false;
1758 1808
1759 // Cross-Origin Resource Sharing with simple requests 1809 // Cross-Origin Resource Sharing with simple requests
1760 if (responsedata.ContainsKey("access_control_allow_origin")) 1810 if (responsedata.ContainsKey("access_control_allow_origin"))
@@ -1768,8 +1818,11 @@ namespace OpenSim.Framework.Servers.HttpServer
1768 contentType = "text/html"; 1818 contentType = "text/html";
1769 } 1819 }
1770 1820
1821
1822
1771 // The client ignores anything but 200 here for web login, so ensure that this is 200 for that 1823 // The client ignores anything but 200 here for web login, so ensure that this is 200 for that
1772 1824
1825
1773 response.StatusCode = responsecode; 1826 response.StatusCode = responsecode;
1774 1827
1775 if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently) 1828 if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently)
@@ -1780,25 +1833,40 @@ namespace OpenSim.Framework.Servers.HttpServer
1780 1833
1781 response.AddHeader("Content-Type", contentType); 1834 response.AddHeader("Content-Type", contentType);
1782 1835
1836 if (responsedata.ContainsKey("headers"))
1837 {
1838 Hashtable headerdata = (Hashtable)responsedata["headers"];
1839
1840 foreach (string header in headerdata.Keys)
1841 response.AddHeader(header, (string)headerdata[header]);
1842 }
1843
1783 byte[] buffer; 1844 byte[] buffer;
1784 1845
1785 if (!(contentType.Contains("image") 1846 if (responseData != null)
1786 || contentType.Contains("x-shockwave-flash")
1787 || contentType.Contains("application/x-oar")
1788 || contentType.Contains("application/vnd.ll.mesh")))
1789 { 1847 {
1790 // Text 1848 buffer = responseData;
1791 buffer = Encoding.UTF8.GetBytes(responseString);
1792 } 1849 }
1793 else 1850 else
1794 { 1851 {
1795 // Binary! 1852 if (!(contentType.Contains("image")
1796 buffer = Convert.FromBase64String(responseString); 1853 || contentType.Contains("x-shockwave-flash")
1797 } 1854 || contentType.Contains("application/x-oar")
1855 || contentType.Contains("application/vnd.ll.mesh")))
1856 {
1857 // Text
1858 buffer = Encoding.UTF8.GetBytes(responseString);
1859 }
1860 else
1861 {
1862 // Binary!
1863 buffer = Convert.FromBase64String(responseString);
1864 }
1798 1865
1799 response.SendChunked = false; 1866 response.SendChunked = false;
1800 response.ContentLength64 = buffer.Length; 1867 response.ContentLength64 = buffer.Length;
1801 response.ContentEncoding = Encoding.UTF8; 1868 response.ContentEncoding = Encoding.UTF8;
1869 }
1802 1870
1803 return buffer; 1871 return buffer;
1804 } 1872 }
@@ -1886,6 +1954,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1886 m_httpListener2.Start(64); 1954 m_httpListener2.Start(64);
1887 1955
1888 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events 1956 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events
1957
1889 PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 3, 25000); 1958 PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 3, 25000);
1890 PollServiceRequestManager.Start(); 1959 PollServiceRequestManager.Start();
1891 1960
@@ -1937,7 +2006,9 @@ namespace OpenSim.Framework.Servers.HttpServer
1937 2006
1938 public void httpServerException(object source, Exception exception) 2007 public void httpServerException(object source, Exception exception)
1939 { 2008 {
1940 m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); 2009 if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException"))
2010 return;
2011 m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString());
1941 /* 2012 /*
1942 if (HTTPDRunning)// && NotSocketErrors > 5) 2013 if (HTTPDRunning)// && NotSocketErrors > 5)
1943 { 2014 {
@@ -1984,6 +2055,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1984 2055
1985 public void RemoveHTTPHandler(string httpMethod, string path) 2056 public void RemoveHTTPHandler(string httpMethod, string path)
1986 { 2057 {
2058 if (path == null) return; // Caps module isn't loaded, tries to remove handler where path = null
1987 lock (m_HTTPHandlers) 2059 lock (m_HTTPHandlers)
1988 { 2060 {
1989 if (httpMethod != null && httpMethod.Length == 0) 2061 if (httpMethod != null && httpMethod.Length == 0)
diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs
index 89fb5d4..17e9dc2 100644
--- a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs
+++ b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs
@@ -148,6 +148,7 @@ namespace OpenSim.Framework.Servers.HttpServer
148 _httpResponse.Connection = ConnectionType.Close; 148 _httpResponse.Connection = ConnectionType.Close;
149 _httpResponse.KeepAlive = 0; 149 _httpResponse.KeepAlive = 0;
150 } 150 }
151
151 else 152 else
152 { 153 {
153 _httpResponse.Connection = ConnectionType.KeepAlive; 154 _httpResponse.Connection = ConnectionType.KeepAlive;
@@ -320,6 +321,11 @@ namespace OpenSim.Framework.Servers.HttpServer
320 public void Send() 321 public void Send()
321 { 322 {
322 _httpResponse.Body.Flush(); 323 _httpResponse.Body.Flush();
324
325 // disable this till they are safe to use
326 _httpResponse.Connection = ConnectionType.Close;
327 _httpResponse.Chunked = false;
328
323 _httpResponse.Send(); 329 _httpResponse.Send();
324 } 330 }
325 331
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
index 9477100..3fd3bf7 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
@@ -52,7 +52,9 @@ namespace OpenSim.Framework.Servers.HttpServer
52 { 52 {
53 LongPoll = 0, 53 LongPoll = 0,
54 LslHttp = 1, 54 LslHttp = 1,
55 Inventory = 2 55 Inventory = 2,
56 Texture = 3,
57 Mesh = 4
56 } 58 }
57 59
58 public string Url { get; set; } 60 public string Url { get; set; }
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
index caf0e98..49cd110 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
30using System.Reflection; 31using System.Reflection;
31using System.Text; 32using System.Text;
32using HttpServer; 33using HttpServer;
@@ -44,6 +45,24 @@ namespace OpenSim.Framework.Servers.HttpServer
44 public readonly IHttpRequest Request; 45 public readonly IHttpRequest Request;
45 public readonly int RequestTime; 46 public readonly int RequestTime;
46 public readonly UUID RequestID; 47 public readonly UUID RequestID;
48 public int contextHash;
49
50 private void GenContextHash()
51 {
52 Random rnd = new Random();
53 contextHash = 0;
54 if (Request.Headers["remote_addr"] != null)
55 contextHash = (Request.Headers["remote_addr"]).GetHashCode() << 16;
56 else
57 contextHash = rnd.Next() << 16;
58 if (Request.Headers["remote_port"] != null)
59 {
60 string[] strPorts = Request.Headers["remote_port"].Split(new char[] { ',' });
61 contextHash += Int32.Parse(strPorts[0]);
62 }
63 else
64 contextHash += rnd.Next() & 0xffff;
65 }
47 66
48 public PollServiceHttpRequest( 67 public PollServiceHttpRequest(
49 PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) 68 PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest)
@@ -53,6 +72,7 @@ namespace OpenSim.Framework.Servers.HttpServer
53 Request = pRequest; 72 Request = pRequest;
54 RequestTime = System.Environment.TickCount; 73 RequestTime = System.Environment.TickCount;
55 RequestID = UUID.Random(); 74 RequestID = UUID.Random();
75 GenContextHash();
56 } 76 }
57 77
58 internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata) 78 internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata)
@@ -65,6 +85,7 @@ namespace OpenSim.Framework.Servers.HttpServer
65 response.SendChunked = false; 85 response.SendChunked = false;
66 response.ContentLength64 = buffer.Length; 86 response.ContentLength64 = buffer.Length;
67 response.ContentEncoding = Encoding.UTF8; 87 response.ContentEncoding = Encoding.UTF8;
88 response.ReuseContext = false;
68 89
69 try 90 try
70 { 91 {
@@ -93,5 +114,44 @@ namespace OpenSim.Framework.Servers.HttpServer
93 PollServiceArgs.RequestsHandled++; 114 PollServiceArgs.RequestsHandled++;
94 } 115 }
95 } 116 }
117
118 internal void DoHTTPstop(BaseHttpServer server)
119 {
120 OSHttpResponse response
121 = new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext);
122
123 response.SendChunked = false;
124 response.ContentLength64 = 0;
125 response.ContentEncoding = Encoding.UTF8;
126 response.ReuseContext = false;
127 response.KeepAlive = false;
128 response.SendChunked = false;
129 response.StatusCode = 503;
130
131 try
132 {
133 response.OutputStream.Flush();
134 response.Send();
135 }
136 catch (Exception e)
137 {
138 }
139 }
140 }
141
142 class PollServiceHttpRequestComparer : IEqualityComparer<PollServiceHttpRequest>
143 {
144 public bool Equals(PollServiceHttpRequest b1, PollServiceHttpRequest b2)
145 {
146 if (b1.contextHash != b2.contextHash)
147 return false;
148 bool b = Object.ReferenceEquals(b1.HttpContext, b2.HttpContext);
149 return b;
150 }
151
152 public int GetHashCode(PollServiceHttpRequest b2)
153 {
154 return (int)b2.contextHash;
155 }
96 } 156 }
97} \ No newline at end of file 157} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index 28bba70..0e4323a 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -44,183 +44,199 @@ namespace OpenSim.Framework.Servers.HttpServer
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 /// <summary>
48 /// Is the poll service request manager running?
49 /// </summary>
50 /// <remarks>
51 /// Can be running either synchronously or asynchronously
52 /// </remarks>
53 public bool IsRunning { get; private set; }
54
55 /// <summary>
56 /// Is the poll service performing responses asynchronously (with its own threads) or synchronously (via
57 /// external calls)?
58 /// </summary>
59 public bool PerformResponsesAsync { get; private set; }
60
61 /// <summary>
62 /// Number of responses actually processed and sent to viewer (or aborted due to error).
63 /// </summary>
64 public int ResponsesProcessed { get; private set; }
65
66 private readonly BaseHttpServer m_server; 47 private readonly BaseHttpServer m_server;
67 48
49 private Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>> m_bycontext;
68 private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>(); 50 private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>();
69 private static List<PollServiceHttpRequest> m_longPollRequests = new List<PollServiceHttpRequest>(); 51 private static Queue<PollServiceHttpRequest> m_slowRequests = new Queue<PollServiceHttpRequest>();
52 private static Queue<PollServiceHttpRequest> m_retryRequests = new Queue<PollServiceHttpRequest>();
70 53
71 private uint m_WorkerThreadCount = 0; 54 private uint m_WorkerThreadCount = 0;
72 private Thread[] m_workerThreads; 55 private Thread[] m_workerThreads;
56 private Thread m_retrysThread;
57
58 private bool m_running = false;
59 private int slowCount = 0;
73 60
74 private SmartThreadPool m_threadPool = new SmartThreadPool(20000, 12, 2); 61 private SmartThreadPool m_threadPool;
75 62
76// private int m_timeout = 1000; // increase timeout 250; now use the event one
77 63
78 public PollServiceRequestManager( 64 public PollServiceRequestManager(
79 BaseHttpServer pSrv, bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout) 65 BaseHttpServer pSrv, bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout)
80 { 66 {
81 m_server = pSrv; 67 m_server = pSrv;
82 PerformResponsesAsync = performResponsesAsync;
83 m_WorkerThreadCount = pWorkerThreadCount; 68 m_WorkerThreadCount = pWorkerThreadCount;
84 m_workerThreads = new Thread[m_WorkerThreadCount]; 69 m_workerThreads = new Thread[m_WorkerThreadCount];
85 70
86 StatsManager.RegisterStat( 71 PollServiceHttpRequestComparer preqCp = new PollServiceHttpRequestComparer();
87 new Stat( 72 m_bycontext = new Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>>(preqCp);
88 "QueuedPollResponses", 73
89 "Number of poll responses queued for processing.", 74 STPStartInfo startInfo = new STPStartInfo();
90 "", 75 startInfo.IdleTimeout = 30000;
91 "", 76 startInfo.MaxWorkerThreads = 15;
92 "httpserver", 77 startInfo.MinWorkerThreads = 1;
93 m_server.Port.ToString(), 78 startInfo.ThreadPriority = ThreadPriority.Normal;
94 StatType.Pull, 79 startInfo.StartSuspended = true;
95 MeasuresOfInterest.AverageChangeOverTime, 80 startInfo.ThreadPoolName = "PoolService";
96 stat => stat.Value = m_requests.Count(), 81
97 StatVerbosity.Debug)); 82 m_threadPool = new SmartThreadPool(startInfo);
98 83
99 StatsManager.RegisterStat(
100 new Stat(
101 "ProcessedPollResponses",
102 "Number of poll responses processed.",
103 "",
104 "",
105 "httpserver",
106 m_server.Port.ToString(),
107 StatType.Pull,
108 MeasuresOfInterest.AverageChangeOverTime,
109 stat => stat.Value = ResponsesProcessed,
110 StatVerbosity.Debug));
111 } 84 }
112 85
113 public void Start() 86 public void Start()
114 { 87 {
115 IsRunning = true; 88 m_running = true;
116 89 m_threadPool.Start();
117 if (PerformResponsesAsync) 90 //startup worker threads
91 for (uint i = 0; i < m_WorkerThreadCount; i++)
118 { 92 {
119 //startup worker threads 93 m_workerThreads[i]
120 for (uint i = 0; i < m_WorkerThreadCount; i++) 94 = WorkManager.StartThread(
121 { 95 PoolWorkerJob,
122 m_workerThreads[i] 96 string.Format("PollServiceWorkerThread {0}:{1}", i, m_server.Port),
123 = WorkManager.StartThread( 97 ThreadPriority.Normal,
124 PoolWorkerJob, 98 false,
125 string.Format("PollServiceWorkerThread{0}:{1}", i, m_server.Port), 99 false,
126 ThreadPriority.Normal, 100 null,
127 false, 101 int.MaxValue);
128 false,
129 null,
130 int.MaxValue);
131 }
132
133 WorkManager.StartThread(
134 this.CheckLongPollThreads,
135 string.Format("LongPollServiceWatcherThread:{0}", m_server.Port),
136 ThreadPriority.Normal,
137 false,
138 true,
139 null,
140 1000 * 60 * 10);
141 } 102 }
103
104 m_retrysThread = WorkManager.StartThread(
105 this.CheckRetries,
106 string.Format("PollServiceWatcherThread:{0}", m_server.Port),
107 ThreadPriority.Normal,
108 false,
109 true,
110 null,
111 1000 * 60 * 10);
112
113
142 } 114 }
143 115
144 private void ReQueueEvent(PollServiceHttpRequest req) 116 private void ReQueueEvent(PollServiceHttpRequest req)
145 { 117 {
146 if (IsRunning) 118 if (m_running)
147 { 119 {
148 // delay the enqueueing for 100ms. There's no need to have the event 120 lock (m_retryRequests)
149 // actively on the queue 121 m_retryRequests.Enqueue(req);
150 Timer t = new Timer(self => {
151 ((Timer)self).Dispose();
152 m_requests.Enqueue(req);
153 });
154
155 t.Change(100, Timeout.Infinite);
156
157 } 122 }
158 } 123 }
159 124
160 public void Enqueue(PollServiceHttpRequest req) 125 public void Enqueue(PollServiceHttpRequest req)
161 { 126 {
162 if (IsRunning) 127 lock (m_bycontext)
163 { 128 {
164 if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) 129 Queue<PollServiceHttpRequest> ctxQeueue;
130 if (m_bycontext.TryGetValue(req, out ctxQeueue))
165 { 131 {
166 lock (m_longPollRequests) 132 ctxQeueue.Enqueue(req);
167 m_longPollRequests.Add(req);
168 } 133 }
169 else 134 else
170 m_requests.Enqueue(req); 135 {
136 ctxQeueue = new Queue<PollServiceHttpRequest>();
137 m_bycontext[req] = ctxQeueue;
138 EnqueueInt(req);
139 }
171 } 140 }
172 } 141 }
173 142
174 private void CheckLongPollThreads() 143 public void byContextDequeue(PollServiceHttpRequest req)
175 { 144 {
176 // The only purpose of this thread is to check the EQs for events. 145 Queue<PollServiceHttpRequest> ctxQeueue;
177 // If there are events, that thread will be placed in the "ready-to-serve" queue, m_requests. 146 lock (m_bycontext)
178 // If there are no events, that thread will be back to its "waiting" queue, m_longPollRequests.
179 // All other types of tasks (Inventory handlers, http-in, etc) don't have the long-poll nature,
180 // so if they aren't ready to be served by a worker thread (no events), they are placed
181 // directly back in the "ready-to-serve" queue by the worker thread.
182 while (IsRunning)
183 { 147 {
184 Thread.Sleep(500); 148 if (m_bycontext.TryGetValue(req, out ctxQeueue))
185 Watchdog.UpdateThread();
186
187// List<PollServiceHttpRequest> not_ready = new List<PollServiceHttpRequest>();
188 lock (m_longPollRequests)
189 { 149 {
190 if (m_longPollRequests.Count > 0 && IsRunning) 150 if (ctxQeueue.Count > 0)
191 { 151 {
192 List<PollServiceHttpRequest> ready = m_longPollRequests.FindAll(req => 152 PollServiceHttpRequest newreq = ctxQeueue.Dequeue();
193 (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id) || // there are events in this EQ 153 EnqueueInt(newreq);
194 (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) // no events, but timeout 154 }
195 ); 155 else
156 {
157 m_bycontext.Remove(req);
158 }
159 }
160 }
161 }
196 162
197 ready.ForEach(req =>
198 {
199 m_requests.Enqueue(req);
200 m_longPollRequests.Remove(req);
201 });
202 163
203 } 164 public void EnqueueInt(PollServiceHttpRequest req)
165 {
166 if (m_running)
167 {
168 if (req.PollServiceArgs.Type != PollServiceEventArgs.EventType.LongPoll)
169 {
170 m_requests.Enqueue(req);
171 }
172 else
173 {
174 lock (m_slowRequests)
175 m_slowRequests.Enqueue(req);
176 }
177 }
178 }
179
180 private void CheckRetries()
181 {
182 while (m_running)
183
184 {
185 Thread.Sleep(100); // let the world move .. back to faster rate
186 Watchdog.UpdateThread();
187 lock (m_retryRequests)
188 {
189 while (m_retryRequests.Count > 0 && m_running)
190 m_requests.Enqueue(m_retryRequests.Dequeue());
191 }
192 slowCount++;
193 if (slowCount >= 10)
194 {
195 slowCount = 0;
204 196
197 lock (m_slowRequests)
198 {
199 while (m_slowRequests.Count > 0 && m_running)
200 m_requests.Enqueue(m_slowRequests.Dequeue());
201 }
205 } 202 }
206 } 203 }
207 } 204 }
208 205
209 public void Stop() 206 public void Stop()
210 { 207 {
211 IsRunning = false; 208 m_running = false;
212// m_timeout = -10000; // cause all to expire 209
213 Thread.Sleep(1000); // let the world move 210 Thread.Sleep(1000); // let the world move
214 211
215 foreach (Thread t in m_workerThreads) 212 foreach (Thread t in m_workerThreads)
216 Watchdog.AbortThread(t.ManagedThreadId); 213 Watchdog.AbortThread(t.ManagedThreadId);
217 214
215 // any entry in m_bycontext should have a active request on the other queues
216 // so just delete contents to easy GC
217 foreach (Queue<PollServiceHttpRequest> qu in m_bycontext.Values)
218 qu.Clear();
219 m_bycontext.Clear();
220
221 try
222 {
223 foreach (PollServiceHttpRequest req in m_retryRequests)
224 {
225 req.DoHTTPstop(m_server);
226 }
227 }
228 catch
229 {
230 }
231
218 PollServiceHttpRequest wreq; 232 PollServiceHttpRequest wreq;
233 m_retryRequests.Clear();
219 234
220 lock (m_longPollRequests) 235 lock (m_slowRequests)
221 { 236 {
222 if (m_longPollRequests.Count > 0 && IsRunning) 237 while (m_slowRequests.Count > 0)
223 m_longPollRequests.ForEach(req => m_requests.Enqueue(req)); 238 m_requests.Enqueue(m_slowRequests.Dequeue());
239
224 } 240 }
225 241
226 while (m_requests.Count() > 0) 242 while (m_requests.Count() > 0)
@@ -228,16 +244,14 @@ namespace OpenSim.Framework.Servers.HttpServer
228 try 244 try
229 { 245 {
230 wreq = m_requests.Dequeue(0); 246 wreq = m_requests.Dequeue(0);
231 ResponsesProcessed++; 247 wreq.DoHTTPstop(m_server);
232 wreq.DoHTTPGruntWork( 248
233 m_server, wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id));
234 } 249 }
235 catch 250 catch
236 { 251 {
237 } 252 }
238 } 253 }
239 254
240 m_longPollRequests.Clear();
241 m_requests.Clear(); 255 m_requests.Clear();
242 } 256 }
243 257
@@ -245,87 +259,70 @@ namespace OpenSim.Framework.Servers.HttpServer
245 259
246 private void PoolWorkerJob() 260 private void PoolWorkerJob()
247 { 261 {
248 while (IsRunning) 262 while (m_running)
249 { 263 {
250 Watchdog.UpdateThread(); 264 PollServiceHttpRequest req = m_requests.Dequeue(5000);
251 WaitPerformResponse();
252 }
253 }
254
255 public void WaitPerformResponse()
256 {
257 PollServiceHttpRequest req = m_requests.Dequeue(5000);
258// m_log.DebugFormat("[YYY]: Dequeued {0}", (req == null ? "null" : req.PollServiceArgs.Type.ToString()));
259 265
260 if (req != null) 266 Watchdog.UpdateThread();
261 { 267 if (req != null)
262 try
263 { 268 {
264 if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) 269 try
265 { 270 {
266 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); 271 if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
267
268 if (responsedata == null)
269 return;
270
271 // This is the event queue.
272 // Even if we're not running we can still perform responses by explicit request.
273 if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll
274 || !PerformResponsesAsync)
275 { 272 {
276 try 273 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id);
277 { 274
278 ResponsesProcessed++; 275 if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) // This is the event queue
279 req.DoHTTPGruntWork(m_server, responsedata);
280 }
281 catch (ObjectDisposedException e) // Browser aborted before we could read body, server closed the stream
282 {
283 // Ignore it, no need to reply
284 m_log.Error(e);
285 }
286 }
287 else
288 {
289 m_threadPool.QueueWorkItem(x =>
290 { 276 {
291 try 277 try
292 { 278 {
293 ResponsesProcessed++;
294 req.DoHTTPGruntWork(m_server, responsedata); 279 req.DoHTTPGruntWork(m_server, responsedata);
280 byContextDequeue(req);
295 } 281 }
296 catch (ObjectDisposedException e) // Browser aborted before we could read body, server closed the stream 282 catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
297 { 283 {
298 // Ignore it, no need to reply 284 // Ignore it, no need to reply
299 m_log.Error(e);
300 } 285 }
301 catch (Exception e) 286 }
287 else
288 {
289 m_threadPool.QueueWorkItem(x =>
302 { 290 {
303 m_log.Error(e); 291 try
304 } 292 {
305 293 req.DoHTTPGruntWork(m_server, responsedata);
306 return null; 294 byContextDequeue(req);
307 }, null); 295 }
308 } 296 catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
309 } 297 {
310 else 298 // Ignore it, no need to reply
311 { 299 }
312 if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) 300
313 { 301 return null;
314 ResponsesProcessed++; 302 }, null);
315 req.DoHTTPGruntWork( 303 }
316 m_server, req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
317 } 304 }
318 else 305 else
319 { 306 {
320 ReQueueEvent(req); 307 if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
308 {
309 req.DoHTTPGruntWork(m_server,
310 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
311 byContextDequeue(req);
312 }
313 else
314 {
315 ReQueueEvent(req);
316 }
321 } 317 }
322 } 318 }
323 } 319 catch (Exception e)
324 catch (Exception e) 320 {
325 { 321 m_log.ErrorFormat("Exception in poll service thread: " + e.ToString());
326 m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); 322 }
327 } 323 }
328 } 324 }
329 } 325 }
326
330 } 327 }
331} \ No newline at end of file 328}
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs
index 07a09e6..b330384 100644
--- a/OpenSim/Framework/Servers/ServerBase.cs
+++ b/OpenSim/Framework/Servers/ServerBase.cs
@@ -871,7 +871,7 @@ namespace OpenSim.Framework.Servers
871 } 871 }
872 } 872 }
873 873
874 protected string GetVersionText() 874 public string GetVersionText()
875 { 875 {
876 return String.Format("Version: {0} (SIMULATION/{1} - SIMULATION/{2})", 876 return String.Format("Version: {0} (SIMULATION/{1} - SIMULATION/{2})",
877 m_version, VersionInfo.SimulationServiceVersionSupportedMin, VersionInfo.SimulationServiceVersionSupportedMax); 877 m_version, VersionInfo.SimulationServiceVersionSupportedMin, VersionInfo.SimulationServiceVersionSupportedMax);
diff --git a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
index 5c0e0df..1b47cc6 100644
--- a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
+++ b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
@@ -41,7 +41,327 @@ namespace OpenSim.Framework.Servers.Tests
41{ 41{
42 [TestFixture] 42 [TestFixture]
43 public class OSHttpTests : OpenSimTestCase 43 public class OSHttpTests : OpenSimTestCase
44 { 44 {
45 // we need an IHttpClientContext for our tests
46 public class TestHttpClientContext: IHttpClientContext
47 {
48 private bool _secured;
49 public bool IsSecured
50 {
51 get { return _secured; }
52 }
53 public bool Secured
54 {
55 get { return _secured; }
56 }
57
58 public TestHttpClientContext(bool secured)
59 {
60 _secured = secured;
61 }
62
63 public void Disconnect(SocketError error) {}
64 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body) {}
65 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason) {}
66 public void Respond(string body) {}
67 public void Send(byte[] buffer) {}
68 public void Send(byte[] buffer, int offset, int size) {}
69 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body, string contentType) {}
70 public void Close() { }
71 public bool EndWhenDone { get { return false;} set { return;}}
72
73 public HTTPNetworkContext GiveMeTheNetworkStreamIKnowWhatImDoing()
74 {
75 return new HTTPNetworkContext();
76 }
77
78 public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { };
79 /// <summary>
80 /// A request have been received in the context.
81 /// </summary>
82 public event EventHandler<RequestEventArgs> RequestReceived = delegate { };
83
84 public bool CanSend { get { return true; } }
85 public string RemoteEndPoint { get { return ""; } }
86 public string RemoteEndPointAddress { get { return ""; } }
87 public string RemoteEndPointPort { get { return ""; } }
88 }
89
90 public class TestHttpRequest: IHttpRequest
91 {
92 private string _uriPath;
93 public bool BodyIsComplete
94 {
95 get { return true; }
96 }
97 public string[] AcceptTypes
98 {
99 get {return _acceptTypes; }
100 }
101 private string[] _acceptTypes;
102 public Stream Body
103 {
104 get { return _body; }
105 set { _body = value;}
106 }
107 private Stream _body;
108 public ConnectionType Connection
109 {
110 get { return _connection; }
111 set { _connection = value; }
112 }
113 private ConnectionType _connection;
114 public int ContentLength
115 {
116 get { return _contentLength; }
117 set { _contentLength = value; }
118 }
119 private int _contentLength;
120 public NameValueCollection Headers
121 {
122 get { return _headers; }
123 }
124 private NameValueCollection _headers = new NameValueCollection();
125 public string HttpVersion
126 {
127 get { return _httpVersion; }
128 set { _httpVersion = value; }
129 }
130 private string _httpVersion = null;
131 public string Method
132 {
133 get { return _method; }
134 set { _method = value; }
135 }
136 private string _method = null;
137 public HttpInput QueryString
138 {
139 get { return _queryString; }
140 }
141 private HttpInput _queryString = null;
142 public Uri Uri
143 {
144 get { return _uri; }
145 set { _uri = value; }
146 }
147 private Uri _uri = null;
148 public string[] UriParts
149 {
150 get { return _uri.Segments; }
151 }
152 public HttpParam Param
153 {
154 get { return null; }
155 }
156 public HttpForm Form
157 {
158 get { return null; }
159 }
160 public bool IsAjax
161 {
162 get { return false; }
163 }
164 public RequestCookies Cookies
165 {
166 get { return null; }
167 }
168
169 public TestHttpRequest() {}
170
171 public TestHttpRequest(string contentEncoding, string contentType, string userAgent,
172 string remoteAddr, string remotePort, string[] acceptTypes,
173 ConnectionType connectionType, int contentLength, Uri uri)
174 {
175 _headers["content-encoding"] = contentEncoding;
176 _headers["content-type"] = contentType;
177 _headers["user-agent"] = userAgent;
178 _headers["remote_addr"] = remoteAddr;
179 _headers["remote_port"] = remotePort;
180
181 _acceptTypes = acceptTypes;
182 _connection = connectionType;
183 _contentLength = contentLength;
184 _uri = uri;
185 }
186
187 public void DecodeBody(FormDecoderProvider providers) {}
188 public void SetCookies(RequestCookies cookies) {}
189 public void AddHeader(string name, string value)
190 {
191 _headers.Add(name, value);
192 }
193 public int AddToBody(byte[] bytes, int offset, int length)
194 {
195 return 0;
196 }
197 public void Clear() {}
198
199 public object Clone()
200 {
201 TestHttpRequest clone = new TestHttpRequest();
202 clone._acceptTypes = _acceptTypes;
203 clone._connection = _connection;
204 clone._contentLength = _contentLength;
205 clone._uri = _uri;
206 clone._headers = new NameValueCollection(_headers);
207
208 return clone;
209 }
210 public IHttpResponse CreateResponse(IHttpClientContext context)
211 {
212 return new HttpResponse(context, this);
213 }
214 /// <summary>
215 /// Path and query (will be merged with the host header) and put in Uri
216 /// </summary>
217 /// <see cref="Uri"/>
218 public string UriPath
219 {
220 get { return _uriPath; }
221 set
222 {
223 _uriPath = value;
224
225 }
226 }
227
228 }
229
230 public class TestHttpResponse: IHttpResponse
231 {
232 public Stream Body
233 {
234 get { return _body; }
235
236 set { _body = value; }
237 }
238 private Stream _body;
239
240 public string ProtocolVersion
241 {
242 get { return _protocolVersion; }
243 set { _protocolVersion = value; }
244 }
245 private string _protocolVersion;
246
247 public bool Chunked
248 {
249 get { return _chunked; }
250
251 set { _chunked = value; }
252 }
253 private bool _chunked;
254
255 public ConnectionType Connection
256 {
257 get { return _connection; }
258
259 set { _connection = value; }
260 }
261 private ConnectionType _connection;
262
263 public Encoding Encoding
264 {
265 get { return _encoding; }
266
267 set { _encoding = value; }
268 }
269 private Encoding _encoding;
270
271 public int KeepAlive
272 {
273 get { return _keepAlive; }
274
275 set { _keepAlive = value; }
276 }
277 private int _keepAlive;
278
279 public HttpStatusCode Status
280 {
281 get { return _status; }
282
283 set { _status = value; }
284 }
285 private HttpStatusCode _status;
286
287 public string Reason
288 {
289 get { return _reason; }
290
291 set { _reason = value; }
292 }
293 private string _reason;
294
295 public long ContentLength
296 {
297 get { return _contentLength; }
298
299 set { _contentLength = value; }
300 }
301 private long _contentLength;
302
303 public string ContentType
304 {
305 get { return _contentType; }
306
307 set { _contentType = value; }
308 }
309 private string _contentType;
310
311 public bool HeadersSent
312 {
313 get { return _headersSent; }
314 }
315 private bool _headersSent;
316
317 public bool Sent
318 {
319 get { return _sent; }
320 }
321 private bool _sent;
322
323 public ResponseCookies Cookies
324 {
325 get { return _cookies; }
326 }
327 private ResponseCookies _cookies = null;
328
329 public TestHttpResponse()
330 {
331 _headersSent = false;
332 _sent = false;
333 }
334
335 public void AddHeader(string name, string value) {}
336 public void Send()
337 {
338 if (!_headersSent) SendHeaders();
339 if (_sent) throw new InvalidOperationException("stuff already sent");
340 _sent = true;
341 }
342
343 public void SendBody(byte[] buffer, int offset, int count)
344 {
345 if (!_headersSent) SendHeaders();
346 _sent = true;
347 }
348 public void SendBody(byte[] buffer)
349 {
350 if (!_headersSent) SendHeaders();
351 _sent = true;
352 }
353
354 public void SendHeaders()
355 {
356 if (_headersSent) throw new InvalidOperationException("headers already sent");
357 _headersSent = true;
358 }
359
360 public void Redirect(Uri uri) {}
361 public void Redirect(string url) {}
362 }
363
364
45 public OSHttpRequest req0; 365 public OSHttpRequest req0;
46 public OSHttpRequest req1; 366 public OSHttpRequest req1;
47 367
@@ -113,4 +433,4 @@ namespace OpenSim.Framework.Servers.Tests
113 Assert.That(rsp0.ContentType, Is.EqualTo("text/xml")); 433 Assert.That(rsp0.ContentType, Is.EqualTo("text/xml"));
114 } 434 }
115 } 435 }
116} \ No newline at end of file 436}
diff --git a/OpenSim/Framework/SimStats.cs b/OpenSim/Framework/SimStats.cs
index 3d8f32f..a811187 100644
--- a/OpenSim/Framework/SimStats.cs
+++ b/OpenSim/Framework/SimStats.cs
@@ -55,13 +55,19 @@ namespace OpenSim.Framework
55 get { return m_regionBlock; } 55 get { return m_regionBlock; }
56 } 56 }
57 private SimStatsPacket.RegionBlock m_regionBlock; 57 private SimStatsPacket.RegionBlock m_regionBlock;
58 58
59 public SimStatsPacket.StatBlock[] StatsBlock 59 public SimStatsPacket.StatBlock[] StatsBlock
60 { 60 {
61 get { return m_statsBlock; } 61 get { return m_statsBlock; }
62 } 62 }
63 private SimStatsPacket.StatBlock[] m_statsBlock; 63 private SimStatsPacket.StatBlock[] m_statsBlock;
64 64
65 public SimStatsPacket.StatBlock[] ExtraStatsBlock
66 {
67 get { return m_extraStatsBlock; }
68 }
69 private SimStatsPacket.StatBlock[] m_extraStatsBlock;
70
65 public uint RegionFlags 71 public uint RegionFlags
66 { 72 {
67 get { return m_regionFlags; } 73 get { return m_regionFlags; }
@@ -82,7 +88,8 @@ namespace OpenSim.Framework
82 88
83 public SimStats( 89 public SimStats(
84 uint regionX, uint regionY, uint regionFlags, uint objectCapacity, 90 uint regionX, uint regionY, uint regionFlags, uint objectCapacity,
85 SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock, UUID pRUUID) 91 SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock,
92 SimStatsPacket.StatBlock[] ExtraStatsBlock, UUID pRUUID)
86 { 93 {
87 regionUUID = pRUUID; 94 regionUUID = pRUUID;
88 m_regionX = regionX; 95 m_regionX = regionX;
@@ -91,6 +98,7 @@ namespace OpenSim.Framework
91 m_objectCapacity = objectCapacity; 98 m_objectCapacity = objectCapacity;
92 m_regionBlock = regionBlock; 99 m_regionBlock = regionBlock;
93 m_statsBlock = statsBlock; 100 m_statsBlock = statsBlock;
101 m_extraStatsBlock = ExtraStatsBlock;
94 } 102 }
95 } 103 }
96} 104}
diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs
index 8af2c41..2c20ef7 100644
--- a/OpenSim/Framework/TaskInventoryDictionary.cs
+++ b/OpenSim/Framework/TaskInventoryDictionary.cs
@@ -27,9 +27,13 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Threading;
31using System.Reflection;
30using System.Xml; 32using System.Xml;
33using System.Diagnostics;
31using System.Xml.Schema; 34using System.Xml.Schema;
32using System.Xml.Serialization; 35using System.Xml.Serialization;
36using log4net;
33using OpenMetaverse; 37using OpenMetaverse;
34 38
35namespace OpenSim.Framework 39namespace OpenSim.Framework
@@ -47,6 +51,180 @@ namespace OpenSim.Framework
47 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 52
49 private static XmlSerializer tiiSerializer = new XmlSerializer(typeof (TaskInventoryItem)); 53 private static XmlSerializer tiiSerializer = new XmlSerializer(typeof (TaskInventoryItem));
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 private Thread LockedByThread;
57// private string WriterStack;
58
59// private Dictionary<Thread, string> ReadLockers =
60// new Dictionary<Thread, string>();
61
62 /// <value>
63 /// An advanced lock for inventory data
64 /// </value>
65 private volatile System.Threading.ReaderWriterLockSlim m_itemLock = new System.Threading.ReaderWriterLockSlim();
66
67 /// <summary>
68 /// Are we readlocked by the calling thread?
69 /// </summary>
70 public bool IsReadLockedByMe()
71 {
72 if (m_itemLock.RecursiveReadCount > 0)
73 {
74 return true;
75 }
76 else
77 {
78 return false;
79 }
80 }
81
82 /// <summary>
83 /// Lock our inventory list for reading (many can read, one can write)
84 /// </summary>
85 public void LockItemsForRead(bool locked)
86 {
87 if (locked)
88 {
89 if (m_itemLock.IsWriteLockHeld && LockedByThread != null)
90 {
91 if (!LockedByThread.IsAlive)
92 {
93 //Locked by dead thread, reset.
94 m_itemLock = new System.Threading.ReaderWriterLockSlim();
95 }
96 }
97
98 if (m_itemLock.RecursiveReadCount > 0)
99 {
100 m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
101 try
102 {
103 // That call stack is useful for end users only. RealProgrammers need a full dump. Commented.
104 // StackTrace stackTrace = new StackTrace(); // get call stack
105 // StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames)
106 //
107 // // write call stack method names
108 // foreach (StackFrame stackFrame in stackFrames)
109 // {
110 // m_log.Error("[SceneObjectGroup.m_parts] "+(stackFrame.GetMethod().Name)); // write method name
111 // }
112
113 // The below is far more useful
114// System.Console.WriteLine("------------------------------------------");
115// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
116// System.Console.WriteLine("------------------------------------------");
117// foreach (KeyValuePair<Thread, string> kvp in ReadLockers)
118// {
119// System.Console.WriteLine("Locker name {0} call stack:\n" + kvp.Value, kvp.Key.Name);
120// System.Console.WriteLine("------------------------------------------");
121// }
122 }
123 catch
124 {}
125 m_itemLock.ExitReadLock();
126 }
127 if (m_itemLock.RecursiveWriteCount > 0)
128 {
129 m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed.");
130// try
131// {
132// System.Console.WriteLine("------------------------------------------");
133// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
134// System.Console.WriteLine("------------------------------------------");
135// System.Console.WriteLine("Locker's call stack:\n" + WriterStack);
136// System.Console.WriteLine("------------------------------------------");
137// }
138// catch
139// {}
140 m_itemLock.ExitWriteLock();
141 }
142
143 while (!m_itemLock.TryEnterReadLock(60000))
144 {
145 m_log.Error("Thread lock detected while trying to aquire READ lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
146 //if (m_itemLock.IsWriteLockHeld)
147 //{
148 m_itemLock = new System.Threading.ReaderWriterLockSlim();
149// System.Console.WriteLine("------------------------------------------");
150// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
151// System.Console.WriteLine("------------------------------------------");
152// System.Console.WriteLine("Locker's call stack:\n" + WriterStack);
153// System.Console.WriteLine("------------------------------------------");
154// LockedByThread = null;
155// ReadLockers.Clear();
156 //}
157 }
158// ReadLockers[Thread.CurrentThread] = Environment.StackTrace;
159 }
160 else
161 {
162 if (m_itemLock.RecursiveReadCount>0)
163 {
164 m_itemLock.ExitReadLock();
165 }
166// if (m_itemLock.RecursiveReadCount == 0)
167// ReadLockers.Remove(Thread.CurrentThread);
168 }
169 }
170
171 /// <summary>
172 /// Lock our inventory list for writing (many can read, one can write)
173 /// </summary>
174 public void LockItemsForWrite(bool locked)
175 {
176 if (locked)
177 {
178 //Enter a write lock, wait indefinately for one to open.
179 if (m_itemLock.RecursiveReadCount > 0)
180 {
181 m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
182 m_itemLock.ExitReadLock();
183 }
184 if (m_itemLock.RecursiveWriteCount > 0)
185 {
186 m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed.");
187
188 m_itemLock.ExitWriteLock();
189 }
190 while (!m_itemLock.TryEnterWriteLock(60000))
191 {
192 if (m_itemLock.IsWriteLockHeld)
193 {
194 m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
195// System.Console.WriteLine("------------------------------------------");
196// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
197// System.Console.WriteLine("------------------------------------------");
198// System.Console.WriteLine("Locker's call stack:\n" + WriterStack);
199// System.Console.WriteLine("------------------------------------------");
200 }
201 else
202 {
203 m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by a reader. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
204// System.Console.WriteLine("------------------------------------------");
205// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
206// System.Console.WriteLine("------------------------------------------");
207// foreach (KeyValuePair<Thread, string> kvp in ReadLockers)
208// {
209// System.Console.WriteLine("Locker name {0} call stack:\n" + kvp.Value, kvp.Key.Name);
210// System.Console.WriteLine("------------------------------------------");
211// }
212 }
213 m_itemLock = new System.Threading.ReaderWriterLockSlim();
214// ReadLockers.Clear();
215 }
216
217 LockedByThread = Thread.CurrentThread;
218// WriterStack = Environment.StackTrace;
219 }
220 else
221 {
222 if (m_itemLock.RecursiveWriteCount > 0)
223 {
224 m_itemLock.ExitWriteLock();
225 }
226 }
227 }
50 228
51 #region ICloneable Members 229 #region ICloneable Members
52 230
@@ -54,14 +232,13 @@ namespace OpenSim.Framework
54 { 232 {
55 TaskInventoryDictionary clone = new TaskInventoryDictionary(); 233 TaskInventoryDictionary clone = new TaskInventoryDictionary();
56 234
57 lock (this) 235 m_itemLock.EnterReadLock();
236 foreach (UUID uuid in Keys)
58 { 237 {
59 foreach (UUID uuid in Keys) 238 clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone());
60 {
61 clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone());
62 }
63 } 239 }
64 240 m_itemLock.ExitReadLock();
241
65 return clone; 242 return clone;
66 } 243 }
67 244
diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs
index 307cb75..2ec4bd1 100644
--- a/OpenSim/Framework/TaskInventoryItem.cs
+++ b/OpenSim/Framework/TaskInventoryItem.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Framework
72 private UUID _loadedID = UUID.Zero; 72 private UUID _loadedID = UUID.Zero;
73 73
74 private bool _ownerChanged = false; 74 private bool _ownerChanged = false;
75 75
76 public UUID AssetID { 76 public UUID AssetID {
77 get { 77 get {
78 return _assetID; 78 return _assetID;
diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs
index 6b1be4e..d2e1c6a 100644
--- a/OpenSim/Framework/TerrainData.cs
+++ b/OpenSim/Framework/TerrainData.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.IO.Compression;
31using System.Reflection; 32using System.Reflection;
32 33
33using OpenMetaverse; 34using OpenMetaverse;
@@ -48,6 +49,7 @@ namespace OpenSim.Framework
48 49
49 public abstract float this[int x, int y] { get; set; } 50 public abstract float this[int x, int y] { get; set; }
50 // Someday terrain will have caves 51 // Someday terrain will have caves
52 // at most holes :p
51 public abstract float this[int x, int y, int z] { get; set; } 53 public abstract float this[int x, int y, int z] { get; set; }
52 54
53 public abstract bool IsTaintedAt(int xx, int yy); 55 public abstract bool IsTaintedAt(int xx, int yy);
@@ -72,8 +74,8 @@ namespace OpenSim.Framework
72 return new HeightmapTerrainData(pSizeX, pSizeY, pSizeZ, pFormatCode, pBlob); 74 return new HeightmapTerrainData(pSizeX, pSizeY, pSizeZ, pFormatCode, pBlob);
73 } 75 }
74 76
75 // return a special compressed representation of the heightmap in ints 77 // return a special compressed representation of the heightmap in ushort
76 public abstract int[] GetCompressedMap(); 78 public abstract float[] GetCompressedMap();
77 public abstract float CompressionFactor { get; } 79 public abstract float CompressionFactor { get; }
78 80
79 public abstract float[] GetFloatsSerialized(); 81 public abstract float[] GetFloatsSerialized();
@@ -94,14 +96,18 @@ namespace OpenSim.Framework
94 { 96 {
95 // Terrain is 'double[256,256]' 97 // Terrain is 'double[256,256]'
96 Legacy256 = 11, 98 Legacy256 = 11,
99
97 // Terrain is 'int32, int32, float[,]' where the ints are X and Y dimensions 100 // Terrain is 'int32, int32, float[,]' where the ints are X and Y dimensions
98 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256. 101 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256.
99 Variable2D = 22, 102 Variable2D = 22,
103 Variable2DGzip = 23,
104
100 // Terrain is 'int32, int32, int32, int16[]' where the ints are X and Y dimensions 105 // Terrain is 'int32, int32, int32, int16[]' where the ints are X and Y dimensions
101 // and third int is the 'compression factor'. The heights are compressed as 106 // and third int is the 'compression factor'. The heights are compressed as
102 // "int compressedHeight = (int)(height * compressionFactor);" 107 // "ushort compressedHeight = (ushort)(height * compressionFactor);"
103 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256. 108 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256.
104 Compressed2D = 27, 109 Compressed2D = 27,
110
105 // A revision that is not listed above or any revision greater than this value is 'Legacy256'. 111 // A revision that is not listed above or any revision greater than this value is 'Legacy256'.
106 RevisionHigh = 1234 112 RevisionHigh = 1234
107 } 113 }
@@ -109,7 +115,7 @@ namespace OpenSim.Framework
109 // Version of terrain that is a heightmap. 115 // Version of terrain that is a heightmap.
110 // This should really be 'LLOptimizedHeightmapTerrainData' as it includes knowledge 116 // This should really be 'LLOptimizedHeightmapTerrainData' as it includes knowledge
111 // of 'patches' which are 16x16 terrain areas which can be sent separately to the viewer. 117 // of 'patches' which are 16x16 terrain areas which can be sent separately to the viewer.
112 // The heighmap is kept as an array of integers. The integer values are converted to 118 // The heighmap is kept as an array of ushorts. The ushort values are converted to
113 // and from floats by TerrainCompressionFactor. 119 // and from floats by TerrainCompressionFactor.
114 public class HeightmapTerrainData : TerrainData 120 public class HeightmapTerrainData : TerrainData
115 { 121 {
@@ -119,12 +125,12 @@ namespace OpenSim.Framework
119 // TerrainData.this[x, y] 125 // TerrainData.this[x, y]
120 public override float this[int x, int y] 126 public override float this[int x, int y]
121 { 127 {
122 get { return FromCompressedHeight(m_heightmap[x, y]); } 128 get { return m_heightmap[x, y]; }
123 set { 129 set
124 int newVal = ToCompressedHeight(value); 130 {
125 if (m_heightmap[x, y] != newVal) 131 if (m_heightmap[x, y] != value)
126 { 132 {
127 m_heightmap[x, y] = newVal; 133 m_heightmap[x, y] = value;
128 m_taint[x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize] = true; 134 m_taint[x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize] = true;
129 } 135 }
130 } 136 }
@@ -164,10 +170,9 @@ namespace OpenSim.Framework
164 // TerrainData.ClearLand(float) 170 // TerrainData.ClearLand(float)
165 public override void ClearLand(float pHeight) 171 public override void ClearLand(float pHeight)
166 { 172 {
167 int flatHeight = ToCompressedHeight(pHeight);
168 for (int xx = 0; xx < SizeX; xx++) 173 for (int xx = 0; xx < SizeX; xx++)
169 for (int yy = 0; yy < SizeY; yy++) 174 for (int yy = 0; yy < SizeY; yy++)
170 m_heightmap[xx, yy] = flatHeight; 175 m_heightmap[xx, yy] = pHeight;
171 } 176 }
172 177
173 // Return 'true' of the patch that contains these region coordinates has been modified. 178 // Return 'true' of the patch that contains these region coordinates has been modified.
@@ -177,13 +182,15 @@ namespace OpenSim.Framework
177 { 182 {
178 int tx = xx / Constants.TerrainPatchSize; 183 int tx = xx / Constants.TerrainPatchSize;
179 int ty = yy / Constants.TerrainPatchSize; 184 int ty = yy / Constants.TerrainPatchSize;
180 bool ret = m_taint[tx, ty]; 185 bool ret = m_taint[tx, ty];
181 if (ret && clearOnTest) 186 if (ret && clearOnTest)
182 m_taint[tx, ty] = false; 187 m_taint[tx, ty] = false;
183 return ret; 188 return ret;
184 } 189 }
185 190
186 // Old form that clears the taint flag when we check it. 191 // Old form that clears the taint flag when we check it.
192 // ubit: this dangerus naming should be only check without clear
193 // keeping for old modules outthere
187 public override bool IsTaintedAt(int xx, int yy) 194 public override bool IsTaintedAt(int xx, int yy)
188 { 195 {
189 return IsTaintedAt(xx, yy, true /* clearOnTest */); 196 return IsTaintedAt(xx, yy, true /* clearOnTest */);
@@ -202,8 +209,10 @@ namespace OpenSim.Framework
202 } 209 }
203 else 210 else
204 { 211 {
205 DBRevisionCode = (int)DBTerrainRevision.Compressed2D; 212 DBRevisionCode = (int)DBTerrainRevision.Variable2DGzip;
206 blob = ToCompressedTerrainSerialization(); 213// DBRevisionCode = (int)DBTerrainRevision.Variable2D;
214 blob = ToCompressedTerrainSerializationV2DGzip();
215// blob = ToCompressedTerrainSerializationV2D();
207 ret = true; 216 ret = true;
208 } 217 }
209 return ret; 218 return ret;
@@ -214,9 +223,9 @@ namespace OpenSim.Framework
214 public override float CompressionFactor { get { return m_compressionFactor; } } 223 public override float CompressionFactor { get { return m_compressionFactor; } }
215 224
216 // TerrainData.GetCompressedMap 225 // TerrainData.GetCompressedMap
217 public override int[] GetCompressedMap() 226 public override float[] GetCompressedMap()
218 { 227 {
219 int[] newMap = new int[SizeX * SizeY]; 228 float[] newMap = new float[SizeX * SizeY];
220 229
221 int ind = 0; 230 int ind = 0;
222 for (int xx = 0; xx < SizeX; xx++) 231 for (int xx = 0; xx < SizeX; xx++)
@@ -230,7 +239,7 @@ namespace OpenSim.Framework
230 public override TerrainData Clone() 239 public override TerrainData Clone()
231 { 240 {
232 HeightmapTerrainData ret = new HeightmapTerrainData(SizeX, SizeY, SizeZ); 241 HeightmapTerrainData ret = new HeightmapTerrainData(SizeX, SizeY, SizeZ);
233 ret.m_heightmap = (int[,])this.m_heightmap.Clone(); 242 ret.m_heightmap = (float[,])this.m_heightmap.Clone();
234 return ret; 243 return ret;
235 } 244 }
236 245
@@ -247,7 +256,7 @@ namespace OpenSim.Framework
247 for (int jj = 0; jj < SizeY; jj++) 256 for (int jj = 0; jj < SizeY; jj++)
248 for (int ii = 0; ii < SizeX; ii++) 257 for (int ii = 0; ii < SizeX; ii++)
249 { 258 {
250 heights[idx++] = FromCompressedHeight(m_heightmap[ii, jj]); 259 heights[idx++] = m_heightmap[ii, jj];
251 } 260 }
252 261
253 return heights; 262 return heights;
@@ -259,7 +268,7 @@ namespace OpenSim.Framework
259 double[,] ret = new double[SizeX, SizeY]; 268 double[,] ret = new double[SizeX, SizeY];
260 for (int xx = 0; xx < SizeX; xx++) 269 for (int xx = 0; xx < SizeX; xx++)
261 for (int yy = 0; yy < SizeY; yy++) 270 for (int yy = 0; yy < SizeY; yy++)
262 ret[xx, yy] = FromCompressedHeight(m_heightmap[xx, yy]); 271 ret[xx, yy] = (double)m_heightmap[xx, yy];
263 272
264 return ret; 273 return ret;
265 } 274 }
@@ -267,19 +276,40 @@ namespace OpenSim.Framework
267 276
268 // ============================================================= 277 // =============================================================
269 278
270 private int[,] m_heightmap; 279 private float[,] m_heightmap;
271 // Remember subregions of the heightmap that has changed. 280 // Remember subregions of the heightmap that has changed.
272 private bool[,] m_taint; 281 private bool[,] m_taint;
273 282
274 // To save space (especially for large regions), keep the height as a short integer
275 // that is coded as the float height times the compression factor (usually '100' 283 // that is coded as the float height times the compression factor (usually '100'
276 // to make for two decimal points). 284 // to make for two decimal points).
277 public int ToCompressedHeight(double pHeight) 285 public short ToCompressedHeightshort(float pHeight)
286 {
287 // clamp into valid range
288 pHeight *= CompressionFactor;
289 if (pHeight < short.MinValue)
290 return short.MinValue;
291 else if (pHeight > short.MaxValue)
292 return short.MaxValue;
293 return (short)pHeight;
294 }
295
296 public ushort ToCompressedHeightushort(float pHeight)
278 { 297 {
279 return (int)(pHeight * CompressionFactor); 298 // clamp into valid range
299 pHeight *= CompressionFactor;
300 if (pHeight < ushort.MinValue)
301 return ushort.MinValue;
302 else if (pHeight > ushort.MaxValue)
303 return ushort.MaxValue;
304 return (ushort)pHeight;
280 } 305 }
281 306
282 public float FromCompressedHeight(int pHeight) 307 public float FromCompressedHeight(short pHeight)
308 {
309 return ((float)pHeight) / CompressionFactor;
310 }
311
312 public float FromCompressedHeight(ushort pHeight)
283 { 313 {
284 return ((float)pHeight) / CompressionFactor; 314 return ((float)pHeight) / CompressionFactor;
285 } 315 }
@@ -293,12 +323,12 @@ namespace OpenSim.Framework
293 SizeZ = (int)Constants.RegionHeight; 323 SizeZ = (int)Constants.RegionHeight;
294 m_compressionFactor = 100.0f; 324 m_compressionFactor = 100.0f;
295 325
296 m_heightmap = new int[SizeX, SizeY]; 326 m_heightmap = new float[SizeX, SizeY];
297 for (int ii = 0; ii < SizeX; ii++) 327 for (int ii = 0; ii < SizeX; ii++)
298 { 328 {
299 for (int jj = 0; jj < SizeY; jj++) 329 for (int jj = 0; jj < SizeY; jj++)
300 { 330 {
301 m_heightmap[ii, jj] = ToCompressedHeight(pTerrain[ii, jj]); 331 m_heightmap[ii, jj] = (float)pTerrain[ii, jj];
302 332
303 } 333 }
304 } 334 }
@@ -315,14 +345,15 @@ namespace OpenSim.Framework
315 SizeY = pY; 345 SizeY = pY;
316 SizeZ = pZ; 346 SizeZ = pZ;
317 m_compressionFactor = 100.0f; 347 m_compressionFactor = 100.0f;
318 m_heightmap = new int[SizeX, SizeY]; 348 m_heightmap = new float[SizeX, SizeY];
319 m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize]; 349 m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize];
320 // m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); 350 // m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ);
321 ClearTaint(); 351 ClearTaint();
322 ClearLand(0f); 352 ClearLand(0f);
323 } 353 }
324 354
325 public HeightmapTerrainData(int[] cmap, float pCompressionFactor, int pX, int pY, int pZ) : this(pX, pY, pZ) 355 public HeightmapTerrainData(float[] cmap, float pCompressionFactor, int pX, int pY, int pZ)
356 : this(pX, pY, pZ)
326 { 357 {
327 m_compressionFactor = pCompressionFactor; 358 m_compressionFactor = pCompressionFactor;
328 int ind = 0; 359 int ind = 0;
@@ -333,12 +364,22 @@ namespace OpenSim.Framework
333 } 364 }
334 365
335 // Create a heighmap from a database blob 366 // Create a heighmap from a database blob
336 public HeightmapTerrainData(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob) : this(pSizeX, pSizeY, pSizeZ) 367 public HeightmapTerrainData(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob)
368 : this(pSizeX, pSizeY, pSizeZ)
337 { 369 {
338 switch ((DBTerrainRevision)pFormatCode) 370 switch ((DBTerrainRevision)pFormatCode)
339 { 371 {
372 case DBTerrainRevision.Variable2DGzip:
373 FromCompressedTerrainSerializationV2DGZip(pBlob);
374 m_log.DebugFormat("{0} HeightmapTerrainData create from Variable2DGzip serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY);
375 break;
376
377 case DBTerrainRevision.Variable2D:
378 FromCompressedTerrainSerializationV2D(pBlob);
379 m_log.DebugFormat("{0} HeightmapTerrainData create from Variable2D serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY);
380 break;
340 case DBTerrainRevision.Compressed2D: 381 case DBTerrainRevision.Compressed2D:
341 FromCompressedTerrainSerialization(pBlob); 382 FromCompressedTerrainSerialization2D(pBlob);
342 m_log.DebugFormat("{0} HeightmapTerrainData create from Compressed2D serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY); 383 m_log.DebugFormat("{0} HeightmapTerrainData create from Compressed2D serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY);
343 break; 384 break;
344 default: 385 default:
@@ -373,50 +414,116 @@ namespace OpenSim.Framework
373 return ret; 414 return ret;
374 } 415 }
375 416
376 // Just create an array of doubles. Presumes the caller implicitly knows the size. 417 // Presumes the caller implicitly knows the size.
377 public void FromLegacyTerrainSerialization(byte[] pBlob) 418 public void FromLegacyTerrainSerialization(byte[] pBlob)
378 { 419 {
379 // In case database info doesn't match real terrain size, initialize the whole terrain. 420 // In case database info doesn't match real terrain size, initialize the whole terrain.
380 ClearLand(); 421 ClearLand();
381 422
382 using (MemoryStream mstr = new MemoryStream(pBlob)) 423 try
383 { 424 {
384 using (BinaryReader br = new BinaryReader(mstr)) 425 using (MemoryStream mstr = new MemoryStream(pBlob))
385 { 426 {
386 for (int xx = 0; xx < (int)Constants.RegionSize; xx++) 427 using (BinaryReader br = new BinaryReader(mstr))
387 { 428 {
388 for (int yy = 0; yy < (int)Constants.RegionSize; yy++) 429 for (int xx = 0; xx < (int)Constants.RegionSize; xx++)
389 { 430 {
390 float val = (float)br.ReadDouble(); 431 for (int yy = 0; yy < (int)Constants.RegionSize; yy++)
391 if (xx < SizeX && yy < SizeY) 432 {
392 m_heightmap[xx, yy] = ToCompressedHeight(val); 433 float val = (float)br.ReadDouble();
434
435 if (xx < SizeX && yy < SizeY)
436 m_heightmap[xx, yy] = val;
437 }
393 } 438 }
394 } 439 }
395 } 440 }
396 ClearTaint();
397 } 441 }
442 catch
443 {
444 ClearLand();
445 }
446 ClearTaint();
398 } 447 }
399 448
400 // See the reader below. 449
401 public Array ToCompressedTerrainSerialization() 450 // stores as variable2D
451 // int32 sizeX
452 // int32 sizeY
453 // float[,] array
454
455 public Array ToCompressedTerrainSerializationV2D()
402 { 456 {
403 Array ret = null; 457 Array ret = null;
404 using (MemoryStream str = new MemoryStream((3 * sizeof(Int32)) + (SizeX * SizeY * sizeof(Int16)))) 458 try
405 { 459 {
406 using (BinaryWriter bw = new BinaryWriter(str)) 460 using (MemoryStream str = new MemoryStream((2 * sizeof(Int32)) + (SizeX * SizeY * sizeof(float))))
461 {
462 using (BinaryWriter bw = new BinaryWriter(str))
463 {
464 bw.Write((Int32)SizeX);
465 bw.Write((Int32)SizeY);
466 for (int yy = 0; yy < SizeY; yy++)
467 for (int xx = 0; xx < SizeX; xx++)
468 {
469 // reduce to 1cm resolution
470 float val = (float)Math.Round(m_heightmap[xx, yy],2,MidpointRounding.ToEven);
471 bw.Write(val);
472 }
473 }
474 ret = str.ToArray();
475 }
476 }
477 catch
478 {
479
480 }
481
482 m_log.DebugFormat("{0} V2D {1} bytes",
483 LogHeader, ret.Length);
484
485 return ret;
486 }
487
488 // as above with Gzip compression
489 public Array ToCompressedTerrainSerializationV2DGzip()
490 {
491 Array ret = null;
492 try
493 {
494 using (MemoryStream inp = new MemoryStream((2 * sizeof(Int32)) + (SizeX * SizeY * sizeof(float))))
407 { 495 {
408 bw.Write((Int32)DBTerrainRevision.Compressed2D); 496 using (BinaryWriter bw = new BinaryWriter(inp))
409 bw.Write((Int32)SizeX); 497 {
410 bw.Write((Int32)SizeY); 498 bw.Write((Int32)SizeX);
411 bw.Write((Int32)CompressionFactor); 499 bw.Write((Int32)SizeY);
412 for (int yy = 0; yy < SizeY; yy++) 500 for (int yy = 0; yy < SizeY; yy++)
413 for (int xx = 0; xx < SizeX; xx++) 501 for (int xx = 0; xx < SizeX; xx++)
502 {
503 bw.Write((float)m_heightmap[xx, yy]);
504 }
505
506 bw.Flush();
507 inp.Seek(0, SeekOrigin.Begin);
508
509 using (MemoryStream outputStream = new MemoryStream())
414 { 510 {
415 bw.Write((Int16)m_heightmap[xx, yy]); 511 using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress))
512 {
513 inp.CopyStream(compressionStream, int.MaxValue);
514 compressionStream.Close();
515 ret = outputStream.ToArray();
516 }
416 } 517 }
518 }
417 } 519 }
418 ret = str.ToArray();
419 } 520 }
521 catch
522 {
523
524 }
525 m_log.DebugFormat("{0} V2DGzip {1} bytes",
526 LogHeader, ret.Length);
420 return ret; 527 return ret;
421 } 528 }
422 529
@@ -426,7 +533,7 @@ namespace OpenSim.Framework
426 // the forth int is the compression factor for the following int16s 533 // the forth int is the compression factor for the following int16s
427 // This is just sets heightmap info. The actual size of the region was set on this instance's 534 // This is just sets heightmap info. The actual size of the region was set on this instance's
428 // creation and any heights not initialized by theis blob are set to the default height. 535 // creation and any heights not initialized by theis blob are set to the default height.
429 public void FromCompressedTerrainSerialization(byte[] pBlob) 536 public void FromCompressedTerrainSerialization2D(byte[] pBlob)
430 { 537 {
431 Int32 hmFormatCode, hmSizeX, hmSizeY, hmCompressionFactor; 538 Int32 hmFormatCode, hmSizeX, hmSizeY, hmCompressionFactor;
432 539
@@ -448,7 +555,7 @@ namespace OpenSim.Framework
448 { 555 {
449 for (int xx = 0; xx < hmSizeX; xx++) 556 for (int xx = 0; xx < hmSizeX; xx++)
450 { 557 {
451 Int16 val = br.ReadInt16(); 558 float val = FromCompressedHeight(br.ReadInt16());
452 if (xx < SizeX && yy < SizeY) 559 if (xx < SizeX && yy < SizeY)
453 m_heightmap[xx, yy] = val; 560 m_heightmap[xx, yy] = val;
454 } 561 }
@@ -456,9 +563,112 @@ namespace OpenSim.Framework
456 } 563 }
457 ClearTaint(); 564 ClearTaint();
458 565
459 m_log.InfoFormat("{0} Read compressed 2d heightmap. Heightmap size=<{1},{2}>. Region size=<{3},{4}>. CompFact={5}", 566 m_log.DebugFormat("{0} Read (compressed2D) heightmap. Heightmap size=<{1},{2}>. Region size=<{3},{4}>. CompFact={5}",
460 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor); 567 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor);
461 } 568 }
462 } 569 }
570
571 // Initialize heightmap from blob consisting of:
572 // int32, int32, int32, float[]
573 // where the first int32 is format code, next two int32s are the X and y of heightmap data
574 // This is just sets heightmap info. The actual size of the region was set on this instance's
575 // creation and any heights not initialized by theis blob are set to the default height.
576 public void FromCompressedTerrainSerializationV2D(byte[] pBlob)
577 {
578 Int32 hmSizeX, hmSizeY;
579 try
580 {
581 using (MemoryStream mstr = new MemoryStream(pBlob))
582 {
583 using (BinaryReader br = new BinaryReader(mstr))
584 {
585 hmSizeX = br.ReadInt32();
586 hmSizeY = br.ReadInt32();
587
588 // In case database info doesn't match real terrain size, initialize the whole terrain.
589 ClearLand();
590
591 for (int yy = 0; yy < hmSizeY; yy++)
592 {
593 for (int xx = 0; xx < hmSizeX; xx++)
594 {
595 float val = br.ReadSingle();
596 if (xx < SizeX && yy < SizeY)
597 m_heightmap[xx, yy] = val;
598 }
599 }
600 }
601 }
602 }
603 catch (Exception e)
604 {
605 ClearTaint();
606 m_log.ErrorFormat("{0} 2D error: {1} - terrain may be damaged",
607 LogHeader, e.Message);
608 return;
609 }
610 ClearTaint();
611
612 m_log.DebugFormat("{0} V2D Heightmap size=<{1},{2}>. Region size=<{3},{4}>",
613 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY);
614
615 }
616
617 // as above but Gzip compressed
618 public void FromCompressedTerrainSerializationV2DGZip(byte[] pBlob)
619 {
620 m_log.InfoFormat("{0} VD2Gzip {1} bytes input",
621 LogHeader, pBlob.Length);
622
623 Int32 hmSizeX, hmSizeY;
624
625 try
626 {
627 using (MemoryStream outputStream = new MemoryStream())
628 {
629 using (MemoryStream inputStream = new MemoryStream(pBlob))
630 {
631 using (GZipStream decompressionStream = new GZipStream(inputStream, CompressionMode.Decompress))
632 {
633 decompressionStream.Flush();
634 decompressionStream.CopyTo(outputStream);
635 }
636 }
637
638 outputStream.Seek(0, SeekOrigin.Begin);
639
640 using (BinaryReader br = new BinaryReader(outputStream))
641 {
642 hmSizeX = br.ReadInt32();
643 hmSizeY = br.ReadInt32();
644
645 // In case database info doesn't match real terrain size, initialize the whole terrain.
646 ClearLand();
647
648 for (int yy = 0; yy < hmSizeY; yy++)
649 {
650 for (int xx = 0; xx < hmSizeX; xx++)
651 {
652 float val = br.ReadSingle();
653 if (xx < SizeX && yy < SizeY)
654 m_heightmap[xx, yy] = val;
655 }
656 }
657 }
658 }
659 }
660 catch( Exception e)
661 {
662 ClearTaint();
663 m_log.ErrorFormat("{0} V2DGzip error: {1} - terrain may be damaged",
664 LogHeader, e.Message);
665 return;
666 }
667
668 ClearTaint();
669 m_log.DebugFormat("{0} V2DGzip. Heightmap size=<{1},{2}>. Region size=<{3},{4}>",
670 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY);
671
672 }
463 } 673 }
464} 674}
diff --git a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
index 95e9439..e8ae728 100644
--- a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
+++ b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
@@ -311,8 +311,9 @@ namespace OpenSim.Framework.Tests
311 Agent1Data.SessionID = SessionId; 311 Agent1Data.SessionID = SessionId;
312 Agent1Data.startpos = StartPos; 312 Agent1Data.startpos = StartPos;
313 313
314 EntityTransferContext ctx = new EntityTransferContext();
314 OSDMap map2; 315 OSDMap map2;
315 OSDMap map = Agent1Data.PackAgentCircuitData(); 316 OSDMap map = Agent1Data.PackAgentCircuitData(ctx);
316 try 317 try
317 { 318 {
318 string str = OSDParser.SerializeJsonString(map); 319 string str = OSDParser.SerializeJsonString(map);
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
index 3f0a031..d8072c7 100644
--- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
+++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
@@ -116,7 +116,8 @@ namespace OpenSim.Framework.Tests
116 position2 = new AgentPosition(); 116 position2 = new AgentPosition();
117 117
118 Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition"); 118 Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition");
119 position2.Unpack(position1.Pack(), null); 119 EntityTransferContext ctx = new EntityTransferContext();
120 position2.Unpack(position1.Pack(ctx), null, ctx);
120 121
121 Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed"); 122 Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed");
122 Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed"); 123 Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed");
@@ -218,12 +219,12 @@ namespace OpenSim.Framework.Tests
218 BannedHostNameMask = string.Empty, 219 BannedHostNameMask = string.Empty,
219 BannedUserID = bannedUserId} 220 BannedUserID = bannedUserId}
220 ); 221 );
221 Assert.IsTrue(es.IsBanned(bannedUserId), "User Should be banned but is not."); 222 Assert.IsTrue(es.IsBanned(bannedUserId, 32), "User Should be banned but is not.");
222 Assert.IsFalse(es.IsBanned(UUID.Zero), "User Should not be banned but is."); 223 Assert.IsFalse(es.IsBanned(UUID.Zero, 32), "User Should not be banned but is.");
223 224
224 es.RemoveBan(bannedUserId); 225 es.RemoveBan(bannedUserId);
225 226
226 Assert.IsFalse(es.IsBanned(bannedUserId), "User Should not be banned but is."); 227 Assert.IsFalse(es.IsBanned(bannedUserId, 32), "User Should not be banned but is.");
227 228
228 es.AddEstateManager(UUID.Zero); 229 es.AddEstateManager(UUID.Zero);
229 230
@@ -305,4 +306,4 @@ namespace OpenSim.Framework.Tests
305 306
306 } 307 }
307 } 308 }
308} \ No newline at end of file 309}
diff --git a/OpenSim/Framework/ThrottleOutPacketType.cs b/OpenSim/Framework/ThrottleOutPacketType.cs
index ca4b126..87899f0 100644
--- a/OpenSim/Framework/ThrottleOutPacketType.cs
+++ b/OpenSim/Framework/ThrottleOutPacketType.cs
@@ -47,6 +47,8 @@ namespace OpenSim.Framework
47 Texture = 5, 47 Texture = 5,
48 /// <summary>Non-texture assets</summary> 48 /// <summary>Non-texture assets</summary>
49 Asset = 6, 49 Asset = 6,
50
51 HighPriority = 128,
50 } 52 }
51 53
52 [Flags] 54 [Flags]
diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs
index 266ccf0..f7069a5 100644
--- a/OpenSim/Framework/UserProfileData.cs
+++ b/OpenSim/Framework/UserProfileData.cs
@@ -160,7 +160,7 @@ namespace OpenSim.Framework
160 public virtual ulong HomeRegion 160 public virtual ulong HomeRegion
161 { 161 {
162 get 162 get
163 { 163 {
164 return Util.RegionWorldLocToHandle(Util.RegionToWorldLoc(m_homeRegionX), Util.RegionToWorldLoc(m_homeRegionY)); 164 return Util.RegionWorldLocToHandle(Util.RegionToWorldLoc(m_homeRegionX), Util.RegionToWorldLoc(m_homeRegionY));
165 // return Utils.UIntsToLong( m_homeRegionX * (uint)Constants.RegionSize, m_homeRegionY * (uint)Constants.RegionSize); 165 // return Utils.UIntsToLong( m_homeRegionX * (uint)Constants.RegionSize, m_homeRegionY * (uint)Constants.RegionSize);
166 } 166 }
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 1f74168..4dafaef 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -61,6 +61,15 @@ namespace OpenSim.Framework
61 public enum PermissionMask : uint 61 public enum PermissionMask : uint
62 { 62 {
63 None = 0, 63 None = 0,
64
65 // folded perms
66 foldedTransfer = 1,
67 foldedModify = 1 << 1,
68 foldedCopy = 1 << 2,
69
70 foldedMask = 0x07,
71
72 //
64 Transfer = 1 << 13, 73 Transfer = 1 << 13,
65 Modify = 1 << 14, 74 Modify = 1 << 14,
66 Copy = 1 << 15, 75 Copy = 1 << 15,
@@ -131,10 +140,14 @@ namespace OpenSim.Framework
131 140
132 public static readonly int MAX_THREADPOOL_LEVEL = 3; 141 public static readonly int MAX_THREADPOOL_LEVEL = 3;
133 142
143 public static double TimeStampClockPeriodMS;
144
134 static Util() 145 static Util()
135 { 146 {
136 LogThreadPool = 0; 147 LogThreadPool = 0;
137 LogOverloads = true; 148 LogOverloads = true;
149 TimeStampClockPeriodMS = 1000.0D / (double)Stopwatch.Frequency;
150 m_log.InfoFormat("[UTIL] TimeStamp clock with period of {0}ms", Math.Round(TimeStampClockPeriodMS,6,MidpointRounding.AwayFromZero));
138 } 151 }
139 152
140 private static uint nextXferID = 5000; 153 private static uint nextXferID = 5000;
@@ -267,14 +280,12 @@ namespace OpenSim.Framework
267 /// </summary> 280 /// </summary>
268 /// <param name="a">A 3d vector</param> 281 /// <param name="a">A 3d vector</param>
269 /// <returns>A new vector which is normalized form of the vector</returns> 282 /// <returns>A new vector which is normalized form of the vector</returns>
270 /// <remarks>The vector paramater cannot be <0,0,0></remarks> 283
271 public static Vector3 GetNormalizedVector(Vector3 a) 284 public static Vector3 GetNormalizedVector(Vector3 a)
272 { 285 {
273 if (IsZeroVector(a)) 286 Vector3 v = new Vector3(a.X, a.Y, a.Z);
274 throw new ArgumentException("Vector paramater cannot be a zero vector."); 287 v.Normalize();
275 288 return v;
276 float Mag = (float) GetMagnitude(a);
277 return new Vector3(a.X / Mag, a.Y / Mag, a.Z / Mag);
278 } 289 }
279 290
280 /// <summary> 291 /// <summary>
@@ -641,19 +652,25 @@ namespace OpenSim.Framework
641 /// </summary> 652 /// </summary>
642 /// <param name="data"></param> 653 /// <param name="data"></param>
643 /// <returns></returns> 654 /// <returns></returns>
655
644 public static string Md5Hash(string data) 656 public static string Md5Hash(string data)
645 { 657 {
646 byte[] dataMd5 = ComputeMD5Hash(data); 658 return Md5Hash(data, Encoding.Default);
659 }
660
661 public static string Md5Hash(string data, Encoding encoding)
662 {
663 byte[] dataMd5 = ComputeMD5Hash(data, encoding);
647 StringBuilder sb = new StringBuilder(); 664 StringBuilder sb = new StringBuilder();
648 for (int i = 0; i < dataMd5.Length; i++) 665 for (int i = 0; i < dataMd5.Length; i++)
649 sb.AppendFormat("{0:x2}", dataMd5[i]); 666 sb.AppendFormat("{0:x2}", dataMd5[i]);
650 return sb.ToString(); 667 return sb.ToString();
651 } 668 }
652 669
653 private static byte[] ComputeMD5Hash(string data) 670 private static byte[] ComputeMD5Hash(string data, Encoding encoding)
654 { 671 {
655 MD5 md5 = MD5.Create(); 672 MD5 md5 = MD5.Create();
656 return md5.ComputeHash(Encoding.Default.GetBytes(data)); 673 return md5.ComputeHash(encoding.GetBytes(data));
657 } 674 }
658 675
659 /// <summary> 676 /// <summary>
@@ -661,6 +678,12 @@ namespace OpenSim.Framework
661 /// </summary> 678 /// </summary>
662 /// <param name="data"></param> 679 /// <param name="data"></param>
663 /// <returns></returns> 680 /// <returns></returns>
681
682 public static string SHA1Hash(string data, Encoding enc)
683 {
684 return SHA1Hash(enc.GetBytes(data));
685 }
686
664 public static string SHA1Hash(string data) 687 public static string SHA1Hash(string data)
665 { 688 {
666 return SHA1Hash(Encoding.Default.GetBytes(data)); 689 return SHA1Hash(Encoding.Default.GetBytes(data));
@@ -714,17 +737,26 @@ namespace OpenSim.Framework
714 /// <param name="oldy">Old region y-coord</param> 737 /// <param name="oldy">Old region y-coord</param>
715 /// <param name="newy">New region y-coord</param> 738 /// <param name="newy">New region y-coord</param>
716 /// <returns></returns> 739 /// <returns></returns>
717 public static bool IsOutsideView(float drawdist, uint oldx, uint newx, uint oldy, uint newy) 740 public static bool IsOutsideView(float drawdist, uint oldx, uint newx, uint oldy, uint newy,
741 int oldsizex, int oldsizey, int newsizex, int newsizey)
718 { 742 {
719 int dd = (int)((drawdist + Constants.RegionSize - 1) / Constants.RegionSize); 743 // we still need to make sure we see new region 1stNeighbors
720 744
721 int startX = (int)oldx - dd; 745 oldx *= Constants.RegionSize;
722 int startY = (int)oldy - dd; 746 newx *= Constants.RegionSize;
747 if (oldx + oldsizex + drawdist < newx)
748 return true;
749 if (newx + newsizex + drawdist < oldx)
750 return true;
723 751
724 int endX = (int)oldx + dd; 752 oldy *= Constants.RegionSize;
725 int endY = (int)oldy + dd; 753 newy *= Constants.RegionSize;
754 if (oldy + oldsizey + drawdist < newy)
755 return true;
756 if (newy + newsizey + drawdist< oldy)
757 return true;
726 758
727 return (newx < startX || endX < newx || newy < startY || endY < newy); 759 return false;
728 } 760 }
729 761
730 public static string FieldToString(byte[] bytes) 762 public static string FieldToString(byte[] bytes)
@@ -805,6 +837,16 @@ namespace OpenSim.Framework
805 } 837 }
806 838
807 /// <summary> 839 /// <summary>
840 /// Converts a URL to a IPAddress
841 /// </summary>
842 /// <param name="url">URL Standard Format</param>
843 /// <returns>A resolved IP Address</returns>
844 public static IPAddress GetHostFromURL(string url)
845 {
846 return GetHostFromDNS(url.Split(new char[] {'/', ':'})[3]);
847 }
848
849 /// <summary>
808 /// Returns a IP address from a specified DNS, favouring IPv4 addresses. 850 /// Returns a IP address from a specified DNS, favouring IPv4 addresses.
809 /// </summary> 851 /// </summary>
810 /// <param name="dnsAddress">DNS Hostname</param> 852 /// <param name="dnsAddress">DNS Hostname</param>
@@ -1065,6 +1107,25 @@ namespace OpenSim.Framework
1065 } 1107 }
1066 } 1108 }
1067 1109
1110 public static string GetConfigVarWithDefaultSection(IConfigSource config, string varname, string section)
1111 {
1112 // First, check the Startup section, the default section
1113 IConfig cnf = config.Configs["Startup"];
1114 if (cnf == null)
1115 return string.Empty;
1116 string val = cnf.GetString(varname, string.Empty);
1117
1118 // Then check for an overwrite of the default in the given section
1119 if (!string.IsNullOrEmpty(section))
1120 {
1121 cnf = config.Configs[section];
1122 if (cnf != null)
1123 val = cnf.GetString(varname, val);
1124 }
1125
1126 return val;
1127 }
1128
1068 /// <summary> 1129 /// <summary>
1069 /// Gets the value of a configuration variable by looking into 1130 /// Gets the value of a configuration variable by looking into
1070 /// multiple sections in order. The latter sections overwrite 1131 /// multiple sections in order. The latter sections overwrite
@@ -1388,6 +1449,46 @@ namespace OpenSim.Framework
1388 return ret; 1449 return ret;
1389 } 1450 }
1390 1451
1452 public static string Compress(string text)
1453 {
1454 byte[] buffer = Util.UTF8.GetBytes(text);
1455 MemoryStream memory = new MemoryStream();
1456 using (GZipStream compressor = new GZipStream(memory, CompressionMode.Compress, true))
1457 {
1458 compressor.Write(buffer, 0, buffer.Length);
1459 }
1460
1461 memory.Position = 0;
1462
1463 byte[] compressed = new byte[memory.Length];
1464 memory.Read(compressed, 0, compressed.Length);
1465
1466 byte[] compressedBuffer = new byte[compressed.Length + 4];
1467 Buffer.BlockCopy(compressed, 0, compressedBuffer, 4, compressed.Length);
1468 Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, compressedBuffer, 0, 4);
1469 return Convert.ToBase64String(compressedBuffer);
1470 }
1471
1472 public static string Decompress(string compressedText)
1473 {
1474 byte[] compressedBuffer = Convert.FromBase64String(compressedText);
1475 using (MemoryStream memory = new MemoryStream())
1476 {
1477 int msgLength = BitConverter.ToInt32(compressedBuffer, 0);
1478 memory.Write(compressedBuffer, 4, compressedBuffer.Length - 4);
1479
1480 byte[] buffer = new byte[msgLength];
1481
1482 memory.Position = 0;
1483 using (GZipStream decompressor = new GZipStream(memory, CompressionMode.Decompress))
1484 {
1485 decompressor.Read(buffer, 0, buffer.Length);
1486 }
1487
1488 return Util.UTF8.GetString(buffer);
1489 }
1490 }
1491
1391 /// <summary> 1492 /// <summary>
1392 /// Copy data from one stream to another, leaving the read position of both streams at the beginning. 1493 /// Copy data from one stream to another, leaving the read position of both streams at the beginning.
1393 /// </summary> 1494 /// </summary>
@@ -1524,19 +1625,19 @@ namespace OpenSim.Framework
1524 { 1625 {
1525 string os = String.Empty; 1626 string os = String.Empty;
1526 1627
1527 if (Environment.OSVersion.Platform != PlatformID.Unix) 1628// if (Environment.OSVersion.Platform != PlatformID.Unix)
1528 { 1629// {
1529 os = Environment.OSVersion.ToString(); 1630// os = Environment.OSVersion.ToString();
1530 } 1631// }
1531 else 1632// else
1532 { 1633// {
1533 os = ReadEtcIssue(); 1634// os = ReadEtcIssue();
1534 } 1635// }
1535 1636//
1536 if (os.Length > 45) 1637// if (os.Length > 45)
1537 { 1638// {
1538 os = os.Substring(0, 45); 1639// os = os.Substring(0, 45);
1539 } 1640// }
1540 1641
1541 return os; 1642 return os;
1542 } 1643 }
@@ -1645,7 +1746,7 @@ namespace OpenSim.Framework
1645 1746
1646 public static Guid GetHashGuid(string data, string salt) 1747 public static Guid GetHashGuid(string data, string salt)
1647 { 1748 {
1648 byte[] hash = ComputeMD5Hash(data + salt); 1749 byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default);
1649 1750
1650 //string s = BitConverter.ToString(hash); 1751 //string s = BitConverter.ToString(hash);
1651 1752
@@ -1792,6 +1893,32 @@ namespace OpenSim.Framework
1792 return found.ToArray(); 1893 return found.ToArray();
1793 } 1894 }
1794 1895
1896 public static string ServerURI(string uri)
1897 {
1898 if (uri == string.Empty)
1899 return string.Empty;
1900
1901 // Get rid of eventual slashes at the end
1902 uri = uri.TrimEnd('/');
1903
1904 IPAddress ipaddr1 = null;
1905 string port1 = "";
1906 try
1907 {
1908 ipaddr1 = Util.GetHostFromURL(uri);
1909 }
1910 catch { }
1911
1912 try
1913 {
1914 port1 = uri.Split(new char[] { ':' })[2];
1915 }
1916 catch { }
1917
1918 // We tried our best to convert the domain names to IP addresses
1919 return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri;
1920 }
1921
1795 /// <summary> 1922 /// <summary>
1796 /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 256 bytes if necessary. 1923 /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 256 bytes if necessary.
1797 /// </summary> 1924 /// </summary>
@@ -1895,6 +2022,56 @@ namespace OpenSim.Framework
1895 } 2022 }
1896 2023
1897 /// <summary> 2024 /// <summary>
2025 /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to MaxLength bytes if necessary.
2026 /// </summary>
2027 /// <param name="str">
2028 /// If null or empty, then an bytes[0] is returned.
2029 /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0]
2030 /// </param>
2031 /// <param name="args">
2032 /// Arguments to substitute into the string via the {} mechanism.
2033 /// </param>
2034 /// <returns></returns>
2035 public static byte[] StringToBytes(string str, int MaxLength, params object[] args)
2036 {
2037 return StringToBytes1024(string.Format(str, args), MaxLength);
2038 }
2039
2040 /// <summary>
2041 /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to MaxLength bytes if necessary.
2042 /// </summary>
2043 /// <param name="str">
2044 /// If null or empty, then an bytes[0] is returned.
2045 /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0]
2046 /// </param>
2047 /// <returns></returns>
2048 public static byte[] StringToBytes(string str, int MaxLength)
2049 {
2050 if (String.IsNullOrEmpty(str))
2051 return Utils.EmptyBytes;
2052
2053 if (!str.EndsWith("\0"))
2054 str += "\0";
2055
2056 // Because this is UTF-8 encoding and not ASCII, it's possible we
2057 // might have gotten an oversized array even after the string trim
2058 byte[] data = UTF8.GetBytes(str);
2059
2060 if (data.Length > MaxLength)
2061 {
2062 int cut = MaxLength -1 ;
2063 if((data[cut] & 0x80 ) != 0 )
2064 {
2065 while(cut > 0 && (data[cut] & 0xc0) != 0xc0)
2066 cut--;
2067 }
2068 Array.Resize<byte>(ref data, cut + 1);
2069 data[cut] = 0;
2070 }
2071
2072 return data;
2073 }
2074 /// <summary>
1898 /// Pretty format the hashtable contents to a single line. 2075 /// Pretty format the hashtable contents to a single line.
1899 /// </summary> 2076 /// </summary>
1900 /// <remarks> 2077 /// <remarks>
@@ -2004,7 +2181,7 @@ namespace OpenSim.Framework
2004 2181
2005 STPStartInfo startInfo = new STPStartInfo(); 2182 STPStartInfo startInfo = new STPStartInfo();
2006 startInfo.ThreadPoolName = "Util"; 2183 startInfo.ThreadPoolName = "Util";
2007 startInfo.IdleTimeout = 2000; 2184 startInfo.IdleTimeout = 20000;
2008 startInfo.MaxWorkerThreads = maxThreads; 2185 startInfo.MaxWorkerThreads = maxThreads;
2009 startInfo.MinWorkerThreads = minThreads; 2186 startInfo.MinWorkerThreads = minThreads;
2010 2187
@@ -2557,6 +2734,13 @@ namespace OpenSim.Framework
2557 return tcA - tcB; 2734 return tcA - tcB;
2558 } 2735 }
2559 2736
2737 // returns a timestamp in ms as double
2738 // using the time resolution avaiable to StopWatch
2739 public static double GetTimeStampMS()
2740 {
2741 return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriodMS;
2742 }
2743
2560 /// <summary> 2744 /// <summary>
2561 /// Formats a duration (given in milliseconds). 2745 /// Formats a duration (given in milliseconds).
2562 /// </summary> 2746 /// </summary>
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs
index 1aecf79..af28abc 100644
--- a/OpenSim/Framework/WearableCacheItem.cs
+++ b/OpenSim/Framework/WearableCacheItem.cs
@@ -43,12 +43,13 @@ namespace OpenSim.Framework
43 43
44 public static WearableCacheItem[] GetDefaultCacheItem() 44 public static WearableCacheItem[] GetDefaultCacheItem()
45 { 45 {
46 int itemmax = 21; 46 int itemmax = AvatarAppearance.TEXTURE_COUNT;
47 WearableCacheItem[] retitems = new WearableCacheItem[itemmax]; 47 WearableCacheItem[] retitems = new WearableCacheItem[itemmax];
48 for (uint i=0;i<itemmax;i++) 48 for (uint i=0;i<itemmax;i++)
49 retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i + 1}; 49 retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i};
50 return retitems; 50 return retitems;
51 } 51 }
52
52 public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache) 53 public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache)
53 { 54 {
54 List<WearableCacheItem> ret = new List<WearableCacheItem>(); 55 List<WearableCacheItem> ret = new List<WearableCacheItem>();
@@ -98,6 +99,7 @@ namespace OpenSim.Framework
98 return ret.ToArray(); 99 return ret.ToArray();
99 100
100 } 101 }
102
101 public static OSD ToOSD(WearableCacheItem[] pcacheItems, IImprovedAssetCache dataCache) 103 public static OSD ToOSD(WearableCacheItem[] pcacheItems, IImprovedAssetCache dataCache)
102 { 104 {
103 OSDArray arr = new OSDArray(); 105 OSDArray arr = new OSDArray();
@@ -124,6 +126,68 @@ namespace OpenSim.Framework
124 } 126 }
125 return arr; 127 return arr;
126 } 128 }
129
130 public static OSDArray BakedToOSD(WearableCacheItem[] pcacheItems)
131 {
132 if (pcacheItems.Length < AvatarAppearance.BAKE_INDICES[AvatarAppearance.BAKE_INDICES.Length - 1])
133 return null;
134
135 OSDArray arr = new OSDArray();
136
137 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
138 {
139 int idx = AvatarAppearance.BAKE_INDICES[i];
140
141 WearableCacheItem item = pcacheItems[idx];
142
143 OSDMap itemmap = new OSDMap();
144 itemmap.Add("textureindex", OSD.FromUInteger(item.TextureIndex));
145 itemmap.Add("cacheid", OSD.FromUUID(item.CacheId));
146 itemmap.Add("textureid", OSD.FromUUID(item.TextureID));
147/*
148 if (item.TextureAsset != null)
149 {
150 itemmap.Add("assetdata", OSD.FromBinary(item.TextureAsset.Data));
151 itemmap.Add("assetcreator", OSD.FromString(item.TextureAsset.CreatorID));
152 itemmap.Add("assetname", OSD.FromString(item.TextureAsset.Name));
153 }
154 */
155 arr.Add(itemmap);
156 }
157 return arr;
158 }
159
160 public static WearableCacheItem[] BakedFromOSD(OSD pInput)
161 {
162 WearableCacheItem[] pcache = WearableCacheItem.GetDefaultCacheItem();
163
164 if (pInput.Type == OSDType.Array)
165 {
166 OSDArray itemarray = (OSDArray)pInput;
167 foreach (OSDMap item in itemarray)
168 {
169 int idx = (int)item["textureindex"].AsUInteger();
170 if (idx < 0 || idx > pcache.Length)
171 continue;
172 pcache[idx].CacheId = item["cacheid"].AsUUID();
173 pcache[idx].TextureID = item["textureid"].AsUUID();
174/*
175 if (item.ContainsKey("assetdata"))
176 {
177 AssetBase asset = new AssetBase(item["textureid"].AsUUID(), "BakedTexture", (sbyte)AssetType.Texture, UUID.Zero.ToString());
178 asset.Temporary = true;
179 asset.Local = true;
180 asset.Data = item["assetdata"].AsBinary();
181 pcache[idx].TextureAsset = asset;
182 }
183 else
184 */
185 pcache[idx].TextureAsset = null;
186 }
187 }
188 return pcache;
189 }
190
127 public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems) 191 public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems)
128 { 192 {
129 for (int i = 0; i < pcacheItems.Length; i++) 193 for (int i = 0; i < pcacheItems.Length; i++)
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index b180c8a..3436984 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -233,6 +233,9 @@ namespace OpenSim.Framework
233 string errorMessage = "unknown error"; 233 string errorMessage = "unknown error";
234 int tickstart = Util.EnvironmentTickCount(); 234 int tickstart = Util.EnvironmentTickCount();
235 int tickdata = 0; 235 int tickdata = 0;
236 int tickcompressdata = 0;
237 int tickJsondata = 0;
238 int compsize = 0;
236 string strBuffer = null; 239 string strBuffer = null;
237 240
238 try 241 try
@@ -250,6 +253,8 @@ namespace OpenSim.Framework
250 { 253 {
251 strBuffer = OSDParser.SerializeJsonString(data); 254 strBuffer = OSDParser.SerializeJsonString(data);
252 255
256 tickJsondata = Util.EnvironmentTickCountSubtract(tickstart);
257
253 if (DebugLevel >= 5) 258 if (DebugLevel >= 5)
254 LogOutgoingDetail("SEND", reqnum, strBuffer); 259 LogOutgoingDetail("SEND", reqnum, strBuffer);
255 260
@@ -271,13 +276,20 @@ namespace OpenSim.Framework
271 // gets written on the stream upon Dispose() 276 // gets written on the stream upon Dispose()
272 } 277 }
273 byte[] buf = ms.ToArray(); 278 byte[] buf = ms.ToArray();
279
280 tickcompressdata = Util.EnvironmentTickCountSubtract(tickstart);
281
274 request.ContentLength = buf.Length; //Count bytes to send 282 request.ContentLength = buf.Length; //Count bytes to send
283 compsize = buf.Length;
275 using (Stream requestStream = request.GetRequestStream()) 284 using (Stream requestStream = request.GetRequestStream())
276 requestStream.Write(buf, 0, (int)buf.Length); 285 requestStream.Write(buf, 0, (int)buf.Length);
277 } 286 }
278 } 287 }
279 else 288 else
280 { 289 {
290 tickcompressdata = tickJsondata;
291 compsize = buffer.Length;
292
281 request.ContentLength = buffer.Length; //Count bytes to send 293 request.ContentLength = buffer.Length; //Count bytes to send
282 using (Stream requestStream = request.GetRequestStream()) 294 using (Stream requestStream = request.GetRequestStream())
283 requestStream.Write(buffer, 0, buffer.Length); //Send it 295 requestStream.Write(buffer, 0, buffer.Length); //Send it
@@ -314,6 +326,7 @@ namespace OpenSim.Framework
314 catch (Exception ex) 326 catch (Exception ex)
315 { 327 {
316 errorMessage = ex.Message; 328 errorMessage = ex.Message;
329 m_log.Debug("[WEB UTIL]: Exception making request: " + ex.ToString());
317 } 330 }
318 finally 331 finally
319 { 332 {
@@ -321,8 +334,17 @@ namespace OpenSim.Framework
321 if (tickdiff > LongCallTime) 334 if (tickdiff > LongCallTime)
322 { 335 {
323 m_log.InfoFormat( 336 m_log.InfoFormat(
324 "[LOGHTTP]: Slow JSON-RPC request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", 337 "[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4}ms writing({5} at Json; {6} at comp), {7} bytes ({8} uncomp): {9}",
325 reqnum, method, url, tickdiff, tickdata, 338 reqnum,
339 method,
340 url,
341 tickdiff,
342 tickdata,
343 tickJsondata,
344 tickcompressdata,
345 compsize,
346 strBuffer != null ? strBuffer.Length : 0,
347
326 strBuffer != null 348 strBuffer != null
327 ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) 349 ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer)
328 : ""); 350 : "");
@@ -396,7 +418,7 @@ namespace OpenSim.Framework
396 /// </summary> 418 /// </summary>
397 public static OSDMap PostToService(string url, NameValueCollection data) 419 public static OSDMap PostToService(string url, NameValueCollection data)
398 { 420 {
399 return ServiceFormRequest(url,data,10000); 421 return ServiceFormRequest(url,data, 30000);
400 } 422 }
401 423
402 public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout) 424 public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout)
@@ -779,6 +801,20 @@ namespace OpenSim.Framework
779 MakeRequest<TRequest, TResponse>(verb, requestUrl, obj, action, maxConnections, null); 801 MakeRequest<TRequest, TResponse>(verb, requestUrl, obj, action, maxConnections, null);
780 } 802 }
781 803
804 /// <summary>
805 /// Perform a synchronous REST request.
806 /// </summary>
807 /// <param name="verb"></param>
808 /// <param name="requestUrl"></param>
809 /// <param name="obj"></param>
810 /// <param name="pTimeout">
811 /// Request timeout in seconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds)
812 /// </param>
813 /// <param name="maxConnections"></param>
814 /// <returns>
815 /// The response. If there was an internal exception or the request timed out,
816 /// then the default(TResponse) is returned.
817 /// </returns>
782 public static void MakeRequest<TRequest, TResponse>(string verb, 818 public static void MakeRequest<TRequest, TResponse>(string verb,
783 string requestUrl, TRequest obj, Action<TResponse> action, 819 string requestUrl, TRequest obj, Action<TResponse> action,
784 int maxConnections, IServiceAuth auth) 820 int maxConnections, IServiceAuth auth)
@@ -791,6 +827,7 @@ namespace OpenSim.Framework
791 827
792 int tickstart = Util.EnvironmentTickCount(); 828 int tickstart = Util.EnvironmentTickCount();
793 int tickdata = 0; 829 int tickdata = 0;
830 int tickdiff = 0;
794 831
795 Type type = typeof(TRequest); 832 Type type = typeof(TRequest);
796 833
@@ -936,7 +973,7 @@ namespace OpenSim.Framework
936 }, null); 973 }, null);
937 } 974 }
938 975
939 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); 976 tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
940 if (tickdiff > WebUtil.LongCallTime) 977 if (tickdiff > WebUtil.LongCallTime)
941 { 978 {
942 string originalRequest = null; 979 string originalRequest = null;
@@ -948,8 +985,7 @@ namespace OpenSim.Framework
948 if (originalRequest.Length > WebUtil.MaxRequestDiagLength) 985 if (originalRequest.Length > WebUtil.MaxRequestDiagLength)
949 originalRequest = originalRequest.Remove(WebUtil.MaxRequestDiagLength); 986 originalRequest = originalRequest.Remove(WebUtil.MaxRequestDiagLength);
950 } 987 }
951 988 m_log.InfoFormat(
952 m_log.InfoFormat(
953 "[LOGHTTP]: Slow AsynchronousRequestObject request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", 989 "[LOGHTTP]: Slow AsynchronousRequestObject request {0} {1} to {2} took {3}ms, {4}ms writing, {5}",
954 reqnum, verb, requestUrl, tickdiff, tickdata, 990 reqnum, verb, requestUrl, tickdiff, tickdata,
955 originalRequest); 991 originalRequest);
@@ -957,6 +993,7 @@ namespace OpenSim.Framework
957 else if (WebUtil.DebugLevel >= 4) 993 else if (WebUtil.DebugLevel >= 4)
958 { 994 {
959 m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", 995 m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing",
996
960 reqnum, tickdiff, tickdata); 997 reqnum, tickdiff, tickdata);
961 } 998 }
962 } 999 }
@@ -1004,6 +1041,8 @@ namespace OpenSim.Framework
1004 1041
1005 string respstring = String.Empty; 1042 string respstring = String.Empty;
1006 1043
1044 int tickset = Util.EnvironmentTickCountSubtract(tickstart);
1045
1007 using (MemoryStream buffer = new MemoryStream()) 1046 using (MemoryStream buffer = new MemoryStream())
1008 { 1047 {
1009 if ((verb == "POST") || (verb == "PUT")) 1048 if ((verb == "POST") || (verb == "PUT"))
@@ -1070,8 +1109,13 @@ namespace OpenSim.Framework
1070 if (tickdiff > WebUtil.LongCallTime) 1109 if (tickdiff > WebUtil.LongCallTime)
1071 { 1110 {
1072 m_log.InfoFormat( 1111 m_log.InfoFormat(
1073 "[LOGHTTP]: Slow SynchronousRestForms request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", 1112 "[FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
1074 reqnum, verb, requestUrl, tickdiff, tickdata, 1113 reqnum,
1114 verb,
1115 requestUrl,
1116 tickdiff,
1117 tickset,
1118 tickdata,
1075 obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); 1119 obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj);
1076 } 1120 }
1077 else if (WebUtil.DebugLevel >= 4) 1121 else if (WebUtil.DebugLevel >= 4)
@@ -1202,7 +1246,7 @@ namespace OpenSim.Framework
1202 auth.AddAuthorization(ht.Headers); 1246 auth.AddAuthorization(ht.Headers);
1203 1247
1204 if (pTimeout != 0) 1248 if (pTimeout != 0)
1205 ht.Timeout = pTimeout; 1249 request.Timeout = pTimeout;
1206 1250
1207 if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections) 1251 if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections)
1208 ht.ServicePoint.ConnectionLimit = maxConnections; 1252 ht.ServicePoint.ConnectionLimit = maxConnections;
@@ -1343,7 +1387,6 @@ namespace OpenSim.Framework
1343 1387
1344 return deserial; 1388 return deserial;
1345 } 1389 }
1346
1347 1390
1348 public static class XMLResponseHelper 1391 public static class XMLResponseHelper
1349 { 1392 {