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/Application/OpenSimBase.cs | 2 +- .../Region/ClientStack/LindenUDP/LLClientView.cs | 1 + .../Modules/World/Terrain/TerrainModule.cs | 4 +- OpenSim/Region/Environment/Scenes/Scene.cs | 81 ++++++++++++++++++++-- 4 files changed, 82 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index f96c29b..6d74903 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -511,7 +511,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(true); + scene.CreateTerrainTexture(false); try { diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 5cbe04e..0b2aa52 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1224,6 +1224,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { mapReply.Data[i] = new MapBlockReplyPacket.DataBlock(); mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId; + //m_log.Warn(mapBlocks2[i].MapImageId.ToString()); mapReply.Data[i].X = mapBlocks2[i].X; mapReply.Data[i].Y = mapBlocks2[i].Y; mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight; 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