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

Function l_selection_or

src/nhlsel.c:305–328  ·  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

303
304/* local sel = selection.area(4,5, 40,10) | selection.rect(7,8, 60,14); */
305staticfn int
306l_selection_or(lua_State *L)
307{
308 int x,y;
309 struct selectionvar *sela = l_selection_check(L, 1);
310 struct selectionvar *selb = l_selection_check(L, 2);
311 struct selectionvar *selr = l_selection_push_new(L);
312 NhRect rect = cg.zeroNhRect;
313
314 rect_bounds(sela->bounds, selb->bounds, &rect);
315
316 for (x = rect.lx; x <= rect.hx; x++)
317 for (y = rect.ly; y <= rect.hy; y++) {
318 int val = (selection_getpoint(x, y, sela)
319 | selection_getpoint(x, y, selb));
320
321 selection_setpoint(x, y, selr, val);
322 }
323 selr->bounds = rect;
324
325 lua_remove(L, 1);
326 lua_remove(L, 1);
327 return 1;
328}
329
330/* local sel = selection.area(4,5, 40,10) ~ selection.rect(7,8, 60,14); */
331staticfn 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