diff --git a/OpenMetaverse.StructuredData/LLSD/XmlLLSD.cs b/OpenMetaverse.StructuredData/LLSD/XmlLLSD.cs
index 6b2a4e9a..16b6ef16 100644
--- a/OpenMetaverse.StructuredData/LLSD/XmlLLSD.cs
+++ b/OpenMetaverse.StructuredData/LLSD/XmlLLSD.cs
@@ -71,13 +71,20 @@ namespace OpenMetaverse.StructuredData
///
public static OSD DeserializeLLSDXml(XmlTextReader xmlData)
{
- xmlData.Read();
- SkipWhitespace(xmlData);
+ try
+ {
+ xmlData.Read();
+ SkipWhitespace(xmlData);
- xmlData.Read();
- OSD ret = ParseLLSDXmlElement(xmlData);
+ xmlData.Read();
+ OSD ret = ParseLLSDXmlElement(xmlData);
- return ret;
+ return ret;
+ }
+ catch
+ {
+ return new OSD();
+ }
}
///
diff --git a/OpenMetaverse.Utilities/Utilities.cs b/OpenMetaverse.Utilities/Utilities.cs
index 672b4601..d922ad1e 100644
--- a/OpenMetaverse.Utilities/Utilities.cs
+++ b/OpenMetaverse.Utilities/Utilities.cs
@@ -266,344 +266,4 @@ namespace OpenMetaverse.Utilities
}
}
}
-
- ///
- ///
- ///
- [Obsolete("ParcelDownloader has been replaced by Parcels.RequestAllSimParcels()")]
- public class ParcelDownloader
- {
- ///
- ///
- ///
- /// Simulator where the parcels are located
- /// Mapping of parcel LocalIDs to Parcel objects
- ///
- public delegate void ParcelsDownloadedCallback(Simulator simulator, Dictionary Parcels, int[,] map);
-
-
- ///
- ///
- ///
- public event ParcelsDownloadedCallback OnParcelsDownloaded;
-
- private GridClient Client;
- /// Dictionary of 64x64 arrays of parcels which have been successfully downloaded
- /// for each simulator (and their LocalID's, 0 = Null)
- private Dictionary ParcelMarked = new Dictionary();
- private Dictionary> Parcels = new Dictionary>();
- private List active_sims = new List();
-
- ///
- /// Default constructor
- ///
- /// A reference to the GridClient object
- public ParcelDownloader(GridClient client)
- {
- Client = client;
- Client.Parcels.OnParcelProperties += new ParcelManager.ParcelPropertiesCallback(Parcels_OnParcelProperties);
- Client.Parcels.OnAccessListReply += new ParcelManager.ParcelAccessListReplyCallback(Parcels_OnParcelAccessList);
- }
-
- public void DownloadSimParcels(Simulator simulator)
- {
- if (simulator == null)
- {
- Logger.Log("DownloadSimParcels() will not work with a null simulator", Helpers.LogLevel.Error, Client);
- return;
- }
-
- lock (active_sims)
- {
- if (active_sims.Contains(simulator))
- {
- Logger.Log("DownloadSimParcels(" + simulator + ") called more than once?", Helpers.LogLevel.Error, Client);
- return;
- }
-
- active_sims.Add(simulator);
- }
-
- lock (ParcelMarked)
- {
- if (!ParcelMarked.ContainsKey(simulator))
- {
- ParcelMarked[simulator] = new int[64, 64];
- Parcels[simulator] = new Dictionary();
- }
- }
-
- Client.Parcels.PropertiesRequest(simulator, 0.0f, 0.0f, 0.0f, 0.0f, 0, false);
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- public float GetHeightRange(int[,] map, int localid)
- {
- float min = Single.MaxValue;
- float max = 0.0f;
-
- for (int y = 0; y < 64; y++)
- {
- for (int x = 0; x < 64; x++)
- {
- if (map[y, x] == localid)
- {
- for (int y1 = 0; y1 < 4; y1++)
- {
- for (int x1 = 0; x1 < 4; x1++)
- {
- float height;
- int tries = 0;
-
- CheckHeight:
-
- if (Client.Terrain.TerrainHeightAtPoint(Client.Network.CurrentSim.Handle,
- x * 4 + x1, y * 4 + y1, out height))
- {
- if (height < min)
- min = height;
- if (height > max)
- max = height;
- }
- else if (tries > 4)
- {
- Logger.Log("Too many tries on this terrain block, skipping",
- Helpers.LogLevel.Warning, Client);
- continue;
- }
- else
- {
- Logger.Log(String.Format("Terrain height is null at {0},{1} retrying",
- x * 4 + x1, y * 4 + y1), Helpers.LogLevel.Info, Client);
-
- // Terrain at this point hasn't been downloaded, move the camera to this spot
- // and try again
- Vector3 position = new Vector3((float)(x * 4 + x1), (float)(y * 4 + y1),
- Client.Self.SimPosition.Z);
- Client.Self.Movement.Camera.Position = position;
-
- Client.Self.Movement.SendUpdate(true);
-
- Thread.Sleep(1000);
- goto CheckHeight;
- }
- }
- }
- }
- }
- }
-
- if (min != Single.MaxValue)
- {
- return max - min;
- }
- else
- {
- Logger.Log("Error decoding terrain for parcel " + localid, Helpers.LogLevel.Error, Client);
- return Single.NaN;
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- public WaterType GetWaterType(int[,] map, int localid)
- {
- if (!Client.Settings.STORE_LAND_PATCHES)
- {
- Logger.Log("GetWaterType() will not work without Settings.STORE_LAND_PATCHES set to true",
- Helpers.LogLevel.Error, Client);
- return WaterType.Unknown;
- }
- else if (!Client.Network.Connected && Client.Network.CurrentSim != null)
- {
- Logger.Log("GetWaterType() can only be used with an online client", Helpers.LogLevel.Error, Client);
- return WaterType.Unknown;
- }
-
- bool underwater = false;
- bool abovewater = false;
-
- for (int y = 0; y < 64; y++)
- {
- for (int x = 0; x < 64; x++)
- {
- if (map[y, x] == localid)
- {
- for (int y1 = 0; y1 < 4; y1++)
- {
- for (int x1 = 0; x1 < 4; x1++)
- {
- float height;
- int tries = 0;
-
- CheckHeight:
- tries++;
-
- if (Client.Terrain.TerrainHeightAtPoint(Client.Network.CurrentSim.Handle,
- x * 4 + x1, y * 4 + y1, out height))
- {
- if (height < Client.Network.CurrentSim.WaterHeight)
- {
- underwater = true;
- }
- else
- {
- abovewater = true;
- }
- }
- else if (tries > 4)
- {
- Logger.Log("Too many tries on this terrain block, skipping",
- Helpers.LogLevel.Warning, Client);
- continue;
- }
- else
- {
- Logger.Log(String.Format("Terrain height is null at {0},{1} retrying",
- x * 4 + x1, y * 4 + y1), Helpers.LogLevel.Info, Client);
-
- // Terrain at this point hasn't been downloaded, move the camera to this spot
- // and try again
- Vector3 position = new Vector3((float)(x * 4 + x1), (float)(y * 4 + y1),
- Client.Self.SimPosition.Z);
- Client.Self.Movement.Camera.Position = position;
-
- Client.Self.Movement.SendUpdate(true);
-
- Thread.Sleep(1000);
- goto CheckHeight;
- }
- }
- }
- }
- }
- }
-
- if (underwater && abovewater)
- {
- return WaterType.Waterfront;
- }
- else if (abovewater)
- {
- return WaterType.Dry;
- }
- else if (underwater)
- {
- return WaterType.Underwater;
- }
- else
- {
- Logger.Log("Error decoding terrain for parcel " + localid, Helpers.LogLevel.Error, Client);
- return WaterType.Unknown;
- }
- }
-
- public int GetRectangularDeviation(Vector3 aabbmin, Vector3 aabbmax, int area)
- {
- int xlength = (int)(aabbmax.X - aabbmin.X);
- int ylength = (int)(aabbmax.Y - aabbmin.Y);
- int aabbarea = xlength * ylength;
- return (aabbarea - area) / 16;
- }
-
- private void Parcels_OnParcelAccessList(Simulator simulator, int sequenceID, int localID, uint flags,
- List accessEntries)
- {
- if (simulator != null && Parcels.ContainsKey(simulator) && Parcels[simulator].ContainsKey(localID))
- {
- Parcel parcel = Parcels[simulator][localID];
- //parcel.AccessList = accessEntries;
- Parcels[simulator][localID] = parcel;
- }
- }
-
- private void Parcels_OnParcelProperties(Simulator simulator, Parcel parcel, ParcelResult result,
- int selectedPrims, int sequenceID, bool snapSelection)
- {
- // Check if this is for a simulator we're concerned with
- if (!active_sims.Contains(simulator)) return;
-
- // Warn about parcel property request errors and bail out
- if (result == ParcelResult.NoData)
- {
- Logger.Log("ParcelDownloader received a NoData response, sequenceID " + sequenceID,
- Helpers.LogLevel.Warning, Client);
- return;
- }
-
- // Warn about unexpected data and bail out
- if (!ParcelMarked.ContainsKey(simulator))
- {
- Logger.Log("ParcelDownloader received unexpected parcel data for " + simulator,
- Helpers.LogLevel.Warning, Client);
- return;
- }
-
- int x, y, index, bit;
- int[,] markers = ParcelMarked[simulator];
-
- // Add this parcel to the dictionary of LocalID -> Parcel mappings
- lock (Parcels[simulator])
- if (!Parcels[simulator].ContainsKey(parcel.LocalID))
- Parcels[simulator][parcel.LocalID] = parcel;
-
- // Request the access list for this parcel
- Client.Parcels.AccessListRequest(simulator, parcel.LocalID,
- AccessList.Both, 0);
-
- // Mark this area as downloaded
- for (y = 0; y < 64; y++)
- {
- for (x = 0; x < 64; x++)
- {
- if (markers[y, x] == 0)
- {
- index = (y * 64) + x;
- bit = index % 8;
- index >>= 3;
-
- if ((parcel.Bitmap[index] & (1 << bit)) != 0)
- markers[y, x] = parcel.LocalID;
- }
- }
- }
-
- // Request parcel information for the next missing area
- for (y = 0; y < 64; y++)
- {
- for (x = 0; x < 64; x++)
- {
- if (markers[y, x] == 0)
- {
- Client.Parcels.PropertiesRequest(simulator,
- (y + 1) * 4.0f, (x + 1) * 4.0f,
- y * 4.0f, x * 4.0f, 0, false);
- return;
- }
- }
- }
-
- // If we get here, there are no more zeroes in the markers map
- lock (active_sims)
- {
- active_sims.Remove(simulator);
-
- if (OnParcelsDownloaded != null)
- {
- // This map is complete, fire callback
- try { OnParcelsDownloaded(simulator, Parcels[simulator], markers); }
- catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
- }
- }
- }
- }
}
diff --git a/OpenMetaverse/Caps.cs b/OpenMetaverse/Caps.cs
index c271fe11..71c72fc1 100644
--- a/OpenMetaverse/Caps.cs
+++ b/OpenMetaverse/Caps.cs
@@ -176,8 +176,8 @@ namespace OpenMetaverse
Logger.DebugLog("Starting event queue for " + Simulator.ToString(), Simulator.Client);
_EventQueueCap = new EventQueueClient(_Caps["EventQueueGet"]);
- _EventQueueCap.OnConnected += new EventQueueClient.ConnectedCallback(EventQueueConnectedHandler);
- _EventQueueCap.OnEvent += new EventQueueClient.EventCallback(EventQueueEventHandler);
+ _EventQueueCap.OnConnected += EventQueueConnectedHandler;
+ _EventQueueCap.OnEvent += EventQueueEventHandler;
_EventQueueCap.Start();
}
}
diff --git a/OpenMetaverse/NetworkManager.cs b/OpenMetaverse/NetworkManager.cs
index ea9b3661..ddeee3f3 100644
--- a/OpenMetaverse/NetworkManager.cs
+++ b/OpenMetaverse/NetworkManager.cs
@@ -675,8 +675,7 @@ namespace OpenMetaverse
OutgoingPacket outgoingPacket = null;
Simulator simulator = null;
Packet packet = null;
- int now;
- int lastPacketTime = Environment.TickCount;
+ System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
while (connected)
{
@@ -686,16 +685,15 @@ namespace OpenMetaverse
packet = outgoingPacket.Packet;
// Very primitive rate limiting, keeps a fixed buffer of time between each packet
- now = Environment.TickCount;
- int ms = now - lastPacketTime;
- if (ms < 75)
+ stopwatch.Stop();
+ if (stopwatch.ElapsedMilliseconds < 10)
{
//Logger.DebugLog(String.Format("Rate limiting, last packet was {0}ms ago", ms));
- Thread.Sleep(75 - ms);
+ Thread.Sleep(10 - (int)stopwatch.ElapsedMilliseconds);
}
- lastPacketTime = now;
simulator.SendPacketUnqueued(outgoingPacket);
+ stopwatch.Start();
}
}
}
diff --git a/OpenMetaverse/ParcelManager.cs b/OpenMetaverse/ParcelManager.cs
index 04af3209..e69eb954 100644
--- a/OpenMetaverse/ParcelManager.cs
+++ b/OpenMetaverse/ParcelManager.cs
@@ -935,8 +935,6 @@ namespace OpenMetaverse
WaitForSimParcel = new AutoResetEvent(false);
}
-
-
if (refresh)
{
for (int y = 0; y < 64; y++)
@@ -1509,30 +1507,37 @@ namespace OpenMetaverse
if (Client.Settings.PARCEL_TRACKING)
{
- if(sequenceID.Equals(int.MaxValue))
- WaitForSimParcel.Set();
-
lock (simulator.Parcels.Dictionary)
simulator.Parcels.Dictionary[parcel.LocalID] = parcel;
+ bool set = false;
int y, x, index, bit;
- for (y = 0; y < simulator.ParcelMap.GetLength(0); y++)
+ for (y = 0; y < 64; y++)
{
- for (x = 0; x < simulator.ParcelMap.GetLength(1); x++)
+ for (x = 0; x < 64; x++)
{
- if (simulator.ParcelMap[y, x] == 0)
- {
- index = (y * 64) + x;
- bit = index % 8;
- index >>= 3;
+ index = (y * 64) + x;
+ bit = index % 8;
+ index >>= 3;
- if ((parcel.Bitmap[index] & (1 << bit)) != 0)
- simulator.ParcelMap[y, x] = parcel.LocalID;
+ if ((parcel.Bitmap[index] & (1 << bit)) != 0)
+ {
+ simulator.ParcelMap[y, x] = parcel.LocalID;
+ set = true;
}
}
}
+
+ if (!set)
+ {
+ Logger.Log("Received a parcel with a bitmap that did not map to any locations",
+ Helpers.LogLevel.Warning);
+ }
}
+ if (sequenceID.Equals(int.MaxValue) && WaitForSimParcel != null)
+ WaitForSimParcel.Set();
+
// auto request acl, will be stored in parcel tracking dictionary if enabled
if (Client.Settings.ALWAYS_REQUEST_PARCEL_ACL)
Client.Parcels.AccessListRequest(simulator, parcel.LocalID,
diff --git a/OpenMetaverse/Simulator.cs b/OpenMetaverse/Simulator.cs
index 0aea3894..50827c5f 100644
--- a/OpenMetaverse/Simulator.cs
+++ b/OpenMetaverse/Simulator.cs
@@ -342,8 +342,6 @@ namespace OpenMetaverse
/// true if map is full (contains no 0's)
public bool IsParcelMapFull()
{
- //int ny = this.ParcelMap.GetLength(0);
- //int nx = this.ParcelMap.GetLength(1);
for (int y = 0; y < 64; y++)
{
for (int x = 0; x < 64; x++)
diff --git a/Programs/GridProxy/GridProxy.cs b/Programs/GridProxy/GridProxy.cs
index 30a21c27..e2e6e434 100644
--- a/Programs/GridProxy/GridProxy.cs
+++ b/Programs/GridProxy/GridProxy.cs
@@ -299,7 +299,8 @@ namespace GridProxy
PacketType origType = packet.Type;
foreach (PacketDelegate del in delegates[origType])
{
- packet = del(packet, remoteEndPoint);
+ try { packet = del(packet, remoteEndPoint); }
+ catch (Exception ex) { Console.WriteLine("Error in packet delegate: " + ex.ToString()); }
// FIXME: how should we handle the packet type changing?
if (packet == null || packet.Type != origType) break;