add a --no-srng command line option to disable...
...server-side RNG support to allow potential OoS debugging without having to rebuild
This commit is contained in:
parent
63a4de5e61
commit
e638a4b584
4 changed files with 21 additions and 5 deletions
|
@ -442,6 +442,8 @@ game_controller::game_controller(int argc, char** argv) :
|
|||
#else
|
||||
std::cerr << "Option --dummy-locales ignored: support was not compiled in.\n";
|
||||
#endif
|
||||
} else if(val == "--no-srng") {
|
||||
rand_rng::disable_server_rng();
|
||||
} else if(val[0] == '-') {
|
||||
std::cerr << "unknown option: " << val << std::endl;
|
||||
throw config::error("unknown option");
|
||||
|
@ -1773,6 +1775,8 @@ static int process_command_args(int argc, char** argv) {
|
|||
<< " --nocache disables caching of game data.\n"
|
||||
<< " --nomusic runs the game without music.\n"
|
||||
<< " --nosound runs the game without sounds and music.\n"
|
||||
<< " --no-srng disable server-side RNG support (will cause OOS\n"
|
||||
<< " errors unless every player uses it)\n"
|
||||
<< " --path prints the path to the data directory and exits.\n"
|
||||
<< " -r, --resolution XxY sets the screen resolution. Example: -r 800x600\n"
|
||||
<< " --rng-seed <number> seeds the random number generator with number\n"
|
||||
|
@ -1887,7 +1891,7 @@ static int process_command_args(int argc, char** argv) {
|
|||
return 2;
|
||||
}
|
||||
srand(lexical_cast_default<unsigned int>(argv[arg]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not the most intuitive solution, but I wanted to leave current semantics for now
|
||||
|
|
|
@ -676,10 +676,10 @@ bool mouse_handler::attack_enemy_(unit_map::iterator attacker, unit_map::iterato
|
|||
|
||||
gui().draw();
|
||||
recorder.add_attack(attacker_loc, defender_loc, att.attack_num, def.attack_num);
|
||||
if (network::nconnections() == 0) {
|
||||
rand_rng::invalidate_seed();
|
||||
if (rand_rng::has_valid_seed()) { //means SRNG is disabled
|
||||
perform_attack(attacker_loc, defender_loc, att.attack_num, def.attack_num, rand());
|
||||
} else {
|
||||
rand_rng::invalidate_seed();
|
||||
rand_rng::set_new_seed_callback(boost::bind(&mouse_handler::perform_attack,
|
||||
this, attacker_loc, defender_loc, att.attack_num, def.attack_num, _1));
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ namespace {
|
|||
rand_rng::seed_t last_seed;
|
||||
bool seed_valid = false;
|
||||
boost::function<void (rand_rng::seed_t)> new_seed_callback;
|
||||
bool srng_disabled = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,8 +108,8 @@ void invalidate_seed()
|
|||
|
||||
bool has_valid_seed()
|
||||
{
|
||||
//in a SP game the seed is always valid
|
||||
return (network::nconnections() == 0) || seed_valid;
|
||||
//if the SRNG is disabled or we're in a SP game the seed is always valid
|
||||
return srng_disabled || (network::nconnections() == 0) || seed_valid;
|
||||
}
|
||||
|
||||
seed_t get_last_seed()
|
||||
|
@ -128,6 +129,11 @@ void clear_new_seed_callback()
|
|||
new_seed_callback = NULL;
|
||||
}
|
||||
|
||||
void disable_server_rng()
|
||||
{
|
||||
srng_disabled = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
rng::rng() : random_(NULL), random_child_(0), generator_()
|
||||
|
|
|
@ -82,6 +82,12 @@ void set_new_seed_callback(boost::function<void (seed_t)> f);
|
|||
*/
|
||||
void clear_new_seed_callback();
|
||||
|
||||
/**
|
||||
* Disable server RNG support, will cause OOS if playing MP with a client with
|
||||
* SRNG enabled. For debugging purposes, should be removed before 1.8.0
|
||||
*/
|
||||
void disable_server_rng();
|
||||
|
||||
} // ends rand_rng namespace
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue