diff options
author | Melanie Thielker | 2008-08-24 00:51:21 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-08-24 00:51:21 +0000 |
commit | 63b6ab467a2d617b180284861baba544cac602d2 (patch) | |
tree | 87f6589c04dd0340abffe61c5483c899ecc3cf0f /OpenSim | |
parent | Mantis#2036. Thank you kindly, HomerHorwitz for a patch that: (diff) | |
download | opensim-SC-63b6ab467a2d617b180284861baba544cac602d2.zip opensim-SC-63b6ab467a2d617b180284861baba544cac602d2.tar.gz opensim-SC-63b6ab467a2d617b180284861baba544cac602d2.tar.bz2 opensim-SC-63b6ab467a2d617b180284861baba544cac602d2.tar.xz |
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.
Diffstat (limited to 'OpenSim')
7 files changed, 125 insertions, 5 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 8aac9ce..b2d13c7 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -271,6 +271,9 @@ namespace OpenSim.Framework | |||
271 | public delegate void ScriptAnswer(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID, int answer); | 271 | public delegate void ScriptAnswer(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID, int answer); |
272 | 272 | ||
273 | public delegate void RequestPayPrice(IClientAPI remoteClient, LLUUID objectID); | 273 | public delegate void RequestPayPrice(IClientAPI remoteClient, LLUUID objectID); |
274 | public delegate void ObjectSaleInfo(IClientAPI remoteClient, LLUUID agentID, LLUUID sessionID, uint localID, byte saleType, int salePrice); | ||
275 | public delegate void ObjectBuy(IClientAPI remoteClient, LLUUID agentID, LLUUID sessionID, LLUUID groupID, LLUUID categoryID, uint localID, byte saleType, int salePrice); | ||
276 | public delegate void BuyObjectInventory(IClientAPI remoteClient, LLUUID agentID, LLUUID sessionID, LLUUID objectID, LLUUID itemID, LLUUID folderID); | ||
274 | 277 | ||
275 | public delegate void ForceReleaseControls(IClientAPI remoteClient, LLUUID agentID); | 278 | public delegate void ForceReleaseControls(IClientAPI remoteClient, LLUUID agentID); |
276 | 279 | ||
@@ -475,6 +478,9 @@ namespace OpenSim.Framework | |||
475 | event UpdateAvatarProperties OnUpdateAvatarProperties; | 478 | event UpdateAvatarProperties OnUpdateAvatarProperties; |
476 | event ParcelBuy OnParcelBuy; | 479 | event ParcelBuy OnParcelBuy; |
477 | event RequestPayPrice OnRequestPayPrice; | 480 | event RequestPayPrice OnRequestPayPrice; |
481 | event ObjectSaleInfo OnObjectSaleInfo; | ||
482 | event ObjectBuy OnObjectBuy; | ||
483 | event BuyObjectInventory OnBuyObjectInventory; | ||
478 | 484 | ||
479 | event ObjectIncludeInSearch OnObjectIncludeInSearch; | 485 | event ObjectIncludeInSearch OnObjectIncludeInSearch; |
480 | 486 | ||
@@ -688,7 +694,7 @@ namespace OpenSim.Framework | |||
688 | LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, | 694 | LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, |
689 | LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, | 695 | LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, |
690 | string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, | 696 | string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, |
691 | uint BaseMask); | 697 | uint BaseMask, byte saleType, int salePrice); |
692 | void SendAgentOffline(LLUUID[] agentIDs); | 698 | void SendAgentOffline(LLUUID[] agentIDs); |
693 | 699 | ||
694 | void SendAgentOnline(LLUUID[] agentIDs); | 700 | void SendAgentOnline(LLUUID[] agentIDs); |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 83a1181..7c531f3 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -233,6 +233,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
233 | 233 | ||
234 | private ScriptAnswer handlerScriptAnswer = null; | 234 | private ScriptAnswer handlerScriptAnswer = null; |
235 | private RequestPayPrice handlerRequestPayPrice = null; | 235 | private RequestPayPrice handlerRequestPayPrice = null; |
236 | private ObjectSaleInfo handlerObjectSaleInfo = null; | ||
237 | private ObjectBuy handlerObjectBuy = null; | ||
238 | private BuyObjectInventory handlerBuyObjectInventory = null; | ||
236 | private ObjectDeselect handlerObjectDetach = null; | 239 | private ObjectDeselect handlerObjectDetach = null; |
237 | private AgentSit handlerOnUndo = null; | 240 | private AgentSit handlerOnUndo = null; |
238 | 241 | ||
@@ -905,6 +908,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
905 | public event UUIDNameRequest OnUUIDGroupNameRequest; | 908 | public event UUIDNameRequest OnUUIDGroupNameRequest; |
906 | public event ScriptAnswer OnScriptAnswer; | 909 | public event ScriptAnswer OnScriptAnswer; |
907 | public event RequestPayPrice OnRequestPayPrice; | 910 | public event RequestPayPrice OnRequestPayPrice; |
911 | public event ObjectSaleInfo OnObjectSaleInfo; | ||
912 | public event ObjectBuy OnObjectBuy; | ||
913 | public event BuyObjectInventory OnBuyObjectInventory; | ||
908 | public event AgentSit OnUndo; | 914 | public event AgentSit OnUndo; |
909 | public event ForceReleaseControls OnForceReleaseControls; | 915 | public event ForceReleaseControls OnForceReleaseControls; |
910 | public event GodLandStatRequest OnLandStatRequest; | 916 | public event GodLandStatRequest OnLandStatRequest; |
@@ -2523,7 +2529,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2523 | LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, | 2529 | LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, |
2524 | LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, | 2530 | LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, |
2525 | string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, | 2531 | string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, |
2526 | uint BaseMask) | 2532 | uint BaseMask, byte saleType, int salePrice) |
2527 | { | 2533 | { |
2528 | ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties); | 2534 | ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties); |
2529 | // TODO: don't create new blocks if recycling an old packet | 2535 | // TODO: don't create new blocks if recycling an old packet |
@@ -2556,6 +2562,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2556 | // proper.ObjectData[0].AggregatePerms = 53; | 2562 | // proper.ObjectData[0].AggregatePerms = 53; |
2557 | // proper.ObjectData[0].AggregatePermTextures = 0; | 2563 | // proper.ObjectData[0].AggregatePermTextures = 0; |
2558 | // proper.ObjectData[0].AggregatePermTexturesOwner = 0; | 2564 | // proper.ObjectData[0].AggregatePermTexturesOwner = 0; |
2565 | proper.ObjectData[0].SaleType = saleType; | ||
2566 | proper.ObjectData[0].SalePrice = salePrice; | ||
2559 | proper.Header.Zerocoded = true; | 2567 | proper.Header.Zerocoded = true; |
2560 | OutPacket(proper, ThrottleOutPacketType.Task); | 2568 | OutPacket(proper, ThrottleOutPacketType.Task); |
2561 | } | 2569 | } |
@@ -5864,6 +5872,45 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5864 | } | 5872 | } |
5865 | break; | 5873 | break; |
5866 | 5874 | ||
5875 | case PacketType.ObjectSaleInfo: | ||
5876 | ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack; | ||
5877 | handlerObjectSaleInfo = OnObjectSaleInfo; | ||
5878 | if (handlerObjectSaleInfo != null) | ||
5879 | { | ||
5880 | foreach (ObjectSaleInfoPacket.ObjectDataBlock d | ||
5881 | in objectSaleInfoPacket.ObjectData) | ||
5882 | { | ||
5883 | handlerObjectSaleInfo(this, | ||
5884 | objectSaleInfoPacket.AgentData.AgentID, | ||
5885 | objectSaleInfoPacket.AgentData.SessionID, | ||
5886 | d.LocalID, | ||
5887 | d.SaleType, | ||
5888 | d.SalePrice); | ||
5889 | } | ||
5890 | } | ||
5891 | break; | ||
5892 | |||
5893 | case PacketType.ObjectBuy: | ||
5894 | ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack; | ||
5895 | handlerObjectBuy = OnObjectBuy; | ||
5896 | Console.WriteLine(objectBuyPacket.ToString()); | ||
5897 | if (handlerObjectBuy != null) | ||
5898 | { | ||
5899 | foreach (ObjectBuyPacket.ObjectDataBlock d | ||
5900 | in objectBuyPacket.ObjectData) | ||
5901 | { | ||
5902 | handlerObjectBuy(this, | ||
5903 | objectBuyPacket.AgentData.AgentID, | ||
5904 | objectBuyPacket.AgentData.SessionID, | ||
5905 | objectBuyPacket.AgentData.GroupID, | ||
5906 | objectBuyPacket.AgentData.CategoryID, | ||
5907 | d.ObjectLocalID, | ||
5908 | d.SaleType, | ||
5909 | d.SalePrice); | ||
5910 | } | ||
5911 | } | ||
5912 | break; | ||
5913 | |||
5867 | #endregion | 5914 | #endregion |
5868 | 5915 | ||
5869 | #region Script Packets | 5916 | #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 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 | |||
354 | client.OnEconomyDataRequest += EconomyDataRequestHandler; | 354 | client.OnEconomyDataRequest += EconomyDataRequestHandler; |
355 | client.OnMoneyBalanceRequest += SendMoneyBalance; | 355 | client.OnMoneyBalanceRequest += SendMoneyBalance; |
356 | client.OnRequestPayPrice += requestPayPrice; | 356 | client.OnRequestPayPrice += requestPayPrice; |
357 | client.OnObjectBuy += ObjectBuy; | ||
357 | client.OnLogout += ClientClosed; | 358 | client.OnLogout += ClientClosed; |
358 | } | 359 | } |
359 | 360 | ||
@@ -1554,6 +1555,40 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney | |||
1554 | } | 1555 | } |
1555 | 1556 | ||
1556 | #endregion | 1557 | #endregion |
1558 | |||
1559 | public void ObjectBuy(IClientAPI remoteClient, LLUUID agentID, | ||
1560 | LLUUID sessionID, LLUUID groupID, LLUUID categoryID, | ||
1561 | uint localID, byte saleType, int salePrice) | ||
1562 | { | ||
1563 | GetClientFunds(remoteClient); | ||
1564 | |||
1565 | if (!m_KnownClientFunds.ContainsKey(remoteClient.AgentId)) | ||
1566 | { | ||
1567 | remoteClient.SendAgentAlertMessage("Unable to buy now. Your account balance was not found.", false); | ||
1568 | return; | ||
1569 | } | ||
1570 | |||
1571 | int funds = m_KnownClientFunds[remoteClient.AgentId]; | ||
1572 | |||
1573 | if(salePrice != 0 && funds < salePrice) | ||
1574 | { | ||
1575 | remoteClient.SendAgentAlertMessage("Unable to buy now. You don't have sufficient funds.", false); | ||
1576 | return; | ||
1577 | } | ||
1578 | |||
1579 | Scene s = LocateSceneClientIn(remoteClient.AgentId); | ||
1580 | |||
1581 | SceneObjectPart part = s.GetSceneObjectPart(localID); | ||
1582 | if (part == null) | ||
1583 | { | ||
1584 | remoteClient.SendAgentAlertMessage("Unable to buy now. The object was not found.", false); | ||
1585 | return; | ||
1586 | } | ||
1587 | |||
1588 | bool transactionresult = doMoneyTransfer(remoteClient.AgentId, part.OwnerID, salePrice, 5000, "Object buy"); | ||
1589 | |||
1590 | s.PerformObjectBuy(remoteClient, categoryID, localID, saleType); | ||
1591 | } | ||
1557 | } | 1592 | } |
1558 | 1593 | ||
1559 | public enum TransactionType : int | 1594 | 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 | |||
274 | 274 | ||
275 | public event ScriptAnswer OnScriptAnswer; | 275 | public event ScriptAnswer OnScriptAnswer; |
276 | public event RequestPayPrice OnRequestPayPrice; | 276 | public event RequestPayPrice OnRequestPayPrice; |
277 | public event ObjectSaleInfo OnObjectSaleInfo; | ||
278 | public event ObjectBuy OnObjectBuy; | ||
279 | public event BuyObjectInventory OnBuyObjectInventory; | ||
277 | public event AgentSit OnUndo; | 280 | public event AgentSit OnUndo; |
278 | 281 | ||
279 | public event ForceReleaseControls OnForceReleaseControls; | 282 | public event ForceReleaseControls OnForceReleaseControls; |
@@ -695,7 +698,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC | |||
695 | LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, | 698 | LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, |
696 | LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, | 699 | LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, |
697 | string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, | 700 | string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, |
698 | uint BaseMask) | 701 | uint BaseMask, byte saleType, int salePrice) |
699 | { | 702 | { |
700 | } | 703 | } |
701 | 704 | ||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 3bae463..c44a714 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -2153,6 +2153,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
2153 | client.OnUndo += m_innerScene.HandleUndo; | 2153 | client.OnUndo += m_innerScene.HandleUndo; |
2154 | client.OnObjectGroupRequest += m_innerScene.HandleObjectGroupUpdate; | 2154 | client.OnObjectGroupRequest += m_innerScene.HandleObjectGroupUpdate; |
2155 | client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel; | 2155 | client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel; |
2156 | client.OnObjectSaleInfo += ObjectSaleInfo; | ||
2156 | client.OnScriptReset += ProcessScriptReset; | 2157 | client.OnScriptReset += ProcessScriptReset; |
2157 | client.OnGetScriptRunning += GetScriptRunning; | 2158 | client.OnGetScriptRunning += GetScriptRunning; |
2158 | client.OnSetScriptRunning += SetScriptRunning; | 2159 | client.OnSetScriptRunning += SetScriptRunning; |
@@ -3924,5 +3925,28 @@ namespace OpenSim.Region.Environment.Scenes | |||
3924 | 3925 | ||
3925 | return inv.NeedSceneCacheClear(agentID, this); | 3926 | return inv.NeedSceneCacheClear(agentID, this); |
3926 | } | 3927 | } |
3928 | |||
3929 | public void ObjectSaleInfo(IClientAPI client, LLUUID agentID, LLUUID sessionID, uint localID, byte saleType, int salePrice) | ||
3930 | { | ||
3931 | SceneObjectPart part = GetSceneObjectPart(localID); | ||
3932 | if(part == null || part.ParentGroup == null) | ||
3933 | return; | ||
3934 | |||
3935 | if(part.ParentGroup.RootPart == null) | ||
3936 | return; | ||
3937 | |||
3938 | part = part.ParentGroup.RootPart; | ||
3939 | |||
3940 | part.ObjectSaleType = saleType; | ||
3941 | part.SalePrice = salePrice; | ||
3942 | |||
3943 | m_log.DebugFormat("[SCENE] Set sale data of object {0} to {1} ${2}", part.UUID, saleType, salePrice); | ||
3944 | part.GetProperties(client); | ||
3945 | } | ||
3946 | |||
3947 | public void PerformObjectBuy(IClientAPI remoteClient, LLUUID categoryID, | ||
3948 | uint localID, byte saleType) | ||
3949 | { | ||
3950 | } | ||
3927 | } | 3951 | } |
3928 | } | 3952 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 517114f..927791f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -1500,7 +1500,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
1500 | _groupID, (short)InventorySerial, _lastOwnerID, UUID, _ownerID, | 1500 | _groupID, (short)InventorySerial, _lastOwnerID, UUID, _ownerID, |
1501 | ParentGroup.RootPart.TouchName, new byte[0], ParentGroup.RootPart.SitName, Name, Description, | 1501 | ParentGroup.RootPart.TouchName, new byte[0], ParentGroup.RootPart.SitName, Name, Description, |
1502 | ParentGroup.RootPart._ownerMask, ParentGroup.RootPart._nextOwnerMask, ParentGroup.RootPart._groupMask, ParentGroup.RootPart._everyoneMask, | 1502 | ParentGroup.RootPart._ownerMask, ParentGroup.RootPart._nextOwnerMask, ParentGroup.RootPart._groupMask, ParentGroup.RootPart._everyoneMask, |
1503 | ParentGroup.RootPart._baseMask); | 1503 | ParentGroup.RootPart._baseMask, |
1504 | ParentGroup.RootPart.ObjectSaleType, | ||
1505 | ParentGroup.RootPart.SalePrice); | ||
1504 | } | 1506 | } |
1505 | 1507 | ||
1506 | public LLUUID GetRootPartUUID() | 1508 | public LLUUID GetRootPartUUID() |
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index e2e7081..655dfe4 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs | |||
@@ -176,6 +176,9 @@ namespace OpenSim.Region.Examples.SimpleModule | |||
176 | 176 | ||
177 | public event ScriptAnswer OnScriptAnswer; | 177 | public event ScriptAnswer OnScriptAnswer; |
178 | public event RequestPayPrice OnRequestPayPrice; | 178 | public event RequestPayPrice OnRequestPayPrice; |
179 | public event ObjectSaleInfo OnObjectSaleInfo; | ||
180 | public event ObjectBuy OnObjectBuy; | ||
181 | public event BuyObjectInventory OnBuyObjectInventory; | ||
179 | public event AgentSit OnUndo; | 182 | public event AgentSit OnUndo; |
180 | 183 | ||
181 | public event ForceReleaseControls OnForceReleaseControls; | 184 | public event ForceReleaseControls OnForceReleaseControls; |
@@ -615,7 +618,7 @@ namespace OpenSim.Region.Examples.SimpleModule | |||
615 | LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, | 618 | LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, |
616 | LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, | 619 | LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, |
617 | string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, | 620 | string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, |
618 | uint BaseMask) | 621 | uint BaseMask, byte saleType, int salePrice) |
619 | { | 622 | { |
620 | } | 623 | } |
621 | 624 | ||