The Battle for Wesnoth  1.15.12+dev
mapgen_lua_kernel.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2018 by Chris Beck <render787@gmail.com>
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 
18 #include <optional>
19 
20 #include <cstdint>
21 #include <random>
22 
23 class config;
24 
25 #include <string>
26 
28 public:
29  mapgen_lua_kernel(const config* vars);
30 
31  virtual std::string my_name() { return "Mapgen Lua Kernel"; }
32 
33  void user_config(const char * prog, const config & generator); // throws game::lua_error
34  std::string create_map(const char * prog, const config & generator, std::optional<uint32_t> seed); // throws game::lua_error
35  config create_scenario(const char * prog, const config & generator, std::optional<uint32_t> seed); // throws game::lua_error
36 
37  virtual uint32_t get_random_seed();
38  std::mt19937& get_default_rng();
39 private:
40  void run_generator(const char * prog, const config & generator);
42  std::optional<uint32_t> random_seed_;
43  std::optional<std::mt19937> default_rng_;
44  const config* vars_;
45 };
std::optional< std::mt19937 > default_rng_
const config * vars_
void user_config(const char *prog, const config &generator)
int intf_get_variable(lua_State *L)
virtual std::string my_name()
User-visible name of the lua kernel that they are talking to.
virtual uint32_t get_random_seed()
rng * generator
This generator is automatically synced during synced context.
Definition: random.cpp:60
std::string create_map(const char *prog, const config &generator, std::optional< uint32_t > seed)
config create_scenario(const char *prog, const config &generator, std::optional< uint32_t > seed)
std::mt19937 & get_default_rng()
mapgen_lua_kernel(const config *vars)
void run_generator(const char *prog, const config &generator)
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:59
std::optional< uint32_t > random_seed_