diff options
Diffstat (limited to 'OpenSim/Region/CoreModules')
53 files changed, 3224 insertions, 1665 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 0271738..da1ff2e 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs | |||
@@ -143,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | public void RequestCreateInventoryItem(IClientAPI remoteClient, | 146 | public bool RequestCreateInventoryItem(IClientAPI remoteClient, |
147 | UUID transactionID, UUID folderID, uint callbackID, | 147 | UUID transactionID, UUID folderID, uint callbackID, |
148 | string description, string name, sbyte invType, | 148 | string description, string name, sbyte invType, |
149 | sbyte type, byte wearableType, uint nextOwnerMask) | 149 | sbyte type, byte wearableType, uint nextOwnerMask) |
@@ -153,6 +153,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
153 | uploader.RequestCreateInventoryItem( | 153 | uploader.RequestCreateInventoryItem( |
154 | remoteClient, folderID, callbackID, | 154 | remoteClient, folderID, callbackID, |
155 | description, name, invType, type, wearableType, nextOwnerMask); | 155 | description, name, invType, type, wearableType, nextOwnerMask); |
156 | |||
157 | return true; | ||
156 | } | 158 | } |
157 | 159 | ||
158 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, | 160 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, |
@@ -172,4 +174,4 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
172 | uploader.RequestUpdateInventoryItem(remoteClient, item); | 174 | uploader.RequestUpdateInventoryItem(remoteClient, item); |
173 | } | 175 | } |
174 | } | 176 | } |
175 | } \ No newline at end of file | 177 | } |
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index d1ad74f..faee189 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs | |||
@@ -158,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
158 | /// <param name="type"></param> | 158 | /// <param name="type"></param> |
159 | /// <param name="wearableType"></param> | 159 | /// <param name="wearableType"></param> |
160 | /// <param name="nextOwnerMask"></param> | 160 | /// <param name="nextOwnerMask"></param> |
161 | public void HandleItemCreationFromTransaction(IClientAPI remoteClient, | 161 | public bool HandleItemCreationFromTransaction(IClientAPI remoteClient, |
162 | UUID transactionID, UUID folderID, uint callbackID, | 162 | UUID transactionID, UUID folderID, uint callbackID, |
163 | string description, string name, sbyte invType, | 163 | string description, string name, sbyte invType, |
164 | sbyte type, byte wearableType, uint nextOwnerMask) | 164 | sbyte type, byte wearableType, uint nextOwnerMask) |
@@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
169 | AgentAssetTransactions transactions = | 169 | AgentAssetTransactions transactions = |
170 | GetUserTransactions(remoteClient.AgentId); | 170 | GetUserTransactions(remoteClient.AgentId); |
171 | 171 | ||
172 | transactions.RequestCreateInventoryItem(remoteClient, transactionID, | 172 | return transactions.RequestCreateInventoryItem(remoteClient, transactionID, |
173 | folderID, callbackID, description, name, invType, type, | 173 | folderID, callbackID, description, name, invType, type, |
174 | wearableType, nextOwnerMask); | 174 | wearableType, nextOwnerMask); |
175 | } | 175 | } |
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index 11efe6d..43b8b44 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Collections.Generic; | ||
31 | using log4net; | 32 | using log4net; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -38,6 +39,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
38 | { | 39 | { |
39 | public class AssetXferUploader | 40 | public class AssetXferUploader |
40 | { | 41 | { |
42 | // Viewer's notion of the default texture | ||
43 | private List<UUID> defaultIDs = new List<UUID> { | ||
44 | new UUID("5748decc-f629-461c-9a36-a35a221fe21f"), | ||
45 | new UUID("7ca39b4c-bd19-4699-aff7-f93fd03d3e7b"), | ||
46 | new UUID("6522e74d-1660-4e7f-b601-6f48c1659a77"), | ||
47 | new UUID("c228d1cf-4b5d-4ba8-84f4-899a0796aa97") | ||
48 | }; | ||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 50 | ||
43 | /// <summary> | 51 | /// <summary> |
@@ -85,6 +93,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
85 | 93 | ||
86 | private sbyte type = 0; | 94 | private sbyte type = 0; |
87 | private byte wearableType = 0; | 95 | private byte wearableType = 0; |
96 | private byte[] m_oldData = null; | ||
88 | public ulong XferID; | 97 | public ulong XferID; |
89 | private Scene m_Scene; | 98 | private Scene m_Scene; |
90 | 99 | ||
@@ -127,18 +136,27 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
127 | 136 | ||
128 | if (XferID == xferID) | 137 | if (XferID == xferID) |
129 | { | 138 | { |
130 | if (m_asset.Data.Length > 1) | 139 | lock (this) |
131 | { | 140 | { |
132 | byte[] destinationArray = new byte[m_asset.Data.Length + data.Length]; | 141 | int assetLength = m_asset.Data.Length; |
133 | Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length); | 142 | int dataLength = data.Length; |
134 | Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length); | 143 | |
135 | m_asset.Data = destinationArray; | 144 | if (m_asset.Data.Length > 1) |
136 | } | 145 | { |
137 | else | 146 | byte[] destinationArray = new byte[assetLength + dataLength]; |
138 | { | 147 | Array.Copy(m_asset.Data, 0, destinationArray, 0, assetLength); |
139 | byte[] buffer2 = new byte[data.Length - 4]; | 148 | Array.Copy(data, 0, destinationArray, assetLength, dataLength); |
140 | Array.Copy(data, 4, buffer2, 0, data.Length - 4); | 149 | m_asset.Data = destinationArray; |
141 | m_asset.Data = buffer2; | 150 | } |
151 | else | ||
152 | { | ||
153 | if (dataLength > 4) | ||
154 | { | ||
155 | byte[] buffer2 = new byte[dataLength - 4]; | ||
156 | Array.Copy(data, 4, buffer2, 0, dataLength - 4); | ||
157 | m_asset.Data = buffer2; | ||
158 | } | ||
159 | } | ||
142 | } | 160 | } |
143 | 161 | ||
144 | ourClient.SendConfirmXfer(xferID, packetID); | 162 | ourClient.SendConfirmXfer(xferID, packetID); |
@@ -394,6 +412,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
394 | 412 | ||
395 | private void CompleteCreateItem(uint callbackID) | 413 | private void CompleteCreateItem(uint callbackID) |
396 | { | 414 | { |
415 | ValidateAssets(); | ||
397 | m_Scene.AssetService.Store(m_asset); | 416 | m_Scene.AssetService.Store(m_asset); |
398 | 417 | ||
399 | InventoryItemBase item = new InventoryItemBase(); | 418 | InventoryItemBase item = new InventoryItemBase(); |
@@ -414,6 +433,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
414 | item.Flags = (uint) wearableType; | 433 | item.Flags = (uint) wearableType; |
415 | item.CreationDate = Util.UnixTimeSinceEpoch(); | 434 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
416 | 435 | ||
436 | m_log.DebugFormat("[XFER]: Created item {0} with asset {1}", | ||
437 | item.ID, item.AssetID); | ||
438 | |||
417 | if (m_Scene.AddInventoryItem(item)) | 439 | if (m_Scene.AddInventoryItem(item)) |
418 | ourClient.SendInventoryItemCreateUpdate(item, callbackID); | 440 | ourClient.SendInventoryItemCreateUpdate(item, callbackID); |
419 | else | 441 | else |
@@ -421,5 +443,132 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
421 | 443 | ||
422 | m_transactions.RemoveXferUploader(m_transactionID); | 444 | m_transactions.RemoveXferUploader(m_transactionID); |
423 | } | 445 | } |
446 | |||
447 | private void ValidateAssets() | ||
448 | { | ||
449 | if (m_asset.Type == (sbyte)AssetType.Clothing || | ||
450 | m_asset.Type == (sbyte)AssetType.Bodypart) | ||
451 | { | ||
452 | string content = System.Text.Encoding.ASCII.GetString(m_asset.Data); | ||
453 | string[] lines = content.Split(new char[] {'\n'}); | ||
454 | |||
455 | List<string> validated = new List<string>(); | ||
456 | |||
457 | Dictionary<int, UUID> allowed = ExtractTexturesFromOldData(); | ||
458 | |||
459 | int textures = 0; | ||
460 | |||
461 | foreach (string line in lines) | ||
462 | { | ||
463 | try | ||
464 | { | ||
465 | if (line.StartsWith("textures ")) | ||
466 | { | ||
467 | textures = Convert.ToInt32(line.Substring(9)); | ||
468 | validated.Add(line); | ||
469 | } | ||
470 | else if (textures > 0) | ||
471 | { | ||
472 | string[] parts = line.Split(new char[] {' '}); | ||
473 | |||
474 | UUID tx = new UUID(parts[1]); | ||
475 | int id = Convert.ToInt32(parts[0]); | ||
476 | |||
477 | if (defaultIDs.Contains(tx) || tx == UUID.Zero || | ||
478 | (allowed.ContainsKey(id) && allowed[id] == tx)) | ||
479 | { | ||
480 | validated.Add(parts[0] + " " + tx.ToString()); | ||
481 | } | ||
482 | else | ||
483 | { | ||
484 | int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, tx); | ||
485 | int full = (int)(PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Copy); | ||
486 | |||
487 | if ((perms & full) != full) | ||
488 | { | ||
489 | m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId); | ||
490 | validated.Add(parts[0] + " " + UUID.Zero.ToString()); | ||
491 | } | ||
492 | else | ||
493 | { | ||
494 | validated.Add(line); | ||
495 | } | ||
496 | } | ||
497 | textures--; | ||
498 | } | ||
499 | else | ||
500 | { | ||
501 | validated.Add(line); | ||
502 | } | ||
503 | } | ||
504 | catch | ||
505 | { | ||
506 | // If it's malformed, skip it | ||
507 | } | ||
508 | } | ||
509 | |||
510 | string final = String.Join("\n", validated.ToArray()); | ||
511 | |||
512 | m_asset.Data = System.Text.Encoding.ASCII.GetBytes(final); | ||
513 | } | ||
514 | } | ||
515 | |||
516 | /// <summary> | ||
517 | /// Get the asset data uploaded in this transfer. | ||
518 | /// </summary> | ||
519 | /// <returns>null if the asset has not finished uploading</returns> | ||
520 | public AssetBase GetAssetData() | ||
521 | { | ||
522 | if (m_uploadState == UploadState.Complete) | ||
523 | { | ||
524 | ValidateAssets(); | ||
525 | return m_asset; | ||
526 | } | ||
527 | |||
528 | return null; | ||
529 | } | ||
530 | |||
531 | public void SetOldData(byte[] d) | ||
532 | { | ||
533 | m_oldData = d; | ||
534 | } | ||
535 | |||
536 | private Dictionary<int,UUID> ExtractTexturesFromOldData() | ||
537 | { | ||
538 | Dictionary<int,UUID> result = new Dictionary<int,UUID>(); | ||
539 | if (m_oldData == null) | ||
540 | return result; | ||
541 | |||
542 | string content = System.Text.Encoding.ASCII.GetString(m_oldData); | ||
543 | string[] lines = content.Split(new char[] {'\n'}); | ||
544 | |||
545 | int textures = 0; | ||
546 | |||
547 | foreach (string line in lines) | ||
548 | { | ||
549 | try | ||
550 | { | ||
551 | if (line.StartsWith("textures ")) | ||
552 | { | ||
553 | textures = Convert.ToInt32(line.Substring(9)); | ||
554 | } | ||
555 | else if (textures > 0) | ||
556 | { | ||
557 | string[] parts = line.Split(new char[] {' '}); | ||
558 | |||
559 | UUID tx = new UUID(parts[1]); | ||
560 | int id = Convert.ToInt32(parts[0]); | ||
561 | result[id] = tx; | ||
562 | textures--; | ||
563 | } | ||
564 | } | ||
565 | catch | ||
566 | { | ||
567 | // If it's malformed, skip it | ||
568 | } | ||
569 | } | ||
570 | |||
571 | return result; | ||
572 | } | ||
424 | } | 573 | } |
425 | } \ No newline at end of file | 574 | } |
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index 4299726..7113f4f 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | |||
@@ -160,6 +160,8 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
160 | { | 160 | { |
161 | byte[] fileData = NewFiles[fileName].Data; | 161 | byte[] fileData = NewFiles[fileName].Data; |
162 | XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); | 162 | XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); |
163 | if (fileName.StartsWith("inventory_")) | ||
164 | transaction.isTaskInventory = true; | ||
163 | 165 | ||
164 | Transfers.Add(xferID, transaction); | 166 | Transfers.Add(xferID, transaction); |
165 | 167 | ||
@@ -243,6 +245,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
243 | public uint Packet = 0; | 245 | public uint Packet = 0; |
244 | public uint Serial = 1; | 246 | public uint Serial = 1; |
245 | public ulong XferID = 0; | 247 | public ulong XferID = 0; |
248 | public bool isTaskInventory = false; | ||
246 | 249 | ||
247 | public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) | 250 | public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) |
248 | { | 251 | { |
@@ -268,7 +271,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
268 | byte[] transferData = new byte[Data.Length + 4]; | 271 | byte[] transferData = new byte[Data.Length + 4]; |
269 | Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); | 272 | Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); |
270 | Array.Copy(Data, 0, transferData, 4, Data.Length); | 273 | Array.Copy(Data, 0, transferData, 4, Data.Length); |
271 | Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); | 274 | Client.SendXferPacket(XferID, 0 + 0x80000000, transferData, isTaskInventory); |
272 | complete = true; | 275 | complete = true; |
273 | } | 276 | } |
274 | else | 277 | else |
@@ -276,7 +279,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
276 | byte[] transferData = new byte[1000 + 4]; | 279 | byte[] transferData = new byte[1000 + 4]; |
277 | Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); | 280 | Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); |
278 | Array.Copy(Data, 0, transferData, 4, 1000); | 281 | Array.Copy(Data, 0, transferData, 4, 1000); |
279 | Client.SendXferPacket(XferID, 0, transferData); | 282 | Client.SendXferPacket(XferID, 0, transferData, isTaskInventory); |
280 | Packet++; | 283 | Packet++; |
281 | DataPointer = 1000; | 284 | DataPointer = 1000; |
282 | } | 285 | } |
@@ -297,7 +300,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
297 | { | 300 | { |
298 | byte[] transferData = new byte[1000]; | 301 | byte[] transferData = new byte[1000]; |
299 | Array.Copy(Data, DataPointer, transferData, 0, 1000); | 302 | Array.Copy(Data, DataPointer, transferData, 0, 1000); |
300 | Client.SendXferPacket(XferID, Packet, transferData); | 303 | Client.SendXferPacket(XferID, Packet, transferData, isTaskInventory); |
301 | Packet++; | 304 | Packet++; |
302 | DataPointer += 1000; | 305 | DataPointer += 1000; |
303 | } | 306 | } |
@@ -306,7 +309,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
306 | byte[] transferData = new byte[Data.Length - DataPointer]; | 309 | byte[] transferData = new byte[Data.Length - DataPointer]; |
307 | Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); | 310 | Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); |
308 | uint endPacket = Packet |= (uint) 0x80000000; | 311 | uint endPacket = Packet |= (uint) 0x80000000; |
309 | Client.SendXferPacket(XferID, endPacket, transferData); | 312 | Client.SendXferPacket(XferID, endPacket, transferData, isTaskInventory); |
310 | Packet++; | 313 | Packet++; |
311 | DataPointer += (Data.Length - DataPointer); | 314 | DataPointer += (Data.Length - DataPointer); |
312 | 315 | ||
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index e40caec..f43305f 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -194,6 +194,12 @@ namespace OpenSim.Region.CoreModules.Asset | |||
194 | 194 | ||
195 | #region IImprovedAssetCache Members | 195 | #region IImprovedAssetCache Members |
196 | 196 | ||
197 | |||
198 | public bool Check(string id) | ||
199 | { | ||
200 | return false; | ||
201 | } | ||
202 | |||
197 | /// <summary> | 203 | /// <summary> |
198 | /// Cache asset. | 204 | /// Cache asset. |
199 | /// </summary> | 205 | /// </summary> |
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index 9742a5c..58ce61a 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs | |||
@@ -112,6 +112,10 @@ namespace OpenSim.Region.CoreModules.Asset | |||
112 | //////////////////////////////////////////////////////////// | 112 | //////////////////////////////////////////////////////////// |
113 | // IImprovedAssetCache | 113 | // IImprovedAssetCache |
114 | // | 114 | // |
115 | public bool Check(string id) | ||
116 | { | ||
117 | return false; | ||
118 | } | ||
115 | 119 | ||
116 | public void Cache(AssetBase asset) | 120 | public void Cache(AssetBase asset) |
117 | { | 121 | { |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 00af175..730643d 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -251,57 +251,70 @@ namespace OpenSim.Region.CoreModules.Asset | |||
251 | 251 | ||
252 | private void UpdateFileCache(string key, AssetBase asset) | 252 | private void UpdateFileCache(string key, AssetBase asset) |
253 | { | 253 | { |
254 | string filename = GetFileName(asset.ID); | 254 | // TODO: Spawn this off to some seperate thread to do the actual writing |
255 | 255 | if (asset != null) | |
256 | try | ||
257 | { | 256 | { |
258 | // If the file is already cached just update access time. | 257 | string filename = GetFileName(key); |
259 | if (File.Exists(filename)) | 258 | |
260 | { | 259 | try |
261 | lock (m_CurrentlyWriting) | ||
262 | { | ||
263 | if (!m_CurrentlyWriting.Contains(filename)) | ||
264 | File.SetLastAccessTime(filename, DateTime.Now); | ||
265 | } | ||
266 | } | ||
267 | else | ||
268 | { | 260 | { |
269 | // Once we start writing, make sure we flag that we're writing | 261 | // If the file is already cached, don't cache it, just touch it so access time is updated |
270 | // that object to the cache so that we don't try to write the | 262 | if (File.Exists(filename)) |
271 | // same file multiple times. | ||
272 | lock (m_CurrentlyWriting) | ||
273 | { | 263 | { |
274 | #if WAIT_ON_INPROGRESS_REQUESTS | 264 | // We don't really want to know about sharing |
275 | if (m_CurrentlyWriting.ContainsKey(filename)) | 265 | // violations here. If the file is locked, then |
266 | // the other thread has updated the time for us. | ||
267 | try | ||
276 | { | 268 | { |
277 | return; | 269 | lock (m_CurrentlyWriting) |
270 | { | ||
271 | if (!m_CurrentlyWriting.Contains(filename)) | ||
272 | File.SetLastAccessTime(filename, DateTime.Now); | ||
273 | } | ||
278 | } | 274 | } |
279 | else | 275 | catch |
280 | { | 276 | { |
281 | m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); | ||
282 | } | ||
283 | |||
284 | #else | ||
285 | if (m_CurrentlyWriting.Contains(filename)) | ||
286 | { | ||
287 | return; | ||
288 | } | 277 | } |
289 | else | 278 | } else { |
279 | |||
280 | // Once we start writing, make sure we flag that we're writing | ||
281 | // that object to the cache so that we don't try to write the | ||
282 | // same file multiple times. | ||
283 | lock (m_CurrentlyWriting) | ||
290 | { | 284 | { |
291 | m_CurrentlyWriting.Add(filename); | 285 | #if WAIT_ON_INPROGRESS_REQUESTS |
292 | } | 286 | if (m_CurrentlyWriting.ContainsKey(filename)) |
287 | { | ||
288 | return; | ||
289 | } | ||
290 | else | ||
291 | { | ||
292 | m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); | ||
293 | } | ||
294 | |||
295 | #else | ||
296 | if (m_CurrentlyWriting.Contains(filename)) | ||
297 | { | ||
298 | return; | ||
299 | } | ||
300 | else | ||
301 | { | ||
302 | m_CurrentlyWriting.Add(filename); | ||
303 | } | ||
293 | #endif | 304 | #endif |
294 | } | ||
295 | 305 | ||
296 | Util.FireAndForget( | 306 | } |
297 | delegate { WriteFileCache(filename, asset); }); | 307 | |
308 | Util.FireAndForget( | ||
309 | delegate { WriteFileCache(filename, asset); }); | ||
310 | } | ||
311 | } | ||
312 | catch (Exception e) | ||
313 | { | ||
314 | m_log.ErrorFormat( | ||
315 | "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", | ||
316 | asset.ID, e.Message, e.StackTrace); | ||
298 | } | 317 | } |
299 | } | ||
300 | catch (Exception e) | ||
301 | { | ||
302 | m_log.ErrorFormat( | ||
303 | "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", | ||
304 | asset.ID, e.Message, e.StackTrace); | ||
305 | } | 318 | } |
306 | } | 319 | } |
307 | 320 | ||
@@ -335,6 +348,17 @@ namespace OpenSim.Region.CoreModules.Asset | |||
335 | return asset; | 348 | return asset; |
336 | } | 349 | } |
337 | 350 | ||
351 | private bool CheckFromMemoryCache(string id) | ||
352 | { | ||
353 | AssetBase asset = null; | ||
354 | |||
355 | if (m_MemoryCache.TryGetValue(id, out asset)) | ||
356 | return true; | ||
357 | |||
358 | return false; | ||
359 | } | ||
360 | |||
361 | |||
338 | /// <summary> | 362 | /// <summary> |
339 | /// Try to get an asset from the file cache. | 363 | /// Try to get an asset from the file cache. |
340 | /// </summary> | 364 | /// </summary> |
@@ -407,6 +431,50 @@ namespace OpenSim.Region.CoreModules.Asset | |||
407 | return asset; | 431 | return asset; |
408 | } | 432 | } |
409 | 433 | ||
434 | private bool CheckFromFileCache(string id) | ||
435 | { | ||
436 | bool found = false; | ||
437 | |||
438 | string filename = GetFileName(id); | ||
439 | if (File.Exists(filename)) | ||
440 | { | ||
441 | // actually check if we can open it, and so update expire | ||
442 | FileStream stream = null; | ||
443 | try | ||
444 | { | ||
445 | stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); | ||
446 | if (stream != null) | ||
447 | { | ||
448 | found = true; | ||
449 | stream.Close(); | ||
450 | } | ||
451 | |||
452 | } | ||
453 | catch (System.Runtime.Serialization.SerializationException e) | ||
454 | { | ||
455 | found = false; | ||
456 | m_log.ErrorFormat( | ||
457 | "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", | ||
458 | filename, id, e.Message, e.StackTrace); | ||
459 | |||
460 | // If there was a problem deserializing the asset, the asset may | ||
461 | // either be corrupted OR was serialized under an old format | ||
462 | // {different version of AssetBase} -- we should attempt to | ||
463 | // delete it and re-cache | ||
464 | File.Delete(filename); | ||
465 | } | ||
466 | catch (Exception e) | ||
467 | { | ||
468 | found = false; | ||
469 | m_log.ErrorFormat( | ||
470 | "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", | ||
471 | filename, id, e.Message, e.StackTrace); | ||
472 | } | ||
473 | } | ||
474 | |||
475 | return found; | ||
476 | } | ||
477 | |||
410 | public AssetBase Get(string id) | 478 | public AssetBase Get(string id) |
411 | { | 479 | { |
412 | m_Requests++; | 480 | m_Requests++; |
@@ -443,11 +511,26 @@ namespace OpenSim.Region.CoreModules.Asset | |||
443 | return asset; | 511 | return asset; |
444 | } | 512 | } |
445 | 513 | ||
514 | public bool Check(string id) | ||
515 | { | ||
516 | if (m_MemoryCacheEnabled && CheckFromMemoryCache(id)) | ||
517 | return true; | ||
518 | |||
519 | if (m_FileCacheEnabled && CheckFromFileCache(id)) | ||
520 | return true; | ||
521 | return false; | ||
522 | } | ||
523 | |||
446 | public AssetBase GetCached(string id) | 524 | public AssetBase GetCached(string id) |
447 | { | 525 | { |
448 | return Get(id); | 526 | return Get(id); |
449 | } | 527 | } |
450 | 528 | ||
529 | public AssetBase CheckCached(string id) | ||
530 | { | ||
531 | return Get(id); | ||
532 | } | ||
533 | |||
451 | public void Expire(string id) | 534 | public void Expire(string id) |
452 | { | 535 | { |
453 | if (m_LogLevel >= 2) | 536 | if (m_LogLevel >= 2) |
@@ -939,6 +1022,11 @@ namespace OpenSim.Region.CoreModules.Asset | |||
939 | return asset.Data; | 1022 | return asset.Data; |
940 | } | 1023 | } |
941 | 1024 | ||
1025 | public bool CheckData(string id) | ||
1026 | { | ||
1027 | return Check(id); ; | ||
1028 | } | ||
1029 | |||
942 | public bool Get(string id, object sender, AssetRetrieved handler) | 1030 | public bool Get(string id, object sender, AssetRetrieved handler) |
943 | { | 1031 | { |
944 | AssetBase asset = Get(id); | 1032 | AssetBase asset = Get(id); |
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index 9592ca0..ce9b546 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs | |||
@@ -115,6 +115,11 @@ namespace OpenSim.Region.CoreModules.Asset | |||
115 | // IImprovedAssetCache | 115 | // IImprovedAssetCache |
116 | // | 116 | // |
117 | 117 | ||
118 | public bool Check(string id) | ||
119 | { | ||
120 | return false; | ||
121 | } | ||
122 | |||
118 | public void Cache(AssetBase asset) | 123 | public void Cache(AssetBase asset) |
119 | { | 124 | { |
120 | if (asset != null) | 125 | if (asset != null) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 8a3eeaa..6323160 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Region.Framework; | |||
40 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Scenes.Serialization; | 42 | using OpenSim.Region.Framework.Scenes.Serialization; |
43 | using OpenSim.Services.Interfaces; | ||
43 | 44 | ||
44 | namespace OpenSim.Region.CoreModules.Avatar.Attachments | 45 | namespace OpenSim.Region.CoreModules.Avatar.Attachments |
45 | { | 46 | { |
@@ -75,40 +76,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
75 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); | 76 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); |
76 | 77 | ||
77 | if (Enabled) | 78 | if (Enabled) |
78 | { | ||
79 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; | 79 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; |
80 | m_scene.EventManager.OnStartScript += (localID, itemID) => HandleScriptStateChange(localID, true); | ||
81 | m_scene.EventManager.OnStopScript += (localID, itemID) => HandleScriptStateChange(localID, false); | ||
82 | } | ||
83 | 80 | ||
84 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI | 81 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI |
85 | } | 82 | } |
86 | |||
87 | /// <summary> | ||
88 | /// Listen for client triggered running state changes so that we can persist the script's object if necessary. | ||
89 | /// </summary> | ||
90 | /// <param name='localID'></param> | ||
91 | /// <param name='itemID'></param> | ||
92 | private void HandleScriptStateChange(uint localID, bool started) | ||
93 | { | ||
94 | SceneObjectGroup sog = m_scene.GetGroupByPrim(localID); | ||
95 | if (sog != null && sog.IsAttachment) | ||
96 | { | ||
97 | if (!started) | ||
98 | { | ||
99 | // FIXME: This is a convoluted way for working out whether the script state has changed to stop | ||
100 | // because it has been manually stopped or because the stop was called in UpdateDetachedObject() below | ||
101 | // This needs to be handled in a less tangled way. | ||
102 | ScenePresence sp = m_scene.GetScenePresence(sog.AttachedAvatar); | ||
103 | if (sp.ControllingClient.IsActive) | ||
104 | sog.HasGroupChanged = true; | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | sog.HasGroupChanged = true; | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | 83 | ||
113 | public void RemoveRegion(Scene scene) | 84 | public void RemoveRegion(Scene scene) |
114 | { | 85 | { |
@@ -199,6 +170,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
199 | 170 | ||
200 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0}", sp.Name); | 171 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0}", sp.Name); |
201 | 172 | ||
173 | XmlDocument doc = new XmlDocument(); | ||
174 | string stateData = String.Empty; | ||
175 | |||
176 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
177 | if (attServ != null) | ||
178 | { | ||
179 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
180 | stateData = attServ.Get(sp.UUID.ToString()); | ||
181 | if (stateData != String.Empty) | ||
182 | { | ||
183 | try | ||
184 | { | ||
185 | doc.LoadXml(stateData); | ||
186 | } | ||
187 | catch { } | ||
188 | } | ||
189 | } | ||
190 | |||
191 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
192 | |||
193 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
194 | if (nodes.Count > 0) | ||
195 | { | ||
196 | foreach (XmlNode n in nodes) | ||
197 | { | ||
198 | XmlElement elem = (XmlElement)n; | ||
199 | string itemID = elem.GetAttribute("ItemID"); | ||
200 | string xml = elem.InnerXml; | ||
201 | |||
202 | itemData[new UUID(itemID)] = xml; | ||
203 | } | ||
204 | } | ||
205 | |||
206 | |||
202 | List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); | 207 | List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); |
203 | foreach (AvatarAttachment attach in attachments) | 208 | foreach (AvatarAttachment attach in attachments) |
204 | { | 209 | { |
@@ -218,12 +223,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
218 | 223 | ||
219 | try | 224 | try |
220 | { | 225 | { |
226 | string xmlData; | ||
227 | XmlDocument d = null; | ||
228 | UUID asset; | ||
229 | if (itemData.TryGetValue(attach.ItemID, out xmlData)) | ||
230 | { | ||
231 | d = new XmlDocument(); | ||
232 | d.LoadXml(xmlData); | ||
233 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", attach.ItemID); | ||
234 | } | ||
235 | |||
221 | // If we're an NPC then skip all the item checks and manipulations since we don't have an | 236 | // If we're an NPC then skip all the item checks and manipulations since we don't have an |
222 | // inventory right now. | 237 | // inventory right now. |
223 | if (sp.PresenceType == PresenceType.Npc) | 238 | if (sp.PresenceType == PresenceType.Npc) |
224 | RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p); | 239 | RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null); |
225 | else | 240 | else |
226 | RezSingleAttachmentFromInventory(sp, attach.ItemID, p); | 241 | RezSingleAttachmentFromInventory(sp, attach.ItemID, p, d); |
227 | } | 242 | } |
228 | catch (Exception e) | 243 | catch (Exception e) |
229 | { | 244 | { |
@@ -268,13 +283,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
268 | 283 | ||
269 | sp.ClearAttachments(); | 284 | sp.ClearAttachments(); |
270 | } | 285 | } |
271 | 286 | ||
272 | public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp) | 287 | public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp) |
273 | { | 288 | { |
274 | if (!Enabled) | 289 | if (!Enabled) |
275 | return false; | 290 | return false; |
276 | 291 | ||
277 | if (AttachObjectInternal(sp, group, attachmentPt, silent, temp)) | 292 | if (AttachObjectInternal(sp, group, attachmentPt, silent, useAttachData, temp)) |
278 | { | 293 | { |
279 | m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID); | 294 | m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID); |
280 | return true; | 295 | return true; |
@@ -283,7 +298,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
283 | return false; | 298 | return false; |
284 | } | 299 | } |
285 | 300 | ||
286 | private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp) | 301 | private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp) |
287 | { | 302 | { |
288 | lock (sp.AttachmentsSyncLock) | 303 | lock (sp.AttachmentsSyncLock) |
289 | { | 304 | { |
@@ -338,6 +353,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
338 | attachPos = Vector3.Zero; | 353 | attachPos = Vector3.Zero; |
339 | } | 354 | } |
340 | 355 | ||
356 | if (useAttachData) | ||
357 | { | ||
358 | group.RootPart.RotationOffset = group.RootPart.AttachRotation; | ||
359 | attachPos = group.RootPart.AttachOffset; | ||
360 | if (attachmentPt == 0) | ||
361 | { | ||
362 | attachmentPt = group.RootPart.AttachPoint; | ||
363 | if (attachmentPt == 0) | ||
364 | { | ||
365 | attachmentPt = (uint)AttachmentPoint.LeftHand; | ||
366 | attachPos = Vector3.Zero; | ||
367 | } | ||
368 | } | ||
369 | else if (group.RootPart.AttachPoint != attachmentPt) | ||
370 | { | ||
371 | attachPos = Vector3.Zero; | ||
372 | } | ||
373 | } | ||
341 | group.AttachmentPoint = attachmentPt; | 374 | group.AttachmentPoint = attachmentPt; |
342 | group.AbsolutePosition = attachPos; | 375 | group.AbsolutePosition = attachPos; |
343 | 376 | ||
@@ -378,7 +411,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
378 | } | 411 | } |
379 | } | 412 | } |
380 | 413 | ||
381 | public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) | 414 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) |
415 | { | ||
416 | return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, null); | ||
417 | } | ||
418 | |||
419 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, XmlDocument doc) | ||
382 | { | 420 | { |
383 | if (!Enabled) | 421 | if (!Enabled) |
384 | return null; | 422 | return null; |
@@ -417,7 +455,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
417 | return null; | 455 | return null; |
418 | } | 456 | } |
419 | 457 | ||
420 | return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt); | 458 | return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc); |
421 | } | 459 | } |
422 | 460 | ||
423 | public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) | 461 | public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) |
@@ -491,7 +529,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
491 | so.AttachedAvatar = UUID.Zero; | 529 | so.AttachedAvatar = UUID.Zero; |
492 | rootPart.SetParentLocalId(0); | 530 | rootPart.SetParentLocalId(0); |
493 | so.ClearPartAttachmentData(); | 531 | so.ClearPartAttachmentData(); |
494 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive); | 532 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive,false); |
495 | so.HasGroupChanged = true; | 533 | so.HasGroupChanged = true; |
496 | rootPart.Rezzed = DateTime.Now; | 534 | rootPart.Rezzed = DateTime.Now; |
497 | rootPart.RemFlag(PrimFlags.TemporaryOnRez); | 535 | rootPart.RemFlag(PrimFlags.TemporaryOnRez); |
@@ -803,8 +841,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
803 | UpdateDetachedObject(sp, so); | 841 | UpdateDetachedObject(sp, so); |
804 | } | 842 | } |
805 | 843 | ||
806 | private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( | 844 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( |
807 | IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt) | 845 | IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc) |
808 | { | 846 | { |
809 | if (m_invAccessModule == null) | 847 | if (m_invAccessModule == null) |
810 | return null; | 848 | return null; |
@@ -842,7 +880,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
842 | // This will throw if the attachment fails | 880 | // This will throw if the attachment fails |
843 | try | 881 | try |
844 | { | 882 | { |
845 | AttachObjectInternal(sp, objatt, attachmentPt, false, false); | 883 | AttachObjectInternal(sp, objatt, attachmentPt, false, false, false); |
846 | } | 884 | } |
847 | catch (Exception e) | 885 | catch (Exception e) |
848 | { | 886 | { |
@@ -855,10 +893,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
855 | m_scene.DeleteSceneObject(objatt, false); | 893 | m_scene.DeleteSceneObject(objatt, false); |
856 | return null; | 894 | return null; |
857 | } | 895 | } |
858 | 896 | ||
859 | if (tainted) | 897 | if (tainted) |
860 | objatt.HasGroupChanged = true; | 898 | objatt.HasGroupChanged = true; |
861 | 899 | ||
900 | if (doc != null) | ||
901 | { | ||
902 | objatt.LoadScriptState(doc); | ||
903 | objatt.ResetOwnerChangeFlag(); | ||
904 | } | ||
905 | |||
862 | // Fire after attach, so we don't get messy perms dialogs | 906 | // Fire after attach, so we don't get messy perms dialogs |
863 | // 4 == AttachedRez | 907 | // 4 == AttachedRez |
864 | objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); | 908 | objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); |
@@ -876,7 +920,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
876 | itemID, sp.Name, attachmentPt); | 920 | itemID, sp.Name, attachmentPt); |
877 | } | 921 | } |
878 | } | 922 | } |
879 | 923 | ||
880 | return null; | 924 | return null; |
881 | } | 925 | } |
882 | 926 | ||
@@ -999,7 +1043,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
999 | AttachmentPt &= 0x7f; | 1043 | AttachmentPt &= 0x7f; |
1000 | 1044 | ||
1001 | // Calls attach with a Zero position | 1045 | // Calls attach with a Zero position |
1002 | AttachObject(sp, part.ParentGroup, AttachmentPt, false, false); | 1046 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false)) |
1047 | { | ||
1048 | // m_log.Debug( | ||
1049 | // "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | ||
1050 | // + ", AttachmentPoint: " + AttachmentPt); | ||
1051 | |||
1052 | // Save avatar attachment information | ||
1053 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); | ||
1054 | } | ||
1003 | } | 1055 | } |
1004 | catch (Exception e) | 1056 | catch (Exception e) |
1005 | { | 1057 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 0ee01c7..4e9d3f9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -197,7 +197,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
197 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); | 197 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); |
198 | 198 | ||
199 | m_numberOfAttachEventsFired = 0; | 199 | m_numberOfAttachEventsFired = 0; |
200 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); | 200 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); |
201 | 201 | ||
202 | // Check status on scene presence | 202 | // Check status on scene presence |
203 | Assert.That(sp.HasAttachments(), Is.True); | 203 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -254,7 +254,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
254 | sp2.AbsolutePosition = new Vector3(0, 0, 0); | 254 | sp2.AbsolutePosition = new Vector3(0, 0, 0); |
255 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); | 255 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); |
256 | 256 | ||
257 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); | 257 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); |
258 | 258 | ||
259 | Assert.That(sp.HasAttachments(), Is.False); | 259 | Assert.That(sp.HasAttachments(), Is.False); |
260 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 260 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
@@ -438,7 +438,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
438 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | 438 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; |
439 | 439 | ||
440 | SceneObjectGroup rezzedSo | 440 | SceneObjectGroup rezzedSo |
441 | = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | 441 | = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest)); |
442 | 442 | ||
443 | // Wait for chat to signal rezzed script has been started. | 443 | // Wait for chat to signal rezzed script has been started. |
444 | m_chatEvent.WaitOne(60000); | 444 | m_chatEvent.WaitOne(60000); |
@@ -457,7 +457,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
457 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); | 457 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); |
458 | 458 | ||
459 | // Re-rez the attachment to check script running state | 459 | // Re-rez the attachment to check script running state |
460 | SceneObjectGroup reRezzedSo = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | 460 | SceneObjectGroup reRezzedSo = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest)); |
461 | 461 | ||
462 | // Wait for chat to signal rezzed script has been started. | 462 | // Wait for chat to signal rezzed script has been started. |
463 | m_chatEvent.WaitOne(60000); | 463 | m_chatEvent.WaitOne(60000); |
@@ -663,4 +663,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
663 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); | 663 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); |
664 | } | 664 | } |
665 | } | 665 | } |
666 | } \ No newline at end of file | 666 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index ce79f07..3c6bbe6 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -140,9 +140,24 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
140 | /// <param name="sp"></param> | 140 | /// <param name="sp"></param> |
141 | /// <param name="texture"></param> | 141 | /// <param name="texture"></param> |
142 | /// <param name="visualParam"></param> | 142 | /// <param name="visualParam"></param> |
143 | public void SetAppearance(IScenePresence sp, AvatarAppearance appearance) | 143 | public void SetAppearance(IScenePresence sp, AvatarAppearance appearance, WearableCacheItem[] cacheItems) |
144 | { | 144 | { |
145 | SetAppearance(sp, appearance.Texture, appearance.VisualParams); | 145 | SetAppearance(sp, appearance.Texture, appearance.VisualParams, cacheItems); |
146 | } | ||
147 | |||
148 | |||
149 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) | ||
150 | { | ||
151 | float oldoff = sp.Appearance.AvatarFeetOffset; | ||
152 | Vector3 oldbox = sp.Appearance.AvatarBoxSize; | ||
153 | |||
154 | SetAppearance(sp, textureEntry, visualParams, cacheItems); | ||
155 | sp.Appearance.SetSize(avSize); | ||
156 | |||
157 | float off = sp.Appearance.AvatarFeetOffset; | ||
158 | Vector3 box = sp.Appearance.AvatarBoxSize; | ||
159 | if (oldoff != off || oldbox != box) | ||
160 | ((ScenePresence)sp).SetSize(box, off); | ||
146 | } | 161 | } |
147 | 162 | ||
148 | /// <summary> | 163 | /// <summary> |
@@ -151,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
151 | /// <param name="sp"></param> | 166 | /// <param name="sp"></param> |
152 | /// <param name="texture"></param> | 167 | /// <param name="texture"></param> |
153 | /// <param name="visualParam"></param> | 168 | /// <param name="visualParam"></param> |
154 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams) | 169 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, WearableCacheItem[] cacheItems) |
155 | { | 170 | { |
156 | // m_log.DebugFormat( | 171 | // m_log.DebugFormat( |
157 | // "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}", | 172 | // "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}", |
@@ -174,18 +189,27 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
174 | // m_log.DebugFormat( | 189 | // m_log.DebugFormat( |
175 | // "[AVFACTORY]: Setting visual params for {0} to {1}", | 190 | // "[AVFACTORY]: Setting visual params for {0} to {1}", |
176 | // client.Name, string.Join(", ", visualParamsStrings)); | 191 | // client.Name, string.Join(", ", visualParamsStrings)); |
177 | 192 | /* | |
178 | float oldHeight = sp.Appearance.AvatarHeight; | 193 | float oldHeight = sp.Appearance.AvatarHeight; |
179 | changed = sp.Appearance.SetVisualParams(visualParams); | 194 | changed = sp.Appearance.SetVisualParams(visualParams); |
180 | 195 | ||
181 | if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) | 196 | if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) |
182 | ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); | 197 | ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); |
183 | } | 198 | */ |
199 | // float oldoff = sp.Appearance.AvatarFeetOffset; | ||
200 | // Vector3 oldbox = sp.Appearance.AvatarBoxSize; | ||
201 | changed = sp.Appearance.SetVisualParams(visualParams); | ||
202 | // float off = sp.Appearance.AvatarFeetOffset; | ||
203 | // Vector3 box = sp.Appearance.AvatarBoxSize; | ||
204 | // if(oldoff != off || oldbox != box) | ||
205 | // ((ScenePresence)sp).SetSize(box,off); | ||
184 | 206 | ||
207 | } | ||
208 | |||
185 | // Process the baked texture array | 209 | // Process the baked texture array |
186 | if (textureEntry != null) | 210 | if (textureEntry != null) |
187 | { | 211 | { |
188 | // m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); | 212 | m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); |
189 | 213 | ||
190 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); | 214 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); |
191 | 215 | ||
@@ -254,6 +278,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
254 | return GetBakedTextureFaces(sp); | 278 | return GetBakedTextureFaces(sp); |
255 | } | 279 | } |
256 | 280 | ||
281 | public WearableCacheItem[] GetCachedItems(UUID agentId) | ||
282 | { | ||
283 | ScenePresence sp = m_scene.GetScenePresence(agentId); | ||
284 | WearableCacheItem[] items = sp.Appearance.WearableCacheItems; | ||
285 | //foreach (WearableCacheItem item in items) | ||
286 | //{ | ||
287 | |||
288 | //} | ||
289 | return items; | ||
290 | } | ||
291 | |||
257 | public bool SaveBakedTextures(UUID agentId) | 292 | public bool SaveBakedTextures(UUID agentId) |
258 | { | 293 | { |
259 | ScenePresence sp = m_scene.GetScenePresence(agentId); | 294 | ScenePresence sp = m_scene.GetScenePresence(agentId); |
@@ -340,6 +375,53 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
340 | public bool ValidateBakedTextureCache(IScenePresence sp) | 375 | public bool ValidateBakedTextureCache(IScenePresence sp) |
341 | { | 376 | { |
342 | bool defonly = true; // are we only using default textures | 377 | bool defonly = true; // are we only using default textures |
378 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
379 | IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
380 | WearableCacheItem[] wearableCache = null; | ||
381 | |||
382 | // Cache wearable data for teleport. | ||
383 | // Only makes sense if there's a bake module and a cache module | ||
384 | if (bakedModule != null && cache != null) | ||
385 | { | ||
386 | try | ||
387 | { | ||
388 | wearableCache = bakedModule.Get(sp.UUID); | ||
389 | } | ||
390 | catch (Exception) | ||
391 | { | ||
392 | |||
393 | } | ||
394 | if (wearableCache != null) | ||
395 | { | ||
396 | for (int i = 0; i < wearableCache.Length; i++) | ||
397 | { | ||
398 | cache.Cache(wearableCache[i].TextureAsset); | ||
399 | } | ||
400 | } | ||
401 | } | ||
402 | /* | ||
403 | IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
404 | if (invService.GetRootFolder(userID) != null) | ||
405 | { | ||
406 | WearableCacheItem[] wearableCache = null; | ||
407 | if (bakedModule != null) | ||
408 | { | ||
409 | try | ||
410 | { | ||
411 | wearableCache = bakedModule.Get(userID); | ||
412 | appearance.WearableCacheItems = wearableCache; | ||
413 | appearance.WearableCacheItemsDirty = false; | ||
414 | foreach (WearableCacheItem item in wearableCache) | ||
415 | { | ||
416 | appearance.Texture.FaceTextures[item.TextureIndex].TextureID = item.TextureID; | ||
417 | } | ||
418 | } | ||
419 | catch (Exception) | ||
420 | { | ||
421 | |||
422 | } | ||
423 | } | ||
424 | */ | ||
343 | 425 | ||
344 | // Process the texture entry | 426 | // Process the texture entry |
345 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | 427 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) |
@@ -347,9 +429,32 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
347 | int idx = AvatarAppearance.BAKE_INDICES[i]; | 429 | int idx = AvatarAppearance.BAKE_INDICES[i]; |
348 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; | 430 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; |
349 | 431 | ||
350 | // if there is no texture entry, skip it | 432 | // No face, so lets check our baked service cache, teleport or login. |
351 | if (face == null) | 433 | if (face == null) |
352 | continue; | 434 | { |
435 | if (wearableCache != null) | ||
436 | { | ||
437 | // If we find the an appearance item, set it as the textureentry and the face | ||
438 | WearableCacheItem searchitem = WearableCacheItem.SearchTextureIndex((uint) idx, wearableCache); | ||
439 | if (searchitem != null) | ||
440 | { | ||
441 | sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx); | ||
442 | sp.Appearance.Texture.FaceTextures[idx].TextureID = searchitem.TextureID; | ||
443 | face = sp.Appearance.Texture.FaceTextures[idx]; | ||
444 | } | ||
445 | else | ||
446 | { | ||
447 | // if there is no texture entry and no baked cache, skip it | ||
448 | continue; | ||
449 | } | ||
450 | } | ||
451 | else | ||
452 | { | ||
453 | //No texture entry face and no cache. Skip this face. | ||
454 | continue; | ||
455 | } | ||
456 | } | ||
457 | |||
353 | 458 | ||
354 | // m_log.DebugFormat( | 459 | // m_log.DebugFormat( |
355 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", | 460 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", |
@@ -364,8 +469,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
364 | 469 | ||
365 | defonly = false; // found a non-default texture reference | 470 | defonly = false; // found a non-default texture reference |
366 | 471 | ||
367 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | 472 | if (cache != null) |
368 | return false; | 473 | { |
474 | if (!cache.Check(face.TextureID.ToString())) | ||
475 | return false; | ||
476 | } | ||
477 | else | ||
478 | { | ||
479 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | ||
480 | return false; | ||
481 | } | ||
369 | } | 482 | } |
370 | 483 | ||
371 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); | 484 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); |
@@ -377,6 +490,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
377 | public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) | 490 | public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) |
378 | { | 491 | { |
379 | int texturesRebaked = 0; | 492 | int texturesRebaked = 0; |
493 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
380 | 494 | ||
381 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | 495 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) |
382 | { | 496 | { |
@@ -400,21 +514,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
400 | 514 | ||
401 | if (missingTexturesOnly) | 515 | if (missingTexturesOnly) |
402 | { | 516 | { |
403 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) | 517 | if (cache != null) |
404 | { | 518 | { |
405 | continue; | 519 | if (cache.Check(face.TextureID.ToString())) |
520 | continue; | ||
521 | else | ||
522 | { | ||
523 | m_log.DebugFormat( | ||
524 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | ||
525 | face.TextureID, idx, sp.Name); | ||
526 | } | ||
406 | } | 527 | } |
407 | else | 528 | else |
408 | { | 529 | { |
409 | // On inter-simulator teleports, this occurs if baked textures are not being stored by the | 530 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) |
410 | // grid asset service (which means that they are not available to the new region and so have | 531 | { |
411 | // to be re-requested from the client). | 532 | continue; |
412 | // | 533 | } |
413 | // The only available core OpenSimulator behaviour right now | 534 | |
414 | // is not to store these textures, temporarily or otherwise. | 535 | else |
415 | m_log.DebugFormat( | 536 | { |
416 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | 537 | // On inter-simulator teleports, this occurs if baked textures are not being stored by the |
417 | face.TextureID, idx, sp.Name); | 538 | // grid asset service (which means that they are not available to the new region and so have |
539 | // to be re-requested from the client). | ||
540 | // | ||
541 | // The only available core OpenSimulator behaviour right now | ||
542 | // is not to store these textures, temporarily or otherwise. | ||
543 | m_log.DebugFormat( | ||
544 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | ||
545 | face.TextureID, idx, sp.Name); | ||
546 | } | ||
418 | } | 547 | } |
419 | } | 548 | } |
420 | else | 549 | else |
@@ -548,20 +677,53 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
548 | private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) | 677 | private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) |
549 | { | 678 | { |
550 | IInventoryService invService = m_scene.InventoryService; | 679 | IInventoryService invService = m_scene.InventoryService; |
551 | 680 | bool resetwearable = false; | |
552 | if (invService.GetRootFolder(userID) != null) | 681 | if (invService.GetRootFolder(userID) != null) |
553 | { | 682 | { |
554 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) | 683 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) |
555 | { | 684 | { |
556 | for (int j = 0; j < appearance.Wearables[i].Count; j++) | 685 | for (int j = 0; j < appearance.Wearables[i].Count; j++) |
557 | { | 686 | { |
687 | // Check if the default wearables are not set | ||
558 | if (appearance.Wearables[i][j].ItemID == UUID.Zero) | 688 | if (appearance.Wearables[i][j].ItemID == UUID.Zero) |
689 | { | ||
690 | switch ((WearableType) i) | ||
691 | { | ||
692 | case WearableType.Eyes: | ||
693 | case WearableType.Hair: | ||
694 | case WearableType.Shape: | ||
695 | case WearableType.Skin: | ||
696 | //case WearableType.Underpants: | ||
697 | TryAndRepair((WearableType)i, invService, userID, appearance); | ||
698 | resetwearable = true; | ||
699 | m_log.Warn("[AVFACTORY]: UUID.Zero Wearables, passing fake values."); | ||
700 | resetwearable = true; | ||
701 | break; | ||
702 | |||
703 | } | ||
559 | continue; | 704 | continue; |
705 | } | ||
560 | 706 | ||
561 | // Ignore ruth's assets | 707 | // Ignore ruth's assets except for the body parts! missing body parts fail avatar appearance on V1 |
562 | if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) | 708 | if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) |
709 | { | ||
710 | switch ((WearableType)i) | ||
711 | { | ||
712 | case WearableType.Eyes: | ||
713 | case WearableType.Hair: | ||
714 | case WearableType.Shape: | ||
715 | case WearableType.Skin: | ||
716 | //case WearableType.Underpants: | ||
717 | TryAndRepair((WearableType)i, invService, userID, appearance); | ||
718 | |||
719 | m_log.WarnFormat("[AVFACTORY]: {0} Default Wearables, passing existing values.", (WearableType)i); | ||
720 | resetwearable = true; | ||
721 | break; | ||
722 | |||
723 | } | ||
563 | continue; | 724 | continue; |
564 | 725 | } | |
726 | |||
565 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); | 727 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); |
566 | baseItem = invService.GetItem(baseItem); | 728 | baseItem = invService.GetItem(baseItem); |
567 | 729 | ||
@@ -575,17 +737,236 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
575 | "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", | 737 | "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", |
576 | appearance.Wearables[i][j].ItemID, (WearableType)i); | 738 | appearance.Wearables[i][j].ItemID, (WearableType)i); |
577 | 739 | ||
578 | appearance.Wearables[i].RemoveItem(appearance.Wearables[i][j].ItemID); | 740 | TryAndRepair((WearableType)i, invService, userID, appearance); |
741 | resetwearable = true; | ||
742 | |||
579 | } | 743 | } |
580 | } | 744 | } |
581 | } | 745 | } |
746 | |||
747 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
748 | if (appearance.Wearables[(int) WearableType.Eyes] == null) | ||
749 | { | ||
750 | m_log.WarnFormat("[AVFACTORY]: {0} Eyes are Null, passing existing values.", (WearableType.Eyes)); | ||
751 | |||
752 | TryAndRepair(WearableType.Eyes, invService, userID, appearance); | ||
753 | resetwearable = true; | ||
754 | } | ||
755 | else | ||
756 | { | ||
757 | if (appearance.Wearables[(int) WearableType.Eyes][0].ItemID == UUID.Zero) | ||
758 | { | ||
759 | m_log.WarnFormat("[AVFACTORY]: Eyes are UUID.Zero are broken, {0} {1}", | ||
760 | appearance.Wearables[(int) WearableType.Eyes][0].ItemID, | ||
761 | appearance.Wearables[(int) WearableType.Eyes][0].AssetID); | ||
762 | TryAndRepair(WearableType.Eyes, invService, userID, appearance); | ||
763 | resetwearable = true; | ||
764 | |||
765 | } | ||
766 | |||
767 | } | ||
768 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
769 | if (appearance.Wearables[(int)WearableType.Shape] == null) | ||
770 | { | ||
771 | m_log.WarnFormat("[AVFACTORY]: {0} shape is Null, passing existing values.", (WearableType.Shape)); | ||
772 | |||
773 | TryAndRepair(WearableType.Shape, invService, userID, appearance); | ||
774 | resetwearable = true; | ||
775 | } | ||
776 | else | ||
777 | { | ||
778 | if (appearance.Wearables[(int)WearableType.Shape][0].ItemID == UUID.Zero) | ||
779 | { | ||
780 | m_log.WarnFormat("[AVFACTORY]: Shape is UUID.Zero and broken, {0} {1}", | ||
781 | appearance.Wearables[(int)WearableType.Shape][0].ItemID, | ||
782 | appearance.Wearables[(int)WearableType.Shape][0].AssetID); | ||
783 | TryAndRepair(WearableType.Shape, invService, userID, appearance); | ||
784 | resetwearable = true; | ||
785 | |||
786 | } | ||
787 | |||
788 | } | ||
789 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
790 | if (appearance.Wearables[(int)WearableType.Hair] == null) | ||
791 | { | ||
792 | m_log.WarnFormat("[AVFACTORY]: {0} Hair is Null, passing existing values.", (WearableType.Hair)); | ||
793 | |||
794 | TryAndRepair(WearableType.Hair, invService, userID, appearance); | ||
795 | resetwearable = true; | ||
796 | } | ||
797 | else | ||
798 | { | ||
799 | if (appearance.Wearables[(int)WearableType.Hair][0].ItemID == UUID.Zero) | ||
800 | { | ||
801 | m_log.WarnFormat("[AVFACTORY]: Hair is UUID.Zero and broken, {0} {1}", | ||
802 | appearance.Wearables[(int)WearableType.Hair][0].ItemID, | ||
803 | appearance.Wearables[(int)WearableType.Hair][0].AssetID); | ||
804 | TryAndRepair(WearableType.Hair, invService, userID, appearance); | ||
805 | resetwearable = true; | ||
806 | |||
807 | } | ||
808 | |||
809 | } | ||
810 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
811 | if (appearance.Wearables[(int)WearableType.Skin] == null) | ||
812 | { | ||
813 | m_log.WarnFormat("[AVFACTORY]: {0} Skin is Null, passing existing values.", (WearableType.Skin)); | ||
814 | |||
815 | TryAndRepair(WearableType.Skin, invService, userID, appearance); | ||
816 | resetwearable = true; | ||
817 | } | ||
818 | else | ||
819 | { | ||
820 | if (appearance.Wearables[(int)WearableType.Skin][0].ItemID == UUID.Zero) | ||
821 | { | ||
822 | m_log.WarnFormat("[AVFACTORY]: Skin is UUID.Zero and broken, {0} {1}", | ||
823 | appearance.Wearables[(int)WearableType.Skin][0].ItemID, | ||
824 | appearance.Wearables[(int)WearableType.Skin][0].AssetID); | ||
825 | TryAndRepair(WearableType.Skin, invService, userID, appearance); | ||
826 | resetwearable = true; | ||
827 | |||
828 | } | ||
829 | |||
830 | } | ||
831 | if (resetwearable) | ||
832 | { | ||
833 | ScenePresence presence = null; | ||
834 | if (m_scene.TryGetScenePresence(userID, out presence)) | ||
835 | { | ||
836 | presence.ControllingClient.SendWearables(presence.Appearance.Wearables, | ||
837 | presence.Appearance.Serial++); | ||
838 | } | ||
839 | } | ||
840 | |||
582 | } | 841 | } |
583 | else | 842 | else |
584 | { | 843 | { |
585 | m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); | 844 | m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); |
586 | } | 845 | } |
587 | } | 846 | } |
847 | private void TryAndRepair(WearableType type, IInventoryService invService, UUID userID,AvatarAppearance appearance) | ||
848 | { | ||
849 | UUID defaultwearable = GetDefaultItem(type); | ||
850 | if (defaultwearable != UUID.Zero) | ||
851 | { | ||
852 | UUID newInvItem = UUID.Random(); | ||
853 | InventoryItemBase itembase = new InventoryItemBase(newInvItem, userID) | ||
854 | { | ||
855 | AssetID = | ||
856 | defaultwearable, | ||
857 | AssetType | ||
858 | = | ||
859 | (int) | ||
860 | AssetType | ||
861 | .Bodypart, | ||
862 | CreatorId | ||
863 | = | ||
864 | userID | ||
865 | .ToString | ||
866 | (), | ||
867 | //InvType = (int)InventoryType.Wearable, | ||
868 | |||
869 | Description | ||
870 | = | ||
871 | "Failed Wearable Replacement", | ||
872 | Folder = | ||
873 | invService | ||
874 | .GetFolderForType | ||
875 | (userID, | ||
876 | AssetType | ||
877 | .Bodypart) | ||
878 | .ID, | ||
879 | Flags = (uint) type, | ||
880 | Name = Enum.GetName(typeof (WearableType), type), | ||
881 | BasePermissions = (uint) PermissionMask.Copy, | ||
882 | CurrentPermissions = (uint) PermissionMask.Copy, | ||
883 | EveryOnePermissions = (uint) PermissionMask.Copy, | ||
884 | GroupPermissions = (uint) PermissionMask.Copy, | ||
885 | NextPermissions = (uint) PermissionMask.Copy | ||
886 | }; | ||
887 | invService.AddItem(itembase); | ||
888 | UUID LinkInvItem = UUID.Random(); | ||
889 | itembase = new InventoryItemBase(LinkInvItem, userID) | ||
890 | { | ||
891 | AssetID = | ||
892 | newInvItem, | ||
893 | AssetType | ||
894 | = | ||
895 | (int) | ||
896 | AssetType | ||
897 | .Link, | ||
898 | CreatorId | ||
899 | = | ||
900 | userID | ||
901 | .ToString | ||
902 | (), | ||
903 | InvType = (int) InventoryType.Wearable, | ||
904 | |||
905 | Description | ||
906 | = | ||
907 | "Failed Wearable Replacement", | ||
908 | Folder = | ||
909 | invService | ||
910 | .GetFolderForType | ||
911 | (userID, | ||
912 | AssetType | ||
913 | .CurrentOutfitFolder) | ||
914 | .ID, | ||
915 | Flags = (uint) type, | ||
916 | Name = Enum.GetName(typeof (WearableType), type), | ||
917 | BasePermissions = (uint) PermissionMask.Copy, | ||
918 | CurrentPermissions = (uint) PermissionMask.Copy, | ||
919 | EveryOnePermissions = (uint) PermissionMask.Copy, | ||
920 | GroupPermissions = (uint) PermissionMask.Copy, | ||
921 | NextPermissions = (uint) PermissionMask.Copy | ||
922 | }; | ||
923 | invService.AddItem(itembase); | ||
924 | appearance.Wearables[(int)type] = new AvatarWearable(newInvItem, GetDefaultItem(type)); | ||
925 | ScenePresence presence = null; | ||
926 | if (m_scene.TryGetScenePresence(userID, out presence)) | ||
927 | { | ||
928 | m_scene.SendInventoryUpdate(presence.ControllingClient, | ||
929 | invService.GetFolderForType(userID, | ||
930 | AssetType | ||
931 | .CurrentOutfitFolder), | ||
932 | false, true); | ||
933 | } | ||
934 | } | ||
935 | } | ||
936 | private UUID GetDefaultItem(WearableType wearable) | ||
937 | { | ||
938 | // These are ruth | ||
939 | UUID ret = UUID.Zero; | ||
940 | switch (wearable) | ||
941 | { | ||
942 | case WearableType.Eyes: | ||
943 | ret = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7"); | ||
944 | break; | ||
945 | case WearableType.Hair: | ||
946 | ret = new UUID("d342e6c0-b9d2-11dc-95ff-0800200c9a66"); | ||
947 | break; | ||
948 | case WearableType.Pants: | ||
949 | ret = new UUID("00000000-38f9-1111-024e-222222111120"); | ||
950 | break; | ||
951 | case WearableType.Shape: | ||
952 | ret = new UUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
953 | break; | ||
954 | case WearableType.Shirt: | ||
955 | ret = new UUID("00000000-38f9-1111-024e-222222111110"); | ||
956 | break; | ||
957 | case WearableType.Skin: | ||
958 | ret = new UUID("77c41e39-38f9-f75a-024e-585989bbabbb"); | ||
959 | break; | ||
960 | case WearableType.Undershirt: | ||
961 | ret = new UUID("16499ebb-3208-ec27-2def-481881728f47"); | ||
962 | break; | ||
963 | case WearableType.Underpants: | ||
964 | ret = new UUID("4ac2e9c7-3671-d229-316a-67717730841d"); | ||
965 | break; | ||
966 | } | ||
588 | 967 | ||
968 | return ret; | ||
969 | } | ||
589 | #endregion | 970 | #endregion |
590 | 971 | ||
591 | #region Client Event Handlers | 972 | #region Client Event Handlers |
@@ -595,12 +976,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
595 | /// <param name="client"></param> | 976 | /// <param name="client"></param> |
596 | private void Client_OnRequestWearables(IClientAPI client) | 977 | private void Client_OnRequestWearables(IClientAPI client) |
597 | { | 978 | { |
598 | // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); | 979 | Util.FireAndForget(delegate(object x) |
599 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 980 | { |
600 | if (sp != null) | 981 | Thread.Sleep(4000); |
601 | client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); | 982 | |
602 | else | 983 | // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); |
603 | m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); | 984 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
985 | if (sp != null) | ||
986 | client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); | ||
987 | else | ||
988 | m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); | ||
989 | }); | ||
604 | } | 990 | } |
605 | 991 | ||
606 | /// <summary> | 992 | /// <summary> |
@@ -609,12 +995,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
609 | /// <param name="client"></param> | 995 | /// <param name="client"></param> |
610 | /// <param name="texture"></param> | 996 | /// <param name="texture"></param> |
611 | /// <param name="visualParam"></param> | 997 | /// <param name="visualParam"></param> |
612 | private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) | 998 | private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) |
613 | { | 999 | { |
614 | // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); | 1000 | // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); |
615 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 1001 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
616 | if (sp != null) | 1002 | if (sp != null) |
617 | SetAppearance(sp, textureEntry, visualParams); | 1003 | SetAppearance(sp, textureEntry, visualParams,avSize, cacheItems); |
618 | else | 1004 | else |
619 | m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); | 1005 | m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); |
620 | } | 1006 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index 1830d41..f090e15 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | |||
@@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
61 | for (byte i = 0; i < visualParams.Length; i++) | 61 | for (byte i = 0; i < visualParams.Length; i++) |
62 | visualParams[i] = i; | 62 | visualParams[i] = i; |
63 | 63 | ||
64 | afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams); | 64 | afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams, new WearableCacheItem[0]); |
65 | 65 | ||
66 | // TODO: Check baked texture | 66 | // TODO: Check baked texture |
67 | Assert.AreEqual(visualParams, sp.Appearance.VisualParams); | 67 | Assert.AreEqual(visualParams, sp.Appearance.VisualParams); |
@@ -102,7 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
102 | Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); | 102 | Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); |
103 | eyesFace.TextureID = eyesTextureId; | 103 | eyesFace.TextureID = eyesTextureId; |
104 | 104 | ||
105 | afm.SetAppearance(sp, bakedTextureEntry, visualParams); | 105 | afm.SetAppearance(sp, bakedTextureEntry, visualParams, new WearableCacheItem[0]); |
106 | afm.SaveBakedTextures(userId); | 106 | afm.SaveBakedTextures(userId); |
107 | // Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId); | 107 | // Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId); |
108 | 108 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 6d62ff0..4c3f1cc 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -51,7 +51,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
51 | private int m_shoutdistance = 100; | 51 | private int m_shoutdistance = 100; |
52 | private int m_whisperdistance = 10; | 52 | private int m_whisperdistance = 10; |
53 | private List<Scene> m_scenes = new List<Scene>(); | 53 | private List<Scene> m_scenes = new List<Scene>(); |
54 | 54 | private List<string> FreezeCache = new List<string>(); | |
55 | private string m_adminPrefix = ""; | ||
55 | internal object m_syncy = new object(); | 56 | internal object m_syncy = new object(); |
56 | 57 | ||
57 | internal IConfig m_config; | 58 | internal IConfig m_config; |
@@ -78,6 +79,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
78 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); | 79 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); |
79 | m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); | 80 | m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); |
80 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); | 81 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); |
82 | m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", ""); | ||
81 | } | 83 | } |
82 | 84 | ||
83 | public virtual void AddRegion(Scene scene) | 85 | public virtual void AddRegion(Scene scene) |
@@ -173,7 +175,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
173 | return; | 175 | return; |
174 | } | 176 | } |
175 | 177 | ||
176 | DeliverChatToAvatars(ChatSourceType.Agent, c); | 178 | if (FreezeCache.Contains(c.Sender.AgentId.ToString())) |
179 | { | ||
180 | if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping) | ||
181 | c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false); | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | DeliverChatToAvatars(ChatSourceType.Agent, c); | ||
186 | } | ||
177 | } | 187 | } |
178 | 188 | ||
179 | public virtual void OnChatFromWorld(Object sender, OSChatMessage c) | 189 | public virtual void OnChatFromWorld(Object sender, OSChatMessage c) |
@@ -187,11 +197,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
187 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) | 197 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) |
188 | { | 198 | { |
189 | string fromName = c.From; | 199 | string fromName = c.From; |
200 | string fromNamePrefix = ""; | ||
190 | UUID fromID = UUID.Zero; | 201 | UUID fromID = UUID.Zero; |
191 | UUID ownerID = UUID.Zero; | 202 | UUID ownerID = UUID.Zero; |
192 | UUID targetID = c.TargetUUID; | ||
193 | string message = c.Message; | 203 | string message = c.Message; |
194 | IScene scene = c.Scene; | 204 | IScene scene = c.Scene; |
205 | UUID destination = c.Destination; | ||
195 | Vector3 fromPos = c.Position; | 206 | Vector3 fromPos = c.Position; |
196 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, | 207 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, |
197 | scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 208 | scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
@@ -211,6 +222,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
211 | fromPos = avatar.AbsolutePosition; | 222 | fromPos = avatar.AbsolutePosition; |
212 | fromName = avatar.Name; | 223 | fromName = avatar.Name; |
213 | fromID = c.Sender.AgentId; | 224 | fromID = c.Sender.AgentId; |
225 | if (avatar.GodLevel >= 200) | ||
226 | { | ||
227 | fromNamePrefix = m_adminPrefix; | ||
228 | } | ||
229 | destination = UUID.Zero; // Avatars cant "SayTo" | ||
214 | ownerID = c.Sender.AgentId; | 230 | ownerID = c.Sender.AgentId; |
215 | 231 | ||
216 | break; | 232 | break; |
@@ -229,40 +245,47 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
229 | message = message.Substring(0, 1000); | 245 | message = message.Substring(0, 1000); |
230 | 246 | ||
231 | // m_log.DebugFormat( | 247 | // m_log.DebugFormat( |
232 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", | 248 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", |
233 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); | 249 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); |
234 | 250 | ||
235 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 251 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
236 | 252 | ||
237 | foreach (Scene s in m_scenes) | 253 | foreach (Scene s in m_scenes) |
238 | { | 254 | { |
239 | if (targetID == UUID.Zero) | 255 | // This should use ForEachClient, but clients don't have a position. |
240 | { | 256 | // If camera is moved into client, then camera position can be used |
241 | // This should use ForEachClient, but clients don't have a position. | 257 | // MT: No, it can't, as chat is heard from the avatar position, not |
242 | // If camera is moved into client, then camera position can be used | 258 | // the camera position. |
243 | s.ForEachRootScenePresence( | 259 | s.ForEachRootScenePresence( |
244 | delegate(ScenePresence presence) | 260 | delegate(ScenePresence presence) |
261 | { | ||
262 | if (destination != UUID.Zero && presence.UUID != destination) | ||
263 | return; | ||
264 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); | ||
265 | if (Presencecheck != null) | ||
245 | { | 266 | { |
246 | if (TrySendChatMessage( | 267 | // This will pass all chat from objects. Not |
247 | presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false)) | 268 | // perfect, but it will do. For now. Better |
248 | receiverIDs.Add(presence.UUID); | 269 | // than the prior behavior of muting all |
270 | // objects on a parcel with access restrictions | ||
271 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | ||
272 | { | ||
273 | if (destination != UUID.Zero) | ||
274 | { | ||
275 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, true)) | ||
276 | receiverIDs.Add(presence.UUID); | ||
277 | } | ||
278 | else | ||
279 | { | ||
280 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, false)) | ||
281 | receiverIDs.Add(presence.UUID); | ||
282 | } | ||
283 | } | ||
249 | } | 284 | } |
250 | ); | ||
251 | } | ||
252 | else | ||
253 | { | ||
254 | // This is a send to a specific client eg from llRegionSayTo | ||
255 | // no need to check distance etc, jand send is as say | ||
256 | ScenePresence presence = s.GetScenePresence(targetID); | ||
257 | if (presence != null && !presence.IsChildAgent) | ||
258 | { | ||
259 | if (TrySendChatMessage( | ||
260 | presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true)) | ||
261 | receiverIDs.Add(presence.UUID); | ||
262 | } | 285 | } |
263 | } | 286 | ); |
264 | } | 287 | } |
265 | 288 | ||
266 | (scene as Scene).EventManager.TriggerOnChatToClients( | 289 | (scene as Scene).EventManager.TriggerOnChatToClients( |
267 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); | 290 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); |
268 | } | 291 | } |
@@ -302,28 +325,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
302 | } | 325 | } |
303 | 326 | ||
304 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | 327 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); |
305 | |||
306 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 328 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
307 | 329 | ||
308 | ((Scene)c.Scene).ForEachRootClient( | 330 | if (c.Scene != null) |
309 | delegate(IClientAPI client) | 331 | { |
310 | { | 332 | ((Scene)c.Scene).ForEachRootClient |
311 | // don't forward SayOwner chat from objects to | 333 | ( |
312 | // non-owner agents | 334 | delegate(IClientAPI client) |
313 | if ((c.Type == ChatTypeEnum.Owner) && | 335 | { |
314 | (null != c.SenderObject) && | 336 | // don't forward SayOwner chat from objects to |
315 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | 337 | // non-owner agents |
316 | return; | 338 | if ((c.Type == ChatTypeEnum.Owner) && |
317 | 339 | (null != c.SenderObject) && | |
318 | client.SendChatMessage( | 340 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) |
319 | c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID, | 341 | return; |
320 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 342 | |
321 | 343 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID, | |
322 | receiverIDs.Add(client.AgentId); | 344 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); |
323 | }); | 345 | receiverIDs.Add(client.AgentId); |
324 | 346 | } | |
325 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | 347 | ); |
326 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | 348 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( |
349 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | ||
350 | } | ||
327 | } | 351 | } |
328 | 352 | ||
329 | /// <summary> | 353 | /// <summary> |
@@ -348,7 +372,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
348 | UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type, | 372 | UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type, |
349 | string message, ChatSourceType src, bool ignoreDistance) | 373 | string message, ChatSourceType src, bool ignoreDistance) |
350 | { | 374 | { |
351 | // don't send stuff to child agents | 375 | // don't send chat to child agents |
352 | if (presence.IsChildAgent) return false; | 376 | if (presence.IsChildAgent) return false; |
353 | 377 | ||
354 | Vector3 fromRegionPos = fromPos + regionPos; | 378 | Vector3 fromRegionPos = fromPos + regionPos; |
@@ -357,15 +381,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
357 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 381 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
358 | 382 | ||
359 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); | 383 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); |
360 | 384 | ||
361 | if (!ignoreDistance) | 385 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || |
386 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
387 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
362 | { | 388 | { |
363 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || | 389 | return false; |
364 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
365 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
366 | { | ||
367 | return false; | ||
368 | } | ||
369 | } | 390 | } |
370 | 391 | ||
371 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView | 392 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView |
@@ -375,5 +396,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
375 | 396 | ||
376 | return true; | 397 | return true; |
377 | } | 398 | } |
399 | |||
400 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | ||
401 | public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
402 | { | ||
403 | System.Threading.Timer Timer; | ||
404 | if (flags == 0) | ||
405 | { | ||
406 | FreezeCache.Add(target.ToString()); | ||
407 | System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen); | ||
408 | Timer = new System.Threading.Timer(timeCB, target, 30000, 0); | ||
409 | Timers.Add(target, Timer); | ||
410 | } | ||
411 | else | ||
412 | { | ||
413 | FreezeCache.Remove(target.ToString()); | ||
414 | Timers.TryGetValue(target, out Timer); | ||
415 | Timers.Remove(target); | ||
416 | Timer.Dispose(); | ||
417 | } | ||
418 | } | ||
419 | |||
420 | private void OnEndParcelFrozen(object avatar) | ||
421 | { | ||
422 | UUID target = (UUID)avatar; | ||
423 | FreezeCache.Remove(target.ToString()); | ||
424 | System.Threading.Timer Timer; | ||
425 | Timers.TryGetValue(target, out Timer); | ||
426 | Timers.Remove(target); | ||
427 | Timer.Dispose(); | ||
428 | } | ||
378 | } | 429 | } |
379 | } \ No newline at end of file | 430 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index d26907b..0e7ab7e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | |||
@@ -260,4 +260,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
260 | return result; | 260 | return result; |
261 | } | 261 | } |
262 | } | 262 | } |
263 | } \ No newline at end of file | 263 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 5a7446f..9fa9be1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs | |||
@@ -32,6 +32,24 @@ using OpenMetaverse; | |||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
34 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | using System; | ||
36 | using System.Reflection; | ||
37 | using System.Collections; | ||
38 | using System.Collections.Specialized; | ||
39 | using System.Reflection; | ||
40 | using System.IO; | ||
41 | using System.Web; | ||
42 | using System.Xml; | ||
43 | using log4net; | ||
44 | using Mono.Addins; | ||
45 | using OpenMetaverse.Messages.Linden; | ||
46 | using OpenMetaverse.StructuredData; | ||
47 | using OpenSim.Framework.Capabilities; | ||
48 | using OpenSim.Framework.Servers; | ||
49 | using OpenSim.Framework.Servers.HttpServer; | ||
50 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
51 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | ||
52 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
35 | 53 | ||
36 | using Mono.Addins; | 54 | using Mono.Addins; |
37 | 55 | ||
@@ -40,11 +58,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
40 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GodsModule")] | 58 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GodsModule")] |
41 | public class GodsModule : INonSharedRegionModule, IGodsModule | 59 | public class GodsModule : INonSharedRegionModule, IGodsModule |
42 | { | 60 | { |
61 | private static readonly ILog m_log = | ||
62 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
63 | |||
43 | /// <summary>Special UUID for actions that apply to all agents</summary> | 64 | /// <summary>Special UUID for actions that apply to all agents</summary> |
44 | private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); | 65 | private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); |
45 | 66 | ||
46 | protected Scene m_scene; | 67 | protected Scene m_scene; |
47 | protected IDialogModule m_dialogModule; | 68 | protected IDialogModule m_dialogModule; |
69 | |||
70 | protected Dictionary<UUID, string> m_capsDict = | ||
71 | new Dictionary<UUID, string>(); | ||
72 | |||
48 | protected IDialogModule DialogModule | 73 | protected IDialogModule DialogModule |
49 | { | 74 | { |
50 | get | 75 | get |
@@ -65,6 +90,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
65 | m_scene = scene; | 90 | m_scene = scene; |
66 | m_scene.RegisterModuleInterface<IGodsModule>(this); | 91 | m_scene.RegisterModuleInterface<IGodsModule>(this); |
67 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; | 92 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; |
93 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
94 | m_scene.EventManager.OnClientClosed += OnClientClosed; | ||
95 | scene.EventManager.OnIncomingInstantMessage += | ||
96 | OnIncomingInstantMessage; | ||
68 | } | 97 | } |
69 | 98 | ||
70 | public void RemoveRegion(Scene scene) | 99 | public void RemoveRegion(Scene scene) |
@@ -98,6 +127,54 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
98 | client.OnRequestGodlikePowers -= RequestGodlikePowers; | 127 | client.OnRequestGodlikePowers -= RequestGodlikePowers; |
99 | } | 128 | } |
100 | 129 | ||
130 | private void OnClientClosed(UUID agentID, Scene scene) | ||
131 | { | ||
132 | m_capsDict.Remove(agentID); | ||
133 | } | ||
134 | |||
135 | private void OnRegisterCaps(UUID agentID, Caps caps) | ||
136 | { | ||
137 | string uri = "/CAPS/" + UUID.Random(); | ||
138 | m_capsDict[agentID] = uri; | ||
139 | |||
140 | caps.RegisterHandler("UntrustedSimulatorMessage", | ||
141 | new RestStreamHandler("POST", uri, | ||
142 | HandleUntrustedSimulatorMessage)); | ||
143 | } | ||
144 | |||
145 | private string HandleUntrustedSimulatorMessage(string request, | ||
146 | string path, string param, IOSHttpRequest httpRequest, | ||
147 | IOSHttpResponse httpResponse) | ||
148 | { | ||
149 | OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
150 | |||
151 | string message = osd["message"].AsString(); | ||
152 | |||
153 | if (message == "GodKickUser") | ||
154 | { | ||
155 | OSDMap body = (OSDMap)osd["body"]; | ||
156 | OSDArray userInfo = (OSDArray)body["UserInfo"]; | ||
157 | OSDMap userData = (OSDMap)userInfo[0]; | ||
158 | |||
159 | UUID agentID = userData["AgentID"].AsUUID(); | ||
160 | UUID godID = userData["GodID"].AsUUID(); | ||
161 | UUID godSessionID = userData["GodSessionID"].AsUUID(); | ||
162 | uint kickFlags = userData["KickFlags"].AsUInteger(); | ||
163 | string reason = userData["Reason"].AsString(); | ||
164 | |||
165 | ScenePresence god = m_scene.GetScenePresence(godID); | ||
166 | if (god == null || god.ControllingClient.SessionId != godSessionID) | ||
167 | return String.Empty; | ||
168 | |||
169 | KickUser(godID, godSessionID, agentID, kickFlags, Util.StringToBytes1024(reason)); | ||
170 | } | ||
171 | else | ||
172 | { | ||
173 | m_log.ErrorFormat("[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message); | ||
174 | } | ||
175 | return String.Empty; | ||
176 | } | ||
177 | |||
101 | public void RequestGodlikePowers( | 178 | public void RequestGodlikePowers( |
102 | UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) | 179 | UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) |
103 | { | 180 | { |
@@ -146,76 +223,86 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
146 | /// <param name="reason">The message to send to the user after it's been turned into a field</param> | 223 | /// <param name="reason">The message to send to the user after it's been turned into a field</param> |
147 | public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) | 224 | public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) |
148 | { | 225 | { |
149 | UUID kickUserID = ALL_AGENTS; | 226 | if (!m_scene.Permissions.IsGod(godID)) |
150 | 227 | return; | |
228 | |||
151 | ScenePresence sp = m_scene.GetScenePresence(agentID); | 229 | ScenePresence sp = m_scene.GetScenePresence(agentID); |
152 | 230 | ||
153 | if (sp != null || agentID == kickUserID) | 231 | if (sp == null && agentID != ALL_AGENTS) |
154 | { | 232 | { |
155 | if (m_scene.Permissions.IsGod(godID)) | 233 | IMessageTransferModule transferModule = |
234 | m_scene.RequestModuleInterface<IMessageTransferModule>(); | ||
235 | if (transferModule != null) | ||
156 | { | 236 | { |
157 | if (kickflags == 0) | 237 | m_log.DebugFormat("[GODS]: Sending nonlocal kill for agent {0}", agentID); |
158 | { | 238 | transferModule.SendInstantMessage(new GridInstantMessage( |
159 | if (agentID == kickUserID) | 239 | m_scene, godID, "God", agentID, (byte)250, false, |
160 | { | 240 | Utils.BytesToString(reason), UUID.Zero, true, |
161 | string reasonStr = Utils.BytesToString(reason); | 241 | new Vector3(), new byte[] {(byte)kickflags}, true), |
162 | 242 | delegate(bool success) {} ); | |
163 | m_scene.ForEachClient( | 243 | } |
164 | delegate(IClientAPI controller) | 244 | return; |
165 | { | 245 | } |
166 | if (controller.AgentId != godID) | ||
167 | controller.Kick(reasonStr); | ||
168 | } | ||
169 | ); | ||
170 | |||
171 | // This is a bit crude. It seems the client will be null before it actually stops the thread | ||
172 | // The thread will kill itself eventually :/ | ||
173 | // Is there another way to make sure *all* clients get this 'inter region' message? | ||
174 | m_scene.ForEachRootClient( | ||
175 | delegate(IClientAPI client) | ||
176 | { | ||
177 | if (client.AgentId != godID) | ||
178 | { | ||
179 | client.Close(); | ||
180 | } | ||
181 | } | ||
182 | ); | ||
183 | } | ||
184 | else | ||
185 | { | ||
186 | m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent); | ||
187 | 246 | ||
188 | sp.ControllingClient.Kick(Utils.BytesToString(reason)); | 247 | switch (kickflags) |
189 | sp.ControllingClient.Close(); | 248 | { |
190 | } | 249 | case 0: |
191 | } | 250 | if (sp != null) |
192 | 251 | { | |
193 | if (kickflags == 1) | 252 | KickPresence(sp, Utils.BytesToString(reason)); |
194 | { | ||
195 | sp.AllowMovement = false; | ||
196 | if (DialogModule != null) | ||
197 | { | ||
198 | DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
199 | DialogModule.SendAlertToUser(godID, "User Frozen"); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | if (kickflags == 2) | ||
204 | { | ||
205 | sp.AllowMovement = true; | ||
206 | if (DialogModule != null) | ||
207 | { | ||
208 | DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
209 | DialogModule.SendAlertToUser(godID, "User Unfrozen"); | ||
210 | } | ||
211 | } | ||
212 | } | 253 | } |
213 | else | 254 | else if (agentID == ALL_AGENTS) |
214 | { | 255 | { |
215 | if (DialogModule != null) | 256 | m_scene.ForEachRootScenePresence( |
216 | DialogModule.SendAlertToUser(godID, "Kick request denied"); | 257 | delegate(ScenePresence p) |
258 | { | ||
259 | if (p.UUID != godID && (!m_scene.Permissions.IsGod(p.UUID))) | ||
260 | KickPresence(p, Utils.BytesToString(reason)); | ||
261 | } | ||
262 | ); | ||
263 | } | ||
264 | break; | ||
265 | case 1: | ||
266 | if (sp != null) | ||
267 | { | ||
268 | sp.AllowMovement = false; | ||
269 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
270 | m_dialogModule.SendAlertToUser(godID, "User Frozen"); | ||
217 | } | 271 | } |
272 | break; | ||
273 | case 2: | ||
274 | if (sp != null) | ||
275 | { | ||
276 | sp.AllowMovement = true; | ||
277 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
278 | m_dialogModule.SendAlertToUser(godID, "User Unfrozen"); | ||
279 | } | ||
280 | break; | ||
281 | default: | ||
282 | break; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | private void KickPresence(ScenePresence sp, string reason) | ||
287 | { | ||
288 | if (sp.IsChildAgent) | ||
289 | return; | ||
290 | sp.ControllingClient.Kick(reason); | ||
291 | sp.MakeChildAgent(); | ||
292 | sp.ControllingClient.Close(); | ||
293 | } | ||
294 | |||
295 | private void OnIncomingInstantMessage(GridInstantMessage msg) | ||
296 | { | ||
297 | if (msg.dialog == (uint)250) // Nonlocal kick | ||
298 | { | ||
299 | UUID agentID = new UUID(msg.toAgentID); | ||
300 | string reason = msg.message; | ||
301 | UUID godID = new UUID(msg.fromAgentID); | ||
302 | uint kickMode = (uint)msg.binaryBucket[0]; | ||
303 | |||
304 | KickUser(godID, UUID.Zero, agentID, kickMode, Util.StringToBytes1024(reason)); | ||
218 | } | 305 | } |
219 | } | 306 | } |
220 | } | 307 | } |
221 | } \ No newline at end of file | 308 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs deleted file mode 100644 index b735c61..0000000 --- a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs +++ /dev/null | |||
@@ -1,260 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | |||
38 | using Mono.Addins; | ||
39 | |||
40 | namespace OpenSim.Region.CoreModules.Avatar.Groups | ||
41 | { | ||
42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsModule")] | ||
43 | public class GroupsModule : ISharedRegionModule | ||
44 | { | ||
45 | private static readonly ILog m_log = | ||
46 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private Dictionary<UUID, GroupMembershipData> m_GroupMap = | ||
49 | new Dictionary<UUID, GroupMembershipData>(); | ||
50 | |||
51 | private Dictionary<UUID, IClientAPI> m_ClientMap = | ||
52 | new Dictionary<UUID, IClientAPI>(); | ||
53 | |||
54 | private UUID opensimulatorGroupID = | ||
55 | new UUID("00000000-68f9-1111-024e-222222111123"); | ||
56 | |||
57 | private List<Scene> m_SceneList = new List<Scene>(); | ||
58 | |||
59 | private static GroupMembershipData osGroup = | ||
60 | new GroupMembershipData(); | ||
61 | |||
62 | private bool m_Enabled = false; | ||
63 | |||
64 | #region ISharedRegionModule Members | ||
65 | |||
66 | public void Initialise(IConfigSource config) | ||
67 | { | ||
68 | IConfig groupsConfig = config.Configs["Groups"]; | ||
69 | |||
70 | if (groupsConfig == null) | ||
71 | { | ||
72 | m_log.Info("[GROUPS]: No configuration found. Using defaults"); | ||
73 | } | ||
74 | else | ||
75 | { | ||
76 | m_Enabled = groupsConfig.GetBoolean("Enabled", false); | ||
77 | if (!m_Enabled) | ||
78 | { | ||
79 | m_log.Info("[GROUPS]: Groups disabled in configuration"); | ||
80 | return; | ||
81 | } | ||
82 | |||
83 | if (groupsConfig.GetString("Module", "Default") != "Default") | ||
84 | { | ||
85 | m_Enabled = false; | ||
86 | return; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | } | ||
91 | |||
92 | public void AddRegion(Scene scene) | ||
93 | { | ||
94 | if (!m_Enabled) | ||
95 | return; | ||
96 | |||
97 | lock (m_SceneList) | ||
98 | { | ||
99 | if (!m_SceneList.Contains(scene)) | ||
100 | { | ||
101 | if (m_SceneList.Count == 0) | ||
102 | { | ||
103 | osGroup.GroupID = opensimulatorGroupID; | ||
104 | osGroup.GroupName = "OpenSimulator Testing"; | ||
105 | osGroup.GroupPowers = | ||
106 | (uint)(GroupPowers.AllowLandmark | | ||
107 | GroupPowers.AllowSetHome); | ||
108 | m_GroupMap[opensimulatorGroupID] = osGroup; | ||
109 | } | ||
110 | m_SceneList.Add(scene); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | scene.EventManager.OnNewClient += OnNewClient; | ||
115 | scene.EventManager.OnClientClosed += OnClientClosed; | ||
116 | // scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | ||
117 | } | ||
118 | |||
119 | public void RemoveRegion(Scene scene) | ||
120 | { | ||
121 | if (!m_Enabled) | ||
122 | return; | ||
123 | |||
124 | lock (m_SceneList) | ||
125 | { | ||
126 | if (m_SceneList.Contains(scene)) | ||
127 | m_SceneList.Remove(scene); | ||
128 | } | ||
129 | |||
130 | scene.EventManager.OnNewClient -= OnNewClient; | ||
131 | scene.EventManager.OnClientClosed -= OnClientClosed; | ||
132 | } | ||
133 | |||
134 | public void RegionLoaded(Scene scene) | ||
135 | { | ||
136 | } | ||
137 | |||
138 | public void PostInitialise() | ||
139 | { | ||
140 | } | ||
141 | |||
142 | public void Close() | ||
143 | { | ||
144 | if (!m_Enabled) | ||
145 | return; | ||
146 | |||
147 | // m_log.Debug("[GROUPS]: Shutting down group module."); | ||
148 | |||
149 | lock (m_ClientMap) | ||
150 | { | ||
151 | m_ClientMap.Clear(); | ||
152 | } | ||
153 | |||
154 | lock (m_GroupMap) | ||
155 | { | ||
156 | m_GroupMap.Clear(); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | public string Name | ||
161 | { | ||
162 | get { return "GroupsModule"; } | ||
163 | } | ||
164 | |||
165 | public Type ReplaceableInterface | ||
166 | { | ||
167 | get { return null; } | ||
168 | } | ||
169 | |||
170 | #endregion | ||
171 | |||
172 | private void OnNewClient(IClientAPI client) | ||
173 | { | ||
174 | // Subscribe to instant messages | ||
175 | // client.OnInstantMessage += OnInstantMessage; | ||
176 | client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; | ||
177 | client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; | ||
178 | lock (m_ClientMap) | ||
179 | { | ||
180 | if (!m_ClientMap.ContainsKey(client.AgentId)) | ||
181 | { | ||
182 | m_ClientMap.Add(client.AgentId, client); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | GroupMembershipData[] updateGroups = new GroupMembershipData[1]; | ||
187 | updateGroups[0] = osGroup; | ||
188 | |||
189 | client.SendGroupMembership(updateGroups); | ||
190 | } | ||
191 | |||
192 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, | ||
193 | UUID AgentID, UUID SessionID) | ||
194 | { | ||
195 | UUID ActiveGroupID; | ||
196 | string ActiveGroupName; | ||
197 | ulong ActiveGroupPowers; | ||
198 | |||
199 | string firstname = remoteClient.FirstName; | ||
200 | string lastname = remoteClient.LastName; | ||
201 | |||
202 | string ActiveGroupTitle = "I IZ N0T"; | ||
203 | |||
204 | ActiveGroupID = osGroup.GroupID; | ||
205 | ActiveGroupName = osGroup.GroupName; | ||
206 | ActiveGroupPowers = osGroup.GroupPowers; | ||
207 | |||
208 | remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, | ||
209 | lastname, ActiveGroupPowers, ActiveGroupName, | ||
210 | ActiveGroupTitle); | ||
211 | } | ||
212 | |||
213 | // private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | ||
214 | // { | ||
215 | // } | ||
216 | |||
217 | // private void OnGridInstantMessage(GridInstantMessage msg) | ||
218 | // { | ||
219 | // // Trigger the above event handler | ||
220 | // OnInstantMessage(null, msg); | ||
221 | // } | ||
222 | |||
223 | private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client) | ||
224 | { | ||
225 | string groupnamereply = "Unknown"; | ||
226 | UUID groupUUID = UUID.Zero; | ||
227 | |||
228 | lock (m_GroupMap) | ||
229 | { | ||
230 | if (m_GroupMap.ContainsKey(id)) | ||
231 | { | ||
232 | GroupMembershipData grp = m_GroupMap[id]; | ||
233 | groupnamereply = grp.GroupName; | ||
234 | groupUUID = grp.GroupID; | ||
235 | } | ||
236 | } | ||
237 | remote_client.SendGroupNameReply(groupUUID, groupnamereply); | ||
238 | } | ||
239 | |||
240 | private void OnClientClosed(UUID agentID, Scene scene) | ||
241 | { | ||
242 | lock (m_ClientMap) | ||
243 | { | ||
244 | if (m_ClientMap.ContainsKey(agentID)) | ||
245 | { | ||
246 | // IClientAPI cli = m_ClientMap[agentID]; | ||
247 | // if (cli != null) | ||
248 | // { | ||
249 | // //m_log.Info("[GROUPS]: Removing all reference to groups for " + cli.Name); | ||
250 | // } | ||
251 | // else | ||
252 | // { | ||
253 | // //m_log.Info("[GROUPS]: Removing all reference to groups for " + agentID.ToString()); | ||
254 | // } | ||
255 | m_ClientMap.Remove(agentID); | ||
256 | } | ||
257 | } | ||
258 | } | ||
259 | } | ||
260 | } | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs index c33a296..55e30a0 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Timers; | ||
30 | using log4net; | 31 | using log4net; |
31 | using Mono.Addins; | 32 | using Mono.Addins; |
32 | using Nini.Config; | 33 | using Nini.Config; |
@@ -44,6 +45,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
44 | private static readonly ILog m_log = LogManager.GetLogger( | 45 | private static readonly ILog m_log = LogManager.GetLogger( |
45 | MethodBase.GetCurrentMethod().DeclaringType); | 46 | MethodBase.GetCurrentMethod().DeclaringType); |
46 | 47 | ||
48 | private Timer m_logTimer = new Timer(10000); | ||
49 | private List<GridInstantMessage> m_logData = new List<GridInstantMessage>(); | ||
50 | private string m_restUrl; | ||
51 | |||
47 | /// <value> | 52 | /// <value> |
48 | /// Is this module enabled? | 53 | /// Is this module enabled? |
49 | /// </value> | 54 | /// </value> |
@@ -63,9 +68,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
63 | "InstantMessageModule", "InstantMessageModule") != | 68 | "InstantMessageModule", "InstantMessageModule") != |
64 | "InstantMessageModule") | 69 | "InstantMessageModule") |
65 | return; | 70 | return; |
71 | m_restUrl = config.Configs["Messaging"].GetString("LogURL", String.Empty); | ||
66 | } | 72 | } |
67 | 73 | ||
68 | m_enabled = true; | 74 | m_enabled = true; |
75 | m_logTimer.AutoReset = false; | ||
76 | m_logTimer.Elapsed += LogTimerElapsed; | ||
69 | } | 77 | } |
70 | 78 | ||
71 | public void AddRegion(Scene scene) | 79 | public void AddRegion(Scene scene) |
@@ -150,6 +158,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
150 | { | 158 | { |
151 | byte dialog = im.dialog; | 159 | byte dialog = im.dialog; |
152 | 160 | ||
161 | if (client != null && dialog == (byte)InstantMessageDialog.MessageFromAgent) | ||
162 | LogInstantMesssage(im); | ||
163 | |||
153 | if (dialog != (byte)InstantMessageDialog.MessageFromAgent | 164 | if (dialog != (byte)InstantMessageDialog.MessageFromAgent |
154 | && dialog != (byte)InstantMessageDialog.StartTyping | 165 | && dialog != (byte)InstantMessageDialog.StartTyping |
155 | && dialog != (byte)InstantMessageDialog.StopTyping | 166 | && dialog != (byte)InstantMessageDialog.StopTyping |
@@ -159,6 +170,32 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
159 | return; | 170 | return; |
160 | } | 171 | } |
161 | 172 | ||
173 | //DateTime dt = DateTime.UtcNow; | ||
174 | |||
175 | // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
176 | //dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
177 | |||
178 | //try | ||
179 | //{ | ||
180 | // // Convert that to the PST timezone | ||
181 | // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
182 | // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
183 | //} | ||
184 | //catch | ||
185 | //{ | ||
186 | // //m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp."); | ||
187 | //} | ||
188 | |||
189 | //// And make it look local again to fool the unix time util | ||
190 | //dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
191 | |||
192 | // If client is null, this message comes from storage and IS offline | ||
193 | if (client != null) | ||
194 | im.offline = 0; | ||
195 | |||
196 | if (im.offline == 0) | ||
197 | im.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
198 | |||
162 | if (m_TransferModule != null) | 199 | if (m_TransferModule != null) |
163 | { | 200 | { |
164 | if (client != null) | 201 | if (client != null) |
@@ -202,5 +239,35 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
202 | // | 239 | // |
203 | OnInstantMessage(null, msg); | 240 | OnInstantMessage(null, msg); |
204 | } | 241 | } |
242 | |||
243 | private void LogInstantMesssage(GridInstantMessage im) | ||
244 | { | ||
245 | if (m_logData.Count < 20) | ||
246 | { | ||
247 | // Restart the log write timer | ||
248 | m_logTimer.Stop(); | ||
249 | } | ||
250 | if (!m_logTimer.Enabled) | ||
251 | m_logTimer.Start(); | ||
252 | |||
253 | lock (m_logData) | ||
254 | { | ||
255 | m_logData.Add(im); | ||
256 | } | ||
257 | } | ||
258 | |||
259 | private void LogTimerElapsed(object source, ElapsedEventArgs e) | ||
260 | { | ||
261 | lock (m_logData) | ||
262 | { | ||
263 | if (m_restUrl != String.Empty && m_logData.Count > 0) | ||
264 | { | ||
265 | bool success = SynchronousRestObjectRequester.MakeRequest<List<GridInstantMessage>, bool>("POST", m_restUrl + "/LogMessages/", m_logData); | ||
266 | if (!success) | ||
267 | m_log.ErrorFormat("[INSTANT MESSAGE]: Failed to save log data"); | ||
268 | } | ||
269 | m_logData.Clear(); | ||
270 | } | ||
271 | } | ||
205 | } | 272 | } |
206 | } | 273 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index fa935cd..1627f6c 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 51 | ||
52 | private bool m_Enabled = false; | 52 | private bool m_Enabled = false; |
53 | protected string m_MessageKey = String.Empty; | ||
53 | protected List<Scene> m_Scenes = new List<Scene>(); | 54 | protected List<Scene> m_Scenes = new List<Scene>(); |
54 | protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); | 55 | protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); |
55 | 56 | ||
@@ -69,14 +70,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
69 | public virtual void Initialise(IConfigSource config) | 70 | public virtual void Initialise(IConfigSource config) |
70 | { | 71 | { |
71 | IConfig cnf = config.Configs["Messaging"]; | 72 | IConfig cnf = config.Configs["Messaging"]; |
72 | if (cnf != null && cnf.GetString( | 73 | if (cnf != null) |
73 | "MessageTransferModule", "MessageTransferModule") != | ||
74 | "MessageTransferModule") | ||
75 | { | 74 | { |
76 | m_log.Debug("[MESSAGE TRANSFER]: Disabled by configuration"); | 75 | if (cnf.GetString("MessageTransferModule", |
77 | return; | 76 | "MessageTransferModule") != "MessageTransferModule") |
78 | } | 77 | { |
78 | return; | ||
79 | } | ||
79 | 80 | ||
81 | m_MessageKey = cnf.GetString("MessageKey", String.Empty); | ||
82 | } | ||
83 | m_log.Debug("[MESSAGE TRANSFER]: Module enabled"); | ||
80 | m_Enabled = true; | 84 | m_Enabled = true; |
81 | } | 85 | } |
82 | 86 | ||
@@ -135,6 +139,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
135 | { | 139 | { |
136 | UUID toAgentID = new UUID(im.toAgentID); | 140 | UUID toAgentID = new UUID(im.toAgentID); |
137 | 141 | ||
142 | if (toAgentID == UUID.Zero) | ||
143 | return; | ||
144 | |||
138 | // Try root avatar only first | 145 | // Try root avatar only first |
139 | foreach (Scene scene in m_Scenes) | 146 | foreach (Scene scene in m_Scenes) |
140 | { | 147 | { |
@@ -249,6 +256,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
249 | && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") | 256 | && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") |
250 | && requestData.ContainsKey("binary_bucket")) | 257 | && requestData.ContainsKey("binary_bucket")) |
251 | { | 258 | { |
259 | if (m_MessageKey != String.Empty) | ||
260 | { | ||
261 | XmlRpcResponse error_resp = new XmlRpcResponse(); | ||
262 | Hashtable error_respdata = new Hashtable(); | ||
263 | error_respdata["success"] = "FALSE"; | ||
264 | error_resp.Value = error_respdata; | ||
265 | |||
266 | if (!requestData.Contains("message_key")) | ||
267 | return error_resp; | ||
268 | if (m_MessageKey != (string)requestData["message_key"]) | ||
269 | return error_resp; | ||
270 | } | ||
271 | |||
252 | // Do the easy way of validating the UUIDs | 272 | // Do the easy way of validating the UUIDs |
253 | UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); | 273 | UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); |
254 | UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); | 274 | UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); |
@@ -425,24 +445,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
425 | return resp; | 445 | return resp; |
426 | } | 446 | } |
427 | 447 | ||
428 | /// <summary> | 448 | private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); |
429 | /// delegate for sending a grid instant message asynchronously | ||
430 | /// </summary> | ||
431 | public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID); | ||
432 | 449 | ||
433 | protected virtual void GridInstantMessageCompleted(IAsyncResult iar) | 450 | private class GIM { |
434 | { | 451 | public GridInstantMessage im; |
435 | GridInstantMessageDelegate icon = | 452 | public MessageResultNotification result; |
436 | (GridInstantMessageDelegate)iar.AsyncState; | 453 | }; |
437 | icon.EndInvoke(iar); | ||
438 | } | ||
439 | 454 | ||
455 | private Queue<GIM> pendingInstantMessages = new Queue<GIM>(); | ||
456 | private int numInstantMessageThreads = 0; | ||
440 | 457 | ||
441 | protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) | 458 | private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) |
442 | { | 459 | { |
443 | GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; | 460 | lock (pendingInstantMessages) { |
461 | if (numInstantMessageThreads >= 4) { | ||
462 | GIM gim = new GIM(); | ||
463 | gim.im = im; | ||
464 | gim.result = result; | ||
465 | pendingInstantMessages.Enqueue(gim); | ||
466 | } else { | ||
467 | ++ numInstantMessageThreads; | ||
468 | //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads); | ||
469 | GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain; | ||
470 | d.BeginInvoke(im, result, GridInstantMessageCompleted, d); | ||
471 | } | ||
472 | } | ||
473 | } | ||
444 | 474 | ||
445 | d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); | 475 | private void GridInstantMessageCompleted(IAsyncResult iar) |
476 | { | ||
477 | GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState; | ||
478 | d.EndInvoke(iar); | ||
446 | } | 479 | } |
447 | 480 | ||
448 | /// <summary> | 481 | /// <summary> |
@@ -457,8 +490,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
457 | /// Pass in 0 the first time this method is called. It will be called recursively with the last | 490 | /// Pass in 0 the first time this method is called. It will be called recursively with the last |
458 | /// regionhandle tried | 491 | /// regionhandle tried |
459 | /// </param> | 492 | /// </param> |
460 | protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) | 493 | private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result) |
461 | { | 494 | { |
495 | GIM gim; | ||
496 | do { | ||
497 | try { | ||
498 | SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero); | ||
499 | } catch (Exception e) { | ||
500 | m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message); | ||
501 | } | ||
502 | lock (pendingInstantMessages) { | ||
503 | if (pendingInstantMessages.Count > 0) { | ||
504 | gim = pendingInstantMessages.Dequeue(); | ||
505 | im = gim.im; | ||
506 | result = gim.result; | ||
507 | } else { | ||
508 | gim = null; | ||
509 | -- numInstantMessageThreads; | ||
510 | //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads); | ||
511 | } | ||
512 | } | ||
513 | } while (gim != null); | ||
514 | } | ||
515 | private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) | ||
516 | { | ||
517 | |||
462 | UUID toAgentID = new UUID(im.toAgentID); | 518 | UUID toAgentID = new UUID(im.toAgentID); |
463 | 519 | ||
464 | PresenceInfo upd = null; | 520 | PresenceInfo upd = null; |
@@ -525,7 +581,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
525 | 581 | ||
526 | if (upd != null) | 582 | if (upd != null) |
527 | { | 583 | { |
528 | GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, | 584 | GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(UUID.Zero, |
529 | upd.RegionID); | 585 | upd.RegionID); |
530 | if (reginfo != null) | 586 | if (reginfo != null) |
531 | { | 587 | { |
@@ -674,6 +730,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
674 | gim["position_z"] = msg.Position.Z.ToString(); | 730 | gim["position_z"] = msg.Position.Z.ToString(); |
675 | gim["region_id"] = msg.RegionID.ToString(); | 731 | gim["region_id"] = msg.RegionID.ToString(); |
676 | gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); | 732 | gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); |
733 | if (m_MessageKey != String.Empty) | ||
734 | gim["message_key"] = m_MessageKey; | ||
677 | return gim; | 735 | return gim; |
678 | } | 736 | } |
679 | 737 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 7d763fa..2d46276 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -173,7 +173,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
173 | 173 | ||
174 | private void RetrieveInstantMessages(IClientAPI client) | 174 | private void RetrieveInstantMessages(IClientAPI client) |
175 | { | 175 | { |
176 | if (m_RestURL != "") | 176 | if (m_RestURL == String.Empty) |
177 | { | ||
178 | return; | ||
179 | } | ||
180 | else | ||
177 | { | 181 | { |
178 | m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); | 182 | m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); |
179 | 183 | ||
@@ -181,25 +185,28 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
181 | = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( | 185 | = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( |
182 | "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); | 186 | "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); |
183 | 187 | ||
184 | if (msglist == null) | 188 | if (msglist != null) |
185 | m_log.WarnFormat("[OFFLINE MESSAGING]: WARNING null message list."); | ||
186 | |||
187 | foreach (GridInstantMessage im in msglist) | ||
188 | { | 189 | { |
189 | if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) | 190 | foreach (GridInstantMessage im in msglist) |
190 | // send it directly or else the item will be given twice | ||
191 | client.SendInstantMessage(im); | ||
192 | else | ||
193 | { | 191 | { |
194 | // Send through scene event manager so all modules get a chance | 192 | if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) |
195 | // to look at this message before it gets delivered. | 193 | // send it directly or else the item will be given twice |
196 | // | 194 | client.SendInstantMessage(im); |
197 | // Needed for proper state management for stored group | 195 | else |
198 | // invitations | 196 | { |
199 | // | 197 | // Send through scene event manager so all modules get a chance |
200 | Scene s = FindScene(client.AgentId); | 198 | // to look at this message before it gets delivered. |
201 | if (s != null) | 199 | // |
202 | s.EventManager.TriggerIncomingInstantMessage(im); | 200 | // Needed for proper state management for stored group |
201 | // invitations | ||
202 | // | ||
203 | |||
204 | im.offline = 1; | ||
205 | |||
206 | Scene s = FindScene(client.AgentId); | ||
207 | if (s != null) | ||
208 | s.EventManager.TriggerIncomingInstantMessage(im); | ||
209 | } | ||
203 | } | 210 | } |
204 | } | 211 | } |
205 | } | 212 | } |
@@ -211,24 +218,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
211 | im.dialog != (byte)InstantMessageDialog.MessageFromAgent && | 218 | im.dialog != (byte)InstantMessageDialog.MessageFromAgent && |
212 | im.dialog != (byte)InstantMessageDialog.GroupNotice && | 219 | im.dialog != (byte)InstantMessageDialog.GroupNotice && |
213 | im.dialog != (byte)InstantMessageDialog.GroupInvitation && | 220 | im.dialog != (byte)InstantMessageDialog.GroupInvitation && |
214 | im.dialog != (byte)InstantMessageDialog.InventoryOffered) | 221 | im.dialog != (byte)InstantMessageDialog.InventoryOffered && |
222 | im.dialog != (byte)InstantMessageDialog.TaskInventoryOffered) | ||
215 | { | 223 | { |
216 | return; | 224 | return; |
217 | } | 225 | } |
218 | 226 | ||
219 | if (!m_ForwardOfflineGroupMessages) | ||
220 | { | ||
221 | if (im.dialog == (byte)InstantMessageDialog.GroupNotice || | ||
222 | im.dialog == (byte)InstantMessageDialog.GroupInvitation) | ||
223 | return; | ||
224 | } | ||
225 | |||
226 | Scene scene = FindScene(new UUID(im.fromAgentID)); | 227 | Scene scene = FindScene(new UUID(im.fromAgentID)); |
227 | if (scene == null) | 228 | if (scene == null) |
228 | scene = m_SceneList[0]; | 229 | scene = m_SceneList[0]; |
229 | 230 | ||
230 | bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( | 231 | bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( |
231 | "POST", m_RestURL+"/SaveMessage/", im); | 232 | "POST", m_RestURL+"/SaveMessage/?scope=" + |
233 | scene.RegionInfo.ScopeID.ToString(), im); | ||
232 | 234 | ||
233 | if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) | 235 | if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) |
234 | { | 236 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 5069803..dc2b0e0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -634,4 +634,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
634 | m_assetsLoaded = true; | 634 | m_assetsLoaded = true; |
635 | } | 635 | } |
636 | } | 636 | } |
637 | } \ No newline at end of file | 637 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 849449b..f4f9e2d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -519,6 +519,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
519 | return null; | 519 | return null; |
520 | } | 520 | } |
521 | 521 | ||
522 | return account; | ||
523 | /* | ||
522 | try | 524 | try |
523 | { | 525 | { |
524 | string encpass = Util.Md5Hash(pass); | 526 | string encpass = Util.Md5Hash(pass); |
@@ -539,6 +541,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
539 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message); | 541 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message); |
540 | return null; | 542 | return null; |
541 | } | 543 | } |
544 | */ | ||
542 | } | 545 | } |
543 | 546 | ||
544 | /// <summary> | 547 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index bcb7f42..ae58dfd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -177,8 +177,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
177 | if (im.binaryBucket.Length < 17) // Invalid | 177 | if (im.binaryBucket.Length < 17) // Invalid |
178 | return; | 178 | return; |
179 | 179 | ||
180 | UUID receipientID = new UUID(im.toAgentID); | 180 | UUID recipientID = new UUID(im.toAgentID); |
181 | ScenePresence user = scene.GetScenePresence(receipientID); | 181 | ScenePresence user = scene.GetScenePresence(recipientID); |
182 | UUID copyID; | 182 | UUID copyID; |
183 | 183 | ||
184 | // First byte is the asset type | 184 | // First byte is the asset type |
@@ -193,7 +193,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
193 | folderID, new UUID(im.toAgentID)); | 193 | folderID, new UUID(im.toAgentID)); |
194 | 194 | ||
195 | InventoryFolderBase folderCopy | 195 | InventoryFolderBase folderCopy |
196 | = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); | 196 | = scene.GiveInventoryFolder(recipientID, client.AgentId, folderID, UUID.Zero); |
197 | 197 | ||
198 | if (folderCopy == null) | 198 | if (folderCopy == null) |
199 | { | 199 | { |
@@ -246,6 +246,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
246 | im.imSessionID = itemID.Guid; | 246 | im.imSessionID = itemID.Guid; |
247 | } | 247 | } |
248 | 248 | ||
249 | im.offline = 0; | ||
250 | |||
249 | // Send the IM to the recipient. The item is already | 251 | // Send the IM to the recipient. The item is already |
250 | // in their inventory, so it will not be lost if | 252 | // in their inventory, so it will not be lost if |
251 | // they are offline. | 253 | // they are offline. |
@@ -265,8 +267,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
265 | }); | 267 | }); |
266 | } | 268 | } |
267 | } | 269 | } |
268 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) | 270 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted || |
271 | im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
269 | { | 272 | { |
273 | UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip | ||
274 | IInventoryService invService = scene.InventoryService; | ||
275 | |||
276 | // Special case: folder redirect. | ||
277 | // RLV uses this | ||
278 | if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
279 | { | ||
280 | InventoryFolderBase folder = new InventoryFolderBase(inventoryID, client.AgentId); | ||
281 | folder = invService.GetFolder(folder); | ||
282 | |||
283 | if (folder != null) | ||
284 | { | ||
285 | if (im.binaryBucket.Length >= 16) | ||
286 | { | ||
287 | UUID destFolderID = new UUID(im.binaryBucket, 0); | ||
288 | if (destFolderID != UUID.Zero) | ||
289 | { | ||
290 | InventoryFolderBase destFolder = new InventoryFolderBase(destFolderID, client.AgentId); | ||
291 | destFolder = invService.GetFolder(destFolder); | ||
292 | if (destFolder != null) | ||
293 | { | ||
294 | if (folder.ParentID != destFolder.ID) | ||
295 | { | ||
296 | folder.ParentID = destFolder.ID; | ||
297 | invService.MoveFolder(folder); | ||
298 | client.SendBulkUpdateInventory(folder); | ||
299 | } | ||
300 | } | ||
301 | } | ||
302 | } | ||
303 | } | ||
304 | } | ||
305 | |||
270 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); | 306 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
271 | 307 | ||
272 | if (user != null) // Local | 308 | if (user != null) // Local |
@@ -276,27 +312,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
276 | else | 312 | else |
277 | { | 313 | { |
278 | if (m_TransferModule != null) | 314 | if (m_TransferModule != null) |
279 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { | 315 | m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); |
280 | |||
281 | // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011 | ||
282 | // and is apparently supposed to fix bulk inventory updates after accepting items. But | ||
283 | // instead it appears to cause two copies of an accepted folder for the receiving user in | ||
284 | // at least some cases. Folder/item update is already done when the offer is made (see code above) | ||
285 | |||
286 | // // Send BulkUpdateInventory | ||
287 | // IInventoryService invService = scene.InventoryService; | ||
288 | // UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip | ||
289 | // | ||
290 | // InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); | ||
291 | // folder = invService.GetFolder(folder); | ||
292 | // | ||
293 | // ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); | ||
294 | // | ||
295 | // // If the user has left the scene by the time the message comes back then we can't send | ||
296 | // // them the update. | ||
297 | // if (fromUser != null) | ||
298 | // fromUser.ControllingClient.SendBulkUpdateInventory(folder); | ||
299 | }); | ||
300 | } | 316 | } |
301 | } | 317 | } |
302 | 318 | ||
@@ -409,6 +425,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
409 | previousParentFolderID = folder.ParentID; | 425 | previousParentFolderID = folder.ParentID; |
410 | folder.ParentID = trashFolder.ID; | 426 | folder.ParentID = trashFolder.ID; |
411 | invService.MoveFolder(folder); | 427 | invService.MoveFolder(folder); |
428 | client.SendBulkUpdateInventory(folder); | ||
412 | } | 429 | } |
413 | } | 430 | } |
414 | 431 | ||
@@ -522,22 +539,113 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
522 | /// | 539 | /// |
523 | /// </summary> | 540 | /// </summary> |
524 | /// <param name="msg"></param> | 541 | /// <param name="msg"></param> |
525 | private void OnGridInstantMessage(GridInstantMessage msg) | 542 | private void OnGridInstantMessage(GridInstantMessage im) |
526 | { | 543 | { |
527 | // Check if this is ours to handle | 544 | // Check if this is ours to handle |
528 | // | 545 | // |
529 | Scene scene = FindClientScene(new UUID(msg.toAgentID)); | 546 | Scene scene = FindClientScene(new UUID(im.toAgentID)); |
530 | 547 | ||
531 | if (scene == null) | 548 | if (scene == null) |
532 | return; | 549 | return; |
533 | 550 | ||
534 | // Find agent to deliver to | 551 | // Find agent to deliver to |
535 | // | 552 | // |
536 | ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); | 553 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
554 | if (user == null) | ||
555 | return; | ||
556 | |||
557 | // This requires a little bit of processing because we have to make the | ||
558 | // new item visible in the recipient's inventory here | ||
559 | // | ||
560 | if (im.dialog == (byte) InstantMessageDialog.InventoryOffered) | ||
561 | { | ||
562 | if (im.binaryBucket.Length < 17) // Invalid | ||
563 | return; | ||
564 | |||
565 | UUID recipientID = new UUID(im.toAgentID); | ||
566 | |||
567 | // First byte is the asset type | ||
568 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
569 | |||
570 | if (AssetType.Folder == assetType) | ||
571 | { | ||
572 | UUID folderID = new UUID(im.binaryBucket, 1); | ||
537 | 573 | ||
538 | // Just forward to local handling | 574 | InventoryFolderBase given = |
539 | OnInstantMessage(user.ControllingClient, msg); | 575 | new InventoryFolderBase(folderID, recipientID); |
576 | InventoryFolderBase folder = | ||
577 | scene.InventoryService.GetFolder(given); | ||
540 | 578 | ||
579 | if (folder != null) | ||
580 | user.ControllingClient.SendBulkUpdateInventory(folder); | ||
581 | } | ||
582 | else | ||
583 | { | ||
584 | UUID itemID = new UUID(im.binaryBucket, 1); | ||
585 | |||
586 | InventoryItemBase given = | ||
587 | new InventoryItemBase(itemID, recipientID); | ||
588 | InventoryItemBase item = | ||
589 | scene.InventoryService.GetItem(given); | ||
590 | |||
591 | if (item != null) | ||
592 | { | ||
593 | user.ControllingClient.SendBulkUpdateInventory(item); | ||
594 | } | ||
595 | } | ||
596 | user.ControllingClient.SendInstantMessage(im); | ||
597 | } | ||
598 | if (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered) | ||
599 | { | ||
600 | if (im.binaryBucket.Length < 1) // Invalid | ||
601 | return; | ||
602 | |||
603 | UUID recipientID = new UUID(im.toAgentID); | ||
604 | |||
605 | // Bucket is the asset type | ||
606 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
607 | |||
608 | if (AssetType.Folder == assetType) | ||
609 | { | ||
610 | UUID folderID = new UUID(im.imSessionID); | ||
611 | |||
612 | InventoryFolderBase given = | ||
613 | new InventoryFolderBase(folderID, recipientID); | ||
614 | InventoryFolderBase folder = | ||
615 | scene.InventoryService.GetFolder(given); | ||
616 | |||
617 | if (folder != null) | ||
618 | user.ControllingClient.SendBulkUpdateInventory(folder); | ||
619 | } | ||
620 | else | ||
621 | { | ||
622 | UUID itemID = new UUID(im.imSessionID); | ||
623 | |||
624 | InventoryItemBase given = | ||
625 | new InventoryItemBase(itemID, recipientID); | ||
626 | InventoryItemBase item = | ||
627 | scene.InventoryService.GetItem(given); | ||
628 | |||
629 | if (item != null) | ||
630 | { | ||
631 | user.ControllingClient.SendBulkUpdateInventory(item); | ||
632 | } | ||
633 | } | ||
634 | |||
635 | // Fix up binary bucket since this may be 17 chars long here | ||
636 | Byte[] bucket = new Byte[1]; | ||
637 | bucket[0] = im.binaryBucket[0]; | ||
638 | im.binaryBucket = bucket; | ||
639 | |||
640 | user.ControllingClient.SendInstantMessage(im); | ||
641 | } | ||
642 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted || | ||
643 | im.dialog == (byte) InstantMessageDialog.InventoryDeclined || | ||
644 | im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined || | ||
645 | im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
646 | { | ||
647 | user.ControllingClient.SendInstantMessage(im); | ||
648 | } | ||
541 | } | 649 | } |
542 | } | 650 | } |
543 | } | 651 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index e4b0cfa..f3adb95 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs | |||
@@ -163,16 +163,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
163 | scene.RegionInfo.RegionHandle, | 163 | scene.RegionInfo.RegionHandle, |
164 | (uint)presence.AbsolutePosition.X, | 164 | (uint)presence.AbsolutePosition.X, |
165 | (uint)presence.AbsolutePosition.Y, | 165 | (uint)presence.AbsolutePosition.Y, |
166 | (uint)Math.Ceiling(presence.AbsolutePosition.Z)); | 166 | (uint)presence.AbsolutePosition.Z + 2); |
167 | 167 | ||
168 | m_log.DebugFormat("TP invite with message {0}", message); | 168 | m_log.DebugFormat("[LURE]: TP invite with message {0}", message); |
169 | |||
170 | GridInstantMessage m; | ||
171 | |||
172 | if (scene.Permissions.IsAdministrator(client.AgentId) && presence.GodLevel >= 200 && (!scene.Permissions.IsAdministrator(targetid))) | ||
173 | { | ||
174 | m = new GridInstantMessage(scene, client.AgentId, | ||
175 | client.FirstName+" "+client.LastName, targetid, | ||
176 | (byte)InstantMessageDialog.GodLikeRequestTeleport, false, | ||
177 | message, dest, false, presence.AbsolutePosition, | ||
178 | new Byte[0], true); | ||
179 | } | ||
180 | else | ||
181 | { | ||
182 | m = new GridInstantMessage(scene, client.AgentId, | ||
183 | client.FirstName+" "+client.LastName, targetid, | ||
184 | (byte)InstantMessageDialog.RequestTeleport, false, | ||
185 | message, dest, false, presence.AbsolutePosition, | ||
186 | new Byte[0], true); | ||
187 | } | ||
169 | 188 | ||
170 | GridInstantMessage m = new GridInstantMessage(scene, client.AgentId, | ||
171 | client.FirstName+" "+client.LastName, targetid, | ||
172 | (byte)InstantMessageDialog.RequestTeleport, false, | ||
173 | message, dest, false, presence.AbsolutePosition, | ||
174 | new Byte[0], true); | ||
175 | |||
176 | if (m_TransferModule != null) | 189 | if (m_TransferModule != null) |
177 | { | 190 | { |
178 | m_TransferModule.SendInstantMessage(m, | 191 | m_TransferModule.SendInstantMessage(m, |
@@ -207,7 +220,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
207 | { | 220 | { |
208 | // Forward remote teleport requests | 221 | // Forward remote teleport requests |
209 | // | 222 | // |
210 | if (msg.dialog != 22) | 223 | if (msg.dialog != (byte)InstantMessageDialog.RequestTeleport && |
224 | msg.dialog != (byte)InstantMessageDialog.GodLikeRequestTeleport) | ||
211 | return; | 225 | return; |
212 | 226 | ||
213 | if (m_TransferModule != null) | 227 | if (m_TransferModule != null) |
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index 8329af0..7f30e5a 100644 --- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | |||
@@ -102,7 +102,8 @@ namespace OpenSim.Region.CoreModules.Framework | |||
102 | 102 | ||
103 | public void CreateCaps(UUID agentId) | 103 | public void CreateCaps(UUID agentId) |
104 | { | 104 | { |
105 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) | 105 | int flags = m_scene.GetUserFlags(agentId); |
106 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags)) | ||
106 | return; | 107 | return; |
107 | 108 | ||
108 | String capsObjectPath = GetCapsPath(agentId); | 109 | String capsObjectPath = GetCapsPath(agentId); |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 3cb1901..cb09047 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -148,8 +148,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
148 | 148 | ||
149 | protected virtual void OnNewClient(IClientAPI client) | 149 | protected virtual void OnNewClient(IClientAPI client) |
150 | { | 150 | { |
151 | client.OnTeleportHomeRequest += TeleportHome; | 151 | client.OnTeleportHomeRequest += TriggerTeleportHome; |
152 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; | 152 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; |
153 | client.OnTeleportCancel += TeleportCancel; | ||
153 | } | 154 | } |
154 | 155 | ||
155 | public virtual void Close() {} | 156 | public virtual void Close() {} |
@@ -222,7 +223,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
222 | /// <param name="sp"></param> | 223 | /// <param name="sp"></param> |
223 | /// <param name="position"></param> | 224 | /// <param name="position"></param> |
224 | /// <param name="lookAt"></param> | 225 | /// <param name="lookAt"></param> |
225 | /// <param name="teleportFlags"></param | 226 | /// <param name="teleportFlags"></param> |
226 | private void TeleportAgentWithinRegion(ScenePresence sp, Vector3 position, Vector3 lookAt, uint teleportFlags) | 227 | private void TeleportAgentWithinRegion(ScenePresence sp, Vector3 position, Vector3 lookAt, uint teleportFlags) |
227 | { | 228 | { |
228 | m_log.DebugFormat( | 229 | m_log.DebugFormat( |
@@ -266,11 +267,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
266 | position.Z = newPosZ; | 267 | position.Z = newPosZ; |
267 | } | 268 | } |
268 | 269 | ||
270 | if (sp.Flying) | ||
271 | teleportFlags |= (uint)TeleportFlags.IsFlying; | ||
272 | |||
269 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); | 273 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); |
270 | 274 | ||
271 | sp.ControllingClient.SendTeleportStart(teleportFlags); | 275 | sp.ControllingClient.SendTeleportStart(teleportFlags); |
272 | 276 | ||
273 | sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); | 277 | sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); |
278 | sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags; | ||
274 | sp.Velocity = Vector3.Zero; | 279 | sp.Velocity = Vector3.Zero; |
275 | sp.Teleport(position); | 280 | sp.Teleport(position); |
276 | 281 | ||
@@ -397,14 +402,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
397 | { | 402 | { |
398 | // Record that this agent is in transit so that we can prevent simultaneous requests and do later detection | 403 | // Record that this agent is in transit so that we can prevent simultaneous requests and do later detection |
399 | // of whether the destination region completes the teleport. | 404 | // of whether the destination region completes the teleport. |
400 | if (!m_entityTransferStateMachine.SetInTransit(sp.UUID)) | 405 | m_entityTransferStateMachine.SetInTransit(sp.UUID); |
401 | { | 406 | // if (!m_entityTransferStateMachine.SetInTransit(sp.UUID)) |
402 | m_log.DebugFormat( | 407 | // { |
403 | "[ENTITY TRANSFER MODULE]: Ignoring teleport request of {0} {1} to {2} ({3}) {4}/{5} - agent is already in transit.", | 408 | // m_log.DebugFormat( |
404 | sp.Name, sp.UUID, reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position); | 409 | // "[ENTITY TRANSFER MODULE]: Ignoring teleport request of {0} {1} to {2} ({3}) {4}/{5} - agent is already in transit.", |
405 | 410 | // sp.Name, sp.UUID, reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position); | |
406 | return; | 411 | // |
407 | } | 412 | // return; |
413 | // } | ||
408 | 414 | ||
409 | if (reg == null || finalDestination == null) | 415 | if (reg == null || finalDestination == null) |
410 | { | 416 | { |
@@ -446,8 +452,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
446 | // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, | 452 | // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, |
447 | // it's actually doing a lot of work. | 453 | // it's actually doing a lot of work. |
448 | IPEndPoint endPoint = finalDestination.ExternalEndPoint; | 454 | IPEndPoint endPoint = finalDestination.ExternalEndPoint; |
449 | 455 | if (endPoint == null || endPoint.Address == null) | |
450 | if (endPoint.Address == null) | ||
451 | { | 456 | { |
452 | sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); | 457 | sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); |
453 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); | 458 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); |
@@ -487,6 +492,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
487 | // both regions | 492 | // both regions |
488 | if (sp.ParentID != (uint)0) | 493 | if (sp.ParentID != (uint)0) |
489 | sp.StandUp(); | 494 | sp.StandUp(); |
495 | else if (sp.Flying) | ||
496 | teleportFlags |= (uint)TeleportFlags.IsFlying; | ||
490 | 497 | ||
491 | // At least on LL 3.3.4, this is not strictly necessary - a teleport will succeed without sending this to | 498 | // At least on LL 3.3.4, this is not strictly necessary - a teleport will succeed without sending this to |
492 | // the viewer. However, it might mean that the viewer does not see the black teleport screen (untested). | 499 | // the viewer. However, it might mean that the viewer does not see the black teleport screen (untested). |
@@ -664,7 +671,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
664 | // | 671 | // |
665 | // This sleep can be increased if necessary. However, whilst it's active, | 672 | // This sleep can be increased if necessary. However, whilst it's active, |
666 | // an agent cannot teleport back to this region if it has teleported away. | 673 | // an agent cannot teleport back to this region if it has teleported away. |
667 | Thread.Sleep(2000); | 674 | Thread.Sleep(3000); |
668 | 675 | ||
669 | sp.Scene.IncomingCloseAgent(sp.UUID, false); | 676 | sp.Scene.IncomingCloseAgent(sp.UUID, false); |
670 | } | 677 | } |
@@ -804,7 +811,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
804 | 811 | ||
805 | #region Teleport Home | 812 | #region Teleport Home |
806 | 813 | ||
807 | public virtual void TeleportHome(UUID id, IClientAPI client) | 814 | public virtual void TriggerTeleportHome(UUID id, IClientAPI client) |
815 | { | ||
816 | TeleportHome(id, client); | ||
817 | } | ||
818 | |||
819 | public virtual bool TeleportHome(UUID id, IClientAPI client) | ||
808 | { | 820 | { |
809 | m_log.DebugFormat( | 821 | m_log.DebugFormat( |
810 | "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); | 822 | "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); |
@@ -814,12 +826,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
814 | 826 | ||
815 | if (uinfo != null) | 827 | if (uinfo != null) |
816 | { | 828 | { |
829 | if (uinfo.HomeRegionID == UUID.Zero) | ||
830 | { | ||
831 | // can't find the Home region: Tell viewer and abort | ||
832 | client.SendTeleportFailed("You don't have a home position set."); | ||
833 | return false; | ||
834 | } | ||
817 | GridRegion regionInfo = Scene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); | 835 | GridRegion regionInfo = Scene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); |
818 | if (regionInfo == null) | 836 | if (regionInfo == null) |
819 | { | 837 | { |
820 | // can't find the Home region: Tell viewer and abort | 838 | // can't find the Home region: Tell viewer and abort |
821 | client.SendTeleportFailed("Your home region could not be found."); | 839 | client.SendTeleportFailed("Your home region could not be found."); |
822 | return; | 840 | return false; |
823 | } | 841 | } |
824 | 842 | ||
825 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Home region of {0} is {1} ({2}-{3})", | 843 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Home region of {0} is {1} ({2}-{3})", |
@@ -832,10 +850,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
832 | } | 850 | } |
833 | else | 851 | else |
834 | { | 852 | { |
835 | m_log.ErrorFormat( | 853 | // can't find the Home region: Tell viewer and abort |
836 | "[ENTITY TRANSFER MODULE]: No grid user information found for {0} {1}. Cannot send home.", | 854 | client.SendTeleportFailed("Your home region could not be found."); |
837 | client.Name, client.AgentId); | 855 | return false; |
838 | } | 856 | } |
857 | return true; | ||
839 | } | 858 | } |
840 | 859 | ||
841 | #endregion | 860 | #endregion |
@@ -843,11 +862,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
843 | 862 | ||
844 | #region Agent Crossings | 863 | #region Agent Crossings |
845 | 864 | ||
846 | public bool Cross(ScenePresence agent, bool isFlying) | 865 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos) |
847 | { | 866 | { |
848 | Scene scene = agent.Scene; | 867 | version = String.Empty; |
849 | Vector3 pos = agent.AbsolutePosition; | 868 | newpos = new Vector3(pos.X, pos.Y, pos.Z); |
850 | Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z); | ||
851 | uint neighbourx = scene.RegionInfo.RegionLocX; | 869 | uint neighbourx = scene.RegionInfo.RegionLocX; |
852 | uint neighboury = scene.RegionInfo.RegionLocY; | 870 | uint neighboury = scene.RegionInfo.RegionLocY; |
853 | const float boundaryDistance = 1.7f; | 871 | const float boundaryDistance = 1.7f; |
@@ -868,52 +886,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
868 | } | 886 | } |
869 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | 887 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) |
870 | { | 888 | { |
871 | Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); | 889 | neighboury--; |
872 | if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) | 890 | newpos.Y = Constants.RegionSize - enterDistance; |
873 | { | ||
874 | neighboury--; | ||
875 | newpos.Y = Constants.RegionSize - enterDistance; | ||
876 | } | ||
877 | else | ||
878 | { | ||
879 | agent.IsInTransit = true; | ||
880 | |||
881 | neighboury = b.TriggerRegionY; | ||
882 | neighbourx = b.TriggerRegionX; | ||
883 | |||
884 | Vector3 newposition = pos; | ||
885 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
886 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
887 | agent.ControllingClient.SendAgentAlertMessage( | ||
888 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
889 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
890 | return true; | ||
891 | } | ||
892 | } | ||
893 | |||
894 | Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W); | ||
895 | if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) | ||
896 | { | ||
897 | neighbourx--; | ||
898 | newpos.X = Constants.RegionSize - enterDistance; | ||
899 | } | ||
900 | else | ||
901 | { | ||
902 | agent.IsInTransit = true; | ||
903 | |||
904 | neighboury = ba.TriggerRegionY; | ||
905 | neighbourx = ba.TriggerRegionX; | ||
906 | |||
907 | Vector3 newposition = pos; | ||
908 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
909 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
910 | agent.ControllingClient.SendAgentAlertMessage( | ||
911 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
912 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
913 | |||
914 | return true; | ||
915 | } | 891 | } |
916 | 892 | ||
893 | neighbourx--; | ||
894 | newpos.X = Constants.RegionSize - enterDistance; | ||
917 | } | 895 | } |
918 | else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) | 896 | else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) |
919 | { | 897 | { |
@@ -923,26 +901,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
923 | 901 | ||
924 | if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | 902 | if (scene.TestBorderCross(pos + southCross, Cardinals.S)) |
925 | { | 903 | { |
926 | Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S); | 904 | neighboury--; |
927 | if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) | 905 | newpos.Y = Constants.RegionSize - enterDistance; |
928 | { | ||
929 | neighboury--; | ||
930 | newpos.Y = Constants.RegionSize - enterDistance; | ||
931 | } | ||
932 | else | ||
933 | { | ||
934 | agent.IsInTransit = true; | ||
935 | |||
936 | neighboury = ba.TriggerRegionY; | ||
937 | neighbourx = ba.TriggerRegionX; | ||
938 | Vector3 newposition = pos; | ||
939 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
940 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
941 | agent.ControllingClient.SendAgentAlertMessage( | ||
942 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
943 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
944 | return true; | ||
945 | } | ||
946 | } | 906 | } |
947 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | 907 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) |
948 | { | 908 | { |
@@ -954,25 +914,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
954 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | 914 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) |
955 | { | 915 | { |
956 | Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); | 916 | Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); |
957 | if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) | 917 | neighboury--; |
958 | { | 918 | newpos.Y = Constants.RegionSize - enterDistance; |
959 | neighboury--; | ||
960 | newpos.Y = Constants.RegionSize - enterDistance; | ||
961 | } | ||
962 | else | ||
963 | { | ||
964 | agent.IsInTransit = true; | ||
965 | |||
966 | neighboury = b.TriggerRegionY; | ||
967 | neighbourx = b.TriggerRegionX; | ||
968 | Vector3 newposition = pos; | ||
969 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
970 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
971 | agent.ControllingClient.SendAgentAlertMessage( | ||
972 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
973 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
974 | return true; | ||
975 | } | ||
976 | } | 919 | } |
977 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | 920 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) |
978 | { | 921 | { |
@@ -1006,19 +949,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1006 | } | 949 | } |
1007 | */ | 950 | */ |
1008 | 951 | ||
1009 | ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | 952 | xDest = neighbourx; |
953 | yDest = neighboury; | ||
1010 | 954 | ||
1011 | int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); | 955 | int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); |
1012 | 956 | ||
957 | ulong neighbourHandle = Utils.UIntsToLong((uint)x, (uint)y); | ||
958 | |||
1013 | ExpiringCache<ulong, DateTime> r; | 959 | ExpiringCache<ulong, DateTime> r; |
1014 | DateTime banUntil; | 960 | DateTime banUntil; |
1015 | 961 | ||
1016 | if (m_bannedRegions.TryGetValue(agent.ControllingClient.AgentId, out r)) | 962 | if (m_bannedRegions.TryGetValue(agentID, out r)) |
1017 | { | 963 | { |
1018 | if (r.TryGetValue(neighbourHandle, out banUntil)) | 964 | if (r.TryGetValue(neighbourHandle, out banUntil)) |
1019 | { | 965 | { |
1020 | if (DateTime.Now < banUntil) | 966 | if (DateTime.Now < banUntil) |
1021 | return false; | 967 | return null; |
1022 | r.Remove(neighbourHandle); | 968 | r.Remove(neighbourHandle); |
1023 | } | 969 | } |
1024 | } | 970 | } |
@@ -1030,28 +976,48 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1030 | GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); | 976 | GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); |
1031 | 977 | ||
1032 | string reason; | 978 | string reason; |
1033 | string version; | 979 | if (!scene.SimulationService.QueryAccess(neighbourRegion, agentID, newpos, out version, out reason)) |
1034 | if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos, out version, out reason)) | ||
1035 | { | 980 | { |
1036 | agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); | ||
1037 | if (r == null) | 981 | if (r == null) |
1038 | { | 982 | { |
1039 | r = new ExpiringCache<ulong, DateTime>(); | 983 | r = new ExpiringCache<ulong, DateTime>(); |
1040 | r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); | 984 | r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); |
1041 | 985 | ||
1042 | m_bannedRegions.Add(agent.ControllingClient.AgentId, r, TimeSpan.FromSeconds(45)); | 986 | m_bannedRegions.Add(agentID, r, TimeSpan.FromSeconds(45)); |
1043 | } | 987 | } |
1044 | else | 988 | else |
1045 | { | 989 | { |
1046 | r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); | 990 | r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); |
1047 | } | 991 | } |
992 | return null; | ||
993 | } | ||
994 | |||
995 | return neighbourRegion; | ||
996 | } | ||
997 | |||
998 | private void TeleportCancel(IClientAPI remoteClient) | ||
999 | { | ||
1000 | m_entityTransferStateMachine.ResetFromTransit(remoteClient.AgentId); | ||
1001 | } | ||
1002 | |||
1003 | public bool Cross(ScenePresence agent, bool isFlying) | ||
1004 | { | ||
1005 | uint x; | ||
1006 | uint y; | ||
1007 | Vector3 newpos; | ||
1008 | string version; | ||
1009 | |||
1010 | GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, agent.AbsolutePosition, out x, out y, out version, out newpos); | ||
1011 | if (neighbourRegion == null) | ||
1012 | { | ||
1013 | agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); | ||
1048 | return false; | 1014 | return false; |
1049 | } | 1015 | } |
1050 | 1016 | ||
1051 | agent.IsInTransit = true; | 1017 | agent.IsInTransit = true; |
1052 | 1018 | ||
1053 | CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; | 1019 | CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; |
1054 | d.BeginInvoke(agent, newpos, neighbourx, neighboury, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d); | 1020 | d.BeginInvoke(agent, newpos, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d); |
1055 | 1021 | ||
1056 | return true; | 1022 | return true; |
1057 | } | 1023 | } |
@@ -1120,44 +1086,43 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1120 | icon.EndInvoke(iar); | 1086 | icon.EndInvoke(iar); |
1121 | } | 1087 | } |
1122 | 1088 | ||
1123 | public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying, string version); | 1089 | public bool CrossAgentToNewRegionPrep(ScenePresence agent, GridRegion neighbourRegion) |
1090 | { | ||
1091 | if (neighbourRegion == null) | ||
1092 | return false; | ||
1093 | |||
1094 | m_entityTransferStateMachine.SetInTransit(agent.UUID); | ||
1095 | |||
1096 | agent.RemoveFromPhysicalScene(); | ||
1097 | |||
1098 | return true; | ||
1099 | } | ||
1124 | 1100 | ||
1125 | /// <summary> | 1101 | /// <summary> |
1126 | /// This Closes child agents on neighbouring regions | 1102 | /// This Closes child agents on neighbouring regions |
1127 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | 1103 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. |
1128 | /// </summary> | 1104 | /// </summary> |
1129 | protected ScenePresence CrossAgentToNewRegionAsync( | 1105 | public ScenePresence CrossAgentToNewRegionAsync( |
1130 | ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, | 1106 | ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, |
1131 | bool isFlying, string version) | 1107 | bool isFlying, string version) |
1132 | { | 1108 | { |
1133 | if (neighbourRegion == null) | 1109 | if (!CrossAgentToNewRegionPrep(agent, neighbourRegion)) |
1134 | return agent; | 1110 | return agent; |
1135 | 1111 | ||
1136 | try | 1112 | if (!CrossAgentIntoNewRegionMain(agent, pos, neighbourRegion, isFlying)) |
1137 | { | 1113 | return agent; |
1138 | m_entityTransferStateMachine.SetInTransit(agent.UUID); | ||
1139 | |||
1140 | ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | ||
1141 | |||
1142 | m_log.DebugFormat( | ||
1143 | "[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3} running version {4}", | ||
1144 | agent.Firstname, agent.Lastname, neighbourx, neighboury, version); | ||
1145 | |||
1146 | Scene m_scene = agent.Scene; | ||
1147 | |||
1148 | if (!agent.ValidateAttachments()) | ||
1149 | m_log.DebugFormat( | ||
1150 | "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for region crossing of {0} from {1} to {2}. Continuing.", | ||
1151 | agent.Name, agent.Scene.RegionInfo.RegionName, neighbourRegion.RegionName); | ||
1152 | |||
1153 | pos = pos + agent.Velocity; | ||
1154 | Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0); | ||
1155 | 1114 | ||
1156 | agent.RemoveFromPhysicalScene(); | 1115 | CrossAgentToNewRegionPost(agent, pos, neighbourRegion, isFlying, version); |
1116 | return agent; | ||
1117 | } | ||
1157 | 1118 | ||
1119 | public bool CrossAgentIntoNewRegionMain(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying) | ||
1120 | { | ||
1121 | try | ||
1122 | { | ||
1158 | AgentData cAgent = new AgentData(); | 1123 | AgentData cAgent = new AgentData(); |
1159 | agent.CopyTo(cAgent); | 1124 | agent.CopyTo(cAgent); |
1160 | cAgent.Position = pos; | 1125 | cAgent.Position = pos + agent.Velocity; |
1161 | if (isFlying) | 1126 | if (isFlying) |
1162 | cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | 1127 | cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; |
1163 | 1128 | ||
@@ -1167,7 +1132,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1167 | // Beyond this point, extra cleanup is needed beyond removing transit state | 1132 | // Beyond this point, extra cleanup is needed beyond removing transit state |
1168 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring); | 1133 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring); |
1169 | 1134 | ||
1170 | if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) | 1135 | if (!agent.Scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) |
1171 | { | 1136 | { |
1172 | // region doesn't take it | 1137 | // region doesn't take it |
1173 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); | 1138 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); |
@@ -1176,93 +1141,108 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1176 | agent.AddToPhysicalScene(isFlying); | 1141 | agent.AddToPhysicalScene(isFlying); |
1177 | m_entityTransferStateMachine.ResetFromTransit(agent.UUID); | 1142 | m_entityTransferStateMachine.ResetFromTransit(agent.UUID); |
1178 | 1143 | ||
1179 | return agent; | 1144 | return false; |
1180 | } | 1145 | } |
1181 | 1146 | ||
1182 | //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); | 1147 | } |
1183 | agent.ControllingClient.RequestClientInfo(); | 1148 | catch (Exception e) |
1149 | { | ||
1150 | m_log.ErrorFormat( | ||
1151 | "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2}. Exception {3}{4}", | ||
1152 | agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName, e.Message, e.StackTrace); | ||
1153 | |||
1154 | // TODO: Might be worth attempting other restoration here such as reinstantiation of scripts, etc. | ||
1155 | return false; | ||
1156 | } | ||
1184 | 1157 | ||
1185 | //m_log.Debug("BEFORE CROSS"); | 1158 | return true; |
1186 | //Scene.DumpChildrenSeeds(UUID); | 1159 | } |
1187 | //DumpKnownRegions(); | ||
1188 | string agentcaps; | ||
1189 | if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) | ||
1190 | { | ||
1191 | m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", | ||
1192 | neighbourRegion.RegionHandle); | ||
1193 | return agent; | ||
1194 | } | ||
1195 | // No turning back | ||
1196 | agent.IsChildAgent = true; | ||
1197 | 1160 | ||
1198 | string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); | 1161 | public void CrossAgentToNewRegionPost(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, |
1162 | bool isFlying, string version) | ||
1163 | { | ||
1164 | agent.ControllingClient.RequestClientInfo(); | ||
1199 | 1165 | ||
1200 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); | 1166 | string agentcaps; |
1167 | if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) | ||
1168 | { | ||
1169 | m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", | ||
1170 | neighbourRegion.RegionHandle); | ||
1171 | return; | ||
1172 | } | ||
1201 | 1173 | ||
1202 | if (m_eqModule != null) | 1174 | // No turning back |
1203 | { | 1175 | agent.IsChildAgent = true; |
1204 | m_eqModule.CrossRegion( | ||
1205 | neighbourHandle, pos, vel2 /* agent.Velocity */, neighbourRegion.ExternalEndPoint, | ||
1206 | capsPath, agent.UUID, agent.ControllingClient.SessionId); | ||
1207 | } | ||
1208 | else | ||
1209 | { | ||
1210 | agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, | ||
1211 | capsPath); | ||
1212 | } | ||
1213 | 1176 | ||
1214 | // SUCCESS! | 1177 | string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); |
1215 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination); | ||
1216 | 1178 | ||
1217 | // Unlike a teleport, here we do not wait for the destination region to confirm the receipt. | 1179 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); |
1218 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); | ||
1219 | 1180 | ||
1220 | agent.MakeChildAgent(); | 1181 | Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0); |
1221 | 1182 | ||
1222 | // FIXME: Possibly this should occur lower down after other commands to close other agents, | 1183 | if (m_eqModule != null) |
1223 | // but not sure yet what the side effects would be. | 1184 | { |
1224 | m_entityTransferStateMachine.ResetFromTransit(agent.UUID); | 1185 | m_eqModule.CrossRegion( |
1186 | neighbourRegion.RegionHandle, pos + agent.Velocity, vel2 /* agent.Velocity */, neighbourRegion.ExternalEndPoint, | ||
1187 | capsPath, agent.UUID, agent.ControllingClient.SessionId); | ||
1188 | } | ||
1189 | else | ||
1190 | { | ||
1191 | agent.ControllingClient.CrossRegion(neighbourRegion.RegionHandle, pos + agent.Velocity, agent.Velocity, neighbourRegion.ExternalEndPoint, | ||
1192 | capsPath); | ||
1193 | } | ||
1225 | 1194 | ||
1226 | // now we have a child agent in this region. Request all interesting data about other (root) agents | 1195 | // SUCCESS! |
1227 | agent.SendOtherAgentsAvatarDataToMe(); | 1196 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination); |
1228 | agent.SendOtherAgentsAppearanceToMe(); | ||
1229 | 1197 | ||
1230 | // Backwards compatibility. Best effort | 1198 | // Unlike a teleport, here we do not wait for the destination region to confirm the receipt. |
1231 | if (version == "Unknown" || version == string.Empty) | 1199 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); |
1232 | { | ||
1233 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one..."); | ||
1234 | Thread.Sleep(3000); // wait a little now that we're not waiting for the callback | ||
1235 | CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); | ||
1236 | } | ||
1237 | 1200 | ||
1238 | // Next, let's close the child agent connections that are too far away. | 1201 | agent.MakeChildAgent(); |
1239 | agent.CloseChildAgents(neighbourx, neighboury); | ||
1240 | 1202 | ||
1241 | AgentHasMovedAway(agent, false); | 1203 | // FIXME: Possibly this should occur lower down after other commands to close other agents, |
1204 | // but not sure yet what the side effects would be. | ||
1205 | m_entityTransferStateMachine.ResetFromTransit(agent.UUID); | ||
1242 | 1206 | ||
1243 | // // the user may change their profile information in other region, | 1207 | // now we have a child agent in this region. Request all interesting data about other (root) agents |
1244 | // // so the userinfo in UserProfileCache is not reliable any more, delete it | 1208 | agent.SendOtherAgentsAvatarDataToMe(); |
1245 | // // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | 1209 | agent.SendOtherAgentsAppearanceToMe(); |
1246 | // if (agent.Scene.NeedSceneCacheClear(agent.UUID)) | ||
1247 | // { | ||
1248 | // m_log.DebugFormat( | ||
1249 | // "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); | ||
1250 | // } | ||
1251 | |||
1252 | //m_log.Debug("AFTER CROSS"); | ||
1253 | //Scene.DumpChildrenSeeds(UUID); | ||
1254 | //DumpKnownRegions(); | ||
1255 | } | ||
1256 | catch (Exception e) | ||
1257 | { | ||
1258 | m_log.ErrorFormat( | ||
1259 | "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2}. Exception {3}{4}", | ||
1260 | agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName, e.Message, e.StackTrace); | ||
1261 | 1210 | ||
1262 | // TODO: Might be worth attempting other restoration here such as reinstantiation of scripts, etc. | 1211 | // Backwards compatibility. Best effort |
1212 | if (version == "Unknown" || version == string.Empty) | ||
1213 | { | ||
1214 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one..."); | ||
1215 | Thread.Sleep(3000); // wait a little now that we're not waiting for the callback | ||
1216 | CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); | ||
1263 | } | 1217 | } |
1264 | 1218 | ||
1265 | return agent; | 1219 | // Next, let's close the child agent connections that are too far away. |
1220 | uint neighbourx; | ||
1221 | uint neighboury; | ||
1222 | |||
1223 | Utils.LongToUInts(neighbourRegion.RegionHandle, out neighbourx, out neighboury); | ||
1224 | |||
1225 | neighbourx /= Constants.RegionSize; | ||
1226 | neighboury /= Constants.RegionSize; | ||
1227 | |||
1228 | agent.CloseChildAgents(neighbourx, neighboury); | ||
1229 | |||
1230 | AgentHasMovedAway(agent, false); | ||
1231 | |||
1232 | // the user may change their profile information in other region, | ||
1233 | // so the userinfo in UserProfileCache is not reliable any more, delete it | ||
1234 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | ||
1235 | // if (agent.Scene.NeedSceneCacheClear(agent.UUID)) | ||
1236 | // { | ||
1237 | // m_log.DebugFormat( | ||
1238 | // "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); | ||
1239 | // } | ||
1240 | |||
1241 | //m_log.Debug("AFTER CROSS"); | ||
1242 | //Scene.DumpChildrenSeeds(UUID); | ||
1243 | //DumpKnownRegions(); | ||
1244 | |||
1245 | return; | ||
1266 | } | 1246 | } |
1267 | 1247 | ||
1268 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) | 1248 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) |
@@ -1333,10 +1313,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1333 | agent.Id0 = currentAgentCircuit.Id0; | 1313 | agent.Id0 = currentAgentCircuit.Id0; |
1334 | } | 1314 | } |
1335 | 1315 | ||
1336 | InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; | 1316 | IPEndPoint external = region.ExternalEndPoint; |
1337 | d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, | 1317 | if (external != null) |
1318 | { | ||
1319 | InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; | ||
1320 | d.BeginInvoke(sp, agent, region, external, true, | ||
1338 | InformClientOfNeighbourCompleted, | 1321 | InformClientOfNeighbourCompleted, |
1339 | d); | 1322 | d); |
1323 | } | ||
1340 | } | 1324 | } |
1341 | #endregion | 1325 | #endregion |
1342 | 1326 | ||
@@ -1917,27 +1901,31 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1917 | Utils.LongToUInts(newRegionHandle, out x, out y); | 1901 | Utils.LongToUInts(newRegionHandle, out x, out y); |
1918 | GridRegion destination = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); | 1902 | GridRegion destination = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); |
1919 | 1903 | ||
1920 | if (destination == null || !CrossPrimGroupIntoNewRegion(destination, pos, grp, silent)) | 1904 | if (destination != null) |
1921 | { | 1905 | { |
1922 | m_log.InfoFormat("[ENTITY TRANSFER MODULE] cross region transfer failed for object {0}",grp.UUID); | 1906 | if (CrossPrimGroupIntoNewRegion(destination, pos, grp, silent)) |
1907 | return; // we did it | ||
1908 | } | ||
1923 | 1909 | ||
1924 | // We are going to move the object back to the old position so long as the old position | 1910 | // no one or failed lets go back and tell physics to go on |
1925 | // is in the region | 1911 | oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X, 0.5f, (float)Constants.RegionSize - 0.5f); |
1926 | oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X,1.0f,(float)Constants.RegionSize-1); | 1912 | oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y, 0.5f, (float)Constants.RegionSize - 0.5f); |
1927 | oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y,1.0f,(float)Constants.RegionSize-1); | 1913 | oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z, 0.5f, 4096.0f); |
1928 | oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z,1.0f,4096.0f); | ||
1929 | 1914 | ||
1930 | grp.RootPart.GroupPosition = oldGroupPosition; | 1915 | grp.AbsolutePosition = oldGroupPosition; |
1916 | grp.Velocity = Vector3.Zero; | ||
1931 | 1917 | ||
1932 | // Need to turn off the physics flags, otherwise the object will continue to attempt to | 1918 | if (grp.RootPart.PhysActor != null) |
1933 | // move out of the region creating an infinite loop of failed attempts to cross | 1919 | grp.RootPart.PhysActor.CrossingFailure(); |
1934 | grp.UpdatePrimFlags(grp.RootPart.LocalId,false,grp.IsTemporary,grp.IsPhantom,false); | ||
1935 | 1920 | ||
1936 | grp.ScheduleGroupForFullUpdate(); | 1921 | if (grp.RootPart.KeyframeMotion != null) |
1937 | } | 1922 | grp.RootPart.KeyframeMotion.CrossingFailure(); |
1923 | |||
1924 | grp.ScheduleGroupForFullUpdate(); | ||
1938 | } | 1925 | } |
1939 | 1926 | ||
1940 | 1927 | ||
1928 | |||
1941 | /// <summary> | 1929 | /// <summary> |
1942 | /// Move the given scene object into a new region | 1930 | /// Move the given scene object into a new region |
1943 | /// </summary> | 1931 | /// </summary> |
@@ -1988,17 +1976,30 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1988 | grp, e); | 1976 | grp, e); |
1989 | } | 1977 | } |
1990 | } | 1978 | } |
1979 | /* | ||
1980 | * done on caller ( not in attachments crossing for now) | ||
1991 | else | 1981 | else |
1992 | { | 1982 | { |
1983 | |||
1993 | if (!grp.IsDeleted) | 1984 | if (!grp.IsDeleted) |
1994 | { | 1985 | { |
1995 | PhysicsActor pa = grp.RootPart.PhysActor; | 1986 | PhysicsActor pa = grp.RootPart.PhysActor; |
1996 | if (pa != null) | 1987 | if (pa != null) |
1988 | { | ||
1997 | pa.CrossingFailure(); | 1989 | pa.CrossingFailure(); |
1990 | if (grp.RootPart.KeyframeMotion != null) | ||
1991 | { | ||
1992 | // moved to KeyframeMotion.CrossingFailure | ||
1993 | // grp.RootPart.Velocity = Vector3.Zero; | ||
1994 | grp.RootPart.KeyframeMotion.CrossingFailure(); | ||
1995 | // grp.SendGroupRootTerseUpdate(); | ||
1996 | } | ||
1997 | } | ||
1998 | } | 1998 | } |
1999 | 1999 | ||
2000 | m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp); | 2000 | m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp); |
2001 | } | 2001 | } |
2002 | */ | ||
2002 | } | 2003 | } |
2003 | else | 2004 | else |
2004 | { | 2005 | { |
@@ -2083,4 +2084,4 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2083 | #endregion | 2084 | #endregion |
2084 | 2085 | ||
2085 | } | 2086 | } |
2086 | } \ No newline at end of file | 2087 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs index d0cab49..70dd1bc 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs | |||
@@ -218,7 +218,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
218 | id, m_mod.Scene.RegionInfo.RegionName, currentState)); | 218 | id, m_mod.Scene.RegionInfo.RegionName, currentState)); |
219 | } | 219 | } |
220 | 220 | ||
221 | int count = 200; | 221 | int count = 400; |
222 | 222 | ||
223 | // There should be no race condition here since no other code should be removing the agent transfer or | 223 | // There should be no race condition here since no other code should be removing the agent transfer or |
224 | // changing the state to another other than Transferring => ReceivedAtDestination. | 224 | // changing the state to another other than Transferring => ReceivedAtDestination. |
@@ -266,4 +266,4 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
266 | } | 266 | } |
267 | } | 267 | } |
268 | } | 268 | } |
269 | } \ No newline at end of file | 269 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index b188741..9b78b3b 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -184,7 +184,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
184 | 184 | ||
185 | protected override void OnNewClient(IClientAPI client) | 185 | protected override void OnNewClient(IClientAPI client) |
186 | { | 186 | { |
187 | client.OnTeleportHomeRequest += TeleportHome; | 187 | client.OnTeleportHomeRequest += TriggerTeleportHome; |
188 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; | 188 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; |
189 | client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed); | 189 | client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed); |
190 | } | 190 | } |
@@ -291,6 +291,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
291 | return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout); | 291 | return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout); |
292 | } | 292 | } |
293 | 293 | ||
294 | public void TriggerTeleportHome(UUID id, IClientAPI client) | ||
295 | { | ||
296 | TeleportHome(id, client); | ||
297 | } | ||
298 | |||
294 | protected override bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason) | 299 | protected override bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason) |
295 | { | 300 | { |
296 | reason = "Please wear your grid's allowed appearance before teleporting to another grid"; | 301 | reason = "Please wear your grid's allowed appearance before teleporting to another grid"; |
@@ -409,7 +414,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
409 | // return base.UpdateAgent(reg, finalDestination, agentData, sp); | 414 | // return base.UpdateAgent(reg, finalDestination, agentData, sp); |
410 | //} | 415 | //} |
411 | 416 | ||
412 | public override void TeleportHome(UUID id, IClientAPI client) | 417 | public override bool TeleportHome(UUID id, IClientAPI client) |
413 | { | 418 | { |
414 | m_log.DebugFormat( | 419 | m_log.DebugFormat( |
415 | "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); | 420 | "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); |
@@ -420,8 +425,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
420 | { | 425 | { |
421 | // local grid user | 426 | // local grid user |
422 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); | 427 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); |
423 | base.TeleportHome(id, client); | 428 | return base.TeleportHome(id, client); |
424 | return; | ||
425 | } | 429 | } |
426 | 430 | ||
427 | // Foreign user wants to go home | 431 | // Foreign user wants to go home |
@@ -431,7 +435,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
431 | { | 435 | { |
432 | client.SendTeleportFailed("Your information has been lost"); | 436 | client.SendTeleportFailed("Your information has been lost"); |
433 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); | 437 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); |
434 | return; | 438 | return false; |
435 | } | 439 | } |
436 | 440 | ||
437 | IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); | 441 | IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); |
@@ -441,7 +445,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
441 | { | 445 | { |
442 | client.SendTeleportFailed("Your home region could not be found"); | 446 | client.SendTeleportFailed("Your home region could not be found"); |
443 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); | 447 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); |
444 | return; | 448 | return false; |
445 | } | 449 | } |
446 | 450 | ||
447 | ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId); | 451 | ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId); |
@@ -449,7 +453,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
449 | { | 453 | { |
450 | client.SendTeleportFailed("Internal error"); | 454 | client.SendTeleportFailed("Internal error"); |
451 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be"); | 455 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be"); |
452 | return; | 456 | return false; |
453 | } | 457 | } |
454 | 458 | ||
455 | GridRegion homeGatekeeper = MakeRegion(aCircuit); | 459 | GridRegion homeGatekeeper = MakeRegion(aCircuit); |
@@ -457,9 +461,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
457 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}", | 461 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}", |
458 | aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName); | 462 | aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName); |
459 | 463 | ||
460 | DoTeleport( | 464 | DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); |
461 | sp, homeGatekeeper, finalDestination, | 465 | return true; |
462 | position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); | ||
463 | } | 466 | } |
464 | 467 | ||
465 | /// <summary> | 468 | /// <summary> |
@@ -586,4 +589,4 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
586 | return region; | 589 | return region; |
587 | } | 590 | } |
588 | } | 591 | } |
589 | } \ No newline at end of file | 592 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 8b7c16e..6e5a4a5 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -182,44 +182,49 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
182 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) | 182 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) |
183 | return; | 183 | return; |
184 | 184 | ||
185 | if (transactionID == UUID.Zero) | 185 | InventoryFolderBase f = new InventoryFolderBase(folderID, remoteClient.AgentId); |
186 | InventoryFolderBase folder = m_Scene.InventoryService.GetFolder(f); | ||
187 | |||
188 | if (folder == null || folder.Owner != remoteClient.AgentId) | ||
189 | return; | ||
190 | |||
191 | if (transactionID != UUID.Zero) | ||
186 | { | 192 | { |
187 | ScenePresence presence; | 193 | IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule; |
188 | if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 194 | if (agentTransactions != null) |
189 | { | 195 | { |
190 | byte[] data = null; | 196 | if (agentTransactions.HandleItemCreationFromTransaction( |
197 | remoteClient, transactionID, folderID, callbackID, description, | ||
198 | name, invType, assetType, wearableType, nextOwnerMask)) | ||
199 | return; | ||
200 | } | ||
201 | } | ||
191 | 202 | ||
192 | if (invType == (sbyte)InventoryType.Landmark && presence != null) | 203 | ScenePresence presence; |
193 | { | 204 | if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence)) |
194 | string suffix = string.Empty, prefix = string.Empty; | 205 | { |
195 | string strdata = GenerateLandmark(presence, out prefix, out suffix); | 206 | byte[] data = null; |
196 | data = Encoding.ASCII.GetBytes(strdata); | ||
197 | name = prefix + name; | ||
198 | description += suffix; | ||
199 | } | ||
200 | 207 | ||
201 | AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); | 208 | if (invType == (sbyte)InventoryType.Landmark && presence != null) |
202 | m_Scene.AssetService.Store(asset); | ||
203 | m_Scene.CreateNewInventoryItem( | ||
204 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, | ||
205 | name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate); | ||
206 | } | ||
207 | else | ||
208 | { | 209 | { |
209 | m_log.ErrorFormat( | 210 | string suffix = string.Empty, prefix = string.Empty; |
210 | "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", | 211 | string strdata = GenerateLandmark(presence, out prefix, out suffix); |
211 | remoteClient.AgentId); | 212 | data = Encoding.ASCII.GetBytes(strdata); |
213 | name = prefix + name; | ||
214 | description += suffix; | ||
212 | } | 215 | } |
216 | |||
217 | AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); | ||
218 | m_Scene.AssetService.Store(asset); | ||
219 | m_Scene.CreateNewInventoryItem( | ||
220 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, | ||
221 | name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate,transactionID); | ||
213 | } | 222 | } |
214 | else | 223 | else |
215 | { | 224 | { |
216 | IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule; | 225 | m_log.ErrorFormat( |
217 | if (agentTransactions != null) | 226 | "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", |
218 | { | 227 | remoteClient.AgentId); |
219 | agentTransactions.HandleItemCreationFromTransaction( | ||
220 | remoteClient, transactionID, folderID, callbackID, description, | ||
221 | name, invType, assetType, wearableType, nextOwnerMask); | ||
222 | } | ||
223 | } | 228 | } |
224 | } | 229 | } |
225 | 230 | ||
@@ -356,6 +361,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
356 | 361 | ||
357 | foreach (SceneObjectGroup objectGroup in objlist) | 362 | foreach (SceneObjectGroup objectGroup in objlist) |
358 | { | 363 | { |
364 | if (objectGroup.RootPart.KeyframeMotion != null) | ||
365 | objectGroup.RootPart.KeyframeMotion.Stop(); | ||
366 | objectGroup.RootPart.SetForce(Vector3.Zero); | ||
367 | objectGroup.RootPart.SetAngularImpulse(Vector3.Zero, false); | ||
368 | objectGroup.RootPart.KeyframeMotion = null; | ||
369 | |||
359 | Vector3 inventoryStoredPosition = new Vector3 | 370 | Vector3 inventoryStoredPosition = new Vector3 |
360 | (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | 371 | (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) |
361 | ? 250 | 372 | ? 250 |
@@ -366,9 +377,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
366 | : objectGroup.AbsolutePosition.Y, | 377 | : objectGroup.AbsolutePosition.Y, |
367 | objectGroup.AbsolutePosition.Z); | 378 | objectGroup.AbsolutePosition.Z); |
368 | 379 | ||
380 | Quaternion inventoryStoredRotation = objectGroup.GroupRotation; | ||
369 | originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; | 381 | originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; |
370 | 382 | ||
383 | // Restore attachment data after trip through the sim | ||
384 | if (objectGroup.RootPart.AttachPoint > 0) | ||
385 | { | ||
386 | inventoryStoredPosition = objectGroup.RootPart.AttachOffset; | ||
387 | inventoryStoredRotation = objectGroup.RootPart.AttachRotation; | ||
388 | } | ||
389 | objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint; | ||
390 | |||
371 | objectGroup.AbsolutePosition = inventoryStoredPosition; | 391 | objectGroup.AbsolutePosition = inventoryStoredPosition; |
392 | objectGroup.RootPart.RotationOffset = inventoryStoredRotation; | ||
372 | 393 | ||
373 | // Make sure all bits but the ones we want are clear | 394 | // Make sure all bits but the ones we want are clear |
374 | // on take. | 395 | // on take. |
@@ -486,8 +507,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
486 | IClientAPI remoteClient) | 507 | IClientAPI remoteClient) |
487 | { | 508 | { |
488 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; | 509 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; |
510 | // For the porposes of inventory, an object is modify if the prims | ||
511 | // are modify. This allows renaming an object that contains no | ||
512 | // mod items. | ||
489 | foreach (SceneObjectGroup grp in objsForEffectivePermissions) | 513 | foreach (SceneObjectGroup grp in objsForEffectivePermissions) |
490 | effectivePerms &= grp.GetEffectivePermissions(); | 514 | { |
515 | uint groupPerms = grp.GetEffectivePermissions(true); | ||
516 | if ((grp.RootPart.BaseMask & (uint)PermissionMask.Modify) != 0) | ||
517 | groupPerms |= (uint)PermissionMask.Modify; | ||
518 | |||
519 | effectivePerms &= groupPerms; | ||
520 | } | ||
491 | effectivePerms |= (uint)PermissionMask.Move; | 521 | effectivePerms |= (uint)PermissionMask.Move; |
492 | 522 | ||
493 | if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) | 523 | if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) |
@@ -666,7 +696,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
666 | if (so.FromFolderID != UUID.Zero && userID == remoteClient.AgentId) | 696 | if (so.FromFolderID != UUID.Zero && userID == remoteClient.AgentId) |
667 | { | 697 | { |
668 | InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID); | 698 | InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID); |
669 | folder = m_Scene.InventoryService.GetFolder(f); | 699 | if (f != null) |
700 | folder = m_Scene.InventoryService.GetFolder(f); | ||
670 | } | 701 | } |
671 | } | 702 | } |
672 | 703 | ||
@@ -696,16 +727,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
696 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | 727 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) |
697 | { | 728 | { |
698 | // m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); | 729 | // m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); |
699 | |||
700 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 730 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); |
701 | item = m_Scene.InventoryService.GetItem(item); | 731 | item = m_Scene.InventoryService.GetItem(item); |
702 | 732 | ||
703 | if (item == null) | 733 | if (item == null) |
704 | { | 734 | { |
705 | m_log.WarnFormat( | ||
706 | "[INVENTORY ACCESS MODULE]: Could not find item {0} for {1} in RezObject()", | ||
707 | itemID, remoteClient.Name); | ||
708 | |||
709 | return null; | 735 | return null; |
710 | } | 736 | } |
711 | 737 | ||
@@ -756,6 +782,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
756 | if (e == null || attachment) // Single | 782 | if (e == null || attachment) // Single |
757 | { | 783 | { |
758 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 784 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
785 | if (!attachment) | ||
786 | { | ||
787 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
788 | g.RootPart.AttachOffset = g.AbsolutePosition; | ||
789 | g.RootPart.AttachRotation = g.GroupRotation; | ||
790 | g.RootPart.Shape.State = 0; | ||
791 | } | ||
759 | 792 | ||
760 | objlist.Add(g); | 793 | objlist.Add(g); |
761 | veclist.Add(new Vector3(0, 0, 0)); | 794 | veclist.Add(new Vector3(0, 0, 0)); |
@@ -785,6 +818,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
785 | foreach (XmlNode n in groups) | 818 | foreach (XmlNode n in groups) |
786 | { | 819 | { |
787 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); | 820 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); |
821 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
822 | g.RootPart.AttachOffset = g.AbsolutePosition; | ||
823 | g.RootPart.AttachRotation = g.GroupRotation; | ||
824 | g.RootPart.Shape.State = 0; | ||
788 | 825 | ||
789 | objlist.Add(g); | 826 | objlist.Add(g); |
790 | XmlElement el = (XmlElement)n; | 827 | XmlElement el = (XmlElement)n; |
@@ -804,12 +841,35 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
804 | } | 841 | } |
805 | } | 842 | } |
806 | 843 | ||
844 | int primcount = 0; | ||
845 | foreach (SceneObjectGroup g in objlist) | ||
846 | primcount += g.PrimCount; | ||
847 | |||
848 | if (!m_Scene.Permissions.CanRezObject( | ||
849 | primcount, remoteClient.AgentId, pos) | ||
850 | && !attachment) | ||
851 | { | ||
852 | // The client operates in no fail mode. It will | ||
853 | // have already removed the item from the folder | ||
854 | // if it's no copy. | ||
855 | // Put it back if it's not an attachment | ||
856 | // | ||
857 | if (item != null) | ||
858 | { | ||
859 | if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) | ||
860 | remoteClient.SendBulkUpdateInventory(item); | ||
861 | } | ||
862 | |||
863 | return null; | ||
864 | } | ||
865 | |||
807 | if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, attachment)) | 866 | if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, attachment)) |
808 | return null; | 867 | return null; |
809 | 868 | ||
810 | for (int i = 0; i < objlist.Count; i++) | 869 | for (int i = 0; i < objlist.Count; i++) |
811 | { | 870 | { |
812 | group = objlist[i]; | 871 | group = objlist[i]; |
872 | SceneObjectPart rootPart = group.RootPart; | ||
813 | 873 | ||
814 | // m_log.DebugFormat( | 874 | // m_log.DebugFormat( |
815 | // "[INVENTORY ACCESS MODULE]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", | 875 | // "[INVENTORY ACCESS MODULE]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", |
@@ -870,8 +930,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
870 | 930 | ||
871 | if (!attachment) | 931 | if (!attachment) |
872 | { | 932 | { |
873 | SceneObjectPart rootPart = group.RootPart; | ||
874 | |||
875 | if (rootPart.Shape.PCode == (byte)PCode.Prim) | 933 | if (rootPart.Shape.PCode == (byte)PCode.Prim) |
876 | group.ClearPartAttachmentData(); | 934 | group.ClearPartAttachmentData(); |
877 | 935 | ||
@@ -889,6 +947,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
889 | // remoteClient.Name); | 947 | // remoteClient.Name); |
890 | } | 948 | } |
891 | 949 | ||
950 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); | ||
951 | |||
892 | if (item != null) | 952 | if (item != null) |
893 | DoPostRezWhenFromItem(item, attachment); | 953 | DoPostRezWhenFromItem(item, attachment); |
894 | 954 | ||
@@ -967,8 +1027,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
967 | { | 1027 | { |
968 | rootPart.Name = item.Name; | 1028 | rootPart.Name = item.Name; |
969 | rootPart.Description = item.Description; | 1029 | rootPart.Description = item.Description; |
970 | rootPart.ObjectSaleType = item.SaleType; | 1030 | if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0) |
971 | rootPart.SalePrice = item.SalePrice; | 1031 | { |
1032 | rootPart.ObjectSaleType = item.SaleType; | ||
1033 | rootPart.SalePrice = item.SalePrice; | ||
1034 | } | ||
972 | } | 1035 | } |
973 | 1036 | ||
974 | so.FromFolderID = item.Folder; | 1037 | so.FromFolderID = item.Folder; |
@@ -978,7 +1041,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
978 | // rootPart.OwnerID, item.Owner, item.CurrentPermissions); | 1041 | // rootPart.OwnerID, item.Owner, item.CurrentPermissions); |
979 | 1042 | ||
980 | if ((rootPart.OwnerID != item.Owner) || | 1043 | if ((rootPart.OwnerID != item.Owner) || |
981 | (item.CurrentPermissions & 16) != 0) | 1044 | (item.CurrentPermissions & 16) != 0 || |
1045 | (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) | ||
982 | { | 1046 | { |
983 | //Need to kill the for sale here | 1047 | //Need to kill the for sale here |
984 | rootPart.ObjectSaleType = 0; | 1048 | rootPart.ObjectSaleType = 0; |
@@ -988,31 +1052,43 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
988 | { | 1052 | { |
989 | foreach (SceneObjectPart part in so.Parts) | 1053 | foreach (SceneObjectPart part in so.Parts) |
990 | { | 1054 | { |
991 | if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) | ||
992 | { | ||
993 | part.EveryoneMask = item.EveryOnePermissions; | ||
994 | part.NextOwnerMask = item.NextPermissions; | ||
995 | } | ||
996 | part.GroupMask = 0; // DO NOT propagate here | 1055 | part.GroupMask = 0; // DO NOT propagate here |
1056 | |||
1057 | part.LastOwnerID = part.OwnerID; | ||
1058 | part.OwnerID = item.Owner; | ||
1059 | part.Inventory.ChangeInventoryOwner(item.Owner); | ||
997 | } | 1060 | } |
998 | 1061 | ||
999 | so.ApplyNextOwnerPermissions(); | 1062 | so.ApplyNextOwnerPermissions(); |
1063 | |||
1064 | // In case the user has changed flags on a received item | ||
1065 | // we have to apply those changes after the slam. Else we | ||
1066 | // get a net loss of permissions | ||
1067 | foreach (SceneObjectPart part in so.Parts) | ||
1068 | { | ||
1069 | if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) | ||
1070 | { | ||
1071 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | ||
1072 | part.EveryoneMask = item.EveryOnePermissions & part.BaseMask; | ||
1073 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | ||
1074 | part.NextOwnerMask = item.NextPermissions & part.BaseMask; | ||
1075 | } | ||
1076 | } | ||
1000 | } | 1077 | } |
1001 | } | 1078 | } |
1002 | 1079 | else | |
1003 | foreach (SceneObjectPart part in so.Parts) | ||
1004 | { | 1080 | { |
1005 | part.FromUserInventoryItemID = fromUserInventoryItemId; | 1081 | foreach (SceneObjectPart part in so.Parts) |
1006 | |||
1007 | if ((part.OwnerID != item.Owner) || | ||
1008 | (item.CurrentPermissions & 16) != 0) | ||
1009 | { | 1082 | { |
1010 | part.Inventory.ChangeInventoryOwner(item.Owner); | 1083 | part.FromUserInventoryItemID = fromUserInventoryItemId; |
1011 | part.GroupMask = 0; // DO NOT propagate here | 1084 | |
1085 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | ||
1086 | part.EveryoneMask = item.EveryOnePermissions; | ||
1087 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | ||
1088 | part.NextOwnerMask = item.NextPermissions; | ||
1089 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) | ||
1090 | part.GroupMask = item.GroupPermissions; | ||
1012 | } | 1091 | } |
1013 | |||
1014 | part.EveryoneMask = item.EveryOnePermissions; | ||
1015 | part.NextOwnerMask = item.NextPermissions; | ||
1016 | } | 1092 | } |
1017 | 1093 | ||
1018 | rootPart.TrimPermissions(); | 1094 | rootPart.TrimPermissions(); |
@@ -1150,4 +1226,4 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1150 | 1226 | ||
1151 | #endregion | 1227 | #endregion |
1152 | } | 1228 | } |
1153 | } \ No newline at end of file | 1229 | } |
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs index e0921ad..ec94420 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs | |||
@@ -92,9 +92,9 @@ namespace OpenSim.Region.CoreModules.Hypergrid | |||
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | protected override List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 95 | protected override List<MapBlockData> GetAndSendBlocksInternal(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) |
96 | { | 96 | { |
97 | List<MapBlockData> mapBlocks = base.GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag); | 97 | List<MapBlockData> mapBlocks = base.GetAndSendBlocksInternal(remoteClient, minX, minY, maxX, maxY, flag); |
98 | lock (m_SeenMapBlocks) | 98 | lock (m_SeenMapBlocks) |
99 | { | 99 | { |
100 | if (!m_SeenMapBlocks.ContainsKey(remoteClient.AgentId)) | 100 | if (!m_SeenMapBlocks.ContainsKey(remoteClient.AgentId)) |
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index a676971..0276267 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | |||
@@ -42,6 +42,7 @@ using OpenSim.Framework.Servers.HttpServer; | |||
42 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using Mono.Addins; | 44 | using Mono.Addins; |
45 | using Amib.Threading; | ||
45 | 46 | ||
46 | /***************************************************** | 47 | /***************************************************** |
47 | * | 48 | * |
@@ -102,6 +103,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
102 | private Dictionary<UUID, HttpRequestClass> m_pendingRequests; | 103 | private Dictionary<UUID, HttpRequestClass> m_pendingRequests; |
103 | private Scene m_scene; | 104 | private Scene m_scene; |
104 | // private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>(); | 105 | // private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>(); |
106 | public static SmartThreadPool ThreadPool = null; | ||
105 | 107 | ||
106 | public HttpRequestModule() | 108 | public HttpRequestModule() |
107 | { | 109 | { |
@@ -279,7 +281,30 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
279 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); | 281 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); |
280 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); | 282 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); |
281 | 283 | ||
284 | int maxThreads = 50; | ||
285 | |||
286 | IConfig httpConfig = config.Configs["HttpRequestModule"]; | ||
287 | if (httpConfig != null) | ||
288 | { | ||
289 | maxThreads = httpConfig.GetInt("MaxPoolThreads", maxThreads); | ||
290 | } | ||
291 | |||
282 | m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); | 292 | m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); |
293 | |||
294 | // First instance sets this up for all sims | ||
295 | if (ThreadPool == null) | ||
296 | { | ||
297 | STPStartInfo startInfo = new STPStartInfo(); | ||
298 | startInfo.IdleTimeout = 20000; | ||
299 | startInfo.MaxWorkerThreads = maxThreads; | ||
300 | startInfo.MinWorkerThreads = 5; | ||
301 | startInfo.ThreadPriority = ThreadPriority.BelowNormal; | ||
302 | startInfo.StartSuspended = true; | ||
303 | |||
304 | ThreadPool = new SmartThreadPool(startInfo); | ||
305 | |||
306 | ThreadPool.Start(); | ||
307 | } | ||
283 | } | 308 | } |
284 | 309 | ||
285 | public void AddRegion(Scene scene) | 310 | public void AddRegion(Scene scene) |
@@ -340,7 +365,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
340 | public string HttpMIMEType = "text/plain;charset=utf-8"; | 365 | public string HttpMIMEType = "text/plain;charset=utf-8"; |
341 | public int HttpTimeout; | 366 | public int HttpTimeout; |
342 | public bool HttpVerifyCert = true; | 367 | public bool HttpVerifyCert = true; |
343 | private Thread httpThread; | 368 | public IWorkItemResult WorkItem = null; |
344 | 369 | ||
345 | // Request info | 370 | // Request info |
346 | private UUID _itemID; | 371 | private UUID _itemID; |
@@ -374,12 +399,16 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
374 | 399 | ||
375 | public void Process() | 400 | public void Process() |
376 | { | 401 | { |
377 | httpThread = new Thread(SendRequest); | ||
378 | httpThread.Name = "HttpRequestThread"; | ||
379 | httpThread.Priority = ThreadPriority.BelowNormal; | ||
380 | httpThread.IsBackground = true; | ||
381 | _finished = false; | 402 | _finished = false; |
382 | httpThread.Start(); | 403 | |
404 | lock (HttpRequestModule.ThreadPool) | ||
405 | WorkItem = HttpRequestModule.ThreadPool.QueueWorkItem(new WorkItemCallback(StpSendWrapper), null); | ||
406 | } | ||
407 | |||
408 | private object StpSendWrapper(object o) | ||
409 | { | ||
410 | SendRequest(); | ||
411 | return null; | ||
383 | } | 412 | } |
384 | 413 | ||
385 | /* | 414 | /* |
@@ -398,6 +427,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
398 | try | 427 | try |
399 | { | 428 | { |
400 | Request = (HttpWebRequest) WebRequest.Create(Url); | 429 | Request = (HttpWebRequest) WebRequest.Create(Url); |
430 | |||
431 | //This works around some buggy HTTP Servers like Lighttpd | ||
432 | Request.ServicePoint.Expect100Continue = false; | ||
433 | |||
401 | Request.Method = HttpMethod; | 434 | Request.Method = HttpMethod; |
402 | Request.ContentType = HttpMIMEType; | 435 | Request.ContentType = HttpMIMEType; |
403 | 436 | ||
@@ -405,13 +438,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
405 | { | 438 | { |
406 | // We could hijack Connection Group Name to identify | 439 | // We could hijack Connection Group Name to identify |
407 | // a desired security exception. But at the moment we'll use a dummy header instead. | 440 | // a desired security exception. But at the moment we'll use a dummy header instead. |
408 | // Request.ConnectionGroupName = "NoVerify"; | ||
409 | Request.Headers.Add("NoVerifyCert", "true"); | 441 | Request.Headers.Add("NoVerifyCert", "true"); |
410 | } | 442 | } |
411 | // else | ||
412 | // { | ||
413 | // Request.ConnectionGroupName="Verify"; | ||
414 | // } | ||
415 | if (proxyurl != null && proxyurl.Length > 0) | 443 | if (proxyurl != null && proxyurl.Length > 0) |
416 | { | 444 | { |
417 | if (proxyexcepts != null && proxyexcepts.Length > 0) | 445 | if (proxyexcepts != null && proxyexcepts.Length > 0) |
@@ -474,25 +502,56 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
474 | 502 | ||
475 | // continue building the string | 503 | // continue building the string |
476 | sb.Append(tempString); | 504 | sb.Append(tempString); |
505 | if (sb.Length > 2048) | ||
506 | break; | ||
477 | } | 507 | } |
478 | } while (count > 0); // any more data to read? | 508 | } while (count > 0); // any more data to read? |
479 | 509 | ||
480 | ResponseBody = sb.ToString(); | 510 | ResponseBody = sb.ToString().Replace("\r", ""); |
481 | } | 511 | } |
482 | catch (Exception e) | 512 | catch (WebException e) |
483 | { | 513 | { |
484 | Status = (int)OSHttpStatusCode.ClientErrorJoker; | 514 | if (e.Status == WebExceptionStatus.ProtocolError) |
485 | ResponseBody = e.Message; | 515 | { |
516 | HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response; | ||
517 | Status = (int)webRsp.StatusCode; | ||
518 | try | ||
519 | { | ||
520 | using (Stream responseStream = webRsp.GetResponseStream()) | ||
521 | { | ||
522 | ResponseBody = responseStream.GetStreamString(); | ||
523 | } | ||
524 | } | ||
525 | catch | ||
526 | { | ||
527 | ResponseBody = webRsp.StatusDescription; | ||
528 | } | ||
529 | } | ||
530 | else | ||
531 | { | ||
532 | Status = (int)OSHttpStatusCode.ClientErrorJoker; | ||
533 | ResponseBody = e.Message; | ||
534 | } | ||
535 | |||
536 | if (ResponseBody == null) | ||
537 | ResponseBody = String.Empty; | ||
486 | 538 | ||
487 | _finished = true; | 539 | _finished = true; |
488 | return; | 540 | return; |
489 | } | 541 | } |
542 | catch (Exception e) | ||
543 | { | ||
544 | // Don't crash on anything else | ||
545 | } | ||
490 | finally | 546 | finally |
491 | { | 547 | { |
492 | if (response != null) | 548 | if (response != null) |
493 | response.Close(); | 549 | response.Close(); |
494 | } | 550 | } |
495 | 551 | ||
552 | if (ResponseBody == null) | ||
553 | ResponseBody = String.Empty; | ||
554 | |||
496 | _finished = true; | 555 | _finished = true; |
497 | } | 556 | } |
498 | 557 | ||
@@ -500,7 +559,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
500 | { | 559 | { |
501 | try | 560 | try |
502 | { | 561 | { |
503 | httpThread.Abort(); | 562 | if (!WorkItem.Cancel()) |
563 | { | ||
564 | WorkItem.Abort(); | ||
565 | } | ||
504 | } | 566 | } |
505 | catch (Exception) | 567 | catch (Exception) |
506 | { | 568 | { |
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index be617a5..60b7190 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | |||
@@ -42,39 +42,13 @@ using OpenSim.Region.Framework.Scenes; | |||
42 | 42 | ||
43 | namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | 43 | namespace OpenSim.Region.CoreModules.Scripting.LSLHttp |
44 | { | 44 | { |
45 | /// <summary> | ||
46 | /// Data describing an external URL set up by a script. | ||
47 | /// </summary> | ||
48 | public class UrlData | 45 | public class UrlData |
49 | { | 46 | { |
50 | /// <summary> | ||
51 | /// Scene object part hosting the script | ||
52 | /// </summary> | ||
53 | public UUID hostID; | 47 | public UUID hostID; |
54 | |||
55 | /// <summary> | ||
56 | /// The item ID of the script that requested the URL. | ||
57 | /// </summary> | ||
58 | public UUID itemID; | 48 | public UUID itemID; |
59 | |||
60 | /// <summary> | ||
61 | /// The script engine that runs the script. | ||
62 | /// </summary> | ||
63 | public IScriptModule engine; | 49 | public IScriptModule engine; |
64 | |||
65 | /// <summary> | ||
66 | /// The generated URL. | ||
67 | /// </summary> | ||
68 | public string url; | 50 | public string url; |
69 | |||
70 | /// <summary> | ||
71 | /// The random UUID component of the generated URL. | ||
72 | /// </summary> | ||
73 | public UUID urlcode; | 51 | public UUID urlcode; |
74 | |||
75 | /// <summary> | ||
76 | /// The external requests currently being processed or awaiting retrieval for this URL. | ||
77 | /// </summary> | ||
78 | public Dictionary<UUID, RequestData> requests; | 52 | public Dictionary<UUID, RequestData> requests; |
79 | } | 53 | } |
80 | 54 | ||
@@ -89,6 +63,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
89 | //public ManualResetEvent ev; | 63 | //public ManualResetEvent ev; |
90 | public bool requestDone; | 64 | public bool requestDone; |
91 | public int startTime; | 65 | public int startTime; |
66 | public bool responseSent; | ||
92 | public string uri; | 67 | public string uri; |
93 | } | 68 | } |
94 | 69 | ||
@@ -102,25 +77,16 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
102 | LogManager.GetLogger( | 77 | LogManager.GetLogger( |
103 | MethodBase.GetCurrentMethod().DeclaringType); | 78 | MethodBase.GetCurrentMethod().DeclaringType); |
104 | 79 | ||
105 | /// <summary> | 80 | private Dictionary<UUID, UrlData> m_RequestMap = |
106 | /// Indexs the URL request metadata (which script requested it, outstanding requests, etc.) by the request ID | 81 | new Dictionary<UUID, UrlData>(); |
107 | /// randomly generated when a request is received for this URL. | ||
108 | /// </summary> | ||
109 | /// <remarks> | ||
110 | /// Manipulation or retrieval from this dictionary must be locked on m_UrlMap to preserve consistency with | ||
111 | /// m_UrlMap | ||
112 | /// </remarks> | ||
113 | private Dictionary<UUID, UrlData> m_RequestMap = new Dictionary<UUID, UrlData>(); | ||
114 | 82 | ||
115 | /// <summary> | 83 | private Dictionary<string, UrlData> m_UrlMap = |
116 | /// Indexs the URL request metadata (which script requested it, outstanding requests, etc.) by the full URL | 84 | new Dictionary<string, UrlData>(); |
117 | /// </summary> | ||
118 | private Dictionary<string, UrlData> m_UrlMap = new Dictionary<string, UrlData>(); | ||
119 | 85 | ||
120 | /// <summary> | 86 | /// <summary> |
121 | /// Maximum number of external urls that can be set up by this module. | 87 | /// Maximum number of external urls that can be set up by this module. |
122 | /// </summary> | 88 | /// </summary> |
123 | private int m_TotalUrls = 100; | 89 | private int m_TotalUrls = 15000; |
124 | 90 | ||
125 | private uint https_port = 0; | 91 | private uint https_port = 0; |
126 | private IHttpServer m_HttpServer = null; | 92 | private IHttpServer m_HttpServer = null; |
@@ -146,9 +112,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
146 | { | 112 | { |
147 | m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); | 113 | m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); |
148 | bool ssl_enabled = config.Configs["Network"].GetBoolean("https_listener",false); | 114 | bool ssl_enabled = config.Configs["Network"].GetBoolean("https_listener",false); |
149 | |||
150 | if (ssl_enabled) | 115 | if (ssl_enabled) |
116 | { | ||
151 | https_port = (uint) config.Configs["Network"].GetInt("https_port",0); | 117 | https_port = (uint) config.Configs["Network"].GetInt("https_port",0); |
118 | } | ||
152 | 119 | ||
153 | IConfig llFunctionsConfig = config.Configs["LL-Functions"]; | 120 | IConfig llFunctionsConfig = config.Configs["LL-Functions"]; |
154 | 121 | ||
@@ -209,7 +176,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
209 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); | 176 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); |
210 | return urlcode; | 177 | return urlcode; |
211 | } | 178 | } |
212 | string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; | 179 | string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString(); |
213 | 180 | ||
214 | UrlData urlData = new UrlData(); | 181 | UrlData urlData = new UrlData(); |
215 | urlData.hostID = host.UUID; | 182 | urlData.hostID = host.UUID; |
@@ -218,18 +185,18 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
218 | urlData.url = url; | 185 | urlData.url = url; |
219 | urlData.urlcode = urlcode; | 186 | urlData.urlcode = urlcode; |
220 | urlData.requests = new Dictionary<UUID, RequestData>(); | 187 | urlData.requests = new Dictionary<UUID, RequestData>(); |
221 | 188 | ||
222 | m_UrlMap[url] = urlData; | 189 | m_UrlMap[url] = urlData; |
223 | 190 | ||
224 | string uri = "/lslhttp/" + urlcode.ToString() + "/"; | 191 | string uri = "/lslhttp/" + urlcode.ToString(); |
225 | 192 | ||
226 | m_HttpServer.AddPollServiceHTTPHandler( | 193 | PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); |
227 | uri, | 194 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
228 | new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); | 195 | m_HttpServer.AddPollServiceHTTPHandler(uri, args); |
229 | 196 | ||
230 | m_log.DebugFormat( | 197 | // m_log.DebugFormat( |
231 | "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}", | 198 | // "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}", |
232 | uri, itemID, host.Name, host.LocalId); | 199 | // uri, itemID, host.Name, host.LocalId); |
233 | 200 | ||
234 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); | 201 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); |
235 | } | 202 | } |
@@ -254,7 +221,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
254 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); | 221 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); |
255 | return urlcode; | 222 | return urlcode; |
256 | } | 223 | } |
257 | string url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; | 224 | string url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString(); |
258 | 225 | ||
259 | UrlData urlData = new UrlData(); | 226 | UrlData urlData = new UrlData(); |
260 | urlData.hostID = host.UUID; | 227 | urlData.hostID = host.UUID; |
@@ -264,17 +231,18 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
264 | urlData.urlcode = urlcode; | 231 | urlData.urlcode = urlcode; |
265 | urlData.requests = new Dictionary<UUID, RequestData>(); | 232 | urlData.requests = new Dictionary<UUID, RequestData>(); |
266 | 233 | ||
234 | |||
267 | m_UrlMap[url] = urlData; | 235 | m_UrlMap[url] = urlData; |
268 | 236 | ||
269 | string uri = "/lslhttps/" + urlcode.ToString() + "/"; | 237 | string uri = "/lslhttps/" + urlcode.ToString(); |
270 | 238 | ||
271 | m_HttpsServer.AddPollServiceHTTPHandler( | 239 | PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); |
272 | uri, | 240 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
273 | new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); | 241 | m_HttpsServer.AddPollServiceHTTPHandler(uri, args); |
274 | 242 | ||
275 | m_log.DebugFormat( | 243 | // m_log.DebugFormat( |
276 | "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", | 244 | // "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", |
277 | uri, itemID, host.Name, host.LocalId); | 245 | // uri, itemID, host.Name, host.LocalId); |
278 | 246 | ||
279 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); | 247 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); |
280 | } | 248 | } |
@@ -293,12 +261,15 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
293 | return; | 261 | return; |
294 | } | 262 | } |
295 | 263 | ||
296 | foreach (UUID req in data.requests.Keys) | 264 | lock (m_RequestMap) |
297 | m_RequestMap.Remove(req); | 265 | { |
298 | 266 | foreach (UUID req in data.requests.Keys) | |
299 | m_log.DebugFormat( | 267 | m_RequestMap.Remove(req); |
300 | "[URL MODULE]: Releasing url {0} for {1} in {2}", | 268 | } |
301 | url, data.itemID, data.hostID); | 269 | |
270 | // m_log.DebugFormat( | ||
271 | // "[URL MODULE]: Releasing url {0} for {1} in {2}", | ||
272 | // url, data.itemID, data.hostID); | ||
302 | 273 | ||
303 | RemoveUrl(data); | 274 | RemoveUrl(data); |
304 | m_UrlMap.Remove(url); | 275 | m_UrlMap.Remove(url); |
@@ -323,29 +294,34 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
323 | 294 | ||
324 | public void HttpResponse(UUID request, int status, string body) | 295 | public void HttpResponse(UUID request, int status, string body) |
325 | { | 296 | { |
326 | lock (m_UrlMap) | 297 | lock (m_RequestMap) |
327 | { | 298 | { |
328 | if (m_RequestMap.ContainsKey(request)) | 299 | if (m_RequestMap.ContainsKey(request)) |
329 | { | 300 | { |
330 | UrlData urlData = m_RequestMap[request]; | 301 | UrlData urlData = m_RequestMap[request]; |
331 | string responseBody = body; | 302 | if (!urlData.requests[request].responseSent) |
332 | if (urlData.requests[request].responseType.Equals("text/plain")) | ||
333 | { | 303 | { |
334 | string value; | 304 | string responseBody = body; |
335 | if (urlData.requests[request].headers.TryGetValue("user-agent", out value)) | 305 | if (urlData.requests[request].responseType.Equals("text/plain")) |
336 | { | 306 | { |
337 | if (value != null && value.IndexOf("MSIE") >= 0) | 307 | string value; |
308 | if (urlData.requests[request].headers.TryGetValue("user-agent", out value)) | ||
338 | { | 309 | { |
339 | // wrap the html escaped response if the target client is IE | 310 | if (value != null && value.IndexOf("MSIE") >= 0) |
340 | // It ignores "text/plain" if the body is html | 311 | { |
341 | responseBody = "<html>" + System.Web.HttpUtility.HtmlEncode(body) + "</html>"; | 312 | // wrap the html escaped response if the target client is IE |
313 | // It ignores "text/plain" if the body is html | ||
314 | responseBody = "<html>" + System.Web.HttpUtility.HtmlEncode(body) + "</html>"; | ||
315 | } | ||
342 | } | 316 | } |
343 | } | 317 | } |
318 | |||
319 | urlData.requests[request].responseCode = status; | ||
320 | urlData.requests[request].responseBody = body; | ||
321 | //urlData.requests[request].ev.Set(); | ||
322 | urlData.requests[request].requestDone = true; | ||
323 | urlData.requests[request].responseSent = true; | ||
344 | } | 324 | } |
345 | urlData.requests[request].responseCode = status; | ||
346 | urlData.requests[request].responseBody = responseBody; | ||
347 | //urlData.requests[request].ev.Set(); | ||
348 | urlData.requests[request].requestDone =true; | ||
349 | } | 325 | } |
350 | else | 326 | else |
351 | { | 327 | { |
@@ -356,7 +332,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
356 | 332 | ||
357 | public string GetHttpHeader(UUID requestId, string header) | 333 | public string GetHttpHeader(UUID requestId, string header) |
358 | { | 334 | { |
359 | lock (m_UrlMap) | 335 | lock (m_RequestMap) |
360 | { | 336 | { |
361 | if (m_RequestMap.ContainsKey(requestId)) | 337 | if (m_RequestMap.ContainsKey(requestId)) |
362 | { | 338 | { |
@@ -370,14 +346,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
370 | m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); | 346 | m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); |
371 | } | 347 | } |
372 | } | 348 | } |
373 | |||
374 | return String.Empty; | 349 | return String.Empty; |
375 | } | 350 | } |
376 | 351 | ||
377 | public int GetFreeUrls() | 352 | public int GetFreeUrls() |
378 | { | 353 | { |
379 | lock (m_UrlMap) | 354 | return m_TotalUrls - m_UrlMap.Count; |
380 | return m_TotalUrls - m_UrlMap.Count; | ||
381 | } | 355 | } |
382 | 356 | ||
383 | public void ScriptRemoved(UUID itemID) | 357 | public void ScriptRemoved(UUID itemID) |
@@ -394,8 +368,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
394 | { | 368 | { |
395 | RemoveUrl(url.Value); | 369 | RemoveUrl(url.Value); |
396 | removeURLs.Add(url.Key); | 370 | removeURLs.Add(url.Key); |
397 | foreach (UUID req in url.Value.requests.Keys) | 371 | lock (m_RequestMap) |
398 | m_RequestMap.Remove(req); | 372 | { |
373 | foreach (UUID req in url.Value.requests.Keys) | ||
374 | m_RequestMap.Remove(req); | ||
375 | } | ||
399 | } | 376 | } |
400 | } | 377 | } |
401 | 378 | ||
@@ -416,9 +393,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
416 | { | 393 | { |
417 | RemoveUrl(url.Value); | 394 | RemoveUrl(url.Value); |
418 | removeURLs.Add(url.Key); | 395 | removeURLs.Add(url.Key); |
419 | 396 | lock (m_RequestMap) | |
420 | foreach (UUID req in url.Value.requests.Keys) | 397 | { |
421 | m_RequestMap.Remove(req); | 398 | foreach (UUID req in url.Value.requests.Keys) |
399 | m_RequestMap.Remove(req); | ||
400 | } | ||
422 | } | 401 | } |
423 | } | 402 | } |
424 | 403 | ||
@@ -427,123 +406,125 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
427 | } | 406 | } |
428 | } | 407 | } |
429 | 408 | ||
409 | |||
430 | private void RemoveUrl(UrlData data) | 410 | private void RemoveUrl(UrlData data) |
431 | { | 411 | { |
432 | m_HttpServer.RemoveHTTPHandler("", "/lslhttp/" + data.urlcode.ToString() + "/"); | 412 | m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); |
433 | } | 413 | } |
434 | 414 | ||
435 | private Hashtable NoEvents(UUID requestID, UUID sessionID) | 415 | private Hashtable NoEvents(UUID requestID, UUID sessionID) |
436 | { | 416 | { |
437 | Hashtable response = new Hashtable(); | 417 | Hashtable response = new Hashtable(); |
438 | UrlData urlData; | 418 | UrlData url; |
439 | 419 | int startTime = 0; | |
440 | lock (m_UrlMap) | 420 | lock (m_RequestMap) |
441 | { | 421 | { |
442 | // We need to return a 404 here in case the request URL was removed at exactly the same time that a | ||
443 | // request was made. In this case, the request thread can outrace llRemoveURL() and still be polling | ||
444 | // for the request ID. | ||
445 | if (!m_RequestMap.ContainsKey(requestID)) | 422 | if (!m_RequestMap.ContainsKey(requestID)) |
446 | { | ||
447 | response["int_response_code"] = 404; | ||
448 | response["str_response_string"] = ""; | ||
449 | response["keepalive"] = false; | ||
450 | response["reusecontext"] = false; | ||
451 | |||
452 | return response; | 423 | return response; |
453 | } | 424 | url = m_RequestMap[requestID]; |
425 | startTime = url.requests[requestID].startTime; | ||
426 | } | ||
454 | 427 | ||
455 | urlData = m_RequestMap[requestID]; | 428 | if (System.Environment.TickCount - startTime > 25000) |
429 | { | ||
430 | response["int_response_code"] = 500; | ||
431 | response["str_response_string"] = "Script timeout"; | ||
432 | response["content_type"] = "text/plain"; | ||
433 | response["keepalive"] = false; | ||
434 | response["reusecontext"] = false; | ||
456 | 435 | ||
457 | if (System.Environment.TickCount - urlData.requests[requestID].startTime > 25000) | 436 | //remove from map |
437 | lock (url.requests) | ||
438 | { | ||
439 | url.requests.Remove(requestID); | ||
440 | } | ||
441 | lock (m_RequestMap) | ||
458 | { | 442 | { |
459 | response["int_response_code"] = 500; | ||
460 | response["str_response_string"] = "Script timeout"; | ||
461 | response["content_type"] = "text/plain"; | ||
462 | response["keepalive"] = false; | ||
463 | response["reusecontext"] = false; | ||
464 | |||
465 | //remove from map | ||
466 | urlData.requests.Remove(requestID); | ||
467 | m_RequestMap.Remove(requestID); | 443 | m_RequestMap.Remove(requestID); |
468 | |||
469 | return response; | ||
470 | } | 444 | } |
445 | |||
446 | return response; | ||
471 | } | 447 | } |
472 | 448 | ||
449 | |||
473 | return response; | 450 | return response; |
474 | } | 451 | } |
475 | 452 | ||
476 | private bool HasEvents(UUID requestID, UUID sessionID) | 453 | private bool HasEvents(UUID requestID, UUID sessionID) |
477 | { | 454 | { |
478 | lock (m_UrlMap) | 455 | UrlData url=null; |
456 | |||
457 | lock (m_RequestMap) | ||
479 | { | 458 | { |
480 | // We return true here because an external URL request that happened at the same time as an llRemoveURL() | ||
481 | // can still make it through to HttpRequestHandler(). That will return without setting up a request | ||
482 | // when it detects that the URL has been removed. The poller, however, will continue to ask for | ||
483 | // events for that request, so here we will signal that there are events and in GetEvents we will | ||
484 | // return a 404. | ||
485 | if (!m_RequestMap.ContainsKey(requestID)) | 459 | if (!m_RequestMap.ContainsKey(requestID)) |
486 | { | 460 | { |
487 | return true; | 461 | return false; |
488 | } | 462 | } |
489 | 463 | url = m_RequestMap[requestID]; | |
490 | UrlData urlData = m_RequestMap[requestID]; | 464 | } |
491 | 465 | lock (url.requests) | |
492 | if (!urlData.requests.ContainsKey(requestID)) | 466 | { |
467 | if (!url.requests.ContainsKey(requestID)) | ||
493 | { | 468 | { |
494 | return true; | 469 | return false; |
495 | } | 470 | } |
496 | 471 | else | |
497 | // Trigger return of timeout response. | ||
498 | if (System.Environment.TickCount - urlData.requests[requestID].startTime > 25000) | ||
499 | { | 472 | { |
500 | return true; | 473 | if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) |
474 | { | ||
475 | return true; | ||
476 | } | ||
477 | if (url.requests[requestID].requestDone) | ||
478 | return true; | ||
479 | else | ||
480 | return false; | ||
501 | } | 481 | } |
502 | |||
503 | return urlData.requests[requestID].requestDone; | ||
504 | } | 482 | } |
505 | } | 483 | } |
506 | 484 | private Hashtable GetEvents(UUID requestID, UUID sessionID) | |
507 | private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) | ||
508 | { | 485 | { |
509 | Hashtable response; | 486 | UrlData url = null; |
487 | RequestData requestData = null; | ||
510 | 488 | ||
511 | lock (m_UrlMap) | 489 | lock (m_RequestMap) |
512 | { | 490 | { |
513 | UrlData url = null; | ||
514 | RequestData requestData = null; | ||
515 | |||
516 | if (!m_RequestMap.ContainsKey(requestID)) | 491 | if (!m_RequestMap.ContainsKey(requestID)) |
517 | return NoEvents(requestID, sessionID); | 492 | return NoEvents(requestID,sessionID); |
518 | |||
519 | url = m_RequestMap[requestID]; | 493 | url = m_RequestMap[requestID]; |
494 | } | ||
495 | lock (url.requests) | ||
496 | { | ||
520 | requestData = url.requests[requestID]; | 497 | requestData = url.requests[requestID]; |
498 | } | ||
499 | |||
500 | if (!requestData.requestDone) | ||
501 | return NoEvents(requestID,sessionID); | ||
502 | |||
503 | Hashtable response = new Hashtable(); | ||
521 | 504 | ||
522 | if (!requestData.requestDone) | 505 | if (System.Environment.TickCount - requestData.startTime > 25000) |
523 | return NoEvents(requestID, sessionID); | 506 | { |
524 | 507 | response["int_response_code"] = 500; | |
525 | response = new Hashtable(); | 508 | response["str_response_string"] = "Script timeout"; |
526 | 509 | response["content_type"] = "text/plain"; | |
527 | if (System.Environment.TickCount - requestData.startTime > 25000) | ||
528 | { | ||
529 | response["int_response_code"] = 500; | ||
530 | response["str_response_string"] = "Script timeout"; | ||
531 | response["content_type"] = "text/plain"; | ||
532 | response["keepalive"] = false; | ||
533 | response["reusecontext"] = false; | ||
534 | return response; | ||
535 | } | ||
536 | |||
537 | //put response | ||
538 | response["int_response_code"] = requestData.responseCode; | ||
539 | response["str_response_string"] = requestData.responseBody; | ||
540 | response["content_type"] = requestData.responseType; | ||
541 | // response["content_type"] = "text/plain"; | ||
542 | response["keepalive"] = false; | 510 | response["keepalive"] = false; |
543 | response["reusecontext"] = false; | 511 | response["reusecontext"] = false; |
544 | 512 | return response; | |
545 | //remove from map | 513 | } |
514 | //put response | ||
515 | response["int_response_code"] = requestData.responseCode; | ||
516 | response["str_response_string"] = requestData.responseBody; | ||
517 | response["content_type"] = "text/plain"; | ||
518 | response["keepalive"] = false; | ||
519 | response["reusecontext"] = false; | ||
520 | |||
521 | //remove from map | ||
522 | lock (url.requests) | ||
523 | { | ||
546 | url.requests.Remove(requestID); | 524 | url.requests.Remove(requestID); |
525 | } | ||
526 | lock (m_RequestMap) | ||
527 | { | ||
547 | m_RequestMap.Remove(requestID); | 528 | m_RequestMap.Remove(requestID); |
548 | } | 529 | } |
549 | 530 | ||
@@ -552,41 +533,45 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
552 | 533 | ||
553 | public void HttpRequestHandler(UUID requestID, Hashtable request) | 534 | public void HttpRequestHandler(UUID requestID, Hashtable request) |
554 | { | 535 | { |
555 | string uri = request["uri"].ToString(); | 536 | lock (request) |
556 | bool is_ssl = uri.Contains("lslhttps"); | ||
557 | |||
558 | try | ||
559 | { | 537 | { |
560 | Hashtable headers = (Hashtable)request["headers"]; | 538 | string uri = request["uri"].ToString(); |
561 | 539 | bool is_ssl = uri.Contains("lslhttps"); | |
562 | // string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; | ||
563 | 540 | ||
564 | int pos1 = uri.IndexOf("/");// /lslhttp | 541 | try |
565 | int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ | ||
566 | int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/ | ||
567 | string uri_tmp = uri.Substring(0, pos3 + 1); | ||
568 | //HTTP server code doesn't provide us with QueryStrings | ||
569 | string pathInfo; | ||
570 | string queryString; | ||
571 | queryString = ""; | ||
572 | |||
573 | pathInfo = uri.Substring(pos3); | ||
574 | |||
575 | UrlData urlData = null; | ||
576 | |||
577 | lock (m_UrlMap) | ||
578 | { | 542 | { |
579 | string url; | 543 | Hashtable headers = (Hashtable)request["headers"]; |
544 | |||
545 | // string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; | ||
580 | 546 | ||
581 | if (is_ssl) | 547 | int pos1 = uri.IndexOf("/");// /lslhttp |
582 | url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp; | 548 | int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ |
549 | int pos3 = pos2 + 37; // /lslhttp/urlcode | ||
550 | string uri_tmp = uri.Substring(0, pos3); | ||
551 | //HTTP server code doesn't provide us with QueryStrings | ||
552 | string pathInfo; | ||
553 | string queryString; | ||
554 | queryString = ""; | ||
555 | |||
556 | pathInfo = uri.Substring(pos3); | ||
557 | |||
558 | UrlData url = null; | ||
559 | string urlkey; | ||
560 | if (!is_ssl) | ||
561 | urlkey = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp; | ||
562 | //m_UrlMap[]; | ||
583 | else | 563 | else |
584 | url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp; | 564 | urlkey = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp; |
585 | 565 | ||
586 | // Avoid a race - the request URL may have been released via llRequestUrl() whilst this | 566 | if (m_UrlMap.ContainsKey(urlkey)) |
587 | // request was being processed. | 567 | { |
588 | if (!m_UrlMap.TryGetValue(url, out urlData)) | 568 | url = m_UrlMap[urlkey]; |
569 | } | ||
570 | else | ||
571 | { | ||
572 | //m_log.Warn("[HttpRequestHandler]: http-in request failed; no such url: "+urlkey.ToString()); | ||
589 | return; | 573 | return; |
574 | } | ||
590 | 575 | ||
591 | //for llGetHttpHeader support we need to store original URI here | 576 | //for llGetHttpHeader support we need to store original URI here |
592 | //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers | 577 | //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers |
@@ -606,7 +591,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
606 | string value = (string)header.Value; | 591 | string value = (string)header.Value; |
607 | requestData.headers.Add(key, value); | 592 | requestData.headers.Add(key, value); |
608 | } | 593 | } |
609 | |||
610 | foreach (DictionaryEntry de in request) | 594 | foreach (DictionaryEntry de in request) |
611 | { | 595 | { |
612 | if (de.Key.ToString() == "querystringkeys") | 596 | if (de.Key.ToString() == "querystringkeys") |
@@ -617,13 +601,21 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
617 | if (request.ContainsKey(key)) | 601 | if (request.ContainsKey(key)) |
618 | { | 602 | { |
619 | string val = (String)request[key]; | 603 | string val = (String)request[key]; |
620 | queryString = queryString + key + "=" + val + "&"; | 604 | if (key != "") |
605 | { | ||
606 | queryString = queryString + key + "=" + val + "&"; | ||
607 | } | ||
608 | else | ||
609 | { | ||
610 | queryString = queryString + val + "&"; | ||
611 | } | ||
621 | } | 612 | } |
622 | } | 613 | } |
623 | |||
624 | if (queryString.Length > 1) | 614 | if (queryString.Length > 1) |
625 | queryString = queryString.Substring(0, queryString.Length - 1); | 615 | queryString = queryString.Substring(0, queryString.Length - 1); |
616 | |||
626 | } | 617 | } |
618 | |||
627 | } | 619 | } |
628 | 620 | ||
629 | //if this machine is behind DNAT/port forwarding, currently this is being | 621 | //if this machine is behind DNAT/port forwarding, currently this is being |
@@ -631,23 +623,34 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
631 | requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; | 623 | requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; |
632 | requestData.headers["x-path-info"] = pathInfo; | 624 | requestData.headers["x-path-info"] = pathInfo; |
633 | requestData.headers["x-query-string"] = queryString; | 625 | requestData.headers["x-query-string"] = queryString; |
634 | requestData.headers["x-script-url"] = urlData.url; | 626 | requestData.headers["x-script-url"] = url.url; |
635 | 627 | ||
636 | urlData.requests.Add(requestID, requestData); | 628 | //requestData.ev = new ManualResetEvent(false); |
637 | m_RequestMap.Add(requestID, urlData); | 629 | lock (url.requests) |
638 | } | 630 | { |
631 | url.requests.Add(requestID, requestData); | ||
632 | } | ||
633 | lock (m_RequestMap) | ||
634 | { | ||
635 | //add to request map | ||
636 | m_RequestMap.Add(requestID, url); | ||
637 | } | ||
639 | 638 | ||
640 | urlData.engine.PostScriptEvent( | 639 | url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); |
641 | urlData.itemID, | 640 | |
642 | "http_request", | 641 | //send initial response? |
643 | new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); | 642 | // Hashtable response = new Hashtable(); |
644 | } | 643 | |
645 | catch (Exception we) | 644 | return; |
646 | { | 645 | |
647 | //Hashtable response = new Hashtable(); | 646 | } |
648 | m_log.Warn("[HttpRequestHandler]: http-in request failed"); | 647 | catch (Exception we) |
649 | m_log.Warn(we.Message); | 648 | { |
650 | m_log.Warn(we.StackTrace); | 649 | //Hashtable response = new Hashtable(); |
650 | m_log.Warn("[HttpRequestHandler]: http-in request failed"); | ||
651 | m_log.Warn(we.Message); | ||
652 | m_log.Warn(we.StackTrace); | ||
653 | } | ||
651 | } | 654 | } |
652 | } | 655 | } |
653 | 656 | ||
@@ -656,4 +659,4 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
656 | ScriptRemoved(itemID); | 659 | ScriptRemoved(itemID); |
657 | } | 660 | } |
658 | } | 661 | } |
659 | } \ No newline at end of file | 662 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index 689e8a7..f395441 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | |||
@@ -852,4 +852,4 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
852 | return null; | 852 | return null; |
853 | } | 853 | } |
854 | } | 854 | } |
855 | } \ No newline at end of file | 855 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 2c2c99c..87a0537 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -96,6 +96,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
96 | // private static readonly ILog m_log = | 96 | // private static readonly ILog m_log = |
97 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 97 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
98 | 98 | ||
99 | private const int DEBUG_CHANNEL = 2147483647; | ||
100 | |||
99 | private ListenerManager m_listenerManager; | 101 | private ListenerManager m_listenerManager; |
100 | private Queue m_pending; | 102 | private Queue m_pending; |
101 | private Queue m_pendingQ; | 103 | private Queue m_pendingQ; |
@@ -366,67 +368,60 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
366 | /// <param name='msg'> | 368 | /// <param name='msg'> |
367 | /// Message. | 369 | /// Message. |
368 | /// </param> | 370 | /// </param> |
369 | public void DeliverMessageTo(UUID target, int channel, Vector3 pos, | 371 | public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) |
370 | string name, UUID id, string msg) | ||
371 | { | 372 | { |
373 | error = null; | ||
374 | |||
375 | if (channel == DEBUG_CHANNEL) | ||
376 | return true; | ||
377 | |||
372 | // Is id an avatar? | 378 | // Is id an avatar? |
373 | ScenePresence sp = m_scene.GetScenePresence(target); | 379 | ScenePresence sp = m_scene.GetScenePresence(target); |
374 | 380 | ||
375 | if (sp != null) | 381 | if (sp != null) |
376 | { | 382 | { |
377 | // ignore if a child agent this is restricted to inside one | 383 | // Send message to avatar |
378 | // region | ||
379 | if (sp.IsChildAgent) | ||
380 | return; | ||
381 | |||
382 | // Send message to the avatar. | ||
383 | // Channel zero only goes to the avatar | ||
384 | // non zero channel messages only go to the attachments | ||
385 | if (channel == 0) | 384 | if (channel == 0) |
386 | { | 385 | { |
387 | m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), | 386 | // Channel 0 goes to viewer ONLY |
388 | pos, name, id, false); | 387 | m_scene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, target, false, false); |
388 | return true; | ||
389 | } | 389 | } |
390 | else | ||
391 | { | ||
392 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
393 | if (attachments.Count == 0) | ||
394 | return; | ||
395 | 390 | ||
396 | // Get uuid of attachments | 391 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
397 | List<UUID> targets = new List<UUID>(); | ||
398 | foreach (SceneObjectGroup sog in attachments) | ||
399 | { | ||
400 | if (!sog.IsDeleted) | ||
401 | targets.Add(sog.UUID); | ||
402 | } | ||
403 | 392 | ||
404 | // Need to check each attachment | 393 | if (attachments.Count == 0) |
405 | foreach (ListenerInfo li | 394 | return true; |
406 | in m_listenerManager.GetListeners(UUID.Zero, | ||
407 | channel, name, id, msg)) | ||
408 | { | ||
409 | if (li.GetHostID().Equals(id)) | ||
410 | continue; | ||
411 | 395 | ||
412 | if (m_scene.GetSceneObjectPart( | 396 | // Get uuid of attachments |
413 | li.GetHostID()) == null) | 397 | List<UUID> targets = new List<UUID>(); |
414 | { | 398 | foreach (SceneObjectGroup sog in attachments) |
415 | continue; | 399 | { |
416 | } | 400 | if (!sog.IsDeleted) |
401 | targets.Add(sog.UUID); | ||
402 | } | ||
417 | 403 | ||
418 | if (targets.Contains(li.GetHostID())) | 404 | // Need to check each attachment |
419 | QueueMessage(new ListenerInfo(li, name, id, msg)); | 405 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) |
420 | } | 406 | { |
407 | if (li.GetHostID().Equals(id)) | ||
408 | continue; | ||
409 | |||
410 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) | ||
411 | continue; | ||
412 | |||
413 | if (targets.Contains(li.GetHostID())) | ||
414 | QueueMessage(new ListenerInfo(li, name, id, msg)); | ||
421 | } | 415 | } |
422 | 416 | ||
423 | return; | 417 | return true; |
424 | } | 418 | } |
425 | 419 | ||
426 | // No avatar found so look for an object | 420 | SceneObjectPart part = m_scene.GetSceneObjectPart(target); |
427 | foreach (ListenerInfo li | 421 | if (part == null) // Not even an object |
428 | in m_listenerManager.GetListeners(UUID.Zero, channel, | 422 | return true; // No error |
429 | name, id, msg)) | 423 | |
424 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | ||
430 | { | 425 | { |
431 | // Dont process if this message is from yourself! | 426 | // Dont process if this message is from yourself! |
432 | if (li.GetHostID().Equals(id)) | 427 | if (li.GetHostID().Equals(id)) |
@@ -444,7 +439,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
444 | } | 439 | } |
445 | } | 440 | } |
446 | 441 | ||
447 | return; | 442 | return true; |
448 | } | 443 | } |
449 | 444 | ||
450 | protected void QueueMessage(ListenerInfo li) | 445 | protected void QueueMessage(ListenerInfo li) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs index 16f42a7..f027810 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs | |||
@@ -139,6 +139,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication | |||
139 | 139 | ||
140 | #region IAuthenticationService | 140 | #region IAuthenticationService |
141 | 141 | ||
142 | public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) | ||
143 | { | ||
144 | // Not implemented at the regions | ||
145 | realID = UUID.Zero; | ||
146 | return string.Empty; | ||
147 | } | ||
148 | |||
142 | public string Authenticate(UUID principalID, string password, int lifetime) | 149 | public string Authenticate(UUID principalID, string password, int lifetime) |
143 | { | 150 | { |
144 | // Not implemented at the regions | 151 | // Not implemented at the regions |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 26d22b8..b61062f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -92,8 +92,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
92 | if (config == null) | 92 | if (config == null) |
93 | return; | 93 | return; |
94 | 94 | ||
95 | int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime")); | 95 | int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime", "-1")); |
96 | if (refreshminutes <= 0) | 96 | if (refreshminutes < 0) |
97 | { | 97 | { |
98 | m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: No refresh time given in config. Module disabled."); | 98 | m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: No refresh time given in config. Module disabled."); |
99 | return; | 99 | return; |
@@ -116,12 +116,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | 118 | ||
119 | m_refreshTimer.Enabled = true; | 119 | if (m_refreshtime > 0) |
120 | m_refreshTimer.AutoReset = true; | 120 | { |
121 | m_refreshTimer.Interval = m_refreshtime; | 121 | m_refreshTimer.Enabled = true; |
122 | m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh); | 122 | m_refreshTimer.AutoReset = true; |
123 | m_refreshTimer.Interval = m_refreshtime; | ||
124 | m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh); | ||
125 | } | ||
123 | 126 | ||
124 | m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0}min and service object {1}", | 127 | m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0} min and service object {1}", |
125 | refreshminutes, service); | 128 | refreshminutes, service); |
126 | 129 | ||
127 | m_enabled = true; | 130 | m_enabled = true; |
@@ -231,4 +234,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
231 | } | 234 | } |
232 | } | 235 | } |
233 | } | 236 | } |
234 | } \ No newline at end of file | 237 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 3c18074..b485194 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -303,6 +303,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
303 | return false; | 303 | return false; |
304 | } | 304 | } |
305 | 305 | ||
306 | public bool CloseChildAgent(GridRegion destination, UUID id) | ||
307 | { | ||
308 | return CloseAgent(destination, id); | ||
309 | } | ||
310 | |||
306 | public bool CloseAgent(GridRegion destination, UUID id) | 311 | public bool CloseAgent(GridRegion destination, UUID id) |
307 | { | 312 | { |
308 | if (destination == null) | 313 | if (destination == null) |
@@ -317,7 +322,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
317 | Util.FireAndForget(delegate { m_scenes[destination.RegionID].IncomingCloseAgent(id, false); }); | 322 | Util.FireAndForget(delegate { m_scenes[destination.RegionID].IncomingCloseAgent(id, false); }); |
318 | return true; | 323 | return true; |
319 | } | 324 | } |
320 | |||
321 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); | 325 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); |
322 | return false; | 326 | return false; |
323 | } | 327 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index b2a1b23..c8698ca 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | |||
@@ -262,6 +262,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
262 | return false; | 262 | return false; |
263 | } | 263 | } |
264 | 264 | ||
265 | public bool CloseChildAgent(GridRegion destination, UUID id) | ||
266 | { | ||
267 | if (destination == null) | ||
268 | return false; | ||
269 | |||
270 | // Try local first | ||
271 | if (m_localBackend.CloseChildAgent(destination, id)) | ||
272 | return true; | ||
273 | |||
274 | // else do the remote thing | ||
275 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
276 | return m_remoteConnector.CloseChildAgent(destination, id); | ||
277 | |||
278 | return false; | ||
279 | } | ||
265 | 280 | ||
266 | public bool CloseAgent(GridRegion destination, UUID id) | 281 | public bool CloseAgent(GridRegion destination, UUID id) |
267 | { | 282 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 529bfd7..ea4ade5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs | |||
@@ -129,6 +129,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
129 | // FIXME: Why do we bother setting this module and caching up if we just end up registering the inner | 129 | // FIXME: Why do we bother setting this module and caching up if we just end up registering the inner |
130 | // user account service?! | 130 | // user account service?! |
131 | scene.RegisterModuleInterface<IUserAccountService>(UserAccountService); | 131 | scene.RegisterModuleInterface<IUserAccountService>(UserAccountService); |
132 | scene.RegisterModuleInterface<IUserAccountCacheModule>(m_Cache); | ||
132 | } | 133 | } |
133 | 134 | ||
134 | public void RemoveRegion(Scene scene) | 135 | public void RemoveRegion(Scene scene) |
@@ -181,6 +182,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
181 | return UserAccountService.GetUserAccount(scopeID, Email); | 182 | return UserAccountService.GetUserAccount(scopeID, Email); |
182 | } | 183 | } |
183 | 184 | ||
185 | public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query) | ||
186 | { | ||
187 | return null; | ||
188 | } | ||
189 | |||
184 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) | 190 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) |
185 | { | 191 | { |
186 | return UserAccountService.GetUserAccounts(scopeID, query); | 192 | return UserAccountService.GetUserAccounts(scopeID, query); |
@@ -195,4 +201,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
195 | 201 | ||
196 | #endregion | 202 | #endregion |
197 | } | 203 | } |
198 | } \ No newline at end of file | 204 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index 5aa87d3..afbba30 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs | |||
@@ -34,6 +34,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
34 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Services.Interfaces; | 35 | using OpenSim.Services.Interfaces; |
36 | using OpenSim.Services.Connectors; | 36 | using OpenSim.Services.Connectors; |
37 | using OpenSim.Framework; | ||
37 | 38 | ||
38 | using OpenMetaverse; | 39 | using OpenMetaverse; |
39 | 40 | ||
@@ -103,6 +104,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
103 | return; | 104 | return; |
104 | 105 | ||
105 | scene.RegisterModuleInterface<IUserAccountService>(this); | 106 | scene.RegisterModuleInterface<IUserAccountService>(this); |
107 | scene.RegisterModuleInterface<IUserAccountCacheModule>(m_Cache); | ||
108 | |||
109 | scene.EventManager.OnNewClient += OnNewClient; | ||
106 | } | 110 | } |
107 | 111 | ||
108 | public void RemoveRegion(Scene scene) | 112 | public void RemoveRegion(Scene scene) |
@@ -117,6 +121,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
117 | return; | 121 | return; |
118 | } | 122 | } |
119 | 123 | ||
124 | // When a user actually enters the sim, clear them from | ||
125 | // cache so the sim will have the current values for | ||
126 | // flags, title, etc. And country, don't forget country! | ||
127 | private void OnNewClient(IClientAPI client) | ||
128 | { | ||
129 | m_Cache.Remove(client.Name); | ||
130 | } | ||
131 | |||
120 | #region Overwritten methods from IUserAccountService | 132 | #region Overwritten methods from IUserAccountService |
121 | 133 | ||
122 | public override UserAccount GetUserAccount(UUID scopeID, UUID userID) | 134 | public override UserAccount GetUserAccount(UUID scopeID, UUID userID) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs index ddef75f..cbe2eaa 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs | |||
@@ -34,7 +34,7 @@ using log4net; | |||
34 | 34 | ||
35 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | 35 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts |
36 | { | 36 | { |
37 | public class UserAccountCache | 37 | public class UserAccountCache : IUserAccountCacheModule |
38 | { | 38 | { |
39 | private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! | 39 | private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! |
40 | 40 | ||
@@ -92,5 +92,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
92 | 92 | ||
93 | return null; | 93 | return null; |
94 | } | 94 | } |
95 | |||
96 | public void Remove(string name) | ||
97 | { | ||
98 | if (!m_NameCache.Contains(name)) | ||
99 | return; | ||
100 | |||
101 | UUID uuid = UUID.Zero; | ||
102 | if (m_NameCache.TryGetValue(name, out uuid)) | ||
103 | { | ||
104 | m_NameCache.Remove(name); | ||
105 | m_UUIDCache.Remove(uuid); | ||
106 | } | ||
107 | } | ||
95 | } | 108 | } |
96 | } | 109 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 32d245f..fcfdf7c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -490,6 +490,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
490 | // being no copy/no mod for everyone | 490 | // being no copy/no mod for everyone |
491 | lock (part.TaskInventory) | 491 | lock (part.TaskInventory) |
492 | { | 492 | { |
493 | if (!ResolveUserUuid(scene, part.CreatorID)) | ||
494 | part.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner; | ||
495 | |||
496 | if (!ResolveUserUuid(scene, part.OwnerID)) | ||
497 | part.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner; | ||
498 | |||
499 | if (!ResolveUserUuid(scene, part.LastOwnerID)) | ||
500 | part.LastOwnerID = scene.RegionInfo.EstateSettings.EstateOwner; | ||
501 | |||
502 | // And zap any troublesome sit target information | ||
503 | part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); | ||
504 | part.SitTargetPosition = new Vector3(0, 0, 0); | ||
505 | |||
506 | // Fix ownership/creator of inventory items | ||
507 | // Not doing so results in inventory items | ||
508 | // being no copy/no mod for everyone | ||
509 | part.TaskInventory.LockItemsForRead(true); | ||
493 | TaskInventoryDictionary inv = part.TaskInventory; | 510 | TaskInventoryDictionary inv = part.TaskInventory; |
494 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) | 511 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) |
495 | { | 512 | { |
@@ -510,6 +527,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
510 | if (!ResolveGroupUuid(kvp.Value.GroupID)) | 527 | if (!ResolveGroupUuid(kvp.Value.GroupID)) |
511 | kvp.Value.GroupID = UUID.Zero; | 528 | kvp.Value.GroupID = UUID.Zero; |
512 | } | 529 | } |
530 | part.TaskInventory.LockItemsForRead(false); | ||
513 | } | 531 | } |
514 | } | 532 | } |
515 | 533 | ||
@@ -899,4 +917,4 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
899 | return dearchivedScenes; | 917 | return dearchivedScenes; |
900 | } | 918 | } |
901 | } | 919 | } |
902 | } \ No newline at end of file | 920 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index b22bcf9..715bf51 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | |||
@@ -269,18 +269,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
269 | 269 | ||
270 | if (asset != null) | 270 | if (asset != null) |
271 | { | 271 | { |
272 | if (m_options.ContainsKey("verbose")) | 272 | // m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id); |
273 | m_log.InfoFormat("[ARCHIVER]: Writing asset {0}", id); | ||
274 | |||
275 | m_foundAssetUuids.Add(asset.FullID); | 273 | m_foundAssetUuids.Add(asset.FullID); |
276 | 274 | ||
277 | m_assetsArchiver.WriteAsset(PostProcess(asset)); | 275 | m_assetsArchiver.WriteAsset(PostProcess(asset)); |
278 | } | 276 | } |
279 | else | 277 | else |
280 | { | 278 | { |
281 | if (m_options.ContainsKey("verbose")) | 279 | // m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id); |
282 | m_log.InfoFormat("[ARCHIVER]: Recording asset {0} as not found", id); | ||
283 | |||
284 | m_notFoundAssetUuids.Add(new UUID(id)); | 280 | m_notFoundAssetUuids.Add(new UUID(id)); |
285 | } | 281 | } |
286 | 282 | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 60f6739..a5f5749 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; |
@@ -48,6 +49,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
48 | { | 49 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 51 | ||
52 | private Timer m_regionChangeTimer = new Timer(); | ||
51 | public Scene Scene { get; private set; } | 53 | public Scene Scene { get; private set; } |
52 | public IUserManagement UserManager { get; private set; } | 54 | public IUserManagement UserManager { get; private set; } |
53 | 55 | ||
@@ -65,6 +67,8 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
65 | public event ChangeDelegate OnEstateInfoChange; | 67 | public event ChangeDelegate OnEstateInfoChange; |
66 | public event MessageDelegate OnEstateMessage; | 68 | public event MessageDelegate OnEstateMessage; |
67 | 69 | ||
70 | private int m_delayCount = 0; | ||
71 | |||
68 | #region Region Module interface | 72 | #region Region Module interface |
69 | 73 | ||
70 | public string Name { get { return "EstateManagementModule"; } } | 74 | public string Name { get { return "EstateManagementModule"; } } |
@@ -114,6 +118,12 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
114 | 118 | ||
115 | #region Packet Data Responders | 119 | #region Packet Data Responders |
116 | 120 | ||
121 | private void clientSendDetailedEstateData(IClientAPI remote_client, UUID invoice) | ||
122 | { | ||
123 | sendDetailedEstateData(remote_client, invoice); | ||
124 | sendEstateLists(remote_client, invoice); | ||
125 | } | ||
126 | |||
117 | private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) | 127 | private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) |
118 | { | 128 | { |
119 | uint sun = 0; | 129 | uint sun = 0; |
@@ -136,7 +146,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
136 | (uint) Scene.RegionInfo.RegionSettings.CovenantChangedDateTime, | 146 | (uint) Scene.RegionInfo.RegionSettings.CovenantChangedDateTime, |
137 | Scene.RegionInfo.EstateSettings.AbuseEmail, | 147 | Scene.RegionInfo.EstateSettings.AbuseEmail, |
138 | estateOwner); | 148 | estateOwner); |
149 | } | ||
139 | 150 | ||
151 | private void sendEstateLists(IClientAPI remote_client, UUID invoice) | ||
152 | { | ||
140 | remote_client.SendEstateList(invoice, | 153 | remote_client.SendEstateList(invoice, |
141 | (int)Constants.EstateAccessCodex.EstateManagers, | 154 | (int)Constants.EstateAccessCodex.EstateManagers, |
142 | Scene.RegionInfo.EstateSettings.EstateManagers, | 155 | Scene.RegionInfo.EstateSettings.EstateManagers, |
@@ -318,6 +331,16 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
318 | IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>(); | 331 | IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>(); |
319 | if (restartModule != null) | 332 | if (restartModule != null) |
320 | { | 333 | { |
334 | if (timeInSeconds == -1) | ||
335 | { | ||
336 | m_delayCount++; | ||
337 | if (m_delayCount > 3) | ||
338 | return; | ||
339 | |||
340 | restartModule.DelayRestart(3600, "Restart delayed by region manager"); | ||
341 | return; | ||
342 | } | ||
343 | |||
321 | List<int> times = new List<int>(); | 344 | List<int> times = new List<int>(); |
322 | while (timeInSeconds > 0) | 345 | while (timeInSeconds > 0) |
323 | { | 346 | { |
@@ -330,7 +353,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
330 | timeInSeconds -= 15; | 353 | timeInSeconds -= 15; |
331 | } | 354 | } |
332 | 355 | ||
333 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | 356 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), false); |
334 | 357 | ||
335 | m_log.InfoFormat( | 358 | m_log.InfoFormat( |
336 | "User {0} requested restart of region {1} in {2} seconds", | 359 | "User {0} requested restart of region {1} in {2} seconds", |
@@ -546,7 +569,11 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
546 | { | 569 | { |
547 | if (!s.IsChildAgent) | 570 | if (!s.IsChildAgent) |
548 | { | 571 | { |
549 | Scene.TeleportClientHome(user, s.ControllingClient); | 572 | if (!Scene.TeleportClientHome(user, s.ControllingClient)) |
573 | { | ||
574 | s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out."); | ||
575 | s.ControllingClient.Close(); | ||
576 | } | ||
550 | } | 577 | } |
551 | } | 578 | } |
552 | 579 | ||
@@ -555,7 +582,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
555 | { | 582 | { |
556 | remote_client.SendAlertMessage("User is already on the region ban list"); | 583 | remote_client.SendAlertMessage("User is already on the region ban list"); |
557 | } | 584 | } |
558 | //m_scene.RegionInfo.regionBanlist.Add(Manager(user); | 585 | //Scene.RegionInfo.regionBanlist.Add(Manager(user); |
559 | remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); | 586 | remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); |
560 | } | 587 | } |
561 | else | 588 | else |
@@ -611,7 +638,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
611 | remote_client.SendAlertMessage("User is not on the region ban list"); | 638 | remote_client.SendAlertMessage("User is not on the region ban list"); |
612 | } | 639 | } |
613 | 640 | ||
614 | //m_scene.RegionInfo.regionBanlist.Add(Manager(user); | 641 | //Scene.RegionInfo.regionBanlist.Add(Manager(user); |
615 | remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); | 642 | remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); |
616 | } | 643 | } |
617 | else | 644 | else |
@@ -777,7 +804,11 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
777 | ScenePresence s = Scene.GetScenePresence(prey); | 804 | ScenePresence s = Scene.GetScenePresence(prey); |
778 | if (s != null) | 805 | if (s != null) |
779 | { | 806 | { |
780 | Scene.TeleportClientHome(prey, s.ControllingClient); | 807 | if (!Scene.TeleportClientHome(prey, s.ControllingClient)) |
808 | { | ||
809 | s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); | ||
810 | s.ControllingClient.Close(); | ||
811 | } | ||
781 | } | 812 | } |
782 | } | 813 | } |
783 | } | 814 | } |
@@ -795,7 +826,13 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
795 | // Also make sure they are actually in the region | 826 | // Also make sure they are actually in the region |
796 | ScenePresence p; | 827 | ScenePresence p; |
797 | if(Scene.TryGetScenePresence(client.AgentId, out p)) | 828 | if(Scene.TryGetScenePresence(client.AgentId, out p)) |
798 | Scene.TeleportClientHome(p.UUID, p.ControllingClient); | 829 | { |
830 | if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient)) | ||
831 | { | ||
832 | p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); | ||
833 | p.ControllingClient.Close(); | ||
834 | } | ||
835 | } | ||
799 | } | 836 | } |
800 | }); | 837 | }); |
801 | } | 838 | } |
@@ -1170,7 +1207,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1170 | 1207 | ||
1171 | private void EventManager_OnNewClient(IClientAPI client) | 1208 | private void EventManager_OnNewClient(IClientAPI client) |
1172 | { | 1209 | { |
1173 | client.OnDetailedEstateDataRequest += sendDetailedEstateData; | 1210 | client.OnDetailedEstateDataRequest += clientSendDetailedEstateData; |
1174 | client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler; | 1211 | client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler; |
1175 | // client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture; | 1212 | // client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture; |
1176 | client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture; | 1213 | client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture; |
@@ -1222,6 +1259,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1222 | flags |= RegionFlags.AllowParcelChanges; | 1259 | flags |= RegionFlags.AllowParcelChanges; |
1223 | if (Scene.RegionInfo.RegionSettings.BlockShowInSearch) | 1260 | if (Scene.RegionInfo.RegionSettings.BlockShowInSearch) |
1224 | flags |= RegionFlags.BlockParcelSearch; | 1261 | flags |= RegionFlags.BlockParcelSearch; |
1262 | if (Scene.RegionInfo.RegionSettings.GodBlockSearch) | ||
1263 | flags |= (RegionFlags)(1 << 11); | ||
1264 | if (Scene.RegionInfo.RegionSettings.Casino) | ||
1265 | flags |= (RegionFlags)(1 << 10); | ||
1225 | 1266 | ||
1226 | if (Scene.RegionInfo.RegionSettings.FixedSun) | 1267 | if (Scene.RegionInfo.RegionSettings.FixedSun) |
1227 | flags |= RegionFlags.SunFixed; | 1268 | flags |= RegionFlags.SunFixed; |
@@ -1229,11 +1270,15 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1229 | flags |= RegionFlags.Sandbox; | 1270 | flags |= RegionFlags.Sandbox; |
1230 | if (Scene.RegionInfo.EstateSettings.AllowVoice) | 1271 | if (Scene.RegionInfo.EstateSettings.AllowVoice) |
1231 | flags |= RegionFlags.AllowVoice; | 1272 | flags |= RegionFlags.AllowVoice; |
1273 | if (Scene.RegionInfo.EstateSettings.AllowLandmark) | ||
1274 | flags |= RegionFlags.AllowLandmark; | ||
1275 | if (Scene.RegionInfo.EstateSettings.AllowSetHome) | ||
1276 | flags |= RegionFlags.AllowSetHome; | ||
1277 | if (Scene.RegionInfo.EstateSettings.BlockDwell) | ||
1278 | flags |= RegionFlags.BlockDwell; | ||
1279 | if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport) | ||
1280 | flags |= RegionFlags.ResetHomeOnTeleport; | ||
1232 | 1281 | ||
1233 | // Fudge these to always on, so the menu options activate | ||
1234 | // | ||
1235 | flags |= RegionFlags.AllowLandmark; | ||
1236 | flags |= RegionFlags.AllowSetHome; | ||
1237 | 1282 | ||
1238 | // TODO: SkipUpdateInterestList | 1283 | // TODO: SkipUpdateInterestList |
1239 | 1284 | ||
@@ -1274,6 +1319,12 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1274 | flags |= RegionFlags.ResetHomeOnTeleport; | 1319 | flags |= RegionFlags.ResetHomeOnTeleport; |
1275 | if (Scene.RegionInfo.EstateSettings.TaxFree) | 1320 | if (Scene.RegionInfo.EstateSettings.TaxFree) |
1276 | flags |= RegionFlags.TaxFree; | 1321 | flags |= RegionFlags.TaxFree; |
1322 | if (Scene.RegionInfo.EstateSettings.AllowLandmark) | ||
1323 | flags |= RegionFlags.AllowLandmark; | ||
1324 | if (Scene.RegionInfo.EstateSettings.AllowParcelChanges) | ||
1325 | flags |= RegionFlags.AllowParcelChanges; | ||
1326 | if (Scene.RegionInfo.EstateSettings.AllowSetHome) | ||
1327 | flags |= RegionFlags.AllowSetHome; | ||
1277 | if (Scene.RegionInfo.EstateSettings.DenyMinors) | 1328 | if (Scene.RegionInfo.EstateSettings.DenyMinors) |
1278 | flags |= (RegionFlags)(1 << 30); | 1329 | flags |= (RegionFlags)(1 << 30); |
1279 | 1330 | ||
@@ -1294,6 +1345,12 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1294 | 1345 | ||
1295 | public void TriggerRegionInfoChange() | 1346 | public void TriggerRegionInfoChange() |
1296 | { | 1347 | { |
1348 | m_regionChangeTimer.Stop(); | ||
1349 | m_regionChangeTimer.Start(); | ||
1350 | } | ||
1351 | |||
1352 | protected void RaiseRegionInfoChange(object sender, ElapsedEventArgs e) | ||
1353 | { | ||
1297 | ChangeDelegate change = OnRegionInfoChange; | 1354 | ChangeDelegate change = OnRegionInfoChange; |
1298 | 1355 | ||
1299 | if (change != null) | 1356 | if (change != null) |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index dbf5138..b4f7d51 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -88,19 +88,21 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
88 | /// <value> | 88 | /// <value> |
89 | /// Land objects keyed by local id | 89 | /// Land objects keyed by local id |
90 | /// </value> | 90 | /// </value> |
91 | private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); | 91 | // private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); |
92 | |||
93 | //ubit: removed the readonly so i can move it around | ||
94 | private Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); | ||
92 | 95 | ||
93 | private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; | 96 | private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; |
94 | 97 | ||
95 | private bool m_allowedForcefulBans = true; | 98 | private bool m_allowedForcefulBans = true; |
99 | private UUID DefaultGodParcelGroup; | ||
100 | private string DefaultGodParcelName; | ||
96 | 101 | ||
97 | // caches ExtendedLandData | 102 | // caches ExtendedLandData |
98 | private Cache parcelInfoCache; | 103 | private Cache parcelInfoCache; |
99 | 104 | private Dictionary<UUID, Vector3> forcedPosition = | |
100 | /// <summary> | 105 | new Dictionary<UUID, Vector3>(); |
101 | /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions. | ||
102 | /// </summary> | ||
103 | private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>(); | ||
104 | 106 | ||
105 | #region INonSharedRegionModule Members | 107 | #region INonSharedRegionModule Members |
106 | 108 | ||
@@ -111,6 +113,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
111 | 113 | ||
112 | public void Initialise(IConfigSource source) | 114 | public void Initialise(IConfigSource source) |
113 | { | 115 | { |
116 | IConfig cnf = source.Configs["LandManagement"]; | ||
117 | if (cnf != null) | ||
118 | { | ||
119 | DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString())); | ||
120 | DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel"); | ||
121 | } | ||
114 | } | 122 | } |
115 | 123 | ||
116 | public void AddRegion(Scene scene) | 124 | public void AddRegion(Scene scene) |
@@ -163,13 +171,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
163 | m_scene.UnregisterModuleCommander(m_commander.Name); | 171 | m_scene.UnregisterModuleCommander(m_commander.Name); |
164 | } | 172 | } |
165 | 173 | ||
166 | // private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason) | ||
167 | // { | ||
168 | // ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y); | ||
169 | // reason = "You are not allowed to enter this sim."; | ||
170 | // return nearestParcel != null; | ||
171 | // } | ||
172 | |||
173 | /// <summary> | 174 | /// <summary> |
174 | /// Processes commandline input. Do not call directly. | 175 | /// Processes commandline input. Do not call directly. |
175 | /// </summary> | 176 | /// </summary> |
@@ -210,6 +211,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
210 | client.OnParcelInfoRequest += ClientOnParcelInfoRequest; | 211 | client.OnParcelInfoRequest += ClientOnParcelInfoRequest; |
211 | client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; | 212 | client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; |
212 | client.OnPreAgentUpdate += ClientOnPreAgentUpdate; | 213 | client.OnPreAgentUpdate += ClientOnPreAgentUpdate; |
214 | client.OnParcelEjectUser += ClientOnParcelEjectUser; | ||
215 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; | ||
213 | 216 | ||
214 | EntityBase presenceEntity; | 217 | EntityBase presenceEntity; |
215 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) | 218 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) |
@@ -226,48 +229,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
226 | 229 | ||
227 | void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | 230 | void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) |
228 | { | 231 | { |
229 | //If we are forcing a position for them to go | ||
230 | if (forcedPosition.ContainsKey(remoteClient.AgentId)) | ||
231 | { | ||
232 | ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId); | ||
233 | |||
234 | //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND | ||
235 | //When the avatar walks into a ban line on the ground, it prevents getting stuck | ||
236 | agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
237 | |||
238 | //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines | ||
239 | if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2) | ||
240 | { | ||
241 | // m_log.DebugFormat( | ||
242 | // "[LAND MANAGEMENT MODULE]: Stopping force position of {0} because {1} is close enough to {2}", | ||
243 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]); | ||
244 | |||
245 | forcedPosition.Remove(remoteClient.AgentId); | ||
246 | } | ||
247 | //if we are far away, teleport | ||
248 | else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3) | ||
249 | { | ||
250 | Vector3 forcePosition = forcedPosition[remoteClient.AgentId]; | ||
251 | // m_log.DebugFormat( | ||
252 | // "[LAND MANAGEMENT MODULE]: Teleporting out {0} because {1} is too far from avatar position {2}", | ||
253 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcePosition); | ||
254 | |||
255 | m_scene.RequestTeleportLocation(remoteClient, m_scene.RegionInfo.RegionHandle, | ||
256 | forcePosition, clientAvatar.Lookat, (uint)Constants.TeleportFlags.ForceRedirect); | ||
257 | |||
258 | forcedPosition.Remove(remoteClient.AgentId); | ||
259 | } | ||
260 | else | ||
261 | { | ||
262 | // m_log.DebugFormat( | ||
263 | // "[LAND MANAGEMENT MODULE]: Forcing {0} from {1} to {2}", | ||
264 | // clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]); | ||
265 | |||
266 | //Forces them toward the forced position we want if they aren't there yet | ||
267 | agentData.UseClientAgentPosition = true; | ||
268 | agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId]; | ||
269 | } | ||
270 | } | ||
271 | } | 232 | } |
272 | 233 | ||
273 | public void Close() | 234 | public void Close() |
@@ -292,6 +253,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
292 | { | 253 | { |
293 | LandData newData = data.Copy(); | 254 | LandData newData = data.Copy(); |
294 | newData.LocalID = local_id; | 255 | newData.LocalID = local_id; |
256 | ILandObject landobj = null; | ||
295 | 257 | ||
296 | ILandObject land; | 258 | ILandObject land; |
297 | lock (m_landList) | 259 | lock (m_landList) |
@@ -331,14 +293,14 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
331 | protected ILandObject CreateDefaultParcel() | 293 | protected ILandObject CreateDefaultParcel() |
332 | { | 294 | { |
333 | m_log.DebugFormat( | 295 | m_log.DebugFormat( |
334 | "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); | 296 | "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); |
335 | 297 | ||
336 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); | 298 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); |
337 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | 299 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); |
338 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 300 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
339 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); | 301 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); |
340 | 302 | ||
341 | return AddLandObject(fullSimParcel); | 303 | return AddLandObject(fullSimParcel); |
342 | } | 304 | } |
343 | 305 | ||
344 | public List<ILandObject> AllParcels() | 306 | public List<ILandObject> AllParcels() |
@@ -387,10 +349,16 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
387 | private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) | 349 | private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) |
388 | { | 350 | { |
389 | if (m_scene.Permissions.IsGod(avatar.UUID)) return; | 351 | if (m_scene.Permissions.IsGod(avatar.UUID)) return; |
390 | if (position.HasValue) | 352 | |
391 | { | 353 | if (!position.HasValue) |
392 | forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; | 354 | return; |
393 | } | 355 | |
356 | bool isFlying = avatar.PhysicsActor.Flying; | ||
357 | avatar.RemoveFromPhysicalScene(); | ||
358 | |||
359 | avatar.AbsolutePosition = (Vector3)position; | ||
360 | |||
361 | avatar.AddToPhysicalScene(isFlying); | ||
394 | } | 362 | } |
395 | 363 | ||
396 | public void SendYouAreRestrictedNotice(ScenePresence avatar) | 364 | public void SendYouAreRestrictedNotice(ScenePresence avatar) |
@@ -410,29 +378,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
410 | } | 378 | } |
411 | 379 | ||
412 | if (parcelAvatarIsEntering != null) | 380 | if (parcelAvatarIsEntering != null) |
413 | { | 381 | EnforceBans(parcelAvatarIsEntering, avatar); |
414 | if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT) | ||
415 | { | ||
416 | if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID)) | ||
417 | { | ||
418 | SendYouAreBannedNotice(avatar); | ||
419 | ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); | ||
420 | } | ||
421 | else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID)) | ||
422 | { | ||
423 | SendYouAreRestrictedNotice(avatar); | ||
424 | ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); | ||
425 | } | ||
426 | else | ||
427 | { | ||
428 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; | ||
429 | } | ||
430 | } | ||
431 | else | ||
432 | { | ||
433 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; | ||
434 | } | ||
435 | } | ||
436 | } | 382 | } |
437 | } | 383 | } |
438 | 384 | ||
@@ -461,30 +407,51 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
461 | 407 | ||
462 | public void SendLandUpdate(ScenePresence avatar, bool force) | 408 | public void SendLandUpdate(ScenePresence avatar, bool force) |
463 | { | 409 | { |
410 | |||
411 | /* stop sendind same data twice | ||
412 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), | ||
413 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); | ||
414 | |||
415 | if (over != null) | ||
416 | { | ||
417 | |||
418 | if (force) | ||
419 | { | ||
420 | if (!avatar.IsChildAgent) | ||
421 | { | ||
422 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
423 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
424 | m_scene.RegionInfo.RegionID); | ||
425 | } | ||
426 | } | ||
427 | |||
428 | if (avatar.currentParcelUUID != over.LandData.GlobalID) | ||
429 | { | ||
430 | if (!avatar.IsChildAgent) | ||
431 | { | ||
432 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
433 | avatar.currentParcelUUID = over.LandData.GlobalID; | ||
434 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
435 | m_scene.RegionInfo.RegionID); | ||
436 | } | ||
437 | } | ||
438 | */ | ||
439 | if (avatar.IsChildAgent) | ||
440 | return; | ||
441 | |||
464 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), | 442 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), |
465 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); | 443 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); |
466 | 444 | ||
467 | if (over != null) | 445 | if (over != null) |
468 | { | 446 | { |
469 | if (force) | 447 | bool NotsameID = (avatar.currentParcelUUID != over.LandData.GlobalID); |
448 | if (force || NotsameID) | ||
470 | { | 449 | { |
471 | if (!avatar.IsChildAgent) | 450 | over.SendLandUpdateToClient(avatar.ControllingClient); |
472 | { | 451 | if (NotsameID) |
473 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
474 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
475 | m_scene.RegionInfo.RegionID); | ||
476 | } | ||
477 | } | ||
478 | |||
479 | if (avatar.currentParcelUUID != over.LandData.GlobalID) | ||
480 | { | ||
481 | if (!avatar.IsChildAgent) | ||
482 | { | ||
483 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
484 | avatar.currentParcelUUID = over.LandData.GlobalID; | 452 | avatar.currentParcelUUID = over.LandData.GlobalID; |
485 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | 453 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, |
486 | m_scene.RegionInfo.RegionID); | 454 | m_scene.RegionInfo.RegionID); |
487 | } | ||
488 | } | 455 | } |
489 | } | 456 | } |
490 | } | 457 | } |
@@ -536,6 +503,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
536 | //when we are finally in a safe place, lets release the forced position lock | 503 | //when we are finally in a safe place, lets release the forced position lock |
537 | forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); | 504 | forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); |
538 | } | 505 | } |
506 | EnforceBans(parcel, clientAvatar); | ||
539 | } | 507 | } |
540 | } | 508 | } |
541 | 509 | ||
@@ -686,27 +654,28 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
686 | /// </summary> | 654 | /// </summary> |
687 | public void Clear(bool setupDefaultParcel) | 655 | public void Clear(bool setupDefaultParcel) |
688 | { | 656 | { |
689 | List<ILandObject> parcels; | 657 | Dictionary<int, ILandObject> landworkList; |
658 | // move to work pointer since we are deleting it all | ||
690 | lock (m_landList) | 659 | lock (m_landList) |
691 | { | 660 | { |
692 | parcels = new List<ILandObject>(m_landList.Values); | 661 | landworkList = m_landList; |
662 | m_landList = new Dictionary<int, ILandObject>(); | ||
693 | } | 663 | } |
694 | 664 | ||
695 | foreach (ILandObject lo in parcels) | 665 | // this 2 methods have locks (now) |
666 | ResetSimLandObjects(); | ||
667 | |||
668 | if (setupDefaultParcel) | ||
669 | CreateDefaultParcel(); | ||
670 | |||
671 | // fire outside events unlocked | ||
672 | foreach (ILandObject lo in landworkList.Values) | ||
696 | { | 673 | { |
697 | //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); | 674 | //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); |
698 | m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); | 675 | m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); |
699 | } | 676 | } |
677 | landworkList.Clear(); | ||
700 | 678 | ||
701 | lock (m_landList) | ||
702 | { | ||
703 | m_landList.Clear(); | ||
704 | |||
705 | ResetSimLandObjects(); | ||
706 | } | ||
707 | |||
708 | if (setupDefaultParcel) | ||
709 | CreateDefaultParcel(); | ||
710 | } | 679 | } |
711 | 680 | ||
712 | private void performFinalLandJoin(ILandObject master, ILandObject slave) | 681 | private void performFinalLandJoin(ILandObject master, ILandObject slave) |
@@ -753,7 +722,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
753 | int x; | 722 | int x; |
754 | int y; | 723 | int y; |
755 | 724 | ||
756 | if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) | 725 | if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0) |
757 | return null; | 726 | return null; |
758 | 727 | ||
759 | try | 728 | try |
@@ -803,14 +772,13 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
803 | { | 772 | { |
804 | try | 773 | try |
805 | { | 774 | { |
806 | return m_landList[m_landIDList[x / 4, y / 4]]; | 775 | //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) |
776 | return m_landList[m_landIDList[x / 4, y / 4]]; | ||
777 | //else | ||
778 | // return null; | ||
807 | } | 779 | } |
808 | catch (IndexOutOfRangeException) | 780 | catch (IndexOutOfRangeException) |
809 | { | 781 | { |
810 | // m_log.WarnFormat( | ||
811 | // "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}", | ||
812 | // x, y, m_scene.RegionInfo.RegionName); | ||
813 | |||
814 | return null; | 782 | return null; |
815 | } | 783 | } |
816 | } | 784 | } |
@@ -1094,6 +1062,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1094 | //Owner Flag | 1062 | //Owner Flag |
1095 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); | 1063 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); |
1096 | } | 1064 | } |
1065 | else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID)) | ||
1066 | { | ||
1067 | tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP); | ||
1068 | } | ||
1097 | else if (currentParcelBlock.LandData.SalePrice > 0 && | 1069 | else if (currentParcelBlock.LandData.SalePrice > 0 && |
1098 | (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || | 1070 | (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || |
1099 | currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) | 1071 | currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) |
@@ -1174,8 +1146,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1174 | { | 1146 | { |
1175 | if (!temp.Contains(currentParcel)) | 1147 | if (!temp.Contains(currentParcel)) |
1176 | { | 1148 | { |
1177 | currentParcel.ForceUpdateLandInfo(); | 1149 | if (!currentParcel.IsEitherBannedOrRestricted(remote_client.AgentId)) |
1178 | temp.Add(currentParcel); | 1150 | { |
1151 | currentParcel.ForceUpdateLandInfo(); | ||
1152 | temp.Add(currentParcel); | ||
1153 | } | ||
1179 | } | 1154 | } |
1180 | } | 1155 | } |
1181 | } | 1156 | } |
@@ -1394,8 +1369,26 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1394 | 1369 | ||
1395 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) | 1370 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) |
1396 | { | 1371 | { |
1397 | // m_log.DebugFormat( | 1372 | Dictionary<int, ILandObject> landworkList; |
1398 | // "[LAND MANAGMENT MODULE]: Processing {0} incoming parcels on {1}", data.Count, m_scene.Name); | 1373 | // move to work pointer since we are deleting it all |
1374 | lock (m_landList) | ||
1375 | { | ||
1376 | landworkList = m_landList; | ||
1377 | m_landList = new Dictionary<int, ILandObject>(); | ||
1378 | } | ||
1379 | |||
1380 | //Remove all the land objects in the sim and then process our new data | ||
1381 | foreach (int n in landworkList.Keys) | ||
1382 | { | ||
1383 | m_scene.EventManager.TriggerLandObjectRemoved(landworkList[n].LandData.GlobalID); | ||
1384 | } | ||
1385 | landworkList.Clear(); | ||
1386 | |||
1387 | lock (m_landList) | ||
1388 | { | ||
1389 | m_landIDList.Initialize(); | ||
1390 | m_landList.Clear(); | ||
1391 | } | ||
1399 | 1392 | ||
1400 | for (int i = 0; i < data.Count; i++) | 1393 | for (int i = 0; i < data.Count; i++) |
1401 | IncomingLandObjectFromStorage(data[i]); | 1394 | IncomingLandObjectFromStorage(data[i]); |
@@ -1403,10 +1396,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1403 | 1396 | ||
1404 | public void IncomingLandObjectFromStorage(LandData data) | 1397 | public void IncomingLandObjectFromStorage(LandData data) |
1405 | { | 1398 | { |
1399 | |||
1406 | ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); | 1400 | ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); |
1407 | new_land.LandData = data.Copy(); | 1401 | new_land.LandData = data.Copy(); |
1408 | new_land.SetLandBitmapFromByteArray(); | 1402 | new_land.SetLandBitmapFromByteArray(); |
1409 | AddLandObject(new_land); | 1403 | AddLandObject(new_land); |
1404 | new_land.SendLandUpdateToAvatarsOverMe(); | ||
1410 | } | 1405 | } |
1411 | 1406 | ||
1412 | public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) | 1407 | public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) |
@@ -1737,6 +1732,168 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1737 | 1732 | ||
1738 | UpdateLandObject(localID, land.LandData); | 1733 | UpdateLandObject(localID, land.LandData); |
1739 | } | 1734 | } |
1735 | |||
1736 | public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID) | ||
1737 | { | ||
1738 | ILandObject land = null; | ||
1739 | List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels(); | ||
1740 | foreach (ILandObject landObject in Land) | ||
1741 | { | ||
1742 | if (landObject.LandData.LocalID == landID) | ||
1743 | { | ||
1744 | land = landObject; | ||
1745 | } | ||
1746 | } | ||
1747 | land.DeedToGroup(DefaultGodParcelGroup); | ||
1748 | land.LandData.Name = DefaultGodParcelName; | ||
1749 | land.SendLandUpdateToAvatarsOverMe(); | ||
1750 | } | ||
1751 | |||
1752 | private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID) | ||
1753 | { | ||
1754 | ScenePresence SP; | ||
1755 | ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP); | ||
1756 | List<SceneObjectGroup> returns = new List<SceneObjectGroup>(); | ||
1757 | if (SP.UserLevel != 0) | ||
1758 | { | ||
1759 | if (flags == 0) //All parcels, scripted or not | ||
1760 | { | ||
1761 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1762 | { | ||
1763 | if (e.OwnerID == targetID) | ||
1764 | { | ||
1765 | returns.Add(e); | ||
1766 | } | ||
1767 | } | ||
1768 | ); | ||
1769 | } | ||
1770 | if (flags == 4) //All parcels, scripted object | ||
1771 | { | ||
1772 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1773 | { | ||
1774 | if (e.OwnerID == targetID) | ||
1775 | { | ||
1776 | if (e.ContainsScripts()) | ||
1777 | { | ||
1778 | returns.Add(e); | ||
1779 | } | ||
1780 | } | ||
1781 | } | ||
1782 | ); | ||
1783 | } | ||
1784 | if (flags == 4) //not target parcel, scripted object | ||
1785 | { | ||
1786 | ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e) | ||
1787 | { | ||
1788 | if (e.OwnerID == targetID) | ||
1789 | { | ||
1790 | ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y); | ||
1791 | if (landobject.LandData.OwnerID != e.OwnerID) | ||
1792 | { | ||
1793 | if (e.ContainsScripts()) | ||
1794 | { | ||
1795 | returns.Add(e); | ||
1796 | } | ||
1797 | } | ||
1798 | } | ||
1799 | } | ||
1800 | ); | ||
1801 | } | ||
1802 | foreach (SceneObjectGroup ol in returns) | ||
1803 | { | ||
1804 | ReturnObject(ol, client); | ||
1805 | } | ||
1806 | } | ||
1807 | } | ||
1808 | public void ReturnObject(SceneObjectGroup obj, IClientAPI client) | ||
1809 | { | ||
1810 | SceneObjectGroup[] objs = new SceneObjectGroup[1]; | ||
1811 | objs[0] = obj; | ||
1812 | ((Scene)client.Scene).returnObjects(objs, client.AgentId); | ||
1813 | } | ||
1814 | |||
1815 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | ||
1816 | |||
1817 | public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
1818 | { | ||
1819 | ScenePresence targetAvatar = null; | ||
1820 | ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar); | ||
1821 | ScenePresence parcelManager = null; | ||
1822 | ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager); | ||
1823 | System.Threading.Timer Timer; | ||
1824 | |||
1825 | if (targetAvatar.UserLevel == 0) | ||
1826 | { | ||
1827 | ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y); | ||
1828 | if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze)) | ||
1829 | return; | ||
1830 | if (flags == 0) | ||
1831 | { | ||
1832 | targetAvatar.AllowMovement = false; | ||
1833 | targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world."); | ||
1834 | parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen."); | ||
1835 | System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen); | ||
1836 | Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0); | ||
1837 | Timers.Add(targetAvatar.UUID, Timer); | ||
1838 | } | ||
1839 | else | ||
1840 | { | ||
1841 | targetAvatar.AllowMovement = true; | ||
1842 | targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you."); | ||
1843 | parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen."); | ||
1844 | Timers.TryGetValue(targetAvatar.UUID, out Timer); | ||
1845 | Timers.Remove(targetAvatar.UUID); | ||
1846 | Timer.Dispose(); | ||
1847 | } | ||
1848 | } | ||
1849 | } | ||
1850 | private void OnEndParcelFrozen(object avatar) | ||
1851 | { | ||
1852 | ScenePresence targetAvatar = (ScenePresence)avatar; | ||
1853 | targetAvatar.AllowMovement = true; | ||
1854 | System.Threading.Timer Timer; | ||
1855 | Timers.TryGetValue(targetAvatar.UUID, out Timer); | ||
1856 | Timers.Remove(targetAvatar.UUID); | ||
1857 | targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false); | ||
1858 | } | ||
1859 | |||
1860 | |||
1861 | public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
1862 | { | ||
1863 | ScenePresence targetAvatar = null; | ||
1864 | ScenePresence parcelManager = null; | ||
1865 | |||
1866 | // Must have presences | ||
1867 | if (!m_scene.TryGetScenePresence(target, out targetAvatar) || | ||
1868 | !m_scene.TryGetScenePresence(client.AgentId, out parcelManager)) | ||
1869 | return; | ||
1870 | |||
1871 | // Cannot eject estate managers or gods | ||
1872 | if (m_scene.Permissions.IsAdministrator(target)) | ||
1873 | return; | ||
1874 | |||
1875 | // Check if you even have permission to do this | ||
1876 | ILandObject land = m_scene.LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y); | ||
1877 | if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) && | ||
1878 | !m_scene.Permissions.IsAdministrator(client.AgentId)) | ||
1879 | return; | ||
1880 | |||
1881 | Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); | ||
1882 | |||
1883 | targetAvatar.TeleportWithMomentum(pos, null); | ||
1884 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1885 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); | ||
1886 | |||
1887 | if ((flags & 1) != 0) // Ban TODO: Remove magic number | ||
1888 | { | ||
1889 | LandAccessEntry entry = new LandAccessEntry(); | ||
1890 | entry.AgentID = targetAvatar.UUID; | ||
1891 | entry.Flags = AccessList.Ban; | ||
1892 | entry.Expires = 0; // Perm | ||
1893 | |||
1894 | land.LandData.ParcelAccessList.Add(entry); | ||
1895 | } | ||
1896 | } | ||
1740 | 1897 | ||
1741 | protected void InstallInterfaces() | 1898 | protected void InstallInterfaces() |
1742 | { | 1899 | { |
@@ -1799,5 +1956,27 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1799 | 1956 | ||
1800 | MainConsole.Instance.Output(report.ToString()); | 1957 | MainConsole.Instance.Output(report.ToString()); |
1801 | } | 1958 | } |
1959 | |||
1960 | public void EnforceBans(ILandObject land, ScenePresence avatar) | ||
1961 | { | ||
1962 | if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT) | ||
1963 | return; | ||
1964 | |||
1965 | if (land.IsEitherBannedOrRestricted(avatar.UUID)) | ||
1966 | { | ||
1967 | if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y))) | ||
1968 | { | ||
1969 | Vector3? pos = m_scene.GetNearestAllowedPosition(avatar); | ||
1970 | if (pos == null) | ||
1971 | m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient); | ||
1972 | else | ||
1973 | ForceAvatarToPosition(avatar, (Vector3)pos); | ||
1974 | } | ||
1975 | else | ||
1976 | { | ||
1977 | ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition); | ||
1978 | } | ||
1979 | } | ||
1980 | } | ||
1802 | } | 1981 | } |
1803 | } | 1982 | } |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 5969d45..07d00c0 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -51,6 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
51 | private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; | 51 | private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; |
52 | 52 | ||
53 | private int m_lastSeqId = 0; | 53 | private int m_lastSeqId = 0; |
54 | private int m_expiryCounter = 0; | ||
54 | 55 | ||
55 | protected LandData m_landData = new LandData(); | 56 | protected LandData m_landData = new LandData(); |
56 | protected Scene m_scene; | 57 | protected Scene m_scene; |
@@ -136,6 +137,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
136 | else | 137 | else |
137 | LandData.GroupID = UUID.Zero; | 138 | LandData.GroupID = UUID.Zero; |
138 | LandData.IsGroupOwned = is_group_owned; | 139 | LandData.IsGroupOwned = is_group_owned; |
140 | |||
141 | m_scene.EventManager.OnFrame += OnFrame; | ||
139 | } | 142 | } |
140 | 143 | ||
141 | #endregion | 144 | #endregion |
@@ -194,10 +197,27 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
194 | else | 197 | else |
195 | { | 198 | { |
196 | // Normal Calculations | 199 | // Normal Calculations |
197 | int parcelMax = (int)(((float)LandData.Area / 65536.0f) | 200 | int parcelMax = (int)((long)LandData.Area |
198 | * (float)m_scene.RegionInfo.ObjectCapacity | 201 | * (long)m_scene.RegionInfo.ObjectCapacity |
199 | * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); | 202 | * (long)m_scene.RegionInfo.RegionSettings.ObjectBonus |
200 | // TODO: The calculation of ObjectBonus should be refactored. It does still not work in the same manner as SL! | 203 | / 65536L); |
204 | //m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_scene.RegionInfo.ObjectCapacity, m_scene.RegionInfo.RegionSettings.ObjectBonus, parcelMax); | ||
205 | return parcelMax; | ||
206 | } | ||
207 | } | ||
208 | |||
209 | private int GetParcelBasePrimCount() | ||
210 | { | ||
211 | if (overrideParcelMaxPrimCount != null) | ||
212 | { | ||
213 | return overrideParcelMaxPrimCount(this); | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | // Normal Calculations | ||
218 | int parcelMax = (int)((long)LandData.Area | ||
219 | * (long)m_scene.RegionInfo.ObjectCapacity | ||
220 | / 65536L); | ||
201 | return parcelMax; | 221 | return parcelMax; |
202 | } | 222 | } |
203 | } | 223 | } |
@@ -211,8 +231,9 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
211 | else | 231 | else |
212 | { | 232 | { |
213 | //Normal Calculations | 233 | //Normal Calculations |
214 | int simMax = (int)(((float)LandData.SimwideArea / 65536.0f) | 234 | int simMax = (int)((long)LandData.SimwideArea |
215 | * (float)m_scene.RegionInfo.ObjectCapacity); | 235 | * (long)m_scene.RegionInfo.ObjectCapacity / 65536L); |
236 | // m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}", LandData.SimwideArea, m_scene.RegionInfo.ObjectCapacity, simMax); | ||
216 | return simMax; | 237 | return simMax; |
217 | } | 238 | } |
218 | } | 239 | } |
@@ -249,7 +270,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
249 | remote_client.SendLandProperties(seq_id, | 270 | remote_client.SendLandProperties(seq_id, |
250 | snap_selection, request_result, this, | 271 | snap_selection, request_result, this, |
251 | (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, | 272 | (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, |
252 | GetParcelMaxPrimCount(), | 273 | GetParcelBasePrimCount(), |
253 | GetSimulatorMaxPrimCount(), regionFlags); | 274 | GetSimulatorMaxPrimCount(), regionFlags); |
254 | } | 275 | } |
255 | 276 | ||
@@ -309,7 +330,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
309 | 330 | ||
310 | allowedDelta |= (uint)(ParcelFlags.ShowDirectory | | 331 | allowedDelta |= (uint)(ParcelFlags.ShowDirectory | |
311 | ParcelFlags.AllowPublish | | 332 | ParcelFlags.AllowPublish | |
312 | ParcelFlags.MaturePublish); | 333 | ParcelFlags.MaturePublish) | (uint)(1 << 23); |
313 | } | 334 | } |
314 | 335 | ||
315 | if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) | 336 | if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) |
@@ -421,6 +442,19 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
421 | return false; | 442 | return false; |
422 | } | 443 | } |
423 | 444 | ||
445 | public bool CanBeOnThisLand(UUID avatar, float posHeight) | ||
446 | { | ||
447 | if (posHeight < LandChannel.BAN_LINE_SAFETY_HIEGHT && IsBannedFromLand(avatar)) | ||
448 | { | ||
449 | return false; | ||
450 | } | ||
451 | else if (IsRestrictedFromLand(avatar)) | ||
452 | { | ||
453 | return false; | ||
454 | } | ||
455 | return true; | ||
456 | } | ||
457 | |||
424 | public bool HasGroupAccess(UUID avatar) | 458 | public bool HasGroupAccess(UUID avatar) |
425 | { | 459 | { |
426 | if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup) | 460 | if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup) |
@@ -1185,6 +1219,17 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1185 | 1219 | ||
1186 | #endregion | 1220 | #endregion |
1187 | 1221 | ||
1222 | private void OnFrame() | ||
1223 | { | ||
1224 | m_expiryCounter++; | ||
1225 | |||
1226 | if (m_expiryCounter >= 50) | ||
1227 | { | ||
1228 | ExpireAccessList(); | ||
1229 | m_expiryCounter = 0; | ||
1230 | } | ||
1231 | } | ||
1232 | |||
1188 | private void ExpireAccessList() | 1233 | private void ExpireAccessList() |
1189 | { | 1234 | { |
1190 | List<LandAccessEntry> delete = new List<LandAccessEntry>(); | 1235 | List<LandAccessEntry> delete = new List<LandAccessEntry>(); |
@@ -1195,7 +1240,22 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1195 | delete.Add(entry); | 1240 | delete.Add(entry); |
1196 | } | 1241 | } |
1197 | foreach (LandAccessEntry entry in delete) | 1242 | foreach (LandAccessEntry entry in delete) |
1243 | { | ||
1198 | LandData.ParcelAccessList.Remove(entry); | 1244 | LandData.ParcelAccessList.Remove(entry); |
1245 | ScenePresence presence; | ||
1246 | |||
1247 | if (m_scene.TryGetScenePresence(entry.AgentID, out presence) && (!presence.IsChildAgent)) | ||
1248 | { | ||
1249 | ILandObject land = m_scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); | ||
1250 | if (land.LandData.LocalID == LandData.LocalID) | ||
1251 | { | ||
1252 | Vector3 pos = m_scene.GetNearestAllowedPosition(presence, land); | ||
1253 | presence.TeleportWithMomentum(pos, null); | ||
1254 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); | ||
1255 | } | ||
1256 | } | ||
1257 | m_log.DebugFormat("[LAND]: Removing entry {0} because it has expired", entry.AgentID); | ||
1258 | } | ||
1199 | 1259 | ||
1200 | if (delete.Count > 0) | 1260 | if (delete.Count > 0) |
1201 | m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this); | 1261 | m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this); |
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 9b51cc8..771fdd2 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | |||
@@ -207,7 +207,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
207 | if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) | 207 | if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) |
208 | { | 208 | { |
209 | UUID landOwner = landData.OwnerID; | 209 | UUID landOwner = landData.OwnerID; |
210 | int partCount = obj.Parts.Length; | 210 | int partCount = obj.GetPartCount(); |
211 | 211 | ||
212 | m_SimwideCounts[landOwner] += partCount; | 212 | m_SimwideCounts[landOwner] += partCount; |
213 | if (parcelCounts.Users.ContainsKey(obj.OwnerID)) | 213 | if (parcelCounts.Users.ContainsKey(obj.OwnerID)) |
@@ -597,4 +597,4 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
597 | } | 597 | } |
598 | } | 598 | } |
599 | } | 599 | } |
600 | } \ No newline at end of file | 600 | } |
diff --git a/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs index 4e20196..6f92ef6 100644 --- a/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs +++ b/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs | |||
@@ -190,6 +190,9 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
190 | 190 | ||
191 | public void SendProfileToClient(IClientAPI client, RegionLightShareData wl) | 191 | public void SendProfileToClient(IClientAPI client, RegionLightShareData wl) |
192 | { | 192 | { |
193 | if (client == null) | ||
194 | return; | ||
195 | |||
193 | if (m_enableWindlight) | 196 | if (m_enableWindlight) |
194 | { | 197 | { |
195 | if (m_scene.RegionInfo.WindlightSettings.valid) | 198 | if (m_scene.RegionInfo.WindlightSettings.valid) |
@@ -207,7 +210,8 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
207 | 210 | ||
208 | private void EventManager_OnMakeRootAgent(ScenePresence presence) | 211 | private void EventManager_OnMakeRootAgent(ScenePresence presence) |
209 | { | 212 | { |
210 | m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); | 213 | if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) |
214 | m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); | ||
211 | SendProfileToClient(presence.ControllingClient); | 215 | SendProfileToClient(presence.ControllingClient); |
212 | } | 216 | } |
213 | 217 | ||
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs index 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/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs index 249a40d..9c441ed 100644 --- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs +++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs | |||
@@ -29,6 +29,8 @@ using System; | |||
29 | using System.Linq; | 29 | using System.Linq; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Timers; | 31 | using System.Timers; |
32 | using System.IO; | ||
33 | using System.Diagnostics; | ||
32 | using System.Threading; | 34 | using System.Threading; |
33 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
34 | using log4net; | 36 | using log4net; |
@@ -57,13 +59,24 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
57 | protected UUID m_Initiator; | 59 | protected UUID m_Initiator; |
58 | protected bool m_Notice = false; | 60 | protected bool m_Notice = false; |
59 | protected IDialogModule m_DialogModule = null; | 61 | protected IDialogModule m_DialogModule = null; |
62 | protected string m_MarkerPath = String.Empty; | ||
63 | private int[] m_CurrentAlerts = null; | ||
60 | 64 | ||
61 | public void Initialise(IConfigSource config) | 65 | public void Initialise(IConfigSource config) |
62 | { | 66 | { |
67 | IConfig restartConfig = config.Configs["RestartModule"]; | ||
68 | if (restartConfig != null) | ||
69 | { | ||
70 | m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty); | ||
71 | } | ||
63 | } | 72 | } |
64 | 73 | ||
65 | public void AddRegion(Scene scene) | 74 | public void AddRegion(Scene scene) |
66 | { | 75 | { |
76 | if (m_MarkerPath != String.Empty) | ||
77 | File.Delete(Path.Combine(m_MarkerPath, | ||
78 | scene.RegionInfo.RegionID.ToString())); | ||
79 | |||
67 | m_Scene = scene; | 80 | m_Scene = scene; |
68 | 81 | ||
69 | scene.RegisterModuleInterface<IRestartModule>(this); | 82 | scene.RegisterModuleInterface<IRestartModule>(this); |
@@ -122,6 +135,7 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
122 | 135 | ||
123 | if (alerts == null) | 136 | if (alerts == null) |
124 | { | 137 | { |
138 | CreateMarkerFile(); | ||
125 | m_Scene.RestartNow(); | 139 | m_Scene.RestartNow(); |
126 | return; | 140 | return; |
127 | } | 141 | } |
@@ -129,25 +143,28 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
129 | m_Message = message; | 143 | m_Message = message; |
130 | m_Initiator = initiator; | 144 | m_Initiator = initiator; |
131 | m_Notice = notice; | 145 | m_Notice = notice; |
146 | m_CurrentAlerts = alerts; | ||
132 | m_Alerts = new List<int>(alerts); | 147 | m_Alerts = new List<int>(alerts); |
133 | m_Alerts.Sort(); | 148 | m_Alerts.Sort(); |
134 | m_Alerts.Reverse(); | 149 | m_Alerts.Reverse(); |
135 | 150 | ||
136 | if (m_Alerts[0] == 0) | 151 | if (m_Alerts[0] == 0) |
137 | { | 152 | { |
153 | CreateMarkerFile(); | ||
138 | m_Scene.RestartNow(); | 154 | m_Scene.RestartNow(); |
139 | return; | 155 | return; |
140 | } | 156 | } |
141 | 157 | ||
142 | int nextInterval = DoOneNotice(); | 158 | int nextInterval = DoOneNotice(true); |
143 | 159 | ||
144 | SetTimer(nextInterval); | 160 | SetTimer(nextInterval); |
145 | } | 161 | } |
146 | 162 | ||
147 | public int DoOneNotice() | 163 | public int DoOneNotice(bool sendOut) |
148 | { | 164 | { |
149 | if (m_Alerts.Count == 0 || m_Alerts[0] == 0) | 165 | if (m_Alerts.Count == 0 || m_Alerts[0] == 0) |
150 | { | 166 | { |
167 | CreateMarkerFile(); | ||
151 | m_Scene.RestartNow(); | 168 | m_Scene.RestartNow(); |
152 | return 0; | 169 | return 0; |
153 | } | 170 | } |
@@ -168,34 +185,37 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
168 | 185 | ||
169 | m_Alerts.RemoveAt(0); | 186 | m_Alerts.RemoveAt(0); |
170 | 187 | ||
171 | int minutes = currentAlert / 60; | 188 | if (sendOut) |
172 | string currentAlertString = String.Empty; | ||
173 | if (minutes > 0) | ||
174 | { | 189 | { |
175 | if (minutes == 1) | 190 | int minutes = currentAlert / 60; |
176 | currentAlertString += "1 minute"; | 191 | string currentAlertString = String.Empty; |
177 | else | 192 | if (minutes > 0) |
178 | currentAlertString += String.Format("{0} minutes", minutes); | 193 | { |
194 | if (minutes == 1) | ||
195 | currentAlertString += "1 minute"; | ||
196 | else | ||
197 | currentAlertString += String.Format("{0} minutes", minutes); | ||
198 | if ((currentAlert % 60) != 0) | ||
199 | currentAlertString += " and "; | ||
200 | } | ||
179 | if ((currentAlert % 60) != 0) | 201 | if ((currentAlert % 60) != 0) |
180 | currentAlertString += " and "; | 202 | { |
181 | } | 203 | int seconds = currentAlert % 60; |
182 | if ((currentAlert % 60) != 0) | 204 | if (seconds == 1) |
183 | { | 205 | currentAlertString += "1 second"; |
184 | int seconds = currentAlert % 60; | 206 | else |
185 | if (seconds == 1) | 207 | currentAlertString += String.Format("{0} seconds", seconds); |
186 | currentAlertString += "1 second"; | 208 | } |
187 | else | ||
188 | currentAlertString += String.Format("{0} seconds", seconds); | ||
189 | } | ||
190 | 209 | ||
191 | string msg = String.Format(m_Message, currentAlertString); | 210 | string msg = String.Format(m_Message, currentAlertString); |
192 | 211 | ||
193 | if (m_DialogModule != null && msg != String.Empty) | 212 | if (m_DialogModule != null && msg != String.Empty) |
194 | { | 213 | { |
195 | if (m_Notice) | 214 | if (m_Notice) |
196 | m_DialogModule.SendGeneralAlert(msg); | 215 | m_DialogModule.SendGeneralAlert(msg); |
197 | else | 216 | else |
198 | m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg); | 217 | m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg); |
218 | } | ||
199 | } | 219 | } |
200 | 220 | ||
201 | return currentAlert - nextAlert; | 221 | return currentAlert - nextAlert; |
@@ -212,7 +232,25 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
212 | 232 | ||
213 | private void OnTimer(object source, ElapsedEventArgs e) | 233 | private void OnTimer(object source, ElapsedEventArgs e) |
214 | { | 234 | { |
215 | int nextInterval = DoOneNotice(); | 235 | int nextInterval = DoOneNotice(true); |
236 | |||
237 | SetTimer(nextInterval); | ||
238 | } | ||
239 | |||
240 | public void DelayRestart(int seconds, string message) | ||
241 | { | ||
242 | if (m_CountdownTimer == null) | ||
243 | return; | ||
244 | |||
245 | m_CountdownTimer.Stop(); | ||
246 | m_CountdownTimer = null; | ||
247 | |||
248 | m_Alerts = new List<int>(m_CurrentAlerts); | ||
249 | m_Alerts.Add(seconds); | ||
250 | m_Alerts.Sort(); | ||
251 | m_Alerts.Reverse(); | ||
252 | |||
253 | int nextInterval = DoOneNotice(false); | ||
216 | 254 | ||
217 | SetTimer(nextInterval); | 255 | SetTimer(nextInterval); |
218 | } | 256 | } |
@@ -226,6 +264,9 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
226 | if (m_DialogModule != null && message != String.Empty) | 264 | if (m_DialogModule != null && message != String.Empty) |
227 | m_DialogModule.SendGeneralAlert(message); | 265 | m_DialogModule.SendGeneralAlert(message); |
228 | } | 266 | } |
267 | if (m_MarkerPath != String.Empty) | ||
268 | File.Delete(Path.Combine(m_MarkerPath, | ||
269 | m_Scene.RegionInfo.RegionID.ToString())); | ||
229 | } | 270 | } |
230 | 271 | ||
231 | private void HandleRegionRestart(string module, string[] args) | 272 | private void HandleRegionRestart(string module, string[] args) |
@@ -270,5 +311,25 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
270 | 311 | ||
271 | ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); | 312 | ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); |
272 | } | 313 | } |
314 | |||
315 | protected void CreateMarkerFile() | ||
316 | { | ||
317 | if (m_MarkerPath == String.Empty) | ||
318 | return; | ||
319 | |||
320 | string path = Path.Combine(m_MarkerPath, m_Scene.RegionInfo.RegionID.ToString()); | ||
321 | try | ||
322 | { | ||
323 | string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); | ||
324 | FileStream fs = File.Create(path); | ||
325 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | ||
326 | Byte[] buf = enc.GetBytes(pidstring); | ||
327 | fs.Write(buf, 0, buf.Length); | ||
328 | fs.Close(); | ||
329 | } | ||
330 | catch (Exception) | ||
331 | { | ||
332 | } | ||
333 | } | ||
273 | } | 334 | } |
274 | } \ No newline at end of file | 335 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index fd30c46..4d738a5 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -644,6 +644,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
644 | m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); | 644 | m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); |
645 | m_scene.SaveTerrain(); | 645 | m_scene.SaveTerrain(); |
646 | 646 | ||
647 | m_scene.EventManager.TriggerTerrainUpdate(); | ||
648 | |||
647 | // Clients who look at the map will never see changes after they looked at the map, so i've commented this out. | 649 | // Clients who look at the map will never see changes after they looked at the map, so i've commented this out. |
648 | //m_scene.CreateTerrainTexture(true); | 650 | //m_scene.CreateTerrainTexture(true); |
649 | } | 651 | } |
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index 5e0dfa7..7ef44db 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | |||
@@ -65,6 +65,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
65 | private bool m_useAntiAliasing = false; // TODO: Make this a config option | 65 | private bool m_useAntiAliasing = false; // TODO: Make this a config option |
66 | private bool m_Enabled = false; | 66 | private bool m_Enabled = false; |
67 | 67 | ||
68 | private Bitmap lastImage = null; | ||
69 | private DateTime lastImageTime = DateTime.MinValue; | ||
70 | |||
68 | #region Region Module interface | 71 | #region Region Module interface |
69 | 72 | ||
70 | public void Initialise(IConfigSource source) | 73 | public void Initialise(IConfigSource source) |
@@ -87,14 +90,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
87 | 90 | ||
88 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); | 91 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); |
89 | if (renderers.Count > 0) | 92 | if (renderers.Count > 0) |
90 | { | 93 | m_log.Info("[MAPTILE]: Loaded prim mesher " + renderers[0]); |
91 | m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); | ||
92 | m_log.DebugFormat("[WARP 3D IMAGE MODULE]: Loaded prim mesher {0}", m_primMesher); | ||
93 | } | ||
94 | else | 94 | else |
95 | { | 95 | m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); |
96 | m_log.Debug("[WARP 3D IMAGE MODULE]: No prim mesher loaded, prim rendering will be disabled"); | ||
97 | } | ||
98 | 96 | ||
99 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); | 97 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); |
100 | } | 98 | } |
@@ -127,9 +125,25 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
127 | 125 | ||
128 | public Bitmap CreateMapTile() | 126 | public Bitmap CreateMapTile() |
129 | { | 127 | { |
128 | if ((DateTime.Now - lastImageTime).TotalSeconds < 3600) | ||
129 | { | ||
130 | return lastImage.Clone(new Rectangle(0, 0, 256, 256), lastImage.PixelFormat); | ||
131 | } | ||
132 | |||
133 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); | ||
134 | if (renderers.Count > 0) | ||
135 | { | ||
136 | m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); | ||
137 | } | ||
138 | |||
130 | Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); | 139 | Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); |
131 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, (int)Constants.RegionSize, (int)Constants.RegionSize, (float)Constants.RegionSize, (float)Constants.RegionSize); | 140 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, (int)Constants.RegionSize, (int)Constants.RegionSize, (float)Constants.RegionSize, (float)Constants.RegionSize); |
132 | return CreateMapTile(viewport, false); | 141 | Bitmap tile = CreateMapTile(viewport, false); |
142 | m_primMesher = null; | ||
143 | |||
144 | lastImage = tile; | ||
145 | lastImageTime = DateTime.Now; | ||
146 | return lastImage.Clone(new Rectangle(0, 0, 256, 256), lastImage.PixelFormat); | ||
133 | } | 147 | } |
134 | 148 | ||
135 | public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures) | 149 | public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures) |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 708a9a2..4c96a50 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | |||
@@ -128,85 +128,93 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
128 | 128 | ||
129 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) | 129 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) |
130 | { | 130 | { |
131 | List<MapBlockData> blocks = new List<MapBlockData>(); | 131 | Util.FireAndForget(x => |
132 | MapBlockData data; | ||
133 | if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) | ||
134 | { | 132 | { |
133 | if (mapName.Length < 2) | ||
134 | { | ||
135 | remoteClient.SendAlertMessage("Use a search string with at least 2 characters"); | ||
136 | return; | ||
137 | } | ||
138 | |||
139 | //m_log.DebugFormat("MAP NAME=({0})", mapName); | ||
140 | |||
141 | // Hack to get around the fact that ll V3 now drops the port from the | ||
142 | // map name. See https://jira.secondlife.com/browse/VWR-28570 | ||
143 | // | ||
144 | // Caller, use this magic form instead: | ||
145 | // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 | ||
146 | // or url encode if possible. | ||
147 | // the hacks we do with this viewer... | ||
148 | // | ||
149 | string mapNameOrig = mapName; | ||
150 | if (mapName.Contains("|")) | ||
151 | mapName = mapName.Replace('|', ':'); | ||
152 | if (mapName.Contains("+")) | ||
153 | mapName = mapName.Replace('+', ' '); | ||
154 | if (mapName.Contains("!")) | ||
155 | mapName = mapName.Replace('!', '/'); | ||
156 | |||
157 | // try to fetch from GridServer | ||
158 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); | ||
159 | // if (regionInfos.Count == 0) | ||
160 | // remoteClient.SendAlertMessage("Hyperlink could not be established."); | ||
161 | |||
162 | //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); | ||
163 | List<MapBlockData> blocks = new List<MapBlockData>(); | ||
164 | |||
165 | MapBlockData data; | ||
166 | if (regionInfos.Count > 0) | ||
167 | { | ||
168 | foreach (GridRegion info in regionInfos) | ||
169 | { | ||
170 | data = new MapBlockData(); | ||
171 | data.Agents = 0; | ||
172 | data.Access = info.Access; | ||
173 | if (flags == 2) // V2 sends this | ||
174 | data.MapImageId = UUID.Zero; | ||
175 | else | ||
176 | data.MapImageId = info.TerrainImage; | ||
177 | // ugh! V2-3 is very sensitive about the result being | ||
178 | // exactly the same as the requested name | ||
179 | if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+")) | ||
180 | data.Name = mapNameOrig; | ||
181 | else | ||
182 | data.Name = info.RegionName; | ||
183 | data.RegionFlags = 0; // TODO not used? | ||
184 | data.WaterHeight = 0; // not used | ||
185 | data.X = (ushort)(info.RegionLocX / Constants.RegionSize); | ||
186 | data.Y = (ushort)(info.RegionLocY / Constants.RegionSize); | ||
187 | blocks.Add(data); | ||
188 | } | ||
189 | } | ||
190 | |||
135 | // final block, closing the search result | 191 | // final block, closing the search result |
136 | AddFinalBlock(blocks); | 192 | data = new MapBlockData(); |
193 | data.Agents = 0; | ||
194 | data.Access = 255; | ||
195 | data.MapImageId = UUID.Zero; | ||
196 | data.Name = mapName; | ||
197 | data.RegionFlags = 0; | ||
198 | data.WaterHeight = 0; // not used | ||
199 | data.X = 0; | ||
200 | data.Y = 0; | ||
201 | blocks.Add(data); | ||
137 | 202 | ||
138 | // flags are agent flags sent from the viewer. | 203 | // flags are agent flags sent from the viewer. |
139 | // they have different values depending on different viewers, apparently | 204 | // they have different values depending on different viewers, apparently |
140 | remoteClient.SendMapBlock(blocks, flags); | 205 | remoteClient.SendMapBlock(blocks, flags); |
141 | remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | 206 | ||
146 | //m_log.DebugFormat("MAP NAME=({0})", mapName); | 207 | // send extra user messages for V3 |
147 | 208 | // because the UI is very confusing | |
148 | // Hack to get around the fact that ll V3 now drops the port from the | 209 | // while we don't fix the hard-coded urls |
149 | // map name. See https://jira.secondlife.com/browse/VWR-28570 | 210 | if (flags == 2) |
150 | // | ||
151 | // Caller, use this magic form instead: | ||
152 | // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 | ||
153 | // or url encode if possible. | ||
154 | // the hacks we do with this viewer... | ||
155 | // | ||
156 | string mapNameOrig = mapName; | ||
157 | if (mapName.Contains("|")) | ||
158 | mapName = mapName.Replace('|', ':'); | ||
159 | if (mapName.Contains("+")) | ||
160 | mapName = mapName.Replace('+', ' '); | ||
161 | if (mapName.Contains("!")) | ||
162 | mapName = mapName.Replace('!', '/'); | ||
163 | |||
164 | // try to fetch from GridServer | ||
165 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); | ||
166 | |||
167 | m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); | ||
168 | if (regionInfos.Count > 0) | ||
169 | { | ||
170 | foreach (GridRegion info in regionInfos) | ||
171 | { | 211 | { |
172 | data = new MapBlockData(); | 212 | if (regionInfos.Count == 0) |
173 | data.Agents = 0; | 213 | remoteClient.SendAgentAlertMessage("No regions found with that name.", true); |
174 | data.Access = info.Access; | 214 | else if (regionInfos.Count == 1) |
175 | if (flags == 2) // V2 sends this | 215 | remoteClient.SendAgentAlertMessage("Region found!", false); |
176 | data.MapImageId = UUID.Zero; | ||
177 | else | ||
178 | data.MapImageId = info.TerrainImage; | ||
179 | // ugh! V2-3 is very sensitive about the result being | ||
180 | // exactly the same as the requested name | ||
181 | if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+")) | ||
182 | data.Name = mapNameOrig; | ||
183 | else | ||
184 | data.Name = info.RegionName; | ||
185 | data.RegionFlags = 0; // TODO not used? | ||
186 | data.WaterHeight = 0; // not used | ||
187 | data.X = (ushort)(info.RegionLocX / Constants.RegionSize); | ||
188 | data.Y = (ushort)(info.RegionLocY / Constants.RegionSize); | ||
189 | blocks.Add(data); | ||
190 | } | 216 | } |
191 | } | 217 | }); |
192 | |||
193 | // final block, closing the search result | ||
194 | AddFinalBlock(blocks); | ||
195 | |||
196 | // flags are agent flags sent from the viewer. | ||
197 | // they have different values depending on different viewers, apparently | ||
198 | remoteClient.SendMapBlock(blocks, flags); | ||
199 | |||
200 | // send extra user messages for V3 | ||
201 | // because the UI is very confusing | ||
202 | // while we don't fix the hard-coded urls | ||
203 | if (flags == 2) | ||
204 | { | ||
205 | if (regionInfos.Count == 0) | ||
206 | remoteClient.SendAlertMessage("No regions found with that name."); | ||
207 | else if (regionInfos.Count == 1) | ||
208 | remoteClient.SendAlertMessage("Region found!"); | ||
209 | } | ||
210 | } | 218 | } |
211 | 219 | ||
212 | private void AddFinalBlock(List<MapBlockData> blocks) | 220 | private void AddFinalBlock(List<MapBlockData> blocks) |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index e2f525c..2184a59 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -66,7 +66,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
66 | private static readonly UUID STOP_UUID = UUID.Random(); | 66 | private static readonly UUID STOP_UUID = UUID.Random(); |
67 | private static readonly string m_mapLayerPath = "0001/"; | 67 | private static readonly string m_mapLayerPath = "0001/"; |
68 | 68 | ||
69 | private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>(); | 69 | private ManualResetEvent queueEvent = new ManualResetEvent(false); |
70 | private Queue<MapRequestState> requests = new Queue<MapRequestState>(); | ||
71 | |||
72 | private ManualResetEvent m_mapBlockRequestEvent = new ManualResetEvent(false); | ||
73 | private Dictionary<UUID, Queue<MapBlockRequestData>> m_mapBlockRequests = new Dictionary<UUID, Queue<MapBlockRequestData>>(); | ||
70 | 74 | ||
71 | protected Scene m_scene; | 75 | protected Scene m_scene; |
72 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); | 76 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); |
@@ -74,7 +78,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
74 | private int blacklistTimeout = 10*60*1000; // 10 minutes | 78 | private int blacklistTimeout = 10*60*1000; // 10 minutes |
75 | private byte[] myMapImageJPEG; | 79 | private byte[] myMapImageJPEG; |
76 | protected volatile bool m_Enabled = false; | 80 | protected volatile bool m_Enabled = false; |
77 | private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>(); | ||
78 | private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); | 81 | private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); |
79 | private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); | 82 | private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); |
80 | private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>(); | 83 | private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>(); |
@@ -231,54 +234,54 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
231 | // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is | 234 | // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is |
232 | // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. | 235 | // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. |
233 | 236 | ||
234 | if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) | 237 | //if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) |
235 | { | 238 | //{ |
236 | ScenePresence avatarPresence = null; | 239 | // ScenePresence avatarPresence = null; |
237 | 240 | ||
238 | m_scene.TryGetScenePresence(agentID, out avatarPresence); | 241 | // m_scene.TryGetScenePresence(agentID, out avatarPresence); |
239 | 242 | ||
240 | if (avatarPresence != null) | 243 | // if (avatarPresence != null) |
241 | { | 244 | // { |
242 | bool lookup = false; | 245 | // bool lookup = false; |
243 | 246 | ||
244 | lock (cachedMapBlocks) | 247 | // lock (cachedMapBlocks) |
245 | { | 248 | // { |
246 | if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) | 249 | // if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) |
247 | { | 250 | // { |
248 | List<MapBlockData> mapBlocks; | 251 | // List<MapBlockData> mapBlocks; |
249 | 252 | ||
250 | mapBlocks = cachedMapBlocks; | 253 | // mapBlocks = cachedMapBlocks; |
251 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); | 254 | // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); |
252 | } | 255 | // } |
253 | else | 256 | // else |
254 | { | 257 | // { |
255 | lookup = true; | 258 | // lookup = true; |
256 | } | 259 | // } |
257 | } | 260 | // } |
258 | if (lookup) | 261 | // if (lookup) |
259 | { | 262 | // { |
260 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; | 263 | // List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; |
261 | 264 | ||
262 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | 265 | // List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
263 | (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, | 266 | // (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, |
264 | (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, | 267 | // (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, |
265 | (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, | 268 | // (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, |
266 | (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); | 269 | // (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); |
267 | foreach (GridRegion r in regions) | 270 | // foreach (GridRegion r in regions) |
268 | { | 271 | // { |
269 | MapBlockData block = new MapBlockData(); | 272 | // MapBlockData block = new MapBlockData(); |
270 | MapBlockFromGridRegion(block, r, 0); | 273 | // MapBlockFromGridRegion(block, r, 0); |
271 | mapBlocks.Add(block); | 274 | // mapBlocks.Add(block); |
272 | } | 275 | // } |
273 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); | 276 | // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); |
274 | 277 | ||
275 | lock (cachedMapBlocks) | 278 | // lock (cachedMapBlocks) |
276 | cachedMapBlocks = mapBlocks; | 279 | // cachedMapBlocks = mapBlocks; |
277 | 280 | ||
278 | cachedTime = Util.UnixTimeSinceEpoch(); | 281 | // cachedTime = Util.UnixTimeSinceEpoch(); |
279 | } | 282 | // } |
280 | } | 283 | // } |
281 | } | 284 | //} |
282 | 285 | ||
283 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); | 286 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); |
284 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); | 287 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); |
@@ -305,8 +308,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
305 | protected static OSDMapLayer GetOSDMapLayerResponse() | 308 | protected static OSDMapLayer GetOSDMapLayerResponse() |
306 | { | 309 | { |
307 | OSDMapLayer mapLayer = new OSDMapLayer(); | 310 | OSDMapLayer mapLayer = new OSDMapLayer(); |
308 | mapLayer.Right = 5000; | 311 | mapLayer.Right = 2048; |
309 | mapLayer.Top = 5000; | 312 | mapLayer.Top = 2048; |
310 | mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); | 313 | mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); |
311 | 314 | ||
312 | return mapLayer; | 315 | return mapLayer; |
@@ -335,6 +338,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
335 | { | 338 | { |
336 | m_rootAgents.Remove(AgentId); | 339 | m_rootAgents.Remove(AgentId); |
337 | } | 340 | } |
341 | lock (m_mapBlockRequestEvent) | ||
342 | { | ||
343 | if (m_mapBlockRequests.ContainsKey(AgentId)) | ||
344 | m_mapBlockRequests.Remove(AgentId); | ||
345 | } | ||
338 | } | 346 | } |
339 | #endregion | 347 | #endregion |
340 | 348 | ||
@@ -357,6 +365,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
357 | ThreadPriority.BelowNormal, | 365 | ThreadPriority.BelowNormal, |
358 | true, | 366 | true, |
359 | true); | 367 | true); |
368 | Watchdog.StartThread( | ||
369 | MapBlockSendThread, | ||
370 | string.Format("MapBlockSendThread ({0})", m_scene.RegionInfo.RegionName), | ||
371 | ThreadPriority.BelowNormal, | ||
372 | true, | ||
373 | true); | ||
360 | } | 374 | } |
361 | 375 | ||
362 | /// <summary> | 376 | /// <summary> |
@@ -372,7 +386,27 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
372 | st.itemtype=0; | 386 | st.itemtype=0; |
373 | st.regionhandle=0; | 387 | st.regionhandle=0; |
374 | 388 | ||
375 | requests.Enqueue(st); | 389 | lock (requests) |
390 | { | ||
391 | queueEvent.Set(); | ||
392 | requests.Enqueue(st); | ||
393 | } | ||
394 | |||
395 | MapBlockRequestData req = new MapBlockRequestData(); | ||
396 | |||
397 | req.client = null; | ||
398 | req.minX = 0; | ||
399 | req.maxX = 0; | ||
400 | req.minY = 0; | ||
401 | req.maxY = 0; | ||
402 | req.flags = 0; | ||
403 | |||
404 | lock (m_mapBlockRequestEvent) | ||
405 | { | ||
406 | m_mapBlockRequests[UUID.Zero] = new Queue<MapBlockRequestData>(); | ||
407 | m_mapBlockRequests[UUID.Zero].Enqueue(req); | ||
408 | m_mapBlockRequestEvent.Set(); | ||
409 | } | ||
376 | } | 410 | } |
377 | 411 | ||
378 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, | 412 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, |
@@ -528,7 +562,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
528 | { | 562 | { |
529 | while (true) | 563 | while (true) |
530 | { | 564 | { |
531 | MapRequestState st = requests.Dequeue(1000); | 565 | MapRequestState st = new MapRequestState(); |
566 | bool valid = false; | ||
567 | queueEvent.WaitOne(); | ||
568 | lock (requests) | ||
569 | { | ||
570 | if (requests.Count > 0) | ||
571 | { | ||
572 | st = requests.Dequeue(); | ||
573 | valid = true; | ||
574 | } | ||
575 | if (requests.Count == 0) | ||
576 | queueEvent.Reset(); | ||
577 | } | ||
578 | if (!valid) | ||
579 | continue; | ||
532 | 580 | ||
533 | // end gracefully | 581 | // end gracefully |
534 | if (st.agentID == STOP_UUID) | 582 | if (st.agentID == STOP_UUID) |
@@ -546,13 +594,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
546 | if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) | 594 | if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) |
547 | { | 595 | { |
548 | while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break | 596 | while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break |
549 | Thread.Sleep(80); | 597 | Thread.Sleep(100); |
550 | 598 | ||
551 | RequestMapItemsDelegate d = RequestMapItemsAsync; | ||
552 | d.BeginInvoke(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle, RequestMapItemsCompleted, null); | ||
553 | //OSDMap response = RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); | ||
554 | //RequestMapItemsCompleted(response); | ||
555 | Interlocked.Increment(ref nAsyncRequests); | 599 | Interlocked.Increment(ref nAsyncRequests); |
600 | Util.FireAndForget(x => | ||
601 | { | ||
602 | RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); | ||
603 | }); | ||
556 | } | 604 | } |
557 | } | 605 | } |
558 | 606 | ||
@@ -574,110 +622,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
574 | /// <param name="state"></param> | 622 | /// <param name="state"></param> |
575 | public void EnqueueMapItemRequest(MapRequestState state) | 623 | public void EnqueueMapItemRequest(MapRequestState state) |
576 | { | 624 | { |
577 | requests.Enqueue(state); | 625 | lock (requests) |
578 | } | ||
579 | |||
580 | /// <summary> | ||
581 | /// Sends the mapitem response to the IClientAPI | ||
582 | /// </summary> | ||
583 | /// <param name="response">The OSDMap Response for the mapitem</param> | ||
584 | private void RequestMapItemsCompleted(IAsyncResult iar) | ||
585 | { | ||
586 | AsyncResult result = (AsyncResult)iar; | ||
587 | RequestMapItemsDelegate icon = (RequestMapItemsDelegate)result.AsyncDelegate; | ||
588 | |||
589 | OSDMap response = (OSDMap)icon.EndInvoke(iar); | ||
590 | |||
591 | Interlocked.Decrement(ref nAsyncRequests); | ||
592 | |||
593 | if (!response.ContainsKey("requestID")) | ||
594 | return; | ||
595 | |||
596 | UUID requestID = response["requestID"].AsUUID(); | ||
597 | |||
598 | if (requestID != UUID.Zero) | ||
599 | { | 626 | { |
600 | MapRequestState mrs = new MapRequestState(); | 627 | queueEvent.Set(); |
601 | mrs.agentID = UUID.Zero; | 628 | requests.Enqueue(state); |
602 | lock (m_openRequests) | ||
603 | { | ||
604 | if (m_openRequests.ContainsKey(requestID)) | ||
605 | { | ||
606 | mrs = m_openRequests[requestID]; | ||
607 | m_openRequests.Remove(requestID); | ||
608 | } | ||
609 | } | ||
610 | |||
611 | if (mrs.agentID != UUID.Zero) | ||
612 | { | ||
613 | ScenePresence av = null; | ||
614 | m_scene.TryGetScenePresence(mrs.agentID, out av); | ||
615 | if (av != null) | ||
616 | { | ||
617 | if (response.ContainsKey(mrs.itemtype.ToString())) | ||
618 | { | ||
619 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
620 | OSDArray itemarray = (OSDArray)response[mrs.itemtype.ToString()]; | ||
621 | for (int i = 0; i < itemarray.Count; i++) | ||
622 | { | ||
623 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
624 | mapItemReply mi = new mapItemReply(); | ||
625 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
626 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
627 | mi.id = mapitem["ID"].AsUUID(); | ||
628 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
629 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
630 | mi.name = mapitem["Name"].AsString(); | ||
631 | returnitems.Add(mi); | ||
632 | } | ||
633 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags); | ||
634 | } | ||
635 | |||
636 | // Service 7 (MAP_ITEM_LAND_FOR_SALE) | ||
637 | uint itemtype = 7; | ||
638 | |||
639 | if (response.ContainsKey(itemtype.ToString())) | ||
640 | { | ||
641 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
642 | OSDArray itemarray = (OSDArray)response[itemtype.ToString()]; | ||
643 | for (int i = 0; i < itemarray.Count; i++) | ||
644 | { | ||
645 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
646 | mapItemReply mi = new mapItemReply(); | ||
647 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
648 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
649 | mi.id = mapitem["ID"].AsUUID(); | ||
650 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
651 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
652 | mi.name = mapitem["Name"].AsString(); | ||
653 | returnitems.Add(mi); | ||
654 | } | ||
655 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); | ||
656 | } | ||
657 | |||
658 | // Service 1 (MAP_ITEM_TELEHUB) | ||
659 | itemtype = 1; | ||
660 | |||
661 | if (response.ContainsKey(itemtype.ToString())) | ||
662 | { | ||
663 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
664 | OSDArray itemarray = (OSDArray)response[itemtype.ToString()]; | ||
665 | for (int i = 0; i < itemarray.Count; i++) | ||
666 | { | ||
667 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
668 | mapItemReply mi = new mapItemReply(); | ||
669 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
670 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
671 | mi.id = mapitem["ID"].AsUUID(); | ||
672 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
673 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
674 | mi.name = mapitem["Name"].AsString(); | ||
675 | returnitems.Add(mi); | ||
676 | } | ||
677 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); | ||
678 | } | ||
679 | } | ||
680 | } | ||
681 | } | 629 | } |
682 | } | 630 | } |
683 | 631 | ||
@@ -704,8 +652,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
704 | EnqueueMapItemRequest(st); | 652 | EnqueueMapItemRequest(st); |
705 | } | 653 | } |
706 | 654 | ||
707 | private delegate OSDMap RequestMapItemsDelegate(UUID id, uint flags, | ||
708 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle); | ||
709 | /// <summary> | 655 | /// <summary> |
710 | /// Does the actual remote mapitem request | 656 | /// Does the actual remote mapitem request |
711 | /// This should be called from an asynchronous thread | 657 | /// This should be called from an asynchronous thread |
@@ -720,7 +666,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
720 | /// <param name="itemtype">passed in from packet</param> | 666 | /// <param name="itemtype">passed in from packet</param> |
721 | /// <param name="regionhandle">Region we're looking up</param> | 667 | /// <param name="regionhandle">Region we're looking up</param> |
722 | /// <returns></returns> | 668 | /// <returns></returns> |
723 | private OSDMap RequestMapItemsAsync(UUID id, uint flags, | 669 | private void RequestMapItemsAsync(UUID id, uint flags, |
724 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) | 670 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) |
725 | { | 671 | { |
726 | // m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); | 672 | // m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); |
@@ -743,7 +689,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
743 | } | 689 | } |
744 | 690 | ||
745 | if (blacklisted) | 691 | if (blacklisted) |
746 | return new OSDMap(); | 692 | { |
693 | Interlocked.Decrement(ref nAsyncRequests); | ||
694 | return; | ||
695 | } | ||
747 | 696 | ||
748 | UUID requestID = UUID.Random(); | 697 | UUID requestID = UUID.Random(); |
749 | lock (m_cachedRegionMapItemsAddress) | 698 | lock (m_cachedRegionMapItemsAddress) |
@@ -751,6 +700,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
751 | if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) | 700 | if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) |
752 | httpserver = m_cachedRegionMapItemsAddress[regionhandle]; | 701 | httpserver = m_cachedRegionMapItemsAddress[regionhandle]; |
753 | } | 702 | } |
703 | |||
754 | if (httpserver.Length == 0) | 704 | if (httpserver.Length == 0) |
755 | { | 705 | { |
756 | uint x = 0, y = 0; | 706 | uint x = 0, y = 0; |
@@ -795,18 +745,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
795 | 745 | ||
796 | // Can't find the http server | 746 | // Can't find the http server |
797 | if (httpserver.Length == 0 || blacklisted) | 747 | if (httpserver.Length == 0 || blacklisted) |
798 | return new OSDMap(); | 748 | { |
799 | 749 | Interlocked.Decrement(ref nAsyncRequests); | |
800 | MapRequestState mrs = new MapRequestState(); | 750 | return; |
801 | mrs.agentID = id; | 751 | } |
802 | mrs.EstateID = EstateID; | ||
803 | mrs.flags = flags; | ||
804 | mrs.godlike = godlike; | ||
805 | mrs.itemtype=itemtype; | ||
806 | mrs.regionhandle = regionhandle; | ||
807 | |||
808 | lock (m_openRequests) | ||
809 | m_openRequests.Add(requestID, mrs); | ||
810 | 752 | ||
811 | WebRequest mapitemsrequest = null; | 753 | WebRequest mapitemsrequest = null; |
812 | try | 754 | try |
@@ -816,7 +758,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
816 | catch (Exception e) | 758 | catch (Exception e) |
817 | { | 759 | { |
818 | m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e); | 760 | m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e); |
819 | return new OSDMap(); | 761 | Interlocked.Decrement(ref nAsyncRequests); |
762 | return; | ||
820 | } | 763 | } |
821 | 764 | ||
822 | mapitemsrequest.Method = "POST"; | 765 | mapitemsrequest.Method = "POST"; |
@@ -841,7 +784,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
841 | catch (WebException ex) | 784 | catch (WebException ex) |
842 | { | 785 | { |
843 | m_log.WarnFormat("[WORLD MAP]: Bad send on GetMapItems {0}", ex.Message); | 786 | m_log.WarnFormat("[WORLD MAP]: Bad send on GetMapItems {0}", ex.Message); |
844 | responseMap["connect"] = OSD.FromBoolean(false); | ||
845 | lock (m_blacklistedurls) | 787 | lock (m_blacklistedurls) |
846 | { | 788 | { |
847 | if (!m_blacklistedurls.ContainsKey(httpserver)) | 789 | if (!m_blacklistedurls.ContainsKey(httpserver)) |
@@ -850,13 +792,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
850 | 792 | ||
851 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); | 793 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); |
852 | 794 | ||
853 | return responseMap; | 795 | Interlocked.Decrement(ref nAsyncRequests); |
796 | return; | ||
854 | } | 797 | } |
855 | catch | 798 | catch |
856 | { | 799 | { |
857 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); | 800 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); |
858 | responseMap["connect"] = OSD.FromBoolean(false); | 801 | Interlocked.Decrement(ref nAsyncRequests); |
859 | return responseMap; | 802 | return; |
860 | } | 803 | } |
861 | finally | 804 | finally |
862 | { | 805 | { |
@@ -877,12 +820,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
877 | } | 820 | } |
878 | else | 821 | else |
879 | { | 822 | { |
880 | return new OSDMap(); | 823 | Interlocked.Decrement(ref nAsyncRequests); |
824 | return; | ||
881 | } | 825 | } |
882 | } | 826 | } |
883 | catch (WebException) | 827 | catch (WebException) |
884 | { | 828 | { |
885 | responseMap["connect"] = OSD.FromBoolean(false); | ||
886 | lock (m_blacklistedurls) | 829 | lock (m_blacklistedurls) |
887 | { | 830 | { |
888 | if (!m_blacklistedurls.ContainsKey(httpserver)) | 831 | if (!m_blacklistedurls.ContainsKey(httpserver)) |
@@ -891,19 +834,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
891 | 834 | ||
892 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); | 835 | m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); |
893 | 836 | ||
894 | return responseMap; | 837 | Interlocked.Decrement(ref nAsyncRequests); |
838 | return; | ||
895 | } | 839 | } |
896 | catch | 840 | catch |
897 | { | 841 | { |
898 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); | 842 | m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); |
899 | responseMap["connect"] = OSD.FromBoolean(false); | ||
900 | lock (m_blacklistedregions) | 843 | lock (m_blacklistedregions) |
901 | { | 844 | { |
902 | if (!m_blacklistedregions.ContainsKey(regionhandle)) | 845 | if (!m_blacklistedregions.ContainsKey(regionhandle)) |
903 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); | 846 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); |
904 | } | 847 | } |
905 | 848 | ||
906 | return responseMap; | 849 | Interlocked.Decrement(ref nAsyncRequests); |
850 | return; | ||
907 | } | 851 | } |
908 | finally | 852 | finally |
909 | { | 853 | { |
@@ -922,14 +866,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
922 | catch (Exception ex) | 866 | catch (Exception ex) |
923 | { | 867 | { |
924 | m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); | 868 | m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); |
925 | responseMap["connect"] = OSD.FromBoolean(false); | ||
926 | lock (m_blacklistedregions) | 869 | lock (m_blacklistedregions) |
927 | { | 870 | { |
928 | if (!m_blacklistedregions.ContainsKey(regionhandle)) | 871 | if (!m_blacklistedregions.ContainsKey(regionhandle)) |
929 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); | 872 | m_blacklistedregions.Add(regionhandle, Environment.TickCount); |
930 | } | 873 | } |
931 | 874 | ||
932 | return responseMap; | 875 | Interlocked.Decrement(ref nAsyncRequests); |
876 | return; | ||
933 | } | 877 | } |
934 | } | 878 | } |
935 | 879 | ||
@@ -943,7 +887,78 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
943 | } | 887 | } |
944 | } | 888 | } |
945 | 889 | ||
946 | return responseMap; | 890 | Interlocked.Decrement(ref nAsyncRequests); |
891 | |||
892 | if (id != UUID.Zero) | ||
893 | { | ||
894 | ScenePresence av = null; | ||
895 | m_scene.TryGetScenePresence(id, out av); | ||
896 | if (av != null) | ||
897 | { | ||
898 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
899 | { | ||
900 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
901 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
902 | for (int i = 0; i < itemarray.Count; i++) | ||
903 | { | ||
904 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
905 | mapItemReply mi = new mapItemReply(); | ||
906 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
907 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
908 | mi.id = mapitem["ID"].AsUUID(); | ||
909 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
910 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
911 | mi.name = mapitem["Name"].AsString(); | ||
912 | returnitems.Add(mi); | ||
913 | } | ||
914 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
915 | } | ||
916 | |||
917 | // Service 7 (MAP_ITEM_LAND_FOR_SALE) | ||
918 | itemtype = 7; | ||
919 | |||
920 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
921 | { | ||
922 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
923 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
924 | for (int i = 0; i < itemarray.Count; i++) | ||
925 | { | ||
926 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
927 | mapItemReply mi = new mapItemReply(); | ||
928 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
929 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
930 | mi.id = mapitem["ID"].AsUUID(); | ||
931 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
932 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
933 | mi.name = mapitem["Name"].AsString(); | ||
934 | returnitems.Add(mi); | ||
935 | } | ||
936 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
937 | } | ||
938 | |||
939 | // Service 1 (MAP_ITEM_TELEHUB) | ||
940 | itemtype = 1; | ||
941 | |||
942 | if (responseMap.ContainsKey(itemtype.ToString())) | ||
943 | { | ||
944 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
945 | OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; | ||
946 | for (int i = 0; i < itemarray.Count; i++) | ||
947 | { | ||
948 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
949 | mapItemReply mi = new mapItemReply(); | ||
950 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
951 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
952 | mi.id = mapitem["ID"].AsUUID(); | ||
953 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
954 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
955 | mi.name = mapitem["Name"].AsString(); | ||
956 | returnitems.Add(mi); | ||
957 | } | ||
958 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); | ||
959 | } | ||
960 | } | ||
961 | } | ||
947 | } | 962 | } |
948 | 963 | ||
949 | /// <summary> | 964 | /// <summary> |
@@ -953,7 +968,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
953 | /// <param name="minY"></param> | 968 | /// <param name="minY"></param> |
954 | /// <param name="maxX"></param> | 969 | /// <param name="maxX"></param> |
955 | /// <param name="maxY"></param> | 970 | /// <param name="maxY"></param> |
956 | public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 971 | public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) |
957 | { | 972 | { |
958 | //m_log.ErrorFormat("[YYY] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag); | 973 | //m_log.ErrorFormat("[YYY] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag); |
959 | if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible | 974 | if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible |
@@ -1006,21 +1021,91 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1006 | 1021 | ||
1007 | protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 1022 | protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) |
1008 | { | 1023 | { |
1024 | MapBlockRequestData req = new MapBlockRequestData(); | ||
1025 | |||
1026 | req.client = remoteClient; | ||
1027 | req.minX = minX; | ||
1028 | req.maxX = maxX; | ||
1029 | req.minY = minY; | ||
1030 | req.maxY = maxY; | ||
1031 | req.flags = flag; | ||
1032 | |||
1033 | lock (m_mapBlockRequestEvent) | ||
1034 | { | ||
1035 | if (!m_mapBlockRequests.ContainsKey(remoteClient.AgentId)) | ||
1036 | m_mapBlockRequests[remoteClient.AgentId] = new Queue<MapBlockRequestData>(); | ||
1037 | m_mapBlockRequests[remoteClient.AgentId].Enqueue(req); | ||
1038 | m_mapBlockRequestEvent.Set(); | ||
1039 | } | ||
1040 | |||
1041 | return new List<MapBlockData>(); | ||
1042 | } | ||
1043 | |||
1044 | protected void MapBlockSendThread() | ||
1045 | { | ||
1046 | while (true) | ||
1047 | { | ||
1048 | List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>(); | ||
1049 | |||
1050 | m_mapBlockRequestEvent.WaitOne(); | ||
1051 | lock (m_mapBlockRequestEvent) | ||
1052 | { | ||
1053 | int total = 0; | ||
1054 | foreach (Queue<MapBlockRequestData> q in m_mapBlockRequests.Values) | ||
1055 | { | ||
1056 | if (q.Count > 0) | ||
1057 | thisRunData.Add(q.Dequeue()); | ||
1058 | |||
1059 | total += q.Count; | ||
1060 | } | ||
1061 | |||
1062 | if (total == 0) | ||
1063 | m_mapBlockRequestEvent.Reset(); | ||
1064 | } | ||
1065 | |||
1066 | foreach (MapBlockRequestData req in thisRunData) | ||
1067 | { | ||
1068 | // Null client stops thread | ||
1069 | if (req.client == null) | ||
1070 | return; | ||
1071 | |||
1072 | GetAndSendBlocksInternal(req.client, req.minX, req.minY, req.maxX, req.maxY, req.flags); | ||
1073 | } | ||
1074 | |||
1075 | Thread.Sleep(50); | ||
1076 | } | ||
1077 | } | ||
1078 | |||
1079 | protected virtual List<MapBlockData> GetAndSendBlocksInternal(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | ||
1080 | { | ||
1081 | List<MapBlockData> allBlocks = new List<MapBlockData>(); | ||
1009 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); | 1082 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); |
1010 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | 1083 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
1011 | (minX - 4) * (int)Constants.RegionSize, | 1084 | minX * (int)Constants.RegionSize, |
1012 | (maxX + 4) * (int)Constants.RegionSize, | 1085 | maxX * (int)Constants.RegionSize, |
1013 | (minY - 4) * (int)Constants.RegionSize, | 1086 | minY * (int)Constants.RegionSize, |
1014 | (maxY + 4) * (int)Constants.RegionSize); | 1087 | maxY * (int)Constants.RegionSize); |
1088 | // (minX - 4) * (int)Constants.RegionSize, | ||
1089 | // (maxX + 4) * (int)Constants.RegionSize, | ||
1090 | // (minY - 4) * (int)Constants.RegionSize, | ||
1091 | // (maxY + 4) * (int)Constants.RegionSize); | ||
1015 | foreach (GridRegion r in regions) | 1092 | foreach (GridRegion r in regions) |
1016 | { | 1093 | { |
1017 | MapBlockData block = new MapBlockData(); | 1094 | MapBlockData block = new MapBlockData(); |
1018 | MapBlockFromGridRegion(block, r, flag); | 1095 | MapBlockFromGridRegion(block, r, flag); |
1019 | mapBlocks.Add(block); | 1096 | mapBlocks.Add(block); |
1097 | allBlocks.Add(block); | ||
1098 | if (mapBlocks.Count >= 10) | ||
1099 | { | ||
1100 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | ||
1101 | mapBlocks.Clear(); | ||
1102 | Thread.Sleep(50); | ||
1103 | } | ||
1020 | } | 1104 | } |
1021 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | 1105 | if (mapBlocks.Count > 0) |
1106 | remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); | ||
1022 | 1107 | ||
1023 | return mapBlocks; | 1108 | return allBlocks; |
1024 | } | 1109 | } |
1025 | 1110 | ||
1026 | protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) | 1111 | protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) |
@@ -1244,7 +1329,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1244 | } | 1329 | } |
1245 | else | 1330 | else |
1246 | { | 1331 | { |
1247 | OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); | 1332 | OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount()); |
1248 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 1333 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
1249 | { | 1334 | { |
1250 | OSDMap responsemapdata = new OSDMap(); | 1335 | OSDMap responsemapdata = new OSDMap(); |
@@ -1420,6 +1505,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1420 | { | 1505 | { |
1421 | m_rootAgents.Remove(avatar.UUID); | 1506 | m_rootAgents.Remove(avatar.UUID); |
1422 | } | 1507 | } |
1508 | |||
1509 | lock (m_mapBlockRequestEvent) | ||
1510 | { | ||
1511 | if (m_mapBlockRequests.ContainsKey(avatar.UUID)) | ||
1512 | m_mapBlockRequests.Remove(avatar.UUID); | ||
1513 | } | ||
1423 | } | 1514 | } |
1424 | 1515 | ||
1425 | public void OnRegionUp(GridRegion otherRegion) | 1516 | public void OnRegionUp(GridRegion otherRegion) |
@@ -1464,9 +1555,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1464 | Color background = Color.FromArgb(0, 0, 0, 0); | 1555 | Color background = Color.FromArgb(0, 0, 0, 0); |
1465 | SolidBrush transparent = new SolidBrush(background); | 1556 | SolidBrush transparent = new SolidBrush(background); |
1466 | Graphics g = Graphics.FromImage(overlay); | 1557 | Graphics g = Graphics.FromImage(overlay); |
1467 | g.FillRectangle(transparent, 0, 0, 256, 256); | 1558 | g.FillRectangle(transparent, 0, 0, 255, 255); |
1468 | 1559 | ||
1469 | SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); | 1560 | SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); |
1561 | Pen grey = new Pen(Color.FromArgb(255, 92, 92, 92)); | ||
1470 | 1562 | ||
1471 | foreach (ILandObject land in parcels) | 1563 | foreach (ILandObject land in parcels) |
1472 | { | 1564 | { |
@@ -1474,8 +1566,42 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1474 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) | 1566 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) |
1475 | { | 1567 | { |
1476 | landForSale = true; | 1568 | landForSale = true; |
1569 | |||
1570 | bool[,] landBitmap = land.GetLandBitmap(); | ||
1571 | |||
1572 | for (int x = 0 ; x < 64 ; x++) | ||
1573 | { | ||
1574 | for (int y = 0 ; y < 64 ; y++) | ||
1575 | { | ||
1576 | if (landBitmap[x, y]) | ||
1577 | { | ||
1578 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | ||
1579 | |||
1580 | if (x > 0) | ||
1581 | { | ||
1582 | if ((saleBitmap[x - 1, y] || landBitmap[x - 1, y]) == false) | ||
1583 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4, 255 - (y * 4)); | ||
1584 | } | ||
1585 | if (y > 0) | ||
1586 | { | ||
1587 | if ((saleBitmap[x, y-1] || landBitmap[x, y-1]) == false) | ||
1588 | g.DrawLine(grey, x * 4, 255 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1589 | } | ||
1590 | if (x < 63) | ||
1591 | { | ||
1592 | if ((saleBitmap[x + 1, y] || landBitmap[x + 1, y]) == false) | ||
1593 | g.DrawLine(grey, x * 4 + 3, 252 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1594 | } | ||
1595 | if (y < 63) | ||
1596 | { | ||
1597 | if ((saleBitmap[x, y + 1] || landBitmap[x, y + 1]) == false) | ||
1598 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4 + 3, 252 - (y * 4)); | ||
1599 | } | ||
1600 | } | ||
1601 | } | ||
1602 | } | ||
1477 | 1603 | ||
1478 | saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap()); | 1604 | saleBitmap = land.MergeLandBitmaps(saleBitmap, landBitmap); |
1479 | } | 1605 | } |
1480 | } | 1606 | } |
1481 | 1607 | ||
@@ -1487,15 +1613,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1487 | 1613 | ||
1488 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); | 1614 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); |
1489 | 1615 | ||
1490 | for (int x = 0 ; x < 64 ; x++) | ||
1491 | { | ||
1492 | for (int y = 0 ; y < 64 ; y++) | ||
1493 | { | ||
1494 | if (saleBitmap[x, y]) | ||
1495 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | ||
1496 | } | ||
1497 | } | ||
1498 | |||
1499 | try | 1616 | try |
1500 | { | 1617 | { |
1501 | return OpenJPEG.EncodeFromImage(overlay, true); | 1618 | return OpenJPEG.EncodeFromImage(overlay, true); |
@@ -1517,4 +1634,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1517 | public uint itemtype; | 1634 | public uint itemtype; |
1518 | public ulong regionhandle; | 1635 | public ulong regionhandle; |
1519 | } | 1636 | } |
1637 | |||
1638 | public struct MapBlockRequestData | ||
1639 | { | ||
1640 | public IClientAPI client; | ||
1641 | public int minX; | ||
1642 | public int minY; | ||
1643 | public int maxX; | ||
1644 | public int maxY; | ||
1645 | public uint flags; | ||
1646 | } | ||
1520 | } | 1647 | } |