diff options
author | Adam Frisby | 2008-04-21 06:39:16 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-21 06:39:16 +0000 |
commit | 05e24c8f58e5cc41b3e7704b1912dfbe9703d4fe (patch) | |
tree | 09f7aa55e82ede0839373e85895a34fb3e797b31 /OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs | |
parent | * Written a improved self-contained version of the XML Object Serialiser for ... (diff) | |
download | opensim-SC_OLD-05e24c8f58e5cc41b3e7704b1912dfbe9703d4fe.zip opensim-SC_OLD-05e24c8f58e5cc41b3e7704b1912dfbe9703d4fe.tar.gz opensim-SC_OLD-05e24c8f58e5cc41b3e7704b1912dfbe9703d4fe.tar.bz2 opensim-SC_OLD-05e24c8f58e5cc41b3e7704b1912dfbe9703d4fe.tar.xz |
* Terrain Module code has been reformatted to comply with guidelines.
* Fixed a variety of code quality issues. (Yes, I've found ReSharper.)
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs index 7575b1b..d496069 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs | |||
@@ -25,7 +25,6 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
29 | using System.IO; | 28 | using System.IO; |
30 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
31 | 30 | ||
@@ -57,11 +56,6 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | |||
57 | return retval; | 56 | return retval; |
58 | } | 57 | } |
59 | 58 | ||
60 | public override string ToString() | ||
61 | { | ||
62 | return "RAW32"; | ||
63 | } | ||
64 | |||
65 | public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) | 59 | public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) |
66 | { | 60 | { |
67 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); | 61 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); |
@@ -69,7 +63,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | |||
69 | FileInfo file = new FileInfo(filename); | 63 | FileInfo file = new FileInfo(filename); |
70 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 64 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
71 | BinaryReader bs = new BinaryReader(s); | 65 | BinaryReader bs = new BinaryReader(s); |
72 | 66 | ||
73 | int currFileXOffset = 0; | 67 | int currFileXOffset = 0; |
74 | int currFileYOffset = 0; | 68 | int currFileYOffset = 0; |
75 | 69 | ||
@@ -79,7 +73,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | |||
79 | { | 73 | { |
80 | // read a whole strip of regions | 74 | // read a whole strip of regions |
81 | int heightsToRead = sectionHeight * (fileWidth * sectionWidth); | 75 | int heightsToRead = sectionHeight * (fileWidth * sectionWidth); |
82 | bs.ReadBytes( heightsToRead * 4); // because the floats are 4 bytes in the file | 76 | bs.ReadBytes(heightsToRead * 4); // because the floats are 4 bytes in the file |
83 | currFileYOffset++; | 77 | currFileYOffset++; |
84 | } | 78 | } |
85 | 79 | ||
@@ -90,13 +84,13 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | |||
90 | for (y = 0; y < sectionHeight; y++) | 84 | for (y = 0; y < sectionHeight; y++) |
91 | { | 85 | { |
92 | currFileXOffset = 0; | 86 | currFileXOffset = 0; |
93 | 87 | ||
94 | // if our region isn't the first X section of the areas to be landscaped, then | 88 | // if our region isn't the first X section of the areas to be landscaped, then |
95 | // advance the stream to the X start pos of our section in the file | 89 | // advance the stream to the X start pos of our section in the file |
96 | // i.e. eat X upto where we start | 90 | // i.e. eat X upto where we start |
97 | while (currFileXOffset < offsetX) | 91 | while (currFileXOffset < offsetX) |
98 | { | 92 | { |
99 | bs.ReadBytes( sectionWidth * 4); // 4 bytes = single | 93 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single |
100 | currFileXOffset++; | 94 | currFileXOffset++; |
101 | } | 95 | } |
102 | 96 | ||
@@ -111,14 +105,12 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | |||
111 | 105 | ||
112 | // if our region isn't the last X section of the areas to be landscaped, then | 106 | // if our region isn't the last X section of the areas to be landscaped, then |
113 | // advance the stream to the end of this Y column | 107 | // advance the stream to the end of this Y column |
114 | while (currFileXOffset < fileWidth ) | 108 | while (currFileXOffset < fileWidth) |
115 | { | 109 | { |
116 | // eat the next regions x line | 110 | // eat the next regions x line |
117 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | 111 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single |
118 | currFileXOffset++; | 112 | currFileXOffset++; |
119 | } | 113 | } |
120 | |||
121 | |||
122 | } | 114 | } |
123 | 115 | ||
124 | bs.Close(); | 116 | bs.Close(); |
@@ -138,7 +130,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | |||
138 | { | 130 | { |
139 | for (x = 0; x < map.Width; x++) | 131 | for (x = 0; x < map.Width; x++) |
140 | { | 132 | { |
141 | bs.Write((float)map[x, y]); | 133 | bs.Write((float) map[x, y]); |
142 | } | 134 | } |
143 | } | 135 | } |
144 | 136 | ||
@@ -147,5 +139,10 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | |||
147 | } | 139 | } |
148 | 140 | ||
149 | #endregion | 141 | #endregion |
142 | |||
143 | public override string ToString() | ||
144 | { | ||
145 | return "RAW32"; | ||
146 | } | ||
150 | } | 147 | } |
151 | } | 148 | } \ No newline at end of file |