From 6bea792436521c1635eed73a002975f4334c9354 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 14 Jun 2008 02:39:27 +0000 Subject: * Enables maptile display in grid mode for simulators that are not on the same instance. * Only generates a new maptile after a refresh interval * Maptile names have the UnixTimeSinceEpoch that they were generated and the regionUUID they're from, so you can know which ones are no longer necessary. * Updates RegionInfo, so backup your /bin/Region/*.xml files. --- OpenSim/Region/Environment/Scenes/Scene.cs | 81 ++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index e70fbe2..a7535e1 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1287,12 +1287,51 @@ namespace OpenSim.Region.Environment.Scenes return; } - m_regInfo.EstateSettings.terrainImageID = LLUUID.Random(); + + + LLUUID lastMapRegionUUID = m_regInfo.lastMapUUID; + + int lastMapRefresh = 0; + int twoDays = 172800; + int RefreshSeconds = twoDays; + + try + { + lastMapRefresh = Convert.ToInt32(m_regInfo.lastMapRefresh); + } catch (ArgumentException) + {} + catch (FormatException) + {} + catch (OverflowException) + {} + + LLUUID TerrainImageLLUUID = LLUUID.Random(); + + if (lastMapRegionUUID == LLUUID.Zero || (lastMapRefresh + RefreshSeconds) < Util.UnixTimeSinceEpoch()) + { + + m_regInfo.SaveLastMapUUID(TerrainImageLLUUID); + + m_log.Warn("[MAPTILE]: STORING MAPTILE IMAGE"); + //Extra protection.. probably not needed. + + } + else + { + TerrainImageLLUUID = lastMapRegionUUID; + m_log.Warn("[MAPTILE]: REUSING OLD MAPTILE IMAGE ID"); + } + + + + m_regInfo.EstateSettings.terrainImageID = TerrainImageLLUUID; + AssetBase asset = new AssetBase(); asset.FullID = m_regInfo.EstateSettings.terrainImageID; asset.Data = data; - asset.Name = "terrainImage"; + asset.Name = "terrainImage_" + m_regInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(); asset.Description = RegionInfo.RegionName; + asset.Type = 0; asset.Temporary = temporary; AssetCache.AddAsset(asset); @@ -1302,11 +1341,45 @@ namespace OpenSim.Region.Environment.Scenes byte[] data = terrain.WriteJpeg2000Image("defaultstripe.png"); if (data != null) { - m_regInfo.EstateSettings.terrainImageID = LLUUID.Random(); + LLUUID lastMapRegionUUID = m_regInfo.lastMapUUID; + + int lastMapRefresh = 0; + int twoDays = 172800; + int RefreshSeconds = twoDays; + + try + { + lastMapRefresh = Convert.ToInt32(m_regInfo.lastMapRefresh); + } + catch (ArgumentException) + { } + catch (FormatException) + { } + catch (OverflowException) + { } + + LLUUID TerrainImageLLUUID = LLUUID.Random(); + + if (lastMapRegionUUID == LLUUID.Zero || (lastMapRefresh + RefreshSeconds) < Util.UnixTimeSinceEpoch()) + { + + m_regInfo.SaveLastMapUUID(TerrainImageLLUUID); + + //m_log.Warn(terrainImageID); + //Extra protection.. probably not needed. + + } + else + { + TerrainImageLLUUID = lastMapRegionUUID; + } + + m_regInfo.EstateSettings.terrainImageID = TerrainImageLLUUID; + AssetBase asset = new AssetBase(); asset.FullID = m_regInfo.EstateSettings.terrainImageID; asset.Data = data; - asset.Name = "terrainImage"; + asset.Name = "terrainImage_" + m_regInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(); asset.Description = RegionInfo.RegionName; asset.Type = 0; asset.Temporary = temporary; -- cgit v1.1