| 647 | } |
| 648 | |
| 649 | static void units_set_add_remove(lua_State *L, bool do_set, bool enable) { |
| 650 | df::burrow *target = get_burrow(L, 1); |
| 651 | if (!target) { |
| 652 | luaL_argerror(L, 1, "invalid burrow specifier or burrow not found"); |
| 653 | return; |
| 654 | } |
| 655 | |
| 656 | if (do_set) |
| 657 | Burrows::clearUnits(target); |
| 658 | |
| 659 | lua_pushnil(L); // first key |
| 660 | while (lua_next(L, 2)) { |
| 661 | if (auto burrow = get_burrow(L, -1)) |
| 662 | copyUnits(target, burrow, enable); |
| 663 | lua_pop(L, 1); // remove value, leave key |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | static int burrow_units_set(lua_State *L) { |
| 668 | color_ostream *out = Lua::GetOutput(L); |
no test coverage detected