vault_place.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. #ifndef __VAULT_PLACE_H
  2. #define __VAULT_PLACE_H
  3. struct vault_packing_t {
  4. unsigned int x;
  5. unsigned int y;
  6. unsigned int w;
  7. unsigned int h;
  8. };
  9. namespace serialize {
  10. template <>
  11. struct reader<vault_packing_t> {
  12. void read(Source& s, vault_packing_t& t) {
  13. serialize::read(s, t.x);
  14. serialize::read(s, t.y);
  15. serialize::read(s, t.w);
  16. serialize::read(s, t.h);
  17. }
  18. };
  19. template <>
  20. struct writer<vault_packing_t> {
  21. void write(Sink& s, const vault_packing_t& t) {
  22. serialize::write(s, t.x);
  23. serialize::write(s, t.y);
  24. serialize::write(s, t.w);
  25. serialize::write(s, t.h);
  26. }
  27. };
  28. }
  29. /* (i is inner rectangle, o is outer rectangle)
  30. +-----------------------------------+
  31. | | |
  32. | | 1 |
  33. | | |
  34. | +--------------------+-------|
  35. | 4 |....................| |
  36. | |....................| |
  37. | |....................| |
  38. | |....................| 2 |
  39. |------+--------------------+ |
  40. | | |
  41. | 3 | |
  42. +-----------------------------------+
  43. offx = i.x - o.x
  44. offy = i.y - o.y
  45. 1:
  46. i.x, o.y, o.w - offx, offy
  47. 2:
  48. i.x + i.w, i.y, o.w - offx - i.w, o.h - offy
  49. 3:
  50. o.x, i.y + i.h, offx + i.w, o.h - offy - i.h
  51. 4:
  52. o.y, o.y, offx, offy + i.h
  53. */
  54. inline bool packing_placement(GameState& state, unsigned int w, unsigned int h,
  55. std::vector<vault_packing_t>& packed, grid::pt& out) {
  56. if (packed.empty()) {
  57. packed.push_back(vault_packing_t{0, 0, state.grid.w, state.grid.h});
  58. }
  59. auto i = packed.begin();
  60. while (i != packed.end()) {
  61. const auto& vp = *i;
  62. if (vp.w < w || vp.h < h) {
  63. ++i;
  64. continue;
  65. }
  66. unsigned int offx = state.rng.range(0u, vp.w - w);
  67. unsigned int offy = state.rng.range(0u, vp.h - h);
  68. out.first = vp.x + offx;
  69. out.second = vp.y + offy;
  70. vault_packing_t tmp = vp;
  71. packed.erase(i);
  72. vault_packing_t s1{out.first, tmp.y, tmp.w - offx, offy};
  73. if (s1.w > 0 && s1.h > 0) packed.push_back(s1);
  74. vault_packing_t s2{out.first + w, out.second, tmp.w - offx - w, tmp.h - offy};
  75. if (s2.w > 0 && s2.h > 0) packed.push_back(s2);
  76. vault_packing_t s3{tmp.x, out.second + h, offx + w, tmp.h - offy - h};
  77. if (s3.w > 0 && s3.h > 0) packed.push_back(s3);
  78. vault_packing_t s4{tmp.x, tmp.y, offx, offy + h};
  79. if (s4.w > 0 && s4.h > 0) packed.push_back(s4);
  80. std::sort(packed.begin(), packed.end(),
  81. [](const vault_packing_t& a, const vault_packing_t& b) { return (a.w*a.h) > (b.w*b.h); });
  82. return true;
  83. }
  84. return false;
  85. }
  86. struct vault_state_t {
  87. std::vector<summons_t> summons;
  88. std::vector<itemplace_t> itemplace;
  89. std::set<grid::pt> affected;
  90. std::vector<vault_packing_t> packed;
  91. std::vector<grid::pt> player_positions;
  92. void affect(GameState& state, const grid::pt& xy) {
  93. for (const auto& v : state.neigh(xy)) {
  94. affected.insert(state.neigh.mk(v, xy));
  95. }
  96. affected.insert(xy);
  97. }
  98. };
  99. const Vault::brush& vault_get_brush(const Vault::brushes_t& brushes, unsigned char c) {
  100. auto bi = brushes.find(c);
  101. if (bi == brushes.end()) {
  102. throw std::runtime_error("Invalid brush char: '" + std::string(1, c) + "'");
  103. }
  104. return bi->second;
  105. }
  106. inline void vault_draw_point(unsigned int xi, unsigned int yi, const Vault::brush& b,
  107. GameState& state, vault_state_t& vaultstate, bool use_species_counts) {
  108. if (!b.is_blank) {
  109. if (b.is_walk) {
  110. state.grid.walkmap.insert(grid::pt(xi, yi));
  111. } else {
  112. state.grid.walkmap.erase(grid::pt(xi, yi));
  113. }
  114. if (b.is_water) {
  115. state.grid.watermap.insert(grid::pt(xi, yi));
  116. } else {
  117. state.grid.watermap.erase(grid::pt(xi, yi));
  118. }
  119. }
  120. if (!b.terrain.null()) {
  121. state.features.set(xi, yi, b.terrain, state.render);
  122. } else {
  123. state.features.unset(xi, yi, state.render);
  124. }
  125. switch (b.design.type) {
  126. case Vault::brush::design_t::type_t::NONE:
  127. break;
  128. case Vault::brush::design_t::type_t::SPECIFIC:
  129. vaultstate.itemplace.emplace_back(xi, yi, itemplace_t::type_t::SPECIFIC, b.design.tag, 0);
  130. break;
  131. case Vault::brush::design_t::type_t::LEVEL:
  132. vaultstate.itemplace.emplace_back(xi, yi, itemplace_t::type_t::LEVEL, tag_t(), b.design.level);
  133. break;
  134. case Vault::brush::design_t::type_t::LEVEL_ANY:
  135. vaultstate.itemplace.emplace_back(xi, yi, itemplace_t::type_t::LEVEL_ANY, tag_t(), b.design.level);
  136. break;
  137. }
  138. if (b.species.type != Vault::brush::species_t::type_t::NONE &&
  139. !state.grid.is_walk(xi, yi)) {
  140. throw std::runtime_error("Invalid vault monster placement");
  141. }
  142. switch (b.species.type) {
  143. case Vault::brush::species_t::type_t::NONE:
  144. break;
  145. case Vault::brush::species_t::type_t::SPECIFIC:
  146. vaultstate.summons.emplace_back(xi, yi, summons_t::type_t::SPECIFIC, b.species.tag,
  147. 0, (use_species_counts ? 1u : 0u), tag_t(), tag_t(), "");
  148. break;
  149. case Vault::brush::species_t::type_t::LEVEL:
  150. vaultstate.summons.emplace_back(xi, yi, summons_t::type_t::LEVEL, b.species.tag,
  151. b.species.level, (use_species_counts ? 1u : 0u), tag_t(), tag_t(), "");
  152. break;
  153. case Vault::brush::species_t::type_t::GENUS:
  154. vaultstate.summons.emplace_back(xi, yi, summons_t::type_t::GENUS, b.species.tag,
  155. b.species.level, (use_species_counts ? 1u : 0u), tag_t(), tag_t(), "");
  156. break;
  157. }
  158. }
  159. inline void vault_draw_cloud(GameState& state, vault_state_t& vaultstate,
  160. const grid::pt& xy, unsigned int ax, unsigned int ay,
  161. const Vault::brushes_t& brushes, const Vault::cloud_t& cloud,
  162. bool use_species_counts) {
  163. std::unordered_set<grid::pt> used;
  164. for (size_t i = 0; i < cloud.n; ++i) {
  165. grid::pt cxy;
  166. size_t j;
  167. for (j = 0; j < 10; ++j) {
  168. double xx = state.rng.gauss(cloud.distrib.mean, cloud.distrib.deviation);
  169. double yy = state.rng.gauss(cloud.distrib.mean, cloud.distrib.deviation);
  170. int xi = (int)(xy.first + ax) + xx;
  171. int yi = (int)(xy.second + ay) + yy;
  172. if (xi < 0 || yi < 0 || xi >= (int)state.grid.w || yi >= (int)state.grid.h)
  173. continue;
  174. cxy = grid::pt(xi, yi);
  175. if (used.count(cxy) != 0)
  176. continue;
  177. used.insert(cxy);
  178. break;
  179. }
  180. if (j >= 10)
  181. continue;
  182. std::discrete_distribution<size_t> d(cloud.chances.begin(), cloud.chances.end());
  183. unsigned char c = cloud.brushes[d(state.rng.gen)];
  184. const Vault::brush& b = vault_get_brush(brushes, c);
  185. vault_draw_point(cxy.first, cxy.second, b, state, vaultstate, use_species_counts);
  186. vaultstate.affect(state, cxy);
  187. }
  188. }
  189. inline void vault_draw_blob(GameState& state, vault_state_t& vaultstate, grid::pt xy,
  190. const Vault::brushes_t& brushes, const Vault::blob_t& blob,
  191. bool use_species_counts) {
  192. auto check_memfn = std::mem_fn(&grid::Map::is_floor);
  193. switch (blob.placement) {
  194. case Vault::placement_t::water:
  195. check_memfn = std::mem_fn(&grid::Map::is_lake);
  196. break;
  197. case Vault::placement_t::corner:
  198. check_memfn = std::mem_fn(&grid::Map::is_corner);
  199. break;
  200. case Vault::placement_t::shoreline:
  201. check_memfn = std::mem_fn(&grid::Map::is_shore);
  202. break;
  203. case Vault::placement_t::lowlands:
  204. check_memfn = std::mem_fn(&grid::Map::is_lowlands);
  205. break;
  206. default:
  207. break;
  208. }
  209. std::unordered_set<grid::pt> used;
  210. for (size_t i = 0; i < blob.n; ++i) {
  211. std::vector<grid::pt> possibles;
  212. for (const auto& v : state.neigh(xy)) {
  213. grid::pt nxy = state.neigh.mk(v, xy);
  214. if (check_memfn(state.grid, nxy.first, nxy.second) && used.count(nxy) == 0) {
  215. possibles.push_back(nxy);
  216. }
  217. }
  218. if (possibles.empty())
  219. break;
  220. xy = possibles[state.rng.n(possibles.size())];
  221. used.insert(xy);
  222. const Vault::brush& b = vault_get_brush(brushes, blob.brush);
  223. vault_draw_point(xy.first, xy.second, b, state, vaultstate, use_species_counts);
  224. vaultstate.affect(state, xy);
  225. }
  226. }
  227. inline void vault_draw_river(GameState& state, vault_state_t& vaultstate, double x, double y,
  228. const Vault::brushes_t& brushes, const Vault::river_t& river,
  229. double angle, double width, size_t length,
  230. bool use_species_counts) {
  231. const Vault::brush& b = vault_get_brush(brushes, river.brush);
  232. std::unordered_set<grid::pt> drawn;
  233. auto do_draw = [&](int px, int py) {
  234. while (px < 0) px += state.grid.w;
  235. while (py < 0) py += state.grid.h;
  236. px = px % state.grid.w;
  237. py = py % state.grid.h;
  238. grid::pt pxy(px, py);
  239. if (drawn.count(pxy) == 0) {
  240. vault_draw_point(px, py, b, state, vaultstate, use_species_counts);
  241. drawn.insert(pxy);
  242. }
  243. };
  244. for (size_t i = 0; i < length; ++i) {
  245. double ax = ::cos(angle);
  246. double ay = ::sin(angle);
  247. double o1x = ay;
  248. double o1y = -ax;
  249. double o2x = -ay;
  250. double o2y = ax;
  251. int fromx = ::round(x + o1x * width);
  252. int fromy = ::round(y + o1y * width);
  253. int tox = ::round(x + o2x * width);
  254. int toy = ::round(y + o2y * width);
  255. bresenham::Line line(fromx, fromy, tox, toy);
  256. int px;
  257. int py;
  258. while (line.step(px, py)) {
  259. do_draw(px, py);
  260. }
  261. int tmpx = ::round(x);
  262. int tmpy = ::round(y);
  263. do_draw(tmpx, tmpy);
  264. x += ax * 0.5;
  265. y += ay * 0.5;
  266. angle += state.rng.gauss(river.angle.mean, river.angle.deviation);
  267. width += state.rng.gauss(river.width.mean, river.width.deviation);
  268. if (width < 1)
  269. width = 1;
  270. if (river.splitchance > 0 && state.rng.n(river.splitchance) == 0) {
  271. vault_draw_river(state, vaultstate, x, y, brushes, river, angle, width, length-i, use_species_counts);
  272. }
  273. }
  274. for (const grid::pt& xy : drawn) {
  275. vaultstate.affect(state, xy);
  276. }
  277. }
  278. inline void vault_draw_tunnel(GameState& state, vault_state_t& vaultstate, grid::pt xy, grid::pt xy2,
  279. const Vault::brushes_t& brushes, const Vault::tunnel_t& tunnel,
  280. bool transpose, bool use_species_counts) {
  281. unsigned int xo = std::min(xy.first, xy2.first);
  282. unsigned int xd = std::max(xy.first, xy2.first);
  283. unsigned int yo = std::min(xy.second, xy2.second);
  284. unsigned int yd = std::max(xy.second, xy2.second);
  285. auto draw_line = [&](bool orient, bool neg,
  286. unsigned int _xo, unsigned int _xd, unsigned int _yv,
  287. std::list<grid::pt>& prevpt, bool& ground, int& tstate) {
  288. const Vault::brush& brush_p = vault_get_brush(brushes, tunnel.plain_brush);
  289. const Vault::brush& brush_b = vault_get_brush(brushes, tunnel.b_brush);
  290. const Vault::brush& brush_a = vault_get_brush(brushes, tunnel.a_brush);
  291. for (unsigned int _xi = _xo; _xi <= _xd; ++_xi) {
  292. unsigned int xi = (neg ? _xo + _xd - _xi : _xi);
  293. bool next_ground = state.grid.is_walk(xi, yo);
  294. auto b = std::cref(brush_p);
  295. if (tstate == 1) {
  296. b = std::cref(brush_b);
  297. --tstate;
  298. } else if (ground != next_ground) {
  299. auto ptli = prevpt.rbegin();
  300. if (!ground) {
  301. if (ptli != prevpt.rend()) {
  302. vault_draw_point(ptli->first, ptli->second, brush_a, state, vaultstate, use_species_counts);
  303. ++ptli;
  304. }
  305. if (ptli != prevpt.rend()) {
  306. vault_draw_point(ptli->first, ptli->second, brush_b, state, vaultstate, use_species_counts);
  307. }
  308. b = std::cref(brush_b);
  309. } else {
  310. if (ptli != prevpt.rend()) {
  311. vault_draw_point(ptli->first, ptli->second, brush_b, state, vaultstate, use_species_counts);
  312. }
  313. b = std::cref(brush_a);
  314. tstate = 1;
  315. }
  316. }
  317. ground = next_ground;
  318. grid::pt tmp(orient ? xi : _yv, orient ? _yv : xi);
  319. vault_draw_point(tmp.first, tmp.second, b, state, vaultstate, use_species_counts);
  320. vaultstate.affect(state, tmp);
  321. prevpt.push_back(tmp);
  322. if (prevpt.size() > 2)
  323. prevpt.pop_front();
  324. }
  325. };
  326. if (xy == grid::pt(xo, yo) || xy2 == grid::pt(xo, yo)) {
  327. std::list<grid::pt> tmp;
  328. bool ground = state.grid.is_walk(xo, yo);
  329. int tstate = 0;
  330. if (transpose) {
  331. draw_line(false, false, yo, yd, xo, tmp, ground, tstate);
  332. draw_line(true, false, xo+1, xd, yd, tmp, ground, tstate);
  333. } else {
  334. draw_line(true, false, xo, xd, yo, tmp, ground, tstate);
  335. draw_line(false, false, yo+1, yd, xd, tmp, ground, tstate);
  336. }
  337. } else {
  338. std::list<grid::pt> tmp;
  339. bool ground = state.grid.is_walk(xo, yd);
  340. int tstate = 0;
  341. if (transpose) {
  342. draw_line(false, true, yo, yd, xo, tmp, ground, tstate);
  343. draw_line(true, false, xo+1, xd, yo, tmp, ground, tstate);
  344. } else {
  345. draw_line(true, false, xo, xd, yd, tmp, ground, tstate);
  346. draw_line(false, true, yo, yd-1, xd, tmp, ground, tstate);
  347. }
  348. }
  349. }
  350. template <typename T>
  351. inline bool get_vault_placement(GameState& state, T& ptsource, vault_state_t& vaultstate,
  352. unsigned int w, unsigned int h, unsigned int ax, unsigned int ay,
  353. Vault::placement_t placement, grid::pt& xy) {
  354. if (placement == Vault::placement_t::packing) {
  355. return packing_placement(state, w, h, vaultstate.packed, xy);
  356. } else {
  357. for (unsigned int i = 0; i < 10; ++i) {
  358. switch (placement) {
  359. case Vault::placement_t::floor:
  360. if (!ptsource.one_of_floor(state.rng, xy)) return false;
  361. break;
  362. case Vault::placement_t::water:
  363. if (!ptsource.one_of_lake(state.rng, xy)) return false;
  364. break;
  365. case Vault::placement_t::corner:
  366. if (!ptsource.one_of_corner(state.rng, xy)) return false;
  367. break;
  368. case Vault::placement_t::shoreline:
  369. if (!ptsource.one_of_shore(state.rng, xy)) return false;
  370. break;
  371. case Vault::placement_t::lowlands:
  372. if (!ptsource.one_of_lowlands(state.rng, xy)) return false;
  373. break;
  374. default:
  375. return false;
  376. }
  377. if ((int)xy.first - (int)ax < 0 ||
  378. (int)xy.second - (int)ay < 0)
  379. continue;
  380. xy.first -= ax;
  381. xy.second -= ay;
  382. if (xy.first >= state.grid.w - w ||
  383. xy.second >= state.grid.h - h)
  384. continue;
  385. if (i >= 9) {
  386. return false;
  387. }
  388. break;
  389. }
  390. }
  391. return true;
  392. }
  393. template <typename T>
  394. inline void generate_vault(const Vault& vault, GameState& state, T& ptsource, vault_state_t& vaultstate) {
  395. grid::pt xy;
  396. unsigned int _w = (vault.inherit.null() ? vault.w : vaults().get(vault.inherit).w);
  397. unsigned int _h = (vault.inherit.null() ? vault.h : vaults().get(vault.inherit).h);
  398. unsigned int w = (vault.transpose ? _h : _w);
  399. unsigned int h = (vault.transpose ? _w : _h);
  400. unsigned int ax = (vault.transpose ? vault.ay : vault.ax);
  401. unsigned int ay = (vault.transpose ? vault.ax : vault.ay);
  402. int _px = (vault.transpose ? vault.py : vault.px);
  403. int _py = (vault.transpose ? vault.px : vault.py);
  404. const auto& brushes = (vault.inherit.null() ?
  405. vault.brushes :
  406. vaults().get(vault.inherit).brushes);
  407. const auto& pic = (vault.inherit.null() ?
  408. vault.pic :
  409. vaults().get(vault.inherit).pic);
  410. const auto& cloud = (vault.inherit.null() ?
  411. vault.cloud :
  412. vaults().get(vault.inherit).cloud);
  413. const auto& blob = (vault.inherit.null() ?
  414. vault.blob :
  415. vaults().get(vault.inherit).blob);
  416. const auto& river = (vault.inherit.null() ?
  417. vault.river :
  418. vaults().get(vault.inherit).river);
  419. const auto& room = (vault.inherit.null() ?
  420. vault.room :
  421. vaults().get(vault.inherit).room);
  422. const auto& tunnel = (vault.inherit.null() ?
  423. vault.tunnel :
  424. vaults().get(vault.inherit).tunnel);
  425. unsigned int roomw = state.rng.range(room.w1, room.w2);
  426. unsigned int roomh = state.rng.range(room.h1, room.h2);
  427. unsigned int picw = w;
  428. unsigned int pich = h;
  429. w = std::max(picw, vault.transpose ? roomh : roomw);
  430. h = std::max(pich, vault.transpose ? roomw : roomh);
  431. if (w > picw)
  432. ax += (w - picw) / 2;
  433. if (h > pich)
  434. ay += (h - pich) / 2;
  435. if (w > 0 && h > 0 && (ax >= w || ay >= h)) {
  436. std::cerr << "Sanity error in vault anchor! " << ax << "," << ay << " "
  437. << w << "," << h << " : " << vault.tag.v << " " << vault.inherit.v << std::endl;
  438. return;
  439. }
  440. if (!get_vault_placement(state, ptsource, vaultstate, w, h, ax, ay, vault.placement, xy))
  441. return;
  442. //
  443. if (_px >= 0 && _py >= 0) {
  444. vaultstate.player_positions.push_back(grid::pt(xy.first + _px, xy.second +_py));
  445. }
  446. for (int i = -1; i <= (int)w; ++i) {
  447. vaultstate.affected.insert(grid::pt(xy.first + i, xy.second - 1));
  448. vaultstate.affected.insert(grid::pt(xy.first + i, xy.second + h));
  449. }
  450. for (int i = 0; i < (int)h; ++i) {
  451. vaultstate.affected.insert(grid::pt(xy.first - 1, xy.second + i));
  452. vaultstate.affected.insert(grid::pt(xy.first + w, xy.second + i));
  453. }
  454. /*** Pre-drawn vault (possibly in a room) ***/
  455. if (w > picw || h > pich) {
  456. for (unsigned int y = 0; y < h; ++y) {
  457. for (unsigned int x = 0; x < w; ++x) {
  458. const Vault::brush& b = vault_get_brush(brushes, room.brush);
  459. unsigned int xi = xy.first + x;
  460. unsigned int yi = xy.second + y;
  461. vaultstate.affected.insert(grid::pt(xi, yi));
  462. vault_draw_point(xi, yi, b, state, vaultstate, vault.use_species_counts);
  463. }
  464. }
  465. }
  466. if (pic.size() > 0) {
  467. unsigned int offx = (w - picw) / 2;
  468. unsigned int offy = (h - pich) / 2;
  469. for (unsigned int y = 0; y < _h; ++y) {
  470. for (unsigned int x = 0; x < _w; ++x) {
  471. const std::string& line = pic[y];
  472. if (x >= line.size())
  473. continue;
  474. unsigned int c = line[x];
  475. const Vault::brush& b = vault_get_brush(brushes, c);
  476. unsigned int xi = xy.first + offx + (vault.transpose ? y : x);
  477. unsigned int yi = xy.second + offy + (vault.transpose ? x : y);
  478. vaultstate.affected.insert(grid::pt(xi, yi));
  479. vault_draw_point(xi, yi, b, state, vaultstate, vault.use_species_counts);
  480. }
  481. }
  482. }
  483. /*** Cloud ***/
  484. if (cloud.n > 0) {
  485. vault_draw_cloud(state, vaultstate, xy, ax, ay, brushes, cloud, vault.use_species_counts);
  486. }
  487. /*** Blobs ***/
  488. if (blob.n > 0) {
  489. vault_draw_blob(state, vaultstate, xy, brushes, blob, vault.use_species_counts);
  490. }
  491. /*** Rivers ***/
  492. if (river.n > 0) {
  493. vault_draw_river(state, vaultstate, xy.first, xy.second, brushes, river,
  494. state.rng.uniform(0.0, 2*3.141592653589793), 1.0, river.n, vault.use_species_counts);
  495. }
  496. if (tunnel.enabled) {
  497. grid::pt xy2;
  498. if (!get_vault_placement(state, ptsource, vaultstate, w, h, ax, ay, vault.placement, xy2))
  499. return;
  500. vault_draw_tunnel(state, vaultstate, xy, xy2, brushes, tunnel, vault.transpose, vault.use_species_counts);
  501. }
  502. }
  503. inline void vault_generation_cleanup(GameState& state, std::set<grid::pt>& affected) {
  504. state.grid._set_maps_of(state.neigh, affected);
  505. affected.clear();
  506. }
  507. #endif