diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 8aac9ce88e..b2d13c7874 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -271,6 +271,9 @@ namespace OpenSim.Framework public delegate void ScriptAnswer(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID, int answer); public delegate void RequestPayPrice(IClientAPI remoteClient, LLUUID objectID); + public delegate void ObjectSaleInfo(IClientAPI remoteClient, LLUUID agentID, LLUUID sessionID, uint localID, byte saleType, int salePrice); + public delegate void ObjectBuy(IClientAPI remoteClient, LLUUID agentID, LLUUID sessionID, LLUUID groupID, LLUUID categoryID, uint localID, byte saleType, int salePrice); + public delegate void BuyObjectInventory(IClientAPI remoteClient, LLUUID agentID, LLUUID sessionID, LLUUID objectID, LLUUID itemID, LLUUID folderID); public delegate void ForceReleaseControls(IClientAPI remoteClient, LLUUID agentID); @@ -475,6 +478,9 @@ namespace OpenSim.Framework event UpdateAvatarProperties OnUpdateAvatarProperties; event ParcelBuy OnParcelBuy; event RequestPayPrice OnRequestPayPrice; + event ObjectSaleInfo OnObjectSaleInfo; + event ObjectBuy OnObjectBuy; + event BuyObjectInventory OnBuyObjectInventory; event ObjectIncludeInSearch OnObjectIncludeInSearch; @@ -688,7 +694,7 @@ namespace OpenSim.Framework 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); void SendAgentOffline(LLUUID[] agentIDs); void SendAgentOnline(LLUUID[] agentIDs); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 83a118101d..7c531f3efb 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -233,6 +233,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP private ScriptAnswer handlerScriptAnswer = null; private RequestPayPrice handlerRequestPayPrice = null; + private ObjectSaleInfo handlerObjectSaleInfo = null; + private ObjectBuy handlerObjectBuy = null; + private BuyObjectInventory handlerBuyObjectInventory = null; private ObjectDeselect handlerObjectDetach = null; private AgentSit handlerOnUndo = null; @@ -905,6 +908,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event UUIDNameRequest OnUUIDGroupNameRequest; 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; public event GodLandStatRequest OnLandStatRequest; @@ -2523,7 +2529,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP 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) { ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties); // TODO: don't create new blocks if recycling an old packet @@ -2556,6 +2562,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP // proper.ObjectData[0].AggregatePerms = 53; // proper.ObjectData[0].AggregatePermTextures = 0; // proper.ObjectData[0].AggregatePermTexturesOwner = 0; + proper.ObjectData[0].SaleType = saleType; + proper.ObjectData[0].SalePrice = salePrice; proper.Header.Zerocoded = true; OutPacket(proper, ThrottleOutPacketType.Task); } @@ -5864,6 +5872,45 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.ObjectSaleInfo: + ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack; + handlerObjectSaleInfo = OnObjectSaleInfo; + if (handlerObjectSaleInfo != null) + { + foreach (ObjectSaleInfoPacket.ObjectDataBlock d + in objectSaleInfoPacket.ObjectData) + { + handlerObjectSaleInfo(this, + objectSaleInfoPacket.AgentData.AgentID, + objectSaleInfoPacket.AgentData.SessionID, + d.LocalID, + d.SaleType, + d.SalePrice); + } + } + break; + + case PacketType.ObjectBuy: + ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack; + handlerObjectBuy = OnObjectBuy; + Console.WriteLine(objectBuyPacket.ToString()); + if (handlerObjectBuy != null) + { + foreach (ObjectBuyPacket.ObjectDataBlock d + in objectBuyPacket.ObjectData) + { + handlerObjectBuy(this, + objectBuyPacket.AgentData.AgentID, + objectBuyPacket.AgentData.SessionID, + objectBuyPacket.AgentData.GroupID, + objectBuyPacket.AgentData.CategoryID, + d.ObjectLocalID, + d.SaleType, + d.SalePrice); + } + } + break; + #endregion #region Script Packets diff --git a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs index 4a6828c592..2795358c5f 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 0b0f4c17c4..4754a04ae1 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) { } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 3bae46373b..c44a714ef5 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -2153,6 +2153,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnUndo += m_innerScene.HandleUndo; client.OnObjectGroupRequest += m_innerScene.HandleObjectGroupUpdate; client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel; + client.OnObjectSaleInfo += ObjectSaleInfo; client.OnScriptReset += ProcessScriptReset; client.OnGetScriptRunning += GetScriptRunning; client.OnSetScriptRunning += SetScriptRunning; @@ -3924,5 +3925,28 @@ namespace OpenSim.Region.Environment.Scenes return inv.NeedSceneCacheClear(agentID, this); } + + public void ObjectSaleInfo(IClientAPI client, LLUUID agentID, LLUUID sessionID, uint localID, byte saleType, int salePrice) + { + SceneObjectPart part = GetSceneObjectPart(localID); + if(part == null || part.ParentGroup == null) + return; + + if(part.ParentGroup.RootPart == null) + return; + + part = part.ParentGroup.RootPart; + + part.ObjectSaleType = saleType; + part.SalePrice = salePrice; + + m_log.DebugFormat("[SCENE] Set sale data of object {0} to {1} ${2}", part.UUID, saleType, salePrice); + part.GetProperties(client); + } + + public void PerformObjectBuy(IClientAPI remoteClient, LLUUID categoryID, + uint localID, byte saleType) + { + } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 517114fd27..927791fdce 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -1500,7 +1500,9 @@ namespace OpenSim.Region.Environment.Scenes _groupID, (short)InventorySerial, _lastOwnerID, UUID, _ownerID, ParentGroup.RootPart.TouchName, new byte[0], ParentGroup.RootPart.SitName, Name, Description, ParentGroup.RootPart._ownerMask, ParentGroup.RootPart._nextOwnerMask, ParentGroup.RootPart._groupMask, ParentGroup.RootPart._everyoneMask, - ParentGroup.RootPart._baseMask); + ParentGroup.RootPart._baseMask, + ParentGroup.RootPart.ObjectSaleType, + ParentGroup.RootPart.SalePrice); } public LLUUID GetRootPartUUID() diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index e2e70811db..655dfe4098 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -176,6 +176,9 @@ namespace OpenSim.Region.Examples.SimpleModule 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; @@ -615,7 +618,7 @@ namespace OpenSim.Region.Examples.SimpleModule 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) { }