The Battle for Wesnoth  1.15.2+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 <boost/optional.hpp>
19 #include <cstdint>
20 #include <random>
21 
22 class config;
23 
24 #include <string>
25 
27 public:
28  mapgen_lua_kernel(const config* vars);
29 
30  virtual std::string my_name() { return "Mapgen Lua Kernel"; }
31 
32  void user_config(const char * prog, const config & generator); // throws game::lua_error
33  std::string create_map(const char * prog, const config & generator, boost::optional<uint32_t> seed); // throws game::lua_error
34  config create_scenario(const char * prog, const config & generator, boost::optional<uint32_t> seed); // throws game::lua_error
35 
36  virtual uint32_t get_random_seed();
37  std::mt19937& get_default_rng();
38 private:
39  void run_generator(const char * prog, const config & generator);
41  boost::optional<uint32_t> random_seed_;
42  boost::optional<std::mt19937> default_rng_;
43  const config* vars_;
44 };
boost::optional< std::mt19937 > default_rng_
std::string create_map(const char *prog, const config &generator, boost::optional< uint32_t > seed)
config create_scenario(const char *prog, const config &generator, boost::optional< uint32_t > seed)
boost::optional< uint32_t > random_seed_
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::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:68