1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
|
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.IO;
using System.Reflection;
using libsecondlife;
using log4net;
namespace OpenSim.Framework
{
public class EstateSettings
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private ConfigurationMember configMember;
//Settings to this island
private float m_billableFactor;
private uint m_estateID;
private LLUUID m_estateManager0;
private LLUUID m_estateManager1;
private LLUUID m_estateManager2;
private LLUUID m_estateManager3;
private LLUUID m_estateManager4;
private LLUUID m_estateManager5;
private LLUUID m_estateManager6;
private LLUUID m_estateManager7;
private LLUUID m_estateManager8;
private LLUUID m_estateManager9;
private string m_estateName;
private uint m_parentEstateID;
private int m_pricePerMeter;
private int m_redirectGridX;
private int m_redirectGridY;
public EstateSettings()
{
// Temporary hack to prevent multiple loadings.
if (configMember == null)
{
configMember =
new ConfigurationMember(Path.Combine(Util.configDir(), "estate_settings.xml"), "ESTATE SETTINGS",
loadConfigurationOptions, handleIncomingConfiguration, true);
configMember.performConfigurationRetrieve();
}
}
public float billableFactor
{
get { return m_billableFactor; }
set
{
m_billableFactor = value;
configMember.forceSetConfigurationOption("billable_factor", m_billableFactor.ToString());
}
}
public uint estateID
{
get { return m_estateID; }
set
{
m_estateID = value;
configMember.forceSetConfigurationOption("estate_id", m_estateID.ToString());
}
}
public uint parentEstateID
{
get { return m_parentEstateID; }
set
{
m_parentEstateID = value;
configMember.forceSetConfigurationOption("parent_estate_id", m_parentEstateID.ToString());
}
}
public int redirectGridX
{
get { return m_redirectGridX; }
set
{
m_redirectGridX = value;
configMember.forceSetConfigurationOption("redirect_grid_x", m_redirectGridX.ToString());
}
}
public int redirectGridY
{
get { return m_redirectGridY; }
set
{
m_redirectGridY = value;
configMember.forceSetConfigurationOption("redirect_grid_y", m_redirectGridY.ToString());
}
}
public int pricePerMeter
{
get { return m_pricePerMeter; }
set
{
m_pricePerMeter = value;
configMember.forceSetConfigurationOption("price_per_meter", m_pricePerMeter.ToString());
}
}
// Estate name
public string estateName
{
get { return m_estateName; }
set
{
m_estateName = value;
configMember.forceSetConfigurationOption("estate_name", m_estateName.ToString());
}
}
public LLUUID[] estateManagers
{
get
{
// returns a condensed array of LLUUIDs
return GetEstateManagers();
}
set
{
// Sets a Condensed array of LLUUIDS
int i = 0;
for (i = 0; i < value.Length; i++)
{
switch (i)
{
case 0:
m_estateManager0 = value[i];
break;
case 1:
m_estateManager1 = value[i];
break;
case 2:
m_estateManager2 = value[i];
break;
case 3:
m_estateManager3 = value[i];
break;
case 4:
m_estateManager4 = value[i];
break;
case 5:
m_estateManager5 = value[i];
break;
case 6:
m_estateManager6 = value[i];
break;
case 7:
m_estateManager7 = value[i];
break;
case 8:
m_estateManager8 = value[i];
break;
case 9:
m_estateManager9 = value[i];
break;
}
}
// Clear the rest of them.. as they're no longer valid
for (int j = i; j < 10; j++)
{
switch (j)
{
case 0:
m_estateManager0 = LLUUID.Zero;
break;
case 1:
m_estateManager1 = LLUUID.Zero;
break;
case 2:
m_estateManager2 = LLUUID.Zero;
break;
case 3:
m_estateManager3 = LLUUID.Zero;
break;
case 4:
m_estateManager4 = LLUUID.Zero;
break;
case 5:
m_estateManager5 = LLUUID.Zero;
break;
case 6:
m_estateManager6 = LLUUID.Zero;
break;
case 7:
m_estateManager7 = LLUUID.Zero;
break;
case 8:
m_estateManager8 = LLUUID.Zero;
break;
case 9:
m_estateManager9 = LLUUID.Zero;
break;
}
}
for (i = 0; i < 10; i++)
{
// Writes out the Estate managers to the XML file.
configMember.forceSetConfigurationOption("estate_manager_" + i, (GetEstateManagerAtPos(i)).ToString());
}
}
}
#region EstateManager Get Methods to sort out skipped spots in the XML (suser error)
private LLUUID GetEstateManagerAtPos(int pos)
{
// This is a helper for writing them out to the xml file
switch (pos)
{
case 0:
return m_estateManager0;
case 1:
return m_estateManager1;
case 2:
return m_estateManager2;
case 3:
return m_estateManager3;
case 4:
return m_estateManager4;
case 5:
return m_estateManager5;
case 6:
return m_estateManager6;
case 7:
return m_estateManager7;
case 8:
return m_estateManager8;
case 9:
return m_estateManager9;
default:
return LLUUID.Zero;
}
}
private LLUUID[] GetEstateManagers()
{
int numEstateManagers = GetNumberOfEstateManagers();
LLUUID[] rEstateManagers = new LLUUID[numEstateManagers];
int pos = 0;
for (int i = 0; i < numEstateManagers; i++)
{
pos = GetNextEstateManager(pos);
rEstateManagers[i] = GetEstateManagerAtPos(pos);
pos++;
}
return rEstateManagers;
}
private int GetNextEstateManager(int startpos)
{
// This is a utility function that skips over estate managers set to LLUUID.Zero
int i = startpos;
for (i = startpos; i < 10; i++)
{
if (GetEstateManagerAtPos(i) != LLUUID.Zero) return i;
}
return i;
}
private int GetNumberOfEstateManagers()
{
// This function returns the number of estate managers set
// Regardless of whether there is a skipped spot
int numEstateManagers = 0;
if (m_estateManager0 != LLUUID.Zero) numEstateManagers++;
if (m_estateManager1 != LLUUID.Zero) numEstateManagers++;
if (m_estateManager2 != LLUUID.Zero) numEstateManagers++;
if (m_estateManager3 != LLUUID.Zero) numEstateManagers++;
if (m_estateManager4 != LLUUID.Zero) numEstateManagers++;
if (m_estateManager5 != LLUUID.Zero) numEstateManagers++;
if (m_estateManager6 != LLUUID.Zero) numEstateManagers++;
if (m_estateManager7 != LLUUID.Zero) numEstateManagers++;
if (m_estateManager8 != LLUUID.Zero) numEstateManagers++;
if (m_estateManager9 != LLUUID.Zero) numEstateManagers++;
return numEstateManagers;
}
public void AddEstateManager(LLUUID avatarID)
{
LLUUID[] testateManagers = GetEstateManagers();
LLUUID[] nestateManagers = new LLUUID[testateManagers.Length + 1];
int i = 0;
for (i = 0; i < testateManagers.Length; i++)
{
nestateManagers[i] = testateManagers[i];
}
nestateManagers[i] = avatarID;
//Saves it to the estate settings file
estateManagers = nestateManagers;
}
public void RemoveEstateManager(LLUUID avatarID)
{
int notfoundparam = 11; // starting high so the condense routine (max ten) doesn't run if we don't find it.
LLUUID[] testateManagers = GetEstateManagers(); // temporary estate managers list
int i = 0;
int foundpos = notfoundparam;
// search for estate manager.
for (i = 0; i < testateManagers.Length; i++)
{
if (testateManagers[i] == avatarID)
{
foundpos = i;
break;
}
}
if (foundpos < notfoundparam)
{
LLUUID[] restateManagers = new LLUUID[testateManagers.Length - 1];
// fill new estate managers array up to the found spot
for (int j = 0; j < foundpos; j++)
restateManagers[j] = testateManagers[j];
// skip over the estate manager we're removing and compress
for (int j = foundpos + 1; j < testateManagers.Length; j++)
restateManagers[j - 1] = testateManagers[j];
estateManagers = restateManagers;
}
else
{
m_log.Error("[ESTATESETTINGS]: Unable to locate estate manager : " + avatarID.ToString() + " for removal");
}
}
#endregion
public void loadConfigurationOptions()
{
configMember.addConfigurationOption("billable_factor", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, String.Empty,
"0.0", true);
configMember.addConfigurationOption("estate_id", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, String.Empty, "100",
true);
configMember.addConfigurationOption("parent_estate_id", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
String.Empty, "1", true);
configMember.addConfigurationOption("max_agents", ConfigurationOption.ConfigurationTypes.TYPE_BYTE, String.Empty, "40",
true);
configMember.addConfigurationOption("redirect_grid_x", ConfigurationOption.ConfigurationTypes.TYPE_INT32, String.Empty,
"0", true);
configMember.addConfigurationOption("redirect_grid_y", ConfigurationOption.ConfigurationTypes.TYPE_INT32, String.Empty,
"0", true);
configMember.addConfigurationOption("price_per_meter", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
String.Empty, "1", true);
configMember.addConfigurationOption("water_height", ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE, String.Empty,
"20.0", true);
configMember.addConfigurationOption("estate_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
String.Empty, "TestEstate", true);
configMember.addConfigurationOption("estate_manager_0", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_1", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_2", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_3", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_4", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_5", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_6", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_7", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_8", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_9", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
{
switch (configuration_key)
{
case "billable_factor":
m_billableFactor = (float) configuration_result;
break;
case "estate_id":
m_estateID = (uint) configuration_result;
break;
case "parent_estate_id":
m_parentEstateID = (uint) configuration_result;
break;
case "redirect_grid_x":
m_redirectGridX = (int) configuration_result;
break;
case "redirect_grid_y":
m_redirectGridY = (int) configuration_result;
break;
case "price_per_meter":
m_pricePerMeter = Convert.ToInt32(configuration_result);
break;
case "estate_name":
m_estateName = (string) configuration_result;
break;
case "estate_manager_0":
m_estateManager0 = (LLUUID) configuration_result;
break;
case "estate_manager_1":
m_estateManager1 = (LLUUID) configuration_result;
break;
case "estate_manager_2":
m_estateManager2 = (LLUUID) configuration_result;
break;
case "estate_manager_3":
m_estateManager3 = (LLUUID) configuration_result;
break;
case "estate_manager_4":
m_estateManager4 = (LLUUID) configuration_result;
break;
case "estate_manager_5":
m_estateManager5 = (LLUUID) configuration_result;
break;
case "estate_manager_6":
m_estateManager6 = (LLUUID) configuration_result;
break;
case "estate_manager_7":
m_estateManager7 = (LLUUID) configuration_result;
break;
case "estate_manager_8":
m_estateManager8 = (LLUUID) configuration_result;
break;
case "estate_manager_9":
m_estateManager9 = (LLUUID) configuration_result;
break;
}
return true;
}
}
}
|