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. --- .../Modules/World/Terrain/TerrainModule.cs | 4 +- OpenSim/Region/Environment/Scenes/Scene.cs | 81 ++++++++++++++++++++-- 2 files changed, 80 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs index e2b7fb2..9d8bbfc 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs @@ -389,7 +389,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain m_tainted = false; m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); m_scene.SaveTerrain(); - m_scene.CreateTerrainTexture(true); + + // Clients who look at the map will never see changes after they looked at the map, so i've commented this out. + //m_scene.CreateTerrainTexture(true); } } 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