The Battle for Wesnoth  1.17.0-dev
mapgen_lua_kernel.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2021
3  by Chris Beck <render787@gmail.com>
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 
19 #include <optional>
20 
21 #include <cstdint>
22 #include <random>
23 
24 class config;
25 
26 #include <string>
27 
29 public:
30  mapgen_lua_kernel(const config* vars);
31 
32  virtual std::string my_name() { return "Mapgen Lua Kernel"; }
33 
34  void user_config(const char * prog, const config & generator); // throws game::lua_error
35  std::string create_map(const char * prog, const config & generator, std::optional<uint32_t> seed); // throws game::lua_error
36  config create_scenario(const char * prog, const config & generator, std::optional<uint32_t> seed); // throws game::lua_error
37 
38  virtual uint32_t get_random_seed();
39  std::mt19937& get_default_rng();
40 private:
41  void run_generator(const char * prog, const config & generator);
44  std::optional<uint32_t> random_seed_;
45  std::optional<std::mt19937> default_rng_;
46  const config* vars_;
47 };
std::optional< std::mt19937 > default_rng_
int intf_get_all_vars(lua_State *L)
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:61
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:61
std::optional< uint32_t > random_seed_