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/Framework/RegionInfo.cs | 28 ++++++++ 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 ++++++++++++++++++++-- 5 files changed, 110 insertions(+), 6 deletions(-) diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 9c27891..979ced5 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -208,6 +208,9 @@ namespace OpenSim.Framework public string RegionName = String.Empty; public string regionSecret = LLUUID.Random().ToString(); + public LLUUID lastMapUUID = LLUUID.Zero; + public string lastMapRefresh = "0"; + // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. public RegionInfo(string description, string filename, bool skipConsoleConfig) @@ -384,6 +387,11 @@ namespace OpenSim.Framework configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "(Sandbox Mode Only)Password for Master Avatar account", MasterAvatarSandboxPassword, true); + configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + "Last Map UUID", lastMapUUID.ToString(), true); + configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); + } public void loadConfigurationOptions() @@ -430,6 +438,12 @@ namespace OpenSim.Framework "(Sandbox Mode Only)Password for Master Avatar account", "test", false, (ConfigurationOption.ConfigurationOptionShouldBeAsked) shouldMasterAvatarDetailsBeAsked); + configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + "Last Map UUID", lastMapUUID.ToString(), true); + + configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); + } public bool shouldMasterAvatarDetailsBeAsked(string configuration_key) @@ -498,6 +512,12 @@ namespace OpenSim.Framework string tempMD5Passwd = (string) configuration_result; MasterAvatarSandboxPassword = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty); break; + case "lastmap_uuid": + lastMapUUID = (LLUUID)configuration_result; + break; + case "lastmap_refresh": + lastMapRefresh = (string)configuration_result; + break; } return true; @@ -507,5 +527,13 @@ namespace OpenSim.Framework { configMember.forceSetConfigurationOption("estate_covanant_uuid", notecard.ToString()); } + public void SaveLastMapUUID(LLUUID mapUUID) + { + lastMapUUID = mapUUID; + lastMapRefresh = Util.UnixTimeSinceEpoch().ToString(); + + configMember.forceSetConfigurationOption("lastmap_uuid", mapUUID.ToString()); + configMember.forceSetConfigurationOption("lastmap_refresh", lastMapRefresh); + } } } \ No newline at end of file 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