aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
authorTeravus Ovares2008-04-14 17:13:38 +0000
committerTeravus Ovares2008-04-14 17:13:38 +0000
commite21886eea0a4d2782a74bb1f974b2e1056fea055 (patch)
tree33512912e98ad07ab04f3370fd48d1d0ed307a66 /OpenSim/Region/Environment/Modules
parent* Get Util.GetHostFromDNS to tell us the dns address it was trying to resolve... (diff)
downloadopensim-SC_OLD-e21886eea0a4d2782a74bb1f974b2e1056fea055.zip
opensim-SC_OLD-e21886eea0a4d2782a74bb1f974b2e1056fea055.tar.gz
opensim-SC_OLD-e21886eea0a4d2782a74bb1f974b2e1056fea055.tar.bz2
opensim-SC_OLD-e21886eea0a4d2782a74bb1f974b2e1056fea055.tar.xz
* 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.
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r--OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs106
-rw-r--r--OpenSim/Region/Environment/Modules/LandManagement/LandChannel.cs89
-rw-r--r--OpenSim/Region/Environment/Modules/LandManagement/LandManagementModule.cs33
-rw-r--r--OpenSim/Region/Environment/Modules/LandManagement/LandObject.cs18
4 files changed, 242 insertions, 4 deletions
diff --git a/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs b/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs
index aabb2d1..d950af9 100644
--- a/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs
+++ b/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs
@@ -39,12 +39,20 @@ using OpenSim.Region.Environment.Scenes;
39using Nwc.XmlRpc; 39using Nwc.XmlRpc;
40 40
41using MoneyTransferArgs = OpenSim.Region.Environment.Scenes.EventManager.MoneyTransferArgs; 41using MoneyTransferArgs = OpenSim.Region.Environment.Scenes.EventManager.MoneyTransferArgs;
42using LandBuyArgs = OpenSim.Region.Environment.Scenes.EventManager.LandBuyArgs;
42 43
43namespace OpenSim.Region.Environment.Modules 44namespace OpenSim.Region.Environment.Modules
44{ 45{
45 /// <summary> 46 /// <summary>
46 /// Demo Economy/Money Module. This is not a production quality money/economy module! 47 /// Demo Economy/Money Module. This is not a production quality money/economy module!
47 /// This is a demo for you to use when making one that works for you. 48 /// This is a demo for you to use when making one that works for you.
49 /// // To use the following you need to add:
50 /// -helperuri <ADDRESS TO HERE OR grid MONEY SERVER>
51 /// to the command line parameters you use to start up your client
52 /// This commonly looks like -helperuri http://127.0.0.1:9000/
53 ///
54 /// Centralized grid structure example using OpenSimWi Redux revision 9+
55 /// svn co https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux
48 /// </summary> 56 /// </summary>
49 public class BetaGridLikeMoneyModule: IRegionModule 57 public class BetaGridLikeMoneyModule: IRegionModule
50 { 58 {
@@ -134,6 +142,7 @@ namespace OpenSim.Region.Environment.Modules
134 if (m_MoneyAddress.Length > 0) 142 if (m_MoneyAddress.Length > 0)
135 { 143 {
136 // Centralized grid structure using OpenSimWi Redux revision 9+ 144 // Centralized grid structure using OpenSimWi Redux revision 9+
145 // https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux
137 scene.AddXmlRPCHandler("dynamic_balance_update_request", GridMoneyUpdate); 146 scene.AddXmlRPCHandler("dynamic_balance_update_request", GridMoneyUpdate);
138 } 147 }
139 else 148 else
@@ -165,6 +174,8 @@ namespace OpenSim.Region.Environment.Modules
165 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; 174 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
166 scene.EventManager.OnMakeChildAgent += MakeChildAgent; 175 scene.EventManager.OnMakeChildAgent += MakeChildAgent;
167 scene.EventManager.OnClientClosed += ClientLoggedOut; 176 scene.EventManager.OnClientClosed += ClientLoggedOut;
177 scene.EventManager.OnLandBuy += ValidateLandBuy;
178 scene.EventManager.OnValidatedLandBuy += processLandBuy;
168 179
169 } 180 }
170 } 181 }
@@ -329,6 +340,101 @@ namespace OpenSim.Region.Environment.Modules
329 } 340 }
330 } 341 }
331 342
343 private void ValidateLandBuy (Object osender, LandBuyArgs e)
344 {
345 LLUUID agentId = e.agentId;
346 int price = e.parcelPrice;
347 bool final = e.final;
348
349 int funds = 0;
350
351 if (m_MoneyAddress.Length > 0)
352 {
353 IClientAPI aClient = LocateClientObject(agentId);
354 if (aClient != null)
355 {
356 Scene s = LocateSceneClientIn(agentId);
357 if (s != null)
358 {
359 Hashtable hbinfo = GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(), s.RegionInfo.regionSecret);
360 if ((bool)hbinfo["success"] == true)
361 {
362
363 Helpers.TryParse((string)hbinfo["agentId"], out agentId);
364 try
365 {
366 funds = (Int32)hbinfo["funds"];
367 }
368 catch (ArgumentException)
369 {
370 }
371 catch (FormatException)
372 {
373 }
374 catch (OverflowException)
375 {
376 m_log.ErrorFormat("[MONEY]: While getting the Currency for user {0}, the return funds overflowed.", agentId);
377 aClient.SendAlertMessage("Unable to get your money balance, money operations will be unavailable");
378 }
379 catch (InvalidCastException)
380 {
381 funds = 0;
382 }
383
384 SetLocalFundsForAgentID(agentId, funds);
385
386 }
387 else
388 {
389 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId, (string)hbinfo["errorMessage"]);
390 aClient.SendAlertMessage((string)hbinfo["errorMessage"]);
391 }
392 }
393 }
394 }
395 else
396 {
397 funds = GetFundsForAgentID(agentId);
398 }
399 if (funds >= e.parcelPrice)
400 {
401 lock (e)
402 {
403 e.economyValidated = true;
404 }
405 XMLRPCHandler.EventManager.TriggerValidatedLandBuy(this, e);
406 }
407 }
408
409 private void processLandBuy(Object osender, LandBuyArgs e)
410 {
411 LLUUID agentId = e.agentId;
412 int price = e.parcelPrice;
413 bool final = e.final;
414
415 int funds = 0;
416
417 // Only do this if we have not already transacted against this.
418 if (e.transactionID == 0)
419 {
420 funds = GetFundsForAgentID(e.agentId);
421 if (e.landValidated)
422 {
423 if (e.parcelPrice >= 0)
424 {
425 doMoneyTranfer(agentId, e.parcelOwnerID, e.parcelPrice);
426 lock (e)
427 {
428 e.transactionID = Util.UnixTimeSinceEpoch();
429 e.amountDebited = e.parcelPrice;
430 }
431 }
432 // This tells the land module that we've transacted.
433 XMLRPCHandler.EventManager.TriggerValidatedLandBuy(this, e);
434 }
435 }
436
437 }
332 /// <summary> 438 /// <summary>
333 /// THis method gets called when someone pays someone else as a gift. 439 /// THis method gets called when someone pays someone else as a gift.
334 /// </summary> 440 /// </summary>
diff --git a/OpenSim/Region/Environment/Modules/LandManagement/LandChannel.cs b/OpenSim/Region/Environment/Modules/LandManagement/LandChannel.cs
index ba5a098..a46895e 100644
--- a/OpenSim/Region/Environment/Modules/LandManagement/LandChannel.cs
+++ b/OpenSim/Region/Environment/Modules/LandManagement/LandChannel.cs
@@ -1,7 +1,33 @@
1using System; 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
2using System.Collections.Generic; 29using System.Collections.Generic;
3using System.Text; 30using System.Text;
4
5using Axiom.Math; 31using Axiom.Math;
6using libsecondlife; 32using libsecondlife;
7using libsecondlife.Packets; 33using libsecondlife.Packets;
@@ -11,6 +37,8 @@ using OpenSim.Region.Environment.Scenes;
11using OpenSim.Region.Environment.Interfaces; 37using OpenSim.Region.Environment.Interfaces;
12using OpenSim.Region.Physics.Manager; 38using OpenSim.Region.Physics.Manager;
13 39
40using LandBuyArgs = OpenSim.Region.Environment.Scenes.EventManager.LandBuyArgs;
41
14namespace OpenSim.Region.Environment.Modules.LandManagement 42namespace OpenSim.Region.Environment.Modules.LandManagement
15{ 43{
16 public class LandChannel : ILandChannel 44 public class LandChannel : ILandChannel
@@ -232,6 +260,18 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
232 } 260 }
233 } 261 }
234 262
263 public ILandObject getLandObject(int parcelLocalID)
264 {
265 lock (landList)
266 {
267 if (landList.ContainsKey(parcelLocalID))
268 {
269 return landList[parcelLocalID];
270 }
271 }
272 return null;
273 }
274
235 public ILandObject getLandObject(int x, int y) 275 public ILandObject getLandObject(int x, int y)
236 { 276 {
237 if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0) 277 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
657 if (landList.ContainsKey(packet.ParcelData.LocalID)) 697 if (landList.ContainsKey(packet.ParcelData.LocalID))
658 { 698 {
659 landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client); 699 landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client);
700
660 } 701 }
661 } 702 }
662 703
@@ -912,5 +953,49 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
912 } 953 }
913 } 954 }
914 955
956 public void handleLandBuyRequest(Object o, LandBuyArgs e)
957 {
958 if (e.economyValidated && e.landValidated)
959 {
960 lock (landList)
961 {
962 if (landList.ContainsKey(e.parcelLocalID))
963 {
964 landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint)e.transactionID, e.parcelPrice, e.parcelArea);
965 return;
966 }
967 }
968 }
969 else if (e.landValidated == false)
970 {
971 ILandObject lob = null;
972 lock (landList)
973 {
974 if (landList.ContainsKey(e.parcelLocalID))
975 {
976 lob = landList[e.parcelLocalID];
977 }
978 }
979 if (lob != null)
980 {
981 LLUUID AuthorizedID = lob.landData.authBuyerID;
982 int saleprice = lob.landData.salePrice;
983 LLUUID pOwnerID = lob.landData.ownerID;
984
985 bool landforsale = ((lob.landData.landFlags & (uint)(libsecondlife.Parcel.ParcelFlags.ForSale | libsecondlife.Parcel.ParcelFlags.ForSaleObjects | libsecondlife.Parcel.ParcelFlags.SellParcelObjects)) != 0);
986 if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale)
987 {
988 lock (e)
989 {
990 e.parcelOwnerID = pOwnerID;
991 e.landValidated = true;
992
993 }
994
995 }
996 }
997 m_scene.EventManager.TriggerValidatedLandBuy(this, e);
998 }
999 }
915 } 1000 }
916} 1001}
diff --git a/OpenSim/Region/Environment/Modules/LandManagement/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/LandManagement/LandManagementModule.cs
index 614929b..6b2de47 100644
--- a/OpenSim/Region/Environment/Modules/LandManagement/LandManagementModule.cs
+++ b/OpenSim/Region/Environment/Modules/LandManagement/LandManagementModule.cs
@@ -1,4 +1,31 @@
1using System; 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
2using System.Collections.Generic; 29using System.Collections.Generic;
3using libsecondlife; 30using libsecondlife;
4using libsecondlife.Packets; 31using libsecondlife.Packets;
@@ -8,6 +35,8 @@ using OpenSim.Region.Environment.Scenes;
8using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
9using Nini.Config; 36using Nini.Config;
10 37
38using LandBuyArgs = OpenSim.Region.Environment.Scenes.EventManager.LandBuyArgs;
39
11namespace OpenSim.Region.Environment.Modules.LandManagement 40namespace OpenSim.Region.Environment.Modules.LandManagement
12{ 41{
13 public class LandManagementModule : IRegionModule 42 public class LandManagementModule : IRegionModule
@@ -26,6 +55,8 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
26 m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts; 55 m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts;
27 m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel); 56 m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel);
28 m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement); 57 m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement);
58 m_scene.EventManager.OnLandBuy += landChannel.handleLandBuyRequest;
59 m_scene.EventManager.OnValidatedLandBuy += landChannel.handleLandBuyRequest;
29 60
30 lock (m_scene) 61 lock (m_scene)
31 { 62 {
diff --git a/OpenSim/Region/Environment/Modules/LandManagement/LandObject.cs b/OpenSim/Region/Environment/Modules/LandManagement/LandObject.cs
index 46ddf38..161434e 100644
--- a/OpenSim/Region/Environment/Modules/LandManagement/LandObject.cs
+++ b/OpenSim/Region/Environment/Modules/LandManagement/LandObject.cs
@@ -256,12 +256,28 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
256 newData.snapshotID = packet.ParcelData.SnapshotID; 256 newData.snapshotID = packet.ParcelData.SnapshotID;
257 newData.userLocation = packet.ParcelData.UserLocation; 257 newData.userLocation = packet.ParcelData.UserLocation;
258 newData.userLookAt = packet.ParcelData.UserLookAt; 258 newData.userLookAt = packet.ParcelData.UserLookAt;
259 259
260 m_scene.LandChannel.updateLandObject(landData.localID, newData); 260 m_scene.LandChannel.updateLandObject(landData.localID, newData);
261 261
262 sendLandUpdateToAvatarsOverMe(); 262 sendLandUpdateToAvatarsOverMe();
263 } 263 }
264 } 264 }
265 public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area)
266 {
267 LandData newData = landData.Copy();
268 newData.ownerID = avatarID;
269 newData.groupID = groupID;
270 newData.isGroupOwned = groupOwned;
271 //newData.auctionID = AuctionID;
272 newData.claimDate = Util.UnixTimeSinceEpoch();
273 newData.claimPrice = claimprice;
274 newData.salePrice = 0;
275 newData.authBuyerID = LLUUID.Zero;
276 newData.landFlags &= ~(uint)(libsecondlife.Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects);
277 m_scene.LandChannel.updateLandObject(landData.localID, newData);
278
279 sendLandUpdateToAvatarsOverMe();
280 }
265 281
266 public bool isEitherBannedOrRestricted(LLUUID avatar) 282 public bool isEitherBannedOrRestricted(LLUUID avatar)
267 { 283 {