From b4084c7b2e6bbee2af687e40d803fa9ef288c4ba Mon Sep 17 00:00:00 2001 From: Jim Radford Date: Fri, 7 Mar 2008 17:43:51 +0000 Subject: [PATCH] * Added overload to RequestAllSimParcels which allows user to do a full refresh of Parcel dictionary * Increased time delay between requests due to caps being slower responding to parcel PropertiesRequests * See TestClient/Commands/Land/ParcelInfoCommand.cs for example usage. git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1659 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife/ParcelManager.cs | 20 ++++++++++++++- .../Commands/Land/ParcelInfoCommand.cs | 25 +++++++++++-------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/libsecondlife/ParcelManager.cs b/libsecondlife/ParcelManager.cs index ba3889a4..4f3aae21 100644 --- a/libsecondlife/ParcelManager.cs +++ b/libsecondlife/ParcelManager.cs @@ -769,6 +769,24 @@ namespace libsecondlife /// Simulator to request parcels from (must be connected) public void RequestAllSimParcels(Simulator simulator) { + RequestAllSimParcels(simulator, false); + } + + /// + /// Request all simulator parcel properties (used for populating the Simulator.Parcels + /// dictionary) + /// + /// Simulator to request parcels from (must be connected) + /// If set to true, will force a full refresh + public void RequestAllSimParcels(Simulator simulator, bool refresh) + { + + if (refresh) + { + lock (simulator.ParcelMap) + simulator.ParcelMap = new int[64,64]; + } + Thread th = new Thread(delegate() { int y, x; @@ -782,7 +800,7 @@ namespace libsecondlife (y + 1) * 4.0f, (x + 1) * 4.0f, y * 4.0f, x * 4.0f, 0, false); // Pause for 50 ms after every request to avoid flooding the sim - System.Threading.Thread.Sleep(50); + System.Threading.Thread.Sleep(200); } } } diff --git a/libsecondlife/examples/TestClient/Commands/Land/ParcelInfoCommand.cs b/libsecondlife/examples/TestClient/Commands/Land/ParcelInfoCommand.cs index cc41a717..5f02722f 100644 --- a/libsecondlife/examples/TestClient/Commands/Land/ParcelInfoCommand.cs +++ b/libsecondlife/examples/TestClient/Commands/Land/ParcelInfoCommand.cs @@ -10,7 +10,6 @@ namespace libsecondlife.TestClient public class ParcelInfoCommand : Command { private AutoResetEvent ParcelsDownloaded = new AutoResetEvent(false); - private int ParcelCount = 0; public ParcelInfoCommand(TestClient testClient) { @@ -30,25 +29,31 @@ namespace libsecondlife.TestClient ParcelManager.SimParcelsDownloaded del = delegate(Simulator simulator, InternalDictionary simParcels, int[,] parcelMap) { - ParcelCount = simParcels.Count; - - simParcels.ForEach(delegate(Parcel parcel) - { - sb.AppendFormat("Parcels[{0}]: Name: \"{1}\", Description: \"{2}\" ACL Count: {3}" + System.Environment.NewLine, - parcel.LocalID, parcel.Name, parcel.Desc, parcel.AccessList.Count); - }); ParcelsDownloaded.Set(); - }; ParcelsDownloaded.Reset(); Client.Parcels.OnSimParcelsDownloaded += del; Client.Parcels.RequestAllSimParcels(Client.Network.CurrentSim); + if (Client.Network.CurrentSim.IsParcelMapFull()) + ParcelsDownloaded.Set(); + if (ParcelsDownloaded.WaitOne(20000, false) && Client.Network.Connected) + { + sb.AppendFormat("Downloaded {0} Parcels in {1}", + Client.Network.CurrentSim.Parcels.Count, Client.Network.CurrentSim.Name); + + Client.Network.CurrentSim.Parcels.ForEach(delegate(Parcel parcel) + { + sb.AppendFormat("Parcels[{0}]: Name: \"{1}\", Description: \"{2}\" ACL Count: {3}" + System.Environment.NewLine, + parcel.LocalID, parcel.Name, parcel.Desc, parcel.AccessList.Count); + }); + result = sb.ToString(); + } else - result = "Failed to retrieve information on all the simulator parcels"; + result = "Failed to retrieve information on all the simulator parcels"; Client.Parcels.OnSimParcelsDownloaded -= del; return result;