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.cs167
1 files changed, 98 insertions, 69 deletions
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
index 5f47810..f378921 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,23 @@ 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 result = 0;
566 577 // Set it to the OpenSim version, plus the SC build number. Muahahaha;
567 return returnfunds; 578 string v = VersionInfo.VersionNumber + VersionInfo.SC_BUILD_NUMBER.PadLeft(3, '0');
579 try
580 {
581 result = Int32.Parse(v.Replace(".", ""));
582 }
583 catch (FormatException)
584 {
585 }
586
587 return result;
568 } 588 }
569 589
570 // private void SetLocalFundsForAgentID(UUID AgentID, int amount) 590 // private void SetLocalFundsForAgentID(UUID AgentID, int amount)
571 // { 591 // {
572 592
573 // } 593 // }
574 594
575 #endregion 595 #endregion
@@ -688,7 +708,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
688 /// <see cref="OpenSim.Region.Framework.Scenes.EventManager.ClientClosed"/> 708 /// <see cref="OpenSim.Region.Framework.Scenes.EventManager.ClientClosed"/>
689 public void ClientClosed(UUID AgentID, Scene scene) 709 public void ClientClosed(UUID AgentID, Scene scene)
690 { 710 {
691 711
692 } 712 }
693 713
694 /// <summary> 714 /// <summary>
@@ -707,19 +727,19 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
707 727
708 private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e) 728 private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e)
709 { 729 {
710 730
711 731
712 lock (e) 732 lock (e)
713 { 733 {
714 e.economyValidated = true; 734 e.economyValidated = true;
715 } 735 }
716 736
717 737
718 } 738 }
719 739
720 private void processLandBuy(Object osender, EventManager.LandBuyArgs e) 740 private void processLandBuy(Object osender, EventManager.LandBuyArgs e)
721 { 741 {
722 742
723 } 743 }
724 744
725 /// <summary> 745 /// <summary>
@@ -729,7 +749,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
729 /// <param name="e"></param> 749 /// <param name="e"></param>
730 private void MoneyTransferAction(Object osender, EventManager.MoneyTransferArgs e) 750 private void MoneyTransferAction(Object osender, EventManager.MoneyTransferArgs e)
731 { 751 {
732 752
733 } 753 }
734 754
735 /// <summary> 755 /// <summary>
@@ -738,7 +758,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
738 /// <param name="avatar"></param> 758 /// <param name="avatar"></param>
739 private void MakeChildAgent(ScenePresence avatar) 759 private void MakeChildAgent(ScenePresence avatar)
740 { 760 {
741 761
742 } 762 }
743 763
744 /// <summary> 764 /// <summary>
@@ -747,7 +767,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
747 /// <param name="AgentId"></param> 767 /// <param name="AgentId"></param>
748 private void ClientLoggedOut(UUID AgentId, Scene scene) 768 private void ClientLoggedOut(UUID AgentId, Scene scene)
749 { 769 {
750 770
751 } 771 }
752 772
753 /// <summary> 773 /// <summary>
@@ -767,7 +787,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
767 /// <param name="regionID"></param> 787 /// <param name="regionID"></param>
768 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) 788 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID)
769 { 789 {
770 790
771 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); 791 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
772 } 792 }
773 793
@@ -808,12 +828,12 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
808 828
809 Scene s = LocateSceneClientIn(remoteClient.AgentId); 829 Scene s = LocateSceneClientIn(remoteClient.AgentId);
810 830
811 // Implmenting base sale data checking here so the default OpenSimulator implementation isn't useless 831 // 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 832 // 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 833 // 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 834 // 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 835 // 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 836 // 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.. 837 // 'crowning glory' examples of good practice..
818 838
819 // Validate that the object exists in the scene the user is in 839 // Validate that the object exists in the scene the user is in
@@ -823,15 +843,15 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
823 remoteClient.SendAgentAlertMessage("Unable to buy now. The object was not found.", false); 843 remoteClient.SendAgentAlertMessage("Unable to buy now. The object was not found.", false);
824 return; 844 return;
825 } 845 }
826 846
827 // Validate that the client sent the price that the object is being sold for 847 // Validate that the client sent the price that the object is being sold for
828 if (part.SalePrice != salePrice) 848 if (part.SalePrice != salePrice)
829 { 849 {
830 remoteClient.SendAgentAlertMessage("Cannot buy at this price. Buy Failed. If you continue to get this relog.", false); 850 remoteClient.SendAgentAlertMessage("Cannot buy at this price. Buy Failed. If you continue to get this relog.", false);
831 return; 851 return;
832 } 852 }
833 853
834 // Validate that the client sent the proper sale type the object has set 854 // Validate that the client sent the proper sale type the object has set
835 if (part.ObjectSaleType != saleType) 855 if (part.ObjectSaleType != saleType)
836 { 856 {
837 remoteClient.SendAgentAlertMessage("Cannot buy this way. Buy Failed. If you continue to get this relog.", false); 857 remoteClient.SendAgentAlertMessage("Cannot buy this way. Buy Failed. If you continue to get this relog.", false);
@@ -842,6 +862,15 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
842 if (module != null) 862 if (module != null)
843 module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice); 863 module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice);
844 } 864 }
865
866 public void MoveMoney(UUID fromUser, UUID toUser, int amount, string text)
867 {
868 }
869
870 public bool MoveMoney(UUID fromUser, UUID toUser, int amount, MoneyTransactionType type, string text)
871 {
872 return true;
873 }
845 } 874 }
846 875
847 public enum TransactionType : int 876 public enum TransactionType : int