From f000a0324ab9bd83fb034d48dbc59d09636415c6 Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Tue, 29 Apr 2025 17:00:21 +0100 Subject: [PATCH] maybe fix Parcel return all passing null does not trigger it to return for everyone so using the parcel prim owners list to then request a return for each owner. --- SecondBotEvents/Commands/ParcelCommands.cs | 37 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/SecondBotEvents/Commands/ParcelCommands.cs b/SecondBotEvents/Commands/ParcelCommands.cs index c3386cd..11a75df 100644 --- a/SecondBotEvents/Commands/ParcelCommands.cs +++ b/SecondBotEvents/Commands/ParcelCommands.cs @@ -707,8 +707,41 @@ namespace SecondBotEvents.Commands { return Failure(tests.Value); } - GetClient().Parcels.ReturnObjects(GetClient().Network.CurrentSim, targetparcel.LocalID, ObjectReturnType.None, null); - return BasicReply("ok"); + // Create a blocking event + AutoResetEvent eventWaitHandle = new(false); + + void OnParcelObjectOwnersReply(object sender, ParcelObjectOwnersReplyEventArgs e) + { + // Signal that the event has been handled + eventWaitHandle.Set(); + if(e.Simulator != GetClient().Network.CurrentSim) + { + return; + } + foreach (ParcelPrimOwners A in e.PrimOwners) + { + ParcelReturnTargeted(A.OwnerID.ToString()); + } + } + + try + { + GetClient().Parcels.ParcelObjectOwnersReply += OnParcelObjectOwnersReply; + GetClient().Parcels.RequestObjectOwners(GetClient().Network.CurrentSim, targetparcel.LocalID); + bool eventTriggered = eventWaitHandle.WaitOne(5000); // 5000ms timeout + + if (!eventTriggered) + { + return Failure("Timed out waiting for ParcelObjectOwnersReply"); + } + return BasicReply("processing request"); + } + finally + { + // Ensure the event handler is removed to avoid memory leaks + GetClient().Parcels.ParcelObjectOwnersReply -= OnParcelObjectOwnersReply; + + } }