| 741 | #undef X_GOAL |
| 742 | |
| 743 | staticfn int |
| 744 | get_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 | |
| 780 | staticfn int |
| 781 | get_dgn_align(lua_State *L) |
no test coverage detected