aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs156
1 files changed, 88 insertions, 68 deletions
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
index 5f47810..b32a429 100644
--- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
+++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
@@ -65,10 +65,10 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
65 /// </summary> 65 /// </summary>
66 // private UUID EconomyBaseAccount = UUID.Zero; 66 // private UUID EconomyBaseAccount = UUID.Zero;
67 67
68 private float EnergyEfficiency = 0f; 68 private float EnergyEfficiency = 1f;
69 // private ObjectPaid handerOnObjectPaid; 69 // private ObjectPaid handerOnObjectPaid;
70 private bool m_enabled = true; 70 private bool m_enabled = true;
71 private bool m_sellEnabled = false; 71 private bool m_sellEnabled = true;
72 72
73 private IConfigSource m_gConfig; 73 private IConfigSource m_gConfig;
74 74
@@ -85,12 +85,12 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
85 85
86 private int ObjectCount = 0; 86 private int ObjectCount = 0;
87 private int PriceEnergyUnit = 0; 87 private int PriceEnergyUnit = 0;
88 private int PriceGroupCreate = 0; 88 private int PriceGroupCreate = -1;
89 private int PriceObjectClaim = 0; 89 private int PriceObjectClaim = 0;
90 private float PriceObjectRent = 0f; 90 private float PriceObjectRent = 0f;
91 private float PriceObjectScaleFactor = 0f; 91 private float PriceObjectScaleFactor = 10f;
92 private int PriceParcelClaim = 0; 92 private int PriceParcelClaim = 0;
93 private float PriceParcelClaimFactor = 0f; 93 private float PriceParcelClaimFactor = 1f;
94 private int PriceParcelRent = 0; 94 private int PriceParcelRent = 0;
95 private int PricePublicObjectDecay = 0; 95 private int PricePublicObjectDecay = 0;
96 private int PricePublicObjectDelete = 0; 96 private int PricePublicObjectDelete = 0;
@@ -98,7 +98,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
98 private int PriceUpload = 0; 98 private int PriceUpload = 0;
99 private int TeleportMinPrice = 0; 99 private int TeleportMinPrice = 0;
100 100
101 private float TeleportPriceExponent = 0f; 101 private float TeleportPriceExponent = 2f;
102 102
103 103
104 #region IMoneyModule Members 104 #region IMoneyModule Members
@@ -124,13 +124,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
124 public void Initialise(IConfigSource config) 124 public void Initialise(IConfigSource config)
125 { 125 {
126 m_gConfig = config; 126 m_gConfig = config;
127 127 ReadConfigAndPopulate();
128 IConfig startupConfig = m_gConfig.Configs["Startup"];
129 IConfig economyConfig = m_gConfig.Configs["Economy"];
130
131
132 ReadConfigAndPopulate(startupConfig, "Startup");
133 ReadConfigAndPopulate(economyConfig, "Economy");
134 } 128 }
135 129
136 public void AddRegion(Scene scene) 130 public void AddRegion(Scene scene)
@@ -151,13 +145,13 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
151 // to the command line parameters you use to start up your client 145 // to the command line parameters you use to start up your client
152 // This commonly looks like -helperuri http://127.0.0.1:9000/ 146 // This commonly looks like -helperuri http://127.0.0.1:9000/
153 147
154 148
155 // Local Server.. enables functionality only. 149 // Local Server.. enables functionality only.
156 httpServer.AddXmlRPCHandler("getCurrencyQuote", quote_func); 150 httpServer.AddXmlRPCHandler("getCurrencyQuote", quote_func);
157 httpServer.AddXmlRPCHandler("buyCurrency", buy_func); 151 httpServer.AddXmlRPCHandler("buyCurrency", buy_func);
158 httpServer.AddXmlRPCHandler("preflightBuyLandPrep", preflightBuyLandPrep_func); 152 httpServer.AddXmlRPCHandler("preflightBuyLandPrep", preflightBuyLandPrep_func);
159 httpServer.AddXmlRPCHandler("buyLandPrep", landBuy_func); 153 httpServer.AddXmlRPCHandler("buyLandPrep", landBuy_func);
160 154
161 } 155 }
162 156
163 if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle)) 157 if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle))
@@ -205,13 +199,14 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
205 { 199 {
206 } 200 }
207 201
208 public bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, int amount) 202 public bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, int amount, UUID txn, out string result)
209 { 203 {
204 result = String.Empty;
210 string description = String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID)); 205 string description = String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID));
211 206
212 bool give_result = doMoneyTransfer(fromID, toID, amount, 2, description); 207 bool give_result = doMoneyTransfer(fromID, toID, amount, 2, description);
213 208
214 209
215 BalanceUpdate(fromID, toID, give_result, description); 210 BalanceUpdate(fromID, toID, give_result, description);
216 211
217 return give_result; 212 return give_result;
@@ -240,35 +235,51 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
240 /// <summary> 235 /// <summary>
241 /// Parse Configuration 236 /// Parse Configuration
242 /// </summary> 237 /// </summary>
243 /// <param name="scene"></param> 238 private void ReadConfigAndPopulate()
244 /// <param name="startupConfig"></param>
245 /// <param name="config"></param>
246 private void ReadConfigAndPopulate(IConfig startupConfig, string config)
247 { 239 {
248 if (config == "Startup" && startupConfig != null) 240 // we are enabled by default
241
242 IConfig startupConfig = m_gConfig.Configs["Startup"];
243
244 if(startupConfig == null) // should not happen
245 return;
246
247 IConfig economyConfig = m_gConfig.Configs["Economy"];
248
249 // economymodule may be at startup or Economy (legacy)
250 string mmodule = startupConfig.GetString("economymodule","");
251 if(String.IsNullOrEmpty(mmodule))
249 { 252 {
250 m_enabled = (startupConfig.GetString("economymodule", "BetaGridLikeMoneyModule") == "BetaGridLikeMoneyModule"); 253 if(economyConfig != null)
254 mmodule = economyConfig.GetString("economymodule","");
251 } 255 }
252 256
253 if (config == "Economy" && startupConfig != null) 257 if(!String.IsNullOrEmpty(mmodule) && mmodule != Name)
254 { 258 {
255 PriceEnergyUnit = startupConfig.GetInt("PriceEnergyUnit", 100); 259 // some other money module selected
256 PriceObjectClaim = startupConfig.GetInt("PriceObjectClaim", 10); 260 m_enabled = false;
257 PricePublicObjectDecay = startupConfig.GetInt("PricePublicObjectDecay", 4); 261 return;
258 PricePublicObjectDelete = startupConfig.GetInt("PricePublicObjectDelete", 4);
259 PriceParcelClaim = startupConfig.GetInt("PriceParcelClaim", 1);
260 PriceParcelClaimFactor = startupConfig.GetFloat("PriceParcelClaimFactor", 1f);
261 PriceUpload = startupConfig.GetInt("PriceUpload", 0);
262 PriceRentLight = startupConfig.GetInt("PriceRentLight", 5);
263 TeleportMinPrice = startupConfig.GetInt("TeleportMinPrice", 2);
264 TeleportPriceExponent = startupConfig.GetFloat("TeleportPriceExponent", 2f);
265 EnergyEfficiency = startupConfig.GetFloat("EnergyEfficiency", 1);
266 PriceObjectRent = startupConfig.GetFloat("PriceObjectRent", 1);
267 PriceObjectScaleFactor = startupConfig.GetFloat("PriceObjectScaleFactor", 10);
268 PriceParcelRent = startupConfig.GetInt("PriceParcelRent", 1);
269 PriceGroupCreate = startupConfig.GetInt("PriceGroupCreate", -1);
270 m_sellEnabled = startupConfig.GetBoolean("SellEnabled", false);
271 } 262 }
263
264 if(economyConfig == null)
265 return;
266
267 PriceEnergyUnit = economyConfig.GetInt("PriceEnergyUnit", 0);
268 PriceObjectClaim = economyConfig.GetInt("PriceObjectClaim", 0);
269 PricePublicObjectDecay = economyConfig.GetInt("PricePublicObjectDecay", 4);
270 PricePublicObjectDelete = economyConfig.GetInt("PricePublicObjectDelete", 0);
271 PriceParcelClaim = economyConfig.GetInt("PriceParcelClaim", 0);
272 PriceParcelClaimFactor = economyConfig.GetFloat("PriceParcelClaimFactor", 1f);
273 PriceUpload = economyConfig.GetInt("PriceUpload", 0);
274 PriceRentLight = economyConfig.GetInt("PriceRentLight", 0);
275 TeleportMinPrice = economyConfig.GetInt("TeleportMinPrice", 0);
276 TeleportPriceExponent = economyConfig.GetFloat("TeleportPriceExponent", 2f);
277 EnergyEfficiency = economyConfig.GetFloat("EnergyEfficiency", 1);
278 PriceObjectRent = economyConfig.GetFloat("PriceObjectRent", 0);
279 PriceObjectScaleFactor = economyConfig.GetFloat("PriceObjectScaleFactor", 10);
280 PriceParcelRent = economyConfig.GetInt("PriceParcelRent", 0);
281 PriceGroupCreate = economyConfig.GetInt("PriceGroupCreate", -1);
282 m_sellEnabled = economyConfig.GetBoolean("SellEnabled", true);
272 } 283 }
273 284
274 private void GetClientFunds(IClientAPI client) 285 private void GetClientFunds(IClientAPI client)
@@ -302,7 +313,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
302 private bool doMoneyTransfer(UUID Sender, UUID Receiver, int amount, int transactiontype, string description) 313 private bool doMoneyTransfer(UUID Sender, UUID Receiver, int amount, int transactiontype, string description)
303 { 314 {
304 bool result = true; 315 bool result = true;
305 316
306 return result; 317 return result;
307 } 318 }
308 319
@@ -376,10 +387,10 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
376 else 387 else
377 { 388 {
378 m_log.ErrorFormat( 389 m_log.ErrorFormat(
379 "[MONEY]: Could not resolve user {0}", 390 "[MONEY]: Could not resolve user {0}",
380 agentID); 391 agentID);
381 } 392 }
382 393
383 return String.Empty; 394 return String.Empty;
384 } 395 }
385 396
@@ -463,7 +474,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
463 Hashtable quoteResponse = new Hashtable(); 474 Hashtable quoteResponse = new Hashtable();
464 XmlRpcResponse returnval = new XmlRpcResponse(); 475 XmlRpcResponse returnval = new XmlRpcResponse();
465 476
466 477
467 Hashtable currencyResponse = new Hashtable(); 478 Hashtable currencyResponse = new Hashtable();
468 currencyResponse.Add("estimatedCost", 0); 479 currencyResponse.Add("estimatedCost", 0);
469 currencyResponse.Add("currencyBuy", amount); 480 currencyResponse.Add("currencyBuy", amount);
@@ -474,7 +485,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
474 485
475 returnval.Value = quoteResponse; 486 returnval.Value = quoteResponse;
476 return returnval; 487 return returnval;
477 488
478 489
479 490
480 } 491 }
@@ -484,7 +495,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
484 // Hashtable requestData = (Hashtable) request.Params[0]; 495 // Hashtable requestData = (Hashtable) request.Params[0];
485 // UUID agentId = UUID.Zero; 496 // UUID agentId = UUID.Zero;
486 // int amount = 0; 497 // int amount = 0;
487 498
488 XmlRpcResponse returnval = new XmlRpcResponse(); 499 XmlRpcResponse returnval = new XmlRpcResponse();
489 Hashtable returnresp = new Hashtable(); 500 Hashtable returnresp = new Hashtable();
490 returnresp.Add("success", true); 501 returnresp.Add("success", true);
@@ -535,7 +546,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
535 546
536 // UUID agentId = UUID.Zero; 547 // UUID agentId = UUID.Zero;
537 // int amount = 0; 548 // int amount = 0;
538 549
539 retparam.Add("success", true); 550 retparam.Add("success", true);
540 ret.Value = retparam; 551 ret.Value = retparam;
541 552
@@ -552,7 +563,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
552 /// <param name="agentID"></param> 563 /// <param name="agentID"></param>
553 private void CheckExistAndRefreshFunds(UUID agentID) 564 private void CheckExistAndRefreshFunds(UUID agentID)
554 { 565 {
555 566
556 } 567 }
557 568
558 /// <summary> 569 /// <summary>
@@ -562,14 +573,14 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
562 /// <returns></returns> 573 /// <returns></returns>
563 private int GetFundsForAgentID(UUID AgentID) 574 private int GetFundsForAgentID(UUID AgentID)
564 { 575 {
565 int returnfunds = 82101; // Set it to the OpenSim version, plus the IG build number. Muahahaha; 576 int returnfunds = 0;
566 577
567 return returnfunds; 578 return returnfunds;
568 } 579 }
569 580
570 // private void SetLocalFundsForAgentID(UUID AgentID, int amount) 581 // private void SetLocalFundsForAgentID(UUID AgentID, int amount)
571 // { 582 // {
572 583
573 // } 584 // }
574 585
575 #endregion 586 #endregion
@@ -688,7 +699,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
688 /// <see cref="OpenSim.Region.Framework.Scenes.EventManager.ClientClosed"/> 699 /// <see cref="OpenSim.Region.Framework.Scenes.EventManager.ClientClosed"/>
689 public void ClientClosed(UUID AgentID, Scene scene) 700 public void ClientClosed(UUID AgentID, Scene scene)
690 { 701 {
691 702
692 } 703 }
693 704
694 /// <summary> 705 /// <summary>
@@ -707,19 +718,19 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
707 718
708 private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e) 719 private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e)
709 { 720 {
710 721
711 722
712 lock (e) 723 lock (e)
713 { 724 {
714 e.economyValidated = true; 725 e.economyValidated = true;
715 } 726 }
716 727
717 728
718 } 729 }
719 730
720 private void processLandBuy(Object osender, EventManager.LandBuyArgs e) 731 private void processLandBuy(Object osender, EventManager.LandBuyArgs e)
721 { 732 {
722 733
723 } 734 }
724 735
725 /// <summary> 736 /// <summary>
@@ -729,7 +740,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
729 /// <param name="e"></param> 740 /// <param name="e"></param>
730 private void MoneyTransferAction(Object osender, EventManager.MoneyTransferArgs e) 741 private void MoneyTransferAction(Object osender, EventManager.MoneyTransferArgs e)
731 { 742 {
732 743
733 } 744 }
734 745
735 /// <summary> 746 /// <summary>
@@ -738,7 +749,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
738 /// <param name="avatar"></param> 749 /// <param name="avatar"></param>
739 private void MakeChildAgent(ScenePresence avatar) 750 private void MakeChildAgent(ScenePresence avatar)
740 { 751 {
741 752
742 } 753 }
743 754
744 /// <summary> 755 /// <summary>
@@ -747,7 +758,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
747 /// <param name="AgentId"></param> 758 /// <param name="AgentId"></param>
748 private void ClientLoggedOut(UUID AgentId, Scene scene) 759 private void ClientLoggedOut(UUID AgentId, Scene scene)
749 { 760 {
750 761
751 } 762 }
752 763
753 /// <summary> 764 /// <summary>
@@ -767,7 +778,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
767 /// <param name="regionID"></param> 778 /// <param name="regionID"></param>
768 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) 779 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID)
769 { 780 {
770 781
771 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); 782 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
772 } 783 }
773 784
@@ -808,12 +819,12 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
808 819
809 Scene s = LocateSceneClientIn(remoteClient.AgentId); 820 Scene s = LocateSceneClientIn(remoteClient.AgentId);
810 821
811 // Implmenting base sale data checking here so the default OpenSimulator implementation isn't useless 822 // Implmenting base sale data checking here so the default OpenSimulator implementation isn't useless
812 // combined with other implementations. We're actually validating that the client is sending the data 823 // combined with other implementations. We're actually validating that the client is sending the data
813 // that it should. In theory, the client should already know what to send here because it'll see it when it 824 // that it should. In theory, the client should already know what to send here because it'll see it when it
814 // gets the object data. If the data sent by the client doesn't match the object, the viewer probably has an 825 // gets the object data. If the data sent by the client doesn't match the object, the viewer probably has an
815 // old idea of what the object properties are. Viewer developer Hazim informed us that the base module 826 // old idea of what the object properties are. Viewer developer Hazim informed us that the base module
816 // didn't check the client sent data against the object do any. Since the base modules are the 827 // didn't check the client sent data against the object do any. Since the base modules are the
817 // 'crowning glory' examples of good practice.. 828 // 'crowning glory' examples of good practice..
818 829
819 // Validate that the object exists in the scene the user is in 830 // Validate that the object exists in the scene the user is in
@@ -823,15 +834,15 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
823 remoteClient.SendAgentAlertMessage("Unable to buy now. The object was not found.", false); 834 remoteClient.SendAgentAlertMessage("Unable to buy now. The object was not found.", false);
824 return; 835 return;
825 } 836 }
826 837
827 // Validate that the client sent the price that the object is being sold for 838 // Validate that the client sent the price that the object is being sold for
828 if (part.SalePrice != salePrice) 839 if (part.SalePrice != salePrice)
829 { 840 {
830 remoteClient.SendAgentAlertMessage("Cannot buy at this price. Buy Failed. If you continue to get this relog.", false); 841 remoteClient.SendAgentAlertMessage("Cannot buy at this price. Buy Failed. If you continue to get this relog.", false);
831 return; 842 return;
832 } 843 }
833 844
834 // Validate that the client sent the proper sale type the object has set 845 // Validate that the client sent the proper sale type the object has set
835 if (part.ObjectSaleType != saleType) 846 if (part.ObjectSaleType != saleType)
836 { 847 {
837 remoteClient.SendAgentAlertMessage("Cannot buy this way. Buy Failed. If you continue to get this relog.", false); 848 remoteClient.SendAgentAlertMessage("Cannot buy this way. Buy Failed. If you continue to get this relog.", false);
@@ -842,6 +853,15 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
842 if (module != null) 853 if (module != null)
843 module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice); 854 module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice);
844 } 855 }
856
857 public void MoveMoney(UUID fromUser, UUID toUser, int amount, string text)
858 {
859 }
860
861 public bool MoveMoney(UUID fromUser, UUID toUser, int amount, MoneyTransactionType type, string text)
862 {
863 return true;
864 }
845 } 865 }
846 866
847 public enum TransactionType : int 867 public enum TransactionType : int