diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs index ba430b7..fc81376 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs | |||
@@ -57,6 +57,43 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | |||
57 | return retval; | 57 | return retval; |
58 | } | 58 | } |
59 | 59 | ||
60 | public override string ToString() | ||
61 | { | ||
62 | return "RAW32"; | ||
63 | } | ||
64 | |||
65 | public ITerrainChannel LoadFile(string filename, int fileStartX, int fileStartY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) | ||
66 | { | ||
67 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); | ||
68 | |||
69 | FileInfo file = new FileInfo(filename); | ||
70 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | ||
71 | BinaryReader bs = new BinaryReader(s); | ||
72 | |||
73 | // Advance to our section of the file | ||
74 | if (fileStartY * sectionHeight > 0) | ||
75 | bs.ReadBytes(fileStartY * sectionHeight); | ||
76 | |||
77 | int x, y; | ||
78 | for (y = 0; y < retval.Height; y++) | ||
79 | { | ||
80 | // Advance the stream if we aren't at the start of the section in the file | ||
81 | if (fileStartX * sectionWidth > 0) | ||
82 | bs.ReadBytes(fileStartX * sectionHeight); | ||
83 | |||
84 | for (x = 0; x < retval.Width; x++) | ||
85 | { | ||
86 | // Read a strip and continue | ||
87 | retval[x, y] = bs.ReadSingle(); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | bs.Close(); | ||
92 | s.Close(); | ||
93 | |||
94 | return retval; | ||
95 | } | ||
96 | |||
60 | public void SaveFile(string filename, ITerrainChannel map) | 97 | public void SaveFile(string filename, ITerrainChannel map) |
61 | { | 98 | { |
62 | FileInfo file = new FileInfo(filename); | 99 | FileInfo file = new FileInfo(filename); |