aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorUbitUmarov2015-09-01 14:54:35 +0100
committerUbitUmarov2015-09-01 14:54:35 +0100
commit371c9dd2af01a2e7422ec901ee1f80757284a78c (patch)
tree058d2a513cacb12efcce0c0df0ae14ad135dbfe2 /OpenSim/Region/CoreModules
parentremove lixo (diff)
parentdont change camera on crossings (diff)
downloadopensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.zip
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.gz
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.bz2
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.xz
bad merge?
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs28
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs206
-rw-r--r--OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs178
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs14
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs389
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs216
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs260
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs67
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs113
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs112
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs175
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs30
-rw-r--r--OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs187
-rw-r--r--OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs104
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs1027
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs20
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs263
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs98
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs233
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs454
-rw-r--r--OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs76
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs7
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs69
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs27
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs15
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs8
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs12
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs92
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs33
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs75
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandChannel.cs32
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs687
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs233
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs18
-rw-r--r--OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Region/RestartModule.cs127
-rw-r--r--OpenSim/Region/CoreModules/World/Sound/SoundModule.cs176
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs28
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs13
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs12
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs30
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs12
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs16
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs480
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs122
-rw-r--r--OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs64
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs99
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs607
83 files changed, 5869 insertions, 1737 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index f56d17d..1a19585 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -152,7 +152,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
152 } 152 }
153 } 153 }
154 154
155 public void RequestCreateInventoryItem(IClientAPI remoteClient, 155 public bool RequestCreateInventoryItem(IClientAPI remoteClient,
156 UUID transactionID, UUID folderID, uint callbackID, 156 UUID transactionID, UUID folderID, uint callbackID,
157 string description, string name, sbyte invType, 157 string description, string name, sbyte invType,
158 sbyte type, byte wearableType, uint nextOwnerMask) 158 sbyte type, byte wearableType, uint nextOwnerMask)
@@ -162,6 +162,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
162 uploader.RequestCreateInventoryItem( 162 uploader.RequestCreateInventoryItem(
163 remoteClient, folderID, callbackID, 163 remoteClient, folderID, callbackID,
164 description, name, invType, type, wearableType, nextOwnerMask); 164 description, name, invType, type, wearableType, nextOwnerMask);
165
166 return true;
165 } 167 }
166 168
167 public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, 169 public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient,
@@ -170,6 +172,17 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
170 { 172 {
171 AssetXferUploader uploader = RequestXferUploader(transactionID); 173 AssetXferUploader uploader = RequestXferUploader(transactionID);
172 174
175 // Here we need to get the old asset to extract the
176 // texture UUIDs if it's a wearable.
177 if (item.Type == (int)AssetType.Bodypart ||
178 item.Type == (int)AssetType.Clothing ||
179 item.Type == (int)CustomAssetType.AnimationSet)
180 {
181 AssetBase oldAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
182 if (oldAsset != null)
183 uploader.SetOldData(oldAsset.Data);
184 }
185
173 uploader.RequestUpdateTaskInventoryItem(remoteClient, item); 186 uploader.RequestUpdateTaskInventoryItem(remoteClient, item);
174 } 187 }
175 188
@@ -178,7 +191,18 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
178 { 191 {
179 AssetXferUploader uploader = RequestXferUploader(transactionID); 192 AssetXferUploader uploader = RequestXferUploader(transactionID);
180 193
194 // Here we need to get the old asset to extract the
195 // texture UUIDs if it's a wearable.
196 if (item.AssetType == (int)AssetType.Bodypart ||
197 item.AssetType == (int)AssetType.Clothing ||
198 item.AssetType == (int)CustomAssetType.AnimationSet)
199 {
200 AssetBase oldAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
201 if (oldAsset != null)
202 uploader.SetOldData(oldAsset.Data);
203 }
204
181 uploader.RequestUpdateInventoryItem(remoteClient, item); 205 uploader.RequestUpdateInventoryItem(remoteClient, item);
182 } 206 }
183 } 207 }
184} \ No newline at end of file 208}
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
index b67c0df..f489262 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 49a96f4..345b53d 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Reflection; 30using System.Reflection;
31using System.Collections.Generic;
31using log4net; 32using log4net;
32using OpenMetaverse; 33using OpenMetaverse;
33using OpenSim.Framework; 34using OpenSim.Framework;
@@ -40,6 +41,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
40{ 41{
41 public class AssetXferUploader 42 public class AssetXferUploader
42 { 43 {
44 // Viewer's notion of the default texture
45 private List<UUID> defaultIDs = new List<UUID> {
46 new UUID("5748decc-f629-461c-9a36-a35a221fe21f"),
47 new UUID("7ca39b4c-bd19-4699-aff7-f93fd03d3e7b"),
48 new UUID("6522e74d-1660-4e7f-b601-6f48c1659a77"),
49 new UUID("c228d1cf-4b5d-4ba8-84f4-899a0796aa97")
50 };
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 52
45 /// <summary> 53 /// <summary>
@@ -87,6 +95,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
87 95
88 private sbyte type = 0; 96 private sbyte type = 0;
89 private byte wearableType = 0; 97 private byte wearableType = 0;
98 private byte[] m_oldData = null;
90 public ulong XferID; 99 public ulong XferID;
91 private Scene m_Scene; 100 private Scene m_Scene;
92 101
@@ -129,18 +138,27 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
129 138
130 if (XferID == xferID) 139 if (XferID == xferID)
131 { 140 {
132 if (m_asset.Data.Length > 1) 141 lock (this)
133 { 142 {
134 byte[] destinationArray = new byte[m_asset.Data.Length + data.Length]; 143 int assetLength = m_asset.Data.Length;
135 Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length); 144 int dataLength = data.Length;
136 Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length); 145
137 m_asset.Data = destinationArray; 146 if (m_asset.Data.Length > 1)
138 } 147 {
139 else 148 byte[] destinationArray = new byte[assetLength + dataLength];
140 { 149 Array.Copy(m_asset.Data, 0, destinationArray, 0, assetLength);
141 byte[] buffer2 = new byte[data.Length - 4]; 150 Array.Copy(data, 0, destinationArray, assetLength, dataLength);
142 Array.Copy(data, 4, buffer2, 0, data.Length - 4); 151 m_asset.Data = destinationArray;
143 m_asset.Data = buffer2; 152 }
153 else
154 {
155 if (dataLength > 4)
156 {
157 byte[] buffer2 = new byte[dataLength - 4];
158 Array.Copy(data, 4, buffer2, 0, dataLength - 4);
159 m_asset.Data = buffer2;
160 }
161 }
144 } 162 }
145 163
146 ourClient.SendConfirmXfer(xferID, packetID); 164 ourClient.SendConfirmXfer(xferID, packetID);
@@ -244,10 +262,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
244 { 262 {
245 CompleteTaskItemUpdate(m_updateTaskItemData); 263 CompleteTaskItemUpdate(m_updateTaskItemData);
246 } 264 }
247// else if (m_storeLocal) 265 else if (m_asset.Local)
248// { 266 {
249// m_Scene.AssetService.Store(m_asset); 267 m_Scene.AssetService.Store(m_asset);
250// } 268 }
251 } 269 }
252 270
253 m_log.DebugFormat( 271 m_log.DebugFormat(
@@ -374,7 +392,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
374// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}", 392// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}",
375// m_asset.FullID, item.Name, ourClient.Name); 393// m_asset.FullID, item.Name, ourClient.Name);
376 394
395 ValidateAssets();
377 m_Scene.AssetService.Store(m_asset); 396 m_Scene.AssetService.Store(m_asset);
397 if (m_asset.FullID != UUID.Zero)
398 {
399 item.AssetID = m_asset.FullID;
400 m_Scene.InventoryService.UpdateItem(item);
401 }
378 402
379 m_transactions.RemoveXferUploader(m_transactionID); 403 m_transactions.RemoveXferUploader(m_transactionID);
380 404
@@ -391,6 +415,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
391// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}", 415// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}",
392// m_asset.FullID, taskItem.Name, ourClient.Name); 416// m_asset.FullID, taskItem.Name, ourClient.Name);
393 417
418 ValidateAssets();
394 m_Scene.AssetService.Store(m_asset); 419 m_Scene.AssetService.Store(m_asset);
395 420
396 m_transactions.RemoveXferUploader(m_transactionID); 421 m_transactions.RemoveXferUploader(m_transactionID);
@@ -398,6 +423,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
398 423
399 private void CompleteCreateItem(uint callbackID) 424 private void CompleteCreateItem(uint callbackID)
400 { 425 {
426 ValidateAssets();
401 m_Scene.AssetService.Store(m_asset); 427 m_Scene.AssetService.Store(m_asset);
402 428
403 InventoryItemBase item = new InventoryItemBase(); 429 InventoryItemBase item = new InventoryItemBase();
@@ -418,6 +444,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
418 item.Flags = (uint) wearableType; 444 item.Flags = (uint) wearableType;
419 item.CreationDate = Util.UnixTimeSinceEpoch(); 445 item.CreationDate = Util.UnixTimeSinceEpoch();
420 446
447 m_log.DebugFormat("[XFER]: Created item {0} with asset {1}",
448 item.ID, item.AssetID);
449
421 if (m_Scene.AddInventoryItem(item)) 450 if (m_Scene.AddInventoryItem(item))
422 ourClient.SendInventoryItemCreateUpdate(item, callbackID); 451 ourClient.SendInventoryItemCreateUpdate(item, callbackID);
423 else 452 else
@@ -426,5 +455,150 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
426 m_transactions.RemoveXferUploader(m_transactionID); 455 m_transactions.RemoveXferUploader(m_transactionID);
427 } 456 }
428 457
458<<<<<<< HEAD
459=======
460 private void ValidateAssets()
461 {
462 if (m_asset.Type == (sbyte)CustomAssetType.AnimationSet)
463 {
464 AnimationSet animSet = new AnimationSet(m_asset.Data);
465
466 bool allOk = animSet.Validate(x => {
467 int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, x);
468 int required = (int)(PermissionMask.Transfer | PermissionMask.Copy);
469 if ((perms & required) != required)
470 return false;
471 return true;
472 });
473
474 if (!allOk)
475 m_asset.Data = animSet.ToBytes();
476 }
477
478 if (m_asset.Type == (sbyte)AssetType.Clothing ||
479 m_asset.Type == (sbyte)AssetType.Bodypart)
480 {
481 string content = System.Text.Encoding.ASCII.GetString(m_asset.Data);
482 string[] lines = content.Split(new char[] {'\n'});
483
484 List<string> validated = new List<string>();
485
486 Dictionary<int, UUID> allowed = ExtractTexturesFromOldData();
487
488 int textures = 0;
489
490 foreach (string line in lines)
491 {
492 try
493 {
494 if (line.StartsWith("textures "))
495 {
496 textures = Convert.ToInt32(line.Substring(9));
497 validated.Add(line);
498 }
499 else if (textures > 0)
500 {
501 string[] parts = line.Split(new char[] {' '});
502
503 UUID tx = new UUID(parts[1]);
504 int id = Convert.ToInt32(parts[0]);
505
506 if (defaultIDs.Contains(tx) || tx == UUID.Zero ||
507 (allowed.ContainsKey(id) && allowed[id] == tx))
508 {
509 validated.Add(parts[0] + " " + tx.ToString());
510 }
511 else
512 {
513 int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, tx);
514 int full = (int)(PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Copy);
515
516 if ((perms & full) != full)
517 {
518 m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId);
519 validated.Add(parts[0] + " " + UUID.Zero.ToString());
520 }
521 else
522 {
523 validated.Add(line);
524 }
525 }
526 textures--;
527 }
528 else
529 {
530 validated.Add(line);
531 }
532 }
533 catch
534 {
535 // If it's malformed, skip it
536 }
537 }
538
539 string final = String.Join("\n", validated.ToArray());
540
541 m_asset.Data = System.Text.Encoding.ASCII.GetBytes(final);
542 }
543 }
544
545 /// <summary>
546 /// Get the asset data uploaded in this transfer.
547 /// </summary>
548 /// <returns>null if the asset has not finished uploading</returns>
549 public AssetBase GetAssetData()
550 {
551 if (m_uploadState == UploadState.Complete)
552 {
553 ValidateAssets();
554 return m_asset;
555 }
556
557 return null;
558 }
559
560 public void SetOldData(byte[] d)
561 {
562 m_oldData = d;
563 }
564
565 private Dictionary<int,UUID> ExtractTexturesFromOldData()
566 {
567 Dictionary<int,UUID> result = new Dictionary<int,UUID>();
568 if (m_oldData == null)
569 return result;
570
571 string content = System.Text.Encoding.ASCII.GetString(m_oldData);
572 string[] lines = content.Split(new char[] {'\n'});
573
574 int textures = 0;
575
576 foreach (string line in lines)
577 {
578 try
579 {
580 if (line.StartsWith("textures "))
581 {
582 textures = Convert.ToInt32(line.Substring(9));
583 }
584 else if (textures > 0)
585 {
586 string[] parts = line.Split(new char[] {' '});
587
588 UUID tx = new UUID(parts[1]);
589 int id = Convert.ToInt32(parts[0]);
590 result[id] = tx;
591 textures--;
592 }
593 }
594 catch
595 {
596 // If it's malformed, skip it
597 }
598 }
599
600 return result;
601 }
602>>>>>>> avn/ubitvar
429 } 603 }
430} \ No newline at end of file 604}
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/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 7d9c9a9..c4abc99 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -594,6 +594,11 @@ namespace OpenSim.Region.CoreModules.Asset
594 dir, dirSize); 594 dir, dirSize);
595 } 595 }
596 } 596 }
597 catch (DirectoryNotFoundException)
598 {
599 // If we get here, another node on the same box has
600 // already removed the directory. Continue with next.
601 }
597 catch (Exception e) 602 catch (Exception e)
598 { 603 {
599 m_log.Warn( 604 m_log.Warn(
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2f67c4e..b24dc0c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -41,6 +41,7 @@ using OpenSim.Region.Framework;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization; 43using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces;
44 45
45namespace OpenSim.Region.CoreModules.Avatar.Attachments 46namespace OpenSim.Region.CoreModules.Avatar.Attachments
46{ 47{
@@ -303,6 +304,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
303 if (DebugLevel > 0) 304 if (DebugLevel > 0)
304 m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name); 305 m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name);
305 306
307 XmlDocument doc = new XmlDocument();
308 string stateData = String.Empty;
309
310 IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>();
311 if (attServ != null)
312 {
313 m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service");
314 stateData = attServ.Get(sp.UUID.ToString());
315 if (stateData != String.Empty)
316 {
317 try
318 {
319 doc.LoadXml(stateData);
320 }
321 catch { }
322 }
323 }
324
325 Dictionary<UUID, string> itemData = new Dictionary<UUID, string>();
326
327 XmlNodeList nodes = doc.GetElementsByTagName("Attachment");
328 if (nodes.Count > 0)
329 {
330 foreach (XmlNode n in nodes)
331 {
332 XmlElement elem = (XmlElement)n;
333 string itemID = elem.GetAttribute("ItemID");
334 string xml = elem.InnerXml;
335
336 itemData[new UUID(itemID)] = xml;
337 }
338 }
339
340
306 List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); 341 List<AvatarAttachment> attachments = sp.Appearance.GetAttachments();
307 342
308 // Let's get all items at once, so they get cached 343 // Let's get all items at once, so they get cached
@@ -330,10 +365,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
330 365
331 try 366 try
332 { 367 {
368 string xmlData;
369 XmlDocument d = null;
370 UUID asset;
371 if (itemData.TryGetValue(attach.ItemID, out xmlData))
372 {
373 d = new XmlDocument();
374 d.LoadXml(xmlData);
375 m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", attach.ItemID);
376 }
377
333 // If we're an NPC then skip all the item checks and manipulations since we don't have an 378 // If we're an NPC then skip all the item checks and manipulations since we don't have an
334 // inventory right now. 379 // inventory right now.
335 RezSingleAttachmentFromInventoryInternal( 380 RezSingleAttachmentFromInventoryInternal(
336 sp, sp.PresenceType == PresenceType.Npc ? UUID.Zero : attach.ItemID, attach.AssetID, attachmentPt, true); 381 sp, sp.PresenceType == PresenceType.Npc ? UUID.Zero : attach.ItemID, attach.AssetID, attachmentPt, true, d);
337 } 382 }
338 catch (Exception e) 383 catch (Exception e)
339 { 384 {
@@ -361,6 +406,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
361 406
362 Dictionary<SceneObjectGroup, string> scriptStates = new Dictionary<SceneObjectGroup, string>(); 407 Dictionary<SceneObjectGroup, string> scriptStates = new Dictionary<SceneObjectGroup, string>();
363 408
409<<<<<<< HEAD
364 foreach (SceneObjectGroup so in attachments) 410 foreach (SceneObjectGroup so in attachments)
365 { 411 {
366 // Scripts MUST be snapshotted before the object is 412 // Scripts MUST be snapshotted before the object is
@@ -376,12 +422,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
376 } 422 }
377 423
378 lock (sp.AttachmentsSyncLock) 424 lock (sp.AttachmentsSyncLock)
425=======
426 if (sp.PresenceType != PresenceType.Npc)
427>>>>>>> avn/ubitvar
379 { 428 {
380 foreach (SceneObjectGroup so in attachments) 429 foreach (SceneObjectGroup so in attachments)
381 UpdateDetachedObject(sp, so, scriptStates[so]); 430 {
382 431 // Scripts MUST be snapshotted before the object is
383 sp.ClearAttachments(); 432 // removed from the scene because doing otherwise will
433 // clobber the run flag
434 // This must be done outside the sp.AttachmentSyncLock so that there is no risk of a deadlock from
435 // scripts performing attachment operations at the same time. Getting object states stops the scripts.
436 scriptStates[so] = PrepareScriptInstanceForSave(so, false);
437 }
438
439 lock (sp.AttachmentsSyncLock)
440 {
441 foreach (SceneObjectGroup so in attachments)
442 UpdateDetachedObject(sp, so, scriptStates[so]);
443 sp.ClearAttachments();
444 }
384 } 445 }
446 else
447 {
448 lock (sp.AttachmentsSyncLock)
449 {
450 foreach (SceneObjectGroup so in attachments)
451 UpdateDetachedObject(sp, so, String.Empty);
452 sp.ClearAttachments();
453 }
454 }
385 } 455 }
386 456
387 public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent) 457 public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent)
@@ -402,12 +472,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
402 sp.ClearAttachments(); 472 sp.ClearAttachments();
403 } 473 }
404 474
405 public bool AttachObject( 475 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool addToInventory, bool append)
406 IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool append)
407 { 476 {
408 if (!Enabled) 477 if (!Enabled)
409 return false; 478 return false;
410 479
480<<<<<<< HEAD
411 group.DetachFromBackup(); 481 group.DetachFromBackup();
412 482
413 bool success = AttachObjectInternal(sp, group, attachmentPt, silent, addToInventory, false, append); 483 bool success = AttachObjectInternal(sp, group, attachmentPt, silent, addToInventory, false, append);
@@ -416,6 +486,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
416 group.AttachToBackup(); 486 group.AttachToBackup();
417 487
418 return success; 488 return success;
489=======
490 return AttachObjectInternal(sp, group, attachmentPt, silent, useAttachData, addToInventory, false, append);
491>>>>>>> avn/ubitvar
419 } 492 }
420 493
421 /// <summary> 494 /// <summary>
@@ -428,10 +501,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
428 /// <param name='silent'></param> 501 /// <param name='silent'></param>
429 /// <param name='addToInventory'>If true then add object to user inventory.</param> 502 /// <param name='addToInventory'>If true then add object to user inventory.</param>
430 /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param> 503 /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param>
431 /// <param name='append'>Append to attachment point rather than replace.</param> 504 private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool addToInventory, bool resumeScripts, bool append)
432 private bool AttachObjectInternal(
433 IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool resumeScripts, bool append)
434 { 505 {
506// m_log.DebugFormat(
507// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
508// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
509
510 if (sp.GetAttachments().Contains(group))
511 {
512// m_log.WarnFormat(
513// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
514// group.Name, group.LocalId, sp.Name, AttachmentPt);
515
516 return false;
517 }
518
435 if (group.GetSittingAvatarsCount() != 0) 519 if (group.GetSittingAvatarsCount() != 0)
436 { 520 {
437 if (DebugLevel > 0) 521 if (DebugLevel > 0)
@@ -443,6 +527,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
443 } 527 }
444 528
445 Vector3 attachPos = group.AbsolutePosition; 529 Vector3 attachPos = group.AbsolutePosition;
530
531 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
532 // be removed when that functionality is implemented in opensim
533 attachmentPt &= 0x7f;
534
446 // If the attachment point isn't the same as the one previously used 535 // If the attachment point isn't the same as the one previously used
447 // set it's offset position = 0 so that it appears on the attachment point 536 // set it's offset position = 0 so that it appears on the attachment point
448 // and not in a weird location somewhere unknown. 537 // and not in a weird location somewhere unknown.
@@ -481,9 +570,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
481 attachPos = Vector3.Zero; 570 attachPos = Vector3.Zero;
482 } 571 }
483 572
484 group.AttachmentPoint = attachmentPt;
485 group.AbsolutePosition = attachPos;
486
487 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); 573 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
488 574
489 if (attachments.Contains(group)) 575 if (attachments.Contains(group))
@@ -516,6 +602,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
516 602
517 lock (sp.AttachmentsSyncLock) 603 lock (sp.AttachmentsSyncLock)
518 { 604 {
605 group.AttachmentPoint = attachmentPt;
606 group.AbsolutePosition = attachPos;
607
519 if (addToInventory && sp.PresenceType != PresenceType.Npc) 608 if (addToInventory && sp.PresenceType != PresenceType.Npc)
520 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append); 609 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append);
521 610
@@ -546,7 +635,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
546 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append); 635 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append);
547 } 636 }
548 637
549 public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) 638 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
639 {
640 return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, null);
641 }
642
643 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, XmlDocument doc)
550 { 644 {
551 if (!Enabled) 645 if (!Enabled)
552 return null; 646 return null;
@@ -584,7 +678,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
584 bool append = (AttachmentPt & 0x80) != 0; 678 bool append = (AttachmentPt & 0x80) != 0;
585 AttachmentPt &= 0x7f; 679 AttachmentPt &= 0x7f;
586 680
587 return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, append); 681 return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, append, doc);
588 } 682 }
589 683
590 public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) 684 public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist)
@@ -649,26 +743,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
649 if (changed && m_scene.AvatarFactory != null) 743 if (changed && m_scene.AvatarFactory != null)
650 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); 744 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
651 745
746 so.RootPart.Shape.LastAttachPoint = (byte)so.AttachmentPoint;
747
652 sp.RemoveAttachment(so); 748 sp.RemoveAttachment(so);
653 so.FromItemID = UUID.Zero; 749 so.FromItemID = UUID.Zero;
654 750
751 so.AttachedAvatar = UUID.Zero;
752 so.ClearPartAttachmentData();
753
655 SceneObjectPart rootPart = so.RootPart; 754 SceneObjectPart rootPart = so.RootPart;
755
756 rootPart.SetParentLocalId(0);
656 so.AbsolutePosition = absolutePos; 757 so.AbsolutePosition = absolutePos;
657 if (absoluteRot != Quaternion.Identity) 758 if (absoluteRot != Quaternion.Identity)
658 { 759 {
659 so.UpdateGroupRotationR(absoluteRot); 760 so.UpdateGroupRotationR(absoluteRot);
660 } 761 }
661 so.AttachedAvatar = UUID.Zero; 762
662 rootPart.SetParentLocalId(0); 763 rootPart.RemFlag(PrimFlags.TemporaryOnRez);
663 so.ClearPartAttachmentData(); 764
664 rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive); 765 // not physical, not temporary, phaton, not volume detector
766// so.UpdatePrimFlags(rootPart.LocalId,false,false,true,rootPart.VolumeDetectActive);
767
768 // restore full physical state instead
769 so.ApplyPhysics();
770
665 so.HasGroupChanged = true; 771 so.HasGroupChanged = true;
666 so.RootPart.Shape.LastAttachPoint = (byte)so.AttachmentPoint;
667 rootPart.Rezzed = DateTime.Now; 772 rootPart.Rezzed = DateTime.Now;
668 rootPart.RemFlag(PrimFlags.TemporaryOnRez);
669 so.AttachToBackup(); 773 so.AttachToBackup();
670 m_scene.EventManager.TriggerParcelPrimCountTainted(); 774 m_scene.EventManager.TriggerParcelPrimCountTainted();
671 rootPart.ScheduleFullUpdate(); 775
672 rootPart.ClearUndoState(); 776 rootPart.ClearUndoState();
673 777
674 List<UUID> uuids = new List<UUID>(); 778 List<UUID> uuids = new List<UUID>();
@@ -678,6 +782,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
678 } 782 }
679 783
680 m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero); 784 m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero);
785
786 // Attach (NULL) stops scripts. We don't want that. Resume them.
787 so.ResumeScripts();
788 so.ScheduleGroupForTerseUpdate();
789 so.RootPart.ScheduleFullUpdate();
681 } 790 }
682 791
683 public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so) 792 public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so)
@@ -848,8 +957,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
848 957
849 so.AttachedAvatar = sp.UUID; 958 so.AttachedAvatar = sp.UUID;
850 959
851 if (so.RootPart.PhysActor != null) 960 foreach (SceneObjectPart part in so.Parts)
852 so.RootPart.RemoveFromPhysics(); 961 {
962// if (part.KeyframeMotion != null)
963// part.KeyframeMotion.Suspend();
964
965 if (part.PhysActor != null)
966 {
967 part.RemoveFromPhysics();
968 }
969 }
853 970
854 so.AbsolutePosition = attachOffset; 971 so.AbsolutePosition = attachOffset;
855 so.RootPart.AttachedPos = attachOffset; 972 so.RootPart.AttachedPos = attachOffset;
@@ -971,6 +1088,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
971 // Remove the object from the scene so no more updates 1088 // Remove the object from the scene so no more updates
972 // are sent. Doing this before the below changes will ensure 1089 // are sent. Doing this before the below changes will ensure
973 // updates can't cause "HUD artefacts" 1090 // updates can't cause "HUD artefacts"
1091
974 m_scene.DeleteSceneObject(so, false, false); 1092 m_scene.DeleteSceneObject(so, false, false);
975 1093
976 // Prepare sog for storage 1094 // Prepare sog for storage
@@ -992,7 +1110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
992 } 1110 }
993 1111
994 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 1112 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
995 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, bool append) 1113 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, bool append, XmlDocument doc)
996 { 1114 {
997 if (m_invAccessModule == null) 1115 if (m_invAccessModule == null)
998 return null; 1116 return null;
@@ -1043,7 +1161,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1043 // This will throw if the attachment fails 1161 // This will throw if the attachment fails
1044 try 1162 try
1045 { 1163 {
1046 AttachObjectInternal(sp, objatt, attachmentPt, false, true, true, append); 1164 if (doc != null)
1165 {
1166 objatt.LoadScriptState(doc);
1167 objatt.ResetOwnerChangeFlag();
1168 }
1169
1170 AttachObjectInternal(sp, objatt, attachmentPt, false, true, true, true, append);
1047 } 1171 }
1048 catch (Exception e) 1172 catch (Exception e)
1049 { 1173 {
@@ -1197,7 +1321,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1197 AttachmentPt &= 0x7f; 1321 AttachmentPt &= 0x7f;
1198 1322
1199 // Calls attach with a Zero position 1323 // Calls attach with a Zero position
1200 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, append)) 1324 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, false, true, append))
1201 { 1325 {
1202 if (DebugLevel > 0) 1326 if (DebugLevel > 0)
1203 m_log.Debug( 1327 m_log.Debug(
@@ -1205,7 +1329,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1205 + ", AttachmentPoint: " + AttachmentPt); 1329 + ", AttachmentPoint: " + AttachmentPt);
1206 1330
1207 // Save avatar attachment information 1331 // Save avatar attachment information
1208 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); 1332 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
1209 } 1333 }
1210 } 1334 }
1211 catch (Exception e) 1335 catch (Exception e)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index f1b002b..b632774 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -201,7 +201,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
201 Assert.That(so.Backup, Is.True); 201 Assert.That(so.Backup, Is.True);
202 202
203 m_numberOfAttachEventsFired = 0; 203 m_numberOfAttachEventsFired = 0;
204 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false); 204 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false, false);
205 205
206 // Check status on scene presence 206 // Check status on scene presence
207 Assert.That(sp.HasAttachments(), Is.True); 207 Assert.That(sp.HasAttachments(), Is.True);
@@ -249,7 +249,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
249 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID); 249 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID);
250 250
251 m_numberOfAttachEventsFired = 0; 251 m_numberOfAttachEventsFired = 0;
252 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false); 252 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false, false);
253 253
254 // Check status on scene presence 254 // Check status on scene presence
255 Assert.That(sp.HasAttachments(), Is.True); 255 Assert.That(sp.HasAttachments(), Is.True);
@@ -282,7 +282,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
282 282
283 // Test wearing a different attachment from the ground. 283 // Test wearing a different attachment from the ground.
284 { 284 {
285 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false); 285 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false, false);
286 286
287 // Check status on scene presence 287 // Check status on scene presence
288 Assert.That(sp.HasAttachments(), Is.True); 288 Assert.That(sp.HasAttachments(), Is.True);
@@ -315,7 +315,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
315 315
316 // Test rewearing an already worn attachment from ground. Nothing should happen. 316 // Test rewearing an already worn attachment from ground. Nothing should happen.
317 { 317 {
318 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false); 318 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false, false);
319 319
320 // Check status on scene presence 320 // Check status on scene presence
321 Assert.That(sp.HasAttachments(), Is.True); 321 Assert.That(sp.HasAttachments(), Is.True);
@@ -373,7 +373,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
373 sp2.AbsolutePosition = new Vector3(0, 0, 0); 373 sp2.AbsolutePosition = new Vector3(0, 0, 0);
374 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); 374 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
375 375
376 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false); 376 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false, false);
377 377
378 Assert.That(sp.HasAttachments(), Is.False); 378 Assert.That(sp.HasAttachments(), Is.False);
379 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); 379 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
@@ -671,7 +671,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
671 scene.EventManager.OnChatFromWorld += OnChatFromWorld; 671 scene.EventManager.OnChatFromWorld += OnChatFromWorld;
672 672
673 SceneObjectGroup rezzedSo 673 SceneObjectGroup rezzedSo
674 = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); 674 = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest));
675 675
676 // Wait for chat to signal rezzed script has been started. 676 // Wait for chat to signal rezzed script has been started.
677 m_chatEvent.WaitOne(60000); 677 m_chatEvent.WaitOne(60000);
@@ -690,7 +690,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
690 Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); 690 Assert.That(scriptStateNodes.Count, Is.EqualTo(1));
691 691
692 // Re-rez the attachment to check script running state 692 // Re-rez the attachment to check script running state
693 SceneObjectGroup reRezzedSo = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); 693 SceneObjectGroup reRezzedSo = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest));
694 694
695 // Wait for chat to signal rezzed script has been started. 695 // Wait for chat to signal rezzed script has been started.
696 m_chatEvent.WaitOne(60000); 696 m_chatEvent.WaitOne(60000);
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index cfb082b..1e9cfba 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -188,27 +188,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
188 // Process the visual params, this may change height as well 188 // Process the visual params, this may change height as well
189 if (visualParams != null) 189 if (visualParams != null)
190 { 190 {
191 // string[] visualParamsStrings = new string[visualParams.Length];
192 // for (int i = 0; i < visualParams.Length; i++)
193 // visualParamsStrings[i] = visualParams[i].ToString();
194 // m_log.DebugFormat(
195 // "[AVFACTORY]: Setting visual params for {0} to {1}",
196 // client.Name, string.Join(", ", visualParamsStrings));
197/*
198 float oldHeight = sp.Appearance.AvatarHeight;
199 changed = sp.Appearance.SetVisualParams(visualParams);
200
201 if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0)
202 ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight);
203 */
204// float oldoff = sp.Appearance.AvatarFeetOffset;
205// Vector3 oldbox = sp.Appearance.AvatarBoxSize;
206 changed = sp.Appearance.SetVisualParams(visualParams); 191 changed = sp.Appearance.SetVisualParams(visualParams);
207// float off = sp.Appearance.AvatarFeetOffset;
208// Vector3 box = sp.Appearance.AvatarBoxSize;
209// if(oldoff != off || oldbox != box)
210// ((ScenePresence)sp).SetSize(box,off);
211
212 } 192 }
213 193
214 // Process the baked texture array 194 // Process the baked texture array
@@ -222,9 +202,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
222 202
223// WriteBakedTexturesReport(sp, m_log.DebugFormat); 203// WriteBakedTexturesReport(sp, m_log.DebugFormat);
224 204
225 // If bake textures are missing and this is not an NPC, request a rebake from client 205 UpdateBakedTextureCache(sp, cacheItems);
226 if (!ValidateBakedTextureCache(sp) && (((ScenePresence)sp).PresenceType != PresenceType.Npc))
227 RequestRebake(sp, true);
228 206
229 // This appears to be set only in the final stage of the appearance 207 // This appears to be set only in the final stage of the appearance
230 // update transaction. In theory, we should be able to do an immediate 208 // update transaction. In theory, we should be able to do an immediate
@@ -377,114 +355,335 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
377 } 355 }
378 } 356 }
379 357
380 public bool ValidateBakedTextureCache(IScenePresence sp) 358 // called on textures update
359 public bool UpdateBakedTextureCache(IScenePresence sp, WearableCacheItem[] cacheItems)
381 { 360 {
382 bool defonly = true; // are we only using default textures 361 // npcs dont have baked cache
383 IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); 362 if (((ScenePresence)sp).isNPC)
384 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); 363 return true;
385 WearableCacheItem[] wearableCache = null; 364
386 365 // uploaded baked textures will be in assets local cache
387 // Cache wearable data for teleport. 366 IAssetService cache = m_scene.AssetService;
388 // Only makes sense if there's a bake module and a cache module 367 IBakedTextureModule m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
389 if (bakedModule != null && cache != null) 368
369 int validDirtyBakes = 0;
370 int hits = 0;
371
372 // our main cacheIDs mapper is p.Appearance.WearableCacheItems
373 WearableCacheItem[] wearableCache = sp.Appearance.WearableCacheItems;
374
375 if (wearableCache == null)
390 { 376 {
391 try 377 wearableCache = WearableCacheItem.GetDefaultCacheItem();
392 { 378 }
393 wearableCache = bakedModule.Get(sp.UUID); 379
394 } 380 List<UUID> missing = new List<UUID>();
395 catch (Exception) 381
396 { 382 // Process received baked textures
383 for (int i = 0; i < cacheItems.Length; i++)
384 {
385 int idx = (int)cacheItems[i].TextureIndex;
386 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
397 387
388 // No face
389 if (face == null)
390 {
391 // for some reason viewer is cleaning this
392 sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx);
393 sp.Appearance.Texture.FaceTextures[idx].TextureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
394 wearableCache[idx].CacheId = UUID.Zero;
395 wearableCache[idx].TextureID = UUID.Zero;
396 wearableCache[idx].TextureAsset = null;
397 continue;
398 } 398 }
399 if (wearableCache != null) 399 else
400 { 400 {
401 for (int i = 0; i < wearableCache.Length; i++) 401 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
402 { 402 {
403 cache.Cache(wearableCache[i].TextureAsset); 403 wearableCache[idx].CacheId = UUID.Zero;
404 wearableCache[idx].TextureID = UUID.Zero;
405 wearableCache[idx].TextureAsset = null;
406 continue;
404 } 407 }
405 } 408
406 } 409/*
407 /* 410 if (face.TextureID == wearableCache[idx].TextureID && m_BakedTextureModule != null)
408 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
409 if (invService.GetRootFolder(userID) != null)
410 {
411 WearableCacheItem[] wearableCache = null;
412 if (bakedModule != null)
413 {
414 try
415 { 411 {
416 wearableCache = bakedModule.Get(userID); 412 if (wearableCache[idx].CacheId != cacheItems[i].CacheId)
417 appearance.WearableCacheItems = wearableCache;
418 appearance.WearableCacheItemsDirty = false;
419 foreach (WearableCacheItem item in wearableCache)
420 { 413 {
421 appearance.Texture.FaceTextures[item.TextureIndex].TextureID = item.TextureID; 414 wearableCache[idx].CacheId = cacheItems[i].CacheId;
415 validDirtyBakes++;
416
417 //assuming this can only happen if asset is in cache
422 } 418 }
419 hits++;
420 continue;
421 }
422*/
423 wearableCache[idx].TextureAsset = null;
424 if (cache != null)
425 wearableCache[idx].TextureAsset = cache.GetCached(face.TextureID.ToString());
426
427 if (wearableCache[idx].TextureAsset != null)
428 {
429 if ( wearableCache[idx].TextureID != face.TextureID ||
430 wearableCache[idx].CacheId != cacheItems[i].CacheId)
431 validDirtyBakes++;
432
433 wearableCache[idx].TextureID = face.TextureID;
434 wearableCache[idx].CacheId = cacheItems[i].CacheId;
435 hits++;
423 } 436 }
424 catch (Exception) 437 else
425 { 438 {
426 439 wearableCache[idx].CacheId = UUID.Zero;
440 wearableCache[idx].TextureID = UUID.Zero;
441 wearableCache[idx].TextureAsset = null;
442 missing.Add(face.TextureID);
443 continue;
427 } 444 }
428 } 445 }
429 */ 446 }
430 447
431 // Process the texture entry 448 sp.Appearance.WearableCacheItems = wearableCache;
432 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) 449
450 if (missing.Count > 0)
433 { 451 {
434 int idx = AvatarAppearance.BAKE_INDICES[i]; 452 foreach (UUID id in missing)
435 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; 453 sp.ControllingClient.SendRebakeAvatarTextures(id);
454 }
436 455
437 // No face, so lets check our baked service cache, teleport or login. 456 if (validDirtyBakes > 0 && hits == cacheItems.Length)
438 if (face == null) 457 {
458 // if we got a full set of baked textures save all in BakedTextureModule
459 if (m_BakedTextureModule != null)
439 { 460 {
440 if (wearableCache != null) 461 m_log.Debug("[UpdateBakedCache] uploading to bakedModule cache");
462
463 m_BakedTextureModule.Store(sp.UUID);
464 }
465 }
466
467
468 // debug
469 m_log.Debug("[UpdateBakedCache] cache hits: " + hits.ToString() + " changed entries: " + validDirtyBakes.ToString() + " rebakes " + missing.Count);
470/*
471 for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
472 {
473 int j = AvatarAppearance.BAKE_INDICES[iter];
474 m_log.Debug("[UpdateBCache] {" + iter + "/" +
475 sp.Appearance.WearableCacheItems[j].TextureIndex + "}: c-" +
476 sp.Appearance.WearableCacheItems[j].CacheId + ", t-" +
477 sp.Appearance.WearableCacheItems[j].TextureID);
478 }
479*/
480 return (hits == cacheItems.Length);
481 }
482
483 // called when we get a new root avatar
484 public bool ValidateBakedTextureCache(IScenePresence sp)
485 {
486 int hits = 0;
487
488 if (((ScenePresence)sp).isNPC)
489 return true;
490
491 lock (m_setAppearanceLock)
492 {
493 IAssetService cache = m_scene.AssetService;
494 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
495 WearableCacheItem[] bakedModuleCache = null;
496
497 if (cache == null)
498 return false;
499
500 WearableCacheItem[] wearableCache = sp.Appearance.WearableCacheItems;
501
502 // big debug
503 m_log.DebugFormat("[AVFACTORY]: ValidateBakedTextureCache start for {0} {1}", sp.Name, sp.UUID);
504/*
505 for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
506 {
507 int j = AvatarAppearance.BAKE_INDICES[iter];
508 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[j];
509 if (wearableCache == null)
441 { 510 {
442 // If we find the an appearance item, set it as the textureentry and the face 511 if (face != null)
443 WearableCacheItem searchitem = WearableCacheItem.SearchTextureIndex((uint) idx, wearableCache); 512 m_log.Debug("[ValidateBakedCache] {" + iter + "/" + j + " t- " + face.TextureID);
444 if (searchitem != null)
445 {
446 sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx);
447 sp.Appearance.Texture.FaceTextures[idx].TextureID = searchitem.TextureID;
448 face = sp.Appearance.Texture.FaceTextures[idx];
449 }
450 else 513 else
451 { 514 m_log.Debug("[ValidateBakedCache] {" + iter + "/" + j + " t- No texture");
452 // if there is no texture entry and no baked cache, skip it
453 continue;
454 }
455 } 515 }
456 else 516 else
457 { 517 {
458 //No texture entry face and no cache. Skip this face. 518 if (face != null)
459 continue; 519 m_log.Debug("[ValidateBakedCache] {" + iter + "/" + j + " ft- " + face.TextureID +
520 "}: cc-" +
521 wearableCache[j].CacheId + ", ct-" +
522 wearableCache[j].TextureID
523 );
524 else
525 m_log.Debug("[ValidateBakedCache] {" + iter + "/" + j + " t - No texture" +
526 "}: cc-" +
527 wearableCache[j].CacheId + ", ct-" +
528 wearableCache[j].TextureID
529 );
460 } 530 }
461 } 531 }
532<<<<<<< HEAD
462 533
463// m_log.DebugFormat( 534// m_log.DebugFormat(
464// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", 535// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}",
465// face.TextureID, idx, client.Name, client.AgentId); 536// face.TextureID, idx, client.Name, client.AgentId);
537=======
538*/
539 bool wearableCacheValid = false;
540 if (wearableCache == null)
541 {
542 wearableCache = WearableCacheItem.GetDefaultCacheItem();
543 }
544 else
545 {
546 // we may have received a full cache
547 // check same coerence and store
548 wearableCacheValid = true;
549 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
550 {
551 int idx = AvatarAppearance.BAKE_INDICES[i];
552 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
553 if (face != null)
554 {
555 if (face.TextureID == wearableCache[idx].TextureID &&
556 face.TextureID != UUID.Zero)
557 {
558 if (wearableCache[idx].TextureAsset != null)
559 {
560 hits++;
561 wearableCache[idx].TextureAsset.Temporary = true;
562 wearableCache[idx].TextureAsset.Local = true;
563 cache.Store(wearableCache[idx].TextureAsset);
564 continue;
565 }
566 if (cache.GetCached((wearableCache[idx].TextureID).ToString()) != null)
567 {
568 hits++;
569 continue;
570 }
571 }
572 wearableCacheValid = false;
573 }
574 }
575
576 wearableCacheValid = (wearableCacheValid && (hits >= AvatarAppearance.BAKE_INDICES.Length - 1));
577 if (wearableCacheValid)
578 m_log.Debug("[ValidateBakedCache] have valid local cache");
579 }
580>>>>>>> avn/ubitvar
466 581
467 // if the texture is one of the "defaults" then skip it 582 bool checkExternal = false;
468 // this should probably be more intelligent (skirt texture doesnt matter
469 // if the avatar isnt wearing a skirt) but if any of the main baked
470 // textures is default then the rest should be as well
471 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
472 continue;
473
474 defonly = false; // found a non-default texture reference
475 583
584<<<<<<< HEAD
476 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) 585 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
477 return false; 586 return false;
478 } 587 }
588=======
589 if (!wearableCacheValid)
590 {
591 // only use external bake module on login condition check
592// ScenePresence ssp = null;
593// if (sp is ScenePresence)
594 {
595// ssp = (ScenePresence)sp;
596// checkExternal = (((uint)ssp.TeleportFlags & (uint)TeleportFlags.ViaLogin) != 0) &&
597// bakedModule != null;
598
599 // or do it anytime we dont have the cache
600 checkExternal = bakedModule != null;
601 }
602 }
479 603
480// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); 604 if (checkExternal)
605 {
606 hits = 0;
607 bool gotbacked = false;
481 608
482 // If we only found default textures, then the appearance is not cached 609 m_log.Debug("[ValidateBakedCache] local cache invalid, checking bakedModule");
483 return (defonly ? false : true); 610 try
611 {
612 bakedModuleCache = bakedModule.Get(sp.UUID);
613 }
614 catch (Exception e)
615 {
616 m_log.ErrorFormat(e.ToString());
617 bakedModuleCache = null;
618 }
619
620 if (bakedModuleCache != null)
621 {
622 m_log.Debug("[ValidateBakedCache] got bakedModule " + bakedModuleCache.Length + " cached textures");
623
624 for (int i = 0; i < bakedModuleCache.Length; i++)
625 {
626 int j = (int)bakedModuleCache[i].TextureIndex;
627
628 if (bakedModuleCache[i].TextureAsset != null)
629 {
630 wearableCache[j].TextureID = bakedModuleCache[i].TextureID;
631 wearableCache[j].CacheId = bakedModuleCache[i].CacheId;
632 wearableCache[j].TextureAsset = bakedModuleCache[i].TextureAsset;
633 bakedModuleCache[i].TextureAsset.Temporary = true;
634 bakedModuleCache[i].TextureAsset.Local = true;
635 cache.Store(bakedModuleCache[i].TextureAsset);
636 }
637 }
638 gotbacked = true;
639 }
640
641 if (gotbacked)
642 {
643 // force the ones we got
644 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
645 {
646 int idx = AvatarAppearance.BAKE_INDICES[i];
647 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
648
649 if (sp.Appearance.Texture.FaceTextures[idx] == null)
650 sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint)idx);
651 sp.Appearance.Texture.FaceTextures[idx].TextureID = wearableCache[idx].TextureID;
652 face = sp.Appearance.Texture.FaceTextures[idx];
653
654 // this should be removed
655 if (face.TextureID != UUID.Zero && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
656 hits++;
657 continue;
658 }
659 }
660 }
661>>>>>>> avn/ubitvar
662
663 sp.Appearance.WearableCacheItems = wearableCache;
664
665 }
666
667 // debug
668 m_log.DebugFormat("[ValidateBakedCache]: Completed texture check for {0} {1} with {2} hits", sp.Name, sp.UUID, hits);
669/*
670 for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
671 {
672 int j = AvatarAppearance.BAKE_INDICES[iter];
673 m_log.Debug("[ValidateBakedCache] {" + iter + "/" +
674 sp.Appearance.WearableCacheItems[j].TextureIndex + "}: c-" +
675 sp.Appearance.WearableCacheItems[j].CacheId + ", t-" +
676 sp.Appearance.WearableCacheItems[j].TextureID);
677 }
678*/
679 return (hits >= AvatarAppearance.BAKE_INDICES.Length - 1); // skirt is optional
484 } 680 }
485 681
486 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) 682 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly)
487 { 683 {
684 if (((ScenePresence)sp).isNPC)
685 return 0;
686
488 int texturesRebaked = 0; 687 int texturesRebaked = 0;
489// IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); 688// IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
490 689
@@ -497,14 +696,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
497 if (face == null) 696 if (face == null)
498 continue; 697 continue;
499 698
500// m_log.DebugFormat(
501// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}",
502// face.TextureID, idx, client.Name, client.AgentId);
503
504 // if the texture is one of the "defaults" then skip it
505 // this should probably be more intelligent (skirt texture doesnt matter
506 // if the avatar isnt wearing a skirt) but if any of the main baked
507 // textures is default then the rest should be as well
508 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) 699 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
509 continue; 700 continue;
510 701
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
index 9513408..b7ff4e0 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
@@ -132,6 +132,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
132 for (byte i = 0; i < visualParams.Length; i++) 132 for (byte i = 0; i < visualParams.Length; i++)
133 visualParams[i] = i; 133 visualParams[i] = i;
134 134
135<<<<<<< HEAD
135 Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)); 136 Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10));
136 uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes); 137 uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes);
137 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); 138 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);
@@ -144,6 +145,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
144 afm.SetAppearance(sp, bakedTextureEntry, visualParams, null); 145 afm.SetAppearance(sp, bakedTextureEntry, visualParams, null);
145 146
146 Assert.That(rebakeRequestsReceived, Is.EqualTo(0)); 147 Assert.That(rebakeRequestsReceived, Is.EqualTo(0));
148=======
149 afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams, new WearableCacheItem[0]);
150
151 // TODO: Check baked texture
152 Assert.AreEqual(visualParams, sp.Appearance.VisualParams);
153>>>>>>> avn/ubitvar
147 } 154 }
148 155
149 [Test] 156 [Test]
@@ -181,7 +188,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
181 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); 188 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);
182 eyesFace.TextureID = eyesTextureId; 189 eyesFace.TextureID = eyesTextureId;
183 190
191<<<<<<< HEAD
184 afm.SetAppearance(sp, bakedTextureEntry, visualParams, null); 192 afm.SetAppearance(sp, bakedTextureEntry, visualParams, null);
193=======
194 afm.SetAppearance(sp, bakedTextureEntry, visualParams, new WearableCacheItem[0]);
195>>>>>>> avn/ubitvar
185 afm.SaveBakedTextures(userId); 196 afm.SaveBakedTextures(userId);
186// Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId); 197// Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId);
187 198
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index a9d2de0..2801ef0 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -51,7 +51,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
51 private int m_saydistance = 20; 51 private int m_saydistance = 20;
52 private int m_shoutdistance = 100; 52 private int m_shoutdistance = 100;
53 private int m_whisperdistance = 10; 53 private int m_whisperdistance = 10;
54 54 private List<Scene> m_scenes = new List<Scene>();
55 private List<string> FreezeCache = new List<string>();
56 private string m_adminPrefix = "";
55 internal object m_syncy = new object(); 57 internal object m_syncy = new object();
56 58
57 internal IConfig m_config; 59 internal IConfig m_config;
@@ -78,16 +80,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
78 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 80 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
79 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 81 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
80 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 82 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
83 m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", "");
81 } 84 }
82 85
83 public virtual void AddRegion(Scene scene) 86 public virtual void AddRegion(Scene scene)
84 { 87 {
85 if (!m_enabled) 88 if (!m_enabled) return;
86 return;
87 89
88 scene.EventManager.OnNewClient += OnNewClient; 90 lock (m_syncy)
89 scene.EventManager.OnChatFromWorld += OnChatFromWorld; 91 {
90 scene.EventManager.OnChatBroadcast += OnChatBroadcast; 92 if (!m_scenes.Contains(scene))
93 {
94 m_scenes.Add(scene);
95 scene.EventManager.OnNewClient += OnNewClient;
96 scene.EventManager.OnChatFromWorld += OnChatFromWorld;
97 scene.EventManager.OnChatBroadcast += OnChatBroadcast;
98 }
99 }
91 100
92 m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName, 101 m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName,
93 m_whisperdistance, m_saydistance, m_shoutdistance); 102 m_whisperdistance, m_saydistance, m_shoutdistance);
@@ -107,12 +116,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
107 116
108 public virtual void RemoveRegion(Scene scene) 117 public virtual void RemoveRegion(Scene scene)
109 { 118 {
110 if (!m_enabled) 119 if (!m_enabled) return;
111 return;
112 120
113 scene.EventManager.OnNewClient -= OnNewClient; 121 lock (m_syncy)
114 scene.EventManager.OnChatFromWorld -= OnChatFromWorld; 122 {
115 scene.EventManager.OnChatBroadcast -= OnChatBroadcast; 123 if (m_scenes.Contains(scene))
124 {
125 scene.EventManager.OnNewClient -= OnNewClient;
126 scene.EventManager.OnChatFromWorld -= OnChatFromWorld;
127 scene.EventManager.OnChatBroadcast -= OnChatBroadcast;
128 m_scenes.Remove(scene);
129 }
130 }
116 } 131 }
117 132
118 public virtual void Close() 133 public virtual void Close()
@@ -169,7 +184,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
169 return; 184 return;
170 } 185 }
171 186
172 DeliverChatToAvatars(ChatSourceType.Agent, c); 187 if (FreezeCache.Contains(c.Sender.AgentId.ToString()))
188 {
189 if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping)
190 c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false);
191 }
192 else
193 {
194 DeliverChatToAvatars(ChatSourceType.Agent, c);
195 }
173 } 196 }
174 197
175 public virtual void OnChatFromWorld(Object sender, OSChatMessage c) 198 public virtual void OnChatFromWorld(Object sender, OSChatMessage c)
@@ -183,33 +206,64 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
183 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) 206 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
184 { 207 {
185 string fromName = c.From; 208 string fromName = c.From;
209 string fromNamePrefix = "";
186 UUID fromID = UUID.Zero; 210 UUID fromID = UUID.Zero;
187 UUID ownerID = UUID.Zero; 211 UUID ownerID = UUID.Zero;
188 UUID targetID = c.TargetUUID;
189 string message = c.Message; 212 string message = c.Message;
190 Scene scene = (Scene)c.Scene; 213 IScene scene = c.Scene;
214 UUID destination = c.Destination;
191 Vector3 fromPos = c.Position; 215 Vector3 fromPos = c.Position;
192 Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0); 216 Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);
217<<<<<<< HEAD
218=======
219
220 bool checkParcelHide = false;
221 UUID sourceParcelID = UUID.Zero;
222 Vector3 hidePos = fromPos;
223>>>>>>> avn/ubitvar
193 224
194 if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; 225 if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel;
195 226
196 switch (sourceType) 227 switch (sourceType)
197 { 228 {
198 case ChatSourceType.Agent: 229 case ChatSourceType.Agent:
199 ScenePresence avatar = scene.GetScenePresence(c.Sender.AgentId); 230 if (!(scene is Scene))
231 {
232 m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
233 scene.RegionInfo.RegionName, c.Sender.AgentId);
234 return;
235 }
236 ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
200 fromPos = avatar.AbsolutePosition; 237 fromPos = avatar.AbsolutePosition;
201 fromName = avatar.Name; 238 fromName = avatar.Name;
202 fromID = c.Sender.AgentId; 239 fromID = c.Sender.AgentId;
240 if (avatar.GodLevel >= 200)
241 { // let gods speak to outside or things may get confusing
242 fromNamePrefix = m_adminPrefix;
243 checkParcelHide = false;
244 }
245 else
246 {
247 checkParcelHide = true;
248 }
249 destination = UUID.Zero; // Avatars cant "SayTo"
203 ownerID = c.Sender.AgentId; 250 ownerID = c.Sender.AgentId;
204 251
252 hidePos = fromPos;
205 break; 253 break;
206 254
207 case ChatSourceType.Object: 255 case ChatSourceType.Object:
208 fromID = c.SenderUUID; 256 fromID = c.SenderUUID;
209 257
210 if (c.SenderObject != null && c.SenderObject is SceneObjectPart) 258 if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
259 {
211 ownerID = ((SceneObjectPart)c.SenderObject).OwnerID; 260 ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
212 261 if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
262 {
263 checkParcelHide = true;
264 hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition;
265 }
266 }
213 break; 267 break;
214 } 268 }
215 269
@@ -218,38 +272,68 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
218 message = message.Substring(0, 1000); 272 message = message.Substring(0, 1000);
219 273
220// m_log.DebugFormat( 274// m_log.DebugFormat(
221// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", 275// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}",
222// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); 276// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);
223 277
224 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 278 HashSet<UUID> receiverIDs = new HashSet<UUID>();
225 279
226 if (targetID == UUID.Zero) 280 if (checkParcelHide)
281 {
282 checkParcelHide = false;
283 if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero)
284 {
285 ILandObject srcland = (scene as Scene).LandChannel.GetLandObject(hidePos.X, hidePos.Y);
286 if (srcland != null && !srcland.LandData.SeeAVs)
287 {
288 sourceParcelID = srcland.LandData.GlobalID;
289 checkParcelHide = true;
290 }
291 }
292 }
293
294 foreach (Scene s in m_scenes)
227 { 295 {
228 // This should use ForEachClient, but clients don't have a position. 296 // This should use ForEachClient, but clients don't have a position.
229 // If camera is moved into client, then camera position can be used 297 // If camera is moved into client, then camera position can be used
230 scene.ForEachScenePresence( 298 // MT: No, it can't, as chat is heard from the avatar position, not
299 // the camera position.
300
301 s.ForEachScenePresence(
231 delegate(ScenePresence presence) 302 delegate(ScenePresence presence)
232 { 303 {
233 if (TrySendChatMessage( 304 if (destination != UUID.Zero && presence.UUID != destination)
234 presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false)) 305 return;
235 receiverIDs.Add(presence.UUID); 306 ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
307 if (Presencecheck != null)
308 {
309 // This will pass all chat from objects. Not
310 // perfect, but it will do. For now. Better
311 // than the prior behavior of muting all
312 // objects on a parcel with access restrictions
313 if (checkParcelHide)
314 {
315 if (sourceParcelID != Presencecheck.LandData.GlobalID && presence.GodLevel < 200)
316 return;
317 }
318 if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
319 {
320 if (destination != UUID.Zero)
321 {
322 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, true))
323 receiverIDs.Add(presence.UUID);
324 }
325 else
326 {
327 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, false))
328 receiverIDs.Add(presence.UUID);
329 }
330 }
331 }
236 } 332 }
237 ); 333 );
238 } 334 }
239 else 335
240 { 336 (scene as Scene).EventManager.TriggerOnChatToClients(
241 // This is a send to a specific client eg from llRegionSayTo
242 // no need to check distance etc, jand send is as say
243 ScenePresence presence = scene.GetScenePresence(targetID);
244 if (presence != null && !presence.IsChildAgent)
245 {
246 if (TrySendChatMessage(
247 presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true))
248 receiverIDs.Add(presence.UUID);
249 }
250 }
251
252 scene.EventManager.TriggerOnChatToClients(
253 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); 337 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
254 } 338 }
255 339
@@ -291,9 +375,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
291 } 375 }
292 376
293 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); 377 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
294
295 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 378 HashSet<UUID> receiverIDs = new HashSet<UUID>();
296 379
380<<<<<<< HEAD
297 ((Scene)c.Scene).ForEachRootClient( 381 ((Scene)c.Scene).ForEachRootClient(
298 delegate(IClientAPI client) 382 delegate(IClientAPI client)
299 { 383 {
@@ -313,6 +397,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
313 397
314 (c.Scene as Scene).EventManager.TriggerOnChatToClients( 398 (c.Scene as Scene).EventManager.TriggerOnChatToClients(
315 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); 399 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
400=======
401 if (c.Scene != null)
402 {
403 ((Scene)c.Scene).ForEachRootClient
404 (
405 delegate(IClientAPI client)
406 {
407 // don't forward SayOwner chat from objects to
408 // non-owner agents
409 if ((c.Type == ChatTypeEnum.Owner) &&
410 (null != c.SenderObject) &&
411 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
412 return;
413
414 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID,
415 (byte)sourceType, (byte)ChatAudibleLevel.Fully);
416 receiverIDs.Add(client.AgentId);
417 }
418 );
419 (c.Scene as Scene).EventManager.TriggerOnChatToClients(
420 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
421 }
422>>>>>>> avn/ubitvar
316 } 423 }
317 424
318 /// <summary> 425 /// <summary>
@@ -364,6 +471,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
364 return true; 471 return true;
365 } 472 }
366 473
474 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
475 public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
476 {
477 System.Threading.Timer Timer;
478 if (flags == 0)
479 {
480 FreezeCache.Add(target.ToString());
481 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
482 Timer = new System.Threading.Timer(timeCB, target, 30000, 0);
483 Timers.Add(target, Timer);
484 }
485 else
486 {
487 FreezeCache.Remove(target.ToString());
488 Timers.TryGetValue(target, out Timer);
489 Timers.Remove(target);
490 Timer.Dispose();
491 }
492 }
493
494 private void OnEndParcelFrozen(object avatar)
495 {
496 UUID target = (UUID)avatar;
497 FreezeCache.Remove(target.ToString());
498 System.Threading.Timer Timer;
499 Timers.TryGetValue(target, out Timer);
500 Timers.Remove(target);
501 Timer.Dispose();
502 }
367 #region SimulatorFeaturesRequest 503 #region SimulatorFeaturesRequest
368 504
369 static OSDInteger m_SayRange, m_WhisperRange, m_ShoutRange; 505 static OSDInteger m_SayRange, m_WhisperRange, m_ShoutRange;
@@ -392,4 +528,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
392 528
393 #endregion 529 #endregion
394 } 530 }
395} \ No newline at end of file 531}
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
index fc23b72..b0b7054 100644
--- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
@@ -183,10 +183,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
183 try 183 try
184 { 184 {
185 ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 185 ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
186<<<<<<< HEAD
186 187
187 if (obj == null) 188 if (obj == null)
188 return; 189 return;
189 190
191=======
192 if (obj == null)
193 return;
194>>>>>>> avn/ubitvar
190 if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0 195 if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0
191 || avatar.Scene.RegionInfo.RegionSettings.AllowDamage) 196 || avatar.Scene.RegionInfo.RegionSettings.AllowDamage)
192 { 197 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index a896897..56819fa 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -203,8 +203,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
203 { 203 {
204 m_scene.ForEachRootClient(delegate(IClientAPI client) 204 m_scene.ForEachRootClient(delegate(IClientAPI client)
205 { 205 {
206 client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, 206 client.SendAgentAlertMessage(
207 message); 207 message, false);
208 }); 208 });
209 } 209 }
210 210
@@ -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 3b6d970..adb838c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -49,6 +49,8 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
49using OSDArray = OpenMetaverse.StructuredData.OSDArray; 49using OSDArray = OpenMetaverse.StructuredData.OSDArray;
50using OSDMap = OpenMetaverse.StructuredData.OSDMap; 50using OSDMap = OpenMetaverse.StructuredData.OSDMap;
51 51
52using Mono.Addins;
53
52namespace OpenSim.Region.CoreModules.Avatar.Gods 54namespace OpenSim.Region.CoreModules.Avatar.Gods
53{ 55{
54 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GodsModule")] 56 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GodsModule")]
@@ -62,6 +64,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
62 64
63 protected Scene m_scene; 65 protected Scene m_scene;
64 protected IDialogModule m_dialogModule; 66 protected IDialogModule m_dialogModule;
67
65 protected IDialogModule DialogModule 68 protected IDialogModule DialogModule
66 { 69 {
67 get 70 get
@@ -146,6 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
146 UUID godSessionID = userData["GodSessionID"].AsUUID(); 149 UUID godSessionID = userData["GodSessionID"].AsUUID();
147 uint kickFlags = userData["KickFlags"].AsUInteger(); 150 uint kickFlags = userData["KickFlags"].AsUInteger();
148 string reason = userData["Reason"].AsString(); 151 string reason = userData["Reason"].AsString();
152
149 ScenePresence god = m_scene.GetScenePresence(godID); 153 ScenePresence god = m_scene.GetScenePresence(godID);
150 if (god == null || god.ControllingClient.SessionId != godSessionID) 154 if (god == null || god.ControllingClient.SessionId != godSessionID)
151 return String.Empty; 155 return String.Empty;
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37
38using Mono.Addins;
39
40namespace 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 @@
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Reflection; 29using System.Reflection;
30using System.Timers;
30using log4net; 31using log4net;
31using Mono.Addins; 32using Mono.Addins;
32using Nini.Config; 33using 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 2462ff8..5573c94 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,34 +445,89 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
425 return resp; 445 return resp;
426 } 446 }
427 447
448<<<<<<< HEAD
428 /// <summary> 449 /// <summary>
429 /// delegate for sending a grid instant message asynchronously 450 /// delegate for sending a grid instant message asynchronously
430 /// </summary> 451 /// </summary>
431 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); 452 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
453=======
454 private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
455>>>>>>> avn/ubitvar
432 456
433 protected virtual void GridInstantMessageCompleted(IAsyncResult iar) 457 private class GIM {
434 { 458 public GridInstantMessage im;
435 GridInstantMessageDelegate icon = 459 public MessageResultNotification result;
436 (GridInstantMessageDelegate)iar.AsyncState; 460 };
437 icon.EndInvoke(iar);
438 }
439 461
462 private Queue<GIM> pendingInstantMessages = new Queue<GIM>();
463 private int numInstantMessageThreads = 0;
440 464
441 protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) 465 private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result)
442 { 466 {
443 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; 467 lock (pendingInstantMessages) {
468 if (numInstantMessageThreads >= 4) {
469 GIM gim = new GIM();
470 gim.im = im;
471 gim.result = result;
472 pendingInstantMessages.Enqueue(gim);
473 } else {
474 ++ numInstantMessageThreads;
475 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads);
476 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain;
477 d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
478 }
479 }
480 }
444 481
482<<<<<<< HEAD
445 d.BeginInvoke(im, result, GridInstantMessageCompleted, d); 483 d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
484=======
485 private void GridInstantMessageCompleted(IAsyncResult iar)
486 {
487 GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState;
488 d.EndInvoke(iar);
489>>>>>>> avn/ubitvar
446 } 490 }
447 491
448 /// <summary> 492 /// <summary>
449 /// Internal SendGridInstantMessage over XMLRPC method. 493 /// Internal SendGridInstantMessage over XMLRPC method.
450 /// </summary> 494 /// </summary>
495<<<<<<< HEAD
451 /// <remarks> 496 /// <remarks>
452 /// This is called from within a dedicated thread. 497 /// This is called from within a dedicated thread.
453 /// </remarks> 498 /// </remarks>
454 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result) 499 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result)
500=======
501 /// <param name="prevRegionHandle">
502 /// Pass in 0 the first time this method is called. It will be called recursively with the last
503 /// regionhandle tried
504 /// </param>
505 private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result)
506>>>>>>> avn/ubitvar
455 { 507 {
508 GIM gim;
509 do {
510 try {
511 SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero);
512 } catch (Exception e) {
513 m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message);
514 }
515 lock (pendingInstantMessages) {
516 if (pendingInstantMessages.Count > 0) {
517 gim = pendingInstantMessages.Dequeue();
518 im = gim.im;
519 result = gim.result;
520 } else {
521 gim = null;
522 -- numInstantMessageThreads;
523 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads);
524 }
525 }
526 } while (gim != null);
527 }
528 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
529 {
530
456 UUID toAgentID = new UUID(im.toAgentID); 531 UUID toAgentID = new UUID(im.toAgentID);
457 UUID regionID; 532 UUID regionID;
458 bool needToLookupAgent; 533 bool needToLookupAgent;
@@ -494,6 +569,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
494 break; 569 break;
495 } 570 }
496 571
572<<<<<<< HEAD
497 // Try to send the message to the agent via the retrieved region. 573 // Try to send the message to the agent via the retrieved region.
498 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); 574 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
499 msgdata["region_handle"] = 0; 575 msgdata["region_handle"] = 0;
@@ -501,6 +577,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
501 577
502 // If the message delivery was successful, then cache the entry. 578 // If the message delivery was successful, then cache the entry.
503 if (imresult) 579 if (imresult)
580=======
581 if (upd != null)
582 {
583 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(UUID.Zero,
584 upd.RegionID);
585 if (reginfo != null)
586>>>>>>> avn/ubitvar
504 { 587 {
505 lock (m_UserRegionMap) 588 lock (m_UserRegionMap)
506 { 589 {
@@ -622,6 +705,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
622 gim["position_z"] = msg.Position.Z.ToString(); 705 gim["position_z"] = msg.Position.Z.ToString();
623 gim["region_id"] = new UUID(msg.RegionID).ToString(); 706 gim["region_id"] = new UUID(msg.RegionID).ToString();
624 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); 707 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None);
708 if (m_MessageKey != String.Empty)
709 gim["message_key"] = m_MessageKey;
625 return gim; 710 return gim;
626 } 711 }
627 712
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index c75920d..76023bd 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -40,6 +40,13 @@ using OpenSim.Region.Framework.Scenes;
40 40
41namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 41namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
42{ 42{
43 public struct SendReply
44 {
45 public bool Success;
46 public string Message;
47 public int Disposition;
48 }
49
43 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "OfflineMessageModule")] 50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "OfflineMessageModule")]
44 public class OfflineMessageModule : ISharedRegionModule 51 public class OfflineMessageModule : ISharedRegionModule
45 { 52 {
@@ -50,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
50 private string m_RestURL = String.Empty; 57 private string m_RestURL = String.Empty;
51 IMessageTransferModule m_TransferModule = null; 58 IMessageTransferModule m_TransferModule = null;
52 private bool m_ForwardOfflineGroupMessages = true; 59 private bool m_ForwardOfflineGroupMessages = true;
60 private Dictionary<IClientAPI, List<UUID>> m_repliesSent= new Dictionary<IClientAPI, List<UUID>>();
53 61
54 public void Initialise(IConfigSource config) 62 public void Initialise(IConfigSource config)
55 { 63 {
@@ -169,11 +177,21 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
169 private void OnNewClient(IClientAPI client) 177 private void OnNewClient(IClientAPI client)
170 { 178 {
171 client.OnRetrieveInstantMessages += RetrieveInstantMessages; 179 client.OnRetrieveInstantMessages += RetrieveInstantMessages;
180 client.OnLogout += OnClientLoggedOut;
181 }
182
183 public void OnClientLoggedOut(IClientAPI client)
184 {
185 m_repliesSent.Remove(client);
172 } 186 }
173 187
174 private void RetrieveInstantMessages(IClientAPI client) 188 private void RetrieveInstantMessages(IClientAPI client)
175 { 189 {
176 if (m_RestURL != "") 190 if (m_RestURL == String.Empty)
191 {
192 return;
193 }
194 else
177 { 195 {
178 m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); 196 m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId);
179 197
@@ -181,28 +199,28 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
181 = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( 199 = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>(
182 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); 200 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
183 201
184 if (msglist == null) 202 if (msglist != null)
185 { 203 {
186 m_log.WarnFormat("[OFFLINE MESSAGING]: WARNING null message list."); 204 foreach (GridInstantMessage im in msglist)
187 return;
188 }
189
190 foreach (GridInstantMessage im in msglist)
191 {
192 if (im.dialog == (byte)InstantMessageDialog.InventoryOffered)
193 // send it directly or else the item will be given twice
194 client.SendInstantMessage(im);
195 else
196 { 205 {
197 // Send through scene event manager so all modules get a chance 206 if (im.dialog == (byte)InstantMessageDialog.InventoryOffered)
198 // to look at this message before it gets delivered. 207 // send it directly or else the item will be given twice
199 // 208 client.SendInstantMessage(im);
200 // Needed for proper state management for stored group 209 else
201 // invitations 210 {
202 // 211 // Send through scene event manager so all modules get a chance
203 Scene s = FindScene(client.AgentId); 212 // to look at this message before it gets delivered.
204 if (s != null) 213 //
205 s.EventManager.TriggerIncomingInstantMessage(im); 214 // Needed for proper state management for stored group
215 // invitations
216 //
217
218 im.offline = 1;
219
220 Scene s = FindScene(client.AgentId);
221 if (s != null)
222 s.EventManager.TriggerIncomingInstantMessage(im);
223 }
206 } 224 }
207 } 225 }
208 } 226 }
@@ -214,11 +232,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
214 im.dialog != (byte)InstantMessageDialog.MessageFromAgent && 232 im.dialog != (byte)InstantMessageDialog.MessageFromAgent &&
215 im.dialog != (byte)InstantMessageDialog.GroupNotice && 233 im.dialog != (byte)InstantMessageDialog.GroupNotice &&
216 im.dialog != (byte)InstantMessageDialog.GroupInvitation && 234 im.dialog != (byte)InstantMessageDialog.GroupInvitation &&
217 im.dialog != (byte)InstantMessageDialog.InventoryOffered) 235 im.dialog != (byte)InstantMessageDialog.InventoryOffered &&
236 im.dialog != (byte)InstantMessageDialog.TaskInventoryOffered)
218 { 237 {
219 return; 238 return;
220 } 239 }
221 240
241<<<<<<< HEAD
222 if (!m_ForwardOfflineGroupMessages) 242 if (!m_ForwardOfflineGroupMessages)
223 { 243 {
224 if (im.dialog == (byte)InstantMessageDialog.GroupNotice || 244 if (im.dialog == (byte)InstantMessageDialog.GroupNotice ||
@@ -228,6 +248,15 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
228 248
229 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( 249 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
230 "POST", m_RestURL+"/SaveMessage/", im, 10000); 250 "POST", m_RestURL+"/SaveMessage/", im, 10000);
251=======
252 Scene scene = FindScene(new UUID(im.fromAgentID));
253 if (scene == null)
254 scene = m_SceneList[0];
255
256 SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>(
257 "POST", m_RestURL+"/SaveMessage/?scope=" +
258 scene.RegionInfo.ScopeID.ToString(), im);
259>>>>>>> avn/ubitvar
231 260
232 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 261 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
233 { 262 {
@@ -235,13 +264,38 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
235 if (client == null) 264 if (client == null)
236 return; 265 return;
237 266
238 client.SendInstantMessage(new GridInstantMessage( 267 if (reply.Message == String.Empty)
239 null, new UUID(im.toAgentID), 268 reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved");
240 "System", new UUID(im.fromAgentID), 269
241 (byte)InstantMessageDialog.MessageFromAgent, 270 bool sendReply = true;
242 "User is not logged in. "+ 271
243 (success ? "Message saved." : "Message not saved"), 272 switch (reply.Disposition)
244 false, new Vector3())); 273 {
274 case 0: // Normal
275 break;
276 case 1: // Only once per user
277 if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID)))
278 {
279 sendReply = false;
280 }
281 else
282 {
283 if (!m_repliesSent.ContainsKey(client))
284 m_repliesSent[client] = new List<UUID>();
285 m_repliesSent[client].Add(new UUID(im.toAgentID));
286 }
287 break;
288 }
289
290 if (sendReply)
291 {
292 client.SendInstantMessage(new GridInstantMessage(
293 null, new UUID(im.toAgentID),
294 "System", new UUID(im.fromAgentID),
295 (byte)InstantMessageDialog.MessageFromAgent,
296 reply.Message,
297 false, new Vector3()));
298 }
245 } 299 }
246 } 300 }
247 } 301 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 420520e..5295ba3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -566,6 +566,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
566 return null; 566 return null;
567 } 567 }
568 568
569 return account;
570 /*
569 try 571 try
570 { 572 {
571 string encpass = Util.Md5Hash(pass); 573 string encpass = Util.Md5Hash(pass);
@@ -586,6 +588,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
586 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e); 588 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e);
587 return null; 589 return null;
588 } 590 }
591 */
589 } 592 }
590 593
591 /// <summary> 594 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index bba48cc..18e18a9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -165,8 +165,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
165 if (im.binaryBucket.Length < 17) // Invalid 165 if (im.binaryBucket.Length < 17) // Invalid
166 return; 166 return;
167 167
168 UUID receipientID = new UUID(im.toAgentID); 168 UUID recipientID = new UUID(im.toAgentID);
169 ScenePresence user = scene.GetScenePresence(receipientID); 169 ScenePresence user = scene.GetScenePresence(recipientID);
170 UUID copyID; 170 UUID copyID;
171 171
172 // First byte is the asset type 172 // First byte is the asset type
@@ -180,8 +180,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
180 "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory", 180 "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory",
181 folderID, new UUID(im.toAgentID)); 181 folderID, new UUID(im.toAgentID));
182 182
183<<<<<<< HEAD
183 InventoryFolderBase folderCopy 184 InventoryFolderBase folderCopy
184 = scene.GiveInventoryFolder(client, receipientID, client.AgentId, folderID, UUID.Zero); 185 = scene.GiveInventoryFolder(client, receipientID, client.AgentId, folderID, UUID.Zero);
186=======
187 InventoryFolderBase folderCopy
188 = scene.GiveInventoryFolder(recipientID, client.AgentId, folderID, UUID.Zero);
189>>>>>>> avn/ubitvar
185 190
186 if (folderCopy == null) 191 if (folderCopy == null)
187 { 192 {
@@ -239,6 +244,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
239 im.imSessionID = copyID.Guid; 244 im.imSessionID = copyID.Guid;
240 } 245 }
241 246
247 im.offline = 0;
248
242 // Send the IM to the recipient. The item is already 249 // Send the IM to the recipient. The item is already
243 // in their inventory, so it will not be lost if 250 // in their inventory, so it will not be lost if
244 // they are offline. 251 // they are offline.
@@ -258,8 +265,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
258 }); 265 });
259 } 266 }
260 } 267 }
261 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) 268 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted ||
269 im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted)
262 { 270 {
271 UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
272 IInventoryService invService = scene.InventoryService;
273
274 // Special case: folder redirect.
275 // RLV uses this
276 if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted)
277 {
278 InventoryFolderBase folder = new InventoryFolderBase(inventoryID, client.AgentId);
279 folder = invService.GetFolder(folder);
280
281 if (folder != null)
282 {
283 if (im.binaryBucket.Length >= 16)
284 {
285 UUID destFolderID = new UUID(im.binaryBucket, 0);
286 if (destFolderID != UUID.Zero)
287 {
288 InventoryFolderBase destFolder = new InventoryFolderBase(destFolderID, client.AgentId);
289 destFolder = invService.GetFolder(destFolder);
290 if (destFolder != null)
291 {
292 if (folder.ParentID != destFolder.ID)
293 {
294 folder.ParentID = destFolder.ID;
295 invService.MoveFolder(folder);
296 client.SendBulkUpdateInventory(folder);
297 }
298 }
299 }
300 }
301 }
302 }
303
263 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); 304 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
264 305
265 if (user != null) // Local 306 if (user != null) // Local
@@ -269,27 +310,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
269 else 310 else
270 { 311 {
271 if (m_TransferModule != null) 312 if (m_TransferModule != null)
272 m_TransferModule.SendInstantMessage(im, delegate(bool success) { 313 m_TransferModule.SendInstantMessage(im, delegate(bool success) {});
273
274 // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011
275 // and is apparently supposed to fix bulk inventory updates after accepting items. But
276 // instead it appears to cause two copies of an accepted folder for the receiving user in
277 // at least some cases. Folder/item update is already done when the offer is made (see code above)
278
279// // Send BulkUpdateInventory
280// IInventoryService invService = scene.InventoryService;
281// UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip
282//
283// InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId);
284// folder = invService.GetFolder(folder);
285//
286// ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID));
287//
288// // If the user has left the scene by the time the message comes back then we can't send
289// // them the update.
290// if (fromUser != null)
291// fromUser.ControllingClient.SendBulkUpdateInventory(folder);
292 });
293 } 314 }
294 } 315 }
295 316
@@ -402,6 +423,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
402 previousParentFolderID = folder.ParentID; 423 previousParentFolderID = folder.ParentID;
403 folder.ParentID = trashFolder.ID; 424 folder.ParentID = trashFolder.ID;
404 invService.MoveFolder(folder); 425 invService.MoveFolder(folder);
426 client.SendBulkUpdateInventory(folder);
405 } 427 }
406 } 428 }
407 429
@@ -453,6 +475,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
453 /// <param name="im"></param> 475 /// <param name="im"></param>
454 private void OnGridInstantMessage(GridInstantMessage im) 476 private void OnGridInstantMessage(GridInstantMessage im)
455 { 477 {
478<<<<<<< HEAD
456 // Check if it's a type of message that we should handle 479 // Check if it's a type of message that we should handle
457 if (!((im.dialog == (byte) InstantMessageDialog.InventoryOffered) 480 if (!((im.dialog == (byte) InstantMessageDialog.InventoryOffered)
458 || (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered) 481 || (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered)
@@ -465,6 +488,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
465 "[INVENTORY TRANSFER]: {0} IM type received from grid. From={1} ({2}), To={3}", 488 "[INVENTORY TRANSFER]: {0} IM type received from grid. From={1} ({2}), To={3}",
466 (InstantMessageDialog)im.dialog, im.fromAgentID, im.fromAgentName, im.toAgentID); 489 (InstantMessageDialog)im.dialog, im.fromAgentID, im.fromAgentName, im.toAgentID);
467 490
491=======
492>>>>>>> avn/ubitvar
468 // Check if this is ours to handle 493 // Check if this is ours to handle
469 // 494 //
470 Scene scene = FindClientScene(new UUID(im.toAgentID)); 495 Scene scene = FindClientScene(new UUID(im.toAgentID));
@@ -475,32 +500,100 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
475 // Find agent to deliver to 500 // Find agent to deliver to
476 // 501 //
477 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); 502 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
503 if (user == null)
504 return;
478 505
479 if (user != null) 506 // This requires a little bit of processing because we have to make the
507 // new item visible in the recipient's inventory here
508 //
509 if (im.dialog == (byte) InstantMessageDialog.InventoryOffered)
480 { 510 {
481 user.ControllingClient.SendInstantMessage(im); 511 if (im.binaryBucket.Length < 17) // Invalid
512 return;
513
514 UUID recipientID = new UUID(im.toAgentID);
482 515
483 if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) 516 // First byte is the asset type
484 { 517 AssetType assetType = (AssetType)im.binaryBucket[0];
485 AssetType assetType = (AssetType)im.binaryBucket[0];
486 UUID inventoryID = new UUID(im.binaryBucket, 1);
487 518
488 IInventoryService invService = scene.InventoryService; 519 if (AssetType.Folder == assetType)
489 InventoryNodeBase node = null; 520 {
490 if (AssetType.Folder == assetType) 521 UUID folderID = new UUID(im.binaryBucket, 1);
522
523 InventoryFolderBase given =
524 new InventoryFolderBase(folderID, recipientID);
525 InventoryFolderBase folder =
526 scene.InventoryService.GetFolder(given);
527
528 if (folder != null)
529 user.ControllingClient.SendBulkUpdateInventory(folder);
530 }
531 else
532 {
533 UUID itemID = new UUID(im.binaryBucket, 1);
534
535 InventoryItemBase given =
536 new InventoryItemBase(itemID, recipientID);
537 InventoryItemBase item =
538 scene.InventoryService.GetItem(given);
539
540 if (item != null)
491 { 541 {
492 InventoryFolderBase folder = new InventoryFolderBase(inventoryID, new UUID(im.toAgentID)); 542 user.ControllingClient.SendBulkUpdateInventory(item);
493 node = invService.GetFolder(folder);
494 } 543 }
495 else 544 }
545 user.ControllingClient.SendInstantMessage(im);
546 }
547 if (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered)
548 {
549 if (im.binaryBucket.Length < 1) // Invalid
550 return;
551
552 UUID recipientID = new UUID(im.toAgentID);
553
554 // Bucket is the asset type
555 AssetType assetType = (AssetType)im.binaryBucket[0];
556
557 if (AssetType.Folder == assetType)
558 {
559 UUID folderID = new UUID(im.imSessionID);
560
561 InventoryFolderBase given =
562 new InventoryFolderBase(folderID, recipientID);
563 InventoryFolderBase folder =
564 scene.InventoryService.GetFolder(given);
565
566 if (folder != null)
567 user.ControllingClient.SendBulkUpdateInventory(folder);
568 }
569 else
570 {
571 UUID itemID = new UUID(im.imSessionID);
572
573 InventoryItemBase given =
574 new InventoryItemBase(itemID, recipientID);
575 InventoryItemBase item =
576 scene.InventoryService.GetItem(given);
577
578 if (item != null)
496 { 579 {
497 InventoryItemBase item = new InventoryItemBase(inventoryID, new UUID(im.toAgentID)); 580 user.ControllingClient.SendBulkUpdateInventory(item);
498 node = invService.GetItem(item);
499 } 581 }
500
501 if (node != null)
502 user.ControllingClient.SendBulkUpdateInventory(node);
503 } 582 }
583
584 // Fix up binary bucket since this may be 17 chars long here
585 Byte[] bucket = new Byte[1];
586 bucket[0] = im.binaryBucket[0];
587 im.binaryBucket = bucket;
588
589 user.ControllingClient.SendInstantMessage(im);
590 }
591 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted ||
592 im.dialog == (byte) InstantMessageDialog.InventoryDeclined ||
593 im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined ||
594 im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted)
595 {
596 user.ControllingClient.SendInstantMessage(im);
504 } 597 }
505 } 598 }
506 } 599 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
index 465ffbc..c517a30 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("[LURE MODULE]: TP invite with message {0}, type {1}", message, lureType); 168 m_log.DebugFormat("[LURE MODULE]: TP invite with message {0}, type {1}", message, lureType);
169 169
170 GridInstantMessage m = new GridInstantMessage(scene, client.AgentId, 170 GridInstantMessage m;
171 client.FirstName+" "+client.LastName, targetid, 171
172 (byte)InstantMessageDialog.RequestTeleport, false, 172 if (scene.Permissions.IsAdministrator(client.AgentId) && presence.GodLevel >= 200 && (!scene.Permissions.IsAdministrator(targetid)))
173 message, dest, false, presence.AbsolutePosition, 173 {
174 new Byte[0], true); 174 m = new GridInstantMessage(scene, client.AgentId,
175 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 }
188
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/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index c20369c..bea2834 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -288,10 +288,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
288 // Notes 288 // Notes
289 client.AddGenericPacketHandler("avatarnotesrequest", NotesRequest); 289 client.AddGenericPacketHandler("avatarnotesrequest", NotesRequest);
290 client.OnAvatarNotesUpdate += NotesUpdate; 290 client.OnAvatarNotesUpdate += NotesUpdate;
291
292 // Preferences
293 client.OnUserInfoRequest += UserPreferencesRequest;
294 client.OnUpdateUserInfo += UpdateUserPreferences;
295 } 291 }
296 #endregion Region Event Handlers 292 #endregion Region Event Handlers
297 293
@@ -873,6 +869,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
873 } 869 }
874 #endregion Notes 870 #endregion Notes
875 871
872<<<<<<< HEAD
876 #region User Preferences 873 #region User Preferences
877 /// <summary> 874 /// <summary>
878 /// Updates the user preferences. 875 /// Updates the user preferences.
@@ -936,6 +933,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
936 } 933 }
937 #endregion User Preferences 934 #endregion User Preferences
938 935
936=======
937>>>>>>> avn/ubitvar
939 #region Avatar Properties 938 #region Avatar Properties
940 /// <summary> 939 /// <summary>
941 /// Update the avatars interests . 940 /// Update the avatars interests .
@@ -1402,5 +1401,185 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
1402 return null; 1401 return null;
1403 } 1402 }
1404 #endregion Util 1403 #endregion Util
1404<<<<<<< HEAD
1405=======
1406
1407 #region Web Util
1408 /// <summary>
1409 /// Sends json-rpc request with a serializable type.
1410 /// </summary>
1411 /// <returns>
1412 /// OSD Map.
1413 /// </returns>
1414 /// <param name='parameters'>
1415 /// Serializable type .
1416 /// </param>
1417 /// <param name='method'>
1418 /// Json-rpc method to call.
1419 /// </param>
1420 /// <param name='uri'>
1421 /// URI of json-rpc service.
1422 /// </param>
1423 /// <param name='jsonId'>
1424 /// Id for our call.
1425 /// </param>
1426 bool JsonRpcRequest(ref object parameters, string method, string uri, string jsonId)
1427 {
1428 if (jsonId == null)
1429 throw new ArgumentNullException ("jsonId");
1430 if (uri == null)
1431 throw new ArgumentNullException ("uri");
1432 if (method == null)
1433 throw new ArgumentNullException ("method");
1434 if (parameters == null)
1435 throw new ArgumentNullException ("parameters");
1436
1437 // Prep our payload
1438 OSDMap json = new OSDMap();
1439
1440 json.Add("jsonrpc", OSD.FromString("2.0"));
1441 json.Add("id", OSD.FromString(jsonId));
1442 json.Add("method", OSD.FromString(method));
1443
1444 json.Add("params", OSD.SerializeMembers(parameters));
1445
1446 string jsonRequestData = OSDParser.SerializeJsonString(json);
1447 byte[] content = Encoding.UTF8.GetBytes(jsonRequestData);
1448
1449 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
1450
1451 webRequest.ContentType = "application/json-rpc";
1452 webRequest.Method = "POST";
1453
1454 Stream dataStream = webRequest.GetRequestStream();
1455 dataStream.Write(content, 0, content.Length);
1456 dataStream.Close();
1457
1458 WebResponse webResponse = null;
1459 try
1460 {
1461 webResponse = webRequest.GetResponse();
1462 }
1463 catch (WebException e)
1464 {
1465 Console.WriteLine("Web Error" + e.Message);
1466 Console.WriteLine ("Please check input");
1467 return false;
1468 }
1469
1470 OSDMap mret = new OSDMap();
1471
1472 using (Stream rstream = webResponse.GetResponseStream())
1473 {
1474 try
1475 {
1476 mret = (OSDMap)OSDParser.DeserializeJson(rstream);
1477 }
1478 catch (Exception e)
1479 {
1480 m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message);
1481 if (webResponse != null)
1482 webResponse.Close();
1483 return false;
1484 }
1485 }
1486
1487 if (webResponse != null)
1488 webResponse.Close();
1489
1490 if (mret.ContainsKey("error"))
1491 return false;
1492
1493 // get params...
1494 OSD.DeserializeMembers(ref parameters, (OSDMap) mret["result"]);
1495 return true;
1496 }
1497
1498 /// <summary>
1499 /// Sends json-rpc request with OSD parameter.
1500 /// </summary>
1501 /// <returns>
1502 /// The rpc request.
1503 /// </returns>
1504 /// <param name='data'>
1505 /// data - incoming as parameters, outgong as result/error
1506 /// </param>
1507 /// <param name='method'>
1508 /// Json-rpc method to call.
1509 /// </param>
1510 /// <param name='uri'>
1511 /// URI of json-rpc service.
1512 /// </param>
1513 /// <param name='jsonId'>
1514 /// If set to <c>true</c> json identifier.
1515 /// </param>
1516 bool JsonRpcRequest(ref OSD data, string method, string uri, string jsonId)
1517 {
1518 OSDMap map = new OSDMap();
1519
1520 map["jsonrpc"] = "2.0";
1521 if(string.IsNullOrEmpty(jsonId))
1522 map["id"] = UUID.Random().ToString();
1523 else
1524 map["id"] = jsonId;
1525
1526 map["method"] = method;
1527 map["params"] = data;
1528
1529 string jsonRequestData = OSDParser.SerializeJsonString(map);
1530 byte[] content = Encoding.UTF8.GetBytes(jsonRequestData);
1531
1532 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
1533 webRequest.ContentType = "application/json-rpc";
1534 webRequest.Method = "POST";
1535
1536 Stream dataStream = webRequest.GetRequestStream();
1537 dataStream.Write(content, 0, content.Length);
1538 dataStream.Close();
1539
1540 WebResponse webResponse = null;
1541 try
1542 {
1543 webResponse = webRequest.GetResponse();
1544 }
1545 catch (WebException e)
1546 {
1547 Console.WriteLine("Web Error" + e.Message);
1548 Console.WriteLine ("Please check input");
1549 return false;
1550 }
1551
1552 OSDMap response = new OSDMap();
1553
1554 using (Stream rstream = webResponse.GetResponseStream())
1555 {
1556 try
1557 {
1558 response = (OSDMap)OSDParser.DeserializeJson(rstream);
1559 }
1560 catch (Exception e)
1561 {
1562 m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message);
1563 if (webResponse != null)
1564 webResponse.Close();
1565 return false;
1566 }
1567 }
1568
1569 if (webResponse != null)
1570 webResponse.Close();
1571
1572 if(response.ContainsKey("error"))
1573 {
1574 data = response["error"];
1575 return false;
1576 }
1577
1578 data = response;
1579
1580 return true;
1581 }
1582 #endregion Web Util
1583>>>>>>> avn/ubitvar
1405 } 1584 }
1406} 1585}
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
index 817ef85..44eee89 100644
--- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.Framework
57 /// <summary> 57 /// <summary>
58 /// Each agent has its own capabilities handler. 58 /// Each agent has its own capabilities handler.
59 /// </summary> 59 /// </summary>
60 protected Dictionary<UUID, Caps> m_capsObjects = new Dictionary<UUID, Caps>(); 60 protected Dictionary<uint, Caps> m_capsObjects = new Dictionary<uint, Caps>();
61 61
62 protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>(); 62 protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>();
63 63
@@ -118,23 +118,46 @@ namespace OpenSim.Region.CoreModules.Framework
118 get { return null; } 118 get { return null; }
119 } 119 }
120 120
121 public void CreateCaps(UUID agentId) 121 public void CreateCaps(UUID agentId, uint circuitCode)
122 { 122 {
123 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) 123 int ts = Util.EnvironmentTickCount();
124 return; 124/* this as no business here...
125 * must be done elsewhere ( and is )
126 int flags = m_scene.GetUserFlags(agentId);
127
128 m_log.ErrorFormat("[CreateCaps]: banCheck {0} ", Util.EnvironmentTickCountSubtract(ts));
125 129
130 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
131 return;
132*/
126 Caps caps; 133 Caps caps;
127 String capsObjectPath = GetCapsPath(agentId); 134 String capsObjectPath = GetCapsPath(agentId);
128 135
129 lock (m_capsObjects) 136 lock (m_capsObjects)
130 { 137 {
131 if (m_capsObjects.ContainsKey(agentId)) 138 if (m_capsObjects.ContainsKey(circuitCode))
132 { 139 {
133 Caps oldCaps = m_capsObjects[agentId]; 140 Caps oldCaps = m_capsObjects[circuitCode];
134 141
135 //m_log.WarnFormat( 142
136 // "[CAPS]: Recreating caps for agent {0} in region {1}. Old caps path {2}, new caps path {3}. ", 143 if (capsObjectPath == oldCaps.CapsObjectPath)
137 // agentId, m_scene.RegionInfo.RegionName, oldCaps.CapsObjectPath, capsObjectPath); 144 {
145 m_log.WarnFormat(
146 "[CAPS]: Reusing caps for agent {0} in region {1}. Old caps path {2}, new caps path {3}. ",
147 agentId, m_scene.RegionInfo.RegionName, oldCaps.CapsObjectPath, capsObjectPath);
148 return;
149 }
150 else
151 {
152 // not reusing add extra melanie cleanup
153 // Remove tge handlers. They may conflict with the
154 // new object created below
155 oldCaps.DeregisterHandlers();
156
157 // Better safe ... should not be needed but also
158 // no big deal
159 m_capsObjects.Remove(circuitCode);
160 }
138 } 161 }
139 162
140// m_log.DebugFormat( 163// m_log.DebugFormat(
@@ -145,13 +168,17 @@ namespace OpenSim.Region.CoreModules.Framework
145 (MainServer.Instance == null) ? 0: MainServer.Instance.Port, 168 (MainServer.Instance == null) ? 0: MainServer.Instance.Port,
146 capsObjectPath, agentId, m_scene.RegionInfo.RegionName); 169 capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
147 170
148 m_capsObjects[agentId] = caps; 171 m_log.ErrorFormat("[CreateCaps]: new caps agent {0}, circuit {1}, path {2}, time {3} ",agentId,
149 } 172 circuitCode,caps.CapsObjectPath, Util.EnvironmentTickCountSubtract(ts));
150 173
174 m_capsObjects[circuitCode] = caps;
175 }
151 m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); 176 m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps);
177// m_log.ErrorFormat("[CreateCaps]: end {0} ", Util.EnvironmentTickCountSubtract(ts));
178
152 } 179 }
153 180
154 public void RemoveCaps(UUID agentId) 181 public void RemoveCaps(UUID agentId, uint circuitCode)
155 { 182 {
156 m_log.DebugFormat("[CAPS]: Remove caps for agent {0} in region {1}", agentId, m_scene.RegionInfo.RegionName); 183 m_log.DebugFormat("[CAPS]: Remove caps for agent {0} in region {1}", agentId, m_scene.RegionInfo.RegionName);
157 lock (m_childrenSeeds) 184 lock (m_childrenSeeds)
@@ -164,14 +191,24 @@ namespace OpenSim.Region.CoreModules.Framework
164 191
165 lock (m_capsObjects) 192 lock (m_capsObjects)
166 { 193 {
167 if (m_capsObjects.ContainsKey(agentId)) 194 if (m_capsObjects.ContainsKey(circuitCode))
168 { 195 {
169 m_capsObjects[agentId].DeregisterHandlers(); 196 m_capsObjects[circuitCode].DeregisterHandlers();
170 m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsObjects[agentId]); 197 m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsObjects[circuitCode]);
171 m_capsObjects.Remove(agentId); 198 m_capsObjects.Remove(circuitCode);
172 } 199 }
173 else 200 else
174 { 201 {
202 foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects)
203 {
204 if (kvp.Value.AgentID == agentId)
205 {
206 kvp.Value.DeregisterHandlers();
207 m_scene.EventManager.TriggerOnDeregisterCaps(agentId, kvp.Value);
208 m_capsObjects.Remove(kvp.Key);
209 return;
210 }
211 }
175 m_log.WarnFormat( 212 m_log.WarnFormat(
176 "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!", 213 "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!",
177 agentId, m_scene.RegionInfo.RegionName); 214 agentId, m_scene.RegionInfo.RegionName);
@@ -179,19 +216,30 @@ namespace OpenSim.Region.CoreModules.Framework
179 } 216 }
180 } 217 }
181 218
182 public Caps GetCapsForUser(UUID agentId) 219 public Caps GetCapsForUser(uint circuitCode)
183 { 220 {
184 lock (m_capsObjects) 221 lock (m_capsObjects)
185 { 222 {
186 if (m_capsObjects.ContainsKey(agentId)) 223 if (m_capsObjects.ContainsKey(circuitCode))
187 { 224 {
188 return m_capsObjects[agentId]; 225 return m_capsObjects[circuitCode];
189 } 226 }
190 } 227 }
191 228
192 return null; 229 return null;
193 } 230 }
194 231
232 public void ActivateCaps(uint circuitCode)
233 {
234 lock (m_capsObjects)
235 {
236 if (m_capsObjects.ContainsKey(circuitCode))
237 {
238 m_capsObjects[circuitCode].Activate();
239 }
240 }
241 }
242
195 public void SetAgentCapsSeeds(AgentCircuitData agent) 243 public void SetAgentCapsSeeds(AgentCircuitData agent)
196 { 244 {
197 lock (m_capsPaths) 245 lock (m_capsPaths)
@@ -289,9 +337,9 @@ namespace OpenSim.Region.CoreModules.Framework
289 337
290 lock (m_capsObjects) 338 lock (m_capsObjects)
291 { 339 {
292 foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects) 340 foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects)
293 { 341 {
294 capsReport.AppendFormat("** User {0}:\n", kvp.Key); 342 capsReport.AppendFormat("** Circuit {0}:\n", kvp.Key);
295 Caps caps = kvp.Value; 343 Caps caps = kvp.Value;
296 344
297 for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) 345 for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); )
@@ -339,6 +387,7 @@ namespace OpenSim.Region.CoreModules.Framework
339 387
340 private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName) 388 private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName)
341 { 389 {
390 /*
342 sb.AppendFormat("Capability name {0}\n", capName); 391 sb.AppendFormat("Capability name {0}\n", capName);
343 392
344 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 393 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
@@ -384,10 +433,12 @@ namespace OpenSim.Region.CoreModules.Framework
384 } 433 }
385 434
386 sb.Append(cdt.ToString()); 435 sb.Append(cdt.ToString());
436 */
387 } 437 }
388 438
389 private void BuildSummaryStatsByCapReport(StringBuilder sb) 439 private void BuildSummaryStatsByCapReport(StringBuilder sb)
390 { 440 {
441 /*
391 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 442 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
392 cdt.AddColumn("Name", 34); 443 cdt.AddColumn("Name", 34);
393 cdt.AddColumn("Req Received", 12); 444 cdt.AddColumn("Req Received", 12);
@@ -444,10 +495,12 @@ namespace OpenSim.Region.CoreModules.Framework
444 cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]); 495 cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
445 496
446 sb.Append(cdt.ToString()); 497 sb.Append(cdt.ToString());
498 */
447 } 499 }
448 500
449 private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams) 501 private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams)
450 { 502 {
503 /*
451 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) 504 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
452 return; 505 return;
453 506
@@ -478,10 +531,12 @@ namespace OpenSim.Region.CoreModules.Framework
478 } 531 }
479 532
480 MainConsole.Instance.Output(sb.ToString()); 533 MainConsole.Instance.Output(sb.ToString());
534 */
481 } 535 }
482 536
483 private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp) 537 private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp)
484 { 538 {
539 /*
485 sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root"); 540 sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root");
486 541
487 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 542 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
@@ -507,10 +562,12 @@ namespace OpenSim.Region.CoreModules.Framework
507 cdt.AddRow(ctr.Name, ctr.RequestsReceived, ctr.RequestsHandled); 562 cdt.AddRow(ctr.Name, ctr.RequestsReceived, ctr.RequestsHandled);
508 563
509 sb.Append(cdt.ToString()); 564 sb.Append(cdt.ToString());
565 */
510 } 566 }
511 567
512 private void BuildSummaryStatsByUserReport(StringBuilder sb) 568 private void BuildSummaryStatsByUserReport(StringBuilder sb)
513 { 569 {
570 /*
514 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 571 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
515 cdt.AddColumn("Name", 32); 572 cdt.AddColumn("Name", 32);
516 cdt.AddColumn("Type", 5); 573 cdt.AddColumn("Type", 5);
@@ -550,6 +607,7 @@ namespace OpenSim.Region.CoreModules.Framework
550 ); 607 );
551 608
552 sb.Append(cdt.ToString()); 609 sb.Append(cdt.ToString());
610 */
553 } 611 }
554 612
555 private class CapTableRow 613 private class CapTableRow
@@ -566,4 +624,4 @@ namespace OpenSim.Region.CoreModules.Framework
566 } 624 }
567 } 625 }
568 } 626 }
569} \ No newline at end of file 627}
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 4be19f0..7937383 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -154,12 +154,25 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
154 // Add this agent in this region as a banned person 154 // Add this agent in this region as a banned person
155 public void Add(ulong pRegionHandle, UUID pAgentID) 155 public void Add(ulong pRegionHandle, UUID pAgentID)
156 { 156 {
157<<<<<<< HEAD
157 if (!m_bannedRegions.TryGetValue(pAgentID, out m_idCache)) 158 if (!m_bannedRegions.TryGetValue(pAgentID, out m_idCache))
158 { 159 {
159 m_idCache = new ExpiringCache<ulong, DateTime>(); 160 m_idCache = new ExpiringCache<ulong, DateTime>();
160 m_bannedRegions.Add(pAgentID, m_idCache, TimeSpan.FromSeconds(45)); 161 m_bannedRegions.Add(pAgentID, m_idCache, TimeSpan.FromSeconds(45));
161 } 162 }
162 m_idCache.Add(pRegionHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); 163 m_idCache.Add(pRegionHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
164=======
165 this.Add(pRegionHandle, pAgentID, 45, 15);
166 }
167 public void Add(ulong pRegionHandle, UUID pAgentID, double newTime, double extendTime)
168 {
169 if (!m_bannedRegions.TryGetValue(pAgentID, out m_idCache))
170 {
171 m_idCache = new ExpiringCache<ulong, DateTime>();
172 m_bannedRegions.Add(pAgentID, m_idCache, TimeSpan.FromSeconds(newTime));
173 }
174 m_idCache.Add(pRegionHandle, DateTime.Now + TimeSpan.FromSeconds(extendTime), TimeSpan.FromSeconds(extendTime));
175>>>>>>> avn/ubitvar
163 } 176 }
164 // Remove the agent from the region's banned list 177 // Remove the agent from the region's banned list
165 public void Remove(ulong pRegionHandle, UUID pAgentID) 178 public void Remove(ulong pRegionHandle, UUID pAgentID)
@@ -209,6 +222,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
209 { 222 {
210 string transferVersionName = "SIMULATION"; 223 string transferVersionName = "SIMULATION";
211 float maxTransferVersion = 0.3f; 224 float maxTransferVersion = 0.3f;
225<<<<<<< HEAD
212 226
213 IConfig hypergridConfig = source.Configs["Hypergrid"]; 227 IConfig hypergridConfig = source.Configs["Hypergrid"];
214 if (hypergridConfig != null) 228 if (hypergridConfig != null)
@@ -221,6 +235,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
221 if (m_GatekeeperURI != string.Empty && !m_GatekeeperURI.EndsWith("/")) 235 if (m_GatekeeperURI != string.Empty && !m_GatekeeperURI.EndsWith("/"))
222 m_GatekeeperURI += '/'; 236 m_GatekeeperURI += '/';
223 } 237 }
238=======
239>>>>>>> avn/ubitvar
224 240
225 IConfig transferConfig = source.Configs["EntityTransfer"]; 241 IConfig transferConfig = source.Configs["EntityTransfer"];
226 if (transferConfig != null) 242 if (transferConfig != null)
@@ -491,16 +507,23 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
491 } 507 }
492 508
493 // TODO: Get proper AVG Height 509 // TODO: Get proper AVG Height
494 float localAVHeight = 1.56f; 510 float localHalfAVHeight = 0.8f;
511 if (sp.Appearance != null)
512 localHalfAVHeight = sp.Appearance.AvatarHeight / 2;
513
495 float posZLimit = 22; 514 float posZLimit = 22;
496 515
497 // TODO: Check other Scene HeightField 516 // TODO: Check other Scene HeightField
498 posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y]; 517 posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y];
518<<<<<<< HEAD
519=======
520
521 posZLimit += localHalfAVHeight + 0.1f;
522>>>>>>> avn/ubitvar
499 523
500 float newPosZ = posZLimit + localAVHeight; 524 if ((position.Z < posZLimit) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit)))
501 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
502 { 525 {
503 position.Z = newPosZ; 526 position.Z = posZLimit;
504 } 527 }
505 528
506 if (sp.Flying) 529 if (sp.Flying)
@@ -599,9 +622,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
599 Util.RegionHandleToRegionLoc(regionHandle, out regX, out regY); 622 Util.RegionHandleToRegionLoc(regionHandle, out regX, out regY);
600 623
601 MapBlockData block = new MapBlockData(); 624 MapBlockData block = new MapBlockData();
625<<<<<<< HEAD
602 block.X = (ushort)regX; 626 block.X = (ushort)regX;
603 block.Y = (ushort)regY; 627 block.Y = (ushort)regY;
604 block.Access = (byte)SimAccess.Down; 628 block.Access = (byte)SimAccess.Down;
629=======
630 block.X = (ushort)(regX);
631 block.Y = (ushort)(regY);
632 block.Access = (byte)SimAccess.Down; // == not there
633>>>>>>> avn/ubitvar
605 634
606 List<MapBlockData> blocks = new List<MapBlockData>(); 635 List<MapBlockData> blocks = new List<MapBlockData>();
607 blocks.Add(block); 636 blocks.Add(block);
@@ -736,10 +765,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
736 return; 765 return;
737 } 766 }
738 767
768<<<<<<< HEAD
739 uint newRegionX, newRegionY, oldRegionX, oldRegionY; 769 uint newRegionX, newRegionY, oldRegionX, oldRegionY;
740 Util.RegionHandleToRegionLoc(reg.RegionHandle, out newRegionX, out newRegionY); 770 Util.RegionHandleToRegionLoc(reg.RegionHandle, out newRegionX, out newRegionY);
741 Util.RegionHandleToRegionLoc(sp.Scene.RegionInfo.RegionHandle, out oldRegionX, out oldRegionY); 771 Util.RegionHandleToRegionLoc(sp.Scene.RegionInfo.RegionHandle, out oldRegionX, out oldRegionY);
742 772
773=======
774>>>>>>> avn/ubitvar
743 ulong destinationHandle = finalDestination.RegionHandle; 775 ulong destinationHandle = finalDestination.RegionHandle;
744 776
745 // Let's do DNS resolution only once in this process, please! 777 // Let's do DNS resolution only once in this process, please!
@@ -762,7 +794,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
762 string version; 794 string version;
763 string myversion = string.Format("{0}/{1}", OutgoingTransferVersionName, MaxOutgoingTransferVersion); 795 string myversion = string.Format("{0}/{1}", OutgoingTransferVersionName, MaxOutgoingTransferVersion);
764 if (!Scene.SimulationService.QueryAccess( 796 if (!Scene.SimulationService.QueryAccess(
797<<<<<<< HEAD
765 finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, myversion, sp.Scene.GetFormatsOffered(), out version, out reason)) 798 finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, myversion, sp.Scene.GetFormatsOffered(), out version, out reason))
799=======
800 finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, myversion, out version, out reason))
801>>>>>>> avn/ubitvar
766 { 802 {
767 sp.ControllingClient.SendTeleportFailed(reason); 803 sp.ControllingClient.SendTeleportFailed(reason);
768 804
@@ -808,7 +844,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
808 AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); 844 AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
809 agentCircuit.startpos = position; 845 agentCircuit.startpos = position;
810 agentCircuit.child = true; 846 agentCircuit.child = true;
811 agentCircuit.Appearance = sp.Appearance; 847
848// agentCircuit.Appearance = sp.Appearance;
849// agentCircuit.Appearance = new AvatarAppearance(sp.Appearance, true, false);
850 agentCircuit.Appearance = new AvatarAppearance();
851 agentCircuit.Appearance.AvatarHeight = sp.Appearance.AvatarHeight;
852
812 if (currentAgentCircuit != null) 853 if (currentAgentCircuit != null)
813 { 854 {
814 agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; 855 agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs;
@@ -819,14 +860,48 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
819 agentCircuit.Id0 = currentAgentCircuit.Id0; 860 agentCircuit.Id0 = currentAgentCircuit.Id0;
820 } 861 }
821 862
863<<<<<<< HEAD
822 // if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) 864 // if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
823 float dist = (float)Math.Max(sp.Scene.DefaultDrawDistance, 865 float dist = (float)Math.Max(sp.Scene.DefaultDrawDistance,
824 (float)Math.Max(sp.Scene.RegionInfo.RegionSizeX, sp.Scene.RegionInfo.RegionSizeY)); 866 (float)Math.Max(sp.Scene.RegionInfo.RegionSizeX, sp.Scene.RegionInfo.RegionSizeY));
825 if (NeedsNewAgent(dist, oldRegionX, newRegionX, oldRegionY, newRegionY)) 867 if (NeedsNewAgent(dist, oldRegionX, newRegionX, oldRegionY, newRegionY))
868=======
869 IClientIPEndpoint ipepClient;
870
871 uint newRegionX, newRegionY, oldRegionX, oldRegionY;
872 Util.RegionHandleToRegionLoc(destinationHandle, out newRegionX, out newRegionY);
873 Util.RegionHandleToRegionLoc(sourceRegion.RegionHandle, out oldRegionX, out oldRegionY);
874 int oldSizeX = (int)sourceRegion.RegionSizeX;
875 int oldSizeY = (int)sourceRegion.RegionSizeY;
876 int newSizeX = finalDestination.RegionSizeX;
877 int newSizeY = finalDestination.RegionSizeY;
878
879 bool OutSideViewRange = NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY,
880 oldSizeX, oldSizeY, newSizeX, newSizeY);
881
882 if (OutSideViewRange)
883>>>>>>> avn/ubitvar
826 { 884 {
827 // brand new agent, let's create a new caps seed 885 m_log.DebugFormat(
886 "[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} needs new child agent for agent {3} from {4}",
887 finalDestination.RegionName, newRegionX, newRegionY, sp.Name, Scene.Name);
888
889 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
890 #region IP Translation for NAT
891 // Uses ipepClient above
892 if (sp.ClientView.TryGet(out ipepClient))
893 {
894 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
895 }
896 #endregion
828 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); 897 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
829 } 898 }
899 else
900 {
901 agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle);
902 if (agentCircuit.CapsPath == null)
903 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
904 }
830 905
831 // We're going to fallback to V1 if the destination gives us anything smaller than 0.2 or we're forcing 906 // We're going to fallback to V1 if the destination gives us anything smaller than 0.2 or we're forcing
832 // use of the earlier protocol 907 // use of the earlier protocol
@@ -836,13 +911,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
836 float.TryParse(versionComponents[1], out versionNumber); 911 float.TryParse(versionComponents[1], out versionNumber);
837 912
838 if (versionNumber >= 0.2f && MaxOutgoingTransferVersion >= versionNumber) 913 if (versionNumber >= 0.2f && MaxOutgoingTransferVersion >= versionNumber)
914<<<<<<< HEAD
839 TransferAgent_V2(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason); 915 TransferAgent_V2(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason);
916=======
917 TransferAgent_V2(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, OutSideViewRange , version, out reason);
918>>>>>>> avn/ubitvar
840 else 919 else
841 TransferAgent_V1(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason); 920 TransferAgent_V1(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, OutSideViewRange, version, out reason);
842 } 921 }
843 922
844 private void TransferAgent_V1(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination, 923 private void TransferAgent_V1(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination,
845 IPEndPoint endPoint, uint teleportFlags, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, string version, out string reason) 924 IPEndPoint endPoint, uint teleportFlags, bool OutSideViewRange, string version, out string reason)
846 { 925 {
847 ulong destinationHandle = finalDestination.RegionHandle; 926 ulong destinationHandle = finalDestination.RegionHandle;
848 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 927 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
@@ -851,6 +930,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
851 "[ENTITY TRANSFER MODULE]: Using TP V1 for {0} going from {1} to {2}", 930 "[ENTITY TRANSFER MODULE]: Using TP V1 for {0} going from {1} to {2}",
852 sp.Name, Scene.Name, finalDestination.RegionName); 931 sp.Name, Scene.Name, finalDestination.RegionName);
853 932
933 string capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
934
854 // Let's create an agent there if one doesn't exist yet. 935 // Let's create an agent there if one doesn't exist yet.
855 // NOTE: logout will always be false for a non-HG teleport. 936 // NOTE: logout will always be false for a non-HG teleport.
856 bool logout = false; 937 bool logout = false;
@@ -892,6 +973,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
892 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); 973 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
893 974
894 // OK, it got this agent. Let's close some child agents 975 // OK, it got this agent. Let's close some child agents
976<<<<<<< HEAD
895 sp.CloseChildAgents(newRegionX, newRegionY); 977 sp.CloseChildAgents(newRegionX, newRegionY);
896 978
897 IClientIPEndpoint ipepClient; 979 IClientIPEndpoint ipepClient;
@@ -903,17 +985,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
903 m_log.DebugFormat( 985 m_log.DebugFormat(
904 "[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} needs new child agent for incoming agent {3} from {4}", 986 "[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} needs new child agent for incoming agent {3} from {4}",
905 finalDestination.RegionName, newRegionX, newRegionY, sp.Name, Scene.Name); 987 finalDestination.RegionName, newRegionX, newRegionY, sp.Name, Scene.Name);
988=======
989>>>>>>> avn/ubitvar
906 990
907 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
908 #region IP Translation for NAT
909 // Uses ipepClient above
910 if (sp.ClientView.TryGet(out ipepClient))
911 {
912 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
913 }
914 #endregion
915 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
916 991
992 if (OutSideViewRange)
993 {
917 if (m_eqModule != null) 994 if (m_eqModule != null)
918 { 995 {
919 // The EnableSimulator message makes the client establish a connection with the destination 996 // The EnableSimulator message makes the client establish a connection with the destination
@@ -943,15 +1020,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
943 sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); 1020 sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint);
944 } 1021 }
945 } 1022 }
946 else
947 {
948 agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle);
949 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
950 }
951 1023
952 // Let's send a full update of the agent. This is a synchronous call. 1024 // Let's send a full update of the agent. This is a synchronous call.
953 AgentData agent = new AgentData(); 1025 AgentData agent = new AgentData();
954 sp.CopyTo(agent); 1026 sp.CopyTo(agent);
1027
1028 if ((teleportFlags & (uint)TeleportFlags.IsFlying) != 0)
1029 agent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1030
955 agent.Position = agentCircuit.startpos; 1031 agent.Position = agentCircuit.startpos;
956 SetCallbackURL(agent, sp.Scene.RegionInfo); 1032 SetCallbackURL(agent, sp.Scene.RegionInfo);
957 1033
@@ -1053,7 +1129,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1053 return; 1129 return;
1054 } 1130 }
1055 1131
1056 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
1057 1132
1058 // For backwards compatibility 1133 // For backwards compatibility
1059 if (version == "Unknown" || version == string.Empty) 1134 if (version == "Unknown" || version == string.Empty)
@@ -1063,18 +1138,30 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1063 CrossAttachmentsIntoNewRegion(finalDestination, sp, true); 1138 CrossAttachmentsIntoNewRegion(finalDestination, sp, true);
1064 } 1139 }
1065 1140
1141 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
1142
1143
1066 // May need to logout or other cleanup 1144 // May need to logout or other cleanup
1067 AgentHasMovedAway(sp, logout); 1145// AgentHasMovedAway(sp, logout);
1146// AgentHasMovedAway(sp, true); // until logout use is checked
1068 1147
1069 // Well, this is it. The agent is over there. 1148 // Well, this is it. The agent is over there.
1070 KillEntity(sp.Scene, sp.LocalId); 1149// KillEntity(sp.Scene, sp.LocalId);
1150
1151 sp.HasMovedAway(!OutSideViewRange);
1152
1153 sp.CloseChildAgents(destinationHandle,finalDestination.RegionSizeX,finalDestination.RegionSizeY);
1071 1154
1072 // Now let's make it officially a child agent 1155 // Now let's make it officially a child agent
1073 sp.MakeChildAgent(); 1156 sp.MakeChildAgent(destinationHandle);
1074 1157
1075 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone 1158 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
1076 1159
1160<<<<<<< HEAD
1077 if (NeedsClosing(sp.Scene.DefaultDrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 1161 if (NeedsClosing(sp.Scene.DefaultDrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
1162=======
1163 if (OutSideViewRange)
1164>>>>>>> avn/ubitvar
1078 { 1165 {
1079 if (!sp.Scene.IncomingPreCloseClient(sp)) 1166 if (!sp.Scene.IncomingPreCloseClient(sp))
1080 return; 1167 return;
@@ -1089,19 +1176,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1089 1176
1090 sp.Scene.CloseAgent(sp.UUID, false); 1177 sp.Scene.CloseAgent(sp.UUID, false);
1091 } 1178 }
1092 else
1093 {
1094 // now we have a child agent in this region.
1095 sp.Reset();
1096 }
1097 } 1179 }
1098 1180
1099 private void TransferAgent_V2(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination, 1181 private void TransferAgent_V2(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination,
1100 IPEndPoint endPoint, uint teleportFlags, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, string version, out string reason) 1182 IPEndPoint endPoint, uint teleportFlags, bool OutSideViewRange, string version, out string reason)
1101 { 1183 {
1102 ulong destinationHandle = finalDestination.RegionHandle; 1184 ulong destinationHandle = finalDestination.RegionHandle;
1103 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 1185 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
1104 1186
1187 string capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);;
1188
1105 // Let's create an agent there if one doesn't exist yet. 1189 // Let's create an agent there if one doesn't exist yet.
1106 // NOTE: logout will always be false for a non-HG teleport. 1190 // NOTE: logout will always be false for a non-HG teleport.
1107 bool logout = false; 1191 bool logout = false;
@@ -1142,6 +1226,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1142 // Past this point we have to attempt clean up if the teleport fails, so update transfer state. 1226 // Past this point we have to attempt clean up if the teleport fails, so update transfer state.
1143 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); 1227 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
1144 1228
1229<<<<<<< HEAD
1145 IClientIPEndpoint ipepClient; 1230 IClientIPEndpoint ipepClient;
1146 string capsPath = String.Empty; 1231 string capsPath = String.Empty;
1147 float dist = (float)Math.Max(sp.Scene.DefaultDrawDistance, 1232 float dist = (float)Math.Max(sp.Scene.DefaultDrawDistance,
@@ -1168,6 +1253,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1168 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); 1253 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
1169 } 1254 }
1170 1255
1256=======
1257>>>>>>> avn/ubitvar
1171 // We need to set this here to avoid an unlikely race condition when teleporting to a neighbour simulator, 1258 // We need to set this here to avoid an unlikely race condition when teleporting to a neighbour simulator,
1172 // where that neighbour simulator could otherwise request a child agent create on the source which then 1259 // where that neighbour simulator could otherwise request a child agent create on the source which then
1173 // closes our existing agent which is still signalled as root. 1260 // closes our existing agent which is still signalled as root.
@@ -1189,6 +1276,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1189 AgentData agent = new AgentData(); 1276 AgentData agent = new AgentData();
1190 sp.CopyTo(agent); 1277 sp.CopyTo(agent);
1191 agent.Position = agentCircuit.startpos; 1278 agent.Position = agentCircuit.startpos;
1279
1280 if ((teleportFlags & (uint)TeleportFlags.IsFlying) != 0)
1281 agent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1282
1192 agent.SenderWantsToWaitForRoot = true; 1283 agent.SenderWantsToWaitForRoot = true;
1193 //SetCallbackURL(agent, sp.Scene.RegionInfo); 1284 //SetCallbackURL(agent, sp.Scene.RegionInfo);
1194 1285
@@ -1224,25 +1315,29 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1224 1315
1225 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); 1316 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
1226 1317
1318 sp.HasMovedAway(!OutSideViewRange);
1319
1227 // Need to signal neighbours whether child agents may need closing irrespective of whether this 1320 // Need to signal neighbours whether child agents may need closing irrespective of whether this
1228 // one needed closing. We also need to close child agents as quickly as possible to avoid complicated 1321 // one needed closing. We also need to close child agents as quickly as possible to avoid complicated
1229 // race conditions with rapid agent releporting (e.g. from A1 to a non-neighbour B, back 1322 // race conditions with rapid agent releporting (e.g. from A1 to a non-neighbour B, back
1230 // to a neighbour A2 then off to a non-neighbour C). Closing child agents any later requires complex 1323 // to a neighbour A2 then off to a non-neighbour C). Closing child agents any later requires complex
1231 // distributed checks to avoid problems in rapid reteleporting scenarios and where child agents are 1324 // distributed checks to avoid problems in rapid reteleporting scenarios and where child agents are
1232 // abandoned without proper close by viewer but then re-used by an incoming connection. 1325 // abandoned without proper close by viewer but then re-used by an incoming connection.
1233 sp.CloseChildAgents(newRegionX, newRegionY); 1326 sp.CloseChildAgents(destinationHandle, finalDestination.RegionSizeX, finalDestination.RegionSizeY);
1234
1235 // May need to logout or other cleanup
1236 AgentHasMovedAway(sp, logout);
1237 1327
1328// AgentHasMovedAway(sp, true);
1238 // Well, this is it. The agent is over there. 1329 // Well, this is it. The agent is over there.
1239 KillEntity(sp.Scene, sp.LocalId); 1330// KillEntity(sp.Scene, sp.LocalId);
1240 1331
1241 // Now let's make it officially a child agent 1332 // Now let's make it officially a child agent
1242 sp.MakeChildAgent(); 1333 sp.MakeChildAgent(destinationHandle);
1243 1334
1244 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone 1335 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
1336<<<<<<< HEAD
1245 if (NeedsClosing(sp.Scene.DefaultDrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 1337 if (NeedsClosing(sp.Scene.DefaultDrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
1338=======
1339 if (OutSideViewRange)
1340>>>>>>> avn/ubitvar
1246 { 1341 {
1247 if (!sp.Scene.IncomingPreCloseClient(sp)) 1342 if (!sp.Scene.IncomingPreCloseClient(sp))
1248 return; 1343 return;
@@ -1263,11 +1358,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1263 1358
1264 sp.Scene.CloseAgent(sp.UUID, false); 1359 sp.Scene.CloseAgent(sp.UUID, false);
1265 } 1360 }
1361/*
1266 else 1362 else
1267 { 1363 {
1268 // now we have a child agent in this region. 1364 // now we have a child agent in this region.
1269 sp.Reset(); 1365 sp.Reset();
1270 } 1366 }
1367 */
1271 } 1368 }
1272 1369
1273 /// <summary> 1370 /// <summary>
@@ -1351,7 +1448,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1351 protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) 1448 protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout)
1352 { 1449 {
1353 if (sp.Scene.AttachmentsModule != null) 1450 if (sp.Scene.AttachmentsModule != null)
1354 sp.Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, true); 1451 sp.Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, logout);
1355 } 1452 }
1356 1453
1357 protected void KillEntity(Scene scene, uint localID) 1454 protected void KillEntity(Scene scene, uint localID)
@@ -1368,7 +1465,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1368 // This returns 'true' if the new region already has a child agent for our 1465 // This returns 'true' if the new region already has a child agent for our
1369 // incoming agent. The implication is that, if 'false', we have to create the 1466 // incoming agent. The implication is that, if 'false', we have to create the
1370 // child and then teleport into the region. 1467 // child and then teleport into the region.
1468<<<<<<< HEAD
1371 protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) 1469 protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY)
1470=======
1471 protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY,
1472 int oldsizeX, int oldsizeY, int newsizeX, int newsizeY)
1473>>>>>>> avn/ubitvar
1372 { 1474 {
1373 if (m_regionCombinerModule != null && m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID)) 1475 if (m_regionCombinerModule != null && m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID))
1374 { 1476 {
@@ -1381,17 +1483,23 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1381 1483
1382 return !(newRegionX >= swCorner.X && newRegionX <= neCorner.X && newRegionY >= swCorner.Y && newRegionY <= neCorner.Y); 1484 return !(newRegionX >= swCorner.X && newRegionX <= neCorner.X && newRegionY >= swCorner.Y && newRegionY <= neCorner.Y);
1383 } 1485 }
1384 else 1486
1385 { 1487 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY,
1386 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY); 1488 oldsizeX, oldsizeY, newsizeX, newsizeY);
1387 }
1388 } 1489 }
1490<<<<<<< HEAD
1389 1491
1390 protected virtual bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) 1492=======
1493/*
1494 protected virtual bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY,
1495 uint oldsizeX, uint oldsizeY, uint newsizeX, uint newsizeY, GridRegion reg)
1391 { 1496 {
1392 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
1393 }
1394 1497
1498 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY,
1499 oldsizeX, oldsizeY, newsizeX, newsizeY);
1500 }
1501*/
1502>>>>>>> avn/ubitvar
1395 #endregion 1503 #endregion
1396 1504
1397 #region Landmark Teleport 1505 #region Landmark Teleport
@@ -1472,14 +1580,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1472 1580
1473 #region Agent Crossings 1581 #region Agent Crossings
1474 1582
1583<<<<<<< HEAD
1475 // Given a position relative to the current region (which has previously been tested to 1584 // Given a position relative to the current region (which has previously been tested to
1476 // see that it is actually outside the current region), find the new region that the 1585 // see that it is actually outside the current region), find the new region that the
1477 // point is actually in. 1586 // point is actually in.
1478 // Returns the coordinates and information of the new region or 'null' of it doesn't exist. 1587 // Returns the coordinates and information of the new region or 'null' of it doesn't exist.
1479 public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, 1588 public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos,
1480 out string version, out Vector3 newpos, out string failureReason) 1589 out string version, out Vector3 newpos, out string failureReason)
1590=======
1591 public bool checkAgentAccessToRegion(ScenePresence agent, GridRegion destiny, Vector3 position, out string version, out string reason)
1592>>>>>>> avn/ubitvar
1481 { 1593 {
1594 reason = String.Empty;
1482 version = String.Empty; 1595 version = String.Empty;
1596<<<<<<< HEAD
1483 newpos = pos; 1597 newpos = pos;
1484 failureReason = string.Empty; 1598 failureReason = string.Empty;
1485 string homeURI = scene.GetAgentHomeURI(agentID); 1599 string homeURI = scene.GetAgentHomeURI(agentID);
@@ -1541,32 +1655,180 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1541 LogHeader, neighbourRegion.RegionName, 1655 LogHeader, neighbourRegion.RegionName,
1542 neighbourRegion.RegionLocX, neighbourRegion.RegionLocY, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY, 1656 neighbourRegion.RegionLocX, neighbourRegion.RegionLocY, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY,
1543 newpos.X, newpos.Y); 1657 newpos.X, newpos.Y);
1658=======
1659
1660 UUID agentID = agent.UUID;
1661 ulong destinyHandle = destiny.RegionHandle;
1662
1663 if (m_bannedRegionCache.IfBanned(destinyHandle, agentID))
1664 {
1665 reason = "Cannot connect to region";
1666 return false;
1667 }
1668
1669 Scene ascene = agent.Scene;
1670 string homeURI = ascene.GetAgentHomeURI(agentID);
1671 string myversion = string.Format("{0}/{1}", OutgoingTransferVersionName, MaxOutgoingTransferVersion);
1672
1673
1674 if (!ascene.SimulationService.QueryAccess(destiny, agentID, homeURI, false, position,
1675 myversion, out version, out reason))
1676 {
1677 m_bannedRegionCache.Add(destinyHandle, agentID, 30.0, 30.0);
1678 return false;
1679 }
1680
1681 return true;
1682 }
1683
1684 public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version, out Vector3 newpos)
1685 {
1686 string r = String.Empty;
1687 return GetDestination(scene, agentID, pos, out version, out newpos, out r);
1688 }
1689
1690 // Given a position relative to the current region (which has previously been tested to
1691 // see that it is actually outside the current region), find the new region that the
1692 // point is actually in.
1693 // Returns the coordinates and information of the new region or 'null' of it doesn't exist.
1694
1695 // now only works for crossings
1696
1697 public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos,
1698 out string version, out Vector3 newpos, out string failureReason)
1699 {
1700 version = String.Empty;
1701 newpos = pos;
1702 failureReason = string.Empty;
1703
1704// m_log.DebugFormat(
1705// "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name);
1706
1707 // Compute world location of the object's position
1708 double presenceWorldX = (double)scene.RegionInfo.WorldLocX + pos.X;
1709 double presenceWorldY = (double)scene.RegionInfo.WorldLocY + pos.Y;
1710
1711 // Call the grid service to lookup the region containing the new position.
1712 GridRegion neighbourRegion = GetRegionContainingWorldLocation(scene.GridService, scene.RegionInfo.ScopeID,
1713 presenceWorldX, presenceWorldY,
1714 Math.Max(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY));
1715
1716 if (neighbourRegion != null)
1717 {
1718 // Compute the entity's position relative to the new region
1719 newpos = new Vector3((float)(presenceWorldX - (double)neighbourRegion.RegionLocX),
1720 (float)(presenceWorldY - (double)neighbourRegion.RegionLocY),
1721 pos.Z);
1722
1723 if (m_bannedRegionCache.IfBanned(neighbourRegion.RegionHandle, agentID))
1724 {
1725 failureReason = "Cannot region cross into banned parcel";
1726 neighbourRegion = null;
1727 }
1728 else
1729 {
1730 // If not banned, make sure this agent is not in the list.
1731 m_bannedRegionCache.Remove(neighbourRegion.RegionHandle, agentID);
1732 }
1733
1734 // Check to see if we have access to the target region.
1735 string myversion = string.Format("{0}/{1}", OutgoingTransferVersionName, MaxOutgoingTransferVersion);
1736 string homeURI = scene.GetAgentHomeURI(agentID);
1737 if (neighbourRegion != null
1738 && !scene.SimulationService.QueryAccess(neighbourRegion, agentID, homeURI, false, newpos, myversion, out version, out failureReason))
1739 {
1740 // remember banned
1741 m_bannedRegionCache.Add(neighbourRegion.RegionHandle, agentID);
1742 neighbourRegion = null;
1743 }
1744 }
1745 else
1746 {
1747 // The destination region just doesn't exist
1748 failureReason = "Cannot cross into non-existent region";
1749 }
1750>>>>>>> avn/ubitvar
1751
1752 if (neighbourRegion == null)
1753 m_log.DebugFormat("{0} GetDestination: region not found. Old region name={1} at <{2},{3}> of size <{4},{5}>. Old pos={6}",
1754 LogHeader, scene.RegionInfo.RegionName,
1755 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
1756 scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY,
1757 pos);
1758 else
1759 m_log.DebugFormat("{0} GetDestination: new region={1} at <{2},{3}> of size <{4},{5}>, newpos=<{6},{7}>",
1760 LogHeader, neighbourRegion.RegionName,
1761 neighbourRegion.RegionLocX, neighbourRegion.RegionLocY, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY,
1762 newpos.X, newpos.Y);
1544 1763
1545 return neighbourRegion; 1764 return neighbourRegion;
1546 } 1765 }
1547 1766
1548 public bool Cross(ScenePresence agent, bool isFlying) 1767 public bool Cross(ScenePresence agent, bool isFlying)
1549 { 1768 {
1769<<<<<<< HEAD
1770=======
1771 agent.IsInTransit = true;
1772 CrossAsyncDelegate d = CrossAsync;
1773 d.BeginInvoke(agent, isFlying, CrossCompleted, d);
1774 return true;
1775 }
1776
1777 private void CrossCompleted(IAsyncResult iar)
1778 {
1779 CrossAsyncDelegate icon = (CrossAsyncDelegate)iar.AsyncState;
1780 ScenePresence agent = icon.EndInvoke(iar);
1781
1782 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
1783
1784 if(!agent.IsChildAgent)
1785 {
1786 // crossing failed
1787 agent.CrossToNewRegionFail();
1788 }
1789 agent.IsInTransit = false;
1790 }
1791
1792 public ScenePresence CrossAsync(ScenePresence agent, bool isFlying)
1793 {
1794 uint x;
1795 uint y;
1796>>>>>>> avn/ubitvar
1550 Vector3 newpos; 1797 Vector3 newpos;
1551 string version; 1798 string version;
1552 string failureReason; 1799 string failureReason;
1553 1800
1801<<<<<<< HEAD
1554 GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, agent.AbsolutePosition, 1802 GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, agent.AbsolutePosition,
1555 out version, out newpos, out failureReason); 1803 out version, out newpos, out failureReason);
1556 if (neighbourRegion == null) 1804 if (neighbourRegion == null)
1557 { 1805 {
1558 agent.ControllingClient.SendAlertMessage(failureReason); 1806 agent.ControllingClient.SendAlertMessage(failureReason);
1559 return false; 1807 return false;
1560 } 1808=======
1809 Vector3 pos = agent.AbsolutePosition + agent.Velocity;
1561 1810
1562 agent.IsInTransit = true; 1811 GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, pos,
1812 out version, out newpos, out failureReason);
1813 if (neighbourRegion == null)
1814 {
1815 if (failureReason != String.Empty)
1816 agent.ControllingClient.SendAlertMessage(failureReason);
1817 return agent;
1818>>>>>>> avn/ubitvar
1819 }
1563 1820
1564 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; 1821// agent.IsInTransit = true;
1565 d.BeginInvoke(agent, newpos, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d);
1566 1822
1823<<<<<<< HEAD
1567 Scene.EventManager.TriggerCrossAgentToNewRegion(agent, isFlying, neighbourRegion); 1824 Scene.EventManager.TriggerCrossAgentToNewRegion(agent, isFlying, neighbourRegion);
1568 1825
1569 return true; 1826 return true;
1827=======
1828 CrossAgentToNewRegionAsync(agent, newpos, neighbourRegion, isFlying, version);
1829 agent.IsInTransit = false;
1830 return agent;
1831>>>>>>> avn/ubitvar
1570 } 1832 }
1571 1833
1572 1834
@@ -1691,12 +1953,23 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1691 1953
1692 public bool CrossAgentIntoNewRegionMain(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying) 1954 public bool CrossAgentIntoNewRegionMain(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying)
1693 { 1955 {
1956 int ts = Util.EnvironmentTickCount();
1694 try 1957 try
1695 { 1958 {
1696 AgentData cAgent = new AgentData(); 1959 AgentData cAgent = new AgentData();
1697 agent.CopyTo(cAgent); 1960 agent.CopyTo(cAgent);
1961<<<<<<< HEAD
1698 cAgent.Position = pos; 1962 cAgent.Position = pos;
1699 1963
1964=======
1965
1966// agent.Appearance.WearableCacheItems = null;
1967
1968 cAgent.Position = pos;
1969
1970 cAgent.ChildrenCapSeeds = agent.KnownRegions;
1971
1972>>>>>>> avn/ubitvar
1700 if (isFlying) 1973 if (isFlying)
1701 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; 1974 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1702 1975
@@ -1716,11 +1989,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1716 neighbourRegion.RegionName, agent.Name); 1989 neighbourRegion.RegionName, agent.Name);
1717 1990
1718 ReInstantiateScripts(agent); 1991 ReInstantiateScripts(agent);
1719 agent.AddToPhysicalScene(isFlying); 1992 if(agent.ParentID == 0 && agent.ParentUUID == UUID.Zero)
1993 agent.AddToPhysicalScene(isFlying);
1720 1994
1721 return false; 1995 return false;
1722 } 1996 }
1723 1997
1998 m_log.DebugFormat("[CrossAgentIntoNewRegionMain] ok, time {0}ms",Util.EnvironmentTickCountSubtract(ts));
1999
1724 } 2000 }
1725 catch (Exception e) 2001 catch (Exception e)
1726 { 2002 {
@@ -1738,7 +2014,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1738 public void CrossAgentToNewRegionPost(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, 2014 public void CrossAgentToNewRegionPost(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion,
1739 bool isFlying, string version) 2015 bool isFlying, string version)
1740 { 2016 {
1741 agent.ControllingClient.RequestClientInfo();
1742 2017
1743 string agentcaps; 2018 string agentcaps;
1744 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) 2019 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
@@ -1749,6 +2024,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1749 } 2024 }
1750 2025
1751 // No turning back 2026 // No turning back
2027
1752 agent.IsChildAgent = true; 2028 agent.IsChildAgent = true;
1753 2029
1754 string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); 2030 string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps);
@@ -1760,7 +2036,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1760 if (m_eqModule != null) 2036 if (m_eqModule != null)
1761 { 2037 {
1762 m_eqModule.CrossRegion( 2038 m_eqModule.CrossRegion(
1763 neighbourRegion.RegionHandle, pos + agent.Velocity, vel2 /* agent.Velocity */, 2039 neighbourRegion.RegionHandle, pos, vel2 /* agent.Velocity */,
1764 neighbourRegion.ExternalEndPoint, 2040 neighbourRegion.ExternalEndPoint,
1765 capsPath, agent.UUID, agent.ControllingClient.SessionId, 2041 capsPath, agent.UUID, agent.ControllingClient.SessionId,
1766 neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY); 2042 neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY);
@@ -1768,10 +2044,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1768 else 2044 else
1769 { 2045 {
1770 m_log.ErrorFormat("{0} Using old CrossRegion packet. Varregion will not work!!", LogHeader); 2046 m_log.ErrorFormat("{0} Using old CrossRegion packet. Varregion will not work!!", LogHeader);
1771 agent.ControllingClient.CrossRegion(neighbourRegion.RegionHandle, pos + agent.Velocity, agent.Velocity, neighbourRegion.ExternalEndPoint, 2047 agent.ControllingClient.CrossRegion(neighbourRegion.RegionHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1772 capsPath); 2048 capsPath);
1773 } 2049 }
1774 2050
2051<<<<<<< HEAD
1775 // SUCCESS! 2052 // SUCCESS!
1776 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination); 2053 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination);
1777 2054
@@ -1788,6 +2065,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1788 agent.SendOtherAgentsAvatarDataToClient(); 2065 agent.SendOtherAgentsAvatarDataToClient();
1789 agent.SendOtherAgentsAppearanceToClient(); 2066 agent.SendOtherAgentsAppearanceToClient();
1790 2067
2068=======
2069>>>>>>> avn/ubitvar
1791 // Backwards compatibility. Best effort 2070 // Backwards compatibility. Best effort
1792 if (version == "Unknown" || version == string.Empty) 2071 if (version == "Unknown" || version == string.Empty)
1793 { 2072 {
@@ -1796,14 +2075,31 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1796 CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); 2075 CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
1797 } 2076 }
1798 2077
2078<<<<<<< HEAD
1799 // Next, let's close the child agent connections that are too far away. 2079 // Next, let's close the child agent connections that are too far away.
1800 uint neighbourx; 2080 uint neighbourx;
1801 uint neighboury; 2081 uint neighboury;
1802 Util.RegionHandleToRegionLoc(neighbourRegion.RegionHandle, out neighbourx, out neighboury); 2082 Util.RegionHandleToRegionLoc(neighbourRegion.RegionHandle, out neighbourx, out neighboury);
2083=======
2084 // SUCCESS!
2085 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination);
2086
2087 // Unlike a teleport, here we do not wait for the destination region to confirm the receipt.
2088 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
1803 2089
1804 agent.CloseChildAgents(neighbourx, neighboury); 2090 // this may need the attachments
2091
2092 agent.HasMovedAway(true);
2093
2094 agent.MakeChildAgent(neighbourRegion.RegionHandle);
2095
2096 // FIXME: Possibly this should occur lower down after other commands to close other agents,
2097 // but not sure yet what the side effects would be.
2098 m_entityTransferStateMachine.ResetFromTransit(agent.UUID);
2099>>>>>>> avn/ubitvar
2100
2101 agent.CloseChildAgents(neighbourRegion.RegionHandle, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY);
1805 2102
1806 AgentHasMovedAway(agent, false);
1807 2103
1808 // the user may change their profile information in other region, 2104 // the user may change their profile information in other region,
1809 // so the userinfo in UserProfileCache is not reliable any more, delete it 2105 // so the userinfo in UserProfileCache is not reliable any more, delete it
@@ -1843,7 +2139,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1843 #region Enable Child Agent 2139 #region Enable Child Agent
1844 2140
1845 /// <summary> 2141 /// <summary>
1846 /// This informs a single neighbouring region about agent "avatar". 2142 /// This informs a single neighbouring region about agent "avatar", and avatar about it
1847 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 2143 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
1848 /// </summary> 2144 /// </summary>
1849 /// <param name="sp"></param> 2145 /// <param name="sp"></param>
@@ -1852,22 +2148,36 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1852 { 2148 {
1853 m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName); 2149 m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName);
1854 2150
2151 ulong currentRegionHandler = sp.Scene.RegionInfo.RegionHandle;
2152 ulong regionhandler = region.RegionHandle;
2153
2154 Dictionary<ulong, string> seeds = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID));
2155
2156 if (seeds.ContainsKey(regionhandler))
2157 seeds.Remove(regionhandler);
2158/*
2159 List<ulong> oldregions = new List<ulong>(seeds.Keys);
2160
2161 if (oldregions.Contains(currentRegionHandler))
2162 oldregions.Remove(currentRegionHandler);
2163*/
2164 if (!seeds.ContainsKey(currentRegionHandler))
2165 seeds.Add(currentRegionHandler, sp.ControllingClient.RequestClientInfo().CapsPath);
2166
1855 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 2167 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
1856 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); 2168 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo();
1857 agent.BaseFolder = UUID.Zero; 2169 agent.BaseFolder = UUID.Zero;
1858 agent.InventoryFolder = UUID.Zero; 2170 agent.InventoryFolder = UUID.Zero;
1859 agent.startpos = new Vector3(128, 128, 70); 2171 agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, region);
1860 agent.child = true; 2172 agent.child = true;
1861 agent.Appearance = sp.Appearance; 2173 agent.Appearance = new AvatarAppearance();
1862 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); 2174 agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight;
1863 2175
1864 agent.ChildrenCapSeeds = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); 2176 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
1865 //m_log.DebugFormat("[XXX] Seeds 1 {0}", agent.ChildrenCapSeeds.Count);
1866 2177
1867 if (!agent.ChildrenCapSeeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle)) 2178 seeds.Add(regionhandler, agent.CapsPath);
1868 agent.ChildrenCapSeeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath);
1869 //m_log.DebugFormat("[XXX] Seeds 2 {0}", agent.ChildrenCapSeeds.Count);
1870 2179
2180<<<<<<< HEAD
1871 sp.AddNeighbourRegion(region.RegionHandle, agent.CapsPath); 2181 sp.AddNeighbourRegion(region.RegionHandle, agent.CapsPath);
1872 //foreach (ulong h in agent.ChildrenCapSeeds.Keys) 2182 //foreach (ulong h in agent.ChildrenCapSeeds.Keys)
1873 // m_log.DebugFormat("[XXX] --> {0}", h); 2183 // m_log.DebugFormat("[XXX] --> {0}", h);
@@ -1881,12 +2191,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1881 } 2191 }
1882 2192
1883 agent.ChildrenCapSeeds[region.RegionHandle] = agent.CapsPath; 2193 agent.ChildrenCapSeeds[region.RegionHandle] = agent.CapsPath;
2194=======
2195// agent.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
2196 agent.ChildrenCapSeeds = null;
2197>>>>>>> avn/ubitvar
1884 2198
1885 if (sp.Scene.CapsModule != null) 2199 if (sp.Scene.CapsModule != null)
1886 { 2200 {
1887 sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, agent.ChildrenCapSeeds); 2201 sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds);
1888 } 2202 }
1889 2203
2204 sp.KnownRegions = seeds;
2205 sp.AddNeighbourRegionSizeInfo(region);
2206
1890 if (currentAgentCircuit != null) 2207 if (currentAgentCircuit != null)
1891 { 2208 {
1892 agent.ServiceURLs = currentAgentCircuit.ServiceURLs; 2209 agent.ServiceURLs = currentAgentCircuit.ServiceURLs;
@@ -1896,7 +2213,24 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1896 agent.Mac = currentAgentCircuit.Mac; 2213 agent.Mac = currentAgentCircuit.Mac;
1897 agent.Id0 = currentAgentCircuit.Id0; 2214 agent.Id0 = currentAgentCircuit.Id0;
1898 } 2215 }
1899 2216/*
2217 AgentPosition agentpos = null;
2218
2219 if (oldregions.Count > 0)
2220 {
2221 agentpos = new AgentPosition();
2222 agentpos.AgentID = new UUID(sp.UUID.Guid);
2223 agentpos.SessionID = sp.ControllingClient.SessionId;
2224 agentpos.Size = sp.Appearance.AvatarSize;
2225 agentpos.Center = sp.CameraPosition;
2226 agentpos.Far = sp.DrawDistance;
2227 agentpos.Position = sp.AbsolutePosition;
2228 agentpos.Velocity = sp.Velocity;
2229 agentpos.RegionHandle = currentRegionHandler;
2230 agentpos.Throttles = sp.ControllingClient.GetThrottlesPacked(1);
2231 agentpos.ChildrenCapSeeds = seeds;
2232 }
2233*/
1900 IPEndPoint external = region.ExternalEndPoint; 2234 IPEndPoint external = region.ExternalEndPoint;
1901 if (external != null) 2235 if (external != null)
1902 { 2236 {
@@ -1905,7 +2239,23 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1905 InformClientOfNeighbourCompleted, 2239 InformClientOfNeighbourCompleted,
1906 d); 2240 d);
1907 } 2241 }
2242/*
2243 if(oldregions.Count >0)
2244 {
2245 uint neighbourx;
2246 uint neighboury;
2247 UUID scope = sp.Scene.RegionInfo.ScopeID;
2248 foreach (ulong handler in oldregions)
2249 {
2250 // crap code
2251 Utils.LongToUInts(handler, out neighbourx, out neighboury);
2252 GridRegion neighbour = sp.Scene.GridService.GetRegionByPosition(scope, (int)neighbourx, (int)neighboury);
2253 sp.Scene.SimulationService.UpdateAgent(neighbour, agentpos);
2254 }
2255 }
2256 */
1908 } 2257 }
2258
1909 #endregion 2259 #endregion
1910 2260
1911 #region Enable Child Agents 2261 #region Enable Child Agents
@@ -1915,146 +2265,157 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1915 2265
1916 /// <summary> 2266 /// <summary>
1917 /// This informs all neighbouring regions about agent "avatar". 2267 /// This informs all neighbouring regions about agent "avatar".
2268 /// and as important informs the avatar about then
1918 /// </summary> 2269 /// </summary>
1919 /// <param name="sp"></param> 2270 /// <param name="sp"></param>
1920 public void EnableChildAgents(ScenePresence sp) 2271 public void EnableChildAgents(ScenePresence sp)
1921 { 2272 {
2273 // assumes that out of view range regions are disconnected by the previus region
2274
1922 List<GridRegion> neighbours = new List<GridRegion>(); 2275 List<GridRegion> neighbours = new List<GridRegion>();
1923 RegionInfo m_regionInfo = sp.Scene.RegionInfo; 2276 Scene spScene = sp.Scene;
2277 RegionInfo m_regionInfo = spScene.RegionInfo;
1924 2278
1925 if (m_regionInfo != null) 2279 if (m_regionInfo != null)
1926 { 2280 {
2281<<<<<<< HEAD
1927 neighbours = GetNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 2282 neighbours = GetNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
2283=======
2284 neighbours = GetNeighbors(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
2285>>>>>>> avn/ubitvar
1928 } 2286 }
1929 else 2287 else
1930 { 2288 {
1931 m_log.Debug("[ENTITY TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); 2289 m_log.Debug("[ENTITY TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?");
1932 } 2290 }
1933 2291
1934 /// We need to find the difference between the new regions where there are no child agents 2292 ulong currentRegionHandler = m_regionInfo.RegionHandle;
1935 /// and the regions where there are already child agents. We only send notification to the former.
1936 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
1937 neighbourHandles.Add(sp.Scene.RegionInfo.RegionHandle); // add this region too
1938 List<ulong> previousRegionNeighbourHandles;
1939 2293
1940 if (sp.Scene.CapsModule != null) 2294 LinkedList<ulong> previousRegionNeighbourHandles;
2295 Dictionary<ulong, string> seeds;
2296 ICapabilitiesModule capsModule = spScene.CapsModule;
2297
2298 if (capsModule != null)
1941 { 2299 {
1942 previousRegionNeighbourHandles = 2300 seeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(sp.UUID));
1943 new List<ulong>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID).Keys); 2301 previousRegionNeighbourHandles = new LinkedList<ulong>(seeds.Keys);
1944 } 2302 }
1945 else 2303 else
1946 { 2304 {
1947 previousRegionNeighbourHandles = new List<ulong>(); 2305 seeds = new Dictionary<ulong, string>();
2306 previousRegionNeighbourHandles = new LinkedList<ulong>();
1948 } 2307 }
1949 2308
1950 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles); 2309 IClientAPI spClient = sp.ControllingClient;
1951 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
1952
1953// Dump("Current Neighbors", neighbourHandles);
1954// Dump("Previous Neighbours", previousRegionNeighbourHandles);
1955// Dump("New Neighbours", newRegions);
1956// Dump("Old Neighbours", oldRegions);
1957 2310
1958 /// Update the scene presence's known regions here on this region 2311 if (!seeds.ContainsKey(currentRegionHandler))
1959 sp.DropOldNeighbours(oldRegions); 2312 seeds.Add(currentRegionHandler, spClient.RequestClientInfo().CapsPath);
1960 2313
1961 /// Collect as many seeds as possible 2314 AgentCircuitData currentAgentCircuit =
1962 Dictionary<ulong, string> seeds; 2315 spScene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
1963 if (sp.Scene.CapsModule != null)
1964 seeds = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID));
1965 else
1966 seeds = new Dictionary<ulong, string>();
1967 2316
1968 //m_log.Debug(" !!! No. of seeds: " + seeds.Count);
1969 if (!seeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle))
1970 seeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath);
1971
1972 /// Create the necessary child agents
1973 List<AgentCircuitData> cagents = new List<AgentCircuitData>(); 2317 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
2318 List<ulong> newneighbours = new List<ulong>();
2319
1974 foreach (GridRegion neighbour in neighbours) 2320 foreach (GridRegion neighbour in neighbours)
1975 { 2321 {
1976 if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) 2322 ulong handler = neighbour.RegionHandle;
2323
2324 if (previousRegionNeighbourHandles.Contains(handler))
1977 { 2325 {
1978 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 2326 // agent already knows this region
1979 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); 2327 previousRegionNeighbourHandles.Remove(handler);
1980 agent.BaseFolder = UUID.Zero; 2328 continue;
1981 agent.InventoryFolder = UUID.Zero; 2329 }
1982 agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, neighbour);
1983 agent.child = true;
1984 agent.Appearance = sp.Appearance;
1985 if (currentAgentCircuit != null)
1986 {
1987 agent.ServiceURLs = currentAgentCircuit.ServiceURLs;
1988 agent.IPAddress = currentAgentCircuit.IPAddress;
1989 agent.Viewer = currentAgentCircuit.Viewer;
1990 agent.Channel = currentAgentCircuit.Channel;
1991 agent.Mac = currentAgentCircuit.Mac;
1992 agent.Id0 = currentAgentCircuit.Id0;
1993 }
1994 2330
1995 if (newRegions.Contains(neighbour.RegionHandle)) 2331 if (handler == currentRegionHandler)
1996 { 2332 continue;
1997 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
1998 sp.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
1999 seeds.Add(neighbour.RegionHandle, agent.CapsPath);
2000 }
2001 else
2002 {
2003 agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle);
2004 }
2005 2333
2006 cagents.Add(agent); 2334 // a new region to add
2335 AgentCircuitData agent = spClient.RequestClientInfo();
2336 agent.BaseFolder = UUID.Zero;
2337 agent.InventoryFolder = UUID.Zero;
2338 agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, neighbour);
2339 agent.child = true;
2340 agent.Appearance = new AvatarAppearance();
2341 agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight;
2342
2343 if (currentAgentCircuit != null)
2344 {
2345 agent.ServiceURLs = currentAgentCircuit.ServiceURLs;
2346 agent.IPAddress = currentAgentCircuit.IPAddress;
2347 agent.Viewer = currentAgentCircuit.Viewer;
2348 agent.Channel = currentAgentCircuit.Channel;
2349 agent.Mac = currentAgentCircuit.Mac;
2350 agent.Id0 = currentAgentCircuit.Id0;
2007 } 2351 }
2008 }
2009 2352
2010 /// Update all child agent with everyone's seeds 2353 newneighbours.Add(handler);
2011 foreach (AgentCircuitData a in cagents) 2354 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
2012 { 2355 seeds.Add(handler, agent.CapsPath);
2013 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
2014 }
2015 2356
2016 if (sp.Scene.CapsModule != null) 2357 agent.ChildrenCapSeeds = null;
2017 { 2358 cagents.Add(agent);
2018 sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds);
2019 } 2359 }
2020 sp.KnownRegions = seeds;
2021 //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
2022 //avatar.DumpKnownRegions();
2023 2360
2024 bool newAgent = false; 2361 if (previousRegionNeighbourHandles.Contains(currentRegionHandler))
2025 int count = 0; 2362 previousRegionNeighbourHandles.Remove(currentRegionHandler);
2026 foreach (GridRegion neighbour in neighbours) 2363
2027 { 2364 // previousRegionNeighbourHandles now contains regions to forget
2028 //m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName); 2365 foreach (ulong handler in previousRegionNeighbourHandles)
2029 // Don't do it if there's already an agent in that region 2366 seeds.Remove(handler);
2030 if (newRegions.Contains(neighbour.RegionHandle)) 2367
2031 newAgent = true; 2368 /// Update all child agent with everyone's seeds
2032 else 2369 // foreach (AgentCircuitData a in cagents)
2033 newAgent = false; 2370 // a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
2034// continue; 2371
2372 if (capsModule != null)
2373 capsModule.SetChildrenSeed(sp.UUID, seeds);
2035 2374
2036 if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) 2375 sp.KnownRegions = seeds;
2376 sp.SetNeighbourRegionSizeInfo(neighbours);
2377
2378 AgentPosition agentpos = new AgentPosition();
2379 agentpos.AgentID = new UUID(sp.UUID.Guid);
2380 agentpos.SessionID = spClient.SessionId;
2381 agentpos.Size = sp.Appearance.AvatarSize;
2382 agentpos.Center = sp.CameraPosition;
2383 agentpos.Far = sp.DrawDistance;
2384 agentpos.Position = sp.AbsolutePosition;
2385 agentpos.Velocity = sp.Velocity;
2386 agentpos.RegionHandle = currentRegionHandler;
2387 agentpos.Throttles = spClient.GetThrottlesPacked(1);
2388 // agentpos.ChildrenCapSeeds = seeds;
2389
2390 Util.FireAndForget(delegate
2391 {
2392 Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start
2393 int count = 0;
2394
2395 foreach (GridRegion neighbour in neighbours)
2037 { 2396 {
2397 ulong handler = neighbour.RegionHandle;
2038 try 2398 try
2039 { 2399 {
2040 // Let's put this back at sync, so that it doesn't clog 2400 if (newneighbours.Contains(handler))
2041 // the network, especially for regions in the same physical server. 2401 {
2042 // We're really not in a hurry here. 2402 InformClientOfNeighbourAsync(sp, cagents[count], neighbour,
2043 InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent); 2403 neighbour.ExternalEndPoint, true);
2044 //InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 2404 count++;
2045 //d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, 2405 }
2046 // InformClientOfNeighbourCompleted, 2406 else if (!previousRegionNeighbourHandles.Contains(handler))
2047 // d); 2407 {
2408 spScene.SimulationService.UpdateAgent(neighbour, agentpos);
2409 }
2048 } 2410 }
2049
2050 catch (ArgumentOutOfRangeException) 2411 catch (ArgumentOutOfRangeException)
2051 { 2412 {
2052 m_log.ErrorFormat( 2413 m_log.ErrorFormat(
2053 "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbour list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", 2414 "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbour list. The following region will not display to the client: {0} for region {1} ({2}, {3}).",
2054 neighbour.ExternalHostName, 2415 neighbour.ExternalHostName,
2055 neighbour.RegionHandle, 2416 neighbour.RegionHandle,
2056 neighbour.RegionLocX, 2417 neighbour.RegionLocX,
2057 neighbour.RegionLocY); 2418 neighbour.RegionLocY);
2058 } 2419 }
2059 catch (Exception e) 2420 catch (Exception e)
2060 { 2421 {
@@ -2071,13 +2432,106 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2071 2432
2072 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. 2433 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
2073 // throw e; 2434 // throw e;
2435 }
2436 }
2437 });
2438 }
2439
2440 // Computes the difference between two region bases.
2441 // Returns a vector of world coordinates (meters) from base of first region to the second.
2442 // The first region is the home region of the passed scene presence.
2443 Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour)
2444 {
2445 return new Vector3(sp.Scene.RegionInfo.WorldLocX - neighbour.RegionLocX,
2446 sp.Scene.RegionInfo.WorldLocY - neighbour.RegionLocY,
2447 0f);
2448 }
2449
2074 2450
2451 #region NotFoundLocationCache class
2452 // A collection of not found locations to make future lookups 'not found' lookups quick.
2453 // A simple expiring cache that keeps not found locations for some number of seconds.
2454 // A 'not found' location is presumed to be anywhere in the minimum sized region that
2455 // contains that point. A conservitive estimate.
2456 private class NotFoundLocationCache
2457 {
2458 private struct NotFoundLocation
2459 {
2460 public double minX, maxX, minY, maxY;
2461 public DateTime expireTime;
2462 }
2463 private List<NotFoundLocation> m_notFoundLocations = new List<NotFoundLocation>();
2464 public NotFoundLocationCache()
2465 {
2466 }
2467 // Add an area to the list of 'not found' places. The area is the snapped region
2468 // area around the added point.
2469 public void Add(double pX, double pY)
2470 {
2471 lock (m_notFoundLocations)
2472 {
2473 if (!LockedContains(pX, pY))
2474 {
2475 NotFoundLocation nfl = new NotFoundLocation();
2476 // A not found location is not found for at least a whole region sized area
2477 nfl.minX = pX - (pX % (double)Constants.RegionSize);
2478 nfl.minY = pY - (pY % (double)Constants.RegionSize);
2479 nfl.maxX = nfl.minX + (double)Constants.RegionSize;
2480 nfl.maxY = nfl.minY + (double)Constants.RegionSize;
2481 nfl.expireTime = DateTime.Now + TimeSpan.FromSeconds(30);
2482 m_notFoundLocations.Add(nfl);
2483 }
2484 }
2485
2486 }
2487 // Test to see of this point is in any of the 'not found' areas.
2488 // Return 'true' if the point is found inside the 'not found' areas.
2489 public bool Contains(double pX, double pY)
2490 {
2491 bool ret = false;
2492 lock (m_notFoundLocations)
2493 ret = LockedContains(pX, pY);
2494 return ret;
2495 }
2496 private bool LockedContains(double pX, double pY)
2497 {
2498 bool ret = false;
2499 this.DoExpiration();
2500 foreach (NotFoundLocation nfl in m_notFoundLocations)
2501 {
2502 if (pX >= nfl.minX && pX < nfl.maxX && pY >= nfl.minY && pY < nfl.maxY)
2503 {
2504 ret = true;
2505 break;
2075 } 2506 }
2076 } 2507 }
2077 count++; 2508 return ret;
2509 }
2510 private void DoExpiration()
2511 {
2512 List<NotFoundLocation> m_toRemove = null;
2513 DateTime now = DateTime.Now;
2514 foreach (NotFoundLocation nfl in m_notFoundLocations)
2515 {
2516 if (nfl.expireTime < now)
2517 {
2518 if (m_toRemove == null)
2519 m_toRemove = new List<NotFoundLocation>();
2520 m_toRemove.Add(nfl);
2521 }
2522 }
2523 if (m_toRemove != null)
2524 {
2525 foreach (NotFoundLocation nfl in m_toRemove)
2526 m_notFoundLocations.Remove(nfl);
2527 m_toRemove.Clear();
2528 }
2078 } 2529 }
2079 } 2530 }
2531 #endregion // NotFoundLocationCache class
2532 private NotFoundLocationCache m_notFoundLocationCache = new NotFoundLocationCache();
2080 2533
2534<<<<<<< HEAD
2081 // Computes the difference between two region bases. 2535 // Computes the difference between two region bases.
2082 // Returns a vector of world coordinates (meters) from base of first region to the second. 2536 // Returns a vector of world coordinates (meters) from base of first region to the second.
2083 // The first region is the home region of the passed scene presence. 2537 // The first region is the home region of the passed scene presence.
@@ -2197,6 +2651,27 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2197 double px, double py, uint pSizeHint) 2651 double px, double py, uint pSizeHint)
2198 { 2652 {
2199 m_log.DebugFormat("{0} GetRegionContainingWorldLocation: query, loc=<{1},{2}>", LogHeader, px, py); 2653 m_log.DebugFormat("{0} GetRegionContainingWorldLocation: query, loc=<{1},{2}>", LogHeader, px, py);
2654=======
2655// needed for current OSG or old grid code
2656
2657 public GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID, double px, double py)
2658 {
2659 // Since we don't know how big the regions could be, we have to search a very large area
2660 // to find possible regions.
2661 return GetRegionContainingWorldLocation(pGridService, pScopeID, px, py, Constants.MaximumRegionSize);
2662 }
2663
2664 // Given a world position, get the GridRegion info for
2665 // the region containing that point.
2666 // Someday this should be a method on GridService.
2667 // 'pSizeHint' is the size of the source region but since the destination point can be anywhere
2668 // the size of the target region is unknown thus the search area might have to be very large.
2669 // Return 'null' if no such region exists.
2670 public GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID,
2671 double px, double py, uint pSizeHint)
2672 {
2673 m_log.DebugFormat("{0} GetRegionContainingWorldLocation: call, XY=<{1},{2}>", LogHeader, px, py);
2674>>>>>>> avn/ubitvar
2200 GridRegion ret = null; 2675 GridRegion ret = null;
2201 const double fudge = 2.0; 2676 const double fudge = 2.0;
2202 2677
@@ -2289,55 +2764,71 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2289 private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg, 2764 private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg,
2290 IPEndPoint endPoint, bool newAgent) 2765 IPEndPoint endPoint, bool newAgent)
2291 { 2766 {
2292 // Let's wait just a little to give time to originating regions to catch up with closing child agents
2293 // after a cross here
2294 Thread.Sleep(500);
2295 2767
2768<<<<<<< HEAD
2296 Scene scene = sp.Scene; 2769 Scene scene = sp.Scene;
2297 2770
2298 m_log.DebugFormat( 2771 m_log.DebugFormat(
2299 "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})", 2772 "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})",
2300 sp.Name, sp.UUID, reg.RegionName, endPoint, reg.RegionCoordX, reg.RegionCoordY); 2773 sp.Name, sp.UUID, reg.RegionName, endPoint, reg.RegionCoordX, reg.RegionCoordY);
2774=======
2775 if (newAgent)
2776 {
2777 Scene scene = sp.Scene;
2778
2779 m_log.DebugFormat(
2780 "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})",
2781 sp.Name, sp.UUID, reg.RegionName, endPoint, reg.RegionCoordX, reg.RegionCoordY);
2782>>>>>>> avn/ubitvar
2301 2783
2302 string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath); 2784 string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath);
2303 2785
2304 string reason = String.Empty; 2786 string reason = String.Empty;
2305 2787
2788<<<<<<< HEAD
2306 bool regionAccepted = scene.SimulationService.CreateAgent(null, reg, a, (uint)TeleportFlags.Default, out reason); 2789 bool regionAccepted = scene.SimulationService.CreateAgent(null, reg, a, (uint)TeleportFlags.Default, out reason);
2790=======
2791 bool regionAccepted = scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason);
2792>>>>>>> avn/ubitvar
2307 2793
2308 if (regionAccepted && newAgent) 2794 if (regionAccepted)
2309 {
2310 if (m_eqModule != null)
2311 { 2795 {
2312 #region IP Translation for NAT 2796 // give time for createAgent to finish, since it is async and does grid services access
2313 IClientIPEndpoint ipepClient; 2797 Thread.Sleep(500);
2314 if (sp.ClientView.TryGet(out ipepClient)) 2798
2799 if (m_eqModule != null)
2315 { 2800 {
2316 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); 2801 #region IP Translation for NAT
2317 } 2802 IClientIPEndpoint ipepClient;
2318 #endregion 2803 if (sp.ClientView.TryGet(out ipepClient))
2804 {
2805 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
2806 }
2807 #endregion
2319 2808
2320 m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " + 2809 m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " +
2321 "and EstablishAgentCommunication with seed cap {8}", LogHeader, 2810 "and EstablishAgentCommunication with seed cap {8}", LogHeader,
2322 scene.RegionInfo.RegionName, sp.Name, 2811 scene.RegionInfo.RegionName, sp.Name,
2323 reg.RegionName, reg.RegionLocX, reg.RegionLocY, reg.RegionSizeX, reg.RegionSizeY , capsPath); 2812 reg.RegionName, reg.RegionLocX, reg.RegionLocY, reg.RegionSizeX, reg.RegionSizeY, capsPath);
2324 2813
2325 m_eqModule.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID, reg.RegionSizeX, reg.RegionSizeY); 2814 m_eqModule.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID, reg.RegionSizeX, reg.RegionSizeY);
2326 m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath, reg.RegionHandle, reg.RegionSizeX, reg.RegionSizeY); 2815 m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath, reg.RegionHandle, reg.RegionSizeX, reg.RegionSizeY);
2327 } 2816 }
2328 else 2817 else
2329 { 2818 {
2330 sp.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint); 2819 sp.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
2331 // TODO: make Event Queue disablable! 2820 // TODO: make Event Queue disablable!
2821 }
2822
2823 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Completed inform {0} {1} about neighbour {2}", sp.Name, sp.UUID, endPoint);
2332 } 2824 }
2333 2825
2334 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Completed inform {0} {1} about neighbour {2}", sp.Name, sp.UUID, endPoint); 2826 if (!regionAccepted)
2827 m_log.WarnFormat(
2828 "[ENTITY TRANSFER MODULE]: Region {0} did not accept {1} {2}: {3}",
2829 reg.RegionName, sp.Name, sp.UUID, reason);
2335 } 2830 }
2336 2831
2337 if (!regionAccepted)
2338 m_log.WarnFormat(
2339 "[ENTITY TRANSFER MODULE]: Region {0} did not accept {1} {2}: {3}",
2340 reg.RegionName, sp.Name, sp.UUID, reason);
2341 } 2832 }
2342 2833
2343 /// <summary> 2834 /// <summary>
@@ -2357,6 +2848,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2357 extent.Y = (float)Util.WorldToRegionLoc((uint)megaRegionSize.Y); 2848 extent.Y = (float)Util.WorldToRegionLoc((uint)megaRegionSize.Y);
2358 } 2849 }
2359 2850
2851<<<<<<< HEAD
2852=======
2853
2854>>>>>>> avn/ubitvar
2360 swCorner.X = Scene.RegionInfo.RegionLocX - 1; 2855 swCorner.X = Scene.RegionInfo.RegionLocX - 1;
2361 swCorner.Y = Scene.RegionInfo.RegionLocY - 1; 2856 swCorner.Y = Scene.RegionInfo.RegionLocY - 1;
2362 neCorner.X = Scene.RegionInfo.RegionLocX + extent.X; 2857 neCorner.X = Scene.RegionInfo.RegionLocX + extent.X;
@@ -2370,7 +2865,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2370 /// <param name="pRegionLocX"></param> 2865 /// <param name="pRegionLocX"></param>
2371 /// <param name="pRegionLocY"></param> 2866 /// <param name="pRegionLocY"></param>
2372 /// <returns></returns> 2867 /// <returns></returns>
2868<<<<<<< HEAD
2373 protected List<GridRegion> GetNeighbours(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY) 2869 protected List<GridRegion> GetNeighbours(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY)
2870=======
2871 protected List<GridRegion> GetNeighbors(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY)
2872>>>>>>> avn/ubitvar
2374 { 2873 {
2375 Scene pScene = avatar.Scene; 2874 Scene pScene = avatar.Scene;
2376 RegionInfo m_regionInfo = pScene.RegionInfo; 2875 RegionInfo m_regionInfo = pScene.RegionInfo;
@@ -2381,6 +2880,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2381 // view to include everything in the megaregion 2880 // view to include everything in the megaregion
2382 if (m_regionCombinerModule == null || !m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID)) 2881 if (m_regionCombinerModule == null || !m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID))
2383 { 2882 {
2883<<<<<<< HEAD
2384 // The area to check is as big as the current region. 2884 // The area to check is as big as the current region.
2385 // We presume all adjacent regions are the same size as this region. 2885 // We presume all adjacent regions are the same size as this region.
2386 uint dd = Math.Max((uint)avatar.Scene.DefaultDrawDistance, 2886 uint dd = Math.Max((uint)avatar.Scene.DefaultDrawDistance,
@@ -2395,6 +2895,32 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2395 neighbours 2895 neighbours
2396 = avatar.Scene.GridService.GetRegionRange( 2896 = avatar.Scene.GridService.GetRegionRange(
2397 m_regionInfo.ScopeID, (int)startX, (int)endX, (int)startY, (int)endY); 2897 m_regionInfo.ScopeID, (int)startX, (int)endX, (int)startY, (int)endY);
2898=======
2899 uint dd = (uint)avatar.DrawDistance;
2900
2901 // until avatar movement updates client connections, we need to seend at least this current region imediate Neighbors
2902 uint ddX = Math.Max(dd, Constants.RegionSize);
2903 uint ddY = Math.Max(dd, Constants.RegionSize);
2904
2905 ddX--;
2906 ddY--;
2907
2908 // reference to region edges. Should be avatar position
2909 uint startX = Util.RegionToWorldLoc(pRegionLocX);
2910 uint endX = startX + m_regionInfo.RegionSizeX;
2911 uint startY = Util.RegionToWorldLoc(pRegionLocY);
2912 uint endY = startY + m_regionInfo.RegionSizeY;
2913
2914 startX -= ddX;
2915 startY -= ddY;
2916 endX += ddX;
2917 endY += ddY;
2918
2919 neighbours
2920 = avatar.Scene.GridService.GetRegionRange(
2921 m_regionInfo.ScopeID, (int)startX, (int)endX, (int)startY, (int)endY);
2922
2923>>>>>>> avn/ubitvar
2398 } 2924 }
2399 else 2925 else
2400 { 2926 {
@@ -2408,6 +2934,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2408 (int)Util.RegionToWorldLoc((uint)swCorner.Y), (int)Util.RegionToWorldLoc((uint)neCorner.Y)); 2934 (int)Util.RegionToWorldLoc((uint)swCorner.Y), (int)Util.RegionToWorldLoc((uint)neCorner.Y));
2409 } 2935 }
2410 2936
2937<<<<<<< HEAD
2411// neighbours.ForEach( 2938// neighbours.ForEach(
2412// n => 2939// n =>
2413// m_log.DebugFormat( 2940// m_log.DebugFormat(
@@ -2420,59 +2947,72 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2420 r.RegionID == m_regionInfo.RegionID 2947 r.RegionID == m_regionInfo.RegionID
2421 || (r.RegionFlags != null && (r.RegionFlags & OpenSim.Framework.RegionFlags.RegionOnline) == 0)); 2948 || (r.RegionFlags != null && (r.RegionFlags & OpenSim.Framework.RegionFlags.RegionOnline) == 0));
2422 2949
2950=======
2951 // The r.RegionFlags == null check only needs to be made for simulators before 2015-01-14 (pre 0.8.1).
2952 neighbours.RemoveAll( r => r.RegionID == m_regionInfo.RegionID );
2953
2954>>>>>>> avn/ubitvar
2423 return neighbours; 2955 return neighbours;
2424 } 2956 }
2957 #endregion
2958
2959 #region Agent Arrived
2425 2960
2426 private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) 2961 public void AgentArrivedAtDestination(UUID id)
2427 { 2962 {
2428 return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); }); 2963 m_entityTransferStateMachine.SetAgentArrivedAtDestination(id);
2429 } 2964 }
2430 2965
2431 // private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) 2966 #endregion
2432 // { 2967
2433 // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); }); 2968 #region Object Transfers
2434 // }
2435 2969
2436 private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) 2970 public GridRegion GetObjectDestination(SceneObjectGroup grp, Vector3 targetPosition,out Vector3 newpos)
2437 { 2971 {
2438 return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); }); 2972 newpos = targetPosition;
2439 }
2440 2973
2441 private List<ulong> NeighbourHandles(List<GridRegion> neighbours) 2974 Scene scene = grp.Scene;
2442 { 2975 if (scene == null)
2443 List<ulong> handles = new List<ulong>(); 2976 return null;
2444 foreach (GridRegion reg in neighbours) 2977
2978 int x = (int)targetPosition.X + (int)scene.RegionInfo.WorldLocX;
2979 if (targetPosition.X >= 0)
2980 x++;
2981 else
2982 x--;
2983
2984 int y = (int)targetPosition.Y + (int)scene.RegionInfo.WorldLocY;
2985 if (targetPosition.Y >= 0)
2986 y++;
2987 else
2988 y--;
2989
2990
2991 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID,x,y);
2992 if (neighbourRegion == null)
2445 { 2993 {
2446 handles.Add(reg.RegionHandle); 2994 return null;
2447 } 2995 }
2448 return handles;
2449 }
2450 2996
2451// private void Dump(string msg, List<ulong> handles) 2997 float newRegionSizeX = neighbourRegion.RegionSizeX;
2452// { 2998 float newRegionSizeY = neighbourRegion.RegionSizeY;
2453// m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg); 2999 if (newRegionSizeX == 0)
2454// foreach (ulong handle in handles) 3000 newRegionSizeX = Constants.RegionSize;
2455// { 3001 if (newRegionSizeY == 0)
2456// uint x, y; 3002 newRegionSizeY = Constants.RegionSize;
2457// Utils.LongToUInts(handle, out x, out y);
2458// x = x / Constants.RegionSize;
2459// y = y / Constants.RegionSize;
2460// m_log.InfoFormat("({0}, {1})", x, y);
2461// }
2462// }
2463 3003
2464 #endregion
2465 3004
2466 #region Agent Arrived 3005 newpos.X = targetPosition.X - (neighbourRegion.RegionLocX - (int)scene.RegionInfo.WorldLocX);
3006 newpos.Y = targetPosition.Y - (neighbourRegion.RegionLocY - (int)scene.RegionInfo.WorldLocY);
2467 3007
2468 public void AgentArrivedAtDestination(UUID id)
2469 {
2470 m_entityTransferStateMachine.SetAgentArrivedAtDestination(id);
2471 }
2472 3008
2473 #endregion 3009 const float enterDistance = 0.2f;
3010 newpos.X = Util.Clamp(newpos.X, enterDistance, newRegionSizeX - enterDistance);
3011 newpos.Y = Util.Clamp(newpos.Y, enterDistance, newRegionSizeY - enterDistance);
3012
3013 return neighbourRegion;
3014 }
2474 3015
2475 #region Object Transfers
2476 3016
2477 /// <summary> 3017 /// <summary>
2478 /// Move the given scene object into a new region depending on which region its absolute position has moved 3018 /// Move the given scene object into a new region depending on which region its absolute position has moved
@@ -2496,6 +3036,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2496 if (scene == null) 3036 if (scene == null)
2497 return; 3037 return;
2498 3038
3039<<<<<<< HEAD
2499 if (grp.RootPart.DIE_AT_EDGE) 3040 if (grp.RootPart.DIE_AT_EDGE)
2500 { 3041 {
2501 // We remove the object here 3042 // We remove the object here
@@ -2510,6 +3051,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2510 return; 3051 return;
2511 } 3052 }
2512 3053
3054=======
3055>>>>>>> avn/ubitvar
2513 // Remember the old group position in case the region lookup fails so position can be restored. 3056 // Remember the old group position in case the region lookup fails so position can be restored.
2514 Vector3 oldGroupPosition = grp.RootPart.GroupPosition; 3057 Vector3 oldGroupPosition = grp.RootPart.GroupPosition;
2515 3058
@@ -2562,7 +3105,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2562 /// true if the crossing itself was successful, false on failure 3105 /// true if the crossing itself was successful, false on failure
2563 /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region 3106 /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region
2564 /// </returns> 3107 /// </returns>
2565 protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, Vector3 newPosition, SceneObjectGroup grp, bool silent) 3108 public bool CrossPrimGroupIntoNewRegion(GridRegion destination, Vector3 newPosition, SceneObjectGroup grp, bool silent)
2566 { 3109 {
2567 //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); 3110 //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<");
2568 3111
@@ -2603,30 +3146,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2603 grp, e); 3146 grp, e);
2604 } 3147 }
2605 } 3148 }
2606/*
2607 * done on caller ( not in attachments crossing for now)
2608 else
2609 {
2610
2611 if (!grp.IsDeleted)
2612 {
2613 PhysicsActor pa = grp.RootPart.PhysActor;
2614 if (pa != null)
2615 {
2616 pa.CrossingFailure();
2617 if (grp.RootPart.KeyframeMotion != null)
2618 {
2619 // moved to KeyframeMotion.CrossingFailure
2620// grp.RootPart.Velocity = Vector3.Zero;
2621 grp.RootPart.KeyframeMotion.CrossingFailure();
2622// grp.SendGroupRootTerseUpdate();
2623 }
2624 }
2625 }
2626
2627 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp);
2628 }
2629 */
2630 } 3149 }
2631 else 3150 else
2632 { 3151 {
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs
index 6a04acf..54ec751 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs
@@ -299,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
299 id, m_mod.Scene.RegionInfo.RegionName, currentState)); 299 id, m_mod.Scene.RegionInfo.RegionName, currentState));
300 } 300 }
301 301
302 int count = 200; 302 int count = 400;
303 303
304 // There should be no race condition here since no other code should be removing the agent transfer or 304 // There should be no race condition here since no other code should be removing the agent transfer or
305 // changing the state to another other than Transferring => ReceivedAtDestination. 305 // changing the state to another other than Transferring => ReceivedAtDestination.
@@ -354,4 +354,4 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
354 } 354 }
355 } 355 }
356 } 356 }
357} \ No newline at end of file 357}
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index fa23590..233b251 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -238,19 +238,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
238 238
239 return region; 239 return region;
240 } 240 }
241 241/* NEEDFIX
242 protected override bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) 242 protected override bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
243 { 243 {
244 if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 244 if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
245 return true; 245 return true;
246 246
247 int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); 247 int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID);
248 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) 248 if (flags == -1 || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0)
249 return true; 249 return true;
250 250
251 return false; 251 return false;
252 } 252 }
253 253*/
254 protected override void AgentHasMovedAway(ScenePresence sp, bool logout) 254 protected override void AgentHasMovedAway(ScenePresence sp, bool logout)
255 { 255 {
256 base.AgentHasMovedAway(sp, logout); 256 base.AgentHasMovedAway(sp, logout);
@@ -311,6 +311,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
311 return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout); 311 return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout);
312 } 312 }
313 313
314 public void TriggerTeleportHome(UUID id, IClientAPI client)
315 {
316 TeleportHome(id, client);
317 }
318
314 protected override bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason) 319 protected override bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason)
315 { 320 {
316 reason = "Please wear your grid's allowed appearance before teleporting to another grid"; 321 reason = "Please wear your grid's allowed appearance before teleporting to another grid";
@@ -429,11 +434,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
429 // return base.UpdateAgent(reg, finalDestination, agentData, sp); 434 // return base.UpdateAgent(reg, finalDestination, agentData, sp);
430 //} 435 //}
431 436
437<<<<<<< HEAD
432 public override void TriggerTeleportHome(UUID id, IClientAPI client) 438 public override void TriggerTeleportHome(UUID id, IClientAPI client)
433 { 439 {
434 TeleportHome(id, client); 440 TeleportHome(id, client);
435 } 441 }
436 442
443=======
444>>>>>>> avn/ubitvar
437 public override bool TeleportHome(UUID id, IClientAPI client) 445 public override bool TeleportHome(UUID id, IClientAPI client)
438 { 446 {
439 m_log.DebugFormat( 447 m_log.DebugFormat(
@@ -491,9 +499,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
491 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}", 499 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}",
492 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName); 500 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName);
493 501
494 DoTeleport( 502 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
495 sp, homeGatekeeper, finalDestination,
496 position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
497 return true; 503 return true;
498 } 504 }
499 505
@@ -760,4 +766,4 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
760 return region; 766 return region;
761 } 767 }
762 } 768 }
763} \ No newline at end of file 769}
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 5a9efb8..dff9126 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -178,27 +178,36 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
178 sbyte assetType, 178 sbyte assetType,
179 byte wearableType, uint nextOwnerMask, int creationDate) 179 byte wearableType, uint nextOwnerMask, int creationDate)
180 { 180 {
181 m_log.DebugFormat("[INVENTORY ACCESS MODULE]: Received request to create inventory item {0} in folder {1}", name, folderID); 181 m_log.DebugFormat("[INVENTORY ACCESS MODULE]: Received request to create inventory item {0} in folder {1}, transactionID {2}", name,
182 folderID, transactionID);
182 183
183 if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) 184 if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
184 return; 185 return;
185 186
186 if (transactionID == UUID.Zero) 187 InventoryFolderBase f = new InventoryFolderBase(folderID, remoteClient.AgentId);
188 InventoryFolderBase folder = m_Scene.InventoryService.GetFolder(f);
189
190 if (folder == null || folder.Owner != remoteClient.AgentId)
191 return;
192
193 if (transactionID != UUID.Zero)
187 { 194 {
188 ScenePresence presence; 195 IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule;
189 if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence)) 196 if (agentTransactions != null)
190 { 197 {
191 byte[] data = null; 198 if (agentTransactions.HandleItemCreationFromTransaction(
199 remoteClient, transactionID, folderID, callbackID, description,
200 name, invType, assetType, wearableType, nextOwnerMask))
201 return;
202 }
203 }
192 204
193 if (invType == (sbyte)InventoryType.Landmark && presence != null) 205 ScenePresence presence;
194 { 206 if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence))
195 string suffix = string.Empty, prefix = string.Empty; 207 {
196 string strdata = GenerateLandmark(presence, out prefix, out suffix); 208 byte[] data = null;
197 data = Encoding.ASCII.GetBytes(strdata);
198 name = prefix + name;
199 description += suffix;
200 }
201 209
210<<<<<<< HEAD
202 AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); 211 AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId);
203 m_Scene.AssetService.Store(asset); 212 m_Scene.AssetService.Store(asset);
204 m_Scene.CreateNewInventoryItem( 213 m_Scene.CreateNewInventoryItem(
@@ -206,21 +215,28 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
206 name, description, 0, callbackID, asset.FullID, asset.Type, invType, nextOwnerMask, creationDate); 215 name, description, 0, callbackID, asset.FullID, asset.Type, invType, nextOwnerMask, creationDate);
207 } 216 }
208 else 217 else
218=======
219 if (invType == (sbyte)InventoryType.Landmark && presence != null)
220>>>>>>> avn/ubitvar
209 { 221 {
210 m_log.ErrorFormat( 222 string suffix = string.Empty, prefix = string.Empty;
211 "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", 223 string strdata = GenerateLandmark(presence, out prefix, out suffix);
212 remoteClient.AgentId); 224 data = Encoding.ASCII.GetBytes(strdata);
225 name = prefix + name;
226 description += suffix;
213 } 227 }
228
229 AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId);
230 m_Scene.AssetService.Store(asset);
231 m_Scene.CreateNewInventoryItem(
232 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
233 name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate,transactionID);
214 } 234 }
215 else 235 else
216 { 236 {
217 IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule; 237 m_log.ErrorFormat(
218 if (agentTransactions != null) 238 "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
219 { 239 remoteClient.AgentId);
220 agentTransactions.HandleItemCreationFromTransaction(
221 remoteClient, transactionID, folderID, callbackID, description,
222 name, invType, assetType, wearableType, nextOwnerMask);
223 }
224 } 240 }
225 } 241 }
226 242
@@ -272,6 +288,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
272 288
273 remoteClient.SendAlertMessage("Script saved"); 289 remoteClient.SendAlertMessage("Script saved");
274 } 290 }
291 else if ((CustomInventoryType)item.InvType == CustomInventoryType.AnimationSet)
292 {
293 AnimationSet animSet = new AnimationSet(data);
294 if (!animSet.Validate(x => {
295 int perms = m_Scene.InventoryService.GetAssetPermissions(remoteClient.AgentId, x);
296 int required = (int)(PermissionMask.Transfer | PermissionMask.Copy);
297 if ((perms & required) != required)
298 return false;
299 return true;
300 }))
301 {
302 data = animSet.ToBytes();
303 }
304 }
275 305
276 AssetBase asset = 306 AssetBase asset =
277 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString()); 307 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString());
@@ -380,7 +410,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
380 bool asAttachment) 410 bool asAttachment)
381 { 411 {
382 CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); 412 CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero);
383// Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); 413 Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>();
414 // this possible is not needed if keyframes are saved
415 Dictionary<UUID, KeyframeMotion> originalKeyframes = new Dictionary<UUID, KeyframeMotion>();
384 416
385 Dictionary<SceneObjectGroup, KeyframeMotion> group2Keyframe = new Dictionary<SceneObjectGroup, KeyframeMotion>(); 417 Dictionary<SceneObjectGroup, KeyframeMotion> group2Keyframe = new Dictionary<SceneObjectGroup, KeyframeMotion>();
386 418
@@ -388,6 +420,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
388 { 420 {
389 if (objectGroup.RootPart.KeyframeMotion != null) 421 if (objectGroup.RootPart.KeyframeMotion != null)
390 { 422 {
423<<<<<<< HEAD
391 objectGroup.RootPart.KeyframeMotion.Pause(); 424 objectGroup.RootPart.KeyframeMotion.Pause();
392 group2Keyframe.Add(objectGroup, objectGroup.RootPart.KeyframeMotion); 425 group2Keyframe.Add(objectGroup, objectGroup.RootPart.KeyframeMotion);
393 objectGroup.RootPart.KeyframeMotion = null; 426 objectGroup.RootPart.KeyframeMotion = null;
@@ -406,6 +439,48 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
406// originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; 439// originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition;
407// 440//
408// objectGroup.AbsolutePosition = inventoryStoredPosition; 441// objectGroup.AbsolutePosition = inventoryStoredPosition;
442=======
443 objectGroup.RootPart.KeyframeMotion.Suspend();
444 }
445 objectGroup.RootPart.SetForce(Vector3.Zero);
446 objectGroup.RootPart.SetAngularImpulse(Vector3.Zero, false);
447
448 originalKeyframes[objectGroup.UUID] = objectGroup.RootPart.KeyframeMotion;
449 objectGroup.RootPart.KeyframeMotion = null;
450
451 Vector3 inventoryStoredPosition = new Vector3
452 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
453 ? 250
454 : objectGroup.AbsolutePosition.X)
455 ,
456 (objectGroup.AbsolutePosition.Y > (int)Constants.RegionSize)
457 ? 250
458 : objectGroup.AbsolutePosition.Y,
459 objectGroup.AbsolutePosition.Z);
460
461 Quaternion inventoryStoredRotation = objectGroup.GroupRotation;
462 originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition;
463
464 // Restore attachment data after trip through the sim
465 if (objectGroup.RootPart.AttachPoint > 0)
466 {
467 inventoryStoredPosition = objectGroup.RootPart.AttachedPos;
468 inventoryStoredRotation = objectGroup.RootPart.AttachRotation;
469 }
470
471 // Trees could be attached and it's been done, but it makes
472 // no sense. State must be preserved because it's the tree type
473 if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree &&
474 objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree)
475 {
476 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
477 if (objectGroup.RootPart.AttachPoint > 0)
478 objectGroup.RootPart.Shape.LastAttachPoint = objectGroup.RootPart.AttachPoint;
479 }
480
481 objectGroup.AbsolutePosition = inventoryStoredPosition;
482 objectGroup.RootPart.RotationOffset = inventoryStoredRotation;
483>>>>>>> avn/ubitvar
409 484
410 // Make sure all bits but the ones we want are clear 485 // Make sure all bits but the ones we want are clear
411 // on take. 486 // on take.
@@ -433,9 +508,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
433 else 508 else
434 itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment); 509 itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment);
435 510
436// // Restore the position of each group now that it has been stored to inventory. 511 // Restore the position of each group now that it has been stored to inventory.
437// foreach (SceneObjectGroup objectGroup in objlist) 512 foreach (SceneObjectGroup objectGroup in objlist)
438// objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; 513 {
514 objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID];
515 objectGroup.RootPart.KeyframeMotion = originalKeyframes[objectGroup.UUID];
516 if (objectGroup.RootPart.KeyframeMotion != null)
517 objectGroup.RootPart.KeyframeMotion.Resume();
518 }
439 519
440 InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); 520 InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID);
441 521
@@ -492,7 +572,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
492 item.Name = asset.Name; 572 item.Name = asset.Name;
493 item.AssetType = asset.Type; 573 item.AssetType = asset.Type;
494 574
495 AddPermissions(item, objlist[0], objlist, remoteClient); 575 //preserve perms on return
576 if(DeRezAction.Return == action)
577 AddPermissions(item, objlist[0], objlist, null);
578 else
579 AddPermissions(item, objlist[0], objlist, remoteClient);
496 580
497 m_Scene.AddInventoryItem(item); 581 m_Scene.AddInventoryItem(item);
498 582
@@ -542,16 +626,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
542 IClientAPI remoteClient) 626 IClientAPI remoteClient)
543 { 627 {
544 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7; 628 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7;
545 uint allObjectsNextOwnerPerms = 0x7fffffff; 629 // For the porposes of inventory, an object is modify if the prims
546 uint allObjectsEveryOnePerms = 0x7fffffff; 630 // are modify. This allows renaming an object that contains no
547 uint allObjectsGroupPerms = 0x7fffffff; 631 // mod items.
548
549 foreach (SceneObjectGroup grp in objsForEffectivePermissions) 632 foreach (SceneObjectGroup grp in objsForEffectivePermissions)
550 { 633 {
551 effectivePerms &= grp.GetEffectivePermissions(); 634 uint groupPerms = grp.GetEffectivePermissions(true);
552 allObjectsNextOwnerPerms &= grp.RootPart.NextOwnerMask; 635 if ((grp.RootPart.BaseMask & (uint)PermissionMask.Modify) != 0)
553 allObjectsEveryOnePerms &= grp.RootPart.EveryoneMask; 636 groupPerms |= (uint)PermissionMask.Modify;
554 allObjectsGroupPerms &= grp.RootPart.GroupMask; 637
638 effectivePerms &= groupPerms;
555 } 639 }
556 effectivePerms |= (uint)PermissionMask.Move; 640 effectivePerms |= (uint)PermissionMask.Move;
557 641
@@ -565,11 +649,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
565 uint perms = effectivePerms; 649 uint perms = effectivePerms;
566 PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms); 650 PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms);
567 651
568 item.BasePermissions = perms & allObjectsNextOwnerPerms; 652 item.BasePermissions = perms & so.RootPart.NextOwnerMask;
569 item.CurrentPermissions = item.BasePermissions; 653 item.CurrentPermissions = item.BasePermissions;
570 item.NextPermissions = perms & allObjectsNextOwnerPerms; 654 item.NextPermissions = perms & so.RootPart.NextOwnerMask;
571 item.EveryOnePermissions = allObjectsEveryOnePerms & allObjectsNextOwnerPerms; 655 item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask;
572 item.GroupPermissions = allObjectsGroupPerms & allObjectsNextOwnerPerms; 656 item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask;
573 657
574 // apply next owner perms on rez 658 // apply next owner perms on rez
575 item.CurrentPermissions |= SceneObjectGroup.SLAM; 659 item.CurrentPermissions |= SceneObjectGroup.SLAM;
@@ -585,9 +669,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
585 669
586 item.BasePermissions = effectivePerms; 670 item.BasePermissions = effectivePerms;
587 item.CurrentPermissions = effectivePerms; 671 item.CurrentPermissions = effectivePerms;
588 item.NextPermissions = allObjectsNextOwnerPerms & effectivePerms; 672 item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms;
589 item.EveryOnePermissions = allObjectsEveryOnePerms & effectivePerms; 673 item.EveryOnePermissions = so.RootPart.EveryoneMask & effectivePerms;
590 item.GroupPermissions = allObjectsGroupPerms & effectivePerms; 674 item.GroupPermissions = so.RootPart.GroupMask & effectivePerms;
591 675
592 item.CurrentPermissions &= 676 item.CurrentPermissions &=
593 ((uint)PermissionMask.Copy | 677 ((uint)PermissionMask.Copy |
@@ -743,7 +827,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
743 if (so.FromFolderID != UUID.Zero && so.RootPart.OwnerID == remoteClient.AgentId) 827 if (so.FromFolderID != UUID.Zero && so.RootPart.OwnerID == remoteClient.AgentId)
744 { 828 {
745 InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID); 829 InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID);
746 folder = m_Scene.InventoryService.GetFolder(f); 830 if (f != null)
831 folder = m_Scene.InventoryService.GetFolder(f);
747 832
748 if(folder.Type == 14 || folder.Type == 16) 833 if(folder.Type == 14 || folder.Type == 16)
749 { 834 {
@@ -779,16 +864,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
779 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) 864 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
780 { 865 {
781// m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); 866// m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID);
782
783 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 867 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
784 item = m_Scene.InventoryService.GetItem(item); 868 item = m_Scene.InventoryService.GetItem(item);
785 869
786 if (item == null) 870 if (item == null)
787 { 871 {
788 m_log.WarnFormat(
789 "[INVENTORY ACCESS MODULE]: Could not find item {0} for {1} in RezObject()",
790 itemID, remoteClient.Name);
791
792 return null; 872 return null;
793 } 873 }
794 874
@@ -856,12 +936,35 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
856 pos -= bbox / 2; 936 pos -= bbox / 2;
857 } 937 }
858 938
939 int primcount = 0;
940 foreach (SceneObjectGroup g in objlist)
941 primcount += g.PrimCount;
942
943 if (!m_Scene.Permissions.CanRezObject(
944 primcount, remoteClient.AgentId, pos)
945 && !attachment)
946 {
947 // The client operates in no fail mode. It will
948 // have already removed the item from the folder
949 // if it's no copy.
950 // Put it back if it's not an attachment
951 //
952 if (item != null)
953 {
954 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
955 remoteClient.SendBulkUpdateInventory(item);
956 }
957
958 return null;
959 }
960
859 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, veclist, attachment)) 961 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, veclist, attachment))
860 return null; 962 return null;
861 963
862 for (int i = 0; i < objlist.Count; i++) 964 for (int i = 0; i < objlist.Count; i++)
863 { 965 {
864 group = objlist[i]; 966 group = objlist[i];
967 SceneObjectPart rootPart = group.RootPart;
865 968
866// m_log.DebugFormat( 969// m_log.DebugFormat(
867// "[INVENTORY ACCESS MODULE]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", 970// "[INVENTORY ACCESS MODULE]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}",
@@ -909,7 +1012,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
909 1012
910 if (attachment) 1013 if (attachment)
911 { 1014 {
912 group.RootPart.Flags |= PrimFlags.Phantom; 1015// group.RootPart.Flags |= PrimFlags.Phantom;
913 group.IsAttachment = true; 1016 group.IsAttachment = true;
914 } 1017 }
915 1018
@@ -934,8 +1037,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
934 1037
935 if (!attachment) 1038 if (!attachment)
936 { 1039 {
937 SceneObjectPart rootPart = group.RootPart;
938
939 if (rootPart.Shape.PCode == (byte)PCode.Prim) 1040 if (rootPart.Shape.PCode == (byte)PCode.Prim)
940 group.ClearPartAttachmentData(); 1041 group.ClearPartAttachmentData();
941 1042
@@ -953,6 +1054,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
953// remoteClient.Name); 1054// remoteClient.Name);
954 } 1055 }
955 1056
1057 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
1058
956 if (item != null) 1059 if (item != null)
957 DoPostRezWhenFromItem(item, attachment); 1060 DoPostRezWhenFromItem(item, attachment);
958 1061
@@ -1033,10 +1136,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1033 // object itself before we rez. 1136 // object itself before we rez.
1034 // 1137 //
1035 // Only do these for the first object if we are rezzing a coalescence. 1138 // Only do these for the first object if we are rezzing a coalescence.
1036 if (i == 0) 1139 // nahh dont mess with coalescence objects,
1140 // the name in inventory can be change for inventory purpuses only
1141 if (objlist.Count == 1)
1037 { 1142 {
1038 rootPart.Name = item.Name; 1143 rootPart.Name = item.Name;
1039 rootPart.Description = item.Description; 1144 rootPart.Description = item.Description;
1145 }
1146
1147 if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0)
1148 {
1040 rootPart.ObjectSaleType = item.SaleType; 1149 rootPart.ObjectSaleType = item.SaleType;
1041 rootPart.SalePrice = item.SalePrice; 1150 rootPart.SalePrice = item.SalePrice;
1042 } 1151 }
@@ -1047,17 +1156,55 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1047// "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}", 1156// "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}",
1048// rootPart.OwnerID, item.Owner, item.CurrentPermissions); 1157// rootPart.OwnerID, item.Owner, item.CurrentPermissions);
1049 1158
1050 if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & SceneObjectGroup.SLAM) != 0) 1159 if ((rootPart.OwnerID != item.Owner) ||
1160 (item.CurrentPermissions & 16) != 0 ||
1161 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
1051 { 1162 {
1052 //Need to kill the for sale here 1163 //Need to kill the for sale here
1053 rootPart.ObjectSaleType = 0; 1164 rootPart.ObjectSaleType = 0;
1054 rootPart.SalePrice = 10; 1165 rootPart.SalePrice = 10;
1055 } 1166
1167 if (m_Scene.Permissions.PropagatePermissions())
1168 {
1169 foreach (SceneObjectPart part in so.Parts)
1170 {
1171 part.GroupMask = 0; // DO NOT propagate here
1056 1172
1057 foreach (SceneObjectPart part in so.Parts) 1173 part.LastOwnerID = part.OwnerID;
1174 part.OwnerID = item.Owner;
1175 part.Inventory.ChangeInventoryOwner(item.Owner);
1176 }
1177
1178 so.ApplyNextOwnerPermissions();
1179
1180 // In case the user has changed flags on a received item
1181 // we have to apply those changes after the slam. Else we
1182 // get a net loss of permissions
1183 foreach (SceneObjectPart part in so.Parts)
1184 {
1185 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
1186 {
1187 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
1188 part.EveryoneMask = item.EveryOnePermissions & part.BaseMask;
1189 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
1190 part.NextOwnerMask = item.NextPermissions & part.BaseMask;
1191 }
1192 }
1193 }
1194 }
1195 else
1058 { 1196 {
1059 part.FromUserInventoryItemID = fromUserInventoryItemId; 1197 foreach (SceneObjectPart part in so.Parts)
1060 part.ApplyPermissionsOnRez(item, true, m_Scene); 1198 {
1199 part.FromUserInventoryItemID = fromUserInventoryItemId;
1200
1201 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
1202 part.EveryoneMask = item.EveryOnePermissions;
1203 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
1204 part.NextOwnerMask = item.NextPermissions;
1205 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
1206 part.GroupMask = item.GroupPermissions;
1207 }
1061 } 1208 }
1062 1209
1063 rootPart.TrimPermissions(); 1210 rootPart.TrimPermissions();
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 7ecbd26..a536757 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -336,6 +336,104 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
336 } 336 }
337 } 337 }
338 338
339<<<<<<< HEAD
340=======
341 /// <summary>
342 ///
343 /// </summary>
344 /// <param name="uuid"></param>
345 /// <param name="names">Caller please provide a properly instantiated array for names, string[2]</param>
346 /// <returns></returns>
347 private bool TryGetUserNames(UUID uuid, string[] names)
348 {
349 if (names == null)
350 names = new string[2];
351
352 if (TryGetUserNamesFromCache(uuid, names))
353 return true;
354
355 if (TryGetUserNamesFromServices(uuid, names))
356 return true;
357
358 return false;
359 }
360
361 private bool TryGetUserNamesFromCache(UUID uuid, string[] names)
362 {
363 lock (m_UserCache)
364 {
365 if (m_UserCache.ContainsKey(uuid))
366 {
367 names[0] = m_UserCache[uuid].FirstName;
368 names[1] = m_UserCache[uuid].LastName;
369
370 return true;
371 }
372 }
373
374 return false;
375 }
376
377 /// <summary>
378 /// Try to get the names bound to the given uuid, from the services.
379 /// </summary>
380 /// <returns>True if the name was found, false if not.</returns>
381 /// <param name='uuid'></param>
382 /// <param name='names'>The array of names if found. If not found, then names[0] = "Unknown" and names[1] = "User"</param>
383 private bool TryGetUserNamesFromServices(UUID uuid, string[] names)
384 {
385 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, uuid);
386
387 if (account != null)
388 {
389 names[0] = account.FirstName;
390 names[1] = account.LastName;
391
392 UserData user = new UserData();
393 user.FirstName = account.FirstName;
394 user.LastName = account.LastName;
395
396 lock (m_UserCache)
397 m_UserCache[uuid] = user;
398
399 return true;
400 }
401 else
402 {
403 // Let's try the GridUser service
404 GridUserInfo uInfo = m_Scenes[0].GridUserService.GetGridUserInfo(uuid.ToString());
405 if (uInfo != null)
406 {
407 string url, first, last, tmp;
408 UUID u;
409 if (Util.ParseUniversalUserIdentifier(uInfo.UserID, out u, out url, out first, out last, out tmp))
410 {
411 AddUser(uuid, first, last, url);
412
413 if (m_UserCache.ContainsKey(uuid))
414 {
415 names[0] = m_UserCache[uuid].FirstName;
416 names[1] = m_UserCache[uuid].LastName;
417
418 return true;
419 }
420 }
421 else
422 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Unable to parse UUI {0}", uInfo.UserID);
423 }
424// else
425// {
426// m_log.DebugFormat("[USER MANAGEMENT MODULE]: No grid user found for {0}", uuid);
427// }
428
429 names[0] = "Unknown";
430 names[1] = "UserUMMTGUN9";
431
432 return false;
433 }
434 }
435
436>>>>>>> avn/ubitvar
339 #region IUserManagement 437 #region IUserManagement
340 438
341 public UUID GetUserIdByName(string name) 439 public UUID GetUserIdByName(string name)
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
index ea5b34e..a5c7543 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
@@ -138,9 +138,9 @@ namespace OpenSim.Region.CoreModules.Hypergrid
138 } 138 }
139 } 139 }
140 140
141 protected override List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 141 protected override List<MapBlockData> GetAndSendBlocksInternal(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
142 { 142 {
143 List<MapBlockData> mapBlocks = base.GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag); 143 List<MapBlockData> mapBlocks = base.GetAndSendBlocksInternal(remoteClient, minX, minY, maxX, maxY, flag);
144 lock (m_SeenMapBlocks) 144 lock (m_SeenMapBlocks)
145 { 145 {
146 if (!m_SeenMapBlocks.ContainsKey(remoteClient.AgentId)) 146 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 b1f3f9b..235fbbb 100644
--- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -28,15 +28,12 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Linq;
32using System.Net; 31using System.Net;
33using System.Net.Mail; 32using System.Net.Mail;
34using System.Net.Security; 33using System.Net.Security;
35using System.Reflection;
36using System.Text; 34using System.Text;
37using System.Threading; 35using System.Threading;
38using System.Security.Cryptography.X509Certificates; 36using System.Security.Cryptography.X509Certificates;
39using log4net;
40using Nini.Config; 37using Nini.Config;
41using OpenMetaverse; 38using OpenMetaverse;
42using OpenSim.Framework; 39using OpenSim.Framework;
@@ -46,6 +43,7 @@ using OpenSim.Framework.Servers.HttpServer;
46using OpenSim.Region.Framework.Interfaces; 43using OpenSim.Region.Framework.Interfaces;
47using OpenSim.Region.Framework.Scenes; 44using OpenSim.Region.Framework.Scenes;
48using Mono.Addins; 45using Mono.Addins;
46using Amib.Threading;
49 47
50/***************************************************** 48/*****************************************************
51 * 49 *
@@ -109,6 +107,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
109 private Dictionary<UUID, HttpRequestClass> m_pendingRequests; 107 private Dictionary<UUID, HttpRequestClass> m_pendingRequests;
110 private Scene m_scene; 108 private Scene m_scene;
111 // private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>(); 109 // private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>();
110 public static SmartThreadPool ThreadPool = null;
112 111
113 public HttpRequestModule() 112 public HttpRequestModule()
114 { 113 {
@@ -291,29 +290,18 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
291 return true; 290 return true;
292 } 291 }
293 292
294 public void StopHttpRequestsForScript(UUID id) 293 public void StopHttpRequest(uint m_localID, UUID m_itemID)
295 { 294 {
296 if (m_pendingRequests != null) 295 if (m_pendingRequests != null)
297 { 296 {
298 List<UUID> keysToRemove = null;
299
300 lock (HttpListLock) 297 lock (HttpListLock)
301 { 298 {
302 foreach (HttpRequestClass req in m_pendingRequests.Values) 299 HttpRequestClass tmpReq;
300 if (m_pendingRequests.TryGetValue(m_itemID, out tmpReq))
303 { 301 {
304 if (req.ItemID == id) 302 tmpReq.Stop();
305 { 303 m_pendingRequests.Remove(m_itemID);
306 req.Stop();
307
308 if (keysToRemove == null)
309 keysToRemove = new List<UUID>();
310
311 keysToRemove.Add(req.ReqID);
312 }
313 } 304 }
314
315 if (keysToRemove != null)
316 keysToRemove.ForEach(keyToRemove => m_pendingRequests.Remove(keyToRemove));
317 } 305 }
318 } 306 }
319 } 307 }
@@ -331,13 +319,19 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
331 { 319 {
332 lock (HttpListLock) 320 lock (HttpListLock)
333 { 321 {
334 foreach (HttpRequestClass req in m_pendingRequests.Values) 322 foreach (UUID luid in m_pendingRequests.Keys)
335 { 323 {
336 if (req.Finished) 324 HttpRequestClass tmpReq;
337 return req; 325
326 if (m_pendingRequests.TryGetValue(luid, out tmpReq))
327 {
328 if (tmpReq.Finished)
329 {
330 return tmpReq;
331 }
332 }
338 } 333 }
339 } 334 }
340
341 return null; 335 return null;
342 } 336 }
343 337
@@ -364,9 +358,34 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
364 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); 358 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy");
365 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); 359 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions");
366 360
361<<<<<<< HEAD
367 m_outboundUrlFilter = new OutboundUrlFilter("Script HTTP request module", config); 362 m_outboundUrlFilter = new OutboundUrlFilter("Script HTTP request module", config);
363=======
364 int maxThreads = 15;
365
366 IConfig httpConfig = config.Configs["HttpRequestModule"];
367 if (httpConfig != null)
368 {
369 maxThreads = httpConfig.GetInt("MaxPoolThreads", maxThreads);
370 }
371>>>>>>> avn/ubitvar
368 372
369 m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); 373 m_pendingRequests = new Dictionary<UUID, HttpRequestClass>();
374
375 // First instance sets this up for all sims
376 if (ThreadPool == null)
377 {
378 STPStartInfo startInfo = new STPStartInfo();
379 startInfo.IdleTimeout = 20000;
380 startInfo.MaxWorkerThreads = maxThreads;
381 startInfo.MinWorkerThreads = 1;
382 startInfo.ThreadPriority = ThreadPriority.BelowNormal;
383 startInfo.StartSuspended = true;
384 startInfo.ThreadPoolName = "ScriptsHttpReq";
385
386 ThreadPool = new SmartThreadPool(startInfo);
387 ThreadPool.Start();
388 }
370 } 389 }
371 390
372 public void AddRegion(Scene scene) 391 public void AddRegion(Scene scene)
@@ -410,8 +429,6 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
410 429
411 public class HttpRequestClass : IServiceRequest 430 public class HttpRequestClass : IServiceRequest
412 { 431 {
413// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
414
415 // Constants for parameters 432 // Constants for parameters
416 // public const int HTTP_BODY_MAXLENGTH = 2; 433 // public const int HTTP_BODY_MAXLENGTH = 2;
417 // public const int HTTP_METHOD = 0; 434 // public const int HTTP_METHOD = 0;
@@ -438,6 +455,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
438 public string HttpMIMEType = "text/plain;charset=utf-8"; 455 public string HttpMIMEType = "text/plain;charset=utf-8";
439 public int HttpTimeout; 456 public int HttpTimeout;
440 public bool HttpVerifyCert = true; 457 public bool HttpVerifyCert = true;
458 public IWorkItemResult WorkItem = null;
459
441 //public bool HttpVerboseThrottle = true; // not implemented 460 //public bool HttpVerboseThrottle = true; // not implemented
442 public List<string> HttpCustomHeaders = null; 461 public List<string> HttpCustomHeaders = null;
443 public bool HttpPragmaNoCache = true; 462 public bool HttpPragmaNoCache = true;
@@ -485,15 +504,44 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
485 504
486 public void Process() 505 public void Process()
487 { 506 {
507 _finished = false;
508
509 lock (HttpRequestModule.ThreadPool)
510 WorkItem = HttpRequestModule.ThreadPool.QueueWorkItem(new WorkItemCallback(StpSendWrapper), null);
511 }
512
513 private object StpSendWrapper(object o)
514 {
488 SendRequest(); 515 SendRequest();
516 return null;
489 } 517 }
490 518
519 /*
520 * TODO: More work on the response codes. Right now
521 * returning 200 for success or 499 for exception
522 */
523
491 public void SendRequest() 524 public void SendRequest()
492 { 525 {
526 HttpWebResponse response = null;
527 Stream resStream = null;
528 StringBuilder sb = new StringBuilder();
529 byte[] buf = new byte[8192];
530 string tempString = null;
531 int count = 0;
532
493 try 533 try
494 { 534 {
535<<<<<<< HEAD
495 Request = (HttpWebRequest)WebRequest.Create(Url); 536 Request = (HttpWebRequest)WebRequest.Create(Url);
496 Request.AllowAutoRedirect = false; 537 Request.AllowAutoRedirect = false;
538=======
539 Request = (HttpWebRequest) WebRequest.Create(Url);
540
541 //This works around some buggy HTTP Servers like Lighttpd
542 Request.ServicePoint.Expect100Continue = false;
543
544>>>>>>> avn/ubitvar
497 Request.Method = HttpMethod; 545 Request.Method = HttpMethod;
498 Request.ContentType = HttpMIMEType; 546 Request.ContentType = HttpMIMEType;
499 547
@@ -501,7 +549,6 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
501 { 549 {
502 // We could hijack Connection Group Name to identify 550 // We could hijack Connection Group Name to identify
503 // a desired security exception. But at the moment we'll use a dummy header instead. 551 // a desired security exception. But at the moment we'll use a dummy header instead.
504// Request.ConnectionGroupName = "NoVerify";
505 Request.Headers.Add("NoVerifyCert", "true"); 552 Request.Headers.Add("NoVerifyCert", "true");
506 } 553 }
507// else 554// else
@@ -534,14 +581,11 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
534 } 581 }
535 } 582 }
536 583
537 if (ResponseHeaders != null) 584 foreach (KeyValuePair<string, string> entry in ResponseHeaders)
538 { 585 if (entry.Key.ToLower().Equals("user-agent"))
539 foreach (KeyValuePair<string, string> entry in ResponseHeaders) 586 Request.UserAgent = entry.Value;
540 if (entry.Key.ToLower().Equals("user-agent") && Request is HttpWebRequest) 587 else
541 ((HttpWebRequest)Request).UserAgent = entry.Value; 588 Request.Headers[entry.Key] = entry.Value;
542 else
543 Request.Headers[entry.Key] = entry.Value;
544 }
545 589
546 // Encode outbound data 590 // Encode outbound data
547 if (!string.IsNullOrEmpty(OutboundBody)) 591 if (!string.IsNullOrEmpty(OutboundBody))
@@ -553,12 +597,11 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
553 bstream.Write(data, 0, data.Length); 597 bstream.Write(data, 0, data.Length);
554 } 598 }
555 599
600 Request.Timeout = HttpTimeout;
556 try 601 try
557 { 602 {
558 IAsyncResult result = (IAsyncResult)Request.BeginGetResponse(ResponseCallback, null); 603 // execute the request
559 604 response = (HttpWebResponse) Request.GetResponse();
560 ThreadPool.RegisterWaitForSingleObject(
561 result.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), null, HttpTimeout, true);
562 } 605 }
563 catch (WebException e) 606 catch (WebException e)
564 { 607 {
@@ -566,65 +609,74 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
566 { 609 {
567 throw; 610 throw;
568 } 611 }
612 response = (HttpWebResponse)e.Response;
613 }
569 614
570 HttpWebResponse response = (HttpWebResponse)e.Response; 615 Status = (int)response.StatusCode;
571 616
572 Status = (int)response.StatusCode; 617 resStream = response.GetResponseStream();
573 ResponseBody = response.StatusDescription;
574 _finished = true;
575 }
576 }
577 catch (Exception e)
578 {
579// m_log.Debug(
580// string.Format("[SCRIPTS HTTP REQUESTS]: Exception on request to {0} for {1} ", Url, ItemID), e);
581 618
582 Status = (int)OSHttpStatusCode.ClientErrorJoker; 619 do
583 ResponseBody = e.Message; 620 {
584 _finished = true; 621 // fill the buffer with data
585 } 622 count = resStream.Read(buf, 0, buf.Length);
586 }
587 623
588 private void ResponseCallback(IAsyncResult ar) 624 // make sure we read some data
589 { 625 if (count != 0)
590 HttpWebResponse response = null; 626 {
627 // translate from bytes to ASCII text
628 tempString = Util.UTF8.GetString(buf, 0, count);
591 629
592 try 630 // continue building the string
631 sb.Append(tempString);
632 if (sb.Length > 2048)
633 break;
634 }
635 } while (count > 0); // any more data to read?
636
637 ResponseBody = sb.ToString().Replace("\r", "");
638 }
639 catch (WebException e)
593 { 640 {
594 try 641 if (e.Status == WebExceptionStatus.ProtocolError)
595 {
596 response = (HttpWebResponse)Request.EndGetResponse(ar);
597 }
598 catch (WebException e)
599 { 642 {
600 if (e.Status != WebExceptionStatus.ProtocolError) 643 HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response;
644 Status = (int)webRsp.StatusCode;
645 try
601 { 646 {
602 throw; 647 using (Stream responseStream = webRsp.GetResponseStream())
648 {
649 ResponseBody = responseStream.GetStreamString();
650 }
603 } 651 }
604 652 catch
605 response = (HttpWebResponse)e.Response; 653 {
654 ResponseBody = webRsp.StatusDescription;
655 }
656 }
657 else
658 {
659 Status = (int)OSHttpStatusCode.ClientErrorJoker;
660 ResponseBody = e.Message;
606 } 661 }
607 662
608 Status = (int)response.StatusCode; 663 if (ResponseBody == null)
664 ResponseBody = String.Empty;
609 665
610 using (Stream stream = response.GetResponseStream()) 666 _finished = true;
611 { 667 return;
612 StreamReader reader = new StreamReader(stream, Encoding.UTF8);
613 ResponseBody = reader.ReadToEnd();
614 }
615 } 668 }
616 catch (Exception e) 669 catch (Exception e)
617 { 670 {
618 Status = (int)OSHttpStatusCode.ClientErrorJoker; 671 // Don't crash on anything else
619 ResponseBody = e.Message;
620
621// m_log.Debug(
622// string.Format("[SCRIPTS HTTP REQUESTS]: Exception on response to {0} for {1} ", Url, ItemID), e);
623 } 672 }
624 finally 673 finally
625 { 674 {
675 if (resStream != null)
676 resStream.Close();
626 if (response != null) 677 if (response != null)
627 response.Close(); 678 response.Close();
679<<<<<<< HEAD
628 680
629 // We need to resubmit 681 // We need to resubmit
630 if ( 682 if (
@@ -672,21 +724,28 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
672 { 724 {
673 _finished = true; 725 _finished = true;
674 } 726 }
727=======
728>>>>>>> avn/ubitvar
675 } 729 }
676 }
677 730
678 private void TimeoutCallback(object state, bool timedOut) 731 if (ResponseBody == null)
679 { 732 ResponseBody = String.Empty;
680 if (timedOut) 733
681 Request.Abort(); 734 _finished = true;
682 } 735 }
683 736
684 public void Stop() 737 public void Stop()
685 { 738 {
686// m_log.DebugFormat("[SCRIPTS HTTP REQUESTS]: Stopping request to {0} for {1} ", Url, ItemID); 739 try
687 740 {
688 if (Request != null) 741 if (!WorkItem.Cancel())
689 Request.Abort(); 742 {
743 WorkItem.Cancel(true);
744 }
745 }
746 catch (Exception)
747 {
748 }
690 } 749 }
691 } 750 }
692} \ No newline at end of file 751}
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 99a3122..1983fed 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -42,40 +42,16 @@ using OpenSim.Region.Framework.Scenes;
42 42
43namespace OpenSim.Region.CoreModules.Scripting.LSLHttp 43namespace 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;
53 public bool isSsl;
54 public Scene scene;
79 } 55 }
80 56
81 public class RequestData 57 public class RequestData
@@ -89,7 +65,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
89 //public ManualResetEvent ev; 65 //public ManualResetEvent ev;
90 public bool requestDone; 66 public bool requestDone;
91 public int startTime; 67 public int startTime;
68 public bool responseSent;
92 public string uri; 69 public string uri;
70 public bool allowResponseType = false;
71 public UUID hostID;
72 public Scene scene;
93 } 73 }
94 74
95 /// <summary> 75 /// <summary>
@@ -102,20 +82,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
102 LogManager.GetLogger( 82 LogManager.GetLogger(
103 MethodBase.GetCurrentMethod().DeclaringType); 83 MethodBase.GetCurrentMethod().DeclaringType);
104 84
105 /// <summary> 85 private Dictionary<UUID, UrlData> m_RequestMap =
106 /// Indexs the URL request metadata (which script requested it, outstanding requests, etc.) by the request ID 86 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 87
115 /// <summary> 88 private Dictionary<string, UrlData> m_UrlMap =
116 /// Indexs the URL request metadata (which script requested it, outstanding requests, etc.) by the full URL 89 new Dictionary<string, UrlData>();
117 /// </summary>
118 private Dictionary<string, UrlData> m_UrlMap = new Dictionary<string, UrlData>();
119 90
120 private uint m_HttpsPort = 0; 91 private uint m_HttpsPort = 0;
121 private IHttpServer m_HttpServer = null; 92 private IHttpServer m_HttpServer = null;
@@ -126,7 +97,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
126 /// <summary> 97 /// <summary>
127 /// The default maximum number of urls 98 /// The default maximum number of urls
128 /// </summary> 99 /// </summary>
129 public const int DefaultTotalUrls = 100; 100 public const int DefaultTotalUrls = 15000;
130 101
131 /// <summary> 102 /// <summary>
132 /// Maximum number of external urls that can be set up by this module. 103 /// Maximum number of external urls that can be set up by this module.
@@ -204,6 +175,17 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
204 175
205 public void RemoveRegion(Scene scene) 176 public void RemoveRegion(Scene scene)
206 { 177 {
178 // Drop references to that scene
179 foreach (KeyValuePair<string, UrlData> kvp in m_UrlMap)
180 {
181 if (kvp.Value.scene == scene)
182 kvp.Value.scene = null;
183 }
184 foreach (KeyValuePair<UUID, UrlData> kvp in m_RequestMap)
185 {
186 if (kvp.Value.scene == scene)
187 kvp.Value.scene = null;
188 }
207 } 189 }
208 190
209 public void Close() 191 public void Close()
@@ -221,7 +203,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
221 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 203 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
222 return urlcode; 204 return urlcode;
223 } 205 }
224 string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; 206 string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString();
225 207
226 UrlData urlData = new UrlData(); 208 UrlData urlData = new UrlData();
227 urlData.hostID = host.UUID; 209 urlData.hostID = host.UUID;
@@ -229,20 +211,22 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
229 urlData.engine = engine; 211 urlData.engine = engine;
230 urlData.url = url; 212 urlData.url = url;
231 urlData.urlcode = urlcode; 213 urlData.urlcode = urlcode;
214 urlData.isSsl = false;
232 urlData.requests = new Dictionary<UUID, RequestData>(); 215 urlData.requests = new Dictionary<UUID, RequestData>();
233 216 urlData.scene = host.ParentGroup.Scene;
217
234 m_UrlMap[url] = urlData; 218 m_UrlMap[url] = urlData;
235 219
236 string uri = "/lslhttp/" + urlcode.ToString() + "/"; 220 string uri = "/lslhttp/" + urlcode.ToString();
237 221
238 PollServiceEventArgs args 222 PollServiceEventArgs args
239 = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); 223 = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000);
240 args.Type = PollServiceEventArgs.EventType.LslHttp; 224 args.Type = PollServiceEventArgs.EventType.LslHttp;
241 m_HttpServer.AddPollServiceHTTPHandler(uri, args); 225 m_HttpServer.AddPollServiceHTTPHandler(uri, args);
242 226
243 m_log.DebugFormat( 227// m_log.DebugFormat(
244 "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}", 228// "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}",
245 uri, itemID, host.Name, host.LocalId); 229// uri, itemID, host.Name, host.LocalId);
246 230
247 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); 231 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url });
248 } 232 }
@@ -267,7 +251,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
267 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 251 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
268 return urlcode; 252 return urlcode;
269 } 253 }
270 string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; 254 string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString();
271 255
272 UrlData urlData = new UrlData(); 256 UrlData urlData = new UrlData();
273 urlData.hostID = host.UUID; 257 urlData.hostID = host.UUID;
@@ -275,20 +259,22 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
275 urlData.engine = engine; 259 urlData.engine = engine;
276 urlData.url = url; 260 urlData.url = url;
277 urlData.urlcode = urlcode; 261 urlData.urlcode = urlcode;
262 urlData.isSsl = true;
278 urlData.requests = new Dictionary<UUID, RequestData>(); 263 urlData.requests = new Dictionary<UUID, RequestData>();
279 264
265
280 m_UrlMap[url] = urlData; 266 m_UrlMap[url] = urlData;
281 267
282 string uri = "/lslhttps/" + urlcode.ToString() + "/"; 268 string uri = "/lslhttps/" + urlcode.ToString();
283 269
284 PollServiceEventArgs args 270 PollServiceEventArgs args
285 = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); 271 = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000);
286 args.Type = PollServiceEventArgs.EventType.LslHttp; 272 args.Type = PollServiceEventArgs.EventType.LslHttp;
287 m_HttpsServer.AddPollServiceHTTPHandler(uri, args); 273 m_HttpsServer.AddPollServiceHTTPHandler(uri, args);
288 274
289 m_log.DebugFormat( 275// m_log.DebugFormat(
290 "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", 276// "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}",
291 uri, itemID, host.Name, host.LocalId); 277// uri, itemID, host.Name, host.LocalId);
292 278
293 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); 279 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url });
294 } 280 }
@@ -307,12 +293,15 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
307 return; 293 return;
308 } 294 }
309 295
310 foreach (UUID req in data.requests.Keys) 296 lock (m_RequestMap)
311 m_RequestMap.Remove(req); 297 {
312 298 foreach (UUID req in data.requests.Keys)
313 m_log.DebugFormat( 299 m_RequestMap.Remove(req);
314 "[URL MODULE]: Releasing url {0} for {1} in {2}", 300 }
315 url, data.itemID, data.hostID); 301
302// m_log.DebugFormat(
303// "[URL MODULE]: Releasing url {0} for {1} in {2}",
304// url, data.itemID, data.hostID);
316 305
317 RemoveUrl(data); 306 RemoveUrl(data);
318 m_UrlMap.Remove(url); 307 m_UrlMap.Remove(url);
@@ -337,29 +326,39 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
337 326
338 public void HttpResponse(UUID request, int status, string body) 327 public void HttpResponse(UUID request, int status, string body)
339 { 328 {
340 lock (m_UrlMap) 329 lock (m_RequestMap)
341 { 330 {
342 if (m_RequestMap.ContainsKey(request)) 331 if (m_RequestMap.ContainsKey(request))
343 { 332 {
344 UrlData urlData = m_RequestMap[request]; 333 UrlData urlData = m_RequestMap[request];
345 string responseBody = body; 334 if (!urlData.requests[request].responseSent)
346 if (urlData.requests[request].responseType.Equals("text/plain"))
347 { 335 {
348 string value; 336 string responseBody = body;
349 if (urlData.requests[request].headers.TryGetValue("user-agent", out value)) 337
338 // If we have no OpenID from built-in browser, disable this
339 if (!urlData.requests[request].allowResponseType)
340 urlData.requests[request].responseType = "text/plain";
341
342 if (urlData.requests[request].responseType.Equals("text/plain"))
350 { 343 {
351 if (value != null && value.IndexOf("MSIE") >= 0) 344 string value;
345 if (urlData.requests[request].headers.TryGetValue("user-agent", out value))
352 { 346 {
353 // wrap the html escaped response if the target client is IE 347 if (value != null && value.IndexOf("MSIE") >= 0)
354 // It ignores "text/plain" if the body is html 348 {
355 responseBody = "<html>" + System.Web.HttpUtility.HtmlEncode(body) + "</html>"; 349 // wrap the html escaped response if the target client is IE
350 // It ignores "text/plain" if the body is html
351 responseBody = "<html>" + System.Web.HttpUtility.HtmlEncode(body) + "</html>";
352 }
356 } 353 }
357 } 354 }
355
356 urlData.requests[request].responseCode = status;
357 urlData.requests[request].responseBody = body;
358 //urlData.requests[request].ev.Set();
359 urlData.requests[request].requestDone = true;
360 urlData.requests[request].responseSent = true;
358 } 361 }
359 urlData.requests[request].responseCode = status;
360 urlData.requests[request].responseBody = responseBody;
361 //urlData.requests[request].ev.Set();
362 urlData.requests[request].requestDone =true;
363 } 362 }
364 else 363 else
365 { 364 {
@@ -370,7 +369,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
370 369
371 public string GetHttpHeader(UUID requestId, string header) 370 public string GetHttpHeader(UUID requestId, string header)
372 { 371 {
373 lock (m_UrlMap) 372 lock (m_RequestMap)
374 { 373 {
375 if (m_RequestMap.ContainsKey(requestId)) 374 if (m_RequestMap.ContainsKey(requestId))
376 { 375 {
@@ -384,7 +383,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
384 m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); 383 m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId);
385 } 384 }
386 } 385 }
387
388 return String.Empty; 386 return String.Empty;
389 } 387 }
390 388
@@ -408,8 +406,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
408 { 406 {
409 RemoveUrl(url.Value); 407 RemoveUrl(url.Value);
410 removeURLs.Add(url.Key); 408 removeURLs.Add(url.Key);
411 foreach (UUID req in url.Value.requests.Keys) 409 lock (m_RequestMap)
412 m_RequestMap.Remove(req); 410 {
411 foreach (UUID req in url.Value.requests.Keys)
412 m_RequestMap.Remove(req);
413 }
413 } 414 }
414 } 415 }
415 416
@@ -430,9 +431,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
430 { 431 {
431 RemoveUrl(url.Value); 432 RemoveUrl(url.Value);
432 removeURLs.Add(url.Key); 433 removeURLs.Add(url.Key);
433 434 lock (m_RequestMap)
434 foreach (UUID req in url.Value.requests.Keys) 435 {
435 m_RequestMap.Remove(req); 436 foreach (UUID req in url.Value.requests.Keys)
437 m_RequestMap.Remove(req);
438 }
436 } 439 }
437 } 440 }
438 441
@@ -441,123 +444,128 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
441 } 444 }
442 } 445 }
443 446
447
444 private void RemoveUrl(UrlData data) 448 private void RemoveUrl(UrlData data)
445 { 449 {
446 m_HttpServer.RemoveHTTPHandler("", "/lslhttp/" + data.urlcode.ToString() + "/"); 450 if (data.isSsl)
451 m_HttpsServer.RemoveHTTPHandler("", "/lslhttps/"+data.urlcode.ToString()+"/");
452 else
453 m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/");
447 } 454 }
448 455
449 private Hashtable NoEvents(UUID requestID, UUID sessionID) 456 private Hashtable NoEvents(UUID requestID, UUID sessionID)
450 { 457 {
451 Hashtable response = new Hashtable(); 458 Hashtable response = new Hashtable();
452 UrlData urlData; 459 UrlData url;
453 460 int startTime = 0;
454 lock (m_UrlMap) 461 lock (m_RequestMap)
455 { 462 {
456 // We need to return a 404 here in case the request URL was removed at exactly the same time that a
457 // request was made. In this case, the request thread can outrace llRemoveURL() and still be polling
458 // for the request ID.
459 if (!m_RequestMap.ContainsKey(requestID)) 463 if (!m_RequestMap.ContainsKey(requestID))
460 {
461 response["int_response_code"] = 404;
462 response["str_response_string"] = "";
463 response["keepalive"] = false;
464 response["reusecontext"] = false;
465
466 return response; 464 return response;
467 } 465 url = m_RequestMap[requestID];
466 startTime = url.requests[requestID].startTime;
467 }
468 468
469 urlData = m_RequestMap[requestID]; 469 if (System.Environment.TickCount - startTime > 25000)
470 {
471 response["int_response_code"] = 500;
472 response["str_response_string"] = "Script timeout";
473 response["content_type"] = "text/plain";
474 response["keepalive"] = false;
475 response["reusecontext"] = false;
470 476
471 if (System.Environment.TickCount - urlData.requests[requestID].startTime > 25000) 477 //remove from map
478 lock (url.requests)
479 {
480 url.requests.Remove(requestID);
481 }
482 lock (m_RequestMap)
472 { 483 {
473 response["int_response_code"] = 500;
474 response["str_response_string"] = "Script timeout";
475 response["content_type"] = "text/plain";
476 response["keepalive"] = false;
477 response["reusecontext"] = false;
478
479 //remove from map
480 urlData.requests.Remove(requestID);
481 m_RequestMap.Remove(requestID); 484 m_RequestMap.Remove(requestID);
482
483 return response;
484 } 485 }
486
487 return response;
485 } 488 }
486 489
490
487 return response; 491 return response;
488 } 492 }
489 493
490 private bool HasEvents(UUID requestID, UUID sessionID) 494 private bool HasEvents(UUID requestID, UUID sessionID)
491 { 495 {
492 lock (m_UrlMap) 496 UrlData url=null;
497
498 lock (m_RequestMap)
493 { 499 {
494 // We return true here because an external URL request that happened at the same time as an llRemoveURL()
495 // can still make it through to HttpRequestHandler(). That will return without setting up a request
496 // when it detects that the URL has been removed. The poller, however, will continue to ask for
497 // events for that request, so here we will signal that there are events and in GetEvents we will
498 // return a 404.
499 if (!m_RequestMap.ContainsKey(requestID)) 500 if (!m_RequestMap.ContainsKey(requestID))
500 { 501 {
501 return true; 502 return false;
502 } 503 }
503 504 url = m_RequestMap[requestID];
504 UrlData urlData = m_RequestMap[requestID]; 505 }
505 506 lock (url.requests)
506 if (!urlData.requests.ContainsKey(requestID)) 507 {
508 if (!url.requests.ContainsKey(requestID))
507 { 509 {
508 return true; 510 return false;
509 } 511 }
510 512 else
511 // Trigger return of timeout response.
512 if (System.Environment.TickCount - urlData.requests[requestID].startTime > 25000)
513 { 513 {
514 return true; 514 if (System.Environment.TickCount - url.requests[requestID].startTime > 25000)
515 {
516 return true;
517 }
518 if (url.requests[requestID].requestDone)
519 return true;
520 else
521 return false;
515 } 522 }
516
517 return urlData.requests[requestID].requestDone;
518 } 523 }
519 } 524 }
520
521 private Hashtable GetEvents(UUID requestID, UUID sessionID) 525 private Hashtable GetEvents(UUID requestID, UUID sessionID)
522 { 526 {
523 Hashtable response; 527 UrlData url = null;
528 RequestData requestData = null;
524 529
525 lock (m_UrlMap) 530 lock (m_RequestMap)
526 { 531 {
527 UrlData url = null;
528 RequestData requestData = null;
529
530 if (!m_RequestMap.ContainsKey(requestID)) 532 if (!m_RequestMap.ContainsKey(requestID))
531 return NoEvents(requestID, sessionID); 533 return NoEvents(requestID,sessionID);
532
533 url = m_RequestMap[requestID]; 534 url = m_RequestMap[requestID];
535 }
536 lock (url.requests)
537 {
534 requestData = url.requests[requestID]; 538 requestData = url.requests[requestID];
539 }
540
541 if (!requestData.requestDone)
542 return NoEvents(requestID,sessionID);
543
544 Hashtable response = new Hashtable();
535 545
536 if (!requestData.requestDone) 546 if (System.Environment.TickCount - requestData.startTime > 25000)
537 return NoEvents(requestID, sessionID); 547 {
538 548 response["int_response_code"] = 500;
539 response = new Hashtable(); 549 response["str_response_string"] = "Script timeout";
540 550 response["content_type"] = "text/plain";
541 if (System.Environment.TickCount - requestData.startTime > 25000)
542 {
543 response["int_response_code"] = 500;
544 response["str_response_string"] = "Script timeout";
545 response["content_type"] = "text/plain";
546 response["keepalive"] = false;
547 response["reusecontext"] = false;
548 return response;
549 }
550
551 //put response
552 response["int_response_code"] = requestData.responseCode;
553 response["str_response_string"] = requestData.responseBody;
554 response["content_type"] = requestData.responseType;
555 // response["content_type"] = "text/plain";
556 response["keepalive"] = false; 551 response["keepalive"] = false;
557 response["reusecontext"] = false; 552 response["reusecontext"] = false;
558 553 return response;
559 //remove from map 554 }
555 //put response
556 response["int_response_code"] = requestData.responseCode;
557 response["str_response_string"] = requestData.responseBody;
558 response["content_type"] = requestData.responseType;
559 response["keepalive"] = false;
560 response["reusecontext"] = false;
561
562 //remove from map
563 lock (url.requests)
564 {
560 url.requests.Remove(requestID); 565 url.requests.Remove(requestID);
566 }
567 lock (m_RequestMap)
568 {
561 m_RequestMap.Remove(requestID); 569 m_RequestMap.Remove(requestID);
562 } 570 }
563 571
@@ -566,41 +574,45 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
566 574
567 public void HttpRequestHandler(UUID requestID, Hashtable request) 575 public void HttpRequestHandler(UUID requestID, Hashtable request)
568 { 576 {
569 string uri = request["uri"].ToString(); 577 lock (request)
570 bool is_ssl = uri.Contains("lslhttps");
571
572 try
573 { 578 {
574 Hashtable headers = (Hashtable)request["headers"]; 579 string uri = request["uri"].ToString();
580 bool is_ssl = uri.Contains("lslhttps");
575 581
576// string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; 582 try
577
578 int pos1 = uri.IndexOf("/");// /lslhttp
579 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/
580 int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/
581 string uri_tmp = uri.Substring(0, pos3 + 1);
582 //HTTP server code doesn't provide us with QueryStrings
583 string pathInfo;
584 string queryString;
585 queryString = "";
586
587 pathInfo = uri.Substring(pos3);
588
589 UrlData urlData = null;
590
591 lock (m_UrlMap)
592 { 583 {
593 string url; 584 Hashtable headers = (Hashtable)request["headers"];
594 585
595 if (is_ssl) 586// string uri_full = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/";
596 url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp; 587
588 int pos1 = uri.IndexOf("/");// /lslhttp
589 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/
590 int pos3 = pos2 + 37; // /lslhttp/urlcode
591 string uri_tmp = uri.Substring(0, pos3);
592 //HTTP server code doesn't provide us with QueryStrings
593 string pathInfo;
594 string queryString;
595 queryString = "";
596
597 pathInfo = uri.Substring(pos3);
598
599 UrlData url = null;
600 string urlkey;
601 if (!is_ssl)
602 urlkey = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp;
603 //m_UrlMap[];
597 else 604 else
598 url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp; 605 urlkey = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp;
599 606
600 // Avoid a race - the request URL may have been released via llRequestUrl() whilst this 607 if (m_UrlMap.ContainsKey(urlkey))
601 // request was being processed. 608 {
602 if (!m_UrlMap.TryGetValue(url, out urlData)) 609 url = m_UrlMap[urlkey];
610 }
611 else
612 {
613 //m_log.Warn("[HttpRequestHandler]: http-in request failed; no such url: "+urlkey.ToString());
603 return; 614 return;
615 }
604 616
605 //for llGetHttpHeader support we need to store original URI here 617 //for llGetHttpHeader support we need to store original URI here
606 //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers 618 //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers
@@ -611,6 +623,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
611 requestData.requestDone = false; 623 requestData.requestDone = false;
612 requestData.startTime = System.Environment.TickCount; 624 requestData.startTime = System.Environment.TickCount;
613 requestData.uri = uri; 625 requestData.uri = uri;
626 requestData.hostID = url.hostID;
627 requestData.scene = url.scene;
614 if (requestData.headers == null) 628 if (requestData.headers == null)
615 requestData.headers = new Dictionary<string, string>(); 629 requestData.headers = new Dictionary<string, string>();
616 630
@@ -619,8 +633,33 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
619 string key = (string)header.Key; 633 string key = (string)header.Key;
620 string value = (string)header.Value; 634 string value = (string)header.Value;
621 requestData.headers.Add(key, value); 635 requestData.headers.Add(key, value);
636 if (key == "cookie")
637 {
638 string[] parts = value.Split(new char[] {'='});
639 if (parts[0] == "agni_sl_session_id" && parts.Length > 1)
640 {
641 string cookie = Uri.UnescapeDataString(parts[1]);
642 string[] crumbs = cookie.Split(new char[] {':'});
643 UUID owner;
644 if (crumbs.Length == 2 && UUID.TryParse(crumbs[0], out owner))
645 {
646 if (crumbs[1].Length == 32)
647 {
648 Scene scene = requestData.scene;
649 if (scene != null)
650 {
651 SceneObjectPart host = scene.GetSceneObjectPart(requestData.hostID);
652 if (host != null)
653 {
654 if (host.OwnerID == owner)
655 requestData.allowResponseType = true;
656 }
657 }
658 }
659 }
660 }
661 }
622 } 662 }
623
624 foreach (DictionaryEntry de in request) 663 foreach (DictionaryEntry de in request)
625 { 664 {
626 if (de.Key.ToString() == "querystringkeys") 665 if (de.Key.ToString() == "querystringkeys")
@@ -631,13 +670,21 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
631 if (request.ContainsKey(key)) 670 if (request.ContainsKey(key))
632 { 671 {
633 string val = (String)request[key]; 672 string val = (String)request[key];
634 queryString = queryString + key + "=" + val + "&"; 673 if (key != "")
674 {
675 queryString = queryString + key + "=" + val + "&";
676 }
677 else
678 {
679 queryString = queryString + val + "&";
680 }
635 } 681 }
636 } 682 }
637
638 if (queryString.Length > 1) 683 if (queryString.Length > 1)
639 queryString = queryString.Substring(0, queryString.Length - 1); 684 queryString = queryString.Substring(0, queryString.Length - 1);
685
640 } 686 }
687
641 } 688 }
642 689
643 //if this machine is behind DNAT/port forwarding, currently this is being 690 //if this machine is behind DNAT/port forwarding, currently this is being
@@ -645,23 +692,34 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
645 requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; 692 requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"];
646 requestData.headers["x-path-info"] = pathInfo; 693 requestData.headers["x-path-info"] = pathInfo;
647 requestData.headers["x-query-string"] = queryString; 694 requestData.headers["x-query-string"] = queryString;
648 requestData.headers["x-script-url"] = urlData.url; 695 requestData.headers["x-script-url"] = url.url;
649 696
650 urlData.requests.Add(requestID, requestData); 697 //requestData.ev = new ManualResetEvent(false);
651 m_RequestMap.Add(requestID, urlData); 698 lock (url.requests)
652 } 699 {
700 url.requests.Add(requestID, requestData);
701 }
702 lock (m_RequestMap)
703 {
704 //add to request map
705 m_RequestMap.Add(requestID, url);
706 }
653 707
654 urlData.engine.PostScriptEvent( 708 url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() });
655 urlData.itemID, 709
656 "http_request", 710 //send initial response?
657 new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); 711// Hashtable response = new Hashtable();
658 } 712
659 catch (Exception we) 713 return;
660 { 714
661 //Hashtable response = new Hashtable(); 715 }
662 m_log.Warn("[HttpRequestHandler]: http-in request failed"); 716 catch (Exception we)
663 m_log.Warn(we.Message); 717 {
664 m_log.Warn(we.StackTrace); 718 //Hashtable response = new Hashtable();
719 m_log.Warn("[HttpRequestHandler]: http-in request failed");
720 m_log.Warn(we.Message);
721 m_log.Warn(we.StackTrace);
722 }
665 } 723 }
666 } 724 }
667 725
diff --git a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 6da2222..ad33f23 100644
--- a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -271,6 +271,8 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
271 return "modInvokeR"; 271 return "modInvokeR";
272 else if (sid.ReturnType == typeof(object[])) 272 else if (sid.ReturnType == typeof(object[]))
273 return "modInvokeL"; 273 return "modInvokeL";
274 else if (sid.ReturnType == typeof(void))
275 return "modInvokeN";
274 276
275 m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name); 277 m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name);
276 } 278 }
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index 4cecd85..2fc89fc 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -861,4 +861,4 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
861 return null; 861 return null;
862 } 862 }
863 } 863 }
864} \ No newline at end of file 864}
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
index 3484387..1c3a714 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,14 +368,19 @@ 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 {
383<<<<<<< HEAD
377 // ignore if a child agent this is restricted to inside one 384 // ignore if a child agent this is restricted to inside one
378 // region 385 // region
379 if (sp.IsChildAgent) 386 if (sp.IsChildAgent)
@@ -386,41 +393,50 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
386 List<SceneObjectGroup> attachments = sp.GetAttachments(); 393 List<SceneObjectGroup> attachments = sp.GetAttachments();
387 if (attachments.Count == 0) 394 if (attachments.Count == 0)
388 return; 395 return;
396=======
397 // Send message to avatar
398 if (channel == 0)
399 {
400 // Channel 0 goes to viewer ONLY
401 m_scene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, target, false, false);
402 return true;
403 }
404>>>>>>> avn/ubitvar
389 405
390 // Get uuid of attachments 406 List<SceneObjectGroup> attachments = sp.GetAttachments();
391 List<UUID> targets = new List<UUID>();
392 foreach (SceneObjectGroup sog in attachments)
393 {
394 if (!sog.IsDeleted)
395 targets.Add(sog.UUID);
396 }
397 407
398 // Need to check each attachment 408 if (attachments.Count == 0)
399 foreach (ListenerInfo li 409 return true;
400 in m_listenerManager.GetListeners(UUID.Zero,
401 channel, name, id, msg))
402 {
403 if (li.GetHostID().Equals(id))
404 continue;
405 410
406 if (m_scene.GetSceneObjectPart( 411 // Get uuid of attachments
407 li.GetHostID()) == null) 412 List<UUID> targets = new List<UUID>();
408 { 413 foreach (SceneObjectGroup sog in attachments)
409 continue; 414 {
410 } 415 if (!sog.IsDeleted)
416 targets.Add(sog.UUID);
417 }
411 418
412 if (targets.Contains(li.GetHostID())) 419 // Need to check each attachment
413 QueueMessage(new ListenerInfo(li, name, id, msg)); 420 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
414 } 421 {
422 if (li.GetHostID().Equals(id))
423 continue;
424
425 if (m_scene.GetSceneObjectPart(li.GetHostID()) == null)
426 continue;
427
428 if (targets.Contains(li.GetHostID()))
429 QueueMessage(new ListenerInfo(li, name, id, msg));
415 } 430 }
416 431
417 return; 432 return true;
418 } 433 }
419 434
420 // No avatar found so look for an object 435 SceneObjectPart part = m_scene.GetSceneObjectPart(target);
421 foreach (ListenerInfo li 436 if (part == null) // Not even an object
422 in m_listenerManager.GetListeners(UUID.Zero, channel, 437 return true; // No error
423 name, id, msg)) 438
439 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
424 { 440 {
425 // Dont process if this message is from yourself! 441 // Dont process if this message is from yourself!
426 if (li.GetHostID().Equals(id)) 442 if (li.GetHostID().Equals(id))
@@ -438,7 +454,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
438 } 454 }
439 } 455 }
440 456
441 return; 457 return true;
442 } 458 }
443 459
444 protected void QueueMessage(ListenerInfo li) 460 protected void QueueMessage(ListenerInfo li)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs
index 4701ee6..323535a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs
@@ -153,8 +153,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Profile
153 Server.AddJsonRPCHandler("avatar_properties_request", handler.AvatarPropertiesRequest); 153 Server.AddJsonRPCHandler("avatar_properties_request", handler.AvatarPropertiesRequest);
154 Server.AddJsonRPCHandler("avatar_properties_update", handler.AvatarPropertiesUpdate); 154 Server.AddJsonRPCHandler("avatar_properties_update", handler.AvatarPropertiesUpdate);
155 Server.AddJsonRPCHandler("avatar_interests_update", handler.AvatarInterestsUpdate); 155 Server.AddJsonRPCHandler("avatar_interests_update", handler.AvatarInterestsUpdate);
156 Server.AddJsonRPCHandler("user_preferences_update", handler.UserPreferenecesUpdate);
157 Server.AddJsonRPCHandler("user_preferences_request", handler.UserPreferencesRequest);
158 Server.AddJsonRPCHandler("image_assets_request", handler.AvatarImageAssetsRequest); 156 Server.AddJsonRPCHandler("image_assets_request", handler.AvatarImageAssetsRequest);
159 Server.AddJsonRPCHandler("user_data_request", handler.RequestUserAppData); 157 Server.AddJsonRPCHandler("user_data_request", handler.RequestUserAppData);
160 Server.AddJsonRPCHandler("user_data_update", handler.UpdateUserAppData); 158 Server.AddJsonRPCHandler("user_data_update", handler.UpdateUserAppData);
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/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
index aa5f889..8df30d4 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -198,4 +198,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
198 Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected"); 198 Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected");
199 } 199 }
200 } 200 }
201} \ No newline at end of file 201}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
index 860a526..d786c80 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
@@ -53,7 +53,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
53 /// </remarks> 53 /// </remarks>
54 54
55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")] 55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")]
56<<<<<<< HEAD
56 public class MapImageServiceModule : IMapImageUploadModule, ISharedRegionModule 57 public class MapImageServiceModule : IMapImageUploadModule, ISharedRegionModule
58=======
59 public class MapImageServiceModule : ISharedRegionModule, IMapImageUploadModule
60>>>>>>> avn/ubitvar
57 { 61 {
58 private static readonly ILog m_log = 62 private static readonly ILog m_log =
59 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 63 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -93,9 +97,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
93 if (config == null) 97 if (config == null)
94 return; 98 return;
95 99
100<<<<<<< HEAD
96 int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime")); 101 int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime"));
97 102
98 // if refresh is less than zero, disable the module 103 // if refresh is less than zero, disable the module
104=======
105 int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime", "-1"));
106>>>>>>> avn/ubitvar
99 if (refreshminutes < 0) 107 if (refreshminutes < 0)
100 { 108 {
101 m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Negative refresh time given in config. Module disabled."); 109 m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Negative refresh time given in config. Module disabled.");
@@ -128,7 +136,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
128 m_refreshTimer.Interval = m_refreshtime; 136 m_refreshTimer.Interval = m_refreshtime;
129 m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh); 137 m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh);
130 138
139<<<<<<< HEAD
131 m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0} min and service object {1}", 140 m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0} min and service object {1}",
141=======
142 if (m_refreshtime > 0)
143 {
144 m_refreshTimer.Enabled = true;
145 m_refreshTimer.AutoReset = true;
146 m_refreshTimer.Interval = m_refreshtime;
147 m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh);
148 }
149
150 m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0} min and service object {1}",
151>>>>>>> avn/ubitvar
132 refreshminutes, service); 152 refreshminutes, service);
133 } 153 }
134 else 154 else
@@ -154,7 +174,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
154 // v2 Map generation on startup is now handled by scene to allow bmp to be shared with 174 // v2 Map generation on startup is now handled by scene to allow bmp to be shared with
155 // v1 service and not generate map tiles twice as was previous behavior 175 // v1 service and not generate map tiles twice as was previous behavior
156 //scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) UploadMapTile(s); }; 176 //scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) UploadMapTile(s); };
177<<<<<<< HEAD
157 178
179=======
180>>>>>>> avn/ubitvar
158 scene.RegisterModuleInterface<IMapImageUploadModule>(this); 181 scene.RegisterModuleInterface<IMapImageUploadModule>(this);
159 } 182 }
160 183
@@ -212,9 +235,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
212 // If the region/maptile is legacy sized, just upload the one tile like it has always been done 235 // If the region/maptile is legacy sized, just upload the one tile like it has always been done
213 if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize) 236 if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
214 { 237 {
238<<<<<<< HEAD
215 ConvertAndUploadMaptile(mapTile, 239 ConvertAndUploadMaptile(mapTile,
216 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, 240 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
217 scene.RegionInfo.RegionName); 241 scene.RegionInfo.RegionName);
242=======
243 ConvertAndUploadMaptile(mapTile, scene,
244 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
245 scene.RegionInfo.RegionName);
246>>>>>>> avn/ubitvar
218 } 247 }
219 else 248 else
220 { 249 {
@@ -234,10 +263,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
234 (int)Constants.RegionSize, (int)Constants.RegionSize); 263 (int)Constants.RegionSize, (int)Constants.RegionSize);
235 using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat)) 264 using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat))
236 { 265 {
266<<<<<<< HEAD
237 ConvertAndUploadMaptile(subMapTile, 267 ConvertAndUploadMaptile(subMapTile,
238 scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize), 268 scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize),
239 scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize), 269 scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize),
240 scene.Name); 270 scene.Name);
271=======
272 ConvertAndUploadMaptile(subMapTile, scene,
273 scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize),
274 scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize),
275 scene.Name);
276>>>>>>> avn/ubitvar
241 } 277 }
242 } 278 }
243 } 279 }
@@ -247,8 +283,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
247 ///<summary> 283 ///<summary>
248 /// 284 ///
249 ///</summary> 285 ///</summary>
250 private void UploadMapTile(IScene scene) 286 public void UploadMapTile(IScene scene)
251 { 287 {
288<<<<<<< HEAD
289=======
290 m_log.DebugFormat("{0}: upload maptile for {1}", LogHeader, scene.RegionInfo.RegionName);
291
292>>>>>>> avn/ubitvar
252 // Create a JPG map tile and upload it to the AddMapTile API 293 // Create a JPG map tile and upload it to the AddMapTile API
253 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); 294 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
254 if (tileGenerator == null) 295 if (tileGenerator == null)
@@ -259,6 +300,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
259 300
260 using (Bitmap mapTile = tileGenerator.CreateMapTile()) 301 using (Bitmap mapTile = tileGenerator.CreateMapTile())
261 { 302 {
303<<<<<<< HEAD
262 if (mapTile != null) 304 if (mapTile != null)
263 { 305 {
264 UploadMapTile(scene, mapTile); 306 UploadMapTile(scene, mapTile);
@@ -274,6 +316,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
274 { 316 {
275 byte[] jpgData = Utils.EmptyBytes; 317 byte[] jpgData = Utils.EmptyBytes;
276 318
319=======
320 // XXX: The MapImageModule will return a null if the user has chosen not to create map tiles and there
321 // is no static map tile.
322 if (mapTile == null)
323 return;
324
325 UploadMapTile(scene, mapTile);
326 }
327 }
328
329 private void ConvertAndUploadMaptile(Image tileImage, IScene scene, uint locX, uint locY, string regionName)
330 {
331 byte[] jpgData = Utils.EmptyBytes;
332
333>>>>>>> avn/ubitvar
277 using (MemoryStream stream = new MemoryStream()) 334 using (MemoryStream stream = new MemoryStream())
278 { 335 {
279 tileImage.Save(stream, ImageFormat.Jpeg); 336 tileImage.Save(stream, ImageFormat.Jpeg);
@@ -282,7 +339,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
282 if (jpgData != Utils.EmptyBytes) 339 if (jpgData != Utils.EmptyBytes)
283 { 340 {
284 string reason = string.Empty; 341 string reason = string.Empty;
342<<<<<<< HEAD
285 if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, out reason)) 343 if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, out reason))
344=======
345 if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, scene.RegionInfo.ScopeID, out reason))
346>>>>>>> avn/ubitvar
286 { 347 {
287 m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader, 348 m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader,
288 regionName, locX, locY, reason); 349 regionName, locX, locY, reason);
@@ -290,8 +351,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
290 } 351 }
291 else 352 else
292 { 353 {
354<<<<<<< HEAD
293 m_log.WarnFormat("{0} Tile image generation failed for region {1}", LogHeader, regionName); 355 m_log.WarnFormat("{0} Tile image generation failed for region {1}", LogHeader, regionName);
356=======
357 m_log.WarnFormat("{0} Tile image generation failed for region {1}", LogHeader, scene.RegionInfo.RegionName);
358>>>>>>> avn/ubitvar
294 } 359 }
295 } 360 }
296 } 361 }
297} \ No newline at end of file 362}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index adf3a91..50238a5 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -269,7 +269,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
269 return true; 269 return true;
270 } 270 }
271 271
272<<<<<<< HEAD
272 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, string theirversion, List<UUID> features, out string version, out string reason) 273 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, string theirversion, List<UUID> features, out string version, out string reason)
274=======
275 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, string theirversion, out string version, out string reason)
276>>>>>>> avn/ubitvar
273 { 277 {
274 reason = "Communications failure"; 278 reason = "Communications failure";
275 version = ServiceVersion; 279 version = ServiceVersion;
@@ -298,7 +302,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
298 302
299 } 303 }
300 304
305<<<<<<< HEAD
301 return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, viaTeleport, position, features, out reason); 306 return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, viaTeleport, position, features, out reason);
307=======
308
309 // not really need on a grid running var regions sims
310
311 uint size = m_scenes[destination.RegionID].RegionInfo.RegionSizeX;
312
313 float theirVersionNumber = 0f;
314 string[] versionComponents = theirversion.Split(new char[] { '/' });
315 if (versionComponents.Length >= 2)
316 float.TryParse(versionComponents[1], out theirVersionNumber);
317
318 // Var regions here, and the requesting simulator is in an older version.
319 // We will forbide this, because it crashes the viewers
320 if (theirVersionNumber < 0.3f && size > 256)
321 {
322 reason = "Destination is a variable-sized region, and source is an old simulator. Consider upgrading.";
323 m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Request to access this variable-sized region from {0} simulator was denied", theirVersionNumber);
324 return false;
325 }
326 return m_scenes[destination.RegionID].QueryAccess(agentID, position, out reason);
327>>>>>>> avn/ubitvar
302 } 328 }
303 329
304 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess"); 330 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
@@ -335,7 +361,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
335 m_scenes[destination.RegionID].CloseAgent(id, false, auth_token); 361 m_scenes[destination.RegionID].CloseAgent(id, false, auth_token);
336 return true; 362 return true;
337 } 363 }
338
339 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); 364 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
340 return false; 365 return false;
341 } 366 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index dca3dd7..7044d92 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -206,7 +206,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
206 return m_remoteConnector.UpdateAgent(destination, cAgentData); 206 return m_remoteConnector.UpdateAgent(destination, cAgentData);
207 } 207 }
208 208
209<<<<<<< HEAD
209 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, string sversion, List<UUID> features, out string version, out string reason) 210 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, string sversion, List<UUID> features, out string version, out string reason)
211=======
212 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, string sversion, out string version, out string reason)
213>>>>>>> avn/ubitvar
210 { 214 {
211 reason = "Communications failure"; 215 reason = "Communications failure";
212 version = "Unknown"; 216 version = "Unknown";
@@ -215,12 +219,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
215 return false; 219 return false;
216 220
217 // Try local first 221 // Try local first
222<<<<<<< HEAD
218 if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, sversion, features, out version, out reason)) 223 if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, sversion, features, out version, out reason))
224=======
225 if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, sversion, out version, out reason))
226 return true;
227>>>>>>> avn/ubitvar
219 return true; 228 return true;
220 229
221 // else do the remote thing 230 // else do the remote thing
222 if (!m_localBackend.IsLocalRegion(destination.RegionID)) 231 if (!m_localBackend.IsLocalRegion(destination.RegionID))
232<<<<<<< HEAD
223 return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, sversion, features, out version, out reason); 233 return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, sversion, features, out version, out reason);
234=======
235 return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, sversion, out version, out reason);
236
237>>>>>>> avn/ubitvar
224 238
225 return false; 239 return false;
226 } 240 }
@@ -238,7 +252,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
238 return false; 252 return false;
239 } 253 }
240 254
241
242 public bool CloseAgent(GridRegion destination, UUID id, string auth_token) 255 public bool CloseAgent(GridRegion destination, UUID id, string auth_token)
243 { 256 {
244 if (destination == null) 257 if (destination == null)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
index 6d4ac39..cf9a7b4 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);
@@ -203,4 +209,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
203 209
204 #endregion 210 #endregion
205 } 211 }
206} \ No newline at end of file 212}
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;
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36using OpenSim.Services.Connectors; 36using OpenSim.Services.Connectors;
37using OpenSim.Framework;
37 38
38using OpenMetaverse; 39using 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 ed52e48..53610d9 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
35namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts 35namespace 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
@@ -97,5 +97,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
97 97
98 return null; 98 return null;
99 } 99 }
100
101 public void Remove(string name)
102 {
103 if (!m_NameCache.Contains(name))
104 return;
105
106 UUID uuid = UUID.Zero;
107 if (m_NameCache.TryGetValue(name, out uuid))
108 {
109 m_NameCache.Remove(name);
110 m_UUIDCache.Remove(uuid);
111 }
112 }
100 } 113 }
101} 114}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 9c6706f..f0b0f4a 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -160,10 +160,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
160 160
161 private IAssetService m_assetService = null; 161 private IAssetService m_assetService = null;
162 162
163 private UUID m_defaultUser;
163 164
165<<<<<<< HEAD
164 private UUID m_defaultUser; 166 private UUID m_defaultUser;
165 167
166 public ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionary<string,object>options) 168 public ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionary<string,object>options)
169=======
170 public ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionary<string, object> options)
171>>>>>>> avn/ubitvar
167 { 172 {
168 m_rootScene = scene; 173 m_rootScene = scene;
169 174
@@ -172,7 +177,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
172 m_defaultUser = (UUID)options["default-user"]; 177 m_defaultUser = (UUID)options["default-user"];
173 m_log.InfoFormat("Using User {0} as default user", m_defaultUser.ToString()); 178 m_log.InfoFormat("Using User {0} as default user", m_defaultUser.ToString());
174 } 179 }
180<<<<<<< HEAD
175 else 181 else
182=======
183 else
184>>>>>>> avn/ubitvar
176 { 185 {
177 m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner; 186 m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner;
178 } 187 }
@@ -189,8 +198,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
189 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 198 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
190 m_log.Error(e); 199 m_log.Error(e);
191 } 200 }
192 201
193 m_errorMessage = String.Empty; 202 m_errorMessage = String.Empty;
203<<<<<<< HEAD
204=======
205
206>>>>>>> avn/ubitvar
194 m_merge = options.ContainsKey("merge"); 207 m_merge = options.ContainsKey("merge");
195 m_forceTerrain = options.ContainsKey("force-terrain"); 208 m_forceTerrain = options.ContainsKey("force-terrain");
196 m_forceParcels = options.ContainsKey("force-parcels"); 209 m_forceParcels = options.ContainsKey("force-parcels");
@@ -199,18 +212,34 @@ namespace OpenSim.Region.CoreModules.World.Archiver
199 m_requestId = requestId; 212 m_requestId = requestId;
200 m_displacement = options.ContainsKey("displacement") ? (Vector3)options["displacement"] : Vector3.Zero; 213 m_displacement = options.ContainsKey("displacement") ? (Vector3)options["displacement"] : Vector3.Zero;
201 m_rotation = options.ContainsKey("rotation") ? (float)options["rotation"] : 0f; 214 m_rotation = options.ContainsKey("rotation") ? (float)options["rotation"] : 0f;
215<<<<<<< HEAD
202 m_rotationCenter = options.ContainsKey("rotation-center") ? (Vector3)options["rotation-center"] 216 m_rotationCenter = options.ContainsKey("rotation-center") ? (Vector3)options["rotation-center"]
203 : new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 0f); 217 : new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 0f);
204 218
205 // Zero can never be a valid user or group id 219 // Zero can never be a valid user or group id
206 m_validUserUuids[UUID.Zero] = false; 220 m_validUserUuids[UUID.Zero] = false;
207 m_validGroupUuids[UUID.Zero] = false; 221 m_validGroupUuids[UUID.Zero] = false;
222=======
223 m_rotationCenter = options.ContainsKey("rotation-center") ? (Vector3)options["rotation-center"]
224 : new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 0f);
225
226 m_requestId = requestId;
227
228 // Zero can never be a valid user id (or group)
229 m_validUserUuids[UUID.Zero] = false;
230 m_validGroupUuids[UUID.Zero] = false;
231
232>>>>>>> avn/ubitvar
208 233
209 m_groupsModule = m_rootScene.RequestModuleInterface<IGroupsModule>(); 234 m_groupsModule = m_rootScene.RequestModuleInterface<IGroupsModule>();
210 m_assetService = m_rootScene.AssetService; 235 m_assetService = m_rootScene.AssetService;
211 } 236 }
212 237
238<<<<<<< HEAD
213 public ArchiveReadRequest(Scene scene, Stream loadStream, Guid requestId, Dictionary<string, object>options) 239 public ArchiveReadRequest(Scene scene, Stream loadStream, Guid requestId, Dictionary<string, object>options)
240=======
241 public ArchiveReadRequest(Scene scene, Stream loadStream, Guid requestId, Dictionary<string, object> options)
242>>>>>>> avn/ubitvar
214 { 243 {
215 m_rootScene = scene; 244 m_rootScene = scene;
216 m_loadPath = null; 245 m_loadPath = null;
@@ -220,7 +249,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
220 m_requestId = requestId; 249 m_requestId = requestId;
221 250
222 m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner; 251 m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner;
252<<<<<<< HEAD
223 253
254=======
255
256>>>>>>> avn/ubitvar
224 // Zero can never be a valid user id 257 // Zero can never be a valid user id
225 m_validUserUuids[UUID.Zero] = false; 258 m_validUserUuids[UUID.Zero] = false;
226 259
@@ -294,15 +327,24 @@ namespace OpenSim.Region.CoreModules.World.Archiver
294 if ((successfulAssetRestores + failedAssetRestores) % 250 == 0) 327 if ((successfulAssetRestores + failedAssetRestores) % 250 == 0)
295 m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets..."); 328 m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets...");
296 } 329 }
330<<<<<<< HEAD
297 else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH) && (!m_merge || m_forceTerrain)) 331 else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH) && (!m_merge || m_forceTerrain))
332=======
333 else if ((!m_merge || m_forceTerrain) && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
334>>>>>>> avn/ubitvar
298 { 335 {
299 LoadTerrain(scene, filePath, data); 336 LoadTerrain(scene, filePath, data);
300 } 337 }
301 else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH)) 338 else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH))
302 { 339 {
303 LoadRegionSettings(scene, filePath, data, dearchivedScenes); 340 LoadRegionSettings(scene, filePath, data, dearchivedScenes);
341<<<<<<< HEAD
304 } 342 }
305 else if (filePath.StartsWith(ArchiveConstants.LANDDATA_PATH) && (!m_merge || m_forceParcels)) 343 else if (filePath.StartsWith(ArchiveConstants.LANDDATA_PATH) && (!m_merge || m_forceParcels))
344=======
345 }
346 else if ((!m_merge || m_forceParcels) && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
347>>>>>>> avn/ubitvar
306 { 348 {
307 sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data)); 349 sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data));
308 } 350 }
@@ -523,7 +565,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
523 } 565 }
524 } 566 }
525 567
568<<<<<<< HEAD
526 569
570=======
571>>>>>>> avn/ubitvar
527 bool isTelehub = (sceneObject.UUID == oldTelehubUUID) && (oldTelehubUUID != UUID.Zero); 572 bool isTelehub = (sceneObject.UUID == oldTelehubUUID) && (oldTelehubUUID != UUID.Zero);
528 573
529 // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned 574 // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned
@@ -540,6 +585,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
540 } 585 }
541 586
542 ModifySceneObject(scene, sceneObject); 587 ModifySceneObject(scene, sceneObject);
588<<<<<<< HEAD
589=======
590
591>>>>>>> avn/ubitvar
543 592
544 if (scene.AddRestoredSceneObject(sceneObject, true, false)) 593 if (scene.AddRestoredSceneObject(sceneObject, true, false))
545 { 594 {
@@ -600,6 +649,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver
600 // being no copy/no mod for everyone 649 // being no copy/no mod for everyone
601 lock (part.TaskInventory) 650 lock (part.TaskInventory)
602 { 651 {
652<<<<<<< HEAD
653=======
654 // And zap any troublesome sit target information
655 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
656 part.SitTargetPosition = new Vector3(0, 0, 0);
657
658 // Fix ownership/creator of inventory items
659 // Not doing so results in inventory items
660 // being no copy/no mod for everyone
661 part.TaskInventory.LockItemsForRead(true);
662>>>>>>> avn/ubitvar
603 TaskInventoryDictionary inv = part.TaskInventory; 663 TaskInventoryDictionary inv = part.TaskInventory;
604 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) 664 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
605 { 665 {
@@ -620,11 +680,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver
620 if (!ResolveGroupUuid(kvp.Value.GroupID)) 680 if (!ResolveGroupUuid(kvp.Value.GroupID))
621 kvp.Value.GroupID = UUID.Zero; 681 kvp.Value.GroupID = UUID.Zero;
622 } 682 }
683<<<<<<< HEAD
684=======
685 part.TaskInventory.LockItemsForRead(false);
686>>>>>>> avn/ubitvar
623 } 687 }
624 } 688 }
625 } 689 }
626 690
691<<<<<<< HEAD
627 692
693=======
694>>>>>>> avn/ubitvar
628 /// <summary> 695 /// <summary>
629 /// Load serialized parcels. 696 /// Load serialized parcels.
630 /// </summary> 697 /// </summary>
@@ -645,7 +712,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
645 parcel.AABBMin += parcelDisp; 712 parcel.AABBMin += parcelDisp;
646 parcel.AABBMax += parcelDisp; 713 parcel.AABBMax += parcelDisp;
647 } 714 }
715<<<<<<< HEAD
648 716
717=======
718
719>>>>>>> avn/ubitvar
649 // Validate User and Group UUID's 720 // Validate User and Group UUID's
650 721
651 if (!ResolveGroupUuid(parcel.GroupID)) 722 if (!ResolveGroupUuid(parcel.GroupID))
@@ -660,14 +731,26 @@ namespace OpenSim.Region.CoreModules.World.Archiver
660 } 731 }
661 else 732 else
662 { 733 {
734<<<<<<< HEAD
663 parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner; 735 parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner;
736=======
737 parcel.OwnerID = m_defaultUser;
738 parcel.GroupID = UUID.Zero;
739>>>>>>> avn/ubitvar
664 parcel.IsGroupOwned = false; 740 parcel.IsGroupOwned = false;
665 } 741 }
666 } 742 }
667 else 743 else
668 { 744 {
669 if (!ResolveUserUuid(scene, parcel.OwnerID)) 745 if (!ResolveUserUuid(scene, parcel.OwnerID))
746<<<<<<< HEAD
670 parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner; 747 parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner;
748=======
749 parcel.OwnerID = m_defaultUser;
750
751 if (!ResolveGroupUuid(parcel.GroupID))
752 parcel.GroupID = UUID.Zero;
753>>>>>>> avn/ubitvar
671 } 754 }
672 755
673 List<LandAccessEntry> accessList = new List<LandAccessEntry>(); 756 List<LandAccessEntry> accessList = new List<LandAccessEntry>();
@@ -796,7 +879,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
796 if (data == null) 879 if (data == null)
797 return false; 880 return false;
798 } 881 }
882<<<<<<< HEAD
799 883
884=======
885>>>>>>> avn/ubitvar
800 //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); 886 //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
801 887
802 AssetBase asset = new AssetBase(new UUID(uuid), String.Empty, assetType, UUID.Zero.ToString()); 888 AssetBase asset = new AssetBase(new UUID(uuid), String.Empty, assetType, UUID.Zero.ToString());
@@ -918,7 +1004,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
918 private bool LoadTerrain(Scene scene, string terrainPath, byte[] data) 1004 private bool LoadTerrain(Scene scene, string terrainPath, byte[] data)
919 { 1005 {
920 ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); 1006 ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
1007<<<<<<< HEAD
921 1008
1009=======
1010
1011>>>>>>> avn/ubitvar
922 using (MemoryStream ms = new MemoryStream(data)) 1012 using (MemoryStream ms = new MemoryStream(data))
923 { 1013 {
924 if (m_displacement != Vector3.Zero || m_rotation != 0f) 1014 if (m_displacement != Vector3.Zero || m_rotation != 0f)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index 6a09caf..0fb8a32 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -111,6 +111,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
111 String defaultUser = ""; 111 String defaultUser = "";
112 float rotation = 0f; 112 float rotation = 0f;
113 Vector3 rotationCenter = new Vector3(Constants.RegionSize / 2f, Constants.RegionSize / 2f, 0); 113 Vector3 rotationCenter = new Vector3(Constants.RegionSize / 2f, Constants.RegionSize / 2f, 0);
114<<<<<<< HEAD
114 115
115 OptionSet options = new OptionSet(); 116 OptionSet options = new OptionSet();
116 options.Add("m|merge", delegate (string v) { mergeOar = (v != null); }); 117 options.Add("m|merge", delegate (string v) { mergeOar = (v != null); });
@@ -122,6 +123,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver
122 options.Add("no-objects", delegate (string v) { noObjects = (v != null); }); 123 options.Add("no-objects", delegate (string v) { noObjects = (v != null); });
123 options.Add("default-user=", delegate(string v) { defaultUser = (v == null) ? "" : v; }); 124 options.Add("default-user=", delegate(string v) { defaultUser = (v == null) ? "" : v; });
124 options.Add("displacement=", delegate (string v) { 125 options.Add("displacement=", delegate (string v) {
126=======
127
128 OptionSet options = new OptionSet();
129 options.Add("m|merge", delegate(string v) { mergeOar = (v != null); });
130 options.Add("s|skip-assets", delegate(string v) { skipAssets = (v != null); });
131 options.Add("force-terrain", delegate(string v) { forceTerrain = (v != null); });
132 options.Add("forceterrain", delegate(string v) { forceTerrain = (v != null); }); // downward compatibility
133 options.Add("force-parcels", delegate(string v) { forceParcels = (v != null); });
134 options.Add("forceparcels", delegate(string v) { forceParcels = (v != null); }); // downward compatibility
135 options.Add("no-objects", delegate(string v) { noObjects = (v != null); });
136 options.Add("default-user=", delegate(string v) { defaultUser = (v == null) ? "" : v; });
137 options.Add("displacement=", delegate(string v)
138 {
139>>>>>>> avn/ubitvar
125 try 140 try
126 { 141 {
127 displacement = v == null ? Vector3.Zero : Vector3.Parse(v); 142 displacement = v == null ? Vector3.Zero : Vector3.Parse(v);
@@ -148,7 +163,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
148 // Convert to radians for internals 163 // Convert to radians for internals
149 rotation = Util.Clamp<float>(rotation, -359f, 359f) / 180f * (float)Math.PI; 164 rotation = Util.Clamp<float>(rotation, -359f, 359f) / 180f * (float)Math.PI;
150 }); 165 });
166<<<<<<< HEAD
151 options.Add("rotation-center=", delegate (string v) { 167 options.Add("rotation-center=", delegate (string v) {
168=======
169 options.Add("rotation-center=", delegate(string v)
170 {
171>>>>>>> avn/ubitvar
152 try 172 try
153 { 173 {
154 rotationCenter = v == null ? Vector3.Zero : Vector3.Parse(v); 174 rotationCenter = v == null ? Vector3.Zero : Vector3.Parse(v);
@@ -288,12 +308,21 @@ namespace OpenSim.Region.CoreModules.World.Archiver
288 Dictionary<string, object> archiveOptions = new Dictionary<string, object>(); 308 Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
289 DearchiveRegion(loadPath, Guid.Empty, archiveOptions); 309 DearchiveRegion(loadPath, Guid.Empty, archiveOptions);
290 } 310 }
311<<<<<<< HEAD
291 312
292 public void DearchiveRegion(string loadPath, Guid requestId, Dictionary<string,object> options) 313 public void DearchiveRegion(string loadPath, Guid requestId, Dictionary<string,object> options)
293 { 314 {
294 m_log.InfoFormat( 315 m_log.InfoFormat(
295 "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath); 316 "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath);
296 317
318=======
319
320 public void DearchiveRegion(string loadPath, Guid requestId, Dictionary<string, object> options)
321 {
322 m_log.InfoFormat(
323 "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath);
324
325>>>>>>> avn/ubitvar
297 new ArchiveReadRequest(Scene, loadPath, requestId, options).DearchiveRegion(); 326 new ArchiveReadRequest(Scene, loadPath, requestId, options).DearchiveRegion();
298 } 327 }
299 328
@@ -302,7 +331,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
302 Dictionary<string, object> archiveOptions = new Dictionary<string, object>(); 331 Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
303 DearchiveRegion(loadStream, Guid.Empty, archiveOptions); 332 DearchiveRegion(loadStream, Guid.Empty, archiveOptions);
304 } 333 }
334<<<<<<< HEAD
305 335
336=======
337
338>>>>>>> avn/ubitvar
306 public void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string, object> options) 339 public void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string, object> options)
307 { 340 {
308 new ArchiveReadRequest(Scene, loadStream, requestId, options).DearchiveRegion(); 341 new ArchiveReadRequest(Scene, loadStream, requestId, options).DearchiveRegion();
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index db66c83..895b55d 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -271,18 +271,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver
271 271
272 if (asset != null) 272 if (asset != null)
273 { 273 {
274 if (m_options.ContainsKey("verbose")) 274// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
275 m_log.InfoFormat("[ARCHIVER]: Writing asset {0}", id);
276
277 m_foundAssetUuids.Add(asset.FullID); 275 m_foundAssetUuids.Add(asset.FullID);
278 276
279 m_assetsArchiver.WriteAsset(PostProcess(asset)); 277 m_assetsArchiver.WriteAsset(PostProcess(asset));
280 } 278 }
281 else 279 else
282 { 280 {
283 if (m_options.ContainsKey("verbose")) 281// m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id);
284 m_log.InfoFormat("[ARCHIVER]: Recording asset {0} as not found", id);
285
286 m_notFoundAssetUuids.Add(new UUID(id)); 282 m_notFoundAssetUuids.Add(new UUID(id));
287 } 283 }
288 284
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 80fa08a..e6e6485 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -95,6 +95,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
95 95
96 m_commands = new EstateManagementCommands(this); 96 m_commands = new EstateManagementCommands(this);
97 m_commands.Initialise(); 97 m_commands.Initialise();
98
99 m_regionChangeTimer.Interval = 10000;
100 m_regionChangeTimer.Elapsed += RaiseRegionInfoChange;
101 m_regionChangeTimer.AutoReset = false;
98 } 102 }
99 103
100 public void RemoveRegion(Scene scene) {} 104 public void RemoveRegion(Scene scene) {}
@@ -587,6 +591,16 @@ namespace OpenSim.Region.CoreModules.World.Estate
587 IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>(); 591 IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>();
588 if (restartModule != null) 592 if (restartModule != null)
589 { 593 {
594 if (timeInSeconds == -1)
595 {
596 m_delayCount++;
597 if (m_delayCount > 3)
598 return;
599
600 restartModule.DelayRestart(3600, "Restart delayed by region manager");
601 return;
602 }
603
590 List<int> times = new List<int>(); 604 List<int> times = new List<int>();
591 while (timeInSeconds > 0) 605 while (timeInSeconds > 0)
592 { 606 {
@@ -1477,7 +1491,68 @@ namespace OpenSim.Region.CoreModules.World.Estate
1477 sendRegionHandshake(client); 1491 sendRegionHandshake(client);
1478 } 1492 }
1479 1493
1494<<<<<<< HEAD
1480 private uint GetEstateFlags() 1495 private uint GetEstateFlags()
1496=======
1497 public uint GetRegionFlags()
1498 {
1499 RegionFlags flags = RegionFlags.None;
1500
1501 // Fully implemented
1502 //
1503 if (Scene.RegionInfo.RegionSettings.AllowDamage)
1504 flags |= RegionFlags.AllowDamage;
1505 if (Scene.RegionInfo.RegionSettings.BlockTerraform)
1506 flags |= RegionFlags.BlockTerraform;
1507 if (!Scene.RegionInfo.RegionSettings.AllowLandResell)
1508 flags |= RegionFlags.BlockLandResell;
1509 if (Scene.RegionInfo.RegionSettings.DisableCollisions)
1510 flags |= RegionFlags.SkipCollisions;
1511 if (Scene.RegionInfo.RegionSettings.DisableScripts)
1512 flags |= RegionFlags.SkipScripts;
1513 if (Scene.RegionInfo.RegionSettings.DisablePhysics)
1514 flags |= RegionFlags.SkipPhysics;
1515 if (Scene.RegionInfo.RegionSettings.BlockFly)
1516 flags |= RegionFlags.NoFly;
1517 if (Scene.RegionInfo.RegionSettings.RestrictPushing)
1518 flags |= RegionFlags.RestrictPushObject;
1519 if (Scene.RegionInfo.RegionSettings.AllowLandJoinDivide)
1520 flags |= RegionFlags.AllowParcelChanges;
1521 if (Scene.RegionInfo.RegionSettings.BlockShowInSearch)
1522 flags |= RegionFlags.BlockParcelSearch;
1523 if (Scene.RegionInfo.RegionSettings.GodBlockSearch)
1524 flags |= (RegionFlags)(1 << 11);
1525 if (Scene.RegionInfo.RegionSettings.Casino)
1526 flags |= (RegionFlags)(1 << 10);
1527
1528 if (Scene.RegionInfo.RegionSettings.FixedSun)
1529 flags |= RegionFlags.SunFixed;
1530 if (Scene.RegionInfo.RegionSettings.Sandbox)
1531 flags |= RegionFlags.Sandbox;
1532 if (Scene.RegionInfo.EstateSettings.AllowVoice)
1533 flags |= RegionFlags.AllowVoice;
1534 if (Scene.RegionInfo.EstateSettings.AllowLandmark)
1535 flags |= RegionFlags.AllowLandmark;
1536 if (Scene.RegionInfo.EstateSettings.AllowSetHome)
1537 flags |= RegionFlags.AllowSetHome;
1538 if (Scene.RegionInfo.EstateSettings.BlockDwell)
1539 flags |= RegionFlags.BlockDwell;
1540 if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
1541 flags |= RegionFlags.ResetHomeOnTeleport;
1542
1543
1544 // TODO: SkipUpdateInterestList
1545
1546 // Omitted
1547 //
1548 // Omitted: NullLayer (what is that?)
1549 // Omitted: SkipAgentAction (what does it do?)
1550
1551 return (uint)flags;
1552 }
1553
1554 public uint GetEstateFlags()
1555>>>>>>> avn/ubitvar
1481 { 1556 {
1482 RegionFlags flags = RegionFlags.None; 1557 RegionFlags flags = RegionFlags.None;
1483 1558
diff --git a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
index 73c592d..378826d 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
@@ -40,23 +40,33 @@ namespace OpenSim.Region.CoreModules.World.Land
40 //Land types set with flags in ParcelOverlay. 40 //Land types set with flags in ParcelOverlay.
41 //Only one of these can be used. 41 //Only one of these can be used.
42 public const float BAN_LINE_SAFETY_HIEGHT = 100; 42 public const float BAN_LINE_SAFETY_HIEGHT = 100;
43 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = 128; //Equals 10000000
44 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = 64; //Equals 01000000
45 43
46 //RequestResults (I think these are right, they seem to work): 44 //RequestResults (I think these are right, they seem to work):
47 public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land 45 public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land
48 public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land 46 public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land
49 47
50 //ParcelSelectObjects 48 //ParcelSelectObjects
49 public const int LAND_SELECT_OBJECTS_OWNER = 2;
51 public const int LAND_SELECT_OBJECTS_GROUP = 4; 50 public const int LAND_SELECT_OBJECTS_GROUP = 4;
52 public const int LAND_SELECT_OBJECTS_OTHER = 8; 51 public const int LAND_SELECT_OBJECTS_OTHER = 8;
53 public const int LAND_SELECT_OBJECTS_OWNER = 2; 52
54 public const byte LAND_TYPE_IS_BEING_AUCTIONED = 5; //Equals 00000101 53
55 public const byte LAND_TYPE_IS_FOR_SALE = 4; //Equals 00000100 54 public const byte LAND_TYPE_PUBLIC = 0; //Equals 00000000
56 public const byte LAND_TYPE_OWNED_BY_GROUP = 2; //Equals 00000010 55 // types 1 to 7 are exclusive
57 public const byte LAND_TYPE_OWNED_BY_OTHER = 1; //Equals 00000001 56 public const byte LAND_TYPE_OWNED_BY_OTHER = 1; //Equals 00000001
57 public const byte LAND_TYPE_OWNED_BY_GROUP = 2; //Equals 00000010
58 public const byte LAND_TYPE_OWNED_BY_REQUESTER = 3; //Equals 00000011 58 public const byte LAND_TYPE_OWNED_BY_REQUESTER = 3; //Equals 00000011
59 public const byte LAND_TYPE_PUBLIC = 0; //Equals 00000000 59 public const byte LAND_TYPE_IS_FOR_SALE = 4; //Equals 00000100
60 public const byte LAND_TYPE_IS_BEING_AUCTIONED = 5; //Equals 00000101
61 public const byte LAND_TYPE_unused6 = 6;
62 public const byte LAND_TYPE_unused7 = 7;
63 // next are flags
64 public const byte LAND_FLAG_unused8 = 0x08; // this may become excluside in future
65 public const byte LAND_FLAG_HIDEAVATARS = 0x10;
66 public const byte LAND_FLAG_LOCALSOUND = 0x20;
67 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = 0x40; //Equals 01000000
68 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = 0x80; //Equals 10000000
69
60 70
61 //These are other constants. Yay! 71 //These are other constants. Yay!
62 public const int START_LAND_LOCAL_ID = 1; 72 public const int START_LAND_LOCAL_ID = 1;
@@ -203,7 +213,13 @@ namespace OpenSim.Region.CoreModules.World.Land
203 m_landManagementModule.setParcelOtherCleanTime(remoteClient, localID, otherCleanTime); 213 m_landManagementModule.setParcelOtherCleanTime(remoteClient, localID, otherCleanTime);
204 } 214 }
205 } 215 }
206 216 public void sendClientInitialLandInfo(IClientAPI remoteClient)
217 {
218 if (m_landManagementModule != null)
219 {
220 m_landManagementModule.sendClientInitialLandInfo(remoteClient);
221 }
222 }
207 #endregion 223 #endregion
208 } 224 }
209} 225}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 25e1454..8bd46f6 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -69,7 +69,11 @@ namespace OpenSim.Region.CoreModules.World.Land
69 /// <summary> 69 /// <summary>
70 /// Minimum land unit size in region co-ordinates. 70 /// Minimum land unit size in region co-ordinates.
71 /// </summary> 71 /// </summary>
72<<<<<<< HEAD
72 public const int LandUnit = 4; 73 public const int LandUnit = 4;
74=======
75 public const int landUnit = 4;
76>>>>>>> avn/ubitvar
73 77
74 private static readonly string remoteParcelRequestPath = "0009/"; 78 private static readonly string remoteParcelRequestPath = "0009/";
75 79
@@ -89,20 +93,30 @@ namespace OpenSim.Region.CoreModules.World.Land
89 /// <value> 93 /// <value>
90 /// Land objects keyed by local id 94 /// Land objects keyed by local id
91 /// </value> 95 /// </value>
92 private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); 96// private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
97
98 //ubit: removed the readonly so i can move it around
99 private Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
93 100
94 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 101 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
95 102
96 private bool m_allowedForcefulBans = true; 103 private bool m_allowedForcefulBans = true;
104 private UUID DefaultGodParcelGroup;
105 private string DefaultGodParcelName;
97 106
98 // caches ExtendedLandData 107 // caches ExtendedLandData
99 private Cache parcelInfoCache; 108 private Cache parcelInfoCache;
109<<<<<<< HEAD
100 110
101 111
102 /// <summary> 112 /// <summary>
103 /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions. 113 /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions.
104 /// </summary> 114 /// </summary>
105 private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>(); 115 private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>();
116=======
117 private Dictionary<UUID, Vector3> forcedPosition =
118 new Dictionary<UUID, Vector3>();
119>>>>>>> avn/ubitvar
106 120
107 // Enables limiting parcel layer info transmission when doing simple updates 121 // Enables limiting parcel layer info transmission when doing simple updates
108 private bool shouldLimitParcelLayerInfoToViewDistance { get; set; } 122 private bool shouldLimitParcelLayerInfoToViewDistance { get; set; }
@@ -118,6 +132,7 @@ namespace OpenSim.Region.CoreModules.World.Land
118 132
119 public void Initialise(IConfigSource source) 133 public void Initialise(IConfigSource source)
120 { 134 {
135<<<<<<< HEAD
121 shouldLimitParcelLayerInfoToViewDistance = true; 136 shouldLimitParcelLayerInfoToViewDistance = true;
122 parcelLayerViewDistance = 128; 137 parcelLayerViewDistance = 128;
123 IConfig landManagementConfig = source.Configs["LandManagement"]; 138 IConfig landManagementConfig = source.Configs["LandManagement"];
@@ -125,13 +140,24 @@ namespace OpenSim.Region.CoreModules.World.Land
125 { 140 {
126 shouldLimitParcelLayerInfoToViewDistance = landManagementConfig.GetBoolean("LimitParcelLayerUpdateDistance", shouldLimitParcelLayerInfoToViewDistance); 141 shouldLimitParcelLayerInfoToViewDistance = landManagementConfig.GetBoolean("LimitParcelLayerUpdateDistance", shouldLimitParcelLayerInfoToViewDistance);
127 parcelLayerViewDistance = landManagementConfig.GetInt("ParcelLayerViewDistance", parcelLayerViewDistance); 142 parcelLayerViewDistance = landManagementConfig.GetInt("ParcelLayerViewDistance", parcelLayerViewDistance);
143=======
144 IConfig cnf = source.Configs["LandManagement"];
145 if (cnf != null)
146 {
147 DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
148 DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
149>>>>>>> avn/ubitvar
128 } 150 }
129 } 151 }
130 152
131 public void AddRegion(Scene scene) 153 public void AddRegion(Scene scene)
132 { 154 {
133 m_scene = scene; 155 m_scene = scene;
156<<<<<<< HEAD
134 m_landIDList = new int[m_scene.RegionInfo.RegionSizeX / LandUnit, m_scene.RegionInfo.RegionSizeY / LandUnit]; 157 m_landIDList = new int[m_scene.RegionInfo.RegionSizeX / LandUnit, m_scene.RegionInfo.RegionSizeY / LandUnit];
158=======
159 m_landIDList = new int[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit];
160>>>>>>> avn/ubitvar
135 landChannel = new LandChannel(scene, this); 161 landChannel = new LandChannel(scene, this);
136 162
137 parcelInfoCache = new Cache(); 163 parcelInfoCache = new Cache();
@@ -154,7 +180,7 @@ namespace OpenSim.Region.CoreModules.World.Land
154 m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage; 180 m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage;
155 m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan; 181 m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan;
156 m_scene.EventManager.OnRegisterCaps += EventManagerOnRegisterCaps; 182 m_scene.EventManager.OnRegisterCaps += EventManagerOnRegisterCaps;
157 183
158 lock (m_scene) 184 lock (m_scene)
159 { 185 {
160 m_scene.LandChannel = (ILandChannel)landChannel; 186 m_scene.LandChannel = (ILandChannel)landChannel;
@@ -204,13 +230,14 @@ namespace OpenSim.Region.CoreModules.World.Land
204 client.OnParcelFreezeUser += ClientOnParcelFreezeUser; 230 client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
205 client.OnSetStartLocationRequest += ClientOnSetHome; 231 client.OnSetStartLocationRequest += ClientOnSetHome;
206 232
207 233/* avatar is still a child here position is unknown
208 EntityBase presenceEntity; 234 EntityBase presenceEntity;
209 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) 235 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
210 { 236 {
211 SendLandUpdate((ScenePresence)presenceEntity, true); 237 SendLandUpdate((ScenePresence)presenceEntity, true);
212 SendParcelOverlay(client); 238 SendParcelOverlay(client);
213 } 239 }
240*/
214 } 241 }
215 242
216 public void EventMakeChildAgent(ScenePresence avatar) 243 public void EventMakeChildAgent(ScenePresence avatar)
@@ -220,48 +247,6 @@ namespace OpenSim.Region.CoreModules.World.Land
220 247
221 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 248 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
222 { 249 {
223 //If we are forcing a position for them to go
224 if (forcedPosition.ContainsKey(remoteClient.AgentId))
225 {
226 ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
227
228 //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
229 //When the avatar walks into a ban line on the ground, it prevents getting stuck
230 agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
231
232 //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
233 if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2)
234 {
235// m_log.DebugFormat(
236// "[LAND MANAGEMENT MODULE]: Stopping force position of {0} because {1} is close enough to {2}",
237// clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
238
239 forcedPosition.Remove(remoteClient.AgentId);
240 }
241 //if we are far away, teleport
242 else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3)
243 {
244 Vector3 forcePosition = forcedPosition[remoteClient.AgentId];
245// m_log.DebugFormat(
246// "[LAND MANAGEMENT MODULE]: Teleporting out {0} because {1} is too far from avatar position {2}",
247// clientAvatar.Name, clientAvatar.AbsolutePosition, forcePosition);
248
249 m_scene.RequestTeleportLocation(remoteClient, m_scene.RegionInfo.RegionHandle,
250 forcePosition, clientAvatar.Lookat, (uint)Constants.TeleportFlags.ForceRedirect);
251
252 forcedPosition.Remove(remoteClient.AgentId);
253 }
254 else
255 {
256// m_log.DebugFormat(
257// "[LAND MANAGEMENT MODULE]: Forcing {0} from {1} to {2}",
258// clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
259
260 //Forces them toward the forced position we want if they aren't there yet
261 agentData.UseClientAgentPosition = true;
262 agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId];
263 }
264 }
265 } 250 }
266 251
267 public void Close() 252 public void Close()
@@ -314,7 +299,11 @@ namespace OpenSim.Region.CoreModules.World.Land
314 { 299 {
315 m_landList.Clear(); 300 m_landList.Clear();
316 m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 301 m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
302<<<<<<< HEAD
317 m_landIDList = new int[m_scene.RegionInfo.RegionSizeX / LandUnit, m_scene.RegionInfo.RegionSizeY / LandUnit]; 303 m_landIDList = new int[m_scene.RegionInfo.RegionSizeX / LandUnit, m_scene.RegionInfo.RegionSizeY / LandUnit];
304=======
305 m_landIDList = new int[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit];
306>>>>>>> avn/ubitvar
318 } 307 }
319 } 308 }
320 309
@@ -324,16 +313,22 @@ namespace OpenSim.Region.CoreModules.World.Land
324 /// <returns>The parcel created.</returns> 313 /// <returns>The parcel created.</returns>
325 protected ILandObject CreateDefaultParcel() 314 protected ILandObject CreateDefaultParcel()
326 { 315 {
316<<<<<<< HEAD
327 m_log.DebugFormat( 317 m_log.DebugFormat(
328 "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); 318 "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName);
329 319
330 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); 320 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
321=======
322 m_log.DebugFormat("{0} Creating default parcel for region {1}", LogHeader, m_scene.RegionInfo.RegionName);
323
324 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
325>>>>>>> avn/ubitvar
331 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, 326 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0,
332 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY)); 327 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY));
333 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 328 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
334 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 329 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
335 330
336 return AddLandObject(fullSimParcel); 331 return AddLandObject(fullSimParcel);
337 } 332 }
338 333
339 public List<ILandObject> AllParcels() 334 public List<ILandObject> AllParcels()
@@ -382,10 +377,17 @@ namespace OpenSim.Region.CoreModules.World.Land
382 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) 377 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
383 { 378 {
384 if (m_scene.Permissions.IsGod(avatar.UUID)) return; 379 if (m_scene.Permissions.IsGod(avatar.UUID)) return;
385 if (position.HasValue) 380
386 { 381 if (!position.HasValue)
387 forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; 382 return;
388 } 383
384// land should have no word on avatar physics
385// bool isFlying = avatar.PhysicsActor.Flying;
386// avatar.RemoveFromPhysicalScene();
387
388 avatar.AbsolutePosition = (Vector3)position;
389
390// avatar.AddToPhysicalScene(isFlying);
389 } 391 }
390 392
391 public void SendYouAreRestrictedNotice(ScenePresence avatar) 393 public void SendYouAreRestrictedNotice(ScenePresence avatar)
@@ -405,36 +407,14 @@ namespace OpenSim.Region.CoreModules.World.Land
405 } 407 }
406 408
407 if (parcelAvatarIsEntering != null) 409 if (parcelAvatarIsEntering != null)
408 { 410 EnforceBans(parcelAvatarIsEntering, avatar);
409 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
410 {
411 if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
412 {
413 SendYouAreBannedNotice(avatar);
414 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
415 }
416 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
417 {
418 SendYouAreRestrictedNotice(avatar);
419 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
420 }
421 else
422 {
423 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
424 }
425 }
426 else
427 {
428 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
429 }
430 }
431 } 411 }
432 } 412 }
433 413
434 public void SendOutNearestBanLine(IClientAPI client) 414 public void SendOutNearestBanLine(IClientAPI client)
435 { 415 {
436 ScenePresence sp = m_scene.GetScenePresence(client.AgentId); 416 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
437 if (sp == null || sp.IsChildAgent) 417 if (sp == null)
438 return; 418 return;
439 419
440 List<ILandObject> checkLandParcels = ParcelsNearPoint(sp.AbsolutePosition); 420 List<ILandObject> checkLandParcels = ParcelsNearPoint(sp.AbsolutePosition);
@@ -454,32 +434,49 @@ namespace OpenSim.Region.CoreModules.World.Land
454 return; 434 return;
455 } 435 }
456 436
437 public void sendClientInitialLandInfo(IClientAPI remoteClient)
438 {
439 ScenePresence avatar;
440
441 if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out avatar))
442 return;
443
444
445 if (!avatar.IsChildAgent)
446 {
447 ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
448 if (over == null)
449 return;
450
451 avatar.currentParcelUUID = over.LandData.GlobalID;
452 over.SendLandUpdateToClient(avatar.ControllingClient);
453 }
454 SendParcelOverlay(remoteClient);
455 }
456
457 public void SendLandUpdate(ScenePresence avatar, bool force) 457 public void SendLandUpdate(ScenePresence avatar, bool force)
458 { 458 {
459<<<<<<< HEAD
459 ILandObject over = GetLandObject((int)Math.Min(((int)m_scene.RegionInfo.RegionSizeX - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), 460 ILandObject over = GetLandObject((int)Math.Min(((int)m_scene.RegionInfo.RegionSizeX - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
460 (int)Math.Min(((int)m_scene.RegionInfo.RegionSizeY - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); 461 (int)Math.Min(((int)m_scene.RegionInfo.RegionSizeY - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
462=======
463 if (avatar.IsChildAgent)
464 return;
465
466 ILandObject over = GetLandObjectClipedXY(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
467>>>>>>> avn/ubitvar
461 468
462 if (over != null) 469 if (over != null)
463 { 470 {
464 if (force) 471 bool NotsameID = (avatar.currentParcelUUID != over.LandData.GlobalID);
472 if (force || NotsameID)
465 { 473 {
466 if (!avatar.IsChildAgent) 474 over.SendLandUpdateToClient(avatar.ControllingClient);
467 { 475// sl doesnt seem to send this now, as it used 2
468 over.SendLandUpdateToClient(avatar.ControllingClient); 476// SendParcelOverlay(avatar.ControllingClient);
469 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, 477 avatar.currentParcelUUID = over.LandData.GlobalID;
470 m_scene.RegionInfo.RegionID); 478 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
471 } 479 m_scene.RegionInfo.RegionID);
472 }
473
474 if (avatar.currentParcelUUID != over.LandData.GlobalID)
475 {
476 if (!avatar.IsChildAgent)
477 {
478 over.SendLandUpdateToClient(avatar.ControllingClient);
479 avatar.currentParcelUUID = over.LandData.GlobalID;
480 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
481 m_scene.RegionInfo.RegionID);
482 }
483 } 480 }
484 } 481 }
485 } 482 }
@@ -531,6 +528,7 @@ namespace OpenSim.Region.CoreModules.World.Land
531 //when we are finally in a safe place, lets release the forced position lock 528 //when we are finally in a safe place, lets release the forced position lock
532 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); 529 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
533 } 530 }
531 EnforceBans(parcel, clientAvatar);
534 } 532 }
535 } 533 }
536 534
@@ -589,7 +587,7 @@ namespace OpenSim.Region.CoreModules.World.Land
589 requiredPowers = GroupPowers.LandManageBanned; 587 requiredPowers = GroupPowers.LandManageBanned;
590 588
591 if (m_scene.Permissions.CanEditParcelProperties(agentID, 589 if (m_scene.Permissions.CanEditParcelProperties(agentID,
592 land, requiredPowers)) 590 land, requiredPowers, false))
593 { 591 {
594 land.UpdateAccessList(flags, transactionID, sequenceID, 592 land.UpdateAccessList(flags, transactionID, sequenceID,
595 sections, entries, remote_client); 593 sections, entries, remote_client);
@@ -623,20 +621,28 @@ namespace OpenSim.Region.CoreModules.World.Land
623 new_land.LandData.LocalID = newLandLocalID; 621 new_land.LandData.LocalID = newLandLocalID;
624 622
625 bool[,] landBitmap = new_land.GetLandBitmap(); 623 bool[,] landBitmap = new_land.GetLandBitmap();
624<<<<<<< HEAD
626 // m_log.DebugFormat("{0} AddLandObject. new_land.bitmapSize=({1},{2}). newLocalID={3}", 625 // m_log.DebugFormat("{0} AddLandObject. new_land.bitmapSize=({1},{2}). newLocalID={3}",
627 // LogHeader, landBitmap.GetLength(0), landBitmap.GetLength(1), newLandLocalID); 626 // LogHeader, landBitmap.GetLength(0), landBitmap.GetLength(1), newLandLocalID);
628 627
628=======
629>>>>>>> avn/ubitvar
629 if (landBitmap.GetLength(0) != m_landIDList.GetLength(0) || landBitmap.GetLength(1) != m_landIDList.GetLength(1)) 630 if (landBitmap.GetLength(0) != m_landIDList.GetLength(0) || landBitmap.GetLength(1) != m_landIDList.GetLength(1))
630 { 631 {
631 // Going to variable sized regions can cause mismatches 632 // Going to variable sized regions can cause mismatches
632 m_log.ErrorFormat("{0} AddLandObject. Added land bitmap different size than region ID map. bitmapSize=({1},{2}), landIDSize=({3},{4})", 633 m_log.ErrorFormat("{0} AddLandObject. Added land bitmap different size than region ID map. bitmapSize=({1},{2}), landIDSize=({3},{4})",
634<<<<<<< HEAD
633 LogHeader, landBitmap.GetLength(0), landBitmap.GetLength(1), m_landIDList.GetLength(0), m_landIDList.GetLength(1) ); 635 LogHeader, landBitmap.GetLength(0), landBitmap.GetLength(1), m_landIDList.GetLength(0), m_landIDList.GetLength(1) );
636=======
637 LogHeader, landBitmap.GetLength(0), landBitmap.GetLength(1), m_landIDList.GetLength(0), m_landIDList.GetLength(1));
638>>>>>>> avn/ubitvar
634 } 639 }
635 else 640 else
636 { 641 {
637 // If other land objects still believe that they occupy any parts of the same space, 642 // If other land objects still believe that they occupy any parts of the same space,
638 // then do not allow the add to proceed. 643 // then do not allow the add to proceed.
639 for (int x = 0; x < landBitmap.GetLength(0); x++) 644 for (int x = 0; x < landBitmap.GetLength(0); x++)
645<<<<<<< HEAD
640 { 646 {
641 for (int y = 0; y < landBitmap.GetLength(1); y++) 647 for (int y = 0; y < landBitmap.GetLength(1); y++)
642 { 648 {
@@ -663,15 +669,50 @@ namespace OpenSim.Region.CoreModules.World.Land
663 } 669 }
664 670
665 for (int x = 0; x < landBitmap.GetLength(0); x++) 671 for (int x = 0; x < landBitmap.GetLength(0); x++)
672=======
673>>>>>>> avn/ubitvar
666 { 674 {
667 for (int y = 0; y < landBitmap.GetLength(1); y++) 675 for (int y = 0; y < landBitmap.GetLength(1); y++)
668 { 676 {
669 if (landBitmap[x, y]) 677 if (landBitmap[x, y])
670 { 678 {
679<<<<<<< HEAD
671 // m_log.DebugFormat( 680 // m_log.DebugFormat(
672 // "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}", 681 // "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}",
673 // new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName); 682 // new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName);
674 683
684=======
685 int lastRecordedLandId = m_landIDList[x, y];
686
687 if (lastRecordedLandId > 0)
688 {
689 ILandObject lastRecordedLo = m_landList[lastRecordedLandId];
690
691 if (lastRecordedLo.LandBitmap[x, y])
692 {
693 m_log.ErrorFormat(
694 "{0}: Cannot add parcel \"{1}\", local ID {2} at tile {3},{4} because this is still occupied by parcel \"{5}\", local ID {6} in {7}",
695 LogHeader, new_land.LandData.Name, new_land.LandData.LocalID, x, y,
696 lastRecordedLo.LandData.Name, lastRecordedLo.LandData.LocalID, m_scene.Name);
697
698 return null;
699 }
700 }
701 }
702 }
703 }
704
705 for (int x = 0; x < landBitmap.GetLength(0); x++)
706 {
707 for (int y = 0; y < landBitmap.GetLength(1); y++)
708 {
709 if (landBitmap[x, y])
710 {
711 // m_log.DebugFormat(
712 // "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}",
713 // new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName);
714
715>>>>>>> avn/ubitvar
675 m_landIDList[x, y] = newLandLocalID; 716 m_landIDList[x, y] = newLandLocalID;
676 } 717 }
677 } 718 }
@@ -723,27 +764,28 @@ namespace OpenSim.Region.CoreModules.World.Land
723 /// </summary> 764 /// </summary>
724 public void Clear(bool setupDefaultParcel) 765 public void Clear(bool setupDefaultParcel)
725 { 766 {
726 List<ILandObject> parcels; 767 Dictionary<int, ILandObject> landworkList;
768 // move to work pointer since we are deleting it all
727 lock (m_landList) 769 lock (m_landList)
728 { 770 {
729 parcels = new List<ILandObject>(m_landList.Values); 771 landworkList = m_landList;
772 m_landList = new Dictionary<int, ILandObject>();
730 } 773 }
731 774
732 foreach (ILandObject lo in parcels) 775 // this 2 methods have locks (now)
776 ResetSimLandObjects();
777
778 if (setupDefaultParcel)
779 CreateDefaultParcel();
780
781 // fire outside events unlocked
782 foreach (ILandObject lo in landworkList.Values)
733 { 783 {
734 //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); 784 //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID);
735 m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); 785 m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
736 } 786 }
787 landworkList.Clear();
737 788
738 lock (m_landList)
739 {
740 m_landList.Clear();
741
742 ResetSimLandObjects();
743 }
744
745 if (setupDefaultParcel)
746 CreateDefaultParcel();
747 } 789 }
748 790
749 private void performFinalLandJoin(ILandObject master, ILandObject slave) 791 private void performFinalLandJoin(ILandObject master, ILandObject slave)
@@ -787,6 +829,7 @@ namespace OpenSim.Region.CoreModules.World.Land
787 /// <returns>Land object at the point supplied</returns> 829 /// <returns>Land object at the point supplied</returns>
788 public ILandObject GetLandObject(float x_float, float y_float) 830 public ILandObject GetLandObject(float x_float, float y_float)
789 { 831 {
832<<<<<<< HEAD
790 return GetLandObject((int)x_float, (int)y_float, true /* returnNullIfLandObjectNotFound */); 833 return GetLandObject((int)x_float, (int)y_float, true /* returnNullIfLandObjectNotFound */);
791 /* 834 /*
792 int x; 835 int x;
@@ -812,9 +855,31 @@ namespace OpenSim.Region.CoreModules.World.Land
812 { 855 {
813 return null; 856 return null;
814 } 857 }
858=======
859 return GetLandObject((int)x_float, (int)y_float, true);
860 }
815 861
816 lock (m_landList) 862 // if x,y is off region this will return the parcel at cliped x,y
863 // as did code it replaces
864 public ILandObject GetLandObjectClipedXY(float x, float y)
865 {
866 //do clip inline
867 int avx = (int)x;
868 if (avx < 0)
869 avx = 0;
870 else if (avx >= m_scene.RegionInfo.RegionSizeX)
871 avx = (int)Constants.RegionSize - 1;
872
873 int avy = (int)y;
874 if (avy < 0)
875 avy = 0;
876 else if (avy >= m_scene.RegionInfo.RegionSizeY)
877 avy = (int)Constants.RegionSize - 1;
878>>>>>>> avn/ubitvar
879
880 lock (m_landIDList)
817 { 881 {
882<<<<<<< HEAD
818 // Corner case. If an autoreturn happens during sim startup 883 // Corner case. If an autoreturn happens during sim startup
819 // we will come here with the list uninitialized 884 // we will come here with the list uninitialized
820 // 885 //
@@ -837,6 +902,16 @@ namespace OpenSim.Region.CoreModules.World.Land
837 } 902 }
838 903
839 return null; 904 return null;
905=======
906 try
907 {
908 return m_landList[m_landIDList[avx / landUnit, avy / landUnit]];
909 }
910 catch (IndexOutOfRangeException)
911 {
912 return null;
913 }
914>>>>>>> avn/ubitvar
840 } 915 }
841 */ 916 */
842 } 917 }
@@ -848,6 +923,7 @@ namespace OpenSim.Region.CoreModules.World.Land
848 return GetLandObject(x, y, false /* returnNullIfLandObjectNotFound */); 923 return GetLandObject(x, y, false /* returnNullIfLandObjectNotFound */);
849 } 924 }
850 925
926<<<<<<< HEAD
851 /// <summary> 927 /// <summary>
852 /// Given a region position, return the parcel land object for that location 928 /// Given a region position, return the parcel land object for that location
853 /// </summary> 929 /// </summary>
@@ -862,16 +938,37 @@ namespace OpenSim.Region.CoreModules.World.Land
862 private ILandObject GetLandObject(int x, int y, bool returnNullIfLandObjectOutsideBounds) 938 private ILandObject GetLandObject(int x, int y, bool returnNullIfLandObjectOutsideBounds)
863 { 939 {
864 if (x >= m_scene.RegionInfo.RegionSizeX || y >= m_scene.RegionInfo.RegionSizeY || x < 0 || y < 0) 940 if (x >= m_scene.RegionInfo.RegionSizeX || y >= m_scene.RegionInfo.RegionSizeY || x < 0 || y < 0)
941=======
942 public ILandObject GetLandObject(int x, int y, bool returnNullIfLandObjectOutsideBounds)
943 {
944 if (x >= m_scene.RegionInfo.RegionSizeX || y >= m_scene.RegionInfo.RegionSizeY || x < 0 || y < 0)
945>>>>>>> avn/ubitvar
865 { 946 {
866 // These exceptions here will cause a lot of complaints from the users specifically because 947 // These exceptions here will cause a lot of complaints from the users specifically because
867 // they happen every time at border crossings 948 // they happen every time at border crossings
868 if (returnNullIfLandObjectOutsideBounds) 949 if (returnNullIfLandObjectOutsideBounds)
869 return null; 950 return null;
870 else 951 else
952<<<<<<< HEAD
871 throw new Exception( 953 throw new Exception(
872 String.Format("{0} GetLandObject for non-existent position. Region={1}, pos=<{2},{3}", 954 String.Format("{0} GetLandObject for non-existent position. Region={1}, pos=<{2},{3}",
873 LogHeader, m_scene.RegionInfo.RegionName, x, y) 955 LogHeader, m_scene.RegionInfo.RegionName, x, y)
874 ); 956 );
957=======
958 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
959 }
960
961 lock (m_landIDList)
962 {
963 try
964 {
965 return m_landList[m_landIDList[x / 4, y / 4]];
966 }
967 catch (IndexOutOfRangeException)
968 {
969 return null;
970 }
971>>>>>>> avn/ubitvar
875 } 972 }
876 973
877 return m_landList[m_landIDList[x / 4, y / 4]]; 974 return m_landList[m_landIDList[x / 4, y / 4]];
@@ -890,6 +987,19 @@ namespace OpenSim.Region.CoreModules.World.Land
890 return ret; 987 return ret;
891 } 988 }
892 989
990 // Create a 'parcel is here' bitmap for the parcel identified by the passed landID
991 private bool[,] CreateBitmapForID(int landID)
992 {
993 bool[,] ret = new bool[m_landIDList.GetLength(0), m_landIDList.GetLength(1)];
994
995 for (int xx = 0; xx < m_landIDList.GetLength(0); xx++)
996 for (int yy = 0; yy < m_landIDList.GetLength(0); yy++)
997 if (m_landIDList[xx, yy] == landID)
998 ret[xx, yy] = true;
999
1000 return ret;
1001 }
1002
893 #endregion 1003 #endregion
894 1004
895 #region Parcel Modification 1005 #region Parcel Modification
@@ -1033,7 +1143,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1033 1143
1034 //If we are still here, then they are subdividing within one piece of land 1144 //If we are still here, then they are subdividing within one piece of land
1035 //Check owner 1145 //Check owner
1036 if (!m_scene.Permissions.CanEditParcelProperties(attempting_user_id, startLandObject, GroupPowers.LandDivideJoin)) 1146 if (!m_scene.Permissions.CanEditParcelProperties(attempting_user_id, startLandObject, GroupPowers.LandDivideJoin, true))
1037 { 1147 {
1038 return; 1148 return;
1039 } 1149 }
@@ -1043,6 +1153,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1043 newLand.LandData.Name = newLand.LandData.Name; 1153 newLand.LandData.Name = newLand.LandData.Name;
1044 newLand.LandData.GlobalID = UUID.Random(); 1154 newLand.LandData.GlobalID = UUID.Random();
1045 newLand.LandData.Dwell = 0; 1155 newLand.LandData.Dwell = 0;
1156 // Clear "Show in search" on the cut out parcel to prevent double-charging
1157 newLand.LandData.Flags &= ~(uint)ParcelFlags.ShowDirectory;
1046 1158
1047 newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y)); 1159 newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y));
1048 1160
@@ -1057,12 +1169,19 @@ namespace OpenSim.Region.CoreModules.World.Land
1057 1169
1058 //Now add the new land object 1170 //Now add the new land object
1059 ILandObject result = AddLandObject(newLand); 1171 ILandObject result = AddLandObject(newLand);
1172<<<<<<< HEAD
1060 1173
1061 if (result != null) 1174 if (result != null)
1062 { 1175 {
1063 UpdateLandObject(startLandObject.LandData.LocalID, startLandObject.LandData); 1176 UpdateLandObject(startLandObject.LandData.LocalID, startLandObject.LandData);
1064 result.SendLandUpdateToAvatarsOverMe(); 1177 result.SendLandUpdateToAvatarsOverMe();
1065 } 1178 }
1179=======
1180 UpdateLandObject(startLandObject.LandData.LocalID, startLandObject.LandData);
1181 result.SendLandUpdateToAvatarsOverMe();
1182 startLandObject.SendLandUpdateToAvatarsOverMe();
1183 m_scene.ForEachClient(SendParcelOverlay);
1184>>>>>>> avn/ubitvar
1066 } 1185 }
1067 1186
1068 /// <summary> 1187 /// <summary>
@@ -1104,7 +1223,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1104 { 1223 {
1105 return; 1224 return;
1106 } 1225 }
1107 if (!m_scene.Permissions.CanEditParcelProperties(attempting_user_id, masterLandObject, GroupPowers.LandDivideJoin)) 1226 if (!m_scene.Permissions.CanEditParcelProperties(attempting_user_id, masterLandObject, GroupPowers.LandDivideJoin, true))
1108 { 1227 {
1109 return; 1228 return;
1110 } 1229 }
@@ -1127,6 +1246,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1127 } 1246 }
1128 1247
1129 masterLandObject.SendLandUpdateToAvatarsOverMe(); 1248 masterLandObject.SendLandUpdateToAvatarsOverMe();
1249 m_scene.ForEachClient(SendParcelOverlay);
1130 } 1250 }
1131 1251
1132 public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) 1252 public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
@@ -1143,11 +1263,14 @@ namespace OpenSim.Region.CoreModules.World.Land
1143 1263
1144 #region Parcel Updating 1264 #region Parcel Updating
1145 1265
1266<<<<<<< HEAD
1146 // Send parcel layer info for the whole region 1267 // Send parcel layer info for the whole region
1147 public void SendParcelOverlay(IClientAPI remote_client) 1268 public void SendParcelOverlay(IClientAPI remote_client)
1148 { 1269 {
1149 SendParcelOverlay(remote_client, 0, 0, (int)Constants.MaximumRegionSize); 1270 SendParcelOverlay(remote_client, 0, 0, (int)Constants.MaximumRegionSize);
1150 } 1271 }
1272=======
1273>>>>>>> avn/ubitvar
1151 1274
1152 /// <summary> 1275 /// <summary>
1153 /// Send the parcel overlay blocks to the client. We send the overlay packets 1276 /// Send the parcel overlay blocks to the client. We send the overlay packets
@@ -1164,11 +1287,15 @@ namespace OpenSim.Region.CoreModules.World.Land
1164 /// <param name="layerViewDistance">Distance from x,y position to send parcel layer info</param> 1287 /// <param name="layerViewDistance">Distance from x,y position to send parcel layer info</param>
1165 private void SendParcelOverlay(IClientAPI remote_client, int xPlace, int yPlace, int layerViewDistance) 1288 private void SendParcelOverlay(IClientAPI remote_client, int xPlace, int yPlace, int layerViewDistance)
1166 { 1289 {
1290 if (remote_client.SceneAgent.PresenceType == PresenceType.Npc)
1291 return;
1292
1167 const int LAND_BLOCKS_PER_PACKET = 1024; 1293 const int LAND_BLOCKS_PER_PACKET = 1024;
1168 1294
1169 byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET]; 1295 byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET];
1170 int byteArrayCount = 0; 1296 int byteArrayCount = 0;
1171 int sequenceID = 0; 1297 int sequenceID = 0;
1298<<<<<<< HEAD
1172 1299
1173 int xLow = 0; 1300 int xLow = 0;
1174 int xHigh = (int)m_scene.RegionInfo.RegionSizeX; 1301 int xHigh = (int)m_scene.RegionInfo.RegionSizeX;
@@ -1182,6 +1309,13 @@ namespace OpenSim.Region.CoreModules.World.Land
1182 int txHigh = xPlace + layerViewDistance; 1309 int txHigh = xPlace + layerViewDistance;
1183 // If the distance is outside the region area, move the view distance to ba all in the region 1310 // If the distance is outside the region area, move the view distance to ba all in the region
1184 if (txLow < xLow) 1311 if (txLow < xLow)
1312=======
1313
1314 // Layer data is in landUnit (4m) chunks
1315 for (int y = 0; y < m_scene.RegionInfo.RegionSizeY; y += landUnit)
1316 {
1317 for (int x = 0; x < m_scene.RegionInfo.RegionSizeX; x += landUnit)
1318>>>>>>> avn/ubitvar
1185 { 1319 {
1186 txLow = xLow; 1320 txLow = xLow;
1187 txHigh = Math.Min(yLow + (layerViewDistance * 2), xHigh); 1321 txHigh = Math.Min(yLow + (layerViewDistance * 2), xHigh);
@@ -1194,6 +1328,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1194 xLow = txLow; 1328 xLow = txLow;
1195 xHigh = txHigh; 1329 xHigh = txHigh;
1196 1330
1331<<<<<<< HEAD
1197 int tyLow = yPlace - layerViewDistance; 1332 int tyLow = yPlace - layerViewDistance;
1198 int tyHigh = yPlace + layerViewDistance; 1333 int tyHigh = yPlace + layerViewDistance;
1199 if (tyLow < yLow) 1334 if (tyLow < yLow)
@@ -1211,6 +1346,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1211 } 1346 }
1212 // m_log.DebugFormat("{0} SendParcelOverlay: place=<{1},{2}>, vDist={3}, xLH=<{4},{5}, yLH=<{6},{7}>", 1347 // m_log.DebugFormat("{0} SendParcelOverlay: place=<{1},{2}>, vDist={3}, xLH=<{4},{5}, yLH=<{6},{7}>",
1213 // LogHeader, xPlace, yPlace, layerViewDistance, xLow, xHigh, yLow, yHigh); 1348 // LogHeader, xPlace, yPlace, layerViewDistance, xLow, xHigh, yLow, yHigh);
1349=======
1350 ILandObject currentParcelBlock = GetLandObject(x, y);
1351>>>>>>> avn/ubitvar
1214 1352
1215 // Layer data is in landUnit (4m) chunks 1353 // Layer data is in landUnit (4m) chunks
1216 for (int y = yLow; y < yHigh / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); y++) 1354 for (int y = yLow; y < yHigh / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); y++)
@@ -1221,6 +1359,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1221 byteArrayCount++; 1359 byteArrayCount++;
1222 if (byteArrayCount >= LAND_BLOCKS_PER_PACKET) 1360 if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
1223 { 1361 {
1362<<<<<<< HEAD
1224 // m_log.DebugFormat("{0} SendParcelOverlay, sending packet, bytes={1}", LogHeader, byteArray.Length); 1363 // m_log.DebugFormat("{0} SendParcelOverlay, sending packet, bytes={1}", LogHeader, byteArray.Length);
1225 remote_client.SendLandParcelOverlay(byteArray, sequenceID); 1364 remote_client.SendLandParcelOverlay(byteArray, sequenceID);
1226 byteArrayCount = 0; 1365 byteArrayCount = 0;
@@ -1298,6 +1437,95 @@ namespace OpenSim.Region.CoreModules.World.Land
1298 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_FLAG_PROPERTY_BORDER_SOUTH); 1437 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_FLAG_PROPERTY_BORDER_SOUTH);
1299 } 1438 }
1300 1439
1440=======
1441 // types
1442 if (currentParcelBlock.LandData.OwnerID == remote_client.AgentId)
1443 {
1444 //Owner Flag
1445 tempByte = (byte)LandChannel.LAND_TYPE_OWNED_BY_REQUESTER;
1446 }
1447 else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID))
1448 {
1449 tempByte = (byte)LandChannel.LAND_TYPE_OWNED_BY_GROUP;
1450 }
1451 else if (currentParcelBlock.LandData.SalePrice > 0 &&
1452 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
1453 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
1454 {
1455 //Sale type
1456 tempByte = (byte)LandChannel.LAND_TYPE_IS_FOR_SALE;
1457 }
1458 else if (currentParcelBlock.LandData.OwnerID == UUID.Zero)
1459 {
1460 //Public type
1461 tempByte = (byte)LandChannel.LAND_TYPE_PUBLIC; // this does nothing, its zero
1462 }
1463 // LAND_TYPE_IS_BEING_AUCTIONED still unsuported
1464 else
1465 {
1466 //Other Flag
1467 tempByte = (byte)LandChannel.LAND_TYPE_OWNED_BY_OTHER;
1468 }
1469
1470 // now flags
1471 // border control
1472
1473 ILandObject westParcel = null;
1474 ILandObject southParcel = null;
1475 if (x > 0)
1476 {
1477 westParcel = GetLandObject((x - 1), y);
1478 }
1479 if (y > 0)
1480 {
1481 southParcel = GetLandObject(x, (y - 1));
1482 }
1483
1484 if (x == 0)
1485 {
1486 tempByte |= (byte)LandChannel.LAND_FLAG_PROPERTY_BORDER_WEST;
1487 }
1488 else if (westParcel != null && westParcel != currentParcelBlock)
1489 {
1490 tempByte |= (byte)LandChannel.LAND_FLAG_PROPERTY_BORDER_WEST;
1491 }
1492
1493 if (y == 0)
1494 {
1495 tempByte |= (byte)LandChannel.LAND_FLAG_PROPERTY_BORDER_SOUTH;
1496 }
1497 else if (southParcel != null && southParcel != currentParcelBlock)
1498 {
1499 tempByte |= (byte)LandChannel.LAND_FLAG_PROPERTY_BORDER_SOUTH;
1500 }
1501
1502 // local sound
1503 if ((currentParcelBlock.LandData.Flags & (uint)ParcelFlags.SoundLocal) != 0)
1504 tempByte |= (byte)LandChannel.LAND_FLAG_LOCALSOUND;
1505
1506 // hide avatars
1507 if (!currentParcelBlock.LandData.SeeAVs)
1508 tempByte |= (byte)LandChannel.LAND_FLAG_HIDEAVATARS;
1509
1510
1511 byteArray[byteArrayCount] = tempByte;
1512 byteArrayCount++;
1513 if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
1514 {
1515 remote_client.SendLandParcelOverlay(byteArray, sequenceID);
1516 byteArrayCount = 0;
1517 sequenceID++;
1518 byteArray = new byte[LAND_BLOCKS_PER_PACKET];
1519 }
1520 }
1521 }
1522
1523 }
1524
1525 if (byteArrayCount > 0)
1526 {
1527 remote_client.SendLandParcelOverlay(byteArray, sequenceID);
1528>>>>>>> avn/ubitvar
1301 } 1529 }
1302 1530
1303 return tempByte; 1531 return tempByte;
@@ -1320,8 +1548,11 @@ namespace OpenSim.Region.CoreModules.World.Land
1320 { 1548 {
1321 if (!temp.Contains(currentParcel)) 1549 if (!temp.Contains(currentParcel))
1322 { 1550 {
1323 currentParcel.ForceUpdateLandInfo(); 1551 if (!currentParcel.IsEitherBannedOrRestricted(remote_client.AgentId))
1324 temp.Add(currentParcel); 1552 {
1553 currentParcel.ForceUpdateLandInfo();
1554 temp.Add(currentParcel);
1555 }
1325 } 1556 }
1326 } 1557 }
1327 } 1558 }
@@ -1338,8 +1569,50 @@ namespace OpenSim.Region.CoreModules.World.Land
1338 temp[i].SendLandProperties(sequence_id, snap_selection, requestResult, remote_client); 1569 temp[i].SendLandProperties(sequence_id, snap_selection, requestResult, remote_client);
1339 } 1570 }
1340 1571
1572<<<<<<< HEAD
1341 // Also send the layer data around the point of interest 1573 // Also send the layer data around the point of interest
1342 SendParcelOverlay(remote_client, (start_x + end_x) / 2, (start_y + end_y) / 2, parcelLayerViewDistance); 1574 SendParcelOverlay(remote_client, (start_x + end_x) / 2, (start_y + end_y) / 2, parcelLayerViewDistance);
1575=======
1576// SendParcelOverlay(remote_client);
1577 }
1578
1579 public void UpdateLandProperties(ILandObject land, LandUpdateArgs args, IClientAPI remote_client)
1580 {
1581 bool snap_selection = false;
1582 bool needOverlay = false;
1583 if (land.UpdateLandProperties(args, remote_client, out snap_selection, out needOverlay))
1584 {
1585 //the proprieties to who changed them
1586 ScenePresence av = m_scene.GetScenePresence(remote_client.AgentId);
1587 if(av.IsChildAgent || land != GetLandObject(av.AbsolutePosition.X, av.AbsolutePosition.Y))
1588 land.SendLandProperties(-10000, false, LandChannel.LAND_RESULT_SINGLE, remote_client);
1589 else
1590 land.SendLandProperties(0, false, LandChannel.LAND_RESULT_SINGLE, remote_client);
1591
1592 UUID parcelID = land.LandData.GlobalID;
1593 m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
1594 {
1595 if (avatar.IsDeleted || avatar.isNPC)
1596 return;
1597
1598 IClientAPI client = avatar.ControllingClient;
1599 if (needOverlay)
1600 SendParcelOverlay(client);
1601
1602 if (avatar.IsChildAgent)
1603 return;
1604
1605 ILandObject aland = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
1606 if (aland != null)
1607 {
1608 if (client != remote_client && land == aland)
1609 aland.SendLandProperties(0, false, LandChannel.LAND_RESULT_SINGLE, client);
1610 }
1611 if (avatar.currentParcelUUID == parcelID)
1612 avatar.currentParcelUUID = parcelID; // force parcel flags review
1613 });
1614 }
1615>>>>>>> avn/ubitvar
1343 } 1616 }
1344 1617
1345 public void ClientOnParcelPropertiesUpdateRequest(LandUpdateArgs args, int localID, IClientAPI remote_client) 1618 public void ClientOnParcelPropertiesUpdateRequest(LandUpdateArgs args, int localID, IClientAPI remote_client)
@@ -1352,7 +1625,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1352 1625
1353 if (land != null) 1626 if (land != null)
1354 { 1627 {
1355 land.UpdateLandProperties(args, remote_client); 1628 UpdateLandProperties(land, args, remote_client);
1356 m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(args, localID, remote_client); 1629 m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(args, localID, remote_client);
1357 } 1630 }
1358 } 1631 }
@@ -1408,7 +1681,6 @@ namespace OpenSim.Region.CoreModules.World.Land
1408 land.LandData.GroupID = UUID.Zero; 1681 land.LandData.GroupID = UUID.Zero;
1409 land.LandData.IsGroupOwned = false; 1682 land.LandData.IsGroupOwned = false;
1410 land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory); 1683 land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
1411
1412 m_scene.ForEachClient(SendParcelOverlay); 1684 m_scene.ForEachClient(SendParcelOverlay);
1413 land.SendLandUpdateToClient(true, remote_client); 1685 land.SendLandUpdateToClient(true, remote_client);
1414 UpdateLandObject(land.LandData.LocalID, land.LandData); 1686 UpdateLandObject(land.LandData.LocalID, land.LandData);
@@ -1459,7 +1731,6 @@ namespace OpenSim.Region.CoreModules.World.Land
1459 land.LandData.SalePrice = 0; 1731 land.LandData.SalePrice = 0;
1460 land.LandData.AuthBuyerID = UUID.Zero; 1732 land.LandData.AuthBuyerID = UUID.Zero;
1461 land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory); 1733 land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
1462
1463 m_scene.ForEachClient(SendParcelOverlay); 1734 m_scene.ForEachClient(SendParcelOverlay);
1464 land.SendLandUpdateToClient(true, remote_client); 1735 land.SendLandUpdateToClient(true, remote_client);
1465 UpdateLandObject(land.LandData.LocalID, land.LandData); 1736 UpdateLandObject(land.LandData.LocalID, land.LandData);
@@ -1545,9 +1816,12 @@ namespace OpenSim.Region.CoreModules.World.Land
1545 1816
1546 private void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1817 private void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
1547 { 1818 {
1548// m_log.DebugFormat( 1819 lock (m_landList)
1549// "[LAND MANAGMENT MODULE]: Processing {0} incoming parcels on {1}", data.Count, m_scene.Name); 1820 {
1821 for (int i = 0; i < data.Count; i++)
1822 IncomingLandObjectFromStorage(data[i]);
1550 1823
1824<<<<<<< HEAD
1551 // Prevent race conditions from any auto-creation of new parcels for varregions whilst we are still loading 1825 // Prevent race conditions from any auto-creation of new parcels for varregions whilst we are still loading
1552 // the existing parcels. 1826 // the existing parcels.
1553 lock (m_landList) 1827 lock (m_landList)
@@ -1559,13 +1833,23 @@ namespace OpenSim.Region.CoreModules.World.Land
1559 for (int y = 0; y < m_scene.RegionInfo.RegionSizeY / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); y++) 1833 for (int y = 0; y < m_scene.RegionInfo.RegionSizeY / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); y++)
1560 { 1834 {
1561 for (int x = 0; x < m_scene.RegionInfo.RegionSizeX / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); x++) 1835 for (int x = 0; x < m_scene.RegionInfo.RegionSizeX / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); x++)
1836=======
1837 // Layer data is in landUnit (4m) chunks
1838 for (int y = 0; y < m_scene.RegionInfo.RegionSizeY / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / landUnit); y++)
1839 {
1840 for (int x = 0; x < m_scene.RegionInfo.RegionSizeX / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / landUnit); x++)
1841>>>>>>> avn/ubitvar
1562 { 1842 {
1563 if (m_landIDList[x, y] == 0) 1843 if (m_landIDList[x, y] == 0)
1564 { 1844 {
1565 if (m_landList.Count == 1) 1845 if (m_landList.Count == 1)
1566 { 1846 {
1567 m_log.DebugFormat( 1847 m_log.DebugFormat(
1848<<<<<<< HEAD
1568 "[{0}]: Auto-extending land parcel as landID at {1},{2} is 0 and only one land parcel is present in {3}", 1849 "[{0}]: Auto-extending land parcel as landID at {1},{2} is 0 and only one land parcel is present in {3}",
1850=======
1851 "[{0}]: Auto-extending land parcel as landID at {1},{2} is 0 and only one land parcel is present in {3}",
1852>>>>>>> avn/ubitvar
1569 LogHeader, x, y, m_scene.Name); 1853 LogHeader, x, y, m_scene.Name);
1570 1854
1571 int onlyParcelID = 0; 1855 int onlyParcelID = 0;
@@ -1588,11 +1872,19 @@ namespace OpenSim.Region.CoreModules.World.Land
1588 else if (m_landList.Count > 1) 1872 else if (m_landList.Count > 1)
1589 { 1873 {
1590 m_log.DebugFormat( 1874 m_log.DebugFormat(
1875<<<<<<< HEAD
1591 "{0}: Auto-creating land parcel as landID at {1},{2} is 0 and more than one land parcel is present in {3}", 1876 "{0}: Auto-creating land parcel as landID at {1},{2} is 0 and more than one land parcel is present in {3}",
1592 LogHeader, x, y, m_scene.Name); 1877 LogHeader, x, y, m_scene.Name);
1593 1878
1594 // There are several other parcels so we must create a new one for the unassigned space 1879 // There are several other parcels so we must create a new one for the unassigned space
1595 ILandObject newLand = new LandObject(UUID.Zero, false, m_scene); 1880 ILandObject newLand = new LandObject(UUID.Zero, false, m_scene);
1881=======
1882 "{0}: Auto-creating land parcel as landID at {1},{2} is 0 and more than one land parcel is present in {3}",
1883 LogHeader, x, y, m_scene.Name);
1884
1885 // There are several other parcels so we must create a new one for the unassigned space
1886 ILandObject newLand = new LandObject(UUID.Zero, false, m_scene);
1887>>>>>>> avn/ubitvar
1596 // Claim all the unclaimed "0" ids 1888 // Claim all the unclaimed "0" ids
1597 newLand.SetLandBitmap(CreateBitmapForID(0)); 1889 newLand.SetLandBitmap(CreateBitmapForID(0));
1598 newLand.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 1890 newLand.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
@@ -1603,7 +1895,11 @@ namespace OpenSim.Region.CoreModules.World.Land
1603 { 1895 {
1604 // We should never reach this point as the separate code path when no land data exists should have fired instead. 1896 // We should never reach this point as the separate code path when no land data exists should have fired instead.
1605 m_log.WarnFormat( 1897 m_log.WarnFormat(
1898<<<<<<< HEAD
1606 "{0}: Ignoring request to auto-create parcel in {1} as there are no other parcels present", 1899 "{0}: Ignoring request to auto-create parcel in {1} as there are no other parcels present",
1900=======
1901 "{0}: Ignoring request to auto-create parcel in {1} as there are no other parcels present",
1902>>>>>>> avn/ubitvar
1607 LogHeader, m_scene.Name); 1903 LogHeader, m_scene.Name);
1608 } 1904 }
1609 } 1905 }
@@ -1614,9 +1910,16 @@ namespace OpenSim.Region.CoreModules.World.Land
1614 1910
1615 private void IncomingLandObjectFromStorage(LandData data) 1911 private void IncomingLandObjectFromStorage(LandData data)
1616 { 1912 {
1913<<<<<<< HEAD
1617 ILandObject new_land = new LandObject(data, m_scene); 1914 ILandObject new_land = new LandObject(data, m_scene);
1915=======
1916
1917 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1918 new_land.LandData = data.Copy();
1919>>>>>>> avn/ubitvar
1618 new_land.SetLandBitmapFromByteArray(); 1920 new_land.SetLandBitmapFromByteArray();
1619 AddLandObject(new_land); 1921 AddLandObject(new_land);
1922// new_land.SendLandUpdateToAvatarsOverMe();
1620 } 1923 }
1621 1924
1622 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) 1925 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
@@ -1773,6 +2076,19 @@ namespace OpenSim.Region.CoreModules.World.Land
1773 land_update.ObscureMusic = properties.ObscureMusic; 2076 land_update.ObscureMusic = properties.ObscureMusic;
1774 land_update.ObscureMedia = properties.ObscureMedia; 2077 land_update.ObscureMedia = properties.ObscureMedia;
1775 2078
2079 if (args.ContainsKey("see_avs"))
2080 {
2081 land_update.SeeAVs = args["see_avs"].AsBoolean();
2082 land_update.AnyAVSounds = args["any_av_sounds"].AsBoolean();
2083 land_update.GroupAVSounds = args["group_av_sounds"].AsBoolean();
2084 }
2085 else
2086 {
2087 land_update.SeeAVs = true;
2088 land_update.AnyAVSounds = true;
2089 land_update.GroupAVSounds = true;
2090 }
2091
1776 ILandObject land; 2092 ILandObject land;
1777 lock (m_landList) 2093 lock (m_landList)
1778 { 2094 {
@@ -1781,13 +2097,14 @@ namespace OpenSim.Region.CoreModules.World.Land
1781 2097
1782 if (land != null) 2098 if (land != null)
1783 { 2099 {
1784 land.UpdateLandProperties(land_update, client); 2100 UpdateLandProperties(land,land_update, client);
1785 m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(land_update, parcelID, client); 2101 m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(land_update, parcelID, client);
1786 } 2102 }
1787 else 2103 else
1788 { 2104 {
1789 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID); 2105 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID);
1790 } 2106 }
2107
1791 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); 2108 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
1792 } 2109 }
1793 // we cheat here: As we don't have (and want) a grid-global parcel-store, we can't return the 2110 // we cheat here: As we don't have (and want) a grid-global parcel-store, we can't return the
@@ -1940,14 +2257,93 @@ namespace OpenSim.Region.CoreModules.World.Land
1940 2257
1941 if (land == null) return; 2258 if (land == null) return;
1942 2259
1943 if (!m_scene.Permissions.CanEditParcelProperties(remoteClient.AgentId, land, GroupPowers.LandOptions)) 2260 if (!m_scene.Permissions.CanEditParcelProperties(remoteClient.AgentId, land, GroupPowers.LandOptions, false))
1944 return; 2261 return;
1945 2262
1946 land.LandData.OtherCleanTime = otherCleanTime; 2263 land.LandData.OtherCleanTime = otherCleanTime;
1947 2264
1948 UpdateLandObject(localID, land.LandData); 2265 UpdateLandObject(localID, land.LandData);
1949 } 2266 }
1950 2267
2268 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
2269 {
2270 ILandObject land = null;
2271 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
2272 foreach (ILandObject landObject in Land)
2273 {
2274 if (landObject.LandData.LocalID == landID)
2275 {
2276 land = landObject;
2277 }
2278 }
2279 land.DeedToGroup(DefaultGodParcelGroup);
2280 land.LandData.Name = DefaultGodParcelName;
2281 land.SendLandUpdateToAvatarsOverMe();
2282 }
2283
2284 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
2285 {
2286 ScenePresence SP;
2287 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP);
2288 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
2289 if (SP.UserLevel != 0)
2290 {
2291 if (flags == 0) //All parcels, scripted or not
2292 {
2293 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
2294 {
2295 if (e.OwnerID == targetID)
2296 {
2297 returns.Add(e);
2298 }
2299 }
2300 );
2301 }
2302 if (flags == 4) //All parcels, scripted object
2303 {
2304 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
2305 {
2306 if (e.OwnerID == targetID)
2307 {
2308 if (e.ContainsScripts())
2309 {
2310 returns.Add(e);
2311 }
2312 }
2313 }
2314 );
2315 }
2316 if (flags == 4) //not target parcel, scripted object
2317 {
2318 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
2319 {
2320 if (e.OwnerID == targetID)
2321 {
2322 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
2323 if (landobject.LandData.OwnerID != e.OwnerID)
2324 {
2325 if (e.ContainsScripts())
2326 {
2327 returns.Add(e);
2328 }
2329 }
2330 }
2331 }
2332 );
2333 }
2334 foreach (SceneObjectGroup ol in returns)
2335 {
2336 ReturnObject(ol, client);
2337 }
2338 }
2339 }
2340 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
2341 {
2342 SceneObjectGroup[] objs = new SceneObjectGroup[1];
2343 objs[0] = obj;
2344 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
2345 }
2346
1951 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); 2347 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1952 2348
1953 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) 2349 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
@@ -1961,7 +2357,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1961 if (targetAvatar.UserLevel == 0) 2357 if (targetAvatar.UserLevel == 0)
1962 { 2358 {
1963 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y); 2359 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1964 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze)) 2360 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze, true))
1965 return; 2361 return;
1966 if (flags == 0) 2362 if (flags == 0)
1967 { 2363 {
@@ -1983,7 +2379,6 @@ namespace OpenSim.Region.CoreModules.World.Land
1983 } 2379 }
1984 } 2380 }
1985 } 2381 }
1986
1987 private void OnEndParcelFrozen(object avatar) 2382 private void OnEndParcelFrozen(object avatar)
1988 { 2383 {
1989 ScenePresence targetAvatar = (ScenePresence)avatar; 2384 ScenePresence targetAvatar = (ScenePresence)avatar;
@@ -1994,6 +2389,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1994 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false); 2389 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1995 } 2390 }
1996 2391
2392
1997 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) 2393 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1998 { 2394 {
1999 ScenePresence targetAvatar = null; 2395 ScenePresence targetAvatar = null;
@@ -2010,15 +2406,16 @@ namespace OpenSim.Region.CoreModules.World.Land
2010 2406
2011 // Check if you even have permission to do this 2407 // Check if you even have permission to do this
2012 ILandObject land = m_scene.LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y); 2408 ILandObject land = m_scene.LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
2013 if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) && 2409 if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze, true) &&
2014 !m_scene.Permissions.IsAdministrator(client.AgentId)) 2410 !m_scene.Permissions.IsAdministrator(client.AgentId))
2015 return; 2411 return;
2412
2016 Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); 2413 Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land);
2017 2414
2018 targetAvatar.TeleportWithMomentum(pos, null); 2415 targetAvatar.TeleportWithMomentum(pos, null);
2019 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); 2416 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
2020 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); 2417 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
2021 2418
2022 if ((flags & 1) != 0) // Ban TODO: Remove magic number 2419 if ((flags & 1) != 0) // Ban TODO: Remove magic number
2023 { 2420 {
2024 LandAccessEntry entry = new LandAccessEntry(); 2421 LandAccessEntry entry = new LandAccessEntry();
@@ -2171,6 +2568,7 @@ namespace OpenSim.Region.CoreModules.World.Land
2171 2568
2172 private void AppendParcelsSummaryReport(StringBuilder report) 2569 private void AppendParcelsSummaryReport(StringBuilder report)
2173 { 2570 {
2571<<<<<<< HEAD
2174 report.AppendFormat("Land information for {0}\n", m_scene.Name); 2572 report.AppendFormat("Land information for {0}\n", m_scene.Name);
2175 2573
2176 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 2574 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
@@ -2180,12 +2578,24 @@ namespace OpenSim.Region.CoreModules.World.Land
2180 cdt.AddColumn("Starts", ConsoleDisplayUtil.VectorSize); 2578 cdt.AddColumn("Starts", ConsoleDisplayUtil.VectorSize);
2181 cdt.AddColumn("Ends", ConsoleDisplayUtil.VectorSize); 2579 cdt.AddColumn("Ends", ConsoleDisplayUtil.VectorSize);
2182 cdt.AddColumn("Owner", ConsoleDisplayUtil.UserNameSize); 2580 cdt.AddColumn("Owner", ConsoleDisplayUtil.UserNameSize);
2581=======
2582 report.AppendFormat("Land information for {0}\n", m_scene.RegionInfo.RegionName);
2583 report.AppendFormat(
2584 "{0,-20} {1,-10} {2,-9} {3,-18} {4,-18} {5,-20}\n",
2585 "Parcel Name",
2586 "Local ID",
2587 "Area",
2588 "AABBMin",
2589 "AABBMax",
2590 "Owner");
2591>>>>>>> avn/ubitvar
2183 2592
2184 lock (m_landList) 2593 lock (m_landList)
2185 { 2594 {
2186 foreach (ILandObject lo in m_landList.Values) 2595 foreach (ILandObject lo in m_landList.Values)
2187 { 2596 {
2188 LandData ld = lo.LandData; 2597 LandData ld = lo.LandData;
2598<<<<<<< HEAD
2189 string ownerName; 2599 string ownerName;
2190 if (ld.IsGroupOwned) 2600 if (ld.IsGroupOwned)
2191 { 2601 {
@@ -2198,6 +2608,35 @@ namespace OpenSim.Region.CoreModules.World.Land
2198 } 2608 }
2199 cdt.AddRow( 2609 cdt.AddRow(
2200 ld.Name, ld.LocalID, ld.Area, lo.StartPoint, lo.EndPoint, ownerName); 2610 ld.Name, ld.LocalID, ld.Area, lo.StartPoint, lo.EndPoint, ownerName);
2611=======
2612
2613 report.AppendFormat(
2614 "{0,-20} {1,-10} {2,-9} {3,-18} {4,-18} {5,-20}\n",
2615 ld.Name, ld.LocalID, ld.Area, ld.AABBMin, ld.AABBMax, m_userManager.GetUserName(ld.OwnerID));
2616 }
2617 }
2618
2619 }
2620
2621 public void EnforceBans(ILandObject land, ScenePresence avatar)
2622 {
2623 if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
2624 return;
2625
2626 if (land.IsEitherBannedOrRestricted(avatar.UUID))
2627 {
2628 if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
2629 {
2630 Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
2631 if (pos == null)
2632 m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
2633 else
2634 ForceAvatarToPosition(avatar, (Vector3)pos);
2635 }
2636 else
2637 {
2638 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
2639>>>>>>> avn/ubitvar
2201 } 2640 }
2202 } 2641 }
2203 2642
@@ -2214,8 +2653,6 @@ namespace OpenSim.Region.CoreModules.World.Land
2214 cdl.AddRow("Description", ld.Description); 2653 cdl.AddRow("Description", ld.Description);
2215 cdl.AddRow("Snapshot ID", ld.SnapshotID); 2654 cdl.AddRow("Snapshot ID", ld.SnapshotID);
2216 cdl.AddRow("Area", ld.Area); 2655 cdl.AddRow("Area", ld.Area);
2217 cdl.AddRow("Starts", lo.StartPoint);
2218 cdl.AddRow("Ends", lo.EndPoint);
2219 cdl.AddRow("AABB Min", ld.AABBMin); 2656 cdl.AddRow("AABB Min", ld.AABBMin);
2220 cdl.AddRow("AABB Max", ld.AABBMax); 2657 cdl.AddRow("AABB Max", ld.AABBMax);
2221 string ownerName; 2658 string ownerName;
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index a0c1b9d..3b81d6b 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -46,11 +46,20 @@ namespace OpenSim.Region.CoreModules.World.Land
46 46
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private static readonly string LogHeader = "[LAND OBJECT]"; 48 private static readonly string LogHeader = "[LAND OBJECT]";
49<<<<<<< HEAD
49 50
50 private readonly int landUnit = 4; 51 private readonly int landUnit = 4;
51 52
52 private int m_lastSeqId = 0; 53 private int m_lastSeqId = 0;
53 54
55=======
56
57 private readonly int landUnit = 4;
58
59 private int m_lastSeqId = 0;
60 private int m_expiryCounter = 0;
61
62>>>>>>> avn/ubitvar
54 protected Scene m_scene; 63 protected Scene m_scene;
55 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); 64 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
56 protected Dictionary<uint, UUID> m_listTransactions = new Dictionary<uint, UUID>(); 65 protected Dictionary<uint, UUID> m_listTransactions = new Dictionary<uint, UUID>();
@@ -58,7 +67,16 @@ namespace OpenSim.Region.CoreModules.World.Land
58 protected ExpiringCache<UUID, bool> m_groupMemberCache = new ExpiringCache<UUID, bool>(); 67 protected ExpiringCache<UUID, bool> m_groupMemberCache = new ExpiringCache<UUID, bool>();
59 protected TimeSpan m_groupMemberCacheTimeout = TimeSpan.FromSeconds(30); // cache invalidation after 30 seconds 68 protected TimeSpan m_groupMemberCacheTimeout = TimeSpan.FromSeconds(30); // cache invalidation after 30 seconds
60 69
70<<<<<<< HEAD
61 public bool[,] LandBitmap { get; set; } 71 public bool[,] LandBitmap { get; set; }
72=======
73 private bool[,] m_landBitmap;
74 public bool[,] LandBitmap
75 {
76 get { return m_landBitmap; }
77 set { m_landBitmap = value; }
78 }
79>>>>>>> avn/ubitvar
62 80
63 #endregion 81 #endregion
64 82
@@ -69,7 +87,17 @@ namespace OpenSim.Region.CoreModules.World.Land
69 return free; 87 return free;
70 } 88 }
71 89
90<<<<<<< HEAD
72 public LandData LandData { get; set; } 91 public LandData LandData { get; set; }
92=======
93 protected LandData m_landData;
94 public LandData LandData
95 {
96 get { return m_landData; }
97
98 set { m_landData = value; }
99 }
100>>>>>>> avn/ubitvar
73 101
74 public IPrimCounts PrimCounts { get; set; } 102 public IPrimCounts PrimCounts { get; set; }
75 103
@@ -141,6 +169,8 @@ namespace OpenSim.Region.CoreModules.World.Land
141 else 169 else
142 LandData.GroupID = UUID.Zero; 170 LandData.GroupID = UUID.Zero;
143 LandData.IsGroupOwned = is_group_owned; 171 LandData.IsGroupOwned = is_group_owned;
172
173 m_scene.EventManager.OnFrame += OnFrame;
144 } 174 }
145 175
146 #endregion 176 #endregion
@@ -195,10 +225,34 @@ namespace OpenSim.Region.CoreModules.World.Land
195 else 225 else
196 { 226 {
197 // Normal Calculations 227 // Normal Calculations
228<<<<<<< HEAD
198 int parcelMax = (int)(((float)LandData.Area / (m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY)) 229 int parcelMax = (int)(((float)LandData.Area / (m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY))
199 * (float)m_scene.RegionInfo.ObjectCapacity 230 * (float)m_scene.RegionInfo.ObjectCapacity
200 * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); 231 * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
201 // TODO: The calculation of ObjectBonus should be refactored. It does still not work in the same manner as SL! 232 // TODO: The calculation of ObjectBonus should be refactored. It does still not work in the same manner as SL!
233=======
234 int parcelMax = (int)( (long)LandData.Area
235 * (long)m_scene.RegionInfo.ObjectCapacity
236 * (long)m_scene.RegionInfo.RegionSettings.ObjectBonus
237 / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY) );
238 //m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_scene.RegionInfo.ObjectCapacity, m_scene.RegionInfo.RegionSettings.ObjectBonus, parcelMax);
239 return parcelMax;
240 }
241 }
242
243 private int GetParcelBasePrimCount()
244 {
245 if (overrideParcelMaxPrimCount != null)
246 {
247 return overrideParcelMaxPrimCount(this);
248 }
249 else
250 {
251 // Normal Calculations
252 int parcelMax = (int)((long)LandData.Area
253 * (long)m_scene.RegionInfo.ObjectCapacity
254 / 65536L);
255>>>>>>> avn/ubitvar
202 return parcelMax; 256 return parcelMax;
203 } 257 }
204 } 258 }
@@ -212,8 +266,15 @@ namespace OpenSim.Region.CoreModules.World.Land
212 else 266 else
213 { 267 {
214 //Normal Calculations 268 //Normal Calculations
269<<<<<<< HEAD
215 int simMax = (int)(((float)LandData.SimwideArea / (m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY)) 270 int simMax = (int)(((float)LandData.SimwideArea / (m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY))
216 * (float)m_scene.RegionInfo.ObjectCapacity); 271 * (float)m_scene.RegionInfo.ObjectCapacity);
272=======
273 int simMax = (int)( (long)LandData.SimwideArea
274 * (long)m_scene.RegionInfo.ObjectCapacity
275 / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY) );
276 // m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}", LandData.SimwideArea, m_scene.RegionInfo.ObjectCapacity, simMax);
277>>>>>>> avn/ubitvar
217 return simMax; 278 return simMax;
218 } 279 }
219 } 280 }
@@ -224,6 +285,9 @@ namespace OpenSim.Region.CoreModules.World.Land
224 285
225 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client) 286 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client)
226 { 287 {
288 if (remote_client.SceneAgent.PresenceType == PresenceType.Npc)
289 return;
290
227 IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>(); 291 IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>();
228 // uint regionFlags = 336723974 & ~((uint)(RegionFlags.AllowLandmark | RegionFlags.AllowSetHome)); 292 // uint regionFlags = 336723974 & ~((uint)(RegionFlags.AllowLandmark | RegionFlags.AllowSetHome));
229 uint regionFlags = (uint)(RegionFlags.PublicAllowed 293 uint regionFlags = (uint)(RegionFlags.PublicAllowed
@@ -248,14 +312,15 @@ namespace OpenSim.Region.CoreModules.World.Land
248 remote_client.SendLandProperties(seq_id, 312 remote_client.SendLandProperties(seq_id,
249 snap_selection, request_result, this, 313 snap_selection, request_result, this,
250 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, 314 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus,
251 GetParcelMaxPrimCount(), 315 GetParcelBasePrimCount(),
252 GetSimulatorMaxPrimCount(), regionFlags); 316 GetSimulatorMaxPrimCount(), regionFlags);
253 } 317 }
254 318
255 public void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client) 319 public bool UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client, out bool snap_selection, out bool needOverlay)
256 { 320 {
257 //Needs later group support 321 //Needs later group support
258 bool snap_selection = false; 322 snap_selection = false;
323 needOverlay = false;
259 LandData newData = LandData.Copy(); 324 LandData newData = LandData.Copy();
260 325
261 uint allowedDelta = 0; 326 uint allowedDelta = 0;
@@ -264,7 +329,7 @@ namespace OpenSim.Region.CoreModules.World.Land
264 // ParcelFlags.ForSaleObjects 329 // ParcelFlags.ForSaleObjects
265 // ParcelFlags.LindenHome 330 // ParcelFlags.LindenHome
266 331
267 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions)) 332 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions, false))
268 { 333 {
269 allowedDelta |= (uint)(ParcelFlags.AllowLandmark | 334 allowedDelta |= (uint)(ParcelFlags.AllowLandmark |
270 ParcelFlags.AllowTerraform | 335 ParcelFlags.AllowTerraform |
@@ -277,9 +342,12 @@ namespace OpenSim.Region.CoreModules.World.Land
277 ParcelFlags.AllowAPrimitiveEntry | 342 ParcelFlags.AllowAPrimitiveEntry |
278 ParcelFlags.AllowGroupObjectEntry | 343 ParcelFlags.AllowGroupObjectEntry |
279 ParcelFlags.AllowFly); 344 ParcelFlags.AllowFly);
345 newData.SeeAVs = args.SeeAVs;
346 newData.AnyAVSounds = args.AnyAVSounds;
347 newData.GroupAVSounds = args.GroupAVSounds;
280 } 348 }
281 349
282 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandSetSale)) 350 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandSetSale, true))
283 { 351 {
284 if (args.AuthBuyerID != newData.AuthBuyerID || 352 if (args.AuthBuyerID != newData.AuthBuyerID ||
285 args.SalePrice != newData.SalePrice) 353 args.SalePrice != newData.SalePrice)
@@ -302,30 +370,30 @@ namespace OpenSim.Region.CoreModules.World.Land
302 allowedDelta |= (uint)ParcelFlags.ForSale; 370 allowedDelta |= (uint)ParcelFlags.ForSale;
303 } 371 }
304 372
305 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.FindPlaces)) 373 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.FindPlaces, false))
306 { 374 {
307 newData.Category = args.Category; 375 newData.Category = args.Category;
308 376
309 allowedDelta |= (uint)(ParcelFlags.ShowDirectory | 377 allowedDelta |= (uint)(ParcelFlags.ShowDirectory |
310 ParcelFlags.AllowPublish | 378 ParcelFlags.AllowPublish |
311 ParcelFlags.MaturePublish); 379 ParcelFlags.MaturePublish) | (uint)(1 << 23);
312 } 380 }
313 381
314 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) 382 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity, false))
315 { 383 {
316 newData.Description = args.Desc; 384 newData.Description = args.Desc;
317 newData.Name = args.Name; 385 newData.Name = args.Name;
318 newData.SnapshotID = args.SnapshotID; 386 newData.SnapshotID = args.SnapshotID;
319 } 387 }
320 388
321 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.SetLandingPoint)) 389 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.SetLandingPoint, false))
322 { 390 {
323 newData.LandingType = args.LandingType; 391 newData.LandingType = args.LandingType;
324 newData.UserLocation = args.UserLocation; 392 newData.UserLocation = args.UserLocation;
325 newData.UserLookAt = args.UserLookAt; 393 newData.UserLookAt = args.UserLookAt;
326 } 394 }
327 395
328 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.ChangeMedia)) 396 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.ChangeMedia, false))
329 { 397 {
330 newData.MediaAutoScale = args.MediaAutoScale; 398 newData.MediaAutoScale = args.MediaAutoScale;
331 newData.MediaID = args.MediaID; 399 newData.MediaID = args.MediaID;
@@ -346,7 +414,7 @@ namespace OpenSim.Region.CoreModules.World.Land
346 ParcelFlags.UseEstateVoiceChan); 414 ParcelFlags.UseEstateVoiceChan);
347 } 415 }
348 416
349 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandManagePasses)) 417 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandManagePasses, false))
350 { 418 {
351 newData.PassHours = args.PassHours; 419 newData.PassHours = args.PassHours;
352 newData.PassPrice = args.PassPrice; 420 newData.PassPrice = args.PassPrice;
@@ -354,13 +422,13 @@ namespace OpenSim.Region.CoreModules.World.Land
354 allowedDelta |= (uint)ParcelFlags.UsePassList; 422 allowedDelta |= (uint)ParcelFlags.UsePassList;
355 } 423 }
356 424
357 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageAllowed)) 425 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageAllowed, false))
358 { 426 {
359 allowedDelta |= (uint)(ParcelFlags.UseAccessGroup | 427 allowedDelta |= (uint)(ParcelFlags.UseAccessGroup |
360 ParcelFlags.UseAccessList); 428 ParcelFlags.UseAccessList);
361 } 429 }
362 430
363 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageBanned)) 431 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageBanned, false))
364 { 432 {
365 allowedDelta |= (uint)(ParcelFlags.UseBanList | 433 allowedDelta |= (uint)(ParcelFlags.UseBanList |
366 ParcelFlags.DenyAnonymous | 434 ParcelFlags.DenyAnonymous |
@@ -371,10 +439,24 @@ namespace OpenSim.Region.CoreModules.World.Land
371 { 439 {
372 uint preserve = LandData.Flags & ~allowedDelta; 440 uint preserve = LandData.Flags & ~allowedDelta;
373 newData.Flags = preserve | (args.ParcelFlags & allowedDelta); 441 newData.Flags = preserve | (args.ParcelFlags & allowedDelta);
442<<<<<<< HEAD
374 443
375 m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); 444 m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData);
376 SendLandUpdateToAvatarsOverMe(snap_selection); 445 SendLandUpdateToAvatarsOverMe(snap_selection);
377 } 446 }
447=======
448
449 uint curdelta = LandData.Flags ^ newData.Flags;
450 curdelta &= (uint)(ParcelFlags.SoundLocal);
451
452 if(curdelta != 0 || newData.SeeAVs != LandData.SeeAVs)
453 needOverlay = true;
454
455 m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData);
456 return true;
457 }
458 return false;
459>>>>>>> avn/ubitvar
378 } 460 }
379 461
380 public void UpdateLandSold(UUID avatarID, UUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) 462 public void UpdateLandSold(UUID avatarID, UUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area)
@@ -395,7 +477,7 @@ namespace OpenSim.Region.CoreModules.World.Land
395 UUID previousOwner = LandData.OwnerID; 477 UUID previousOwner = LandData.OwnerID;
396 478
397 m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); 479 m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData);
398 m_scene.EventManager.TriggerParcelPrimCountUpdate(); 480// m_scene.EventManager.TriggerParcelPrimCountUpdate();
399 SendLandUpdateToAvatarsOverMe(true); 481 SendLandUpdateToAvatarsOverMe(true);
400 482
401 if (sellObjects) SellLandObjects(previousOwner); 483 if (sellObjects) SellLandObjects(previousOwner);
@@ -568,6 +650,7 @@ namespace OpenSim.Region.CoreModules.World.Land
568 650
569 public void SendLandUpdateToAvatarsOverMe(bool snap_selection) 651 public void SendLandUpdateToAvatarsOverMe(bool snap_selection)
570 { 652 {
653 m_scene.EventManager.TriggerParcelPrimCountUpdate();
571 m_scene.ForEachRootScenePresence(delegate(ScenePresence avatar) 654 m_scene.ForEachRootScenePresence(delegate(ScenePresence avatar)
572 { 655 {
573 ILandObject over = null; 656 ILandObject over = null;
@@ -594,6 +677,7 @@ namespace OpenSim.Region.CoreModules.World.Land
594 avatar.Invulnerable = true; 677 avatar.Invulnerable = true;
595 678
596 SendLandUpdateToClient(snap_selection, avatar.ControllingClient); 679 SendLandUpdateToClient(snap_selection, avatar.ControllingClient);
680 avatar.currentParcelUUID = LandData.GlobalID;
597 } 681 }
598 } 682 }
599 }); 683 });
@@ -722,10 +806,17 @@ namespace OpenSim.Region.CoreModules.World.Land
722 /// </summary> 806 /// </summary>
723 private void UpdateAABBAndAreaValues() 807 private void UpdateAABBAndAreaValues()
724 { 808 {
809<<<<<<< HEAD
725 int min_x = 10000; 810 int min_x = 10000;
726 int min_y = 10000; 811 int min_y = 10000;
727 int max_x = 0; 812 int max_x = 0;
728 int max_y = 0; 813 int max_y = 0;
814=======
815 int min_x = Int32.MaxValue;
816 int min_y = Int32.MaxValue;
817 int max_x = Int32.MinValue;
818 int max_y = Int32.MinValue;
819>>>>>>> avn/ubitvar
729 int tempArea = 0; 820 int tempArea = 0;
730 int x, y; 821 int x, y;
731 for (x = 0; x < LandBitmap.GetLength(0); x++) 822 for (x = 0; x < LandBitmap.GetLength(0); x++)
@@ -734,10 +825,21 @@ namespace OpenSim.Region.CoreModules.World.Land
734 { 825 {
735 if (LandBitmap[x, y] == true) 826 if (LandBitmap[x, y] == true)
736 { 827 {
828<<<<<<< HEAD
737 if (min_x > x) min_x = x; 829 if (min_x > x) min_x = x;
738 if (min_y > y) min_y = y; 830 if (min_y > y) min_y = y;
739 if (max_x < x) max_x = x; 831 if (max_x < x) max_x = x;
740 if (max_y < y) max_y = y; 832 if (max_y < y) max_y = y;
833=======
834 if (min_x > x)
835 min_x = x;
836 if (min_y > y)
837 min_y = y;
838 if (max_x < x)
839 max_x = x;
840 if (max_y < y)
841 max_y = y;
842>>>>>>> avn/ubitvar
741 tempArea += landUnit * landUnit; //16sqm peice of land 843 tempArea += landUnit * landUnit; //16sqm peice of land
742 } 844 }
743 } 845 }
@@ -745,6 +847,7 @@ namespace OpenSim.Region.CoreModules.World.Land
745 int tx = min_x * landUnit; 847 int tx = min_x * landUnit;
746 if (tx > ((int)m_scene.RegionInfo.RegionSizeX - 1)) 848 if (tx > ((int)m_scene.RegionInfo.RegionSizeX - 1))
747 tx = ((int)m_scene.RegionInfo.RegionSizeX - 1); 849 tx = ((int)m_scene.RegionInfo.RegionSizeX - 1);
850<<<<<<< HEAD
748 int ty = min_y * landUnit; 851 int ty = min_y * landUnit;
749 if (ty > ((int)m_scene.RegionInfo.RegionSizeY - 1)) 852 if (ty > ((int)m_scene.RegionInfo.RegionSizeY - 1))
750 ty = ((int)m_scene.RegionInfo.RegionSizeY - 1); 853 ty = ((int)m_scene.RegionInfo.RegionSizeY - 1);
@@ -763,6 +866,45 @@ namespace OpenSim.Region.CoreModules.World.Land
763 LandData.AABBMax 866 LandData.AABBMax
764 = new Vector3( 867 = new Vector3(
765 (float)(max_x * landUnit), (float)(max_y * landUnit), m_scene != null ? (float)m_scene.Heightmap[tx, ty] : 0); 868 (float)(max_x * landUnit), (float)(max_y * landUnit), m_scene != null ? (float)m_scene.Heightmap[tx, ty] : 0);
869=======
870
871 int htx;
872 if (tx >= ((int)m_scene.RegionInfo.RegionSizeX))
873 htx = (int)m_scene.RegionInfo.RegionSizeX - 1;
874 else
875 htx = tx;
876
877 int ty = min_y * landUnit;
878 int hty;
879
880 if (ty >= ((int)m_scene.RegionInfo.RegionSizeY))
881 hty = (int)m_scene.RegionInfo.RegionSizeY - 1;
882 else
883 hty = ty;
884
885 LandData.AABBMin =
886 new Vector3(
887 (float)(tx), (float)(ty), m_scene != null ? (float)m_scene.Heightmap[htx, hty] : 0);
888
889 max_x++;
890 tx = max_x * landUnit;
891 if (tx >= ((int)m_scene.RegionInfo.RegionSizeX))
892 htx = (int)m_scene.RegionInfo.RegionSizeX - 1;
893 else
894 htx = tx;
895
896 max_y++;
897 ty = max_y * 4;
898
899 if (ty >= ((int)m_scene.RegionInfo.RegionSizeY))
900 hty = (int)m_scene.RegionInfo.RegionSizeY - 1;
901 else
902 hty = ty;
903
904 LandData.AABBMax
905 = new Vector3(
906 (float)(tx), (float)(ty), m_scene != null ? (float)m_scene.Heightmap[htx, hty] : 0);
907>>>>>>> avn/ubitvar
766 908
767 LandData.Area = tempArea; 909 LandData.Area = tempArea;
768 } 910 }
@@ -778,7 +920,10 @@ namespace OpenSim.Region.CoreModules.World.Land
778 public void SetLandBitmap(bool[,] bitmap) 920 public void SetLandBitmap(bool[,] bitmap)
779 { 921 {
780 LandBitmap = bitmap; 922 LandBitmap = bitmap;
923<<<<<<< HEAD
781 // m_log.DebugFormat("{0} SetLandBitmap. BitmapSize=<{1},{2}>", LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1)); 924 // m_log.DebugFormat("{0} SetLandBitmap. BitmapSize=<{1},{2}>", LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1));
925=======
926>>>>>>> avn/ubitvar
782 ForceUpdateLandInfo(); 927 ForceUpdateLandInfo();
783 } 928 }
784 929
@@ -879,13 +1024,37 @@ namespace OpenSim.Region.CoreModules.World.Land
879 private byte[] ConvertLandBitmapToBytes() 1024 private byte[] ConvertLandBitmapToBytes()
880 { 1025 {
881 byte[] tempConvertArr = new byte[LandBitmap.GetLength(0) * LandBitmap.GetLength(1) / 8]; 1026 byte[] tempConvertArr = new byte[LandBitmap.GetLength(0) * LandBitmap.GetLength(1) / 8];
1027<<<<<<< HEAD
882 byte tempByte = 0; 1028 byte tempByte = 0;
883 int byteNum = 0; 1029 int byteNum = 0;
884 int i = 0; 1030 int i = 0;
1031=======
1032 int tempByte = 0;
1033 int i, byteNum = 0;
1034 int mask = 1;
1035 i = 0;
1036>>>>>>> avn/ubitvar
885 for (int y = 0; y < LandBitmap.GetLength(1); y++) 1037 for (int y = 0; y < LandBitmap.GetLength(1); y++)
886 { 1038 {
887 for (int x = 0; x < LandBitmap.GetLength(0); x++) 1039 for (int x = 0; x < LandBitmap.GetLength(0); x++)
888 { 1040 {
1041 if (LandBitmap[x, y])
1042 tempByte |= mask;
1043 mask = mask << 1;
1044 if (mask == 0x100)
1045 {
1046 mask = 1;
1047 tempConvertArr[byteNum++] = (byte)tempByte;
1048 tempByte = 0;
1049 }
1050 }
1051 }
1052
1053 if(tempByte != 0 && byteNum < 512)
1054 tempConvertArr[byteNum] = (byte)tempByte;
1055
1056
1057/*
889 tempByte = Convert.ToByte(tempByte | Convert.ToByte(LandBitmap[x, y]) << (i++ % 8)); 1058 tempByte = Convert.ToByte(tempByte | Convert.ToByte(LandBitmap[x, y]) << (i++ % 8));
890 if (i % 8 == 0) 1059 if (i % 8 == 0)
891 { 1060 {
@@ -894,10 +1063,14 @@ namespace OpenSim.Region.CoreModules.World.Land
894 i = 0; 1063 i = 0;
895 byteNum++; 1064 byteNum++;
896 } 1065 }
1066<<<<<<< HEAD
897 } 1067 }
898 } 1068 }
899 // m_log.DebugFormat("{0} ConvertLandBitmapToBytes. BitmapSize=<{1},{2}>", 1069 // m_log.DebugFormat("{0} ConvertLandBitmapToBytes. BitmapSize=<{1},{2}>",
900 // LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1)); 1070 // LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1));
1071=======
1072 */
1073>>>>>>> avn/ubitvar
901 return tempConvertArr; 1074 return tempConvertArr;
902 } 1075 }
903 1076
@@ -951,7 +1124,7 @@ namespace OpenSim.Region.CoreModules.World.Land
951 1124
952 public void SendForceObjectSelect(int local_id, int request_type, List<UUID> returnIDs, IClientAPI remote_client) 1125 public void SendForceObjectSelect(int local_id, int request_type, List<UUID> returnIDs, IClientAPI remote_client)
953 { 1126 {
954 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions)) 1127 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions, true))
955 { 1128 {
956 List<uint> resultLocalIDs = new List<uint>(); 1129 List<uint> resultLocalIDs = new List<uint>();
957 try 1130 try
@@ -1001,7 +1174,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1001 /// </param> 1174 /// </param>
1002 public void SendLandObjectOwners(IClientAPI remote_client) 1175 public void SendLandObjectOwners(IClientAPI remote_client)
1003 { 1176 {
1004 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions)) 1177 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions, true))
1005 { 1178 {
1006 Dictionary<UUID, int> primCount = new Dictionary<UUID, int>(); 1179 Dictionary<UUID, int> primCount = new Dictionary<UUID, int>();
1007 List<UUID> groups = new List<UUID>(); 1180 List<UUID> groups = new List<UUID>();
@@ -1233,6 +1406,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1233 public void SetMediaUrl(string url) 1406 public void SetMediaUrl(string url)
1234 { 1407 {
1235 LandData.MediaURL = url; 1408 LandData.MediaURL = url;
1409 m_scene.LandChannel.UpdateLandObject(LandData.LocalID, LandData);
1236 SendLandUpdateToAvatarsOverMe(); 1410 SendLandUpdateToAvatarsOverMe();
1237 } 1411 }
1238 1412
@@ -1243,6 +1417,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1243 public void SetMusicUrl(string url) 1417 public void SetMusicUrl(string url)
1244 { 1418 {
1245 LandData.MusicURL = url; 1419 LandData.MusicURL = url;
1420 m_scene.LandChannel.UpdateLandObject(LandData.LocalID, LandData);
1246 SendLandUpdateToAvatarsOverMe(); 1421 SendLandUpdateToAvatarsOverMe();
1247 } 1422 }
1248 1423
@@ -1257,6 +1432,17 @@ namespace OpenSim.Region.CoreModules.World.Land
1257 1432
1258 #endregion 1433 #endregion
1259 1434
1435 private void OnFrame()
1436 {
1437 m_expiryCounter++;
1438
1439 if (m_expiryCounter >= 50)
1440 {
1441 ExpireAccessList();
1442 m_expiryCounter = 0;
1443 }
1444 }
1445
1260 private void ExpireAccessList() 1446 private void ExpireAccessList()
1261 { 1447 {
1262 List<LandAccessEntry> delete = new List<LandAccessEntry>(); 1448 List<LandAccessEntry> delete = new List<LandAccessEntry>();
@@ -1267,7 +1453,22 @@ namespace OpenSim.Region.CoreModules.World.Land
1267 delete.Add(entry); 1453 delete.Add(entry);
1268 } 1454 }
1269 foreach (LandAccessEntry entry in delete) 1455 foreach (LandAccessEntry entry in delete)
1456 {
1270 LandData.ParcelAccessList.Remove(entry); 1457 LandData.ParcelAccessList.Remove(entry);
1458 ScenePresence presence;
1459
1460 if (m_scene.TryGetScenePresence(entry.AgentID, out presence) && (!presence.IsChildAgent))
1461 {
1462 ILandObject land = m_scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
1463 if (land.LandData.LocalID == LandData.LocalID)
1464 {
1465 Vector3 pos = m_scene.GetNearestAllowedPosition(presence, land);
1466 presence.TeleportWithMomentum(pos, null);
1467 presence.ControllingClient.SendAlertMessage("You have been ejected from this land");
1468 }
1469 }
1470 m_log.DebugFormat("[LAND]: Removing entry {0} because it has expired", entry.AgentID);
1471 }
1271 1472
1272 if (delete.Count > 0) 1473 if (delete.Count > 0)
1273 m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this); 1474 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/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
index 796a15f..a228e7a 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
@@ -104,6 +104,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
104 104
105 terrainRenderer.Initialise(m_scene, m_config); 105 terrainRenderer.Initialise(m_scene, m_config);
106 106
107<<<<<<< HEAD
107 mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height, 108 mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height,
108 System.Drawing.Imaging.PixelFormat.Format24bppRgb); 109 System.Drawing.Imaging.PixelFormat.Format24bppRgb);
109 //long t = System.Environment.TickCount; 110 //long t = System.Environment.TickCount;
@@ -112,6 +113,16 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
112 //} 113 //}
113 //t = System.Environment.TickCount - t; 114 //t = System.Environment.TickCount - t;
114 //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t); 115 //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
116=======
117 mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height,
118 System.Drawing.Imaging.PixelFormat.Format24bppRgb);
119 //long t = System.Environment.TickCount;
120 //for (int i = 0; i < 10; ++i) {
121 terrainRenderer.TerrainToBitmap(mapbmp);
122 //}
123 //t = System.Environment.TickCount - t;
124 //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
125>>>>>>> avn/ubitvar
115 126
116 if (drawPrimVolume) 127 if (drawPrimVolume)
117 { 128 {
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
index 9f23141..a9cc993 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
@@ -270,8 +270,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
270 270
271 // the heigthfield might have some jumps in values. Rendered land is smooth, though, 271 // the heigthfield might have some jumps in values. Rendered land is smooth, though,
272 // as a slope is rendered at that place. So average 4 neighbour values to emulate that. 272 // as a slope is rendered at that place. So average 4 neighbour values to emulate that.
273<<<<<<< HEAD
273 private float getHeight(ITerrainChannel hm, int x, int y) { 274 private float getHeight(ITerrainChannel hm, int x, int y) {
274 if (x < (hm.Width - 1) && y < (hm.Height - 1)) 275 if (x < (hm.Width - 1) && y < (hm.Height - 1))
276=======
277 private float getHeight(ITerrainChannel hm, int x, int y)
278 {
279 if (x < ((int)Constants.RegionSize - 1) && y < ((int)Constants.RegionSize - 1))
280>>>>>>> avn/ubitvar
275 return (float)(hm[x, y] * .444 + (hm[x + 1, y] + hm[x, y + 1]) * .222 + hm[x + 1, y +1] * .112); 281 return (float)(hm[x, y] * .444 + (hm[x + 1, y] + hm[x, y + 1]) * .222 + hm[x + 1, y +1] * .112);
276 else 282 else
277 return (float)hm[x, y]; 283 return (float)hm[x, y];
@@ -291,6 +297,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
291 LogHeader, mapbmp.Width, mapbmp.Height, hm.Width, hm.Height); 297 LogHeader, mapbmp.Width, mapbmp.Height, hm.Width, hm.Height);
292 } 298 }
293 299
300 ITerrainChannel hm = m_scene.Heightmap;
301
302 if (mapbmp.Width != hm.Width || mapbmp.Height != hm.Height)
303 {
304 m_log.ErrorFormat("{0} TerrainToBitmap. Passed bitmap wrong dimensions. passed=<{1},{2}>, size=<{3},{4}>",
305 "[TEXTURED MAP TILE RENDERER]", mapbmp.Width, mapbmp.Height, hm.Width, hm.Height);
306 }
307
294 // These textures should be in the AssetCache anyway, as every client conneting to this 308 // These textures should be in the AssetCache anyway, as every client conneting to this
295 // region needs them. Except on start, when the map is recreated (before anyone connected), 309 // region needs them. Except on start, when the map is recreated (before anyone connected),
296 // and on change of the estate settings (textures and terrain values), when the map should 310 // and on change of the estate settings (textures and terrain values), when the map should
@@ -371,8 +385,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
371 // first, rescale h to 0.0 - 1.0 385 // first, rescale h to 0.0 - 1.0
372 hmod = (hmod - low) / (high - low); 386 hmod = (hmod - low) / (high - low);
373 // now we have to split: 0.00 => color1, 0.33 => color2, 0.67 => color3, 1.00 => color4 387 // now we have to split: 0.00 => color1, 0.33 => color2, 0.67 => color3, 1.00 => color4
374 if (hmod < 1f/3f) hsv = interpolateHSV(ref hsv1, ref hsv2, hmod * 3f); 388 if (hmod < 1f / 3f) hsv = interpolateHSV(ref hsv1, ref hsv2, hmod * 3f);
375 else if (hmod < 2f/3f) hsv = interpolateHSV(ref hsv2, ref hsv3, (hmod * 3f) - 1f); 389 else if (hmod < 2f / 3f) hsv = interpolateHSV(ref hsv2, ref hsv3, (hmod * 3f) - 1f);
376 else hsv = interpolateHSV(ref hsv3, ref hsv4, (hmod * 3f) - 2f); 390 else hsv = interpolateHSV(ref hsv3, ref hsv4, (hmod * 3f) - 2f);
377 } 391 }
378 392
diff --git a/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs
index 0a4e83e..f13d648 100644
--- a/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs
+++ b/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs
@@ -190,6 +190,9 @@ namespace OpenSim.Region.CoreModules.World.LightShare
190 190
191 public void SendProfileToClient(IClientAPI client, RegionLightShareData wl) 191 public void SendProfileToClient(IClientAPI client, RegionLightShareData wl)
192 { 192 {
193 if (client == null)
194 return;
195
193 if (m_enableWindlight) 196 if (m_enableWindlight)
194 { 197 {
195 if (m_scene.RegionInfo.WindlightSettings.valid) 198 if (m_scene.RegionInfo.WindlightSettings.valid)
@@ -207,8 +210,8 @@ namespace OpenSim.Region.CoreModules.World.LightShare
207 210
208 private void EventManager_OnMakeRootAgent(ScenePresence presence) 211 private void EventManager_OnMakeRootAgent(ScenePresence presence)
209 { 212 {
210// m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client {0}", presence.Name); 213 if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
211 214 m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
212 SendProfileToClient(presence.ControllingClient); 215 SendProfileToClient(presence.ControllingClient);
213 } 216 }
214 217
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 2abc910..0e0f05f 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -173,6 +173,13 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
173 return false; 173 return false;
174 } 174 }
175 175
176 if ((perms & (uint)PermissionMask.Copy) == 0)
177 {
178 if (m_dialogModule != null)
179 m_dialogModule.SendAlertToUser(remoteClient, "This sale has been blocked by the permissions system");
180 return false;
181 }
182
176 AssetBase asset = m_scene.CreateAsset( 183 AssetBase asset = m_scene.CreateAsset(
177 group.GetPartName(localID), 184 group.GetPartName(localID),
178 group.GetPartDescription(localID), 185 group.GetPartDescription(localID),
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 780ec69..12e8fb1 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -43,8 +43,8 @@ using PermissionMask = OpenSim.Framework.PermissionMask;
43 43
44namespace OpenSim.Region.CoreModules.World.Permissions 44namespace OpenSim.Region.CoreModules.World.Permissions
45{ 45{
46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "PermissionsModule")] 46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DefaultPermissionsModule")]
47 public class PermissionsModule : INonSharedRegionModule, IPermissionsModule 47 public class DefaultPermissionsModule : INonSharedRegionModule, IPermissionsModule
48 { 48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
@@ -349,7 +349,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
349 349
350 public string Name 350 public string Name
351 { 351 {
352 get { return "PermissionsModule"; } 352 get { return "DefaultPermissionsModule"; }
353 } 353 }
354 354
355 public Type ReplaceableInterface 355 public Type ReplaceableInterface
@@ -1052,7 +1052,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1052 return GenericObjectPermission(editorID, objectID, false); 1052 return GenericObjectPermission(editorID, objectID, false);
1053 } 1053 }
1054 1054
1055 private bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p, Scene scene) 1055 private bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p, Scene scene, bool allowManager)
1056 { 1056 {
1057 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1057 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1058 if (m_bypassPermissions) return m_bypassPermissionsValue; 1058 if (m_bypassPermissions) return m_bypassPermissionsValue;
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
index 75a8295..e6a0205 100644
--- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
+++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
@@ -29,6 +29,8 @@ using System;
29using System.Linq; 29using System.Linq;
30using System.Reflection; 30using System.Reflection;
31using System.Timers; 31using System.Timers;
32using System.IO;
33using System.Diagnostics;
32using System.Threading; 34using System.Threading;
33using System.Collections.Generic; 35using System.Collections.Generic;
34using log4net; 36using 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);
@@ -118,10 +131,14 @@ namespace OpenSim.Region.CoreModules.World.Region
118 public void ScheduleRestart(UUID initiator, string message, int[] alerts, bool notice) 131 public void ScheduleRestart(UUID initiator, string message, int[] alerts, bool notice)
119 { 132 {
120 if (m_CountdownTimer != null) 133 if (m_CountdownTimer != null)
121 return; 134 {
135 m_CountdownTimer.Stop();
136 m_CountdownTimer = null;
137 }
122 138
123 if (alerts == null) 139 if (alerts == null)
124 { 140 {
141 CreateMarkerFile();
125 m_Scene.RestartNow(); 142 m_Scene.RestartNow();
126 return; 143 return;
127 } 144 }
@@ -129,25 +146,28 @@ namespace OpenSim.Region.CoreModules.World.Region
129 m_Message = message; 146 m_Message = message;
130 m_Initiator = initiator; 147 m_Initiator = initiator;
131 m_Notice = notice; 148 m_Notice = notice;
149 m_CurrentAlerts = alerts;
132 m_Alerts = new List<int>(alerts); 150 m_Alerts = new List<int>(alerts);
133 m_Alerts.Sort(); 151 m_Alerts.Sort();
134 m_Alerts.Reverse(); 152 m_Alerts.Reverse();
135 153
136 if (m_Alerts[0] == 0) 154 if (m_Alerts[0] == 0)
137 { 155 {
156 CreateMarkerFile();
138 m_Scene.RestartNow(); 157 m_Scene.RestartNow();
139 return; 158 return;
140 } 159 }
141 160
142 int nextInterval = DoOneNotice(); 161 int nextInterval = DoOneNotice(true);
143 162
144 SetTimer(nextInterval); 163 SetTimer(nextInterval);
145 } 164 }
146 165
147 public int DoOneNotice() 166 public int DoOneNotice(bool sendOut)
148 { 167 {
149 if (m_Alerts.Count == 0 || m_Alerts[0] == 0) 168 if (m_Alerts.Count == 0 || m_Alerts[0] == 0)
150 { 169 {
170 CreateMarkerFile();
151 m_Scene.RestartNow(); 171 m_Scene.RestartNow();
152 return 0; 172 return 0;
153 } 173 }
@@ -168,34 +188,37 @@ namespace OpenSim.Region.CoreModules.World.Region
168 188
169 m_Alerts.RemoveAt(0); 189 m_Alerts.RemoveAt(0);
170 190
171 int minutes = currentAlert / 60; 191 if (sendOut)
172 string currentAlertString = String.Empty;
173 if (minutes > 0)
174 { 192 {
175 if (minutes == 1) 193 int minutes = currentAlert / 60;
176 currentAlertString += "1 minute"; 194 string currentAlertString = String.Empty;
177 else 195 if (minutes > 0)
178 currentAlertString += String.Format("{0} minutes", minutes); 196 {
197 if (minutes == 1)
198 currentAlertString += "1 minute";
199 else
200 currentAlertString += String.Format("{0} minutes", minutes);
201 if ((currentAlert % 60) != 0)
202 currentAlertString += " and ";
203 }
179 if ((currentAlert % 60) != 0) 204 if ((currentAlert % 60) != 0)
180 currentAlertString += " and "; 205 {
181 } 206 int seconds = currentAlert % 60;
182 if ((currentAlert % 60) != 0) 207 if (seconds == 1)
183 { 208 currentAlertString += "1 second";
184 int seconds = currentAlert % 60; 209 else
185 if (seconds == 1) 210 currentAlertString += String.Format("{0} seconds", seconds);
186 currentAlertString += "1 second"; 211 }
187 else
188 currentAlertString += String.Format("{0} seconds", seconds);
189 }
190 212
191 string msg = String.Format(m_Message, currentAlertString); 213 string msg = String.Format(m_Message, currentAlertString);
192 214
193 if (m_DialogModule != null && msg != String.Empty) 215 if (m_DialogModule != null && msg != String.Empty)
194 { 216 {
195 if (m_Notice) 217 if (m_Notice)
196 m_DialogModule.SendGeneralAlert(msg); 218 m_DialogModule.SendGeneralAlert(msg);
197 else 219 else
198 m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg); 220 m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg);
221 }
199 } 222 }
200 223
201 return currentAlert - nextAlert; 224 return currentAlert - nextAlert;
@@ -226,7 +249,27 @@ namespace OpenSim.Region.CoreModules.World.Region
226 249
227 private void OnTimer(object source, ElapsedEventArgs e) 250 private void OnTimer(object source, ElapsedEventArgs e)
228 { 251 {
229 SetTimer(DoOneNotice()); 252 int nextInterval = DoOneNotice(true);
253
254 SetTimer(nextInterval);
255 }
256
257 public void DelayRestart(int seconds, string message)
258 {
259 if (m_CountdownTimer == null)
260 return;
261
262 m_CountdownTimer.Stop();
263 m_CountdownTimer = null;
264
265 m_Alerts = new List<int>(m_CurrentAlerts);
266 m_Alerts.Add(seconds);
267 m_Alerts.Sort();
268 m_Alerts.Reverse();
269
270 int nextInterval = DoOneNotice(false);
271
272 SetTimer(nextInterval);
230 } 273 }
231 274
232 public void AbortRestart(string message) 275 public void AbortRestart(string message)
@@ -236,8 +279,12 @@ namespace OpenSim.Region.CoreModules.World.Region
236 m_CountdownTimer.Stop(); 279 m_CountdownTimer.Stop();
237 m_CountdownTimer = null; 280 m_CountdownTimer = null;
238 if (m_DialogModule != null && message != String.Empty) 281 if (m_DialogModule != null && message != String.Empty)
239 m_DialogModule.SendGeneralAlert(message); 282 m_DialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
283 //m_DialogModule.SendGeneralAlert(message);
240 } 284 }
285 if (m_MarkerPath != String.Empty)
286 File.Delete(Path.Combine(m_MarkerPath,
287 m_Scene.RegionInfo.RegionID.ToString()));
241 } 288 }
242 289
243 private void HandleRegionRestart(string module, string[] args) 290 private void HandleRegionRestart(string module, string[] args)
@@ -282,5 +329,25 @@ namespace OpenSim.Region.CoreModules.World.Region
282 329
283 ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); 330 ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice);
284 } 331 }
332
333 protected void CreateMarkerFile()
334 {
335 if (m_MarkerPath == String.Empty)
336 return;
337
338 string path = Path.Combine(m_MarkerPath, m_Scene.RegionInfo.RegionID.ToString());
339 try
340 {
341 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
342 FileStream fs = File.Create(path);
343 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
344 Byte[] buf = enc.GetBytes(pidstring);
345 fs.Write(buf, 0, buf.Length);
346 fs.Close();
347 }
348 catch (Exception)
349 {
350 }
351 }
285 } 352 }
286} \ No newline at end of file 353}
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index d093224..9c99c19 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -48,6 +48,18 @@ namespace OpenSim.Region.CoreModules.World.Sound
48 48
49 private Scene m_scene; 49 private Scene m_scene;
50 50
51 public enum SoundFlags: byte
52 {
53 NONE = 0,
54 LOOP = 1 << 0,
55 SYNC_MASTER = 1<<1,
56 SYNC_SLAVE = 1<<2,
57 SYNC_PENDING = 1<<3,
58 QUEUE = 1<<4,
59 STOP = 1<<5,
60 SYNC_MASK = SYNC_MASTER | SYNC_SLAVE | SYNC_PENDING
61 }
62
51 public bool Enabled { get; private set; } 63 public bool Enabled { get; private set; }
52 64
53 public float MaxDistance { get; private set; } 65 public float MaxDistance { get; private set; }
@@ -124,26 +136,30 @@ namespace OpenSim.Region.CoreModules.World.Sound
124 if (radius == 0) 136 if (radius == 0)
125 radius = MaxDistance; 137 radius = MaxDistance;
126 138
127 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 139 if (part.SoundQueueing)
140 flags |= (byte)SoundFlags.QUEUE;
141
142 if (grp.IsAttachment)
128 { 143 {
129 double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); 144 ScenePresence ssp = null;
130 if (dis > MaxDistance) // Max audio distance 145 if (!m_scene.TryGetScenePresence(grp.AttachedAvatar, out ssp))
131 return; 146 return;
132 147
133 if (grp.IsAttachment) 148 if (!ssp.ParcelAllowThisAvatarSounds)
134 { 149 return;
135 if (grp.HasPrivateAttachmentPoint && sp.ControllingClient.AgentId != grp.OwnerID)
136 return;
137 150
138 if (sp.ControllingClient.AgentId == grp.OwnerID) 151 if (grp.HasPrivateAttachmentPoint)
139 dis = 0; 152 {
153 ssp.ControllingClient.SendPlayAttachedSound(soundID, objectID,
154 ownerID, (float)gain, flags);
155 return;
140 } 156 }
157 }
141 158
142 // Scale by distance 159 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
143 double thisSpGain = gain * ((radius - dis) / radius); 160 {
144
145 sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, 161 sp.ControllingClient.SendPlayAttachedSound(soundID, objectID,
146 ownerID, (float)thisSpGain, flags); 162 ownerID, (float)gain, flags);
147 }); 163 });
148 } 164 }
149 165
@@ -151,20 +167,33 @@ namespace OpenSim.Region.CoreModules.World.Sound
151 UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) 167 UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius)
152 { 168 {
153 SceneObjectPart part; 169 SceneObjectPart part;
170 ScenePresence ssp = null;
154 if (!m_scene.TryGetSceneObjectPart(objectID, out part)) 171 if (!m_scene.TryGetSceneObjectPart(objectID, out part))
155 { 172 {
156 ScenePresence sp; 173 if (!m_scene.TryGetScenePresence(ownerID, out ssp))
157 if (!m_scene.TryGetScenePresence(ownerID, out sp)) 174 return;
175 if (!ssp.ParcelAllowThisAvatarSounds)
158 return; 176 return;
159 } 177 }
160 else 178 else
161 { 179 {
162 SceneObjectGroup grp = part.ParentGroup; 180 SceneObjectGroup grp = part.ParentGroup;
163 181
164 if (grp.IsAttachment && grp.AttachmentPoint > 30) 182 if (grp.IsAttachment)
165 { 183 {
166 objectID = ownerID; 184 if (!m_scene.TryGetScenePresence(grp.AttachedAvatar, out ssp))
167 parentID = ownerID; 185 return;
186
187 if (!ssp.ParcelAllowThisAvatarSounds)
188 return;
189
190 if (grp.HasPrivateAttachmentPoint)
191 {
192 ssp.ControllingClient.SendTriggeredSound(soundId, ownerID,
193 objectID, parentID, handle, position,
194 (float)gain);
195 return;
196 }
168 } 197 }
169 } 198 }
170 199
@@ -174,16 +203,12 @@ namespace OpenSim.Region.CoreModules.World.Sound
174 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 203 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
175 { 204 {
176 double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); 205 double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
177 206 if (dis > radius) // Max audio distance
178 if (dis > MaxDistance) // Max audio distance
179 return; 207 return;
180 208
181 // Scale by distance
182 double thisSpGain = gain * ((radius - dis) / radius);
183
184 sp.ControllingClient.SendTriggeredSound(soundId, ownerID, 209 sp.ControllingClient.SendTriggeredSound(soundId, ownerID,
185 objectID, parentID, handle, position, 210 objectID, parentID, handle, position,
186 (float)thisSpGain); 211 (float)gain);
187 }); 212 });
188 } 213 }
189 214
@@ -198,40 +223,13 @@ namespace OpenSim.Region.CoreModules.World.Sound
198 223
199 private static void StopSound(SceneObjectPart m_host) 224 private static void StopSound(SceneObjectPart m_host)
200 { 225 {
201 m_host.AdjustSoundGain(0); 226// m_host.AdjustSoundGain(0);
202 // Xantor 20080528: Clear prim data of sound instead 227 m_host.Sound = UUID.Zero;
203 if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) 228 m_host.SoundFlags = (byte)SoundFlags.STOP;
204 { 229 m_host.SoundRadius = 0;
205 if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) 230 m_host.SoundGain = 0;
206 { 231 m_host.ScheduleFullUpdate();
207 foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims) 232 m_host.SendFullUpdateToAllClients();
208 {
209 part.Sound = UUID.Zero;
210 part.SoundFlags = 1 << 5;
211 part.SoundRadius = 0;
212 part.ScheduleFullUpdate();
213 part.SendFullUpdateToAllClients();
214 }
215 m_host.ParentGroup.LoopSoundMasterPrim = null;
216 m_host.ParentGroup.LoopSoundSlavePrims.Clear();
217 }
218 else
219 {
220 m_host.Sound = UUID.Zero;
221 m_host.SoundFlags = 1 << 5;
222 m_host.SoundRadius = 0;
223 m_host.ScheduleFullUpdate();
224 m_host.SendFullUpdateToAllClients();
225 }
226 }
227 else
228 {
229 m_host.Sound = UUID.Zero;
230 m_host.SoundFlags = 1 << 5;
231 m_host.SoundRadius = 0;
232 m_host.ScheduleFullUpdate();
233 m_host.SendFullUpdateToAllClients();
234 }
235 } 233 }
236 234
237 public virtual void PreloadSound(UUID objectID, UUID soundID, float radius) 235 public virtual void PreloadSound(UUID objectID, UUID soundID, float radius)
@@ -248,7 +246,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
248 246
249 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 247 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
250 { 248 {
251 if (!(Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) >= MaxDistance)) 249 if (Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) < radius)
252 sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); 250 sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
253 }); 251 });
254 } 252 }
@@ -262,21 +260,24 @@ namespace OpenSim.Region.CoreModules.World.Sound
262 // 20080530 Updated to remove code duplication 260 // 20080530 Updated to remove code duplication
263 // 20080530 Stop sound if there is one, otherwise volume only changes don't work 261 // 20080530 Stop sound if there is one, otherwise volume only changes don't work
264 public void LoopSound(UUID objectID, UUID soundID, 262 public void LoopSound(UUID objectID, UUID soundID,
265 double volume, double radius, bool isMaster) 263 double volume, double radius, bool isMaster, bool isSlave)
266 { 264 {
267 SceneObjectPart m_host; 265 SceneObjectPart m_host;
268 if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) 266 if (!m_scene.TryGetSceneObjectPart(objectID, out m_host))
269 return; 267 return;
270 268
269 byte iflags = 1; // looping
271 if (isMaster) 270 if (isMaster)
272 m_host.ParentGroup.LoopSoundMasterPrim = m_host; 271 iflags |= (byte)SoundFlags.SYNC_MASTER;
273 272 // TODO check viewer seems to accept both
274 if (m_host.Sound != UUID.Zero) 273 if (isSlave)
275 StopSound(m_host); 274 iflags |= (byte)SoundFlags.SYNC_SLAVE;
275 if (m_host.SoundQueueing)
276 iflags |= (byte)SoundFlags.QUEUE;
276 277
277 m_host.Sound = soundID; 278 m_host.Sound = soundID;
278 m_host.SoundGain = volume; 279 m_host.SoundGain = volume;
279 m_host.SoundFlags = 1; // looping 280 m_host.SoundFlags = iflags;
280 m_host.SoundRadius = radius; 281 m_host.SoundRadius = radius;
281 282
282 m_host.ScheduleFullUpdate(); 283 m_host.ScheduleFullUpdate();
@@ -301,42 +302,19 @@ namespace OpenSim.Region.CoreModules.World.Sound
301 Vector3 position = part.AbsolutePosition; // region local 302 Vector3 position = part.AbsolutePosition; // region local
302 ulong regionHandle = m_scene.RegionInfo.RegionHandle; 303 ulong regionHandle = m_scene.RegionInfo.RegionHandle;
303 304
304 if (useMaster) 305 if(triggered)
305 { 306 TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
306 if (isMaster)
307 {
308 if (triggered)
309 TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
310 else
311 PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius);
312 part.ParentGroup.PlaySoundMasterPrim = part;
313 if (triggered)
314 TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
315 else
316 PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius);
317 foreach (SceneObjectPart prim in part.ParentGroup.PlaySoundSlavePrims)
318 {
319 position = prim.AbsolutePosition; // region local
320 if (triggered)
321 TriggerSound(soundID, part.OwnerID, prim.UUID, parentID, volume, position, regionHandle, radius);
322 else
323 PlayAttachedSound(soundID, part.OwnerID, prim.UUID, volume, position, flags, radius);
324 }
325 part.ParentGroup.PlaySoundSlavePrims.Clear();
326 part.ParentGroup.PlaySoundMasterPrim = null;
327 }
328 else
329 {
330 part.ParentGroup.PlaySoundSlavePrims.Add(part);
331 }
332 }
333 else 307 else
334 { 308 {
335 if (triggered) 309 byte bflags = 0;
336 TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); 310
337 else 311 if (isMaster)
338 PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); 312 bflags |= (byte)SoundFlags.SYNC_MASTER;
339 } 313 // TODO check viewer seems to accept both
314 if (useMaster)
315 bflags |= (byte)SoundFlags.SYNC_SLAVE;
316 PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, bflags, radius);
317 }
340 } 318 }
341 319
342 public void TriggerSoundLimited(UUID objectID, UUID sound, 320 public void TriggerSoundLimited(UUID objectID, UUID sound,
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs
index 36917e9..b456aa1 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
64 64
65 for (int i = 0; i < rounds; i++) 65 for (int i = 0; i < rounds; i++)
66 { 66 {
67 smoothFunction.FloodEffect(map, bitmap, 1.0); 67 smoothFunction.FloodEffect(map, bitmap, 1.0, 0, map.Width - 1, 0, map.Height - 1);
68 } 68 }
69 } 69 }
70 70
@@ -99,7 +99,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
99 } 99 }
100 } 100 }
101 101
102 raiseFunction.FloodEffect(map, bitmap, height); 102 raiseFunction.FloodEffect(map, bitmap, height, 0, map.Width - 1, 0, map.Height - 1);
103 } 103 }
104 } 104 }
105 } 105 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs
index dc76ad5..3222524 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
84 for (y = 0; y < map.Height; y++) 84 for (y = 0; y < map.Height; y++)
85 { 85 {
86 if (cliffMask[x, y]) 86 if (cliffMask[x, y])
87 eroder.PaintEffect(map, allowMask, x, y, -1, 4, 0.1); 87 eroder.PaintEffect(map, allowMask, x, y, -1, 4, 0.1,0,map.Width - 1,0,map.Height - 1);
88 } 88 }
89 } 89 }
90 90
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
index 89087b1..80396c4 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
@@ -53,4 +53,4 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
53 53
54 #endregion 54 #endregion
55 } 55 }
56} \ No newline at end of file 56}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs
index 774e7b2..0c4171e 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs
@@ -33,15 +33,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
37 int startX, int endX, int startY, int endY)
37 { 38 {
38 double sum = 0.0; 39 double sum = 0.0;
39 double steps = 0.0; 40 double steps = 0.0;
40 41
41 int x, y; 42 int x, y;
42 for (x = 0; x < map.Width; x++) 43 for (x = startX; x <= endX; x++)
43 { 44 {
44 for (y = 0; y < map.Height; y++) 45 for (y = startY; y <= endY; y++)
45 { 46 {
46 if (fillArea[x, y]) 47 if (fillArea[x, y])
47 { 48 {
@@ -55,9 +56,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
55 56
56 double str = 0.1 * strength; // == 0.2 in the default client 57 double str = 0.1 * strength; // == 0.2 in the default client
57 58
58 for (x = 0; x < map.Width; x++) 59 for (x = startX; x <= endX; x++)
59 { 60 {
60 for (y = 0; y < map.Height; y++) 61 for (y = startY; y <= endY; y++)
61 { 62 {
62 if (fillArea[x, y]) 63 if (fillArea[x, y])
63 map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str); 64 map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str);
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs
index 3e87390..a275a86 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs
@@ -33,13 +33,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
37 int startX, int endX, int startY, int endY)
37 { 38 {
38 int x; 39 int x,y;
39 for (x = 0; x < map.Width; x++) 40 for (x = startX; x <= endX; x++)
40 { 41 {
41 int y; 42 for (y = startY; y <= endY; y++)
42 for (y = 0; y < map.Height; y++)
43 { 43 {
44 if (fillArea[x, y]) 44 if (fillArea[x, y])
45 { 45 {
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
index b6c635c..236584a 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
@@ -35,18 +35,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
35 { 35 {
36 #region ITerrainFloodEffect Members 36 #region ITerrainFloodEffect Members
37 37
38 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 38 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
39 int startX, int endX, int startY, int endY)
39 { 40 {
40 int x; 41 int x, y;
41 for (x = 0; x < map.Width; x++) 42 for (x = startX; x <= endX; x++)
42 { 43 {
43 int y; 44 for (y = startY; y <= endY; y++)
44 for (y = 0; y < map.Height; y++)
45 { 45 {
46 if (fillArea[x, y]) 46 if (fillArea[x, y])
47 { 47 {
48 double noise = TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0); 48 double noise = TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0);
49<<<<<<< HEAD
49 50
51=======
52>>>>>>> avn/ubitvar
50 map[x, y] += noise * strength; 53 map[x, y] += noise * strength;
51 } 54 }
52 } 55 }
@@ -55,4 +58,4 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
55 58
56 #endregion 59 #endregion
57 } 60 }
58} \ No newline at end of file 61}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs
index 3bdc5e7..6ccd5df 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs
@@ -33,13 +33,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
37 int startX, int endX, int startY, int endY)
37 { 38 {
38 int x; 39 int x,y;
39 for (x = 0; x < map.Width; x++) 40 for (x = startX; x <= endX; x++)
40 { 41 {
41 int y; 42 for (y = startY; y <= endY; y++)
42 for (y = 0; y < map.Height; y++)
43 { 43 {
44 if (fillArea[x, y]) 44 if (fillArea[x, y])
45 { 45 {
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs
index c5527fa..4230133 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs
@@ -46,13 +46,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
46 /// <param name="map">the current heightmap</param> 46 /// <param name="map">the current heightmap</param>
47 /// <param name="fillArea">array indicating which sections of the map are to be reverted</param> 47 /// <param name="fillArea">array indicating which sections of the map are to be reverted</param>
48 /// <param name="strength">unused</param> 48 /// <param name="strength">unused</param>
49 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 49 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
50 int startX, int endX, int startY, int endY)
50 { 51 {
51 int x; 52 int x, y;
52 for (x = 0; x < map.Width; x++) 53 for (x = startX; x <= endX; x++)
53 { 54 {
54 int y; 55 for (y = startY; y <= endY; y++)
55 for (y = 0; y < map.Height; y++)
56 { 56 {
57 if (fillArea[x, y]) 57 if (fillArea[x, y])
58 { 58 {
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs
index 6b07747..6c0d60d 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs
@@ -33,16 +33,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
37 int startX, int endX, int startY, int endY)
37 { 38 {
38 double area = strength; 39 double area = strength;
39 double step = strength / 4.0; 40 double step = strength / 4.0;
40 41
41 double[,] manipulate = new double[map.Width,map.Height]; 42 double[,] manipulate = new double[map.Width,map.Height];
42 int x, y; 43 int x, y;
43 for (x = 0; x < map.Width; x++) 44 for (x = startX; x <= endX; x++)
44 { 45 {
45 for (y = 0; y < map.Height; y++) 46 for (y = startY; y <= endY; y++)
46 { 47 {
47 if (!fillArea[x, y]) 48 if (!fillArea[x, y])
48 continue; 49 continue;
@@ -64,9 +65,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
64 manipulate[x, y] = average / avgsteps; 65 manipulate[x, y] = average / avgsteps;
65 } 66 }
66 } 67 }
67 for (x = 0; x < map.Width; x++) 68 for (x = startX; x <= endX; x++)
68 { 69 {
69 for (y = 0; y < map.Height; y++) 70 for (y = startY; y <= endY; y++)
70 { 71 {
71 if (!fillArea[x, y]) 72 if (!fillArea[x, y])
72 continue; 73 continue;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs
index 3984a30..6324aca 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs
@@ -32,6 +32,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
32{ 32{
33 public interface ITerrainFloodEffect 33 public interface ITerrainFloodEffect
34 { 34 {
35 void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength); 35 void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength,
36 int startX, int endX, int startY, int endY);
36 } 37 }
37} \ No newline at end of file 38} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs
index b73defd..d0b05e4 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs
@@ -31,6 +31,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
31{ 31{
32 public interface ITerrainPaintableEffect 32 public interface ITerrainPaintableEffect
33 { 33 {
34 void PaintEffect(ITerrainChannel map, bool[,] allowMask, double x, double y, double z, double strength, double duration); 34 void PaintEffect(ITerrainChannel map, bool[,] allowMask, double x, double y, double z,
35 double strength, double duration, int startX, int endX, int startY, int endY);
35 } 36 }
36} 37}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs
index 7a78cd8..7358ba3 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs
@@ -151,7 +151,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
151 151
152 #region ITerrainPaintableEffect Members 152 #region ITerrainPaintableEffect Members
153 153
154 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 154 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
155 double strength, double duration, int startX, int endX, int startY, int endY)
155 { 156 {
156 strength = TerrainUtil.MetersToSphericalStrength(strength); 157 strength = TerrainUtil.MetersToSphericalStrength(strength);
157 158
@@ -163,18 +164,23 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
163 ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height); 164 ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height);
164 165
165 // Fill with rain 166 // Fill with rain
166 for (x = 0; x < water.Width; x++) 167 for (x = startX; x <= endX; x++)
167 for (y = 0; y < water.Height; y++) 168 {
168 water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration); 169 for (y = startY; y <= endY; y++)
170 {
171 if (mask[x, y])
172 water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration);
173 }
174 }
169 175
170 for (int i = 0; i < rounds; i++) 176 for (int i = 0; i < rounds; i++)
171 { 177 {
172 // Erode underlying terrain 178 // Erode underlying terrain
173 for (x = 0; x < water.Width; x++) 179 for (x = startX; x <= endX; x++)
174 { 180 {
175 for (y = 0; y < water.Height; y++) 181 for (y = startY; y <= endY; y++)
176 { 182 {
177 if (mask[x,y]) 183 if (mask[x, y])
178 { 184 {
179 const double solConst = (1.0 / rounds); 185 const double solConst = (1.0 / rounds);
180 double sedDelta = water[x, y] * solConst; 186 double sedDelta = water[x, y] * solConst;
@@ -185,9 +191,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
185 } 191 }
186 192
187 // Move water 193 // Move water
188 for (x = 0; x < water.Width; x++) 194 for (x = startX; x <= endX; x++)
189 { 195 {
190 for (y = 0; y < water.Height; y++) 196 for (y = startY; y <= endY; y++)
191 { 197 {
192 if (water[x, y] <= 0) 198 if (water[x, y] <= 0)
193 continue; 199 continue;
@@ -296,7 +302,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
296 double sedimentDeposit = sediment[x, y] - waterCapacity; 302 double sedimentDeposit = sediment[x, y] - waterCapacity;
297 if (sedimentDeposit > 0) 303 if (sedimentDeposit > 0)
298 { 304 {
299 if (mask[x,y]) 305 if (mask[x, y])
300 { 306 {
301 sediment[x, y] -= sedimentDeposit; 307 sediment[x, y] -= sedimentDeposit;
302 map[x, y] += sedimentDeposit; 308 map[x, y] += sedimentDeposit;
@@ -309,10 +315,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
309 // Deposit any remainder (should be minimal) 315 // Deposit any remainder (should be minimal)
310 for (x = 0; x < water.Width; x++) 316 for (x = 0; x < water.Width; x++)
311 for (y = 0; y < water.Height; y++) 317 for (y = 0; y < water.Height; y++)
312 if (mask[x,y] && sediment[x, y] > 0) 318 if (mask[x, y] && sediment[x, y] > 0)
313 map[x, y] += sediment[x, y]; 319 map[x, y] += sediment[x, y];
314 } 320 }
315
316 #endregion 321 #endregion
317 } 322 }
318} 323}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs
index 9aa3dff..8937f63 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs
@@ -35,16 +35,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
35 { 35 {
36 #region ITerrainPaintableEffect Members 36 #region ITerrainPaintableEffect Members
37 37
38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
39 double strength, double duration, int startX, int endX, int startY, int endY)
39 { 40 {
40 strength = TerrainUtil.MetersToSphericalStrength(strength); 41 strength = TerrainUtil.MetersToSphericalStrength(strength);
41 42
42 int x, y; 43 int x, y;
43 44
44 // blend in map 45 // blend in map
45 for (x = 0; x < map.Width; x++) 46 for (x = startX; x <= endX; x++)
46 { 47 {
47 for (y = 0; y < map.Height; y++) 48 for (y = startY; y <= endY; y++)
48 { 49 {
49 if (!mask[x,y]) 50 if (!mask[x,y])
50 continue; 51 continue;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs
index 68145f2..bbf9407 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs
@@ -34,34 +34,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
34 { 34 {
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
38 double strength, double duration, int startX, int endX, int startY, int endY)
38 { 39 {
39 int s = (int) (Math.Pow(2, strength) + 0.5); 40 int s = (int) (Math.Pow(2, strength) + 0.5);
40 41
41 int x; 42 int x, y;
42 int xFrom = (int)(rx-s+0.5);
43 int xTo = (int)(rx+s+0.5) + 1;
44 int yFrom = (int)(ry-s+0.5);
45 int yTo = (int)(ry+s+0.5) + 1;
46 43
47 if (xFrom < 0) 44 for (x = startX; x <= endX; x++)
48 xFrom = 0;
49
50 if (yFrom < 0)
51 yFrom = 0;
52
53 if (xTo > map.Width)
54 xTo = map.Width;
55
56 if (yTo > map.Width)
57 yTo = map.Width;
58
59 for (x = xFrom; x < xTo; x++)
60 { 45 {
61 int y; 46 for (y = startY; y <= endY; y++)
62 for (y = yFrom; y < yTo; y++)
63 { 47 {
64 if (!mask[x,y]) 48 if (!mask[x, y])
65 continue; 49 continue;
66 50
67 // Calculate a cos-sphere and add it to the heighmap 51 // Calculate a cos-sphere and add it to the heighmap
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
index e7df3f8..46d47b4 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
@@ -35,17 +35,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
35 { 35 {
36 #region ITerrainPaintableEffect Members 36 #region ITerrainPaintableEffect Members
37 37
38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
39 double strength, double duration, int startX, int endX, int startY, int endY)
39 { 40 {
40 strength = TerrainUtil.MetersToSphericalStrength(strength); 41 strength = TerrainUtil.MetersToSphericalStrength(strength);
41 42
42 int x; 43 int x, y;
43 for (x = 0; x < map.Width; x++) 44
45 for (x = startX; x <= endX; x++)
44 { 46 {
45 int y; 47 for (y = startY; y <= endY; y++)
46 for (y = 0; y < map.Height; y++)
47 { 48 {
48 if (!mask[x,y]) 49 if (!mask[x, y])
49 continue; 50 continue;
50 51
51 // Calculate a sphere and add it to the heighmap 52 // Calculate a sphere and add it to the heighmap
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs
index b199df3..281690d 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs
@@ -152,18 +152,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
152 152
153 #region ITerrainPaintableEffect Members 153 #region ITerrainPaintableEffect Members
154 154
155 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 155 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
156 double strength, double duration, int startX, int endX, int startY, int endY)
156 { 157 {
157 strength = TerrainUtil.MetersToSphericalStrength(strength); 158 strength = TerrainUtil.MetersToSphericalStrength(strength);
158 159
159 int x; 160 int x, y;
160 161
161 for (x = 0; x < map.Width; x++) 162 for (x = startX; x <= endX; x++)
162 { 163 {
163 int y; 164 for (y = startY; y <= endY; y++)
164 for (y = 0; y < map.Height; y++)
165 { 165 {
166 if (!mask[x,y]) 166 if (!mask[x, y])
167 continue; 167 continue;
168 168
169 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 169 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs
index bd9a8a0..1b704bb 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs
@@ -35,38 +35,22 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 37
38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
39 double strength, double duration, int startX, int endX, int startY, int endY)
39 { 40 {
40 int s = (int) (Math.Pow(2, strength) + 0.5); 41 int s = (int) (Math.Pow(2, strength) + 0.5);
41 42
42 int x; 43 int x,y;
43 int xFrom = (int)(rx-s+0.5);
44 int xTo = (int)(rx+s+0.5) + 1;
45 int yFrom = (int)(ry-s+0.5);
46 int yTo = (int)(ry+s+0.5) + 1;
47 44
48 if (xFrom < 0) 45 for (x = startX; x <= endX; x++)
49 xFrom = 0;
50
51 if (yFrom < 0)
52 yFrom = 0;
53
54 if (xTo > map.Width)
55 xTo = map.Width;
56
57 if (yTo > map.Width)
58 yTo = map.Width;
59
60 for (x = xFrom; x < xTo; x++)
61 { 46 {
62 int y; 47 for (y = startY; y <= endY; y++)
63 for (y = yFrom; y < yTo; y++)
64 { 48 {
65 if (!mask[x,y]) 49 if (!mask[x, y])
66 continue; 50 continue;
67 51
68 // Calculate a cos-sphere and add it to the heighmap 52 // Calculate a cos-sphere and add it to the heighmap
69 double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry))); 53 double r = Math.Sqrt((x - rx) * (x - rx) + ((y - ry) * (y - ry)));
70 double z = Math.Cos(r * Math.PI / (s * 2)); 54 double z = Math.Cos(r * Math.PI / (s * 2));
71 if (z > 0.0) 55 if (z > 0.0)
72 map[x, y] += z * duration; 56 map[x, y] += z * duration;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs
index 4b28275..efc5324 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs
@@ -41,7 +41,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
41 41
42 #region ITerrainPaintableEffect Members 42 #region ITerrainPaintableEffect Members
43 43
44 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 44 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
45 double strength, double duration, int startX, int endX, int startY, int endY)
45 { 46 {
46 strength = TerrainUtil.MetersToSphericalStrength(strength); 47 strength = TerrainUtil.MetersToSphericalStrength(strength);
47 duration = 0.03; //MCP Should be read from ini file 48 duration = 0.03; //MCP Should be read from ini file
@@ -51,13 +52,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
51 if (duration < 0) 52 if (duration < 0)
52 return; 53 return;
53 54
54 int x; 55 int x,y;
55 for (x = 0; x < map.Width; x++) 56 for (x = startX; x <= endX; x++)
56 { 57 {
57 int y; 58 for (y = startY; y <= endY; y++)
58 for (y = 0; y < map.Height; y++)
59 { 59 {
60 if (!mask[x,y]) 60 if (!mask[x, y])
61 continue; 61 continue;
62 62
63 // Calculate a sphere and add it to the heighmap 63 // Calculate a sphere and add it to the heighmap
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs
index 4834c86..65dd0a6 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs
@@ -34,7 +34,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
34 { 34 {
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
38 double strength, double duration, int startX, int endX, int startY, int endY)
38 { 39 {
39 strength = TerrainUtil.MetersToSphericalStrength(strength); 40 strength = TerrainUtil.MetersToSphericalStrength(strength);
40 41
@@ -47,10 +48,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
47 48
48 49
49 // compute delta map 50 // compute delta map
50 for (x = 0; x < map.Width; x++) 51 for (x = startX; x <= endX; x++)
51 { 52 {
52 for (y = 0; y < map.Height; y++) 53 for (y = startY; y <= endY; y++)
53 { 54 {
55 if (!mask[x, y])
56 continue;
57
54 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 58 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
55 59
56 if (z > 0) // add in non-zero amount 60 if (z > 0) // add in non-zero amount
@@ -73,11 +77,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
73 } 77 }
74 } 78 }
75 // blend in map 79 // blend in map
76 for (x = 0; x < map.Width; x++) 80 for (x = startX; x <= endX; x++)
77 { 81 {
78 for (y = 0; y < map.Height; y++) 82 for (y = startY; y <= endY; y++)
79 { 83 {
80 if (!mask[x,y]) 84 if (!mask[x, y])
81 continue; 85 continue;
82 86
83 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 87 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs
index f31c8b6..f52fe07 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs
@@ -148,16 +148,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
148 148
149 #region ITerrainPaintableEffect Members 149 #region ITerrainPaintableEffect Members
150 150
151 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 151 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
152 double strength, double duration, int startX, int endX, int startY, int endY)
152 { 153 {
153 strength = TerrainUtil.MetersToSphericalStrength(strength); 154 strength = TerrainUtil.MetersToSphericalStrength(strength);
154 155
155 int x; 156 int x,y;
156 157
157 for (x = 0; x < map.Width; x++) 158 for (x = startX; x <= endX; x++)
158 { 159 {
159 int y; 160 for (y = startY; y <= endY; y++)
160 for (y = 0; y < map.Height; y++)
161 { 161 {
162 if (!mask[x,y]) 162 if (!mask[x,y])
163 continue; 163 continue;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 932652c..925de2a 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -75,6 +75,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
75 #endregion 75 #endregion
76 76
77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
78<<<<<<< HEAD
79=======
80
81#pragma warning disable 414
82 private static readonly string LogHeader = "[TERRAIN MODULE]";
83#pragma warning restore 414
84
85 private readonly Commander m_commander = new Commander("terrain");
86>>>>>>> avn/ubitvar
78 87
79#pragma warning disable 414 88#pragma warning disable 414
80 private static readonly string LogHeader = "[TERRAIN MODULE]"; 89 private static readonly string LogHeader = "[TERRAIN MODULE]";
@@ -86,6 +95,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
86 private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>(); 95 private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>();
87 private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = 96 private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects =
88 new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); 97 new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>();
98<<<<<<< HEAD
89 private Dictionary<string, ITerrainEffect> m_plugineffects; 99 private Dictionary<string, ITerrainEffect> m_plugineffects;
90 private Dictionary<string, ITerrainModifier> m_modifyOperations = 100 private Dictionary<string, ITerrainModifier> m_modifyOperations =
91 new Dictionary<string, ITerrainModifier>(); 101 new Dictionary<string, ITerrainModifier>();
@@ -94,6 +104,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
94 private Scene m_scene; 104 private Scene m_scene;
95 private volatile bool m_tainted; 105 private volatile bool m_tainted;
96 private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5); 106 private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5);
107=======
108
109 private Dictionary<string, ITerrainEffect> m_plugineffects;
110 private ITerrainChannel m_channel;
111 private ITerrainChannel m_baked;
112 private Scene m_scene;
113 private volatile bool m_tainted;
114
115>>>>>>> avn/ubitvar
97 private String m_InitialTerrain = "pinhead-island"; 116 private String m_InitialTerrain = "pinhead-island";
98 117
99 // If true, send terrain patch updates to clients based on their view distance 118 // If true, send terrain patch updates to clients based on their view distance
@@ -107,13 +126,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain
107 private bool[,] updated; // for each patch, whether it needs to be sent to this client 126 private bool[,] updated; // for each patch, whether it needs to be sent to this client
108 private int updateCount; // number of patches that need to be sent 127 private int updateCount; // number of patches that need to be sent
109 public ScenePresence Presence; // a reference to the client to send to 128 public ScenePresence Presence; // a reference to the client to send to
129<<<<<<< HEAD
110 public TerrainData Terrain; // reference to the underlying terrain 130 public TerrainData Terrain; // reference to the underlying terrain
131=======
132>>>>>>> avn/ubitvar
111 public PatchUpdates(TerrainData terrData, ScenePresence pPresence) 133 public PatchUpdates(TerrainData terrData, ScenePresence pPresence)
112 { 134 {
113 updated = new bool[terrData.SizeX / Constants.TerrainPatchSize, terrData.SizeY / Constants.TerrainPatchSize]; 135 updated = new bool[terrData.SizeX / Constants.TerrainPatchSize, terrData.SizeY / Constants.TerrainPatchSize];
114 updateCount = 0; 136 updateCount = 0;
115 Presence = pPresence; 137 Presence = pPresence;
138<<<<<<< HEAD
116 Terrain = terrData; 139 Terrain = terrData;
140=======
141>>>>>>> avn/ubitvar
117 // Initially, send all patches to the client 142 // Initially, send all patches to the client
118 SetAll(true); 143 SetAll(true);
119 } 144 }
@@ -122,17 +147,26 @@ namespace OpenSim.Region.CoreModules.World.Terrain
122 { 147 {
123 return (updateCount > 0); 148 return (updateCount > 0);
124 } 149 }
150<<<<<<< HEAD
125 151
152=======
153>>>>>>> avn/ubitvar
126 public void SetByXY(int x, int y, bool state) 154 public void SetByXY(int x, int y, bool state)
127 { 155 {
128 this.SetByPatch(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, state); 156 this.SetByPatch(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, state);
129 } 157 }
158<<<<<<< HEAD
130 159
160=======
161>>>>>>> avn/ubitvar
131 public bool GetByPatch(int patchX, int patchY) 162 public bool GetByPatch(int patchX, int patchY)
132 { 163 {
133 return updated[patchX, patchY]; 164 return updated[patchX, patchY];
134 } 165 }
166<<<<<<< HEAD
135 167
168=======
169>>>>>>> avn/ubitvar
136 public void SetByPatch(int patchX, int patchY, bool state) 170 public void SetByPatch(int patchX, int patchY, bool state)
137 { 171 {
138 bool prevState = updated[patchX, patchY]; 172 bool prevState = updated[patchX, patchY];
@@ -142,12 +176,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain
142 updateCount--; 176 updateCount--;
143 updated[patchX, patchY] = state; 177 updated[patchX, patchY] = state;
144 } 178 }
179<<<<<<< HEAD
145 180
146 public void SetAll(bool state) 181 public void SetAll(bool state)
147 { 182 {
148 updateCount = 0; 183 updateCount = 0;
149 for(int xx = 0; xx < updated.GetLength(0); xx++) 184 for(int xx = 0; xx < updated.GetLength(0); xx++)
150 for(int yy = 0; yy < updated.GetLength(1); yy++) 185 for(int yy = 0; yy < updated.GetLength(1); yy++)
186=======
187 public void SetAll(bool state)
188 {
189 updateCount = 0;
190 for (int xx = 0; xx < updated.GetLength(0); xx++)
191 for (int yy = 0; yy < updated.GetLength(1); yy++)
192>>>>>>> avn/ubitvar
151 updated[xx, yy] = state; 193 updated[xx, yy] = state;
152 if (state) 194 if (state)
153 updateCount = updated.GetLength(0) * updated.GetLength(1); 195 updateCount = updated.GetLength(0) * updated.GetLength(1);
@@ -164,9 +206,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
164 terrData.SizeX / Constants.TerrainPatchSize, terrData.SizeY / Constants.TerrainPatchSize) 206 terrData.SizeX / Constants.TerrainPatchSize, terrData.SizeY / Constants.TerrainPatchSize)
165 ); 207 );
166 } 208 }
209<<<<<<< HEAD
167 for(int xx = 0; xx < terrData.SizeX; xx += Constants.TerrainPatchSize) 210 for(int xx = 0; xx < terrData.SizeX; xx += Constants.TerrainPatchSize)
168 { 211 {
169 for(int yy = 0; yy < terrData.SizeY; yy += Constants.TerrainPatchSize) 212 for(int yy = 0; yy < terrData.SizeY; yy += Constants.TerrainPatchSize)
213=======
214 for (int xx = 0; xx < terrData.SizeX; xx += Constants.TerrainPatchSize)
215 {
216 for (int yy = 0; yy < terrData.SizeY; yy += Constants.TerrainPatchSize)
217>>>>>>> avn/ubitvar
170 { 218 {
171 // Only set tainted. The patch bit may be set if the patch was to be sent later. 219 // Only set tainted. The patch bit may be set if the patch was to be sent later.
172 if (terrData.IsTaintedAt(xx, yy, false)) 220 if (terrData.IsTaintedAt(xx, yy, false))
@@ -227,12 +275,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain
227 (int)m_scene.RegionInfo.RegionSizeY, 275 (int)m_scene.RegionInfo.RegionSizeY,
228 (int)m_scene.RegionInfo.RegionSizeZ); 276 (int)m_scene.RegionInfo.RegionSizeZ);
229 m_scene.Heightmap = m_channel; 277 m_scene.Heightmap = m_channel;
278<<<<<<< HEAD
230 UpdateRevertMap(); 279 UpdateRevertMap();
280=======
281 UpdateBakedMap();
282>>>>>>> avn/ubitvar
231 } 283 }
232 else 284 else
233 { 285 {
234 m_channel = m_scene.Heightmap; 286 m_channel = m_scene.Heightmap;
287<<<<<<< HEAD
235 UpdateRevertMap(); 288 UpdateRevertMap();
289=======
290 UpdateBakedMap();
291>>>>>>> avn/ubitvar
236 } 292 }
237 293
238 m_scene.RegisterModuleInterface<ITerrainModule>(this); 294 m_scene.RegisterModuleInterface<ITerrainModule>(this);
@@ -240,7 +296,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
240 m_scene.EventManager.OnClientClosed += EventManager_OnClientClosed; 296 m_scene.EventManager.OnClientClosed += EventManager_OnClientClosed;
241 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; 297 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
242 m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick; 298 m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
299<<<<<<< HEAD
243 m_scene.EventManager.OnFrame += EventManager_OnFrame; 300 m_scene.EventManager.OnFrame += EventManager_OnFrame;
301=======
302 m_scene.EventManager.OnTerrainCheckUpdates += EventManager_TerrainCheckUpdates;
303>>>>>>> avn/ubitvar
244 } 304 }
245 305
246 InstallDefaultEffects(); 306 InstallDefaultEffects();
@@ -279,7 +339,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
279 // remove the commands 339 // remove the commands
280 m_scene.UnregisterModuleCommander(m_commander.Name); 340 m_scene.UnregisterModuleCommander(m_commander.Name);
281 // remove the event-handlers 341 // remove the event-handlers
342<<<<<<< HEAD
282 m_scene.EventManager.OnFrame -= EventManager_OnFrame; 343 m_scene.EventManager.OnFrame -= EventManager_OnFrame;
344=======
345 m_scene.EventManager.OnTerrainCheckUpdates -= EventManager_TerrainCheckUpdates;
346>>>>>>> avn/ubitvar
283 m_scene.EventManager.OnTerrainTick -= EventManager_OnTerrainTick; 347 m_scene.EventManager.OnTerrainTick -= EventManager_OnTerrainTick;
284 m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole; 348 m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole;
285 m_scene.EventManager.OnClientClosed -= EventManager_OnClientClosed; 349 m_scene.EventManager.OnClientClosed -= EventManager_OnClientClosed;
@@ -334,7 +398,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
334 m_log.DebugFormat("[TERRAIN]: Loaded terrain, wd/ht: {0}/{1}", channel.Width, channel.Height); 398 m_log.DebugFormat("[TERRAIN]: Loaded terrain, wd/ht: {0}/{1}", channel.Width, channel.Height);
335 m_scene.Heightmap = channel; 399 m_scene.Heightmap = channel;
336 m_channel = channel; 400 m_channel = channel;
337 UpdateRevertMap(); 401 UpdateBakedMap();
338 } 402 }
339 catch(NotImplementedException) 403 catch(NotImplementedException)
340 { 404 {
@@ -426,7 +490,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
426 { 490 {
427 ITerrainChannel channel = loader.Value.LoadStream(stream); 491 ITerrainChannel channel = loader.Value.LoadStream(stream);
428 m_channel.Merge(channel, displacement, radianRotation, rotationDisplacement); 492 m_channel.Merge(channel, displacement, radianRotation, rotationDisplacement);
493<<<<<<< HEAD
429 UpdateRevertMap(); 494 UpdateRevertMap();
495=======
496 UpdateBakedMap();
497>>>>>>> avn/ubitvar
430 } 498 }
431 catch(NotImplementedException) 499 catch(NotImplementedException)
432 { 500 {
@@ -506,16 +574,48 @@ namespace OpenSim.Region.CoreModules.World.Terrain
506 574
507 // Someone diddled terrain outside the normal code paths. Set the taintedness for all clients. 575 // Someone diddled terrain outside the normal code paths. Set the taintedness for all clients.
508 // ITerrainModule.TaintTerrain() 576 // ITerrainModule.TaintTerrain()
577<<<<<<< HEAD
509 public void TaintTerrain() 578 public void TaintTerrain()
510 { 579 {
511 lock(m_perClientPatchUpdates) 580 lock(m_perClientPatchUpdates)
512 { 581 {
513 // Set the flags for all clients so the tainted patches will be sent out 582 // Set the flags for all clients so the tainted patches will be sent out
514 foreach(PatchUpdates pups in m_perClientPatchUpdates.Values) 583 foreach(PatchUpdates pups in m_perClientPatchUpdates.Values)
584=======
585 public void TaintTerrain ()
586 {
587 lock (m_perClientPatchUpdates)
588 {
589 // Set the flags for all clients so the tainted patches will be sent out
590 foreach (PatchUpdates pups in m_perClientPatchUpdates.Values)
591>>>>>>> avn/ubitvar
515 { 592 {
516 pups.SetAll(m_scene.Heightmap.GetTerrainData()); 593 pups.SetAll(m_scene.Heightmap.GetTerrainData());
517 } 594 }
518 } 595 }
596<<<<<<< HEAD
597=======
598 }
599
600 // ITerrainModule.PushTerrain()
601 public void PushTerrain(IClientAPI pClient)
602 {
603 ScenePresence presence = m_scene.GetScenePresence(pClient.AgentId);
604 if (presence != null)
605 {
606 lock (m_perClientPatchUpdates)
607 {
608 PatchUpdates pups;
609 if (!m_perClientPatchUpdates.TryGetValue(pClient.AgentId, out pups))
610 {
611 // There is a ScenePresence without a send patch map. Create one.
612 pups = new PatchUpdates(m_scene.Heightmap.GetTerrainData(), presence);
613 m_perClientPatchUpdates.Add(presence.UUID, pups);
614 }
615 pups.SetAll(true);
616 }
617 }
618>>>>>>> avn/ubitvar
519 } 619 }
520 620
521 // ITerrainModule.PushTerrain() 621 // ITerrainModule.PushTerrain()
@@ -636,7 +736,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
636 m_painteffects[StandardTerrainEffects.Smooth] = new SmoothSphere(); 736 m_painteffects[StandardTerrainEffects.Smooth] = new SmoothSphere();
637 m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere(); 737 m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere();
638 m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere(); 738 m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere();
639 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_revert); 739 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked);
640 m_painteffects[StandardTerrainEffects.Erode] = new ErodeSphere(); 740 m_painteffects[StandardTerrainEffects.Erode] = new ErodeSphere();
641 m_painteffects[StandardTerrainEffects.Weather] = new WeatherSphere(); 741 m_painteffects[StandardTerrainEffects.Weather] = new WeatherSphere();
642 m_painteffects[StandardTerrainEffects.Olsen] = new OlsenSphere(); 742 m_painteffects[StandardTerrainEffects.Olsen] = new OlsenSphere();
@@ -647,7 +747,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
647 m_floodeffects[StandardTerrainEffects.Smooth] = new SmoothArea(); 747 m_floodeffects[StandardTerrainEffects.Smooth] = new SmoothArea();
648 m_floodeffects[StandardTerrainEffects.Noise] = new NoiseArea(); 748 m_floodeffects[StandardTerrainEffects.Noise] = new NoiseArea();
649 m_floodeffects[StandardTerrainEffects.Flatten] = new FlattenArea(); 749 m_floodeffects[StandardTerrainEffects.Flatten] = new FlattenArea();
650 m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_revert); 750 m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_baked);
651 751
652 // Terrain Modifier operations 752 // Terrain Modifier operations
653 m_modifyOperations["min"] = new MinModifier(this); 753 m_modifyOperations["min"] = new MinModifier(this);
@@ -673,10 +773,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain
673 } 773 }
674 774
675 /// <summary> 775 /// <summary>
676 /// Saves the current state of the region into the revert map buffer. 776 /// Saves the current state of the region into the baked map buffer.
777
677 /// </summary> 778 /// </summary>
678 public void UpdateRevertMap() 779 public void UpdateBakedMap()
679 { 780 {
781<<<<<<< HEAD
680 /* 782 /*
681 int x; 783 int x;
682 for (x = 0; x < m_channel.Width; x++) 784 for (x = 0; x < m_channel.Width; x++)
@@ -689,6 +791,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
689 } 791 }
690 */ 792 */
691 m_revert = m_channel.MakeCopy(); 793 m_revert = m_channel.MakeCopy();
794=======
795 m_baked = m_channel.MakeCopy();
796 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked);
797 m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_baked);
798>>>>>>> avn/ubitvar
692 } 799 }
693 800
694 /// <summary> 801 /// <summary>
@@ -715,11 +822,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain
715 { 822 {
716 ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY, 823 ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY,
717 fileWidth, fileHeight, 824 fileWidth, fileHeight,
825<<<<<<< HEAD
718 (int)m_scene.RegionInfo.RegionSizeX, 826 (int)m_scene.RegionInfo.RegionSizeX,
719 (int)m_scene.RegionInfo.RegionSizeY); 827 (int)m_scene.RegionInfo.RegionSizeY);
828=======
829 (int) m_scene.RegionInfo.RegionSizeX,
830 (int) m_scene.RegionInfo.RegionSizeY);
831>>>>>>> avn/ubitvar
720 m_scene.Heightmap = channel; 832 m_scene.Heightmap = channel;
721 m_channel = channel; 833 m_channel = channel;
722 UpdateRevertMap(); 834 UpdateBakedMap();
723 } 835 }
724 836
725 return; 837 return;
@@ -782,12 +894,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain
782 } 894 }
783 895
784 /// <summary> 896 /// <summary>
897<<<<<<< HEAD
785 /// Called before processing of every simulation frame. 898 /// Called before processing of every simulation frame.
899=======
900>>>>>>> avn/ubitvar
786 /// This is used to check to see of any of the terrain is tainted and, if so, schedule 901 /// This is used to check to see of any of the terrain is tainted and, if so, schedule
787 /// updates for all the presences. 902 /// updates for all the presences.
788 /// This also checks to see if there are updates that need to be sent for each presence. 903 /// This also checks to see if there are updates that need to be sent for each presence.
789 /// This is where the logic is to send terrain updates to clients. 904 /// This is where the logic is to send terrain updates to clients.
790 /// </summary> 905 /// </summary>
906<<<<<<< HEAD
791 private void EventManager_OnFrame() 907 private void EventManager_OnFrame()
792 { 908 {
793 TerrainData terrData = m_channel.GetTerrainData(); 909 TerrainData terrData = m_channel.GetTerrainData();
@@ -798,6 +914,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain
798 for(int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize) 914 for(int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize)
799 { 915 {
800 if (terrData.IsTaintedAt(x, y)) 916 if (terrData.IsTaintedAt(x, y))
917=======
918 private void EventManager_TerrainCheckUpdates()
919 {
920 // this needs fixing
921 TerrainData terrData = m_channel.GetTerrainData();
922
923 bool shouldTaint = false;
924 for (int x = 0; x < terrData.SizeX; x += Constants.TerrainPatchSize)
925 {
926 for (int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize)
927 {
928 if (terrData.IsTaintedAt(x, y,true))
929>>>>>>> avn/ubitvar
801 { 930 {
802 // Found a patch that was modified. Push this flag into the clients. 931 // Found a patch that was modified. Push this flag into the clients.
803 SendToClients(terrData, x, y); 932 SendToClients(terrData, x, y);
@@ -815,6 +944,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain
815 m_scene.EventManager.TriggerTerrainTainted(); 944 m_scene.EventManager.TriggerTerrainTainted();
816 m_tainted = true; 945 m_tainted = true;
817 } 946 }
947<<<<<<< HEAD
948=======
949
950>>>>>>> avn/ubitvar
818 } 951 }
819 952
820 /// <summary> 953 /// <summary>
@@ -883,11 +1016,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain
883 presence.ControllingClient.OnLandUndo -= client_OnLandUndo; 1016 presence.ControllingClient.OnLandUndo -= client_OnLandUndo;
884 presence.ControllingClient.OnUnackedTerrain -= client_OnUnackedTerrain; 1017 presence.ControllingClient.OnUnackedTerrain -= client_OnUnackedTerrain;
885 } 1018 }
1019<<<<<<< HEAD
886 1020
887 lock(m_perClientPatchUpdates) 1021 lock(m_perClientPatchUpdates)
888 m_perClientPatchUpdates.Remove(client); 1022 m_perClientPatchUpdates.Remove(client);
889 } 1023 }
1024=======
1025>>>>>>> avn/ubitvar
890 1026
1027 lock (m_perClientPatchUpdates)
1028 m_perClientPatchUpdates.Remove(client);
1029 }
1030
891 /// <summary> 1031 /// <summary>
892 /// Scan over changes in the terrain and limit height changes. This enforces the 1032 /// Scan over changes in the terrain and limit height changes. This enforces the
893 /// non-estate owner limits on rate of terrain editting. 1033 /// non-estate owner limits on rate of terrain editting.
@@ -898,12 +1038,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain
898 TerrainData terrData = m_channel.GetTerrainData(); 1038 TerrainData terrData = m_channel.GetTerrainData();
899 1039
900 bool wasLimited = false; 1040 bool wasLimited = false;
1041<<<<<<< HEAD
901 for(int x = 0; x < terrData.SizeX; x += Constants.TerrainPatchSize) 1042 for(int x = 0; x < terrData.SizeX; x += Constants.TerrainPatchSize)
902 { 1043 {
903 for(int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize) 1044 for(int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize)
904 { 1045 {
905 if (terrData.IsTaintedAt(x, y, false /* clearOnTest */)) 1046 if (terrData.IsTaintedAt(x, y, false /* clearOnTest */))
906 { 1047 {
1048=======
1049 for (int x = 0; x < terrData.SizeX; x += Constants.TerrainPatchSize)
1050 {
1051 for (int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize)
1052 {
1053 if (terrData.IsTaintedAt(x, y, false /* clearOnTest */))
1054 {
1055>>>>>>> avn/ubitvar
907 // If we should respect the estate settings then 1056 // If we should respect the estate settings then
908 // fixup and height deltas that don't respect them. 1057 // fixup and height deltas that don't respect them.
909 // Note that LimitChannelChanges() modifies the TerrainChannel with the limited height values. 1058 // Note that LimitChannelChanges() modifies the TerrainChannel with the limited height values.
@@ -926,13 +1075,22 @@ namespace OpenSim.Region.CoreModules.World.Terrain
926 float maxDelta = (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit; 1075 float maxDelta = (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit;
927 1076
928 // loop through the height map for this patch and compare it against 1077 // loop through the height map for this patch and compare it against
1078<<<<<<< HEAD
929 // the revert map 1079 // the revert map
930 for(int x = xStart; x < xStart + Constants.TerrainPatchSize; x++) 1080 for(int x = xStart; x < xStart + Constants.TerrainPatchSize; x++)
1081=======
1082 // the baked map
1083 for (int x = xStart; x < xStart + Constants.TerrainPatchSize; x++)
1084>>>>>>> avn/ubitvar
931 { 1085 {
932 for(int y = yStart; y < yStart + Constants.TerrainPatchSize; y++) 1086 for(int y = yStart; y < yStart + Constants.TerrainPatchSize; y++)
933 { 1087 {
934 float requestedHeight = terrData[x, y]; 1088 float requestedHeight = terrData[x, y];
1089<<<<<<< HEAD
935 float bakedHeight = (float)m_revert[x, y]; 1090 float bakedHeight = (float)m_revert[x, y];
1091=======
1092 float bakedHeight = (float)m_baked[x, y];
1093>>>>>>> avn/ubitvar
936 float requestedDelta = requestedHeight - bakedHeight; 1094 float requestedDelta = requestedHeight - bakedHeight;
937 1095
938 if (requestedDelta > maxDelta) 1096 if (requestedDelta > maxDelta)
@@ -953,6 +1111,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
953 1111
954 private void client_OnLandUndo(IClientAPI client) 1112 private void client_OnLandUndo(IClientAPI client)
955 { 1113 {
1114<<<<<<< HEAD
956 lock(m_undo) 1115 lock(m_undo)
957 { 1116 {
958 if (m_undo.Count > 0) 1117 if (m_undo.Count > 0)
@@ -962,6 +1121,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain
962 goback.PlaybackState(); 1121 goback.PlaybackState();
963 } 1122 }
964 } 1123 }
1124=======
1125
1126>>>>>>> avn/ubitvar
965 } 1127 }
966 1128
967 /// <summary> 1129 /// <summary>
@@ -971,6 +1133,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
971 /// <param name="x">The patch corner to send</param> 1133 /// <param name="x">The patch corner to send</param>
972 /// <param name="y">The patch corner to send</param> 1134 /// <param name="y">The patch corner to send</param>
973 private void SendToClients(TerrainData terrData, int x, int y) 1135 private void SendToClients(TerrainData terrData, int x, int y)
1136<<<<<<< HEAD
974 { 1137 {
975 if (m_sendTerrainUpdatesByViewDistance) 1138 if (m_sendTerrainUpdatesByViewDistance)
976 { 1139 {
@@ -1138,6 +1301,181 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1138 ret.Add(new PatchesToSend(x, y, dist)); 1301 ret.Add(new PatchesToSend(x, y, dist));
1139 } 1302 }
1140 } 1303 }
1304=======
1305 {
1306 // Add that this patch needs to be sent to the accounting for each client.
1307 lock (m_perClientPatchUpdates)
1308 {
1309 m_scene.ForEachScenePresence(presence =>
1310 {
1311 PatchUpdates thisClientUpdates;
1312 if (!m_perClientPatchUpdates.TryGetValue(presence.UUID, out thisClientUpdates))
1313 {
1314 // There is a ScenePresence without a send patch map. Create one.
1315 thisClientUpdates = new PatchUpdates(terrData, presence);
1316 m_perClientPatchUpdates.Add(presence.UUID, thisClientUpdates);
1317 }
1318 thisClientUpdates.SetByXY(x, y, true);
1319 }
1320 );
1321 }
1322 }
1323
1324 private class PatchesToSend : IComparable<PatchesToSend>
1325 {
1326 public int PatchX;
1327 public int PatchY;
1328 public float Dist;
1329 public PatchesToSend(int pX, int pY, float pDist)
1330 {
1331 PatchX = pX;
1332 PatchY = pY;
1333 Dist = pDist;
1334 }
1335 public int CompareTo(PatchesToSend other)
1336 {
1337 return Dist.CompareTo(other.Dist);
1338 }
1339 }
1340
1341 // Called each frame time to see if there are any patches to send to any of the
1342 // ScenePresences.
1343 // Loop through all the per-client info and send any patches necessary.
1344 private void CheckSendingPatchesToClients()
1345 {
1346 lock (m_perClientPatchUpdates)
1347 {
1348 foreach (PatchUpdates pups in m_perClientPatchUpdates.Values)
1349 {
1350 // throught acording to land queue free to send bytes
1351 if (!pups.Presence.ControllingClient.CanSendLayerData())
1352 continue;
1353
1354 if (pups.HasUpdates())
1355 {
1356 // There is something that could be sent to this client.
1357 List<PatchesToSend> toSend = GetModifiedPatchesInViewDistance(pups);
1358 if (toSend.Count > 0)
1359 {
1360 // m_log.DebugFormat("{0} CheckSendingPatchesToClient: sending {1} patches to {2} in region {3}",
1361 // LogHeader, toSend.Count, pups.Presence.Name, m_scene.RegionInfo.RegionName);
1362 // Sort the patches to send by the distance from the presence
1363 toSend.Sort();
1364 /*
1365 foreach (PatchesToSend pts in toSend)
1366 {
1367 pups.Presence.ControllingClient.SendLayerData(pts.PatchX, pts.PatchY, null);
1368 // presence.ControllingClient.SendLayerData(xs.ToArray(), ys.ToArray(), null, TerrainPatch.LayerType.Land);
1369 }
1370 */
1371
1372 int[] xPieces = new int[toSend.Count];
1373 int[] yPieces = new int[toSend.Count];
1374 float[] patchPieces = new float[toSend.Count * 2];
1375 int pieceIndex = 0;
1376 foreach (PatchesToSend pts in toSend)
1377 {
1378 patchPieces[pieceIndex++] = pts.PatchX;
1379 patchPieces[pieceIndex++] = pts.PatchY;
1380 }
1381 pups.Presence.ControllingClient.SendLayerData(-toSend.Count, 0, patchPieces);
1382 }
1383 }
1384 }
1385 }
1386 }
1387
1388 private List<PatchesToSend> GetModifiedPatchesInViewDistance(PatchUpdates pups)
1389 {
1390 List<PatchesToSend> ret = new List<PatchesToSend>();
1391
1392 int npatchs = 0;
1393
1394 ScenePresence presence = pups.Presence;
1395 if (presence == null)
1396 return ret;
1397
1398 float minz = presence.AbsolutePosition.Z;
1399 if (presence.CameraPosition.Z < minz)
1400 minz = presence.CameraPosition.Z;
1401
1402 // this limit should be max terrainheight + max draw
1403 if (minz > 1500f)
1404 return ret;
1405
1406 int DrawDistance = (int)presence.DrawDistance;
1407
1408 DrawDistance = DrawDistance / Constants.TerrainPatchSize;
1409
1410 int testposX;
1411 int testposY;
1412
1413 if (Math.Abs(presence.AbsolutePosition.X - presence.CameraPosition.X) > 30
1414 || Math.Abs(presence.AbsolutePosition.Y - presence.CameraPosition.Y) > 30)
1415 {
1416 testposX = (int)presence.CameraPosition.X / Constants.TerrainPatchSize;
1417 testposY = (int)presence.CameraPosition.Y / Constants.TerrainPatchSize;
1418 }
1419 else
1420 {
1421 testposX = (int)presence.AbsolutePosition.X / Constants.TerrainPatchSize;
1422 testposY = (int)presence.AbsolutePosition.Y / Constants.TerrainPatchSize;
1423 }
1424 int limitX = (int)m_scene.RegionInfo.RegionSizeX / Constants.TerrainPatchSize;
1425 int limitY = (int)m_scene.RegionInfo.RegionSizeY / Constants.TerrainPatchSize;
1426
1427 // Compute the area of patches within our draw distance
1428 int startX = testposX - DrawDistance;
1429 if (startX < 0)
1430 startX = 0;
1431 else if (startX > limitX)
1432 startX = limitX;
1433
1434 int startY = testposY - DrawDistance;
1435 if (startY < 0)
1436 startY = 0;
1437 else if (startY > limitY)
1438 startY = limitY;
1439
1440 int endX = testposX + DrawDistance;
1441 if (endX < 0)
1442 endX = 0;
1443 else if (endX > limitX)
1444 endX = limitX;
1445
1446 int endY = testposY + DrawDistance;
1447 if (endY < 0)
1448 endY = 0;
1449 else if (endY > limitY)
1450 endY = limitY;
1451
1452 int distx;
1453 int disty;
1454 int distsq;
1455
1456 DrawDistance *= DrawDistance;
1457
1458 for (int x = startX; x < endX; x++)
1459 {
1460 for (int y = startY; y < endY; y++)
1461 {
1462 if (pups.GetByPatch(x, y))
1463 {
1464 distx = x - testposX;
1465 disty = y - testposY;
1466 distsq = distx * distx + disty * disty;
1467 if (distsq < DrawDistance)
1468 {
1469 pups.SetByPatch(x, y, false);
1470 ret.Add(new PatchesToSend(x, y, (float)distsq));
1471 if (npatchs++ > 65536)
1472 {
1473 y = endY;
1474 x = endX;
1475 }
1476 }
1477 }
1478>>>>>>> avn/ubitvar
1141 } 1479 }
1142 } 1480 }
1143 return ret; 1481 return ret;
@@ -1161,6 +1499,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1161 int zx = (int)(west + 0.5); 1499 int zx = (int)(west + 0.5);
1162 int zy = (int)(north + 0.5); 1500 int zy = (int)(north + 0.5);
1163 1501
1502<<<<<<< HEAD
1164 int dx; 1503 int dx;
1165 for(dx=-n; dx<=n; dx++) 1504 for(dx=-n; dx<=n; dx++)
1166 { 1505 {
@@ -1176,16 +1515,52 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1176 allowMask[x, y] = true; 1515 allowMask[x, y] = true;
1177 allowed = true; 1516 allowed = true;
1178 } 1517 }
1518=======
1519
1520 int startX = zx - n;
1521 if (startX < 0)
1522 startX = 0;
1523
1524 int startY = zy - n;
1525 if (startY < 0)
1526 startY = 0;
1527
1528 int endX = zx + n;
1529 if (endX >= m_channel.Width)
1530 endX = m_channel.Width - 1;
1531 int endY = zy + n;
1532 if (endY >= m_channel.Height)
1533 endY = m_channel.Height - 1;
1534
1535 int x, y;
1536
1537 for (x = startX; x <= endX; x++)
1538 {
1539 for (y = startY; y <= endY; y++)
1540 {
1541 if (m_scene.Permissions.CanTerraformLand(agentId, new Vector3(x, y, 0)))
1542 {
1543 allowMask[x, y] = true;
1544 allowed = true;
1545>>>>>>> avn/ubitvar
1179 } 1546 }
1180 } 1547 }
1181 } 1548 }
1182 if (allowed) 1549 if (allowed)
1183 { 1550 {
1184 StoreUndoState(); 1551 StoreUndoState();
1552<<<<<<< HEAD
1185 m_painteffects[(StandardTerrainEffects)action].PaintEffect( 1553 m_painteffects[(StandardTerrainEffects)action].PaintEffect(
1186 m_channel, allowMask, west, south, height, size, seconds); 1554 m_channel, allowMask, west, south, height, size, seconds);
1187 1555
1188 //revert changes outside estate limits 1556 //revert changes outside estate limits
1557=======
1558 m_painteffects[(StandardTerrainEffects) action].PaintEffect(
1559 m_channel, allowMask, west, south, height, size, seconds,
1560 startX, endX, startY, endY);
1561
1562 //block changes outside estate limits
1563>>>>>>> avn/ubitvar
1189 if (!god) 1564 if (!god)
1190 EnforceEstateLimits(); 1565 EnforceEstateLimits();
1191 } 1566 }
@@ -1225,9 +1600,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1225 if (allowed) 1600 if (allowed)
1226 { 1601 {
1227 StoreUndoState(); 1602 StoreUndoState();
1603<<<<<<< HEAD
1228 m_floodeffects[(StandardTerrainEffects)action].FloodEffect(m_channel, fillArea, size); 1604 m_floodeffects[(StandardTerrainEffects)action].FloodEffect(m_channel, fillArea, size);
1229 1605
1230 //revert changes outside estate limits 1606 //revert changes outside estate limits
1607=======
1608 m_floodeffects[(StandardTerrainEffects) action].FloodEffect(m_channel, fillArea, size);
1609
1610 //block changes outside estate limits
1611>>>>>>> avn/ubitvar
1231 if (!god) 1612 if (!god)
1232 EnforceEstateLimits(); 1613 EnforceEstateLimits();
1233 } 1614 }
@@ -1260,6 +1641,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1260 1641
1261 private void StoreUndoState() 1642 private void StoreUndoState()
1262 { 1643 {
1644<<<<<<< HEAD
1263 lock(m_undo) 1645 lock(m_undo)
1264 { 1646 {
1265 if (m_undo.Count > 0) 1647 if (m_undo.Count > 0)
@@ -1275,22 +1657,36 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1275 LandUndoState nUndo = new LandUndoState(this, m_channel); 1657 LandUndoState nUndo = new LandUndoState(this, m_channel);
1276 m_undo.Push(nUndo); 1658 m_undo.Push(nUndo);
1277 } 1659 }
1660=======
1661>>>>>>> avn/ubitvar
1278 } 1662 }
1279 1663
1280 #region Console Commands 1664 #region Console Commands
1281 1665
1282 private void InterfaceLoadFile(Object[] args) 1666 private void InterfaceLoadFile(Object[] args)
1283 { 1667 {
1668<<<<<<< HEAD
1284 LoadFromFile((string)args[0]); 1669 LoadFromFile((string)args[0]);
1670=======
1671 LoadFromFile((string) args[0]);
1672>>>>>>> avn/ubitvar
1285 } 1673 }
1286 1674
1287 private void InterfaceLoadTileFile(Object[] args) 1675 private void InterfaceLoadTileFile(Object[] args)
1288 { 1676 {
1677<<<<<<< HEAD
1289 LoadFromFile((string)args[0], 1678 LoadFromFile((string)args[0],
1290 (int)args[1], 1679 (int)args[1],
1291 (int)args[2], 1680 (int)args[2],
1292 (int)args[3], 1681 (int)args[3],
1293 (int)args[4]); 1682 (int)args[4]);
1683=======
1684 LoadFromFile((string) args[0],
1685 (int) args[1],
1686 (int) args[2],
1687 (int) args[3],
1688 (int) args[4]);
1689>>>>>>> avn/ubitvar
1294 } 1690 }
1295 1691
1296 private void InterfaceSaveFile(Object[] args) 1692 private void InterfaceSaveFile(Object[] args)
@@ -1309,15 +1705,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1309 1705
1310 private void InterfaceBakeTerrain(Object[] args) 1706 private void InterfaceBakeTerrain(Object[] args)
1311 { 1707 {
1312 UpdateRevertMap(); 1708 UpdateBakedMap();
1313 } 1709 }
1314 1710
1315 private void InterfaceRevertTerrain(Object[] args) 1711 private void InterfaceRevertTerrain(Object[] args)
1316 { 1712 {
1317 int x, y; 1713 int x, y;
1714<<<<<<< HEAD
1318 for(x = 0; x < m_channel.Width; x++) 1715 for(x = 0; x < m_channel.Width; x++)
1319 for(y = 0; y < m_channel.Height; y++) 1716 for(y = 0; y < m_channel.Height; y++)
1320 m_channel[x, y] = m_revert[x, y]; 1717 m_channel[x, y] = m_revert[x, y];
1718=======
1719 for (x = 0; x < m_channel.Width; x++)
1720 for (y = 0; y < m_channel.Height; y++)
1721 m_channel[x, y] = m_baked[x, y];
1722>>>>>>> avn/ubitvar
1321 1723
1322 } 1724 }
1323 1725
@@ -1327,9 +1729,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1327 1729
1328 if (direction.ToLower().StartsWith("y")) 1730 if (direction.ToLower().StartsWith("y"))
1329 { 1731 {
1732<<<<<<< HEAD
1330 for(int x = 0; x < m_channel.Width; x++) 1733 for(int x = 0; x < m_channel.Width; x++)
1331 { 1734 {
1332 for(int y = 0; y < m_channel.Height / 2; y++) 1735 for(int y = 0; y < m_channel.Height / 2; y++)
1736=======
1737 for (int x = 0; x < m_channel.Width; x++)
1738 {
1739 for (int y = 0; y < m_channel.Height / 2; y++)
1740>>>>>>> avn/ubitvar
1333 { 1741 {
1334 double height = m_channel[x, y]; 1742 double height = m_channel[x, y];
1335 double flippedHeight = m_channel[x, (int)m_channel.Height - 1 - y]; 1743 double flippedHeight = m_channel[x, (int)m_channel.Height - 1 - y];
@@ -1341,9 +1749,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1341 } 1749 }
1342 else if (direction.ToLower().StartsWith("x")) 1750 else if (direction.ToLower().StartsWith("x"))
1343 { 1751 {
1752<<<<<<< HEAD
1344 for(int y = 0; y < m_channel.Height; y++) 1753 for(int y = 0; y < m_channel.Height; y++)
1345 { 1754 {
1346 for(int x = 0; x < m_channel.Width / 2; x++) 1755 for(int x = 0; x < m_channel.Width / 2; x++)
1756=======
1757 for (int y = 0; y < m_channel.Height; y++)
1758 {
1759 for (int x = 0; x < m_channel.Width / 2; x++)
1760>>>>>>> avn/ubitvar
1347 { 1761 {
1348 double height = m_channel[x, y]; 1762 double height = m_channel[x, y];
1349 double flippedHeight = m_channel[(int)m_channel.Width - 1 - x, y]; 1763 double flippedHeight = m_channel[(int)m_channel.Width - 1 - x, y];
@@ -1420,45 +1834,81 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1420 1834
1421 private void InterfaceElevateTerrain(Object[] args) 1835 private void InterfaceElevateTerrain(Object[] args)
1422 { 1836 {
1837 double val = (double)args[0];
1838
1423 int x, y; 1839 int x, y;
1840<<<<<<< HEAD
1424 for(x = 0; x < m_channel.Width; x++) 1841 for(x = 0; x < m_channel.Width; x++)
1425 for(y = 0; y < m_channel.Height; y++) 1842 for(y = 0; y < m_channel.Height; y++)
1426 m_channel[x, y] += (double)args[0]; 1843 m_channel[x, y] += (double)args[0];
1844=======
1845 for (x = 0; x < m_channel.Width; x++)
1846 for (y = 0; y < m_channel.Height; y++)
1847 m_channel[x, y] += val;
1848>>>>>>> avn/ubitvar
1427 } 1849 }
1428 1850
1429 private void InterfaceMultiplyTerrain(Object[] args) 1851 private void InterfaceMultiplyTerrain(Object[] args)
1430 { 1852 {
1431 int x, y; 1853 int x, y;
1854<<<<<<< HEAD
1432 for(x = 0; x < m_channel.Width; x++) 1855 for(x = 0; x < m_channel.Width; x++)
1433 for(y = 0; y < m_channel.Height; y++) 1856 for(y = 0; y < m_channel.Height; y++)
1434 m_channel[x, y] *= (double)args[0]; 1857 m_channel[x, y] *= (double)args[0];
1858=======
1859 double val = (double)args[0];
1860
1861 for (x = 0; x < m_channel.Width; x++)
1862 for (y = 0; y < m_channel.Height; y++)
1863 m_channel[x, y] *= val;
1864>>>>>>> avn/ubitvar
1435 } 1865 }
1436 1866
1437 private void InterfaceLowerTerrain(Object[] args) 1867 private void InterfaceLowerTerrain(Object[] args)
1438 { 1868 {
1439 int x, y; 1869 int x, y;
1870<<<<<<< HEAD
1440 for(x = 0; x < m_channel.Width; x++) 1871 for(x = 0; x < m_channel.Width; x++)
1441 for(y = 0; y < m_channel.Height; y++) 1872 for(y = 0; y < m_channel.Height; y++)
1442 m_channel[x, y] -= (double)args[0]; 1873 m_channel[x, y] -= (double)args[0];
1874=======
1875 double val = (double)args[0];
1876
1877 for (x = 0; x < m_channel.Width; x++)
1878 for (y = 0; y < m_channel.Height; y++)
1879 m_channel[x, y] -= val;
1880>>>>>>> avn/ubitvar
1443 } 1881 }
1444 1882
1445 public void InterfaceFillTerrain(Object[] args) 1883 public void InterfaceFillTerrain(Object[] args)
1446 { 1884 {
1447 int x, y; 1885 int x, y;
1886 double val = (double)args[0];
1448 1887
1888<<<<<<< HEAD
1449 for(x = 0; x < m_channel.Width; x++) 1889 for(x = 0; x < m_channel.Width; x++)
1450 for(y = 0; y < m_channel.Height; y++) 1890 for(y = 0; y < m_channel.Height; y++)
1451 m_channel[x, y] = (double)args[0]; 1891 m_channel[x, y] = (double)args[0];
1892=======
1893 for (x = 0; x < m_channel.Width; x++)
1894 for (y = 0; y < m_channel.Height; y++)
1895 m_channel[x, y] = val;
1896>>>>>>> avn/ubitvar
1452 } 1897 }
1453 1898
1454 private void InterfaceMinTerrain(Object[] args) 1899 private void InterfaceMinTerrain(Object[] args)
1455 { 1900 {
1456 int x, y; 1901 int x, y;
1902<<<<<<< HEAD
1457 for(x = 0; x < m_channel.Width; x++) 1903 for(x = 0; x < m_channel.Width; x++)
1904=======
1905 double val = (double)args[0];
1906 for (x = 0; x < m_channel.Width; x++)
1907>>>>>>> avn/ubitvar
1458 { 1908 {
1459 for(y = 0; y < m_channel.Height; y++) 1909 for(y = 0; y < m_channel.Height; y++)
1460 { 1910 {
1461 m_channel[x, y] = Math.Max((double)args[0], m_channel[x, y]); 1911 m_channel[x, y] = Math.Max(val, m_channel[x, y]);
1462 } 1912 }
1463 } 1913 }
1464 } 1914 }
@@ -1466,13 +1916,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1466 private void InterfaceMaxTerrain(Object[] args) 1916 private void InterfaceMaxTerrain(Object[] args)
1467 { 1917 {
1468 int x, y; 1918 int x, y;
1919<<<<<<< HEAD
1469 for(x = 0; x < m_channel.Width; x++) 1920 for(x = 0; x < m_channel.Width; x++)
1921=======
1922 double val = (double)args[0];
1923 for (x = 0; x < m_channel.Width; x++)
1924>>>>>>> avn/ubitvar
1470 { 1925 {
1471 for(y = 0; y < m_channel.Height; y++) 1926 for(y = 0; y < m_channel.Height; y++)
1472 { 1927 {
1473 m_channel[x, y] = Math.Min((double)args[0], m_channel[x, y]); 1928 m_channel[x, y] = Math.Min(val, m_channel[x, y]);
1474 } 1929 }
1475 } 1930 }
1931<<<<<<< HEAD
1476 } 1932 }
1477 1933
1478 private void InterfaceShow(Object[] args) 1934 private void InterfaceShow(Object[] args)
@@ -1488,6 +1944,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1488 double height = m_channel[(int)point.X, (int)point.Y]; 1944 double height = m_channel[(int)point.X, (int)point.Y];
1489 1945
1490 Console.WriteLine("Terrain height at {0} is {1}", point, height); 1946 Console.WriteLine("Terrain height at {0} is {1}", point, height);
1947=======
1948>>>>>>> avn/ubitvar
1491 } 1949 }
1492 1950
1493 private void InterfaceShowDebugStats(Object[] args) 1951 private void InterfaceShowDebugStats(Object[] args)
@@ -1620,9 +2078,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1620 multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double"); 2078 multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double");
1621 2079
1622 Command bakeRegionCommand = 2080 Command bakeRegionCommand =
1623 new Command("bake", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBakeTerrain, "Saves the current terrain into the regions revert map."); 2081 new Command("bake", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBakeTerrain, "Saves the current terrain into the regions baked map.");
1624 Command revertRegionCommand = 2082 Command revertRegionCommand =
1625 new Command("revert", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap."); 2083 new Command("revert", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRevertTerrain, "Loads the baked map terrain into the regions heightmap.");
1626 2084
1627 Command flipCommand = 2085 Command flipCommand =
1628 new Command("flip", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFlipTerrain, "Flips the current terrain about the X or Y axis"); 2086 new Command("flip", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFlipTerrain, "Flips the current terrain about the X or Y axis");
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
index 29e80ef..40db370 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
@@ -60,7 +60,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
60 TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); 60 TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
61 ITerrainPaintableEffect effect = new RaiseSphere(); 61 ITerrainPaintableEffect effect = new RaiseSphere();
62 62
63<<<<<<< HEAD
63 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0); 64 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
65=======
66 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0,
67 0, midRegion - 1,0, (int)Constants.RegionSize -1);
68>>>>>>> avn/ubitvar
64 Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128)."); 69 Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128).");
65 Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128)."); 70 Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128).");
66 Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128)."); 71 Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128).");
@@ -79,7 +84,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
79 } 84 }
80 effect = new LowerSphere(); 85 effect = new LowerSphere();
81 86
87<<<<<<< HEAD
82 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0); 88 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
89=======
90 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0,
91 0, (int)Constants.RegionSize -1,0, (int)Constants.RegionSize -1);
92>>>>>>> avn/ubitvar
83 Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128)."); 93 Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
84 Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128)."); 94 Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
85 Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128)."); 95 Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128).");
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs
index 9534ad3..77c10b8 100644
--- a/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs
+++ b/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs
@@ -79,9 +79,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
79 /// <remarks>Based on the algorithm described at http://opensimulator.org/wiki/Terrain_Splatting 79 /// <remarks>Based on the algorithm described at http://opensimulator.org/wiki/Terrain_Splatting
80 /// Note we create a 256x256 dimension texture even if the actual terrain is larger. 80 /// Note we create a 256x256 dimension texture even if the actual terrain is larger.
81 /// </remarks> 81 /// </remarks>
82<<<<<<< HEAD
82 public static Bitmap Splat(ITerrainChannel terrain, 83 public static Bitmap Splat(ITerrainChannel terrain,
83 UUID[] textureIDs, float[] startHeights, float[] heightRanges, 84 UUID[] textureIDs, float[] startHeights, float[] heightRanges,
84 Vector3d regionPosition, IAssetService assetService, bool textureTerrain) 85 Vector3d regionPosition, IAssetService assetService, bool textureTerrain)
86=======
87 public static Bitmap Splat(ITerrainChannel terrain, UUID[] textureIDs, float[] startHeights, float[] heightRanges, Vector3d regionPosition, IAssetService assetService, bool textureTerrain)
88>>>>>>> avn/ubitvar
85 { 89 {
86 Debug.Assert(textureIDs.Length == 4); 90 Debug.Assert(textureIDs.Length == 4);
87 Debug.Assert(startHeights.Length == 4); 91 Debug.Assert(startHeights.Length == 4);
@@ -195,12 +199,74 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
195 using (SolidBrush brush = new SolidBrush(DEFAULT_TERRAIN_COLOR[i])) 199 using (SolidBrush brush = new SolidBrush(DEFAULT_TERRAIN_COLOR[i]))
196 gfx.FillRectangle(brush, 0, 0, 256, 256); 200 gfx.FillRectangle(brush, 0, 0, 256, 256);
197 } 201 }
202 else
203 {
204 if (detailTexture[i].Width != 256 || detailTexture[i].Height != 256)
205 {
206 detailTexture[i] = ResizeBitmap(detailTexture[i], 256, 256);
207 }
208 }
198 } 209 }
210<<<<<<< HEAD
199 else 211 else
212=======
213
214 #region Layer Map
215
216 float[,] layermap = new float[256 , 256];
217
218 int xFactor = terrain.Width / 256;
219 int yFactor = terrain.Height / 256;
220
221 for (int y = 0; y < 256; y++)
222>>>>>>> avn/ubitvar
200 { 223 {
201 if (detailTexture[i].Width != 256 || detailTexture[i].Height != 256) 224 if (detailTexture[i].Width != 256 || detailTexture[i].Height != 256)
202 { 225 {
226<<<<<<< HEAD
203 detailTexture[i] = ResizeBitmap(detailTexture[i], 256, 256); 227 detailTexture[i] = ResizeBitmap(detailTexture[i], 256, 256);
228=======
229 float height = (float)terrain[x * xFactor, y * yFactor];
230
231 float pctX = (float)x / 255f;
232 float pctY = (float)y / 255f;
233
234 // Use bilinear interpolation between the four corners of start height and
235 // height range to select the current values at this position
236 float startHeight = ImageUtils.Bilinear(
237 startHeights[0],
238 startHeights[2],
239 startHeights[1],
240 startHeights[3],
241 pctX, pctY);
242 startHeight = Utils.Clamp(startHeight, 0f, 255f);
243
244 float heightRange = ImageUtils.Bilinear(
245 heightRanges[0],
246 heightRanges[2],
247 heightRanges[1],
248 heightRanges[3],
249 pctX, pctY);
250 heightRange = Utils.Clamp(heightRange, 0f, 255f);
251
252 // Generate two frequencies of perlin noise based on our global position
253 // The magic values were taken from http://opensimulator.org/wiki/Terrain_Splatting
254 Vector3 vec = new Vector3
255 (
256 ((float)regionPosition.X + (x * xFactor)) * 0.20319f,
257 ((float)regionPosition.Y + (y * yFactor)) * 0.20319f,
258 height * 0.25f
259 );
260
261 float lowFreq = Perlin.noise2(vec.X * 0.222222f, vec.Y * 0.222222f) * 6.5f;
262 float highFreq = Perlin.turbulence2(vec.X, vec.Y, 2f) * 2.25f;
263 float noise = (lowFreq + highFreq) * 2f;
264
265 // Combine the current height, generated noise, start height, and height range parameters, then scale all of it
266 float layer = ((height + noise - startHeight) / heightRange) * 4f;
267 if (Single.IsNaN(layer)) layer = 0f;
268 layermap[x,y] = Utils.Clamp(layer, 0f, 3f);
269>>>>>>> avn/ubitvar
204 } 270 }
205 } 271 }
206 } 272 }
@@ -220,6 +286,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
220 { 286 {
221 for (int x = 0; x < 256; x++) 287 for (int x = 0; x < 256; x++)
222 { 288 {
289<<<<<<< HEAD
223 float height = (float)terrain[x * xFactor, y * yFactor]; 290 float height = (float)terrain[x * xFactor, y * yFactor];
224 291
225 float pctX = (float)x / 255f; 292 float pctX = (float)x / 255f;
@@ -261,6 +328,58 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
261 if (Single.IsNaN(layer)) 328 if (Single.IsNaN(layer))
262 layer = 0f; 329 layer = 0f;
263 layermap[x, y] = Utils.Clamp(layer, 0f, 3f); 330 layermap[x, y] = Utils.Clamp(layer, 0f, 3f);
331=======
332 // Get handles to all of the texture data arrays
333 BitmapData[] datas = new BitmapData[]
334 {
335 detailTexture[0].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[0].PixelFormat),
336 detailTexture[1].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[1].PixelFormat),
337 detailTexture[2].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[2].PixelFormat),
338 detailTexture[3].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[3].PixelFormat)
339 };
340
341 int[] comps = new int[]
342 {
343 (datas[0].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3,
344 (datas[1].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3,
345 (datas[2].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3,
346 (datas[3].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3
347 };
348
349 for (int y = 0; y < 256; y++)
350 {
351 for (int x = 0; x < 256; x++)
352 {
353 float layer = layermap[x, y];
354
355 // Select two textures
356 int l0 = (int)Math.Floor(layer);
357 int l1 = Math.Min(l0 + 1, 3);
358
359 byte* ptrA = (byte*)datas[l0].Scan0 + y * datas[l0].Stride + x * comps[l0];
360 byte* ptrB = (byte*)datas[l1].Scan0 + y * datas[l1].Stride + x * comps[l1];
361 byte* ptrO = (byte*)outputData.Scan0 + y * outputData.Stride + x * 3;
362
363 float aB = *(ptrA + 0);
364 float aG = *(ptrA + 1);
365 float aR = *(ptrA + 2);
366
367 float bB = *(ptrB + 0);
368 float bG = *(ptrB + 1);
369 float bR = *(ptrB + 2);
370
371 float layerDiff = layer - l0;
372
373 // Interpolate between the two selected textures
374 *(ptrO + 0) = (byte)Math.Floor(aB + layerDiff * (bB - aB));
375 *(ptrO + 1) = (byte)Math.Floor(aG + layerDiff * (bG - aG));
376 *(ptrO + 2) = (byte)Math.Floor(aR + layerDiff * (bR - aR));
377 }
378 }
379
380 for (int i = 0; i < 4; i++)
381 detailTexture[i].UnlockBits(datas[i]);
382>>>>>>> avn/ubitvar
264 } 383 }
265 } 384 }
266 385
@@ -352,7 +471,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
352 b.Dispose(); 471 b.Dispose();
353 return result; 472 return result;
354 } 473 }
474<<<<<<< HEAD
355 475
476=======
477>>>>>>> avn/ubitvar
356 public static Bitmap SplatSimple(float[] heightmap) 478 public static Bitmap SplatSimple(float[] heightmap)
357 { 479 {
358 const float BASE_HSV_H = 93f / 360f; 480 const float BASE_HSV_H = 93f / 360f;
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
index dd91951..d8420d9 100644
--- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
@@ -80,6 +80,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
80 80
81 private bool m_Enabled = false; 81 private bool m_Enabled = false;
82 82
83 private Bitmap lastImage = null;
84 private DateTime lastImageTime = DateTime.MinValue;
85
83 #region Region Module interface 86 #region Region Module interface
84 87
85 public void Initialise(IConfigSource source) 88 public void Initialise(IConfigSource source)
@@ -118,14 +121,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
118 121
119 List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); 122 List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory());
120 if (renderers.Count > 0) 123 if (renderers.Count > 0)
121 { 124 m_log.Info("[MAPTILE]: Loaded prim mesher " + renderers[0]);
122 m_primMesher = RenderingLoader.LoadRenderer(renderers[0]);
123 m_log.DebugFormat("[WARP 3D IMAGE MODULE]: Loaded prim mesher {0}", m_primMesher);
124 }
125 else 125 else
126 { 126 m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled");
127 m_log.Debug("[WARP 3D IMAGE MODULE]: No prim mesher loaded, prim rendering will be disabled");
128 }
129 127
130 m_scene.RegisterModuleInterface<IMapImageGenerator>(this); 128 m_scene.RegisterModuleInterface<IMapImageGenerator>(this);
131 } 129 }
@@ -158,18 +156,50 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
158 156
159 public Bitmap CreateMapTile() 157 public Bitmap CreateMapTile()
160 { 158 {
159<<<<<<< HEAD
161 // Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); 160 // Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f);
162 // Camera above the middle of the region 161 // Camera above the middle of the region
163 Vector3 camPos = new Vector3( 162 Vector3 camPos = new Vector3(
164 m_scene.RegionInfo.RegionSizeX/2 - 0.5f, 163 m_scene.RegionInfo.RegionSizeX/2 - 0.5f,
165 m_scene.RegionInfo.RegionSizeY/2 - 0.5f, 164 m_scene.RegionInfo.RegionSizeY/2 - 0.5f,
165=======
166 /* this must be on all map, not just its image
167 if ((DateTime.Now - lastImageTime).TotalSeconds < 3600)
168 {
169 return (Bitmap)lastImage.Clone();
170 }
171 */
172
173 List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory());
174 if (renderers.Count > 0)
175 {
176 m_primMesher = RenderingLoader.LoadRenderer(renderers[0]);
177 }
178
179 Vector3 camPos = new Vector3(
180 m_scene.RegionInfo.RegionSizeX / 2 - 0.5f,
181 m_scene.RegionInfo.RegionSizeY / 2 - 0.5f,
182>>>>>>> avn/ubitvar
166 221.7025033688163f); 183 221.7025033688163f);
167 // Viewport viewing down onto the region 184 // Viewport viewing down onto the region
168 Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, 185 Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f,
169 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY, 186 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY,
187<<<<<<< HEAD
170 (float)m_scene.RegionInfo.RegionSizeX, (float)m_scene.RegionInfo.RegionSizeY ); 188 (float)m_scene.RegionInfo.RegionSizeX, (float)m_scene.RegionInfo.RegionSizeY );
171 // Fill the viewport and return the image 189 // Fill the viewport and return the image
172 return CreateMapTile(viewport, false); 190 return CreateMapTile(viewport, false);
191=======
192 (float)m_scene.RegionInfo.RegionSizeX, (float)m_scene.RegionInfo.RegionSizeY);
193
194 Bitmap tile = CreateMapTile(viewport, false);
195 m_primMesher = null;
196 return tile;
197/*
198 lastImage = tile;
199 lastImageTime = DateTime.Now;
200 return (Bitmap)lastImage.Clone();
201 */
202>>>>>>> avn/ubitvar
173 } 203 }
174 204
175 public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures) 205 public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures)
@@ -285,9 +315,15 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
285 float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; 315 float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight;
286 316
287 renderer.AddPlane("Water", m_scene.RegionInfo.RegionSizeX * 0.5f); 317 renderer.AddPlane("Water", m_scene.RegionInfo.RegionSizeX * 0.5f);
318<<<<<<< HEAD
288 renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX/2 - 0.5f, 319 renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX/2 - 0.5f,
289 waterHeight, 320 waterHeight,
290 m_scene.RegionInfo.RegionSizeY/2 - 0.5f ); 321 m_scene.RegionInfo.RegionSizeY/2 - 0.5f );
322=======
323 renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX / 2 - 0.5f,
324 waterHeight,
325 m_scene.RegionInfo.RegionSizeY / 2 - 0.5f);
326>>>>>>> avn/ubitvar
291 327
292 warp_Material waterColorMaterial = new warp_Material(ConvertColor(WATER_COLOR)); 328 warp_Material waterColorMaterial = new warp_Material(ConvertColor(WATER_COLOR));
293 waterColorMaterial.setReflectivity(0); // match water color with standard map module thanks lkalif 329 waterColorMaterial.setReflectivity(0); // match water color with standard map module thanks lkalif
@@ -316,7 +352,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
316 warp_Vector pos = ConvertVector(x, y, (float)terrain[(int)x, (int)y]); 352 warp_Vector pos = ConvertVector(x, y, (float)terrain[(int)x, (int)y]);
317 obj.addVertex(new warp_Vertex(pos, 353 obj.addVertex(new warp_Vertex(pos,
318 x / (float)m_scene.RegionInfo.RegionSizeX, 354 x / (float)m_scene.RegionInfo.RegionSizeX,
355<<<<<<< HEAD
319 (((float)m_scene.RegionInfo.RegionSizeY) - y) / m_scene.RegionInfo.RegionSizeY) ); 356 (((float)m_scene.RegionInfo.RegionSizeY) - y) / m_scene.RegionInfo.RegionSizeY) );
357=======
358 (((float)m_scene.RegionInfo.RegionSizeY) - y) / m_scene.RegionInfo.RegionSizeY));
359>>>>>>> avn/ubitvar
320 } 360 }
321 } 361 }
322 362
@@ -384,7 +424,12 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
384 warp_Texture texture; 424 warp_Texture texture;
385 using ( 425 using (
386 Bitmap image 426 Bitmap image
427<<<<<<< HEAD
387 = TerrainSplat.Splat(terrain, textureIDs, startHeights, heightRanges, 428 = TerrainSplat.Splat(terrain, textureIDs, startHeights, heightRanges,
429=======
430 = TerrainSplat.Splat(
431 terrain, textureIDs, startHeights, heightRanges,
432>>>>>>> avn/ubitvar
388 new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain)) 433 new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain))
389 { 434 {
390 texture = new warp_Texture(image); 435 texture = new warp_Texture(image);
@@ -660,6 +705,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
660 #endregion Rendering Methods 705 #endregion Rendering Methods
661 706
662 #region Static Helpers 707 #region Static Helpers
708 // Note: axis change.
709 private static warp_Vector ConvertVector(float x, float y, float z)
710 {
711 return new warp_Vector(x, z, y);
712 }
663 713
664 // Note: axis change. 714 // Note: axis change.
665 private static warp_Vector ConvertVector(float x, float y, float z) 715 private static warp_Vector ConvertVector(float x, float y, float z)
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index d862f18..553d057 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -141,20 +141,98 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
141 141
142 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) 142 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags)
143 { 143 {
144<<<<<<< HEAD
144 List<MapBlockData> blocks = new List<MapBlockData>(); 145 List<MapBlockData> blocks = new List<MapBlockData>();
145 if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) 146 if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4))
147=======
148 Util.FireAndForget(x =>
149>>>>>>> avn/ubitvar
146 { 150 {
151 List<MapBlockData> blocks = new List<MapBlockData>();
152 if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4))
153 {
154 // final block, closing the search result
155 AddFinalBlock(blocks);
156
157 // flags are agent flags sent from the viewer.
158 // they have different values depending on different viewers, apparently
159 remoteClient.SendMapBlock(blocks, flags);
160 remoteClient.SendAlertMessage("Use a search string with at least 3 characters");
161 return;
162 }
163
164 //m_log.DebugFormat("MAP NAME=({0})", mapName);
165
166 // Hack to get around the fact that ll V3 now drops the port from the
167 // map name. See https://jira.secondlife.com/browse/VWR-28570
168 //
169 // Caller, use this magic form instead:
170 // secondlife://http|!!mygrid.com|8002|Region+Name/128/128
171 // or url encode if possible.
172 // the hacks we do with this viewer...
173 //
174 string mapNameOrig = mapName;
175 if (mapName.Contains("|"))
176 mapName = mapName.Replace('|', ':');
177 if (mapName.Contains("+"))
178 mapName = mapName.Replace('+', ' ');
179 if (mapName.Contains("!"))
180 mapName = mapName.Replace('!', '/');
181
182 // try to fetch from GridServer
183 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
184 // if (regionInfos.Count == 0)
185 // remoteClient.SendAlertMessage("Hyperlink could not be established.");
186
187 //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count);
188
189 MapBlockData data;
190 if (regionInfos.Count > 0)
191 {
192 foreach (GridRegion info in regionInfos)
193 {
194 data = new MapBlockData();
195 data.Agents = 0;
196 data.Access = info.Access;
197 if (flags == 2) // V2 sends this
198 {
199 List<MapBlockData> datas = WorldMap.Map2BlockFromGridRegion(info, flags);
200 // ugh! V2-3 is very sensitive about the result being
201 // exactly the same as the requested name
202
203 if (regionInfos.Count == 1 && (mapName != mapNameOrig))
204 datas.ForEach(d => d.Name = mapNameOrig);
205
206 blocks.AddRange(datas);
207 }
208 else
209 {
210 MapBlockData block = new MapBlockData();
211 WorldMap.MapBlockFromGridRegion(block,info, flags);
212 blocks.Add(block);
213 }
214 // ugh! V2-3 is very sensitive about the result being
215 // exactly the same as the requested name
216 if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+"))
217 data.Name = mapNameOrig;
218 else
219 data.Name = info.RegionName;
220 data.RegionFlags = 0; // TODO not used?
221 data.WaterHeight = 0; // not used
222 data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
223 data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
224 blocks.Add(data);
225 }
226 }
227
147 // final block, closing the search result 228 // final block, closing the search result
148 AddFinalBlock(blocks); 229 AddFinalBlock(blocks);
149 230
150 // flags are agent flags sent from the viewer. 231 // flags are agent flags sent from the viewer.
151 // they have different values depending on different viewers, apparently 232 // they have different values depending on different viewers, apparently
152 remoteClient.SendMapBlock(blocks, flags); 233 remoteClient.SendMapBlock(blocks, flags);
153 remoteClient.SendAlertMessage("Use a search string with at least 3 characters");
154 return;
155 }
156
157 234
235<<<<<<< HEAD
158 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); 236 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
159 237
160 string mapNameOrig = mapName; 238 string mapNameOrig = mapName;
@@ -221,6 +299,19 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
221 //else if (regionInfos.Count == 1) 299 //else if (regionInfos.Count == 1)
222 // remoteClient.SendAlertMessage("Region found!"); 300 // remoteClient.SendAlertMessage("Region found!");
223 } 301 }
302=======
303 // send extra user messages for V3
304 // because the UI is very confusing
305 // while we don't fix the hard-coded urls
306 if (flags == 2)
307 {
308 if (regionInfos.Count == 0)
309 remoteClient.SendAgentAlertMessage("No regions found with that name.", true);
310// else if (regionInfos.Count == 1)
311// remoteClient.SendAgentAlertMessage("Region found!", false);
312 }
313 });
314>>>>>>> avn/ubitvar
224 } 315 }
225 316
226 private void AddFinalBlock(List<MapBlockData> blocks) 317 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 db1187e..2fbd017 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -68,10 +68,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
68 private static readonly UUID STOP_UUID = UUID.Random(); 68 private static readonly UUID STOP_UUID = UUID.Random();
69 private static readonly string m_mapLayerPath = "0001/"; 69 private static readonly string m_mapLayerPath = "0001/";
70 70
71<<<<<<< HEAD
71 private IMapImageGenerator m_mapImageGenerator; 72 private IMapImageGenerator m_mapImageGenerator;
72 private IMapImageUploadModule m_mapImageServiceModule; 73 private IMapImageUploadModule m_mapImageServiceModule;
73 74
74 private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>(); 75 private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>();
76=======
77 private ManualResetEvent queueEvent = new ManualResetEvent(false);
78 private Queue<MapRequestState> requests = new Queue<MapRequestState>();
79
80 private ManualResetEvent m_mapBlockRequestEvent = new ManualResetEvent(false);
81 private Dictionary<UUID, Queue<MapBlockRequestData>> m_mapBlockRequests = new Dictionary<UUID, Queue<MapBlockRequestData>>();
82
83 private IMapImageGenerator m_mapImageGenerator;
84 private IMapImageUploadModule m_mapImageServiceModule;
85>>>>>>> avn/ubitvar
75 86
76 protected Scene m_scene; 87 protected Scene m_scene;
77 private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); 88 private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>();
@@ -79,15 +90,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
79 private int blacklistTimeout = 10*60*1000; // 10 minutes 90 private int blacklistTimeout = 10*60*1000; // 10 minutes
80 private byte[] myMapImageJPEG; 91 private byte[] myMapImageJPEG;
81 protected volatile bool m_Enabled = false; 92 protected volatile bool m_Enabled = false;
82 private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>();
83 private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); 93 private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>();
84 private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); 94 private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>();
85 private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>(); 95 private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>();
86 private List<UUID> m_rootAgents = new List<UUID>(); 96 private List<UUID> m_rootAgents = new List<UUID>();
87 private volatile bool threadrunning = false; 97 private volatile bool threadrunning = false;
88 98
89 private IServiceThrottleModule m_ServiceThrottle;
90
91 //private int CacheRegionsDistance = 256; 99 //private int CacheRegionsDistance = 256;
92 100
93 #region INonSharedRegionModule Members 101 #region INonSharedRegionModule Members
@@ -98,7 +106,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
98 if (Util.GetConfigVarFromSections<string>( 106 if (Util.GetConfigVarFromSections<string>(
99 config, "WorldMapModule", configSections, "WorldMap") == "WorldMap") 107 config, "WorldMapModule", configSections, "WorldMap") == "WorldMap")
100 m_Enabled = true; 108 m_Enabled = true;
101 109
102 blacklistTimeout 110 blacklistTimeout
103 = Util.GetConfigVarFromSections<int>(config, "BlacklistTimeout", configSections, 10 * 60) * 1000; 111 = Util.GetConfigVarFromSections<int>(config, "BlacklistTimeout", configSections, 10 * 60) * 1000;
104 } 112 }
@@ -146,7 +154,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
146 if (!m_Enabled) 154 if (!m_Enabled)
147 return; 155 return;
148 156
157<<<<<<< HEAD
149 m_ServiceThrottle = scene.RequestModuleInterface<IServiceThrottleModule>(); 158 m_ServiceThrottle = scene.RequestModuleInterface<IServiceThrottleModule>();
159=======
160 m_mapImageGenerator = m_scene.RequestModuleInterface<IMapImageGenerator>();
161 m_mapImageServiceModule = m_scene.RequestModuleInterface<IMapImageUploadModule>();
162 }
163>>>>>>> avn/ubitvar
150 164
151 m_mapImageGenerator = m_scene.RequestModuleInterface<IMapImageGenerator>(); 165 m_mapImageGenerator = m_scene.RequestModuleInterface<IMapImageGenerator>();
152 m_mapImageServiceModule = m_scene.RequestModuleInterface<IMapImageUploadModule>(); 166 m_mapImageServiceModule = m_scene.RequestModuleInterface<IMapImageUploadModule>();
@@ -197,13 +211,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
197 m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; 211 m_scene.EventManager.OnMakeRootAgent += MakeRootAgent;
198 m_scene.EventManager.OnRegionUp += OnRegionUp; 212 m_scene.EventManager.OnRegionUp += OnRegionUp;
199 213
200// StartThread(new object()); 214 StartThread(new object());
201 } 215 }
202 216
203 // this has to be called with a lock on m_scene 217 // this has to be called with a lock on m_scene
204 protected virtual void RemoveHandlers() 218 protected virtual void RemoveHandlers()
205 { 219 {
206// StopThread(); 220 StopThread();
207 221
208 m_scene.EventManager.OnRegionUp -= OnRegionUp; 222 m_scene.EventManager.OnRegionUp -= OnRegionUp;
209 m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent; 223 m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent;
@@ -261,6 +275,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
261 // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is 275 // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is
262 // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. 276 // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks.
263 277
278<<<<<<< HEAD
264 if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) 279 if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048)
265 { 280 {
266 ScenePresence avatarPresence = null; 281 ScenePresence avatarPresence = null;
@@ -309,6 +324,56 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
309 } 324 }
310 } 325 }
311 } 326 }
327=======
328 //if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048)
329 //{
330 // ScenePresence avatarPresence = null;
331
332 // m_scene.TryGetScenePresence(agentID, out avatarPresence);
333
334 // if (avatarPresence != null)
335 // {
336 // bool lookup = false;
337
338 // lock (cachedMapBlocks)
339 // {
340 // if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch()))
341 // {
342 // List<MapBlockData> mapBlocks;
343
344 // mapBlocks = cachedMapBlocks;
345 // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);
346 // }
347 // else
348 // {
349 // lookup = true;
350 // }
351 // }
352 // if (lookup)
353 // {
354 // List<MapBlockData> mapBlocks = new List<MapBlockData>(); ;
355
356 // List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
357 // (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize,
358 // (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize,
359 // (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize,
360 // (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize);
361 // foreach (GridRegion r in regions)
362 // {
363 // MapBlockData block = new MapBlockData();
364 // MapBlockFromGridRegion(block, r, 0);
365 // mapBlocks.Add(block);
366 // }
367 // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);
368
369 // lock (cachedMapBlocks)
370 // cachedMapBlocks = mapBlocks;
371
372 // cachedTime = Util.UnixTimeSinceEpoch();
373 // }
374 // }
375 //}
376>>>>>>> avn/ubitvar
312 377
313 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); 378 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
314 mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); 379 mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse());
@@ -335,7 +400,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
335 protected static OSDMapLayer GetOSDMapLayerResponse() 400 protected static OSDMapLayer GetOSDMapLayerResponse()
336 { 401 {
337 OSDMapLayer mapLayer = new OSDMapLayer(); 402 OSDMapLayer mapLayer = new OSDMapLayer();
403// mapLayer.Right = 2048;
338 mapLayer.Right = 5000; 404 mapLayer.Right = 5000;
405// mapLayer.Top = 2048;
339 mapLayer.Top = 5000; 406 mapLayer.Top = 5000;
340 mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); 407 mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006");
341 408
@@ -365,6 +432,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
365 { 432 {
366 m_rootAgents.Remove(AgentId); 433 m_rootAgents.Remove(AgentId);
367 } 434 }
435 lock (m_mapBlockRequestEvent)
436 {
437 if (m_mapBlockRequests.ContainsKey(AgentId))
438 m_mapBlockRequests.Remove(AgentId);
439 }
368 } 440 }
369 #endregion 441 #endregion
370 442
@@ -387,6 +459,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
387 ThreadPriority.BelowNormal, 459 ThreadPriority.BelowNormal,
388 true, 460 true,
389 true); 461 true);
462 Watchdog.StartThread(
463 MapBlockSendThread,
464 string.Format("MapBlockSendThread ({0})", m_scene.RegionInfo.RegionName),
465 ThreadPriority.BelowNormal,
466 true,
467 true);
390 } 468 }
391 469
392 /// <summary> 470 /// <summary>
@@ -402,7 +480,27 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
402 st.itemtype=0; 480 st.itemtype=0;
403 st.regionhandle=0; 481 st.regionhandle=0;
404 482
405 requests.Enqueue(st); 483 lock (requests)
484 {
485 queueEvent.Set();
486 requests.Enqueue(st);
487 }
488
489 MapBlockRequestData req = new MapBlockRequestData();
490
491 req.client = null;
492 req.minX = 0;
493 req.maxX = 0;
494 req.minY = 0;
495 req.maxY = 0;
496 req.flags = 0;
497
498 lock (m_mapBlockRequestEvent)
499 {
500 m_mapBlockRequests[UUID.Zero] = new Queue<MapBlockRequestData>();
501 m_mapBlockRequests[UUID.Zero].Enqueue(req);
502 m_mapBlockRequestEvent.Set();
503 }
406 } 504 }
407 505
408 public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, 506 public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags,
@@ -418,7 +516,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
418 uint xstart = 0; 516 uint xstart = 0;
419 uint ystart = 0; 517 uint ystart = 0;
420 Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out xstart, out ystart); 518 Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out xstart, out ystart);
519<<<<<<< HEAD
421 if (itemtype == (int)GridItemType.AgentLocations) 520 if (itemtype == (int)GridItemType.AgentLocations)
521=======
522
523 if (itemtype == 6) // Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots)
524>>>>>>> avn/ubitvar
422 { 525 {
423 if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) 526 if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
424 { 527 {
@@ -428,12 +531,22 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
428 mapItemReply mapitem = new mapItemReply(); 531 mapItemReply mapitem = new mapItemReply();
429 if (m_scene.GetRootAgentCount() <= 1) 532 if (m_scene.GetRootAgentCount() <= 1)
430 { 533 {
534<<<<<<< HEAD
431 mapitem = new mapItemReply( 535 mapitem = new mapItemReply(
432 xstart + 1, 536 xstart + 1,
433 ystart + 1, 537 ystart + 1,
434 UUID.Zero, 538 UUID.Zero,
435 Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()), 539 Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()),
436 0, 0); 540 0, 0);
541=======
542 mapitem = new mapItemReply();
543 mapitem.x = xstart + 1;
544 mapitem.y = ystart + 1;
545 mapitem.id = UUID.Zero;
546 mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString());
547 mapitem.Extra = 0;
548 mapitem.Extra2 = 0;
549>>>>>>> avn/ubitvar
437 mapitems.Add(mapitem); 550 mapitems.Add(mapitem);
438 } 551 }
439 else 552 else
@@ -443,12 +556,22 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
443 // Don't send a green dot for yourself 556 // Don't send a green dot for yourself
444 if (sp.UUID != remoteClient.AgentId) 557 if (sp.UUID != remoteClient.AgentId)
445 { 558 {
559<<<<<<< HEAD
446 mapitem = new mapItemReply( 560 mapitem = new mapItemReply(
447 xstart + (uint)sp.AbsolutePosition.X, 561 xstart + (uint)sp.AbsolutePosition.X,
448 ystart + (uint)sp.AbsolutePosition.Y, 562 ystart + (uint)sp.AbsolutePosition.Y,
449 UUID.Zero, 563 UUID.Zero,
450 Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()), 564 Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()),
451 1, 0); 565 1, 0);
566=======
567 mapitem = new mapItemReply();
568 mapitem.x = xstart + (uint)sp.AbsolutePosition.X;
569 mapitem.y = ystart + (uint)sp.AbsolutePosition.Y;
570 mapitem.id = UUID.Zero;
571 mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString());
572 mapitem.Extra = 1;
573 mapitem.Extra2 = 0;
574>>>>>>> avn/ubitvar
452 mapitems.Add(mapitem); 575 mapitems.Add(mapitem);
453 } 576 }
454 }); 577 });
@@ -493,6 +616,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
493 float x = (min.X+max.X)/2; 616 float x = (min.X+max.X)/2;
494 float y = (min.Y+max.Y)/2; 617 float y = (min.Y+max.Y)/2;
495 618
619<<<<<<< HEAD
496 mapitem = new mapItemReply( 620 mapitem = new mapItemReply(
497 xstart + (uint)x, 621 xstart + (uint)x,
498 ystart + (uint)y, 622 ystart + (uint)y,
@@ -501,6 +625,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
501 parcel.Area, 625 parcel.Area,
502 parcel.SalePrice 626 parcel.SalePrice
503 ); 627 );
628=======
629 mapitem = new mapItemReply();
630 mapitem.x = xstart + (uint)x;
631 mapitem.y = ystart +(uint)y;
632 // mapitem.z = (uint)m_scene.GetGroundHeight(x,y);
633 mapitem.id = parcel.GlobalID;
634 mapitem.name = parcel.Name;
635 mapitem.Extra = parcel.Area;
636 mapitem.Extra2 = parcel.SalePrice;
637>>>>>>> avn/ubitvar
504 mapitems.Add(mapitem); 638 mapitems.Add(mapitem);
505 } 639 }
506 } 640 }
@@ -525,6 +659,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
525 SceneObjectGroup sog = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject); 659 SceneObjectGroup sog = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject);
526 if (sog != null) 660 if (sog != null)
527 { 661 {
662<<<<<<< HEAD
528 mapitem = new mapItemReply( 663 mapitem = new mapItemReply(
529 xstart + (uint)sog.AbsolutePosition.X, 664 xstart + (uint)sog.AbsolutePosition.X,
530 ystart + (uint)sog.AbsolutePosition.Y, 665 ystart + (uint)sog.AbsolutePosition.Y,
@@ -533,6 +668,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
533 0, // color (not used) 668 0, // color (not used)
534 0 // 0 = telehub / 1 = infohub 669 0 // 0 = telehub / 1 = infohub
535 ); 670 );
671=======
672 mapitem = new mapItemReply();
673 mapitem.x = xstart + (uint)sog.AbsolutePosition.X;
674 mapitem.y = ystart + (uint)sog.AbsolutePosition.Y;
675 mapitem.id = UUID.Zero;
676 mapitem.name = sog.Name;
677 mapitem.Extra = 0; // color (not used)
678 mapitem.Extra2 = 0; // 0 = telehub / 1 = infohub
679>>>>>>> avn/ubitvar
536 mapitems.Add(mapitem); 680 mapitems.Add(mapitem);
537 681
538 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); 682 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
@@ -552,12 +696,26 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
552 /// </summary> 696 /// </summary>
553 public void process() 697 public void process()
554 { 698 {
555 //const int MAX_ASYNC_REQUESTS = 20; 699 const int MAX_ASYNC_REQUESTS = 20;
556 try 700 try
557 { 701 {
558 while (true) 702 while (true)
559 { 703 {
560 MapRequestState st = requests.Dequeue(1000); 704 MapRequestState st = new MapRequestState();
705 bool valid = false;
706 queueEvent.WaitOne();
707 lock (requests)
708 {
709 if (requests.Count > 0)
710 {
711 st = requests.Dequeue();
712 valid = true;
713 }
714 if (requests.Count == 0)
715 queueEvent.Reset();
716 }
717 if (!valid)
718 continue;
561 719
562 // end gracefully 720 // end gracefully
563 if (st.agentID == STOP_UUID) 721 if (st.agentID == STOP_UUID)
@@ -575,13 +733,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
575 if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) 733 if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle))
576 { 734 {
577 while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break 735 while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break
578 Thread.Sleep(80); 736 Thread.Sleep(100);
579 737
580 RequestMapItemsDelegate d = RequestMapItemsAsync;
581 d.BeginInvoke(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle, RequestMapItemsCompleted, null);
582 //OSDMap response = RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle);
583 //RequestMapItemsCompleted(response);
584 Interlocked.Increment(ref nAsyncRequests); 738 Interlocked.Increment(ref nAsyncRequests);
739 Util.FireAndForget(x =>
740 {
741 RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle);
742 });
585 } 743 }
586 } 744 }
587 745
@@ -597,17 +755,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
597 Watchdog.RemoveThread(); 755 Watchdog.RemoveThread();
598 } 756 }
599 757
600 const int MAX_ASYNC_REQUESTS = 20;
601
602 /// <summary> 758 /// <summary>
603 /// Enqueues the map item request into the services throttle processing thread 759 /// Enqueues the map item request into the processing thread
604 /// </summary> 760 /// </summary>
605 /// <param name="state"></param> 761 /// <param name="state"></param>
606 public void EnqueueMapItemRequest(MapRequestState st) 762 public void EnqueueMapItemRequest(MapRequestState state)
607 { 763 {
608 764 lock (requests)
609 m_ServiceThrottle.Enqueue("map-item", st.regionhandle.ToString() + st.agentID.ToString(), delegate
610 { 765 {
766<<<<<<< HEAD
611 if (st.agentID != UUID.Zero) 767 if (st.agentID != UUID.Zero)
612 { 768 {
613 bool dorequest = true; 769 bool dorequest = true;
@@ -723,6 +879,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
723 } 879 }
724 } 880 }
725 } 881 }
882=======
883 queueEvent.Set();
884 requests.Enqueue(state);
885>>>>>>> avn/ubitvar
726 } 886 }
727 } 887 }
728 888
@@ -749,8 +909,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
749 EnqueueMapItemRequest(st); 909 EnqueueMapItemRequest(st);
750 } 910 }
751 911
752 private delegate OSDMap RequestMapItemsDelegate(UUID id, uint flags,
753 uint EstateID, bool godlike, uint itemtype, ulong regionhandle);
754 /// <summary> 912 /// <summary>
755 /// Does the actual remote mapitem request 913 /// Does the actual remote mapitem request
756 /// This should be called from an asynchronous thread 914 /// This should be called from an asynchronous thread
@@ -765,7 +923,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
765 /// <param name="itemtype">passed in from packet</param> 923 /// <param name="itemtype">passed in from packet</param>
766 /// <param name="regionhandle">Region we're looking up</param> 924 /// <param name="regionhandle">Region we're looking up</param>
767 /// <returns></returns> 925 /// <returns></returns>
768 private OSDMap RequestMapItemsAsync(UUID id, uint flags, 926 private void RequestMapItemsAsync(UUID id, uint flags,
769 uint EstateID, bool godlike, uint itemtype, ulong regionhandle) 927 uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
770 { 928 {
771// m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); 929// m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype);
@@ -788,7 +946,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
788 } 946 }
789 947
790 if (blacklisted) 948 if (blacklisted)
791 return new OSDMap(); 949 {
950 Interlocked.Decrement(ref nAsyncRequests);
951 return;
952 }
792 953
793 UUID requestID = UUID.Random(); 954 UUID requestID = UUID.Random();
794 lock (m_cachedRegionMapItemsAddress) 955 lock (m_cachedRegionMapItemsAddress)
@@ -796,6 +957,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
796 if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) 957 if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle))
797 httpserver = m_cachedRegionMapItemsAddress[regionhandle]; 958 httpserver = m_cachedRegionMapItemsAddress[regionhandle];
798 } 959 }
960
799 if (httpserver.Length == 0) 961 if (httpserver.Length == 0)
800 { 962 {
801 uint x = 0, y = 0; 963 uint x = 0, y = 0;
@@ -840,18 +1002,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
840 1002
841 // Can't find the http server 1003 // Can't find the http server
842 if (httpserver.Length == 0 || blacklisted) 1004 if (httpserver.Length == 0 || blacklisted)
843 return new OSDMap(); 1005 {
844 1006 Interlocked.Decrement(ref nAsyncRequests);
845 MapRequestState mrs = new MapRequestState(); 1007 return;
846 mrs.agentID = id; 1008 }
847 mrs.EstateID = EstateID;
848 mrs.flags = flags;
849 mrs.godlike = godlike;
850 mrs.itemtype=itemtype;
851 mrs.regionhandle = regionhandle;
852
853 lock (m_openRequests)
854 m_openRequests.Add(requestID, mrs);
855 1009
856 WebRequest mapitemsrequest = null; 1010 WebRequest mapitemsrequest = null;
857 try 1011 try
@@ -861,7 +1015,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
861 catch (Exception e) 1015 catch (Exception e)
862 { 1016 {
863 m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e); 1017 m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e);
864 return new OSDMap(); 1018 Interlocked.Decrement(ref nAsyncRequests);
1019 return;
865 } 1020 }
866 1021
867 mapitemsrequest.Method = "POST"; 1022 mapitemsrequest.Method = "POST";
@@ -895,13 +1050,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
895 1050
896 m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); 1051 m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver);
897 1052
898 return responseMap; 1053 Interlocked.Decrement(ref nAsyncRequests);
1054 return;
899 } 1055 }
900 catch 1056 catch
901 { 1057 {
902 m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); 1058 m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver);
903 responseMap["connect"] = OSD.FromBoolean(false); 1059 Interlocked.Decrement(ref nAsyncRequests);
904 return responseMap; 1060 return;
905 } 1061 }
906 finally 1062 finally
907 { 1063 {
@@ -910,26 +1066,24 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
910 } 1066 }
911 1067
912 string response_mapItems_reply = null; 1068 string response_mapItems_reply = null;
913 { 1069 { // get the response
1070 StreamReader sr = null;
914 try 1071 try
915 { 1072 {
916 using (WebResponse webResponse = mapitemsrequest.GetResponse()) 1073 WebResponse webResponse = mapitemsrequest.GetResponse();
1074 if (webResponse != null)
917 { 1075 {
918 if (webResponse != null) 1076 sr = new StreamReader(webResponse.GetResponseStream());
919 { 1077 response_mapItems_reply = sr.ReadToEnd().Trim();
920 using (Stream s = webResponse.GetResponseStream()) 1078 }
921 using (StreamReader sr = new StreamReader(s)) 1079 else
922 response_mapItems_reply = sr.ReadToEnd().Trim(); 1080 {
923 } 1081 Interlocked.Decrement(ref nAsyncRequests);
924 else 1082 return;
925 { 1083 }
926 return new OSDMap();
927 }
928 }
929 } 1084 }
930 catch (WebException) 1085 catch (WebException)
931 { 1086 {
932 responseMap["connect"] = OSD.FromBoolean(false);
933 lock (m_blacklistedurls) 1087 lock (m_blacklistedurls)
934 { 1088 {
935 if (!m_blacklistedurls.ContainsKey(httpserver)) 1089 if (!m_blacklistedurls.ContainsKey(httpserver))
@@ -938,19 +1092,25 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
938 1092
939 m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); 1093 m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver);
940 1094
941 return responseMap; 1095 Interlocked.Decrement(ref nAsyncRequests);
1096 return;
942 } 1097 }
943 catch 1098 catch
944 { 1099 {
945 m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); 1100 m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver);
946 responseMap["connect"] = OSD.FromBoolean(false);
947 lock (m_blacklistedregions) 1101 lock (m_blacklistedregions)
948 { 1102 {
949 if (!m_blacklistedregions.ContainsKey(regionhandle)) 1103 if (!m_blacklistedregions.ContainsKey(regionhandle))
950 m_blacklistedregions.Add(regionhandle, Environment.TickCount); 1104 m_blacklistedregions.Add(regionhandle, Environment.TickCount);
951 } 1105 }
952 1106
953 return responseMap; 1107 Interlocked.Decrement(ref nAsyncRequests);
1108 return;
1109 }
1110 finally
1111 {
1112 if (sr != null)
1113 sr.Close();
954 } 1114 }
955 1115
956 OSD rezResponse = null; 1116 OSD rezResponse = null;
@@ -964,15 +1124,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
964 catch (Exception ex) 1124 catch (Exception ex)
965 { 1125 {
966 m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); 1126 m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message);
967 responseMap["connect"] = OSD.FromBoolean(false);
968
969 lock (m_blacklistedregions) 1127 lock (m_blacklistedregions)
970 { 1128 {
971 if (!m_blacklistedregions.ContainsKey(regionhandle)) 1129 if (!m_blacklistedregions.ContainsKey(regionhandle))
972 m_blacklistedregions.Add(regionhandle, Environment.TickCount); 1130 m_blacklistedregions.Add(regionhandle, Environment.TickCount);
973 } 1131 }
974 1132
975 return responseMap; 1133 Interlocked.Decrement(ref nAsyncRequests);
1134 return;
976 } 1135 }
977 } 1136 }
978 1137
@@ -986,7 +1145,78 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
986 } 1145 }
987 } 1146 }
988 1147
989 return responseMap; 1148 Interlocked.Decrement(ref nAsyncRequests);
1149
1150 if (id != UUID.Zero)
1151 {
1152 ScenePresence av = null;
1153 m_scene.TryGetScenePresence(id, out av);
1154 if (av != null)
1155 {
1156 if (responseMap.ContainsKey(itemtype.ToString()))
1157 {
1158 List<mapItemReply> returnitems = new List<mapItemReply>();
1159 OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()];
1160 for (int i = 0; i < itemarray.Count; i++)
1161 {
1162 OSDMap mapitem = (OSDMap)itemarray[i];
1163 mapItemReply mi = new mapItemReply();
1164 mi.x = (uint)mapitem["X"].AsInteger();
1165 mi.y = (uint)mapitem["Y"].AsInteger();
1166 mi.id = mapitem["ID"].AsUUID();
1167 mi.Extra = mapitem["Extra"].AsInteger();
1168 mi.Extra2 = mapitem["Extra2"].AsInteger();
1169 mi.name = mapitem["Name"].AsString();
1170 returnitems.Add(mi);
1171 }
1172 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
1173 }
1174
1175 // Service 7 (MAP_ITEM_LAND_FOR_SALE)
1176 itemtype = 7;
1177
1178 if (responseMap.ContainsKey(itemtype.ToString()))
1179 {
1180 List<mapItemReply> returnitems = new List<mapItemReply>();
1181 OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()];
1182 for (int i = 0; i < itemarray.Count; i++)
1183 {
1184 OSDMap mapitem = (OSDMap)itemarray[i];
1185 mapItemReply mi = new mapItemReply();
1186 mi.x = (uint)mapitem["X"].AsInteger();
1187 mi.y = (uint)mapitem["Y"].AsInteger();
1188 mi.id = mapitem["ID"].AsUUID();
1189 mi.Extra = mapitem["Extra"].AsInteger();
1190 mi.Extra2 = mapitem["Extra2"].AsInteger();
1191 mi.name = mapitem["Name"].AsString();
1192 returnitems.Add(mi);
1193 }
1194 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
1195 }
1196
1197 // Service 1 (MAP_ITEM_TELEHUB)
1198 itemtype = 1;
1199
1200 if (responseMap.ContainsKey(itemtype.ToString()))
1201 {
1202 List<mapItemReply> returnitems = new List<mapItemReply>();
1203 OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()];
1204 for (int i = 0; i < itemarray.Count; i++)
1205 {
1206 OSDMap mapitem = (OSDMap)itemarray[i];
1207 mapItemReply mi = new mapItemReply();
1208 mi.x = (uint)mapitem["X"].AsInteger();
1209 mi.y = (uint)mapitem["Y"].AsInteger();
1210 mi.id = mapitem["ID"].AsUUID();
1211 mi.Extra = mapitem["Extra"].AsInteger();
1212 mi.Extra2 = mapitem["Extra2"].AsInteger();
1213 mi.name = mapitem["Name"].AsString();
1214 returnitems.Add(mi);
1215 }
1216 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
1217 }
1218 }
1219 }
990 } 1220 }
991 1221
992 /// <summary> 1222 /// <summary>
@@ -996,8 +1226,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
996 /// <param name="minY"></param> 1226 /// <param name="minY"></param>
997 /// <param name="maxX"></param> 1227 /// <param name="maxX"></param>
998 /// <param name="maxY"></param> 1228 /// <param name="maxY"></param>
999 public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 1229 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
1000 { 1230 {
1231<<<<<<< HEAD
1232=======
1233 m_log.DebugFormat("[WoldMapModule] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag);
1234/* this flag does not seem to mean what his says
1235>>>>>>> avn/ubitvar
1001 if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible 1236 if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible
1002 { 1237 {
1003 List<MapBlockData> response = new List<MapBlockData>(); 1238 List<MapBlockData> response = new List<MapBlockData>();
@@ -1006,15 +1241,24 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1006 // on an unloaded square. 1241 // on an unloaded square.
1007 // But make sure: Look whether the one we requested is in there 1242 // But make sure: Look whether the one we requested is in there
1008 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, 1243 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
1244<<<<<<< HEAD
1009 (int)Util.RegionToWorldLoc((uint)minX), (int)Util.RegionToWorldLoc((uint)maxX), 1245 (int)Util.RegionToWorldLoc((uint)minX), (int)Util.RegionToWorldLoc((uint)maxX),
1010 (int)Util.RegionToWorldLoc((uint)minY), (int)Util.RegionToWorldLoc((uint)maxY) ); 1246 (int)Util.RegionToWorldLoc((uint)minY), (int)Util.RegionToWorldLoc((uint)maxY) );
1011 1247
1012 m_log.DebugFormat("[WORLD MAP MODULE] RequestMapBlocks min=<{0},{1}>, max=<{2},{3}>, flag={4}, cntFound={5}", 1248 m_log.DebugFormat("[WORLD MAP MODULE] RequestMapBlocks min=<{0},{1}>, max=<{2},{3}>, flag={4}, cntFound={5}",
1013 minX, minY, maxX, maxY, flag.ToString("X"), regions.Count); 1249 minX, minY, maxX, maxY, flag.ToString("X"), regions.Count);
1250=======
1251 (int)Util.RegionToWorldLoc((uint)minX),
1252 (int)Util.RegionToWorldLoc((uint)maxX),
1253 (int)Util.RegionToWorldLoc((uint)minY),
1254 (int)Util.RegionToWorldLoc((uint)maxY) );
1255
1256>>>>>>> avn/ubitvar
1014 if (regions != null) 1257 if (regions != null)
1015 { 1258 {
1016 foreach (GridRegion r in regions) 1259 foreach (GridRegion r in regions)
1017 { 1260 {
1261<<<<<<< HEAD
1018 if (r.RegionLocX == Util.RegionToWorldLoc((uint)minX) 1262 if (r.RegionLocX == Util.RegionToWorldLoc((uint)minX)
1019 && r.RegionLocY == Util.RegionToWorldLoc((uint)minY) ) 1263 && r.RegionLocY == Util.RegionToWorldLoc((uint)minY) )
1020 { 1264 {
@@ -1024,6 +1268,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1024 response.AddRange(Map2BlockFromGridRegion(r, flag)); 1268 response.AddRange(Map2BlockFromGridRegion(r, flag));
1025 else 1269 else
1026 response.Add(MapBlockFromGridRegion(r, flag)); 1270 response.Add(MapBlockFromGridRegion(r, flag));
1271=======
1272 if (r.RegionLocX == Util.RegionToWorldLoc((uint)minX) &&
1273 r.RegionLocY == Util.RegionToWorldLoc((uint)minY))
1274 {
1275 // found it => add it to response
1276 MapBlockData block = new MapBlockData();
1277 if ((flag & 2) == 2)
1278 response.AddRange(Map2BlockFromGridRegion(r, flag));
1279 else
1280 {
1281 MapBlockFromGridRegion(block, r, flag);
1282 response.Add(block);
1283 }
1284>>>>>>> avn/ubitvar
1027 break; 1285 break;
1028 } 1286 }
1029 } 1287 }
@@ -1036,7 +1294,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1036 block.X = (ushort)minX; 1294 block.X = (ushort)minX;
1037 block.Y = (ushort)minY; 1295 block.Y = (ushort)minY;
1038 block.Access = (byte)SimAccess.Down; // means 'simulator is offline' 1296 block.Access = (byte)SimAccess.Down; // means 'simulator is offline'
1297<<<<<<< HEAD
1039 // block.Access = (byte)SimAccess.NonExistent; 1298 // block.Access = (byte)SimAccess.NonExistent;
1299=======
1300>>>>>>> avn/ubitvar
1040 response.Add(block); 1301 response.Add(block);
1041 } 1302 }
1042 // The lower 16 bits are an unsigned int16 1303 // The lower 16 bits are an unsigned int16
@@ -1045,14 +1306,74 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1045 else 1306 else
1046 { 1307 {
1047 // normal mapblock request. Use the provided values 1308 // normal mapblock request. Use the provided values
1309 */
1048 GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag); 1310 GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag);
1049 } 1311 // }
1050 } 1312 }
1051 1313
1052 protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 1314 protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
1053 { 1315 {
1316 MapBlockRequestData req = new MapBlockRequestData();
1317
1318 req.client = remoteClient;
1319 req.minX = minX;
1320 req.maxX = maxX;
1321 req.minY = minY;
1322 req.maxY = maxY;
1323 req.flags = flag;
1324
1325 lock (m_mapBlockRequestEvent)
1326 {
1327 if (!m_mapBlockRequests.ContainsKey(remoteClient.AgentId))
1328 m_mapBlockRequests[remoteClient.AgentId] = new Queue<MapBlockRequestData>();
1329 m_mapBlockRequests[remoteClient.AgentId].Enqueue(req);
1330 m_mapBlockRequestEvent.Set();
1331 }
1332
1333 return new List<MapBlockData>();
1334 }
1335
1336 protected void MapBlockSendThread()
1337 {
1338 while (true)
1339 {
1340 List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>();
1341
1342 m_mapBlockRequestEvent.WaitOne();
1343 lock (m_mapBlockRequestEvent)
1344 {
1345 int total = 0;
1346 foreach (Queue<MapBlockRequestData> q in m_mapBlockRequests.Values)
1347 {
1348 if (q.Count > 0)
1349 thisRunData.Add(q.Dequeue());
1350
1351 total += q.Count;
1352 }
1353
1354 if (total == 0)
1355 m_mapBlockRequestEvent.Reset();
1356 }
1357
1358 foreach (MapBlockRequestData req in thisRunData)
1359 {
1360 // Null client stops thread
1361 if (req.client == null)
1362 return;
1363
1364 GetAndSendBlocksInternal(req.client, req.minX, req.minY, req.maxX, req.maxY, req.flags);
1365 }
1366
1367 Thread.Sleep(50);
1368 }
1369 }
1370
1371 protected virtual List<MapBlockData> GetAndSendBlocksInternal(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
1372 {
1373 List<MapBlockData> allBlocks = new List<MapBlockData>();
1054 List<MapBlockData> mapBlocks = new List<MapBlockData>(); 1374 List<MapBlockData> mapBlocks = new List<MapBlockData>();
1055 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, 1375 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
1376<<<<<<< HEAD
1056 (int)Util.RegionToWorldLoc((uint)(minX - 4)), (int)Util.RegionToWorldLoc((uint)(maxX + 4)), 1377 (int)Util.RegionToWorldLoc((uint)(minX - 4)), (int)Util.RegionToWorldLoc((uint)(maxX + 4)),
1057 (int)Util.RegionToWorldLoc((uint)(minY - 4)), (int)Util.RegionToWorldLoc((uint)(maxY + 4)) ); 1378 (int)Util.RegionToWorldLoc((uint)(minY - 4)), (int)Util.RegionToWorldLoc((uint)(maxY + 4)) );
1058 //m_log.DebugFormat("{0} GetAndSendBlocks. min=<{1},{2}>, max=<{3},{4}>, cntFound={5}", 1379 //m_log.DebugFormat("{0} GetAndSendBlocks. min=<{1},{2}>, max=<{3},{4}>, cntFound={5}",
@@ -1064,14 +1385,65 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1064 mapBlocks.AddRange(Map2BlockFromGridRegion(r, flag)); 1385 mapBlocks.AddRange(Map2BlockFromGridRegion(r, flag));
1065 else 1386 else
1066 mapBlocks.Add(MapBlockFromGridRegion(r, flag)); 1387 mapBlocks.Add(MapBlockFromGridRegion(r, flag));
1388=======
1389 minX * (int)Constants.RegionSize,
1390 maxX * (int)Constants.RegionSize,
1391 minY * (int)Constants.RegionSize,
1392 maxY * (int)Constants.RegionSize);
1393// (minX - 4) * (int)Constants.RegionSize,
1394// (maxX + 4) * (int)Constants.RegionSize,
1395// (minY - 4) * (int)Constants.RegionSize,
1396// (maxY + 4) * (int)Constants.RegionSize);
1397
1398 //mb it means this
1399 if(regions.Count == 0 && (flag & 0x10000) != 0)
1400 {
1401 MapBlockData block = new MapBlockData();
1402 block.X = (ushort)minX;
1403 block.Y = (ushort)minY;
1404 block.MapImageId = UUID.Zero;
1405 block.Access = (byte)SimAccess.NonExistent;
1406 allBlocks.Add(block);
1407 mapBlocks.Add(block);
1408 remoteClient.SendMapBlock(mapBlocks, flag & 0xffff);
1409 return allBlocks;
1410>>>>>>> avn/ubitvar
1067 } 1411 }
1068 remoteClient.SendMapBlock(mapBlocks, flag & 0xffff);
1069 1412
1070 return mapBlocks; 1413 foreach (GridRegion r in regions)
1414 {
1415 MapBlockData block = new MapBlockData();
1416 if ((flag & 2) == 2)
1417 {
1418 List<MapBlockData> blocks = Map2BlockFromGridRegion(r, flag);
1419 mapBlocks.AddRange(blocks);
1420 allBlocks.AddRange(blocks);
1421 }
1422 else
1423 {
1424 MapBlockFromGridRegion(block, r, flag);
1425 mapBlocks.Add(block);
1426 allBlocks.Add(block);
1427 }
1428 if (mapBlocks.Count >= 10)
1429 {
1430 remoteClient.SendMapBlock(mapBlocks, flag & 0xffff);
1431 mapBlocks.Clear();
1432 Thread.Sleep(50);
1433 }
1434 }
1435 if (mapBlocks.Count > 0)
1436 remoteClient.SendMapBlock(mapBlocks, flag & 0xffff);
1437
1438 return allBlocks;
1071 } 1439 }
1072 1440
1441<<<<<<< HEAD
1073 // Fill a passed MapBlockData from a GridRegion 1442 // Fill a passed MapBlockData from a GridRegion
1074 public MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag) 1443 public MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag)
1444=======
1445 public void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag)
1446>>>>>>> avn/ubitvar
1075 { 1447 {
1076 MapBlockData block = new MapBlockData(); 1448 MapBlockData block = new MapBlockData();
1077 1449
@@ -1089,12 +1461,54 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1089 break; 1461 break;
1090 } 1462 }
1091 block.Name = r.RegionName; 1463 block.Name = r.RegionName;
1464<<<<<<< HEAD
1092 block.X = (ushort)Util.WorldToRegionLoc((uint)r.RegionLocX); 1465 block.X = (ushort)Util.WorldToRegionLoc((uint)r.RegionLocX);
1093 block.Y = (ushort)Util.WorldToRegionLoc((uint)r.RegionLocY); 1466 block.Y = (ushort)Util.WorldToRegionLoc((uint)r.RegionLocY);
1094 block.SizeX = (ushort) r.RegionSizeX; 1467 block.SizeX = (ushort) r.RegionSizeX;
1095 block.SizeY = (ushort) r.RegionSizeY; 1468 block.SizeY = (ushort) r.RegionSizeY;
1096 1469
1097 return block; 1470 return block;
1471=======
1472 block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
1473 block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
1474 block.SizeX = (ushort)r.RegionSizeX;
1475 block.SizeY = (ushort)r.RegionSizeY;
1476 }
1477
1478 public List<MapBlockData> Map2BlockFromGridRegion(GridRegion r, uint flag)
1479 {
1480 List<MapBlockData> blocks = new List<MapBlockData>();
1481 MapBlockData block = new MapBlockData();
1482 if (r == null)
1483 {
1484 block.Access = (byte)SimAccess.Down;
1485 block.MapImageId = UUID.Zero;
1486 blocks.Add(block);
1487 }
1488 else
1489 {
1490 block.Access = r.Access;
1491 switch (flag & 0xffff)
1492 {
1493 case 0:
1494 block.MapImageId = r.TerrainImage;
1495 break;
1496 case 2:
1497 block.MapImageId = r.ParcelImage;
1498 break;
1499 default:
1500 block.MapImageId = UUID.Zero;
1501 break;
1502 }
1503 block.Name = r.RegionName;
1504 block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
1505 block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
1506 block.SizeX = (ushort)r.RegionSizeX;
1507 block.SizeY = (ushort)r.RegionSizeY;
1508 blocks.Add(block);
1509 }
1510 return blocks;
1511>>>>>>> avn/ubitvar
1098 } 1512 }
1099 1513
1100 public List<MapBlockData> Map2BlockFromGridRegion(GridRegion r, uint flag) 1514 public List<MapBlockData> Map2BlockFromGridRegion(GridRegion r, uint flag)
@@ -1338,9 +1752,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1338 uint xstart = 0; 1752 uint xstart = 0;
1339 uint ystart = 0; 1753 uint ystart = 0;
1340 1754
1755<<<<<<< HEAD
1341 Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle,out xstart,out ystart); 1756 Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle,out xstart,out ystart);
1342 // m_log.DebugFormat("{0} HandleRemoteMapItemRequest. loc=<{1},{2}>", 1757 // m_log.DebugFormat("{0} HandleRemoteMapItemRequest. loc=<{1},{2}>",
1343 // LogHeader, Util.WorldToRegionLoc(xstart), Util.WorldToRegionLoc(ystart)); 1758 // LogHeader, Util.WorldToRegionLoc(xstart), Util.WorldToRegionLoc(ystart));
1759=======
1760 Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out xstart, out ystart);
1761>>>>>>> avn/ubitvar
1344 1762
1345 // Service 6 (MAP_ITEM_AGENTS_LOCATION; green dots) 1763 // Service 6 (MAP_ITEM_AGENTS_LOCATION; green dots)
1346 1764
@@ -1362,7 +1780,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1362 } 1780 }
1363 else 1781 else
1364 { 1782 {
1365 OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); 1783 OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount());
1366 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 1784 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
1367 { 1785 {
1368 OSDMap responsemapdata = new OSDMap(); 1786 OSDMap responsemapdata = new OSDMap();
@@ -1460,6 +1878,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1460 return; 1878 return;
1461 1879
1462 m_log.DebugFormat("[WORLD MAP]: Generating map image for {0}", m_scene.Name); 1880 m_log.DebugFormat("[WORLD MAP]: Generating map image for {0}", m_scene.Name);
1881<<<<<<< HEAD
1463 1882
1464 using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile()) 1883 using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile())
1465 { 1884 {
@@ -1475,6 +1894,23 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1475 { 1894 {
1476 byte[] data; 1895 byte[] data;
1477 1896
1897=======
1898
1899 using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile())
1900 {
1901 // V1 (This Module)
1902 GenerateMaptile(mapbmp);
1903
1904 // v2/3 (MapImageServiceModule)
1905 m_mapImageServiceModule.UploadMapTile(m_scene, mapbmp);
1906 }
1907 }
1908
1909 private void GenerateMaptile(Bitmap mapbmp)
1910 {
1911 byte[] data;
1912
1913>>>>>>> avn/ubitvar
1478 try 1914 try
1479 { 1915 {
1480 data = OpenJPEG.EncodeFromImage(mapbmp, true); 1916 data = OpenJPEG.EncodeFromImage(mapbmp, true);
@@ -1553,6 +1989,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1553 { 1989 {
1554 m_rootAgents.Remove(avatar.UUID); 1990 m_rootAgents.Remove(avatar.UUID);
1555 } 1991 }
1992
1993 lock (m_mapBlockRequestEvent)
1994 {
1995 if (m_mapBlockRequests.ContainsKey(avatar.UUID))
1996 m_mapBlockRequests.Remove(avatar.UUID);
1997 }
1556 } 1998 }
1557 1999
1558 public void OnRegionUp(GridRegion otherRegion) 2000 public void OnRegionUp(GridRegion otherRegion)
@@ -1585,7 +2027,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1585 int regionSizeX = (int)m_scene.RegionInfo.RegionSizeX; 2027 int regionSizeX = (int)m_scene.RegionInfo.RegionSizeX;
1586 int regionSizeY = (int)m_scene.RegionInfo.RegionSizeY; 2028 int regionSizeY = (int)m_scene.RegionInfo.RegionSizeY;
1587 2029
2030<<<<<<< HEAD
1588 int landTileSize = LandManagementModule.LandUnit; 2031 int landTileSize = LandManagementModule.LandUnit;
2032=======
2033 int landTileSize = LandManagementModule.landUnit;
2034>>>>>>> avn/ubitvar
1589 int regionLandTilesX = regionSizeX / landTileSize; 2035 int regionLandTilesX = regionSizeX / landTileSize;
1590 int regionLandTilesY = regionSizeY / landTileSize; 2036 int regionLandTilesY = regionSizeY / landTileSize;
1591 2037
@@ -1608,6 +2054,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1608 { 2054 {
1609 using (SolidBrush transparent = new SolidBrush(background)) 2055 using (SolidBrush transparent = new SolidBrush(background))
1610 g.FillRectangle(transparent, 0, 0, regionSizeX, regionSizeY); 2056 g.FillRectangle(transparent, 0, 0, regionSizeX, regionSizeY);
2057<<<<<<< HEAD
2058=======
2059
2060>>>>>>> avn/ubitvar
1611 2061
1612 foreach (ILandObject land in parcels) 2062 foreach (ILandObject land in parcels)
1613 { 2063 {
@@ -1630,6 +2080,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1630 2080
1631 using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9))) 2081 using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)))
1632 { 2082 {
2083<<<<<<< HEAD
1633 for (int x = 0 ; x < regionLandTilesX ; x++) 2084 for (int x = 0 ; x < regionLandTilesX ; x++)
1634 { 2085 {
1635 for (int y = 0 ; y < regionLandTilesY ; y++) 2086 for (int y = 0 ; y < regionLandTilesY ; y++)
@@ -1639,6 +2090,18 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1639 yellow, x * landTileSize, 2090 yellow, x * landTileSize,
1640 regionSizeX - landTileSize - (y * landTileSize), 2091 regionSizeX - landTileSize - (y * landTileSize),
1641 landTileSize, 2092 landTileSize,
2093=======
2094 for (int x = 0; x < regionLandTilesX ; x++)
2095 {
2096 for (int y = 0; y < regionLandTilesY ; y++)
2097 {
2098 if (saleBitmap[x, y])
2099 g.FillRectangle(
2100 yellow,
2101 x * landTileSize,
2102 regionSizeX - landTileSize - (y * landTileSize),
2103 landTileSize,
2104>>>>>>> avn/ubitvar
1642 landTileSize); 2105 landTileSize);
1643 } 2106 }
1644 } 2107 }
@@ -1668,4 +2131,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1668 public uint itemtype; 2131 public uint itemtype;
1669 public ulong regionhandle; 2132 public ulong regionhandle;
1670 } 2133 }
2134
2135 public struct MapBlockRequestData
2136 {
2137 public IClientAPI client;
2138 public int minX;
2139 public int minY;
2140 public int maxX;
2141 public int maxY;
2142 public uint flags;
2143 }
1671} 2144}