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.
0.6.0-stable
Melanie Thielker 2008-08-24 00:51:21 +00:00
parent 89f2148f56
commit 63b6ab467a
7 changed files with 125 additions and 5 deletions

View File

@ -271,6 +271,9 @@ namespace OpenSim.Framework
public delegate void ScriptAnswer(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID, int answer); public delegate void ScriptAnswer(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID, int answer);
public delegate void RequestPayPrice(IClientAPI remoteClient, LLUUID objectID); 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); public delegate void ForceReleaseControls(IClientAPI remoteClient, LLUUID agentID);
@ -475,6 +478,9 @@ namespace OpenSim.Framework
event UpdateAvatarProperties OnUpdateAvatarProperties; event UpdateAvatarProperties OnUpdateAvatarProperties;
event ParcelBuy OnParcelBuy; event ParcelBuy OnParcelBuy;
event RequestPayPrice OnRequestPayPrice; event RequestPayPrice OnRequestPayPrice;
event ObjectSaleInfo OnObjectSaleInfo;
event ObjectBuy OnObjectBuy;
event BuyObjectInventory OnBuyObjectInventory;
event ObjectIncludeInSearch OnObjectIncludeInSearch; event ObjectIncludeInSearch OnObjectIncludeInSearch;
@ -688,7 +694,7 @@ namespace OpenSim.Framework
LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID,
LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName,
string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask,
uint BaseMask); uint BaseMask, byte saleType, int salePrice);
void SendAgentOffline(LLUUID[] agentIDs); void SendAgentOffline(LLUUID[] agentIDs);
void SendAgentOnline(LLUUID[] agentIDs); void SendAgentOnline(LLUUID[] agentIDs);

View File

@ -233,6 +233,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private ScriptAnswer handlerScriptAnswer = null; private ScriptAnswer handlerScriptAnswer = null;
private RequestPayPrice handlerRequestPayPrice = null; private RequestPayPrice handlerRequestPayPrice = null;
private ObjectSaleInfo handlerObjectSaleInfo = null;
private ObjectBuy handlerObjectBuy = null;
private BuyObjectInventory handlerBuyObjectInventory = null;
private ObjectDeselect handlerObjectDetach = null; private ObjectDeselect handlerObjectDetach = null;
private AgentSit handlerOnUndo = null; private AgentSit handlerOnUndo = null;
@ -905,6 +908,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event UUIDNameRequest OnUUIDGroupNameRequest; public event UUIDNameRequest OnUUIDGroupNameRequest;
public event ScriptAnswer OnScriptAnswer; public event ScriptAnswer OnScriptAnswer;
public event RequestPayPrice OnRequestPayPrice; public event RequestPayPrice OnRequestPayPrice;
public event ObjectSaleInfo OnObjectSaleInfo;
public event ObjectBuy OnObjectBuy;
public event BuyObjectInventory OnBuyObjectInventory;
public event AgentSit OnUndo; public event AgentSit OnUndo;
public event ForceReleaseControls OnForceReleaseControls; public event ForceReleaseControls OnForceReleaseControls;
public event GodLandStatRequest OnLandStatRequest; public event GodLandStatRequest OnLandStatRequest;
@ -2523,7 +2529,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID,
LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName,
string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, 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); ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
// TODO: don't create new blocks if recycling an old packet // 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].AggregatePerms = 53;
// proper.ObjectData[0].AggregatePermTextures = 0; // proper.ObjectData[0].AggregatePermTextures = 0;
// proper.ObjectData[0].AggregatePermTexturesOwner = 0; // proper.ObjectData[0].AggregatePermTexturesOwner = 0;
proper.ObjectData[0].SaleType = saleType;
proper.ObjectData[0].SalePrice = salePrice;
proper.Header.Zerocoded = true; proper.Header.Zerocoded = true;
OutPacket(proper, ThrottleOutPacketType.Task); OutPacket(proper, ThrottleOutPacketType.Task);
} }
@ -5864,6 +5872,45 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
break; 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 #endregion
#region Script Packets #region Script Packets

