Skip to content

Commit 109c7e3

Browse files
committed
Biomes: Define and use biome_t for biome IDs
1 parent 8ed467d commit 109c7e3

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/mapgen.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3636
#define MG_LIGHT 0x10
3737
#define MG_DECORATIONS 0x20
3838

39+
typedef u8 biome_t; // copy from mg_biome.h to avoid an unnecessary include
40+
3941
class Settings;
4042
class MMVManip;
4143
class INodeDefManager;
@@ -161,7 +163,7 @@ class Mapgen {
161163

162164
u32 blockseed;
163165
s16 *heightmap;
164-
u8 *biomemap;
166+
biome_t *biomemap;
165167
v3s16 csize;
166168

167169
BiomeGen *biomegen;

src/mg_biome.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ BiomeGenOriginal::BiomeGenOriginal(BiomeManager *biomemgr,
128128

129129
heatmap = noise_heat->result;
130130
humidmap = noise_humidity->result;
131-
biomemap = new u8[m_csize.X * m_csize.Z];
131+
biomemap = new biome_t[m_csize.X * m_csize.Z];
132132
}
133133

134134
BiomeGenOriginal::~BiomeGenOriginal()
@@ -171,7 +171,7 @@ void BiomeGenOriginal::calcBiomeNoise(v3s16 pmin)
171171
}
172172

173173

174-
u8 *BiomeGenOriginal::getBiomes(s16 *heightmap)
174+
biome_t *BiomeGenOriginal::getBiomes(s16 *heightmap)
175175
{
176176
for (s32 i = 0; i != m_csize.X * m_csize.Z; i++) {
177177
Biome *biome = calcBiomeFromNoise(

src/mg_biome.h

+6-7
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ class BiomeManager;
3131
//// Biome
3232
////
3333

34-
#define BIOME_NONE ((u8)0)
34+
typedef u8 biome_t;
35+
36+
#define BIOME_NONE ((biome_t)0)
3537

3638
// TODO(hmmmm): Decide whether this is obsolete or will be used in the future
3739
enum BiomeType {
@@ -101,7 +103,7 @@ class BiomeGen {
101103
// Gets all biomes in current chunk using each corresponding element of
102104
// heightmap as the y position, then stores the results by biome index in
103105
// biomemap (also returned)
104-
virtual u8 *getBiomes(s16 *heightmap) = 0;
106+
virtual biome_t *getBiomes(s16 *heightmap) = 0;
105107

106108
// Gets a single biome at the specified position, which must be contained
107109
// in the region formed by m_pmin and (m_pmin + m_csize - 1).
@@ -111,7 +113,7 @@ class BiomeGen {
111113
virtual Biome *getBiomeAtIndex(size_t index, s16 y) const = 0;
112114

113115
// Result of calcBiomes bulk computation.
114-
u8 *biomemap;
116+
biome_t *biomemap;
115117

116118
protected:
117119
BiomeManager *m_bmgr;
@@ -157,7 +159,7 @@ class BiomeGenOriginal : public BiomeGen {
157159
Biome *calcBiomeAtPoint(v3s16 pos) const;
158160
void calcBiomeNoise(v3s16 pmin);
159161

160-
u8 *getBiomes(s16 *heightmap);
162+
biome_t *getBiomes(s16 *heightmap);
161163
Biome *getBiomeAtPoint(v3s16 pos) const;
162164
Biome *getBiomeAtIndex(size_t index, s16 y) const;
163165

@@ -218,9 +220,6 @@ class BiomeManager : public ObjDefManager {
218220

219221
virtual void clear();
220222

221-
// Looks for pos in the biome cache, and if non-existent, looks up by noise
222-
u8 getBiomeAtPoint(v3s16 pos);
223-
224223
private:
225224
IGameDef *m_gamedef;
226225

0 commit comments

Comments
 (0)