diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
14 files changed, 901 insertions, 519 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index d451b9e..efc4998 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -490,6 +490,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
490 | // being no copy/no mod for everyone | 490 | // being no copy/no mod for everyone |
491 | lock (part.TaskInventory) | 491 | lock (part.TaskInventory) |
492 | { | 492 | { |
493 | if (!ResolveUserUuid(scene, part.CreatorID)) | ||
494 | part.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner; | ||
495 | |||
496 | if (!ResolveUserUuid(scene, part.OwnerID)) | ||
497 | part.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner; | ||
498 | |||
499 | if (!ResolveUserUuid(scene, part.LastOwnerID)) | ||
500 | part.LastOwnerID = scene.RegionInfo.EstateSettings.EstateOwner; | ||
501 | |||
502 | // And zap any troublesome sit target information | ||
503 | part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); | ||
504 | part.SitTargetPosition = new Vector3(0, 0, 0); | ||
505 | |||
506 | // Fix ownership/creator of inventory items | ||
507 | // Not doing so results in inventory items | ||
508 | // being no copy/no mod for everyone | ||
509 | part.TaskInventory.LockItemsForRead(true); | ||
493 | TaskInventoryDictionary inv = part.TaskInventory; | 510 | TaskInventoryDictionary inv = part.TaskInventory; |
494 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) | 511 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) |
495 | { | 512 | { |
@@ -510,6 +527,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
510 | if (!ResolveGroupUuid(kvp.Value.GroupID)) | 527 | if (!ResolveGroupUuid(kvp.Value.GroupID)) |
511 | kvp.Value.GroupID = UUID.Zero; | 528 | kvp.Value.GroupID = UUID.Zero; |
512 | } | 529 | } |
530 | part.TaskInventory.LockItemsForRead(false); | ||
513 | } | 531 | } |
514 | } | 532 | } |
515 | 533 | ||
@@ -899,4 +917,4 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
899 | return dearchivedScenes; | 917 | return dearchivedScenes; |
900 | } | 918 | } |
901 | } | 919 | } |
902 | } \ No newline at end of file | 920 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 9600023..ada7ecc 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | |||
@@ -271,18 +271,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
271 | 271 | ||
272 | if (asset != null) | 272 | if (asset != null) |
273 | { | 273 | { |
274 | if (m_options.ContainsKey("verbose")) | 274 | // m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id); |
275 | m_log.InfoFormat("[ARCHIVER]: Writing asset {0}", id); | ||
276 | |||
277 | m_foundAssetUuids.Add(asset.FullID); | 275 | m_foundAssetUuids.Add(asset.FullID); |
278 | 276 | ||
279 | m_assetsArchiver.WriteAsset(PostProcess(asset)); | 277 | m_assetsArchiver.WriteAsset(PostProcess(asset)); |
280 | } | 278 | } |
281 | else | 279 | else |
282 | { | 280 | { |
283 | if (m_options.ContainsKey("verbose")) | 281 | // m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id); |
284 | m_log.InfoFormat("[ARCHIVER]: Recording asset {0} as not found", id); | ||
285 | |||
286 | m_notFoundAssetUuids.Add(new UUID(id)); | 282 | m_notFoundAssetUuids.Add(new UUID(id)); |
287 | } | 283 | } |
288 | 284 | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 17387da..4750b46 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -331,6 +331,16 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
331 | IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>(); | 331 | IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>(); |
332 | if (restartModule != null) | 332 | if (restartModule != null) |
333 | { | 333 | { |
334 | if (timeInSeconds == -1) | ||
335 | { | ||
336 | m_delayCount++; | ||
337 | if (m_delayCount > 3) | ||
338 | return; | ||
339 | |||
340 | restartModule.DelayRestart(3600, "Restart delayed by region manager"); | ||
341 | return; | ||
342 | } | ||
343 | |||
334 | List<int> times = new List<int>(); | 344 | List<int> times = new List<int>(); |
335 | while (timeInSeconds > 0) | 345 | while (timeInSeconds > 0) |
336 | { | 346 | { |
@@ -1256,6 +1266,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1256 | flags |= RegionFlags.AllowParcelChanges; | 1266 | flags |= RegionFlags.AllowParcelChanges; |
1257 | if (Scene.RegionInfo.RegionSettings.BlockShowInSearch) | 1267 | if (Scene.RegionInfo.RegionSettings.BlockShowInSearch) |
1258 | flags |= RegionFlags.BlockParcelSearch; | 1268 | flags |= RegionFlags.BlockParcelSearch; |
1269 | if (Scene.RegionInfo.RegionSettings.GodBlockSearch) | ||
1270 | flags |= (RegionFlags)(1 << 11); | ||
1271 | if (Scene.RegionInfo.RegionSettings.Casino) | ||
1272 | flags |= (RegionFlags)(1 << 10); | ||
1259 | 1273 | ||
1260 | if (Scene.RegionInfo.RegionSettings.FixedSun) | 1274 | if (Scene.RegionInfo.RegionSettings.FixedSun) |
1261 | flags |= RegionFlags.SunFixed; | 1275 | flags |= RegionFlags.SunFixed; |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 73c4d6c..399e9b0 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -87,19 +87,21 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
87 | /// <value> | 87 | /// <value> |
88 | /// Land objects keyed by local id | 88 | /// Land objects keyed by local id |
89 | /// </value> | 89 | /// </value> |
90 | private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); | 90 | // private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); |
91 | |||
92 | //ubit: removed the readonly so i can move it around | ||
93 | private Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); | ||
91 | 94 | ||
92 | private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; | 95 | private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; |
93 | 96 | ||
94 | private bool m_allowedForcefulBans = true; | 97 | private bool m_allowedForcefulBans = true; |
98 | private UUID DefaultGodParcelGroup; | ||
99 | private string DefaultGodParcelName; | ||
95 | 100 | ||
96 | // caches ExtendedLandData | 101 | // caches ExtendedLandData |
97 | private Cache parcelInfoCache; | 102 | private Cache parcelInfoCache; |
98 | 103 | private Dictionary<UUID, Vector3> forcedPosition = | |
99 | /// <summary> | 104 | new Dictionary<UUID, Vector3>(); |
100 | /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions. | ||
101 | /// </summary> | ||
102 | private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>(); | ||
103 | 105 | ||
104 | #region INonSharedRegionModule Members | 106 | #region INonSharedRegionModule Members |
105 | 107 | ||
@@ -110,6 +112,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
110 | 112 | ||
111 | public void Initialise(IConfigSource source) | 113 | public void Initialise(IConfigSource source) |
112 | { | 114 | { |
115 | IConfig cnf = source.Configs["LandManagement"]; | ||
116 | if (cnf != null) | ||
117 | { | ||
118 | DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString())); | ||
119 | DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel"); | ||
120 | } | ||
113 | } | 121 | } |
114 | 122 | ||
115 | public void AddRegion(Scene scene) | 123 | public void AddRegion(Scene scene) |
@@ -187,7 +195,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
187 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; | 195 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; |
188 | client.OnSetStartLocationRequest += ClientOnSetHome; | 196 | client.OnSetStartLocationRequest += ClientOnSetHome; |
189 | 197 | ||
190 | |||
191 | EntityBase presenceEntity; | 198 | EntityBase presenceEntity; |
192 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) | 199 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) |
193 | { | 200 | { |
@@ -203,48 +210,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
203 | 210 | ||
204 | void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | 211 | void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) |
205 | { | 212 | { |
206 | //If we are forcing a position for them to go | ||
207 | if (forcedPosition.ContainsKey(remoteClient.AgentId)) | ||
208 | { | ||
209 | ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId); | ||
210 | |||
211 | //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND | ||
212 | //When the avatar walks into a ban line on the ground, it prevents getting stuck | ||
213 | agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
214 | |||
215 | //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines | ||
216 | if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2) | ||
217 | { | ||
218 | // m_log.DebugFormat( | ||
219 | // "[LAND MANAGEMENT MODULE]: Stopping force position of {0} because {1} is close enough to {2}", | ||
220 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]); | ||
221 | |||
222 | forcedPosition.Remove(remoteClient.AgentId); | ||
223 | } | ||
224 | //if we are far away, teleport | ||
225 | else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3) | ||
226 | { | ||
227 | Vector3 forcePosition = forcedPosition[remoteClient.AgentId]; | ||
228 | // m_log.DebugFormat( | ||
229 | // "[LAND MANAGEMENT MODULE]: Teleporting out {0} because {1} is too far from avatar position {2}", | ||
230 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcePosition); | ||
231 | |||
232 | m_scene.RequestTeleportLocation(remoteClient, m_scene.RegionInfo.RegionHandle, | ||
233 | forcePosition, clientAvatar.Lookat, (uint)Constants.TeleportFlags.ForceRedirect); | ||
234 | |||
235 | forcedPosition.Remove(remoteClient.AgentId); | ||
236 | } | ||
237 | else | ||
238 | { | ||
239 | // m_log.DebugFormat( | ||
240 | // "[LAND MANAGEMENT MODULE]: Forcing {0} from {1} to {2}", | ||
241 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]); | ||
242 | |||
243 | //Forces them toward the forced position we want if they aren't there yet | ||
244 | agentData.UseClientAgentPosition = true; | ||
245 | agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId]; | ||
246 | } | ||
247 | } | ||
248 | } | 213 | } |
249 | 214 | ||
250 | public void Close() | 215 | public void Close() |
@@ -269,6 +234,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
269 | { | 234 | { |
270 | LandData newData = data.Copy(); | 235 | LandData newData = data.Copy(); |
271 | newData.LocalID = local_id; | 236 | newData.LocalID = local_id; |
237 | ILandObject landobj = null; | ||
272 | 238 | ||
273 | ILandObject land; | 239 | ILandObject land; |
274 | lock (m_landList) | 240 | lock (m_landList) |
@@ -308,14 +274,14 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
308 | protected ILandObject CreateDefaultParcel() | 274 | protected ILandObject CreateDefaultParcel() |
309 | { | 275 | { |
310 | m_log.DebugFormat( | 276 | m_log.DebugFormat( |
311 | "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); | 277 | "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); |
312 | 278 | ||
313 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); | 279 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); |
314 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | 280 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); |
315 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 281 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
316 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); | 282 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); |
317 | 283 | ||
318 | return AddLandObject(fullSimParcel); | 284 | return AddLandObject(fullSimParcel); |
319 | } | 285 | } |
320 | 286 | ||
321 | public List<ILandObject> AllParcels() | 287 | public List<ILandObject> AllParcels() |
@@ -364,10 +330,16 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
364 | private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) | 330 | private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) |
365 | { | 331 | { |
366 | if (m_scene.Permissions.IsGod(avatar.UUID)) return; | 332 | if (m_scene.Permissions.IsGod(avatar.UUID)) return; |
367 | if (position.HasValue) | 333 | |
368 | { | 334 | if (!position.HasValue) |
369 | forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; | 335 | return; |
370 | } | 336 | |
337 | bool isFlying = avatar.PhysicsActor.Flying; | ||
338 | avatar.RemoveFromPhysicalScene(); | ||
339 | |||
340 | avatar.AbsolutePosition = (Vector3)position; | ||
341 | |||
342 | avatar.AddToPhysicalScene(isFlying); | ||
371 | } | 343 | } |
372 | 344 | ||
373 | public void SendYouAreRestrictedNotice(ScenePresence avatar) | 345 | public void SendYouAreRestrictedNotice(ScenePresence avatar) |
@@ -387,29 +359,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
387 | } | 359 | } |
388 | 360 | ||
389 | if (parcelAvatarIsEntering != null) | 361 | if (parcelAvatarIsEntering != null) |
390 | { | 362 | EnforceBans(parcelAvatarIsEntering, avatar); |
391 | if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT) | ||
392 | { | ||
393 | if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID)) | ||
394 | { | ||
395 | SendYouAreBannedNotice(avatar); | ||
396 | ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); | ||
397 | } | ||
398 | else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID)) | ||
399 | { | ||
400 | SendYouAreRestrictedNotice(avatar); | ||
401 | ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); | ||
402 | } | ||
403 | else | ||
404 | { | ||
405 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; | ||
406 | } | ||
407 | } | ||
408 | else | ||
409 | { | ||
410 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; | ||
411 | } | ||
412 | } | ||
413 | } | 363 | } |
414 | } | 364 | } |
415 | 365 | ||
@@ -438,30 +388,51 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
438 | 388 | ||
439 | public void SendLandUpdate(ScenePresence avatar, bool force) | 389 | public void SendLandUpdate(ScenePresence avatar, bool force) |
440 | { | 390 | { |
391 | |||
392 | /* stop sendind same data twice | ||
393 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), | ||
394 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); | ||
395 | |||
396 | if (over != null) | ||
397 | { | ||
398 | |||
399 | if (force) | ||
400 | { | ||
401 | if (!avatar.IsChildAgent) | ||
402 | { | ||
403 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
404 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
405 | m_scene.RegionInfo.RegionID); | ||
406 | } | ||
407 | } | ||
408 | |||
409 | if (avatar.currentParcelUUID != over.LandData.GlobalID) | ||
410 | { | ||
411 | if (!avatar.IsChildAgent) | ||
412 | { | ||
413 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
414 | avatar.currentParcelUUID = over.LandData.GlobalID; | ||
415 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
416 | m_scene.RegionInfo.RegionID); | ||
417 | } | ||
418 | } | ||
419 | */ | ||
420 | if (avatar.IsChildAgent) | ||
421 | return; | ||
422 | |||
441 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), | 423 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), |
442 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); | 424 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); |
443 | 425 | ||
444 | if (over != null) | 426 | if (over != null) |
445 | { | 427 | { |
446 | if (force) | 428 | bool NotsameID = (avatar.currentParcelUUID != over.LandData.GlobalID); |
447 | { | 429 | if (force || NotsameID) |
448 | if (!avatar.IsChildAgent) | ||
449 | { | ||
450 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
451 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
452 | m_scene.RegionInfo.RegionID); | ||
453 | } | ||
454 | } | ||
455 | |||
456 | if (avatar.currentParcelUUID != over.LandData.GlobalID) | ||
457 | { | 430 | { |
458 | if (!avatar.IsChildAgent) | 431 | over.SendLandUpdateToClient(avatar.ControllingClient); |
459 | { | 432 | if (NotsameID) |
460 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
461 | avatar.currentParcelUUID = over.LandData.GlobalID; | 433 | avatar.currentParcelUUID = over.LandData.GlobalID; |
462 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | 434 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, |
463 | m_scene.RegionInfo.RegionID); | 435 | m_scene.RegionInfo.RegionID); |
464 | } | ||
465 | } | 436 | } |
466 | } | 437 | } |
467 | } | 438 | } |
@@ -513,6 +484,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
513 | //when we are finally in a safe place, lets release the forced position lock | 484 | //when we are finally in a safe place, lets release the forced position lock |
514 | forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); | 485 | forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); |
515 | } | 486 | } |
487 | EnforceBans(parcel, clientAvatar); | ||
516 | } | 488 | } |
517 | } | 489 | } |
518 | 490 | ||
@@ -663,27 +635,28 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
663 | /// </summary> | 635 | /// </summary> |
664 | public void Clear(bool setupDefaultParcel) | 636 | public void Clear(bool setupDefaultParcel) |
665 | { | 637 | { |
666 | List<ILandObject> parcels; | 638 | Dictionary<int, ILandObject> landworkList; |
639 | // move to work pointer since we are deleting it all | ||
667 | lock (m_landList) | 640 | lock (m_landList) |
668 | { | 641 | { |
669 | parcels = new List<ILandObject>(m_landList.Values); | 642 | landworkList = m_landList; |
643 | m_landList = new Dictionary<int, ILandObject>(); | ||
670 | } | 644 | } |
671 | 645 | ||
672 | foreach (ILandObject lo in parcels) | 646 | // this 2 methods have locks (now) |
647 | ResetSimLandObjects(); | ||
648 | |||
649 | if (setupDefaultParcel) | ||
650 | CreateDefaultParcel(); | ||
651 | |||
652 | // fire outside events unlocked | ||
653 | foreach (ILandObject lo in landworkList.Values) | ||
673 | { | 654 | { |
674 | //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); | 655 | //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); |
675 | m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); | 656 | m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); |
676 | } | 657 | } |
658 | landworkList.Clear(); | ||
677 | 659 | ||
678 | lock (m_landList) | ||
679 | { | ||
680 | m_landList.Clear(); | ||
681 | |||
682 | ResetSimLandObjects(); | ||
683 | } | ||
684 | |||
685 | if (setupDefaultParcel) | ||
686 | CreateDefaultParcel(); | ||
687 | } | 660 | } |
688 | 661 | ||
689 | private void performFinalLandJoin(ILandObject master, ILandObject slave) | 662 | private void performFinalLandJoin(ILandObject master, ILandObject slave) |
@@ -730,7 +703,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
730 | int x; | 703 | int x; |
731 | int y; | 704 | int y; |
732 | 705 | ||
733 | if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) | 706 | if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0) |
734 | return null; | 707 | return null; |
735 | 708 | ||
736 | try | 709 | try |
@@ -780,14 +753,13 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
780 | { | 753 | { |
781 | try | 754 | try |
782 | { | 755 | { |
783 | return m_landList[m_landIDList[x / 4, y / 4]]; | 756 | //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) |
757 | return m_landList[m_landIDList[x / 4, y / 4]]; | ||
758 | //else | ||
759 | // return null; | ||
784 | } | 760 | } |
785 | catch (IndexOutOfRangeException) | 761 | catch (IndexOutOfRangeException) |
786 | { | 762 | { |
787 | // m_log.WarnFormat( | ||
788 | // "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}", | ||
789 | // x, y, m_scene.RegionInfo.RegionName); | ||
790 | |||
791 | return null; | 763 | return null; |
792 | } | 764 | } |
793 | } | 765 | } |
@@ -946,6 +918,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
946 | newLand.LandData.Name = newLand.LandData.Name; | 918 | newLand.LandData.Name = newLand.LandData.Name; |
947 | newLand.LandData.GlobalID = UUID.Random(); | 919 | newLand.LandData.GlobalID = UUID.Random(); |
948 | newLand.LandData.Dwell = 0; | 920 | newLand.LandData.Dwell = 0; |
921 | // Clear "Show in search" on the cut out parcel to prevent double-charging | ||
922 | newLand.LandData.Flags &= ~(uint)ParcelFlags.ShowDirectory; | ||
949 | 923 | ||
950 | newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y)); | 924 | newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y)); |
951 | 925 | ||
@@ -1071,6 +1045,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1071 | //Owner Flag | 1045 | //Owner Flag |
1072 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); | 1046 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); |
1073 | } | 1047 | } |
1048 | else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID)) | ||
1049 | { | ||
1050 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP); | ||
1051 | } | ||
1074 | else if (currentParcelBlock.LandData.SalePrice > 0 && | 1052 | else if (currentParcelBlock.LandData.SalePrice > 0 && |
1075 | (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || | 1053 | (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || |
1076 | currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) | 1054 | currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) |
@@ -1151,8 +1129,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1151 | { | 1129 | { |
1152 | if (!temp.Contains(currentParcel)) | 1130 | if (!temp.Contains(currentParcel)) |
1153 | { | 1131 | { |
1154 | currentParcel.ForceUpdateLandInfo(); | 1132 | if (!currentParcel.IsEitherBannedOrRestricted(remote_client.AgentId)) |
1155 | temp.Add(currentParcel); | 1133 | { |
1134 | currentParcel.ForceUpdateLandInfo(); | ||
1135 | temp.Add(currentParcel); | ||
1136 | } | ||
1156 | } | 1137 | } |
1157 | } | 1138 | } |
1158 | } | 1139 | } |
@@ -1371,8 +1352,26 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1371 | 1352 | ||
1372 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) | 1353 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) |
1373 | { | 1354 | { |
1374 | // m_log.DebugFormat( | 1355 | Dictionary<int, ILandObject> landworkList; |
1375 | // "[LAND MANAGMENT MODULE]: Processing {0} incoming parcels on {1}", data.Count, m_scene.Name); | 1356 | // move to work pointer since we are deleting it all |
1357 | lock (m_landList) | ||
1358 | { | ||
1359 | landworkList = m_landList; | ||
1360 | m_landList = new Dictionary<int, ILandObject>(); | ||
1361 | } | ||
1362 | |||
1363 | //Remove all the land objects in the sim and then process our new data | ||
1364 | foreach (int n in landworkList.Keys) | ||
1365 | { | ||
1366 | m_scene.EventManager.TriggerLandObjectRemoved(landworkList[n].LandData.GlobalID); | ||
1367 | } | ||
1368 | landworkList.Clear(); | ||
1369 | |||
1370 | lock (m_landList) | ||
1371 | { | ||
1372 | m_landIDList.Initialize(); | ||
1373 | m_landList.Clear(); | ||
1374 | } | ||
1376 | 1375 | ||
1377 | for (int i = 0; i < data.Count; i++) | 1376 | for (int i = 0; i < data.Count; i++) |
1378 | IncomingLandObjectFromStorage(data[i]); | 1377 | IncomingLandObjectFromStorage(data[i]); |
@@ -1380,10 +1379,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1380 | 1379 | ||
1381 | public void IncomingLandObjectFromStorage(LandData data) | 1380 | public void IncomingLandObjectFromStorage(LandData data) |
1382 | { | 1381 | { |
1382 | |||
1383 | ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); | 1383 | ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); |
1384 | new_land.LandData = data.Copy(); | 1384 | new_land.LandData = data.Copy(); |
1385 | new_land.SetLandBitmapFromByteArray(); | 1385 | new_land.SetLandBitmapFromByteArray(); |
1386 | AddLandObject(new_land); | 1386 | AddLandObject(new_land); |
1387 | new_land.SendLandUpdateToAvatarsOverMe(); | ||
1387 | } | 1388 | } |
1388 | 1389 | ||
1389 | public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) | 1390 | public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) |
@@ -1714,7 +1715,86 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1714 | 1715 | ||
1715 | UpdateLandObject(localID, land.LandData); | 1716 | UpdateLandObject(localID, land.LandData); |
1716 | } | 1717 | } |
1717 | 1718 | ||
1719 | public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID) | ||
1720 | { | ||
1721 | ILandObject land = null; | ||
1722 | List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels(); | ||
1723 | foreach (ILandObject landObject in Land) | ||
1724 | { | ||
1725 | if (landObject.LandData.LocalID == landID) | ||
1726 | { | ||
1727 | land = landObject; | ||
1728 | } | ||
1729 | } | ||
1730 | land.DeedToGroup(DefaultGodParcelGroup); | ||
1731 | land.LandData.Name = DefaultGodParcelName; | ||
1732 | land.SendLandUpdateToAvatarsOverMe(); | ||
1733 | } | ||
1734 | |||
1735 | private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID) | ||
1736 | { | ||
1737 | ScenePresence SP; | ||
1738 | ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP); | ||
1739 | List<SceneObjectGroup> returns = new List<SceneObjectGroup>(); | ||
1740 | if (SP.UserLevel != 0) | ||
1741 | { | ||
1742 | if (flags == 0) //All parcels, scripted or not | ||
1743 | { | ||
1744 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1745 | { | ||
1746 | if (e.OwnerID == targetID) | ||
1747 | { | ||
1748 | returns.Add(e); | ||
1749 | } | ||
1750 | } | ||
1751 | ); | ||
1752 | } | ||
1753 | if (flags == 4) //All parcels, scripted object | ||
1754 | { | ||
1755 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1756 | { | ||
1757 | if (e.OwnerID == targetID) | ||
1758 | { | ||
1759 | if (e.ContainsScripts()) | ||
1760 | { | ||
1761 | returns.Add(e); | ||
1762 | } | ||
1763 | } | ||
1764 | } | ||
1765 | ); | ||
1766 | } | ||
1767 | if (flags == 4) //not target parcel, scripted object | ||
1768 | { | ||
1769 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1770 | { | ||
1771 | if (e.OwnerID == targetID) | ||
1772 | { | ||
1773 | ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y); | ||
1774 | if (landobject.LandData.OwnerID != e.OwnerID) | ||
1775 | { | ||
1776 | if (e.ContainsScripts()) | ||
1777 | { | ||
1778 | returns.Add(e); | ||
1779 | } | ||
1780 | } | ||
1781 | } | ||
1782 | } | ||
1783 | ); | ||
1784 | } | ||
1785 | foreach (SceneObjectGroup ol in returns) | ||
1786 | { | ||
1787 | ReturnObject(ol, client); | ||
1788 | } | ||
1789 | } | ||
1790 | } | ||
1791 | public void ReturnObject(SceneObjectGroup obj, IClientAPI client) | ||
1792 | { | ||
1793 | SceneObjectGroup[] objs = new SceneObjectGroup[1]; | ||
1794 | objs[0] = obj; | ||
1795 | ((Scene)client.Scene).returnObjects(objs, client.AgentId); | ||
1796 | } | ||
1797 | |||
1718 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | 1798 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); |
1719 | 1799 | ||
1720 | public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | 1800 | public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) |
@@ -1750,7 +1830,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1750 | } | 1830 | } |
1751 | } | 1831 | } |
1752 | } | 1832 | } |
1753 | |||
1754 | private void OnEndParcelFrozen(object avatar) | 1833 | private void OnEndParcelFrozen(object avatar) |
1755 | { | 1834 | { |
1756 | ScenePresence targetAvatar = (ScenePresence)avatar; | 1835 | ScenePresence targetAvatar = (ScenePresence)avatar; |
@@ -1761,6 +1840,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1761 | targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false); | 1840 | targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false); |
1762 | } | 1841 | } |
1763 | 1842 | ||
1843 | |||
1764 | public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | 1844 | public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) |
1765 | { | 1845 | { |
1766 | ScenePresence targetAvatar = null; | 1846 | ScenePresence targetAvatar = null; |
@@ -1780,12 +1860,13 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1780 | if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) && | 1860 | if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) && |
1781 | !m_scene.Permissions.IsAdministrator(client.AgentId)) | 1861 | !m_scene.Permissions.IsAdministrator(client.AgentId)) |
1782 | return; | 1862 | return; |
1863 | |||
1783 | Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); | 1864 | Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); |
1784 | 1865 | ||
1785 | targetAvatar.TeleportWithMomentum(pos, null); | 1866 | targetAvatar.TeleportWithMomentum(pos, null); |
1786 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); | 1867 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); |
1787 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); | 1868 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); |
1788 | 1869 | ||
1789 | if ((flags & 1) != 0) // Ban TODO: Remove magic number | 1870 | if ((flags & 1) != 0) // Ban TODO: Remove magic number |
1790 | { | 1871 | { |
1791 | LandAccessEntry entry = new LandAccessEntry(); | 1872 | LandAccessEntry entry = new LandAccessEntry(); |
@@ -1942,6 +2023,30 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1942 | ld.Name, ld.LocalID, ld.Area, lo.StartPoint, lo.EndPoint, m_userManager.GetUserName(ld.OwnerID)); | 2023 | ld.Name, ld.LocalID, ld.Area, lo.StartPoint, lo.EndPoint, m_userManager.GetUserName(ld.OwnerID)); |
1943 | } | 2024 | } |
1944 | } | 2025 | } |
2026 | |||
2027 | MainConsole.Instance.Output(report.ToString()); | ||
2028 | } | ||
2029 | |||
2030 | public void EnforceBans(ILandObject land, ScenePresence avatar) | ||
2031 | { | ||
2032 | if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT) | ||
2033 | return; | ||
2034 | |||
2035 | if (land.IsEitherBannedOrRestricted(avatar.UUID)) | ||
2036 | { | ||
2037 | if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y))) | ||
2038 | { | ||
2039 | Vector3? pos = m_scene.GetNearestAllowedPosition(avatar); | ||
2040 | if (pos == null) | ||
2041 | m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient); | ||
2042 | else | ||
2043 | ForceAvatarToPosition(avatar, (Vector3)pos); | ||
2044 | } | ||
2045 | else | ||
2046 | { | ||
2047 | ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition); | ||
2048 | } | ||
2049 | } | ||
1945 | } | 2050 | } |
1946 | 2051 | ||
1947 | private void AppendParcelReport(StringBuilder report, ILandObject lo) | 2052 | private void AppendParcelReport(StringBuilder report, ILandObject lo) |
@@ -2007,4 +2112,4 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
2007 | cdl.AddToStringBuilder(report); | 2112 | cdl.AddToStringBuilder(report); |
2008 | } | 2113 | } |
2009 | } | 2114 | } |
2010 | } \ No newline at end of file | 2115 | } |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index e55c9ed..ce4bd0f 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -51,6 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
51 | private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; | 51 | private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; |
52 | 52 | ||
53 | private int m_lastSeqId = 0; | 53 | private int m_lastSeqId = 0; |
54 | private int m_expiryCounter = 0; | ||
54 | 55 | ||
55 | protected LandData m_landData = new LandData(); | 56 | protected LandData m_landData = new LandData(); |
56 | protected Scene m_scene; | 57 | protected Scene m_scene; |
@@ -136,6 +137,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
136 | else | 137 | else |
137 | LandData.GroupID = UUID.Zero; | 138 | LandData.GroupID = UUID.Zero; |
138 | LandData.IsGroupOwned = is_group_owned; | 139 | LandData.IsGroupOwned = is_group_owned; |
140 | |||
141 | m_scene.EventManager.OnFrame += OnFrame; | ||
139 | } | 142 | } |
140 | 143 | ||
141 | #endregion | 144 | #endregion |
@@ -194,10 +197,27 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
194 | else | 197 | else |
195 | { | 198 | { |
196 | // Normal Calculations | 199 | // Normal Calculations |
197 | int parcelMax = (int)(((float)LandData.Area / 65536.0f) | 200 | int parcelMax = (int)((long)LandData.Area |
198 | * (float)m_scene.RegionInfo.ObjectCapacity | 201 | * (long)m_scene.RegionInfo.ObjectCapacity |
199 | * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); | 202 | * (long)m_scene.RegionInfo.RegionSettings.ObjectBonus |
200 | // TODO: The calculation of ObjectBonus should be refactored. It does still not work in the same manner as SL! | 203 | / 65536L); |
204 | //m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_scene.RegionInfo.ObjectCapacity, m_scene.RegionInfo.RegionSettings.ObjectBonus, parcelMax); | ||
205 | return parcelMax; | ||
206 | } | ||
207 | } | ||
208 | |||
209 | private int GetParcelBasePrimCount() | ||
210 | { | ||
211 | if (overrideParcelMaxPrimCount != null) | ||
212 | { | ||
213 | return overrideParcelMaxPrimCount(this); | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | // Normal Calculations | ||
218 | int parcelMax = (int)((long)LandData.Area | ||
219 | * (long)m_scene.RegionInfo.ObjectCapacity | ||
220 | / 65536L); | ||
201 | return parcelMax; | 221 | return parcelMax; |
202 | } | 222 | } |
203 | } | 223 | } |
@@ -211,8 +231,9 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
211 | else | 231 | else |
212 | { | 232 | { |
213 | //Normal Calculations | 233 | //Normal Calculations |
214 | int simMax = (int)(((float)LandData.SimwideArea / 65536.0f) | 234 | int simMax = (int)((long)LandData.SimwideArea |
215 | * (float)m_scene.RegionInfo.ObjectCapacity); | 235 | * (long)m_scene.RegionInfo.ObjectCapacity / 65536L); |
236 | // m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}", LandData.SimwideArea, m_scene.RegionInfo.ObjectCapacity, simMax); | ||
216 | return simMax; | 237 | return simMax; |
217 | } | 238 | } |
218 | } | 239 | } |
@@ -242,7 +263,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
242 | remote_client.SendLandProperties(seq_id, | 263 | remote_client.SendLandProperties(seq_id, |
243 | snap_selection, request_result, this, | 264 | snap_selection, request_result, this, |
244 | (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, | 265 | (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, |
245 | GetParcelMaxPrimCount(), | 266 | GetParcelBasePrimCount(), |
246 | GetSimulatorMaxPrimCount(), regionFlags); | 267 | GetSimulatorMaxPrimCount(), regionFlags); |
247 | } | 268 | } |
248 | 269 | ||
@@ -302,7 +323,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
302 | 323 | ||
303 | allowedDelta |= (uint)(ParcelFlags.ShowDirectory | | 324 | allowedDelta |= (uint)(ParcelFlags.ShowDirectory | |
304 | ParcelFlags.AllowPublish | | 325 | ParcelFlags.AllowPublish | |
305 | ParcelFlags.MaturePublish); | 326 | ParcelFlags.MaturePublish) | (uint)(1 << 23); |
306 | } | 327 | } |
307 | 328 | ||
308 | if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) | 329 | if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) |
@@ -414,6 +435,19 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
414 | return false; | 435 | return false; |
415 | } | 436 | } |
416 | 437 | ||
438 | public bool CanBeOnThisLand(UUID avatar, float posHeight) | ||
439 | { | ||
440 | if (posHeight < LandChannel.BAN_LINE_SAFETY_HIEGHT && IsBannedFromLand(avatar)) | ||
441 | { | ||
442 | return false; | ||
443 | } | ||
444 | else if (IsRestrictedFromLand(avatar)) | ||
445 | { | ||
446 | return false; | ||
447 | } | ||
448 | return true; | ||
449 | } | ||
450 | |||
417 | public bool HasGroupAccess(UUID avatar) | 451 | public bool HasGroupAccess(UUID avatar) |
418 | { | 452 | { |
419 | if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup) | 453 | if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup) |
@@ -1178,6 +1212,17 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1178 | 1212 | ||
1179 | #endregion | 1213 | #endregion |
1180 | 1214 | ||
1215 | private void OnFrame() | ||
1216 | { | ||
1217 | m_expiryCounter++; | ||
1218 | |||
1219 | if (m_expiryCounter >= 50) | ||
1220 | { | ||
1221 | ExpireAccessList(); | ||
1222 | m_expiryCounter = 0; | ||
1223 | } | ||
1224 | } | ||
1225 | |||
1181 | private void ExpireAccessList() | 1226 | private void ExpireAccessList() |
1182 | { | 1227 | { |
1183 | List<LandAccessEntry> delete = new List<LandAccessEntry>(); | 1228 | List<LandAccessEntry> delete = new List<LandAccessEntry>(); |
@@ -1188,7 +1233,22 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1188 | delete.Add(entry); | 1233 | delete.Add(entry); |
1189 | } | 1234 | } |
1190 | foreach (LandAccessEntry entry in delete) | 1235 | foreach (LandAccessEntry entry in delete) |
1236 | { | ||
1191 | LandData.ParcelAccessList.Remove(entry); | 1237 | LandData.ParcelAccessList.Remove(entry); |
1238 | ScenePresence presence; | ||
1239 | |||
1240 | if (m_scene.TryGetScenePresence(entry.AgentID, out presence) && (!presence.IsChildAgent)) | ||
1241 | { | ||
1242 | ILandObject land = m_scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); | ||
1243 | if (land.LandData.LocalID == LandData.LocalID) | ||
1244 | { | ||
1245 | Vector3 pos = m_scene.GetNearestAllowedPosition(presence, land); | ||
1246 | presence.TeleportWithMomentum(pos, null); | ||
1247 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); | ||
1248 | } | ||
1249 | } | ||
1250 | m_log.DebugFormat("[LAND]: Removing entry {0} because it has expired", entry.AgentID); | ||
1251 | } | ||
1192 | 1252 | ||
1193 | if (delete.Count > 0) | 1253 | if (delete.Count > 0) |
1194 | m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this); | 1254 | m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this); |
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 9b51cc8..771fdd2 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | |||
@@ -207,7 +207,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
207 | if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) | 207 | if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) |
208 | { | 208 | { |
209 | UUID landOwner = landData.OwnerID; | 209 | UUID landOwner = landData.OwnerID; |
210 | int partCount = obj.Parts.Length; | 210 | int partCount = obj.GetPartCount(); |
211 | 211 | ||
212 | m_SimwideCounts[landOwner] += partCount; | 212 | m_SimwideCounts[landOwner] += partCount; |
213 | if (parcelCounts.Users.ContainsKey(obj.OwnerID)) | 213 | if (parcelCounts.Users.ContainsKey(obj.OwnerID)) |
@@ -597,4 +597,4 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
597 | } | 597 | } |
598 | } | 598 | } |
599 | } | 599 | } |
600 | } \ No newline at end of file | 600 | } |
diff --git a/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs index 0a4e83e..f13d648 100644 --- a/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs +++ b/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs | |||
@@ -190,6 +190,9 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
190 | 190 | ||
191 | public void SendProfileToClient(IClientAPI client, RegionLightShareData wl) | 191 | public void SendProfileToClient(IClientAPI client, RegionLightShareData wl) |
192 | { | 192 | { |
193 | if (client == null) | ||
194 | return; | ||
195 | |||
193 | if (m_enableWindlight) | 196 | if (m_enableWindlight) |
194 | { | 197 | { |
195 | if (m_scene.RegionInfo.WindlightSettings.valid) | 198 | if (m_scene.RegionInfo.WindlightSettings.valid) |
@@ -207,8 +210,8 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
207 | 210 | ||
208 | private void EventManager_OnMakeRootAgent(ScenePresence presence) | 211 | private void EventManager_OnMakeRootAgent(ScenePresence presence) |
209 | { | 212 | { |
210 | // m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client {0}", presence.Name); | 213 | if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) |
211 | 214 | m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); | |
212 | SendProfileToClient(presence.ControllingClient); | 215 | SendProfileToClient(presence.ControllingClient); |
213 | } | 216 | } |
214 | 217 | ||
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs index 22a53a8..28daf2f 100644 --- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs | |||
@@ -177,6 +177,13 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell | |||
177 | return false; | 177 | return false; |
178 | } | 178 | } |
179 | 179 | ||
180 | if ((perms & (uint)PermissionMask.Copy) == 0) | ||
181 | { | ||
182 | if (m_dialogModule != null) | ||
183 | m_dialogModule.SendAlertToUser(remoteClient, "This sale has been blocked by the permissions system"); | ||
184 | return false; | ||
185 | } | ||
186 | |||
180 | AssetBase asset = m_scene.CreateAsset( | 187 | AssetBase asset = m_scene.CreateAsset( |
181 | group.GetPartName(localID), | 188 | group.GetPartName(localID), |
182 | group.GetPartDescription(localID), | 189 | group.GetPartDescription(localID), |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index f8e93e1..50855fe 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -42,8 +42,8 @@ using PermissionMask = OpenSim.Framework.PermissionMask; | |||
42 | 42 | ||
43 | namespace OpenSim.Region.CoreModules.World.Permissions | 43 | namespace OpenSim.Region.CoreModules.World.Permissions |
44 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "PermissionsModule")] | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DefaultPermissionsModule")] |
46 | public class PermissionsModule : INonSharedRegionModule, IPermissionsModule | 46 | public class DefaultPermissionsModule : INonSharedRegionModule, IPermissionsModule |
47 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
@@ -348,7 +348,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
348 | 348 | ||
349 | public string Name | 349 | public string Name |
350 | { | 350 | { |
351 | get { return "PermissionsModule"; } | 351 | get { return "DefaultPermissionsModule"; } |
352 | } | 352 | } |
353 | 353 | ||
354 | public Type ReplaceableInterface | 354 | public Type ReplaceableInterface |
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs index 75a8295..0c74b49 100644 --- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs +++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs | |||
@@ -29,6 +29,8 @@ using System; | |||
29 | using System.Linq; | 29 | using System.Linq; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Timers; | 31 | using System.Timers; |
32 | using System.IO; | ||
33 | using System.Diagnostics; | ||
32 | using System.Threading; | 34 | using System.Threading; |
33 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
34 | using log4net; | 36 | using log4net; |
@@ -57,13 +59,24 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
57 | protected UUID m_Initiator; | 59 | protected UUID m_Initiator; |
58 | protected bool m_Notice = false; | 60 | protected bool m_Notice = false; |
59 | protected IDialogModule m_DialogModule = null; | 61 | protected IDialogModule m_DialogModule = null; |
62 | protected string m_MarkerPath = String.Empty; | ||
63 | private int[] m_CurrentAlerts = null; | ||
60 | 64 | ||
61 | public void Initialise(IConfigSource config) | 65 | public void Initialise(IConfigSource config) |
62 | { | 66 | { |
67 | IConfig restartConfig = config.Configs["RestartModule"]; | ||
68 | if (restartConfig != null) | ||
69 | { | ||
70 | m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty); | ||
71 | } | ||
63 | } | 72 | } |
64 | 73 | ||
65 | public void AddRegion(Scene scene) | 74 | public void AddRegion(Scene scene) |
66 | { | 75 | { |
76 | if (m_MarkerPath != String.Empty) | ||
77 | File.Delete(Path.Combine(m_MarkerPath, | ||
78 | scene.RegionInfo.RegionID.ToString())); | ||
79 | |||
67 | m_Scene = scene; | 80 | m_Scene = scene; |
68 | 81 | ||
69 | scene.RegisterModuleInterface<IRestartModule>(this); | 82 | scene.RegisterModuleInterface<IRestartModule>(this); |
@@ -122,6 +135,7 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
122 | 135 | ||
123 | if (alerts == null) | 136 | if (alerts == null) |
124 | { | 137 | { |
138 | CreateMarkerFile(); | ||
125 | m_Scene.RestartNow(); | 139 | m_Scene.RestartNow(); |
126 | return; | 140 | return; |
127 | } | 141 | } |
@@ -129,25 +143,28 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
129 | m_Message = message; | 143 | m_Message = message; |
130 | m_Initiator = initiator; | 144 | m_Initiator = initiator; |
131 | m_Notice = notice; | 145 | m_Notice = notice; |
146 | m_CurrentAlerts = alerts; | ||
132 | m_Alerts = new List<int>(alerts); | 147 | m_Alerts = new List<int>(alerts); |
133 | m_Alerts.Sort(); | 148 | m_Alerts.Sort(); |
134 | m_Alerts.Reverse(); | 149 | m_Alerts.Reverse(); |
135 | 150 | ||
136 | if (m_Alerts[0] == 0) | 151 | if (m_Alerts[0] == 0) |
137 | { | 152 | { |
153 | CreateMarkerFile(); | ||
138 | m_Scene.RestartNow(); | 154 | m_Scene.RestartNow(); |
139 | return; | 155 | return; |
140 | } | 156 | } |
141 | 157 | ||
142 | int nextInterval = DoOneNotice(); | 158 | int nextInterval = DoOneNotice(true); |
143 | 159 | ||
144 | SetTimer(nextInterval); | 160 | SetTimer(nextInterval); |
145 | } | 161 | } |
146 | 162 | ||
147 | public int DoOneNotice() | 163 | public int DoOneNotice(bool sendOut) |
148 | { | 164 | { |
149 | if (m_Alerts.Count == 0 || m_Alerts[0] == 0) | 165 | if (m_Alerts.Count == 0 || m_Alerts[0] == 0) |
150 | { | 166 | { |
167 | CreateMarkerFile(); | ||
151 | m_Scene.RestartNow(); | 168 | m_Scene.RestartNow(); |
152 | return 0; | 169 | return 0; |
153 | } | 170 | } |
@@ -168,34 +185,37 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
168 | 185 | ||
169 | m_Alerts.RemoveAt(0); | 186 | m_Alerts.RemoveAt(0); |
170 | 187 | ||
171 | int minutes = currentAlert / 60; | 188 | if (sendOut) |
172 | string currentAlertString = String.Empty; | ||
173 | if (minutes > 0) | ||
174 | { | 189 | { |
175 | if (minutes == 1) | 190 | int minutes = currentAlert / 60; |
176 | currentAlertString += "1 minute"; | 191 | string currentAlertString = String.Empty; |
177 | else | 192 | if (minutes > 0) |
178 | currentAlertString += String.Format("{0} minutes", minutes); | 193 | { |
194 | if (minutes == 1) | ||
195 | currentAlertString += "1 minute"; | ||
196 | else | ||
197 | currentAlertString += String.Format("{0} minutes", minutes); | ||
198 | if ((currentAlert % 60) != 0) | ||
199 | currentAlertString += " and "; | ||
200 | } | ||
179 | if ((currentAlert % 60) != 0) | 201 | if ((currentAlert % 60) != 0) |
180 | currentAlertString += " and "; | 202 | { |
181 | } | 203 | int seconds = currentAlert % 60; |
182 | if ((currentAlert % 60) != 0) | 204 | if (seconds == 1) |
183 | { | 205 | currentAlertString += "1 second"; |
184 | int seconds = currentAlert % 60; | 206 | else |
185 | if (seconds == 1) | 207 | currentAlertString += String.Format("{0} seconds", seconds); |
186 | currentAlertString += "1 second"; | 208 | } |
187 | else | ||
188 | currentAlertString += String.Format("{0} seconds", seconds); | ||
189 | } | ||
190 | 209 | ||
191 | string msg = String.Format(m_Message, currentAlertString); | 210 | string msg = String.Format(m_Message, currentAlertString); |
192 | 211 | ||
193 | if (m_DialogModule != null && msg != String.Empty) | 212 | if (m_DialogModule != null && msg != String.Empty) |
194 | { | 213 | { |
195 | if (m_Notice) | 214 | if (m_Notice) |
196 | m_DialogModule.SendGeneralAlert(msg); | 215 | m_DialogModule.SendGeneralAlert(msg); |
197 | else | 216 | else |
198 | m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg); | 217 | m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg); |
218 | } | ||
199 | } | 219 | } |
200 | 220 | ||
201 | return currentAlert - nextAlert; | 221 | return currentAlert - nextAlert; |
@@ -226,7 +246,27 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
226 | 246 | ||
227 | private void OnTimer(object source, ElapsedEventArgs e) | 247 | private void OnTimer(object source, ElapsedEventArgs e) |
228 | { | 248 | { |
229 | SetTimer(DoOneNotice()); | 249 | int nextInterval = DoOneNotice(true); |
250 | |||
251 | SetTimer(nextInterval); | ||
252 | } | ||
253 | |||
254 | public void DelayRestart(int seconds, string message) | ||
255 | { | ||
256 | if (m_CountdownTimer == null) | ||
257 | return; | ||
258 | |||
259 | m_CountdownTimer.Stop(); | ||
260 | m_CountdownTimer = null; | ||
261 | |||
262 | m_Alerts = new List<int>(m_CurrentAlerts); | ||
263 | m_Alerts.Add(seconds); | ||
264 | m_Alerts.Sort(); | ||
265 | m_Alerts.Reverse(); | ||
266 | |||
267 | int nextInterval = DoOneNotice(false); | ||
268 | |||
269 | SetTimer(nextInterval); | ||
230 | } | 270 | } |
231 | 271 | ||
232 | public void AbortRestart(string message) | 272 | public void AbortRestart(string message) |
@@ -238,6 +278,9 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
238 | if (m_DialogModule != null && message != String.Empty) | 278 | if (m_DialogModule != null && message != String.Empty) |
239 | m_DialogModule.SendGeneralAlert(message); | 279 | m_DialogModule.SendGeneralAlert(message); |
240 | } | 280 | } |
281 | if (m_MarkerPath != String.Empty) | ||
282 | File.Delete(Path.Combine(m_MarkerPath, | ||
283 | m_Scene.RegionInfo.RegionID.ToString())); | ||
241 | } | 284 | } |
242 | 285 | ||
243 | private void HandleRegionRestart(string module, string[] args) | 286 | private void HandleRegionRestart(string module, string[] args) |
@@ -282,5 +325,25 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
282 | 325 | ||
283 | ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); | 326 | ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); |
284 | } | 327 | } |
328 | |||
329 | protected void CreateMarkerFile() | ||
330 | { | ||
331 | if (m_MarkerPath == String.Empty) | ||
332 | return; | ||
333 | |||
334 | string path = Path.Combine(m_MarkerPath, m_Scene.RegionInfo.RegionID.ToString()); | ||
335 | try | ||
336 | { | ||
337 | string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); | ||
338 | FileStream fs = File.Create(path); | ||
339 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | ||
340 | Byte[] buf = enc.GetBytes(pidstring); | ||
341 | fs.Write(buf, 0, buf.Length); | ||
342 | fs.Close(); | ||
343 | } | ||
344 | catch (Exception) | ||
345 | { | ||
346 | } | ||
347 | } | ||
285 | } | 348 | } |
286 | } \ No newline at end of file | 349 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index fd30c46..4d738a5 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -644,6 +644,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
644 | m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); | 644 | m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); |
645 | m_scene.SaveTerrain(); | 645 | m_scene.SaveTerrain(); |
646 | 646 | ||
647 | m_scene.EventManager.TriggerTerrainUpdate(); | ||
648 | |||
647 | // Clients who look at the map will never see changes after they looked at the map, so i've commented this out. | 649 | // Clients who look at the map will never see changes after they looked at the map, so i've commented this out. |
648 | //m_scene.CreateTerrainTexture(true); | 650 | //m_scene.CreateTerrainTexture(true); |
649 | } | 651 | } |
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index ed2b06a..d38f34b 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | |||
@@ -65,6 +65,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
65 | private bool m_useAntiAliasing = false; // TODO: Make this a config option | 65 | private bool m_useAntiAliasing = false; // TODO: Make this a config option |
66 | private bool m_Enabled = false; | 66 | private bool m_Enabled = false; |
67 | 67 | ||
68 | private Bitmap lastImage = null; | ||
69 | private DateTime lastImageTime = DateTime.MinValue; | ||
70 | |||
68 | #region Region Module interface | 71 | #region Region Module interface |
69 | 72 | ||
70 | public void Initialise(IConfigSource source) | 73 | public void Initialise(IConfigSource source) |
@@ -87,14 +90,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
87 | 90 | ||
88 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); | 91 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); |
89 | if (renderers.Count > 0) | 92 | if (renderers.Count > 0) |
90 | { | 93 | m_log.Info("[MAPTILE]: Loaded prim mesher " + renderers[0]); |
91 | m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); | ||
92 | m_log.DebugFormat("[WARP 3D IMAGE MODULE]: Loaded prim mesher {0}", m_primMesher); | ||
93 | } | ||
94 | else | 94 | else |
95 | { | 95 | m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); |
96 | m_log.Debug("[WARP 3D IMAGE MODULE]: No prim mesher loaded, prim rendering will be disabled"); | ||
97 | } | ||
98 | 96 | ||
99 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); | 97 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); |
100 | } | 98 | } |
@@ -127,9 +125,25 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
127 | 125 | ||
128 | public Bitmap CreateMapTile() | 126 | public Bitmap CreateMapTile() |
129 | { | 127 | { |
128 | if ((DateTime.Now - lastImageTime).TotalSeconds < 3600) | ||
129 | { | ||
130 | return lastImage.Clone(new Rectangle(0, 0, 256, 256), lastImage.PixelFormat); | ||
131 | } | ||
132 | |||
133 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); | ||
134 | if (renderers.Count > 0) | ||
135 | { | ||
136 | m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); | ||
137 | } | ||
138 | |||
130 | Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); | 139 | Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); |
131 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, (int)Constants.RegionSize, (int)Constants.RegionSize, (float)Constants.RegionSize, (float)Constants.RegionSize); | 140 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, (int)Constants.RegionSize, (int)Constants.RegionSize, (float)Constants.RegionSize, (float)Constants.RegionSize); |
132 | return CreateMapTile(viewport, false); | 141 | Bitmap tile = CreateMapTile(viewport, false); |
142 | m_primMesher = null; | ||
143 | |||
144 | lastImage = tile; | ||
145 | lastImageTime = DateTime.Now; | ||
146 | return lastImage.Clone(new Rectangle(0, 0, 256, 256), lastImage.PixelFormat); | ||
133 | } | 147 | } |
134 | 148 | ||
135 | public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures) | 149 | public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures) |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 708a9a2..14deeb6 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | |||
@@ -128,85 +128,93 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
128 | 128 | ||
129 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) | 129 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) |
130 | { | 130 | { |
131 | List<MapBlockData> blocks = new List<MapBlockData>(); | 131 | Util.FireAndForget(x => |
132 | MapBlockData data; | ||
133 | if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) | ||
134 | { | 132 | { |
133 | if (mapName.Length < 2) | ||
134 | { | ||
135 | remoteClient.SendAlertMessage("Use a search string with at least 2 characters"); | ||
136 | return; | ||
137 | } | ||
138 | |||
139 | //m_log.DebugFormat("MAP NAME=({0})", mapName); | ||
140 | |||
141 | // Hack to get around the fact that ll V3 now drops the port from the | ||
142 | // map name. See https://jira.secondlife.com/browse/VWR-28570 | ||
143 | // | ||
144 | // Caller, use this magic form instead: | ||
145 | // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 | ||
146 | // or url encode if possible. | ||
147 | // the hacks we do with this viewer... | ||
148 | // | ||
149 | string mapNameOrig = mapName; | ||
150 | if (mapName.Contains("|")) | ||
151 | mapName = mapName.Replace('|', ':'); | ||
152 | if (mapName.Contains("+")) | ||
153 | mapName = mapName.Replace('+', ' '); | ||
154 | if (mapName.Contains("!")) | ||
155 | mapName = mapName.Replace('!', '/'); | ||
156 | |||
157 | // try to fetch from GridServer | ||
158 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); | ||
159 | // if (regionInfos.Count == 0) | ||
160 | // remoteClient.SendAlertMessage("Hyperlink could not be established."); | ||
161 | |||
162 | //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); | ||
163 | List<MapBlockData> blocks = new List<MapBlockData>(); | ||
164 | |||
165 | MapBlockData data; | ||
166 | if (regionInfos.Count > 0) | ||
167 | { | ||
168 | foreach (GridRegion info in regionInfos) | ||
169 | { | ||
170 | data = new MapBlockData(); | ||
171 | data.Agents = 0; | ||
172 | data.Access = info.Access; | ||
173 | if (flags == 2) // V2 sends this | ||
174 | data.MapImageId = UUID.Zero; | ||
175 | else | ||
176 | data.MapImageId = info.TerrainImage; | ||
177 | // ugh! V2-3 is very sensitive about the result being | ||
178 | // exactly the same as the requested name | ||
179 | if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+")) | ||
180 | data.Name = mapNameOrig; | ||
181 | else | ||
182 | data.Name = info.RegionName; | ||
183 | data.RegionFlags = 0; // TODO not used? | ||
184 | data.WaterHeight = 0; // not used | ||
185 | data.X = (ushort)(info.RegionLocX / Constants.RegionSize); | ||
186 | data.Y = (ushort)(info.RegionLocY / Constants.RegionSize); | ||
187 | blocks.Add(data); | ||
188 | } | ||
189 | } | ||
190 | |||
135 | // final block, closing the search result | 191 | // final block, closing the search result |
136 | AddFinalBlock(blocks); | 192 | data = new MapBlockData(); |
193 | data.Agents = 0; | ||
194 | data.Access = 255; | ||
195 | data.MapImageId = UUID.Zero; | ||
196 | data.Name = mapName; | ||
197 | data.RegionFlags = 0; | ||
198 | data.WaterHeight = 0; // not used | ||
199 | data.X = 0; | ||
200 | data.Y = 0; | ||
201 | blocks.Add(data); | ||
137 | 202 | ||
138 | // flags are agent flags sent from the viewer. | 203 | // flags are agent flags sent from the viewer. |
139 | // they have different values depending on different viewers, apparently | 204 | // they have different values depending on different viewers, apparently |
140 | remoteClient.SendMapBlock(blocks, flags); | 205 | remoteClient.SendMapBlock(blocks, flags); |
141 | remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | 206 | ||
146 | //m_log.DebugFormat("MAP NAME=({0})", mapName); | 207 | // send extra user messages for V3 |
147 | 208 | // because the UI is very confusing | |
148 | // Hack to get around the fact that ll V3 now drops the port from the | 209 | // while we don't fix the hard-coded urls |
149 | // map name. See https://jira.secondlife.com/browse/VWR-28570 | 210 | if (flags == 2) |
150 | // | ||
151 | // Caller, use this magic form instead: | ||
152 | // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 | ||
153 | // or url encode if possible. | ||
154 | // the hacks we do with this viewer... | ||
155 | // | ||
156 | string mapNameOrig = mapName; | ||
157 | if (mapName.Contains("|")) | ||
158 | mapName = mapName.Replace('|', ':'); | ||
159 | if (mapName.Contains("+")) | ||
160 | mapName = mapName.Replace('+', ' '); | ||
161 | if (mapName.Contains("!")) | ||
162 | mapName = mapName.Replace('!', '/'); | ||
163 | |||
164 | // try to fetch from GridServer | ||
165 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); | ||
166 | |||
167 | m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); | ||
168 | if (regionInfos.Count > 0) | ||
169 | { | ||
170 | foreach (GridRegion info in regionInfos) | ||
171 | { | 211 | { |
172 | data = new MapBlockData(); | 212 | if (regionInfos.Count == 0) |
173 | data.Agents = 0; | 213 | remoteClient.SendAgentAlertMessage("No regions found with that name.", true); |
174 | data.Access = info.Access; | 214 | // else if (regionInfos.Count == 1) |
175 | if (flags == 2) // V2 sends this | 215 | // remoteClient.SendAgentAlertMessage("Region found!", false); |
176 | data.MapImageId = UUID.Zero; | ||
177 | else | ||
178 | data.MapImageId = info.TerrainImage; | ||
179 | // ugh! V2-3 is very sensitive about the result being | ||
180 | // exactly the same as the requested name | ||
181 | if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+")) | ||
182 | data.Name = mapNameOrig; | ||
183 | else | ||
184 | data.Name = info.RegionName; | ||
185 | data.RegionFlags = 0; // TODO not used? | ||
186 | data.WaterHeight = 0; // not used | ||
187 | data.X = (ushort)(info.RegionLocX / Constants.RegionSize); | ||
188 | data.Y = (ushort)(info.RegionLocY / Constants.RegionSize); | ||
189 | blocks.Add(data); | ||
190 | } | 216 | } |
191 | } | 217 | }); |
192 | |||
193 | // final block, closing the search result | ||
194 | AddFinalBlock(blocks); | ||
195 | |||
196 | // flags are agent flags sent from the viewer. | ||
197 | // they have different values depending on different viewers, apparently | ||
198 | remoteClient.SendMapBlock(blocks, flags); | ||
199 | |||
200 | // send extra user messages for V3 | ||
201 | // because the UI is very confusing | ||
202 | // while we don't fix the hard-coded urls | ||
203 | if (flags == 2) | ||
204 | { | ||
205 | if (regionInfos.Count == 0) | ||
206 | remoteClient.SendAlertMessage("No regions found with that name."); | ||
207 | else if (regionInfos.Count == 1) | ||
208 | remoteClient.SendAlertMessage("Region found!"); | ||
209 | } | ||
210 | } | 218 | } |
211 | 219 | ||
212 | private void AddFinalBlock(List<MapBlockData> blocks) | 220 | private void AddFinalBlock(List<MapBlockData> blocks) |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index cdf1467..98fa763 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -66,7 +66,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
66 | private static readonly UUID STOP_UUID = UUID.Random(); | 66 | private static readonly UUID STOP_UUID = UUID.Random(); |
67 | private static readonly string m_mapLayerPath = "0001/"; | 67 | private static readonly string m_mapLayerPath = "0001/"; |
68 | 68 | ||
69 | private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>(); | 69 | private ManualResetEvent queueEvent = new ManualResetEvent(false); |
70 | private Queue<MapRequestState> requests = new Queue<MapRequestState>(); | ||
71 | |||
72 | private ManualResetEvent m_mapBlockRequestEvent = new ManualResetEvent(false); | ||
73 | private Dictionary<UUID, Queue<MapBlockRequestData>> m_mapBlockRequests = new Dictionary<UUID, Queue<MapBlockRequestData>>(); | ||
70 | 74 | ||
71 | protected Scene m_scene; | 75 | protected Scene m_scene; |
72 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); | 76 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); |
@@ -74,15 +78,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
74 | private int blacklistTimeout = 10*60*1000; // 10 minutes | 78 | private int blacklistTimeout = 10*60*1000; // 10 minutes |
75 | private byte[] myMapImageJPEG; | 79 | private byte[] myMapImageJPEG; |
76 | protected volatile bool m_Enabled = false; | 80 | protected volatile bool m_Enabled = false; |
77 | private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>(); | ||
78 | private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); | 81 | private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); |
79 | private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); | 82 | private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); |
80 | private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>(); | 83 | private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>(); |
81 | private List<UUID> m_rootAgents = new List<UUID>(); | 84 | private List<UUID> m_rootAgents = new List<UUID>(); |
82 | private volatile bool threadrunning = false; | 85 | private volatile bool threadrunning = false; |
83 | 86 | ||
84 | private IServiceThrottleModule m_ServiceThrottle; | ||
85 | |||
86 | //private int CacheRegionsDistance = 256; | 87 | //private int CacheRegionsDistance = 256; |
87 | 88 | ||
88 | #region INonSharedRegionModule Members | 89 | #region INonSharedRegionModule Members |
@@ -93,7 +94,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
93 | if (Util.GetConfigVarFromSections<string>( | 94 | if (Util.GetConfigVarFromSections<string>( |
94 | config, "WorldMapModule", configSections, "WorldMap") == "WorldMap") | 95 | config, "WorldMapModule", configSections, "WorldMap") == "WorldMap") |
95 | m_Enabled = true; | 96 | m_Enabled = true; |
96 | 97 | ||
97 | blacklistTimeout | 98 | blacklistTimeout |
98 | = Util.GetConfigVarFromSections<int>(config, "BlacklistTimeout", configSections, 10 * 60) * 1000; | 99 | = Util.GetConfigVarFromSections<int>(config, "BlacklistTimeout", configSections, 10 * 60) * 1000; |
99 | } | 100 | } |
@@ -133,10 +134,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
133 | 134 | ||
134 | public virtual void RegionLoaded (Scene scene) | 135 | public virtual void RegionLoaded (Scene scene) |
135 | { | 136 | { |
136 | if (!m_Enabled) | ||
137 | return; | ||
138 | |||
139 | m_ServiceThrottle = scene.RequestModuleInterface<IServiceThrottleModule>(); | ||
140 | } | 137 | } |
141 | 138 | ||
142 | 139 | ||
@@ -185,13 +182,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
185 | m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; | 182 | m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; |
186 | m_scene.EventManager.OnRegionUp += OnRegionUp; | 183 | m_scene.EventManager.OnRegionUp += OnRegionUp; |
187 | 184 | ||
188 | // StartThread(new object()); | 185 | StartThread(new object()); |
189 | } | 186 | } |
190 | 187 | ||
191 | // this has to be called with a lock on m_scene | 188 | // this has to be called with a lock on m_scene |
192 | protected virtual void RemoveHandlers() | 189 | protected virtual void RemoveHandlers() |
193 | { | 190 | { |
194 | // StopThread(); | 191 | StopThread(); |
195 | 192 | ||
196 | m_scene.EventManager.OnRegionUp -= OnRegionUp; | 193 | m_scene.EventManager.OnRegionUp -= OnRegionUp; |
197 | m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent; | 194 | m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent; |
@@ -249,54 +246,54 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
249 | // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is | 246 | // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is |
250 | // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. | 247 | // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. |
251 | 248 | ||
252 | if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) | 249 | //if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) |
253 | { | 250 | //{ |
254 | ScenePresence avatarPresence = null; | 251 | // ScenePresence avatarPresence = null; |
255 | 252 | ||
256 | m_scene.TryGetScenePresence(agentID, out avatarPresence); | 253 | // m_scene.TryGetScenePresence(agentID, out avatarPresence); |
257 | 254 | ||
258 | if (avatarPresence != null) | 255 | // if (avatarPresence != null) |
259 | { | 256 | // { |
260 | bool lookup = false; | 257 | // bool lookup = false; |
261 | 258 | ||
262 | lock (cachedMapBlocks) | 259 | // lock (cachedMapBlocks) |
263 | { | 260 | // { |
264 | if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) | 261 | // if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) |
265 | { | 262 | // { |
266 | List<MapBlockData> mapBlocks; | 263 | // List<MapBlockData> mapBlocks; |
267 | 264 | ||
268 | mapBlocks = cachedMapBlocks; | 265 | // mapBlocks = cachedMapBlocks; |
269 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); | 266 | // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); |
270 | } | 267 | // } |
271 | else | 268 | // else |
272 | { | 269 | // { |
273 | lookup = true; | 270 | // lookup = true; |
274 | } | 271 | // } |
275 | } | 272 | // } |
276 | if (lookup) | 273 | // if (lookup) |
277 | { | 274 | // { |
278 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; | 275 | // List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; |
279 | 276 | ||
280 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | 277 | // List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
281 | (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, | 278 | // (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, |
282 | (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, | 279 | // (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, |
283 | (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, | 280 | // (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, |
284 | (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); | 281 | // (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); |
285 | foreach (GridRegion r in regions) | 282 | // foreach (GridRegion r in regions) |
286 | { | 283 | // { |
287 | MapBlockData block = new MapBlockData(); | 284 | // MapBlockData block = new MapBlockData(); |
288 | MapBlockFromGridRegion(block, r, 0); | 285 | // MapBlockFromGridRegion(block, r, 0); |
289 | mapBlocks.Add(block); | 286 | // mapBlocks.Add(block); |
290 | } | 287 | // } |
291 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); | 288 | // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); |
292 | 289 | ||
293 | lock (cachedMapBlocks) | 290 | // lock (cachedMapBlocks) |
294 | cachedMapBlocks = mapBlocks; | 291 | // cachedMapBlocks = mapBlocks; |
295 | 292 | ||
296 | cachedTime = Util.UnixTimeSinceEpoch(); | 293 | // cachedTime = Util.UnixTimeSinceEpoch(); |
297 | } | 294 | // } |
298 | } | 295 | // } |
299 | } | 296 | //} |
300 | 297 | ||
301 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); | 298 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); |
302 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); | 299 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); |
@@ -323,8 +320,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
323 | protected static OSDMapLayer GetOSDMapLayerResponse() | 320 | protected static OSDMapLayer GetOSDMapLayerResponse() |
324 | { | 321 | { |
325 | OSDMapLayer mapLayer = new OSDMapLayer(); | 322 | OSDMapLayer mapLayer = new OSDMapLayer(); |
326 | mapLayer.Right = 5000; | 323 | mapLayer.Right = 2048; |
327 | mapLayer.Top = 5000; | 324 | mapLayer.Top = 2048; |
328 | mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); | 325 | mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); |
329 | 326 | ||
330 | return mapLayer; | 327 | return mapLayer; |
@@ -353,6 +350,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
353 | { | 350 | { |
354 | m_rootAgents.Remove(AgentId); | 351 | m_rootAgents.Remove(AgentId); |
355 | } | 352 | } |
353 | lock (m_mapBlockRequestEvent) | ||
354 | { | ||
355 | if (m_mapBlockRequests.ContainsKey(AgentId)) | ||
356 | m_mapBlockRequests.Remove(AgentId); | ||
357 | } | ||
356 | } | 358 | } |
357 | #endregion | 359 | #endregion |
358 | 360 | ||
@@ -375,6 +377,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
375 | ThreadPriority.BelowNormal, | 377 | ThreadPriority.BelowNormal, |
376 | true, | 378 | true, |
377 | true); | 379 | true); |
380 | Watchdog.StartThread( | ||
381 | MapBlockSendThread, | ||
382 | string.Format("MapBlockSendThread ({0})", m_scene.RegionInfo.RegionName), | ||
383 | ThreadPriority.BelowNormal, | ||
384 | true, | ||
385 | true); | ||
378 | } | 386 | } |
379 | 387 | ||
380 | /// <summary> | 388 | /// <summary> |
@@ -390,7 +398,27 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
390 | st.itemtype=0; | 398 | st.itemtype=0; |
391 | st.regionhandle=0; | 399 | st.regionhandle=0; |
392 | 400 | ||
393 | requests.Enqueue(st); | 401 | lock (requests) |
402 | { | ||
403 | queueEvent.Set(); | ||
404 | requests.Enqueue(st); | ||
405 | } | ||
406 | |||
407 | MapBlockRequestData req = new MapBlockRequestData(); | ||
408 | |||
409 | req.client = null; | ||
410 | req.minX = 0; | ||
411 | req.maxX = 0; | ||
412 | req.minY = 0; | ||
413 | req.maxY = 0; | ||
414 | req.flags = 0; | ||
415 | |||
416 | lock (m_mapBlockRequestEvent) | ||
417 | { | ||
418 | m_mapBlockRequests[UUID.Zero] = new Queue<MapBlockRequestData>(); | ||
419 | m_mapBlockRequests[UUID.Zero].Enqueue(req); | ||
420 | m_mapBlockRequestEvent.Set(); | ||
421 | } | ||
394 | } | 422 | } |
395 | 423 | ||
396 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, | 424 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, |
@@ -541,12 +569,26 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
541 | /// </summary> | 569 | /// </summary> |
542 | public void process() | 570 | public void process() |
543 | { | 571 | { |
544 | //const int MAX_ASYNC_REQUESTS = 20; | 572 | const int MAX_ASYNC_REQUESTS = 20; |
545 | try | 573 | try |
546 | { | 574 | { |
547 | while (true) | 575 | while (true) |
548 | { | 576 | { |
549 | MapRequestState st = requests.Dequeue(1000); | 577 | MapRequestState st = new MapRequestState(); |
578 | bool valid = false; | ||
579 | queueEvent.WaitOne(); | ||
580 | lock (requests) | ||
581 | { | ||
582 | if (requests.Count > 0) | ||
583 | { | ||
584 | st = requests.Dequeue(); | ||
585 | valid = true; | ||
586 | } | ||
587 | if (requests.Count == 0) | ||
588 | queueEvent.Reset(); | ||
589 | } | ||
590 | if (!valid) | ||
591 | continue; | ||
550 | 592 | ||
551 | // end gracefully | 593 | // end gracefully |
552 | if (st.agentID == STOP_UUID) | 594 | if (st.agentID == STOP_UUID) |
@@ -564,13 +606,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
564 | if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) | 606 | if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) |
565 | { | 607 | { |
566 | while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break | 608 | while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break |
567 | Thread.Sleep(80); | 609 | Thread.Sleep(100); |
568 | 610 | ||
569 | RequestMapItemsDelegate d = RequestMapItemsAsync; | ||
570 | d.BeginInvoke(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle, RequestMapItemsCompleted, null); | ||
571 | //OSDMap response = RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); | ||
572 | //RequestMapItemsCompleted(response); | ||
573 | Interlocked.Increment(ref nAsyncRequests); | 611 | Interlocked.Increment(ref nAsyncRequests); |
612 | Util.FireAndForget(x => | ||
613 | { | ||
614 | RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); | ||
615 | }); | ||
574 | } | 616 | } |
575 | } | 617 | } |
576 | 618 | ||
@@ -586,147 +628,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
586 | Watchdog.RemoveThread(); | 628 | Watchdog.RemoveThread(); |
587 | } | 629 | } |
588 | 630 | ||
589 | const int MAX_ASYNC_REQUESTS = 20; | ||
590 | |||
591 | /// <summary> | 631 | /// <summary> |
592 | /// Enqueues the map item request into the services throttle processing thread | 632 | /// Enqueues the map item request into the processing thread |
593 | /// </summary> | 633 | /// </summary> |
594 | /// <param name="state"></param> | 634 | /// <param name="state"></param> |
595 | public void EnqueueMapItemRequest(MapRequestState st) | 635 | public void EnqueueMapItemRequest(MapRequestState state) |
596 | { | ||
597 | |||
598 | m_ServiceThrottle.Enqueue("map-item", st.regionhandle.ToString() + st.agentID.ToString(), delegate | ||
599 | { | ||
600 | if (st.agentID != UUID.Zero) | ||
601 | { | ||
602 | bool dorequest = true; | ||
603 | lock (m_rootAgents) | ||
604 | { | ||
605 | if (!m_rootAgents.Contains(st.agentID)) | ||
606 | dorequest = false; | ||
607 | } | ||
608 | |||
609 | if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) | ||
610 | { | ||
611 | if (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break | ||
612 | { | ||
613 | // AH!!! Recursive ! | ||
614 | // Put this request back in the queue and return | ||
615 | EnqueueMapItemRequest(st); | ||
616 | return; | ||
617 | } | ||
618 | |||
619 | RequestMapItemsDelegate d = RequestMapItemsAsync; | ||
620 | d.BeginInvoke(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle, RequestMapItemsCompleted, null); | ||
621 | //OSDMap response = RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); | ||
622 | //RequestMapItemsCompleted(response); | ||
623 | Interlocked.Increment(ref nAsyncRequests); | ||
624 | } | ||
625 | } | ||
626 | }); | ||
627 | } | ||
628 | |||
629 | /// <summary> | ||
630 | /// Sends the mapitem response to the IClientAPI | ||
631 | /// </summary> | ||
632 | /// <param name="response">The OSDMap Response for the mapitem</param> | ||
633 | private void RequestMapItemsCompleted(IAsyncResult iar) | ||
634 | { | 636 | { |
635 | AsyncResult result = (AsyncResult)iar; | 637 | lock (requests) |
636 | RequestMapItemsDelegate icon = (RequestMapItemsDelegate)result.AsyncDelegate; | ||
637 | |||
638 | OSDMap response = (OSDMap)icon.EndInvoke(iar); | ||
639 | |||
640 | Interlocked.Decrement(ref nAsyncRequests); | ||
641 | |||
642 | if (!response.ContainsKey("requestID")) | ||
643 | return; | ||
644 | |||
645 | UUID requestID = response["requestID"].AsUUID(); | ||
646 | |||
647 | if (requestID != UUID.Zero) | ||
648 | { | 638 | { |
649 | MapRequestState mrs = new MapRequestState(); | 639 | queueEvent.Set(); |
650 | mrs.agentID = UUID.Zero; | 640 | requests.Enqueue(state); |
651 | lock (m_openRequests) | ||
652 | { | ||
653 | if (m_openRequests.ContainsKey(requestID)) | ||
654 | { | ||
655 | mrs = m_openRequests[requestID]; | ||
656 | m_openRequests.Remove(requestID); | ||
657 | } | ||
658 | } | ||
659 | |||
660 | if (mrs.agentID != UUID.Zero) | ||
661 | { | ||
662 | ScenePresence av = null; | ||
663 | m_scene.TryGetScenePresence(mrs.agentID, out av); | ||
664 | if (av != null) | ||
665 | { | ||
666 | if (response.ContainsKey(mrs.itemtype.ToString())) | ||
667 | { | ||
668 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
669 | OSDArray itemarray = (OSDArray)response[mrs.itemtype.ToString()]; | ||
670 | for (int i = 0; i < itemarray.Count; i++) | ||
671 | { | ||
672 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
673 | mapItemReply mi = new mapItemReply(); | ||
674 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
675 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
676 | mi.id = mapitem["ID"].AsUUID(); | ||
677 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
678 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
679 | mi.name = mapitem["Name"].AsString(); | ||
680 | returnitems.Add(mi); | ||
681 | } | ||
682 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags); | ||
683 | } | ||
684 | |||
685 | // Service 7 (MAP_ITEM_LAND_FOR_SALE) | ||
686 | uint itemtype = 7; | ||
687 | |||
688 | if (response.ContainsKey(itemtype.ToString())) | ||
689 | { | ||
690 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
691 | OSDArray itemarray = (OSDArray)response[itemtype.ToString()]; | ||
692 | for (int i = 0; i < itemarray.Count; i++) | ||
693 | { | ||
694 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
695 | mapItemReply mi = new mapItemReply(); | ||
696 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
697 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
698 | mi.id = mapitem["ID"].AsUUID(); | ||
699 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
700 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
701 | mi.name = mapitem["Name"].AsString(); | ||
702 | returnitems.Add(mi); | ||
703 | } | ||
704 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); | ||
705 | } | ||
706 | |||
707 | // Service 1 (MAP_ITEM_TELEHUB) | ||
708 | itemtype = 1; | ||
709 | |||
710 | if (response.ContainsKey(itemtype.ToString())) | ||
711 | { | ||
712 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
713 | OSDArray itemarray = (OSDArray)response[itemtype.ToString()]; | ||
714 | for (int i = 0; i < itemarray.Count; i++) | ||
715 | { | ||
716 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
717 | mapItemReply mi = new mapItemReply(); | ||
718 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
719 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
720 | mi.id = mapitem["ID"].AsUUID(); | ||
721 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
722 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
723 | mi.name = mapitem["Name"].AsString(); | ||
724 | returnitems.Add(mi); | ||
725 | } | ||
726 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); | ||
727 | } | ||
728 | } | ||
729 | } | ||
730 | } | 641 | } |
731 | } | 642 | } |
732 | 643 | ||
@@ -753,8 +664,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
753 | EnqueueMapItemRequest(st); | 664 | EnqueueMapItemRequest(st); |
754 | } | 665 | } |
755 | 666 | ||
756 | private delegate OSDMap RequestMapItemsDelegate(UUID id, uint flags, | ||
757 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle); | ||
758 | /// <summary> | 667 | /// <summary> |
759 | /// Does the actual remote mapitem request | 668 | /// Does the actual remote mapitem request |
760 | /// This should be called from an asynchronous thread | 669 | /// This should be called from an asynchronous thread |
@@ -769,7 +678,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
769 | /// <param name="itemtype">passed in from packet</param> | 678 | /// <param name="itemtype">passed in from packet</param> |
770 | /// <param name="regionhandle">Region we're looking up</param> | 679 | /// <param name="regionhandle">Region we're looking up</param> |
771 | /// <returns></returns> | 680 | /// <returns></returns> |
772 | private OSDMap RequestMapItemsAsync(UUID id, uint flags, | 681 | private void RequestMapItemsAsync(UUID id, uint flags, |
773 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) | 682 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) |
774 | { | 683 | { |
775 | // m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); | 684 | // m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); |
@@ -792,7 +701,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
792 | } | 701 | } |
793 | 702 | ||
794 | if (blacklisted) | 703 | if (blacklisted) |
795 | return new OSDMap(); | 704 | { |
705 | Interlocked.Decrement(ref nAsyncRequests); | ||
706 | return; | ||
707 | } | ||
796 | 708 | ||
797 | UUID requestID = UUID.Random(); | 709 | UUID requestID = UUID.Random(); |
798 | lock (m_cachedRegionMapItemsAddress) | 710 | lock (m_cachedRegionMapItemsAddress) |
@@ -800,6 +712,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
800 | if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) | 712 | if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) |
801 | httpserver = m_cachedRegionMapItemsAddress[regionhandle]; | 713 | httpserver = m_cachedRegionMapItemsAddress[regionhandle]; |
802 | } | 714 | } |
715 | |||
803 | if (httpserver.Length == 0) | 716 | if (httpserver.Length == 0) |
804 | { | 717 | { |
805 | uint x = 0, y = 0; | 718 | uint x = 0, y = 0; |
@@ -844,18 +757,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
844 | 757 | ||
845 | // Can't find the http server | 758 | // Can't find the http server |
846 | if (httpserver.Length == 0 || blacklisted) | 759 | if (httpserver.Length == 0 || blacklisted) |
847 | return new OSDMap(); | 760 | { |
848 | 761 | Interlocked.Decrement(ref nAsyncRequests); | |
849 | MapRequestState mrs = new MapRequestState(); | 762 | return; |
850 | mrs.agentID = id; | 763 | } |
851 | mrs.EstateID = EstateID; | ||
852 | mrs.flags = flags; | ||
853 | mrs.godlike = godlike; | ||
854 | mrs.itemtype=itemtype; | ||
855 | mrs.regionhandle = regionhandle; | ||
856 | |||
857 | lock (m_openRequests) | ||
858 | m_openRequests.Add(requestID, mrs); | ||
859 | 764 | ||
860 | WebRequest mapitemsrequest = null; | 765 | WebRequest mapitemsrequest = null; |
861 | try | 766 | try |
@@ -865,7 +770,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
865 | catch (Exception e) | 770 | catch (Exception e) |
866 | { | 771 | { |
867 | m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e); | 772 | m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e); |
868 | return new OSDMap(); | 773 | Interlocked.Decrement(ref nAsyncRequests); |
774 | return; | ||
869 | } | 775 | } |
870 | 776 | ||
871 | mapitemsrequest.Method = "POST"; | 777 | mapitemsrequest.Method = "POST"; |
@@ -890,7 +796,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
890 | catch (WebException ex) | 796 | catch (WebException ex) |
891 | { | 797 | { |
892 | m_log.WarnFormat("[WORLD MAP]: Bad send on GetMapItems {0}", ex.Message); | 798 | m_log.WarnFormat("[WORLD MAP]: Bad send on GetMapItems {0}", ex.Message); |
893 | responseMap["connect"] = OSD.FromBoolean(false); | ||
894 | lock (m_blacklistedurls) | 799 | lock (m_blacklistedurls) |
895 | { | 800 | { |
896 | if (!m_blacklistedurls.ContainsKey(httpserver)) | 801 | if (!m_blacklistedurls.ContainsKey(httpserver)) |
@@ -899,13 +804,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
899 | 804 | ||
900 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); | 805 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); |
901 | 806 | ||
902 | return responseMap; | 807 | Interlocked.Decrement(ref nAsyncRequests); |
808 | return; | ||
903 | } | 809 | } |
904 | catch | 810 | catch |
905 | { | 811 | { |
906 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); | 812 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); |
907 | responseMap["connect"] = OSD.FromBoolean(false); | 813 | Interlocked.Decrement(ref nAsyncRequests); |
908 | return responseMap; | 814 | return; |
909 | } | 815 | } |
910 | finally | 816 | finally |
911 | { | 817 | { |
@@ -914,26 +820,24 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
914 | } | 820 | } |
915 | 821 | ||
916 | string response_mapItems_reply = null; | 822 | string response_mapItems_reply = null; |
917 | { | 823 | { // get the response |
824 | StreamReader sr = null; | ||
918 | try | 825 | try |
919 | { | 826 | { |
920 | using (WebResponse webResponse = mapitemsrequest.GetResponse()) | 827 | WebResponse webResponse = mapitemsrequest.GetResponse(); |
828 | if (webResponse != null) | ||
921 | { | 829 | { |
922 | if (webResponse != null) | 830 | sr = new StreamReader(webResponse.GetResponseStream()); |
923 | { | 831 | response_mapItems_reply = sr.ReadToEnd().Trim(); |
924 | using (Stream s = webResponse.GetResponseStream()) | 832 | } |
925 | using (StreamReader sr = new StreamReader(s)) | 833 | else |
926 | response_mapItems_reply = sr.ReadToEnd().Trim(); | 834 | { |
927 | } | 835 | Interlocked.Decrement(ref nAsyncRequests); |
928 | else | 836 | return; |
929 | { | 837 | } |
930 | return new OSDMap(); | ||
931 | } | ||
932 | } | ||
933 | } | 838 | } |
934 | catch (WebException) | 839 | catch (WebException) |
935 | { | 840 | { |
936 | responseMap["connect"] = OSD.FromBoolean(false); | ||
937 | lock (m_blacklistedurls) | 841 | lock (m_blacklistedurls) |
938 | { | 842 | { |
939 | if (!m_blacklistedurls.ContainsKey(httpserver)) | 843 | if (!m_blacklistedurls.ContainsKey(httpserver)) |
@@ -942,19 +846,25 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
942 | 846 | ||
943 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); | 847 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); |
944 | 848 | ||
945 | return responseMap; | 849 | Interlocked.Decrement(ref nAsyncRequests); |
850 | return; | ||
946 | } | 851 | } |
947 | catch | 852 | catch |
948 | { | 853 | { |
949 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); | 854 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); |
950 | responseMap["connect"] = OSD.FromBoolean(false); | ||
951 | lock (m_blacklistedregions) | 855 | lock (m_blacklistedregions) |
952 | { | 856 | { |
953 | if (!m_blacklistedregions.ContainsKey(regionhandle)) | 857 | if (!m_blacklistedregions.ContainsKey(regionhandle)) |
954 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); | 858 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); |
955 | } | 859 | } |
956 | 860 | ||
957 | return responseMap; | 861 | Interlocked.Decrement(ref nAsyncRequests); |
862 | return; | ||
863 | } | ||
864 | finally | ||
865 | { | ||
866 | if (sr != null) | ||
867 | sr.Close(); | ||
958 | } | 868 | } |
959 | 869 | ||
960 | OSD rezResponse = null; | 870 | OSD rezResponse = null; |
@@ -968,15 +878,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
968 | catch (Exception ex) | 878 | catch (Exception ex) |
969 | { | 879 | { |
970 | m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); | 880 | m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); |
971 | responseMap["connect"] = OSD.FromBoolean(false); | ||
972 | |||
973 | lock (m_blacklistedregions) | 881 | lock (m_blacklistedregions) |
974 | { | 882 | { |
975 | if (!m_blacklistedregions.ContainsKey(regionhandle)) | 883 | if (!m_blacklistedregions.ContainsKey(regionhandle)) |
976 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); | 884 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); |
977 | } | 885 | } |
978 | 886 | ||
979 | return responseMap; | 887 | Interlocked.Decrement(ref nAsyncRequests); |
888 | return; | ||
980 | } | 889 | } |
981 | } | 890 | } |
982 | 891 | ||
@@ -990,7 +899,78 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
990 | } | 899 | } |
991 | } | 900 | } |
992 | 901 | ||
993 | return responseMap; | 902 | Interlocked.Decrement(ref nAsyncRequests); |
903 | |||
904 | if (id != UUID.Zero) | ||
905 | { | ||
906 | ScenePresence av = null; | ||
907 | m_scene.TryGetScenePresence(id, out av); | ||
908 | if (av != null) | ||
909 | { | ||
910 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
911 | { | ||
912 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
913 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
914 | for (int i = 0; i < itemarray.Count; i++) | ||
915 | { | ||
916 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
917 | mapItemReply mi = new mapItemReply(); | ||
918 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
919 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
920 | mi.id = mapitem["ID"].AsUUID(); | ||
921 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
922 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
923 | mi.name = mapitem["Name"].AsString(); | ||
924 | returnitems.Add(mi); | ||
925 | } | ||
926 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
927 | } | ||
928 | |||
929 | // Service 7 (MAP_ITEM_LAND_FOR_SALE) | ||
930 | itemtype = 7; | ||
931 | |||
932 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
933 | { | ||
934 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
935 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
936 | for (int i = 0; i < itemarray.Count; i++) | ||
937 | { | ||
938 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
939 | mapItemReply mi = new mapItemReply(); | ||
940 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
941 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
942 | mi.id = mapitem["ID"].AsUUID(); | ||
943 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
944 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
945 | mi.name = mapitem["Name"].AsString(); | ||
946 | returnitems.Add(mi); | ||
947 | } | ||
948 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
949 | } | ||
950 | |||
951 | // Service 1 (MAP_ITEM_TELEHUB) | ||
952 | itemtype = 1; | ||
953 | |||
954 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
955 | { | ||
956 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
957 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
958 | for (int i = 0; i < itemarray.Count; i++) | ||
959 | { | ||
960 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
961 | mapItemReply mi = new mapItemReply(); | ||
962 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
963 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
964 | mi.id = mapitem["ID"].AsUUID(); | ||
965 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
966 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
967 | mi.name = mapitem["Name"].AsString(); | ||
968 | returnitems.Add(mi); | ||
969 | } | ||
970 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
971 | } | ||
972 | } | ||
973 | } | ||
994 | } | 974 | } |
995 | 975 | ||
996 | /// <summary> | 976 | /// <summary> |
@@ -1000,7 +980,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1000 | /// <param name="minY"></param> | 980 | /// <param name="minY"></param> |
1001 | /// <param name="maxX"></param> | 981 | /// <param name="maxX"></param> |
1002 | /// <param name="maxY"></param> | 982 | /// <param name="maxY"></param> |
1003 | public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 983 | public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) |
1004 | { | 984 | { |
1005 | //m_log.ErrorFormat("[YYY] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag); | 985 | //m_log.ErrorFormat("[YYY] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag); |
1006 | if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible | 986 | if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible |
@@ -1053,21 +1033,91 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1053 | 1033 | ||
1054 | protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 1034 | protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) |
1055 | { | 1035 | { |
1036 | MapBlockRequestData req = new MapBlockRequestData(); | ||
1037 | |||
1038 | req.client = remoteClient; | ||
1039 | req.minX = minX; | ||
1040 | req.maxX = maxX; | ||
1041 | req.minY = minY; | ||
1042 | req.maxY = maxY; | ||
1043 | req.flags = flag; | ||
1044 | |||
1045 | lock (m_mapBlockRequestEvent) | ||
1046 | { | ||
1047 | if (!m_mapBlockRequests.ContainsKey(remoteClient.AgentId)) | ||
1048 | m_mapBlockRequests[remoteClient.AgentId] = new Queue<MapBlockRequestData>(); | ||
1049 | m_mapBlockRequests[remoteClient.AgentId].Enqueue(req); | ||
1050 | m_mapBlockRequestEvent.Set(); | ||
1051 | } | ||
1052 | |||
1053 | return new List<MapBlockData>(); | ||
1054 | } | ||
1055 | |||
1056 | protected void MapBlockSendThread() | ||
1057 | { | ||
1058 | while (true) | ||
1059 | { | ||
1060 | List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>(); | ||
1061 | |||
1062 | m_mapBlockRequestEvent.WaitOne(); | ||
1063 | lock (m_mapBlockRequestEvent) | ||
1064 | { | ||
1065 | int total = 0; | ||
1066 | foreach (Queue<MapBlockRequestData> q in m_mapBlockRequests.Values) | ||
1067 | { | ||
1068 | if (q.Count > 0) | ||
1069 | thisRunData.Add(q.Dequeue()); | ||
1070 | |||
1071 | total += q.Count; | ||
1072 | } | ||
1073 | |||
1074 | if (total == 0) | ||
1075 | m_mapBlockRequestEvent.Reset(); | ||
1076 | } | ||
1077 | |||
1078 | foreach (MapBlockRequestData req in thisRunData) | ||
1079 | { | ||
1080 | // Null client stops thread | ||
1081 | if (req.client == null) | ||
1082 | return; | ||
1083 | |||
1084 | GetAndSendBlocksInternal(req.client, req.minX, req.minY, req.maxX, req.maxY, req.flags); | ||
1085 | } | ||
1086 | |||
1087 | Thread.Sleep(50); | ||
1088 | } | ||
1089 | } | ||
1090 | |||
1091 | protected virtual List<MapBlockData> GetAndSendBlocksInternal(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | ||
1092 | { | ||
1093 | List<MapBlockData> allBlocks = new List<MapBlockData>(); | ||
1056 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); | 1094 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); |
1057 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | 1095 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
1058 | (minX - 4) * (int)Constants.RegionSize, | 1096 | minX * (int)Constants.RegionSize, |
1059 | (maxX + 4) * (int)Constants.RegionSize, | 1097 | maxX * (int)Constants.RegionSize, |
1060 | (minY - 4) * (int)Constants.RegionSize, | 1098 | minY * (int)Constants.RegionSize, |
1061 | (maxY + 4) * (int)Constants.RegionSize); | 1099 | maxY * (int)Constants.RegionSize); |
1100 | // (minX - 4) * (int)Constants.RegionSize, | ||
1101 | // (maxX + 4) * (int)Constants.RegionSize, | ||
1102 | // (minY - 4) * (int)Constants.RegionSize, | ||
1103 | // (maxY + 4) * (int)Constants.RegionSize); | ||
1062 | foreach (GridRegion r in regions) | 1104 | foreach (GridRegion r in regions) |
1063 | { | 1105 | { |
1064 | MapBlockData block = new MapBlockData(); | 1106 | MapBlockData block = new MapBlockData(); |
1065 | MapBlockFromGridRegion(block, r, flag); | 1107 | MapBlockFromGridRegion(block, r, flag); |
1066 | mapBlocks.Add(block); | 1108 | mapBlocks.Add(block); |
1109 | allBlocks.Add(block); | ||
1110 | if (mapBlocks.Count >= 10) | ||
1111 | { | ||
1112 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | ||
1113 | mapBlocks.Clear(); | ||
1114 | Thread.Sleep(50); | ||
1115 | } | ||
1067 | } | 1116 | } |
1068 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | 1117 | if (mapBlocks.Count > 0) |
1118 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | ||
1069 | 1119 | ||
1070 | return mapBlocks; | 1120 | return allBlocks; |
1071 | } | 1121 | } |
1072 | 1122 | ||
1073 | protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) | 1123 | protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) |
@@ -1301,7 +1351,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1301 | } | 1351 | } |
1302 | else | 1352 | else |
1303 | { | 1353 | { |
1304 | OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); | 1354 | OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount()); |
1305 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 1355 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
1306 | { | 1356 | { |
1307 | OSDMap responsemapdata = new OSDMap(); | 1357 | OSDMap responsemapdata = new OSDMap(); |
@@ -1477,6 +1527,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1477 | { | 1527 | { |
1478 | m_rootAgents.Remove(avatar.UUID); | 1528 | m_rootAgents.Remove(avatar.UUID); |
1479 | } | 1529 | } |
1530 | |||
1531 | lock (m_mapBlockRequestEvent) | ||
1532 | { | ||
1533 | if (m_mapBlockRequests.ContainsKey(avatar.UUID)) | ||
1534 | m_mapBlockRequests.Remove(avatar.UUID); | ||
1535 | } | ||
1480 | } | 1536 | } |
1481 | 1537 | ||
1482 | public void OnRegionUp(GridRegion otherRegion) | 1538 | public void OnRegionUp(GridRegion otherRegion) |
@@ -1521,9 +1577,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1521 | Color background = Color.FromArgb(0, 0, 0, 0); | 1577 | Color background = Color.FromArgb(0, 0, 0, 0); |
1522 | SolidBrush transparent = new SolidBrush(background); | 1578 | SolidBrush transparent = new SolidBrush(background); |
1523 | Graphics g = Graphics.FromImage(overlay); | 1579 | Graphics g = Graphics.FromImage(overlay); |
1524 | g.FillRectangle(transparent, 0, 0, 256, 256); | 1580 | g.FillRectangle(transparent, 0, 0, 255, 255); |
1525 | 1581 | ||
1526 | SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); | 1582 | SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); |
1583 | Pen grey = new Pen(Color.FromArgb(255, 92, 92, 92)); | ||
1527 | 1584 | ||
1528 | foreach (ILandObject land in parcels) | 1585 | foreach (ILandObject land in parcels) |
1529 | { | 1586 | { |
@@ -1531,8 +1588,42 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1531 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) | 1588 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) |
1532 | { | 1589 | { |
1533 | landForSale = true; | 1590 | landForSale = true; |
1591 | |||
1592 | bool[,] landBitmap = land.GetLandBitmap(); | ||
1593 | |||
1594 | for (int x = 0 ; x < 64 ; x++) | ||
1595 | { | ||
1596 | for (int y = 0 ; y < 64 ; y++) | ||
1597 | { | ||
1598 | if (landBitmap[x, y]) | ||
1599 | { | ||
1600 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | ||
1601 | |||
1602 | if (x > 0) | ||
1603 | { | ||
1604 | if ((saleBitmap[x - 1, y] || landBitmap[x - 1, y]) == false) | ||
1605 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4, 255 - (y * 4)); | ||
1606 | } | ||
1607 | if (y > 0) | ||
1608 | { | ||
1609 | if ((saleBitmap[x, y-1] || landBitmap[x, y-1]) == false) | ||
1610 | g.DrawLine(grey, x * 4, 255 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1611 | } | ||
1612 | if (x < 63) | ||
1613 | { | ||
1614 | if ((saleBitmap[x + 1, y] || landBitmap[x + 1, y]) == false) | ||
1615 | g.DrawLine(grey, x * 4 + 3, 252 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1616 | } | ||
1617 | if (y < 63) | ||
1618 | { | ||
1619 | if ((saleBitmap[x, y + 1] || landBitmap[x, y + 1]) == false) | ||
1620 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4 + 3, 252 - (y * 4)); | ||
1621 | } | ||
1622 | } | ||
1623 | } | ||
1624 | } | ||
1534 | 1625 | ||
1535 | saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap()); | 1626 | saleBitmap = land.MergeLandBitmaps(saleBitmap, landBitmap); |
1536 | } | 1627 | } |
1537 | } | 1628 | } |
1538 | 1629 | ||
@@ -1544,15 +1635,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1544 | 1635 | ||
1545 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); | 1636 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); |
1546 | 1637 | ||
1547 | for (int x = 0 ; x < 64 ; x++) | ||
1548 | { | ||
1549 | for (int y = 0 ; y < 64 ; y++) | ||
1550 | { | ||
1551 | if (saleBitmap[x, y]) | ||
1552 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | ||
1553 | } | ||
1554 | } | ||
1555 | |||
1556 | try | 1638 | try |
1557 | { | 1639 | { |
1558 | return OpenJPEG.EncodeFromImage(overlay, true); | 1640 | return OpenJPEG.EncodeFromImage(overlay, true); |
@@ -1574,4 +1656,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1574 | public uint itemtype; | 1656 | public uint itemtype; |
1575 | public ulong regionhandle; | 1657 | public ulong regionhandle; |
1576 | } | 1658 | } |
1659 | |||
1660 | public struct MapBlockRequestData | ||
1661 | { | ||
1662 | public IClientAPI client; | ||
1663 | public int minX; | ||
1664 | public int minY; | ||
1665 | public int maxX; | ||
1666 | public int maxY; | ||
1667 | public uint flags; | ||
1668 | } | ||
1577 | } | 1669 | } |