aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs149
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandChannel.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs112
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs109
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs260
-rw-r--r--OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs382
-rw-r--r--OpenSim/Region/CoreModules/World/Sun/SunModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs6
9 files changed, 861 insertions, 188 deletions
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 57ab135..b6d64ac 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -200,12 +200,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
200 } 200 }
201 Scene.RegionInfo.RegionSettings.Save(); 201 Scene.RegionInfo.RegionSettings.Save();
202 TriggerRegionInfoChange(); 202 TriggerRegionInfoChange();
203 sendRegionHandshakeToAll();
203 sendRegionInfoPacketToAll(); 204 sendRegionInfoPacketToAll();
204 } 205 }
205 206
206 private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient) 207 private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient)
207 { 208 {
208 sendRegionHandshakeToAll(); 209 // sendRegionHandshakeToAll();
209 } 210 }
210 211
211 public void setRegionTerrainSettings(float WaterHeight, 212 public void setRegionTerrainSettings(float WaterHeight,
@@ -274,8 +275,25 @@ namespace OpenSim.Region.CoreModules.World.Estate
274 { 275 {
275 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 276 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
276 { 277 {
278 if ((estateAccessType & 1) != 0) // All estates
279 {
280 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
281 EstateSettings estateSettings;
282
283 foreach (int estateID in estateIDs)
284 {
285 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
286 {
287 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
288 estateSettings.AddEstateUser(user);
289 estateSettings.Save();
290 }
291 }
292 }
293
277 Scene.RegionInfo.EstateSettings.AddEstateUser(user); 294 Scene.RegionInfo.EstateSettings.AddEstateUser(user);
278 Scene.RegionInfo.EstateSettings.Save(); 295 Scene.RegionInfo.EstateSettings.Save();
296
279 TriggerEstateInfoChange(); 297 TriggerEstateInfoChange();
280 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID); 298 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
281 } 299 }
@@ -289,10 +307,26 @@ namespace OpenSim.Region.CoreModules.World.Estate
289 { 307 {
290 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 308 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
291 { 309 {
310 if ((estateAccessType & 1) != 0) // All estates
311 {
312 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
313 EstateSettings estateSettings;
314
315 foreach (int estateID in estateIDs)
316 {
317 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
318 {
319 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
320 estateSettings.RemoveEstateUser(user);
321 estateSettings.Save();
322 }
323 }
324 }
325
292 Scene.RegionInfo.EstateSettings.RemoveEstateUser(user); 326 Scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
293 Scene.RegionInfo.EstateSettings.Save(); 327 Scene.RegionInfo.EstateSettings.Save();
294 TriggerEstateInfoChange();
295 328
329 TriggerEstateInfoChange();
296 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID); 330 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
297 } 331 }
298 else 332 else
@@ -304,8 +338,25 @@ namespace OpenSim.Region.CoreModules.World.Estate
304 { 338 {
305 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 339 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
306 { 340 {
341 if ((estateAccessType & 1) != 0) // All estates
342 {
343 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
344 EstateSettings estateSettings;
345
346 foreach (int estateID in estateIDs)
347 {
348 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
349 {
350 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
351 estateSettings.AddEstateGroup(user);
352 estateSettings.Save();
353 }
354 }
355 }
356
307 Scene.RegionInfo.EstateSettings.AddEstateGroup(user); 357 Scene.RegionInfo.EstateSettings.AddEstateGroup(user);
308 Scene.RegionInfo.EstateSettings.Save(); 358 Scene.RegionInfo.EstateSettings.Save();
359
309 TriggerEstateInfoChange(); 360 TriggerEstateInfoChange();
310 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID); 361 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
311 } 362 }
@@ -318,10 +369,26 @@ namespace OpenSim.Region.CoreModules.World.Estate
318 { 369 {
319 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 370 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
320 { 371 {
372 if ((estateAccessType & 1) != 0) // All estates
373 {
374 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
375 EstateSettings estateSettings;
376
377 foreach (int estateID in estateIDs)
378 {
379 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
380 {
381 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
382 estateSettings.RemoveEstateGroup(user);
383 estateSettings.Save();
384 }
385 }
386 }
387
321 Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user); 388 Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
322 Scene.RegionInfo.EstateSettings.Save(); 389 Scene.RegionInfo.EstateSettings.Save();
323 TriggerEstateInfoChange();
324 390
391 TriggerEstateInfoChange();
325 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID); 392 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
326 } 393 }
327 else 394 else
@@ -349,6 +416,29 @@ namespace OpenSim.Region.CoreModules.World.Estate
349 if (!alreadyInList) 416 if (!alreadyInList)
350 { 417 {
351 418
419 if ((estateAccessType & 1) != 0) // All estates
420 {
421 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
422 EstateSettings estateSettings;
423
424 foreach (int estateID in estateIDs)
425 {
426 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
427 {
428 EstateBan bitem = new EstateBan();
429
430 bitem.BannedUserID = user;
431 bitem.EstateID = (uint)estateID;
432 bitem.BannedHostAddress = "0.0.0.0";
433 bitem.BannedHostIPMask = "0.0.0.0";
434
435 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
436 estateSettings.AddBan(bitem);
437 estateSettings.Save();
438 }
439 }
440 }
441
352 EstateBan item = new EstateBan(); 442 EstateBan item = new EstateBan();
353 443
354 item.BannedUserID = user; 444 item.BannedUserID = user;
@@ -358,6 +448,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
358 448
359 Scene.RegionInfo.EstateSettings.AddBan(item); 449 Scene.RegionInfo.EstateSettings.AddBan(item);
360 Scene.RegionInfo.EstateSettings.Save(); 450 Scene.RegionInfo.EstateSettings.Save();
451
361 TriggerEstateInfoChange(); 452 TriggerEstateInfoChange();
362 453
363 ScenePresence s = Scene.GetScenePresence(user); 454 ScenePresence s = Scene.GetScenePresence(user);
@@ -403,8 +494,25 @@ namespace OpenSim.Region.CoreModules.World.Estate
403 494
404 if (alreadyInList && listitem != null) 495 if (alreadyInList && listitem != null)
405 { 496 {
497 if ((estateAccessType & 1) != 0) // All estates
498 {
499 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
500 EstateSettings estateSettings;
501
502 foreach (int estateID in estateIDs)
503 {
504 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
505 {
506 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
507 estateSettings.RemoveBan(user);
508 estateSettings.Save();
509 }
510 }
511 }
512
406 Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID); 513 Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
407 Scene.RegionInfo.EstateSettings.Save(); 514 Scene.RegionInfo.EstateSettings.Save();
515
408 TriggerEstateInfoChange(); 516 TriggerEstateInfoChange();
409 } 517 }
410 else 518 else
@@ -424,8 +532,25 @@ namespace OpenSim.Region.CoreModules.World.Estate
424 { 532 {
425 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 533 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
426 { 534 {
535 if ((estateAccessType & 1) != 0) // All estates
536 {
537 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
538 EstateSettings estateSettings;
539
540 foreach (int estateID in estateIDs)
541 {
542 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
543 {
544 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
545 estateSettings.AddEstateManager(user);
546 estateSettings.Save();
547 }
548 }
549 }
550
427 Scene.RegionInfo.EstateSettings.AddEstateManager(user); 551 Scene.RegionInfo.EstateSettings.AddEstateManager(user);
428 Scene.RegionInfo.EstateSettings.Save(); 552 Scene.RegionInfo.EstateSettings.Save();
553
429 TriggerEstateInfoChange(); 554 TriggerEstateInfoChange();
430 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID); 555 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
431 } 556 }
@@ -438,10 +563,26 @@ namespace OpenSim.Region.CoreModules.World.Estate
438 { 563 {
439 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 564 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
440 { 565 {
566 if ((estateAccessType & 1) != 0) // All estates
567 {
568 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
569 EstateSettings estateSettings;
570
571 foreach (int estateID in estateIDs)
572 {
573 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
574 {
575 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
576 estateSettings.RemoveEstateManager(user);
577 estateSettings.Save();
578 }
579 }
580 }
581
441 Scene.RegionInfo.EstateSettings.RemoveEstateManager(user); 582 Scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
442 Scene.RegionInfo.EstateSettings.Save(); 583 Scene.RegionInfo.EstateSettings.Save();
443 TriggerEstateInfoChange();
444 584
585 TriggerEstateInfoChange();
445 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID); 586 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
446 } 587 }
447 else 588 else
diff --git a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
index 7d990c2..7fc358d 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
@@ -133,16 +133,6 @@ namespace OpenSim.Region.CoreModules.World.Land
133 return new List<ILandObject>(); 133 return new List<ILandObject>();
134 } 134 }
135 135
136 public bool IsLandPrimCountTainted()
137 {
138 if (m_landManagementModule != null)
139 {
140 return m_landManagementModule.IsLandPrimCountTainted();
141 }
142
143 return false;
144 }
145
146 public bool IsForcefulBansAllowed() 136 public bool IsForcefulBansAllowed()
147 { 137 {
148 if (m_landManagementModule != null) 138 if (m_landManagementModule != null)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 98ba8c3..bfab7b8 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -62,8 +62,7 @@ namespace OpenSim.Region.CoreModules.World.Land
62 62
63 public class LandManagementModule : INonSharedRegionModule 63 public class LandManagementModule : INonSharedRegionModule
64 { 64 {
65 private static readonly ILog m_log = 65 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
66 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
67 66
68 private static readonly string remoteParcelRequestPath = "0009/"; 67 private static readonly string remoteParcelRequestPath = "0009/";
69 68
@@ -72,6 +71,7 @@ namespace OpenSim.Region.CoreModules.World.Land
72 protected Commander m_commander = new Commander("land"); 71 protected Commander m_commander = new Commander("land");
73 72
74 protected IUserManagement m_userManager; 73 protected IUserManagement m_userManager;
74 protected IPrimCountModule m_primCountModule;
75 75
76 // Minimum for parcels to work is 64m even if we don't actually use them. 76 // Minimum for parcels to work is 64m even if we don't actually use them.
77 #pragma warning disable 0429 77 #pragma warning disable 0429
@@ -88,7 +88,6 @@ namespace OpenSim.Region.CoreModules.World.Land
88 /// </value> 88 /// </value>
89 private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); 89 private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
90 90
91 private bool m_landPrimCountTainted;
92 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 91 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
93 92
94 private bool m_allowedForcefulBans = true; 93 private bool m_allowedForcefulBans = true;
@@ -121,18 +120,18 @@ namespace OpenSim.Region.CoreModules.World.Land
121 120
122 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd; 121 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd;
123 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate; 122 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate;
123 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene;
124 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate;
125
124 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel; 126 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel;
125 m_scene.EventManager.OnClientMovement += EventManagerOnClientMovement; 127 m_scene.EventManager.OnClientMovement += EventManagerOnClientMovement;
126 m_scene.EventManager.OnValidateLandBuy += EventManagerOnValidateLandBuy; 128 m_scene.EventManager.OnValidateLandBuy += EventManagerOnValidateLandBuy;
127 m_scene.EventManager.OnLandBuy += EventManagerOnLandBuy; 129 m_scene.EventManager.OnLandBuy += EventManagerOnLandBuy;
128 m_scene.EventManager.OnNewClient += EventManagerOnNewClient; 130 m_scene.EventManager.OnNewClient += EventManagerOnNewClient;
129 m_scene.EventManager.OnSignificantClientMovement += EventManagerOnSignificantClientMovement; 131 m_scene.EventManager.OnSignificantClientMovement += EventManagerOnSignificantClientMovement;
130 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene;
131 m_scene.EventManager.OnNoticeNoLandDataFromStorage += EventManagerOnNoLandDataFromStorage; 132 m_scene.EventManager.OnNoticeNoLandDataFromStorage += EventManagerOnNoLandDataFromStorage;
132 m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage; 133 m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage;
133 m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan; 134 m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan;
134 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate;
135 m_scene.EventManager.OnParcelPrimCountTainted += EventManagerOnParcelPrimCountTainted;
136 m_scene.EventManager.OnRegisterCaps += EventManagerOnRegisterCaps; 135 m_scene.EventManager.OnRegisterCaps += EventManagerOnRegisterCaps;
137 m_scene.EventManager.OnPluginConsole += EventManagerOnPluginConsole; 136 m_scene.EventManager.OnPluginConsole += EventManagerOnPluginConsole;
138 137
@@ -147,6 +146,7 @@ namespace OpenSim.Region.CoreModules.World.Land
147 public void RegionLoaded(Scene scene) 146 public void RegionLoaded(Scene scene)
148 { 147 {
149 m_userManager = m_scene.RequestModuleInterface<IUserManagement>(); 148 m_userManager = m_scene.RequestModuleInterface<IUserManagement>();
149 m_primCountModule = m_scene.RequestModuleInterface<IPrimCountModule>();
150 } 150 }
151 151
152 public void RemoveRegion(Scene scene) 152 public void RemoveRegion(Scene scene)
@@ -306,10 +306,14 @@ namespace OpenSim.Region.CoreModules.World.Land
306 /// <returns>The parcel created.</returns> 306 /// <returns>The parcel created.</returns>
307 protected ILandObject CreateDefaultParcel() 307 protected ILandObject CreateDefaultParcel()
308 { 308 {
309 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); 309 m_log.DebugFormat(
310 "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName);
311
312 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
310 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); 313 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
311 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 314 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
312 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 315 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
316
313 return AddLandObject(fullSimParcel); 317 return AddLandObject(fullSimParcel);
314 } 318 }
315 319
@@ -579,7 +583,7 @@ namespace OpenSim.Region.CoreModules.World.Land
579 } 583 }
580 else 584 else
581 { 585 {
582 m_log.WarnFormat("[LAND]: Invalid local land ID {0}", landLocalID); 586 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid local land ID {0}", landLocalID);
583 } 587 }
584 } 588 }
585 589
@@ -590,6 +594,11 @@ namespace OpenSim.Region.CoreModules.World.Land
590 public ILandObject AddLandObject(ILandObject land) 594 public ILandObject AddLandObject(ILandObject land)
591 { 595 {
592 ILandObject new_land = land.Copy(); 596 ILandObject new_land = land.Copy();
597
598 // Only now can we add the prim counts to the land object - we rely on the global ID which is generated
599 // as a random UUID inside LandData initialization
600 if (m_primCountModule != null)
601 new_land.PrimCounts = m_primCountModule.GetPrimCounts(new_land.LandData.GlobalID);
593 602
594 lock (m_landList) 603 lock (m_landList)
595 { 604 {
@@ -603,6 +612,10 @@ namespace OpenSim.Region.CoreModules.World.Land
603 { 612 {
604 if (landBitmap[x, y]) 613 if (landBitmap[x, y])
605 { 614 {
615// m_log.DebugFormat(
616// "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}",
617// new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName);
618
606 m_landIDList[x, y] = newLandLocalID; 619 m_landIDList[x, y] = newLandLocalID;
607 } 620 }
608 } 621 }
@@ -630,7 +643,7 @@ namespace OpenSim.Region.CoreModules.World.Land
630 { 643 {
631 if (m_landIDList[x, y] == local_id) 644 if (m_landIDList[x, y] == local_id)
632 { 645 {
633 m_log.WarnFormat("[LAND]: Not removing land object {0}; still being used at {1}, {2}", 646 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Not removing land object {0}; still being used at {1}, {2}",
634 local_id, x, y); 647 local_id, x, y);
635 return; 648 return;
636 //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y); 649 //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y);
@@ -732,8 +745,16 @@ namespace OpenSim.Region.CoreModules.World.Land
732 // Corner case. If an autoreturn happens during sim startup 745 // Corner case. If an autoreturn happens during sim startup
733 // we will come here with the list uninitialized 746 // we will come here with the list uninitialized
734 // 747 //
748 int landId = m_landIDList[x, y];
749
750// if (landId == 0)
751// m_log.DebugFormat(
752// "[LAND MANAGEMENT MODULE]: No land object found at ({0}, {1}) on {2}",
753// x, y, m_scene.RegionInfo.RegionName);
754
735 if (m_landList.ContainsKey(m_landIDList[x, y])) 755 if (m_landList.ContainsKey(m_landIDList[x, y]))
736 return m_landList[m_landIDList[x, y]]; 756 return m_landList[m_landIDList[x, y]];
757
737 return null; 758 return null;
738 } 759 }
739 } 760 }
@@ -751,13 +772,14 @@ namespace OpenSim.Region.CoreModules.World.Land
751 { 772 {
752 try 773 try
753 { 774 {
754 //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) 775 return m_landList[m_landIDList[x / 4, y / 4]];
755 return m_landList[m_landIDList[x / 4, y / 4]];
756 //else
757 // return null;
758 } 776 }
759 catch (IndexOutOfRangeException) 777 catch (IndexOutOfRangeException)
760 { 778 {
779// m_log.WarnFormat(
780// "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}",
781// x, y, m_scene.RegionInfo.RegionName);
782
761 return null; 783 return null;
762 } 784 }
763 } 785 }
@@ -767,34 +789,24 @@ namespace OpenSim.Region.CoreModules.World.Land
767 789
768 #region Parcel Modification 790 #region Parcel Modification
769 791
770 public void ResetAllLandPrimCounts() 792 public void ResetOverMeRecords()
771 { 793 {
772 lock (m_landList) 794 lock (m_landList)
773 { 795 {
774 foreach (LandObject p in m_landList.Values) 796 foreach (LandObject p in m_landList.Values)
775 { 797 {
776 p.ResetLandPrimCounts(); 798 p.ResetOverMeRecord();
777 } 799 }
778 } 800 }
779 } 801 }
780 802
781 public void EventManagerOnParcelPrimCountTainted()
782 {
783 m_landPrimCountTainted = true;
784 }
785
786 public bool IsLandPrimCountTainted()
787 {
788 return m_landPrimCountTainted;
789 }
790
791 public void EventManagerOnParcelPrimCountAdd(SceneObjectGroup obj) 803 public void EventManagerOnParcelPrimCountAdd(SceneObjectGroup obj)
792 { 804 {
793 Vector3 position = obj.AbsolutePosition; 805 Vector3 position = obj.AbsolutePosition;
794 ILandObject landUnderPrim = GetLandObject(position.X, position.Y); 806 ILandObject landUnderPrim = GetLandObject(position.X, position.Y);
795 if (landUnderPrim != null) 807 if (landUnderPrim != null)
796 { 808 {
797 landUnderPrim.AddPrimToCount(obj); 809 ((LandObject)landUnderPrim).AddPrimOverMe(obj);
798 } 810 }
799 } 811 }
800 812
@@ -804,7 +816,7 @@ namespace OpenSim.Region.CoreModules.World.Land
804 { 816 {
805 foreach (LandObject p in m_landList.Values) 817 foreach (LandObject p in m_landList.Values)
806 { 818 {
807 p.RemovePrimFromCount(obj); 819 p.RemovePrimFromOverMe(obj);
808 } 820 }
809 } 821 }
810 } 822 }
@@ -837,8 +849,7 @@ namespace OpenSim.Region.CoreModules.World.Land
837 foreach (LandObject p in landOwnersAndParcels[owner]) 849 foreach (LandObject p in landOwnersAndParcels[owner])
838 { 850 {
839 simArea += p.LandData.Area; 851 simArea += p.LandData.Area;
840 simPrims += p.LandData.OwnerPrims + p.LandData.OtherPrims + p.LandData.GroupPrims + 852 simPrims += p.PrimCounts.Total;
841 p.LandData.SelectedPrims;
842 } 853 }
843 854
844 foreach (LandObject p in landOwnersAndParcels[owner]) 855 foreach (LandObject p in landOwnersAndParcels[owner])
@@ -851,7 +862,11 @@ namespace OpenSim.Region.CoreModules.World.Land
851 862
852 public void EventManagerOnParcelPrimCountUpdate() 863 public void EventManagerOnParcelPrimCountUpdate()
853 { 864 {
854 ResetAllLandPrimCounts(); 865// m_log.DebugFormat(
866// "[LAND MANAGEMENT MODULE]: Triggered EventManagerOnParcelPrimCountUpdate() for {0}",
867// m_scene.RegionInfo.RegionName);
868
869 ResetOverMeRecords();
855 EntityBase[] entities = m_scene.Entities.GetEntities(); 870 EntityBase[] entities = m_scene.Entities.GetEntities();
856 foreach (EntityBase obj in entities) 871 foreach (EntityBase obj in entities)
857 { 872 {
@@ -864,15 +879,13 @@ namespace OpenSim.Region.CoreModules.World.Land
864 } 879 }
865 } 880 }
866 FinalizeLandPrimCountUpdate(); 881 FinalizeLandPrimCountUpdate();
867 m_landPrimCountTainted = false;
868 } 882 }
869 883
870 public void EventManagerOnRequestParcelPrimCountUpdate() 884 public void EventManagerOnRequestParcelPrimCountUpdate()
871 { 885 {
872 ResetAllLandPrimCounts(); 886 ResetOverMeRecords();
873 m_scene.EventManager.TriggerParcelPrimCountUpdate(); 887 m_scene.EventManager.TriggerParcelPrimCountUpdate();
874 FinalizeLandPrimCountUpdate(); 888 FinalizeLandPrimCountUpdate();
875 m_landPrimCountTainted = false;
876 } 889 }
877 890
878 /// <summary> 891 /// <summary>
@@ -936,8 +949,6 @@ namespace OpenSim.Region.CoreModules.World.Land
936 m_landList[startLandObjectIndex].ForceUpdateLandInfo(); 949 m_landList[startLandObjectIndex].ForceUpdateLandInfo();
937 } 950 }
938 951
939 EventManagerOnParcelPrimCountTainted();
940
941 //Now add the new land object 952 //Now add the new land object
942 ILandObject result = AddLandObject(newLand); 953 ILandObject result = AddLandObject(newLand);
943 UpdateLandObject(startLandObject.LandData.LocalID, startLandObject.LandData); 954 UpdateLandObject(startLandObject.LandData.LocalID, startLandObject.LandData);
@@ -1004,7 +1015,6 @@ namespace OpenSim.Region.CoreModules.World.Land
1004 performFinalLandJoin(masterLandObject, slaveLandObject); 1015 performFinalLandJoin(masterLandObject, slaveLandObject);
1005 } 1016 }
1006 } 1017 }
1007 EventManagerOnParcelPrimCountTainted();
1008 1018
1009 masterLandObject.SendLandUpdateToAvatarsOverMe(); 1019 masterLandObject.SendLandUpdateToAvatarsOverMe();
1010 } 1020 }
@@ -1194,11 +1204,12 @@ namespace OpenSim.Region.CoreModules.World.Land
1194 1204
1195 if (land != null) 1205 if (land != null)
1196 { 1206 {
1207 m_scene.EventManager.TriggerParcelPrimCountUpdate();
1197 m_landList[local_id].SendLandObjectOwners(remote_client); 1208 m_landList[local_id].SendLandObjectOwners(remote_client);
1198 } 1209 }
1199 else 1210 else
1200 { 1211 {
1201 m_log.WarnFormat("[PARCEL]: Invalid land object {0} passed for parcel object owner request", local_id); 1212 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid land object {0} passed for parcel object owner request", local_id);
1202 } 1213 }
1203 } 1214 }
1204 1215
@@ -1361,7 +1372,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1361 { 1372 {
1362 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); 1373 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1363 new_land.LandData = data.Copy(); 1374 new_land.LandData = data.Copy();
1364 new_land.SetLandBitmapFromByteArray(); 1375 new_land.SetLandBitmapFromByteArray();
1365 AddLandObject(new_land); 1376 AddLandObject(new_land);
1366 } 1377 }
1367 1378
@@ -1425,8 +1436,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1425 private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps) 1436 private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps)
1426 { 1437 {
1427 IClientAPI client; 1438 IClientAPI client;
1428 if (! m_scene.TryGetClient(agentID, out client)) { 1439 if (!m_scene.TryGetClient(agentID, out client))
1429 m_log.WarnFormat("[LAND] unable to retrieve IClientAPI for {0}", agentID.ToString()); 1440 {
1441 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID);
1430 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); 1442 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
1431 } 1443 }
1432 1444
@@ -1475,7 +1487,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1475 } 1487 }
1476 else 1488 else
1477 { 1489 {
1478 m_log.WarnFormat("[LAND] unable to find parcelID {0}", parcelID); 1490 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID);
1479 } 1491 }
1480 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); 1492 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
1481 } 1493 }
@@ -1533,17 +1545,17 @@ namespace OpenSim.Region.CoreModules.World.Land
1533 } 1545 }
1534 catch (LLSD.LLSDParseException e) 1546 catch (LLSD.LLSDParseException e)
1535 { 1547 {
1536 m_log.ErrorFormat("[LAND] Fetch error: {0}", e.Message); 1548 m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Fetch error: {0}", e.Message);
1537 m_log.ErrorFormat("[LAND] ... in request {0}", request); 1549 m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: ... in request {0}", request);
1538 } 1550 }
1539 catch(InvalidCastException) 1551 catch (InvalidCastException)
1540 { 1552 {
1541 m_log.ErrorFormat("[LAND] Wrong type in request {0}", request); 1553 m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Wrong type in request {0}", request);
1542 } 1554 }
1543 1555
1544 LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse(); 1556 LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse();
1545 response.parcel_id = parcelID; 1557 response.parcel_id = parcelID;
1546 m_log.DebugFormat("[LAND] got parcelID {0}", parcelID); 1558 m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelID {0}", parcelID);
1547 1559
1548 return LLSDHelpers.SerialiseLLSDReply(response); 1560 return LLSDHelpers.SerialiseLLSDReply(response);
1549 } 1561 }
@@ -1564,7 +1576,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1564 ExtendedLandData extLandData = new ExtendedLandData(); 1576 ExtendedLandData extLandData = new ExtendedLandData();
1565 Util.ParseFakeParcelID(parcel, out extLandData.RegionHandle, 1577 Util.ParseFakeParcelID(parcel, out extLandData.RegionHandle,
1566 out extLandData.X, out extLandData.Y); 1578 out extLandData.X, out extLandData.Y);
1567 m_log.DebugFormat("[LAND] got parcelinfo request for regionHandle {0}, x/y {1}/{2}", 1579 m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelinfo request for regionHandle {0}, x/y {1}/{2}",
1568 extLandData.RegionHandle, extLandData.X, extLandData.Y); 1580 extLandData.RegionHandle, extLandData.X, extLandData.Y);
1569 1581
1570 // for this region or for somewhere else? 1582 // for this region or for somewhere else?
@@ -1605,7 +1617,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1605 info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); 1617 info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1606 } 1618 }
1607 // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. 1619 // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
1608 m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...", 1620 m_log.DebugFormat("[LAND MANAGEMENT MODULE]: got parcelinfo for parcel {0} in region {1}; sending...",
1609 data.LandData.Name, data.RegionHandle); 1621 data.LandData.Name, data.RegionHandle);
1610 // HACK for now 1622 // HACK for now
1611 RegionInfo r = new RegionInfo(); 1623 RegionInfo r = new RegionInfo();
@@ -1616,7 +1628,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1616 remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y); 1628 remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y);
1617 } 1629 }
1618 else 1630 else
1619 m_log.Debug("[LAND] got no parcelinfo; not sending"); 1631 m_log.Debug("[LAND MANAGEMENT MODULE]: got no parcelinfo; not sending");
1620 } 1632 }
1621 1633
1622 public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime) 1634 public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 46c15ed..c2f104e 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Land
51 51
52 private int m_lastSeqId = 0; 52 private int m_lastSeqId = 0;
53 53
54 protected LandData m_landData = new LandData(); 54 protected LandData m_landData = new LandData();
55 protected Scene m_scene; 55 protected Scene m_scene;
56 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); 56 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
57 protected Dictionary<uint, UUID> m_listTransactions = new Dictionary<uint, UUID>(); 57 protected Dictionary<uint, UUID> m_listTransactions = new Dictionary<uint, UUID>();
@@ -64,8 +64,6 @@ namespace OpenSim.Region.CoreModules.World.Land
64 64
65 #endregion 65 #endregion
66 66
67 #region ILandObject Members
68
69 public int GetPrimsFree() 67 public int GetPrimsFree()
70 { 68 {
71 m_scene.EventManager.TriggerParcelPrimCountUpdate(); 69 m_scene.EventManager.TriggerParcelPrimCountUpdate();
@@ -79,6 +77,8 @@ namespace OpenSim.Region.CoreModules.World.Land
79 77
80 set { m_landData = value; } 78 set { m_landData = value; }
81 } 79 }
80
81 public IPrimCounts PrimCounts { get; set; }
82 82
83 public UUID RegionUUID 83 public UUID RegionUUID
84 { 84 {
@@ -211,6 +211,7 @@ namespace OpenSim.Region.CoreModules.World.Land
211 return simMax; 211 return simMax;
212 } 212 }
213 } 213 }
214
214 #endregion 215 #endregion
215 216
216 #region Packet Request Handling 217 #region Packet Request Handling
@@ -241,7 +242,7 @@ namespace OpenSim.Region.CoreModules.World.Land
241 } 242 }
242 243
243 remote_client.SendLandProperties(seq_id, 244 remote_client.SendLandProperties(seq_id,
244 snap_selection, request_result, LandData, 245 snap_selection, request_result, this,
245 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, 246 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus,
246 GetParcelMaxPrimCount(this), 247 GetParcelMaxPrimCount(this),
247 GetSimulatorMaxPrimCount(this), regionFlags); 248 GetSimulatorMaxPrimCount(this), regionFlags);
@@ -700,23 +701,11 @@ namespace OpenSim.Region.CoreModules.World.Land
700 return LandBitmap; 701 return LandBitmap;
701 } 702 }
702 703
703 /// <summary>
704 /// Full sim land object creation
705 /// </summary>
706 /// <returns></returns>
707 public bool[,] BasicFullRegionLandBitmap() 704 public bool[,] BasicFullRegionLandBitmap()
708 { 705 {
709 return GetSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize); 706 return GetSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize);
710 } 707 }
711 708
712 /// <summary>
713 /// Used to modify the bitmap between the x and y points. Points use 64 scale
714 /// </summary>
715 /// <param name="start_x"></param>
716 /// <param name="start_y"></param>
717 /// <param name="end_x"></param>
718 /// <param name="end_y"></param>
719 /// <returns></returns>
720 public bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y) 709 public bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y)
721 { 710 {
722 bool[,] tempBitmap = new bool[64,64]; 711 bool[,] tempBitmap = new bool[64,64];
@@ -907,9 +896,12 @@ namespace OpenSim.Region.CoreModules.World.Land
907 896
908 lock (primsOverMe) 897 lock (primsOverMe)
909 { 898 {
899// m_log.DebugFormat(
900// "[LAND OBJECT]: Request for SendLandObjectOwners() from {0} with {1} known prims on region",
901// remote_client.Name, primsOverMe.Count);
902
910 try 903 try
911 { 904 {
912
913 foreach (SceneObjectGroup obj in primsOverMe) 905 foreach (SceneObjectGroup obj in primsOverMe)
914 { 906 {
915 try 907 try
@@ -921,7 +913,7 @@ namespace OpenSim.Region.CoreModules.World.Land
921 } 913 }
922 catch (NullReferenceException) 914 catch (NullReferenceException)
923 { 915 {
924 m_log.Info("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel"); 916 m_log.Error("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel");
925 } 917 }
926 try 918 try
927 { 919 {
@@ -948,6 +940,7 @@ namespace OpenSim.Region.CoreModules.World.Land
948 public Dictionary<UUID, int> GetLandObjectOwners() 940 public Dictionary<UUID, int> GetLandObjectOwners()
949 { 941 {
950 Dictionary<UUID, int> ownersAndCount = new Dictionary<UUID, int>(); 942 Dictionary<UUID, int> ownersAndCount = new Dictionary<UUID, int>();
943
951 lock (primsOverMe) 944 lock (primsOverMe)
952 { 945 {
953 try 946 try
@@ -984,8 +977,10 @@ namespace OpenSim.Region.CoreModules.World.Land
984 977
985 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client) 978 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client)
986 { 979 {
987 Dictionary<UUID,List<SceneObjectGroup>> returns = 980// m_log.DebugFormat(
988 new Dictionary<UUID,List<SceneObjectGroup>>(); 981// "[LAND OBJECT]: Request to return objects in {0} from {1}", LandData.Name, remote_client.Name);
982
983 Dictionary<UUID,List<SceneObjectGroup>> returns = new Dictionary<UUID,List<SceneObjectGroup>>();
989 984
990 lock (primsOverMe) 985 lock (primsOverMe)
991 { 986 {
@@ -1058,83 +1053,29 @@ namespace OpenSim.Region.CoreModules.World.Land
1058 1053
1059 #region Object Adding/Removing from Parcel 1054 #region Object Adding/Removing from Parcel
1060 1055
1061 public void ResetLandPrimCounts() 1056 public void ResetOverMeRecord()
1062 { 1057 {
1063 LandData.GroupPrims = 0;
1064 LandData.OwnerPrims = 0;
1065 LandData.OtherPrims = 0;
1066 LandData.SelectedPrims = 0;
1067
1068
1069 lock (primsOverMe) 1058 lock (primsOverMe)
1070 primsOverMe.Clear(); 1059 primsOverMe.Clear();
1071 } 1060 }
1072 1061
1073 public void AddPrimToCount(SceneObjectGroup obj) 1062 public void AddPrimOverMe(SceneObjectGroup obj)
1074 { 1063 {
1075 1064// m_log.DebugFormat("[LAND OBJECT]: Adding scene object {0} {1} over {2}", obj.Name, obj.LocalId, LandData.Name);
1076 UUID prim_owner = obj.OwnerID; 1065
1077 int prim_count = obj.PrimCount;
1078
1079 if (obj.IsSelected)
1080 {
1081 LandData.SelectedPrims += prim_count;
1082 }
1083 else
1084 {
1085 if (prim_owner == LandData.OwnerID)
1086 {
1087 LandData.OwnerPrims += prim_count;
1088 }
1089 else if ((obj.GroupID == LandData.GroupID ||
1090 prim_owner == LandData.GroupID) &&
1091 LandData.GroupID != UUID.Zero)
1092 {
1093 LandData.GroupPrims += prim_count;
1094 }
1095 else
1096 {
1097 LandData.OtherPrims += prim_count;
1098 }
1099 }
1100
1101 lock (primsOverMe) 1066 lock (primsOverMe)
1102 primsOverMe.Add(obj); 1067 primsOverMe.Add(obj);
1103 } 1068 }
1104 1069
1105 public void RemovePrimFromCount(SceneObjectGroup obj) 1070 public void RemovePrimFromOverMe(SceneObjectGroup obj)
1106 { 1071 {
1072// m_log.DebugFormat("[LAND OBJECT]: Removing scene object {0} {1} from over {2}", obj.Name, obj.LocalId, LandData.Name);
1073
1107 lock (primsOverMe) 1074 lock (primsOverMe)
1108 { 1075 primsOverMe.Remove(obj);
1109 if (primsOverMe.Contains(obj))
1110 {
1111 UUID prim_owner = obj.OwnerID;
1112 int prim_count = obj.PrimCount;
1113
1114 if (prim_owner == LandData.OwnerID)
1115 {
1116 LandData.OwnerPrims -= prim_count;
1117 }
1118 else if (obj.GroupID == LandData.GroupID ||
1119 prim_owner == LandData.GroupID)
1120 {
1121 LandData.GroupPrims -= prim_count;
1122 }
1123 else
1124 {
1125 LandData.OtherPrims -= prim_count;
1126 }
1127
1128 primsOverMe.Remove(obj);
1129 }
1130 }
1131 } 1076 }
1132 1077
1133 #endregion 1078 #endregion
1134
1135 #endregion
1136
1137 #endregion
1138 1079
1139 /// <summary> 1080 /// <summary>
1140 /// Set the media url for this land parcel 1081 /// Set the media url for this land parcel
@@ -1155,5 +1096,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1155 LandData.MusicURL = url; 1096 LandData.MusicURL = url;
1156 SendLandUpdateToAvatarsOverMe(); 1097 SendLandUpdateToAvatarsOverMe();
1157 } 1098 }
1099
1100 #endregion
1158 } 1101 }
1159} 1102}
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 34ef67f..dca842a 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -45,14 +45,13 @@ namespace OpenSim.Region.CoreModules.World.Land
45 public int Owner = 0; 45 public int Owner = 0;
46 public int Group = 0; 46 public int Group = 0;
47 public int Others = 0; 47 public int Others = 0;
48 public Dictionary <UUID, int> Users = 48 public int Selected = 0;
49 new Dictionary <UUID, int>(); 49 public Dictionary <UUID, int> Users = new Dictionary <UUID, int>();
50 } 50 }
51 51
52 public class PrimCountModule : IPrimCountModule, INonSharedRegionModule 52 public class PrimCountModule : IPrimCountModule, INonSharedRegionModule
53 { 53 {
54 private static readonly ILog m_log = 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 55
57 private Scene m_Scene; 56 private Scene m_Scene;
58 private Dictionary<UUID, PrimCounts> m_PrimCounts = 57 private Dictionary<UUID, PrimCounts> m_PrimCounts =
@@ -64,10 +63,15 @@ namespace OpenSim.Region.CoreModules.World.Land
64 private Dictionary<UUID, ParcelCounts> m_ParcelCounts = 63 private Dictionary<UUID, ParcelCounts> m_ParcelCounts =
65 new Dictionary<UUID, ParcelCounts>(); 64 new Dictionary<UUID, ParcelCounts>();
66 65
67 // For now, a simple simwide taint to get this up. Later parcel based 66 /// <value>
68 // taint to allow recounting a parcel if only ownership has changed 67 /// For now, a simple simwide taint to get this up. Later parcel based
69 // without recounting the whole sim. 68 /// taint to allow recounting a parcel if only ownership has changed
69 /// without recounting the whole sim.
70 ///
71 /// We start out tainted so that the first get call resets the various prim counts.
72 /// <value>
70 private bool m_Tainted = true; 73 private bool m_Tainted = true;
74
71 private Object m_TaintLock = new Object(); 75 private Object m_TaintLock = new Object();
72 76
73 public Type ReplaceableInterface 77 public Type ReplaceableInterface
@@ -82,13 +86,15 @@ namespace OpenSim.Region.CoreModules.World.Land
82 public void AddRegion(Scene scene) 86 public void AddRegion(Scene scene)
83 { 87 {
84 m_Scene = scene; 88 m_Scene = scene;
89
90 m_Scene.RegisterModuleInterface<IPrimCountModule>(this);
85 91
86 m_Scene.EventManager.OnParcelPrimCountAdd += 92 m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd;
87 OnParcelPrimCountAdd;
88 m_Scene.EventManager.OnObjectBeingRemovedFromScene += 93 m_Scene.EventManager.OnObjectBeingRemovedFromScene +=
89 OnObjectBeingRemovedFromScene; 94 OnObjectBeingRemovedFromScene;
90 m_Scene.EventManager.OnParcelPrimCountTainted += 95 m_Scene.EventManager.OnParcelPrimCountTainted +=
91 OnParcelPrimCountTainted; 96 OnParcelPrimCountTainted;
97 m_Scene.EventManager.OnLandObjectAdded += delegate(ILandObject lo) { OnParcelPrimCountTainted(); };
92 } 98 }
93 99
94 public void RegionLoaded(Scene scene) 100 public void RegionLoaded(Scene scene)
@@ -116,6 +122,11 @@ namespace OpenSim.Region.CoreModules.World.Land
116 { 122 {
117 if (!m_Tainted) 123 if (!m_Tainted)
118 AddObject(obj); 124 AddObject(obj);
125// else
126// m_log.DebugFormat(
127// "[PRIM COUNT MODULE]: Ignoring OnParcelPrimCountAdd() for {0} on {1} since count is tainted",
128// obj.Name, m_Scene.RegionInfo.RegionName);
129
119 } 130 }
120 } 131 }
121 132
@@ -126,11 +137,18 @@ namespace OpenSim.Region.CoreModules.World.Land
126 { 137 {
127 if (!m_Tainted) 138 if (!m_Tainted)
128 RemoveObject(obj); 139 RemoveObject(obj);
140// else
141// m_log.DebugFormat(
142// "[PRIM COUNT MODULE]: Ignoring OnObjectBeingRemovedFromScene() for {0} on {1} since count is tainted",
143// obj.Name, m_Scene.RegionInfo.RegionName);
129 } 144 }
130 } 145 }
131 146
132 private void OnParcelPrimCountTainted() 147 private void OnParcelPrimCountTainted()
133 { 148 {
149// m_log.DebugFormat(
150// "[PRIM COUNT MODULE]: OnParcelPrimCountTainted() called on {0}", m_Scene.RegionInfo.RegionName);
151
134 lock (m_TaintLock) 152 lock (m_TaintLock)
135 m_Tainted = true; 153 m_Tainted = true;
136 } 154 }
@@ -155,15 +173,34 @@ namespace OpenSim.Region.CoreModules.World.Land
155 173
156 // NOTE: Call under Taint Lock 174 // NOTE: Call under Taint Lock
157 private void AddObject(SceneObjectGroup obj) 175 private void AddObject(SceneObjectGroup obj)
158 { 176 {
159 if (obj.IsAttachment) 177 if (obj.IsAttachment)
160 return; 178 return;
161 if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)) 179 if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0))
162 return; 180 return;
163 181
164 Vector3 pos = obj.AbsolutePosition; 182 Vector3 pos = obj.AbsolutePosition;
165 ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); 183 ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
184
185 // If for some reason there is no land object (perhaps the object is out of bounds) then we can't count it
186 if (landObject == null)
187 {
188// m_log.WarnFormat(
189// "[PRIM COUNT MODULE]: Found no land object for {0} at position ({1}, {2}) on {3}",
190// obj.Name, pos.X, pos.Y, m_Scene.RegionInfo.RegionName);
191
192 return;
193 }
194
166 LandData landData = landObject.LandData; 195 LandData landData = landObject.LandData;
196
197// m_log.DebugFormat(
198// "[PRIM COUNT MODULE]: Adding object {0} with {1} parts to prim count for parcel {2} on {3}",
199// obj.Name, obj.Parts.Length, landData.Name, m_Scene.RegionInfo.RegionName);
200
201// m_log.DebugFormat(
202// "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}",
203// obj.Name, obj.OwnerID, landData.OwnerID);
167 204
168 ParcelCounts parcelCounts; 205 ParcelCounts parcelCounts;
169 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) 206 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
@@ -177,23 +214,28 @@ namespace OpenSim.Region.CoreModules.World.Land
177 else 214 else
178 parcelCounts.Users[obj.OwnerID] = partCount; 215 parcelCounts.Users[obj.OwnerID] = partCount;
179 216
180 if (landData.IsGroupOwned) 217 if (obj.IsSelected)
181 { 218 {
182 if (obj.OwnerID == landData.GroupID) 219 parcelCounts.Selected += partCount;
183 parcelCounts.Owner += partCount;
184 else if (obj.GroupID == landData.GroupID)
185 parcelCounts.Group += partCount;
186 else
187 parcelCounts.Others += partCount;
188 } 220 }
189 else 221 else
190 { 222 {
191 if (obj.OwnerID == landData.OwnerID) 223 if (landData.IsGroupOwned)
192 parcelCounts.Owner += partCount; 224 {
193 else if (obj.GroupID == landData.GroupID) 225 if (obj.OwnerID == landData.GroupID)
194 parcelCounts.Group += partCount; 226 parcelCounts.Owner += partCount;
227 else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID)
228 parcelCounts.Group += partCount;
229 else
230 parcelCounts.Others += partCount;
231 }
195 else 232 else
196 parcelCounts.Others += partCount; 233 {
234 if (obj.OwnerID == landData.OwnerID)
235 parcelCounts.Owner += partCount;
236 else
237 parcelCounts.Others += partCount;
238 }
197 } 239 }
198 } 240 }
199 } 241 }
@@ -201,10 +243,16 @@ namespace OpenSim.Region.CoreModules.World.Land
201 // NOTE: Call under Taint Lock 243 // NOTE: Call under Taint Lock
202 private void RemoveObject(SceneObjectGroup obj) 244 private void RemoveObject(SceneObjectGroup obj)
203 { 245 {
246// m_log.DebugFormat("[PRIM COUNT MODULE]: Removing object {0} {1} from prim count", obj.Name, obj.UUID);
247
248 // Currently this is being done by tainting the count instead.
204 } 249 }
205 250
206 public IPrimCounts GetPrimCounts(UUID parcelID) 251 public IPrimCounts GetPrimCounts(UUID parcelID)
207 { 252 {
253// m_log.DebugFormat(
254// "[PRIM COUNT MODULE]: GetPrimCounts for parcel {0} in {1}", parcelID, m_Scene.RegionInfo.RegionName);
255
208 PrimCounts primCounts; 256 PrimCounts primCounts;
209 257
210 lock (m_PrimCounts) 258 lock (m_PrimCounts)
@@ -218,8 +266,16 @@ namespace OpenSim.Region.CoreModules.World.Land
218 return primCounts; 266 return primCounts;
219 } 267 }
220 268
269
270 /// <summary>
271 /// Get the number of prims on the parcel that are owned by the parcel owner.
272 /// </summary>
273 /// <param name="parcelID"></param>
274 /// <returns></returns>
221 public int GetOwnerCount(UUID parcelID) 275 public int GetOwnerCount(UUID parcelID)
222 { 276 {
277 int count = 0;
278
223 lock (m_TaintLock) 279 lock (m_TaintLock)
224 { 280 {
225 if (m_Tainted) 281 if (m_Tainted)
@@ -227,13 +283,25 @@ namespace OpenSim.Region.CoreModules.World.Land
227 283
228 ParcelCounts counts; 284 ParcelCounts counts;
229 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 285 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
230 return counts.Owner; 286 count = counts.Owner;
231 } 287 }
232 return 0; 288
289// m_log.DebugFormat(
290// "[PRIM COUNT MODULE]: GetOwnerCount for parcel {0} in {1} returning {2}",
291// parcelID, m_Scene.RegionInfo.RegionName, count);
292
293 return count;
233 } 294 }
234 295
296 /// <summary>
297 /// Get the number of prims on the parcel that have been set to the group that owns the parcel.
298 /// </summary>
299 /// <param name="parcelID"></param>
300 /// <returns></returns>
235 public int GetGroupCount(UUID parcelID) 301 public int GetGroupCount(UUID parcelID)
236 { 302 {
303 int count = 0;
304
237 lock (m_TaintLock) 305 lock (m_TaintLock)
238 { 306 {
239 if (m_Tainted) 307 if (m_Tainted)
@@ -241,13 +309,25 @@ namespace OpenSim.Region.CoreModules.World.Land
241 309
242 ParcelCounts counts; 310 ParcelCounts counts;
243 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 311 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
244 return counts.Group; 312 count = counts.Group;
245 } 313 }
246 return 0; 314
315// m_log.DebugFormat(
316// "[PRIM COUNT MODULE]: GetGroupCount for parcel {0} in {1} returning {2}",
317// parcelID, m_Scene.RegionInfo.RegionName, count);
318
319 return count;
247 } 320 }
248 321
322 /// <summary>
323 /// Get the number of prims on the parcel that are not owned by the parcel owner or set to the parcel group.
324 /// </summary>
325 /// <param name="parcelID"></param>
326 /// <returns></returns>
249 public int GetOthersCount(UUID parcelID) 327 public int GetOthersCount(UUID parcelID)
250 { 328 {
329 int count = 0;
330
251 lock (m_TaintLock) 331 lock (m_TaintLock)
252 { 332 {
253 if (m_Tainted) 333 if (m_Tainted)
@@ -255,13 +335,83 @@ namespace OpenSim.Region.CoreModules.World.Land
255 335
256 ParcelCounts counts; 336 ParcelCounts counts;
257 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 337 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
258 return counts.Others; 338 count = counts.Others;
259 } 339 }
260 return 0; 340
341// m_log.DebugFormat(
342// "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}",
343// parcelID, m_Scene.RegionInfo.RegionName, count);
344
345 return count;
261 } 346 }
347
348 /// <summary>
349 /// Get the number of selected prims.
350 /// </summary>
351 /// <param name="parcelID"></param>
352 /// <returns></returns>
353 public int GetSelectedCount(UUID parcelID)
354 {
355 int count = 0;
356
357 lock (m_TaintLock)
358 {
359 if (m_Tainted)
360 Recount();
262 361
362 ParcelCounts counts;
363 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
364 count = counts.Selected;
365 }
366
367// m_log.DebugFormat(
368// "[PRIM COUNT MODULE]: GetSelectedCount for parcel {0} in {1} returning {2}",
369// parcelID, m_Scene.RegionInfo.RegionName, count);
370
371 return count;
372 }
373
374 /// <summary>
375 /// Get the total count of owner, group and others prims on the parcel.
376 /// FIXME: Need to do selected prims once this is reimplemented.
377 /// </summary>
378 /// <param name="parcelID"></param>
379 /// <returns></returns>
380 public int GetTotalCount(UUID parcelID)
381 {
382 int count = 0;
383
384 lock (m_TaintLock)
385 {
386 if (m_Tainted)
387 Recount();
388
389 ParcelCounts counts;
390 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
391 {
392 count = counts.Owner;
393 count += counts.Group;
394 count += counts.Others;
395 count += counts.Selected;
396 }
397 }
398
399// m_log.DebugFormat(
400// "[PRIM COUNT MODULE]: GetTotalCount for parcel {0} in {1} returning {2}",
401// parcelID, m_Scene.RegionInfo.RegionName, count);
402
403 return count;
404 }
405
406 /// <summary>
407 /// Get the number of prims that are in the entire simulator for the owner of this parcel.
408 /// </summary>
409 /// <param name="parcelID"></param>
410 /// <returns></returns>
263 public int GetSimulatorCount(UUID parcelID) 411 public int GetSimulatorCount(UUID parcelID)
264 { 412 {
413 int count = 0;
414
265 lock (m_TaintLock) 415 lock (m_TaintLock)
266 { 416 {
267 if (m_Tainted) 417 if (m_Tainted)
@@ -272,14 +422,27 @@ namespace OpenSim.Region.CoreModules.World.Land
272 { 422 {
273 int val; 423 int val;
274 if (m_SimwideCounts.TryGetValue(owner, out val)) 424 if (m_SimwideCounts.TryGetValue(owner, out val))
275 return val; 425 count = val;
276 } 426 }
277 } 427 }
278 return 0; 428
429// m_log.DebugFormat(
430// "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}",
431// parcelID, m_Scene.RegionInfo.RegionName, count);
432
433 return count;
279 } 434 }
280 435
436 /// <summary>
437 /// Get the number of prims that a particular user owns on this parcel.
438 /// </summary>
439 /// <param name="parcelID"></param>
440 /// <param name="userID"></param>
441 /// <returns></returns>
281 public int GetUserCount(UUID parcelID, UUID userID) 442 public int GetUserCount(UUID parcelID, UUID userID)
282 { 443 {
444 int count = 0;
445
283 lock (m_TaintLock) 446 lock (m_TaintLock)
284 { 447 {
285 if (m_Tainted) 448 if (m_Tainted)
@@ -290,27 +453,37 @@ namespace OpenSim.Region.CoreModules.World.Land
290 { 453 {
291 int val; 454 int val;
292 if (counts.Users.TryGetValue(userID, out val)) 455 if (counts.Users.TryGetValue(userID, out val))
293 return val; 456 count = val;
294 } 457 }
295 } 458 }
296 return 0; 459
460// m_log.DebugFormat(
461// "[PRIM COUNT MODULE]: GetUserCount for user {0} in parcel {1} in region {2} returning {3}",
462// userID, parcelID, m_Scene.RegionInfo.RegionName, count);
463
464 return count;
297 } 465 }
298 466
299 // NOTE: This method MUST be called while holding the taint lock! 467 // NOTE: This method MUST be called while holding the taint lock!
300 private void Recount() 468 private void Recount()
301 { 469 {
470// m_log.DebugFormat("[PRIM COUNT MODULE]: Recounting prims on {0}", m_Scene.RegionInfo.RegionName);
471
302 m_OwnerMap.Clear(); 472 m_OwnerMap.Clear();
303 m_SimwideCounts.Clear(); 473 m_SimwideCounts.Clear();
304 m_ParcelCounts.Clear(); 474 m_ParcelCounts.Clear();
305 475
306 List<ILandObject> land = m_Scene.LandChannel.AllParcels(); 476 List<ILandObject> land = m_Scene.LandChannel.AllParcels();
307 477
308 foreach (ILandObject l in land) 478 foreach (ILandObject l in land)
309 { 479 {
310 LandData landData = l.LandData; 480 LandData landData = l.LandData;
311 481
312 m_OwnerMap[landData.GlobalID] = landData.OwnerID; 482 m_OwnerMap[landData.GlobalID] = landData.OwnerID;
313 m_SimwideCounts[landData.OwnerID] = 0; 483 m_SimwideCounts[landData.OwnerID] = 0;
484// m_log.DebugFormat(
485// "[PRIM COUNT MODULE]: Initializing parcel count for {0} on {1}",
486// landData.Name, m_Scene.RegionInfo.RegionName);
314 m_ParcelCounts[landData.GlobalID] = new ParcelCounts(); 487 m_ParcelCounts[landData.GlobalID] = new ParcelCounts();
315 } 488 }
316 489
@@ -322,6 +495,7 @@ namespace OpenSim.Region.CoreModules.World.Land
322 if (!m_OwnerMap.ContainsKey(k)) 495 if (!m_OwnerMap.ContainsKey(k))
323 m_PrimCounts.Remove(k); 496 m_PrimCounts.Remove(k);
324 } 497 }
498
325 m_Tainted = false; 499 m_Tainted = false;
326 } 500 }
327 } 501 }
@@ -363,6 +537,22 @@ namespace OpenSim.Region.CoreModules.World.Land
363 return m_Parent.GetOthersCount(m_ParcelID); 537 return m_Parent.GetOthersCount(m_ParcelID);
364 } 538 }
365 } 539 }
540
541 public int Selected
542 {
543 get
544 {
545 return m_Parent.GetSelectedCount(m_ParcelID);
546 }
547 }
548
549 public int Total
550 {
551 get
552 {
553 return m_Parent.GetTotalCount(m_ParcelID);
554 }
555 }
366 556
367 public int Simulator 557 public int Simulator
368 { 558 {
@@ -403,4 +593,4 @@ namespace OpenSim.Region.CoreModules.World.Land
403 } 593 }
404 } 594 }
405 } 595 }
406} 596} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
new file mode 100644
index 0000000..67b00ac
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
@@ -0,0 +1,382 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenMetaverse.Assets;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock;
40using OpenSim.Tests.Common.Setup;
41
42namespace OpenSim.Region.CoreModules.World.Land.Tests
43{
44 [TestFixture]
45 public class PrimCountModuleTests
46 {
47 protected UUID m_userId = new UUID("00000000-0000-0000-0000-100000000000");
48 protected UUID m_groupId = new UUID("00000000-0000-0000-8888-000000000000");
49 protected UUID m_otherUserId = new UUID("99999999-9999-9999-9999-999999999999");
50 protected TestScene m_scene;
51 protected PrimCountModule m_pcm;
52
53 /// <summary>
54 /// A parcel that covers the entire sim except for a 1 unit wide strip on the eastern side.
55 /// </summary>
56 protected ILandObject m_lo;
57
58 /// <summary>
59 /// A parcel that covers just the eastern strip of the sim.
60 /// </summary>
61 protected ILandObject m_lo2;
62
63 [SetUp]
64 public void SetUp()
65 {
66 m_pcm = new PrimCountModule();
67 LandManagementModule lmm = new LandManagementModule();
68 m_scene = SceneSetupHelpers.SetupScene();
69 SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm);
70
71 int xParcelDivider = (int)Constants.RegionSize - 1;
72
73 ILandObject lo = new LandObject(m_userId, false, m_scene);
74 lo.LandData.Name = "m_lo";
75 lo.SetLandBitmap(
76 lo.GetSquareLandBitmap(0, 0, xParcelDivider, (int)Constants.RegionSize));
77 m_lo = lmm.AddLandObject(lo);
78
79 ILandObject lo2 = new LandObject(m_userId, false, m_scene);
80 lo2.SetLandBitmap(
81 lo2.GetSquareLandBitmap(xParcelDivider, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
82 lo2.LandData.Name = "m_lo2";
83 m_lo2 = lmm.AddLandObject(lo2);
84 }
85
86 /// <summary>
87 /// Test that counts before we do anything are correct.
88 /// </summary>
89 [Test]
90 public void TestInitialCounts()
91 {
92 IPrimCounts pc = m_lo.PrimCounts;
93
94 Assert.That(pc.Owner, Is.EqualTo(0));
95 Assert.That(pc.Group, Is.EqualTo(0));
96 Assert.That(pc.Others, Is.EqualTo(0));
97 Assert.That(pc.Total, Is.EqualTo(0));
98 Assert.That(pc.Selected, Is.EqualTo(0));
99 Assert.That(pc.Users[m_userId], Is.EqualTo(0));
100 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
101 Assert.That(pc.Simulator, Is.EqualTo(0));
102 }
103
104 /// <summary>
105 /// Test count after a parcel owner owned object is added.
106 /// </summary>
107 [Test]
108 public void TestAddOwnerObject()
109 {
110 TestHelper.InMethod();
111// log4net.Config.XmlConfigurator.Configure();
112
113 IPrimCounts pc = m_lo.PrimCounts;
114
115 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
116 m_scene.AddNewSceneObject(sog, false);
117
118 Assert.That(pc.Owner, Is.EqualTo(3));
119 Assert.That(pc.Group, Is.EqualTo(0));
120 Assert.That(pc.Others, Is.EqualTo(0));
121 Assert.That(pc.Total, Is.EqualTo(3));
122 Assert.That(pc.Selected, Is.EqualTo(0));
123 Assert.That(pc.Users[m_userId], Is.EqualTo(3));
124 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
125 Assert.That(pc.Simulator, Is.EqualTo(3));
126
127 // Add a second object and retest
128 SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
129 m_scene.AddNewSceneObject(sog2, false);
130
131 Assert.That(pc.Owner, Is.EqualTo(5));
132 Assert.That(pc.Group, Is.EqualTo(0));
133 Assert.That(pc.Others, Is.EqualTo(0));
134 Assert.That(pc.Total, Is.EqualTo(5));
135 Assert.That(pc.Selected, Is.EqualTo(0));
136 Assert.That(pc.Users[m_userId], Is.EqualTo(5));
137 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
138 Assert.That(pc.Simulator, Is.EqualTo(5));
139 }
140
141 /// <summary>
142 /// Test count after a parcel owner owned copied object is added.
143 /// </summary>
144 [Test]
145 public void TestCopyOwnerObject()
146 {
147 TestHelper.InMethod();
148// log4net.Config.XmlConfigurator.Configure();
149
150 IPrimCounts pc = m_lo.PrimCounts;
151
152 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
153 m_scene.AddNewSceneObject(sog, false);
154 m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity);
155
156 Assert.That(pc.Owner, Is.EqualTo(6));
157 Assert.That(pc.Group, Is.EqualTo(0));
158 Assert.That(pc.Others, Is.EqualTo(0));
159 Assert.That(pc.Total, Is.EqualTo(6));
160 Assert.That(pc.Selected, Is.EqualTo(0));
161 Assert.That(pc.Users[m_userId], Is.EqualTo(6));
162 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
163 Assert.That(pc.Simulator, Is.EqualTo(6));
164 }
165
166 /// <summary>
167 /// Test that parcel counts update correctly when an object is moved between parcels, where that movement
168 /// is not done directly by the user/
169 /// </summary>
170 [Test]
171 public void TestMoveOwnerObject()
172 {
173 TestHelper.InMethod();
174// log4net.Config.XmlConfigurator.Configure();
175
176 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
177 m_scene.AddNewSceneObject(sog, false);
178 SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
179 m_scene.AddNewSceneObject(sog2, false);
180
181 // Move the first scene object to the eastern strip parcel
182 sog.AbsolutePosition = new Vector3(254, 2, 2);
183
184 IPrimCounts pclo1 = m_lo.PrimCounts;
185
186 Assert.That(pclo1.Owner, Is.EqualTo(2));
187 Assert.That(pclo1.Group, Is.EqualTo(0));
188 Assert.That(pclo1.Others, Is.EqualTo(0));
189 Assert.That(pclo1.Total, Is.EqualTo(2));
190 Assert.That(pclo1.Selected, Is.EqualTo(0));
191 Assert.That(pclo1.Users[m_userId], Is.EqualTo(2));
192 Assert.That(pclo1.Users[m_otherUserId], Is.EqualTo(0));
193 Assert.That(pclo1.Simulator, Is.EqualTo(5));
194
195 IPrimCounts pclo2 = m_lo2.PrimCounts;
196
197 Assert.That(pclo2.Owner, Is.EqualTo(3));
198 Assert.That(pclo2.Group, Is.EqualTo(0));
199 Assert.That(pclo2.Others, Is.EqualTo(0));
200 Assert.That(pclo2.Total, Is.EqualTo(3));
201 Assert.That(pclo2.Selected, Is.EqualTo(0));
202 Assert.That(pclo2.Users[m_userId], Is.EqualTo(3));
203 Assert.That(pclo2.Users[m_otherUserId], Is.EqualTo(0));
204 Assert.That(pclo2.Simulator, Is.EqualTo(5));
205
206 // Now move it back again
207 sog.AbsolutePosition = new Vector3(2, 2, 2);
208
209 Assert.That(pclo1.Owner, Is.EqualTo(5));
210 Assert.That(pclo1.Group, Is.EqualTo(0));
211 Assert.That(pclo1.Others, Is.EqualTo(0));
212 Assert.That(pclo1.Total, Is.EqualTo(5));
213 Assert.That(pclo1.Selected, Is.EqualTo(0));
214 Assert.That(pclo1.Users[m_userId], Is.EqualTo(5));
215 Assert.That(pclo1.Users[m_otherUserId], Is.EqualTo(0));
216 Assert.That(pclo1.Simulator, Is.EqualTo(5));
217
218 Assert.That(pclo2.Owner, Is.EqualTo(0));
219 Assert.That(pclo2.Group, Is.EqualTo(0));
220 Assert.That(pclo2.Others, Is.EqualTo(0));
221 Assert.That(pclo2.Total, Is.EqualTo(0));
222 Assert.That(pclo2.Selected, Is.EqualTo(0));
223 Assert.That(pclo2.Users[m_userId], Is.EqualTo(0));
224 Assert.That(pclo2.Users[m_otherUserId], Is.EqualTo(0));
225 Assert.That(pclo2.Simulator, Is.EqualTo(5));
226 }
227
228 /// <summary>
229 /// Test count after a parcel owner owned object is removed.
230 /// </summary>
231 [Test]
232 public void TestRemoveOwnerObject()
233 {
234 TestHelper.InMethod();
235// log4net.Config.XmlConfigurator.Configure();
236
237 IPrimCounts pc = m_lo.PrimCounts;
238
239 m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false);
240 SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
241 m_scene.AddNewSceneObject(sogToDelete, false);
242 m_scene.DeleteSceneObject(sogToDelete, false);
243
244 Assert.That(pc.Owner, Is.EqualTo(1));
245 Assert.That(pc.Group, Is.EqualTo(0));
246 Assert.That(pc.Others, Is.EqualTo(0));
247 Assert.That(pc.Total, Is.EqualTo(1));
248 Assert.That(pc.Selected, Is.EqualTo(0));
249 Assert.That(pc.Users[m_userId], Is.EqualTo(1));
250 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
251 Assert.That(pc.Simulator, Is.EqualTo(1));
252 }
253
254 [Test]
255 public void TestAddGroupObject()
256 {
257 TestHelper.InMethod();
258// log4net.Config.XmlConfigurator.Configure();
259
260 m_lo.DeedToGroup(m_groupId);
261
262 IPrimCounts pc = m_lo.PrimCounts;
263
264 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
265 sog.GroupID = m_groupId;
266 m_scene.AddNewSceneObject(sog, false);
267
268 Assert.That(pc.Owner, Is.EqualTo(0));
269 Assert.That(pc.Group, Is.EqualTo(3));
270 Assert.That(pc.Others, Is.EqualTo(0));
271 Assert.That(pc.Total, Is.EqualTo(3));
272 Assert.That(pc.Selected, Is.EqualTo(0));
273
274 // Is this desired behaviour? Not totally sure.
275 Assert.That(pc.Users[m_userId], Is.EqualTo(0));
276 Assert.That(pc.Users[m_groupId], Is.EqualTo(0));
277 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(3));
278
279 Assert.That(pc.Simulator, Is.EqualTo(3));
280 }
281
282 /// <summary>
283 /// Test count after a parcel owner owned object is removed.
284 /// </summary>
285 [Test]
286 public void TestRemoveGroupObject()
287 {
288 TestHelper.InMethod();
289// log4net.Config.XmlConfigurator.Configure();
290
291 m_lo.DeedToGroup(m_groupId);
292
293 IPrimCounts pc = m_lo.PrimCounts;
294
295 SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1);
296 sogToKeep.GroupID = m_groupId;
297 m_scene.AddNewSceneObject(sogToKeep, false);
298
299 SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
300 m_scene.AddNewSceneObject(sogToDelete, false);
301 m_scene.DeleteSceneObject(sogToDelete, false);
302
303 Assert.That(pc.Owner, Is.EqualTo(0));
304 Assert.That(pc.Group, Is.EqualTo(1));
305 Assert.That(pc.Others, Is.EqualTo(0));
306 Assert.That(pc.Total, Is.EqualTo(1));
307 Assert.That(pc.Selected, Is.EqualTo(0));
308 Assert.That(pc.Users[m_userId], Is.EqualTo(1));
309 Assert.That(pc.Users[m_groupId], Is.EqualTo(0));
310 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
311 Assert.That(pc.Simulator, Is.EqualTo(1));
312 }
313
314 [Test]
315 public void TestAddOthersObject()
316 {
317 TestHelper.InMethod();
318// log4net.Config.XmlConfigurator.Configure();
319
320 IPrimCounts pc = m_lo.PrimCounts;
321
322 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
323 m_scene.AddNewSceneObject(sog, false);
324
325 Assert.That(pc.Owner, Is.EqualTo(0));
326 Assert.That(pc.Group, Is.EqualTo(0));
327 Assert.That(pc.Others, Is.EqualTo(3));
328 Assert.That(pc.Total, Is.EqualTo(3));
329 Assert.That(pc.Selected, Is.EqualTo(0));
330 Assert.That(pc.Users[m_userId], Is.EqualTo(0));
331 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(3));
332 Assert.That(pc.Simulator, Is.EqualTo(3));
333 }
334
335 [Test]
336 public void TestRemoveOthersObject()
337 {
338 TestHelper.InMethod();
339// log4net.Config.XmlConfigurator.Configure();
340
341 IPrimCounts pc = m_lo.PrimCounts;
342
343 m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false);
344 SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10);
345 m_scene.AddNewSceneObject(sogToDelete, false);
346 m_scene.DeleteSceneObject(sogToDelete, false);
347
348 Assert.That(pc.Owner, Is.EqualTo(0));
349 Assert.That(pc.Group, Is.EqualTo(0));
350 Assert.That(pc.Others, Is.EqualTo(1));
351 Assert.That(pc.Total, Is.EqualTo(1));
352 Assert.That(pc.Selected, Is.EqualTo(0));
353 Assert.That(pc.Users[m_userId], Is.EqualTo(0));
354 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(1));
355 Assert.That(pc.Simulator, Is.EqualTo(1));
356 }
357
358 /// <summary>
359 /// Test the count is correct after is has been tainted.
360 /// </summary>
361 [Test]
362 public void TestTaint()
363 {
364 TestHelper.InMethod();
365 IPrimCounts pc = m_lo.PrimCounts;
366
367 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
368 m_scene.AddNewSceneObject(sog, false);
369
370 m_pcm.TaintPrimCount();
371
372 Assert.That(pc.Owner, Is.EqualTo(3));
373 Assert.That(pc.Group, Is.EqualTo(0));
374 Assert.That(pc.Others, Is.EqualTo(0));
375 Assert.That(pc.Total, Is.EqualTo(3));
376 Assert.That(pc.Selected, Is.EqualTo(0));
377 Assert.That(pc.Users[m_userId], Is.EqualTo(3));
378 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
379 Assert.That(pc.Simulator, Is.EqualTo(3));
380 }
381 }
382} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
index cea7c78..4e14c73 100644
--- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
@@ -469,8 +469,8 @@ namespace OpenSim.Region.CoreModules
469 m_SunFixedHour = FixedSunHour; 469 m_SunFixedHour = FixedSunHour;
470 m_SunFixed = FixedSun; 470 m_SunFixed = FixedSun;
471 471
472 m_log.DebugFormat("[SUN]: Sun Settings Update: Fixed Sun? : {0}", m_SunFixed.ToString()); 472 // m_log.DebugFormat("[SUN]: Sun Settings Update: Fixed Sun? : {0}", m_SunFixed.ToString());
473 m_log.DebugFormat("[SUN]: Sun Settings Update: Sun Hour : {0}", m_SunFixedHour.ToString()); 473 // m_log.DebugFormat("[SUN]: Sun Settings Update: Sun Hour : {0}", m_SunFixedHour.ToString());
474 474
475 receivedEstateToolsSunUpdate = true; 475 receivedEstateToolsSunUpdate = true;
476 476
@@ -480,7 +480,7 @@ namespace OpenSim.Region.CoreModules
480 // When sun settings are updated, we should update all clients with new settings. 480 // When sun settings are updated, we should update all clients with new settings.
481 SunUpdateToAllClients(); 481 SunUpdateToAllClients();
482 482
483 m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString()); 483 // m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString());
484 } 484 }
485 } 485 }
486 486
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
index 6676ec8..d6fa093 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
@@ -62,9 +62,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
62 return LoadBitmap(new Bitmap(filename)); 62 return LoadBitmap(new Bitmap(filename));
63 } 63 }
64 64
65 public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) 65 public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h)
66 { 66 {
67 throw new NotImplementedException(); 67 Bitmap bitmap = new Bitmap(filename);
68 ITerrainChannel retval = new TerrainChannel(true);
69
70 for (int x = 0; x < retval.Width; x++)
71 {
72 for (int y = 0; y < retval.Height; y++)
73 {
74 retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128;
75 }
76 }
77
78 return retval;
68 } 79 }
69 80
70 public virtual ITerrainChannel LoadStream(Stream stream) 81 public virtual ITerrainChannel LoadStream(Stream stream)
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 7bb7544..f9ef286 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -100,8 +100,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
100 // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region 100 // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region
101 regionInfos = new List<GridRegion>(); 101 regionInfos = new List<GridRegion>();
102 GridRegion info = m_scene.GridService.GetRegionByName(m_scene.RegionInfo.ScopeID, mapName); 102 GridRegion info = m_scene.GridService.GetRegionByName(m_scene.RegionInfo.ScopeID, mapName);
103 if (info != null) regionInfos.Add(info); 103 if (info != null)
104 regionInfos.Add(info);
104 } 105 }
106 else if (regionInfos.Count == 0 && mapName.StartsWith("http://"))
107 remoteClient.SendAlertMessage("Hyperlink could not be established.");
108
105 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); 109 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count);
106 List<MapBlockData> blocks = new List<MapBlockData>(); 110 List<MapBlockData> blocks = new List<MapBlockData>();
107 111