diff options
Added support for terrain map to be serialised to xml(as base64 binary). useful for places that the terrain map is needed in a serialised form. Also could add console commands to save and load from files, which should be faster than .raw files (these load/save commands are not included/implemented)
Add util functions to compress and uncompress strings.
Fixed a couple of modules so they use SceneCommunicationService rather than directly call functions on the CommsManager.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World')
3 files changed, 77 insertions, 4 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs index eccaa78..a851cad 100644 --- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs | |||
@@ -950,8 +950,6 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions | |||
950 | 950 | ||
951 | return true; | 951 | return true; |
952 | } | 952 | } |
953 | |||
954 | |||
955 | } | 953 | } |
956 | 954 | ||
957 | } | 955 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs index 1399960..53d03fc 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs | |||
@@ -27,6 +27,11 @@ | |||
27 | 27 | ||
28 | using OpenSim.Framework; | 28 | using OpenSim.Framework; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | using System; | ||
31 | using System.Text; | ||
32 | using System.Xml; | ||
33 | using System.IO; | ||
34 | using System.Xml.Serialization; | ||
30 | 35 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 36 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
32 | { | 37 | { |
@@ -151,5 +156,75 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain | |||
151 | 156 | ||
152 | return copy; | 157 | return copy; |
153 | } | 158 | } |
159 | |||
160 | public string SaveToXmlString() | ||
161 | { | ||
162 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
163 | settings.Encoding = Encoding.UTF8; | ||
164 | using (StringWriter sw = new StringWriter()) | ||
165 | { | ||
166 | using (XmlWriter writer = XmlWriter.Create(sw, settings)) | ||
167 | { | ||
168 | WriteXml(writer); | ||
169 | } | ||
170 | string output = sw.ToString(); | ||
171 | return output; | ||
172 | } | ||
173 | } | ||
174 | |||
175 | private void WriteXml(XmlWriter writer) | ||
176 | { | ||
177 | writer.WriteStartElement(String.Empty, "TerrainMap", String.Empty); | ||
178 | ToXml(writer); | ||
179 | writer.WriteEndElement(); | ||
180 | } | ||
181 | |||
182 | public void LoadFromXmlString(string data) | ||
183 | { | ||
184 | StringReader sr = new StringReader(data); | ||
185 | XmlTextReader reader = new XmlTextReader(sr); | ||
186 | reader.Read(); | ||
187 | |||
188 | ReadXml(reader); | ||
189 | reader.Close(); | ||
190 | sr.Close(); | ||
191 | } | ||
192 | |||
193 | private void ReadXml(XmlReader reader) | ||
194 | { | ||
195 | reader.ReadStartElement("TerrainMap"); | ||
196 | FromXml(reader); | ||
197 | } | ||
198 | |||
199 | private void ToXml(XmlWriter xmlWriter) | ||
200 | { | ||
201 | float[] mapData = GetFloatsSerialised(); | ||
202 | byte[] buffer = new byte[mapData.Length * 4]; | ||
203 | for (int i = 0; i < mapData.Length; i++) | ||
204 | { | ||
205 | byte[] value = BitConverter.GetBytes(mapData[i]); | ||
206 | Array.Copy(value, 0, buffer, (i * 4), 4); | ||
207 | } | ||
208 | XmlSerializer serializer = new XmlSerializer(typeof(byte[])); | ||
209 | serializer.Serialize(xmlWriter, buffer); | ||
210 | } | ||
211 | |||
212 | private void FromXml(XmlReader xmlReader) | ||
213 | { | ||
214 | XmlSerializer serializer = new XmlSerializer(typeof(byte[])); | ||
215 | byte[] dataArray = (byte[])serializer.Deserialize(xmlReader); | ||
216 | int index = 0; | ||
217 | |||
218 | for (int y = 0; y < Height; y++) | ||
219 | { | ||
220 | for (int x = 0; x < Width; x++) | ||
221 | { | ||
222 | float value; | ||
223 | value = BitConverter.ToSingle(dataArray, index); | ||
224 | index += 4; | ||
225 | this[x, y] = (double)value; | ||
226 | } | ||
227 | } | ||
228 | } | ||
154 | } | 229 | } |
155 | } \ No newline at end of file | 230 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs index c8d2ef6..5287517 100644 --- a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs | |||
@@ -166,7 +166,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
166 | { | 166 | { |
167 | List<MapBlockData> mapBlocks; | 167 | List<MapBlockData> mapBlocks; |
168 | 168 | ||
169 | mapBlocks = m_scene.CommsManager.GridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8); | 169 | mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8); |
170 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks); | 170 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks); |
171 | 171 | ||
172 | lock (cachedMapBlocks) | 172 | lock (cachedMapBlocks) |
@@ -244,7 +244,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
244 | public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) | 244 | public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) |
245 | { | 245 | { |
246 | List<MapBlockData> mapBlocks; | 246 | List<MapBlockData> mapBlocks; |
247 | mapBlocks = m_scene.CommsManager.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4); | 247 | mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4); |
248 | remoteClient.SendMapBlock(mapBlocks); | 248 | remoteClient.SendMapBlock(mapBlocks); |
249 | } | 249 | } |
250 | public Hashtable OnHTTPGetMapImage(Hashtable keysvals) | 250 | public Hashtable OnHTTPGetMapImage(Hashtable keysvals) |