summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-04 01:41:26 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-04 01:41:26 +0800
commit920cb52f211a03479556866c712298141d368c50 (patch)
tree968cf0db6a62db237b6d928c42e40631a231b792 /mbbsd
parent87fb00ac1f12f18d1176a4dc1988c8b86a7ef63c (diff)
downloadpttbbs-920cb52f211a03479556866c712298141d368c50.tar
pttbbs-920cb52f211a03479556866c712298141d368c50.tar.gz
pttbbs-920cb52f211a03479556866c712298141d368c50.tar.bz2
pttbbs-920cb52f211a03479556866c712298141d368c50.tar.lz
pttbbs-920cb52f211a03479556866c712298141d368c50.tar.xz
pttbbs-920cb52f211a03479556866c712298141d368c50.tar.zst
pttbbs-920cb52f211a03479556866c712298141d368c50.zip
replace rand() with random() for better randomness
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2460 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/cal.c2
-rw-r--r--mbbsd/card.c2
-rw-r--r--mbbsd/chc.c2
-rw-r--r--mbbsd/chicken.c8
-rw-r--r--mbbsd/dark.c2
-rw-r--r--mbbsd/dice.c2
-rw-r--r--mbbsd/edit.c2
-rw-r--r--mbbsd/file.c2
-rw-r--r--mbbsd/guess.c6
-rw-r--r--mbbsd/lovepaper.c2
-rw-r--r--mbbsd/mbbsd.c2
-rw-r--r--mbbsd/menu.c2
-rw-r--r--mbbsd/othello.c2
-rw-r--r--mbbsd/record.c2
-rw-r--r--mbbsd/talk.c2
-rw-r--r--mbbsd/vice.c4
16 files changed, 22 insertions, 22 deletions
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index 1e58d53f..78011f5f 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -60,7 +60,7 @@ int
vice(int money, char *item)
{
char buf[128];
- unsigned int viceserial = (currutmp->lastact % 10000) * 10000 + rand() % 10000;
+ unsigned int viceserial = (currutmp->lastact % 10000) * 10000 + random() % 10000;
demoney(-money);
if(money>=100)
diff --git a/mbbsd/card.c b/mbbsd/card.c
index 0d973be2..6353e425 100644
--- a/mbbsd/card.c
+++ b/mbbsd/card.c
@@ -181,7 +181,7 @@ card_give(int cards[])
assert(nfreecard>0); /* caller 要負責確保還有剩牌 */
- i=freecard[rand()%nfreecard];
+ i=freecard[random()%nfreecard];
cards[i] = 1;
return i;
}
diff --git a/mbbsd/chc.c b/mbbsd/chc.c
index c4f20dff..32e8f1ec 100644
--- a/mbbsd/chc.c
+++ b/mbbsd/chc.c
@@ -381,7 +381,7 @@ chc_log_poem(void)
else {
char buf[80];
FILE *fp;
- sprintf(buf, BBSHOME"/etc/chess/%s", namelist[rand() % n]->d_name);
+ sprintf(buf, BBSHOME"/etc/chess/%s", namelist[random() % n]->d_name);
if ((fp = fopen(buf, "r")) == NULL)
return -1;
diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c
index 05f857cc..40e53da2 100644
--- a/mbbsd/chicken.c
+++ b/mbbsd/chicken.c
@@ -308,7 +308,7 @@ ch_guess()
me -= '1';
if (me > 2 || me < 0)
me = 0;
- win = (int)(3.0 * rand() / (RAND_MAX + 1.0)) - 1;
+ win = (int)(3.0 * random() / (RAND_MAX + 1.0)) - 1;
ch = (me + win + 3) % 3;
prints("%s:%s ! %s:%s !.....%s",
cuser.userid, guess[(int)me], mychicken->name, guess[(int)ch],
@@ -347,7 +347,7 @@ ch_hit()
mychicken->mm_max += time_change[(int)mychicken->type][MM_MAX] / 15;
mychicken->weight -= mychicken->hp_max / 15;
mychicken->hp -= (int)((float)time_change[(int)mychicken->type][HP_MAX] *
- rand() / (RAND_MAX + 1.0)) / 2 + 1;
+ random() / (RAND_MAX + 1.0)) / 2 + 1;
if (mychicken->book > 2)
mychicken->book -= 2;
@@ -800,7 +800,7 @@ static int
recover_chicken(chicken_t * thechicken)
{
char buf[200];
- int price = egg_price[(int)thechicken->type], money = price + (rand() % price);
+ int price = egg_price[(int)thechicken->type], money = price + (random() % price);
if (now - thechicken->lastvisit > (60 * 60 * 24 * 7))
return 0;
@@ -905,7 +905,7 @@ chickenpk(int fd)
show_chicken_data(ochicken, mychicken);
add_io(fd, 3); /* 把fd加到igetch監視 */
while (1) {
- r = rand();
+ r = random();
ch = igetch();
getuser(mateid);
memcpy(&ouser, &xuser, sizeof(userec_t));
diff --git a/mbbsd/dark.c b/mbbsd/dark.c
index 1942aa86..e7d644cd 100644
--- a/mbbsd/dark.c
+++ b/mbbsd/dark.c
@@ -108,7 +108,7 @@ brd_rand()
for (y = 0; y < 4; y++)
for (x = 0; x < 8; x++)
while (1) {
- index = rand() % 32;
+ index = random() % 32;
if (tem[index])
continue;
brd[y][x].color = (index > 15) ? 0 : 1;
diff --git a/mbbsd/dice.c b/mbbsd/dice.c
index b6283731..f3b7ff90 100644
--- a/mbbsd/dice.c
+++ b/mbbsd/dice.c
@@ -356,7 +356,7 @@ dice_main(void)
clear();
show_data();
for (j = 0; j < 3; j++)
- bet[j] = rand() % 6 + 1;
+ bet[j] = random() % 6 + 1;
for (j = 0; j < 100; j++)
value[j] = 0;
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index 4eadc280..310fd7b3 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -1043,7 +1043,7 @@ addsignature(FILE * fp, int ifuseanony)
if (isdigit((int)buf[0]))
ch = buf[0];
else
- ch = '1' + rand() % num;
+ ch = '1' + random() % num;
cuser.signature = buf[0];
if (ch != '0') {
diff --git a/mbbsd/file.c b/mbbsd/file.c
index 9c2e6927..1c934bfb 100644
--- a/mbbsd/file.c
+++ b/mbbsd/file.c
@@ -58,7 +58,7 @@ int file_delete_line(char *file, char *string, int case_sensitive)
char fnew[80];
char genbuf[STRLEN + 1];
- sprintf(fnew, "%s.%3.3X", file, rand() & 0xFFF);
+ sprintf(fnew, "%s.%3.3X", file, random() & 0xFFF);
if ((fp = fopen(file, "r")) && (nfp = fopen(fnew, "w"))) {
int length = strlen(string);
diff --git a/mbbsd/guess.c b/mbbsd/guess.c
index 55e5e624..68ea0591 100644
--- a/mbbsd/guess.c
+++ b/mbbsd/guess.c
@@ -165,10 +165,10 @@ computer(int correct, int total, char flag[], int n[])
if (total == 1) {
do {
- guess = rand() % 10000;
+ guess = random() % 10000;
} while (!legal(guess));
} else
- guess = n[rand() % j];
+ guess = n[random() % j];
k = result(correct, guess);
if (k == 40) {
move(total + 8, 25);
@@ -197,7 +197,7 @@ Diff_Random(char *answer)
register int i = 0, j, k;
while (i < 4) {
- k = rand() % 10 + '0';
+ k = random() % 10 + '0';
for (j = 0; j < i; j++)
if (k == answer[j])
break;
diff --git a/mbbsd/lovepaper.c b/mbbsd/lovepaper.c
index b93fefbd..b7d4c143 100644
--- a/mbbsd/lovepaper.c
+++ b/mbbsd/lovepaper.c
@@ -60,7 +60,7 @@ x_love()
case '8':
case '9':
sscanf(buf1, "%d", &x);
- y = (rand() % (x - 1)) * tline;
+ y = (random() % (x - 1)) * tline;
break;
default:
if (!poem) {
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 34b78e06..20ac1d99 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -207,7 +207,7 @@ abort_bbs_debug(int sig)
static void
mysrand()
{
- srand(time(NULL) + getpid()); /* 時間跟 pid 當 rand 的 seed */
+ srandom(time(NULL) + getpid()); /* 時間跟 pid 當 rand 的 seed */
}
void
diff --git a/mbbsd/menu.c b/mbbsd/menu.c
index 092c497f..6b45d528 100644
--- a/mbbsd/menu.c
+++ b/mbbsd/menu.c
@@ -118,7 +118,7 @@ movie(int i)
do {
if (!i)
i = 1 + (int)(((float)SHM->max_film *
- rand()) / (RAND_MAX + 1.0));
+ random()) / (RAND_MAX + 1.0));
for (j = SHM->max_history; j >= 0; j--)
if (i == history[j]) {
diff --git a/mbbsd/othello.c b/mbbsd/othello.c
index 7f4b77b2..3392ca02 100644
--- a/mbbsd/othello.c
+++ b/mbbsd/othello.c
@@ -533,7 +533,7 @@ othello_main()
think = choose();
showtitle("黑白棋", BBSName);
printboard();
- which_table = rand() % NR_TABLE;
+ which_table = random() % NR_TABLE;
while (true) {
move(STARTX - 1, 30);
outs("輪到你下了...");
diff --git a/mbbsd/record.c b/mbbsd/record.c
index 05773ef7..47b62010 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -479,7 +479,7 @@ stampfile(char *fpath, fileheader_t * fh)
#ifdef _BBS_UTIL_C_
do {
#endif
- sprintf(ip, "M.%d.A.%3.3X", (int)++dtime, rand() & 0xFFF);
+ sprintf(ip, "M.%d.A.%3.3X", (int)++dtime, random() & 0xFFF);
#ifdef _BBS_UTIL_C_
if (fp == -1 && errno != EEXIST)
return -1;
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index 30cc268b..a2cb2733 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -3041,7 +3041,7 @@ FindAngel(void){
if (nAngel == 0)
return 0;
- choose = rand() % nAngel + 1;
+ choose = random() % nAngel + 1;
j = SHM->currsorted;
for (i = 0; i < SHM->UTMPnumber && choose; ++i)
if ((SHM->uinfo[SHM->sorted[j][0][i]].userlevel & PERM_ANGEL)
diff --git a/mbbsd/vice.c b/mbbsd/vice.c
index 843d3e83..ef527b72 100644
--- a/mbbsd/vice.c
+++ b/mbbsd/vice.c
@@ -54,7 +54,7 @@ ran_showfile(int y, int x, char *filename, int maxnum)
char buf[512];
bzero(buf, sizeof(buf));
- snprintf(buf, sizeof(buf), "%s%d", filename, rand() % maxnum + 1);
+ snprintf(buf, sizeof(buf), "%s%d", filename, random() % maxnum + 1);
if (!(fs = fopen(buf, "r"))) {
move(10, 10);
prints("can't open file: %s", buf);
@@ -74,7 +74,7 @@ ran_showmfile(char *filename, int maxnum)
{
char buf[256];
- snprintf(buf, sizeof(buf), "%s%d", filename, rand() % maxnum + 1);
+ snprintf(buf, sizeof(buf), "%s%d", filename, random() % maxnum + 1);
return more(buf, YEA);
}