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

Function l_selection_and

src/nhlsel.c:280–302  ·  view source on GitHub ↗

local sel = selection.area(4,5, 40,10) & selection.rect(7,8, 60,14); */

Source from the content-addressed store, hash-verified

278
279/* local sel = selection.area(4,5, 40,10) & selection.rect(7,8, 60,14); */
280staticfn int
281l_selection_and(lua_State *L)
282{
283 int x, y;
284 struct selectionvar *sela = l_selection_check(L, 1);
285 struct selectionvar *selb = l_selection_check(L, 2);
286 struct selectionvar *selr = l_selection_push_new(L);
287 NhRect rect = cg.zeroNhRect;
288
289 rect_bounds(sela->bounds, selb->bounds, &rect);
290
291 for (x = rect.lx; x <= rect.hx; x++)
292 for (y = rect.ly; y <= rect.hy; y++) {
293 int val = (selection_getpoint(x, y, sela)
294 & selection_getpoint(x, y, selb));
295
296 selection_setpoint(x, y, selr, val);
297 }
298
299 lua_remove(L, 1);
300 lua_remove(L, 1);
301 return 1;
302}
303
304/* local sel = selection.area(4,5, 40,10) | selection.rect(7,8, 60,14); */
305staticfn int

Callers

nothing calls this directly

Calls 5

l_selection_checkFunction · 0.85
l_selection_push_newFunction · 0.85
rect_boundsFunction · 0.85
selection_getpointFunction · 0.85
selection_setpointFunction · 0.85

Tested by

no test coverage detected