diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
13 files changed, 1005 insertions, 477 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index a6923ef..2127f4d 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 | ||
@@ -878,4 +896,4 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
878 | return dearchivedScenes; | 896 | return dearchivedScenes; |
879 | } | 897 | } |
880 | } | 898 | } |
881 | } \ No newline at end of file | 899 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 5787279..bf58591 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | |||
@@ -265,18 +265,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
265 | 265 | ||
266 | if (asset != null) | 266 | if (asset != null) |
267 | { | 267 | { |
268 | if (m_options.ContainsKey("verbose")) | 268 | // m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id); |
269 | m_log.InfoFormat("[ARCHIVER]: Writing asset {0}", id); | ||
270 | |||
271 | m_foundAssetUuids.Add(asset.FullID); | 269 | m_foundAssetUuids.Add(asset.FullID); |
272 | 270 | ||
273 | m_assetsArchiver.WriteAsset(PostProcess(asset)); | 271 | m_assetsArchiver.WriteAsset(PostProcess(asset)); |
274 | } | 272 | } |
275 | else | 273 | else |
276 | { | 274 | { |
277 | if (m_options.ContainsKey("verbose")) | 275 | // m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id); |
278 | m_log.InfoFormat("[ARCHIVER]: Recording asset {0} as not found", id); | ||
279 | |||
280 | m_notFoundAssetUuids.Add(new UUID(id)); | 276 | m_notFoundAssetUuids.Add(new UUID(id)); |
281 | } | 277 | } |
282 | 278 | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 58bbd24..fdef9d8 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -32,6 +32,7 @@ using System.IO; | |||
32 | using System.Linq; | 32 | using System.Linq; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Security; | 34 | using System.Security; |
35 | using System.Timers; | ||
35 | using log4net; | 36 | using log4net; |
36 | using Mono.Addins; | 37 | using Mono.Addins; |
37 | using Nini.Config; | 38 | using Nini.Config; |
@@ -47,6 +48,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
47 | { | 48 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 50 | ||
51 | private Timer m_regionChangeTimer = new Timer(); | ||
50 | public Scene Scene { get; private set; } | 52 | public Scene Scene { get; private set; } |
51 | public IUserManagement UserManager { get; private set; } | 53 | public IUserManagement UserManager { get; private set; } |
52 | 54 | ||
@@ -59,8 +61,16 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
59 | public event ChangeDelegate OnEstateInfoChange; | 61 | public event ChangeDelegate OnEstateInfoChange; |
60 | public event MessageDelegate OnEstateMessage; | 62 | public event MessageDelegate OnEstateMessage; |
61 | 63 | ||
64 | private int m_delayCount = 0; | ||
65 | |||
62 | #region Packet Data Responders | 66 | #region Packet Data Responders |
63 | 67 | ||
68 | private void clientSendDetailedEstateData(IClientAPI remote_client, UUID invoice) | ||
69 | { | ||
70 | sendDetailedEstateData(remote_client, invoice); | ||
71 | sendEstateLists(remote_client, invoice); | ||
72 | } | ||
73 | |||
64 | private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) | 74 | private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) |
65 | { | 75 | { |
66 | uint sun = 0; | 76 | uint sun = 0; |
@@ -83,7 +93,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
83 | (uint) Scene.RegionInfo.RegionSettings.CovenantChangedDateTime, | 93 | (uint) Scene.RegionInfo.RegionSettings.CovenantChangedDateTime, |
84 | Scene.RegionInfo.EstateSettings.AbuseEmail, | 94 | Scene.RegionInfo.EstateSettings.AbuseEmail, |
85 | estateOwner); | 95 | estateOwner); |
96 | } | ||
86 | 97 | ||
98 | private void sendEstateLists(IClientAPI remote_client, UUID invoice) | ||
99 | { | ||
87 | remote_client.SendEstateList(invoice, | 100 | remote_client.SendEstateList(invoice, |
88 | (int)Constants.EstateAccessCodex.EstateManagers, | 101 | (int)Constants.EstateAccessCodex.EstateManagers, |
89 | Scene.RegionInfo.EstateSettings.EstateManagers, | 102 | Scene.RegionInfo.EstateSettings.EstateManagers, |
@@ -257,6 +270,16 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
257 | IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>(); | 270 | IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>(); |
258 | if (restartModule != null) | 271 | if (restartModule != null) |
259 | { | 272 | { |
273 | if (timeInSeconds == -1) | ||
274 | { | ||
275 | m_delayCount++; | ||
276 | if (m_delayCount > 3) | ||
277 | return; | ||
278 | |||
279 | restartModule.DelayRestart(3600, "Restart delayed by region manager"); | ||
280 | return; | ||
281 | } | ||
282 | |||
260 | List<int> times = new List<int>(); | 283 | List<int> times = new List<int>(); |
261 | while (timeInSeconds > 0) | 284 | while (timeInSeconds > 0) |
262 | { | 285 | { |
@@ -269,7 +292,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
269 | timeInSeconds -= 15; | 292 | timeInSeconds -= 15; |
270 | } | 293 | } |
271 | 294 | ||
272 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | 295 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), false); |
273 | } | 296 | } |
274 | } | 297 | } |
275 | 298 | ||
@@ -477,7 +500,11 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
477 | { | 500 | { |
478 | if (!s.IsChildAgent) | 501 | if (!s.IsChildAgent) |
479 | { | 502 | { |
480 | Scene.TeleportClientHome(user, s.ControllingClient); | 503 | if (!Scene.TeleportClientHome(user, s.ControllingClient)) |
504 | { | ||
505 | s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out."); | ||
506 | s.ControllingClient.Close(); | ||
507 | } | ||
481 | } | 508 | } |
482 | } | 509 | } |
483 | 510 | ||
@@ -486,7 +513,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
486 | { | 513 | { |
487 | remote_client.SendAlertMessage("User is already on the region ban list"); | 514 | remote_client.SendAlertMessage("User is already on the region ban list"); |
488 | } | 515 | } |
489 | //m_scene.RegionInfo.regionBanlist.Add(Manager(user); | 516 | //Scene.RegionInfo.regionBanlist.Add(Manager(user); |
490 | remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); | 517 | remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); |
491 | } | 518 | } |
492 | else | 519 | else |
@@ -541,7 +568,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
541 | remote_client.SendAlertMessage("User is not on the region ban list"); | 568 | remote_client.SendAlertMessage("User is not on the region ban list"); |
542 | } | 569 | } |
543 | 570 | ||
544 | //m_scene.RegionInfo.regionBanlist.Add(Manager(user); | 571 | //Scene.RegionInfo.regionBanlist.Add(Manager(user); |
545 | remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); | 572 | remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); |
546 | } | 573 | } |
547 | else | 574 | else |
@@ -700,7 +727,11 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
700 | ScenePresence s = Scene.GetScenePresence(prey); | 727 | ScenePresence s = Scene.GetScenePresence(prey); |
701 | if (s != null) | 728 | if (s != null) |
702 | { | 729 | { |
703 | Scene.TeleportClientHome(prey, s.ControllingClient); | 730 | if (!Scene.TeleportClientHome(prey, s.ControllingClient)) |
731 | { | ||
732 | s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); | ||
733 | s.ControllingClient.Close(); | ||
734 | } | ||
704 | } | 735 | } |
705 | } | 736 | } |
706 | } | 737 | } |
@@ -718,7 +749,13 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
718 | // Also make sure they are actually in the region | 749 | // Also make sure they are actually in the region |
719 | ScenePresence p; | 750 | ScenePresence p; |
720 | if(Scene.TryGetScenePresence(client.AgentId, out p)) | 751 | if(Scene.TryGetScenePresence(client.AgentId, out p)) |
721 | Scene.TeleportClientHome(p.UUID, p.ControllingClient); | 752 | { |
753 | if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient)) | ||
754 | { | ||
755 | p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); | ||
756 | p.ControllingClient.Close(); | ||
757 | } | ||
758 | } | ||
722 | } | 759 | } |
723 | }); | 760 | }); |
724 | } | 761 | } |
@@ -1081,6 +1118,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1081 | 1118 | ||
1082 | public void AddRegion(Scene scene) | 1119 | public void AddRegion(Scene scene) |
1083 | { | 1120 | { |
1121 | m_regionChangeTimer.AutoReset = false; | ||
1122 | m_regionChangeTimer.Interval = 2000; | ||
1123 | m_regionChangeTimer.Elapsed += RaiseRegionInfoChange; | ||
1124 | |||
1084 | Scene = scene; | 1125 | Scene = scene; |
1085 | Scene.RegisterModuleInterface<IEstateModule>(this); | 1126 | Scene.RegisterModuleInterface<IEstateModule>(this); |
1086 | Scene.EventManager.OnNewClient += EventManager_OnNewClient; | 1127 | Scene.EventManager.OnNewClient += EventManager_OnNewClient; |
@@ -1131,7 +1172,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1131 | 1172 | ||
1132 | private void EventManager_OnNewClient(IClientAPI client) | 1173 | private void EventManager_OnNewClient(IClientAPI client) |
1133 | { | 1174 | { |
1134 | client.OnDetailedEstateDataRequest += sendDetailedEstateData; | 1175 | client.OnDetailedEstateDataRequest += clientSendDetailedEstateData; |
1135 | client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler; | 1176 | client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler; |
1136 | // client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture; | 1177 | // client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture; |
1137 | client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture; | 1178 | client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture; |
@@ -1183,6 +1224,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1183 | flags |= RegionFlags.AllowParcelChanges; | 1224 | flags |= RegionFlags.AllowParcelChanges; |
1184 | if (Scene.RegionInfo.RegionSettings.BlockShowInSearch) | 1225 | if (Scene.RegionInfo.RegionSettings.BlockShowInSearch) |
1185 | flags |= RegionFlags.BlockParcelSearch; | 1226 | flags |= RegionFlags.BlockParcelSearch; |
1227 | if (Scene.RegionInfo.RegionSettings.GodBlockSearch) | ||
1228 | flags |= (RegionFlags)(1 << 11); | ||
1229 | if (Scene.RegionInfo.RegionSettings.Casino) | ||
1230 | flags |= (RegionFlags)(1 << 10); | ||
1186 | 1231 | ||
1187 | if (Scene.RegionInfo.RegionSettings.FixedSun) | 1232 | if (Scene.RegionInfo.RegionSettings.FixedSun) |
1188 | flags |= RegionFlags.SunFixed; | 1233 | flags |= RegionFlags.SunFixed; |
@@ -1190,11 +1235,15 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1190 | flags |= RegionFlags.Sandbox; | 1235 | flags |= RegionFlags.Sandbox; |
1191 | if (Scene.RegionInfo.EstateSettings.AllowVoice) | 1236 | if (Scene.RegionInfo.EstateSettings.AllowVoice) |
1192 | flags |= RegionFlags.AllowVoice; | 1237 | flags |= RegionFlags.AllowVoice; |
1238 | if (Scene.RegionInfo.EstateSettings.AllowLandmark) | ||
1239 | flags |= RegionFlags.AllowLandmark; | ||
1240 | if (Scene.RegionInfo.EstateSettings.AllowSetHome) | ||
1241 | flags |= RegionFlags.AllowSetHome; | ||
1242 | if (Scene.RegionInfo.EstateSettings.BlockDwell) | ||
1243 | flags |= RegionFlags.BlockDwell; | ||
1244 | if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport) | ||
1245 | flags |= RegionFlags.ResetHomeOnTeleport; | ||
1193 | 1246 | ||
1194 | // Fudge these to always on, so the menu options activate | ||
1195 | // | ||
1196 | flags |= RegionFlags.AllowLandmark; | ||
1197 | flags |= RegionFlags.AllowSetHome; | ||
1198 | 1247 | ||
1199 | // TODO: SkipUpdateInterestList | 1248 | // TODO: SkipUpdateInterestList |
1200 | 1249 | ||
@@ -1235,6 +1284,12 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1235 | flags |= RegionFlags.ResetHomeOnTeleport; | 1284 | flags |= RegionFlags.ResetHomeOnTeleport; |
1236 | if (Scene.RegionInfo.EstateSettings.TaxFree) | 1285 | if (Scene.RegionInfo.EstateSettings.TaxFree) |
1237 | flags |= RegionFlags.TaxFree; | 1286 | flags |= RegionFlags.TaxFree; |
1287 | if (Scene.RegionInfo.EstateSettings.AllowLandmark) | ||
1288 | flags |= RegionFlags.AllowLandmark; | ||
1289 | if (Scene.RegionInfo.EstateSettings.AllowParcelChanges) | ||
1290 | flags |= RegionFlags.AllowParcelChanges; | ||
1291 | if (Scene.RegionInfo.EstateSettings.AllowSetHome) | ||
1292 | flags |= RegionFlags.AllowSetHome; | ||
1238 | if (Scene.RegionInfo.EstateSettings.DenyMinors) | 1293 | if (Scene.RegionInfo.EstateSettings.DenyMinors) |
1239 | flags |= (RegionFlags)(1 << 30); | 1294 | flags |= (RegionFlags)(1 << 30); |
1240 | 1295 | ||
@@ -1255,6 +1310,12 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1255 | 1310 | ||
1256 | public void TriggerRegionInfoChange() | 1311 | public void TriggerRegionInfoChange() |
1257 | { | 1312 | { |
1313 | m_regionChangeTimer.Stop(); | ||
1314 | m_regionChangeTimer.Start(); | ||
1315 | } | ||
1316 | |||
1317 | protected void RaiseRegionInfoChange(object sender, ElapsedEventArgs e) | ||
1318 | { | ||
1258 | ChangeDelegate change = OnRegionInfoChange; | 1319 | ChangeDelegate change = OnRegionInfoChange; |
1259 | 1320 | ||
1260 | if (change != null) | 1321 | if (change != null) |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 8b7406d..aae6603 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -86,19 +86,21 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
86 | /// <value> | 86 | /// <value> |
87 | /// Land objects keyed by local id | 87 | /// Land objects keyed by local id |
88 | /// </value> | 88 | /// </value> |
89 | private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); | 89 | // private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); |
90 | |||
91 | //ubit: removed the readonly so i can move it around | ||
92 | private Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); | ||
90 | 93 | ||
91 | private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; | 94 | private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; |
92 | 95 | ||
93 | private bool m_allowedForcefulBans = true; | 96 | private bool m_allowedForcefulBans = true; |
97 | private UUID DefaultGodParcelGroup; | ||
98 | private string DefaultGodParcelName; | ||
94 | 99 | ||
95 | // caches ExtendedLandData | 100 | // caches ExtendedLandData |
96 | private Cache parcelInfoCache; | 101 | private Cache parcelInfoCache; |
97 | 102 | private Dictionary<UUID, Vector3> forcedPosition = | |
98 | /// <summary> | 103 | new Dictionary<UUID, Vector3>(); |
99 | /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions. | ||
100 | /// </summary> | ||
101 | private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>(); | ||
102 | 104 | ||
103 | #region INonSharedRegionModule Members | 105 | #region INonSharedRegionModule Members |
104 | 106 | ||
@@ -109,6 +111,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
109 | 111 | ||
110 | public void Initialise(IConfigSource source) | 112 | public void Initialise(IConfigSource source) |
111 | { | 113 | { |
114 | IConfig cnf = source.Configs["LandManagement"]; | ||
115 | if (cnf != null) | ||
116 | { | ||
117 | DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString())); | ||
118 | DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel"); | ||
119 | } | ||
112 | } | 120 | } |
113 | 121 | ||
114 | public void AddRegion(Scene scene) | 122 | public void AddRegion(Scene scene) |
@@ -160,13 +168,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
160 | m_scene.UnregisterModuleCommander(m_commander.Name); | 168 | m_scene.UnregisterModuleCommander(m_commander.Name); |
161 | } | 169 | } |
162 | 170 | ||
163 | // private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason) | ||
164 | // { | ||
165 | // ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y); | ||
166 | // reason = "You are not allowed to enter this sim."; | ||
167 | // return nearestParcel != null; | ||
168 | // } | ||
169 | |||
170 | /// <summary> | 171 | /// <summary> |
171 | /// Processes commandline input. Do not call directly. | 172 | /// Processes commandline input. Do not call directly. |
172 | /// </summary> | 173 | /// </summary> |
@@ -207,6 +208,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
207 | client.OnParcelInfoRequest += ClientOnParcelInfoRequest; | 208 | client.OnParcelInfoRequest += ClientOnParcelInfoRequest; |
208 | client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; | 209 | client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; |
209 | client.OnPreAgentUpdate += ClientOnPreAgentUpdate; | 210 | client.OnPreAgentUpdate += ClientOnPreAgentUpdate; |
211 | client.OnParcelEjectUser += ClientOnParcelEjectUser; | ||
212 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; | ||
210 | 213 | ||
211 | EntityBase presenceEntity; | 214 | EntityBase presenceEntity; |
212 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) | 215 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) |
@@ -218,48 +221,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
218 | 221 | ||
219 | void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | 222 | void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) |
220 | { | 223 | { |
221 | //If we are forcing a position for them to go | ||
222 | if (forcedPosition.ContainsKey(remoteClient.AgentId)) | ||
223 | { | ||
224 | ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId); | ||
225 | |||
226 | //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND | ||
227 | //When the avatar walks into a ban line on the ground, it prevents getting stuck | ||
228 | agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
229 | |||
230 | //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines | ||
231 | if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2) | ||
232 | { | ||
233 | // m_log.DebugFormat( | ||
234 | // "[LAND MANAGEMENT MODULE]: Stopping force position of {0} because {1} is close enough to {2}", | ||
235 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]); | ||
236 | |||
237 | forcedPosition.Remove(remoteClient.AgentId); | ||
238 | } | ||
239 | //if we are far away, teleport | ||
240 | else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3) | ||
241 | { | ||
242 | Vector3 forcePosition = forcedPosition[remoteClient.AgentId]; | ||
243 | // m_log.DebugFormat( | ||
244 | // "[LAND MANAGEMENT MODULE]: Teleporting out {0} because {1} is too far from avatar position {2}", | ||
245 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcePosition); | ||
246 | |||
247 | m_scene.RequestTeleportLocation(remoteClient, m_scene.RegionInfo.RegionHandle, | ||
248 | forcePosition, clientAvatar.Lookat, (uint)Constants.TeleportFlags.ForceRedirect); | ||
249 | |||
250 | forcedPosition.Remove(remoteClient.AgentId); | ||
251 | } | ||
252 | else | ||
253 | { | ||
254 | // m_log.DebugFormat( | ||
255 | // "[LAND MANAGEMENT MODULE]: Forcing {0} from {1} to {2}", | ||
256 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]); | ||
257 | |||
258 | //Forces them toward the forced position we want if they aren't there yet | ||
259 | agentData.UseClientAgentPosition = true; | ||
260 | agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId]; | ||
261 | } | ||
262 | } | ||
263 | } | 224 | } |
264 | 225 | ||
265 | public void Close() | 226 | public void Close() |
@@ -284,15 +245,19 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
284 | { | 245 | { |
285 | LandData newData = data.Copy(); | 246 | LandData newData = data.Copy(); |
286 | newData.LocalID = local_id; | 247 | newData.LocalID = local_id; |
248 | ILandObject landobj = null; | ||
287 | 249 | ||
288 | lock (m_landList) | 250 | lock (m_landList) |
289 | { | 251 | { |
290 | if (m_landList.ContainsKey(local_id)) | 252 | if (m_landList.ContainsKey(local_id)) |
291 | { | 253 | { |
292 | m_landList[local_id].LandData = newData; | 254 | m_landList[local_id].LandData = newData; |
293 | m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, m_landList[local_id]); | 255 | landobj = m_landList[local_id]; |
256 | // m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, m_landList[local_id]); | ||
294 | } | 257 | } |
295 | } | 258 | } |
259 | if(landobj != null) | ||
260 | m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landobj); | ||
296 | } | 261 | } |
297 | 262 | ||
298 | public bool AllowedForcefulBans | 263 | public bool AllowedForcefulBans |
@@ -322,14 +287,14 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
322 | protected ILandObject CreateDefaultParcel() | 287 | protected ILandObject CreateDefaultParcel() |
323 | { | 288 | { |
324 | m_log.DebugFormat( | 289 | m_log.DebugFormat( |
325 | "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); | 290 | "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); |
326 | 291 | ||
327 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); | 292 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); |
328 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | 293 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); |
329 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 294 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
330 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); | 295 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); |
331 | 296 | ||
332 | return AddLandObject(fullSimParcel); | 297 | return AddLandObject(fullSimParcel); |
333 | } | 298 | } |
334 | 299 | ||
335 | public List<ILandObject> AllParcels() | 300 | public List<ILandObject> AllParcels() |
@@ -378,10 +343,16 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
378 | private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) | 343 | private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) |
379 | { | 344 | { |
380 | if (m_scene.Permissions.IsGod(avatar.UUID)) return; | 345 | if (m_scene.Permissions.IsGod(avatar.UUID)) return; |
381 | if (position.HasValue) | 346 | |
382 | { | 347 | if (!position.HasValue) |
383 | forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; | 348 | return; |
384 | } | 349 | |
350 | bool isFlying = avatar.PhysicsActor.Flying; | ||
351 | avatar.RemoveFromPhysicalScene(); | ||
352 | |||
353 | avatar.AbsolutePosition = (Vector3)position; | ||
354 | |||
355 | avatar.AddToPhysicalScene(isFlying); | ||
385 | } | 356 | } |
386 | 357 | ||
387 | public void SendYouAreRestrictedNotice(ScenePresence avatar) | 358 | public void SendYouAreRestrictedNotice(ScenePresence avatar) |
@@ -401,29 +372,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
401 | } | 372 | } |
402 | 373 | ||
403 | if (parcelAvatarIsEntering != null) | 374 | if (parcelAvatarIsEntering != null) |
404 | { | 375 | EnforceBans(parcelAvatarIsEntering, avatar); |
405 | if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT) | ||
406 | { | ||
407 | if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID)) | ||
408 | { | ||
409 | SendYouAreBannedNotice(avatar); | ||
410 | ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); | ||
411 | } | ||
412 | else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID)) | ||
413 | { | ||
414 | SendYouAreRestrictedNotice(avatar); | ||
415 | ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); | ||
416 | } | ||
417 | else | ||
418 | { | ||
419 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; | ||
420 | } | ||
421 | } | ||
422 | else | ||
423 | { | ||
424 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; | ||
425 | } | ||
426 | } | ||
427 | } | 376 | } |
428 | } | 377 | } |
429 | 378 | ||
@@ -452,30 +401,51 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
452 | 401 | ||
453 | public void SendLandUpdate(ScenePresence avatar, bool force) | 402 | public void SendLandUpdate(ScenePresence avatar, bool force) |
454 | { | 403 | { |
404 | |||
405 | /* stop sendind same data twice | ||
406 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), | ||
407 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); | ||
408 | |||
409 | if (over != null) | ||
410 | { | ||
411 | |||
412 | if (force) | ||
413 | { | ||
414 | if (!avatar.IsChildAgent) | ||
415 | { | ||
416 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
417 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
418 | m_scene.RegionInfo.RegionID); | ||
419 | } | ||
420 | } | ||
421 | |||
422 | if (avatar.currentParcelUUID != over.LandData.GlobalID) | ||
423 | { | ||
424 | if (!avatar.IsChildAgent) | ||
425 | { | ||
426 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
427 | avatar.currentParcelUUID = over.LandData.GlobalID; | ||
428 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
429 | m_scene.RegionInfo.RegionID); | ||
430 | } | ||
431 | } | ||
432 | */ | ||
433 | if (avatar.IsChildAgent) | ||
434 | return; | ||
435 | |||
455 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), | 436 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), |
456 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); | 437 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); |
457 | 438 | ||
458 | if (over != null) | 439 | if (over != null) |
459 | { | 440 | { |
460 | if (force) | 441 | bool NotsameID = (avatar.currentParcelUUID != over.LandData.GlobalID); |
442 | if (force || NotsameID) | ||
461 | { | 443 | { |
462 | if (!avatar.IsChildAgent) | 444 | over.SendLandUpdateToClient(avatar.ControllingClient); |
463 | { | 445 | if (NotsameID) |
464 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
465 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
466 | m_scene.RegionInfo.RegionID); | ||
467 | } | ||
468 | } | ||
469 | |||
470 | if (avatar.currentParcelUUID != over.LandData.GlobalID) | ||
471 | { | ||
472 | if (!avatar.IsChildAgent) | ||
473 | { | ||
474 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
475 | avatar.currentParcelUUID = over.LandData.GlobalID; | 446 | avatar.currentParcelUUID = over.LandData.GlobalID; |
476 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | 447 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, |
477 | m_scene.RegionInfo.RegionID); | 448 | m_scene.RegionInfo.RegionID); |
478 | } | ||
479 | } | 449 | } |
480 | } | 450 | } |
481 | } | 451 | } |
@@ -527,6 +497,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
527 | //when we are finally in a safe place, lets release the forced position lock | 497 | //when we are finally in a safe place, lets release the forced position lock |
528 | forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); | 498 | forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); |
529 | } | 499 | } |
500 | EnforceBans(parcel, clientAvatar); | ||
530 | } | 501 | } |
531 | } | 502 | } |
532 | 503 | ||
@@ -674,21 +645,28 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
674 | /// </summary> | 645 | /// </summary> |
675 | public void Clear(bool setupDefaultParcel) | 646 | public void Clear(bool setupDefaultParcel) |
676 | { | 647 | { |
648 | Dictionary<int, ILandObject> landworkList; | ||
649 | // move to work pointer since we are deleting it all | ||
677 | lock (m_landList) | 650 | lock (m_landList) |
678 | { | 651 | { |
679 | foreach (ILandObject lo in m_landList.Values) | 652 | landworkList = m_landList; |
680 | { | 653 | m_landList = new Dictionary<int, ILandObject>(); |
681 | //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); | 654 | } |
682 | m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); | ||
683 | } | ||
684 | 655 | ||
685 | m_landList.Clear(); | 656 | // this 2 methods have locks (now) |
657 | ResetSimLandObjects(); | ||
686 | 658 | ||
687 | ResetSimLandObjects(); | 659 | if (setupDefaultParcel) |
660 | CreateDefaultParcel(); | ||
688 | 661 | ||
689 | if (setupDefaultParcel) | 662 | // fire outside events unlocked |
690 | CreateDefaultParcel(); | 663 | foreach (ILandObject lo in landworkList.Values) |
664 | { | ||
665 | //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); | ||
666 | m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); | ||
691 | } | 667 | } |
668 | landworkList.Clear(); | ||
669 | |||
692 | } | 670 | } |
693 | 671 | ||
694 | private void performFinalLandJoin(ILandObject master, ILandObject slave) | 672 | private void performFinalLandJoin(ILandObject master, ILandObject slave) |
@@ -735,7 +713,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
735 | int x; | 713 | int x; |
736 | int y; | 714 | int y; |
737 | 715 | ||
738 | if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) | 716 | if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0) |
739 | return null; | 717 | return null; |
740 | 718 | ||
741 | try | 719 | try |
@@ -785,14 +763,13 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
785 | { | 763 | { |
786 | try | 764 | try |
787 | { | 765 | { |
788 | return m_landList[m_landIDList[x / 4, y / 4]]; | 766 | //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) |
767 | return m_landList[m_landIDList[x / 4, y / 4]]; | ||
768 | //else | ||
769 | // return null; | ||
789 | } | 770 | } |
790 | catch (IndexOutOfRangeException) | 771 | catch (IndexOutOfRangeException) |
791 | { | 772 | { |
792 | // m_log.WarnFormat( | ||
793 | // "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}", | ||
794 | // x, y, m_scene.RegionInfo.RegionName); | ||
795 | |||
796 | return null; | 773 | return null; |
797 | } | 774 | } |
798 | } | 775 | } |
@@ -1075,6 +1052,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1075 | //Owner Flag | 1052 | //Owner Flag |
1076 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); | 1053 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); |
1077 | } | 1054 | } |
1055 | else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID)) | ||
1056 | { | ||
1057 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP); | ||
1058 | } | ||
1078 | else if (currentParcelBlock.LandData.SalePrice > 0 && | 1059 | else if (currentParcelBlock.LandData.SalePrice > 0 && |
1079 | (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || | 1060 | (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || |
1080 | currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) | 1061 | currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) |
@@ -1155,8 +1136,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1155 | { | 1136 | { |
1156 | if (!temp.Contains(currentParcel)) | 1137 | if (!temp.Contains(currentParcel)) |
1157 | { | 1138 | { |
1158 | currentParcel.ForceUpdateLandInfo(); | 1139 | if (!currentParcel.IsEitherBannedOrRestricted(remote_client.AgentId)) |
1159 | temp.Add(currentParcel); | 1140 | { |
1141 | currentParcel.ForceUpdateLandInfo(); | ||
1142 | temp.Add(currentParcel); | ||
1143 | } | ||
1160 | } | 1144 | } |
1161 | } | 1145 | } |
1162 | } | 1146 | } |
@@ -1375,6 +1359,27 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1375 | 1359 | ||
1376 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) | 1360 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) |
1377 | { | 1361 | { |
1362 | Dictionary<int, ILandObject> landworkList; | ||
1363 | // move to work pointer since we are deleting it all | ||
1364 | lock (m_landList) | ||
1365 | { | ||
1366 | landworkList = m_landList; | ||
1367 | m_landList = new Dictionary<int, ILandObject>(); | ||
1368 | } | ||
1369 | |||
1370 | //Remove all the land objects in the sim and then process our new data | ||
1371 | foreach (int n in landworkList.Keys) | ||
1372 | { | ||
1373 | m_scene.EventManager.TriggerLandObjectRemoved(landworkList[n].LandData.GlobalID); | ||
1374 | } | ||
1375 | landworkList.Clear(); | ||
1376 | |||
1377 | lock (m_landList) | ||
1378 | { | ||
1379 | m_landIDList.Initialize(); | ||
1380 | m_landList.Clear(); | ||
1381 | } | ||
1382 | |||
1378 | for (int i = 0; i < data.Count; i++) | 1383 | for (int i = 0; i < data.Count; i++) |
1379 | { | 1384 | { |
1380 | IncomingLandObjectFromStorage(data[i]); | 1385 | IncomingLandObjectFromStorage(data[i]); |
@@ -1383,10 +1388,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1383 | 1388 | ||
1384 | public void IncomingLandObjectFromStorage(LandData data) | 1389 | public void IncomingLandObjectFromStorage(LandData data) |
1385 | { | 1390 | { |
1391 | |||
1386 | ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); | 1392 | ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); |
1387 | new_land.LandData = data.Copy(); | 1393 | new_land.LandData = data.Copy(); |
1388 | new_land.SetLandBitmapFromByteArray(); | 1394 | new_land.SetLandBitmapFromByteArray(); |
1389 | AddLandObject(new_land); | 1395 | AddLandObject(new_land); |
1396 | new_land.SendLandUpdateToAvatarsOverMe(); | ||
1390 | } | 1397 | } |
1391 | 1398 | ||
1392 | public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) | 1399 | public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) |
@@ -1404,7 +1411,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1404 | 1411 | ||
1405 | public void EventManagerOnNoLandDataFromStorage() | 1412 | public void EventManagerOnNoLandDataFromStorage() |
1406 | { | 1413 | { |
1407 | lock (m_landList) | 1414 | // called methods already have locks |
1415 | // lock (m_landList) | ||
1408 | { | 1416 | { |
1409 | ResetSimLandObjects(); | 1417 | ResetSimLandObjects(); |
1410 | CreateDefaultParcel(); | 1418 | CreateDefaultParcel(); |
@@ -1669,6 +1677,168 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1669 | 1677 | ||
1670 | UpdateLandObject(localID, land.LandData); | 1678 | UpdateLandObject(localID, land.LandData); |
1671 | } | 1679 | } |
1680 | |||
1681 | public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID) | ||
1682 | { | ||
1683 | ILandObject land = null; | ||
1684 | List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels(); | ||
1685 | foreach (ILandObject landObject in Land) | ||
1686 | { | ||
1687 | if (landObject.LandData.LocalID == landID) | ||
1688 | { | ||
1689 | land = landObject; | ||
1690 | } | ||
1691 | } | ||
1692 | land.DeedToGroup(DefaultGodParcelGroup); | ||
1693 | land.LandData.Name = DefaultGodParcelName; | ||
1694 | land.SendLandUpdateToAvatarsOverMe(); | ||
1695 | } | ||
1696 | |||
1697 | private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID) | ||
1698 | { | ||
1699 | ScenePresence SP; | ||
1700 | ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP); | ||
1701 | List<SceneObjectGroup> returns = new List<SceneObjectGroup>(); | ||
1702 | if (SP.UserLevel != 0) | ||
1703 | { | ||
1704 | if (flags == 0) //All parcels, scripted or not | ||
1705 | { | ||
1706 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1707 | { | ||
1708 | if (e.OwnerID == targetID) | ||
1709 | { | ||
1710 | returns.Add(e); | ||
1711 | } | ||
1712 | } | ||
1713 | ); | ||
1714 | } | ||
1715 | if (flags == 4) //All parcels, scripted object | ||
1716 | { | ||
1717 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1718 | { | ||
1719 | if (e.OwnerID == targetID) | ||
1720 | { | ||
1721 | if (e.ContainsScripts()) | ||
1722 | { | ||
1723 | returns.Add(e); | ||
1724 | } | ||
1725 | } | ||
1726 | } | ||
1727 | ); | ||
1728 | } | ||
1729 | if (flags == 4) //not target parcel, scripted object | ||
1730 | { | ||
1731 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1732 | { | ||
1733 | if (e.OwnerID == targetID) | ||
1734 | { | ||
1735 | ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y); | ||
1736 | if (landobject.LandData.OwnerID != e.OwnerID) | ||
1737 | { | ||
1738 | if (e.ContainsScripts()) | ||
1739 | { | ||
1740 | returns.Add(e); | ||
1741 | } | ||
1742 | } | ||
1743 | } | ||
1744 | } | ||
1745 | ); | ||
1746 | } | ||
1747 | foreach (SceneObjectGroup ol in returns) | ||
1748 | { | ||
1749 | ReturnObject(ol, client); | ||
1750 | } | ||
1751 | } | ||
1752 | } | ||
1753 | public void ReturnObject(SceneObjectGroup obj, IClientAPI client) | ||
1754 | { | ||
1755 | SceneObjectGroup[] objs = new SceneObjectGroup[1]; | ||
1756 | objs[0] = obj; | ||
1757 | ((Scene)client.Scene).returnObjects(objs, client.AgentId); | ||
1758 | } | ||
1759 | |||
1760 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | ||
1761 | |||
1762 | public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
1763 | { | ||
1764 | ScenePresence targetAvatar = null; | ||
1765 | ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar); | ||
1766 | ScenePresence parcelManager = null; | ||
1767 | ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager); | ||
1768 | System.Threading.Timer Timer; | ||
1769 | |||
1770 | if (targetAvatar.UserLevel == 0) | ||
1771 | { | ||
1772 | ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y); | ||
1773 | if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze)) | ||
1774 | return; | ||
1775 | if (flags == 0) | ||
1776 | { | ||
1777 | targetAvatar.AllowMovement = false; | ||
1778 | targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world."); | ||
1779 | parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen."); | ||
1780 | System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen); | ||
1781 | Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0); | ||
1782 | Timers.Add(targetAvatar.UUID, Timer); | ||
1783 | } | ||
1784 | else | ||
1785 | { | ||
1786 | targetAvatar.AllowMovement = true; | ||
1787 | targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you."); | ||
1788 | parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen."); | ||
1789 | Timers.TryGetValue(targetAvatar.UUID, out Timer); | ||
1790 | Timers.Remove(targetAvatar.UUID); | ||
1791 | Timer.Dispose(); | ||
1792 | } | ||
1793 | } | ||
1794 | } | ||
1795 | private void OnEndParcelFrozen(object avatar) | ||
1796 | { | ||
1797 | ScenePresence targetAvatar = (ScenePresence)avatar; | ||
1798 | targetAvatar.AllowMovement = true; | ||
1799 | System.Threading.Timer Timer; | ||
1800 | Timers.TryGetValue(targetAvatar.UUID, out Timer); | ||
1801 | Timers.Remove(targetAvatar.UUID); | ||
1802 | targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false); | ||
1803 | } | ||
1804 | |||
1805 | |||
1806 | public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
1807 | { | ||
1808 | ScenePresence targetAvatar = null; | ||
1809 | ScenePresence parcelManager = null; | ||
1810 | |||
1811 | // Must have presences | ||
1812 | if (!m_scene.TryGetScenePresence(target, out targetAvatar) || | ||
1813 | !m_scene.TryGetScenePresence(client.AgentId, out parcelManager)) | ||
1814 | return; | ||
1815 | |||
1816 | // Cannot eject estate managers or gods | ||
1817 | if (m_scene.Permissions.IsAdministrator(target)) | ||
1818 | return; | ||
1819 | |||
1820 | // Check if you even have permission to do this | ||
1821 | ILandObject land = m_scene.LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y); | ||
1822 | if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) && | ||
1823 | !m_scene.Permissions.IsAdministrator(client.AgentId)) | ||
1824 | return; | ||
1825 | |||
1826 | Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); | ||
1827 | |||
1828 | targetAvatar.TeleportWithMomentum(pos, null); | ||
1829 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1830 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); | ||
1831 | |||
1832 | if ((flags & 1) != 0) // Ban TODO: Remove magic number | ||
1833 | { | ||
1834 | LandAccessEntry entry = new LandAccessEntry(); | ||
1835 | entry.AgentID = targetAvatar.UUID; | ||
1836 | entry.Flags = AccessList.Ban; | ||
1837 | entry.Expires = 0; // Perm | ||
1838 | |||
1839 | land.LandData.ParcelAccessList.Add(entry); | ||
1840 | } | ||
1841 | } | ||
1672 | 1842 | ||
1673 | protected void InstallInterfaces() | 1843 | protected void InstallInterfaces() |
1674 | { | 1844 | { |
@@ -1731,5 +1901,27 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1731 | 1901 | ||
1732 | MainConsole.Instance.Output(report.ToString()); | 1902 | MainConsole.Instance.Output(report.ToString()); |
1733 | } | 1903 | } |
1904 | |||
1905 | public void EnforceBans(ILandObject land, ScenePresence avatar) | ||
1906 | { | ||
1907 | if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT) | ||
1908 | return; | ||
1909 | |||
1910 | if (land.IsEitherBannedOrRestricted(avatar.UUID)) | ||
1911 | { | ||
1912 | if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y))) | ||
1913 | { | ||
1914 | Vector3? pos = m_scene.GetNearestAllowedPosition(avatar); | ||
1915 | if (pos == null) | ||
1916 | m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient); | ||
1917 | else | ||
1918 | ForceAvatarToPosition(avatar, (Vector3)pos); | ||
1919 | } | ||
1920 | else | ||
1921 | { | ||
1922 | ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition); | ||
1923 | } | ||
1924 | } | ||
1925 | } | ||
1734 | } | 1926 | } |
1735 | } | 1927 | } |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 0536f6e..4f06737 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
50 | private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; | 50 | private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; |
51 | 51 | ||
52 | private int m_lastSeqId = 0; | 52 | private int m_lastSeqId = 0; |
53 | private int m_expiryCounter = 0; | ||
53 | 54 | ||
54 | protected LandData m_landData = new LandData(); | 55 | protected LandData m_landData = new LandData(); |
55 | protected Scene m_scene; | 56 | protected Scene m_scene; |
@@ -135,6 +136,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
135 | else | 136 | else |
136 | LandData.GroupID = UUID.Zero; | 137 | LandData.GroupID = UUID.Zero; |
137 | LandData.IsGroupOwned = is_group_owned; | 138 | LandData.IsGroupOwned = is_group_owned; |
139 | |||
140 | m_scene.EventManager.OnFrame += OnFrame; | ||
138 | } | 141 | } |
139 | 142 | ||
140 | #endregion | 143 | #endregion |
@@ -193,10 +196,27 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
193 | else | 196 | else |
194 | { | 197 | { |
195 | // Normal Calculations | 198 | // Normal Calculations |
196 | int parcelMax = (int)(((float)LandData.Area / 65536.0f) | 199 | int parcelMax = (int)((long)LandData.Area |
197 | * (float)m_scene.RegionInfo.ObjectCapacity | 200 | * (long)m_scene.RegionInfo.ObjectCapacity |
198 | * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); | 201 | * (long)m_scene.RegionInfo.RegionSettings.ObjectBonus |
199 | // TODO: The calculation of ObjectBonus should be refactored. It does still not work in the same manner as SL! | 202 | / 65536L); |
203 | //m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_scene.RegionInfo.ObjectCapacity, m_scene.RegionInfo.RegionSettings.ObjectBonus, parcelMax); | ||
204 | return parcelMax; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | private int GetParcelBasePrimCount() | ||
209 | { | ||
210 | if (overrideParcelMaxPrimCount != null) | ||
211 | { | ||
212 | return overrideParcelMaxPrimCount(this); | ||
213 | } | ||
214 | else | ||
215 | { | ||
216 | // Normal Calculations | ||
217 | int parcelMax = (int)((long)LandData.Area | ||
218 | * (long)m_scene.RegionInfo.ObjectCapacity | ||
219 | / 65536L); | ||
200 | return parcelMax; | 220 | return parcelMax; |
201 | } | 221 | } |
202 | } | 222 | } |
@@ -210,8 +230,9 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
210 | else | 230 | else |
211 | { | 231 | { |
212 | //Normal Calculations | 232 | //Normal Calculations |
213 | int simMax = (int)(((float)LandData.SimwideArea / 65536.0f) | 233 | int simMax = (int)((long)LandData.SimwideArea |
214 | * (float)m_scene.RegionInfo.ObjectCapacity); | 234 | * (long)m_scene.RegionInfo.ObjectCapacity / 65536L); |
235 | // m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}", LandData.SimwideArea, m_scene.RegionInfo.ObjectCapacity, simMax); | ||
215 | return simMax; | 236 | return simMax; |
216 | } | 237 | } |
217 | } | 238 | } |
@@ -248,7 +269,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
248 | remote_client.SendLandProperties(seq_id, | 269 | remote_client.SendLandProperties(seq_id, |
249 | snap_selection, request_result, this, | 270 | snap_selection, request_result, this, |
250 | (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, | 271 | (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, |
251 | GetParcelMaxPrimCount(), | 272 | GetParcelBasePrimCount(), |
252 | GetSimulatorMaxPrimCount(), regionFlags); | 273 | GetSimulatorMaxPrimCount(), regionFlags); |
253 | } | 274 | } |
254 | 275 | ||
@@ -308,7 +329,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
308 | 329 | ||
309 | allowedDelta |= (uint)(ParcelFlags.ShowDirectory | | 330 | allowedDelta |= (uint)(ParcelFlags.ShowDirectory | |
310 | ParcelFlags.AllowPublish | | 331 | ParcelFlags.AllowPublish | |
311 | ParcelFlags.MaturePublish); | 332 | ParcelFlags.MaturePublish) | (uint)(1 << 23); |
312 | } | 333 | } |
313 | 334 | ||
314 | if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) | 335 | if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) |
@@ -1181,6 +1202,17 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1181 | 1202 | ||
1182 | #endregion | 1203 | #endregion |
1183 | 1204 | ||
1205 | private void OnFrame() | ||
1206 | { | ||
1207 | m_expiryCounter++; | ||
1208 | |||
1209 | if (m_expiryCounter >= 50) | ||
1210 | { | ||
1211 | ExpireAccessList(); | ||
1212 | m_expiryCounter = 0; | ||
1213 | } | ||
1214 | } | ||
1215 | |||
1184 | private void ExpireAccessList() | 1216 | private void ExpireAccessList() |
1185 | { | 1217 | { |
1186 | List<LandAccessEntry> delete = new List<LandAccessEntry>(); | 1218 | List<LandAccessEntry> delete = new List<LandAccessEntry>(); |
@@ -1191,7 +1223,22 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1191 | delete.Add(entry); | 1223 | delete.Add(entry); |
1192 | } | 1224 | } |
1193 | foreach (LandAccessEntry entry in delete) | 1225 | foreach (LandAccessEntry entry in delete) |
1226 | { | ||
1194 | LandData.ParcelAccessList.Remove(entry); | 1227 | LandData.ParcelAccessList.Remove(entry); |
1228 | ScenePresence presence; | ||
1229 | |||
1230 | if (m_scene.TryGetScenePresence(entry.AgentID, out presence) && (!presence.IsChildAgent)) | ||
1231 | { | ||
1232 | ILandObject land = m_scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); | ||
1233 | if (land.LandData.LocalID == LandData.LocalID) | ||
1234 | { | ||
1235 | Vector3 pos = m_scene.GetNearestAllowedPosition(presence, land); | ||
1236 | presence.TeleportWithMomentum(pos, null); | ||
1237 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); | ||
1238 | } | ||
1239 | } | ||
1240 | m_log.DebugFormat("[LAND]: Removing entry {0} because it has expired", entry.AgentID); | ||
1241 | } | ||
1195 | 1242 | ||
1196 | if (delete.Count > 0) | 1243 | if (delete.Count > 0) |
1197 | m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this); | 1244 | 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 665875f..cbb3abe 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | |||
@@ -205,7 +205,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
205 | if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) | 205 | if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) |
206 | { | 206 | { |
207 | UUID landOwner = landData.OwnerID; | 207 | UUID landOwner = landData.OwnerID; |
208 | int partCount = obj.Parts.Length; | 208 | int partCount = obj.GetPartCount(); |
209 | 209 | ||
210 | m_SimwideCounts[landOwner] += partCount; | 210 | m_SimwideCounts[landOwner] += partCount; |
211 | if (parcelCounts.Users.ContainsKey(obj.OwnerID)) | 211 | if (parcelCounts.Users.ContainsKey(obj.OwnerID)) |
@@ -592,4 +592,4 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
592 | } | 592 | } |
593 | } | 593 | } |
594 | } | 594 | } |
595 | } \ No newline at end of file | 595 | } |
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs index 1e4f0a4..eb4731c 100644 --- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs | |||
@@ -176,6 +176,13 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell | |||
176 | return false; | 176 | return false; |
177 | } | 177 | } |
178 | 178 | ||
179 | if ((perms & (uint)PermissionMask.Copy) == 0) | ||
180 | { | ||
181 | if (m_dialogModule != null) | ||
182 | m_dialogModule.SendAlertToUser(remoteClient, "This sale has been blocked by the permissions system"); | ||
183 | return false; | ||
184 | } | ||
185 | |||
179 | AssetBase asset = m_scene.CreateAsset( | 186 | AssetBase asset = m_scene.CreateAsset( |
180 | group.GetPartName(localID), | 187 | group.GetPartName(localID), |
181 | group.GetPartDescription(localID), | 188 | group.GetPartDescription(localID), |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 7a8a57c..f3d38bc 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -368,7 +368,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
368 | 368 | ||
369 | public string Name | 369 | public string Name |
370 | { | 370 | { |
371 | get { return "PermissionsModule"; } | 371 | get { return "DefaultPermissionsModule"; } |
372 | } | 372 | } |
373 | 373 | ||
374 | public bool IsSharedModule | 374 | public bool IsSharedModule |
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs index fea4de0..287738a 100644 --- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs +++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs | |||
@@ -28,6 +28,8 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Timers; | 30 | using System.Timers; |
31 | using System.IO; | ||
32 | using System.Diagnostics; | ||
31 | using System.Threading; | 33 | using System.Threading; |
32 | using System.Collections.Generic; | 34 | using System.Collections.Generic; |
33 | using log4net; | 35 | using log4net; |
@@ -56,13 +58,24 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
56 | protected UUID m_Initiator; | 58 | protected UUID m_Initiator; |
57 | protected bool m_Notice = false; | 59 | protected bool m_Notice = false; |
58 | protected IDialogModule m_DialogModule = null; | 60 | protected IDialogModule m_DialogModule = null; |
61 | protected string m_MarkerPath = String.Empty; | ||
62 | private int[] m_CurrentAlerts = null; | ||
59 | 63 | ||
60 | public void Initialise(IConfigSource config) | 64 | public void Initialise(IConfigSource config) |
61 | { | 65 | { |
66 | IConfig restartConfig = config.Configs["RestartModule"]; | ||
67 | if (restartConfig != null) | ||
68 | { | ||
69 | m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty); | ||
70 | } | ||
62 | } | 71 | } |
63 | 72 | ||
64 | public void AddRegion(Scene scene) | 73 | public void AddRegion(Scene scene) |
65 | { | 74 | { |
75 | if (m_MarkerPath != String.Empty) | ||
76 | File.Delete(Path.Combine(m_MarkerPath, | ||
77 | scene.RegionInfo.RegionID.ToString())); | ||
78 | |||
66 | m_Scene = scene; | 79 | m_Scene = scene; |
67 | 80 | ||
68 | scene.RegisterModuleInterface<IRestartModule>(this); | 81 | scene.RegisterModuleInterface<IRestartModule>(this); |
@@ -121,6 +134,7 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
121 | 134 | ||
122 | if (alerts == null) | 135 | if (alerts == null) |
123 | { | 136 | { |
137 | CreateMarkerFile(); | ||
124 | m_Scene.RestartNow(); | 138 | m_Scene.RestartNow(); |
125 | return; | 139 | return; |
126 | } | 140 | } |
@@ -128,25 +142,28 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
128 | m_Message = message; | 142 | m_Message = message; |
129 | m_Initiator = initiator; | 143 | m_Initiator = initiator; |
130 | m_Notice = notice; | 144 | m_Notice = notice; |
145 | m_CurrentAlerts = alerts; | ||
131 | m_Alerts = new List<int>(alerts); | 146 | m_Alerts = new List<int>(alerts); |
132 | m_Alerts.Sort(); | 147 | m_Alerts.Sort(); |
133 | m_Alerts.Reverse(); | 148 | m_Alerts.Reverse(); |
134 | 149 | ||
135 | if (m_Alerts[0] == 0) | 150 | if (m_Alerts[0] == 0) |
136 | { | 151 | { |
152 | CreateMarkerFile(); | ||
137 | m_Scene.RestartNow(); | 153 | m_Scene.RestartNow(); |
138 | return; | 154 | return; |
139 | } | 155 | } |
140 | 156 | ||
141 | int nextInterval = DoOneNotice(); | 157 | int nextInterval = DoOneNotice(true); |
142 | 158 | ||
143 | SetTimer(nextInterval); | 159 | SetTimer(nextInterval); |
144 | } | 160 | } |
145 | 161 | ||
146 | public int DoOneNotice() | 162 | public int DoOneNotice(bool sendOut) |
147 | { | 163 | { |
148 | if (m_Alerts.Count == 0 || m_Alerts[0] == 0) | 164 | if (m_Alerts.Count == 0 || m_Alerts[0] == 0) |
149 | { | 165 | { |
166 | CreateMarkerFile(); | ||
150 | m_Scene.RestartNow(); | 167 | m_Scene.RestartNow(); |
151 | return 0; | 168 | return 0; |
152 | } | 169 | } |
@@ -167,34 +184,37 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
167 | 184 | ||
168 | m_Alerts.RemoveAt(0); | 185 | m_Alerts.RemoveAt(0); |
169 | 186 | ||
170 | int minutes = currentAlert / 60; | 187 | if (sendOut) |
171 | string currentAlertString = String.Empty; | ||
172 | if (minutes > 0) | ||
173 | { | 188 | { |
174 | if (minutes == 1) | 189 | int minutes = currentAlert / 60; |
175 | currentAlertString += "1 minute"; | 190 | string currentAlertString = String.Empty; |
176 | else | 191 | if (minutes > 0) |
177 | currentAlertString += String.Format("{0} minutes", minutes); | 192 | { |
193 | if (minutes == 1) | ||
194 | currentAlertString += "1 minute"; | ||
195 | else | ||
196 | currentAlertString += String.Format("{0} minutes", minutes); | ||
197 | if ((currentAlert % 60) != 0) | ||
198 | currentAlertString += " and "; | ||
199 | } | ||
178 | if ((currentAlert % 60) != 0) | 200 | if ((currentAlert % 60) != 0) |
179 | currentAlertString += " and "; | 201 | { |
180 | } | 202 | int seconds = currentAlert % 60; |
181 | if ((currentAlert % 60) != 0) | 203 | if (seconds == 1) |
182 | { | 204 | currentAlertString += "1 second"; |
183 | int seconds = currentAlert % 60; | 205 | else |
184 | if (seconds == 1) | 206 | currentAlertString += String.Format("{0} seconds", seconds); |
185 | currentAlertString += "1 second"; | 207 | } |
186 | else | ||
187 | currentAlertString += String.Format("{0} seconds", seconds); | ||
188 | } | ||
189 | 208 | ||
190 | string msg = String.Format(m_Message, currentAlertString); | 209 | string msg = String.Format(m_Message, currentAlertString); |
191 | 210 | ||
192 | if (m_DialogModule != null && msg != String.Empty) | 211 | if (m_DialogModule != null && msg != String.Empty) |
193 | { | 212 | { |
194 | if (m_Notice) | 213 | if (m_Notice) |
195 | m_DialogModule.SendGeneralAlert(msg); | 214 | m_DialogModule.SendGeneralAlert(msg); |
196 | else | 215 | else |
197 | m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg); | 216 | m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg); |
217 | } | ||
198 | } | 218 | } |
199 | 219 | ||
200 | return currentAlert - nextAlert; | 220 | return currentAlert - nextAlert; |
@@ -211,7 +231,25 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
211 | 231 | ||
212 | private void OnTimer(object source, ElapsedEventArgs e) | 232 | private void OnTimer(object source, ElapsedEventArgs e) |
213 | { | 233 | { |
214 | int nextInterval = DoOneNotice(); | 234 | int nextInterval = DoOneNotice(true); |
235 | |||
236 | SetTimer(nextInterval); | ||
237 | } | ||
238 | |||
239 | public void DelayRestart(int seconds, string message) | ||
240 | { | ||
241 | if (m_CountdownTimer == null) | ||
242 | return; | ||
243 | |||
244 | m_CountdownTimer.Stop(); | ||
245 | m_CountdownTimer = null; | ||
246 | |||
247 | m_Alerts = new List<int>(m_CurrentAlerts); | ||
248 | m_Alerts.Add(seconds); | ||
249 | m_Alerts.Sort(); | ||
250 | m_Alerts.Reverse(); | ||
251 | |||
252 | int nextInterval = DoOneNotice(false); | ||
215 | 253 | ||
216 | SetTimer(nextInterval); | 254 | SetTimer(nextInterval); |
217 | } | 255 | } |
@@ -225,6 +263,9 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
225 | if (m_DialogModule != null && message != String.Empty) | 263 | if (m_DialogModule != null && message != String.Empty) |
226 | m_DialogModule.SendGeneralAlert(message); | 264 | m_DialogModule.SendGeneralAlert(message); |
227 | } | 265 | } |
266 | if (m_MarkerPath != String.Empty) | ||
267 | File.Delete(Path.Combine(m_MarkerPath, | ||
268 | m_Scene.RegionInfo.RegionID.ToString())); | ||
228 | } | 269 | } |
229 | 270 | ||
230 | private void HandleRegionRestart(string module, string[] args) | 271 | private void HandleRegionRestart(string module, string[] args) |
@@ -266,5 +307,25 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
266 | 307 | ||
267 | ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); | 308 | ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); |
268 | } | 309 | } |
310 | |||
311 | protected void CreateMarkerFile() | ||
312 | { | ||
313 | if (m_MarkerPath == String.Empty) | ||
314 | return; | ||
315 | |||
316 | string path = Path.Combine(m_MarkerPath, m_Scene.RegionInfo.RegionID.ToString()); | ||
317 | try | ||
318 | { | ||
319 | string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); | ||
320 | FileStream fs = File.Create(path); | ||
321 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | ||
322 | Byte[] buf = enc.GetBytes(pidstring); | ||
323 | fs.Write(buf, 0, buf.Length); | ||
324 | fs.Close(); | ||
325 | } | ||
326 | catch (Exception) | ||
327 | { | ||
328 | } | ||
329 | } | ||
269 | } | 330 | } |
270 | } | 331 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 4694b14..d99567c 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -642,6 +642,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
642 | m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); | 642 | m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); |
643 | m_scene.SaveTerrain(); | 643 | m_scene.SaveTerrain(); |
644 | 644 | ||
645 | m_scene.EventManager.TriggerTerrainUpdate(); | ||
646 | |||
645 | // Clients who look at the map will never see changes after they looked at the map, so i've commented this out. | 647 | // Clients who look at the map will never see changes after they looked at the map, so i've commented this out. |
646 | //m_scene.CreateTerrainTexture(true); | 648 | //m_scene.CreateTerrainTexture(true); |
647 | } | 649 | } |
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index 2d762fb..33f6c3f 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | |||
@@ -63,6 +63,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
63 | private bool m_useAntiAliasing = false; // TODO: Make this a config option | 63 | private bool m_useAntiAliasing = false; // TODO: Make this a config option |
64 | private bool m_Enabled = false; | 64 | private bool m_Enabled = false; |
65 | 65 | ||
66 | private Bitmap lastImage = null; | ||
67 | private DateTime lastImageTime = DateTime.MinValue; | ||
68 | |||
66 | #region IRegionModule Members | 69 | #region IRegionModule Members |
67 | 70 | ||
68 | public void Initialise(IConfigSource source) | 71 | public void Initialise(IConfigSource source) |
@@ -85,14 +88,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
85 | 88 | ||
86 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); | 89 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); |
87 | if (renderers.Count > 0) | 90 | if (renderers.Count > 0) |
88 | { | 91 | m_log.Info("[MAPTILE]: Loaded prim mesher " + renderers[0]); |
89 | m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); | ||
90 | m_log.DebugFormat("[WARP 3D IMAGE MODULE]: Loaded prim mesher {0}", m_primMesher); | ||
91 | } | ||
92 | else | 92 | else |
93 | { | 93 | m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); |
94 | m_log.Debug("[WARP 3D IMAGE MODULE]: No prim mesher loaded, prim rendering will be disabled"); | ||
95 | } | ||
96 | 94 | ||
97 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); | 95 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); |
98 | } | 96 | } |
@@ -125,9 +123,25 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
125 | 123 | ||
126 | public Bitmap CreateMapTile() | 124 | public Bitmap CreateMapTile() |
127 | { | 125 | { |
126 | if ((DateTime.Now - lastImageTime).TotalSeconds < 3600) | ||
127 | { | ||
128 | return lastImage.Clone(new Rectangle(0, 0, 256, 256), lastImage.PixelFormat); | ||
129 | } | ||
130 | |||
131 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); | ||
132 | if (renderers.Count > 0) | ||
133 | { | ||
134 | m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); | ||
135 | } | ||
136 | |||
128 | Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); | 137 | Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); |
129 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, (int)Constants.RegionSize, (int)Constants.RegionSize, (float)Constants.RegionSize, (float)Constants.RegionSize); | 138 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, (int)Constants.RegionSize, (int)Constants.RegionSize, (float)Constants.RegionSize, (float)Constants.RegionSize); |
130 | return CreateMapTile(viewport, false); | 139 | Bitmap tile = CreateMapTile(viewport, false); |
140 | m_primMesher = null; | ||
141 | |||
142 | lastImage = tile; | ||
143 | lastImageTime = DateTime.Now; | ||
144 | return lastImage.Clone(new Rectangle(0, 0, 256, 256), lastImage.PixelFormat); | ||
131 | } | 145 | } |
132 | 146 | ||
133 | public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures) | 147 | 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 f37dd94..2417b1a 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | |||
@@ -86,90 +86,93 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
86 | 86 | ||
87 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) | 87 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) |
88 | { | 88 | { |
89 | if (mapName.Length < 3) | 89 | Util.FireAndForget(x => |
90 | { | 90 | { |
91 | remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); | 91 | if (mapName.Length < 2) |
92 | return; | 92 | { |
93 | } | 93 | remoteClient.SendAlertMessage("Use a search string with at least 2 characters"); |
94 | return; | ||
95 | } | ||
94 | 96 | ||
95 | //m_log.DebugFormat("MAP NAME=({0})", mapName); | 97 | //m_log.DebugFormat("MAP NAME=({0})", mapName); |
96 | 98 | ||
97 | // Hack to get around the fact that ll V3 now drops the port from the | 99 | // Hack to get around the fact that ll V3 now drops the port from the |
98 | // map name. See https://jira.secondlife.com/browse/VWR-28570 | 100 | // map name. See https://jira.secondlife.com/browse/VWR-28570 |
99 | // | 101 | // |
100 | // Caller, use this magic form instead: | 102 | // Caller, use this magic form instead: |
101 | // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 | 103 | // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 |
102 | // or url encode if possible. | 104 | // or url encode if possible. |
103 | // the hacks we do with this viewer... | 105 | // the hacks we do with this viewer... |
104 | // | 106 | // |
105 | string mapNameOrig = mapName; | 107 | string mapNameOrig = mapName; |
106 | if (mapName.Contains("|")) | 108 | if (mapName.Contains("|")) |
107 | mapName = mapName.Replace('|', ':'); | 109 | mapName = mapName.Replace('|', ':'); |
108 | if (mapName.Contains("+")) | 110 | if (mapName.Contains("+")) |
109 | mapName = mapName.Replace('+', ' '); | 111 | mapName = mapName.Replace('+', ' '); |
110 | if (mapName.Contains("!")) | 112 | if (mapName.Contains("!")) |
111 | mapName = mapName.Replace('!', '/'); | 113 | mapName = mapName.Replace('!', '/'); |
112 | 114 | ||
113 | // try to fetch from GridServer | 115 | // try to fetch from GridServer |
114 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); | 116 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); |
115 | if (regionInfos.Count == 0) | 117 | // if (regionInfos.Count == 0) |
116 | remoteClient.SendAlertMessage("Hyperlink could not be established."); | 118 | // remoteClient.SendAlertMessage("Hyperlink could not be established."); |
117 | 119 | ||
118 | m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); | 120 | //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); |
119 | List<MapBlockData> blocks = new List<MapBlockData>(); | 121 | List<MapBlockData> blocks = new List<MapBlockData>(); |
120 | 122 | ||
121 | MapBlockData data; | 123 | MapBlockData data; |
122 | if (regionInfos.Count > 0) | 124 | if (regionInfos.Count > 0) |
123 | { | ||
124 | foreach (GridRegion info in regionInfos) | ||
125 | { | 125 | { |
126 | data = new MapBlockData(); | 126 | foreach (GridRegion info in regionInfos) |
127 | data.Agents = 0; | 127 | { |
128 | data.Access = info.Access; | 128 | data = new MapBlockData(); |
129 | if (flags == 2) // V2 sends this | 129 | data.Agents = 0; |
130 | data.MapImageId = UUID.Zero; | 130 | data.Access = info.Access; |
131 | else | 131 | if (flags == 2) // V2 sends this |
132 | data.MapImageId = info.TerrainImage; | 132 | data.MapImageId = UUID.Zero; |
133 | // ugh! V2-3 is very sensitive about the result being | 133 | else |
134 | // exactly the same as the requested name | 134 | data.MapImageId = info.TerrainImage; |
135 | if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+")) | 135 | // ugh! V2-3 is very sensitive about the result being |
136 | data.Name = mapNameOrig; | 136 | // exactly the same as the requested name |
137 | else | 137 | if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+")) |
138 | data.Name = info.RegionName; | 138 | data.Name = mapNameOrig; |
139 | data.RegionFlags = 0; // TODO not used? | 139 | else |
140 | data.WaterHeight = 0; // not used | 140 | data.Name = info.RegionName; |
141 | data.X = (ushort)(info.RegionLocX / Constants.RegionSize); | 141 | data.RegionFlags = 0; // TODO not used? |
142 | data.Y = (ushort)(info.RegionLocY / Constants.RegionSize); | 142 | data.WaterHeight = 0; // not used |
143 | blocks.Add(data); | 143 | data.X = (ushort)(info.RegionLocX / Constants.RegionSize); |
144 | data.Y = (ushort)(info.RegionLocY / Constants.RegionSize); | ||
145 | blocks.Add(data); | ||
146 | } | ||
144 | } | 147 | } |
145 | } | ||
146 | 148 | ||
147 | // final block, closing the search result | 149 | // final block, closing the search result |
148 | data = new MapBlockData(); | 150 | data = new MapBlockData(); |
149 | data.Agents = 0; | 151 | data.Agents = 0; |
150 | data.Access = 255; | 152 | data.Access = 255; |
151 | data.MapImageId = UUID.Zero; | 153 | data.MapImageId = UUID.Zero; |
152 | data.Name = ""; // mapName; | 154 | data.Name = mapName; |
153 | data.RegionFlags = 0; | 155 | data.RegionFlags = 0; |
154 | data.WaterHeight = 0; // not used | 156 | data.WaterHeight = 0; // not used |
155 | data.X = 0; | 157 | data.X = 0; |
156 | data.Y = 0; | 158 | data.Y = 0; |
157 | blocks.Add(data); | 159 | blocks.Add(data); |
158 | 160 | ||
159 | // flags are agent flags sent from the viewer. | 161 | // flags are agent flags sent from the viewer. |
160 | // they have different values depending on different viewers, apparently | 162 | // they have different values depending on different viewers, apparently |
161 | remoteClient.SendMapBlock(blocks, flags); | 163 | remoteClient.SendMapBlock(blocks, flags); |
162 | 164 | ||
163 | // send extra user messages for V3 | 165 | // send extra user messages for V3 |
164 | // because the UI is very confusing | 166 | // because the UI is very confusing |
165 | // while we don't fix the hard-coded urls | 167 | // while we don't fix the hard-coded urls |
166 | if (flags == 2) | 168 | if (flags == 2) |
167 | { | 169 | { |
168 | if (regionInfos.Count == 0) | 170 | if (regionInfos.Count == 0) |
169 | remoteClient.SendAgentAlertMessage("No regions found with that name.", true); | 171 | remoteClient.SendAgentAlertMessage("No regions found with that name.", true); |
170 | else if (regionInfos.Count == 1) | 172 | else if (regionInfos.Count == 1) |
171 | remoteClient.SendAgentAlertMessage("Region found!", false); | 173 | remoteClient.SendAgentAlertMessage("Region found!", false); |
172 | } | 174 | } |
175 | }); | ||
173 | } | 176 | } |
174 | 177 | ||
175 | // private Scene GetClientScene(IClientAPI client) | 178 | // private Scene GetClientScene(IClientAPI client) |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index dfba3ff..26b406e 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -64,7 +64,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
64 | private static readonly UUID STOP_UUID = UUID.Random(); | 64 | private static readonly UUID STOP_UUID = UUID.Random(); |
65 | private static readonly string m_mapLayerPath = "0001/"; | 65 | private static readonly string m_mapLayerPath = "0001/"; |
66 | 66 | ||
67 | private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>(); | 67 | private ManualResetEvent queueEvent = new ManualResetEvent(false); |
68 | private Queue<MapRequestState> requests = new Queue<MapRequestState>(); | ||
69 | |||
70 | private ManualResetEvent m_mapBlockRequestEvent = new ManualResetEvent(false); | ||
71 | private Dictionary<UUID, Queue<MapBlockRequestData>> m_mapBlockRequests = new Dictionary<UUID, Queue<MapBlockRequestData>>(); | ||
68 | 72 | ||
69 | protected Scene m_scene; | 73 | protected Scene m_scene; |
70 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); | 74 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); |
@@ -72,7 +76,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
72 | private int blacklistTimeout = 10*60*1000; // 10 minutes | 76 | private int blacklistTimeout = 10*60*1000; // 10 minutes |
73 | private byte[] myMapImageJPEG; | 77 | private byte[] myMapImageJPEG; |
74 | protected volatile bool m_Enabled = false; | 78 | protected volatile bool m_Enabled = false; |
75 | private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>(); | ||
76 | private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); | 79 | private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); |
77 | private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); | 80 | private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); |
78 | private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>(); | 81 | private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>(); |
@@ -229,54 +232,54 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
229 | // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is | 232 | // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is |
230 | // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. | 233 | // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. |
231 | 234 | ||
232 | if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) | 235 | //if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) |
233 | { | 236 | //{ |
234 | ScenePresence avatarPresence = null; | 237 | // ScenePresence avatarPresence = null; |
235 | 238 | ||
236 | m_scene.TryGetScenePresence(agentID, out avatarPresence); | 239 | // m_scene.TryGetScenePresence(agentID, out avatarPresence); |
237 | 240 | ||
238 | if (avatarPresence != null) | 241 | // if (avatarPresence != null) |
239 | { | 242 | // { |
240 | bool lookup = false; | 243 | // bool lookup = false; |
241 | 244 | ||
242 | lock (cachedMapBlocks) | 245 | // lock (cachedMapBlocks) |
243 | { | 246 | // { |
244 | if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) | 247 | // if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) |
245 | { | 248 | // { |
246 | List<MapBlockData> mapBlocks; | 249 | // List<MapBlockData> mapBlocks; |
247 | 250 | ||
248 | mapBlocks = cachedMapBlocks; | 251 | // mapBlocks = cachedMapBlocks; |
249 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); | 252 | // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); |
250 | } | 253 | // } |
251 | else | 254 | // else |
252 | { | 255 | // { |
253 | lookup = true; | 256 | // lookup = true; |
254 | } | 257 | // } |
255 | } | 258 | // } |
256 | if (lookup) | 259 | // if (lookup) |
257 | { | 260 | // { |
258 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; | 261 | // List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; |
259 | 262 | ||
260 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | 263 | // List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
261 | (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, | 264 | // (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, |
262 | (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, | 265 | // (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, |
263 | (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, | 266 | // (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, |
264 | (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); | 267 | // (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); |
265 | foreach (GridRegion r in regions) | 268 | // foreach (GridRegion r in regions) |
266 | { | 269 | // { |
267 | MapBlockData block = new MapBlockData(); | 270 | // MapBlockData block = new MapBlockData(); |
268 | MapBlockFromGridRegion(block, r, 0); | 271 | // MapBlockFromGridRegion(block, r, 0); |
269 | mapBlocks.Add(block); | 272 | // mapBlocks.Add(block); |
270 | } | 273 | // } |
271 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); | 274 | // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); |
272 | 275 | ||
273 | lock (cachedMapBlocks) | 276 | // lock (cachedMapBlocks) |
274 | cachedMapBlocks = mapBlocks; | 277 | // cachedMapBlocks = mapBlocks; |
275 | 278 | ||
276 | cachedTime = Util.UnixTimeSinceEpoch(); | 279 | // cachedTime = Util.UnixTimeSinceEpoch(); |
277 | } | 280 | // } |
278 | } | 281 | // } |
279 | } | 282 | //} |
280 | 283 | ||
281 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); | 284 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); |
282 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); | 285 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); |
@@ -303,8 +306,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
303 | protected static OSDMapLayer GetOSDMapLayerResponse() | 306 | protected static OSDMapLayer GetOSDMapLayerResponse() |
304 | { | 307 | { |
305 | OSDMapLayer mapLayer = new OSDMapLayer(); | 308 | OSDMapLayer mapLayer = new OSDMapLayer(); |
306 | mapLayer.Right = 5000; | 309 | mapLayer.Right = 2048; |
307 | mapLayer.Top = 5000; | 310 | mapLayer.Top = 2048; |
308 | mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); | 311 | mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); |
309 | 312 | ||
310 | return mapLayer; | 313 | return mapLayer; |
@@ -333,6 +336,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
333 | { | 336 | { |
334 | m_rootAgents.Remove(AgentId); | 337 | m_rootAgents.Remove(AgentId); |
335 | } | 338 | } |
339 | lock (m_mapBlockRequestEvent) | ||
340 | { | ||
341 | if (m_mapBlockRequests.ContainsKey(AgentId)) | ||
342 | m_mapBlockRequests.Remove(AgentId); | ||
343 | } | ||
336 | } | 344 | } |
337 | #endregion | 345 | #endregion |
338 | 346 | ||
@@ -355,6 +363,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
355 | ThreadPriority.BelowNormal, | 363 | ThreadPriority.BelowNormal, |
356 | true, | 364 | true, |
357 | true); | 365 | true); |
366 | Watchdog.StartThread( | ||
367 | MapBlockSendThread, | ||
368 | string.Format("MapBlockSendThread ({0})", m_scene.RegionInfo.RegionName), | ||
369 | ThreadPriority.BelowNormal, | ||
370 | true, | ||
371 | true); | ||
358 | } | 372 | } |
359 | 373 | ||
360 | /// <summary> | 374 | /// <summary> |
@@ -370,7 +384,27 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
370 | st.itemtype=0; | 384 | st.itemtype=0; |
371 | st.regionhandle=0; | 385 | st.regionhandle=0; |
372 | 386 | ||
373 | requests.Enqueue(st); | 387 | lock (requests) |
388 | { | ||
389 | queueEvent.Set(); | ||
390 | requests.Enqueue(st); | ||
391 | } | ||
392 | |||
393 | MapBlockRequestData req = new MapBlockRequestData(); | ||
394 | |||
395 | req.client = null; | ||
396 | req.minX = 0; | ||
397 | req.maxX = 0; | ||
398 | req.minY = 0; | ||
399 | req.maxY = 0; | ||
400 | req.flags = 0; | ||
401 | |||
402 | lock (m_mapBlockRequestEvent) | ||
403 | { | ||
404 | m_mapBlockRequests[UUID.Zero] = new Queue<MapBlockRequestData>(); | ||
405 | m_mapBlockRequests[UUID.Zero].Enqueue(req); | ||
406 | m_mapBlockRequestEvent.Set(); | ||
407 | } | ||
374 | } | 408 | } |
375 | 409 | ||
376 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, | 410 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, |
@@ -526,7 +560,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
526 | { | 560 | { |
527 | while (true) | 561 | while (true) |
528 | { | 562 | { |
529 | MapRequestState st = requests.Dequeue(1000); | 563 | MapRequestState st = new MapRequestState(); |
564 | bool valid = false; | ||
565 | queueEvent.WaitOne(); | ||
566 | lock (requests) | ||
567 | { | ||
568 | if (requests.Count > 0) | ||
569 | { | ||
570 | st = requests.Dequeue(); | ||
571 | valid = true; | ||
572 | } | ||
573 | if (requests.Count == 0) | ||
574 | queueEvent.Reset(); | ||
575 | } | ||
576 | if (!valid) | ||
577 | continue; | ||
530 | 578 | ||
531 | // end gracefully | 579 | // end gracefully |
532 | if (st.agentID == STOP_UUID) | 580 | if (st.agentID == STOP_UUID) |
@@ -544,13 +592,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
544 | if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) | 592 | if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) |
545 | { | 593 | { |
546 | while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break | 594 | while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break |
547 | Thread.Sleep(80); | 595 | Thread.Sleep(100); |
548 | 596 | ||
549 | RequestMapItemsDelegate d = RequestMapItemsAsync; | ||
550 | d.BeginInvoke(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle, RequestMapItemsCompleted, null); | ||
551 | //OSDMap response = RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); | ||
552 | //RequestMapItemsCompleted(response); | ||
553 | Interlocked.Increment(ref nAsyncRequests); | 597 | Interlocked.Increment(ref nAsyncRequests); |
598 | Util.FireAndForget(x => | ||
599 | { | ||
600 | RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); | ||
601 | }); | ||
554 | } | 602 | } |
555 | } | 603 | } |
556 | 604 | ||
@@ -572,110 +620,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
572 | /// <param name="state"></param> | 620 | /// <param name="state"></param> |
573 | public void EnqueueMapItemRequest(MapRequestState state) | 621 | public void EnqueueMapItemRequest(MapRequestState state) |
574 | { | 622 | { |
575 | requests.Enqueue(state); | 623 | lock (requests) |
576 | } | ||
577 | |||
578 | /// <summary> | ||
579 | /// Sends the mapitem response to the IClientAPI | ||
580 | /// </summary> | ||
581 | /// <param name="response">The OSDMap Response for the mapitem</param> | ||
582 | private void RequestMapItemsCompleted(IAsyncResult iar) | ||
583 | { | ||
584 | AsyncResult result = (AsyncResult)iar; | ||
585 | RequestMapItemsDelegate icon = (RequestMapItemsDelegate)result.AsyncDelegate; | ||
586 | |||
587 | OSDMap response = (OSDMap)icon.EndInvoke(iar); | ||
588 | |||
589 | Interlocked.Decrement(ref nAsyncRequests); | ||
590 | |||
591 | if (!response.ContainsKey("requestID")) | ||
592 | return; | ||
593 | |||
594 | UUID requestID = response["requestID"].AsUUID(); | ||
595 | |||
596 | if (requestID != UUID.Zero) | ||
597 | { | 624 | { |
598 | MapRequestState mrs = new MapRequestState(); | 625 | queueEvent.Set(); |
599 | mrs.agentID = UUID.Zero; | 626 | requests.Enqueue(state); |
600 | lock (m_openRequests) | ||
601 | { | ||
602 | if (m_openRequests.ContainsKey(requestID)) | ||
603 | { | ||
604 | mrs = m_openRequests[requestID]; | ||
605 | m_openRequests.Remove(requestID); | ||
606 | } | ||
607 | } | ||
608 | |||
609 | if (mrs.agentID != UUID.Zero) | ||
610 | { | ||
611 | ScenePresence av = null; | ||
612 | m_scene.TryGetScenePresence(mrs.agentID, out av); | ||
613 | if (av != null) | ||
614 | { | ||
615 | if (response.ContainsKey(mrs.itemtype.ToString())) | ||
616 | { | ||
617 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
618 | OSDArray itemarray = (OSDArray)response[mrs.itemtype.ToString()]; | ||
619 | for (int i = 0; i < itemarray.Count; i++) | ||
620 | { | ||
621 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
622 | mapItemReply mi = new mapItemReply(); | ||
623 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
624 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
625 | mi.id = mapitem["ID"].AsUUID(); | ||
626 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
627 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
628 | mi.name = mapitem["Name"].AsString(); | ||
629 | returnitems.Add(mi); | ||
630 | } | ||
631 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags); | ||
632 | } | ||
633 | |||
634 | // Service 7 (MAP_ITEM_LAND_FOR_SALE) | ||
635 | uint itemtype = 7; | ||
636 | |||
637 | if (response.ContainsKey(itemtype.ToString())) | ||
638 | { | ||
639 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
640 | OSDArray itemarray = (OSDArray)response[itemtype.ToString()]; | ||
641 | for (int i = 0; i < itemarray.Count; i++) | ||
642 | { | ||
643 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
644 | mapItemReply mi = new mapItemReply(); | ||
645 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
646 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
647 | mi.id = mapitem["ID"].AsUUID(); | ||
648 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
649 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
650 | mi.name = mapitem["Name"].AsString(); | ||
651 | returnitems.Add(mi); | ||
652 | } | ||
653 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); | ||
654 | } | ||
655 | |||
656 | // Service 1 (MAP_ITEM_TELEHUB) | ||
657 | itemtype = 1; | ||
658 | |||
659 | if (response.ContainsKey(itemtype.ToString())) | ||
660 | { | ||
661 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
662 | OSDArray itemarray = (OSDArray)response[itemtype.ToString()]; | ||
663 | for (int i = 0; i < itemarray.Count; i++) | ||
664 | { | ||
665 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
666 | mapItemReply mi = new mapItemReply(); | ||
667 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
668 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
669 | mi.id = mapitem["ID"].AsUUID(); | ||
670 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
671 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
672 | mi.name = mapitem["Name"].AsString(); | ||
673 | returnitems.Add(mi); | ||
674 | } | ||
675 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); | ||
676 | } | ||
677 | } | ||
678 | } | ||
679 | } | 627 | } |
680 | } | 628 | } |
681 | 629 | ||
@@ -702,8 +650,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
702 | EnqueueMapItemRequest(st); | 650 | EnqueueMapItemRequest(st); |
703 | } | 651 | } |
704 | 652 | ||
705 | private delegate OSDMap RequestMapItemsDelegate(UUID id, uint flags, | ||
706 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle); | ||
707 | /// <summary> | 653 | /// <summary> |
708 | /// Does the actual remote mapitem request | 654 | /// Does the actual remote mapitem request |
709 | /// This should be called from an asynchronous thread | 655 | /// This should be called from an asynchronous thread |
@@ -718,7 +664,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
718 | /// <param name="itemtype">passed in from packet</param> | 664 | /// <param name="itemtype">passed in from packet</param> |
719 | /// <param name="regionhandle">Region we're looking up</param> | 665 | /// <param name="regionhandle">Region we're looking up</param> |
720 | /// <returns></returns> | 666 | /// <returns></returns> |
721 | private OSDMap RequestMapItemsAsync(UUID id, uint flags, | 667 | private void RequestMapItemsAsync(UUID id, uint flags, |
722 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) | 668 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) |
723 | { | 669 | { |
724 | // m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); | 670 | // m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); |
@@ -741,7 +687,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
741 | } | 687 | } |
742 | 688 | ||
743 | if (blacklisted) | 689 | if (blacklisted) |
744 | return new OSDMap(); | 690 | { |
691 | Interlocked.Decrement(ref nAsyncRequests); | ||
692 | return; | ||
693 | } | ||
745 | 694 | ||
746 | UUID requestID = UUID.Random(); | 695 | UUID requestID = UUID.Random(); |
747 | lock (m_cachedRegionMapItemsAddress) | 696 | lock (m_cachedRegionMapItemsAddress) |
@@ -749,6 +698,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
749 | if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) | 698 | if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) |
750 | httpserver = m_cachedRegionMapItemsAddress[regionhandle]; | 699 | httpserver = m_cachedRegionMapItemsAddress[regionhandle]; |
751 | } | 700 | } |
701 | |||
752 | if (httpserver.Length == 0) | 702 | if (httpserver.Length == 0) |
753 | { | 703 | { |
754 | uint x = 0, y = 0; | 704 | uint x = 0, y = 0; |
@@ -793,18 +743,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
793 | 743 | ||
794 | // Can't find the http server | 744 | // Can't find the http server |
795 | if (httpserver.Length == 0 || blacklisted) | 745 | if (httpserver.Length == 0 || blacklisted) |
796 | return new OSDMap(); | 746 | { |
797 | 747 | Interlocked.Decrement(ref nAsyncRequests); | |
798 | MapRequestState mrs = new MapRequestState(); | 748 | return; |
799 | mrs.agentID = id; | 749 | } |
800 | mrs.EstateID = EstateID; | ||
801 | mrs.flags = flags; | ||
802 | mrs.godlike = godlike; | ||
803 | mrs.itemtype=itemtype; | ||
804 | mrs.regionhandle = regionhandle; | ||
805 | |||
806 | lock (m_openRequests) | ||
807 | m_openRequests.Add(requestID, mrs); | ||
808 | 750 | ||
809 | WebRequest mapitemsrequest = null; | 751 | WebRequest mapitemsrequest = null; |
810 | try | 752 | try |
@@ -814,7 +756,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
814 | catch (Exception e) | 756 | catch (Exception e) |
815 | { | 757 | { |
816 | m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e); | 758 | m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e); |
817 | return new OSDMap(); | 759 | Interlocked.Decrement(ref nAsyncRequests); |
760 | return; | ||
818 | } | 761 | } |
819 | 762 | ||
820 | mapitemsrequest.Method = "POST"; | 763 | mapitemsrequest.Method = "POST"; |
@@ -839,7 +782,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
839 | catch (WebException ex) | 782 | catch (WebException ex) |
840 | { | 783 | { |
841 | m_log.WarnFormat("[WORLD MAP]: Bad send on GetMapItems {0}", ex.Message); | 784 | m_log.WarnFormat("[WORLD MAP]: Bad send on GetMapItems {0}", ex.Message); |
842 | responseMap["connect"] = OSD.FromBoolean(false); | ||
843 | lock (m_blacklistedurls) | 785 | lock (m_blacklistedurls) |
844 | { | 786 | { |
845 | if (!m_blacklistedurls.ContainsKey(httpserver)) | 787 | if (!m_blacklistedurls.ContainsKey(httpserver)) |
@@ -848,13 +790,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
848 | 790 | ||
849 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); | 791 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); |
850 | 792 | ||
851 | return responseMap; | 793 | Interlocked.Decrement(ref nAsyncRequests); |
794 | return; | ||
852 | } | 795 | } |
853 | catch | 796 | catch |
854 | { | 797 | { |
855 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); | 798 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); |
856 | responseMap["connect"] = OSD.FromBoolean(false); | 799 | Interlocked.Decrement(ref nAsyncRequests); |
857 | return responseMap; | 800 | return; |
858 | } | 801 | } |
859 | finally | 802 | finally |
860 | { | 803 | { |
@@ -875,12 +818,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
875 | } | 818 | } |
876 | else | 819 | else |
877 | { | 820 | { |
878 | return new OSDMap(); | 821 | Interlocked.Decrement(ref nAsyncRequests); |
822 | return; | ||
879 | } | 823 | } |
880 | } | 824 | } |
881 | catch (WebException) | 825 | catch (WebException) |
882 | { | 826 | { |
883 | responseMap["connect"] = OSD.FromBoolean(false); | ||
884 | lock (m_blacklistedurls) | 827 | lock (m_blacklistedurls) |
885 | { | 828 | { |
886 | if (!m_blacklistedurls.ContainsKey(httpserver)) | 829 | if (!m_blacklistedurls.ContainsKey(httpserver)) |
@@ -889,19 +832,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
889 | 832 | ||
890 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); | 833 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); |
891 | 834 | ||
892 | return responseMap; | 835 | Interlocked.Decrement(ref nAsyncRequests); |
836 | return; | ||
893 | } | 837 | } |
894 | catch | 838 | catch |
895 | { | 839 | { |
896 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); | 840 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); |
897 | responseMap["connect"] = OSD.FromBoolean(false); | ||
898 | lock (m_blacklistedregions) | 841 | lock (m_blacklistedregions) |
899 | { | 842 | { |
900 | if (!m_blacklistedregions.ContainsKey(regionhandle)) | 843 | if (!m_blacklistedregions.ContainsKey(regionhandle)) |
901 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); | 844 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); |
902 | } | 845 | } |
903 | 846 | ||
904 | return responseMap; | 847 | Interlocked.Decrement(ref nAsyncRequests); |
848 | return; | ||
905 | } | 849 | } |
906 | finally | 850 | finally |
907 | { | 851 | { |
@@ -920,14 +864,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
920 | catch (Exception ex) | 864 | catch (Exception ex) |
921 | { | 865 | { |
922 | m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); | 866 | m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); |
923 | responseMap["connect"] = OSD.FromBoolean(false); | ||
924 | lock (m_blacklistedregions) | 867 | lock (m_blacklistedregions) |
925 | { | 868 | { |
926 | if (!m_blacklistedregions.ContainsKey(regionhandle)) | 869 | if (!m_blacklistedregions.ContainsKey(regionhandle)) |
927 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); | 870 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); |
928 | } | 871 | } |
929 | 872 | ||
930 | return responseMap; | 873 | Interlocked.Decrement(ref nAsyncRequests); |
874 | return; | ||
931 | } | 875 | } |
932 | } | 876 | } |
933 | 877 | ||
@@ -941,7 +885,78 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
941 | } | 885 | } |
942 | } | 886 | } |
943 | 887 | ||
944 | return responseMap; | 888 | Interlocked.Decrement(ref nAsyncRequests); |
889 | |||
890 | if (id != UUID.Zero) | ||
891 | { | ||
892 | ScenePresence av = null; | ||
893 | m_scene.TryGetScenePresence(id, out av); | ||
894 | if (av != null) | ||
895 | { | ||
896 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
897 | { | ||
898 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
899 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
900 | for (int i = 0; i < itemarray.Count; i++) | ||
901 | { | ||
902 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
903 | mapItemReply mi = new mapItemReply(); | ||
904 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
905 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
906 | mi.id = mapitem["ID"].AsUUID(); | ||
907 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
908 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
909 | mi.name = mapitem["Name"].AsString(); | ||
910 | returnitems.Add(mi); | ||
911 | } | ||
912 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
913 | } | ||
914 | |||
915 | // Service 7 (MAP_ITEM_LAND_FOR_SALE) | ||
916 | itemtype = 7; | ||
917 | |||
918 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
919 | { | ||
920 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
921 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
922 | for (int i = 0; i < itemarray.Count; i++) | ||
923 | { | ||
924 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
925 | mapItemReply mi = new mapItemReply(); | ||
926 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
927 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
928 | mi.id = mapitem["ID"].AsUUID(); | ||
929 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
930 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
931 | mi.name = mapitem["Name"].AsString(); | ||
932 | returnitems.Add(mi); | ||
933 | } | ||
934 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
935 | } | ||
936 | |||
937 | // Service 1 (MAP_ITEM_TELEHUB) | ||
938 | itemtype = 1; | ||
939 | |||
940 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
941 | { | ||
942 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
943 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
944 | for (int i = 0; i < itemarray.Count; i++) | ||
945 | { | ||
946 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
947 | mapItemReply mi = new mapItemReply(); | ||
948 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
949 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
950 | mi.id = mapitem["ID"].AsUUID(); | ||
951 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
952 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
953 | mi.name = mapitem["Name"].AsString(); | ||
954 | returnitems.Add(mi); | ||
955 | } | ||
956 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
957 | } | ||
958 | } | ||
959 | } | ||
945 | } | 960 | } |
946 | 961 | ||
947 | /// <summary> | 962 | /// <summary> |
@@ -951,7 +966,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
951 | /// <param name="minY"></param> | 966 | /// <param name="minY"></param> |
952 | /// <param name="maxX"></param> | 967 | /// <param name="maxX"></param> |
953 | /// <param name="maxY"></param> | 968 | /// <param name="maxY"></param> |
954 | public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 969 | public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) |
955 | { | 970 | { |
956 | //m_log.ErrorFormat("[YYY] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag); | 971 | //m_log.ErrorFormat("[YYY] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag); |
957 | if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible | 972 | if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible |
@@ -1004,21 +1019,91 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1004 | 1019 | ||
1005 | protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 1020 | protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) |
1006 | { | 1021 | { |
1022 | MapBlockRequestData req = new MapBlockRequestData(); | ||
1023 | |||
1024 | req.client = remoteClient; | ||
1025 | req.minX = minX; | ||
1026 | req.maxX = maxX; | ||
1027 | req.minY = minY; | ||
1028 | req.maxY = maxY; | ||
1029 | req.flags = flag; | ||
1030 | |||
1031 | lock (m_mapBlockRequestEvent) | ||
1032 | { | ||
1033 | if (!m_mapBlockRequests.ContainsKey(remoteClient.AgentId)) | ||
1034 | m_mapBlockRequests[remoteClient.AgentId] = new Queue<MapBlockRequestData>(); | ||
1035 | m_mapBlockRequests[remoteClient.AgentId].Enqueue(req); | ||
1036 | m_mapBlockRequestEvent.Set(); | ||
1037 | } | ||
1038 | |||
1039 | return new List<MapBlockData>(); | ||
1040 | } | ||
1041 | |||
1042 | protected void MapBlockSendThread() | ||
1043 | { | ||
1044 | while (true) | ||
1045 | { | ||
1046 | List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>(); | ||
1047 | |||
1048 | m_mapBlockRequestEvent.WaitOne(); | ||
1049 | lock (m_mapBlockRequestEvent) | ||
1050 | { | ||
1051 | int total = 0; | ||
1052 | foreach (Queue<MapBlockRequestData> q in m_mapBlockRequests.Values) | ||
1053 | { | ||
1054 | if (q.Count > 0) | ||
1055 | thisRunData.Add(q.Dequeue()); | ||
1056 | |||
1057 | total += q.Count; | ||
1058 | } | ||
1059 | |||
1060 | if (total == 0) | ||
1061 | m_mapBlockRequestEvent.Reset(); | ||
1062 | } | ||
1063 | |||
1064 | foreach (MapBlockRequestData req in thisRunData) | ||
1065 | { | ||
1066 | // Null client stops thread | ||
1067 | if (req.client == null) | ||
1068 | return; | ||
1069 | |||
1070 | GetAndSendBlocksInternal(req.client, req.minX, req.minY, req.maxX, req.maxY, req.flags); | ||
1071 | } | ||
1072 | |||
1073 | Thread.Sleep(50); | ||
1074 | } | ||
1075 | } | ||
1076 | |||
1077 | protected virtual List<MapBlockData> GetAndSendBlocksInternal(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | ||
1078 | { | ||
1079 | List<MapBlockData> allBlocks = new List<MapBlockData>(); | ||
1007 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); | 1080 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); |
1008 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | 1081 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
1009 | (minX - 4) * (int)Constants.RegionSize, | 1082 | minX * (int)Constants.RegionSize, |
1010 | (maxX + 4) * (int)Constants.RegionSize, | 1083 | maxX * (int)Constants.RegionSize, |
1011 | (minY - 4) * (int)Constants.RegionSize, | 1084 | minY * (int)Constants.RegionSize, |
1012 | (maxY + 4) * (int)Constants.RegionSize); | 1085 | maxY * (int)Constants.RegionSize); |
1086 | // (minX - 4) * (int)Constants.RegionSize, | ||
1087 | // (maxX + 4) * (int)Constants.RegionSize, | ||
1088 | // (minY - 4) * (int)Constants.RegionSize, | ||
1089 | // (maxY + 4) * (int)Constants.RegionSize); | ||
1013 | foreach (GridRegion r in regions) | 1090 | foreach (GridRegion r in regions) |
1014 | { | 1091 | { |
1015 | MapBlockData block = new MapBlockData(); | 1092 | MapBlockData block = new MapBlockData(); |
1016 | MapBlockFromGridRegion(block, r, flag); | 1093 | MapBlockFromGridRegion(block, r, flag); |
1017 | mapBlocks.Add(block); | 1094 | mapBlocks.Add(block); |
1095 | allBlocks.Add(block); | ||
1096 | if (mapBlocks.Count >= 10) | ||
1097 | { | ||
1098 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | ||
1099 | mapBlocks.Clear(); | ||
1100 | Thread.Sleep(50); | ||
1101 | } | ||
1018 | } | 1102 | } |
1019 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | 1103 | if (mapBlocks.Count > 0) |
1104 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | ||
1020 | 1105 | ||
1021 | return mapBlocks; | 1106 | return allBlocks; |
1022 | } | 1107 | } |
1023 | 1108 | ||
1024 | protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) | 1109 | protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) |
@@ -1242,7 +1327,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1242 | } | 1327 | } |
1243 | else | 1328 | else |
1244 | { | 1329 | { |
1245 | OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); | 1330 | OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount()); |
1246 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 1331 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
1247 | { | 1332 | { |
1248 | OSDMap responsemapdata = new OSDMap(); | 1333 | OSDMap responsemapdata = new OSDMap(); |
@@ -1418,6 +1503,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1418 | { | 1503 | { |
1419 | m_rootAgents.Remove(avatar.UUID); | 1504 | m_rootAgents.Remove(avatar.UUID); |
1420 | } | 1505 | } |
1506 | |||
1507 | lock (m_mapBlockRequestEvent) | ||
1508 | { | ||
1509 | if (m_mapBlockRequests.ContainsKey(avatar.UUID)) | ||
1510 | m_mapBlockRequests.Remove(avatar.UUID); | ||
1511 | } | ||
1421 | } | 1512 | } |
1422 | 1513 | ||
1423 | public void OnRegionUp(GridRegion otherRegion) | 1514 | public void OnRegionUp(GridRegion otherRegion) |
@@ -1462,9 +1553,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1462 | Color background = Color.FromArgb(0, 0, 0, 0); | 1553 | Color background = Color.FromArgb(0, 0, 0, 0); |
1463 | SolidBrush transparent = new SolidBrush(background); | 1554 | SolidBrush transparent = new SolidBrush(background); |
1464 | Graphics g = Graphics.FromImage(overlay); | 1555 | Graphics g = Graphics.FromImage(overlay); |
1465 | g.FillRectangle(transparent, 0, 0, 256, 256); | 1556 | g.FillRectangle(transparent, 0, 0, 255, 255); |
1466 | 1557 | ||
1467 | SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); | 1558 | SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); |
1559 | Pen grey = new Pen(Color.FromArgb(255, 92, 92, 92)); | ||
1468 | 1560 | ||
1469 | foreach (ILandObject land in parcels) | 1561 | foreach (ILandObject land in parcels) |
1470 | { | 1562 | { |
@@ -1472,8 +1564,42 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1472 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) | 1564 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) |
1473 | { | 1565 | { |
1474 | landForSale = true; | 1566 | landForSale = true; |
1567 | |||
1568 | bool[,] landBitmap = land.GetLandBitmap(); | ||
1569 | |||
1570 | for (int x = 0 ; x < 64 ; x++) | ||
1571 | { | ||
1572 | for (int y = 0 ; y < 64 ; y++) | ||
1573 | { | ||
1574 | if (landBitmap[x, y]) | ||
1575 | { | ||
1576 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | ||
1577 | |||
1578 | if (x > 0) | ||
1579 | { | ||
1580 | if ((saleBitmap[x - 1, y] || landBitmap[x - 1, y]) == false) | ||
1581 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4, 255 - (y * 4)); | ||
1582 | } | ||
1583 | if (y > 0) | ||
1584 | { | ||
1585 | if ((saleBitmap[x, y-1] || landBitmap[x, y-1]) == false) | ||
1586 | g.DrawLine(grey, x * 4, 255 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1587 | } | ||
1588 | if (x < 63) | ||
1589 | { | ||
1590 | if ((saleBitmap[x + 1, y] || landBitmap[x + 1, y]) == false) | ||
1591 | g.DrawLine(grey, x * 4 + 3, 252 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1592 | } | ||
1593 | if (y < 63) | ||
1594 | { | ||
1595 | if ((saleBitmap[x, y + 1] || landBitmap[x, y + 1]) == false) | ||
1596 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4 + 3, 252 - (y * 4)); | ||
1597 | } | ||
1598 | } | ||
1599 | } | ||
1600 | } | ||
1475 | 1601 | ||
1476 | saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap()); | 1602 | saleBitmap = land.MergeLandBitmaps(saleBitmap, landBitmap); |
1477 | } | 1603 | } |
1478 | } | 1604 | } |
1479 | 1605 | ||
@@ -1485,15 +1611,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1485 | 1611 | ||
1486 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); | 1612 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); |
1487 | 1613 | ||
1488 | for (int x = 0 ; x < 64 ; x++) | ||
1489 | { | ||
1490 | for (int y = 0 ; y < 64 ; y++) | ||
1491 | { | ||
1492 | if (saleBitmap[x, y]) | ||
1493 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | ||
1494 | } | ||
1495 | } | ||
1496 | |||
1497 | try | 1614 | try |
1498 | { | 1615 | { |
1499 | return OpenJPEG.EncodeFromImage(overlay, true); | 1616 | return OpenJPEG.EncodeFromImage(overlay, true); |
@@ -1515,4 +1632,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1515 | public uint itemtype; | 1632 | public uint itemtype; |
1516 | public ulong regionhandle; | 1633 | public ulong regionhandle; |
1517 | } | 1634 | } |
1635 | |||
1636 | public struct MapBlockRequestData | ||
1637 | { | ||
1638 | public IClientAPI client; | ||
1639 | public int minX; | ||
1640 | public int minY; | ||
1641 | public int maxX; | ||
1642 | public int maxY; | ||
1643 | public uint flags; | ||
1644 | } | ||
1518 | } | 1645 | } |