diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 35eed56813..13f5fa2ac6 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -111,7 +111,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand( - "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", + "SELECT name, description, assetType, local, temporary, asset_flags, data FROM assets WHERE id=?id", dbcon)) { cmd.Parameters.AddWithValue("?id", assetID.ToString()); @@ -133,6 +133,7 @@ namespace OpenSim.Data.MySQL asset.Local = false; asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); + asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); } } } @@ -345,7 +346,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id"); + MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon); cmd.Parameters.AddWithValue("?id", id); cmd.ExecuteNonQuery(); diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index a395ddc3e7..8c83ef13f7 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -989,7 +989,8 @@ namespace OpenSim.Data.MySQL "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDateTime, ?LoadedCreationID)"; + "?LoadedCreationDateTime, ?LoadedCreationID)" + + "?map_tile_ID, ?TerrainImageID"; FillRegionSettingsCommand(cmd, rs); @@ -1276,6 +1277,8 @@ namespace OpenSim.Data.MySQL else newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; + newSettings.TerrainImageID = new UUID((String)row["map_tile_ID"]); + return newSettings; } @@ -1596,6 +1599,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); + cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); } diff --git a/OpenSim/Data/MySQL/Resources/033_RegionStore.sql b/OpenSim/Data/MySQL/Resources/033_RegionStore.sql new file mode 100644 index 0000000000..2832b413ff --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/033_RegionStore.sql @@ -0,0 +1,3 @@ +BEGIN; +ALTER TABLE regionsettings ADD map_tile_ID CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; +COMMIT; diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index 30ad747d25..d596698127 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs @@ -40,7 +40,7 @@ namespace OpenSim.Data.Null { private static NullRegionData Instance = null; -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); Dictionary m_regionData = new Dictionary(); @@ -62,12 +62,14 @@ namespace OpenSim.Data.Null { if (regionName.Contains("%")) { - if (r.RegionName.Contains(regionName.Replace("%", ""))) + string cleanname = regionName.Replace("%", ""); + m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanname.ToLower(), r.RegionName.ToLower()); + if (r.RegionName.ToLower().Contains(cleanname.ToLower())) ret.Add(r); } else { - if (r.RegionName == regionName) + if (r.RegionName.ToLower() == regionName.ToLower()) ret.Add(r); } } diff --git a/OpenSim/Data/SQLite/Resources/005_AssetStore.sql b/OpenSim/Data/SQLite/Resources/005_AssetStore.sql new file mode 100644 index 0000000000..f06121abc1 --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/005_AssetStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; + +COMMIT; diff --git a/OpenSim/Data/SQLite/Resources/019_RegionStore.sql b/OpenSim/Data/SQLite/Resources/019_RegionStore.sql new file mode 100644 index 0000000000..d62f8484b8 --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/019_RegionStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE regionsettings ADD COLUMN map_tile_ID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000'; + +COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 2783ba1556..7d6df8d627 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -46,8 +46,8 @@ namespace OpenSim.Data.SQLite private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, UUID from assets limit :start, :count"; private const string DeleteAssetSQL = "delete from assets where UUID=:UUID"; - private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Data)"; - private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, Data=:Data where UUID=:UUID"; + private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, asset_flags, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Flags, :Data)"; + private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, asset_flags=:Flags, Data=:Data where UUID=:UUID"; private const string assetSelect = "select * from assets"; private SqliteConnection m_conn; @@ -136,6 +136,7 @@ namespace OpenSim.Data.SQLite cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); + cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags)); cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); cmd.ExecuteNonQuery(); @@ -154,6 +155,7 @@ namespace OpenSim.Data.SQLite cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); + cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags)); cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); cmd.ExecuteNonQuery(); @@ -227,7 +229,8 @@ namespace OpenSim.Data.SQLite asset.Description = (String) row["Description"]; asset.Local = Convert.ToBoolean(row["Local"]); asset.Temporary = Convert.ToBoolean(row["Temporary"]); - asset.Data = (byte[]) row["Data"]; + asset.Flags = (AssetFlags)Convert.ToInt32(row["asset_flags"]); + asset.Data = (byte[])row["Data"]; return asset; } @@ -240,6 +243,7 @@ namespace OpenSim.Data.SQLite metadata.Description = (string) row["Description"]; metadata.Type = Convert.ToSByte(row["Type"]); metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct. + metadata.Flags = (AssetFlags)Convert.ToInt32(row["asset_flags"]); // Current SHA1s are not stored/computed. metadata.SHA1 = new byte[] {}; diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 997664a45c..85703dc2ca 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -1156,6 +1156,7 @@ namespace OpenSim.Data.SQLite createCol(regionsettings, "fixed_sun", typeof (Int32)); createCol(regionsettings, "sun_position", typeof (Double)); createCol(regionsettings, "covenant", typeof(String)); + createCol(regionsettings, "map_tile_ID", typeof(String)); regionsettings.PrimaryKey = new DataColumn[] { regionsettings.Columns["regionUUID"] }; return regionsettings; } @@ -1474,6 +1475,7 @@ namespace OpenSim.Data.SQLite newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); newSettings.Covenant = new UUID((String) row["covenant"]); + newSettings.TerrainImageID = new UUID((String)row["map_tile_ID"]); return newSettings; } @@ -1792,6 +1794,7 @@ namespace OpenSim.Data.SQLite row["fixed_sun"] = settings.FixedSun; row["sun_position"] = settings.SunPosition; row["covenant"] = settings.Covenant.ToString(); + row["map_tile_ID"] = settings.TerrainImageID.ToString(); } /// diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index 7ecf198bd8..53d28be088 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs @@ -36,10 +36,10 @@ namespace OpenSim.Framework [Flags] public enum AssetFlags : int { - Normal = 0, - Maptile = 1, - Rewritable = 2, - Collectable = 4 + Normal = 0, // Immutable asset + Maptile = 1, // What it says + Rewritable = 2, // Content can be rewritten + Collectable = 4 // Can be GC'ed after some time } /// diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 06ffa917f5..83be61ee63 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 53d2cefeac..f8e3d595c9 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 d44ddf4b1a..46741a58ec 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 2b0e83f52f..ac6a633413 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 de1bcd4382..ac6afed9ce 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 c0fa7b4289..edbef4c884 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"); } } diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 4fc38f3173..470a4ddcc5 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -156,6 +156,7 @@ namespace OpenSim.Services.AssetService public bool Delete(string id) { + m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id); UUID assetID; if (!UUID.TryParse(id, out assetID)) return false; @@ -165,7 +166,11 @@ namespace OpenSim.Services.AssetService return false; if ((int)(asset.Flags & AssetFlags.Maptile) != 0) + { return m_Database.Delete(id); + } + else + m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); return false; } diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 4089fcee18..7c9864270c 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -324,6 +324,7 @@ namespace OpenSim.Services.GridService if (rdatas != null) { + m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); foreach (RegionData rdata in rdatas) { if (count++ < maxNumber) @@ -331,7 +332,7 @@ namespace OpenSim.Services.GridService } } - if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0) && name.Contains("."))) + if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0)) && name.Contains(".")) { GridRegion r = m_HypergridLinker.LinkRegion(scopeID, name); if (r != null)