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