| 867 | } |
| 868 | |
| 869 | static int getMaterialMaskFilter(lua_State *L) { |
| 870 | color_ostream *out = Lua::GetOutput(L); |
| 871 | if (!out) |
| 872 | out = &Core::getInstance().getConsole(); |
| 873 | df::building_type type = (df::building_type)luaL_checkint(L, 1); |
| 874 | int16_t subtype = luaL_checkint(L, 2); |
| 875 | int32_t custom = luaL_checkint(L, 3); |
| 876 | int index = luaL_checkint(L, 4); |
| 877 | DEBUG(control,*out).print( |
| 878 | "entering getMaterialFilter building_type={} subtype={} custom={} index={}\n", |
| 879 | ENUM_AS_STR(type), subtype, custom, index); |
| 880 | BuildingTypeKey key(type, subtype, custom); |
| 881 | auto &filters = get_item_filters(*out, key); |
| 882 | if (index < 0 || filters.getItemFilters().size() <= (size_t)index) |
| 883 | return 0; |
| 884 | map<string, bool> ret; |
| 885 | uint32_t bits = filters.getItemFilters()[index].getMaterialMask().whole; |
| 886 | ret.emplace("unset", !bits); |
| 887 | ret.emplace("stone", !bits || bits & stone_cat.whole); |
| 888 | ret.emplace("wood", !bits || bits & wood_cat.whole); |
| 889 | ret.emplace("metal", !bits || bits & metal_cat.whole); |
| 890 | ret.emplace("glass", !bits || bits & glass_cat.whole); |
| 891 | ret.emplace("gem", !bits || bits & gem_cat.whole); |
| 892 | ret.emplace("clay", !bits || bits & clay_cat.whole); |
| 893 | ret.emplace("cloth", !bits || bits & cloth_cat.whole); |
| 894 | ret.emplace("silk", !bits || bits & silk_cat.whole); |
| 895 | ret.emplace("yarn", !bits || bits & yarn_cat.whole); |
| 896 | Lua::Push(L, ret); |
| 897 | return 1; |
| 898 | } |
| 899 | |
| 900 | static int setMaterialFilter(lua_State *L) { |
| 901 | color_ostream *out = Lua::GetOutput(L); |
nothing calls this directly
no test coverage detected