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 | |
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')
-rw-r--r-- | OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 62 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 60 |
2 files changed, 65 insertions, 57 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 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ebf5a06..9cf181b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1129,64 +1129,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1129 | 1129 | ||
1130 | byte[] data = terrain.WriteJpeg2000Image("defaultstripe.png"); | 1130 | byte[] data = terrain.WriteJpeg2000Image("defaultstripe.png"); |
1131 | if (data != null) | 1131 | if (data != null) |
1132 | LazySaveGeneratedMaptile(data, temporary); | ||
1133 | } | ||
1134 | |||
1135 | public void LazySaveGeneratedMaptile(byte[] data, bool temporary) | ||
1136 | { | ||
1137 | // Overwrites the local Asset cache with new maptile data | ||
1138 | // Assets are single write, this causes the asset server to ignore this update, | ||
1139 | // but the local asset cache does not | ||
1140 | |||
1141 | // this is on purpose! The net result of this is the region always has the most up to date | ||
1142 | // map tile while protecting the (grid) asset database from bloat caused by a new asset each | ||
1143 | // time a mapimage is generated! | ||
1144 | |||
1145 | UUID lastMapRegionUUID = m_regInfo.lastMapUUID; | ||
1146 | |||
1147 | int lastMapRefresh = 0; | ||
1148 | int twoDays = 172800; | ||
1149 | int RefreshSeconds = twoDays; | ||
1150 | |||
1151 | try | ||
1152 | { | ||
1153 | lastMapRefresh = Convert.ToInt32(m_regInfo.lastMapRefresh); | ||
1154 | } | ||
1155 | catch (ArgumentException) | ||
1156 | { | 1132 | { |
1133 | IWorldMapModule mapModule = RequestModuleInterface<IWorldMapModule>(); | ||
1134 | |||
1135 | if (mapModule != null) | ||
1136 | mapModule.LazySaveGeneratedMaptile(data, temporary); | ||
1157 | } | 1137 | } |
1158 | catch (FormatException) | ||
1159 | { | ||
1160 | } | ||
1161 | catch (OverflowException) | ||
1162 | { | ||
1163 | } | ||
1164 | |||
1165 | UUID TerrainImageUUID = UUID.Random(); | ||
1166 | |||
1167 | if (lastMapRegionUUID == UUID.Zero || (lastMapRefresh + RefreshSeconds) < Util.UnixTimeSinceEpoch()) | ||
1168 | { | ||
1169 | m_regInfo.SaveLastMapUUID(TerrainImageUUID); | ||
1170 | |||
1171 | m_log.Warn("[MAPTILE]: STORING MAPTILE IMAGE"); | ||
1172 | } | ||
1173 | else | ||
1174 | { | ||
1175 | TerrainImageUUID = lastMapRegionUUID; | ||
1176 | m_log.Warn("[MAPTILE]: REUSING OLD MAPTILE IMAGE ID"); | ||
1177 | } | ||
1178 | |||
1179 | m_regInfo.RegionSettings.TerrainImageID = TerrainImageUUID; | ||
1180 | |||
1181 | AssetBase asset = new AssetBase(); | ||
1182 | asset.Metadata.FullID = m_regInfo.RegionSettings.TerrainImageID; | ||
1183 | asset.Data = data; | ||
1184 | asset.Metadata.Name = "terrainImage_" + m_regInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(); | ||
1185 | asset.Metadata.Description = RegionInfo.RegionName; | ||
1186 | |||
1187 | asset.Metadata.Type = 0; | ||
1188 | asset.Metadata.Temporary = temporary; | ||
1189 | AssetCache.AddAsset(asset); | ||
1190 | } | 1138 | } |
1191 | 1139 | ||
1192 | #endregion | 1140 | #endregion |