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

Function selection_do_randline

src/selvar.c:682–723  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680}
681
682void
683selection_do_randline(
684 coordxy x1, coordxy y1,
685 coordxy x2, coordxy y2,
686 schar rough,
687 schar rec,
688 struct selectionvar *ov)
689{
690 int mx, my;
691 int dx, dy;
692
693 if (rec < 1 || (x2 == x1 && y2 == y1))
694 return;
695
696 if (rough > max(abs(x2 - x1), abs(y2 - y1)))
697 rough = max(abs(x2 - x1), abs(y2 - y1));
698
699 if (rough < 2) {
700 mx = ((x1 + x2) / 2);
701 my = ((y1 + y2) / 2);
702 } else {
703 do {
704 dx = rn2(rough) - (rough / 2);
705 dy = rn2(rough) - (rough / 2);
706 mx = ((x1 + x2) / 2) + dx;
707 my = ((y1 + y2) / 2) + dy;
708 } while ((mx > COLNO - 1 || mx < 0 || my < 0 || my > ROWNO - 1));
709 }
710
711 if (!selection_getpoint(mx, my, ov)) {
712 selection_setpoint(mx, my, ov, 1);
713 }
714
715 rough = (rough * 2) / 3;
716
717 rec--;
718
719 selection_do_randline(x1, y1, mx, my, rough, rec, ov);
720 selection_do_randline(mx, my, x2, y2, rough, rec, ov);
721
722 selection_setpoint(x2, y2, ov, 1);
723}
724
725void
726selection_iterate(

Callers 1

l_selection_randlineFunction · 0.85

Calls 3

rn2Function · 0.85
selection_getpointFunction · 0.85
selection_setpointFunction · 0.85

Tested by

no test coverage detected