aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ReplaceableModules
diff options
context:
space:
mode:
authorMelanie Thielker2009-07-10 20:46:16 +0000
committerMelanie Thielker2009-07-10 20:46:16 +0000
commitec1a5d89336570d1cbef64607160bd8ab1a55fb6 (patch)
treefb6995d36b431e7e65c8f46bb7f3c00fba12fd2b /OpenSim/Region/ReplaceableModules
parentCommitting the interface change and the addition to the modules to get (diff)
downloadopensim-SC-ec1a5d89336570d1cbef64607160bd8ab1a55fb6.zip
opensim-SC-ec1a5d89336570d1cbef64607160bd8ab1a55fb6.tar.gz
opensim-SC-ec1a5d89336570d1cbef64607160bd8ab1a55fb6.tar.bz2
opensim-SC-ec1a5d89336570d1cbef64607160bd8ab1a55fb6.tar.xz
Some module reshuffling, no user functionality yet
Diffstat (limited to 'OpenSim/Region/ReplaceableModules')
-rw-r--r--OpenSim/Region/ReplaceableModules/MoneyModule/Resources/MoneyModulePlugin.addin.xml8
-rw-r--r--OpenSim/Region/ReplaceableModules/MoneyModule/SampleMoneyModule.cs850
2 files changed, 0 insertions, 858 deletions
diff --git a/OpenSim/Region/ReplaceableModules/MoneyModule/Resources/MoneyModulePlugin.addin.xml b/OpenSim/Region/ReplaceableModules/MoneyModule/Resources/MoneyModulePlugin.addin.xml
deleted file mode 100644
index a25f297..0000000
--- a/OpenSim/Region/ReplaceableModules/MoneyModule/Resources/MoneyModulePlugin.addin.xml
+++ /dev/null
@@ -1,8 +0,0 @@
1<Addin id="OpenSim.Region.ReplaceableModules.MoneyModule" version="0.2">
2 <Runtime>
3 <Import assembly="OpenSim.Region.ReplaceableModules.MoneyModule.dll"/>
4 </Runtime>
5 <Dependencies>
6 <Addin id="OpenSim" version="0.5" />
7 </Dependencies>
8</Addin> \ No newline at end of file
diff --git a/OpenSim/Region/ReplaceableModules/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/ReplaceableModules/MoneyModule/SampleMoneyModule.cs
deleted file mode 100644
index c4fd4bc..0000000
--- a/OpenSim/Region/ReplaceableModules/MoneyModule/SampleMoneyModule.cs
+++ /dev/null
@@ -1,850 +0,0 @@
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 OpenSimulator 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;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using log4net;
34using Nini.Config;
35using Nwc.XmlRpc;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes;
42
43namespace OpenSim.Region.ReplaceableModules.MoneyModule
44{
45 /// <summary>
46 /// This is only the functionality required to make the functionality associated with money work
47 /// (such as land transfers). There is no money code here! Use FORGE as an example for money code.
48 /// Demo Economy/Money Module. This is a purposely crippled module!
49 /// // To land transfer you need to add:
50 /// -helperuri <ADDRESS TO THIS 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 /// </summary>
55 public class SampleMoneyModule : IMoneyModule, IRegionModule
56 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58
59 /// <summary>
60 /// Where Stipends come from and Fees go to.
61 /// </summary>
62 // private UUID EconomyBaseAccount = UUID.Zero;
63
64 private float EnergyEfficiency = 0f;
65 private bool gridmode = false;
66 // private ObjectPaid handerOnObjectPaid;
67 private bool m_enabled = true;
68 private bool m_sellEnabled = false;
69
70 private IConfigSource m_gConfig;
71
72
73
74 /// <summary>
75 /// Region UUIDS indexed by AgentID
76 /// </summary>
77
78 /// <summary>
79 /// Scenes by Region Handle
80 /// </summary>
81 private Dictionary<ulong, Scene> m_scenel = new Dictionary<ulong, Scene>();
82
83 // private int m_stipend = 1000;
84
85 private int ObjectCapacity = 45000;
86 private int ObjectCount = 0;
87 private int PriceEnergyUnit = 0;
88 private int PriceGroupCreate = 0;
89 private int PriceObjectClaim = 0;
90 private float PriceObjectRent = 0f;
91 private float PriceObjectScaleFactor = 0f;
92 private int PriceParcelClaim = 0;
93 private float PriceParcelClaimFactor = 0f;
94 private int PriceParcelRent = 0;
95 private int PricePublicObjectDecay = 0;
96 private int PricePublicObjectDelete = 0;
97 private int PriceRentLight = 0;
98 private int PriceUpload = 0;
99 private int TeleportMinPrice = 0;
100
101 private float TeleportPriceExponent = 0f;
102
103
104 #region IMoneyModule Members
105
106 public event ObjectPaid OnObjectPaid;
107
108 /// <summary>
109 /// Startup
110 /// </summary>
111 /// <param name="scene"></param>
112 /// <param name="config"></param>
113 public void Initialise(Scene scene, IConfigSource config)
114 {
115 m_gConfig = config;
116
117 IConfig startupConfig = m_gConfig.Configs["Startup"];
118 IConfig economyConfig = m_gConfig.Configs["Economy"];
119
120
121 ReadConfigAndPopulate(scene, startupConfig, "Startup");
122 ReadConfigAndPopulate(scene, economyConfig, "Economy");
123
124 if (m_enabled)
125 {
126 scene.RegisterModuleInterface<IMoneyModule>(this);
127 IHttpServer httpServer = MainServer.Instance;
128
129 lock (m_scenel)
130 {
131 if (m_scenel.Count == 0)
132 {
133 // XMLRPCHandler = scene;
134
135 // To use the following you need to add:
136 // -helperuri <ADDRESS TO HERE OR grid MONEY SERVER>
137 // to the command line parameters you use to start up your client
138 // This commonly looks like -helperuri http://127.0.0.1:9000/
139
140
141 // Local Server.. enables functionality only.
142 httpServer.AddXmlRPCHandler("getCurrencyQuote", quote_func);
143 httpServer.AddXmlRPCHandler("buyCurrency", buy_func);
144 httpServer.AddXmlRPCHandler("preflightBuyLandPrep", preflightBuyLandPrep_func);
145 httpServer.AddXmlRPCHandler("buyLandPrep", landBuy_func);
146
147 }
148
149 if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle))
150 {
151 m_scenel[scene.RegionInfo.RegionHandle] = scene;
152 }
153 else
154 {
155 m_scenel.Add(scene.RegionInfo.RegionHandle, scene);
156 }
157 }
158
159 scene.EventManager.OnNewClient += OnNewClient;
160 scene.EventManager.OnMoneyTransfer += MoneyTransferAction;
161 scene.EventManager.OnClientClosed += ClientClosed;
162 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
163 scene.EventManager.OnMakeChildAgent += MakeChildAgent;
164 scene.EventManager.OnClientClosed += ClientLoggedOut;
165 scene.EventManager.OnValidateLandBuy += ValidateLandBuy;
166 scene.EventManager.OnLandBuy += processLandBuy;
167 }
168 }
169
170 // Please do not refactor these to be just one method
171 // Existing implementations need the distinction
172 //
173 public void ApplyUploadCharge(UUID agentID)
174 {
175 }
176
177 public void ApplyGroupCreationCharge(UUID agentID)
178 {
179 }
180
181 public void ApplyCharge(UUID agentID, int amount, string text)
182 {
183 }
184
185 public bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, int amount)
186 {
187 string description = String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID));
188
189 bool give_result = doMoneyTransfer(fromID, toID, amount, 2, description);
190
191
192 BalanceUpdate(fromID, toID, give_result, description);
193
194 return give_result;
195 }
196
197 public void PostInitialise()
198 {
199 }
200
201 public void Close()
202 {
203 }
204
205 public string Name
206 {
207 get { return "BetaGridLikeMoneyModule"; }
208 }
209
210 public bool IsSharedModule
211 {
212 get { return true; }
213 }
214
215 #endregion
216
217 /// <summary>
218 /// Parse Configuration
219 /// </summary>
220 /// <param name="scene"></param>
221 /// <param name="startupConfig"></param>
222 /// <param name="config"></param>
223 private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string config)
224 {
225 if (config == "Startup" && startupConfig != null)
226 {
227 gridmode = startupConfig.GetBoolean("gridmode", false);
228 m_enabled = (startupConfig.GetString("economymodule", "BetaGridLikeMoneyModule") == "BetaGridLikeMoneyModule");
229 }
230
231 if (config == "Economy" && startupConfig != null)
232 {
233 ObjectCapacity = startupConfig.GetInt("ObjectCapacity", 45000);
234 PriceEnergyUnit = startupConfig.GetInt("PriceEnergyUnit", 100);
235 PriceObjectClaim = startupConfig.GetInt("PriceObjectClaim", 10);
236 PricePublicObjectDecay = startupConfig.GetInt("PricePublicObjectDecay", 4);
237 PricePublicObjectDelete = startupConfig.GetInt("PricePublicObjectDelete", 4);
238 PriceParcelClaim = startupConfig.GetInt("PriceParcelClaim", 1);
239 PriceParcelClaimFactor = startupConfig.GetFloat("PriceParcelClaimFactor", 1f);
240 PriceUpload = startupConfig.GetInt("PriceUpload", 0);
241 PriceRentLight = startupConfig.GetInt("PriceRentLight", 5);
242 TeleportMinPrice = startupConfig.GetInt("TeleportMinPrice", 2);
243 TeleportPriceExponent = startupConfig.GetFloat("TeleportPriceExponent", 2f);
244 EnergyEfficiency = startupConfig.GetFloat("EnergyEfficiency", 1);
245 PriceObjectRent = startupConfig.GetFloat("PriceObjectRent", 1);
246 PriceObjectScaleFactor = startupConfig.GetFloat("PriceObjectScaleFactor", 10);
247 PriceParcelRent = startupConfig.GetInt("PriceParcelRent", 1);
248 PriceGroupCreate = startupConfig.GetInt("PriceGroupCreate", -1);
249 m_sellEnabled = startupConfig.GetBoolean("SellEnabled", false);
250 }
251
252 // Send ObjectCapacity to Scene.. Which sends it to the SimStatsReporter.
253 scene.SetObjectCapacity(ObjectCapacity);
254 }
255
256 public EconomyData GetEconomyData()
257 {
258 EconomyData edata = new EconomyData();
259 edata.ObjectCapacity = ObjectCapacity;
260 edata.ObjectCount = ObjectCount;
261 edata.PriceEnergyUnit = PriceEnergyUnit;
262 edata.PriceGroupCreate = PriceGroupCreate;
263 edata.PriceObjectClaim = PriceObjectClaim;
264 edata.PriceObjectRent = PriceObjectRent;
265 edata.PriceObjectScaleFactor = PriceObjectScaleFactor;
266 edata.PriceParcelClaim = PriceParcelClaim;
267 edata.PriceParcelClaimFactor = PriceParcelClaimFactor;
268 edata.PriceParcelRent = PriceParcelRent;
269 edata.PricePublicObjectDecay = PricePublicObjectDecay;
270 edata.PricePublicObjectDelete = PricePublicObjectDelete;
271 edata.PriceRentLight = PriceRentLight;
272 edata.PriceUpload = PriceUpload;
273 edata.TeleportMinPrice = TeleportMinPrice;
274 return edata;
275 }
276
277 private void GetClientFunds(IClientAPI client)
278 {
279 // Here we check if we're in grid mode
280 // I imagine that the 'check balance'
281 // function for the client should be here or shortly after
282
283 if (gridmode)
284 {
285 CheckExistAndRefreshFunds(client.AgentId);
286 }
287 else
288 {
289 CheckExistAndRefreshFunds(client.AgentId);
290 }
291
292 }
293
294 /// <summary>
295 /// New Client Event Handler
296 /// </summary>
297 /// <param name="client"></param>
298 private void OnNewClient(IClientAPI client)
299 {
300 GetClientFunds(client);
301
302 // Subscribe to Money messages
303 client.OnEconomyDataRequest += EconomyDataRequestHandler;
304 client.OnMoneyBalanceRequest += SendMoneyBalance;
305 client.OnRequestPayPrice += requestPayPrice;
306 client.OnObjectBuy += ObjectBuy;
307 client.OnLogout += ClientClosed;
308 }
309
310 /// <summary>
311 /// Transfer money
312 /// </summary>
313 /// <param name="Sender"></param>
314 /// <param name="Receiver"></param>
315 /// <param name="amount"></param>
316 /// <returns></returns>
317 private bool doMoneyTransfer(UUID Sender, UUID Receiver, int amount, int transactiontype, string description)
318 {
319 bool result = true;
320
321 return result;
322 }
323
324
325 /// <summary>
326 /// Sends the the stored money balance to the client
327 /// </summary>
328 /// <param name="client"></param>
329 /// <param name="agentID"></param>
330 /// <param name="SessionID"></param>
331 /// <param name="TransactionID"></param>
332 public void SendMoneyBalance(IClientAPI client, UUID agentID, UUID SessionID, UUID TransactionID)
333 {
334 if (client.AgentId == agentID && client.SessionId == SessionID)
335 {
336 int returnfunds = 0;
337
338 try
339 {
340 returnfunds = GetFundsForAgentID(agentID);
341 }
342 catch (Exception e)
343 {
344 client.SendAlertMessage(e.Message + " ");
345 }
346
347 client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds);
348 }
349 else
350 {
351 client.SendAlertMessage("Unable to send your money balance to you!");
352 }
353 }
354
355 private SceneObjectPart findPrim(UUID objectID)
356 {
357 lock (m_scenel)
358 {
359 foreach (Scene s in m_scenel.Values)
360 {
361 SceneObjectPart part = s.GetSceneObjectPart(objectID);
362 if (part != null)
363 {
364 return part;
365 }
366 }
367 }
368 return null;
369 }
370
371 private string resolveObjectName(UUID objectID)
372 {
373 SceneObjectPart part = findPrim(objectID);
374 if (part != null)
375 {
376 return part.Name;
377 }
378 return String.Empty;
379 }
380
381 private string resolveAgentName(UUID agentID)
382 {
383 // try avatar username surname
384 Scene scene = GetRandomScene();
385 CachedUserInfo profile = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID);
386 if (profile != null && profile.UserProfile != null)
387 {
388 string avatarname = profile.UserProfile.FirstName + " " + profile.UserProfile.SurName;
389 return avatarname;
390 }
391 else
392 {
393 m_log.ErrorFormat(
394 "[MONEY]: Could not resolve user {0}",
395 agentID);
396 }
397
398 return String.Empty;
399 }
400
401 private void BalanceUpdate(UUID senderID, UUID receiverID, bool transactionresult, string description)
402 {
403 IClientAPI sender = LocateClientObject(senderID);
404 IClientAPI receiver = LocateClientObject(receiverID);
405
406 if (senderID != receiverID)
407 {
408 if (sender != null)
409 {
410 sender.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(senderID));
411 }
412
413 if (receiver != null)
414 {
415 receiver.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(receiverID));
416 }
417 }
418 }
419
420 /// <summary>
421 /// XMLRPC handler to send alert message and sound to client
422 /// </summary>
423 public XmlRpcResponse UserAlert(XmlRpcRequest request, IPEndPoint remoteClient)
424 {
425 XmlRpcResponse ret = new XmlRpcResponse();
426 Hashtable retparam = new Hashtable();
427 Hashtable requestData = (Hashtable) request.Params[0];
428
429 UUID agentId;
430 UUID soundId;
431 UUID regionId;
432
433 UUID.TryParse((string) requestData["agentId"], out agentId);
434 UUID.TryParse((string) requestData["soundId"], out soundId);
435 UUID.TryParse((string) requestData["regionId"], out regionId);
436 string text = (string) requestData["text"];
437 string secret = (string) requestData["secret"];
438
439 Scene userScene = GetSceneByUUID(regionId);
440 if (userScene != null)
441 {
442 if (userScene.RegionInfo.regionSecret == secret)
443 {
444
445 IClientAPI client = LocateClientObject(agentId);
446 if (client != null)
447 {
448
449 if (soundId != UUID.Zero)
450 client.SendPlayAttachedSound(soundId, UUID.Zero, UUID.Zero, 1.0f, 0);
451
452 client.SendBlueBoxMessage(UUID.Zero, "", text);
453
454 retparam.Add("success", true);
455 }
456 else
457 {
458 retparam.Add("success", false);
459 }
460 }
461 else
462 {
463 retparam.Add("success", false);
464 }
465 }
466
467 ret.Value = retparam;
468 return ret;
469 }
470
471 # region Standalone box enablers only
472
473 public XmlRpcResponse quote_func(XmlRpcRequest request, IPEndPoint remoteClient)
474 {
475 // Hashtable requestData = (Hashtable) request.Params[0];
476 // UUID agentId = UUID.Zero;
477 int amount = 0;
478 Hashtable quoteResponse = new Hashtable();
479 XmlRpcResponse returnval = new XmlRpcResponse();
480
481
482 Hashtable currencyResponse = new Hashtable();
483 currencyResponse.Add("estimatedCost", 0);
484 currencyResponse.Add("currencyBuy", amount);
485
486 quoteResponse.Add("success", true);
487 quoteResponse.Add("currency", currencyResponse);
488 quoteResponse.Add("confirm", "asdfad9fj39ma9fj");
489
490 returnval.Value = quoteResponse;
491 return returnval;
492
493
494
495 }
496
497 public XmlRpcResponse buy_func(XmlRpcRequest request, IPEndPoint remoteClient)
498 {
499 // Hashtable requestData = (Hashtable) request.Params[0];
500 // UUID agentId = UUID.Zero;
501 // int amount = 0;
502
503 XmlRpcResponse returnval = new XmlRpcResponse();
504 Hashtable returnresp = new Hashtable();
505 returnresp.Add("success", true);
506 returnval.Value = returnresp;
507 return returnval;
508 }
509
510 public XmlRpcResponse preflightBuyLandPrep_func(XmlRpcRequest request, IPEndPoint remoteClient)
511 {
512 XmlRpcResponse ret = new XmlRpcResponse();
513 Hashtable retparam = new Hashtable();
514 Hashtable membershiplevels = new Hashtable();
515 ArrayList levels = new ArrayList();
516 Hashtable level = new Hashtable();
517 level.Add("id", "00000000-0000-0000-0000-000000000000");
518 level.Add("description", "some level");
519 levels.Add(level);
520 //membershiplevels.Add("levels",levels);
521
522 Hashtable landuse = new Hashtable();
523 landuse.Add("upgrade", false);
524 landuse.Add("action", "http://invaliddomaininvalid.com/");
525
526 Hashtable currency = new Hashtable();
527 currency.Add("estimatedCost", 0);
528
529 Hashtable membership = new Hashtable();
530 membershiplevels.Add("upgrade", false);
531 membershiplevels.Add("action", "http://invaliddomaininvalid.com/");
532 membershiplevels.Add("levels", membershiplevels);
533
534 retparam.Add("success", true);
535 retparam.Add("currency", currency);
536 retparam.Add("membership", membership);
537 retparam.Add("landuse", landuse);
538 retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
539
540 ret.Value = retparam;
541
542 return ret;
543 }
544
545 public XmlRpcResponse landBuy_func(XmlRpcRequest request, IPEndPoint remoteClient)
546 {
547 XmlRpcResponse ret = new XmlRpcResponse();
548 Hashtable retparam = new Hashtable();
549 // Hashtable requestData = (Hashtable) request.Params[0];
550
551 // UUID agentId = UUID.Zero;
552 // int amount = 0;
553
554 retparam.Add("success", true);
555 ret.Value = retparam;
556
557 return ret;
558 }
559
560 #endregion
561
562 #region local Fund Management
563
564 /// <summary>
565 /// Ensures that the agent accounting data is set up in this instance.
566 /// </summary>
567 /// <param name="agentID"></param>
568 private void CheckExistAndRefreshFunds(UUID agentID)
569 {
570
571 }
572
573 /// <summary>
574 /// Gets the amount of Funds for an agent
575 /// </summary>
576 /// <param name="AgentID"></param>
577 /// <returns></returns>
578 private int GetFundsForAgentID(UUID AgentID)
579 {
580 int returnfunds = 0;
581
582 return returnfunds;
583 }
584
585 // private void SetLocalFundsForAgentID(UUID AgentID, int amount)
586 // {
587
588 // }
589
590 #endregion
591
592 #region Utility Helpers
593
594 /// <summary>
595 /// Locates a IClientAPI for the client specified
596 /// </summary>
597 /// <param name="AgentID"></param>
598 /// <returns></returns>
599 private IClientAPI LocateClientObject(UUID AgentID)
600 {
601 ScenePresence tPresence = null;
602 IClientAPI rclient = null;
603
604 lock (m_scenel)
605 {
606 foreach (Scene _scene in m_scenel.Values)
607 {
608 tPresence = _scene.GetScenePresence(AgentID);
609 if (tPresence != null)
610 {
611 if (!tPresence.IsChildAgent)
612 {
613 rclient = tPresence.ControllingClient;
614 }
615 }
616 if (rclient != null)
617 {
618 return rclient;
619 }
620 }
621 }
622 return null;
623 }
624
625 private Scene LocateSceneClientIn(UUID AgentId)
626 {
627 lock (m_scenel)
628 {
629 foreach (Scene _scene in m_scenel.Values)
630 {
631 ScenePresence tPresence = _scene.GetScenePresence(AgentId);
632 if (tPresence != null)
633 {
634 if (!tPresence.IsChildAgent)
635 {
636 return _scene;
637 }
638 }
639 }
640 }
641 return null;
642 }
643
644 /// <summary>
645 /// Utility function Gets a Random scene in the instance. For when which scene exactly you're doing something with doesn't matter
646 /// </summary>
647 /// <returns></returns>
648 public Scene GetRandomScene()
649 {
650 lock (m_scenel)
651 {
652 foreach (Scene rs in m_scenel.Values)
653 return rs;
654 }
655 return null;
656 }
657
658 /// <summary>
659 /// Utility function to get a Scene by RegionID in a module
660 /// </summary>
661 /// <param name="RegionID"></param>
662 /// <returns></returns>
663 public Scene GetSceneByUUID(UUID RegionID)
664 {
665 lock (m_scenel)
666 {
667 foreach (Scene rs in m_scenel.Values)
668 {
669 if (rs.RegionInfo.originRegionID == RegionID)
670 {
671 return rs;
672 }
673 }
674 }
675 return null;
676 }
677
678 #endregion
679
680 #region event Handlers
681
682 public void requestPayPrice(IClientAPI client, UUID objectID)
683 {
684 Scene scene = LocateSceneClientIn(client.AgentId);
685 if (scene == null)
686 return;
687
688 SceneObjectPart task = scene.GetSceneObjectPart(objectID);
689 if (task == null)
690 return;
691 SceneObjectGroup group = task.ParentGroup;
692 SceneObjectPart root = group.RootPart;
693
694 client.SendPayPrice(objectID, root.PayPrice);
695 }
696
697 /// <summary>
698 /// When the client closes the connection we remove their accounting info from memory to free up resources.
699 /// </summary>
700 /// <param name="AgentID"></param>
701 public void ClientClosed(UUID AgentID, Scene scene)
702 {
703
704 }
705
706 /// <summary>
707 /// Event called Economy Data Request handler.
708 /// </summary>
709 /// <param name="agentId"></param>
710 public void EconomyDataRequestHandler(UUID agentId)
711 {
712 IClientAPI user = LocateClientObject(agentId);
713
714 if (user != null)
715 {
716 user.SendEconomyData(EnergyEfficiency, ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate,
717 PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor,
718 PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload,
719 TeleportMinPrice, TeleportPriceExponent);
720 }
721 }
722
723 private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e)
724 {
725
726
727 lock (e)
728 {
729 e.economyValidated = true;
730 }
731
732
733 }
734
735 private void processLandBuy(Object osender, EventManager.LandBuyArgs e)
736 {
737
738 }
739
740 /// <summary>
741 /// THis method gets called when someone pays someone else as a gift.
742 /// </summary>
743 /// <param name="osender"></param>
744 /// <param name="e"></param>
745 private void MoneyTransferAction(Object osender, EventManager.MoneyTransferArgs e)
746 {
747
748 }
749
750 /// <summary>
751 /// Event Handler for when a root agent becomes a child agent
752 /// </summary>
753 /// <param name="avatar"></param>
754 private void MakeChildAgent(ScenePresence avatar)
755 {
756
757 }
758
759 /// <summary>
760 /// Event Handler for when the client logs out.
761 /// </summary>
762 /// <param name="AgentId"></param>
763 private void ClientLoggedOut(UUID AgentId, Scene scene)
764 {
765
766 }
767
768 /// <summary>
769 /// Call this when the client disconnects.
770 /// </summary>
771 /// <param name="client"></param>
772 public void ClientClosed(IClientAPI client)
773 {
774 ClientClosed(client.AgentId, null);
775 }
776
777 /// <summary>
778 /// Event Handler for when an Avatar enters one of the parcels in the simulator.
779 /// </summary>
780 /// <param name="avatar"></param>
781 /// <param name="localLandID"></param>
782 /// <param name="regionID"></param>
783 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID)
784 {
785
786 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
787 }
788
789 public int GetBalance(IClientAPI client)
790 {
791 return 0;
792 }
793
794 // Please do not refactor these to be just one method
795 // Existing implementations need the distinction
796 //
797 public bool UploadCovered(IClientAPI client)
798 {
799 return AmountCovered(client, PriceUpload);
800 }
801
802 public bool GroupCreationCovered(IClientAPI client)
803 {
804 return AmountCovered(client, PriceGroupCreate);
805 }
806
807 public bool AmountCovered(IClientAPI client, int amount)
808 {
809 return true;
810 }
811
812 #endregion
813
814 public void ObjectBuy(IClientAPI remoteClient, UUID agentID,
815 UUID sessionID, UUID groupID, UUID categoryID,
816 uint localID, byte saleType, int salePrice)
817 {
818 if (!m_sellEnabled)
819 {
820 remoteClient.SendBlueBoxMessage(UUID.Zero, "", "Buying is not implemented in this version");
821 return;
822 }
823
824 if (salePrice != 0)
825 {
826 remoteClient.SendBlueBoxMessage(UUID.Zero, "", "Buying anything for a price other than zero is not implemented");
827 return;
828 }
829
830 Scene s = LocateSceneClientIn(remoteClient.AgentId);
831 SceneObjectPart part = s.GetSceneObjectPart(localID);
832 if (part == null)
833 {
834 remoteClient.SendAgentAlertMessage("Unable to buy now. The object was not found.", false);
835 return;
836 }
837 s.PerformObjectBuy(remoteClient, categoryID, localID, saleType);
838 }
839 }
840
841 public enum TransactionType : int
842 {
843 SystemGenerated = 0,
844 RegionMoneyRequest = 1,
845 Gift = 2,
846 Purchase = 3
847 }
848
849
850}