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:
@@ -2603,7 +2603,7 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir)
|
||||
|
||||
nullpo_ret(ud);
|
||||
|
||||
if(dir > 7)
|
||||
if(dir >= DIR_MAX || dir <= DIR_CENTER)
|
||||
return 1;
|
||||
|
||||
ud->to_x = tx;
|
||||
@@ -2630,7 +2630,7 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir)
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 12; i++ ) {
|
||||
int k = rnd()%8; // Pick a Random Dir
|
||||
int k = rnd_value<int>(DIR_NORTH, DIR_NORTHEAST); // Pick a Random Dir
|
||||
|
||||
dx = -dirx[k] * 2;
|
||||
dy = -diry[k] * 2;
|
||||
|
||||
Reference in New Issue
Block a user