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

Function get_dgn_flags

src/dungeon.c:743–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

741#undef X_GOAL
742
743staticfn int
744get_dgn_flags(lua_State *L)
745{
746 int dgn_flags = 0;
747 static const char *const flagstrs[] = {
748 "town", "hellish", "mazelike", "roguelike", "unconnected", NULL
749 };
750 static const int flagstrs2i[] = {
751 TOWN, HELLISH, MAZELIKE, ROGUELIKE, UNCONNECTED, 0
752 };
753
754 lua_getfield(L, -1, "flags");
755 if (lua_type(L, -1) == LUA_TTABLE) {
756 int f, nflags;
757
758 lua_len(L, -1);
759 nflags = (int) lua_tointeger(L, -1);
760 lua_pop(L, 1);
761 for (f = 0; f < nflags; f++) {
762 lua_pushinteger(L, f + 1);
763 lua_gettable(L, -2);
764 if (lua_type(L, -1) == LUA_TSTRING) {
765 dgn_flags |= flagstrs2i[luaL_checkoption(L, -1, NULL,
766 flagstrs)];
767 lua_pop(L, 1);
768 } else
769 impossible("flags[%i] is not a string", f);
770 }
771 } else if (lua_type(L, -1) == LUA_TSTRING) {
772 dgn_flags |= flagstrs2i[luaL_checkoption(L, -1, NULL, flagstrs)];
773 } else if (lua_type(L, -1) != LUA_TNIL)
774 impossible("flags is not an array or string");
775 lua_pop(L, 1);
776
777 return dgn_flags;
778}
779
780staticfn int
781get_dgn_align(lua_State *L)

Callers 2

init_dungeon_levelsFunction · 0.85
init_dungeon_dungeonsFunction · 0.85

Calls 1

impossibleFunction · 0.70

Tested by

no test coverage detected