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

Function selection_rndcoord

src/selvar.c:283–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283int
284selection_rndcoord(
285 struct selectionvar *ov,
286 coordxy *x, coordxy *y,
287 boolean removeit)
288{
289 int idx = 0;
290 int c;
291 int dx, dy;
292 NhRect rect = cg.zeroNhRect;
293
294 selection_getbounds(ov, &rect);
295
296 for (dx = rect.lx; dx <= rect.hx; dx++)
297 for (dy = rect.ly; dy <= rect.hy; dy++)
298 if (selection_getpoint(dx, dy, ov))
299 idx++;
300
301 if (idx) {
302 c = rn2(idx);
303 for (dx = rect.lx; dx <= rect.hx; dx++)
304 for (dy = rect.ly; dy <= rect.hy; dy++)
305 if (selection_getpoint(dx, dy, ov)) {
306 if (!c) {
307 *x = dx;
308 *y = dy;
309 if (removeit)
310 selection_setpoint(dx, dy, ov, 0);
311 return 1;
312 }
313 c--;
314 }
315 }
316 *x = *y = -1;
317 return 0;
318}
319
320void
321selection_do_grow(struct selectionvar *ov, int dir)

Callers 2

l_selection_rndcoordFunction · 0.85
generate_way_out_methodFunction · 0.85

Calls 4

selection_getboundsFunction · 0.85
selection_getpointFunction · 0.85
rn2Function · 0.85
selection_setpointFunction · 0.85

Tested by

no test coverage detected