levelskins.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #ifndef __LEVELSKINS_H
  2. #define __LEVELSKINS_H
  3. struct Levelskin {
  4. skins deep_water;
  5. skins shallow_water;
  6. skins wall;
  7. skins water_wall;
  8. skins floor1;
  9. skins floor2;
  10. skins floor3;
  11. skins floor4;
  12. skins floor5;
  13. skins floor6;
  14. skins floor7;
  15. skins floor8;
  16. unsigned int lightradius;
  17. unsigned int lightradius_max;
  18. tag_t ailment;
  19. int level;
  20. bool exclusive_monsters;
  21. bool exclusive_items;
  22. bool no_phase_level;
  23. int species_level;
  24. int designs_level;
  25. int vaults_level;
  26. unsigned int number_fixed_vaults;
  27. unsigned int number_semirandom_vaults;
  28. unsigned int number_random_vaults;
  29. mean_deviation_t number_monsters;
  30. mean_deviation_t number_items;
  31. mean_deviation_t number_features;
  32. std::string name;
  33. bool has_treasure;
  34. double treasure_level;
  35. struct mapgen_params_t {
  36. double flow_epsilon;
  37. unsigned int flow_n_freq;
  38. double flow_volume;
  39. double flow_erosion;
  40. unsigned int flow_renorm_freq;
  41. double flow_renorm_scale;
  42. double walk_threshold;
  43. unsigned int lowlands_threshold;
  44. double water_quantile_mean;
  45. double water_quantile_dev;
  46. unsigned int flatten_walk_ng;
  47. unsigned int flatten_water_ng;
  48. unsigned int unflow_ng;
  49. double karma_mean;
  50. double karma_dev;
  51. int nflatten_walk;
  52. int nflatten_water;
  53. int nunflow;
  54. mapgen_params_t() :
  55. flow_epsilon(1e-5),
  56. flow_n_freq(20),
  57. flow_volume(50.0),
  58. flow_erosion(1),
  59. flow_renorm_freq(500),
  60. flow_renorm_scale(15),
  61. walk_threshold(0),
  62. lowlands_threshold(1),
  63. water_quantile_mean(5.0),
  64. water_quantile_dev(1.0),
  65. flatten_walk_ng(0x1FF & ~0x1F), // Bitmask of 5,6,7,8
  66. flatten_water_ng(0x1FF & ~0x7), // Bitmask of 3,4,5,6,7,8
  67. unflow_ng(0x1F), // Bitmask of 0,1,2,3,4
  68. karma_mean(0.0),
  69. karma_dev(0.2),
  70. nflatten_walk(-1),
  71. nflatten_water(-1),
  72. nunflow(-1)
  73. {}
  74. };
  75. mapgen_params_t genparams;
  76. Levelskin() : lightradius(8), lightradius_max(8), level(0), exclusive_monsters(false),
  77. exclusive_items(false), no_phase_level(false),
  78. species_level(-1), designs_level(-1), vaults_level(-1),
  79. number_fixed_vaults(100), number_semirandom_vaults(0), number_random_vaults(0),
  80. number_monsters(250.0, 20.0),
  81. number_items(300.0, 50.0),
  82. number_features(160.0, 30.0),
  83. has_treasure(false), treasure_level(0)
  84. {}
  85. unsigned int get_species_level(int worldz) const {
  86. return (species_level >= 0 ? species_level : std::max(worldz, 0));
  87. }
  88. unsigned int get_designs_level(int worldz) const {
  89. return (designs_level >= 0 ? designs_level : std::max(worldz, 0));
  90. }
  91. unsigned int get_vaults_level(int worldz) const {
  92. return (vaults_level >= 0 ? vaults_level : std::max(worldz, 0));
  93. }
  94. };
  95. struct Levelskins {
  96. std::map<int,Levelskin> skins;
  97. const Levelskin& get(int level) const {
  98. if (skins.size() == 0)
  99. throw std::runtime_error("sanity error: no levelskins defined");
  100. auto i = skins.upper_bound(level);
  101. if (i == skins.begin()) {
  102. return i->second;
  103. } else {
  104. --i;
  105. return i->second;
  106. }
  107. }
  108. void set(const Levelskin& skin) {
  109. skins[skin.level] = skin;
  110. }
  111. };
  112. inline Levelskins& __levelskins__() {
  113. static Levelskins ret;
  114. return ret;
  115. }
  116. inline const Levelskins& levelskins() {
  117. return __levelskins__();
  118. }
  119. inline void init_levelskin(const Levelskin& skin) {
  120. __levelskins__().set(skin);
  121. }
  122. #endif