Cuberite
A lightweight, fast and extensible game server for Minecraft
IntGen.h
Go to the documentation of this file.
1 // IntGen.h
2 
3 // Declares the cIntGen class and descendants for generating and filtering various 2D arrays of ints
4 
5 /*
6 The integers generated may be interpreted in several ways:
7 - land / sea designators
8  - 0 = ocean
9  - >0 = land
10 - biome group
11  - 0 = ocean
12  - 1 = desert biomes
13  - 2 = temperate biomes
14  - 3 = mountains (hills and forests)
15  - 4 = ice biomes
16 - biome group with "bgfRare" flag (for generating rare biomes for the group)
17 - biome IDs
18 The interpretation depends on the generator used and on the position in the chain.
19 
20 The generators can be chained together - one produces data that another one consumes.
21 Some of such chain connections require changing the data dimensions between the two, which is handled automatically
22 by using templates.
23 */
24 
25 
26 
27 
28 
29 #pragma once
30 
31 #include <tuple>
32 #include "../Noise/Noise.h"
33 #include "BiomeDef.h"
34 
35 
36 
37 
38 
40 const int bgOcean = 0;
41 const int bgDesert = 1;
42 const int bgTemperate = 2;
43 const int bgMountains = 3;
44 const int bgIce = 4;
45 const int bgLandOceanMax = 4; // Maximum biome group value generated in the landOcean generator
46 const int bgfRare = 1024; // Flag added to values to generate rare biomes for the group
47 
48 
49 
50 
51 
53 template <int SizeX, int SizeZ = SizeX>
54 class cIntGen
55 {
56 public:
57 
59 
62  virtual ~cIntGen() {}
63 
65  using Values = int[SizeX * SizeZ];
66 
68  virtual void GetInts(int a_MinX, int a_MinZ, Values & a_Values) = 0;
69 
70 };
71 
72 // Code adapted from https://stackoverflow.com/questions/7858817/unpacking-a-tuple-to-call-a-matching-function-pointer
73 
74 template<int... >
75 struct sSeq
76 {
77 };
78 
79 template<int N, int... S>
80 struct sGens : sGens<N - 1, N - 1, S...>
81 {
82 };
83 
84 template<int... S>
85 struct sGens<0, S...>
86 {
87  using type = sSeq<S...>;
88 };
89 
90 
91 template<class Gen, class... Args>
93 {
94 
95 public:
96 
97  using Generator = Gen;
98 
99  cIntGenFactory(Args&&... a_args) :
100  m_args(std::make_tuple<Args...>(std::forward<Args>(a_args)...))
101  {
102  }
103 
104  template <class LhsGen>
105  std::shared_ptr<Gen> construct(LhsGen&& a_Lhs)
106  {
107  return construct_impl<LhsGen>(std::forward<LhsGen>(a_Lhs), typename sGens<sizeof...(Args)>::type());
108  }
109 
110 
111 private:
112  std::tuple<Args...> m_args;
113 
114  template <class LhsGen, int... S>
115  std::shared_ptr<Gen> construct_impl(LhsGen&& a_Lhs, sSeq<S...>)
116  {
117  return std::make_shared<Gen>(std::get<S>(m_args)..., std::forward<LhsGen>(a_Lhs));
118  }
119 
120 };
121 
122 template<class T, class RhsGen, class... Args>
123 std::shared_ptr<RhsGen> operator| (std::shared_ptr<T> a_Lhs, cIntGenFactory<RhsGen, Args...> a_Rhs)
124 {
125  return a_Rhs.construct(static_cast<std::shared_ptr<typename T::IntGenType>>(a_Lhs));
126 }
127 
128 template<class Gen, class... Args>
129 cIntGenFactory<Gen, Args...> MakeIntGen(Args&&... a_Args)
130 {
131  return cIntGenFactory<Gen, Args...>(std::forward<Args>(a_Args)...);
132 }
133 
134 
135 
137 template <int SizeX, int SizeZ = SizeX>
139  public cIntGen<SizeX, SizeZ>
140 {
142 
143 public:
144 
145  cIntGenWithNoise(int a_Seed):
146  m_Noise(a_Seed)
147  {
148  }
149 
150 protected:
152 
154  int ChooseRandomOne(int a_RndX, int a_RndZ, int a_Val1, int a_Val2)
155  {
156  int rnd = m_Noise.IntNoise2DInt(a_RndX, a_RndZ) / 7;
157  return ((rnd & 1) == 0) ? a_Val1 : a_Val2;
158  }
159 
161  int ChooseRandomOne(int a_RndX, int a_RndZ, int a_Val1, int a_Val2, int a_Val3, int a_Val4)
162  {
163  int rnd = m_Noise.IntNoise2DInt(a_RndX, a_RndZ) / 7;
164  switch (rnd % 4)
165  {
166  case 0: return a_Val1;
167  case 1: return a_Val2;
168  case 2: return a_Val3;
169  default: return a_Val4;
170  }
171  }
172 };
173 
174 
175 
176 
177 
179 template <int Range, int SizeX, int SizeZ = SizeX>
181  public cIntGenWithNoise<SizeX, SizeZ>
182 {
184 
185 public:
186 
187  cIntGenChoice(int a_Seed):
188  Super(a_Seed)
189  {
190  }
191 
192 
193  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
194  {
195  for (int z = 0; z < SizeZ; z++)
196  {
197  int BaseZ = a_MinZ + z;
198  for (int x = 0; x < SizeX; x++)
199  {
200  a_Values[x + SizeX * z] = (Super::m_Noise.IntNoise2DInt(a_MinX + x, BaseZ) / 7) % Range;
201  }
202  } // for z
203  }
204 };
205 
206 
207 
208 
209 
213 template <int SizeX, int SizeZ = SizeX>
215  public cIntGenWithNoise<SizeX, SizeZ>
216 {
218 
219 public:
220 
221  cIntGenLandOcean(int a_Seed, int a_Threshold):
222  Super(a_Seed),
223  m_Threshold(a_Threshold)
224  {
225  }
226 
227 
228  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
229  {
230  for (int z = 0; z < SizeZ; z++)
231  {
232  int BaseZ = a_MinZ + z;
233  for (int x = 0; x < SizeX; x++)
234  {
235  int rnd = (Super::m_Noise.IntNoise2DInt(a_MinX + x, BaseZ) / 7);
236  a_Values[x + SizeX * z] = ((rnd % 100) < m_Threshold) ? ((rnd / 101) % bgLandOceanMax + 1) : 0;
237  }
238  }
239 
240  // If the centerpoint of the world is within the area, set it to bgTemperate, always:
241  if ((a_MinX <= 0) && (a_MinZ <= 0) && (a_MinX + SizeX > 0) && (a_MinZ + SizeZ > 0))
242  {
243  a_Values[-a_MinX - a_MinZ * SizeX] = bgTemperate;
244  }
245  }
246 
247 protected:
249 };
250 
251 
252 
253 
254 
258 template <int SizeX, int SizeZ = SizeX>
260  public cIntGenWithNoise<SizeX, SizeZ>
261 {
263 
264 protected:
265 
266  static const int m_LowerSizeX = (SizeX / 2) + 2;
267  static const int m_LowerSizeZ = (SizeZ / 2) + 2;
268 
269 public:
270 
271  using Underlying = std::shared_ptr<cIntGen<m_LowerSizeX, m_LowerSizeZ>>;
272 
273 
274  cIntGenZoom(int a_Seed, Underlying a_UnderlyingGen):
275  Super(a_Seed),
276  m_UnderlyingGen(a_UnderlyingGen)
277  {
278  }
279 
280 
281  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
282  {
283  // Generate the underlying data with half the resolution:
284  int lowerMinX = a_MinX >> 1;
285  int lowerMinZ = a_MinZ >> 1;
286  int lowerData[m_LowerSizeX * m_LowerSizeZ];
287  m_UnderlyingGen->GetInts(lowerMinX, lowerMinZ, lowerData);
288  const int lowStepX = (m_LowerSizeX - 1) * 2;
289  const int lowStepZ = (m_LowerSizeZ - 1) * 2;
290  int cache[lowStepX * lowStepZ];
291 
292  // Discreet-interpolate the values into twice the size:
293  for (int z = 0; z < m_LowerSizeZ - 1; ++z)
294  {
295  int idx = (z * 2) * lowStepX;
296  int PrevZ0 = lowerData[z * m_LowerSizeX];
297  int PrevZ1 = lowerData[(z + 1) * m_LowerSizeX];
298 
299  for (int x = 0; x < m_LowerSizeX - 1; ++x)
300  {
301  int ValX1Z0 = lowerData[x + 1 + z * m_LowerSizeX];
302  int ValX1Z1 = lowerData[x + 1 + (z + 1) * m_LowerSizeX];
303  int RndX = (x + lowerMinX) * 2;
304  int RndZ = (z + lowerMinZ) * 2;
305  cache[idx] = PrevZ0;
306  cache[idx + lowStepX] = Super::ChooseRandomOne(RndX, RndZ + 1, PrevZ0, PrevZ1);
307  cache[idx + 1] = Super::ChooseRandomOne(RndX, RndZ - 1, PrevZ0, ValX1Z0);
308  cache[idx + 1 + lowStepX] = Super::ChooseRandomOne(RndX, RndZ, PrevZ0, ValX1Z0, PrevZ1, ValX1Z1);
309  idx += 2;
310  PrevZ0 = ValX1Z0;
311  PrevZ1 = ValX1Z1;
312  }
313  }
314 
315  // Copy from Cache into a_Values; take into account the even / odd offsets in a_Min:
316  for (int z = 0; z < SizeZ; ++z)
317  {
318  memcpy(a_Values + z * SizeX, cache + (z + (a_MinZ & 1)) * lowStepX + (a_MinX & 1), SizeX * sizeof(int));
319  }
320  }
321 
322 protected:
324 };
325 
326 
327 
328 
329 
332 template <int SizeX, int SizeZ = SizeX>
334  public cIntGenWithNoise<SizeX, SizeZ>
335 {
337 
338  static const int m_LowerSizeX = SizeX + 2;
339  static const int m_LowerSizeZ = SizeZ + 2;
340 
341 public:
342 
343  using Underlying = std::shared_ptr<cIntGen<m_LowerSizeX, m_LowerSizeZ>>;
344 
345 
346  cIntGenSmooth(int a_Seed, Underlying a_Underlying):
347  Super(a_Seed),
348  m_Underlying(a_Underlying)
349  {
350  }
351 
352 
353  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
354  {
355  // Generate the underlying values:
356  int lowerData[m_LowerSizeX * m_LowerSizeZ];
357  m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerData);
358 
359  // Smooth - for each square check if the surroundings are the same, if so, expand them diagonally.
360  // Also get rid of single-pixel irregularities (A-B-A):
361  for (int z = 0; z < SizeZ; z++)
362  {
363  int NoiseZ = a_MinZ + z;
364  for (int x = 0; x < SizeX; x++)
365  {
366  int val = lowerData[x + 1 + (z + 1) * m_LowerSizeX];
367  int above = lowerData[x + 1 + z * m_LowerSizeX];
368  int below = lowerData[x + 1 + (z + 2) * m_LowerSizeX];
369  int left = lowerData[x + (z + 1) * m_LowerSizeX];
370  int right = lowerData[x + 2 + (z + 1) * m_LowerSizeX];
371 
372  if ((left == right) && (above == below))
373  {
374  if (((Super::m_Noise.IntNoise2DInt(a_MinX + x, NoiseZ) / 7) % 2) == 0)
375  {
376  val = left;
377  }
378  else
379  {
380  val = above;
381  }
382  }
383  else
384  {
385  if (left == right)
386  {
387  val = left;
388  }
389 
390  if (above == below)
391  {
392  val = above;
393  }
394  }
395 
396  a_Values[x + z * SizeX] = val;
397  }
398  }
399  }
400 
401 protected:
403 };
404 
405 
406 
407 
408 
410 template <int SizeX, int SizeZ = SizeX>
412  public cIntGen<SizeX, SizeZ>
413 {
415 
416  static const int m_UnderlyingSizeX = SizeX + 2;
417  static const int m_UnderlyingSizeZ = SizeZ + 2;
418 
419 public:
420 
421  using Underlying = std::shared_ptr<cIntGen<m_UnderlyingSizeX, m_UnderlyingSizeZ>>;
422 
423 
424  cIntGenBeaches(Underlying a_Underlying):
425  m_Underlying(a_Underlying)
426  {
427  }
428 
429 
430  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
431  {
432  // Map for biome -> its beach:
433  static const int ToBeach[] =
434  {
435  /* biOcean */ biOcean,
436  /* biPlains */ biBeach,
437  /* biDesert */ biBeach,
438  /* biExtremeHills */ biStoneBeach,
439  /* biForest */ biBeach,
440  /* biTaiga */ biColdBeach,
441  /* biSwampland */ biSwampland,
442  /* biRiver */ biRiver,
443  /* biNether */ biNether,
444  /* biEnd */ biEnd,
445  /* biFrozenOcean */ biColdBeach,
446  /* biFrozenRiver */ biColdBeach,
447  /* biIcePlains */ biColdBeach,
448  /* biIceMountains */ biColdBeach,
449  /* biMushroomIsland */ biMushroomShore,
450  /* biMushroomShore */ biMushroomShore,
451  /* biBeach */ biBeach,
452  /* biDesertHills */ biBeach,
453  /* biForestHills */ biBeach,
454  /* biTaigaHills */ biColdBeach,
455  /* biExtremeHillsEdge */ biStoneBeach,
456  /* biJungle */ biBeach,
457  /* biJungleHills */ biBeach,
458  /* biJungleEdge */ biBeach,
459  /* biDeepOcean */ biOcean,
460  /* biStoneBeach */ biStoneBeach,
461  /* biColdBeach */ biColdBeach,
462  /* biBirchForest */ biBeach,
463  /* biBirchForestHills */ biBeach,
464  /* biRoofedForest */ biBeach,
465  /* biColdTaiga */ biColdBeach,
466  /* biColdTaigaHills */ biColdBeach,
467  /* biMegaTaiga */ biStoneBeach,
468  /* biMegaTaigaHills */ biStoneBeach,
469  /* biExtremeHillsPlus */ biStoneBeach,
470  /* biSavanna */ biBeach,
471  /* biSavannaPlateau */ biBeach,
472  /* biMesa */ biMesa,
473  /* biMesaPlateauF */ biMesa,
474  /* biMesaPlateau */ biMesa,
475  };
476 
477  // Generate the underlying values:
478  int lowerValues[m_UnderlyingSizeX * m_UnderlyingSizeZ];
479  m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerValues);
480 
481  // Add beaches between ocean and biomes:
482  for (int z = 0; z < SizeZ; z++)
483  {
484  for (int x = 0; x < SizeX; x++)
485  {
486  int val = lowerValues[x + 1 + (z + 1) * m_UnderlyingSizeX];
487  int above = lowerValues[x + 1 + z * m_UnderlyingSizeX];
488  int below = lowerValues[x + 1 + (z + 2) * m_UnderlyingSizeX];
489  int left = lowerValues[x + (z + 1) * m_UnderlyingSizeX];
490  int right = lowerValues[x + 2 + (z + 1) * m_UnderlyingSizeX];
491  if (!IsBiomeOcean(val))
492  {
493  if (IsBiomeOcean(above) || IsBiomeOcean(below) || IsBiomeOcean(left) || IsBiomeOcean(right))
494  {
495  // First convert the value to a regular biome (drop the M flag), then modulo by our biome count:
496  val = ToBeach[static_cast<size_t>((val % 128)) % ARRAYCOUNT(ToBeach)];
497  }
498  }
499  a_Values[x + z * SizeX] = val;
500  }
501  }
502  }
503 
504 protected:
506 };
507 
508 
509 
510 
511 
514 template <int SizeX, int SizeZ = SizeX>
516  public cIntGenWithNoise<SizeX, SizeZ>
517 {
519 
520 public:
521 
522  using Underlying = std::shared_ptr<cIntGen<SizeX, SizeZ>>;
523 
524 
525  cIntGenAddIslands(int a_Seed, int a_Chance, Underlying a_Underlying):
526  Super(a_Seed),
527  m_Chance(a_Chance),
528  m_Underlying(a_Underlying)
529  {
530  }
531 
532 
533  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
534  {
535  m_Underlying->GetInts(a_MinX, a_MinZ, a_Values);
536  for (int z = 0; z < SizeZ; z++)
537  {
538  for (int x = 0; x < SizeX; x++)
539  {
540  if (a_Values[x + z * SizeX] == bgOcean)
541  {
542  int rnd = Super::m_Noise.IntNoise2DInt(a_MinX + x, a_MinZ + z) / 7;
543  if (rnd % 1000 < m_Chance)
544  {
545  a_Values[x + z * SizeX] = (rnd / 1003) % bgLandOceanMax;
546  }
547  }
548  } // for x
549  } // for z
550  }
551 
552 protected:
554  int m_Chance;
555 
557 };
558 
559 
560 
561 
562 
564 template <int SizeX, int SizeZ = SizeX>
566  public cIntGen<SizeX, SizeZ>
567 {
569 
570  static const int m_UnderlyingSizeX = SizeX + 2;
571  static const int m_UnderlyingSizeZ = SizeZ + 2;
572 
573 public:
574 
575  using Underlying = std::shared_ptr<cIntGen<m_UnderlyingSizeX, m_UnderlyingSizeZ>>;
576 
577 
579  m_Underlying(a_Underlying)
580  {
581  }
582 
583 
584  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
585  {
586  // Generate the underlying biome groups:
587  int lowerValues[m_UnderlyingSizeX * m_UnderlyingSizeZ];
588  m_Underlying->GetInts(a_MinX, a_MinZ, lowerValues);
589 
590  // Change the biomes on incompatible edges into an edge biome:
591  for (int z = 0; z < SizeZ; z++)
592  {
593  for (int x = 0; x < SizeX; x++)
594  {
595  int val = lowerValues[x + 1 + (z + 1) * m_UnderlyingSizeX];
596  int above = lowerValues[x + 1 + z * m_UnderlyingSizeX];
597  int below = lowerValues[x + 1 + (z + 2) * m_UnderlyingSizeX];
598  int left = lowerValues[x + (z + 1) * m_UnderlyingSizeX];
599  int right = lowerValues[x + 2 + (z + 1) * m_UnderlyingSizeX];
600  switch (val)
601  {
602  // Desert should neighbor only oceans, desert and temperates; change to temperate when another:
603  case bgDesert:
604  {
605  if (
606  !isDesertCompatible(above) ||
607  !isDesertCompatible(below) ||
608  !isDesertCompatible(left) ||
609  !isDesertCompatible(right)
610  )
611  {
612  val = bgTemperate;
613  }
614  break;
615  } // case bgDesert
616 
617  // Ice should not neighbor deserts; change to temperate:
618  case bgIce:
619  {
620  if (
621  (above == bgDesert) ||
622  (below == bgDesert) ||
623  (left == bgDesert) ||
624  (right == bgDesert)
625  )
626  {
627  val = bgTemperate;
628  }
629  break;
630  } // case bgIce
631  }
632  a_Values[x + z * SizeX] = val;
633  } // for x
634  } // for z
635  }
636 
637 protected:
639 
640 
641  inline bool isDesertCompatible(int a_BiomeGroup)
642  {
643  switch (a_BiomeGroup)
644  {
645  case bgOcean:
646  case bgDesert:
647  case bgTemperate:
648  {
649  return true;
650  }
651  default:
652  {
653  return false;
654  }
655  }
656  }
657 };
658 
659 
660 
661 
662 
666 template <int SizeX, int SizeZ = SizeX>
668  public cIntGenWithNoise<SizeX, SizeZ>
669 {
671 
672 public:
673 
674  using Underlying = std::shared_ptr<cIntGen<SizeX, SizeZ>>;
675 
676 
677  cIntGenBiomes(int a_Seed, Underlying a_Underlying):
678  Super(a_Seed),
679  m_Underlying(a_Underlying)
680  {
681  }
682 
683 
684  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
685  {
686  // Define the per-biome-group biomes:
687  static const int oceanBiomes[] =
688  {
689  biOcean, // biDeepOcean,
690  };
691 
692  // Same as oceanBiomes, there are no rare oceanic biomes (mushroom islands are handled separately)
693  static const int rareOceanBiomes[] =
694  {
695  biOcean,
696  };
697 
698  static const int desertBiomes[] =
699  {
701  };
702 
703  static const int rareDesertBiomes[] =
704  {
706  };
707 
708  static const int temperateBiomes[] =
709  {
711  };
712 
713  static const int rareTemperateBiomes[] =
714  {
715  biJungle, // Jungle is not strictly temperate, but let's piggyback it here
716  };
717 
718  static const int mountainBiomes[] =
719  {
721  };
722 
723  static const int rareMountainBiomes[] =
724  {
725  biMegaTaiga,
726  };
727 
728  static const int iceBiomes[] =
729  {
731  };
732 
733  // Same as iceBiomes, there's no rare ice biome
734  static const int rareIceBiomes[] =
735  {
737  };
738 
739  static const cBiomesInGroups biomesInGroups[] =
740  {
741  /* bgOcean */ { static_cast<int>(ARRAYCOUNT(oceanBiomes)), oceanBiomes},
742  /* bgDesert */ { static_cast<int>(ARRAYCOUNT(desertBiomes)), desertBiomes},
743  /* bgTemperate */ { static_cast<int>(ARRAYCOUNT(temperateBiomes)), temperateBiomes},
744  /* bgMountains */ { static_cast<int>(ARRAYCOUNT(mountainBiomes)), mountainBiomes},
745  /* bgIce */ { static_cast<int>(ARRAYCOUNT(iceBiomes)), iceBiomes},
746  };
747 
748  static const cBiomesInGroups rareBiomesInGroups[] =
749  {
750  /* bgOcean */ { static_cast<int>(ARRAYCOUNT(rareOceanBiomes)), rareOceanBiomes},
751  /* bgDesert */ { static_cast<int>(ARRAYCOUNT(rareDesertBiomes)), rareDesertBiomes},
752  /* bgTemperate */ { static_cast<int>(ARRAYCOUNT(rareTemperateBiomes)), rareTemperateBiomes},
753  /* bgMountains */ { static_cast<int>(ARRAYCOUNT(rareMountainBiomes)), rareMountainBiomes},
754  /* bgIce */ { static_cast<int>(ARRAYCOUNT(rareIceBiomes)), rareIceBiomes},
755  };
756 
757  // Generate the underlying values, representing biome groups:
758  m_Underlying->GetInts(a_MinX, a_MinZ, a_Values);
759 
760  // Overwrite each biome group with a random biome from that group:
761  for (int z = 0; z < SizeZ; z++)
762  {
763  int IdxZ = z * SizeX;
764  for (int x = 0; x < SizeX; x++)
765  {
766  size_t val = static_cast<size_t>(a_Values[x + IdxZ]);
767  const cBiomesInGroups & Biomes = (val > bgfRare) ?
768  rareBiomesInGroups[(val & (bgfRare - 1)) % ARRAYCOUNT(rareBiomesInGroups)] :
769  biomesInGroups[val % ARRAYCOUNT(biomesInGroups)];
770  int rnd = (Super::m_Noise.IntNoise2DInt(x + a_MinX, z + a_MinZ) / 7);
771  a_Values[x + IdxZ] = Biomes.Biomes[rnd % Biomes.Count];
772  }
773  }
774  }
775 
776 protected:
777 
779  {
780  const int Count;
781  const int * Biomes;
782  };
783 
784 
787 };
788 
789 
790 
791 
792 
794 template <int SizeX, int SizeZ = SizeX>
796  public cIntGenWithNoise<SizeX, SizeZ>
797 {
799 
800 public:
801 
802  using Underlying = std::shared_ptr<cIntGen<SizeX, SizeZ>>;
803 
804 
805  cIntGenReplaceRandomly(int a_From, int a_To, int a_Chance, int a_Seed, Underlying a_Underlying):
806  Super(a_Seed),
807  m_From(a_From),
808  m_To(a_To),
809  m_Chance(a_Chance),
810  m_Underlying(a_Underlying)
811  {
812  }
813 
814 
815  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
816  {
817  // Generate the underlying values:
818  m_Underlying->GetInts(a_MinX, a_MinZ, a_Values);
819 
820  // Replace some of the values:
821  for (int z = 0; z < SizeZ; z++)
822  {
823  int idxZ = z * SizeX;
824  for (int x = 0; x < SizeX; x++)
825  {
826  int idx = x + idxZ;
827  if (a_Values[idx] == m_From)
828  {
829  int rnd = Super::m_Noise.IntNoise2DInt(x + a_MinX, z + a_MinZ) / 7;
830  if (rnd % 1000 < m_Chance)
831  {
832  a_Values[idx] = m_To;
833  }
834  }
835  }
836  } // for z
837  }
838 
839 
840 protected:
842  int m_From;
843 
845  int m_To;
846 
848  int m_Chance;
849 
851 };
852 
853 
854 
855 
856 
861 template <int SizeX, int SizeZ = SizeX>
863  public cIntGen<SizeX, SizeZ>
864 {
866 
867 public:
868 
869  using Underlying = std::shared_ptr<cIntGen<SizeX, SizeZ>>;
870 
871 
873  m_Biomes(a_Biomes),
874  m_Rivers(a_Rivers)
875  {
876  }
877 
878 
879  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
880  {
881  // Generate the underlying data:
882  m_Biomes->GetInts(a_MinX, a_MinZ, a_Values);
883  typename Super::Values riverData;
884  m_Rivers->GetInts(a_MinX, a_MinZ, riverData);
885 
886  // Mix the values:
887  for (int z = 0; z < SizeZ; z++)
888  {
889  int idxZ = z * SizeX;
890  for (int x = 0; x < SizeX; x++)
891  {
892  int idx = x + idxZ;
893  if (IsBiomeOcean(a_Values[idx]))
894  {
895  // Oceans are kept without any changes
896  continue;
897  }
898  if (riverData[idx] != biRiver)
899  {
900  // There's no river, keep the current value
901  continue;
902  }
903 
904  // There's a river, change the output to a river or a frozen river, based on the original biome:
905  if (IsBiomeVeryCold(static_cast<EMCSBiome>(a_Values[idx])))
906  {
907  a_Values[idx] = biFrozenRiver;
908  }
909  else
910  {
911  a_Values[idx] = biRiver;
912  }
913  } // for x
914  } // for z
915  }
916 
917 protected:
920 };
921 
922 
923 
924 
925 
929 template <int SizeX, int SizeZ = SizeX>
931  public cIntGenWithNoise<SizeX, SizeZ>
932 {
934 
935  static const int UnderlyingSizeX = SizeX + 2;
936  static const int UnderlyingSizeZ = SizeZ + 2;
937 
938 public:
939 
940  using Underlying = std::shared_ptr<cIntGen<UnderlyingSizeX, UnderlyingSizeZ>>;
941 
942 
943  cIntGenRiver(int a_Seed, Underlying a_Underlying):
944  Super(a_Seed),
945  m_Underlying(a_Underlying)
946  {
947  }
948 
949 
950  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
951  {
952  // Generate the underlying data:
953  int Cache[UnderlyingSizeX * UnderlyingSizeZ];
954  m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, Cache);
955 
956  // Detect the edges:
957  for (int z = 0; z < SizeZ; z++)
958  {
959  for (int x = 0; x < SizeX; x++)
960  {
961  int Above = Cache[x + 1 + z * UnderlyingSizeX];
962  int Below = Cache[x + 1 + (z + 2) * UnderlyingSizeX];
963  int Left = Cache[x + (z + 1) * UnderlyingSizeX];
964  int Right = Cache[x + 2 + (z + 1) * UnderlyingSizeX];
965  int val = Cache[x + 1 + (z + 1) * UnderlyingSizeX];
966 
967  if ((val == Above) && (val == Below) && (val == Left) && (val == Right))
968  {
969  val = 0;
970  }
971  else
972  {
973  val = biRiver;
974  }
975  a_Values[x + z * SizeX] = val;
976  } // for x
977  } // for z
978  }
979 
980 protected:
982 };
983 
984 
985 
986 
987 
990 template <int SizeX, int SizeZ = SizeX>
992  public cIntGenWithNoise<SizeX, SizeZ>
993 {
995 
996  static const int UnderlyingSizeX = SizeX + 2;
997  static const int UnderlyingSizeZ = SizeZ + 2;
998 
999 public:
1000 
1001  using Underlying = std::shared_ptr<cIntGen<UnderlyingSizeX, UnderlyingSizeZ>>;
1002 
1003 
1004  cIntGenAddToOcean(int a_Seed, int a_Chance, int a_ToValue, Underlying a_Underlying):
1005  Super(a_Seed),
1006  m_Chance(a_Chance),
1007  m_ToValue(a_ToValue),
1008  m_Underlying(a_Underlying)
1009  {
1010  }
1011 
1012 
1013  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
1014  {
1015  // Generate the underlying data:
1016  int Cache[UnderlyingSizeX * UnderlyingSizeZ];
1017  m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, Cache);
1018 
1019  // Add the mushroom islands:
1020  for (int z = 0; z < SizeZ; z++)
1021  {
1022  for (int x = 0; x < SizeX; x++)
1023  {
1024  int val = Cache[x + 1 + (z + 1) * UnderlyingSizeX];
1025  if (!IsBiomeOcean(val))
1026  {
1027  a_Values[x + z * SizeX] = val;
1028  continue;
1029  }
1030 
1031  // Count the ocean neighbors:
1032  int Above = Cache[x + 1 + z * UnderlyingSizeX];
1033  int Below = Cache[x + 1 + (z + 2) * UnderlyingSizeX];
1034  int Left = Cache[x + (z + 1) * UnderlyingSizeX];
1035  int Right = Cache[x + 2 + (z + 1) * UnderlyingSizeX];
1036  int NumOceanNeighbors = 0;
1037  if (IsBiomeOcean(Above))
1038  {
1039  NumOceanNeighbors += 1;
1040  }
1041  if (IsBiomeOcean(Below))
1042  {
1043  NumOceanNeighbors += 1;
1044  }
1045  if (IsBiomeOcean(Left))
1046  {
1047  NumOceanNeighbors += 1;
1048  }
1049  if (IsBiomeOcean(Right))
1050  {
1051  NumOceanNeighbors += 1;
1052  }
1053 
1054  // If at least 3 ocean neighbors and the chance is right, change:
1055  if (
1056  (NumOceanNeighbors >= 3) &&
1057  ((Super::m_Noise.IntNoise2DInt(x + a_MinX, z + a_MinZ) / 7) % 1000 < m_Chance)
1058  )
1059  {
1060  a_Values[x + z * SizeX] = m_ToValue;
1061  }
1062  else
1063  {
1064  a_Values[x + z * SizeX] = val;
1065  }
1066  } // for x
1067  } // for z
1068  }
1069 
1070 protected:
1073 
1076 
1078 };
1079 
1080 
1081 
1082 
1083 
1085 template <int SizeX, int SizeZ = SizeX>
1087  public cIntGenWithNoise<SizeX, SizeZ>
1088 {
1090 
1091 public:
1092 
1093  using Underlying = std::shared_ptr<cIntGen<SizeX, SizeZ>>;
1094 
1095 
1096  cIntGenSetRandomly(int a_Seed, int a_Chance, int a_ToValue, Underlying a_Underlying):
1097  Super(a_Seed),
1098  m_Chance(a_Chance),
1099  m_ToValue(a_ToValue),
1100  m_Underlying(a_Underlying)
1101  {
1102  }
1103 
1104 
1105  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
1106  {
1107  // Generate the underlying data:
1108  m_Underlying->GetInts(a_MinX, a_MinZ, a_Values);
1109 
1110  // Change random pixels to bgOcean:
1111  for (int z = 0; z < SizeZ; z++)
1112  {
1113  for (int x = 0; x < SizeX; x++)
1114  {
1115  int rnd = Super::m_Noise.IntNoise2DInt(x + a_MinX, z + a_MinZ) / 7;
1116  if (rnd % 1000 < m_Chance)
1117  {
1118  a_Values[x + z * SizeX] = m_ToValue;
1119  }
1120  }
1121  }
1122  }
1123 
1124 protected:
1127 
1130 
1132 };
1133 
1134 
1135 
1136 
1137 
1139 template <int SizeX, int SizeZ = SizeX>
1141  public cIntGenWithNoise<SizeX, SizeZ>
1142 {
1144 
1145 public:
1146 
1147  using Underlying = std::shared_ptr<cIntGen<SizeX, SizeZ>>;
1148 
1149 
1150  cIntGenRareBiomeGroups(int a_Seed, int a_Chance, Underlying a_Underlying):
1151  Super(a_Seed),
1152  m_Chance(a_Chance),
1153  m_Underlying(a_Underlying)
1154  {
1155  }
1156 
1157 
1158  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
1159  {
1160  // Generate the underlying data:
1161  m_Underlying->GetInts(a_MinX, a_MinZ, a_Values);
1162 
1163  // Change some of the biome groups into rare biome groups:
1164  for (int z = 0; z < SizeZ; z++)
1165  {
1166  for (int x = 0; x < SizeX; x++)
1167  {
1168  int rnd = Super::m_Noise.IntNoise2DInt(x + a_MinX, z + a_MinZ) / 7;
1169  if (rnd % 1000 < m_Chance)
1170  {
1171  int idx = x + SizeX * z;
1172  a_Values[idx] = a_Values[idx] | bgfRare;
1173  }
1174  }
1175  }
1176  }
1177 
1178 protected:
1181 
1184 };
1185 
1186 
1187 
1188 
1189 
1192 template <int SizeX, int SizeZ = SizeX>
1194  public cIntGenWithNoise<SizeX, SizeZ>
1195 {
1197 
1198 public:
1199 
1200  using Underlying = std::shared_ptr<cIntGen<SizeX, SizeZ>>;
1201 
1202 
1203  cIntGenAlternateBiomes(int a_Seed, Underlying a_Alterations, Underlying a_BaseBiomes):
1204  Super(a_Seed),
1205  m_Alterations(a_Alterations),
1206  m_BaseBiomes(a_BaseBiomes)
1207  {
1208  }
1209 
1210 
1211  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
1212  {
1213  // Generate the base biomes and the alterations:
1214  m_BaseBiomes->GetInts(a_MinX, a_MinZ, a_Values);
1215  typename Super::Values alterations;
1216  m_Alterations->GetInts(a_MinX, a_MinZ, alterations);
1217 
1218  // Change the biomes into their alternate versions:
1219  for (int idx = 0; idx < SizeX * SizeZ; ++idx)
1220  {
1221  if (alterations[idx] == 0)
1222  {
1223  // No change
1224  continue;
1225  }
1226 
1227  // Change to alternate biomes:
1228  int val = a_Values[idx];
1229  switch (val)
1230  {
1231  case biBirchForest: val = biBirchForestHills; break;
1232  case biDesert: val = biDesertHills; break;
1233  case biExtremeHills: val = biExtremeHillsPlus; break;
1234  case biForest: val = biForestHills; break;
1235  case biIcePlains: val = biIceMountains; break;
1236  case biJungle: val = biJungleHills; break;
1237  case biMegaTaiga: val = biMegaTaigaHills; break;
1238  case biMesaPlateau: val = biMesa; break;
1239  case biMesaPlateauF: val = biMesa; break;
1240  case biMesaPlateauM: val = biMesa; break;
1241  case biMesaPlateauFM: val = biMesa; break;
1242  case biPlains: val = biForest; break;
1243  case biRoofedForest: val = biPlains; break;
1244  case biSavanna: val = biSavannaPlateau; break;
1245  case biTaiga: val = biTaigaHills; break;
1246  }
1247  a_Values[idx] = val;
1248  } // for idx - a_Values[]
1249  }
1250 
1251 protected:
1254 };
1255 
1256 
1257 
1258 
1259 
1261 template <int SizeX, int SizeZ = SizeX>
1263  public cIntGenWithNoise<SizeX, SizeZ>
1264 {
1266 
1267  static const int m_LowerSizeX = SizeX + 2;
1268  static const int m_LowerSizeZ = SizeZ + 2;
1269 
1270 public:
1271 
1272  using Underlying = std::shared_ptr<cIntGen<m_LowerSizeX, m_LowerSizeZ>>;
1273 
1274 
1275  cIntGenBiomeEdges(int a_Seed, Underlying a_Underlying):
1276  Super(a_Seed),
1277  m_Underlying(a_Underlying)
1278  {
1279  }
1280 
1281 
1282  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
1283  {
1284  // Generate the underlying biomes:
1285  typename Underlying::element_type::Values lowerValues;
1286  m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerValues);
1287 
1288  // Convert incompatible edges into neutral biomes:
1289  for (int z = 0; z < SizeZ; z++)
1290  {
1291  for (int x = 0; x < SizeX; x++)
1292  {
1293  int biome = lowerValues[x + 1 + (z + 1) * m_LowerSizeX];
1294  int above = lowerValues[x + 1 + z * m_LowerSizeX];
1295  int below = lowerValues[x + 1 + (z + 2) * m_LowerSizeX];
1296  int left = lowerValues[x + (z + 1) * m_LowerSizeX];
1297  int right = lowerValues[x + 2 + (z + 1) * m_LowerSizeX];
1298 
1299  switch (biome)
1300  {
1301  case biDesert:
1302  case biDesertM:
1303  case biDesertHills:
1304  {
1305  if (
1306  IsBiomeVeryCold(static_cast<EMCSBiome>(above)) ||
1307  IsBiomeVeryCold(static_cast<EMCSBiome>(below)) ||
1308  IsBiomeVeryCold(static_cast<EMCSBiome>(left)) ||
1309  IsBiomeVeryCold(static_cast<EMCSBiome>(right))
1310  )
1311  {
1312  biome = biPlains;
1313  }
1314  break;
1315  } // case biDesert
1316 
1317  case biMesaPlateau:
1318  case biMesaPlateauF:
1319  case biMesaPlateauFM:
1320  case biMesaPlateauM:
1321  {
1322  if (
1323  !isMesaCompatible(above) ||
1324  !isMesaCompatible(below) ||
1325  !isMesaCompatible(left) ||
1326  !isMesaCompatible(right)
1327  )
1328  {
1329  biome = biDesert;
1330  }
1331  break;
1332  } // Mesa biomes
1333 
1334  case biJungle:
1335  case biJungleM:
1336  {
1337  if (
1338  !isJungleCompatible(above) ||
1339  !isJungleCompatible(below) ||
1340  !isJungleCompatible(left) ||
1341  !isJungleCompatible(right)
1342  )
1343  {
1344  biome = (biome == biJungle) ? biJungleEdge : biJungleEdgeM;
1345  }
1346  break;
1347  } // Jungle biomes
1348 
1349  case biSwampland:
1350  case biSwamplandM:
1351  {
1352  if (
1353  IsBiomeNoDownfall(static_cast<EMCSBiome>(above)) ||
1354  IsBiomeNoDownfall(static_cast<EMCSBiome>(below)) ||
1355  IsBiomeNoDownfall(static_cast<EMCSBiome>(left)) ||
1356  IsBiomeNoDownfall(static_cast<EMCSBiome>(right))
1357  )
1358  {
1359  biome = biPlains;
1360  }
1361  break;
1362  } // Swampland biomes
1363  } // switch (biome)
1364 
1365  a_Values[x + z * SizeX] = biome;
1366  } // for x
1367  } // for z
1368  }
1369 
1370 
1371 protected:
1373 
1374 
1375  bool isMesaCompatible(int a_Biome)
1376  {
1377  switch (a_Biome)
1378  {
1379  case biDesert:
1380  case biMesa:
1381  case biMesaBryce:
1382  case biMesaPlateau:
1383  case biMesaPlateauF:
1384  case biMesaPlateauFM:
1385  case biMesaPlateauM:
1386  case biOcean:
1387  case biDeepOcean:
1388  {
1389  return true;
1390  }
1391  default:
1392  {
1393  return false;
1394  }
1395  }
1396  }
1397 
1398 
1399  bool isJungleCompatible(int a_Biome)
1400  {
1401  switch (a_Biome)
1402  {
1403  case biJungle:
1404  case biJungleM:
1405  case biJungleEdge:
1406  case biJungleEdgeM:
1407  case biJungleHills:
1408  {
1409  return true;
1410  }
1411  default:
1412  {
1413  return false;
1414  }
1415  }
1416  }
1417 };
1418 
1419 
1420 
1421 
1422 
1425 template <int SizeX, int SizeZ = SizeX>
1427  public cIntGenWithNoise<SizeX, SizeZ>
1428 {
1430 
1431 public:
1432 
1433  using Underlying = std::shared_ptr<cIntGen<SizeX, SizeZ>>;
1434 
1435 
1436  cIntGenMBiomes(int a_Seed, Underlying a_Alteration, Underlying a_Underlying):
1437  Super(a_Seed),
1438  m_Underlying(a_Underlying),
1439  m_Alteration(a_Alteration)
1440  {
1441  }
1442 
1443 
1444  virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values & a_Values) override
1445  {
1446  // Generate the underlying biomes and the alterations:
1447  m_Underlying->GetInts(a_MinX, a_MinZ, a_Values);
1448  typename Super::Values alterations;
1449  m_Alteration->GetInts(a_MinX, a_MinZ, alterations);
1450 
1451  // Wherever alterations are nonzero, change into alternate biome, if available:
1452  for (int idx = 0; idx < SizeX * SizeZ; ++idx)
1453  {
1454  if (alterations[idx] == 0)
1455  {
1456  continue;
1457  }
1458 
1459  // Ice spikes biome was removed from here, because it was generated way too often
1460  switch (a_Values[idx])
1461  {
1462  case biPlains: a_Values[idx] = biSunflowerPlains; break;
1463  case biDesert: a_Values[idx] = biDesertM; break;
1464  case biExtremeHills: a_Values[idx] = biExtremeHillsM; break;
1465  case biForest: a_Values[idx] = biFlowerForest; break;
1466  case biTaiga: a_Values[idx] = biTaigaM; break;
1467  case biSwampland: a_Values[idx] = biSwamplandM; break;
1468  case biJungle: a_Values[idx] = biJungleM; break;
1469  case biJungleEdge: a_Values[idx] = biJungleEdgeM; break;
1470  case biBirchForest: a_Values[idx] = biBirchForestM; break;
1471  case biBirchForestHills: a_Values[idx] = biBirchForestHillsM; break;
1472  case biRoofedForest: a_Values[idx] = biRoofedForestM; break;
1473  case biColdTaiga: a_Values[idx] = biColdTaigaM; break;
1474  case biMegaSpruceTaiga: a_Values[idx] = biMegaSpruceTaiga; break;
1475  case biMegaSpruceTaigaHills: a_Values[idx] = biMegaSpruceTaigaHills; break;
1476  case biExtremeHillsPlus: a_Values[idx] = biExtremeHillsPlusM; break;
1477  case biSavanna: a_Values[idx] = biSavannaM; break;
1478  case biSavannaPlateau: a_Values[idx] = biSavannaPlateauM; break;
1479  case biMesa: a_Values[idx] = biMesaBryce; break;
1480  case biMesaPlateauF: a_Values[idx] = biMesaPlateauFM; break;
1481  case biMesaPlateau: a_Values[idx] = biMesaBryce; break;
1482  }
1483  } // for idx - a_Values[] / alterations[]
1484  }
1485 
1486 protected:
1489 };
cIntGenRareBiomeGroups::m_Chance
int m_Chance
Chance, in permille, of changing each pixel into the rare biome group.
Definition: IntGen.h:1180
cIntGenSmooth::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:353
cIntGenChoice::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:193
cIntGenFactory::construct_impl
std::shared_ptr< Gen > construct_impl(LhsGen &&a_Lhs, sSeq< S... >)
Definition: IntGen.h:115
biBirchForest
@ biBirchForest
Definition: BiomeDef.h:54
cIntGenReplaceRandomly::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:815
BiomeDef.h
biPlains
@ biPlains
Definition: BiomeDef.h:23
biBirchForestM
@ biBirchForestM
Definition: BiomeDef.h:86
cNoise
Definition: Noise.h:19
cIntGenSetRandomly::cIntGenSetRandomly
cIntGenSetRandomly(int a_Seed, int a_Chance, int a_ToValue, Underlying a_Underlying)
Definition: IntGen.h:1096
biSavannaM
@ biSavannaM
Definition: BiomeDef.h:93
cIntGenSmooth::m_LowerSizeX
static const int m_LowerSizeX
Definition: IntGen.h:338
biFrozenRiver
@ biFrozenRiver
Definition: BiomeDef.h:35
cIntGen
Interface that all the generator classes provide.
Definition: IntGen.h:54
cIntGenZoom::m_UnderlyingGen
Underlying m_UnderlyingGen
Definition: IntGen.h:323
cIntGenAddToOcean::cIntGenAddToOcean
cIntGenAddToOcean(int a_Seed, int a_Chance, int a_ToValue, Underlying a_Underlying)
Definition: IntGen.h:1004
biMesaPlateau
@ biMesaPlateau
Definition: BiomeDef.h:66
operator|
std::shared_ptr< RhsGen > operator|(std::shared_ptr< T > a_Lhs, cIntGenFactory< RhsGen, Args... > a_Rhs)
Definition: IntGen.h:123
cIntGenBiomeGroupEdges::isDesertCompatible
bool isDesertCompatible(int a_BiomeGroup)
Definition: IntGen.h:641
cIntGenLandOcean
Decides between the ocean and landmass biomes.
Definition: IntGen.h:214
cIntGenWithNoise::cIntGenWithNoise
cIntGenWithNoise(int a_Seed)
Definition: IntGen.h:145
biMesa
@ biMesa
Definition: BiomeDef.h:64
biTaigaM
@ biTaigaM
Definition: BiomeDef.h:81
bgOcean
const int bgOcean
Constants representing the biome group designators.
Definition: IntGen.h:40
cIntGenReplaceRandomly::m_To
int m_To
The destination value to which to replace.
Definition: IntGen.h:845
cIntGenFactory
Definition: IntGen.h:92
cIntGenFactory::Generator
Gen Generator
Definition: IntGen.h:97
cIntGenZoom::m_LowerSizeX
static const int m_LowerSizeX
Definition: IntGen.h:266
IsBiomeNoDownfall
bool IsBiomeNoDownfall(EMCSBiome a_Biome)
Returns true if the biome has no downfall - deserts and savannas.
Definition: BiomeDef.cpp:142
cIntGenAlternateBiomes::m_Alterations
Underlying m_Alterations
Definition: IntGen.h:1252
biRoofedForestM
@ biRoofedForestM
Definition: BiomeDef.h:88
biMesaPlateauF
@ biMesaPlateauF
Definition: BiomeDef.h:65
cIntGenBiomes::cBiomesInGroups::Count
const int Count
Definition: IntGen.h:780
cIntGenMixRivers::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:879
cIntGenAddToOcean
Turns some of the oceans into the specified biome.
Definition: IntGen.h:991
cIntGenAddToOcean::m_Underlying
Underlying m_Underlying
Definition: IntGen.h:1077
cIntGenMBiomes::m_Underlying
Underlying m_Underlying
Definition: IntGen.h:1487
cIntGenAddToOcean::UnderlyingSizeX
static const int UnderlyingSizeX
Definition: IntGen.h:996
biMegaTaiga
@ biMegaTaiga
Definition: BiomeDef.h:59
cIntGenSmooth::m_LowerSizeZ
static const int m_LowerSizeZ
Definition: IntGen.h:339
biSavanna
@ biSavanna
Definition: BiomeDef.h:62
cIntGenFactory::construct
std::shared_ptr< Gen > construct(LhsGen &&a_Lhs)
Definition: IntGen.h:105
cIntGenBeaches::Underlying
std::shared_ptr< cIntGen< m_UnderlyingSizeX, m_UnderlyingSizeZ > > Underlying
Definition: IntGen.h:421
sGens
Definition: IntGen.h:80
biForestHills
@ biForestHills
Definition: BiomeDef.h:43
cIntGenAlternateBiomes::cIntGenAlternateBiomes
cIntGenAlternateBiomes(int a_Seed, Underlying a_Alterations, Underlying a_BaseBiomes)
Definition: IntGen.h:1203
biNether
@ biNether
Definition: BiomeDef.h:31
biStoneBeach
@ biStoneBeach
Definition: BiomeDef.h:52
cIntGenAlternateBiomes::Underlying
std::shared_ptr< cIntGen< SizeX, SizeZ > > Underlying
Definition: IntGen.h:1200
cIntGenChoice
Generates a 2D array of random integers in the specified range [0 .
Definition: IntGen.h:180
cIntGenRareBiomeGroups::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:1158
cIntGenSetRandomly::Underlying
std::shared_ptr< cIntGen< SizeX, SizeZ > > Underlying
Definition: IntGen.h:1093
cIntGenBiomes
Turns biome group indices into real biomes.
Definition: IntGen.h:667
biFlowerForest
@ biFlowerForest
Definition: BiomeDef.h:80
biSwampland
@ biSwampland
Definition: BiomeDef.h:28
biJungleEdge
@ biJungleEdge
Definition: BiomeDef.h:50
cIntGenMixRivers::m_Rivers
Underlying m_Rivers
Definition: IntGen.h:919
biIceMountains
@ biIceMountains
Definition: BiomeDef.h:38
biExtremeHillsM
@ biExtremeHillsM
Definition: BiomeDef.h:79
cIntGenSmooth::m_Underlying
Underlying m_Underlying
Definition: IntGen.h:402
cIntGenRareBiomeGroups::m_Underlying
Underlying m_Underlying
The underlying generator.
Definition: IntGen.h:1183
cIntGenBiomes::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:684
biBirchForestHillsM
@ biBirchForestHillsM
Definition: BiomeDef.h:87
cIntGenFactory::m_args
std::tuple< Args... > m_args
Definition: IntGen.h:112
cIntGenZoom::m_LowerSizeZ
static const int m_LowerSizeZ
Definition: IntGen.h:267
cIntGenLandOcean::m_Threshold
int m_Threshold
Definition: IntGen.h:248
biJungleEdgeM
@ biJungleEdgeM
Definition: BiomeDef.h:85
biJungleHills
@ biJungleHills
Definition: BiomeDef.h:47
cIntGenAddToOcean::m_Chance
int m_Chance
Chance, in permille, of changing the biome.
Definition: IntGen.h:1072
cIntGenWithNoise::ChooseRandomOne
int ChooseRandomOne(int a_RndX, int a_RndZ, int a_Val1, int a_Val2, int a_Val3, int a_Val4)
Chooses one of a_ValN, based on m_Noise and the coordinates for querying the noise.
Definition: IntGen.h:161
cIntGenBiomes::Underlying
std::shared_ptr< cIntGen< SizeX, SizeZ > > Underlying
Definition: IntGen.h:674
bgMountains
const int bgMountains
Definition: IntGen.h:43
cIntGenMBiomes::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:1444
cIntGenRiver::m_Underlying
Underlying m_Underlying
Definition: IntGen.h:981
cIntGenChoice::cIntGenChoice
cIntGenChoice(int a_Seed)
Definition: IntGen.h:187
cIntGenZoom::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:281
cIntGenBeaches::cIntGenBeaches
cIntGenBeaches(Underlying a_Underlying)
Definition: IntGen.h:424
cIntGenBiomeEdges::isJungleCompatible
bool isJungleCompatible(int a_Biome)
Definition: IntGen.h:1399
biForest
@ biForest
Definition: BiomeDef.h:26
biColdBeach
@ biColdBeach
Definition: BiomeDef.h:53
cIntGenBiomeEdges::Underlying
std::shared_ptr< cIntGen< m_LowerSizeX, m_LowerSizeZ > > Underlying
Definition: IntGen.h:1272
biIcePlains
@ biIcePlains
Definition: BiomeDef.h:36
cIntGenLandOcean::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:228
biMegaTaigaHills
@ biMegaTaigaHills
Definition: BiomeDef.h:60
cIntGenReplaceRandomly::m_From
int m_From
The original value to be replaced.
Definition: IntGen.h:842
std
Definition: FastNBT.h:131
MakeIntGen
cIntGenFactory< Gen, Args... > MakeIntGen(Args &&... a_Args)
Definition: IntGen.h:129
cIntGenRiver::UnderlyingSizeZ
static const int UnderlyingSizeZ
Definition: IntGen.h:936
cIntGenMBiomes::Underlying
std::shared_ptr< cIntGen< SizeX, SizeZ > > Underlying
Definition: IntGen.h:1433
cIntGenRareBiomeGroups
Adds a "rare" flag to random biome groups, based on the given chance.
Definition: IntGen.h:1140
cIntGenBiomeGroupEdges::m_UnderlyingSizeZ
static const int m_UnderlyingSizeZ
Definition: IntGen.h:571
biMushroomShore
@ biMushroomShore
Definition: BiomeDef.h:40
cIntGenAddIslands::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:533
IsBiomeOcean
bool IsBiomeOcean(int a_Biome)
Returns true if the biome is an ocean biome.
Definition: BiomeDef.h:135
cIntGenWithNoise::m_Noise
cNoise m_Noise
Definition: IntGen.h:151
ARRAYCOUNT
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
Definition: Globals.h:228
cIntGenZoom::cIntGenZoom
cIntGenZoom(int a_Seed, Underlying a_UnderlyingGen)
Definition: IntGen.h:274
cIntGenBiomeEdges::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:1282
cIntGenBiomes::cBiomesInGroups::Biomes
const int * Biomes
Definition: IntGen.h:781
biOcean
@ biOcean
Definition: BiomeDef.h:22
biRiver
@ biRiver
Definition: BiomeDef.h:29
cIntGenMixRivers::cIntGenMixRivers
cIntGenMixRivers(Underlying a_Biomes, Underlying a_Rivers)
Definition: IntGen.h:872
cIntGenAddToOcean::UnderlyingSizeZ
static const int UnderlyingSizeZ
Definition: IntGen.h:997
bgIce
const int bgIce
Definition: IntGen.h:44
cIntGenSetRandomly::m_Underlying
Underlying m_Underlying
Definition: IntGen.h:1131
cIntGenReplaceRandomly
Randomly replaces pixels of one value to another value, using the given chance.
Definition: IntGen.h:795
cIntGenSetRandomly::m_Chance
int m_Chance
Chance, in permille, of changing each pixel.
Definition: IntGen.h:1126
cIntGen::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, Values &a_Values)=0
Generates the array of templated size into a_Values, based on given min coords.
cNoise::IntNoise2DInt
int IntNoise2DInt(int a_X, int a_Y) const
Definition: Noise.h:243
cIntGenBiomeEdges
Adds an edge between two specifically incompatible biomes, such as mesa and forest.
Definition: IntGen.h:1262
biSavannaPlateauM
@ biSavannaPlateauM
Definition: BiomeDef.h:94
cIntGenFactory::cIntGenFactory
cIntGenFactory(Args &&... a_args)
Definition: IntGen.h:99
cIntGenBiomes::m_Underlying
Underlying m_Underlying
The underlying int generator.
Definition: IntGen.h:786
biJungleM
@ biJungleM
Definition: BiomeDef.h:84
cIntGenSetRandomly
Changes random pixels of the underlying data to the specified value.
Definition: IntGen.h:1086
cIntGenRiver::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:950
cIntGenRiver::UnderlyingSizeX
static const int UnderlyingSizeX
Definition: IntGen.h:935
cIntGenRareBiomeGroups::cIntGenRareBiomeGroups
cIntGenRareBiomeGroups(int a_Seed, int a_Chance, Underlying a_Underlying)
Definition: IntGen.h:1150
cIntGenAlternateBiomes::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:1211
cIntGenAddIslands::m_Chance
int m_Chance
Chance, in permille, of an island being generated in ocean.
Definition: IntGen.h:554
sSeq
Definition: IntGen.h:75
cIntGenLandOcean::cIntGenLandOcean
cIntGenLandOcean(int a_Seed, int a_Threshold)
Definition: IntGen.h:221
cIntGenRiver::Underlying
std::shared_ptr< cIntGen< UnderlyingSizeX, UnderlyingSizeZ > > Underlying
Definition: IntGen.h:940
cIntGenSetRandomly::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:1105
biBeach
@ biBeach
Definition: BiomeDef.h:41
biDesertHills
@ biDesertHills
Definition: BiomeDef.h:42
biMegaSpruceTaiga
@ biMegaSpruceTaiga
Definition: BiomeDef.h:90
EMCSBiome
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
Definition: BiomeDef.h:17
cIntGenZoom
Zooms the underlying value array to twice the size.
Definition: IntGen.h:259
cIntGenBiomeGroupEdges::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:584
biMesaPlateauFM
@ biMesaPlateauFM
Definition: BiomeDef.h:96
biMesaBryce
@ biMesaBryce
Definition: BiomeDef.h:95
cIntGenMixRivers::Underlying
std::shared_ptr< cIntGen< SizeX, SizeZ > > Underlying
Definition: IntGen.h:869
cIntGenRiver
Generates a river based on the underlying data.
Definition: IntGen.h:930
cIntGenMBiomes::m_Alteration
Underlying m_Alteration
Definition: IntGen.h:1488
cIntGenWithNoise::ChooseRandomOne
int ChooseRandomOne(int a_RndX, int a_RndZ, int a_Val1, int a_Val2)
Chooses one of a_Val1 or a_Val2, based on m_Noise and the coordinates for querying the noise.
Definition: IntGen.h:154
cIntGenSmooth::Underlying
std::shared_ptr< cIntGen< m_LowerSizeX, m_LowerSizeZ > > Underlying
Definition: IntGen.h:343
cIntGenBiomeEdges::m_LowerSizeZ
static const int m_LowerSizeZ
Definition: IntGen.h:1268
cIntGenBiomes::cBiomesInGroups
Definition: IntGen.h:778
cIntGenAlternateBiomes
Changes biomes in the parent data into an alternate versions (usually "hill" variants),...
Definition: IntGen.h:1193
cIntGenAddIslands::m_Underlying
Underlying m_Underlying
Definition: IntGen.h:556
cIntGenMBiomes::cIntGenMBiomes
cIntGenMBiomes(int a_Seed, Underlying a_Alteration, Underlying a_Underlying)
Definition: IntGen.h:1436
bgLandOceanMax
const int bgLandOceanMax
Definition: IntGen.h:45
bgfRare
const int bgfRare
Definition: IntGen.h:46
cIntGenAddToOcean::m_ToValue
int m_ToValue
The value to change the ocean into.
Definition: IntGen.h:1075
biMegaSpruceTaigaHills
@ biMegaSpruceTaigaHills
Definition: BiomeDef.h:91
biExtremeHillsPlus
@ biExtremeHillsPlus
Definition: BiomeDef.h:61
cIntGenBiomeGroupEdges::m_Underlying
Underlying m_Underlying
Definition: IntGen.h:638
cIntGenMixRivers::m_Biomes
Underlying m_Biomes
Definition: IntGen.h:918
cIntGenSmooth::cIntGenSmooth
cIntGenSmooth(int a_Seed, Underlying a_Underlying)
Definition: IntGen.h:346
cIntGenBiomeGroupEdges
A filter that adds an edge biome group between two biome groups that need an edge between them.
Definition: IntGen.h:565
cIntGenAlternateBiomes::m_BaseBiomes
Underlying m_BaseBiomes
Definition: IntGen.h:1253
cIntGenBeaches::m_UnderlyingSizeZ
static const int m_UnderlyingSizeZ
Definition: IntGen.h:417
cIntGen< SizeX, SizeX >::Values
int[SizeX *SizeZ] Values
Holds the array of values generated by this class (descendant).
Definition: IntGen.h:65
cIntGenBiomeGroupEdges::m_UnderlyingSizeX
static const int m_UnderlyingSizeX
Definition: IntGen.h:570
biExtremeHills
@ biExtremeHills
Definition: BiomeDef.h:25
biDesert
@ biDesert
Definition: BiomeDef.h:24
cIntGenMixRivers
Mixer that joins together finalized biomes and rivers.
Definition: IntGen.h:862
biTaigaHills
@ biTaigaHills
Definition: BiomeDef.h:44
cIntGenBiomeEdges::m_Underlying
Underlying m_Underlying
Definition: IntGen.h:1372
biRoofedForest
@ biRoofedForest
Definition: BiomeDef.h:56
cIntGenBiomeGroupEdges::cIntGenBiomeGroupEdges
cIntGenBiomeGroupEdges(Underlying a_Underlying)
Definition: IntGen.h:578
biColdTaigaM
@ biColdTaigaM
Definition: BiomeDef.h:89
biDeepOcean
@ biDeepOcean
Definition: BiomeDef.h:51
cIntGenZoom::Underlying
std::shared_ptr< cIntGen< m_LowerSizeX, m_LowerSizeZ > > Underlying
Definition: IntGen.h:271
biEnd
@ biEnd
Definition: BiomeDef.h:33
cIntGenMBiomes
Changes biomes in the parent data into their alternate versions ("M" variants), in such places that h...
Definition: IntGen.h:1426
biBirchForestHills
@ biBirchForestHills
Definition: BiomeDef.h:55
biColdTaiga
@ biColdTaiga
Definition: BiomeDef.h:57
cIntGenBeaches::m_UnderlyingSizeX
static const int m_UnderlyingSizeX
Definition: IntGen.h:416
biSavannaPlateau
@ biSavannaPlateau
Definition: BiomeDef.h:63
cIntGenReplaceRandomly::cIntGenReplaceRandomly
cIntGenReplaceRandomly(int a_From, int a_To, int a_Chance, int a_Seed, Underlying a_Underlying)
Definition: IntGen.h:805
cIntGenReplaceRandomly::m_Chance
int m_Chance
Chance, in permille, of replacing the value.
Definition: IntGen.h:848
biDesertM
@ biDesertM
Definition: BiomeDef.h:78
cIntGenBiomeGroupEdges::Underlying
std::shared_ptr< cIntGen< m_UnderlyingSizeX, m_UnderlyingSizeZ > > Underlying
Definition: IntGen.h:575
biMesaPlateauM
@ biMesaPlateauM
Definition: BiomeDef.h:97
biSunflowerPlains
@ biSunflowerPlains
Definition: BiomeDef.h:77
cIntGenAddIslands::Underlying
std::shared_ptr< cIntGen< SizeX, SizeZ > > Underlying
Definition: IntGen.h:522
cIntGenAddIslands
Generates the underlying numbers and then randomly changes some ocean group pixels into random land b...
Definition: IntGen.h:515
cIntGenRiver::cIntGenRiver
cIntGenRiver(int a_Seed, Underlying a_Underlying)
Definition: IntGen.h:943
cIntGenBeaches
Converts land biomes at the edge of an ocean into the respective beach biome.
Definition: IntGen.h:411
bgDesert
const int bgDesert
Definition: IntGen.h:41
biJungle
@ biJungle
Definition: BiomeDef.h:46
cIntGenBiomeEdges::m_LowerSizeX
static const int m_LowerSizeX
Definition: IntGen.h:1267
cIntGenBeaches::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:430
cIntGenReplaceRandomly::Underlying
std::shared_ptr< cIntGen< SizeX, SizeZ > > Underlying
Definition: IntGen.h:802
cIntGenRareBiomeGroups::Underlying
std::shared_ptr< cIntGen< SizeX, SizeZ > > Underlying
Definition: IntGen.h:1147
cIntGenReplaceRandomly::m_Underlying
Underlying m_Underlying
Definition: IntGen.h:850
cIntGenBiomeEdges::isMesaCompatible
bool isMesaCompatible(int a_Biome)
Definition: IntGen.h:1375
IsBiomeVeryCold
bool IsBiomeVeryCold(EMCSBiome a_Biome)
Returns true if the biome is very cold (has snow on ground everywhere, turns top water to ice,...
Definition: BiomeDef.cpp:169
biSwamplandM
@ biSwamplandM
Definition: BiomeDef.h:82
biTaiga
@ biTaiga
Definition: BiomeDef.h:27
biExtremeHillsPlusM
@ biExtremeHillsPlusM
Definition: BiomeDef.h:92
cIntGenBiomeEdges::cIntGenBiomeEdges
cIntGenBiomeEdges(int a_Seed, Underlying a_Underlying)
Definition: IntGen.h:1275
cIntGenWithNoise
Provides additional cNoise member and its helper functions.
Definition: IntGen.h:138
cIntGenAddIslands::cIntGenAddIslands
cIntGenAddIslands(int a_Seed, int a_Chance, Underlying a_Underlying)
Definition: IntGen.h:525
cIntGenSetRandomly::m_ToValue
int m_ToValue
The value to which to set the pixel.
Definition: IntGen.h:1129
cIntGenAddToOcean::Underlying
std::shared_ptr< cIntGen< UnderlyingSizeX, UnderlyingSizeZ > > Underlying
Definition: IntGen.h:1001
bgTemperate
const int bgTemperate
Definition: IntGen.h:42
cIntGenAddToOcean::GetInts
virtual void GetInts(int a_MinX, int a_MinZ, typename Super::Values &a_Values) override
Generates the array of templated size into a_Values, based on given min coords.
Definition: IntGen.h:1013
cIntGen::~cIntGen
virtual ~cIntGen()
Force a virtual destructor in all descendants.
Definition: IntGen.h:62
cIntGenBeaches::m_Underlying
Underlying m_Underlying
Definition: IntGen.h:505
cIntGenBiomes::cIntGenBiomes
cIntGenBiomes(int a_Seed, Underlying a_Underlying)
Definition: IntGen.h:677
cIntGenSmooth
Smoothes out some artifacts generated by the zooming - mostly single-pixel values.
Definition: IntGen.h:333