From d7b2beea1826345e3b5b93ca0aea52629190ca3c Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Mon, 11 May 2009 18:23:39 +0000
Subject: Add selling for $0 back to the sample economy module. This is
 disabled by default but can be enabled in OpenSim.ini. If enabled, things can
 be sold for $0. Other amounts will cause the buyer to see a message and the
 transaction will fail.

---
 .../MoneyModule/SampleMoneyModule.cs               | 30 ++++++++++++++++------
 bin/OpenSim.ini.example                            | 28 ++------------------
 2 files changed, 24 insertions(+), 34 deletions(-)

diff --git a/OpenSim/Region/ReplaceableModules/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/ReplaceableModules/MoneyModule/SampleMoneyModule.cs
index 043c110..cd68541 100644
--- a/OpenSim/Region/ReplaceableModules/MoneyModule/SampleMoneyModule.cs
+++ b/OpenSim/Region/ReplaceableModules/MoneyModule/SampleMoneyModule.cs
@@ -64,6 +64,7 @@ namespace OpenSim.Region.ReplaceableModules.MoneyModule
         private bool gridmode = false;
         // private ObjectPaid handerOnObjectPaid;
         private bool m_enabled = true;
+        private bool m_sellEnabled = false;
 
         private IConfigSource m_gConfig;
 
@@ -244,13 +245,7 @@ namespace OpenSim.Region.ReplaceableModules.MoneyModule
                 PriceObjectScaleFactor = startupConfig.GetFloat("PriceObjectScaleFactor", 10);
                 PriceParcelRent = startupConfig.GetInt("PriceParcelRent", 1);
                 PriceGroupCreate = startupConfig.GetInt("PriceGroupCreate", -1);
-                // string EBA = startupConfig.GetString("EconomyBaseAccount", UUID.Zero.ToString());
-                // Helpers.TryParse(EBA, out EconomyBaseAccount);
-
-                // UserLevelPaysFees = startupConfig.GetInt("UserLevelPaysFees", -1);
-                m_stipend = startupConfig.GetInt("UserStipend", 1000);
-                
-                // m_LandAddress = startupConfig.GetString("LandServer", String.Empty);
+                m_sellEnabled = startupConfig.GetBoolean("SellEnabled", false);
             }
 
             // Send ObjectCapacity to Scene..  Which sends it to the SimStatsReporter.
@@ -819,7 +814,26 @@ namespace OpenSim.Region.ReplaceableModules.MoneyModule
                 UUID sessionID, UUID groupID, UUID categoryID,
                 uint localID, byte saleType, int salePrice)
         {
-            remoteClient.SendBlueBoxMessage(UUID.Zero, "", "Buying is not implemented in this version");
+            if (!m_sellEnabled)
+            {
+                remoteClient.SendBlueBoxMessage(UUID.Zero, "", "Buying is not implemented in this version");
+                return;
+            }
+
+            if (salePrice != 0)
+            {
+                remoteClient.SendBlueBoxMessage(UUID.Zero, "", "Buying anything for a price other than zero is not implemented");
+                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;
+            }
+            s.PerformObjectBuy(remoteClient, categoryID, localID, saleType);
         }
     }
 
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 745b678..de8139b 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -942,13 +942,9 @@
 
 [Economy]
     ; These economy values get used in the BetaGridLikeMoneyModule.  - This module is for demonstration only -
-    ; In grid mode, use this currency XMLRPC server.  Leave blank for normal functionality
-    CurrencyServer = ""
-    ; "http://192.168.1.127/currency.php"
 
-    ; In grid mode, this is the land XMLRPC server. Leave blank for normal functionality
-    LandServer = ""
-    ;"http://192.168.1.127/landtool.php"
+    ; Enables selling things for $0
+    SellEnabled = "false"
 
     ; 45000 is the highest value that the sim could possibly report because of protocol constraints
     ObjectCapacity = 45000
@@ -959,26 +955,6 @@
     ; Money Unit fee to create groups
     PriceGroupCreate = 0
 
-    ; This is the account Money goes to for fees.  Remember, economy requires that money circulates somewhere... even if it's an upload fee
-    EconomyBaseAccount = 00000000-0000-0000-0000-000000000000
-
-    ; This is the type of user that will pay fees.
-    ; Set this to 2 for users, estate managers and Estate Owners
-    ; Set this to 1 for Users and Estate Managers
-    ; Set this to 0 for Users only.
-    ; -1 disables
-    UserLevelPaysFees = -1
-
-    ; Amount to give to user as a stipend
-    UserStipend = 1000
-
-    ; When a user gets low on money units and logs off, then logs back on, issue a new stipend if they have less money units then this
-    ; amount. Be aware that the account money isn't stored anywhere so users will get a stipend if you restart the simulator
-    IssueStipendWhenClientIsBelowAmount = 10
-
-    ; If this is true, the simulator will remember account balances until the simulator is shutdown or restarted.
-    KeepMoneyAcrossLogins = true
-
     ; We don't really know what the rest of these values do.  These get sent to the client
     ; These taken from Agni at a Public Telehub.  Change at your own risk.
     ObjectCount = 0
-- 
cgit v1.1