diff options
author | Sean Dague | 2008-07-17 20:58:24 +0000 |
---|---|---|
committer | Sean Dague | 2008-07-17 20:58:24 +0000 |
commit | 18a5cfd10fa6fa2d3b94f1be7edb656f9688ee27 (patch) | |
tree | 04aec792d43cf02cfeea850a4e8644a3929f2d8a /OpenSim/Data/NHibernate/Terrain.cs | |
parent | need to synchronize the terrain updates (diff) | |
download | opensim-SC_OLD-18a5cfd10fa6fa2d3b94f1be7edb656f9688ee27.zip opensim-SC_OLD-18a5cfd10fa6fa2d3b94f1be7edb656f9688ee27.tar.gz opensim-SC_OLD-18a5cfd10fa6fa2d3b94f1be7edb656f9688ee27.tar.bz2 opensim-SC_OLD-18a5cfd10fa6fa2d3b94f1be7edb656f9688ee27.tar.xz |
terrain is close to working, but I still end up at the bottom of the sea
right now.
Diffstat (limited to 'OpenSim/Data/NHibernate/Terrain.cs')
-rw-r--r-- | OpenSim/Data/NHibernate/Terrain.cs | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/OpenSim/Data/NHibernate/Terrain.cs b/OpenSim/Data/NHibernate/Terrain.cs index 4c184da..a95e45a 100644 --- a/OpenSim/Data/NHibernate/Terrain.cs +++ b/OpenSim/Data/NHibernate/Terrain.cs | |||
@@ -27,13 +27,17 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Reflection; | ||
30 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using log4net; | ||
31 | using libsecondlife; | 33 | using libsecondlife; |
32 | 34 | ||
33 | namespace OpenSim.Data.NHibernate | 35 | namespace OpenSim.Data.NHibernate |
34 | { | 36 | { |
35 | public class Terrain | 37 | public class Terrain |
36 | { | 38 | { |
39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
40 | |||
37 | private double[,] map; | 41 | private double[,] map; |
38 | private LLUUID regionID; | 42 | private LLUUID regionID; |
39 | 43 | ||
@@ -70,29 +74,36 @@ namespace OpenSim.Data.NHibernate | |||
70 | 74 | ||
71 | private static double[,] parseTerrain(byte[] data) | 75 | private static double[,] parseTerrain(byte[] data) |
72 | { | 76 | { |
73 | double[,] terret = new double[Constants.RegionSize,Constants.RegionSize]; | 77 | double[,] terret = new double[256,256]; |
74 | terret.Initialize(); | 78 | terret.Initialize(); |
75 | 79 | ||
76 | MemoryStream str = new MemoryStream(data); | 80 | MemoryStream str = new MemoryStream(data); |
77 | BinaryReader br = new BinaryReader(str); | 81 | BinaryReader br = new BinaryReader(str); |
78 | for (int x = 0; x < Constants.RegionSize; x++) | 82 | try { |
79 | { | 83 | for (int x = 0; x < 256; x++) |
80 | for (int y = 0; y < Constants.RegionSize; y++) | ||
81 | { | 84 | { |
82 | terret[x, y] = br.ReadDouble(); | 85 | for (int y = 0; y < 256; y++) |
86 | { | ||
87 | terret[x, y] = br.ReadDouble(); | ||
88 | } | ||
83 | } | 89 | } |
90 | } | ||
91 | catch (Exception e) | ||
92 | { | ||
93 | m_log.Error("Issue parsing Map", e); | ||
84 | } | 94 | } |
85 | return terret; | 95 | return terret; |
86 | } | 96 | } |
87 | 97 | ||
88 | private static byte[] serializeTerrain(double[,] val) | 98 | private static byte[] serializeTerrain(double[,] val) |
89 | { | 99 | { |
90 | MemoryStream str = new MemoryStream((int)(Constants.RegionSize * Constants.RegionSize * sizeof (double))); | 100 | MemoryStream str = new MemoryStream((int)(65536 * sizeof (double))); |
91 | BinaryWriter bw = new BinaryWriter(str); | 101 | BinaryWriter bw = new BinaryWriter(str); |
92 | 102 | ||
93 | // TODO: COMPATIBILITY - Add byte-order conversions | 103 | // TODO: COMPATIBILITY - Add byte-order conversions |
94 | for (int x = 0; x < Constants.RegionSize; x++) | 104 | for (int x = 0; x < 256; x++) |
95 | for (int y = 0; y < Constants.RegionSize; y++) | 105 | { |
106 | for (int y = 0; y < 256; y++) | ||
96 | { | 107 | { |
97 | double height = val[x, y]; | 108 | double height = val[x, y]; |
98 | if (height <= 0.0) | 109 | if (height <= 0.0) |
@@ -100,8 +111,8 @@ namespace OpenSim.Data.NHibernate | |||
100 | 111 | ||
101 | bw.Write(height); | 112 | bw.Write(height); |
102 | } | 113 | } |
103 | 114 | } | |
104 | return (byte[])str.ToArray(); | 115 | return str.ToArray(); |
105 | } | 116 | } |
106 | } | 117 | } |
107 | } \ No newline at end of file | 118 | } \ No newline at end of file |