The Battle for Wesnoth  1.19.5+dev
mapgen_lua_kernel.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2024
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 "utils/optional_fwd.hpp"
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, utils::optional<uint32_t> seed); // throws game::lua_error
36  config create_scenario(const char * prog, const config & generator, utils::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);
42  int intf_get_variable(lua_State *L);
43  int intf_get_all_vars(lua_State *L);
44  utils::optional<uint32_t> random_seed_;
45  utils::optional<std::mt19937> default_rng_;
46  const config* vars_;
47 };
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
int intf_get_variable(lua_State *L)
virtual uint32_t get_random_seed()
void run_generator(const char *prog, const config &generator)
virtual std::string my_name()
User-visible name of the lua kernel that they are talking to.
void user_config(const char *prog, const config &generator)
std::string create_map(const char *prog, const config &generator, utils::optional< uint32_t > seed)
config create_scenario(const char *prog, const config &generator, utils::optional< uint32_t > seed)
mapgen_lua_kernel(const config *vars)
std::mt19937 & get_default_rng()
utils::optional< uint32_t > random_seed_
int intf_get_all_vars(lua_State *L)
const config * vars_
utils::optional< std::mt19937 > default_rng_
rng * generator
This generator is automatically synced during synced context.
Definition: random.cpp:60