diff options
Diffstat (limited to 'OpenSim/Framework/EstateSettings.cs')
-rw-r--r-- | OpenSim/Framework/EstateSettings.cs | 109 |
1 files changed, 96 insertions, 13 deletions
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 4df7860..8c8270a 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs | |||
@@ -305,11 +305,17 @@ namespace OpenSim.Framework | |||
305 | OnSave(this); | 305 | OnSave(this); |
306 | } | 306 | } |
307 | 307 | ||
308 | public int EstateUsersCount() | ||
309 | { | ||
310 | return l_EstateAccess.Count; | ||
311 | } | ||
312 | |||
308 | public void AddEstateUser(UUID avatarID) | 313 | public void AddEstateUser(UUID avatarID) |
309 | { | 314 | { |
310 | if (avatarID == UUID.Zero) | 315 | if (avatarID == UUID.Zero) |
311 | return; | 316 | return; |
312 | if (!l_EstateAccess.Contains(avatarID)) | 317 | if (!l_EstateAccess.Contains(avatarID) && |
318 | (l_EstateAccess.Count < (int)Constants.EstateAccessLimits.AllowedAccess)) | ||
313 | l_EstateAccess.Add(avatarID); | 319 | l_EstateAccess.Add(avatarID); |
314 | } | 320 | } |
315 | 321 | ||
@@ -319,11 +325,17 @@ namespace OpenSim.Framework | |||
319 | l_EstateAccess.Remove(avatarID); | 325 | l_EstateAccess.Remove(avatarID); |
320 | } | 326 | } |
321 | 327 | ||
328 | public int EstateGroupsCount() | ||
329 | { | ||
330 | return l_EstateGroups.Count; | ||
331 | } | ||
332 | |||
322 | public void AddEstateGroup(UUID avatarID) | 333 | public void AddEstateGroup(UUID avatarID) |
323 | { | 334 | { |
324 | if (avatarID == UUID.Zero) | 335 | if (avatarID == UUID.Zero) |
325 | return; | 336 | return; |
326 | if (!l_EstateGroups.Contains(avatarID)) | 337 | if (!l_EstateGroups.Contains(avatarID) && |
338 | (l_EstateGroups.Count < (int)Constants.EstateAccessLimits.AllowedGroups)) | ||
327 | l_EstateGroups.Add(avatarID); | 339 | l_EstateGroups.Add(avatarID); |
328 | } | 340 | } |
329 | 341 | ||
@@ -333,11 +345,17 @@ namespace OpenSim.Framework | |||
333 | l_EstateGroups.Remove(avatarID); | 345 | l_EstateGroups.Remove(avatarID); |
334 | } | 346 | } |
335 | 347 | ||
348 | public int EstateManagersCount() | ||
349 | { | ||
350 | return l_EstateManagers.Count; | ||
351 | } | ||
352 | |||
336 | public void AddEstateManager(UUID avatarID) | 353 | public void AddEstateManager(UUID avatarID) |
337 | { | 354 | { |
338 | if (avatarID == UUID.Zero) | 355 | if (avatarID == UUID.Zero) |
339 | return; | 356 | return; |
340 | if (!l_EstateManagers.Contains(avatarID)) | 357 | if (!l_EstateManagers.Contains(avatarID) && |
358 | (l_EstateManagers.Count < (int)Constants.EstateAccessLimits.EstateManagers)) | ||
341 | l_EstateManagers.Add(avatarID); | 359 | l_EstateManagers.Add(avatarID); |
342 | } | 360 | } |
343 | 361 | ||
@@ -365,17 +383,55 @@ namespace OpenSim.Framework | |||
365 | 383 | ||
366 | public bool IsBanned(UUID avatarID) | 384 | public bool IsBanned(UUID avatarID) |
367 | { | 385 | { |
368 | foreach (EstateBan ban in l_EstateBans) | 386 | if (!IsEstateManagerOrOwner(avatarID)) |
387 | { | ||
388 | foreach (EstateBan ban in l_EstateBans) | ||
389 | if (ban.BannedUserID == avatarID) | ||
390 | return true; | ||
391 | } | ||
392 | return false; | ||
393 | } | ||
394 | |||
395 | public bool IsBanned(UUID avatarID, int userFlags) | ||
396 | { | ||
397 | if (!IsEstateManagerOrOwner(avatarID)) | ||
398 | { | ||
399 | foreach (EstateBan ban in l_EstateBans) | ||
369 | if (ban.BannedUserID == avatarID) | 400 | if (ban.BannedUserID == avatarID) |
370 | return true; | 401 | return true; |
402 | |||
403 | if (!HasAccess(avatarID)) | ||
404 | { | ||
405 | if (DenyMinors) | ||
406 | { | ||
407 | if ((userFlags & 32) == 0) | ||
408 | { | ||
409 | return true; | ||
410 | } | ||
411 | } | ||
412 | if (DenyAnonymous) | ||
413 | { | ||
414 | if ((userFlags & 4) == 0) | ||
415 | { | ||
416 | return true; | ||
417 | } | ||
418 | } | ||
419 | } | ||
420 | } | ||
371 | return false; | 421 | return false; |
372 | } | 422 | } |
373 | 423 | ||
424 | public int EstateBansCount() | ||
425 | { | ||
426 | return l_EstateBans.Count; | ||
427 | } | ||
428 | |||
374 | public void AddBan(EstateBan ban) | 429 | public void AddBan(EstateBan ban) |
375 | { | 430 | { |
376 | if (ban == null) | 431 | if (ban == null) |
377 | return; | 432 | return; |
378 | if (!IsBanned(ban.BannedUserID)) | 433 | if (!IsBanned(ban.BannedUserID, 32) && |
434 | (l_EstateBans.Count < (int)Constants.EstateAccessLimits.EstateBans)) //Ignore age-based bans | ||
379 | l_EstateBans.Add(ban); | 435 | l_EstateBans.Add(ban); |
380 | } | 436 | } |
381 | 437 | ||
@@ -516,14 +572,41 @@ namespace OpenSim.Framework | |||
516 | 572 | ||
517 | // EstateBans are special | 573 | // EstateBans are special |
518 | if (map.ContainsKey("EstateBans")) | 574 | if (map.ContainsKey("EstateBans")) |
519 | { | 575 | { |
520 | var banData = ((Dictionary<string, object>)map["EstateBans"]).Values; | 576 | if(map["EstateBans"] is string) |
521 | EstateBan[] bans = new EstateBan[banData.Count]; | 577 | { |
522 | int b = 0; | 578 | // JSON encoded bans map |
523 | foreach (Dictionary<string, object> ban in banData) | 579 | Dictionary<string, EstateBan> bdata = new Dictionary<string, EstateBan>(); |
524 | bans[b++] = new EstateBan(ban); | 580 | try |
525 | PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance); | 581 | { |
526 | bansProperty.SetValue(this, bans, null); | 582 | // bypass libovm, we dont need even more useless high level maps |
583 | // this should only be called once.. but no problem, i hope | ||
584 | // (other uses may need more..) | ||
585 | LitJson.JsonMapper.RegisterImporter<string, UUID>((input) => new UUID(input)); | ||
586 | bdata = LitJson.JsonMapper.ToObject<Dictionary<string,EstateBan>>((string)map["EstateBans"]); | ||
587 | } | ||
588 | // catch(Exception e) | ||
589 | catch | ||
590 | { | ||
591 | return; | ||
592 | } | ||
593 | EstateBan[] jbans = new EstateBan[bdata.Count]; | ||
594 | bdata.Values.CopyTo(jbans,0); | ||
595 | |||
596 | PropertyInfo jbansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance); | ||
597 | jbansProperty.SetValue(this, jbans, null); | ||
598 | } | ||
599 | else | ||
600 | { | ||
601 | var banData = ((Dictionary<string, object>)map["EstateBans"]).Values; | ||
602 | EstateBan[] bans = new EstateBan[banData.Count]; | ||
603 | |||
604 | int b = 0; | ||
605 | foreach (Dictionary<string, object> ban in banData) | ||
606 | bans[b++] = new EstateBan(ban); | ||
607 | PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance); | ||
608 | bansProperty.SetValue(this, bans, null); | ||
609 | } | ||
527 | } | 610 | } |
528 | } | 611 | } |
529 | } | 612 | } |