From 63b6ab467a2d617b180284861baba544cac602d2 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 24 Aug 2008 00:51:21 +0000 Subject: Implements 80% of object buy (prim vendor). You can't buy the object yet, and the for sale setting doesn't survive a sim restart, but this is most of the plumbing. --- .../Currency/SampleMoney/SampleMoneyModule.cs | 35 ++++++++++++++++++++++ .../Environment/Modules/World/NPC/NPCAvatar.cs | 5 +++- 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Environment/Modules') diff --git a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs index 4a6828c..2795358 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs @@ -354,6 +354,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney client.OnEconomyDataRequest += EconomyDataRequestHandler; client.OnMoneyBalanceRequest += SendMoneyBalance; client.OnRequestPayPrice += requestPayPrice; + client.OnObjectBuy += ObjectBuy; client.OnLogout += ClientClosed; } @@ -1554,6 +1555,40 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney } #endregion + + public void ObjectBuy(IClientAPI remoteClient, LLUUID agentID, + LLUUID sessionID, LLUUID groupID, LLUUID categoryID, + uint localID, byte saleType, int salePrice) + { + GetClientFunds(remoteClient); + + if (!m_KnownClientFunds.ContainsKey(remoteClient.AgentId)) + { + remoteClient.SendAgentAlertMessage("Unable to buy now. Your account balance was not found.", false); + return; + } + + int funds = m_KnownClientFunds[remoteClient.AgentId]; + + if(salePrice != 0 && funds < salePrice) + { + remoteClient.SendAgentAlertMessage("Unable to buy now. You don't have sufficient funds.", false); + return; + } + + Scene s = LocateSceneClientIn(remoteClient.AgentId); + + SceneObjectPart part = s.GetSceneObjectPart(localID); + if (part == null) + { + remoteClient.SendAgentAlertMessage("Unable to buy now. The object was not found.", false); + return; + } + + bool transactionresult = doMoneyTransfer(remoteClient.AgentId, part.OwnerID, salePrice, 5000, "Object buy"); + + s.PerformObjectBuy(remoteClient, categoryID, localID, saleType); + } } public enum TransactionType : int diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index 0b0f4c1..4754a04 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -274,6 +274,9 @@ namespace OpenSim.Region.Environment.Modules.World.NPC public event ScriptAnswer OnScriptAnswer; public event RequestPayPrice OnRequestPayPrice; + public event ObjectSaleInfo OnObjectSaleInfo; + public event ObjectBuy OnObjectBuy; + public event BuyObjectInventory OnBuyObjectInventory; public event AgentSit OnUndo; public event ForceReleaseControls OnForceReleaseControls; @@ -695,7 +698,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, - uint BaseMask) + uint BaseMask, byte saleType, int salePrice) { } -- cgit v1.1