add first code to process parcel buy pass. Still testing, and still no kick on expire ( does expire on entry )

0.9.0-post-fixes
UbitUmarov 2017-07-25 01:30:35 +01:00
parent 13564aa984
commit 81d1ebc510
1 changed files with 89 additions and 1 deletions

View File

@ -41,6 +41,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Capabilities; using OpenSim.Framework.Capabilities;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Framework.Monitoring;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -216,6 +217,7 @@ namespace OpenSim.Region.CoreModules.World.Land
client.OnParcelEjectUser += ClientOnParcelEjectUser; client.OnParcelEjectUser += ClientOnParcelEjectUser;
client.OnParcelFreezeUser += ClientOnParcelFreezeUser; client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
client.OnSetStartLocationRequest += ClientOnSetHome; client.OnSetStartLocationRequest += ClientOnSetHome;
client.OnParcelBuyPass += ClientParcelBuyPass;
} }
public void EventMakeChildAgent(ScenePresence avatar) public void EventMakeChildAgent(ScenePresence avatar)
@ -537,6 +539,92 @@ namespace OpenSim.Region.CoreModules.World.Land
} }
} }
public void ClientParcelBuyPass(IClientAPI remote_client, UUID targetID, int landLocalID)
{
ILandObject land;
lock (m_landList)
{
m_landList.TryGetValue(landLocalID, out land);
}
// trivial checks
if(land == null)
return;
LandData ldata = land.LandData;
if(ldata == null)
return;
if(ldata.OwnerID == targetID)
return;
if(ldata.PassHours == 0)
return;
if((ldata.Flags & (uint)ParcelFlags.UsePassList) == 0)
return;
int cost = ldata.PassPrice;
int idx = land.LandData.ParcelAccessList.FindIndex(
delegate(LandAccessEntry e)
{
if (e.AgentID == targetID && e.Flags == AccessList.Access)
return true;
return false;
});
int expires = Util.UnixTimeSinceEpoch() + (int)(3600.0 * ldata.PassHours);
if (idx != -1)
{
if(ldata.ParcelAccessList[idx].Expires == 0)
{
remote_client.SendAgentAlertMessage("You already have access to parcel", false);
return;
}
if(expires < land.LandData.ParcelAccessList[idx].Expires - 300f)
{
remote_client.SendAgentAlertMessage("Your pass to parcel is still valid for 5 minutes", false);
return;
}
}
LandAccessEntry entry = new LandAccessEntry();
entry.AgentID = targetID;
entry.Flags = AccessList.Access;
entry.Expires = expires;
IMoneyModule mm = m_scene.RequestModuleInterface<IMoneyModule>();
if(cost != 0 && mm != null)
{
WorkManager.RunInThreadPool(
delegate
{
if (!mm.AmountCovered(remote_client.AgentId, cost))
{
remote_client.SendAgentAlertMessage("Insufficient funds", true);
return;
}
mm.ApplyCharge(remote_client.AgentId, cost, MoneyTransactionType.LandPassSale);
if (idx != -1)
ldata.ParcelAccessList.RemoveAt(idx);
ldata.ParcelAccessList.Add(entry);
m_scene.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land);
return;
}, null, "ParcelBuyPass");
}
else
{
if (idx != -1)
ldata.ParcelAccessList.RemoveAt(idx);
ldata.ParcelAccessList.Add(entry);
m_scene.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land);
}
}
public void ClientOnParcelAccessListRequest(UUID agentID, UUID sessionID, uint flags, int sequenceID, public void ClientOnParcelAccessListRequest(UUID agentID, UUID sessionID, uint flags, int sequenceID,
int landLocalID, IClientAPI remote_client) int landLocalID, IClientAPI remote_client)
{ {
@ -1769,7 +1857,7 @@ namespace OpenSim.Region.CoreModules.World.Land
land_update.MusicURL = properties.MusicURL; land_update.MusicURL = properties.MusicURL;
land_update.Name = properties.Name; land_update.Name = properties.Name;
land_update.ParcelFlags = (uint) properties.ParcelFlags; land_update.ParcelFlags = (uint) properties.ParcelFlags;
land_update.PassHours = (int) properties.PassHours; land_update.PassHours = properties.PassHours;
land_update.PassPrice = (int) properties.PassPrice; land_update.PassPrice = (int) properties.PassPrice;
land_update.SalePrice = (int) properties.SalePrice; land_update.SalePrice = (int) properties.SalePrice;
land_update.SnapshotID = properties.SnapshotID; land_update.SnapshotID = properties.SnapshotID;