diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-28 23:32:09 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-28 23:32:09 +0100 |
commit | f59be39cc5c82b05e2bf836eefa2cd7974d4e6a5 (patch) | |
tree | 388876bb40a6f4add38b878fff7c109f58784ecf | |
parent | 0ae6a4a14a3500efe2fd7a1ebbf11e2bc45ae09f (diff) |
Switched to usage of arc4random
-rw-r--r-- | FICS/adminproc.c | 2 | ||||
-rw-r--r-- | FICS/board.c | 15 | ||||
-rw-r--r-- | FICS/fics_addplayer.c | 2 |
3 files changed, 9 insertions, 10 deletions
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()); |