From 4bcb3f72a1f992103e57b8ee6591b1762d7e152d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 15 Aug 2020 22:02:53 +0100 Subject: [PATCH] change llTransferLindenDollars --- .../Shared/Api/Implementation/LSL_Api.cs | 124 ++++++++++-------- 1 file changed, 69 insertions(+), 55 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 006dfbd39e..62c021f54d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -16899,56 +16899,77 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key llTransferLindenDollars(LSL_Key destination, LSL_Integer amount) { - UUID txn = UUID.Random(); + m_host.AddScriptLPS(1); - Util.FireAndForget(delegate(object x) + IMoneyModule money = World.RequestModuleInterface(); + UUID txn = UUID.Random(); + UUID toID = UUID.Zero; + + string replydata = "UnKnownError"; + bool bad = true; + while(true) + { + if (amount <= 0) + { + replydata = "INVALID_AMOUNT"; + break; + } + + if (money == null) + { + replydata = "TRANSFERS_DISABLED"; + break; + } + + if (m_host.OwnerID == m_host.GroupID) + { + replydata = "GROUP_OWNED"; + break; + } + + if (m_item == null) + { + replydata = "SERVICE_ERROR"; + break; + } + + if (m_item.PermsGranter == UUID.Zero) + { + replydata = "MISSING_PERMISSION_DEBIT"; + break; + } + + if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) + { + replydata = "MISSING_PERMISSION_DEBIT"; + break; + } + + if (!UUID.TryParse(destination, out toID)) + { + replydata = "INVALID_AGENT"; + break; + } + bad = false; + break; + } + if(bad) + { + m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( + "transaction_result", new Object[] { + new LSL_String(txn.ToString()), + new LSL_Integer(0), + new LSL_String(replydata) }, + new DetectParams[0])); + return txn.ToString(); + } + + //fire and forget... + Action act = eventID => { int replycode = 0; - string replydata = destination + "," + amount.ToString(); - try { - if (amount <= 0) - { - replydata = "INVALID_AMOUNT"; - return; - } - - TaskInventoryItem item = m_item; - if (item == null) - { - replydata = "SERVICE_ERROR"; - return; - } - - if (m_host.OwnerID == m_host.GroupID) - { - replydata = "GROUP_OWNED"; - return; - } - - m_host.AddScriptLPS(1); - - if (item.PermsGranter == UUID.Zero) - { - replydata = "MISSING_PERMISSION_DEBIT"; - return; - } - - if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) - { - replydata = "MISSING_PERMISSION_DEBIT"; - return; - } - - UUID toID = new UUID(); - - if (!UUID.TryParse(destination, out toID)) - { - replydata = "INVALID_AGENT"; - return; - } - UserAccount account = m_userAccountService.GetUserAccount(RegionScopeID, toID); if (account == null) { @@ -16956,22 +16977,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - IMoneyModule money = World.RequestModuleInterface(); - - if (money == null) - { - replydata = "TRANSFERS_DISABLED"; - return; - } - bool result = money.ObjectGiveMoney( m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount, txn, out string reason); if (result) { replycode = 1; + replydata = destination + "," + amount.ToString(); return; } - replydata = reason; } finally @@ -16983,8 +16996,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api new LSL_String(replydata) }, new DetectParams[0])); } - }, null, "LSL_Api.llTransferLindenDollars"); + }; + m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, act); return txn.ToString(); }