The Battle for Wesnoth  1.19.5+dev
default_map_generator_job.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
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"
23 #include "terrain/translation.hpp"
24 
25 #include <random>
26 #include <cstdint>
27 #include <map>
28 
30 {
31 public:
33  default_map_generator_job(uint32_t seed);
34 
35  /** Generate the map. */
36  std::string default_generate_map(generator_data data, std::map<map_location,std::string>* labels, const config& cfg);
37 
38  typedef std::vector<std::vector<int>> height_map;
40 
41 
42  height_map generate_height_map(size_t width, size_t height,
43  size_t iterations, size_t hill_size,
44  size_t island_size, size_t island_off_center);
45 
46  height_map generate_height_map(size_t width, size_t height,
47  size_t iterations, size_t hill_size,
48  size_t island_size, size_t center_x, size_t center_y);
49 
50 private:
51 
52  bool generate_river_internal(const height_map& heights,
53  terrain_map& terrain, int x, int y, std::vector<map_location>& river,
54  std::set<map_location>& seen_locations, int river_uphill);
55 
56  std::vector<map_location> generate_river(const height_map& heights, terrain_map& terrain, int x, int y, int river_uphill);
57 
58  bool generate_lake(t_translation::ter_map& terrain, int x, int y, int lake_fall_off, std::set<map_location>& locs_touched);
59  map_location random_point_at_side(std::size_t width, std::size_t height);
60 
61  std::mt19937 rng_;
63 
64 };
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
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.
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.
std::string default_generate_map(generator_data data, std::map< map_location, std::string > *labels, const config &cfg)
Generate the map.
std::vector< map_location > generate_river(const height_map &heights, terrain_map &terrain, int x, int y, int river_uphill)
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.
const game_config_view & game_config_
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.
std::vector< std::vector< int > > height_map
A class grating read only view to a vector of config objects, viewed as one config with all children ...
std::string_view data
Definition: picture.cpp:178
Encapsulates the map of the game.
Definition: location.hpp:45