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

Function lspo_region

src/sp_lev.c:5583–5715  ·  view source on GitHub ↗

region(selection, lit); */ region({ x1=NN, y1=NN, x2=NN, y2=NN, lit=BOOL, type=ROOMTYPE, joined=BOOL, * irregular=BOOL, filled=NN [ , contents = FUNCTION ] }); */ region({ region={x1,y1, x2,y2}, type="ordinary" }); */

Source from the content-addressed store, hash-verified

5581 * irregular=BOOL, filled=NN [ , contents = FUNCTION ] }); */
5582/* region({ region={x1,y1, x2,y2}, type="ordinary" }); */
5583int
5584lspo_region(lua_State *L)
5585{
5586 coordxy dx1, dy1, dx2, dy2;
5587 struct mkroom *troom;
5588 boolean do_arrival_room = FALSE, room_not_needed,
5589 irregular = FALSE, joined = TRUE;
5590 int rtype = OROOM, rlit = 1, needfill = 0;
5591 int argc = lua_gettop(L);
5592
5593 create_des_coder();
5594
5595 if (argc <= 1) {
5596 lcheck_param_table(L);
5597
5598 /* TODO: "unfilled" => filled=0, "filled" => filled=1, and
5599 * "lvflags_only" => filled=2, probably in a get_table_needfill_opt */
5600 needfill = get_table_int_opt(L, "filled", 0);
5601 irregular = get_table_boolean_opt(L, "irregular", 0);
5602 joined = get_table_boolean_opt(L, "joined", TRUE);
5603 do_arrival_room = get_table_boolean_opt(L, "arrival_room", 0);
5604 rtype = get_table_roomtype_opt(L, "type", OROOM);
5605 rlit = get_table_int_opt(L, "lit", -1);
5606
5607 get_table_coords_or_region(L, &dx1, &dy1, &dx2, &dy2);
5608
5609 if (dx1 == -1 && dy1 == -1 && dx2 == -1 && dy2 == -1) {
5610 nhl_error(L, "region needs region");
5611 }
5612
5613 } else if (argc == 2) {
5614 /* region(selection, "lit"); */
5615 static const char *const lits[] = { "unlit", "lit", NULL };
5616 struct selectionvar *orig = l_selection_check(L, 1),
5617 *sel = selection_clone(orig);
5618
5619 rlit = luaL_checkoption(L, 2, "lit", lits);
5620
5621 /*
5622 TODO: lit=random
5623 */
5624 if (rlit)
5625 selection_do_grow(sel, W_ANY);
5626 selection_iterate(sel, sel_set_lit, (genericptr_t) &rlit);
5627
5628 selection_free(sel, TRUE);
5629
5630 /* TODO: skip the rest of this function? */
5631 return 0;
5632 } else {
5633 nhl_error(L, "Wrong parameters");
5634 /*NOTREACHED*/
5635 return 0;
5636 }
5637
5638 rlit = litstate_rnd(rlit);
5639
5640 get_location(&dx1, &dy1, ANY_LOC, (struct mkroom *) 0);

Callers

nothing calls this directly

Calls 15

create_des_coderFunction · 0.85
lcheck_param_tableFunction · 0.85
get_table_int_optFunction · 0.85
get_table_boolean_optFunction · 0.85
get_table_roomtype_optFunction · 0.85
nhl_errorFunction · 0.85
l_selection_checkFunction · 0.85
selection_cloneFunction · 0.85
selection_do_growFunction · 0.85
selection_iterateFunction · 0.85
selection_freeFunction · 0.85

Tested by

no test coverage detected