Macro for picking random entry from array

This commit is contained in:
Pasi Kallinen
2023-12-05 10:06:27 +02:00
parent b98a70e3ec
commit 5dc94f3d83
24 changed files with 45 additions and 42 deletions

View File

@@ -1899,7 +1899,7 @@ static const char *const ghostnames[] = {
const char *
rndghostname(void)
{
return rn2(7) ? ghostnames[rn2(SIZE(ghostnames))]
return rn2(7) ? ROLL_FROM(ghostnames)
: (const char *) gp.plname;
}
@@ -2635,7 +2635,7 @@ rndorcname(char *s)
for (i = 0; i < iend; ++i) {
vstart = 1 - vstart; /* 0 -> 1, 1 -> 0 */
Sprintf(eos(s), "%s%s", (i > 0 && !rn2(30)) ? "-" : "",
vstart ? v[rn2(SIZE(v))] : snd[rn2(SIZE(snd))]);
vstart ? ROLL_FROM(v) : ROLL_FROM(snd));
}
}
return s;