diff options
author | Justin Clarke Casey | 2009-02-13 17:40:52 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-02-13 17:40:52 +0000 |
commit | 92232663e4878d5a1f74489ba9fcfd418a10990e (patch) | |
tree | 05ffb7ee167a3d67758aec8a601e701aa38d3149 /OpenSim/Region/CoreModules | |
parent | * Remove old Scene.CreateTerrainTexture code that is now handled by the world... (diff) | |
download | opensim-SC_OLD-92232663e4878d5a1f74489ba9fcfd418a10990e.zip opensim-SC_OLD-92232663e4878d5a1f74489ba9fcfd418a10990e.tar.gz opensim-SC_OLD-92232663e4878d5a1f74489ba9fcfd418a10990e.tar.bz2 opensim-SC_OLD-92232663e4878d5a1f74489ba9fcfd418a10990e.tar.xz |
* refactor: Move LazySaveGeneratedMapTile from scene to WorldMapModule
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 9f5277b..9355374 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -50,7 +50,7 @@ using OSDMap=OpenMetaverse.StructuredData.OSDMap; | |||
50 | 50 | ||
51 | namespace OpenSim.Region.CoreModules.World.WorldMap | 51 | namespace OpenSim.Region.CoreModules.World.WorldMap |
52 | { | 52 | { |
53 | public class WorldMapModule : IRegionModule | 53 | public class WorldMapModule : IRegionModule, IWorldMapModule |
54 | { | 54 | { |
55 | private static readonly ILog m_log = | 55 | private static readonly ILog m_log = |
56 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 56 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -89,6 +89,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
89 | return; | 89 | return; |
90 | 90 | ||
91 | m_scene = scene; | 91 | m_scene = scene; |
92 | |||
93 | m_scene.RegisterModuleInterface<IWorldMapModule>(this); | ||
92 | 94 | ||
93 | m_scene.AddCommand( | 95 | m_scene.AddCommand( |
94 | this, "export-map", | 96 | this, "export-map", |
@@ -935,6 +937,64 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
935 | } | 937 | } |
936 | return responsemap; | 938 | return responsemap; |
937 | } | 939 | } |
940 | |||
941 | public void LazySaveGeneratedMaptile(byte[] data, bool temporary) | ||
942 | { | ||
943 | // Overwrites the local Asset cache with new maptile data | ||
944 | // Assets are single write, this causes the asset server to ignore this update, | ||
945 | // but the local asset cache does not | ||
946 | |||
947 | // this is on purpose! The net result of this is the region always has the most up to date | ||
948 | // map tile while protecting the (grid) asset database from bloat caused by a new asset each | ||
949 | // time a mapimage is generated! | ||
950 | |||
951 | UUID lastMapRegionUUID = m_scene.RegionInfo.lastMapUUID; | ||
952 | |||
953 | int lastMapRefresh = 0; | ||
954 | int twoDays = 172800; | ||
955 | int RefreshSeconds = twoDays; | ||
956 | |||
957 | try | ||
958 | { | ||
959 | lastMapRefresh = Convert.ToInt32(m_scene.RegionInfo.lastMapRefresh); | ||
960 | } | ||
961 | catch (ArgumentException) | ||
962 | { | ||
963 | } | ||
964 | catch (FormatException) | ||
965 | { | ||
966 | } | ||
967 | catch (OverflowException) | ||
968 | { | ||
969 | } | ||
970 | |||
971 | UUID TerrainImageUUID = UUID.Random(); | ||
972 | |||
973 | if (lastMapRegionUUID == UUID.Zero || (lastMapRefresh + RefreshSeconds) < Util.UnixTimeSinceEpoch()) | ||
974 | { | ||
975 | m_scene.RegionInfo.SaveLastMapUUID(TerrainImageUUID); | ||
976 | |||
977 | m_log.Debug("[MAPTILE]: STORING MAPTILE IMAGE"); | ||
978 | } | ||
979 | else | ||
980 | { | ||
981 | TerrainImageUUID = lastMapRegionUUID; | ||
982 | m_log.Debug("[MAPTILE]: REUSING OLD MAPTILE IMAGE ID"); | ||
983 | } | ||
984 | |||
985 | m_scene.RegionInfo.RegionSettings.TerrainImageID = TerrainImageUUID; | ||
986 | |||
987 | AssetBase asset = new AssetBase(); | ||
988 | asset.Metadata.FullID = m_scene.RegionInfo.RegionSettings.TerrainImageID; | ||
989 | asset.Data = data; | ||
990 | asset.Metadata.Name | ||
991 | = "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(); | ||
992 | asset.Metadata.Description = m_scene.RegionInfo.RegionName; | ||
993 | |||
994 | asset.Metadata.Type = 0; | ||
995 | asset.Metadata.Temporary = temporary; | ||
996 | m_scene.CommsManager.AssetCache.AddAsset(asset); | ||
997 | } | ||
938 | 998 | ||
939 | private void MakeRootAgent(ScenePresence avatar) | 999 | private void MakeRootAgent(ScenePresence avatar) |
940 | { | 1000 | { |