The Battle for Wesnoth  1.15.12+dev
default_map_generator_job.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 class config;
18 class game_config_view;
19 
21 #include "map/location.hpp"
23 #include "terrain/translation.hpp"
24 #include "utils/name_generator.hpp"
25 
26 #include <random>
27 #include <cstdint>
28 #include <map>
29 #include <memory>
30 
32 {
33 public:
35  default_map_generator_job(uint32_t seed);
36 
37  /** Generate the map. */
38  std::string default_generate_map(generator_data data, std::map<map_location,std::string>* labels, const config& cfg);
39 
40  typedef std::vector<std::vector<int>> height_map;
42 
43 
44  height_map generate_height_map(size_t width, size_t height,
45  size_t iterations, size_t hill_size,
46  size_t island_size, size_t island_off_center);
47 
48  height_map generate_height_map(size_t width, size_t height,
49  size_t iterations, size_t hill_size,
50  size_t island_size, size_t center_x, size_t center_y);
51 
52 private:
53 
54  bool generate_river_internal(const height_map& heights,
55  terrain_map& terrain, int x, int y, std::vector<map_location>& river,
56  std::set<map_location>& seen_locations, int river_uphill);
57 
58  std::vector<map_location> generate_river(const height_map& heights, terrain_map& terrain, int x, int y, int river_uphill);
59 
60  bool generate_lake(t_translation::ter_map& terrain, int x, int y, int lake_fall_off, std::set<map_location>& locs_touched);
61  map_location random_point_at_side(std::size_t width, std::size_t height);
62 
63  std::mt19937 rng_;
65 
66 };
map_location random_point_at_side(std::size_t width, std::size_t height)
Returns a random tile at one of the borders of a map that is of the given dimensions.
bool generate_river_internal(const height_map &heights, terrain_map &terrain, int x, int y, std::vector< map_location > &river, std::set< map_location > &seen_locations, int river_uphill)
River generation.
Encapsulates the map of the game.
Definition: location.hpp:37
std::string default_generate_map(generator_data data, std::map< map_location, std::string > *labels, const config &cfg)
Generate the map.
const game_config_view & game_config_
height_map generate_height_map(size_t width, size_t height, size_t iterations, size_t hill_size, size_t island_size, size_t island_off_center)
Generate a height-map.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:59
std::vector< map_location > generate_river(const height_map &heights, terrain_map &terrain, int x, int y, int river_uphill)
std::vector< std::vector< int > > height_map
bool generate_lake(t_translation::ter_map &terrain, int x, int y, int lake_fall_off, std::set< map_location > &locs_touched)
Generate a lake.