aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Currency
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Currency')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs2938
1 files changed, 1469 insertions, 1469 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
index 181984e..966c5e2 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
@@ -1,1470 +1,1470 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Net.Sockets; 32using System.Net.Sockets;
33using System.Reflection; 33using System.Reflection;
34using System.Xml; 34using System.Xml;
35using libsecondlife; 35using libsecondlife;
36using log4net; 36using log4net;
37using Nini.Config; 37using Nini.Config;
38using Nwc.XmlRpc; 38using Nwc.XmlRpc;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Region.Environment.Interfaces; 40using OpenSim.Region.Environment.Interfaces;
41using OpenSim.Region.Environment.Scenes; 41using OpenSim.Region.Environment.Scenes;
42 42
43namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney 43namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
44{ 44{
45 /// <summary> 45 /// <summary>
46 /// Demo Economy/Money Module. This is not a production quality money/economy module! 46 /// 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. 47 /// This is a demo for you to use when making one that works for you.
48 /// // To use the following you need to add: 48 /// // To use the following you need to add:
49 /// -helperuri <ADDRESS TO HERE OR grid MONEY SERVER> 49 /// -helperuri <ADDRESS TO HERE OR grid MONEY SERVER>
50 /// to the command line parameters you use to start up your client 50 /// to the command line parameters you use to start up your client
51 /// This commonly looks like -helperuri http://127.0.0.1:9000/ 51 /// This commonly looks like -helperuri http://127.0.0.1:9000/
52 /// 52 ///
53 /// Centralized grid structure example using OpenSimWi Redux revision 9+ 53 /// Centralized grid structure example using OpenSimWi Redux revision 9+
54 /// svn co https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux 54 /// svn co https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux
55 /// </summary> 55 /// </summary>
56 public delegate void ObjectPaid(LLUUID objectID, LLUUID agentID, int amount); 56 public delegate void ObjectPaid(LLUUID objectID, LLUUID agentID, int amount);
57 57
58 public interface IMoneyModule : IRegionModule 58 public interface IMoneyModule : IRegionModule
59 { 59 {
60 bool ObjectGiveMoney(LLUUID objectID, LLUUID fromID, LLUUID toID, int amount); 60 bool ObjectGiveMoney(LLUUID objectID, LLUUID fromID, LLUUID toID, int amount);
61 61
62 event ObjectPaid OnObjectPaid; 62 event ObjectPaid OnObjectPaid;
63 } 63 }
64 64
65 public class SampleMoneyModule : IMoneyModule 65 public class SampleMoneyModule : IMoneyModule
66 { 66 {
67 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 67 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
68 68
69 /// <summary> 69 /// <summary>
70 /// Where Stipends come from and Fees go to. 70 /// Where Stipends come from and Fees go to.
71 /// </summary> 71 /// </summary>
72 private LLUUID EconomyBaseAccount = LLUUID.Zero; 72 private LLUUID EconomyBaseAccount = LLUUID.Zero;
73 73
74 private float EnergyEfficiency = 0f; 74 private float EnergyEfficiency = 0f;
75 private bool gridmode = false; 75 private bool gridmode = false;
76 private ObjectPaid handerOnObjectPaid; 76 private ObjectPaid handerOnObjectPaid;
77 private bool m_enabled = true; 77 private bool m_enabled = true;
78 78
79 private IConfigSource m_gConfig; 79 private IConfigSource m_gConfig;
80 80
81 private bool m_keepMoneyAcrossLogins = true; 81 private bool m_keepMoneyAcrossLogins = true;
82 private Dictionary<LLUUID, int> m_KnownClientFunds = new Dictionary<LLUUID, int>(); 82 private Dictionary<LLUUID, int> m_KnownClientFunds = new Dictionary<LLUUID, int>();
83 private string m_LandAddress = String.Empty; 83 private string m_LandAddress = String.Empty;
84 84
85 private int m_minFundsBeforeRefresh = 100; 85 private int m_minFundsBeforeRefresh = 100;
86 private string m_MoneyAddress = String.Empty; 86 private string m_MoneyAddress = String.Empty;
87 87
88 /// <summary> 88 /// <summary>
89 /// Region UUIDS indexed by AgentID 89 /// Region UUIDS indexed by AgentID
90 /// </summary> 90 /// </summary>
91 private Dictionary<LLUUID, LLUUID> m_rootAgents = new Dictionary<LLUUID, LLUUID>(); 91 private Dictionary<LLUUID, LLUUID> m_rootAgents = new Dictionary<LLUUID, LLUUID>();
92 92
93 /// <summary> 93 /// <summary>
94 /// Scenes by Region Handle 94 /// Scenes by Region Handle
95 /// </summary> 95 /// </summary>
96 private Dictionary<ulong, Scene> m_scenel = new Dictionary<ulong, Scene>(); 96 private Dictionary<ulong, Scene> m_scenel = new Dictionary<ulong, Scene>();
97 97
98 private int m_stipend = 1000; 98 private int m_stipend = 1000;
99 99
100 private int ObjectCapacity = 45000; 100 private int ObjectCapacity = 45000;
101 private int ObjectCount = 0; 101 private int ObjectCount = 0;
102 private int PriceEnergyUnit = 0; 102 private int PriceEnergyUnit = 0;
103 private int PriceGroupCreate = 0; 103 private int PriceGroupCreate = 0;
104 private int PriceObjectClaim = 0; 104 private int PriceObjectClaim = 0;
105 private float PriceObjectRent = 0f; 105 private float PriceObjectRent = 0f;
106 private float PriceObjectScaleFactor = 0f; 106 private float PriceObjectScaleFactor = 0f;
107 private int PriceParcelClaim = 0; 107 private int PriceParcelClaim = 0;
108 private float PriceParcelClaimFactor = 0f; 108 private float PriceParcelClaimFactor = 0f;
109 private int PriceParcelRent = 0; 109 private int PriceParcelRent = 0;
110 private int PricePublicObjectDecay = 0; 110 private int PricePublicObjectDecay = 0;
111 private int PricePublicObjectDelete = 0; 111 private int PricePublicObjectDelete = 0;
112 private int PriceRentLight = 0; 112 private int PriceRentLight = 0;
113 private int PriceUpload = 0; 113 private int PriceUpload = 0;
114 private int TeleportMinPrice = 0; 114 private int TeleportMinPrice = 0;
115 115
116 private float TeleportPriceExponent = 0f; 116 private float TeleportPriceExponent = 0f;
117 private int UserLevelPaysFees = 2; 117 private int UserLevelPaysFees = 2;
118 private Scene XMLRPCHandler; 118 private Scene XMLRPCHandler;
119 119
120 #region IMoneyModule Members 120 #region IMoneyModule Members
121 121
122 public event ObjectPaid OnObjectPaid; 122 public event ObjectPaid OnObjectPaid;
123 123
124 /// <summary> 124 /// <summary>
125 /// Startup 125 /// Startup
126 /// </summary> 126 /// </summary>
127 /// <param name="scene"></param> 127 /// <param name="scene"></param>
128 /// <param name="config"></param> 128 /// <param name="config"></param>
129 public void Initialise(Scene scene, IConfigSource config) 129 public void Initialise(Scene scene, IConfigSource config)
130 { 130 {
131 m_gConfig = config; 131 m_gConfig = config;
132 132
133 IConfig startupConfig = m_gConfig.Configs["Startup"]; 133 IConfig startupConfig = m_gConfig.Configs["Startup"];
134 IConfig economyConfig = m_gConfig.Configs["Economy"]; 134 IConfig economyConfig = m_gConfig.Configs["Economy"];
135 135
136 scene.RegisterModuleInterface<IMoneyModule>(this); 136 scene.RegisterModuleInterface<IMoneyModule>(this);
137 137
138 ReadConfigAndPopulate(scene, startupConfig, "Startup"); 138 ReadConfigAndPopulate(scene, startupConfig, "Startup");
139 ReadConfigAndPopulate(scene, economyConfig, "Economy"); 139 ReadConfigAndPopulate(scene, economyConfig, "Economy");
140 140
141 if (m_enabled) 141 if (m_enabled)
142 { 142 {
143 lock (m_scenel) 143 lock (m_scenel)
144 { 144 {
145 if (m_scenel.Count == 0) 145 if (m_scenel.Count == 0)
146 { 146 {
147 XMLRPCHandler = scene; 147 XMLRPCHandler = scene;
148 148
149 // To use the following you need to add: 149 // To use the following you need to add:
150 // -helperuri <ADDRESS TO HERE OR grid MONEY SERVER> 150 // -helperuri <ADDRESS TO HERE OR grid MONEY SERVER>
151 // to the command line parameters you use to start up your client 151 // to the command line parameters you use to start up your client
152 // This commonly looks like -helperuri http://127.0.0.1:9000/ 152 // This commonly looks like -helperuri http://127.0.0.1:9000/
153 153
154 if (m_MoneyAddress.Length > 0) 154 if (m_MoneyAddress.Length > 0)
155 { 155 {
156 // Centralized grid structure using OpenSimWi Redux revision 9+ 156 // Centralized grid structure using OpenSimWi Redux revision 9+
157 // https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux 157 // https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux
158 scene.AddXmlRPCHandler("balanceUpdateRequest", GridMoneyUpdate); 158 scene.AddXmlRPCHandler("balanceUpdateRequest", GridMoneyUpdate);
159 scene.AddXmlRPCHandler("userAlert", UserAlert); 159 scene.AddXmlRPCHandler("userAlert", UserAlert);
160 } 160 }
161 else 161 else
162 { 162 {
163 // Local Server.. enables functionality only. 163 // Local Server.. enables functionality only.
164 scene.AddXmlRPCHandler("getCurrencyQuote", quote_func); 164 scene.AddXmlRPCHandler("getCurrencyQuote", quote_func);
165 scene.AddXmlRPCHandler("buyCurrency", buy_func); 165 scene.AddXmlRPCHandler("buyCurrency", buy_func);
166 scene.AddXmlRPCHandler("preflightBuyLandPrep", preflightBuyLandPrep_func); 166 scene.AddXmlRPCHandler("preflightBuyLandPrep", preflightBuyLandPrep_func);
167 scene.AddXmlRPCHandler("buyLandPrep", landBuy_func); 167 scene.AddXmlRPCHandler("buyLandPrep", landBuy_func);
168 } 168 }
169 } 169 }
170 170
171 if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle)) 171 if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle))
172 { 172 {
173 m_scenel[scene.RegionInfo.RegionHandle] = scene; 173 m_scenel[scene.RegionInfo.RegionHandle] = scene;
174 } 174 }
175 else 175 else
176 { 176 {
177 m_scenel.Add(scene.RegionInfo.RegionHandle, scene); 177 m_scenel.Add(scene.RegionInfo.RegionHandle, scene);
178 } 178 }
179 } 179 }
180 180
181 scene.EventManager.OnNewClient += OnNewClient; 181 scene.EventManager.OnNewClient += OnNewClient;
182 scene.EventManager.OnMoneyTransfer += MoneyTransferAction; 182 scene.EventManager.OnMoneyTransfer += MoneyTransferAction;
183 scene.EventManager.OnClientClosed += ClientClosed; 183 scene.EventManager.OnClientClosed += ClientClosed;
184 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; 184 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
185 scene.EventManager.OnMakeChildAgent += MakeChildAgent; 185 scene.EventManager.OnMakeChildAgent += MakeChildAgent;
186 scene.EventManager.OnClientClosed += ClientLoggedOut; 186 scene.EventManager.OnClientClosed += ClientLoggedOut;
187 scene.EventManager.OnValidateLandBuy += ValidateLandBuy; 187 scene.EventManager.OnValidateLandBuy += ValidateLandBuy;
188 scene.EventManager.OnLandBuy += processLandBuy; 188 scene.EventManager.OnLandBuy += processLandBuy;
189 } 189 }
190 } 190 }
191 191
192 public bool ObjectGiveMoney(LLUUID objectID, LLUUID fromID, LLUUID toID, int amount) 192 public bool ObjectGiveMoney(LLUUID objectID, LLUUID fromID, LLUUID toID, int amount)
193 { 193 {
194 string description = String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID)); 194 string description = String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID));
195 195
196 bool give_result = doMoneyTransfer(fromID, toID, amount, 2, description); 196 bool give_result = doMoneyTransfer(fromID, toID, amount, 2, description);
197 197
198 if (m_MoneyAddress.Length == 0) 198 if (m_MoneyAddress.Length == 0)
199 BalanceUpdate(fromID, toID, give_result, description); 199 BalanceUpdate(fromID, toID, give_result, description);
200 200
201 return give_result; 201 return give_result;
202 } 202 }
203 203
204 public void PostInitialise() 204 public void PostInitialise()
205 { 205 {
206 } 206 }
207 207
208 public void Close() 208 public void Close()
209 { 209 {
210 } 210 }
211 211
212 public string Name 212 public string Name
213 { 213 {
214 get { return "BetaGridLikeMoneyModule"; } 214 get { return "BetaGridLikeMoneyModule"; }
215 } 215 }
216 216
217 public bool IsSharedModule 217 public bool IsSharedModule
218 { 218 {
219 get { return true; } 219 get { return true; }
220 } 220 }
221 221
222 #endregion 222 #endregion
223 223
224 /// <summary> 224 /// <summary>
225 /// Parse Configuration 225 /// Parse Configuration
226 /// </summary> 226 /// </summary>
227 /// <param name="scene"></param> 227 /// <param name="scene"></param>
228 /// <param name="startupConfig"></param> 228 /// <param name="startupConfig"></param>
229 /// <param name="config"></param> 229 /// <param name="config"></param>
230 private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string config) 230 private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string config)
231 { 231 {
232 if (config == "Startup" && startupConfig != null) 232 if (config == "Startup" && startupConfig != null)
233 { 233 {
234 gridmode = startupConfig.GetBoolean("gridmode", false); 234 gridmode = startupConfig.GetBoolean("gridmode", false);
235 m_enabled = (startupConfig.GetString("economymodule", "BetaGridLikeMoneyModule") == "BetaGridLikeMoneyModule"); 235 m_enabled = (startupConfig.GetString("economymodule", "BetaGridLikeMoneyModule") == "BetaGridLikeMoneyModule");
236 } 236 }
237 237
238 if (config == "Economy" && startupConfig != null) 238 if (config == "Economy" && startupConfig != null)
239 { 239 {
240 ObjectCapacity = startupConfig.GetInt("ObjectCapacity", 45000); 240 ObjectCapacity = startupConfig.GetInt("ObjectCapacity", 45000);
241 PriceEnergyUnit = startupConfig.GetInt("PriceEnergyUnit", 100); 241 PriceEnergyUnit = startupConfig.GetInt("PriceEnergyUnit", 100);
242 PriceObjectClaim = startupConfig.GetInt("PriceObjectClaim", 10); 242 PriceObjectClaim = startupConfig.GetInt("PriceObjectClaim", 10);
243 PricePublicObjectDecay = startupConfig.GetInt("PricePublicObjectDecay", 4); 243 PricePublicObjectDecay = startupConfig.GetInt("PricePublicObjectDecay", 4);
244 PricePublicObjectDelete = startupConfig.GetInt("PricePublicObjectDelete", 4); 244 PricePublicObjectDelete = startupConfig.GetInt("PricePublicObjectDelete", 4);
245 PriceParcelClaim = startupConfig.GetInt("PriceParcelClaim", 1); 245 PriceParcelClaim = startupConfig.GetInt("PriceParcelClaim", 1);
246 PriceParcelClaimFactor = startupConfig.GetFloat("PriceParcelClaimFactor", 1f); 246 PriceParcelClaimFactor = startupConfig.GetFloat("PriceParcelClaimFactor", 1f);
247 PriceUpload = startupConfig.GetInt("PriceUpload", 0); 247 PriceUpload = startupConfig.GetInt("PriceUpload", 0);
248 PriceRentLight = startupConfig.GetInt("PriceRentLight", 5); 248 PriceRentLight = startupConfig.GetInt("PriceRentLight", 5);
249 TeleportMinPrice = startupConfig.GetInt("TeleportMinPrice", 2); 249 TeleportMinPrice = startupConfig.GetInt("TeleportMinPrice", 2);
250 TeleportPriceExponent = startupConfig.GetFloat("TeleportPriceExponent", 2f); 250 TeleportPriceExponent = startupConfig.GetFloat("TeleportPriceExponent", 2f);
251 EnergyEfficiency = startupConfig.GetFloat("EnergyEfficiency", 1); 251 EnergyEfficiency = startupConfig.GetFloat("EnergyEfficiency", 1);
252 PriceObjectRent = startupConfig.GetFloat("PriceObjectRent", 1); 252 PriceObjectRent = startupConfig.GetFloat("PriceObjectRent", 1);
253 PriceObjectScaleFactor = startupConfig.GetFloat("PriceObjectScaleFactor", 10); 253 PriceObjectScaleFactor = startupConfig.GetFloat("PriceObjectScaleFactor", 10);
254 PriceParcelRent = startupConfig.GetInt("PriceParcelRent", 1); 254 PriceParcelRent = startupConfig.GetInt("PriceParcelRent", 1);
255 PriceGroupCreate = startupConfig.GetInt("PriceGroupCreate", -1); 255 PriceGroupCreate = startupConfig.GetInt("PriceGroupCreate", -1);
256 string EBA = startupConfig.GetString("EconomyBaseAccount", LLUUID.Zero.ToString()); 256 string EBA = startupConfig.GetString("EconomyBaseAccount", LLUUID.Zero.ToString());
257 Helpers.TryParse(EBA, out EconomyBaseAccount); 257 Helpers.TryParse(EBA, out EconomyBaseAccount);
258 258
259 UserLevelPaysFees = startupConfig.GetInt("UserLevelPaysFees", -1); 259 UserLevelPaysFees = startupConfig.GetInt("UserLevelPaysFees", -1);
260 m_stipend = startupConfig.GetInt("UserStipend", 500); 260 m_stipend = startupConfig.GetInt("UserStipend", 500);
261 m_minFundsBeforeRefresh = startupConfig.GetInt("IssueStipendWhenClientIsBelowAmount", 10); 261 m_minFundsBeforeRefresh = startupConfig.GetInt("IssueStipendWhenClientIsBelowAmount", 10);
262 m_keepMoneyAcrossLogins = startupConfig.GetBoolean("KeepMoneyAcrossLogins", true); 262 m_keepMoneyAcrossLogins = startupConfig.GetBoolean("KeepMoneyAcrossLogins", true);
263 m_MoneyAddress = startupConfig.GetString("CurrencyServer", String.Empty); 263 m_MoneyAddress = startupConfig.GetString("CurrencyServer", String.Empty);
264 m_LandAddress = startupConfig.GetString("LandServer", String.Empty); 264 m_LandAddress = startupConfig.GetString("LandServer", String.Empty);
265 } 265 }
266 266
267 // Send ObjectCapacity to Scene.. Which sends it to the SimStatsReporter. 267 // Send ObjectCapacity to Scene.. Which sends it to the SimStatsReporter.
268 scene.SetObjectCapacity(ObjectCapacity); 268 scene.SetObjectCapacity(ObjectCapacity);
269 } 269 }
270 270
271 /// <summary> 271 /// <summary>
272 /// New Client Event Handler 272 /// New Client Event Handler
273 /// </summary> 273 /// </summary>
274 /// <param name="client"></param> 274 /// <param name="client"></param>
275 private void OnNewClient(IClientAPI client) 275 private void OnNewClient(IClientAPI client)
276 { 276 {
277 // Here we check if we're in grid mode 277 // Here we check if we're in grid mode
278 // I imagine that the 'check balance' 278 // I imagine that the 'check balance'
279 // function for the client should be here or shortly after 279 // function for the client should be here or shortly after
280 280
281 if (gridmode) 281 if (gridmode)
282 { 282 {
283 if (m_MoneyAddress.Length == 0) 283 if (m_MoneyAddress.Length == 0)
284 { 284 {
285 CheckExistAndRefreshFunds(client.AgentId); 285 CheckExistAndRefreshFunds(client.AgentId);
286 } 286 }
287 else 287 else
288 { 288 {
289 bool childYN = true; 289 bool childYN = true;
290 ScenePresence agent = null; 290 ScenePresence agent = null;
291 //client.SecureSessionId; 291 //client.SecureSessionId;
292 Scene s = LocateSceneClientIn(client.AgentId); 292 Scene s = LocateSceneClientIn(client.AgentId);
293 if (s != null) 293 if (s != null)
294 { 294 {
295 agent = s.GetScenePresence(client.AgentId); 295 agent = s.GetScenePresence(client.AgentId);
296 if (agent != null) 296 if (agent != null)
297 childYN = agent.IsChildAgent; 297 childYN = agent.IsChildAgent;
298 } 298 }
299 if (s != null && agent != null && childYN == false) 299 if (s != null && agent != null && childYN == false)
300 { 300 {
301 //s.RegionInfo.RegionHandle; 301 //s.RegionInfo.RegionHandle;
302 LLUUID agentID = LLUUID.Zero; 302 LLUUID agentID = LLUUID.Zero;
303 int funds = 0; 303 int funds = 0;
304 304
305 Hashtable hbinfo = 305 Hashtable hbinfo =
306 GetBalanceForUserFromMoneyServer(client.AgentId, client.SecureSessionId, s.RegionInfo.originRegionID.ToString(), 306 GetBalanceForUserFromMoneyServer(client.AgentId, client.SecureSessionId, s.RegionInfo.originRegionID.ToString(),
307 s.RegionInfo.regionSecret); 307 s.RegionInfo.regionSecret);
308 if ((bool) hbinfo["success"] == true) 308 if ((bool) hbinfo["success"] == true)
309 { 309 {
310 Helpers.TryParse((string) hbinfo["agentId"], out agentID); 310 Helpers.TryParse((string) hbinfo["agentId"], out agentID);
311 try 311 try
312 { 312 {
313 funds = (Int32) hbinfo["funds"]; 313 funds = (Int32) hbinfo["funds"];
314 } 314 }
315 catch (ArgumentException) 315 catch (ArgumentException)
316 { 316 {
317 } 317 }
318 catch (FormatException) 318 catch (FormatException)
319 { 319 {
320 } 320 }
321 catch (OverflowException) 321 catch (OverflowException)
322 { 322 {
323 m_log.ErrorFormat("[MONEY]: While getting the Currency for user {0}, the return funds overflowed.", agentID); 323 m_log.ErrorFormat("[MONEY]: While getting the Currency for user {0}, the return funds overflowed.", agentID);
324 client.SendAlertMessage("Unable to get your money balance, money operations will be unavailable"); 324 client.SendAlertMessage("Unable to get your money balance, money operations will be unavailable");
325 } 325 }
326 catch (InvalidCastException) 326 catch (InvalidCastException)
327 { 327 {
328 funds = 0; 328 funds = 0;
329 } 329 }
330 330
331 m_KnownClientFunds[agentID] = funds; 331 m_KnownClientFunds[agentID] = funds;
332 } 332 }
333 else 333 else
334 { 334 {
335 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentID, 335 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentID,
336 (string) hbinfo["errorMessage"]); 336 (string) hbinfo["errorMessage"]);
337 client.SendAlertMessage((string) hbinfo["errorMessage"]); 337 client.SendAlertMessage((string) hbinfo["errorMessage"]);
338 } 338 }
339 SendMoneyBalance(client, agentID, client.SessionId, LLUUID.Zero); 339 SendMoneyBalance(client, agentID, client.SessionId, LLUUID.Zero);
340 } 340 }
341 } 341 }
342 } 342 }
343 else 343 else
344 { 344 {
345 CheckExistAndRefreshFunds(client.AgentId); 345 CheckExistAndRefreshFunds(client.AgentId);
346 } 346 }
347 347
348 // Subscribe to Money messages 348 // Subscribe to Money messages
349 client.OnEconomyDataRequest += EconomyDataRequestHandler; 349 client.OnEconomyDataRequest += EconomyDataRequestHandler;
350 client.OnMoneyBalanceRequest += SendMoneyBalance; 350 client.OnMoneyBalanceRequest += SendMoneyBalance;
351 client.OnRequestPayPrice += requestPayPrice; 351 client.OnRequestPayPrice += requestPayPrice;
352 client.OnLogout += ClientClosed; 352 client.OnLogout += ClientClosed;
353 } 353 }
354 354
355 /// <summary> 355 /// <summary>
356 /// Transfer money 356 /// Transfer money
357 /// </summary> 357 /// </summary>
358 /// <param name="Sender"></param> 358 /// <param name="Sender"></param>
359 /// <param name="Receiver"></param> 359 /// <param name="Receiver"></param>
360 /// <param name="amount"></param> 360 /// <param name="amount"></param>
361 /// <returns></returns> 361 /// <returns></returns>
362 private bool doMoneyTransfer(LLUUID Sender, LLUUID Receiver, int amount, int transactiontype, string description) 362 private bool doMoneyTransfer(LLUUID Sender, LLUUID Receiver, int amount, int transactiontype, string description)
363 { 363 {
364 bool result = false; 364 bool result = false;
365 if (amount >= 0) 365 if (amount >= 0)
366 { 366 {
367 lock (m_KnownClientFunds) 367 lock (m_KnownClientFunds)
368 { 368 {
369 // If we don't know about the sender, then the sender can't 369 // If we don't know about the sender, then the sender can't
370 // actually be here and therefore this is likely fraud or outdated. 370 // actually be here and therefore this is likely fraud or outdated.
371 if (m_MoneyAddress.Length == 0) 371 if (m_MoneyAddress.Length == 0)
372 { 372 {
373 if (m_KnownClientFunds.ContainsKey(Sender)) 373 if (m_KnownClientFunds.ContainsKey(Sender))
374 { 374 {
375 // Does the sender have enough funds to give? 375 // Does the sender have enough funds to give?
376 if (m_KnownClientFunds[Sender] >= amount) 376 if (m_KnownClientFunds[Sender] >= amount)
377 { 377 {
378 // Subtract the funds from the senders account 378 // Subtract the funds from the senders account
379 m_KnownClientFunds[Sender] -= amount; 379 m_KnownClientFunds[Sender] -= amount;
380 380
381 // do we know about the receiver? 381 // do we know about the receiver?
382 if (!m_KnownClientFunds.ContainsKey(Receiver)) 382 if (!m_KnownClientFunds.ContainsKey(Receiver))
383 { 383 {
384 // Make a record for them so they get the updated balance when they login 384 // Make a record for them so they get the updated balance when they login
385 CheckExistAndRefreshFunds(Receiver); 385 CheckExistAndRefreshFunds(Receiver);
386 } 386 }
387 if (m_enabled) 387 if (m_enabled)
388 { 388 {
389 //Add the amount to the Receiver's funds 389 //Add the amount to the Receiver's funds
390 m_KnownClientFunds[Receiver] += amount; 390 m_KnownClientFunds[Receiver] += amount;
391 result = true; 391 result = true;
392 } 392 }
393 } 393 }
394 else 394 else
395 { 395 {
396 // These below are redundant to make this clearer to read 396 // These below are redundant to make this clearer to read
397 result = false; 397 result = false;
398 } 398 }
399 } 399 }
400 else 400 else
401 { 401 {
402 result = false; 402 result = false;
403 } 403 }
404 } 404 }
405 else 405 else
406 { 406 {
407 result = TransferMoneyonMoneyServer(Sender, Receiver, amount, transactiontype, description); 407 result = TransferMoneyonMoneyServer(Sender, Receiver, amount, transactiontype, description);
408 } 408 }
409 } 409 }
410 } 410 }
411 return result; 411 return result;
412 } 412 }
413 413
414 414
415 /// <summary> 415 /// <summary>
416 /// Sends the the stored money balance to the client 416 /// Sends the the stored money balance to the client
417 /// </summary> 417 /// </summary>
418 /// <param name="client"></param> 418 /// <param name="client"></param>
419 /// <param name="agentID"></param> 419 /// <param name="agentID"></param>
420 /// <param name="SessionID"></param> 420 /// <param name="SessionID"></param>
421 /// <param name="TransactionID"></param> 421 /// <param name="TransactionID"></param>
422 public void SendMoneyBalance(IClientAPI client, LLUUID agentID, LLUUID SessionID, LLUUID TransactionID) 422 public void SendMoneyBalance(IClientAPI client, LLUUID agentID, LLUUID SessionID, LLUUID TransactionID)
423 { 423 {
424 if (client.AgentId == agentID && client.SessionId == SessionID) 424 if (client.AgentId == agentID && client.SessionId == SessionID)
425 { 425 {
426 int returnfunds = 0; 426 int returnfunds = 0;
427 427
428 try 428 try
429 { 429 {
430 returnfunds = GetFundsForAgentID(agentID); 430 returnfunds = GetFundsForAgentID(agentID);
431 } 431 }
432 catch (Exception e) 432 catch (Exception e)
433 { 433 {
434 client.SendAlertMessage(e.Message + " "); 434 client.SendAlertMessage(e.Message + " ");
435 } 435 }
436 436
437 client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds); 437 client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds);
438 } 438 }
439 else 439 else
440 { 440 {
441 client.SendAlertMessage("Unable to send your money balance to you!"); 441 client.SendAlertMessage("Unable to send your money balance to you!");
442 } 442 }
443 } 443 }
444 444
445 /// <summary> 445 /// <summary>
446 /// Gets the current balance for the user from the Grid Money Server 446 /// Gets the current balance for the user from the Grid Money Server
447 /// </summary> 447 /// </summary>
448 /// <param name="agentId"></param> 448 /// <param name="agentId"></param>
449 /// <param name="secureSessionID"></param> 449 /// <param name="secureSessionID"></param>
450 /// <param name="regionId"></param> 450 /// <param name="regionId"></param>
451 /// <param name="regionSecret"></param> 451 /// <param name="regionSecret"></param>
452 /// <returns></returns> 452 /// <returns></returns>
453 public Hashtable GetBalanceForUserFromMoneyServer(LLUUID agentId, LLUUID secureSessionID, LLUUID regionId, string regionSecret) 453 public Hashtable GetBalanceForUserFromMoneyServer(LLUUID agentId, LLUUID secureSessionID, LLUUID regionId, string regionSecret)
454 { 454 {
455 Hashtable MoneyBalanceRequestParams = new Hashtable(); 455 Hashtable MoneyBalanceRequestParams = new Hashtable();
456 MoneyBalanceRequestParams["agentId"] = agentId.ToString(); 456 MoneyBalanceRequestParams["agentId"] = agentId.ToString();
457 MoneyBalanceRequestParams["secureSessionId"] = secureSessionID.ToString(); 457 MoneyBalanceRequestParams["secureSessionId"] = secureSessionID.ToString();
458 MoneyBalanceRequestParams["regionId"] = regionId.ToString(); 458 MoneyBalanceRequestParams["regionId"] = regionId.ToString();
459 MoneyBalanceRequestParams["secret"] = regionSecret; 459 MoneyBalanceRequestParams["secret"] = regionSecret;
460 MoneyBalanceRequestParams["currencySecret"] = ""; // per - region/user currency secret gotten from the money system 460 MoneyBalanceRequestParams["currencySecret"] = ""; // per - region/user currency secret gotten from the money system
461 461
462 Hashtable MoneyRespData = genericCurrencyXMLRPCRequest(MoneyBalanceRequestParams, "simulatorUserBalanceRequest"); 462 Hashtable MoneyRespData = genericCurrencyXMLRPCRequest(MoneyBalanceRequestParams, "simulatorUserBalanceRequest");
463 463
464 return MoneyRespData; 464 return MoneyRespData;
465 } 465 }
466 466
467 467
468 /// <summary> 468 /// <summary>
469 /// Generic XMLRPC client abstraction 469 /// Generic XMLRPC client abstraction
470 /// </summary> 470 /// </summary>
471 /// <param name="ReqParams">Hashtable containing parameters to the method</param> 471 /// <param name="ReqParams">Hashtable containing parameters to the method</param>
472 /// <param name="method">Method to invoke</param> 472 /// <param name="method">Method to invoke</param>
473 /// <returns>Hashtable with success=>bool and other values</returns> 473 /// <returns>Hashtable with success=>bool and other values</returns>
474 public Hashtable genericCurrencyXMLRPCRequest(Hashtable ReqParams, string method) 474 public Hashtable genericCurrencyXMLRPCRequest(Hashtable ReqParams, string method)
475 { 475 {
476 ArrayList SendParams = new ArrayList(); 476 ArrayList SendParams = new ArrayList();
477 SendParams.Add(ReqParams); 477 SendParams.Add(ReqParams);
478 // Send Request 478 // Send Request
479 XmlRpcResponse MoneyResp; 479 XmlRpcResponse MoneyResp;
480 try 480 try
481 { 481 {
482 XmlRpcRequest BalanceRequestReq = new XmlRpcRequest(method, SendParams); 482 XmlRpcRequest BalanceRequestReq = new XmlRpcRequest(method, SendParams);
483 MoneyResp = BalanceRequestReq.Send(m_MoneyAddress, 30000); 483 MoneyResp = BalanceRequestReq.Send(m_MoneyAddress, 30000);
484 } 484 }
485 catch (WebException ex) 485 catch (WebException ex)
486 { 486 {
487 m_log.ErrorFormat( 487 m_log.ErrorFormat(
488 "[MONEY]: Unable to connect to Money Server {0}. Exception {1}", 488 "[MONEY]: Unable to connect to Money Server {0}. Exception {1}",
489 m_MoneyAddress, ex); 489 m_MoneyAddress, ex);
490 490
491 Hashtable ErrorHash = new Hashtable(); 491 Hashtable ErrorHash = new Hashtable();
492 ErrorHash["success"] = false; 492 ErrorHash["success"] = false;
493 ErrorHash["errorMessage"] = "Unable to manage your money at this time. Purchases may be unavailable"; 493 ErrorHash["errorMessage"] = "Unable to manage your money at this time. Purchases may be unavailable";
494 ErrorHash["errorURI"] = ""; 494 ErrorHash["errorURI"] = "";
495 495
496 return ErrorHash; 496 return ErrorHash;
497 //throw (ex); 497 //throw (ex);
498 } 498 }
499 catch (SocketException ex) 499 catch (SocketException ex)
500 { 500 {
501 m_log.ErrorFormat( 501 m_log.ErrorFormat(
502 "[MONEY]: Unable to connect to Money Server {0}. Exception {1}", 502 "[MONEY]: Unable to connect to Money Server {0}. Exception {1}",
503 m_MoneyAddress, ex); 503 m_MoneyAddress, ex);
504 504
505 Hashtable ErrorHash = new Hashtable(); 505 Hashtable ErrorHash = new Hashtable();
506 ErrorHash["success"] = false; 506 ErrorHash["success"] = false;
507 ErrorHash["errorMessage"] = "Unable to manage your money at this time. Purchases may be unavailable"; 507 ErrorHash["errorMessage"] = "Unable to manage your money at this time. Purchases may be unavailable";
508 ErrorHash["errorURI"] = ""; 508 ErrorHash["errorURI"] = "";
509 509
510 return ErrorHash; 510 return ErrorHash;
511 //throw (ex); 511 //throw (ex);
512 } 512 }
513 catch (XmlException ex) 513 catch (XmlException ex)
514 { 514 {
515 m_log.ErrorFormat( 515 m_log.ErrorFormat(
516 "[MONEY]: Unable to connect to Money Server {0}. Exception {1}", 516 "[MONEY]: Unable to connect to Money Server {0}. Exception {1}",
517 m_MoneyAddress, ex); 517 m_MoneyAddress, ex);
518 518
519 Hashtable ErrorHash = new Hashtable(); 519 Hashtable ErrorHash = new Hashtable();
520 ErrorHash["success"] = false; 520 ErrorHash["success"] = false;
521 ErrorHash["errorMessage"] = "Unable to manage your money at this time. Purchases may be unavailable"; 521 ErrorHash["errorMessage"] = "Unable to manage your money at this time. Purchases may be unavailable";
522 ErrorHash["errorURI"] = ""; 522 ErrorHash["errorURI"] = "";
523 523
524 return ErrorHash; 524 return ErrorHash;
525 } 525 }
526 if (MoneyResp.IsFault) 526 if (MoneyResp.IsFault)
527 { 527 {
528 Hashtable ErrorHash = new Hashtable(); 528 Hashtable ErrorHash = new Hashtable();
529 ErrorHash["success"] = false; 529 ErrorHash["success"] = false;
530 ErrorHash["errorMessage"] = "Unable to manage your money at this time. Purchases may be unavailable"; 530 ErrorHash["errorMessage"] = "Unable to manage your money at this time. Purchases may be unavailable";
531 ErrorHash["errorURI"] = ""; 531 ErrorHash["errorURI"] = "";
532 532
533 return ErrorHash; 533 return ErrorHash;
534 } 534 }
535 Hashtable MoneyRespData = (Hashtable) MoneyResp.Value; 535 Hashtable MoneyRespData = (Hashtable) MoneyResp.Value;
536 536
537 return MoneyRespData; 537 return MoneyRespData;
538 } 538 }
539 539
540 /// <summary> 540 /// <summary>
541 /// This informs the Money Grid Server that the avatar is in this simulator 541 /// This informs the Money Grid Server that the avatar is in this simulator
542 /// </summary> 542 /// </summary>
543 /// <param name="agentId"></param> 543 /// <param name="agentId"></param>
544 /// <param name="secureSessionID"></param> 544 /// <param name="secureSessionID"></param>
545 /// <param name="regionId"></param> 545 /// <param name="regionId"></param>
546 /// <param name="regionSecret"></param> 546 /// <param name="regionSecret"></param>
547 /// <returns></returns> 547 /// <returns></returns>
548 public Hashtable claim_user(LLUUID agentId, LLUUID secureSessionID, LLUUID regionId, string regionSecret) 548 public Hashtable claim_user(LLUUID agentId, LLUUID secureSessionID, LLUUID regionId, string regionSecret)
549 { 549 {
550 Hashtable MoneyBalanceRequestParams = new Hashtable(); 550 Hashtable MoneyBalanceRequestParams = new Hashtable();
551 MoneyBalanceRequestParams["agentId"] = agentId.ToString(); 551 MoneyBalanceRequestParams["agentId"] = agentId.ToString();
552 MoneyBalanceRequestParams["secureSessionId"] = secureSessionID.ToString(); 552 MoneyBalanceRequestParams["secureSessionId"] = secureSessionID.ToString();
553 MoneyBalanceRequestParams["regionId"] = regionId.ToString(); 553 MoneyBalanceRequestParams["regionId"] = regionId.ToString();
554 MoneyBalanceRequestParams["secret"] = regionSecret; 554 MoneyBalanceRequestParams["secret"] = regionSecret;
555 555
556 Hashtable MoneyRespData = genericCurrencyXMLRPCRequest(MoneyBalanceRequestParams, "simulatorClaimUserRequest"); 556 Hashtable MoneyRespData = genericCurrencyXMLRPCRequest(MoneyBalanceRequestParams, "simulatorClaimUserRequest");
557 IClientAPI sendMoneyBal = LocateClientObject(agentId); 557 IClientAPI sendMoneyBal = LocateClientObject(agentId);
558 if (sendMoneyBal != null) 558 if (sendMoneyBal != null)
559 { 559 {
560 SendMoneyBalance(sendMoneyBal, agentId, sendMoneyBal.SessionId, LLUUID.Zero); 560 SendMoneyBalance(sendMoneyBal, agentId, sendMoneyBal.SessionId, LLUUID.Zero);
561 } 561 }
562 return MoneyRespData; 562 return MoneyRespData;
563 } 563 }
564 564
565 private SceneObjectPart findPrim(LLUUID objectID) 565 private SceneObjectPart findPrim(LLUUID objectID)
566 { 566 {
567 lock (m_scenel) 567 lock (m_scenel)
568 { 568 {
569 foreach (Scene s in m_scenel.Values) 569 foreach (Scene s in m_scenel.Values)
570 { 570 {
571 SceneObjectPart part = s.GetSceneObjectPart(objectID); 571 SceneObjectPart part = s.GetSceneObjectPart(objectID);
572 if (part != null) 572 if (part != null)
573 { 573 {
574 return part; 574 return part;
575 } 575 }
576 } 576 }
577 } 577 }
578 return null; 578 return null;
579 } 579 }
580 580
581 private string resolveObjectName(LLUUID objectID) 581 private string resolveObjectName(LLUUID objectID)
582 { 582 {
583 SceneObjectPart part = findPrim(objectID); 583 SceneObjectPart part = findPrim(objectID);
584 if (part != null) 584 if (part != null)
585 { 585 {
586 return part.Name; 586 return part.Name;
587 } 587 }
588 return String.Empty; 588 return String.Empty;
589 } 589 }
590 590
591 private string resolveAgentName(LLUUID agentID) 591 private string resolveAgentName(LLUUID agentID)
592 { 592 {
593 // try avatar username surname 593 // try avatar username surname
594 Scene scene = GetRandomScene(); 594 Scene scene = GetRandomScene();
595 UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(agentID); 595 UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(agentID);
596 if (profile != null) 596 if (profile != null)
597 { 597 {
598 string avatarname = profile.FirstName + " " + profile.SurName; 598 string avatarname = profile.FirstName + " " + profile.SurName;
599 return avatarname; 599 return avatarname;
600 } 600 }
601 return String.Empty; 601 return String.Empty;
602 } 602 }
603 603
604 private void BalanceUpdate(LLUUID senderID, LLUUID receiverID, bool transactionresult, string description) 604 private void BalanceUpdate(LLUUID senderID, LLUUID receiverID, bool transactionresult, string description)
605 { 605 {
606 IClientAPI sender = LocateClientObject(senderID); 606 IClientAPI sender = LocateClientObject(senderID);
607 IClientAPI receiver = LocateClientObject(receiverID); 607 IClientAPI receiver = LocateClientObject(receiverID);
608 608
609 if (senderID != receiverID) 609 if (senderID != receiverID)
610 { 610 {
611 if (sender != null) 611 if (sender != null)
612 { 612 {
613 sender.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(description), GetFundsForAgentID(senderID)); 613 sender.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(description), GetFundsForAgentID(senderID));
614 } 614 }
615 615
616 if (receiver != null) 616 if (receiver != null)
617 { 617 {
618 receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(description), GetFundsForAgentID(receiverID)); 618 receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(description), GetFundsForAgentID(receiverID));
619 } 619 }
620 } 620 }
621 } 621 }
622 622
623 /// <summary> 623 /// <summary>
624 /// Informs the Money Grid Server of a transfer. 624 /// Informs the Money Grid Server of a transfer.
625 /// </summary> 625 /// </summary>
626 /// <param name="sourceId"></param> 626 /// <param name="sourceId"></param>
627 /// <param name="destId"></param> 627 /// <param name="destId"></param>
628 /// <param name="amount"></param> 628 /// <param name="amount"></param>
629 /// <returns></returns> 629 /// <returns></returns>
630 public bool TransferMoneyonMoneyServer(LLUUID sourceId, LLUUID destId, int amount, int transactiontype, string description) 630 public bool TransferMoneyonMoneyServer(LLUUID sourceId, LLUUID destId, int amount, int transactiontype, string description)
631 { 631 {
632 int aggregatePermInventory = 0; 632 int aggregatePermInventory = 0;
633 int aggregatePermNextOwner = 0; 633 int aggregatePermNextOwner = 0;
634 int flags = 0; 634 int flags = 0;
635 bool rvalue = false; 635 bool rvalue = false;
636 636
637 IClientAPI cli = LocateClientObject(sourceId); 637 IClientAPI cli = LocateClientObject(sourceId);
638 if (cli != null) 638 if (cli != null)
639 { 639 {
640 Scene userScene = null; 640 Scene userScene = null;
641 lock (m_rootAgents) 641 lock (m_rootAgents)
642 { 642 {
643 userScene = GetSceneByUUID(m_rootAgents[sourceId]); 643 userScene = GetSceneByUUID(m_rootAgents[sourceId]);
644 } 644 }
645 if (userScene != null) 645 if (userScene != null)
646 { 646 {
647 Hashtable ht = new Hashtable(); 647 Hashtable ht = new Hashtable();
648 ht["agentId"] = sourceId.ToString(); 648 ht["agentId"] = sourceId.ToString();
649 ht["secureSessionId"] = cli.SecureSessionId.ToString(); 649 ht["secureSessionId"] = cli.SecureSessionId.ToString();
650 ht["regionId"] = userScene.RegionInfo.originRegionID.ToString(); 650 ht["regionId"] = userScene.RegionInfo.originRegionID.ToString();
651 ht["secret"] = userScene.RegionInfo.regionSecret; 651 ht["secret"] = userScene.RegionInfo.regionSecret;
652 ht["currencySecret"] = " "; 652 ht["currencySecret"] = " ";
653 ht["destId"] = destId.ToString(); 653 ht["destId"] = destId.ToString();
654 ht["cash"] = amount; 654 ht["cash"] = amount;
655 ht["aggregatePermInventory"] = aggregatePermInventory; 655 ht["aggregatePermInventory"] = aggregatePermInventory;
656 ht["aggregatePermNextOwner"] = aggregatePermNextOwner; 656 ht["aggregatePermNextOwner"] = aggregatePermNextOwner;
657 ht["flags"] = flags; 657 ht["flags"] = flags;
658 ht["transactionType"] = transactiontype; 658 ht["transactionType"] = transactiontype;
659 ht["description"] = description; 659 ht["description"] = description;
660 660
661 Hashtable hresult = genericCurrencyXMLRPCRequest(ht, "regionMoveMoney"); 661 Hashtable hresult = genericCurrencyXMLRPCRequest(ht, "regionMoveMoney");
662 662
663 if ((bool) hresult["success"] == true) 663 if ((bool) hresult["success"] == true)
664 { 664 {
665 int funds1 = 0; 665 int funds1 = 0;
666 int funds2 = 0; 666 int funds2 = 0;
667 try 667 try
668 { 668 {
669 funds1 = (Int32) hresult["funds"]; 669 funds1 = (Int32) hresult["funds"];
670 } 670 }
671 catch (InvalidCastException) 671 catch (InvalidCastException)
672 { 672 {
673 funds1 = 0; 673 funds1 = 0;
674 } 674 }
675 SetLocalFundsForAgentID(sourceId, funds1); 675 SetLocalFundsForAgentID(sourceId, funds1);
676 if (m_KnownClientFunds.ContainsKey(destId)) 676 if (m_KnownClientFunds.ContainsKey(destId))
677 { 677 {
678 try 678 try
679 { 679 {
680 funds2 = (Int32) hresult["funds2"]; 680 funds2 = (Int32) hresult["funds2"];
681 } 681 }
682 catch (InvalidCastException) 682 catch (InvalidCastException)
683 { 683 {
684 funds2 = 0; 684 funds2 = 0;
685 } 685 }
686 SetLocalFundsForAgentID(destId, funds2); 686 SetLocalFundsForAgentID(destId, funds2);
687 } 687 }
688 688
689 689
690 rvalue = true; 690 rvalue = true;
691 } 691 }
692 else 692 else
693 { 693 {
694 cli.SendAgentAlertMessage((string) hresult["errorMessage"], true); 694 cli.SendAgentAlertMessage((string) hresult["errorMessage"], true);
695 } 695 }
696 } 696 }
697 } 697 }
698 else 698 else
699 { 699 {
700 m_log.ErrorFormat("[MONEY]: Client {0} not found", sourceId.ToString()); 700 m_log.ErrorFormat("[MONEY]: Client {0} not found", sourceId.ToString());
701 } 701 }
702 702
703 return rvalue; 703 return rvalue;
704 } 704 }
705 705
706 public int GetRemoteBalance(LLUUID agentId) 706 public int GetRemoteBalance(LLUUID agentId)
707 { 707 {
708 int funds = 0; 708 int funds = 0;
709 709
710 IClientAPI aClient = LocateClientObject(agentId); 710 IClientAPI aClient = LocateClientObject(agentId);
711 if (aClient != null) 711 if (aClient != null)
712 { 712 {
713 Scene s = LocateSceneClientIn(agentId); 713 Scene s = LocateSceneClientIn(agentId);
714 if (s != null) 714 if (s != null)
715 { 715 {
716 if (m_MoneyAddress.Length > 0) 716 if (m_MoneyAddress.Length > 0)
717 { 717 {
718 Hashtable hbinfo = 718 Hashtable hbinfo =
719 GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(), 719 GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(),
720 s.RegionInfo.regionSecret); 720 s.RegionInfo.regionSecret);
721 if ((bool) hbinfo["success"] == true) 721 if ((bool) hbinfo["success"] == true)
722 { 722 {
723 try 723 try
724 { 724 {
725 funds = (Int32) hbinfo["funds"]; 725 funds = (Int32) hbinfo["funds"];
726 } 726 }
727 catch (ArgumentException) 727 catch (ArgumentException)
728 { 728 {
729 } 729 }
730 catch (FormatException) 730 catch (FormatException)
731 { 731 {
732 } 732 }
733 catch (OverflowException) 733 catch (OverflowException)
734 { 734 {
735 m_log.ErrorFormat("[MONEY]: While getting the Currency for user {0}, the return funds overflowed.", agentId); 735 m_log.ErrorFormat("[MONEY]: While getting the Currency for user {0}, the return funds overflowed.", agentId);
736 aClient.SendAlertMessage("Unable to get your money balance, money operations will be unavailable"); 736 aClient.SendAlertMessage("Unable to get your money balance, money operations will be unavailable");
737 } 737 }
738 catch (InvalidCastException) 738 catch (InvalidCastException)
739 { 739 {
740 funds = 0; 740 funds = 0;
741 } 741 }
742 } 742 }
743 else 743 else
744 { 744 {
745 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId, 745 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId,
746 (string) hbinfo["errorMessage"]); 746 (string) hbinfo["errorMessage"]);
747 aClient.SendAlertMessage((string) hbinfo["errorMessage"]); 747 aClient.SendAlertMessage((string) hbinfo["errorMessage"]);
748 } 748 }
749 } 749 }
750 750
751 SetLocalFundsForAgentID(agentId, funds); 751 SetLocalFundsForAgentID(agentId, funds);
752 SendMoneyBalance(aClient, agentId, aClient.SessionId, LLUUID.Zero); 752 SendMoneyBalance(aClient, agentId, aClient.SessionId, LLUUID.Zero);
753 } 753 }
754 else 754 else
755 { 755 {
756 m_log.Debug("[MONEY]: Got balance request update for agent that is here, but couldn't find which scene."); 756 m_log.Debug("[MONEY]: Got balance request update for agent that is here, but couldn't find which scene.");
757 } 757 }
758 } 758 }
759 else 759 else
760 { 760 {
761 m_log.Debug("[MONEY]: Got balance request update for agent that isn't here."); 761 m_log.Debug("[MONEY]: Got balance request update for agent that isn't here.");
762 } 762 }
763 return funds; 763 return funds;
764 } 764 }
765 765
766 public XmlRpcResponse GridMoneyUpdate(XmlRpcRequest request) 766 public XmlRpcResponse GridMoneyUpdate(XmlRpcRequest request)
767 { 767 {
768 m_log.Debug("[MONEY]: Dynamic balance update called."); 768 m_log.Debug("[MONEY]: Dynamic balance update called.");
769 Hashtable requestData = (Hashtable) request.Params[0]; 769 Hashtable requestData = (Hashtable) request.Params[0];
770 770
771 if (requestData.ContainsKey("agentId")) 771 if (requestData.ContainsKey("agentId"))
772 { 772 {
773 LLUUID agentId = LLUUID.Zero; 773 LLUUID agentId = LLUUID.Zero;
774 774
775 Helpers.TryParse((string) requestData["agentId"], out agentId); 775 Helpers.TryParse((string) requestData["agentId"], out agentId);
776 if (agentId != LLUUID.Zero) 776 if (agentId != LLUUID.Zero)
777 { 777 {
778 GetRemoteBalance(agentId); 778 GetRemoteBalance(agentId);
779 } 779 }
780 else 780 else
781 { 781 {
782 m_log.Debug("[MONEY]: invalid agentId specified, dropping."); 782 m_log.Debug("[MONEY]: invalid agentId specified, dropping.");
783 } 783 }
784 } 784 }
785 else 785 else
786 { 786 {
787 m_log.Debug("[MONEY]: no agentId specified, dropping."); 787 m_log.Debug("[MONEY]: no agentId specified, dropping.");
788 } 788 }
789 XmlRpcResponse r = new XmlRpcResponse(); 789 XmlRpcResponse r = new XmlRpcResponse();
790 Hashtable rparms = new Hashtable(); 790 Hashtable rparms = new Hashtable();
791 rparms["success"] = true; 791 rparms["success"] = true;
792 792
793 r.Value = rparms; 793 r.Value = rparms;
794 return r; 794 return r;
795 } 795 }
796 796
797 /// <summary> 797 /// <summary>
798 /// XMLRPC handler to send alert message and sound to client 798 /// XMLRPC handler to send alert message and sound to client
799 /// </summary> 799 /// </summary>
800 public XmlRpcResponse UserAlert(XmlRpcRequest request) 800 public XmlRpcResponse UserAlert(XmlRpcRequest request)
801 { 801 {
802 XmlRpcResponse ret = new XmlRpcResponse(); 802 XmlRpcResponse ret = new XmlRpcResponse();
803 Hashtable retparam = new Hashtable(); 803 Hashtable retparam = new Hashtable();
804 Hashtable requestData = (Hashtable) request.Params[0]; 804 Hashtable requestData = (Hashtable) request.Params[0];
805 805
806 LLUUID agentId = LLUUID.Zero; 806 LLUUID agentId = LLUUID.Zero;
807 LLUUID soundId = LLUUID.Zero; 807 LLUUID soundId = LLUUID.Zero;
808 808
809 Helpers.TryParse((string) requestData["agentId"], out agentId); 809 Helpers.TryParse((string) requestData["agentId"], out agentId);
810 Helpers.TryParse((string) requestData["soundId"], out soundId); 810 Helpers.TryParse((string) requestData["soundId"], out soundId);
811 string text = (string) requestData["text"]; 811 string text = (string) requestData["text"];
812 string secret = (string) requestData["secret"]; 812 string secret = (string) requestData["secret"];
813 813
814 Scene userScene = GetRandomScene(); 814 Scene userScene = GetRandomScene();
815 if (userScene.RegionInfo.regionSecret.ToString() == secret) 815 if (userScene.RegionInfo.regionSecret.ToString() == secret)
816 { 816 {
817 IClientAPI client = LocateClientObject(agentId); 817 IClientAPI client = LocateClientObject(agentId);
818 818
819 if (client != null) 819 if (client != null)
820 { 820 {
821 if (soundId != LLUUID.Zero) 821 if (soundId != LLUUID.Zero)
822 client.SendPlayAttachedSound(soundId, LLUUID.Zero, LLUUID.Zero, 1.0f, 0); 822 client.SendPlayAttachedSound(soundId, LLUUID.Zero, LLUUID.Zero, 1.0f, 0);
823 client.SendBlueBoxMessage(LLUUID.Zero, LLUUID.Zero, "", text); 823 client.SendBlueBoxMessage(LLUUID.Zero, LLUUID.Zero, "", text);
824 retparam.Add("success", true); 824 retparam.Add("success", true);
825 } 825 }
826 else 826 else
827 { 827 {
828 retparam.Add("success", false); 828 retparam.Add("success", false);
829 } 829 }
830 } 830 }
831 else 831 else
832 { 832 {
833 retparam.Add("success", false); 833 retparam.Add("success", false);
834 } 834 }
835 ret.Value = retparam; 835 ret.Value = retparam;
836 836
837 return ret; 837 return ret;
838 } 838 }
839 839
840 # region Standalone box enablers only 840 # region Standalone box enablers only
841 841
842 public XmlRpcResponse quote_func(XmlRpcRequest request) 842 public XmlRpcResponse quote_func(XmlRpcRequest request)
843 { 843 {
844 Hashtable requestData = (Hashtable) request.Params[0]; 844 Hashtable requestData = (Hashtable) request.Params[0];
845 LLUUID agentId = LLUUID.Zero; 845 LLUUID agentId = LLUUID.Zero;
846 int amount = 0; 846 int amount = 0;
847 Hashtable quoteResponse = new Hashtable(); 847 Hashtable quoteResponse = new Hashtable();
848 XmlRpcResponse returnval = new XmlRpcResponse(); 848 XmlRpcResponse returnval = new XmlRpcResponse();
849 849
850 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy")) 850 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy"))
851 { 851 {
852 Helpers.TryParse((string) requestData["agentId"], out agentId); 852 Helpers.TryParse((string) requestData["agentId"], out agentId);
853 try 853 try
854 { 854 {
855 amount = (Int32) requestData["currencyBuy"]; 855 amount = (Int32) requestData["currencyBuy"];
856 } 856 }
857 catch (InvalidCastException) 857 catch (InvalidCastException)
858 { 858 {
859 } 859 }
860 Hashtable currencyResponse = new Hashtable(); 860 Hashtable currencyResponse = new Hashtable();
861 currencyResponse.Add("estimatedCost", 0); 861 currencyResponse.Add("estimatedCost", 0);
862 currencyResponse.Add("currencyBuy", amount); 862 currencyResponse.Add("currencyBuy", amount);
863 863
864 quoteResponse.Add("success", true); 864 quoteResponse.Add("success", true);
865 quoteResponse.Add("currency", currencyResponse); 865 quoteResponse.Add("currency", currencyResponse);
866 quoteResponse.Add("confirm", "asdfad9fj39ma9fj"); 866 quoteResponse.Add("confirm", "asdfad9fj39ma9fj");
867 867
868 returnval.Value = quoteResponse; 868 returnval.Value = quoteResponse;
869 return returnval; 869 return returnval;
870 } 870 }
871 871
872 872
873 quoteResponse.Add("success", false); 873 quoteResponse.Add("success", false);
874 quoteResponse.Add("errorMessage", "Invalid parameters passed to the quote box"); 874 quoteResponse.Add("errorMessage", "Invalid parameters passed to the quote box");
875 quoteResponse.Add("errorURI", "http://www.opensimulator.org/wiki"); 875 quoteResponse.Add("errorURI", "http://www.opensimulator.org/wiki");
876 returnval.Value = quoteResponse; 876 returnval.Value = quoteResponse;
877 return returnval; 877 return returnval;
878 } 878 }
879 879
880 public XmlRpcResponse buy_func(XmlRpcRequest request) 880 public XmlRpcResponse buy_func(XmlRpcRequest request)
881 { 881 {
882 Hashtable requestData = (Hashtable) request.Params[0]; 882 Hashtable requestData = (Hashtable) request.Params[0];
883 LLUUID agentId = LLUUID.Zero; 883 LLUUID agentId = LLUUID.Zero;
884 int amount = 0; 884 int amount = 0;
885 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy")) 885 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy"))
886 { 886 {
887 Helpers.TryParse((string) requestData["agentId"], out agentId); 887 Helpers.TryParse((string) requestData["agentId"], out agentId);
888 try 888 try
889 { 889 {
890 amount = (Int32) requestData["currencyBuy"]; 890 amount = (Int32) requestData["currencyBuy"];
891 } 891 }
892 catch (InvalidCastException) 892 catch (InvalidCastException)
893 { 893 {
894 } 894 }
895 if (agentId != LLUUID.Zero) 895 if (agentId != LLUUID.Zero)
896 { 896 {
897 lock (m_KnownClientFunds) 897 lock (m_KnownClientFunds)
898 { 898 {
899 if (m_KnownClientFunds.ContainsKey(agentId)) 899 if (m_KnownClientFunds.ContainsKey(agentId))
900 { 900 {
901 m_KnownClientFunds[agentId] += amount; 901 m_KnownClientFunds[agentId] += amount;
902 } 902 }
903 else 903 else
904 { 904 {
905 m_KnownClientFunds.Add(agentId, amount); 905 m_KnownClientFunds.Add(agentId, amount);
906 } 906 }
907 } 907 }
908 IClientAPI client = LocateClientObject(agentId); 908 IClientAPI client = LocateClientObject(agentId);
909 if (client != null) 909 if (client != null)
910 { 910 {
911 SendMoneyBalance(client, agentId, client.SessionId, LLUUID.Zero); 911 SendMoneyBalance(client, agentId, client.SessionId, LLUUID.Zero);
912 } 912 }
913 } 913 }
914 } 914 }
915 XmlRpcResponse returnval = new XmlRpcResponse(); 915 XmlRpcResponse returnval = new XmlRpcResponse();
916 Hashtable returnresp = new Hashtable(); 916 Hashtable returnresp = new Hashtable();
917 returnresp.Add("success", true); 917 returnresp.Add("success", true);
918 returnval.Value = returnresp; 918 returnval.Value = returnresp;
919 return returnval; 919 return returnval;
920 } 920 }
921 921
922 public XmlRpcResponse preflightBuyLandPrep_func(XmlRpcRequest request) 922 public XmlRpcResponse preflightBuyLandPrep_func(XmlRpcRequest request)
923 { 923 {
924 XmlRpcResponse ret = new XmlRpcResponse(); 924 XmlRpcResponse ret = new XmlRpcResponse();
925 Hashtable retparam = new Hashtable(); 925 Hashtable retparam = new Hashtable();
926 Hashtable membershiplevels = new Hashtable(); 926 Hashtable membershiplevels = new Hashtable();
927 ArrayList levels = new ArrayList(); 927 ArrayList levels = new ArrayList();
928 Hashtable level = new Hashtable(); 928 Hashtable level = new Hashtable();
929 level.Add("id", "00000000-0000-0000-0000-000000000000"); 929 level.Add("id", "00000000-0000-0000-0000-000000000000");
930 level.Add("description", "some level"); 930 level.Add("description", "some level");
931 levels.Add(level); 931 levels.Add(level);
932 //membershiplevels.Add("levels",levels); 932 //membershiplevels.Add("levels",levels);
933 933
934 Hashtable landuse = new Hashtable(); 934 Hashtable landuse = new Hashtable();
935 landuse.Add("upgrade", false); 935 landuse.Add("upgrade", false);
936 landuse.Add("action", "http://invaliddomaininvalid.com/"); 936 landuse.Add("action", "http://invaliddomaininvalid.com/");
937 937
938 Hashtable currency = new Hashtable(); 938 Hashtable currency = new Hashtable();
939 currency.Add("estimatedCost", 0); 939 currency.Add("estimatedCost", 0);
940 940
941 Hashtable membership = new Hashtable(); 941 Hashtable membership = new Hashtable();
942 membershiplevels.Add("upgrade", false); 942 membershiplevels.Add("upgrade", false);
943 membershiplevels.Add("action", "http://invaliddomaininvalid.com/"); 943 membershiplevels.Add("action", "http://invaliddomaininvalid.com/");
944 membershiplevels.Add("levels", membershiplevels); 944 membershiplevels.Add("levels", membershiplevels);
945 945
946 retparam.Add("success", true); 946 retparam.Add("success", true);
947 retparam.Add("currency", currency); 947 retparam.Add("currency", currency);
948 retparam.Add("membership", membership); 948 retparam.Add("membership", membership);
949 retparam.Add("landuse", landuse); 949 retparam.Add("landuse", landuse);
950 retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); 950 retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
951 951
952 ret.Value = retparam; 952 ret.Value = retparam;
953 953
954 return ret; 954 return ret;
955 } 955 }
956 956
957 public XmlRpcResponse landBuy_func(XmlRpcRequest request) 957 public XmlRpcResponse landBuy_func(XmlRpcRequest request)
958 { 958 {
959 XmlRpcResponse ret = new XmlRpcResponse(); 959 XmlRpcResponse ret = new XmlRpcResponse();
960 Hashtable retparam = new Hashtable(); 960 Hashtable retparam = new Hashtable();
961 Hashtable requestData = (Hashtable) request.Params[0]; 961 Hashtable requestData = (Hashtable) request.Params[0];
962 962
963 LLUUID agentId = LLUUID.Zero; 963 LLUUID agentId = LLUUID.Zero;
964 int amount = 0; 964 int amount = 0;
965 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy")) 965 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy"))
966 { 966 {
967 Helpers.TryParse((string) requestData["agentId"], out agentId); 967 Helpers.TryParse((string) requestData["agentId"], out agentId);
968 try 968 try
969 { 969 {
970 amount = (Int32) requestData["currencyBuy"]; 970 amount = (Int32) requestData["currencyBuy"];
971 } 971 }
972 catch (InvalidCastException) 972 catch (InvalidCastException)
973 { 973 {
974 } 974 }
975 if (agentId != LLUUID.Zero) 975 if (agentId != LLUUID.Zero)
976 { 976 {
977 lock (m_KnownClientFunds) 977 lock (m_KnownClientFunds)
978 { 978 {
979 if (m_KnownClientFunds.ContainsKey(agentId)) 979 if (m_KnownClientFunds.ContainsKey(agentId))
980 { 980 {
981 m_KnownClientFunds[agentId] += amount; 981 m_KnownClientFunds[agentId] += amount;
982 } 982 }
983 else 983 else
984 { 984 {
985 m_KnownClientFunds.Add(agentId, amount); 985 m_KnownClientFunds.Add(agentId, amount);
986 } 986 }
987 } 987 }
988 IClientAPI client = LocateClientObject(agentId); 988 IClientAPI client = LocateClientObject(agentId);
989 if (client != null) 989 if (client != null)
990 { 990 {
991 SendMoneyBalance(client, agentId, client.SessionId, LLUUID.Zero); 991 SendMoneyBalance(client, agentId, client.SessionId, LLUUID.Zero);
992 } 992 }
993 } 993 }
994 } 994 }
995 retparam.Add("success", true); 995 retparam.Add("success", true);
996 ret.Value = retparam; 996 ret.Value = retparam;
997 997
998 return ret; 998 return ret;
999 } 999 }
1000 1000
1001 #endregion 1001 #endregion
1002 1002
1003 #region local Fund Management 1003 #region local Fund Management
1004 1004
1005 /// <summary> 1005 /// <summary>
1006 /// Ensures that the agent accounting data is set up in this instance. 1006 /// Ensures that the agent accounting data is set up in this instance.
1007 /// </summary> 1007 /// </summary>
1008 /// <param name="agentID"></param> 1008 /// <param name="agentID"></param>
1009 private void CheckExistAndRefreshFunds(LLUUID agentID) 1009 private void CheckExistAndRefreshFunds(LLUUID agentID)
1010 { 1010 {
1011 lock (m_KnownClientFunds) 1011 lock (m_KnownClientFunds)
1012 { 1012 {
1013 if (!m_KnownClientFunds.ContainsKey(agentID)) 1013 if (!m_KnownClientFunds.ContainsKey(agentID))
1014 { 1014 {
1015 m_KnownClientFunds.Add(agentID, m_stipend); 1015 m_KnownClientFunds.Add(agentID, m_stipend);
1016 } 1016 }
1017 else 1017 else
1018 { 1018 {
1019 if (m_KnownClientFunds[agentID] <= m_minFundsBeforeRefresh) 1019 if (m_KnownClientFunds[agentID] <= m_minFundsBeforeRefresh)
1020 { 1020 {
1021 m_KnownClientFunds[agentID] = m_stipend; 1021 m_KnownClientFunds[agentID] = m_stipend;
1022 } 1022 }
1023 } 1023 }
1024 } 1024 }
1025 } 1025 }
1026 1026
1027 /// <summary> 1027 /// <summary>
1028 /// Gets the amount of Funds for an agent 1028 /// Gets the amount of Funds for an agent
1029 /// </summary> 1029 /// </summary>
1030 /// <param name="AgentID"></param> 1030 /// <param name="AgentID"></param>
1031 /// <returns></returns> 1031 /// <returns></returns>
1032 private int GetFundsForAgentID(LLUUID AgentID) 1032 private int GetFundsForAgentID(LLUUID AgentID)
1033 { 1033 {
1034 int returnfunds = 0; 1034 int returnfunds = 0;
1035 lock (m_KnownClientFunds) 1035 lock (m_KnownClientFunds)
1036 { 1036 {
1037 if (m_KnownClientFunds.ContainsKey(AgentID)) 1037 if (m_KnownClientFunds.ContainsKey(AgentID))
1038 { 1038 {
1039 returnfunds = m_KnownClientFunds[AgentID]; 1039 returnfunds = m_KnownClientFunds[AgentID];
1040 } 1040 }
1041 else 1041 else
1042 { 1042 {
1043 //throw new Exception("Unable to get funds."); 1043 //throw new Exception("Unable to get funds.");
1044 } 1044 }
1045 } 1045 }
1046 return returnfunds; 1046 return returnfunds;
1047 } 1047 }
1048 1048
1049 private void SetLocalFundsForAgentID(LLUUID AgentID, int amount) 1049 private void SetLocalFundsForAgentID(LLUUID AgentID, int amount)
1050 { 1050 {
1051 lock (m_KnownClientFunds) 1051 lock (m_KnownClientFunds)
1052 { 1052 {
1053 if (m_KnownClientFunds.ContainsKey(AgentID)) 1053 if (m_KnownClientFunds.ContainsKey(AgentID))
1054 { 1054 {
1055 m_KnownClientFunds[AgentID] = amount; 1055 m_KnownClientFunds[AgentID] = amount;
1056 } 1056 }
1057 else 1057 else
1058 { 1058 {
1059 m_KnownClientFunds.Add(AgentID, amount); 1059 m_KnownClientFunds.Add(AgentID, amount);
1060 } 1060 }
1061 } 1061 }
1062 } 1062 }
1063 1063
1064 #endregion 1064 #endregion
1065 1065
1066 #region Utility Helpers 1066 #region Utility Helpers
1067 1067
1068 /// <summary> 1068 /// <summary>
1069 /// Locates a IClientAPI for the client specified 1069 /// Locates a IClientAPI for the client specified
1070 /// </summary> 1070 /// </summary>
1071 /// <param name="AgentID"></param> 1071 /// <param name="AgentID"></param>
1072 /// <returns></returns> 1072 /// <returns></returns>
1073 private IClientAPI LocateClientObject(LLUUID AgentID) 1073 private IClientAPI LocateClientObject(LLUUID AgentID)
1074 { 1074 {
1075 ScenePresence tPresence = null; 1075 ScenePresence tPresence = null;
1076 IClientAPI rclient = null; 1076 IClientAPI rclient = null;
1077 1077
1078 lock (m_scenel) 1078 lock (m_scenel)
1079 { 1079 {
1080 foreach (Scene _scene in m_scenel.Values) 1080 foreach (Scene _scene in m_scenel.Values)
1081 { 1081 {
1082 tPresence = _scene.GetScenePresence(AgentID); 1082 tPresence = _scene.GetScenePresence(AgentID);
1083 if (tPresence != null) 1083 if (tPresence != null)
1084 { 1084 {
1085 if (!tPresence.IsChildAgent) 1085 if (!tPresence.IsChildAgent)
1086 { 1086 {
1087 rclient = tPresence.ControllingClient; 1087 rclient = tPresence.ControllingClient;
1088 } 1088 }
1089 } 1089 }
1090 if (rclient != null) 1090 if (rclient != null)
1091 { 1091 {
1092 return rclient; 1092 return rclient;
1093 } 1093 }
1094 } 1094 }
1095 } 1095 }
1096 return null; 1096 return null;
1097 } 1097 }
1098 1098
1099 private Scene LocateSceneClientIn(LLUUID AgentId) 1099 private Scene LocateSceneClientIn(LLUUID AgentId)
1100 { 1100 {
1101 lock (m_scenel) 1101 lock (m_scenel)
1102 { 1102 {
1103 foreach (Scene _scene in m_scenel.Values) 1103 foreach (Scene _scene in m_scenel.Values)
1104 { 1104 {
1105 ScenePresence tPresence = _scene.GetScenePresence(AgentId); 1105 ScenePresence tPresence = _scene.GetScenePresence(AgentId);
1106 if (tPresence != null) 1106 if (tPresence != null)
1107 { 1107 {
1108 if (!tPresence.IsChildAgent) 1108 if (!tPresence.IsChildAgent)
1109 { 1109 {
1110 return _scene; 1110 return _scene;
1111 } 1111 }
1112 } 1112 }
1113 } 1113 }
1114 } 1114 }
1115 return null; 1115 return null;
1116 } 1116 }
1117 1117
1118 /// <summary> 1118 /// <summary>
1119 /// Utility function Gets a Random scene in the instance. For when which scene exactly you're doing something with doesn't matter 1119 /// Utility function Gets a Random scene in the instance. For when which scene exactly you're doing something with doesn't matter
1120 /// </summary> 1120 /// </summary>
1121 /// <returns></returns> 1121 /// <returns></returns>
1122 public Scene GetRandomScene() 1122 public Scene GetRandomScene()
1123 { 1123 {
1124 lock (m_scenel) 1124 lock (m_scenel)
1125 { 1125 {
1126 foreach (Scene rs in m_scenel.Values) 1126 foreach (Scene rs in m_scenel.Values)
1127 return rs; 1127 return rs;
1128 } 1128 }
1129 return null; 1129 return null;
1130 } 1130 }
1131 1131
1132 /// <summary> 1132 /// <summary>
1133 /// Utility function to get a Scene by RegionID in a module 1133 /// Utility function to get a Scene by RegionID in a module
1134 /// </summary> 1134 /// </summary>
1135 /// <param name="RegionID"></param> 1135 /// <param name="RegionID"></param>
1136 /// <returns></returns> 1136 /// <returns></returns>
1137 public Scene GetSceneByUUID(LLUUID RegionID) 1137 public Scene GetSceneByUUID(LLUUID RegionID)
1138 { 1138 {
1139 lock (m_scenel) 1139 lock (m_scenel)
1140 { 1140 {
1141 foreach (Scene rs in m_scenel.Values) 1141 foreach (Scene rs in m_scenel.Values)
1142 { 1142 {
1143 if (rs.RegionInfo.originRegionID == RegionID) 1143 if (rs.RegionInfo.originRegionID == RegionID)
1144 { 1144 {
1145 return rs; 1145 return rs;
1146 } 1146 }
1147 } 1147 }
1148 } 1148 }
1149 return null; 1149 return null;
1150 } 1150 }
1151 1151
1152 #endregion 1152 #endregion
1153 1153
1154 #region event Handlers 1154 #region event Handlers
1155 1155
1156 public void requestPayPrice(IClientAPI client, LLUUID objectID) 1156 public void requestPayPrice(IClientAPI client, LLUUID objectID)
1157 { 1157 {
1158 Scene scene = LocateSceneClientIn(client.AgentId); 1158 Scene scene = LocateSceneClientIn(client.AgentId);
1159 if (scene == null) 1159 if (scene == null)
1160 return; 1160 return;
1161 1161
1162 SceneObjectPart task = scene.GetSceneObjectPart(objectID); 1162 SceneObjectPart task = scene.GetSceneObjectPart(objectID);
1163 if (task == null) 1163 if (task == null)
1164 return; 1164 return;
1165 SceneObjectGroup group = task.ParentGroup; 1165 SceneObjectGroup group = task.ParentGroup;
1166 SceneObjectPart root = group.RootPart; 1166 SceneObjectPart root = group.RootPart;
1167 1167
1168 client.SendPayPrice(objectID, root.PayPrice); 1168 client.SendPayPrice(objectID, root.PayPrice);
1169 } 1169 }
1170 1170
1171 /// <summary> 1171 /// <summary>
1172 /// When the client closes the connection we remove their accounting info from memory to free up resources. 1172 /// When the client closes the connection we remove their accounting info from memory to free up resources.
1173 /// </summary> 1173 /// </summary>
1174 /// <param name="AgentID"></param> 1174 /// <param name="AgentID"></param>
1175 public void ClientClosed(LLUUID AgentID) 1175 public void ClientClosed(LLUUID AgentID)
1176 { 1176 {
1177 lock (m_KnownClientFunds) 1177 lock (m_KnownClientFunds)
1178 { 1178 {
1179 if (m_keepMoneyAcrossLogins && m_MoneyAddress.Length == 0) 1179 if (m_keepMoneyAcrossLogins && m_MoneyAddress.Length == 0)
1180 { 1180 {
1181 } 1181 }
1182 else 1182 else
1183 { 1183 {
1184 m_KnownClientFunds.Remove(AgentID); 1184 m_KnownClientFunds.Remove(AgentID);
1185 } 1185 }
1186 } 1186 }
1187 } 1187 }
1188 1188
1189 /// <summary> 1189 /// <summary>
1190 /// Event called Economy Data Request handler. 1190 /// Event called Economy Data Request handler.
1191 /// </summary> 1191 /// </summary>
1192 /// <param name="agentId"></param> 1192 /// <param name="agentId"></param>
1193 public void EconomyDataRequestHandler(LLUUID agentId) 1193 public void EconomyDataRequestHandler(LLUUID agentId)
1194 { 1194 {
1195 IClientAPI user = LocateClientObject(agentId); 1195 IClientAPI user = LocateClientObject(agentId);
1196 1196
1197 if (user != null) 1197 if (user != null)
1198 { 1198 {
1199 user.SendEconomyData(EnergyEfficiency, ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, 1199 user.SendEconomyData(EnergyEfficiency, ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate,
1200 PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, 1200 PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor,
1201 PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload, 1201 PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload,
1202 TeleportMinPrice, TeleportPriceExponent); 1202 TeleportMinPrice, TeleportPriceExponent);
1203 } 1203 }
1204 } 1204 }
1205 1205
1206 private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e) 1206 private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e)
1207 { 1207 {
1208 if (m_MoneyAddress.Length == 0) 1208 if (m_MoneyAddress.Length == 0)
1209 { 1209 {
1210 lock (m_KnownClientFunds) 1210 lock (m_KnownClientFunds)
1211 { 1211 {
1212 if (m_KnownClientFunds.ContainsKey(e.agentId)) 1212 if (m_KnownClientFunds.ContainsKey(e.agentId))
1213 { 1213 {
1214 // Does the sender have enough funds to give? 1214 // Does the sender have enough funds to give?
1215 if (m_KnownClientFunds[e.agentId] >= e.parcelPrice) 1215 if (m_KnownClientFunds[e.agentId] >= e.parcelPrice)
1216 { 1216 {
1217 lock (e) 1217 lock (e)
1218 { 1218 {
1219 e.economyValidated = true; 1219 e.economyValidated = true;
1220 } 1220 }
1221 } 1221 }
1222 } 1222 }
1223 } 1223 }
1224 } 1224 }
1225 else 1225 else
1226 { 1226 {
1227 if (GetRemoteBalance(e.agentId) >= e.parcelPrice) 1227 if (GetRemoteBalance(e.agentId) >= e.parcelPrice)
1228 { 1228 {
1229 lock (e) 1229 lock (e)
1230 { 1230 {
1231 e.economyValidated = true; 1231 e.economyValidated = true;
1232 } 1232 }
1233 } 1233 }
1234 } 1234 }
1235 } 1235 }
1236 1236
1237 private void processLandBuy(Object osender, EventManager.LandBuyArgs e) 1237 private void processLandBuy(Object osender, EventManager.LandBuyArgs e)
1238 { 1238 {
1239 lock (e) 1239 lock (e)
1240 { 1240 {
1241 if (e.economyValidated == true && e.transactionID == 0) 1241 if (e.economyValidated == true && e.transactionID == 0)
1242 { 1242 {
1243 e.transactionID = Util.UnixTimeSinceEpoch(); 1243 e.transactionID = Util.UnixTimeSinceEpoch();
1244 1244
1245 if (doMoneyTransfer(e.agentId, e.parcelOwnerID, e.parcelPrice, 0, "Land purchase")) 1245 if (doMoneyTransfer(e.agentId, e.parcelOwnerID, e.parcelPrice, 0, "Land purchase"))
1246 { 1246 {
1247 lock (e) 1247 lock (e)
1248 { 1248 {
1249 e.amountDebited = e.parcelPrice; 1249 e.amountDebited = e.parcelPrice;
1250 } 1250 }
1251 } 1251 }
1252 } 1252 }
1253 } 1253 }
1254 } 1254 }
1255 1255
1256 /// <summary> 1256 /// <summary>
1257 /// THis method gets called when someone pays someone else as a gift. 1257 /// THis method gets called when someone pays someone else as a gift.
1258 /// </summary> 1258 /// </summary>
1259 /// <param name="osender"></param> 1259 /// <param name="osender"></param>
1260 /// <param name="e"></param> 1260 /// <param name="e"></param>
1261 private void MoneyTransferAction(Object osender, EventManager.MoneyTransferArgs e) 1261 private void MoneyTransferAction(Object osender, EventManager.MoneyTransferArgs e)
1262 { 1262 {
1263 IClientAPI sender = null; 1263 IClientAPI sender = null;
1264 IClientAPI receiver = null; 1264 IClientAPI receiver = null;
1265 1265
1266 if (m_MoneyAddress.Length > 0) // Handled on server 1266 if (m_MoneyAddress.Length > 0) // Handled on server
1267 e.description = String.Empty; 1267 e.description = String.Empty;
1268 1268
1269 if (e.transactiontype == 5008) // Object gets paid 1269 if (e.transactiontype == 5008) // Object gets paid
1270 { 1270 {
1271 sender = LocateClientObject(e.sender); 1271 sender = LocateClientObject(e.sender);
1272 if (sender != null) 1272 if (sender != null)
1273 { 1273 {
1274 SceneObjectPart part = findPrim(e.receiver); 1274 SceneObjectPart part = findPrim(e.receiver);
1275 if (part == null) 1275 if (part == null)
1276 return; 1276 return;
1277 1277
1278 string name = resolveAgentName(part.OwnerID); 1278 string name = resolveAgentName(part.OwnerID);
1279 if (name == String.Empty) 1279 if (name == String.Empty)
1280 name = "(hippos)"; 1280 name = "(hippos)";
1281 1281
1282 receiver = LocateClientObject(part.OwnerID); 1282 receiver = LocateClientObject(part.OwnerID);
1283 1283
1284 string description = String.Format("Paid {0} via object {1}", name, e.description); 1284 string description = String.Format("Paid {0} via object {1}", name, e.description);
1285 bool transactionresult = doMoneyTransfer(e.sender, part.OwnerID, e.amount, e.transactiontype, description); 1285 bool transactionresult = doMoneyTransfer(e.sender, part.OwnerID, e.amount, e.transactiontype, description);
1286 1286
1287 if (transactionresult) 1287 if (transactionresult)
1288 { 1288 {
1289 ObjectPaid handlerOnObjectPaid = OnObjectPaid; 1289 ObjectPaid handlerOnObjectPaid = OnObjectPaid;
1290 if (handlerOnObjectPaid != null) 1290 if (handlerOnObjectPaid != null)
1291 { 1291 {
1292 handlerOnObjectPaid(e.receiver, e.sender, e.amount); 1292 handlerOnObjectPaid(e.receiver, e.sender, e.amount);
1293 } 1293 }
1294 } 1294 }
1295 1295
1296 if (e.sender != e.receiver) 1296 if (e.sender != e.receiver)
1297 { 1297 {
1298 sender.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.sender)); 1298 sender.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.sender));
1299 } 1299 }
1300 if (receiver != null) 1300 if (receiver != null)
1301 { 1301 {
1302 receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(part.OwnerID)); 1302 receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(part.OwnerID));
1303 } 1303 }
1304 } 1304 }
1305 return; 1305 return;
1306 } 1306 }
1307 1307
1308 sender = LocateClientObject(e.sender); 1308 sender = LocateClientObject(e.sender);
1309 if (sender != null) 1309 if (sender != null)
1310 { 1310 {
1311 receiver = LocateClientObject(e.receiver); 1311 receiver = LocateClientObject(e.receiver);
1312 1312
1313 bool transactionresult = doMoneyTransfer(e.sender, e.receiver, e.amount, e.transactiontype, e.description); 1313 bool transactionresult = doMoneyTransfer(e.sender, e.receiver, e.amount, e.transactiontype, e.description);
1314 1314
1315 if (e.sender != e.receiver) 1315 if (e.sender != e.receiver)
1316 { 1316 {
1317 if (sender != null) 1317 if (sender != null)
1318 { 1318 {
1319 sender.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.sender)); 1319 sender.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.sender));
1320 } 1320 }
1321 } 1321 }
1322 1322
1323 if (receiver != null) 1323 if (receiver != null)
1324 { 1324 {
1325 receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.receiver)); 1325 receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.receiver));
1326 } 1326 }
1327 } 1327 }
1328 else 1328 else
1329 { 1329 {
1330 m_log.Warn("[MONEY]: Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" + 1330 m_log.Warn("[MONEY]: Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" +
1331 e.sender.ToString() + " Receiver: " + e.receiver.ToString() + " Amount: " + e.amount.ToString()); 1331 e.sender.ToString() + " Receiver: " + e.receiver.ToString() + " Amount: " + e.amount.ToString());
1332 } 1332 }
1333 } 1333 }
1334 1334
1335 /// <summary> 1335 /// <summary>
1336 /// Event Handler for when a root agent becomes a child agent 1336 /// Event Handler for when a root agent becomes a child agent
1337 /// </summary> 1337 /// </summary>
1338 /// <param name="avatar"></param> 1338 /// <param name="avatar"></param>
1339 private void MakeChildAgent(ScenePresence avatar) 1339 private void MakeChildAgent(ScenePresence avatar)
1340 { 1340 {
1341 lock (m_rootAgents) 1341 lock (m_rootAgents)
1342 { 1342 {
1343 if (m_rootAgents.ContainsKey(avatar.UUID)) 1343 if (m_rootAgents.ContainsKey(avatar.UUID))
1344 { 1344 {
1345 if (m_rootAgents[avatar.UUID] == avatar.Scene.RegionInfo.originRegionID) 1345 if (m_rootAgents[avatar.UUID] == avatar.Scene.RegionInfo.originRegionID)
1346 { 1346 {
1347 m_rootAgents.Remove(avatar.UUID); 1347 m_rootAgents.Remove(avatar.UUID);
1348 m_log.Info("[MONEY]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent"); 1348 m_log.Info("[MONEY]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent");
1349 } 1349 }
1350 } 1350 }
1351 } 1351 }
1352 } 1352 }
1353 1353
1354 /// <summary> 1354 /// <summary>
1355 /// Event Handler for when the client logs out. 1355 /// Event Handler for when the client logs out.
1356 /// </summary> 1356 /// </summary>
1357 /// <param name="AgentId"></param> 1357 /// <param name="AgentId"></param>
1358 private void ClientLoggedOut(LLUUID AgentId) 1358 private void ClientLoggedOut(LLUUID AgentId)
1359 { 1359 {
1360 lock (m_rootAgents) 1360 lock (m_rootAgents)
1361 { 1361 {
1362 if (m_rootAgents.ContainsKey(AgentId)) 1362 if (m_rootAgents.ContainsKey(AgentId))
1363 { 1363 {
1364 m_rootAgents.Remove(AgentId); 1364 m_rootAgents.Remove(AgentId);
1365 //m_log.Info("[MONEY]: Removing " + AgentId + ". Agent logged out."); 1365 //m_log.Info("[MONEY]: Removing " + AgentId + ". Agent logged out.");
1366 } 1366 }
1367 } 1367 }
1368 } 1368 }
1369 1369
1370 /// <summary> 1370 /// <summary>
1371 /// Call this when the client disconnects. 1371 /// Call this when the client disconnects.
1372 /// </summary> 1372 /// </summary>
1373 /// <param name="client"></param> 1373 /// <param name="client"></param>
1374 public void ClientClosed(IClientAPI client) 1374 public void ClientClosed(IClientAPI client)
1375 { 1375 {
1376 ClientClosed(client.AgentId); 1376 ClientClosed(client.AgentId);
1377 } 1377 }
1378 1378
1379 /// <summary> 1379 /// <summary>
1380 /// Event Handler for when an Avatar enters one of the parcels in the simulator. 1380 /// Event Handler for when an Avatar enters one of the parcels in the simulator.
1381 /// </summary> 1381 /// </summary>
1382 /// <param name="avatar"></param> 1382 /// <param name="avatar"></param>
1383 /// <param name="localLandID"></param> 1383 /// <param name="localLandID"></param>
1384 /// <param name="regionID"></param> 1384 /// <param name="regionID"></param>
1385 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID) 1385 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID)
1386 { 1386 {
1387 lock (m_rootAgents) 1387 lock (m_rootAgents)
1388 { 1388 {
1389 if (m_rootAgents.ContainsKey(avatar.UUID)) 1389 if (m_rootAgents.ContainsKey(avatar.UUID))
1390 { 1390 {
1391 if (avatar.Scene.RegionInfo.originRegionID != m_rootAgents[avatar.UUID]) 1391 if (avatar.Scene.RegionInfo.originRegionID != m_rootAgents[avatar.UUID])
1392 { 1392 {
1393 m_rootAgents[avatar.UUID] = avatar.Scene.RegionInfo.originRegionID; 1393 m_rootAgents[avatar.UUID] = avatar.Scene.RegionInfo.originRegionID;
1394 //m_log.Info("[MONEY]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + "."); 1394 //m_log.Info("[MONEY]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + ".");
1395 // Claim User! my user! Mine mine mine! 1395 // Claim User! my user! Mine mine mine!
1396 if (m_MoneyAddress.Length > 0) 1396 if (m_MoneyAddress.Length > 0)
1397 { 1397 {
1398 Scene RegionItem = GetSceneByUUID(regionID); 1398 Scene RegionItem = GetSceneByUUID(regionID);
1399 if (RegionItem != null) 1399 if (RegionItem != null)
1400 { 1400 {
1401 Hashtable hresult = 1401 Hashtable hresult =
1402 claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret); 1402 claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret);
1403 if ((bool) hresult["success"] == true) 1403 if ((bool) hresult["success"] == true)
1404 { 1404 {
1405 int funds = 0; 1405 int funds = 0;
1406 try 1406 try
1407 { 1407 {
1408 funds = (Int32) hresult["funds"]; 1408 funds = (Int32) hresult["funds"];
1409 } 1409 }
1410 catch (InvalidCastException) 1410 catch (InvalidCastException)
1411 { 1411 {
1412 } 1412 }
1413 SetLocalFundsForAgentID(avatar.UUID, funds); 1413 SetLocalFundsForAgentID(avatar.UUID, funds);
1414 } 1414 }
1415 else 1415 else
1416 { 1416 {
1417 avatar.ControllingClient.SendAgentAlertMessage((string) hresult["errorMessage"], true); 1417 avatar.ControllingClient.SendAgentAlertMessage((string) hresult["errorMessage"], true);
1418 } 1418 }
1419 } 1419 }
1420 } 1420 }
1421 } 1421 }
1422 } 1422 }
1423 else 1423 else
1424 { 1424 {
1425 lock (m_rootAgents) 1425 lock (m_rootAgents)
1426 { 1426 {
1427 m_rootAgents.Add(avatar.UUID, avatar.Scene.RegionInfo.originRegionID); 1427 m_rootAgents.Add(avatar.UUID, avatar.Scene.RegionInfo.originRegionID);
1428 } 1428 }
1429 if (m_MoneyAddress.Length > 0) 1429 if (m_MoneyAddress.Length > 0)
1430 { 1430 {
1431 Scene RegionItem = GetSceneByUUID(regionID); 1431 Scene RegionItem = GetSceneByUUID(regionID);
1432 if (RegionItem != null) 1432 if (RegionItem != null)
1433 { 1433 {
1434 Hashtable hresult = claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret); 1434 Hashtable hresult = claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret);
1435 if ((bool) hresult["success"] == true) 1435 if ((bool) hresult["success"] == true)
1436 { 1436 {
1437 int funds = 0; 1437 int funds = 0;
1438 try 1438 try
1439 { 1439 {
1440 funds = (Int32) hresult["funds"]; 1440 funds = (Int32) hresult["funds"];
1441 } 1441 }
1442 catch (InvalidCastException) 1442 catch (InvalidCastException)
1443 { 1443 {
1444 } 1444 }
1445 SetLocalFundsForAgentID(avatar.UUID, funds); 1445 SetLocalFundsForAgentID(avatar.UUID, funds);
1446 } 1446 }
1447 else 1447 else
1448 { 1448 {
1449 avatar.ControllingClient.SendAgentAlertMessage((string) hresult["errorMessage"], true); 1449 avatar.ControllingClient.SendAgentAlertMessage((string) hresult["errorMessage"], true);
1450 } 1450 }
1451 } 1451 }
1452 } 1452 }
1453 1453
1454 //m_log.Info("[MONEY]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + "."); 1454 //m_log.Info("[MONEY]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + ".");
1455 } 1455 }
1456 } 1456 }
1457 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); 1457 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
1458 } 1458 }
1459 1459
1460 #endregion 1460 #endregion
1461 } 1461 }
1462 1462
1463 public enum TransactionType : int 1463 public enum TransactionType : int
1464 { 1464 {
1465 SystemGenerated = 0, 1465 SystemGenerated = 0,
1466 RegionMoneyRequest = 1, 1466 RegionMoneyRequest = 1,
1467 Gift = 2, 1467 Gift = 2,
1468 Purchase = 3 1468 Purchase = 3
1469 } 1469 }
1470} \ No newline at end of file 1470} \ No newline at end of file