From b233a4b2cab3a39f9edc17130cd7c2f2f807d6bb Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sun, 9 May 2010 13:39:56 -0700
Subject: * Fixed spamming the assets table with map tiles. The tile image ID
is now stored in regionsettings. Upon generation of a new tile image, the old
one is deleted. Tested for SQLite and MySql standalone. * Fixed small bug
with map search where the local sim regions weren't found.
---
OpenSim/Region/Application/OpenSimBase.cs | 2 +-
.../CoreModules/Avatar/Assets/GetTextureModule.cs | 2 ++
.../Grid/RemoteGridServiceConnector.cs | 4 ++-
.../CoreModules/World/WorldMap/WorldMapModule.cs | 31 ++++++++++------------
.../Region/Framework/Interfaces/IWorldMapModule.cs | 2 +-
OpenSim/Region/Framework/Scenes/Scene.cs | 6 +++--
6 files changed, 25 insertions(+), 22 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 06ffa91..83be61e 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -349,7 +349,7 @@ namespace OpenSim
// moved these here as the terrain texture has to be created after the modules are initialized
// and has to happen before the region is registered with the grid.
- scene.CreateTerrainTexture(false);
+ scene.CreateTerrainTexture();
// TODO : Try setting resource for region xstats here on scene
MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo));
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
index 53d2cef..f8e3d59 100644
--- a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
@@ -121,6 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
UUID textureID;
if (!String.IsNullOrEmpty(textureStr) && UUID.TryParse(textureStr, out textureID))
{
+ //m_log.DebugFormat("[GETTEXTURE]: {0}", textureID);
AssetBase texture;
if (!String.IsNullOrEmpty(REDIRECT_URL))
@@ -167,6 +168,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
private void SendTexture(OSHttpRequest request, OSHttpResponse response, AssetBase texture)
{
string range = request.Headers.GetOne("Range");
+ //m_log.DebugFormat("[GETTEXTURE]: Range {0}", range);
if (!String.IsNullOrEmpty(range))
{
// Range request
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index d44ddf4..46741a5 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -197,7 +197,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (grinfo != null)
{
//m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetRegionsByName {0} found {1} regions", name, grinfo.Count);
- rinfo.AddRange(grinfo);
+ foreach (GridRegion r in grinfo)
+ if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null)
+ rinfo.Add(r);
}
return rinfo;
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 2b0e83f..ac6a633 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -1000,7 +1000,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
return responsemap;
}
- public void LazySaveGeneratedMaptile(byte[] data, bool temporary)
+ public void RegenerateMaptile(byte[] data)
{
// Overwrites the local Asset cache with new maptile data
// Assets are single write, this causes the asset server to ignore this update,
@@ -1010,7 +1010,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
// map tile while protecting the (grid) asset database from bloat caused by a new asset each
// time a mapimage is generated!
- UUID lastMapRegionUUID = m_scene.RegionInfo.lastMapUUID;
+ UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID;
int lastMapRefresh = 0;
int twoDays = 172800;
@@ -1030,21 +1030,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
{
}
- UUID TerrainImageUUID = UUID.Random();
+ m_log.Debug("[MAPTILE]: STORING MAPTILE IMAGE");
- if (lastMapRegionUUID == UUID.Zero || (lastMapRefresh + RefreshSeconds) < Util.UnixTimeSinceEpoch())
- {
- m_scene.RegionInfo.SaveLastMapUUID(TerrainImageUUID);
-
- m_log.Debug("[MAPTILE]: STORING MAPTILE IMAGE");
- }
- else
- {
- TerrainImageUUID = lastMapRegionUUID;
- m_log.Debug("[MAPTILE]: REUSING OLD MAPTILE IMAGE ID");
- }
-
- m_scene.RegionInfo.RegionSettings.TerrainImageID = TerrainImageUUID;
+ m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Random();
AssetBase asset = new AssetBase(
m_scene.RegionInfo.RegionSettings.TerrainImageID,
@@ -1053,8 +1041,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
m_scene.RegionInfo.RegionID.ToString());
asset.Data = data;
asset.Description = m_scene.RegionInfo.RegionName;
- asset.Temporary = temporary;
+ asset.Temporary = false;
+ asset.Flags = AssetFlags.Maptile;
+
+ // Store the new one
+ m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID);
m_scene.AssetService.Store(asset);
+ m_scene.RegionInfo.RegionSettings.Save();
+
+ // Delete the old one
+ m_log.DebugFormat("[WORLDMAP]: Deleting old map tile {0}", lastMapRegionUUID);
+ m_scene.AssetService.Delete(lastMapRegionUUID.ToString());
}
private void MakeRootAgent(ScenePresence avatar)
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs
index de1bcd4..ac6afed 100644
--- a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs
@@ -29,6 +29,6 @@ namespace OpenSim.Region.Framework.Interfaces
{
public interface IWorldMapModule
{
- void LazySaveGeneratedMaptile(byte[] data, bool temporary);
+ void RegenerateMaptile(byte[] data);
}
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c0fa7b4..edbef4c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1823,7 +1823,7 @@ namespace OpenSim.Region.Framework.Scenes
///
/// Create a terrain texture for this scene
///
- public void CreateTerrainTexture(bool temporary)
+ public void CreateTerrainTexture()
{
//create a texture asset of the terrain
IMapImageGenerator terrain = RequestModuleInterface();
@@ -1841,7 +1841,9 @@ namespace OpenSim.Region.Framework.Scenes
IWorldMapModule mapModule = RequestModuleInterface();
if (mapModule != null)
- mapModule.LazySaveGeneratedMaptile(data, temporary);
+ mapModule.RegenerateMaptile(data);
+ else
+ m_log.DebugFormat("[SCENE]: MapModule is null, can't save maptile");
}
}
--
cgit v1.1