aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/Terrain.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/NHibernate/Terrain.cs118
1 files changed, 0 insertions, 118 deletions
diff --git a/OpenSim/Data/NHibernate/Terrain.cs b/OpenSim/Data/NHibernate/Terrain.cs
deleted file mode 100644
index 4be35c6..0000000
--- a/OpenSim/Data/NHibernate/Terrain.cs
+++ /dev/null
@@ -1,118 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Reflection;
31using log4net;
32using OpenMetaverse;
33using OpenSim.Framework;
34
35namespace OpenSim.Data.NHibernate
36{
37 public class Terrain
38 {
39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40
41 private double[,] map;
42 private UUID regionID;
43
44 public Terrain(UUID Region, double[,] array)
45 {
46 map = array;
47 regionID = Region;
48 }
49
50 public Terrain()
51 {
52 map = new double[Constants.RegionSize, Constants.RegionSize];
53 map.Initialize();
54 regionID = UUID.Zero;
55 }
56
57 public UUID RegionID
58 {
59 get { return regionID; }
60 set { regionID = value; }
61 }
62
63 public byte[] MapData
64 {
65 get { return serializeTerrain(map); }
66 set { map = parseTerrain(value); }
67 }
68
69 public double[,] Doubles
70 {
71 get {return map;}
72 set {map = value;}
73 }
74
75 private static double[,] parseTerrain(byte[] data)
76 {
77 double[,] terret = new double[Constants.RegionSize, Constants.RegionSize];
78 terret.Initialize();
79
80 MemoryStream str = new MemoryStream(data);
81 BinaryReader br = new BinaryReader(str);
82 try {
83 for (int x = 0; x < Constants.RegionSize; x++)
84 {
85 for (int y = 0; y < Constants.RegionSize; y++)
86 {
87 terret[x, y] = br.ReadDouble();
88 }
89 }
90 }
91 catch (Exception e)
92 {
93 m_log.Error("Issue parsing Map", e);
94 }
95 return terret;
96 }
97
98 private static byte[] serializeTerrain(double[,] val)
99 {
100 MemoryStream str = new MemoryStream((int) ((Constants.RegionSize*Constants.RegionSize)*sizeof (double)));
101 BinaryWriter bw = new BinaryWriter(str);
102
103 // TODO: COMPATIBILITY - Add byte-order conversions
104 for (int x = 0; x < Constants.RegionSize; x++)
105 {
106 for (int y = 0; y < Constants.RegionSize; y++)
107 {
108 double height = val[x, y];
109 if (height <= 0.0)
110 height = double.Epsilon;
111
112 bw.Write(height);
113 }
114 }
115 return str.ToArray();
116 }
117 }
118}