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

Function l_selection_fillrect

src/nhlsel.c:558–584  ·  view source on GitHub ↗

local s = selection.fillrect(sel, x1,y1, x2,y2); */ local s = selection.fillrect(x1,y1, x2,y2); */ s:fillrect(x1,y1, x2,y2); */ selection.area(x1,y1, x2,y2); */

Source from the content-addressed store, hash-verified

556/* s:fillrect(x1,y1, x2,y2); */
557/* selection.area(x1,y1, x2,y2); */
558staticfn int
559l_selection_fillrect(lua_State *L)
560{
561 struct selectionvar *sel = NULL;
562 int y;
563 coordxy x1, y1, x2, y2;
564
565 if (!params_sel_2coords(L, &sel, &x1, &y1, &x2, &y2)) {
566 nhl_error(L, "selection.fillrect: illegal arguments");
567 }
568
569 get_location_coord(&x1, &y1, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
570 SP_COORD_PACK(x1, y1));
571 get_location_coord(&x2, &y2, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
572 SP_COORD_PACK(x2, y2));
573
574 (void) l_selection_clone(L);
575 sel = l_selection_check(L, 2);
576 if (x1 == x2) {
577 for (y = y1; y <= y2; y++)
578 selection_setpoint(x1, y, sel, 1);
579 } else {
580 for (y = y1; y <= y2; y++)
581 selection_do_line(x1, y, x2, y, sel);
582 }
583 return 1;
584}
585
586/* local s = selection.randline(sel, x1,y1, x2,y2, roughness); */
587/* local s = selection.randline(x1,y1, x2,y2, roughness); */

Callers

nothing calls this directly

Calls 7

params_sel_2coordsFunction · 0.85
nhl_errorFunction · 0.85
get_location_coordFunction · 0.85
l_selection_cloneFunction · 0.85
l_selection_checkFunction · 0.85
selection_setpointFunction · 0.85
selection_do_lineFunction · 0.85

Tested by

no test coverage detected