diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
13 files changed, 892 insertions, 521 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 32d245f..fcfdf7c 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 121b2aa..a5f5749 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 | { |
@@ -1249,6 +1259,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1249 | flags |= RegionFlags.AllowParcelChanges; | 1259 | flags |= RegionFlags.AllowParcelChanges; |
1250 | if (Scene.RegionInfo.RegionSettings.BlockShowInSearch) | 1260 | if (Scene.RegionInfo.RegionSettings.BlockShowInSearch) |
1251 | flags |= RegionFlags.BlockParcelSearch; | 1261 | flags |= RegionFlags.BlockParcelSearch; |
1262 | if (Scene.RegionInfo.RegionSettings.GodBlockSearch) | ||
1263 | flags |= (RegionFlags)(1 << 11); | ||
1264 | if (Scene.RegionInfo.RegionSettings.Casino) | ||
1265 | flags |= (RegionFlags)(1 << 10); | ||
1252 | 1266 | ||
1253 | if (Scene.RegionInfo.RegionSettings.FixedSun) | 1267 | if (Scene.RegionInfo.RegionSettings.FixedSun) |
1254 | flags |= RegionFlags.SunFixed; | 1268 | flags |= RegionFlags.SunFixed; |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 1789d6d..dbc9296 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -89,19 +89,21 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
89 | /// <value> | 89 | /// <value> |
90 | /// Land objects keyed by local id | 90 | /// Land objects keyed by local id |
91 | /// </value> | 91 | /// </value> |
92 | private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); | 92 | // private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); |
93 | |||
94 | //ubit: removed the readonly so i can move it around | ||
95 | private Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); | ||
93 | 96 | ||
94 | private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; | 97 | private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; |
95 | 98 | ||
96 | private bool m_allowedForcefulBans = true; | 99 | private bool m_allowedForcefulBans = true; |
100 | private UUID DefaultGodParcelGroup; | ||
101 | private string DefaultGodParcelName; | ||
97 | 102 | ||
98 | // caches ExtendedLandData | 103 | // caches ExtendedLandData |
99 | private Cache parcelInfoCache; | 104 | private Cache parcelInfoCache; |
100 | 105 | private Dictionary<UUID, Vector3> forcedPosition = | |
101 | /// <summary> | 106 | new Dictionary<UUID, Vector3>(); |
102 | /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions. | ||
103 | /// </summary> | ||
104 | private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>(); | ||
105 | 107 | ||
106 | #region INonSharedRegionModule Members | 108 | #region INonSharedRegionModule Members |
107 | 109 | ||
@@ -112,6 +114,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
112 | 114 | ||
113 | public void Initialise(IConfigSource source) | 115 | public void Initialise(IConfigSource source) |
114 | { | 116 | { |
117 | IConfig cnf = source.Configs["LandManagement"]; | ||
118 | if (cnf != null) | ||
119 | { | ||
120 | DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString())); | ||
121 | DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel"); | ||
122 | } | ||
115 | } | 123 | } |
116 | 124 | ||
117 | public void AddRegion(Scene scene) | 125 | public void AddRegion(Scene scene) |
@@ -165,13 +173,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
165 | m_scene.UnregisterModuleCommander(m_commander.Name); | 173 | m_scene.UnregisterModuleCommander(m_commander.Name); |
166 | } | 174 | } |
167 | 175 | ||
168 | // private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason) | ||
169 | // { | ||
170 | // ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y); | ||
171 | // reason = "You are not allowed to enter this sim."; | ||
172 | // return nearestParcel != null; | ||
173 | // } | ||
174 | |||
175 | /// <summary> | 176 | /// <summary> |
176 | /// Processes commandline input. Do not call directly. | 177 | /// Processes commandline input. Do not call directly. |
177 | /// </summary> | 178 | /// </summary> |
@@ -216,7 +217,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
216 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; | 217 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; |
217 | client.OnSetStartLocationRequest += ClientOnSetHome; | 218 | client.OnSetStartLocationRequest += ClientOnSetHome; |
218 | 219 | ||
219 | |||
220 | EntityBase presenceEntity; | 220 | EntityBase presenceEntity; |
221 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) | 221 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) |
222 | { | 222 | { |
@@ -232,48 +232,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
232 | 232 | ||
233 | void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | 233 | void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) |
234 | { | 234 | { |
235 | //If we are forcing a position for them to go | ||
236 | if (forcedPosition.ContainsKey(remoteClient.AgentId)) | ||
237 | { | ||
238 | ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId); | ||
239 | |||
240 | //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND | ||
241 | //When the avatar walks into a ban line on the ground, it prevents getting stuck | ||
242 | agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
243 | |||
244 | //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines | ||
245 | if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2) | ||
246 | { | ||
247 | // m_log.DebugFormat( | ||
248 | // "[LAND MANAGEMENT MODULE]: Stopping force position of {0} because {1} is close enough to {2}", | ||
249 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]); | ||
250 | |||
251 | forcedPosition.Remove(remoteClient.AgentId); | ||
252 | } | ||
253 | //if we are far away, teleport | ||
254 | else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3) | ||
255 | { | ||
256 | Vector3 forcePosition = forcedPosition[remoteClient.AgentId]; | ||
257 | // m_log.DebugFormat( | ||
258 | // "[LAND MANAGEMENT MODULE]: Teleporting out {0} because {1} is too far from avatar position {2}", | ||
259 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcePosition); | ||
260 | |||
261 | m_scene.RequestTeleportLocation(remoteClient, m_scene.RegionInfo.RegionHandle, | ||
262 | forcePosition, clientAvatar.Lookat, (uint)Constants.TeleportFlags.ForceRedirect); | ||
263 | |||
264 | forcedPosition.Remove(remoteClient.AgentId); | ||
265 | } | ||
266 | else | ||
267 | { | ||
268 | // m_log.DebugFormat( | ||
269 | // "[LAND MANAGEMENT MODULE]: Forcing {0} from {1} to {2}", | ||
270 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]); | ||
271 | |||
272 | //Forces them toward the forced position we want if they aren't there yet | ||
273 | agentData.UseClientAgentPosition = true; | ||
274 | agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId]; | ||
275 | } | ||
276 | } | ||
277 | } | 235 | } |
278 | 236 | ||
279 | public void Close() | 237 | public void Close() |
@@ -298,6 +256,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
298 | { | 256 | { |
299 | LandData newData = data.Copy(); | 257 | LandData newData = data.Copy(); |
300 | newData.LocalID = local_id; | 258 | newData.LocalID = local_id; |
259 | ILandObject landobj = null; | ||
301 | 260 | ||
302 | ILandObject land; | 261 | ILandObject land; |
303 | lock (m_landList) | 262 | lock (m_landList) |
@@ -337,14 +296,14 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
337 | protected ILandObject CreateDefaultParcel() | 296 | protected ILandObject CreateDefaultParcel() |
338 | { | 297 | { |
339 | m_log.DebugFormat( | 298 | m_log.DebugFormat( |
340 | "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); | 299 | "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); |
341 | 300 | ||
342 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); | 301 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); |
343 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | 302 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); |
344 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 303 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
345 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); | 304 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); |
346 | 305 | ||
347 | return AddLandObject(fullSimParcel); | 306 | return AddLandObject(fullSimParcel); |
348 | } | 307 | } |
349 | 308 | ||
350 | public List<ILandObject> AllParcels() | 309 | public List<ILandObject> AllParcels() |
@@ -393,10 +352,16 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
393 | private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) | 352 | private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) |
394 | { | 353 | { |
395 | if (m_scene.Permissions.IsGod(avatar.UUID)) return; | 354 | if (m_scene.Permissions.IsGod(avatar.UUID)) return; |
396 | if (position.HasValue) | 355 | |
397 | { | 356 | if (!position.HasValue) |
398 | forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; | 357 | return; |
399 | } | 358 | |
359 | bool isFlying = avatar.PhysicsActor.Flying; | ||
360 | avatar.RemoveFromPhysicalScene(); | ||
361 | |||
362 | avatar.AbsolutePosition = (Vector3)position; | ||
363 | |||
364 | avatar.AddToPhysicalScene(isFlying); | ||
400 | } | 365 | } |
401 | 366 | ||
402 | public void SendYouAreRestrictedNotice(ScenePresence avatar) | 367 | public void SendYouAreRestrictedNotice(ScenePresence avatar) |
@@ -416,29 +381,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
416 | } | 381 | } |
417 | 382 | ||
418 | if (parcelAvatarIsEntering != null) | 383 | if (parcelAvatarIsEntering != null) |
419 | { | 384 | EnforceBans(parcelAvatarIsEntering, avatar); |
420 | if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT) | ||
421 | { | ||
422 | if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID)) | ||
423 | { | ||
424 | SendYouAreBannedNotice(avatar); | ||
425 | ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); | ||
426 | } | ||
427 | else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID)) | ||
428 | { | ||
429 | SendYouAreRestrictedNotice(avatar); | ||
430 | ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); | ||
431 | } | ||
432 | else | ||
433 | { | ||
434 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; | ||
435 | } | ||
436 | } | ||
437 | else | ||
438 | { | ||
439 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; | ||
440 | } | ||
441 | } | ||
442 | } | 385 | } |
443 | } | 386 | } |
444 | 387 | ||
@@ -467,30 +410,51 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
467 | 410 | ||
468 | public void SendLandUpdate(ScenePresence avatar, bool force) | 411 | public void SendLandUpdate(ScenePresence avatar, bool force) |
469 | { | 412 | { |
413 | |||
414 | /* stop sendind same data twice | ||
415 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), | ||
416 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); | ||
417 | |||
418 | if (over != null) | ||
419 | { | ||
420 | |||
421 | if (force) | ||
422 | { | ||
423 | if (!avatar.IsChildAgent) | ||
424 | { | ||
425 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
426 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
427 | m_scene.RegionInfo.RegionID); | ||
428 | } | ||
429 | } | ||
430 | |||
431 | if (avatar.currentParcelUUID != over.LandData.GlobalID) | ||
432 | { | ||
433 | if (!avatar.IsChildAgent) | ||
434 | { | ||
435 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
436 | avatar.currentParcelUUID = over.LandData.GlobalID; | ||
437 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
438 | m_scene.RegionInfo.RegionID); | ||
439 | } | ||
440 | } | ||
441 | */ | ||
442 | if (avatar.IsChildAgent) | ||
443 | return; | ||
444 | |||
470 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), | 445 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), |
471 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); | 446 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); |
472 | 447 | ||
473 | if (over != null) | 448 | if (over != null) |
474 | { | 449 | { |
475 | if (force) | 450 | bool NotsameID = (avatar.currentParcelUUID != over.LandData.GlobalID); |
476 | { | 451 | if (force || NotsameID) |
477 | if (!avatar.IsChildAgent) | ||
478 | { | ||
479 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
480 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
481 | m_scene.RegionInfo.RegionID); | ||
482 | } | ||
483 | } | ||
484 | |||
485 | if (avatar.currentParcelUUID != over.LandData.GlobalID) | ||
486 | { | 452 | { |
487 | if (!avatar.IsChildAgent) | 453 | over.SendLandUpdateToClient(avatar.ControllingClient); |
488 | { | 454 | if (NotsameID) |
489 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
490 | avatar.currentParcelUUID = over.LandData.GlobalID; | 455 | avatar.currentParcelUUID = over.LandData.GlobalID; |
491 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | 456 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, |
492 | m_scene.RegionInfo.RegionID); | 457 | m_scene.RegionInfo.RegionID); |
493 | } | ||
494 | } | 458 | } |
495 | } | 459 | } |
496 | } | 460 | } |
@@ -542,6 +506,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
542 | //when we are finally in a safe place, lets release the forced position lock | 506 | //when we are finally in a safe place, lets release the forced position lock |
543 | forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); | 507 | forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); |
544 | } | 508 | } |
509 | EnforceBans(parcel, clientAvatar); | ||
545 | } | 510 | } |
546 | } | 511 | } |
547 | 512 | ||
@@ -692,27 +657,28 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
692 | /// </summary> | 657 | /// </summary> |
693 | public void Clear(bool setupDefaultParcel) | 658 | public void Clear(bool setupDefaultParcel) |
694 | { | 659 | { |
695 | List<ILandObject> parcels; | 660 | Dictionary<int, ILandObject> landworkList; |
661 | // move to work pointer since we are deleting it all | ||
696 | lock (m_landList) | 662 | lock (m_landList) |
697 | { | 663 | { |
698 | parcels = new List<ILandObject>(m_landList.Values); | 664 | landworkList = m_landList; |
665 | m_landList = new Dictionary<int, ILandObject>(); | ||
699 | } | 666 | } |
700 | 667 | ||
701 | foreach (ILandObject lo in parcels) | 668 | // this 2 methods have locks (now) |
669 | ResetSimLandObjects(); | ||
670 | |||
671 | if (setupDefaultParcel) | ||
672 | CreateDefaultParcel(); | ||
673 | |||
674 | // fire outside events unlocked | ||
675 | foreach (ILandObject lo in landworkList.Values) | ||
702 | { | 676 | { |
703 | //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); | 677 | //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); |
704 | m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); | 678 | m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); |
705 | } | 679 | } |
680 | landworkList.Clear(); | ||
706 | 681 | ||
707 | lock (m_landList) | ||
708 | { | ||
709 | m_landList.Clear(); | ||
710 | |||
711 | ResetSimLandObjects(); | ||
712 | } | ||
713 | |||
714 | if (setupDefaultParcel) | ||
715 | CreateDefaultParcel(); | ||
716 | } | 682 | } |
717 | 683 | ||
718 | private void performFinalLandJoin(ILandObject master, ILandObject slave) | 684 | private void performFinalLandJoin(ILandObject master, ILandObject slave) |
@@ -759,7 +725,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
759 | int x; | 725 | int x; |
760 | int y; | 726 | int y; |
761 | 727 | ||
762 | if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) | 728 | if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0) |
763 | return null; | 729 | return null; |
764 | 730 | ||
765 | try | 731 | try |
@@ -809,14 +775,13 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
809 | { | 775 | { |
810 | try | 776 | try |
811 | { | 777 | { |
812 | return m_landList[m_landIDList[x / 4, y / 4]]; | 778 | //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) |
779 | return m_landList[m_landIDList[x / 4, y / 4]]; | ||
780 | //else | ||
781 | // return null; | ||
813 | } | 782 | } |
814 | catch (IndexOutOfRangeException) | 783 | catch (IndexOutOfRangeException) |
815 | { | 784 | { |
816 | // m_log.WarnFormat( | ||
817 | // "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}", | ||
818 | // x, y, m_scene.RegionInfo.RegionName); | ||
819 | |||
820 | return null; | 785 | return null; |
821 | } | 786 | } |
822 | } | 787 | } |
@@ -975,6 +940,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
975 | newLand.LandData.Name = newLand.LandData.Name; | 940 | newLand.LandData.Name = newLand.LandData.Name; |
976 | newLand.LandData.GlobalID = UUID.Random(); | 941 | newLand.LandData.GlobalID = UUID.Random(); |
977 | newLand.LandData.Dwell = 0; | 942 | newLand.LandData.Dwell = 0; |
943 | // Clear "Show in search" on the cut out parcel to prevent double-charging | ||
944 | newLand.LandData.Flags &= ~(uint)ParcelFlags.ShowDirectory; | ||
978 | 945 | ||
979 | newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y)); | 946 | newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y)); |
980 | 947 | ||
@@ -1100,6 +1067,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1100 | //Owner Flag | 1067 | //Owner Flag |
1101 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); | 1068 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); |
1102 | } | 1069 | } |
1070 | else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID)) | ||
1071 | { | ||
1072 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP); | ||
1073 | } | ||
1103 | else if (currentParcelBlock.LandData.SalePrice > 0 && | 1074 | else if (currentParcelBlock.LandData.SalePrice > 0 && |
1104 | (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || | 1075 | (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || |
1105 | currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) | 1076 | currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) |
@@ -1180,8 +1151,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1180 | { | 1151 | { |
1181 | if (!temp.Contains(currentParcel)) | 1152 | if (!temp.Contains(currentParcel)) |
1182 | { | 1153 | { |
1183 | currentParcel.ForceUpdateLandInfo(); | 1154 | if (!currentParcel.IsEitherBannedOrRestricted(remote_client.AgentId)) |
1184 | temp.Add(currentParcel); | 1155 | { |
1156 | currentParcel.ForceUpdateLandInfo(); | ||
1157 | temp.Add(currentParcel); | ||
1158 | } | ||
1185 | } | 1159 | } |
1186 | } | 1160 | } |
1187 | } | 1161 | } |
@@ -1400,8 +1374,26 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1400 | 1374 | ||
1401 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) | 1375 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) |
1402 | { | 1376 | { |
1403 | // m_log.DebugFormat( | 1377 | Dictionary<int, ILandObject> landworkList; |
1404 | // "[LAND MANAGMENT MODULE]: Processing {0} incoming parcels on {1}", data.Count, m_scene.Name); | 1378 | // move to work pointer since we are deleting it all |
1379 | lock (m_landList) | ||
1380 | { | ||
1381 | landworkList = m_landList; | ||
1382 | m_landList = new Dictionary<int, ILandObject>(); | ||
1383 | } | ||
1384 | |||
1385 | //Remove all the land objects in the sim and then process our new data | ||
1386 | foreach (int n in landworkList.Keys) | ||
1387 | { | ||
1388 | m_scene.EventManager.TriggerLandObjectRemoved(landworkList[n].LandData.GlobalID); | ||
1389 | } | ||
1390 | landworkList.Clear(); | ||
1391 | |||
1392 | lock (m_landList) | ||
1393 | { | ||
1394 | m_landIDList.Initialize(); | ||
1395 | m_landList.Clear(); | ||
1396 | } | ||
1405 | 1397 | ||
1406 | for (int i = 0; i < data.Count; i++) | 1398 | for (int i = 0; i < data.Count; i++) |
1407 | IncomingLandObjectFromStorage(data[i]); | 1399 | IncomingLandObjectFromStorage(data[i]); |
@@ -1409,10 +1401,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1409 | 1401 | ||
1410 | public void IncomingLandObjectFromStorage(LandData data) | 1402 | public void IncomingLandObjectFromStorage(LandData data) |
1411 | { | 1403 | { |
1404 | |||
1412 | ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); | 1405 | ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); |
1413 | new_land.LandData = data.Copy(); | 1406 | new_land.LandData = data.Copy(); |
1414 | new_land.SetLandBitmapFromByteArray(); | 1407 | new_land.SetLandBitmapFromByteArray(); |
1415 | AddLandObject(new_land); | 1408 | AddLandObject(new_land); |
1409 | new_land.SendLandUpdateToAvatarsOverMe(); | ||
1416 | } | 1410 | } |
1417 | 1411 | ||
1418 | public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) | 1412 | public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) |
@@ -1743,7 +1737,86 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1743 | 1737 | ||
1744 | UpdateLandObject(localID, land.LandData); | 1738 | UpdateLandObject(localID, land.LandData); |
1745 | } | 1739 | } |
1746 | 1740 | ||
1741 | public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID) | ||
1742 | { | ||
1743 | ILandObject land = null; | ||
1744 | List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels(); | ||
1745 | foreach (ILandObject landObject in Land) | ||
1746 | { | ||
1747 | if (landObject.LandData.LocalID == landID) | ||
1748 | { | ||
1749 | land = landObject; | ||
1750 | } | ||
1751 | } | ||
1752 | land.DeedToGroup(DefaultGodParcelGroup); | ||
1753 | land.LandData.Name = DefaultGodParcelName; | ||
1754 | land.SendLandUpdateToAvatarsOverMe(); | ||
1755 | } | ||
1756 | |||
1757 | private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID) | ||
1758 | { | ||
1759 | ScenePresence SP; | ||
1760 | ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP); | ||
1761 | List<SceneObjectGroup> returns = new List<SceneObjectGroup>(); | ||
1762 | if (SP.UserLevel != 0) | ||
1763 | { | ||
1764 | if (flags == 0) //All parcels, scripted or not | ||
1765 | { | ||
1766 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1767 | { | ||
1768 | if (e.OwnerID == targetID) | ||
1769 | { | ||
1770 | returns.Add(e); | ||
1771 | } | ||
1772 | } | ||
1773 | ); | ||
1774 | } | ||
1775 | if (flags == 4) //All parcels, scripted object | ||
1776 | { | ||
1777 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1778 | { | ||
1779 | if (e.OwnerID == targetID) | ||
1780 | { | ||
1781 | if (e.ContainsScripts()) | ||
1782 | { | ||
1783 | returns.Add(e); | ||
1784 | } | ||
1785 | } | ||
1786 | } | ||
1787 | ); | ||
1788 | } | ||
1789 | if (flags == 4) //not target parcel, scripted object | ||
1790 | { | ||
1791 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1792 | { | ||
1793 | if (e.OwnerID == targetID) | ||
1794 | { | ||
1795 | ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y); | ||
1796 | if (landobject.LandData.OwnerID != e.OwnerID) | ||
1797 | { | ||
1798 | if (e.ContainsScripts()) | ||
1799 | { | ||
1800 | returns.Add(e); | ||
1801 | } | ||
1802 | } | ||
1803 | } | ||
1804 | } | ||
1805 | ); | ||
1806 | } | ||
1807 | foreach (SceneObjectGroup ol in returns) | ||
1808 | { | ||
1809 | ReturnObject(ol, client); | ||
1810 | } | ||
1811 | } | ||
1812 | } | ||
1813 | public void ReturnObject(SceneObjectGroup obj, IClientAPI client) | ||
1814 | { | ||
1815 | SceneObjectGroup[] objs = new SceneObjectGroup[1]; | ||
1816 | objs[0] = obj; | ||
1817 | ((Scene)client.Scene).returnObjects(objs, client.AgentId); | ||
1818 | } | ||
1819 | |||
1747 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | 1820 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); |
1748 | 1821 | ||
1749 | public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | 1822 | public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) |
@@ -1779,7 +1852,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1779 | } | 1852 | } |
1780 | } | 1853 | } |
1781 | } | 1854 | } |
1782 | |||
1783 | private void OnEndParcelFrozen(object avatar) | 1855 | private void OnEndParcelFrozen(object avatar) |
1784 | { | 1856 | { |
1785 | ScenePresence targetAvatar = (ScenePresence)avatar; | 1857 | ScenePresence targetAvatar = (ScenePresence)avatar; |
@@ -1790,6 +1862,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1790 | targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false); | 1862 | targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false); |
1791 | } | 1863 | } |
1792 | 1864 | ||
1865 | |||
1793 | public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | 1866 | public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) |
1794 | { | 1867 | { |
1795 | ScenePresence targetAvatar = null; | 1868 | ScenePresence targetAvatar = null; |
@@ -1809,12 +1882,13 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1809 | if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) && | 1882 | if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) && |
1810 | !m_scene.Permissions.IsAdministrator(client.AgentId)) | 1883 | !m_scene.Permissions.IsAdministrator(client.AgentId)) |
1811 | return; | 1884 | return; |
1885 | |||
1812 | Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); | 1886 | Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); |
1813 | 1887 | ||
1814 | targetAvatar.TeleportWithMomentum(pos, null); | 1888 | targetAvatar.TeleportWithMomentum(pos, null); |
1815 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); | 1889 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); |
1816 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); | 1890 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); |
1817 | 1891 | ||
1818 | if ((flags & 1) != 0) // Ban TODO: Remove magic number | 1892 | if ((flags & 1) != 0) // Ban TODO: Remove magic number |
1819 | { | 1893 | { |
1820 | LandAccessEntry entry = new LandAccessEntry(); | 1894 | LandAccessEntry entry = new LandAccessEntry(); |
@@ -1872,7 +1946,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1872 | m_Dialog.SendAlertToUser(remoteClient, "You are not allowed to set your home location in this parcel."); | 1946 | m_Dialog.SendAlertToUser(remoteClient, "You are not allowed to set your home location in this parcel."); |
1873 | } | 1947 | } |
1874 | 1948 | ||
1875 | |||
1876 | protected void InstallInterfaces() | 1949 | protected void InstallInterfaces() |
1877 | { | 1950 | { |
1878 | Command clearCommand | 1951 | Command clearCommand |
@@ -1934,5 +2007,27 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1934 | 2007 | ||
1935 | MainConsole.Instance.Output(report.ToString()); | 2008 | MainConsole.Instance.Output(report.ToString()); |
1936 | } | 2009 | } |
2010 | |||
2011 | public void EnforceBans(ILandObject land, ScenePresence avatar) | ||
2012 | { | ||
2013 | if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT) | ||
2014 | return; | ||
2015 | |||
2016 | if (land.IsEitherBannedOrRestricted(avatar.UUID)) | ||
2017 | { | ||
2018 | if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y))) | ||
2019 | { | ||
2020 | Vector3? pos = m_scene.GetNearestAllowedPosition(avatar); | ||
2021 | if (pos == null) | ||
2022 | m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient); | ||
2023 | else | ||
2024 | ForceAvatarToPosition(avatar, (Vector3)pos); | ||
2025 | } | ||
2026 | else | ||
2027 | { | ||
2028 | ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition); | ||
2029 | } | ||
2030 | } | ||
2031 | } | ||
1937 | } | 2032 | } |
1938 | } | 2033 | } |
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 89f3280..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,7 +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"); | 213 | if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) |
214 | m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); | ||
211 | SendProfileToClient(presence.ControllingClient); | 215 | SendProfileToClient(presence.ControllingClient); |
212 | } | 216 | } |
213 | 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/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs index 249a40d..9c441ed 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; |
@@ -212,7 +232,25 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
212 | 232 | ||
213 | private void OnTimer(object source, ElapsedEventArgs e) | 233 | private void OnTimer(object source, ElapsedEventArgs e) |
214 | { | 234 | { |
215 | int nextInterval = DoOneNotice(); | 235 | int nextInterval = DoOneNotice(true); |
236 | |||
237 | SetTimer(nextInterval); | ||
238 | } | ||
239 | |||
240 | public void DelayRestart(int seconds, string message) | ||
241 | { | ||
242 | if (m_CountdownTimer == null) | ||
243 | return; | ||
244 | |||
245 | m_CountdownTimer.Stop(); | ||
246 | m_CountdownTimer = null; | ||
247 | |||
248 | m_Alerts = new List<int>(m_CurrentAlerts); | ||
249 | m_Alerts.Add(seconds); | ||
250 | m_Alerts.Sort(); | ||
251 | m_Alerts.Reverse(); | ||
252 | |||
253 | int nextInterval = DoOneNotice(false); | ||
216 | 254 | ||
217 | SetTimer(nextInterval); | 255 | SetTimer(nextInterval); |
218 | } | 256 | } |
@@ -226,6 +264,9 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
226 | if (m_DialogModule != null && message != String.Empty) | 264 | if (m_DialogModule != null && message != String.Empty) |
227 | m_DialogModule.SendGeneralAlert(message); | 265 | m_DialogModule.SendGeneralAlert(message); |
228 | } | 266 | } |
267 | if (m_MarkerPath != String.Empty) | ||
268 | File.Delete(Path.Combine(m_MarkerPath, | ||
269 | m_Scene.RegionInfo.RegionID.ToString())); | ||
229 | } | 270 | } |
230 | 271 | ||
231 | private void HandleRegionRestart(string module, string[] args) | 272 | private void HandleRegionRestart(string module, string[] args) |
@@ -270,5 +311,25 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
270 | 311 | ||
271 | ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); | 312 | ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); |
272 | } | 313 | } |
314 | |||
315 | protected void CreateMarkerFile() | ||
316 | { | ||
317 | if (m_MarkerPath == String.Empty) | ||
318 | return; | ||
319 | |||
320 | string path = Path.Combine(m_MarkerPath, m_Scene.RegionInfo.RegionID.ToString()); | ||
321 | try | ||
322 | { | ||
323 | string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); | ||
324 | FileStream fs = File.Create(path); | ||
325 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | ||
326 | Byte[] buf = enc.GetBytes(pidstring); | ||
327 | fs.Write(buf, 0, buf.Length); | ||
328 | fs.Close(); | ||
329 | } | ||
330 | catch (Exception) | ||
331 | { | ||
332 | } | ||
333 | } | ||
273 | } | 334 | } |
274 | } \ No newline at end of file | 335 | } \ No newline at end of file |
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 a26a5f0..bf18616 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 | ||
@@ -176,13 +173,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
176 | m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; | 173 | m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; |
177 | m_scene.EventManager.OnRegionUp += OnRegionUp; | 174 | m_scene.EventManager.OnRegionUp += OnRegionUp; |
178 | 175 | ||
179 | // StartThread(new object()); | 176 | StartThread(new object()); |
180 | } | 177 | } |
181 | 178 | ||
182 | // this has to be called with a lock on m_scene | 179 | // this has to be called with a lock on m_scene |
183 | protected virtual void RemoveHandlers() | 180 | protected virtual void RemoveHandlers() |
184 | { | 181 | { |
185 | // StopThread(); | 182 | StopThread(); |
186 | 183 | ||
187 | m_scene.EventManager.OnRegionUp -= OnRegionUp; | 184 | m_scene.EventManager.OnRegionUp -= OnRegionUp; |
188 | m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent; | 185 | m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent; |
@@ -240,54 +237,54 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
240 | // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is | 237 | // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is |
241 | // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. | 238 | // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. |
242 | 239 | ||
243 | if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) | 240 | //if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) |
244 | { | 241 | //{ |
245 | ScenePresence avatarPresence = null; | 242 | // ScenePresence avatarPresence = null; |
246 | 243 | ||
247 | m_scene.TryGetScenePresence(agentID, out avatarPresence); | 244 | // m_scene.TryGetScenePresence(agentID, out avatarPresence); |
248 | 245 | ||
249 | if (avatarPresence != null) | 246 | // if (avatarPresence != null) |
250 | { | 247 | // { |
251 | bool lookup = false; | 248 | // bool lookup = false; |
252 | 249 | ||
253 | lock (cachedMapBlocks) | 250 | // lock (cachedMapBlocks) |
254 | { | 251 | // { |
255 | if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) | 252 | // if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) |
256 | { | 253 | // { |
257 | List<MapBlockData> mapBlocks; | 254 | // List<MapBlockData> mapBlocks; |
258 | 255 | ||
259 | mapBlocks = cachedMapBlocks; | 256 | // mapBlocks = cachedMapBlocks; |
260 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); | 257 | // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); |
261 | } | 258 | // } |
262 | else | 259 | // else |
263 | { | 260 | // { |
264 | lookup = true; | 261 | // lookup = true; |
265 | } | 262 | // } |
266 | } | 263 | // } |
267 | if (lookup) | 264 | // if (lookup) |
268 | { | 265 | // { |
269 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; | 266 | // List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; |
270 | 267 | ||
271 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | 268 | // List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
272 | (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, | 269 | // (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, |
273 | (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, | 270 | // (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, |
274 | (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, | 271 | // (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, |
275 | (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); | 272 | // (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); |
276 | foreach (GridRegion r in regions) | 273 | // foreach (GridRegion r in regions) |
277 | { | 274 | // { |
278 | MapBlockData block = new MapBlockData(); | 275 | // MapBlockData block = new MapBlockData(); |
279 | MapBlockFromGridRegion(block, r, 0); | 276 | // MapBlockFromGridRegion(block, r, 0); |
280 | mapBlocks.Add(block); | 277 | // mapBlocks.Add(block); |
281 | } | 278 | // } |
282 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); | 279 | // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); |
283 | 280 | ||
284 | lock (cachedMapBlocks) | 281 | // lock (cachedMapBlocks) |
285 | cachedMapBlocks = mapBlocks; | 282 | // cachedMapBlocks = mapBlocks; |
286 | 283 | ||
287 | cachedTime = Util.UnixTimeSinceEpoch(); | 284 | // cachedTime = Util.UnixTimeSinceEpoch(); |
288 | } | 285 | // } |
289 | } | 286 | // } |
290 | } | 287 | //} |
291 | 288 | ||
292 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); | 289 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); |
293 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); | 290 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); |
@@ -314,8 +311,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
314 | protected static OSDMapLayer GetOSDMapLayerResponse() | 311 | protected static OSDMapLayer GetOSDMapLayerResponse() |
315 | { | 312 | { |
316 | OSDMapLayer mapLayer = new OSDMapLayer(); | 313 | OSDMapLayer mapLayer = new OSDMapLayer(); |
317 | mapLayer.Right = 5000; | 314 | mapLayer.Right = 2048; |
318 | mapLayer.Top = 5000; | 315 | mapLayer.Top = 2048; |
319 | mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); | 316 | mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); |
320 | 317 | ||
321 | return mapLayer; | 318 | return mapLayer; |
@@ -344,6 +341,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
344 | { | 341 | { |
345 | m_rootAgents.Remove(AgentId); | 342 | m_rootAgents.Remove(AgentId); |
346 | } | 343 | } |
344 | lock (m_mapBlockRequestEvent) | ||
345 | { | ||
346 | if (m_mapBlockRequests.ContainsKey(AgentId)) | ||
347 | m_mapBlockRequests.Remove(AgentId); | ||
348 | } | ||
347 | } | 349 | } |
348 | #endregion | 350 | #endregion |
349 | 351 | ||
@@ -366,6 +368,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
366 | ThreadPriority.BelowNormal, | 368 | ThreadPriority.BelowNormal, |
367 | true, | 369 | true, |
368 | true); | 370 | true); |
371 | Watchdog.StartThread( | ||
372 | MapBlockSendThread, | ||
373 | string.Format("MapBlockSendThread ({0})", m_scene.RegionInfo.RegionName), | ||
374 | ThreadPriority.BelowNormal, | ||
375 | true, | ||
376 | true); | ||
369 | } | 377 | } |
370 | 378 | ||
371 | /// <summary> | 379 | /// <summary> |
@@ -381,7 +389,27 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
381 | st.itemtype=0; | 389 | st.itemtype=0; |
382 | st.regionhandle=0; | 390 | st.regionhandle=0; |
383 | 391 | ||
384 | requests.Enqueue(st); | 392 | lock (requests) |
393 | { | ||
394 | queueEvent.Set(); | ||
395 | requests.Enqueue(st); | ||
396 | } | ||
397 | |||
398 | MapBlockRequestData req = new MapBlockRequestData(); | ||
399 | |||
400 | req.client = null; | ||
401 | req.minX = 0; | ||
402 | req.maxX = 0; | ||
403 | req.minY = 0; | ||
404 | req.maxY = 0; | ||
405 | req.flags = 0; | ||
406 | |||
407 | lock (m_mapBlockRequestEvent) | ||
408 | { | ||
409 | m_mapBlockRequests[UUID.Zero] = new Queue<MapBlockRequestData>(); | ||
410 | m_mapBlockRequests[UUID.Zero].Enqueue(req); | ||
411 | m_mapBlockRequestEvent.Set(); | ||
412 | } | ||
385 | } | 413 | } |
386 | 414 | ||
387 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, | 415 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, |
@@ -532,12 +560,26 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
532 | /// </summary> | 560 | /// </summary> |
533 | public void process() | 561 | public void process() |
534 | { | 562 | { |
535 | //const int MAX_ASYNC_REQUESTS = 20; | 563 | const int MAX_ASYNC_REQUESTS = 20; |
536 | try | 564 | try |
537 | { | 565 | { |
538 | while (true) | 566 | while (true) |
539 | { | 567 | { |
540 | MapRequestState st = requests.Dequeue(1000); | 568 | MapRequestState st = new MapRequestState(); |
569 | bool valid = false; | ||
570 | queueEvent.WaitOne(); | ||
571 | lock (requests) | ||
572 | { | ||
573 | if (requests.Count > 0) | ||
574 | { | ||
575 | st = requests.Dequeue(); | ||
576 | valid = true; | ||
577 | } | ||
578 | if (requests.Count == 0) | ||
579 | queueEvent.Reset(); | ||
580 | } | ||
581 | if (!valid) | ||
582 | continue; | ||
541 | 583 | ||
542 | // end gracefully | 584 | // end gracefully |
543 | if (st.agentID == STOP_UUID) | 585 | if (st.agentID == STOP_UUID) |
@@ -555,13 +597,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
555 | if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) | 597 | if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) |
556 | { | 598 | { |
557 | while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break | 599 | while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break |
558 | Thread.Sleep(80); | 600 | Thread.Sleep(100); |
559 | 601 | ||
560 | RequestMapItemsDelegate d = RequestMapItemsAsync; | ||
561 | d.BeginInvoke(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle, RequestMapItemsCompleted, null); | ||
562 | //OSDMap response = RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); | ||
563 | //RequestMapItemsCompleted(response); | ||
564 | Interlocked.Increment(ref nAsyncRequests); | 602 | Interlocked.Increment(ref nAsyncRequests); |
603 | Util.FireAndForget(x => | ||
604 | { | ||
605 | RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); | ||
606 | }); | ||
565 | } | 607 | } |
566 | } | 608 | } |
567 | 609 | ||
@@ -577,147 +619,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
577 | Watchdog.RemoveThread(); | 619 | Watchdog.RemoveThread(); |
578 | } | 620 | } |
579 | 621 | ||
580 | const int MAX_ASYNC_REQUESTS = 20; | ||
581 | |||
582 | /// <summary> | 622 | /// <summary> |
583 | /// Enqueues the map item request into the services throttle processing thread | 623 | /// Enqueues the map item request into the processing thread |
584 | /// </summary> | 624 | /// </summary> |
585 | /// <param name="state"></param> | 625 | /// <param name="state"></param> |
586 | public void EnqueueMapItemRequest(MapRequestState st) | 626 | public void EnqueueMapItemRequest(MapRequestState state) |
587 | { | ||
588 | |||
589 | m_ServiceThrottle.Enqueue("map-item", st.regionhandle.ToString() + st.agentID.ToString(), delegate | ||
590 | { | ||
591 | if (st.agentID != UUID.Zero) | ||
592 | { | ||
593 | bool dorequest = true; | ||
594 | lock (m_rootAgents) | ||
595 | { | ||
596 | if (!m_rootAgents.Contains(st.agentID)) | ||
597 | dorequest = false; | ||
598 | } | ||
599 | |||
600 | if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) | ||
601 | { | ||
602 | if (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break | ||
603 | { | ||
604 | // AH!!! Recursive ! | ||
605 | // Put this request back in the queue and return | ||
606 | EnqueueMapItemRequest(st); | ||
607 | return; | ||
608 | } | ||
609 | |||
610 | RequestMapItemsDelegate d = RequestMapItemsAsync; | ||
611 | d.BeginInvoke(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle, RequestMapItemsCompleted, null); | ||
612 | //OSDMap response = RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); | ||
613 | //RequestMapItemsCompleted(response); | ||
614 | Interlocked.Increment(ref nAsyncRequests); | ||
615 | } | ||
616 | } | ||
617 | }); | ||
618 | } | ||
619 | |||
620 | /// <summary> | ||
621 | /// Sends the mapitem response to the IClientAPI | ||
622 | /// </summary> | ||
623 | /// <param name="response">The OSDMap Response for the mapitem</param> | ||
624 | private void RequestMapItemsCompleted(IAsyncResult iar) | ||
625 | { | 627 | { |
626 | AsyncResult result = (AsyncResult)iar; | 628 | lock (requests) |
627 | RequestMapItemsDelegate icon = (RequestMapItemsDelegate)result.AsyncDelegate; | ||
628 | |||
629 | OSDMap response = (OSDMap)icon.EndInvoke(iar); | ||
630 | |||
631 | Interlocked.Decrement(ref nAsyncRequests); | ||
632 | |||
633 | if (!response.ContainsKey("requestID")) | ||
634 | return; | ||
635 | |||
636 | UUID requestID = response["requestID"].AsUUID(); | ||
637 | |||
638 | if (requestID != UUID.Zero) | ||
639 | { | 629 | { |
640 | MapRequestState mrs = new MapRequestState(); | 630 | queueEvent.Set(); |
641 | mrs.agentID = UUID.Zero; | 631 | requests.Enqueue(state); |
642 | lock (m_openRequests) | ||
643 | { | ||
644 | if (m_openRequests.ContainsKey(requestID)) | ||
645 | { | ||
646 | mrs = m_openRequests[requestID]; | ||
647 | m_openRequests.Remove(requestID); | ||
648 | } | ||
649 | } | ||
650 | |||
651 | if (mrs.agentID != UUID.Zero) | ||
652 | { | ||
653 | ScenePresence av = null; | ||
654 | m_scene.TryGetScenePresence(mrs.agentID, out av); | ||
655 | if (av != null) | ||
656 | { | ||
657 | if (response.ContainsKey(mrs.itemtype.ToString())) | ||
658 | { | ||
659 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
660 | OSDArray itemarray = (OSDArray)response[mrs.itemtype.ToString()]; | ||
661 | for (int i = 0; i < itemarray.Count; i++) | ||
662 | { | ||
663 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
664 | mapItemReply mi = new mapItemReply(); | ||
665 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
666 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
667 | mi.id = mapitem["ID"].AsUUID(); | ||
668 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
669 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
670 | mi.name = mapitem["Name"].AsString(); | ||
671 | returnitems.Add(mi); | ||
672 | } | ||
673 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags); | ||
674 | } | ||
675 | |||
676 | // Service 7 (MAP_ITEM_LAND_FOR_SALE) | ||
677 | uint itemtype = 7; | ||
678 | |||
679 | if (response.ContainsKey(itemtype.ToString())) | ||
680 | { | ||
681 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
682 | OSDArray itemarray = (OSDArray)response[itemtype.ToString()]; | ||
683 | for (int i = 0; i < itemarray.Count; i++) | ||
684 | { | ||
685 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
686 | mapItemReply mi = new mapItemReply(); | ||
687 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
688 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
689 | mi.id = mapitem["ID"].AsUUID(); | ||
690 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
691 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
692 | mi.name = mapitem["Name"].AsString(); | ||
693 | returnitems.Add(mi); | ||
694 | } | ||
695 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); | ||
696 | } | ||
697 | |||
698 | // Service 1 (MAP_ITEM_TELEHUB) | ||
699 | itemtype = 1; | ||
700 | |||
701 | if (response.ContainsKey(itemtype.ToString())) | ||
702 | { | ||
703 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
704 | OSDArray itemarray = (OSDArray)response[itemtype.ToString()]; | ||
705 | for (int i = 0; i < itemarray.Count; i++) | ||
706 | { | ||
707 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
708 | mapItemReply mi = new mapItemReply(); | ||
709 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
710 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
711 | mi.id = mapitem["ID"].AsUUID(); | ||
712 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
713 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
714 | mi.name = mapitem["Name"].AsString(); | ||
715 | returnitems.Add(mi); | ||
716 | } | ||
717 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); | ||
718 | } | ||
719 | } | ||
720 | } | ||
721 | } | 632 | } |
722 | } | 633 | } |
723 | 634 | ||
@@ -744,8 +655,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
744 | EnqueueMapItemRequest(st); | 655 | EnqueueMapItemRequest(st); |
745 | } | 656 | } |
746 | 657 | ||
747 | private delegate OSDMap RequestMapItemsDelegate(UUID id, uint flags, | ||
748 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle); | ||
749 | /// <summary> | 658 | /// <summary> |
750 | /// Does the actual remote mapitem request | 659 | /// Does the actual remote mapitem request |
751 | /// This should be called from an asynchronous thread | 660 | /// This should be called from an asynchronous thread |
@@ -760,7 +669,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
760 | /// <param name="itemtype">passed in from packet</param> | 669 | /// <param name="itemtype">passed in from packet</param> |
761 | /// <param name="regionhandle">Region we're looking up</param> | 670 | /// <param name="regionhandle">Region we're looking up</param> |
762 | /// <returns></returns> | 671 | /// <returns></returns> |
763 | private OSDMap RequestMapItemsAsync(UUID id, uint flags, | 672 | private void RequestMapItemsAsync(UUID id, uint flags, |
764 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) | 673 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) |
765 | { | 674 | { |
766 | // m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); | 675 | // m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); |
@@ -783,7 +692,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
783 | } | 692 | } |
784 | 693 | ||
785 | if (blacklisted) | 694 | if (blacklisted) |
786 | return new OSDMap(); | 695 | { |
696 | Interlocked.Decrement(ref nAsyncRequests); | ||
697 | return; | ||
698 | } | ||
787 | 699 | ||
788 | UUID requestID = UUID.Random(); | 700 | UUID requestID = UUID.Random(); |
789 | lock (m_cachedRegionMapItemsAddress) | 701 | lock (m_cachedRegionMapItemsAddress) |
@@ -791,6 +703,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
791 | if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) | 703 | if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) |
792 | httpserver = m_cachedRegionMapItemsAddress[regionhandle]; | 704 | httpserver = m_cachedRegionMapItemsAddress[regionhandle]; |
793 | } | 705 | } |
706 | |||
794 | if (httpserver.Length == 0) | 707 | if (httpserver.Length == 0) |
795 | { | 708 | { |
796 | uint x = 0, y = 0; | 709 | uint x = 0, y = 0; |
@@ -835,18 +748,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
835 | 748 | ||
836 | // Can't find the http server | 749 | // Can't find the http server |
837 | if (httpserver.Length == 0 || blacklisted) | 750 | if (httpserver.Length == 0 || blacklisted) |
838 | return new OSDMap(); | 751 | { |
839 | 752 | Interlocked.Decrement(ref nAsyncRequests); | |
840 | MapRequestState mrs = new MapRequestState(); | 753 | return; |
841 | mrs.agentID = id; | 754 | } |
842 | mrs.EstateID = EstateID; | ||
843 | mrs.flags = flags; | ||
844 | mrs.godlike = godlike; | ||
845 | mrs.itemtype=itemtype; | ||
846 | mrs.regionhandle = regionhandle; | ||
847 | |||
848 | lock (m_openRequests) | ||
849 | m_openRequests.Add(requestID, mrs); | ||
850 | 755 | ||
851 | WebRequest mapitemsrequest = null; | 756 | WebRequest mapitemsrequest = null; |
852 | try | 757 | try |
@@ -856,7 +761,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
856 | catch (Exception e) | 761 | catch (Exception e) |
857 | { | 762 | { |
858 | m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e); | 763 | m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e); |
859 | return new OSDMap(); | 764 | Interlocked.Decrement(ref nAsyncRequests); |
765 | return; | ||
860 | } | 766 | } |
861 | 767 | ||
862 | mapitemsrequest.Method = "POST"; | 768 | mapitemsrequest.Method = "POST"; |
@@ -881,7 +787,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
881 | catch (WebException ex) | 787 | catch (WebException ex) |
882 | { | 788 | { |
883 | m_log.WarnFormat("[WORLD MAP]: Bad send on GetMapItems {0}", ex.Message); | 789 | m_log.WarnFormat("[WORLD MAP]: Bad send on GetMapItems {0}", ex.Message); |
884 | responseMap["connect"] = OSD.FromBoolean(false); | ||
885 | lock (m_blacklistedurls) | 790 | lock (m_blacklistedurls) |
886 | { | 791 | { |
887 | if (!m_blacklistedurls.ContainsKey(httpserver)) | 792 | if (!m_blacklistedurls.ContainsKey(httpserver)) |
@@ -890,13 +795,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
890 | 795 | ||
891 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); | 796 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); |
892 | 797 | ||
893 | return responseMap; | 798 | Interlocked.Decrement(ref nAsyncRequests); |
799 | return; | ||
894 | } | 800 | } |
895 | catch | 801 | catch |
896 | { | 802 | { |
897 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); | 803 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); |
898 | responseMap["connect"] = OSD.FromBoolean(false); | 804 | Interlocked.Decrement(ref nAsyncRequests); |
899 | return responseMap; | 805 | return; |
900 | } | 806 | } |
901 | finally | 807 | finally |
902 | { | 808 | { |
@@ -905,26 +811,24 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
905 | } | 811 | } |
906 | 812 | ||
907 | string response_mapItems_reply = null; | 813 | string response_mapItems_reply = null; |
908 | { | 814 | { // get the response |
815 | StreamReader sr = null; | ||
909 | try | 816 | try |
910 | { | 817 | { |
911 | using (WebResponse webResponse = mapitemsrequest.GetResponse()) | 818 | WebResponse webResponse = mapitemsrequest.GetResponse(); |
819 | if (webResponse != null) | ||
912 | { | 820 | { |
913 | if (webResponse != null) | 821 | sr = new StreamReader(webResponse.GetResponseStream()); |
914 | { | 822 | response_mapItems_reply = sr.ReadToEnd().Trim(); |
915 | using (Stream s = webResponse.GetResponseStream()) | 823 | } |
916 | using (StreamReader sr = new StreamReader(s)) | 824 | else |
917 | response_mapItems_reply = sr.ReadToEnd().Trim(); | 825 | { |
918 | } | 826 | Interlocked.Decrement(ref nAsyncRequests); |
919 | else | 827 | return; |
920 | { | 828 | } |
921 | return new OSDMap(); | ||
922 | } | ||
923 | } | ||
924 | } | 829 | } |
925 | catch (WebException) | 830 | catch (WebException) |
926 | { | 831 | { |
927 | responseMap["connect"] = OSD.FromBoolean(false); | ||
928 | lock (m_blacklistedurls) | 832 | lock (m_blacklistedurls) |
929 | { | 833 | { |
930 | if (!m_blacklistedurls.ContainsKey(httpserver)) | 834 | if (!m_blacklistedurls.ContainsKey(httpserver)) |
@@ -933,19 +837,25 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
933 | 837 | ||
934 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); | 838 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); |
935 | 839 | ||
936 | return responseMap; | 840 | Interlocked.Decrement(ref nAsyncRequests); |
841 | return; | ||
937 | } | 842 | } |
938 | catch | 843 | catch |
939 | { | 844 | { |
940 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); | 845 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); |
941 | responseMap["connect"] = OSD.FromBoolean(false); | ||
942 | lock (m_blacklistedregions) | 846 | lock (m_blacklistedregions) |
943 | { | 847 | { |
944 | if (!m_blacklistedregions.ContainsKey(regionhandle)) | 848 | if (!m_blacklistedregions.ContainsKey(regionhandle)) |
945 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); | 849 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); |
946 | } | 850 | } |
947 | 851 | ||
948 | return responseMap; | 852 | Interlocked.Decrement(ref nAsyncRequests); |
853 | return; | ||
854 | } | ||
855 | finally | ||
856 | { | ||
857 | if (sr != null) | ||
858 | sr.Close(); | ||
949 | } | 859 | } |
950 | 860 | ||
951 | OSD rezResponse = null; | 861 | OSD rezResponse = null; |
@@ -959,15 +869,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
959 | catch (Exception ex) | 869 | catch (Exception ex) |
960 | { | 870 | { |
961 | m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); | 871 | m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); |
962 | responseMap["connect"] = OSD.FromBoolean(false); | ||
963 | |||
964 | lock (m_blacklistedregions) | 872 | lock (m_blacklistedregions) |
965 | { | 873 | { |
966 | if (!m_blacklistedregions.ContainsKey(regionhandle)) | 874 | if (!m_blacklistedregions.ContainsKey(regionhandle)) |
967 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); | 875 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); |
968 | } | 876 | } |
969 | 877 | ||
970 | return responseMap; | 878 | Interlocked.Decrement(ref nAsyncRequests); |
879 | return; | ||
971 | } | 880 | } |
972 | } | 881 | } |
973 | 882 | ||
@@ -981,7 +890,78 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
981 | } | 890 | } |
982 | } | 891 | } |
983 | 892 | ||
984 | return responseMap; | 893 | Interlocked.Decrement(ref nAsyncRequests); |
894 | |||
895 | if (id != UUID.Zero) | ||
896 | { | ||
897 | ScenePresence av = null; | ||
898 | m_scene.TryGetScenePresence(id, out av); | ||
899 | if (av != null) | ||
900 | { | ||
901 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
902 | { | ||
903 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
904 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
905 | for (int i = 0; i < itemarray.Count; i++) | ||
906 | { | ||
907 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
908 | mapItemReply mi = new mapItemReply(); | ||
909 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
910 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
911 | mi.id = mapitem["ID"].AsUUID(); | ||
912 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
913 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
914 | mi.name = mapitem["Name"].AsString(); | ||
915 | returnitems.Add(mi); | ||
916 | } | ||
917 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
918 | } | ||
919 | |||
920 | // Service 7 (MAP_ITEM_LAND_FOR_SALE) | ||
921 | itemtype = 7; | ||
922 | |||
923 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
924 | { | ||
925 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
926 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
927 | for (int i = 0; i < itemarray.Count; i++) | ||
928 | { | ||
929 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
930 | mapItemReply mi = new mapItemReply(); | ||
931 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
932 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
933 | mi.id = mapitem["ID"].AsUUID(); | ||
934 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
935 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
936 | mi.name = mapitem["Name"].AsString(); | ||
937 | returnitems.Add(mi); | ||
938 | } | ||
939 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
940 | } | ||
941 | |||
942 | // Service 1 (MAP_ITEM_TELEHUB) | ||
943 | itemtype = 1; | ||
944 | |||
945 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
946 | { | ||
947 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
948 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
949 | for (int i = 0; i < itemarray.Count; i++) | ||
950 | { | ||
951 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
952 | mapItemReply mi = new mapItemReply(); | ||
953 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
954 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
955 | mi.id = mapitem["ID"].AsUUID(); | ||
956 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
957 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
958 | mi.name = mapitem["Name"].AsString(); | ||
959 | returnitems.Add(mi); | ||
960 | } | ||
961 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
962 | } | ||
963 | } | ||
964 | } | ||
985 | } | 965 | } |
986 | 966 | ||
987 | /// <summary> | 967 | /// <summary> |
@@ -991,7 +971,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
991 | /// <param name="minY"></param> | 971 | /// <param name="minY"></param> |
992 | /// <param name="maxX"></param> | 972 | /// <param name="maxX"></param> |
993 | /// <param name="maxY"></param> | 973 | /// <param name="maxY"></param> |
994 | public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 974 | public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) |
995 | { | 975 | { |
996 | //m_log.ErrorFormat("[YYY] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag); | 976 | //m_log.ErrorFormat("[YYY] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag); |
997 | if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible | 977 | if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible |
@@ -1044,21 +1024,91 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1044 | 1024 | ||
1045 | protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 1025 | protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) |
1046 | { | 1026 | { |
1027 | MapBlockRequestData req = new MapBlockRequestData(); | ||
1028 | |||
1029 | req.client = remoteClient; | ||
1030 | req.minX = minX; | ||
1031 | req.maxX = maxX; | ||
1032 | req.minY = minY; | ||
1033 | req.maxY = maxY; | ||
1034 | req.flags = flag; | ||
1035 | |||
1036 | lock (m_mapBlockRequestEvent) | ||
1037 | { | ||
1038 | if (!m_mapBlockRequests.ContainsKey(remoteClient.AgentId)) | ||
1039 | m_mapBlockRequests[remoteClient.AgentId] = new Queue<MapBlockRequestData>(); | ||
1040 | m_mapBlockRequests[remoteClient.AgentId].Enqueue(req); | ||
1041 | m_mapBlockRequestEvent.Set(); | ||
1042 | } | ||
1043 | |||
1044 | return new List<MapBlockData>(); | ||
1045 | } | ||
1046 | |||
1047 | protected void MapBlockSendThread() | ||
1048 | { | ||
1049 | while (true) | ||
1050 | { | ||
1051 | List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>(); | ||
1052 | |||
1053 | m_mapBlockRequestEvent.WaitOne(); | ||
1054 | lock (m_mapBlockRequestEvent) | ||
1055 | { | ||
1056 | int total = 0; | ||
1057 | foreach (Queue<MapBlockRequestData> q in m_mapBlockRequests.Values) | ||
1058 | { | ||
1059 | if (q.Count > 0) | ||
1060 | thisRunData.Add(q.Dequeue()); | ||
1061 | |||
1062 | total += q.Count; | ||
1063 | } | ||
1064 | |||
1065 | if (total == 0) | ||
1066 | m_mapBlockRequestEvent.Reset(); | ||
1067 | } | ||
1068 | |||
1069 | foreach (MapBlockRequestData req in thisRunData) | ||
1070 | { | ||
1071 | // Null client stops thread | ||
1072 | if (req.client == null) | ||
1073 | return; | ||
1074 | |||
1075 | GetAndSendBlocksInternal(req.client, req.minX, req.minY, req.maxX, req.maxY, req.flags); | ||
1076 | } | ||
1077 | |||
1078 | Thread.Sleep(50); | ||
1079 | } | ||
1080 | } | ||
1081 | |||
1082 | protected virtual List<MapBlockData> GetAndSendBlocksInternal(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | ||
1083 | { | ||
1084 | List<MapBlockData> allBlocks = new List<MapBlockData>(); | ||
1047 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); | 1085 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); |
1048 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | 1086 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
1049 | (minX - 4) * (int)Constants.RegionSize, | 1087 | minX * (int)Constants.RegionSize, |
1050 | (maxX + 4) * (int)Constants.RegionSize, | 1088 | maxX * (int)Constants.RegionSize, |
1051 | (minY - 4) * (int)Constants.RegionSize, | 1089 | minY * (int)Constants.RegionSize, |
1052 | (maxY + 4) * (int)Constants.RegionSize); | 1090 | maxY * (int)Constants.RegionSize); |
1091 | // (minX - 4) * (int)Constants.RegionSize, | ||
1092 | // (maxX + 4) * (int)Constants.RegionSize, | ||
1093 | // (minY - 4) * (int)Constants.RegionSize, | ||
1094 | // (maxY + 4) * (int)Constants.RegionSize); | ||
1053 | foreach (GridRegion r in regions) | 1095 | foreach (GridRegion r in regions) |
1054 | { | 1096 | { |
1055 | MapBlockData block = new MapBlockData(); | 1097 | MapBlockData block = new MapBlockData(); |
1056 | MapBlockFromGridRegion(block, r, flag); | 1098 | MapBlockFromGridRegion(block, r, flag); |
1057 | mapBlocks.Add(block); | 1099 | mapBlocks.Add(block); |
1100 | allBlocks.Add(block); | ||
1101 | if (mapBlocks.Count >= 10) | ||
1102 | { | ||
1103 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | ||
1104 | mapBlocks.Clear(); | ||
1105 | Thread.Sleep(50); | ||
1106 | } | ||
1058 | } | 1107 | } |
1059 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | 1108 | if (mapBlocks.Count > 0) |
1109 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | ||
1060 | 1110 | ||
1061 | return mapBlocks; | 1111 | return allBlocks; |
1062 | } | 1112 | } |
1063 | 1113 | ||
1064 | protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) | 1114 | protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) |
@@ -1282,7 +1332,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1282 | } | 1332 | } |
1283 | else | 1333 | else |
1284 | { | 1334 | { |
1285 | OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); | 1335 | OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount()); |
1286 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 1336 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
1287 | { | 1337 | { |
1288 | OSDMap responsemapdata = new OSDMap(); | 1338 | OSDMap responsemapdata = new OSDMap(); |
@@ -1458,6 +1508,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1458 | { | 1508 | { |
1459 | m_rootAgents.Remove(avatar.UUID); | 1509 | m_rootAgents.Remove(avatar.UUID); |
1460 | } | 1510 | } |
1511 | |||
1512 | lock (m_mapBlockRequestEvent) | ||
1513 | { | ||
1514 | if (m_mapBlockRequests.ContainsKey(avatar.UUID)) | ||
1515 | m_mapBlockRequests.Remove(avatar.UUID); | ||
1516 | } | ||
1461 | } | 1517 | } |
1462 | 1518 | ||
1463 | public void OnRegionUp(GridRegion otherRegion) | 1519 | public void OnRegionUp(GridRegion otherRegion) |
@@ -1502,9 +1558,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1502 | Color background = Color.FromArgb(0, 0, 0, 0); | 1558 | Color background = Color.FromArgb(0, 0, 0, 0); |
1503 | SolidBrush transparent = new SolidBrush(background); | 1559 | SolidBrush transparent = new SolidBrush(background); |
1504 | Graphics g = Graphics.FromImage(overlay); | 1560 | Graphics g = Graphics.FromImage(overlay); |
1505 | g.FillRectangle(transparent, 0, 0, 256, 256); | 1561 | g.FillRectangle(transparent, 0, 0, 255, 255); |
1506 | 1562 | ||
1507 | SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); | 1563 | SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); |
1564 | Pen grey = new Pen(Color.FromArgb(255, 92, 92, 92)); | ||
1508 | 1565 | ||
1509 | foreach (ILandObject land in parcels) | 1566 | foreach (ILandObject land in parcels) |
1510 | { | 1567 | { |
@@ -1512,8 +1569,42 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1512 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) | 1569 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) |
1513 | { | 1570 | { |
1514 | landForSale = true; | 1571 | landForSale = true; |
1572 | |||
1573 | bool[,] landBitmap = land.GetLandBitmap(); | ||
1574 | |||
1575 | for (int x = 0 ; x < 64 ; x++) | ||
1576 | { | ||
1577 | for (int y = 0 ; y < 64 ; y++) | ||
1578 | { | ||
1579 | if (landBitmap[x, y]) | ||
1580 | { | ||
1581 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | ||
1582 | |||
1583 | if (x > 0) | ||
1584 | { | ||
1585 | if ((saleBitmap[x - 1, y] || landBitmap[x - 1, y]) == false) | ||
1586 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4, 255 - (y * 4)); | ||
1587 | } | ||
1588 | if (y > 0) | ||
1589 | { | ||
1590 | if ((saleBitmap[x, y-1] || landBitmap[x, y-1]) == false) | ||
1591 | g.DrawLine(grey, x * 4, 255 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1592 | } | ||
1593 | if (x < 63) | ||
1594 | { | ||
1595 | if ((saleBitmap[x + 1, y] || landBitmap[x + 1, y]) == false) | ||
1596 | g.DrawLine(grey, x * 4 + 3, 252 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1597 | } | ||
1598 | if (y < 63) | ||
1599 | { | ||
1600 | if ((saleBitmap[x, y + 1] || landBitmap[x, y + 1]) == false) | ||
1601 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4 + 3, 252 - (y * 4)); | ||
1602 | } | ||
1603 | } | ||
1604 | } | ||
1605 | } | ||
1515 | 1606 | ||
1516 | saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap()); | 1607 | saleBitmap = land.MergeLandBitmaps(saleBitmap, landBitmap); |
1517 | } | 1608 | } |
1518 | } | 1609 | } |
1519 | 1610 | ||
@@ -1525,15 +1616,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1525 | 1616 | ||
1526 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); | 1617 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); |
1527 | 1618 | ||
1528 | for (int x = 0 ; x < 64 ; x++) | ||
1529 | { | ||
1530 | for (int y = 0 ; y < 64 ; y++) | ||
1531 | { | ||
1532 | if (saleBitmap[x, y]) | ||
1533 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | ||
1534 | } | ||
1535 | } | ||
1536 | |||
1537 | try | 1619 | try |
1538 | { | 1620 | { |
1539 | return OpenJPEG.EncodeFromImage(overlay, true); | 1621 | return OpenJPEG.EncodeFromImage(overlay, true); |
@@ -1555,4 +1637,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1555 | public uint itemtype; | 1637 | public uint itemtype; |
1556 | public ulong regionhandle; | 1638 | public ulong regionhandle; |
1557 | } | 1639 | } |
1640 | |||
1641 | public struct MapBlockRequestData | ||
1642 | { | ||
1643 | public IClientAPI client; | ||
1644 | public int minX; | ||
1645 | public int minY; | ||
1646 | public int maxX; | ||
1647 | public int maxY; | ||
1648 | public uint flags; | ||
1649 | } | ||
1558 | } | 1650 | } |