MCPcopy Create free account
hub / github.com/NetHack/NetHack / nhl_init

Function nhl_init

src/nhlua.c:2292–2363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2290}
2291
2292DISABLE_WARNING_CONDEXPR_IS_CONSTANT
2293
2294lua_State *
2295nhl_init(nhl_sandbox_info *sbi)
2296{
2297 /* It would be nice to import EXPECTED from each build system. XXX */
2298 /* And it would be nice to do it only once, but it's cheap. */
2299#ifndef NHL_VERSION_EXPECTED
2300#if LUA_VERSION_NUM >= 505
2301#define NHL_VERSION_EXPECTED 50500
2302#else
2303#define NHL_VERSION_EXPECTED 50408
2304#endif
2305#endif
2306
2307#ifdef NHL_SANDBOX
2308 if (NHL_VERSION_EXPECTED != LUA_VERSION_RELEASE_NUM) {
2309 panic(
2310 "sandbox doesn't know this Lua version: this=%d != expected=%d ",
2311 LUA_VERSION_RELEASE_NUM, NHL_VERSION_EXPECTED);
2312 }
2313#endif
2314
2315 lua_State *L = nhlL_newstate(sbi, "nhl_init");
2316 if(!L) return 0;
2317
2318 iflags.in_lua = TRUE;
2319 /* Temporary for development XXX */
2320 /* Turn this off in config.h to disable the sandbox. */
2321#ifdef NHL_SANDBOX
2322 nhlL_openlibs(L, sbi->flags);
2323#else
2324 luaL_openlibs(L);
2325#endif
2326
2327#ifdef notyet
2328 if (sbi->flags & NHL_SB_PACKAGE) {
2329 /* XXX Is this still needed? */
2330 if (nhl_set_package_path(L, "./?.lua"))
2331 return 0;
2332 }
2333#endif
2334
2335 /* register nh -table, and functions for it */
2336 lua_newtable(L);
2337 luaL_setfuncs(L, nhl_functions, 0);
2338 lua_setglobal(L, "nh");
2339
2340 /* init nhc -table */
2341 init_nhc_data(L);
2342
2343 /* init u -table */
2344 init_u_data(L);
2345
2346 l_selection_register(L);
2347 l_register_des(L);
2348
2349 l_obj_register(L);

Callers 7

com_pager_coreFunction · 0.85
l_nhcore_initFunction · 0.85
load_luaFunction · 0.85
get_lua_versionFunction · 0.85
start_luapatFunction · 0.85
init_dungeonsFunction · 0.85
makeroomsFunction · 0.85

Calls 11

nhlL_newstateFunction · 0.85
nhlL_openlibsFunction · 0.85
nhl_set_package_pathFunction · 0.85
init_nhc_dataFunction · 0.85
init_u_dataFunction · 0.85
l_selection_registerFunction · 0.85
l_register_desFunction · 0.85
l_obj_registerFunction · 0.85
nhl_loadluaFunction · 0.85
nhl_doneFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected