1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
#include "stdafx.h"
#include "Arrays.h"
#include "FixedBiomeSource.h"
FixedBiomeSource::FixedBiomeSource(Biome *fixed, float temperature, float downfall)
{
biome = fixed;
this->temperature = temperature;
this->downfall = downfall;
}
Biome *FixedBiomeSource::getBiome(ChunkPos *cp)
{
return biome;
}
Biome *FixedBiomeSource::getBiome(int x, int z)
{
return biome;
}
float FixedBiomeSource::getTemperature(int x, int z)
{
return temperature;
}
void FixedBiomeSource::getTemperatureBlock(floatArray& temperatures, int x, int z, int w, int h) const
{
if (temperatures.data == nullptr || temperatures.length < w * h)
{
if(temperatures.data != nullptr) delete [] temperatures.data;
temperatures = floatArray(w * h);
}
Arrays::fill(temperatures, 0, w * h, temperature);
}
floatArray FixedBiomeSource::getTemperatureBlock(int x, int z, int w, int h) const
{
floatArray temps(w*h);
getTemperatureBlock(temps, x, z, w, h);
return temps;
}
// 4J - note that caller is responsible for deleting returned array. temperatures array is for output only.
void FixedBiomeSource::getTemperatureBlock(doubleArray& temperatures, int x, int z, int w, int h) const
{
temperatures = doubleArray(w * h);
Arrays::fill(temperatures, 0, w * h, (double)temperature);
}
void FixedBiomeSource::getDownfallBlock(floatArray &downfalls, int x, int z, int w, int h) const
{
if (downfalls.data == nullptr || downfalls.length < w * h)
{
if(downfalls.data != nullptr) delete [] downfalls.data;
downfalls = floatArray(w * h);
}
Arrays::fill(downfalls, 0, w * h, downfall);
}
floatArray FixedBiomeSource::getDownfallBlock(int x, int z, int w, int h) const
{
floatArray downfalls(w*h);
getDownfallBlock(downfalls, x, z, w, h);
return downfalls;
}
float FixedBiomeSource::getDownfall(int x, int z) const
{
return downfall;
}
void FixedBiomeSource::getDownfallBlock(doubleArray downfalls, int x, int z, int w, int h)
{
if (downfalls.data == nullptr || downfalls.length < w * h)
{
if(downfalls.data != nullptr) delete [] downfalls.data;
downfalls = doubleArray(w * h);
}
Arrays::fill(downfalls, 0, w * h, (double) downfall);
}
// 4J - caller is responsible for deleting biomes array, plus any optional arrays output if pointers are passed in (_temperatures, _downfalls)
void FixedBiomeSource::getBiomeBlock(BiomeArray& biomes, int x, int z, int w, int h, bool useCache) const
{
MemSect(36);
biomes = BiomeArray(w * h);
MemSect(0);
Arrays::fill(biomes, 0, w * h, biome);
}
// 4J - caller is responsible for deleting biomes array, plus any optional arrays output if pointers are passed in (_temperatures, _downfalls)
void FixedBiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z, int w, int h, bool useCache) const
{
MemSect(36);
biomeIndices = byteArray(w * h);
MemSect(0);
int biomeIndex = biome->id;
Arrays::fill(biomeIndices, 0, w * h, biomeIndex);
}
// 4J-PB added in from beyond 1.8.2
// 4J - caller is responsible for deleting biomes array, plus any optional arrays output if pointers are passed in (_temperatures, _downfalls)
void FixedBiomeSource::getRawBiomeBlock(BiomeArray& biomes,int x, int z, int w, int h) const
{
MemSect(36);
biomes = BiomeArray(w * h);
MemSect(0);
Arrays::fill(biomes, 0, w * h, biome);
}
// 4J-PB added in from beyond 1.8.2
// 4J - caller is responsible for deleting biomes array, plus any optional arrays output if pointers are passed in (_temperatures, _downfalls)
BiomeArray FixedBiomeSource::getRawBiomeBlock( int x, int z, int w, int h) const
{
BiomeArray biomes;
getRawBiomeBlock(biomes, x, z, w, h);
return biomes;
}
TilePos *FixedBiomeSource::findBiome(int x, int z, int r, Biome *toFind, Random *random)
{
if (toFind == biome)
{
return new TilePos(x - r + random->nextInt(r * 2 + 1), 0, z - r + random->nextInt(r * 2 + 1));
}
return nullptr;
}
TilePos *FixedBiomeSource::findBiome(int x, int z, int r, vector<Biome *> allowed, Random *random)
{
if (find(allowed.begin(), allowed.end(), biome) != allowed.end())
{
return new TilePos(x - r + random->nextInt(r * 2 + 1), 0, z - r + random->nextInt(r * 2 + 1));
}
return nullptr;
}
bool FixedBiomeSource::containsOnly(int x, int z, int r, Biome *allowed)
{
return allowed == biome;
}
bool FixedBiomeSource::containsOnly(int x, int z, int r, vector<Biome *> allowed)
{
return find(allowed.begin(), allowed.end(), biome) != allowed.end();
}
|