The Battle for Wesnoth
1.21.0-dev
Loading...
Searching...
No Matches
random_synced.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2014 - 2025
3
by David White <dave@whitevine.net>
4
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY.
12
13
See the COPYING file for more details.
14
*/
15
16
#pragma once
17
18
#include "
random.hpp
"
19
#include "
mt_rng.hpp
"
20
21
#include <functional>
22
23
/*
24
todo: use a boost::random based solution.
25
*/
26
namespace
randomness
27
{
28
class
synced_rng
:
public
randomness::rng
29
{
30
public
:
31
synced_rng
(std::function<std::string()> seed_generator);
32
virtual
~synced_rng
();
33
34
virtual
bool
is_networked
()
const
;
35
36
protected
:
37
virtual
uint32_t
next_random_impl
();
38
private
:
39
void
initialize
();
40
bool
has_valid_seed_
;
41
std::function<std::string()>
seed_generator_
;
42
mt_rng
gen_
;
43
};
44
}
randomness::mt_rng
Definition
mt_rng.hpp:31
randomness::rng
this class does not give synced random results derived classes might do.
Definition
random.hpp:28
randomness::synced_rng
Definition
random_synced.hpp:29
randomness::synced_rng::next_random_impl
virtual uint32_t next_random_impl()
Definition
random_synced.cpp:33
randomness::synced_rng::~synced_rng
virtual ~synced_rng()
Definition
random_synced.cpp:53
randomness::synced_rng::gen_
mt_rng gen_
Definition
random_synced.hpp:42
randomness::synced_rng::is_networked
virtual bool is_networked() const
Is this random source networked? If it is it's very important we do actually use this random source t...
Definition
random_synced.cpp:58
randomness::synced_rng::initialize
void initialize()
Definition
random_synced.cpp:46
randomness::synced_rng::has_valid_seed_
bool has_valid_seed_
Definition
random_synced.hpp:40
randomness::synced_rng::seed_generator_
std::function< std::string()> seed_generator_
Definition
random_synced.hpp:41
mt_rng.hpp
randomness
Definition
attack.hpp:43
random.hpp
Generated by
1.9.8