Skip to content

Commit

Permalink
Use std::srand
Browse files Browse the repository at this point in the history
  • Loading branch information
LegalizeAdulthood committed Nov 24, 2024
1 parent 7af212f commit 201ab55
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion libid/ant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ int ant()
g_random_seed = (int)g_params[5];
}

srand(g_random_seed);
std::srand(g_random_seed);
if (!g_random_seed_flag)
{
++g_random_seed;
Expand Down
2 changes: 1 addition & 1 deletion libid/cellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ int cellular()
}
}

srand(g_random_seed);
std::srand(g_random_seed);
if (!g_random_seed_flag)
{
++g_random_seed;
Expand Down
2 changes: 1 addition & 1 deletion libid/evolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ static void set_random(int ecount)
// Call this routine to set the random # to the proper value
// if it may have changed, before fiddleparms() is called.
// Now called by fiddleparms().
srand(g_evolve_this_generation_random_seed);
std::srand(g_evolve_this_generation_random_seed);
for (int index = 0; index < ecount; index++)
{
for (int i = 0; i < NUM_GENES; i++)
Expand Down
2 changes: 1 addition & 1 deletion libid/id_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static void main_restart(int const argc, char const *const argv[], bool &stacked
g_evolve_max_random_mutation = 1;
g_evolve_mutation_reduction_factor = 1.0;
g_evolve_this_generation_random_seed = (unsigned int)std::clock();
srand(g_evolve_this_generation_random_seed);
std::srand(g_evolve_this_generation_random_seed);
initgene(); /*initialise pointers to lots of variables for the evolution engine*/
g_start_show_orbit = false;
g_show_dot = -1; // turn off show_dot if entered with <g> command
Expand Down
2 changes: 1 addition & 1 deletion libid/intro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void intro()
driver_set_attr(23, 0, C_TITLE_LOW, 160);

driver_set_attr(toprow, 0, C_CONTRIB, (21-END_MAIN_AUTHOR)*80);
srand((unsigned int)std::clock());
std::srand((unsigned int)std::clock());
j = std::rand()%(j-(botrow-toprow)); // first to use
i = j+botrow-toprow; // last to use
char oldchar = credits[authors.at(i + 1)];
Expand Down
6 changes: 3 additions & 3 deletions libid/lorenz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2452,7 +2452,7 @@ static int ifs3dfloat()

// setup affine screen coord conversion
setup_convert_to_screen(&inf.cvt);
srand(1);
std::srand(1);
color_method = (int)g_params[0];
if (driver_diskp()) // this would KILL a disk drive!
{
Expand Down Expand Up @@ -2603,7 +2603,7 @@ static int ifs2d()
// setup affine screen coord conversion
l_setup_convert_to_screen(&cvt);

srand(1);
std::srand(1);
color_method = (int)g_params[0];
bool resized = false;
try
Expand Down Expand Up @@ -2721,7 +2721,7 @@ static int ifs3dlong()
long tempr;
long3dvtinf inf;

srand(1);
std::srand(1);
color_method = (int)g_params[0];
try
{
Expand Down
4 changes: 2 additions & 2 deletions libid/miscfrac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ int plasma()
}
s_get_pix = s_get_color;
}
srand(g_random_seed);
std::srand(g_random_seed);
if (!g_random_seed_flag)
{
++g_random_seed;
Expand Down Expand Up @@ -728,7 +728,7 @@ int diffusion()
border = 10;
}

srand(g_random_seed);
std::srand(g_random_seed);
if (!g_random_seed_flag)
{
++g_random_seed;
Expand Down
4 changes: 2 additions & 2 deletions libid/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ static void set_random()
}

const unsigned int seed = (unsigned) s_rand_num ^ (unsigned) (s_rand_num >> 16);
srand(seed);
std::srand(seed);
s_set_random = true;

// Clear out the seed
Expand All @@ -760,7 +760,7 @@ static void random_seed()

// Use the current time to randomize the random number sequence.
std::time(&ltime);
srand((unsigned int)ltime);
std::srand((unsigned int)ltime);

new_random_num();
new_random_num();
Expand Down
2 changes: 1 addition & 1 deletion libid/rotate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void rotate(int direction) // rotate-the-palette routine
changecolor = -1; // no color (rgb) to change
changedirection = 0; // no color direction to change
incr = 999; // ready to randomize
srand((unsigned)std::time(nullptr)); // randomize things
std::srand((unsigned)std::time(nullptr)); // randomize things

if (direction == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion libid/stereo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ bool do_AutoStereo()

// Use the current time to randomize the random number sequence.
std::time(&ltime);
srand((unsigned int)ltime);
std::srand((unsigned int)ltime);

ValueSaver saved_help_mode{g_help_mode, help_labels::HELP_RDS_KEYS};
driver_save_graphics(); // save graphics image
Expand Down

0 comments on commit 201ab55

Please sign in to comment.