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

Function l_selection_xor

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

329
330/* local sel = selection.area(4,5, 40,10) ~ selection.rect(7,8, 60,14); */
331staticfn int
332l_selection_xor(lua_State *L)
333{
334 int x,y;
335 struct selectionvar *sela = l_selection_check(L, 1);
336 struct selectionvar *selb = l_selection_check(L, 2);
337 struct selectionvar *selr = l_selection_push_new(L);
338 NhRect rect = cg.zeroNhRect;
339
340 rect_bounds(sela->bounds, selb->bounds, &rect);
341
342 for (x = rect.lx; x <= rect.hx; x++)
343 for (y = rect.ly; y <= rect.hy; y++) {
344 int val = (selection_getpoint(x, y, sela)
345 ^ selection_getpoint(x, y, selb));
346
347 selection_setpoint(x, y, selr, val);
348 }
349 /* this may have created a smaller or irregular selection with
350 * bounds_dirty set to true - update its boundaries */
351 selection_recalc_bounds(selr);
352
353 lua_remove(L, 1);
354 lua_remove(L, 1);
355 return 1;
356}
357
358/* local sel = selection.area(10,10, 20,20) - selection.area(14,14, 17,17)
359 * - i.e. points that are in A but not in B */

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected