From f59be39cc5c82b05e2bf836eefa2cd7974d4e6a5 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Thu, 28 Dec 2023 23:32:09 +0100 Subject: Switched to usage of arc4random --- FICS/adminproc.c | 2 +- FICS/board.c | 15 +++++++-------- FICS/fics_addplayer.c | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) (limited to 'FICS') diff --git a/FICS/adminproc.c b/FICS/adminproc.c index 6f10d94..0b47134 100644 --- a/FICS/adminproc.c +++ b/FICS/adminproc.c @@ -978,7 +978,7 @@ com_addplayer(int p, param_list param) if (strcmp(newemail, "none")) { for (i = 0; i < PASSLEN; i++) - password[i] = ('a' + rand() % 26); + password[i] = ('a' + arc4random_uniform(26)); password[i] = '\0'; strcpy(salt, fics_getsalt()); diff --git a/FICS/board.c b/FICS/board.c index 56c2fa2..d404527 100644 --- a/FICS/board.c +++ b/FICS/board.c @@ -1147,9 +1147,9 @@ place_piece(board_t b, int piece, int squareColor) while (!placed) { if (squareColor == ANY_SQUARE) { - f = (rand() % 8); + f = arc4random_uniform(8); } else { - f = (rand() % 4) * 2; + f = arc4random_uniform(4) * 2; if (SquareColor(f, r) != squareColor) f++; @@ -1180,14 +1180,14 @@ wild_update(int style) switch (style) { case 1: - if (rand() & 0x01) { + if (arc4random() & 0x01) { b[4][0] = W_KING; b[3][0] = W_QUEEN; } else { b[3][0] = W_KING; b[4][0] = W_QUEEN; } - if (rand() & 0x01) { + if (arc4random() & 0x01) { b[4][7] = B_KING; b[3][7] = B_QUEEN; } else { @@ -1233,9 +1233,8 @@ wild_update(int style) place_piece(b, W_KING, ANY_SQUARE); for (i = 0; i < 8; i++) { - if (b[i][0] != W_KING) { - b[i][0] = (rand() % 4) + 2; - } + if (b[i][0] != W_KING) + b[i][0] = arc4random_uniform(4) + 2; } /* Black mirrors White */ @@ -1251,7 +1250,7 @@ wild_update(int style) for (i = 0; i < 8; i++) { if (b[i][0] != W_KING) - b[i][0] = (rand() % 4) + 2; + b[i][0] = arc4random_uniform(4) + 2; } /* diff --git a/FICS/fics_addplayer.c b/FICS/fics_addplayer.c index 2c9518d..8f01604 100644 --- a/FICS/fics_addplayer.c +++ b/FICS/fics_addplayer.c @@ -113,7 +113,7 @@ main(int argc, char *argv[]) parray[p].emailAddress = xstrdup(email); for (i = 0; i < PASSLEN; i++) - password[i] = ('a' + rand() % 26); + password[i] = ('a' + arc4random_uniform(26)); password[i] = '\0'; strcpy(salt, fics_getsalt()); -- cgit v1.2.3