Improved randomness (part 1) (#7882)
Faster and with no module bias Removed rnd_init, rnd_uint32 and rnd_uniform From now on we will only use rnd_value(min, max) for values in range [min, max] and rnd_chance(chance, base) for chances Fixes #7881 Fixes #7883 Fixes #7884 Fixes #7885 Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
@@ -7259,7 +7259,7 @@ ACMD_FUNC(pettalk)
|
||||
};
|
||||
int i;
|
||||
ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
|
||||
if( i == ET_DICE1 ) i = rnd()%6 + ET_DICE1; // randomize /dice
|
||||
if( i == ET_DICE1 ) i = rnd_value<int>(ET_DICE1, ET_DICE6); // randomize /dice
|
||||
if( i < ARRAYLENGTH(emo) )
|
||||
{
|
||||
if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
|
||||
@@ -8017,7 +8017,7 @@ ACMD_FUNC(hommutate)
|
||||
}
|
||||
|
||||
if (!message || !*message) {
|
||||
homun_id = 6048 + (rnd() % 4);
|
||||
homun_id = rnd_value<uint16>(MER_EIRA, MER_ELEANOR);
|
||||
} else {
|
||||
homun_id = atoi(message);
|
||||
}
|
||||
@@ -9133,8 +9133,8 @@ ACMD_FUNC(clone)
|
||||
}
|
||||
|
||||
do {
|
||||
x = sd->bl.x + (rnd() % 10 - 5);
|
||||
y = sd->bl.y + (rnd() % 10 - 5);
|
||||
x = sd->bl.x + rnd_value(-5, 5);
|
||||
y = sd->bl.y + rnd_value(-5, 5);
|
||||
} while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
|
||||
|
||||
if (i >= 10) {
|
||||
|
||||
Reference in New Issue
Block a user