View File

@ -354,6 +354,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
client.OnEconomyDataRequest += EconomyDataRequestHandler; client.OnEconomyDataRequest += EconomyDataRequestHandler;
client.OnMoneyBalanceRequest += SendMoneyBalance; client.OnMoneyBalanceRequest += SendMoneyBalance;
client.OnRequestPayPrice += requestPayPrice; client.OnRequestPayPrice += requestPayPrice;
client.OnObjectBuy += ObjectBuy;
client.OnLogout += ClientClosed; client.OnLogout += ClientClosed;
} }
@ -1554,6 +1555,40 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
} }
#endregion #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 public enum TransactionType : int

View File

@ -274,6 +274,9 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
public event ScriptAnswer OnScriptAnswer; public event ScriptAnswer OnScriptAnswer;
public event RequestPayPrice OnRequestPayPrice; public event RequestPayPrice OnRequestPayPrice;
public event ObjectSaleInfo OnObjectSaleInfo;
public event ObjectBuy OnObjectBuy;
public event BuyObjectInventory OnBuyObjectInventory;
public event AgentSit OnUndo; public event AgentSit OnUndo;
public event ForceReleaseControls OnForceReleaseControls; public event ForceReleaseControls OnForceReleaseControls;
@ -695,7 +698,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID,
LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName,
string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask,
uint BaseMask) uint BaseMask, byte saleType, int salePrice)
{ {
} }

View File

@ -2153,6 +2153,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnUndo += m_innerScene.HandleUndo; client.OnUndo += m_innerScene.HandleUndo;
client.OnObjectGroupRequest += m_innerScene.HandleObjectGroupUpdate; client.OnObjectGroupRequest += m_innerScene.HandleObjectGroupUpdate;
client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel; client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel;
client.OnObjectSaleInfo += ObjectSaleInfo;
client.OnScriptReset += ProcessScriptReset; client.OnScriptReset += ProcessScriptReset;
client.OnGetScriptRunning += GetScriptRunning; client.OnGetScriptRunning += GetScriptRunning;
client.OnSetScriptRunning += SetScriptRunning; client.OnSetScriptRunning += SetScriptRunning;
@ -3924,5 +3925,28 @@ namespace OpenSim.Region.Environment.Scenes
return inv.NeedSceneCacheClear(agentID, this); 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)
{
}
} }
} }

View File

@ -1500,7 +1500,9 @@ namespace OpenSim.Region.Environment.Scenes
_groupID, (short)InventorySerial, _lastOwnerID, UUID, _ownerID, _groupID, (short)InventorySerial, _lastOwnerID, UUID, _ownerID,
ParentGroup.RootPart.TouchName, new byte[0], ParentGroup.RootPart.SitName, Name, Description, 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._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() public LLUUID GetRootPartUUID()

View File

@ -176,6 +176,9 @@ namespace OpenSim.Region.Examples.SimpleModule
public event ScriptAnswer OnScriptAnswer; public event ScriptAnswer OnScriptAnswer;
public event RequestPayPrice OnRequestPayPrice; public event RequestPayPrice OnRequestPayPrice;
public event ObjectSaleInfo OnObjectSaleInfo;
public event ObjectBuy OnObjectBuy;
public event BuyObjectInventory OnBuyObjectInventory;
public event AgentSit OnUndo; public event AgentSit OnUndo;
public event ForceReleaseControls OnForceReleaseControls; public event ForceReleaseControls OnForceReleaseControls;
@ -615,7 +618,7 @@ namespace OpenSim.Region.Examples.SimpleModule
LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID, LLUUID GroupUUID, short InventorySerial, LLUUID LastOwnerUUID, LLUUID ObjectUUID,
LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, LLUUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName,
string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask,
uint BaseMask) uint BaseMask, byte saleType, int salePrice)
{ {
} }