random.cpp File Reference

Generate random numbers. More...

#include "global.hpp"
#include "config.hpp"
#include "random.hpp"
#include "util.hpp"
#include <cassert>
#include <cstdio>
#include <sstream>

Include dependency graph for random.cpp:

Go to the source code of this file.

Functions

int get_random ()
const configget_random_results ()
void set_random_results (const config &cfg)

Variables

rngrandom_generator = NULL


Detailed Description

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 syncronized over the network this only seems to work when it's used by 1 player at the same time. It's syncronized 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.


Function Documentation

int get_random (  ) 

const config* get_random_results (  ) 

Definition at line 119 of file random.cpp.

References rng::get_random_results(), and random_generator.

Referenced by attack::attack(), and recruit_unit().

void set_random_results ( const config cfg  ) 

Definition at line 125 of file random.cpp.

References random_generator, and rng::set_random_results().

Referenced by attack::attack(), and recruit_unit().


Variable Documentation

rng* random_generator = NULL [static]


Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs