aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-14 11:44:17 -0700
committerJohn Hurliman2009-10-14 11:44:17 -0700
commit4b5a2f8c024b63f75b122916f6322f2f04d79f42 (patch)
treee4c3b1d086a70c6d50b91bca6f61a08b77b65188
parent* Minimized the number of times textures are pulled off the priority queue (diff)
parentMerge branch 'master' into htb-throttle (diff)
downloadopensim-SC-4b5a2f8c024b63f75b122916f6322f2f04d79f42.zip
opensim-SC-4b5a2f8c024b63f75b122916f6322f2f04d79f42.tar.gz
opensim-SC-4b5a2f8c024b63f75b122916f6322f2f04d79f42.tar.bz2
opensim-SC-4b5a2f8c024b63f75b122916f6322f2f04d79f42.tar.xz
Merge branch 'htb-throttle' of ssh://opensimulator.org/var/git/opensim into htb-throttle
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs5
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs14
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs50
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs5
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs307
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs44
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs3
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/IHyperService.cs37
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs98
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs114
-rw-r--r--OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs1
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs6
-rw-r--r--bin/config-include/FlotsamCache.ini.example7
18 files changed, 610 insertions, 129 deletions
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 3b561d1..f514076 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -151,7 +151,10 @@ namespace OpenSim.Data.MySQL
151 151
152 DataTable schemaTable = result.GetSchemaTable(); 152 DataTable schemaTable = result.GetSchemaTable();
153 foreach (DataRow row in schemaTable.Rows) 153 foreach (DataRow row in schemaTable.Rows)
154 m_ColumnNames.Add(row["ColumnName"].ToString()); 154 {
155 if (row["ColumnName"] != null)
156 m_ColumnNames.Add(row["ColumnName"].ToString());
157 }
155 } 158 }
156 159
157 foreach (string s in m_ColumnNames) 160 foreach (string s in m_ColumnNames)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
index 9ded390..b53a2fb 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
@@ -31,6 +31,7 @@ using OpenMetaverse;
31using OpenMetaverse.Imaging; 31using OpenMetaverse.Imaging;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes.Hypergrid;
34using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
35using log4net; 36using log4net;
36using System.Reflection; 37using System.Reflection;
@@ -54,6 +55,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
54 public UUID TextureID; 55 public UUID TextureID;
55 public IJ2KDecoder J2KDecoder; 56 public IJ2KDecoder J2KDecoder;
56 public IAssetService AssetService; 57 public IAssetService AssetService;
58 public UUID AgentID;
59 public IHyperAssetService HyperAssets;
57 public OpenJPEG.J2KLayerInfo[] Layers; 60 public OpenJPEG.J2KLayerInfo[] Layers;
58 public bool IsDecoded; 61 public bool IsDecoded;
59 public bool HasAsset; 62 public bool HasAsset;
@@ -373,6 +376,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
373 UUID assetID = UUID.Zero; 376 UUID assetID = UUID.Zero;
374 if (asset != null) 377 if (asset != null)
375 assetID = asset.FullID; 378 assetID = asset.FullID;
379 else if ((HyperAssets != null) && (sender != HyperAssets))
380 {
381 // Try the user's inventory, but only if it's different from the regions'
382 string userAssets = HyperAssets.GetUserAssetServer(AgentID);
383 if ((userAssets != string.Empty) && (userAssets != HyperAssets.GetSimAssetServer()))
384 {
385 m_log.DebugFormat("[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", id);
386 AssetService.Get(userAssets + "/" + id, HyperAssets, AssetReceived);
387 return;
388 }
389 }
376 390
377 AssetDataCallback(assetID, asset); 391 AssetDataCallback(assetID, asset);
378 392
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 9afff5a..8487adc 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -43,6 +43,7 @@ using OpenSim.Framework.Communications.Cache;
43using OpenSim.Framework.Statistics; 43using OpenSim.Framework.Statistics;
44using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Region.Framework.Scenes; 45using OpenSim.Region.Framework.Scenes;
46using OpenSim.Region.Framework.Scenes.Hypergrid;
46using OpenSim.Services.Interfaces; 47using OpenSim.Services.Interfaces;
47using Timer=System.Timers.Timer; 48using Timer=System.Timers.Timer;
48using AssetLandmark = OpenSim.Framework.AssetLandmark; 49using AssetLandmark = OpenSim.Framework.AssetLandmark;
@@ -319,6 +320,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
319 /// OnQueueEmpty event is triggered for the texture category</summary> 320 /// OnQueueEmpty event is triggered for the texture category</summary>
320 protected int m_textureSendLimit = 20; 321 protected int m_textureSendLimit = 20;
321 protected IAssetService m_assetService; 322 protected IAssetService m_assetService;
323 private IHyperAssetService m_hyperAssets;
324
322 325
323 #endregion Class Members 326 #endregion Class Members
324 327
@@ -377,6 +380,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
377 380
378 m_scene = scene; 381 m_scene = scene;
379 m_assetService = m_scene.RequestModuleInterface<IAssetService>(); 382 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
383 m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>();
380 m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>(); 384 m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
381 m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>()); 385 m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
382 m_channelVersion = Utils.StringToBytes(scene.GetSimulatorVersion()); 386 m_channelVersion = Utils.StringToBytes(scene.GetSimulatorVersion());
@@ -6895,7 +6899,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6895 #endregion 6899 #endregion
6896 6900
6897 //handlerTextureRequest = null; 6901 //handlerTextureRequest = null;
6898
6899 for (int i = 0; i < imageRequest.RequestImage.Length; i++) 6902 for (int i = 0; i < imageRequest.RequestImage.Length; i++)
6900 { 6903 {
6901 if (OnRequestTexture != null) 6904 if (OnRequestTexture != null)
@@ -6906,7 +6909,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6906 args.PacketNumber = imageRequest.RequestImage[i].Packet; 6909 args.PacketNumber = imageRequest.RequestImage[i].Packet;
6907 args.Priority = imageRequest.RequestImage[i].DownloadPriority; 6910 args.Priority = imageRequest.RequestImage[i].DownloadPriority;
6908 args.requestSequence = imageRequest.Header.Sequence; 6911 args.requestSequence = imageRequest.Header.Sequence;
6909
6910 //handlerTextureRequest = OnRequestTexture; 6912 //handlerTextureRequest = OnRequestTexture;
6911 6913
6912 //if (handlerTextureRequest != null) 6914 //if (handlerTextureRequest != null)
@@ -6929,10 +6931,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6929 // Validate inventory transfers 6931 // Validate inventory transfers
6930 // Has to be done here, because AssetCache can't do it 6932 // Has to be done here, because AssetCache can't do it
6931 // 6933 //
6932 6934 UUID taskID = UUID.Zero;
6933 if (transfer.TransferInfo.SourceType == 3) 6935 if (transfer.TransferInfo.SourceType == 3)
6934 { 6936 {
6935 UUID taskID = new UUID(transfer.TransferInfo.Params, 48); 6937 taskID = new UUID(transfer.TransferInfo.Params, 48);
6936 UUID itemID = new UUID(transfer.TransferInfo.Params, 64); 6938 UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
6937 UUID requestID = new UUID(transfer.TransferInfo.Params, 80); 6939 UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
6938 if (!(((Scene)m_scene).Permissions.BypassPermissions())) 6940 if (!(((Scene)m_scene).Permissions.BypassPermissions()))
@@ -7003,7 +7005,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7003 7005
7004 //m_assetCache.AddAssetRequest(this, transfer); 7006 //m_assetCache.AddAssetRequest(this, transfer);
7005 7007
7006 MakeAssetRequest(transfer); 7008 MakeAssetRequest(transfer, taskID);
7007 7009
7008 /* RequestAsset = OnRequestAsset; 7010 /* RequestAsset = OnRequestAsset;
7009 if (RequestAsset != null) 7011 if (RequestAsset != null)
@@ -10210,7 +10212,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10210 return String.Empty; 10212 return String.Empty;
10211 } 10213 }
10212 10214
10213 public void MakeAssetRequest(TransferRequestPacket transferRequest) 10215 public void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
10214 { 10216 {
10215 UUID requestID = UUID.Zero; 10217 UUID requestID = UUID.Zero;
10216 if (transferRequest.TransferInfo.SourceType == 2) 10218 if (transferRequest.TransferInfo.SourceType == 2)
@@ -10222,12 +10224,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10222 { 10224 {
10223 //inventory asset request 10225 //inventory asset request
10224 requestID = new UUID(transferRequest.TransferInfo.Params, 80); 10226 requestID = new UUID(transferRequest.TransferInfo.Params, 80);
10225 //m_log.Debug("asset request " + requestID); 10227 //m_log.Debug("[XXX] inventory asset request " + requestID);
10228 //if (taskID == UUID.Zero) // Agent
10229 // if (m_scene is HGScene)
10230 // {
10231 // m_log.Debug("[XXX] hg asset request " + requestID);
10232 // // We may need to fetch the asset from the user's asset server into the local asset server
10233 // HGAssetMapper mapper = ((HGScene)m_scene).AssetMapper;
10234 // mapper.Get(requestID, AgentId);
10235 // }
10226 } 10236 }
10227 10237
10228 //check to see if asset is in local cache, if not we need to request it from asset server. 10238 //check to see if asset is in local cache, if not we need to request it from asset server.
10229 //m_log.Debug("asset request " + requestID); 10239 //m_log.Debug("asset request " + requestID);
10230 10240
10231 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); 10241 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
10232 10242
10233 } 10243 }
@@ -10238,12 +10248,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10238 10248
10239 UUID requestID = UUID.Zero; 10249 UUID requestID = UUID.Zero;
10240 byte source = 2; 10250 byte source = 2;
10241 if (transferRequest.TransferInfo.SourceType == 2) 10251 if ((transferRequest.TransferInfo.SourceType == 2) || (transferRequest.TransferInfo.SourceType == 2222))
10242 { 10252 {
10243 //direct asset request 10253 //direct asset request
10244 requestID = new UUID(transferRequest.TransferInfo.Params, 0); 10254 requestID = new UUID(transferRequest.TransferInfo.Params, 0);
10245 } 10255 }
10246 else if (transferRequest.TransferInfo.SourceType == 3) 10256 else if ((transferRequest.TransferInfo.SourceType == 3) || (transferRequest.TransferInfo.SourceType == 3333))
10247 { 10257 {
10248 //inventory asset request 10258 //inventory asset request
10249 requestID = new UUID(transferRequest.TransferInfo.Params, 80); 10259 requestID = new UUID(transferRequest.TransferInfo.Params, 80);
@@ -10251,10 +10261,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10251 //m_log.Debug("asset request " + requestID); 10261 //m_log.Debug("asset request " + requestID);
10252 } 10262 }
10253 10263
10254 // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right.
10255 if (null == asset) 10264 if (null == asset)
10256 { 10265 {
10266 if ((m_hyperAssets != null) && (transferRequest.TransferInfo.SourceType < 2000))
10267 {
10268 // Try the user's inventory, but only if it's different from the regions'
10269 string userAssets = m_hyperAssets.GetUserAssetServer(AgentId);
10270 if ((userAssets != string.Empty) && (userAssets != m_hyperAssets.GetSimAssetServer()))
10271 {
10272 m_log.DebugFormat("[CLIENT]: asset {0} not found in local asset storage. Trying user's storage.", id);
10273 if (transferRequest.TransferInfo.SourceType == 2)
10274 transferRequest.TransferInfo.SourceType = 2222; // marker
10275 else if (transferRequest.TransferInfo.SourceType == 3)
10276 transferRequest.TransferInfo.SourceType = 3333; // marker
10277
10278 m_assetService.Get(userAssets + "/" + id, transferRequest, AssetReceived);
10279 return;
10280 }
10281 }
10282
10257 //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID); 10283 //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID);
10284
10285 // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right.
10258 return; 10286 return;
10259 } 10287 }
10260 10288
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
index 9d36cff..25542ab 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
@@ -59,6 +59,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
59 private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); 59 private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer());
60 private object m_syncRoot = new object(); 60 private object m_syncRoot = new object();
61 61
62 private IHyperAssetService m_hyperAssets;
63
62 public LLClientView Client { get { return m_client; } } 64 public LLClientView Client { get { return m_client; } }
63 public AssetBase MissingImage { get { return m_missingImage; } } 65 public AssetBase MissingImage { get { return m_missingImage; } }
64 66
@@ -74,6 +76,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
74 m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client"); 76 m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client");
75 77
76 m_j2kDecodeModule = pJ2kDecodeModule; 78 m_j2kDecodeModule = pJ2kDecodeModule;
79 m_hyperAssets = client.Scene.RequestModuleInterface<IHyperAssetService>();
77 } 80 }
78 81
79 /// <summary> 82 /// <summary>
@@ -146,6 +149,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
146 imgrequest = new J2KImage(this); 149 imgrequest = new J2KImage(this);
147 imgrequest.J2KDecoder = m_j2kDecodeModule; 150 imgrequest.J2KDecoder = m_j2kDecodeModule;
148 imgrequest.AssetService = m_assetCache; 151 imgrequest.AssetService = m_assetCache;
152 imgrequest.AgentID = m_client.AgentId;
153 imgrequest.HyperAssets = m_hyperAssets;
149 imgrequest.DiscardLevel = newRequest.DiscardLevel; 154 imgrequest.DiscardLevel = newRequest.DiscardLevel;
150 imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); 155 imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber);
151 imgrequest.Priority = newRequest.Priority; 156 imgrequest.Priority = newRequest.Priority;
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index b81ab41..4041b63 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -43,6 +43,7 @@ using Mono.Addins;
43using OpenMetaverse; 43using OpenMetaverse;
44 44
45using OpenSim.Framework; 45using OpenSim.Framework;
46using OpenSim.Framework.Console;
46using OpenSim.Region.Framework.Interfaces; 47using OpenSim.Region.Framework.Interfaces;
47using OpenSim.Region.Framework.Scenes; 48using OpenSim.Region.Framework.Scenes;
48using OpenSim.Services.Interfaces; 49using OpenSim.Services.Interfaces;
@@ -54,7 +55,7 @@ using OpenSim.Services.Interfaces;
54namespace Flotsam.RegionModules.AssetCache 55namespace Flotsam.RegionModules.AssetCache
55{ 56{
56 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 57 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
57 public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache 58 public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache, IAssetService
58 { 59 {
59 private static readonly ILog m_log = 60 private static readonly ILog m_log =
60 LogManager.GetLogger( 61 LogManager.GetLogger(
@@ -102,6 +103,11 @@ namespace Flotsam.RegionModules.AssetCache
102 103
103 private System.Timers.Timer m_CachCleanTimer = new System.Timers.Timer(); 104 private System.Timers.Timer m_CachCleanTimer = new System.Timers.Timer();
104 105
106 private IAssetService m_AssetService = null;
107 private List<Scene> m_Scenes = new List<Scene>();
108
109 private bool m_DeepScanBeforePurge = false;
110
105 public FlotsamAssetCache() 111 public FlotsamAssetCache()
106 { 112 {
107 m_InvalidChars.AddRange(Path.GetInvalidPathChars()); 113 m_InvalidChars.AddRange(Path.GetInvalidPathChars());
@@ -121,6 +127,7 @@ namespace Flotsam.RegionModules.AssetCache
121 public void Initialise(IConfigSource source) 127 public void Initialise(IConfigSource source)
122 { 128 {
123 IConfig moduleConfig = source.Configs["Modules"]; 129 IConfig moduleConfig = source.Configs["Modules"];
130
124 131
125 if (moduleConfig != null) 132 if (moduleConfig != null)
126 { 133 {
@@ -195,7 +202,13 @@ namespace Flotsam.RegionModules.AssetCache
195 202
196 m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", 30000); 203 m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", 30000);
197 204
198 205 m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", false);
206
207 MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache status", "fcache status", "Display cache status", HandleConsoleCommand);
208 MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the file and/or memory cache", HandleConsoleCommand);
209 MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand);
210 MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache expire", "fcache expire <datetime>", "Purge cached assets older then the specified date/time", HandleConsoleCommand);
211
199 } 212 }
200 } 213 }
201 } 214 }
@@ -213,16 +226,23 @@ namespace Flotsam.RegionModules.AssetCache
213 if (m_Enabled) 226 if (m_Enabled)
214 { 227 {
215 scene.RegisterModuleInterface<IImprovedAssetCache>(this); 228 scene.RegisterModuleInterface<IImprovedAssetCache>(this);
229 m_Scenes.Add(scene);
216 230
217 //scene.AddCommand(this, "flotsamcache", "", "Display a list of console commands for the Flotsam Asset Cache", HandleConsoleCommand); 231 if (m_AssetService == null)
218 scene.AddCommand(this, "flotsamcache counts", "flotsamcache counts", "Display the number of cached assets", HandleConsoleCommand); 232 {
219 scene.AddCommand(this, "flotsamcache clearmem", "flotsamcache clearmem", "Remove all assets cached in memory", HandleConsoleCommand); 233 m_AssetService = scene.RequestModuleInterface<IAssetService>();
220 scene.AddCommand(this, "flotsamcache clearfile", "flotsamcache clearfile", "Remove all assets cached on disk", HandleConsoleCommand); 234
235 }
221 } 236 }
222 } 237 }
223 238
224 public void RemoveRegion(Scene scene) 239 public void RemoveRegion(Scene scene)
225 { 240 {
241 if (m_Enabled)
242 {
243 scene.UnregisterModuleInterface<IImprovedAssetCache>(this);
244 m_Scenes.Remove(scene);
245 }
226 } 246 }
227 247
228 public void RegionLoaded(Scene scene) 248 public void RegionLoaded(Scene scene)
@@ -442,31 +462,47 @@ namespace Flotsam.RegionModules.AssetCache
442 if (m_LogLevel >= 2) 462 if (m_LogLevel >= 2)
443 m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration.ToString()); 463 m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration.ToString());
444 464
465 // Purge all files last accessed prior to this point
466 DateTime purgeLine = DateTime.Now - m_FileExpiration;
467
468 // An optional deep scan at this point will ensure assets present in scenes,
469 // or referenced by objects in the scene, but not recently accessed
470 // are not purged.
471 if (m_DeepScanBeforePurge)
472 {
473 CacheScenes();
474 }
475
445 foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) 476 foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
446 { 477 {
447 CleanExpiredFiles(dir); 478 CleanExpiredFiles(dir, purgeLine);
448 } 479 }
449 } 480 }
450 481
451 /// <summary> 482 /// <summary>
452 /// Recurses through specified directory checking for expired asset files and deletes them. Also removes empty directories. 483 /// Recurses through specified directory checking for asset files last
484 /// accessed prior to the specified purge line and deletes them. Also
485 /// removes empty tier directories.
453 /// </summary> 486 /// </summary>
454 /// <param name="dir"></param> 487 /// <param name="dir"></param>
455 private void CleanExpiredFiles(string dir) 488 private void CleanExpiredFiles(string dir, DateTime purgeLine)
456 { 489 {
490
457 foreach (string file in Directory.GetFiles(dir)) 491 foreach (string file in Directory.GetFiles(dir))
458 { 492 {
459 if (DateTime.Now - File.GetLastAccessTime(file) > m_FileExpiration) 493 if (File.GetLastAccessTime(file) < purgeLine)
460 { 494 {
461 File.Delete(file); 495 File.Delete(file);
462 } 496 }
463 } 497 }
464 498
499 // Recurse into lower tiers
465 foreach (string subdir in Directory.GetDirectories(dir)) 500 foreach (string subdir in Directory.GetDirectories(dir))
466 { 501 {
467 CleanExpiredFiles(subdir); 502 CleanExpiredFiles(subdir, purgeLine);
468 } 503 }
469 504
505 // Check if a tier directory is empty, if so, delete it
470 int dirSize = Directory.GetFiles(dir).Length + Directory.GetDirectories(dir).Length; 506 int dirSize = Directory.GetFiles(dir).Length + Directory.GetDirectories(dir).Length;
471 if (dirSize == 0) 507 if (dirSize == 0)
472 { 508 {
@@ -478,6 +514,11 @@ namespace Flotsam.RegionModules.AssetCache
478 } 514 }
479 } 515 }
480 516
517 /// <summary>
518 /// Determines the filename for an AssetID stored in the file cache
519 /// </summary>
520 /// <param name="id"></param>
521 /// <returns></returns>
481 private string GetFileName(string id) 522 private string GetFileName(string id)
482 { 523 {
483 // Would it be faster to just hash the darn thing? 524 // Would it be faster to just hash the darn thing?
@@ -496,14 +537,23 @@ namespace Flotsam.RegionModules.AssetCache
496 return Path.Combine(path, id); 537 return Path.Combine(path, id);
497 } 538 }
498 539
540 /// <summary>
541 /// Writes a file to the file cache, creating any nessesary
542 /// tier directories along the way
543 /// </summary>
544 /// <param name="filename"></param>
545 /// <param name="asset"></param>
499 private void WriteFileCache(string filename, AssetBase asset) 546 private void WriteFileCache(string filename, AssetBase asset)
500 { 547 {
501 Stream stream = null; 548 Stream stream = null;
549
502 // Make sure the target cache directory exists 550 // Make sure the target cache directory exists
503 string directory = Path.GetDirectoryName(filename); 551 string directory = Path.GetDirectoryName(filename);
552
504 // Write file first to a temp name, so that it doesn't look 553 // Write file first to a temp name, so that it doesn't look
505 // like it's already cached while it's still writing. 554 // like it's already cached while it's still writing.
506 string tempname = Path.Combine(directory, Path.GetRandomFileName()); 555 string tempname = Path.Combine(directory, Path.GetRandomFileName());
556
507 try 557 try
508 { 558 {
509 if (!Directory.Exists(directory)) 559 if (!Directory.Exists(directory))
@@ -563,6 +613,11 @@ namespace Flotsam.RegionModules.AssetCache
563 } 613 }
564 } 614 }
565 615
616 /// <summary>
617 /// Scan through the file cache, and return number of assets currently cached.
618 /// </summary>
619 /// <param name="dir"></param>
620 /// <returns></returns>
566 private int GetFileCacheCount(string dir) 621 private int GetFileCacheCount(string dir)
567 { 622 {
568 int count = Directory.GetFiles(dir).Length; 623 int count = Directory.GetFiles(dir).Length;
@@ -575,55 +630,180 @@ namespace Flotsam.RegionModules.AssetCache
575 return count; 630 return count;
576 } 631 }
577 632
633 /// <summary>
634 /// This notes the last time the Region had a deep asset scan performed on it.
635 /// </summary>
636 /// <param name="RegionID"></param>
637 private void StampRegionStatusFile(UUID RegionID)
638 {
639 string RegionCacheStatusFile = Path.Combine(m_CacheDirectory, "RegionStatus_" + RegionID.ToString() + ".fac");
640 if (File.Exists(RegionCacheStatusFile))
641 {
642 File.SetLastWriteTime(RegionCacheStatusFile, DateTime.Now);
643 }
644 else
645 {
646 File.WriteAllText(RegionCacheStatusFile, "Please do not delete this file unless you are manually clearing your Flotsam Asset Cache.");
647 }
648 }
649
650 /// <summary>
651 /// Iterates through all Scenes, doing a deep scan through assets
652 /// to cache all assets present in the scene or referenced by assets
653 /// in the scene
654 /// </summary>
655 /// <returns></returns>
656 private int CacheScenes()
657 {
658 UuidGatherer gatherer = new UuidGatherer(m_AssetService);
659
660 Dictionary<UUID, int> assets = new Dictionary<UUID, int>();
661 foreach (Scene s in m_Scenes)
662 {
663 StampRegionStatusFile(s.RegionInfo.RegionID);
664
665 s.ForEachSOG(delegate(SceneObjectGroup e)
666 {
667 gatherer.GatherAssetUuids(e, assets);
668 }
669 );
670 }
671
672 foreach (UUID assetID in assets.Keys)
673 {
674 string filename = GetFileName(assetID.ToString());
675
676 if (File.Exists(filename))
677 {
678 File.SetLastAccessTime(filename, DateTime.Now);
679 }
680 else
681 {
682 m_AssetService.Get(assetID.ToString());
683 }
684 }
685
686 return assets.Keys.Count;
687 }
688
689 /// <summary>
690 /// Deletes all cache contents
691 /// </summary>
692 private void ClearFileCache()
693 {
694 foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
695 {
696 try
697 {
698 Directory.Delete(dir, true);
699 }
700 catch (Exception e)
701 {
702 LogException(e);
703 }
704 }
705
706 foreach (string file in Directory.GetFiles(m_CacheDirectory))
707 {
708 try
709 {
710 File.Delete(file);
711 }
712 catch (Exception e)
713 {
714 LogException(e);
715 }
716 }
717 }
718
578 #region Console Commands 719 #region Console Commands
579 private void HandleConsoleCommand(string module, string[] cmdparams) 720 private void HandleConsoleCommand(string module, string[] cmdparams)
580 { 721 {
581 if (cmdparams.Length == 2) 722 if (cmdparams.Length >= 2)
582 { 723 {
583 string cmd = cmdparams[1]; 724 string cmd = cmdparams[1];
584 switch (cmd) 725 switch (cmd)
585 { 726 {
586 case "count": 727 case "status":
587 case "counts": 728 m_log.InfoFormat("[FLOTSAM ASSET CACHE] Memory Cache : {0} assets", m_MemoryCache.Count);
588 m_log.InfoFormat("[FLOTSAM ASSET CACHE] Memory Cache : {0}", m_MemoryCache.Count);
589 729
590 int fileCount = GetFileCacheCount(m_CacheDirectory); 730 int fileCount = GetFileCacheCount(m_CacheDirectory);
591 m_log.InfoFormat("[FLOTSAM ASSET CACHE] File Cache : {0}", fileCount); 731 m_log.InfoFormat("[FLOTSAM ASSET CACHE] File Cache : {0} assets", fileCount);
592 732
593 break; 733 foreach ( string s in Directory.GetFiles(m_CacheDirectory, "*.fac" ) )
734 {
735 m_log.Info("[FLOTSAM ASSET CACHE] Deep Scans were performed on the following regions:");
736
737 string RegionID = s.Remove(0,s.IndexOf("_")).Replace(".fac","");
738 DateTime RegionDeepScanTMStamp = File.GetLastWriteTime(s);
739 m_log.InfoFormat("[FLOTSAM ASSET CACHE] Region: {0}, {1}", RegionID, RegionDeepScanTMStamp.ToString("MM/dd/yyyy hh:mm:ss"));
740 }
594 741
595 case "clearmem":
596 m_MemoryCache.Clear();
597 m_log.InfoFormat("[FLOTSAM ASSET CACHE] Memory Cache Cleared, there are now {0} items in the memory cache", m_MemoryCache.Count);
598 break; 742 break;
599 743
600 case "clearfile": 744 case "clear":
601 foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) 745 if (cmdparams.Length < 3)
602 { 746 {
603 try 747 m_log.Warn("[FLOTSAM ASSET CACHE] Please specify memory and/or file cache.");
604 { 748 break;
605 Directory.Delete(dir, true);
606 }
607 catch (Exception e)
608 {
609 LogException(e);
610 }
611 } 749 }
612 750 foreach (string s in cmdparams)
613 foreach (string file in Directory.GetFiles(m_CacheDirectory))
614 { 751 {
615 try 752 if (s.ToLower() == "memory")
616 { 753 {
617 File.Delete(file); 754 m_MemoryCache.Clear();
755 m_log.Info("[FLOTSAM ASSET CACHE] Memory cache cleared.");
618 } 756 }
619 catch (Exception e) 757 else if (s.ToLower() == "file")
620 { 758 {
621 LogException(e); 759 ClearFileCache();
760 m_log.Info("[FLOTSAM ASSET CACHE] File cache cleared.");
622 } 761 }
623 } 762 }
763 break;
764
765
766 case "assets":
767 m_log.Info("[FLOTSAM ASSET CACHE] Caching all assets, in all scenes.");
768
769 Util.FireAndForget(delegate {
770 int assetsCached = CacheScenes();
771 m_log.InfoFormat("[FLOTSAM ASSET CACHE] Completed Scene Caching, {0} assets found.", assetsCached);
772
773 });
624 774
625 break; 775 break;
626 776
777 case "expire":
778
779
780 if (cmdparams.Length >= 3)
781 {
782 m_log.InfoFormat("[FLOTSAM ASSET CACHE] Invalid parameters for Expire, please specify a valid date & time", cmd);
783 break;
784 }
785
786 string s_expirationDate = "";
787 DateTime expirationDate;
788
789 if (cmdparams.Length > 3)
790 {
791 s_expirationDate = string.Join(" ", cmdparams, 2, cmdparams.Length - 2);
792 }
793 else
794 {
795 s_expirationDate = cmdparams[2];
796 }
797
798 if (!DateTime.TryParse(s_expirationDate, out expirationDate))
799 {
800 m_log.InfoFormat("[FLOTSAM ASSET CACHE] {0} is not a valid date & time", cmd);
801 break;
802 }
803
804 CleanExpiredFiles(m_CacheDirectory, expirationDate);
805
806 break;
627 default: 807 default:
628 m_log.InfoFormat("[FLOTSAM ASSET CACHE] Unknown command {0}", cmd); 808 m_log.InfoFormat("[FLOTSAM ASSET CACHE] Unknown command {0}", cmd);
629 break; 809 break;
@@ -631,13 +811,66 @@ namespace Flotsam.RegionModules.AssetCache
631 } 811 }
632 else if (cmdparams.Length == 1) 812 else if (cmdparams.Length == 1)
633 { 813 {
634 m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache counts - Display the number of cached assets"); 814 m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache status - Display cache status");
635 m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache clearmem - Remove all assets cached in memory"); 815 m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache clearmem - Remove all assets cached in memory");
636 m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache clearfile - Remove all assets cached on disk"); 816 m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache clearfile - Remove all assets cached on disk");
817 m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache cachescenes - Attempt a deep cache of all assets in all scenes");
818 m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache <datetime> - Purge assets older then the specified date & time");
637 819
638 } 820 }
639 } 821 }
640 822
641 #endregion 823 #endregion
824
825 #region IAssetService Members
826
827
828 public AssetMetadata GetMetadata(string id)
829 {
830 AssetBase asset = Get(id);
831 return asset.Metadata;
832 }
833
834 public byte[] GetData(string id)
835 {
836 AssetBase asset = Get(id);
837 return asset.Data;
838 }
839
840 public bool Get(string id, object sender, AssetRetrieved handler)
841 {
842 AssetBase asset = Get(id);
843 handler(id, sender, asset);
844 return true;
845 }
846
847 public string Store(AssetBase asset)
848 {
849 if ((asset.FullID == null) || (asset.FullID == UUID.Zero))
850 {
851 asset.FullID = UUID.Random();
852 }
853
854 Cache(asset);
855
856 return asset.ID;
857
858 }
859
860 public bool UpdateContent(string id, byte[] data)
861 {
862 AssetBase asset = Get(id);
863 asset.Data = data;
864 Cache(asset);
865 return true;
866 }
867
868 public bool Delete(string id)
869 {
870 Expire(id);
871 return true;
872 }
873
874 #endregion
642 } 875 }
643} \ No newline at end of file 876} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
index 7b4e374..0aa753d 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
@@ -31,6 +31,7 @@ using System;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache;
34using OpenSim.Server.Base; 35using OpenSim.Server.Base;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
@@ -40,7 +41,7 @@ using OpenMetaverse;
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset 41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
41{ 42{
42 public class HGAssetBroker : 43 public class HGAssetBroker :
43 ISharedRegionModule, IAssetService 44 ISharedRegionModule, IAssetService, IHyperAssetService
44 { 45 {
45 private static readonly ILog m_log = 46 private static readonly ILog m_log =
46 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -50,6 +51,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
50 private IAssetService m_GridService; 51 private IAssetService m_GridService;
51 private IAssetService m_HGService; 52 private IAssetService m_HGService;
52 53
54 private Scene m_aScene;
55 private string m_LocalAssetServiceURI;
56
53 private bool m_Enabled = false; 57 private bool m_Enabled = false;
54 58
55 public Type ReplaceableInterface 59 public Type ReplaceableInterface
@@ -114,6 +118,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
114 return; 118 return;
115 } 119 }
116 120
121 m_LocalAssetServiceURI = assetConfig.GetString("AssetServerURI", string.Empty);
122 if (m_LocalAssetServiceURI == string.Empty)
123 {
124 IConfig netConfig = source.Configs["Network"];
125 m_LocalAssetServiceURI = netConfig.GetString("asset_server_url", string.Empty);
126 }
127
128 if (m_LocalAssetServiceURI != string.Empty)
129 m_LocalAssetServiceURI = m_LocalAssetServiceURI.Trim('/');
130
117 m_Enabled = true; 131 m_Enabled = true;
118 m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled"); 132 m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled");
119 } 133 }
@@ -132,8 +146,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
132 { 146 {
133 if (!m_Enabled) 147 if (!m_Enabled)
134 return; 148 return;
149
150 m_aScene = scene;
135 151
136 scene.RegisterModuleInterface<IAssetService>(this); 152 scene.RegisterModuleInterface<IAssetService>(this);
153 scene.RegisterModuleInterface<IHyperAssetService>(this);
137 } 154 }
138 155
139 public void RemoveRegion(Scene scene) 156 public void RemoveRegion(Scene scene)
@@ -344,5 +361,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
344 else 361 else
345 return m_GridService.Delete(id); 362 return m_GridService.Delete(id);
346 } 363 }
364
365 #region IHyperAssetService
366
367 public string GetUserAssetServer(UUID userID)
368 {
369 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
370 if ((uinfo != null) && (uinfo.UserProfile != null))
371 {
372 if ((uinfo.UserProfile.UserAssetURI == string.Empty) || (uinfo.UserProfile.UserAssetURI == ""))
373 return m_LocalAssetServiceURI;
374 return uinfo.UserProfile.UserAssetURI.Trim('/');
375 }
376 else
377 {
378 // we don't know anyting about this user
379 return string.Empty;
380 }
381 }
382
383 public string GetSimAssetServer()
384 {
385 return m_LocalAssetServiceURI;
386 }
387
388 #endregion
347 } 389 }
348} 390}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index 148331b..1422add 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -759,6 +759,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
759 759
760 } 760 }
761 761
762
762 protected bool IsLocalRegion(ulong handle) 763 protected bool IsLocalRegion(ulong handle)
763 { 764 {
764 return m_LocalScenes.ContainsKey(handle); 765 return m_LocalScenes.ContainsKey(handle);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
index bd32f3b..811569f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
@@ -159,6 +159,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
159 /// <returns>true if the item was successfully added</returns> 159 /// <returns>true if the item was successfully added</returns>
160 public bool AddItem(InventoryItemBase item) 160 public bool AddItem(InventoryItemBase item)
161 { 161 {
162 if (item == null)
163 return false;
164
162 if (item.Folder == UUID.Zero) 165 if (item.Folder == UUID.Zero)
163 { 166 {
164 InventoryFolderBase f = GetFolderForType(item.Owner, (AssetType)item.AssetType); 167 InventoryFolderBase f = GetFolderForType(item.Owner, (AssetType)item.AssetType);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index fd1a759..f073f32 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -386,7 +386,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
386 return false; 386 return false;
387 387
388 if (IsLocalGridUser(item.Owner)) 388 if (IsLocalGridUser(item.Owner))
389 {
389 return m_GridService.AddItem(item); 390 return m_GridService.AddItem(item);
391 }
390 else 392 else
391 { 393 {
392 UUID sessionID = GetSessionID(item.Owner); 394 UUID sessionID = GetSessionID(item.Owner);
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
index 05d19a2..6499915 100644
--- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
@@ -343,7 +343,9 @@ namespace OpenSim.Region.CoreModules.World.Land
343 343
344 lock (scene.WestBorders) 344 lock (scene.WestBorders)
345 { 345 {
346 scene.WestBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport West 346
347
348 scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West
347 349
348 // Trigger auto teleport to root region 350 // Trigger auto teleport to root region
349 scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; 351 scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX;
@@ -410,7 +412,7 @@ namespace OpenSim.Region.CoreModules.World.Land
410 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; 412 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize;
411 lock (scene.SouthBorders) 413 lock (scene.SouthBorders)
412 { 414 {
413 scene.SouthBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport south 415 scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south
414 scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; 416 scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX;
415 scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; 417 scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY;
416 } 418 }
@@ -481,7 +483,7 @@ namespace OpenSim.Region.CoreModules.World.Land
481 483
482 lock (scene.SouthBorders) 484 lock (scene.SouthBorders)
483 { 485 {
484 scene.SouthBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport south 486 scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south
485 scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; 487 scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX;
486 scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; 488 scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY;
487 } 489 }
@@ -503,7 +505,7 @@ namespace OpenSim.Region.CoreModules.World.Land
503 505
504 lock (scene.WestBorders) 506 lock (scene.WestBorders)
505 { 507 {
506 scene.WestBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport West 508 scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West
507 scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; 509 scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX;
508 scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; 510 scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY;
509 } 511 }
diff --git a/OpenSim/Region/Framework/Interfaces/IHyperService.cs b/OpenSim/Region/Framework/Interfaces/IHyperService.cs
new file mode 100644
index 0000000..51ea28a
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IHyperService.cs
@@ -0,0 +1,37 @@
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 */
27using System;
28using OpenMetaverse;
29
30namespace OpenSim.Region.Framework.Interfaces
31{
32 public interface IHyperAssetService
33 {
34 string GetUserAssetServer(UUID userID);
35 string GetSimAssetServer();
36 }
37}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index b6fa41d..244ac3b 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients; 36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization; 37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
39 40
40//using HyperGrid.Framework; 41//using HyperGrid.Framework;
@@ -52,13 +53,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
52 53
53 private Scene m_scene; 54 private Scene m_scene;
54 55
55 private IHyperlinkService m_hyper; 56 private IHyperAssetService m_hyper;
56 IHyperlinkService HyperlinkService 57 IHyperAssetService HyperlinkAssets
57 { 58 {
58 get 59 get
59 { 60 {
60 if (m_hyper == null) 61 if (m_hyper == null)
61 m_hyper = m_scene.RequestModuleInterface<IHyperlinkService>(); 62 m_hyper = m_scene.RequestModuleInterface<IHyperAssetService>();
62 return m_hyper; 63 return m_hyper;
63 } 64 }
64 } 65 }
@@ -99,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
99 100
100 if (asset != null) 101 if (asset != null)
101 { 102 {
102 m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID); 103 m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
103 return asset; 104 return asset;
104 } 105 }
105 return null; 106 return null;
@@ -129,6 +130,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
129 } 130 }
130 131
131 m_scene.AssetService.Store(asset1); 132 m_scene.AssetService.Store(asset1);
133 m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
132 } 134 }
133 return true; 135 return true;
134 } 136 }
@@ -167,34 +169,32 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
167 169
168 public void Get(UUID assetID, UUID ownerID) 170 public void Get(UUID assetID, UUID ownerID)
169 { 171 {
170 if (!HyperlinkService.IsLocalUser(ownerID)) 172 // Get the item from the remote asset server onto the local AssetCache
173 // and place an entry in m_assetMap
174
175 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
176 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
171 { 177 {
172 // Get the item from the remote asset server onto the local AssetCache 178 m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL);
173 // and place an entry in m_assetMap 179 AssetBase asset = FetchAsset(userAssetURL, assetID);
174 180
175 string userAssetURL = UserAssetURL(ownerID); 181 if (asset != null)
176 if (userAssetURL != null)
177 { 182 {
178 m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); 183 // OK, now fetch the inside.
179 AssetBase asset = FetchAsset(userAssetURL, assetID); 184 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
185 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
186 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
187 foreach (UUID uuid in ids.Keys)
188 FetchAsset(userAssetURL, uuid);
189
190 m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
180 191
181 if (asset != null)
182 {
183 m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL);
184
185 // OK, now fetch the inside.
186 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
187 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
188 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
189 foreach (UUID uuid in ids.Keys)
190 FetchAsset(userAssetURL, uuid);
191 }
192 else
193 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
194 } 192 }
195 else 193 else
196 m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); 194 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
197 } 195 }
196 else
197 m_log.Debug("[HGScene]: user's asset server is the local region's asset server");
198 } 198 }
199 199
200 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo) 200 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
@@ -225,44 +225,38 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
225 225
226 public void Post(UUID assetID, UUID ownerID) 226 public void Post(UUID assetID, UUID ownerID)
227 { 227 {
228 if (!HyperlinkService.IsLocalUser(ownerID))
229 {
230 // Post the item from the local AssetCache onto the remote asset server 228 // Post the item from the local AssetCache onto the remote asset server
231 // and place an entry in m_assetMap 229 // and place an entry in m_assetMap
232 230
233 string userAssetURL = UserAssetURL(ownerID); 231 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
234 if (userAssetURL != null) 232 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
233 {
234 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
235 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
236 if (asset != null)
235 { 237 {
236 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); 238 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
237 AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); 239 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
238 if (asset != null) 240 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
241 foreach (UUID uuid in ids.Keys)
239 { 242 {
240 Dictionary<UUID, int> ids = new Dictionary<UUID, int>(); 243 asset = m_scene.AssetService.Get(uuid.ToString());
241 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); 244 if (asset == null)
242 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); 245 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
243 foreach (UUID uuid in ids.Keys) 246 else
244 {
245 asset = m_scene.AssetService.Get(uuid.ToString());
246 if (asset != null)
247 m_log.DebugFormat("[HGScene]: Posting {0} {1}", asset.Type.ToString(), asset.Name);
248 else
249 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
250 PostAsset(userAssetURL, asset); 247 PostAsset(userAssetURL, asset);
251 } 248 }
252 249
253 if (ids.Count > 0) // maybe it succeeded... 250 // maybe all pieces got there...
254 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL); 251 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
255 else
256 m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL);
257 252
258 }
259 else
260 m_log.Debug("[HGScene]: Something wrong with asset, it could not be found");
261 } 253 }
262 else 254 else
263 m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); 255 m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID);
264
265 } 256 }
257 else
258 m_log.Debug("[HGScene]: user's asset server is local region's asset server");
259
266 } 260 }
267 261
268 #endregion 262 #endregion
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
index 8fe3565..6f7f34f 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
@@ -32,6 +32,7 @@ using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache; 34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces;
35 36
36namespace OpenSim.Region.Framework.Scenes.Hypergrid 37namespace OpenSim.Region.Framework.Scenes.Hypergrid
37{ 38{
@@ -41,6 +42,21 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 43
43 private HGAssetMapper m_assMapper; 44 private HGAssetMapper m_assMapper;
45 public HGAssetMapper AssetMapper
46 {
47 get { return m_assMapper; }
48 }
49
50 private IHyperAssetService m_hyper;
51 private IHyperAssetService HyperAssets
52 {
53 get
54 {
55 if (m_hyper == null)
56 m_hyper = RequestModuleInterface<IHyperAssetService>();
57 return m_hyper;
58 }
59 }
44 60
45 #endregion 61 #endregion
46 62
@@ -140,6 +156,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
140 156
141 } 157 }
142 158
159 protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
160 {
161 string userAssetServer = HyperAssets.GetUserAssetServer(sender);
162 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
163 m_assMapper.Get(item.AssetID, sender);
164
165 userAssetServer = HyperAssets.GetUserAssetServer(receiver);
166 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
167 m_assMapper.Post(item.AssetID, receiver);
168 }
143 169
144 #endregion 170 #endregion
145 171
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 1917228..0cb5682 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -408,7 +408,7 @@ namespace OpenSim.Region.Framework.Scenes
408 public virtual InventoryItemBase GiveInventoryItem( 408 public virtual InventoryItemBase GiveInventoryItem(
409 UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId) 409 UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId)
410 { 410 {
411 Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); 411 //Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem");
412 412
413 InventoryItemBase item = new InventoryItemBase(itemId, senderId); 413 InventoryItemBase item = new InventoryItemBase(itemId, senderId);
414 item = InventoryService.GetItem(item); 414 item = InventoryService.GetItem(item);
@@ -472,7 +472,8 @@ namespace OpenSim.Region.Framework.Scenes
472 itemCopy.SalePrice = item.SalePrice; 472 itemCopy.SalePrice = item.SalePrice;
473 itemCopy.SaleType = item.SaleType; 473 itemCopy.SaleType = item.SaleType;
474 474
475 InventoryService.AddItem(itemCopy); 475 if (InventoryService.AddItem(itemCopy))
476 TransferInventoryAssets(itemCopy, senderId, recipient);
476 477
477 if (!Permissions.BypassPermissions()) 478 if (!Permissions.BypassPermissions())
478 { 479 {
@@ -494,6 +495,10 @@ namespace OpenSim.Region.Framework.Scenes
494 495
495 } 496 }
496 497
498 protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
499 {
500 }
501
497 /// <summary> 502 /// <summary>
498 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent 503 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent
499 /// folders) is given. 504 /// folders) is given.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 1ca0267..9f14761 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1772,36 +1772,86 @@ namespace OpenSim.Region.Framework.Scenes
1772 1772
1773 Vector3 pos = attemptedPosition; 1773 Vector3 pos = attemptedPosition;
1774 1774
1775 int changeX = 1;
1776 int changeY = 1;
1777
1775 if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W)) 1778 if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W))
1776 { 1779 {
1777 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) 1780 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1778 { 1781 {
1779 //Border crossedBorderx = GetCrossedBorder(attemptedPosition,Cardinals.W); 1782
1780 //Border crossedBordery = GetCrossedBorder(attemptedPosition, Cardinals.S); 1783 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1784
1785 if (crossedBorderx.BorderLine.Z > 0)
1786 {
1787 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1788 changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize);
1789 }
1790 else
1791 pos.X = ((pos.X + Constants.RegionSize));
1792
1793 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1781 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) 1794 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1782 pos.X = ((pos.X + Constants.RegionSize)); 1795
1783 pos.Y = ((pos.Y + Constants.RegionSize)); 1796 if (crossedBordery.BorderLine.Z > 0)
1797 {
1798 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1799 }
1800 else
1801 pos.Y = ((pos.Y + Constants.RegionSize));
1802
1803
1804
1784 newRegionHandle 1805 newRegionHandle
1785 = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), 1806 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1786 (uint)((thisy - 1) * Constants.RegionSize)); 1807 (uint)((thisy - changeY) * Constants.RegionSize));
1787 // x - 1 1808 // x - 1
1788 // y - 1 1809 // y - 1
1789 } 1810 }
1790 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) 1811 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
1791 { 1812 {
1792 pos.X = ((pos.X + Constants.RegionSize)); 1813 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1793 pos.Y = ((pos.Y - Constants.RegionSize)); 1814
1815 if (crossedBorderx.BorderLine.Z > 0)
1816 {
1817 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1818 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
1819 }
1820 else
1821 pos.X = ((pos.X + Constants.RegionSize));
1822
1823
1824 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1825 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1826
1827 if (crossedBordery.BorderLine.Z > 0)
1828 {
1829 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1830 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1831 }
1832 else
1833 pos.Y = ((pos.Y + Constants.RegionSize));
1834
1794 newRegionHandle 1835 newRegionHandle
1795 = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), 1836 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1796 (uint)((thisy + 1) * Constants.RegionSize)); 1837 (uint)((thisy + changeY) * Constants.RegionSize));
1797 // x - 1 1838 // x - 1
1798 // y + 1 1839 // y + 1
1799 } 1840 }
1800 else 1841 else
1801 { 1842 {
1802 pos.X = ((pos.X + Constants.RegionSize)); 1843 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1844
1845 if (crossedBorderx.BorderLine.Z > 0)
1846 {
1847 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1848 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
1849 }
1850 else
1851 pos.X = ((pos.X + Constants.RegionSize));
1852
1803 newRegionHandle 1853 newRegionHandle
1804 = Util.UIntsToLong((uint) ((thisx - 1)*Constants.RegionSize), 1854 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1805 (uint) (thisy*Constants.RegionSize)); 1855 (uint) (thisy*Constants.RegionSize));
1806 // x - 1 1856 // x - 1
1807 } 1857 }
@@ -1810,11 +1860,23 @@ namespace OpenSim.Region.Framework.Scenes
1810 { 1860 {
1811 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) 1861 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1812 { 1862 {
1863
1813 pos.X = ((pos.X - Constants.RegionSize)); 1864 pos.X = ((pos.X - Constants.RegionSize));
1814 pos.Y = ((pos.Y + Constants.RegionSize)); 1865 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1866 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1867
1868 if (crossedBordery.BorderLine.Z > 0)
1869 {
1870 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1871 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1872 }
1873 else
1874 pos.Y = ((pos.Y + Constants.RegionSize));
1875
1876
1815 newRegionHandle 1877 newRegionHandle
1816 = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), 1878 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1817 (uint)((thisy - 1) * Constants.RegionSize)); 1879 (uint)((thisy - changeY) * Constants.RegionSize));
1818 // x + 1 1880 // x + 1
1819 // y - 1 1881 // y - 1
1820 } 1882 }
@@ -1823,8 +1885,8 @@ namespace OpenSim.Region.Framework.Scenes
1823 pos.X = ((pos.X - Constants.RegionSize)); 1885 pos.X = ((pos.X - Constants.RegionSize));
1824 pos.Y = ((pos.Y - Constants.RegionSize)); 1886 pos.Y = ((pos.Y - Constants.RegionSize));
1825 newRegionHandle 1887 newRegionHandle
1826 = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), 1888 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1827 (uint)((thisy + 1) * Constants.RegionSize)); 1889 (uint)((thisy + changeY) * Constants.RegionSize));
1828 // x + 1 1890 // x + 1
1829 // y + 1 1891 // y + 1
1830 } 1892 }
@@ -1832,16 +1894,26 @@ namespace OpenSim.Region.Framework.Scenes
1832 { 1894 {
1833 pos.X = ((pos.X - Constants.RegionSize)); 1895 pos.X = ((pos.X - Constants.RegionSize));
1834 newRegionHandle 1896 newRegionHandle
1835 = Util.UIntsToLong((uint) ((thisx + 1)*Constants.RegionSize), 1897 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1836 (uint) (thisy*Constants.RegionSize)); 1898 (uint) (thisy*Constants.RegionSize));
1837 // x + 1 1899 // x + 1
1838 } 1900 }
1839 } 1901 }
1840 else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) 1902 else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1841 { 1903 {
1842 pos.Y = ((pos.Y + Constants.RegionSize)); 1904 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1905 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1906
1907 if (crossedBordery.BorderLine.Z > 0)
1908 {
1909 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1910 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1911 }
1912 else
1913 pos.Y = ((pos.Y + Constants.RegionSize));
1914
1843 newRegionHandle 1915 newRegionHandle
1844 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize)); 1916 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize));
1845 // y - 1 1917 // y - 1
1846 } 1918 }
1847 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) 1919 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
@@ -1849,7 +1921,7 @@ namespace OpenSim.Region.Framework.Scenes
1849 1921
1850 pos.Y = ((pos.Y - Constants.RegionSize)); 1922 pos.Y = ((pos.Y - Constants.RegionSize));
1851 newRegionHandle 1923 newRegionHandle
1852 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); 1924 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize));
1853 // y + 1 1925 // y + 1
1854 } 1926 }
1855 1927
diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
index 1004fb9..9878855 100644
--- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
@@ -299,6 +299,7 @@ namespace OpenSim.Services.Connectors.Inventory
299 299
300 if (StringToUrlAndUserID(id, out url, out userID)) 300 if (StringToUrlAndUserID(id, out url, out userID))
301 { 301 {
302 //m_log.DebugFormat("[HGInventory CONNECTOR]: calling {0}", url);
302 ISessionAuthInventoryService connector = GetConnector(url); 303 ISessionAuthInventoryService connector = GetConnector(url);
303 return connector.QueryItem(userID, item, sessionID); 304 return connector.QueryItem(userID, item, sessionID);
304 } 305 }
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index 14560b1..e69e4cd 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -200,6 +200,12 @@ namespace OpenSim.Services.Interfaces
200 Maturity = ConvertFrom.RegionSettings.Maturity; 200 Maturity = ConvertFrom.RegionSettings.Maturity;
201 RegionSecret = ConvertFrom.regionSecret; 201 RegionSecret = ConvertFrom.regionSecret;
202 EstateOwner = ConvertFrom.EstateSettings.EstateOwner; 202 EstateOwner = ConvertFrom.EstateSettings.EstateOwner;
203 if (EstateOwner == UUID.Zero)
204 {
205 EstateOwner = ConvertFrom.MasterAvatarAssignedUUID;
206 ConvertFrom.EstateSettings.EstateOwner = EstateOwner;
207 ConvertFrom.EstateSettings.Save();
208 }
203 } 209 }
204 210
205 public GridRegion(GridRegion ConvertFrom) 211 public GridRegion(GridRegion ConvertFrom)
diff --git a/bin/config-include/FlotsamCache.ini.example b/bin/config-include/FlotsamCache.ini.example
index abb3b9a..b50d7ec 100644
--- a/bin/config-include/FlotsamCache.ini.example
+++ b/bin/config-include/FlotsamCache.ini.example
@@ -50,3 +50,10 @@
50 50
51 ; Warning level for cache directory size 51 ; Warning level for cache directory size
52 ;CacheWarnAt = 30000 52 ;CacheWarnAt = 30000
53
54 ; Perform a deep scan of all assets within all regions, looking for all assets
55 ; present or referenced. Mark all assets found that are already present in the
56 ; cache, and request all assets that are found that are not already cached (this
57 ; will cause those assets to be cached)
58 ;
59 ; DeepScanBeforePurge = false