Generate random numbers. More...
#include "global.hpp"#include "config.hpp"#include "log.hpp"#include "network.hpp"#include "random.hpp"#include "rng.hpp"#include "serialization/string_utils.hpp"#include "simple_rng.hpp"#include "util.hpp"
Go to the source code of this file.
Namespaces | |
| namespace | rand_rng |
Defines | |
| #define | DBG_RND LOG_STREAM(debug, log_random) |
| #define | LOG_RND LOG_STREAM(info, log_random) |
| #define | WRN_RND LOG_STREAM(warn, log_random) |
| #define | ERR_RND LOG_STREAM(err, log_random) |
Functions | |
| int | get_random () |
| int | get_random_nocheck () |
| const config * | get_random_results () |
| void | set_random_results (const config &cfg) |
| void | rand_rng::set_seed (int seed) |
| Set the random seed for the current random number generator, sets the seed as valid nd calls the new seed callback if set. | |
| void | rand_rng::invalidate_seed () |
| Mark the RNG seed as invalid. | |
| bool | rand_rng::has_valid_seed () |
| Function to check whether the RNG has been updated with a new seed since the las invalidate_seed() call. | |
| int | rand_rng::get_last_seed () |
| Get the last seed the RNG was seeded with in set_seed. | |
| void | rand_rng::set_new_seed_callback (boost::function< void(int)> f) |
| Set the callback for a function that will be called on subsequent set_seed calls. | |
| bool | rand_rng::has_new_seed_callback () |
| void | rand_rng::clear_new_seed_callback () |
| Clear the new seed callback. | |
Variables | |
| static lg::log_domain | log_random ("random") |
Generate random numbers.
There are various ways to get a random number. rand() This can be used for things that never are send over the network e.g. generate a random map (the final result the map is send, but the other players don't need to generate the map.
get_random() A random generator which is synchronized over the network this only seems to work when it's used by 1 player at the same time. It's synchronized after an event so if an event runs at two clients at the same time it gets out of sync and sets the entire game out of sync.
game_state::get_random() A random generator which is seeded by the host of an MP game. This generator is (not yet) synchronized over the network. It's only used by [set_variable]rand=. The map designer has to make sure it stays in sync. This generator can be used at the same time at multiple client since the generators are always in sync.
Definition in file random.cpp.
| #define DBG_RND LOG_STREAM(debug, log_random) |
Definition at line 53 of file random.cpp.
Referenced by rand_rng::simple_rng::get_next_random(), and rand_rng::simple_rng::seed_random().
| #define ERR_RND LOG_STREAM(err, log_random) |
Definition at line 56 of file random.cpp.
Referenced by rand_rng::rng::get_random_private().
| #define LOG_RND LOG_STREAM(info, log_random) |
Definition at line 54 of file random.cpp.
Referenced by rand_rng::rng::get_random_private(), and rand_rng::rng::set_seed().
| #define WRN_RND LOG_STREAM(warn, log_random) |
Definition at line 55 of file random.cpp.
| int get_random | ( | ) |
Definition at line 66 of file random.cpp.
Referenced by attack::perform_hit(), and mp::connect::start_game().

| int get_random_nocheck | ( | ) |
Definition at line 73 of file random.cpp.
Referenced by generate_gender(), unit::generate_traits(), and markov_generate_name().

| const config* get_random_results | ( | ) |
Definition at line 80 of file random.cpp.
Referenced by attack::perform_hit(), and place_recruit().

| void set_random_results | ( | const config & | cfg | ) |
Definition at line 87 of file random.cpp.
Referenced by attack::perform_hit(), and place_recruit().

lg::log_domain log_random("random") [static] |
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:08:46 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |