mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 01:06:30 +08:00
* Fixed a few warnings.
* Added license info to a few files it was missing from. * Fleshed out the landbuy interfaces * If you add '-helperuri http://127.0.0.1:9000/' to your list of parameters you tell the client to use when you start it up you can transfer ownership of parcels now in standalone. Structured gridmode requires a lot more work, see the documentation in the example money module. The example money module is not secure especially in standalone mode.
This commit is contained in:
@@ -39,12 +39,20 @@ using OpenSim.Region.Environment.Scenes;
|
||||
using Nwc.XmlRpc;
|
||||
|
||||
using MoneyTransferArgs = OpenSim.Region.Environment.Scenes.EventManager.MoneyTransferArgs;
|
||||
using LandBuyArgs = OpenSim.Region.Environment.Scenes.EventManager.LandBuyArgs;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
/// <summary>
|
||||
/// Demo Economy/Money Module. This is not a production quality money/economy module!
|
||||
/// This is a demo for you to use when making one that works for you.
|
||||
/// // To use the following you need to add:
|
||||
/// -helperuri <ADDRESS TO HERE OR grid MONEY SERVER>
|
||||
/// to the command line parameters you use to start up your client
|
||||
/// This commonly looks like -helperuri http://127.0.0.1:9000/
|
||||
///
|
||||
/// Centralized grid structure example using OpenSimWi Redux revision 9+
|
||||
/// svn co https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux
|
||||
/// </summary>
|
||||
public class BetaGridLikeMoneyModule: IRegionModule
|
||||
{
|
||||
@@ -134,6 +142,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
if (m_MoneyAddress.Length > 0)
|
||||
{
|
||||
// Centralized grid structure using OpenSimWi Redux revision 9+
|
||||
// https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux
|
||||
scene.AddXmlRPCHandler("dynamic_balance_update_request", GridMoneyUpdate);
|
||||
}
|
||||
else
|
||||
@@ -165,6 +174,8 @@ namespace OpenSim.Region.Environment.Modules
|
||||
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
|
||||
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
|
||||
scene.EventManager.OnClientClosed += ClientLoggedOut;
|
||||
scene.EventManager.OnLandBuy += ValidateLandBuy;
|
||||
scene.EventManager.OnValidatedLandBuy += processLandBuy;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -329,6 +340,101 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateLandBuy (Object osender, LandBuyArgs e)
|
||||
{
|
||||
LLUUID agentId = e.agentId;
|
||||
int price = e.parcelPrice;
|
||||
bool final = e.final;
|
||||
|
||||
int funds = 0;
|
||||
|
||||
if (m_MoneyAddress.Length > 0)
|
||||
{
|
||||
IClientAPI aClient = LocateClientObject(agentId);
|
||||
if (aClient != null)
|
||||
{
|
||||
Scene s = LocateSceneClientIn(agentId);
|
||||
if (s != null)
|
||||
{
|
||||
Hashtable hbinfo = GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(), s.RegionInfo.regionSecret);
|
||||
if ((bool)hbinfo["success"] == true)
|
||||
{
|
||||
|
||||
Helpers.TryParse((string)hbinfo["agentId"], out agentId);
|
||||
try
|
||||
{
|
||||
funds = (Int32)hbinfo["funds"];
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
m_log.ErrorFormat("[MONEY]: While getting the Currency for user {0}, the return funds overflowed.", agentId);
|
||||
aClient.SendAlertMessage("Unable to get your money balance, money operations will be unavailable");
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
funds = 0;
|
||||
}
|
||||
|
||||
SetLocalFundsForAgentID(agentId, funds);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId, (string)hbinfo["errorMessage"]);
|
||||
aClient.SendAlertMessage((string)hbinfo["errorMessage"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
funds = GetFundsForAgentID(agentId);
|
||||
}
|
||||
if (funds >= e.parcelPrice)
|
||||
{
|
||||
lock (e)
|
||||
{
|
||||
e.economyValidated = true;
|
||||
}
|
||||
XMLRPCHandler.EventManager.TriggerValidatedLandBuy(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void processLandBuy(Object osender, LandBuyArgs e)
|
||||
{
|
||||
LLUUID agentId = e.agentId;
|
||||
int price = e.parcelPrice;
|
||||
bool final = e.final;
|
||||
|
||||
int funds = 0;
|
||||
|
||||
// Only do this if we have not already transacted against this.
|
||||
if (e.transactionID == 0)
|
||||
{
|
||||
funds = GetFundsForAgentID(e.agentId);
|
||||
if (e.landValidated)
|
||||
{
|
||||
if (e.parcelPrice >= 0)
|
||||
{
|
||||
doMoneyTranfer(agentId, e.parcelOwnerID, e.parcelPrice);
|
||||
lock (e)
|
||||
{
|
||||
e.transactionID = Util.UnixTimeSinceEpoch();
|
||||
e.amountDebited = e.parcelPrice;
|
||||
}
|
||||
}
|
||||
// This tells the land module that we've transacted.
|
||||
XMLRPCHandler.EventManager.TriggerValidatedLandBuy(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// THis method gets called when someone pays someone else as a gift.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,7 +1,33 @@
|
||||
using System;
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Axiom.Math;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
@@ -11,6 +37,8 @@ using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
|
||||
using LandBuyArgs = OpenSim.Region.Environment.Scenes.EventManager.LandBuyArgs;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules.LandManagement
|
||||
{
|
||||
public class LandChannel : ILandChannel
|
||||
@@ -232,6 +260,18 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
|
||||
}
|
||||
}
|
||||
|
||||
public ILandObject getLandObject(int parcelLocalID)
|
||||
{
|
||||
lock (landList)
|
||||
{
|
||||
if (landList.ContainsKey(parcelLocalID))
|
||||
{
|
||||
return landList[parcelLocalID];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ILandObject getLandObject(int x, int y)
|
||||
{
|
||||
if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0)
|
||||
@@ -657,6 +697,7 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
|
||||
if (landList.ContainsKey(packet.ParcelData.LocalID))
|
||||
{
|
||||
landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,5 +953,49 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
|
||||
}
|
||||
}
|
||||
|
||||
public void handleLandBuyRequest(Object o, LandBuyArgs e)
|
||||
{
|
||||
if (e.economyValidated && e.landValidated)
|
||||
{
|
||||
lock (landList)
|
||||
{
|
||||
if (landList.ContainsKey(e.parcelLocalID))
|
||||
{
|
||||
landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint)e.transactionID, e.parcelPrice, e.parcelArea);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.landValidated == false)
|
||||
{
|
||||
ILandObject lob = null;
|
||||
lock (landList)
|
||||
{
|
||||
if (landList.ContainsKey(e.parcelLocalID))
|
||||
{
|
||||
lob = landList[e.parcelLocalID];
|
||||
}
|
||||
}
|
||||
if (lob != null)
|
||||
{
|
||||
LLUUID AuthorizedID = lob.landData.authBuyerID;
|
||||
int saleprice = lob.landData.salePrice;
|
||||
LLUUID pOwnerID = lob.landData.ownerID;
|
||||
|
||||
bool landforsale = ((lob.landData.landFlags & (uint)(libsecondlife.Parcel.ParcelFlags.ForSale | libsecondlife.Parcel.ParcelFlags.ForSaleObjects | libsecondlife.Parcel.ParcelFlags.SellParcelObjects)) != 0);
|
||||
if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale)
|
||||
{
|
||||
lock (e)
|
||||
{
|
||||
e.parcelOwnerID = pOwnerID;
|
||||
e.landValidated = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
m_scene.EventManager.TriggerValidatedLandBuy(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
using System;
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
@@ -8,6 +35,8 @@ using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using Nini.Config;
|
||||
|
||||
using LandBuyArgs = OpenSim.Region.Environment.Scenes.EventManager.LandBuyArgs;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules.LandManagement
|
||||
{
|
||||
public class LandManagementModule : IRegionModule
|
||||
@@ -26,6 +55,8 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
|
||||
m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts;
|
||||
m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel);
|
||||
m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement);
|
||||
m_scene.EventManager.OnLandBuy += landChannel.handleLandBuyRequest;
|
||||
m_scene.EventManager.OnValidatedLandBuy += landChannel.handleLandBuyRequest;
|
||||
|
||||
lock (m_scene)
|
||||
{
|
||||
|
||||
@@ -256,12 +256,28 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
|
||||
newData.snapshotID = packet.ParcelData.SnapshotID;
|
||||
newData.userLocation = packet.ParcelData.UserLocation;
|
||||
newData.userLookAt = packet.ParcelData.UserLookAt;
|
||||
|
||||
|
||||
m_scene.LandChannel.updateLandObject(landData.localID, newData);
|
||||
|
||||
sendLandUpdateToAvatarsOverMe();
|
||||
}
|
||||
}
|
||||
public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area)
|
||||
{
|
||||
LandData newData = landData.Copy();
|
||||
newData.ownerID = avatarID;
|
||||
newData.groupID = groupID;
|
||||
newData.isGroupOwned = groupOwned;
|
||||
//newData.auctionID = AuctionID;
|
||||
newData.claimDate = Util.UnixTimeSinceEpoch();
|
||||
newData.claimPrice = claimprice;
|
||||
newData.salePrice = 0;
|
||||
newData.authBuyerID = LLUUID.Zero;
|
||||
newData.landFlags &= ~(uint)(libsecondlife.Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects);
|
||||
m_scene.LandChannel.updateLandObject(landData.localID, newData);
|
||||
|
||||
sendLandUpdateToAvatarsOverMe();
|
||||
}
|
||||
|
||||
public bool isEitherBannedOrRestricted(LLUUID avatar)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user