34 #define ERR_NG LOG_STREAM(err, log_mapgen)
35 #define LOG_NG LOG_STREAM(info, log_mapgen)
36 #define DBG_NG LOG_STREAM(debug, log_mapgen)
47 boost::mt19937& rng = lua_kernel_base::get_lua_kernel<mapgen_lua_kernel>(L).get_default_rng();
49 double r = double (rng());
50 double r_max = double (rng.max());
58 min = lua_check<int32_t>(L, 1);
59 max = lua_check<int32_t>(L, 2);
63 max = lua_check<int32_t>(L, 1);
68 lua_push(L, min + static_cast<int>(rng() % (max - min + 1)));
104 int nb = res.
steps.size();
106 for (
int i = 0;
i < nb; ++
i)
129 static luaL_Reg const callbacks[] = {
#define lua_isnoneornil(L, n)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
plain_route a_star_search(const map_location &src, const map_location &dst, double stop_at, const cost_calculator *calc, const size_t width, const size_t height, const teleport_map *teleports, bool border)
static int intf_random(lua_State *L)
Returns a random numer, same interface as math.random.
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int narg)
LUA_API void lua_settop(lua_State *L, int idx)
boost::optional< boost::mt19937 > default_rng_
LUA_API int lua_type(lua_State *L, int idx)
rng * generator
This generator is automatically synced during synced context.
LUA_API void lua_getglobal(lua_State *L, const char *var)
LUA_API int lua_gettop(lua_State *L)
#define luaL_typename(L, i)
void lua_push(lua_State *L, const T &val)
Definitions for the interface to Wesnoth Markup Language (WML).
config create_scenario(const char *prog, const config &generator, boost::optional< boost::uint32_t > seed)
virtual boost::uint32_t get_random_seed()
std::vector< map_location > steps
LUA_API int lua_isstring(lua_State *L, int idx)
bool luaW_toboolean(lua_State *L, int n)
Structure which holds a single route between one location and another.
void user_config(const char *prog, const config &generator)
bool protected_call(int nArgs, int nRets, error_handler)
int move_cost
Movement cost for reaching the end of the route.
bool load_string(char const *prog, error_handler)
Encapsulates the map of the game.
#define lua_isboolean(L, n)
bool luaW_toconfig(lua_State *L, int index, config &cfg)
Converts an optional table or vconfig to a config object.
Cost function object relying on a Lua function.
#define lua_isfunction(L, n)
LUALIB_API int luaL_argerror(lua_State *L, int narg, const char *extramsg)
#define lua_tostring(L, i)
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
LUA_API void lua_rawseti(lua_State *L, int idx, int n)
GLdouble GLdouble GLdouble r
LUA_API int lua_isnumber(lua_State *L, int idx)
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
virtual boost::uint32_t get_random_seed()
GLint GLint GLsizei GLsizei GLsizei GLint border
LUA_API int lua_error(lua_State *L)
#define lua_istable(L, n)
static int intf_find_path(lua_State *L)
Finds a path between two locations.
virtual void throw_exception(char const *msg, char const *context="Lua error")
void luaW_pushconfig(lua_State *L, config const &cfg)
Converts a config object to a Lua table pushed at the top of the stack.
static lg::log_domain log_mapgen("mapgen")
Standard logging facilities (interface).
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
GLint GLint GLint GLint GLint GLint GLsizei width
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
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.
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
GLsizei const GLcharARB ** string
boost::mt19937 & get_default_rng()
std::string create_map(const char *prog, const config &generator, boost::optional< boost::uint32_t > seed)
LUA_API const char * lua_typename(lua_State *L, int t)
boost::optional< boost::uint32_t > random_seed_